Managed to export a proper dbus interface for alarm notification
authorEnrico Zini <enrico@enricozini.org>
Sun, 29 Nov 2009 16:17:53 +0000 (17:17 +0100)
committerEnrico Zini <enrico@enricozini.org>
Sun, 29 Nov 2009 16:17:53 +0000 (17:17 +0100)
src/clock.vala
src/zavai.vala

index edc1ca17c642b663ce0bdeb6de4b9bba94418f62..5a22847a7ba13f247ac3217ddf650e462670bbc2 100644 (file)
@@ -147,15 +147,12 @@ public class AlarmNotification : Object {
        public void Alarm () {
                clock.check_alarms();
        }
-       public void AtAlarm (string label) {
-               clock.notify(label);
-       }
 }
 
 [DBus (name = "org.enricozini.zavai.Alarm")]
-public class ZavaiAlarm : Object {
-       public void Notify () {
-               clock.notify("ciao");
+public class ZavaiClock : Object {
+       public void Notify (string label) {
+               clock.notify(label);
        }
 }
 
@@ -170,7 +167,7 @@ public class Clock: zavai.Service
        protected time_t chosen_time;
        protected SourceType chosen_type;
        protected AlarmNotification listener;
-       protected ZavaiAlarm listener1;
+       protected ZavaiClock dbusClock;
 
        protected dynamic DBus.Object otimed_alarm;
        protected dynamic DBus.Object rtc;
@@ -185,7 +182,7 @@ public class Clock: zavai.Service
                Object(name: "clock");
                alarms = null;
                listener = new AlarmNotification();
-               listener1 = new ZavaiAlarm();
+               dbusClock = new ZavaiClock();
                last_minute = 0;
                last_gps_time = 0;
                last_gps_time_system_time = 0;
@@ -209,7 +206,7 @@ public class Clock: zavai.Service
                                "org.freesmartphone.Device.RealtimeClock");
 
                zavai.registry.sbus.register_object("/", listener);
-
+               zavai.registry.sbus.register_object("/org/enricozini/Zavai/Clock", dbusClock);
        }
 
        public void notify(string label)
index 33e0bd72c09417fe7cddb69925136a84686763c7..467aab667ecd0f612473e2aa6375e85de3ed4801 100644 (file)
@@ -58,7 +58,7 @@ static int main (string[] args) {
        return 0;
 */
 
-       if (args[1] == "notify")
+       if (args.length > 1 && args[1] == "notify")
        {
                DBus.Connection sbus;
                dynamic DBus.Object zav;
@@ -71,11 +71,12 @@ static int main (string[] args) {
                // see mdbus -s org.freesmartphone.ousaged /org/freesmartphone/Usage
                zav = sbus.get_object(
                        "org.enricozini.zavai",
-                       "/",
-                       "org.freesmartphone.Notification");
-               zav.AtAlarm("ciao");
-               //      "org.enricozini.zavai.Alarm");
-               //zav.Notify();
+                       "/org/enricozini/Zavai/Clock",
+                       "org.enricozini.zavai.Alarm");
+               if (args.length > 2)
+                       zav.Notify(args[2]);
+               else
+                       zav.Notify("Alarm");
                
                return 0;
        }