You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
359 lines
9.8 KiB
359 lines
9.8 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 2003 Matthias Kretz <kretz@kde.org>
|
||
|
Copyright (C) 2004 Frans Englich <frans.englich@telia.com>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License version 2 as published by the Free Software Foundation.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
|
||
|
*/
|
||
|
|
||
|
#ifndef KCMODULEPROXY_H
|
||
|
#define KCMODULEPROXY_H
|
||
|
|
||
15 years ago
|
#include <tqwidget.h>
|
||
|
#include <tqstringlist.h>
|
||
15 years ago
|
|
||
|
#include <kservice.h>
|
||
13 years ago
|
#include <tdelibs_export.h>
|
||
15 years ago
|
|
||
12 years ago
|
class TDEAboutData;
|
||
12 years ago
|
class TDECModule;
|
||
|
class TDECModuleInfo;
|
||
12 years ago
|
class TDEInstance;
|
||
12 years ago
|
class TDEProcess;
|
||
15 years ago
|
|
||
|
/**
|
||
12 years ago
|
* @ingroup tdecmodule
|
||
15 years ago
|
*
|
||
12 years ago
|
* @brief Encapsulates a TDECModule for embedding.
|
||
15 years ago
|
*
|
||
12 years ago
|
* TDECModuleProxy is a wrapper for TDECModule intended for cases where
|
||
14 years ago
|
* modules are to be displayed. It ensures layout is consistent, handles
|
||
15 years ago
|
* root/administrator modules and in general takes care of the details
|
||
12 years ago
|
* needed for making a module available in an interface. A TDECModuleProxy
|
||
15 years ago
|
* can be treated as a TQWidget, without worrying about the details specific
|
||
12 years ago
|
* for modules such as library loading. TDECModuleProxy is not a sub class of TDECModule
|
||
|
* but its API closely resembles TDECModule's.\n
|
||
15 years ago
|
* Usually, an instance is created by passing one of the constructors a KService::Ptr,
|
||
12 years ago
|
* TDECModuleInfo or simply the name of the module and then added to the layout as any
|
||
15 years ago
|
* other widget. \n
|
||
12 years ago
|
* When the user have changed the module, changed( bool ) as well as changed ( TDECModuleProxy * )
|
||
|
* is emitted. TDECModuleProxy does not take care of prompting for saving - if the object is deleted while
|
||
15 years ago
|
* changes is not saved the changes will be lost. changed() returns true if changes are unsaved. \n
|
||
|
* \n
|
||
12 years ago
|
* TDECModuleProxy does not take care of authorization of TDECModules. \n
|
||
|
* TDECModuleProxy do lazy loading, meaning the library will not be loaded or
|
||
15 years ago
|
* any other initialization done before its show() function is called. This means
|
||
|
* modules will only be loaded when they are actually needed as well as it is possible to
|
||
12 years ago
|
* load many TDECModuleProxy without any speed penalty.
|
||
15 years ago
|
*
|
||
12 years ago
|
* TDECModuleProxy should be used in all cases where modules are embedded in order to
|
||
15 years ago
|
* promote code efficiency and usability consistency.
|
||
|
*
|
||
|
* @author Frans Englich <frans.englich@telia.com>
|
||
|
* @author Matthias Kretz <kretz@kde.org>
|
||
|
*
|
||
|
*/
|
||
12 years ago
|
class KUTILS_EXPORT TDECModuleProxy : public TQWidget
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
13 years ago
|
|
||
15 years ago
|
|
||
12 years ago
|
friend class TDECModuleProxyRootCommunicatorImpl;
|
||
15 years ago
|
|
||
|
public:
|
||
|
|
||
|
/**
|
||
12 years ago
|
* Constructs a TDECModuleProxy from a TDECModuleInfo class.
|
||
15 years ago
|
*
|
||
12 years ago
|
* @param info The TDECModuleInfo to construct the module from.
|
||
15 years ago
|
* @param withFallback If set to true and loading of the module fails,
|
||
|
* a alternative will be tried, resulting in the module appearing in its
|
||
|
* own window, if at all.
|
||
|
* The embedded module will be load()ed.
|
||
15 years ago
|
* @param parent the parent TQWidget.
|
||
15 years ago
|
* @param name the module's name.
|
||
|
* @param args This is used in the implementation and is internal.
|
||
|
* Use the default.
|
||
|
*/
|
||
12 years ago
|
TDECModuleProxy( const TDECModuleInfo & info, bool withFallback = true,
|
||
15 years ago
|
TQWidget * parent = 0, const char * name = 0,
|
||
|
const TQStringList & args = TQStringList() );
|
||
15 years ago
|
|
||
|
/**
|
||
12 years ago
|
* Constructs a TDECModuleProxy from a module's service name, which is
|
||
15 years ago
|
* equivalent to the desktop file for the kcm without the ".desktop" part.
|
||
|
* Otherwise equal to the one above.
|
||
|
*
|
||
|
* @param serviceName The module's service name to construct from.
|
||
|
* @param withFallback If set to true and loading of the module fails,
|
||
|
* a alternative will be tried, resulting in the module appearing in its
|
||
|
* own window, if at all.
|
||
|
* The embedded module will be load()ed.
|
||
15 years ago
|
* @param parent the parent TQWidget.
|
||
15 years ago
|
* @param name the module's name.
|
||
|
* @param args This is used in the implementation and is internal.
|
||
|
* Use the default.
|
||
|
*/
|
||
12 years ago
|
TDECModuleProxy( const TQString& serviceName, bool withFallback = true,
|
||
15 years ago
|
TQWidget * parent = 0, const char * name = 0,
|
||
|
const TQStringList & args = TQStringList() );
|
||
15 years ago
|
|
||
|
/**
|
||
12 years ago
|
* Constructs a TDECModuleProxy from KService. Otherwise equal to the one above.
|
||
15 years ago
|
*
|
||
|
* @param service The KService to construct from.
|
||
|
* @param withFallback If set to true and loading of the module fails,
|
||
|
* a alternative will be tried, resulting in the module appearing in its
|
||
|
* own window, if at all.
|
||
|
* The embedded module will be load()ed.
|
||
15 years ago
|
* @param parent the parent TQWidget.
|
||
15 years ago
|
* @param name the module's name.
|
||
|
* @param args This is used in the implementation and is internal.
|
||
|
* Use the default.
|
||
|
*/
|
||
12 years ago
|
TDECModuleProxy( const KService::Ptr& service, bool withFallback = true,
|
||
15 years ago
|
TQWidget * parent = 0, const char * name = 0,
|
||
|
const TQStringList & args = TQStringList() );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Default destructor
|
||
|
*/
|
||
12 years ago
|
~TDECModuleProxy();
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Calling it will cause the contained module to
|
||
|
* run its load() routine.
|
||
|
*/
|
||
|
void load();
|
||
|
|
||
|
/**
|
||
|
* Calling it will cause the contained module to
|
||
|
* run its save() routine.
|
||
|
*
|
||
|
* If the module was not modified, it will not be asked
|
||
|
* to save.
|
||
|
*/
|
||
|
void save();
|
||
|
|
||
|
/**
|
||
|
* @return the module's quickHelp();
|
||
|
*/
|
||
15 years ago
|
TQString quickHelp() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @return the module's aboutData()
|
||
|
*/
|
||
12 years ago
|
const TDEAboutData * aboutData() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @return what buttons the module
|
||
|
* needs
|
||
|
*/
|
||
|
int buttons() const;
|
||
|
|
||
|
/**
|
||
|
* @return The module's custom root
|
||
|
* message, if it has one
|
||
|
* @deprecated
|
||
|
*/
|
||
15 years ago
|
TQString rootOnlyMsg() const;
|
||
15 years ago
|
//KDE4 remove. There's a limit for convenience functions,
|
||
|
// this one's available via moduleInfo()-> and realModule()->
|
||
|
|
||
|
/**
|
||
|
* @return If the module is a root module.
|
||
|
* @deprecated
|
||
|
*/
|
||
|
bool useRootOnlyMsg() const;
|
||
|
//KDE4 remove. There's a limit for convenience functions,
|
||
|
// this one's available via moduleInfo()-> and realModule()->
|
||
|
|
||
|
/**
|
||
12 years ago
|
* Returns the embedded TDECModule's TDEInstance.
|
||
12 years ago
|
* @return The module's TDEInstance.
|
||
15 years ago
|
* @deprecated
|
||
|
*/
|
||
12 years ago
|
TDEInstance * instance() const;
|
||
15 years ago
|
//KDE4 remove. There's a limit for convenience functions,
|
||
|
// this one's available via realModule()
|
||
|
|
||
|
/**
|
||
|
* @return true if the module is modified
|
||
|
* and needs to be saved.
|
||
|
*/
|
||
|
bool changed() const;
|
||
|
|
||
|
/**
|
||
|
* Returns whether the module is running in root mode. A module is in root mode
|
||
|
* when runAsRoot() has been called. A session under root user will never reach
|
||
|
* root mode.
|
||
|
*
|
||
|
* @note realModule() will return null when the module is running in root mode.
|
||
|
*
|
||
|
* @return true if the module is running with root privileges
|
||
|
* @since 3.4
|
||
|
*/
|
||
|
bool rootMode() const;
|
||
|
|
||
|
/**
|
||
|
* Access to the actual module. However, if the module is
|
||
|
* running in root mode, see rootMode(), this function returns
|
||
|
* a NULL pointer, since the module is in another process. It may also
|
||
|
* return NULL if anything goes wrong.
|
||
|
*
|
||
|
* @return the encapsulated module.
|
||
|
*/
|
||
12 years ago
|
TDECModule* realModule() const;
|
||
15 years ago
|
|
||
|
/**
|
||
12 years ago
|
* @return a TDECModuleInfo for the encapsulated
|
||
15 years ago
|
* module
|
||
|
*/
|
||
12 years ago
|
const TDECModuleInfo& moduleInfo() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns the DCOP the module's DCOPClient
|
||
|
* and DCOPObject has(they are identical).
|
||
|
*
|
||
|
* @since 3.4
|
||
|
*/
|
||
15 years ago
|
TQCString dcopName() const;
|
||
15 years ago
|
|
||
|
public slots:
|
||
|
|
||
|
/**
|
||
|
* Calling this will cause the module to be run in
|
||
|
* "administrator mode".
|
||
|
*
|
||
|
* @since 3.4
|
||
|
*/
|
||
|
void runAsRoot();
|
||
|
|
||
|
/**
|
||
|
* Calling it will cause the contained module to
|
||
|
* load its default values.
|
||
|
*/
|
||
|
void defaults();
|
||
|
|
||
|
/**
|
||
|
* Calling this, results in deleting the contained
|
||
|
* module, and unregistering from DCOP. A similar result is achieved
|
||
12 years ago
|
* by deleting the TDECModuleProxy itself.
|
||
15 years ago
|
*
|
||
|
* @since 3.4
|
||
|
*/
|
||
|
void deleteClient();
|
||
|
|
||
|
signals:
|
||
|
|
||
|
/*
|
||
|
* This signal is emitted when the contained module is changed.
|
||
|
*/
|
||
|
void changed( bool state );
|
||
|
|
||
|
/**
|
||
|
* This is emitted in the same situations as in the one above. Practical
|
||
12 years ago
|
* when several TDECModuleProxys are loaded.
|
||
15 years ago
|
*
|
||
|
* @since 3.4
|
||
|
*/
|
||
12 years ago
|
void changed( TDECModuleProxy* mod );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* When a module running with root privileges and exits, returns to normal mode, the
|
||
|
* childClosed() signal is emitted.
|
||
|
*
|
||
|
* @since 3.4
|
||
|
*/
|
||
|
void childClosed();
|
||
|
|
||
|
/*
|
||
|
* This signal is relayed from the encapsulated module, and
|
||
|
* is equivalent to the module's own quickHelpChanged() signal.
|
||
|
*
|
||
|
* @since 3.4
|
||
|
*/
|
||
|
void quickHelpChanged();
|
||
|
|
||
|
protected:
|
||
|
|
||
|
/**
|
||
|
* Reimplemented for internal purposes. Makes sure the encapsulated
|
||
|
* module is loaded before the show event is taken care of.
|
||
|
*/
|
||
15 years ago
|
void showEvent( TQShowEvent * );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Internal intialization function, called by the constructors.
|
||
|
*
|
||
|
* @internal
|
||
|
* @since 3.4
|
||
|
*/
|
||
12 years ago
|
void init( const TDECModuleInfo& info );
|
||
15 years ago
|
|
||
|
|
||
|
/**
|
||
|
* Emits the quickHelpChanged signal.
|
||
|
* @since 3.4
|
||
|
*/
|
||
|
void emitQuickHelpChanged();
|
||
|
|
||
|
private slots:
|
||
|
|
||
|
/**
|
||
12 years ago
|
* Calls the function @p function of the root module's TDECModuleProxy
|
||
15 years ago
|
* DCOP interface.
|
||
|
*
|
||
|
* @param function the function signature of the function to call.
|
||
|
* @since 3.4
|
||
|
*/
|
||
15 years ago
|
void callRootModule( const TQCString& function );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* This is called when the module exits from root mode. It zeroes
|
||
|
* pointers, deletes the embed window, and so forth.
|
||
|
*
|
||
|
* @since 3.4
|
||
|
*/
|
||
|
void rootExited();
|
||
|
|
||
|
/**
|
||
|
* Makes sure the proper variables is set and signals are emitted.
|
||
|
*/
|
||
|
void moduleChanged( bool );
|
||
|
|
||
|
/**
|
||
|
* Zeroes d->kcm
|
||
|
*/
|
||
|
void moduleDestroyed();
|
||
|
|
||
|
/**
|
||
|
* Gets called by DCOP when an application closes.
|
||
|
* Is used to (try to) reload a KCM which previously
|
||
|
* was loaded.
|
||
|
*
|
||
|
* @since 3.4
|
||
|
*/
|
||
15 years ago
|
void applicationRemoved( const TQCString& app );
|
||
15 years ago
|
|
||
|
private:
|
||
|
|
||
12 years ago
|
class TDECModuleProxyPrivate;
|
||
|
TDECModuleProxyPrivate * d;
|
||
15 years ago
|
};
|
||
|
|
||
|
#endif // KCMODULEPROXY_H
|
||
|
// vim: sw=4 ts=4 noet
|