KDECore
kdedmodule.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "kdedmodule.h"
00025
00026 #include "kdebug.h"
00027 #include <QtCore/QTimer>
00028 #include <QtDBus/QtDBus>
00029
00030
00031
00032 class KDEDModulePrivate
00033 {
00034 public:
00035 QString moduleName;
00036 };
00037
00038 KDEDModule::KDEDModule(QObject* parent)
00039 : QObject(parent), d(new KDEDModulePrivate)
00040 {
00041 }
00042
00043 KDEDModule::~KDEDModule()
00044 {
00045 emit moduleDeleted(this);
00046 delete d;
00047 }
00048
00049 void KDEDModule::setModuleName( const QString& name )
00050 {
00051 d->moduleName = name;
00052 QDBusObjectPath realPath( QString("/modules/") + d->moduleName);
00053
00054 if (realPath.path().isEmpty())
00055 {
00056 kError() << "The kded module name '" << name << "' is invalid!";
00057 return;
00058 }
00059
00060
00061 QDBusConnection::RegisterOptions regOptions;
00062
00063 if (this->metaObject()->indexOfClassInfo("D-Bus Interface")!=-1)
00064 {
00065
00066
00067
00068
00069
00070
00071
00072 regOptions = QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors;
00073 }
00074 else
00075 {
00076
00077 regOptions = QDBusConnection::ExportScriptableSlots
00078 | QDBusConnection::ExportScriptableProperties
00079 | QDBusConnection::ExportAdaptors;
00080 kDebug() << "Registration of kded module " << d->moduleName << "without dbus interface.";
00081 }
00082
00083 if (!QDBusConnection::sessionBus().registerObject(realPath.path(), this, regOptions))
00084 {
00085
00086 kDebug() << "registerObject() returned false for " << d->moduleName;
00087 }
00088 else
00089 {
00090 kDebug() << "registerObject() successful for " << d->moduleName;
00091 emit moduleRegistered(realPath);
00092 }
00093
00094 }
00095
00096 QString KDEDModule::moduleName() const
00097 {
00098 return d->moduleName;
00099 }
00100
00101 #include "kdedmodule.moc"