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

KDECore

  • sources
  • kde-4.14
  • kdelibs
  • kdecore
  • util
kdedmodule.cpp
Go to the documentation of this file.
1 /*
3  This file is part of the KDE libraries
4 
5  Copyright (c) 2001 Waldo Bastian <bastian@kde.org>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 
22 */
23 
24 #include "kdedmodule.h"
25 
26 #include "kdebug.h"
27 #include <QtCore/QTimer>
28 #include <QtDBus/QtDBus>
29 
30 
31 
32 class KDEDModulePrivate
33 {
34 public:
35  QString moduleName;
36 };
37 
38 KDEDModule::KDEDModule(QObject* parent)
39  : QObject(parent), d(new KDEDModulePrivate)
40 {
41 }
42 
43 KDEDModule::~KDEDModule()
44 {
45  emit moduleDeleted(this);
46  delete d;
47 }
48 
49 void KDEDModule::setModuleName( const QString& name )
50 {
51  d->moduleName = name;
52  QDBusObjectPath realPath( QString::fromLatin1("/modules/") + d->moduleName);
53 
54  if (realPath.path().isEmpty())
55  {
56  kError() << "The kded module name '" << name << "' is invalid!";
57  return;
58  }
59 
60 
61  QDBusConnection::RegisterOptions regOptions;
62 
63  if (this->metaObject()->indexOfClassInfo("D-Bus Interface")!=-1)
64  {
65  // 1. There are kded modules that don't have a D-Bus interface.
66  // 2. qt 4.4.3 crashes when trying to emit signals on class without
67  // Q_CLASSINFO("D-Bus Interface", "<your interface>") but
68  // ExportSignal set.
69  // We try to solve that for now with just registering Properties and
70  // Adaptors. But we should investigate where the sense is in registering
71  // the module at all. Just for autoload? Is there a better solution?
72  regOptions = QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors;
73  }
74  else
75  {
76  // Full functional module. Register everything.
77  regOptions = QDBusConnection::ExportScriptableSlots
78  | QDBusConnection::ExportScriptableProperties
79  | QDBusConnection::ExportAdaptors;
80  kDebug() << "Registration of kded module " << d->moduleName << "without D-Bus interface.";
81  }
82 
83  if (!QDBusConnection::sessionBus().registerObject(realPath.path(), this, regOptions))
84  {
85  // Happens for khotkeys but the module works. Need some time to investigate.
86  kDebug() << "registerObject() returned false for " << d->moduleName;
87  }
88  else
89  {
90  kDebug() << "registerObject() successful for " << d->moduleName;
91  emit moduleRegistered(realPath);
92  }
93 
94 }
95 
96 QString KDEDModule::moduleName() const
97 {
98  return d->moduleName;
99 }
100 
101 #include "kdedmodule.moc"
kdebug.h
KDEDModule::~KDEDModule
virtual ~KDEDModule()
Definition: kdedmodule.cpp:43
QObject::metaObject
virtual const QMetaObject * metaObject() const
kError
static QDebug kError(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
Definition: kdebug.h:187
QDBusConnection::sessionBus
QDBusConnection sessionBus()
KDEDModule::setModuleName
void setModuleName(const QString &name)
Definition: kdedmodule.cpp:49
QDBusObjectPath
QObject::name
const char * name() const
kdedmodule.h
QObject
KDEDModule::moduleDeleted
void moduleDeleted(KDEDModule *)
Emitted when the module is being deleted.
QString::isEmpty
bool isEmpty() const
KDEDModule::moduleName
QString moduleName() const
Definition: kdedmodule.cpp:96
QString
QDBusConnection::RegisterOptions
typedef RegisterOptions
KDEDModule::moduleRegistered
void moduleRegistered(const QDBusObjectPath &path)
Emitted after the module is registered successfully with D-Bus.
QString::fromLatin1
QString fromLatin1(const char *str, int size)
kDebug
#define kDebug
Definition: kdebug.h:316
KDEDModule::KDEDModule
KDEDModule(QObject *parent=0)
Constructor.
Definition: kdedmodule.cpp:38
QDBusObjectPath::path
QString path() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal