kdelibs/kded/kded.h

189 lines
5 KiB
C
Raw Normal View History

2014-11-13 01:04:59 +02:00
/* This file is part of the KDE libraries
* Copyright (C) 1999 David Faure <faure@kde.org>
* (C) 1999 Waldo Bastian <bastian@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License version 2 as published by the Free Software Foundation;
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
**/
#ifndef KDED_H
#define KDED_H
#include <QObject>
#include <QString>
#include <QTimer>
#include <QHash>
#include <QDBusMessage>
#include <QDBusAbstractAdaptor>
2014-11-13 01:04:59 +02:00
#include <ksycoca.h>
#include <ksycocatype.h>
#include <kdedmodule.h>
#include <kservice.h>
class KDirWatch;
// Apps get read-only access
2014-11-13 01:04:59 +02:00
class Kded : public QObject
{
Q_OBJECT
public:
Kded(QObject *parent);
2014-11-13 01:04:59 +02:00
virtual ~Kded();
static Kded *self() { return _self;}
static void messageFilter(const QDBusMessage &);
void noDemandLoad(const QString &obj); // Don't load obj on demand
KDEDModule *loadModule(const QString &obj, bool onDemand);
KDEDModule *loadModule(const KService::Ptr& service, bool onDemand);
QStringList loadedModules();
bool unloadModule(const QString &obj);
2014-11-13 01:04:59 +02:00
void loadSecondPhase();
//@{
/**
* Check if a module should be loaded on startup.
*
* @param module the name of the desktop file for the module, without the .desktop extension
* @return @c true if the module will be loaded at startup, @c false otherwise
*/
bool isModuleAutoloaded(const QString &module) const;
/**
* Check if a module should be loaded on startup.
*
* @param module a service description for the module
* @return @c true if the module will be loaded at startup, @c false otherwise
*/
bool isModuleAutoloaded(const KService::Ptr &module) const;
//@}
//@{
/**
* Check if a module should be loaded on demand
*
* @param module the name of the desktop file for the module, without the .desktop extension
* @return @c true if the module will be loaded when its D-Bus interface
* is requested, @c false otherwise
*/
bool isModuleLoadedOnDemand(const QString &module) const;
/**
* Check if a module should be loaded on demand
*
* @param module a service description for the module
* @return @c true if the module will be loaded when its D-Bus interface
* is requested, @c false otherwise
*/
bool isModuleLoadedOnDemand(const KService::Ptr &module) const;
//@}
/**
* Configure whether a module should be loaded on startup
*
* If a module is set to be auto-loaded, it will be loaded at the start of a KDE
* session. Depending on the phase it is set to load in, it may also be loaded
* when the first KDE application is run outside of a KDE session.
*
* @param module the name of the desktop file for the module, without the .desktop extension
* @param autoload if @c true, the module will be loaded at startup,
* otherwise it will not
*/
void setModuleAutoloading(const QString &module, bool autoload);
public Q_SLOTS:
/**
* Loads / unloads modules according to config
*/
void initModules();
/**
* Recreate the database file
*/
void recreate();
/**
* Collect all directories to watch
*/
void updateDirWatch();
/**
* Update directories to watch
*/
void updateResourceList();
/**
* A KDEDModule is about to get destroyed.
*/
void slotKDEDModuleRemoved(KDEDModule *);
private Q_SLOTS:
2014-11-13 01:04:59 +02:00
/**
* @internal Triggers rebuilding
*/
void update(const QString& dir);
2014-11-13 01:04:59 +02:00
/**
* @internal Executes kdontchangethehostname when hostname changes
*/
void checkHostname();
2014-11-13 01:04:59 +02:00
private:
/**
* Pointer to the dirwatch class which tells us, when some directories
* changed.
*/
KDirWatch* m_pDirWatch;
/**
* When a desktop file is updated, a timer is started (5 sec)
* before rebuilding the binary - so that multiple updates result
* in only one rebuilding.
*/
QTimer* m_pTimer;
/**
* Timer for periodic hostname checking.
*/
QTimer* m_hTimer;
/**
* The current hostname.
*/
QByteArray m_hostname;
2014-11-13 01:04:59 +02:00
QHash<QString,KDEDModule *> m_modules;
//QHash<QString,QLibrary *> m_libs;
2014-11-13 01:04:59 +02:00
QHash<QString,QObject *> m_dontLoad;
QStringList m_allResourceDirs;
static Kded *_self;
};
class KBuildsycocaAdaptor: public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.kbuildsycoca")
public:
KBuildsycocaAdaptor(QObject *parent);
public Q_SLOTS:
void recreate();
2014-11-13 01:04:59 +02:00
};
#endif