20 #include "nepomukserveradaptor.h"
23 #include "servicemanageradaptor.h"
25 #include <Soprano/Global>
28 #include <KConfigGroup>
31 #include <KStandardDirs>
33 #include <QtDBus/QDBusConnection>
40 m_fileIndexerServiceName(
"nepomukfileindexer" ),
41 m_noServices(noServices),
42 m_currentState(StateDisabled)
46 m_config = KSharedConfig::openConfig(
"nepomukserverrc" );
48 QDBusConnection::sessionBus().registerService(
"org.kde.NepomukServer" );
51 (void)
new NepomukServerAdaptor(
this );
52 QDBusConnection::sessionBus().registerObject(
"/nepomukserver",
this );
56 connect(m_serviceManager, SIGNAL(serviceInitialized(QString)),
57 this, SLOT(slotServiceInitialized(QString)));
58 connect(m_serviceManager, SIGNAL(serviceStopped(QString)),
59 this, SLOT(slotServiceStopped(QString)));
60 (void)
new ServiceManagerAdaptor( m_serviceManager );
66 if( m_currentState == StateDisabled ) {
75 QDBusConnection::sessionBus().unregisterService(
"org.kde.NepomukServer" );
79 void Nepomuk2::Server::init()
88 kDebug() <<
"enableNepomuk" << enabled;
89 if ( enabled != isNepomukEnabled() ) {
92 m_currentState = StateEnabling;
96 m_serviceManager->startAllServices();
99 QDBusConnection::sessionBus().registerObject(
"/servicemanager", m_serviceManager );
103 m_currentState = StateDisabling;
106 m_serviceManager->stopAllServices();
107 connect(
this, SIGNAL(nepomukDisabled()),
108 QCoreApplication::instance(), SLOT(quit()));
111 QDBusConnection::sessionBus().unregisterObject(
"/servicemanager" );
120 if ( isNepomukEnabled() ) {
122 m_serviceManager->startService( m_fileIndexerServiceName );
125 m_serviceManager->stopService( m_fileIndexerServiceName );
133 return m_currentState == StateEnabled || m_currentState == StateEnabling;
139 return m_serviceManager->runningServices().contains( m_fileIndexerServiceName );
145 return QLatin1String(
"main");
159 if( isNepomukEnabled() &&
160 !m_serviceManager->runningServices().isEmpty() ) {
161 enableNepomuk(
false);
166 QTimer::singleShot( 0, QCoreApplication::instance(), SLOT(quit()) );
182 void Nepomuk2::Server::slotServiceStopped(
const QString &name)
188 if(m_currentState == StateDisabling &&
189 m_serviceManager->runningServices().isEmpty()) {
190 m_currentState = StateDisabled;
191 emit nepomukDisabled();
194 kDebug() <<
"Services still running:" << m_serviceManager->runningServices();
198 void Nepomuk2::Server::slotServiceInitialized(
const QString &name)
202 if(m_currentState == StateEnabling &&
203 m_serviceManager->pendingServices().isEmpty()) {
204 m_currentState = StateEnabled;
205 emit nepomukEnabled();
209 #include "nepomukserver.moc"
void enableFileIndexer(bool enabled)
void quit()
Asyncronically quits the server by first stopping all services and then calling QCoreApplication::qui...
bool isFileIndexerEnabled() const
Manages all Nepomuk services.
bool isNepomukEnabled() const
static NepomukServerSettings * self()
void enableNepomuk(bool enabled)
Server(bool noServices, QObject *parent=0)
KSharedConfig::Ptr config() const
QString defaultRepository() const