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

KDECore

kdedmodule.cpp

Go to the documentation of this file.
00001 
00002 /*
00003    This file is part of the KDE libraries
00004 
00005    Copyright (c) 2001 Waldo Bastian <bastian@kde.org>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public License
00018    along with this library; see the file COPYING.LIB.  If not, write to
00019    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020    Boston, MA 02110-1301, USA.
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       // 1. There are kded modules that don't have a dbus interface.
00066       // 2. qt 4.4.3 crashes when trying to emit signals on class without
00067       //    Q_CLASSINFO("D-Bus Interface", "<your interface>") but
00068       //    ExportSignal set.
00069       // We try to solve that for now with just registering Properties and
00070       // Adaptors. But we should investigate where the sense is in registering
00071       // the module at all. Just for autoload? Is there a better solution?
00072       regOptions = QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors;
00073       }
00074    else
00075       {
00076       // Full functional module. Register everything.
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       // Happens for khotkeys but the module works. Need some time to investigate.
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"

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
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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