20 #ifndef _NEPOMUK2_SERVICE2_H_
21 #define _NEPOMUK2_SERVICE2_H_
24 #include "nepomukversion.h"
26 #include <QtCore/QObject>
27 #include <QtCore/QCoreApplication>
28 #include <QtCore/QTextStream>
29 #include <QtDBus/QDBusConnection>
30 #include <QtDBus/QDBusConnectionInterface>
33 #include <KComponentData>
34 #include <KApplication>
35 #include <KCmdLineArgs>
106 template <
typename T>
107 static int init(
int argc,
char **argv,
const KAboutData& aboutData )
109 QCoreApplication app( argc, argv );
110 KComponentData data( aboutData, KComponentData::RegisterAsMainComponent );
112 const QString name = aboutData.appName();
113 const QString dbusName = dbusServiceName( name );
115 QTextStream s( stderr );
116 QDBusConnectionInterface* busInt = QDBusConnection::sessionBus().interface();
117 if( busInt->isServiceRegistered( dbusName ) ) {
118 s <<
"Service " << name <<
" already running." << endl;
122 T* service =
new T();
123 if( !service->initCommon(name) )
136 template <
typename T>
137 static int initUI(
int argc,
char **argv,
const KAboutData& aboutData ) {
138 KCmdLineArgs::init( argc, argv, &aboutData );
141 app.disableSessionManagement();
145 QDBusConnection con = QDBusConnection::sessionBus();
146 con.unregisterObject( QLatin1String(
"/MainApplication"), QDBusConnection::UnregisterNode );
148 const QString name = aboutData.appName();
149 const QString dbusName = dbusServiceName( name );
151 QTextStream s( stderr );
152 QDBusConnectionInterface* busInt = QDBusConnection::sessionBus().interface();
153 if( busInt->isServiceRegistered( dbusName ) ) {
154 s <<
"Service " << name <<
" already running." << endl;
158 T* service =
new T();
159 if( !service->initCommon(name) )
170 static QString dbusServiceName(
const QString& serviceName );
196 QString description();
201 QString dbusServiceName();
216 void setServiceInitialized(
bool success );
218 bool initCommon(
const QString& name );
static int init(int argc, char **argv, const KAboutData &aboutData)
Use this method in the main function of your service application to initialize your service...
static int initUI(int argc, char **argv, const KAboutData &aboutData)
Similar to the init method above except that it creates an application with a UI so that you can use ...
New Base class for all Nepomuk services.