• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDECore

kdedmodule.cpp

Go to the documentation of this file.
00001 /*
00002    This file is part of the KDE libraries
00003 
00004    Copyright (c) 2001 Waldo Bastian <bastian@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019    Boston, MA 02110-1301, USA.
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    // ExportSignals not used since it triggers a warning at this point
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    // appKey acts as a placeholder
00093    KEntryKey appKey(app, 0);
00094    d->objMap->insert(appKey, 0);
00095 
00096    KEntryKey indexKey(app, key);
00097 
00098    // Prevent deletion in case the same object is inserted again.
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    // Search for placeholder.
00135 
00136    KDEDObjectMap::Iterator it = d->objMap->find(indexKey);
00137    while (it != d->objMap->end())
00138    {
00139       if (it.key().mGroup != app)
00140          break; // All keys for this app have been removed.
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       // for kded that kded implements; or using dcop.
00149 bool KDEDModule::isWindowRegistered(long windowId) const
00150 {
00151    return Kded::self()->isWindowRegistered(windowId);
00152 }
00153 #endif
00154 
00155 #include "kdedmodule.moc"

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal