A header with the proper copyright/lincence statement was added into each source...
[toast/confclerk.git] / src / alarm / alarm.cpp
index 333ed34..0cfb31b 100644 (file)
@@ -1,12 +1,32 @@
+/*
+ * Copyright (C) 2010 Ixonos Plc.
+ *
+ * This file is part of fosdem-schedule.
+ *
+ * fosdem-schedule is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * fosdem-schedule is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * fosdem-schedule.  If not, see <http://www.gnu.org/licenses/>.
+ */
 #include "alarm.h"
 
 #include <QDateTime>
 
 #include <QApplication>
 #include <QDir>
+#include <QFileInfo>
+
 #include <QDebug>
 
-#include <dbus-1.0/dbus/dbus-protocol.h>
+//#include <dbus-1.0/dbus/dbus-protocol.h>
 
 int Alarm::addAlarm(int aEventId, const QDateTime &aDateTime)
 {
@@ -22,25 +42,33 @@ int Alarm::addAlarm(int aEventId, const QDateTime &aDateTime)
     alarm_event_set_message(eve, QString::number(aEventId).toLocal8Bit().data());
 
     /* Use absolute time triggering */
-    eve->alarm_time = time(0) + 5; //aDateTime.toTime_t();
+    //eve->alarm_time = time(0) + 5; // for testing (5 seconds from now)
+    eve->alarm_time = aDateTime.toTime_t();
     eve->flags = ALARM_EVENT_BOOT;
 
     /* Add exec command action */
     act = alarm_event_add_actions(eve, 1);
     alarm_action_set_label(act, "FOSDEM'10");
 
-    // setup this action to be a "DBus command"
+    QString command = QFileInfo(*qApp->argv()).absoluteFilePath() + QString(" %1").arg(QString::number(aEventId));
+    qDebug() << "Setting alarm: " << command;
+    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_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_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());