Alarm dbus connection added
authorhanzes <hanzes@localhost>
Mon, 1 Feb 2010 15:43:00 +0000 (15:43 +0000)
committerhanzes <hanzes@localhost>
Mon, 1 Feb 2010 15:43:00 +0000 (15:43 +0000)
15 files changed:
src/alarm/alarm.cpp
src/alarm/alarm.pro
src/alarm/alarmdbus.cpp [deleted file]
src/alarm/alarmdbus.h [deleted file]
src/alarm/alarmdbusadaptor.cpp [deleted file]
src/alarm/alarmdbusadaptorp.h [deleted file]
src/app/alarmdbus.cpp [new file with mode: 0644]
src/app/alarmdbus.h [new file with mode: 0644]
src/app/alarmdbusadaptor.cpp [new file with mode: 0644]
src/app/alarmdbusadaptorp.h [new file with mode: 0644]
src/app/app.pro
src/app/main.cpp
src/mvc/mvc.pro
src/mvc/treeview.cpp
src/src.pro

index 333ed34..73d5056 100644 (file)
@@ -4,7 +4,7 @@
 
 #include <QApplication>
 #include <QDir>
-#include <QDebug>
+#include <QFileInfo>
 
 #include <dbus-1.0/dbus/dbus-protocol.h>
 
@@ -29,18 +29,28 @@ int Alarm::addAlarm(int aEventId, const QDateTime &aDateTime)
     act = alarm_event_add_actions(eve, 1);
     alarm_action_set_label(act, "FOSDEM'10");
 
-    // setup this action to be a "DBus command"
-    act->flags |= ALARM_ACTION_WHEN_RESPONDED;
-    act->flags |= ALARM_ACTION_TYPE_DBUS;
-
-    // DBus params for this action
-    alarm_action_set_dbus_interface(act, "org.fosdem.schedule.AlarmInterface");
-    alarm_action_set_dbus_service(act, "org.fosdem.schedule");
-    alarm_action_set_dbus_path(act, "/Fosdem");
-    alarm_action_set_dbus_name(act, "Alarm");
+    QFileInfo fi(*qApp->argv());
+    QString name(fi.fileName());
 
-    // DBus arguments for the action
-    alarm_action_set_dbus_args(act,  DBUS_TYPE_INT32, &aEventId, DBUS_TYPE_INVALID);
+    QString command = QDir::currentPath() + "/" + name + QString(" %1").arg(QString::number(aEventId));
+    //QString command =  *qApp->argv() + QString(" %1").arg(QString::number(aEventId));
+    alarm_action_set_exec_command(act, command.toLocal8Bit().data());
+    act->flags |= ALARM_ACTION_TYPE_EXEC;
+    act->flags |= ALARM_ACTION_WHEN_RESPONDED;
+    act->flags |= ALARM_ACTION_EXEC_ADD_COOKIE; // adds assigned cookie at the end of command string
+
+//    // setup this action to be a "DBus command"
+//    act->flags |= ALARM_ACTION_WHEN_RESPONDED;
+//    act->flags |= ALARM_ACTION_TYPE_DBUS;
+//
+//    // DBus params for this action
+//    alarm_action_set_dbus_interface(act, "org.fosdem.schedule.AlarmInterface");
+//    alarm_action_set_dbus_service(act, "org.fosdem.schedule");
+//    alarm_action_set_dbus_path(act, "/Fosdem");
+//    alarm_action_set_dbus_name(act, "Alarm");
+//
+//    // DBus arguments for the action
+//    alarm_action_set_dbus_args(act,  DBUS_TYPE_INT32, &aEventId, DBUS_TYPE_INVALID);
 
     //    act->flags |= ALARM_ACTION_TYPE_EXEC;
     //     alarm_action_set_exec_command(act, command.toLocal8Bit().data());
index 94838c8..0db75aa 100644 (file)
@@ -9,12 +9,8 @@ LIBS += -lalarm
 DEPENDPATH += .
 
 HEADERS += alarm.h \
-                  alarmdbus.h \
-                  alarmdbusadaptorp.h
 
 SOURCES += alarm.cpp \
-                  alarmdbus.cpp \
-                  alarmdbusadaptor.cpp
 
 INCLUDEPATH += ../gui \
     ../mvc \ 
