More attempts at dbus notifications
authorEnrico Zini <enrico@enricozini.org>
Fri, 27 Nov 2009 18:12:55 +0000 (19:12 +0100)
committerEnrico Zini <enrico@enricozini.org>
Fri, 27 Nov 2009 18:12:55 +0000 (19:12 +0100)
README
src/clock.vala
src/zavai.vala

diff --git a/README b/README
index 69064200b70dba72cef405b291c975a38e173220..512a67bd3c61d4e0e68ee62db40bf0e16d1a1d17 100644 (file)
--- a/README
+++ b/README
@@ -154,7 +154,7 @@ TODO list / wish list
  * Features to add:
  - alerts with at
  - work without ogpsd
-    - use the gpsd dbus protocol
+    - use the gpsd protocol
     - power on/off the gps and start/stop gpsd
     - set to keep the GPS on during suspend
     - suspend/resume hooks to put the GPS into low power mode
index bf12606afeb65e2c44dd831676b449e06fe13d10..5b0638bb307444e47c105afec0c84a0bb859457e 100644 (file)
@@ -149,14 +149,12 @@ public class AlarmNotification : Object {
        }
 }
 
-namespace dbus {
-[DBus (name = "org.enricozini.zavai")]
-public class Alarm : Object {
-       public void Notify (string label) {
-               clock.notify(label);
+[DBus (name = "org.enricozini.zavai.Alarm")]
+public class ZavaiAlarm : Object {
+       public void Notify () {
+               clock.notify("ciao");
        }
 }
-}
 
 public class Clock: zavai.Service
 {
@@ -169,6 +167,7 @@ public class Clock: zavai.Service
        protected time_t chosen_time;
        protected SourceType chosen_type;
        protected AlarmNotification listener;
+       protected ZavaiAlarm listener1;
 
        protected dynamic DBus.Object otimed_alarm;
        protected dynamic DBus.Object rtc;
@@ -183,6 +182,7 @@ public class Clock: zavai.Service
                Object(name: "clock");
                alarms = null;
                listener = new AlarmNotification();
+               listener1 = new ZavaiAlarm();
                last_minute = 0;
                last_gps_time = 0;
                last_gps_time_system_time = 0;
index ac9f6b2549e740b1e1f439e4b76ed6acbd646502..77cfa5ccfdd6abaccca63893e463721c298b9103 100644 (file)
@@ -58,11 +58,33 @@ static int main (string[] args) {
        return 0;
 */
 
+       if (args[1] == "notify")
+       {
+               DBus.Connection sbus;
+               dynamic DBus.Object zav;
+               try {
+                       sbus = DBus.Bus.get(DBus.BusType.SYSTEM);
+               } catch (DBus.Error e) {
+                       stderr.printf("Cannot access system DBus bus: %s\n", e.message);
+                       return 1;
+               }
+               // see mdbus -s org.freesmartphone.ousaged /org/freesmartphone/Usage
+               zav = sbus.get_object(
+                       "org.enricozini.zavai",
+                       "/",
+                       "org.freesmartphone.Notification");
+               zav.Alarm();
+               //      "org.enricozini.zavai.Alarm");
+               //zav.Notify();
+               
+               return 0;
+       }
+
     // Core infrastructure
        zavai.config = new zavai.Config();
        zavai.registry = new zavai.Registry();
-       zavai.app = new zavai.Zavai();
 
+       zavai.app = new zavai.Zavai();
        zavai.registry.register_resource("zavai", zavai.app);
 
     // Additional infrastructure