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

KDECore

  • kdecore
  • util
kdedmodule.cpp
Go to the documentation of this file.
1
2/*
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
32class KDEDModulePrivate
33{
34public:
35 QString moduleName;
36};
37
38KDEDModule::KDEDModule(QObject* parent)
39 : QObject(parent), d(new KDEDModulePrivate)
40{
41}
42
43KDEDModule::~KDEDModule()
44{
45 emit moduleDeleted(this);
46 delete d;
47}
48
49void 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
96QString KDEDModule::moduleName() const
97{
98 return d->moduleName;
99}
100
101#include "kdedmodule.moc"
KDEDModule::KDEDModule
KDEDModule(QObject *parent=0)
Constructor.
Definition: kdedmodule.cpp:38
KDEDModule::~KDEDModule
virtual ~KDEDModule()
Definition: kdedmodule.cpp:43
KDEDModule::setModuleName
void setModuleName(const QString &name)
Definition: kdedmodule.cpp:49
KDEDModule::moduleName
QString moduleName() const
Definition: kdedmodule.cpp:96
KDEDModule::moduleRegistered
void moduleRegistered(const QDBusObjectPath &path)
Emitted after the module is registered successfully with D-Bus.
KDEDModule::moduleDeleted
void moduleDeleted(KDEDModule *)
Emitted when the module is being deleted.
QObject
QString
kDebug
#define kDebug
Definition: kdebug.h:316
kError
static QDebug kError(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
Definition: kdebug.h:187
kdebug.h
kdedmodule.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
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