diff --git a/src/alarm/alarmdbus.cpp b/src/alarm/alarmdbus.cpp
deleted file mode 100644 (file)
index 286b851..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-
-#include "alarmdbus.h"
-#include "eventdialog.h"
-
-
-
-
-CAlarmDBus::CAlarmDBus(QWidget * aParent)
-    : QObject(),
-    mParent(aParent)
-{
-    // constructor
-    //setAutoRelaySignals(true);
-}
-
-CAlarmDBus::~CAlarmDBus()
-{
-    // destructor
-}
-
-void CAlarmDBus::Alarm(int aEventId)
-{
-       EventDialog dialog(aEventId,mParent);
-       dialog.exec();
-
-}
diff --git a/src/alarm/alarmdbus.h b/src/alarm/alarmdbus.h
deleted file mode 100644 (file)
index 6363b95..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef SINGLE_INSTANCE_H
-#define SINGLE_INSTANCE_H
-
-#include <QObject>
-#include <QtDBus/QtDBus>
-
-class CAlarmDBus: public QObject
-{
-    Q_OBJECT
-    Q_CLASSINFO("D-Bus Interface", "org.fosdem.schedule")
-
-public:
-       CAlarmDBus(QWidget * aParent);
-    virtual ~CAlarmDBus();
-
-public: // PROPERTIES
-public Q_SLOTS: // METHODS
-    void Alarm(int aEventId);
-private:
-       QWidget * mParent;
-};
-
-
-#endif // SINGLE_INSTANCE_H
diff --git a/src/alarm/alarmdbusadaptor.cpp b/src/alarm/alarmdbusadaptor.cpp
deleted file mode 100644 (file)
index c0c903a..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * This file was generated by dbusxml2cpp version 0.6
- * Command line was: dbusxml2cpp -c CarAdaptor -a car_adaptor_p.h:car_adaptor.cpp car.xml
- *
- * dbusxml2cpp is Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
- *
- * This is an auto-generated file.
- * Do not edit! All changes made to it will be lost.
- */
-
-#include "alarmdbusadaptorp.h"
-#include <QtCore/QMetaObject>
-#include <QtCore/QByteArray>
-#include <QtCore/QList>
-#include <QtCore/QMap>
-#include <QtCore/QString>
-#include <QtCore/QStringList>
-#include <QtCore/QVariant>
-
-/*
- * Implementation of adaptor class CarAdaptor
- */
-
-AlarmDBusAdaptor::AlarmDBusAdaptor(QObject *parent)
-    : QDBusAbstractAdaptor(parent)
-{
-    // constructor
-    setAutoRelaySignals(true);
-}
-
-AlarmDBusAdaptor::~AlarmDBusAdaptor()
-{
-    // destructor
-}
-
-void AlarmDBusAdaptor::Alarm(int aEventId)
-{
-    // handle method call com.trolltech.Examples.CarInterface.accelerate
-    QMetaObject::invokeMethod(parent(), "Alarm",Q_ARG(int, aEventId));
-}
-
-
diff --git a/src/alarm/alarmdbusadaptorp.h b/src/alarm/alarmdbusadaptorp.h
deleted file mode 100644 (file)
index cf22b17..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * This file was generated by dbusxml2cpp version 0.6
- * Command line was: dbusxml2cpp -c CarAdaptor -a car_adaptor_p.h:car_adaptor.cpp car.xml
- *
- * dbusxml2cpp is Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
- *
- * This is an auto-generated file.
- * This file may have been hand-edited. Look for HAND-EDIT comments
- * before re-generating it.
- */
-
-#ifndef ALARM_DBUS_ADAPTOR_P_H
-#define ALARM_DBUS_ADAPTOR_P_H
-
-#include <QtCore/QObject>
-#include <QtDBus/QtDBus>
-
-QT_BEGIN_NAMESPACE
-class QByteArray;
-template<class T> class QList;
-template<class Key, class Value> class QMap;
-class QString;
-class QStringList;
-class QVariant;
-QT_END_NAMESPACE
-
-/*
- * Adaptor class for interface com.trolltech.Examples.CarInterface
- */
-class AlarmDBusAdaptor: public QDBusAbstractAdaptor
-{
-    Q_OBJECT
-    Q_CLASSINFO("D-Bus Interface", "org.fosdem.schedule.AlarmInterface")
-    Q_CLASSINFO("D-Bus Introspection", ""
-"  <interface name=\"org.fosdem.schedule.AlarmInterface\" >\n"
-"  <method name=\"Alarm\">\n"
-"        <arg name=\"aEventId\" type=\"i\" direction=\"in\"/>\n"
-"  </method>\n"
-"  </interface>\n"
-        "")
-public:
-       AlarmDBusAdaptor(QObject *parent);
-    virtual ~AlarmDBusAdaptor();
-
-public: // PROPERTIES
-public Q_SLOTS: // METHODS
-       void Alarm(int aEventId);
-};
-
-#endif
diff --git a/src/app/alarmdbus.cpp b/src/app/alarmdbus.cpp
new file mode 100644 (file)
index 0000000..286b851
--- /dev/null
@@ -0,0 +1,26 @@
+
+#include "alarmdbus.h"
+#include "eventdialog.h"
+
+
+
+
+CAlarmDBus::CAlarmDBus(QWidget * aParent)
+    : QObject(),
+    mParent(aParent)
+{
+    // constructor
+    //setAutoRelaySignals(true);
+}
+
+CAlarmDBus::~CAlarmDBus()
+{
+    // destructor
+}
+
+void CAlarmDBus::Alarm(int aEventId)
+{
+       EventDialog dialog(aEventId,mParent);
+       dialog.exec();
+
+}
diff --git a/src/app/alarmdbus.h b/src/app/alarmdbus.h
new file mode 100644 (file)
index 0000000..6363b95
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef SINGLE_INSTANCE_H
+#define SINGLE_INSTANCE_H
+
+#include <QObject>
+#include <QtDBus/QtDBus>
+
+class CAlarmDBus: public QObject
+{
+    Q_OBJECT
+    Q_CLASSINFO("D-Bus Interface", "org.fosdem.schedule")
+
+public:
+       CAlarmDBus(QWidget * aParent);
+    virtual ~CAlarmDBus();
+
+public: // PROPERTIES
+public Q_SLOTS: // METHODS
+    void Alarm(int aEventId);
+private:
+       QWidget * mParent;
+};
+
+
+#endif // SINGLE_INSTANCE_H
diff --git a/src/app/alarmdbusadaptor.cpp b/src/app/alarmdbusadaptor.cpp
new file mode 100644 (file)
index 0000000..c0c903a
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * This file was generated by dbusxml2cpp version 0.6
+ * Command line was: dbusxml2cpp -c CarAdaptor -a car_adaptor_p.h:car_adaptor.cpp car.xml
+ *
+ * dbusxml2cpp is Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#include "alarmdbusadaptorp.h"
+#include <QtCore/QMetaObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+
+/*
+ * Implementation of adaptor class CarAdaptor
+ */
+
+AlarmDBusAdaptor::AlarmDBusAdaptor(QObject *parent)
+    : QDBusAbstractAdaptor(parent)
+{
+    // constructor
+    setAutoRelaySignals(true);
+}
+
+AlarmDBusAdaptor::~AlarmDBusAdaptor()
+{
+    // destructor
+}
+
+void AlarmDBusAdaptor::Alarm(int aEventId)
+{
+    // handle method call com.trolltech.Examples.CarInterface.accelerate
+    QMetaObject::invokeMethod(parent(), "Alarm",Q_ARG(int, aEventId));
+}
+
+
diff --git a/src/app/alarmdbusadaptorp.h b/src/app/alarmdbusadaptorp.h
new file mode 100644 (file)
index 0000000..cf22b17
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * This file was generated by dbusxml2cpp version 0.6
+ * Command line was: dbusxml2cpp -c CarAdaptor -a car_adaptor_p.h:car_adaptor.cpp car.xml
+ *
+ * dbusxml2cpp is Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#ifndef ALARM_DBUS_ADAPTOR_P_H
+#define ALARM_DBUS_ADAPTOR_P_H
+
+#include <QtCore/QObject>
+#include <QtDBus/QtDBus>
+
+QT_BEGIN_NAMESPACE
+class QByteArray;
+template<class T> class QList;
+template<class Key, class Value> class QMap;
+class QString;
+class QStringList;
+class QVariant;
+QT_END_NAMESPACE
+
+/*
+ * Adaptor class for interface com.trolltech.Examples.CarInterface
+ */
+class AlarmDBusAdaptor: public QDBusAbstractAdaptor
+{
+    Q_OBJECT
+    Q_CLASSINFO("D-Bus Interface", "org.fosdem.schedule.AlarmInterface")
+    Q_CLASSINFO("D-Bus Introspection", ""
+"  <interface name=\"org.fosdem.schedule.AlarmInterface\" >\n"
+"  <method name=\"Alarm\">\n"
+"        <arg name=\"aEventId\" type=\"i\" direction=\"in\"/>\n"
+"  </method>\n"
+"  </interface>\n"
+        "")
+public:
+       AlarmDBusAdaptor(QObject *parent);
+    virtual ~AlarmDBusAdaptor();
+
+public: // PROPERTIES
+public Q_SLOTS: // METHODS
+       void Alarm(int aEventId);
+};
+
+#endif
index dfcd95b..7d2d479 100644 (file)
@@ -2,7 +2,7 @@ include(../global.pri)
 TEMPLATE = app
 TARGET = fosdem-schedule
 DESTDIR = ../bin
