r3903 - in trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-memory: . src

chris at sita.openmoko.org chris at sita.openmoko.org
Mon Jan 21 17:10:21 CET 2008


Author: chris
Date: 2008-01-21 17:10:20 +0100 (Mon, 21 Jan 2008)
New Revision: 3903

Modified:
   trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-memory/ChangeLog
   trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-memory/src/openmoko-panel-memory.c
Log:
        * src/openmoko-panel-memory.c: (update), (sim_full_cb),
        (phone_full_cb), (mb_panel_applet_create):
        Update to match new dbus API


Modified: trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-memory/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-memory/ChangeLog	2008-01-21 16:05:58 UTC (rev 3902)
+++ trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-memory/ChangeLog	2008-01-21 16:10:20 UTC (rev 3903)
@@ -1,5 +1,11 @@
 2008-01-21  Chris Lord  <chris at openedhand.com>
 
+	* src/openmoko-panel-memory.c: (update), (sim_full_cb),
+	(phone_full_cb), (mb_panel_applet_create):
+	Update to match new dbus API
+
+2008-01-21  Chris Lord  <chris at openedhand.com>
+
 	* src/openmoko-panel-memory.c: (memory_full_cb):
 	Don't add multiple idles/try to remove non-existant ones
 

Modified: trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-memory/src/openmoko-panel-memory.c
===================================================================
--- trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-memory/src/openmoko-panel-memory.c	2008-01-21 16:05:58 UTC (rev 3902)
+++ trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-memory/src/openmoko-panel-memory.c	2008-01-21 16:10:20 UTC (rev 3903)
@@ -28,6 +28,9 @@
 	NotifyNotification *notification;
 	
 	guint blink_idle;
+	
+	gboolean sim_full;
+	gboolean phone_full;
 } MemoryAppletData;
 
 static gboolean
@@ -40,10 +43,9 @@
 }
 
 static void
-memory_full_cb (DBusGProxy *proxy, gboolean sim_full, gboolean phone_full,
-		MemoryAppletData *data)
+update (MemoryAppletData *data)
 {
-	if (sim_full || phone_full) {
+	if (data->sim_full || data->phone_full) {
 		const gchar *message;
 		
 		if (!data->blink_idle) {
@@ -52,9 +54,9 @@
 				(GSourceFunc)blink_idle, data);
 		}
 		
-		if (sim_full && phone_full) {
+		if (data->sim_full && data->phone_full) {
 			message = "Phone and SIM memory full";
-		} else if (sim_full) {
+		} else if (data->sim_full) {
 			message = "SIM memory full";
 		} else {
 			message = "Phone memory full";
@@ -73,6 +75,20 @@
 	}
 }
 
+static void
+sim_full_cb (DBusGProxy *proxy, gboolean full, MemoryAppletData *data)
+{
+	data->sim_full = full;
+	update (data);
+}
+
+static void
+phone_full_cb (DBusGProxy *proxy, gboolean full, MemoryAppletData *data)
+{
+	data->phone_full = full;
+	update (data);
+}
+
 G_MODULE_EXPORT GtkWidget *
 mb_panel_applet_create (const char* id, GtkOrientation orientation)
 {
@@ -93,10 +109,14 @@
 		"org.openmoko.PhoneKit", "/org/openmoko/PhoneKit/Sms",
 		"org.openmoko.PhoneKit.Sms");
 	
-	dbus_g_proxy_add_signal (data->sms_proxy, "MemoryFull",
-		G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_INVALID);
-	dbus_g_proxy_connect_signal (data->sms_proxy, "MemoryFull",
-		G_CALLBACK (memory_full_cb), data, NULL);
+	dbus_g_proxy_add_signal (data->sms_proxy, "SimMemoryState",
+		G_TYPE_BOOLEAN, G_TYPE_INVALID);
+	dbus_g_proxy_add_signal (data->sms_proxy, "PhoneMemoryState",
+		G_TYPE_BOOLEAN, G_TYPE_INVALID);
+	dbus_g_proxy_connect_signal (data->sms_proxy, "SimMemoryState",
+		G_CALLBACK (sim_full_cb), data, NULL);
+	dbus_g_proxy_connect_signal (data->sms_proxy, "PhoneMemoryState",
+		G_CALLBACK (phone_full_cb), data, NULL);
 	
 	notify_init ("openmoko-panel-memory");
 	data->notification = notify_notification_new ("Memory full", "",
@@ -109,6 +129,15 @@
 	gtk_widget_show (data->image);
 	moko_panel_applet_set_widget (data->applet, data->image);
 	
+	if (!dbus_g_proxy_call (data->sms_proxy, "GetMemoryStatus", &error,
+	     G_TYPE_INVALID, G_TYPE_BOOLEAN, &data->sim_full,
+	     G_TYPE_BOOLEAN, &data->phone_full, G_TYPE_INVALID)) {
+		g_warning ("Error calling GetMemoryStatus: %s", error->message);
+		g_error_free (error);
+	} else {
+		update (data);
+	}
+	
 	return GTK_WIDGET (data->applet);
 }
 





More information about the commitlog mailing list