s/QMH_HELPER_DBUS_SERVICENAME/QMH_PLAYER_DBUS_SERVICENAME
[qtmediahub:zhxts-qtmediahub-core.git] / mediaplayer / main.cpp
1 #include "testingplayer.h"
2 #ifdef XINE_PLAYER
3 #include "xineplayer.h"
4 #endif
5
6 #include "qtsingleapplication.h"
7 #include <QDebug>
8 #include <QtDBus>
9
10 int main(int argc, char** argv)
11 {
12     QtSingleApplication app(argc, argv);
13     app.setApplicationName("mediahelper");
14     app.setOrganizationName("Nokia");
15     app.setOrganizationDomain("nokia.com");
16
17     if (app.isRunning()) {
18         qWarning() << app.applicationName() << "is already running, aborting";
19         return false;
20     }
21
22     bool dbusRegistration = QDBusConnection::sessionBus().registerService(QMH_PLAYER_DBUS_SERVICENAME);
23     if (!dbusRegistration) {
24         qDebug()
25             << "Can't seem to register dbus service:"
26             << QDBusConnection::sessionBus().lastError().message();
27         app.exit(-1);
28     }
29     AbstractMediaPlayer *player = 0;
30 #ifdef XINE_PLAYER
31 #warning using xine backend
32     qDebug() << "Xine player started";
33     player = new XinePlayer(&app);
34 #else
35 #warning using qDebug testing backend
36     qDebug() << "qDebug player started";
37     player = new TestingPlayer(&app);
38 #endif
39
40     dbusRegistration = QDBusConnection::sessionBus().registerObject("/", player,
41             QDBusConnection::ExportScriptableSlots|QDBusConnection::ExportScriptableSignals);
42
43     if (!dbusRegistration) {
44         qDebug()
45             << "Can't seem to register dbus object:"
46             << QDBusConnection::sessionBus().lastError().message();
47         app.exit(-1);
48     }
49     return app.exec();
50 }