-QT += sql xml network dbus
+QT += sql xml network dbus 
 
 # module dependencies
 LIBS += -L$$DESTDIR -lgui -lmvc -lsql
@@ -16,10 +16,14 @@ maemo {
     TARGETDEPS += $$DESTDIR/libqalarm.a
 }
 
-HEADERS += appsettings.h
+HEADERS += appsettings.h \
+    alarmdbus.h \
+       alarmdbusadaptorp.h
 
 SOURCES += main.cpp \
-           appsettings.cpp
+           appsettings.cpp \
+    alarmdbus.cpp \
+       alarmdbusadaptor.cpp
 
 RESOURCES += ../icons.qrc \
              ../maps.qrc \
index 791add4..acd5e06 100644 (file)
@@ -1,14 +1,16 @@
 #include <mainwindow.h>
 
 #include <QtGui/QApplication>
+#include <sqlengine.h>
+
+#include "eventdialog.h"
+
 #ifdef MAEMO
 //#include <alarmdialog.h>
 #include <alarmdbus.h>
 #include <alarmdbusadaptorp.h>
 #endif /* MAEMO */
 
-#include <sqlengine.h>
-
 
 int main(int argc, char *argv[])
 {
@@ -22,38 +24,41 @@ int main(int argc, char *argv[])
     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 if(argc==2) // display Event dialog automatically
-//        window = new MainWindow(atoi(argv[1])); // eventId = argv[1]
-//    else
-        window = new MainWindow;
-#else
+
     window = new MainWindow;
-#endif /* MAEMO */
-    window->show();
+
 
 #ifdef MAEMO
     // Alarm Dbus
     CAlarmDBus *alarmDBus = new CAlarmDBus(window);
     new AlarmDBusAdaptor(alarmDBus);
-    //QDBusConnection connection = QDBusConnection::sessionBus();
     QDBusConnection connection = QDBusConnection::sessionBus();
 
     if(connection.registerObject("/Fosdem", alarmDBus) == true)
     {
        if( connection.registerService("org.fosdem.schedule") == false)
        {
-               qDebug() << "dbus register service failed";
+               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();
 }
 
index 03cea46..53c0973 100644 (file)
@@ -3,7 +3,7 @@ TEMPLATE = lib
 TARGET = mvc
 DESTDIR = ../bin
 CONFIG += static
-QT += sql
+QT += sql 
 
 # module dependencies
 LIBS += -L$$DESTDIR \
@@ -26,11 +26,11 @@ HEADERS += event.h \
     delegate.h \
     eventmodel.h \
     treeview.h \
-    room.h
+    room.h 
 SOURCES += event.cpp \
     conference.cpp \
     track.cpp \
     delegate.cpp \
     eventmodel.cpp \
     treeview.cpp \
-    room.cpp
+    room.cpp 
index 5fd63ee..f0d8aab 100644 (file)
@@ -97,8 +97,8 @@ bool TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aP
 #ifdef MAEMO
                     // add alarm to the 'alarmd'
                     Alarm alarm;
-                    //int cookie = alarm.addAlarm(event.id(),QDateTime::currentDateTime().addSecs(10)); // testing
-                    int cookie = alarm.addAlarm(event.id(),event.start().addSecs(-15*60)); // 15 minutes before real start
+                    int cookie = alarm.addAlarm(event.id(),QDateTime::currentDateTime().addSecs(10)); // testing
+                    //int cookie = alarm.addAlarm(event.id(),event.start().addSecs(-15*60)); // 15 minutes before real start
                     qDebug() << "cookie: " << cookie;
 #endif /* MAEMO */
                 }
index 1aa5f8f..dd3c615 100644 (file)
@@ -1,8 +1,7 @@
 include(global.pri)
 TEMPLATE = subdirs
-SUBDIRS  += orm mvc sql gui
 maemo : SUBDIRS += alarm
-SUBDIRS += app
+SUBDIRS  += orm sql mvc gui app 
 #SUBDIRS += test
 CONFIG += ordered