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 #include "kdedmodule.h"
00024 #include <QtCore/QTimer>
00025 #include <QtDBus/QtDBus>
00026
00027
00028 #if 0 // KDED_OBJECTS
00029 #include "kconfigdata.h"
00030 typedef QMap<KEntryKey, KSharedPtr<KShared> > KDEDObjectMap;
00031 #endif
00032
00033 class KDEDModulePrivate
00034 {
00035 public:
00036 QString moduleName;
00037 #if 0 // KDED_OBJECTS
00038 KDEDObjectMap *objMap;
00039 int timeout;
00040 QTimer timer;
00041 #endif
00042 };
00043
00044 KDEDModule::KDEDModule(QObject* parent)
00045 : QObject(parent), d(new KDEDModulePrivate)
00046 {
00047 #if 0 // KDED_OBJECTS
00048 d->objMap = 0;
00049 d->timeout = 0;
00050 d->timer.setSingleShot( true );
00051 connect(&(d->timer), SIGNAL(timeout()), this, SLOT(idle()));
00052 #endif
00053 }
00054
00055 KDEDModule::~KDEDModule()
00056 {
00057 emit moduleDeleted(this);
00058 delete d;
00059 }
00060
00061 void KDEDModule::setModuleName( const QString& name )
00062 {
00063 QString realPath = d->moduleName = name;
00064 realPath.prepend("/modules/");
00065
00066 QDBusConnection::sessionBus().registerObject(realPath, this, QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportScriptableProperties | QDBusConnection::ExportAdaptors);
00067 }
00068
00069 QString KDEDModule::moduleName() const
00070 {
00071 return d->moduleName;
00072 }
00073
00074 #if 0 // see header (grep keyword: KDED_OBJECTS)
00075 void KDEDModule::setIdleTimeout(int secs)
00076 {
00077 d->timeout = secs*1000;
00078 }
00079
00080 void KDEDModule::resetIdle()
00081 {
00082 d->timer.stop();
00083 if (!d->objMap || d->objMap->isEmpty())
00084 d->timer.start(d->timeout);
00085 }
00086
00087 void KDEDModule::insert(const DCOPCString &app, const DCOPCString &key, KShared *obj)
00088 {
00089 if (!d->objMap)
00090 d->objMap = new KDEDObjectMap;
00091
00092
00093 KEntryKey appKey(app, 0);
00094 d->objMap->insert(appKey, 0);
00095
00096 KEntryKey indexKey(app, key);
00097
00098
00099 KSharedPtr<KShared> _obj = obj;
00100
00101 d->objMap->insert(indexKey, _obj);
00102 resetIdle();
00103 }
00104
00105 KShared * KDEDModule::find(const DCOPCString &app, const DCOPCString &key)
00106 {
00107 if (!d->objMap)
00108 return 0;
00109 KEntryKey indexKey(app, key);
00110
00111 KDEDObjectMap::ConstIterator it = d->objMap->find(indexKey);
00112 if (it == d->objMap->end())
00113 return 0;
00114
00115 return it.value().get();
00116 }
00117
00118 void KDEDModule::remove(const DCOPCString &app, const DCOPCString &key)
00119 {
00120 if (!d->objMap)
00121 return;
00122 KEntryKey indexKey(app, key);
00123
00124 d->objMap->remove(indexKey);
00125 resetIdle();
00126 }
00127
00128 void KDEDModule::removeAll(const DCOPCString &app)
00129 {
00130 if (!d->objMap)
00131 return;
00132
00133 KEntryKey indexKey(app, 0);
00134
00135
00136 KDEDObjectMap::Iterator it = d->objMap->find(indexKey);
00137 while (it != d->objMap->end())
00138 {
00139 if (it.key().mGroup != app)
00140 break;
00141 it = d->objMap->erase(it);
00142 }
00143 resetIdle();
00144 }
00145 #endif
00146
00147 #if 0 // doesn't seem to be used. If this is needed we'll need an interface
00148
00149 bool KDEDModule::isWindowRegistered(long windowId) const
00150 {
00151 return Kded::self()->isWindowRegistered(windowId);
00152 }
00153 #endif
00154
00155 #include "kdedmodule.moc"