Alarm dbus connection added
[toast/confclerk.git] / src / app / main.cpp
index 9505799e0559ab9cae1410c9ba981421290995f0..acd5e06e66b241a044b06b19af79f2f2529f9616 100644 (file)
@@ -1,33 +1,64 @@
 #include <mainwindow.h>
 
 #include <QtGui/QApplication>
+#include <sqlengine.h>
+
+#include "eventdialog.h"
+
 #ifdef MAEMO
-#include <alarmdialog.h>
+//#include <alarmdialog.h>
+#include <alarmdbus.h>
+#include <alarmdbusadaptorp.h>
 #endif /* MAEMO */
 
+
 int main(int argc, char *argv[])
 {
     Q_INIT_RESOURCE(icons);
     Q_INIT_RESOURCE(maps);
-    Q_INIT_RESOURCE(schedule);
+    Q_INIT_RESOURCE(db);
 
     QApplication a(argc, argv);
     QApplication::setWindowIcon(QIcon(":/icons/fosdem.png"));
 
+    SqlEngine::initialize(); // creates "SQLITE" DB connection
+
     QWidget *window;
-#ifdef MAEMO
-    // if the app is run with two cmd-line arguments
-    // an alarm dialog is to be displayed
-    // Usage: $ ./fosdem eventId alarmId
-    // Example: $ ./fosdem 521 13
-    if(argc==3) 
-        window = new AlarmDialog(argc,argv);
-    else
-        window = new MainWindow;
-#else
+
     window = new MainWindow;
-#endif /* MAEMO */
+
+
+#ifdef MAEMO
+    // Alarm Dbus
+    CAlarmDBus *alarmDBus = new CAlarmDBus(window);
+    new AlarmDBusAdaptor(alarmDBus);
+    QDBusConnection connection = QDBusConnection::sessionBus();
+
+    if(connection.registerObject("/Fosdem", alarmDBus) == true)
+    {
+       if( connection.registerService("org.fosdem.schedule") == false)
+       {
+               if(argc>1)
+               {
+                       QDBusInterface *interface = new QDBusInterface("org.fosdem.schedule",
+                                                                      "/Fosdem",
+                                                                      "org.fosdem.schedule.AlarmInterface",
+                                                                      connection);
+                       interface->call("Alarm",atoi(argv[1]));
+                       return 0;
+               }
+       }
+    }
+
+    if(argc > 1)
+    {
+        EventDialog dialog(atoi(argv[1]),window);
+        dialog.exec();
+    }
+#endif
+
     window->show();
+
     return a.exec();
 }