phonemgr r294 - in trunk: . src



Author: hadess
Date: Fri May 30 13:54:00 2008
New Revision: 294
URL: http://svn.gnome.org/viewvc/phonemgr?rev=294&view=rev

Log:
2008-05-30  Bastien Nocera  <hadess hadess net>

	* configure.in: require glib 2.13 and newer

	* src/app.h:
	* src/connection.c (on_status), (on_network),
	(initialise_connection):
	* src/org_gnome_phone_Manager.xml:
	* src/phonemgr-object.c (phonemgr_object_class_init),
	(phonemgr_object_emit_network_registration_changed),
	(phonemgr_object_coldplug):
	* src/phonemgr-object.h: Add the NetworkRegistrationChanged
	signal on the org.gnome.phone.Manager interface, for the purpose
	of looking up location based on network and cell IDs
	(Closes: #533283)



Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/src/app.h
   trunk/src/connection.c
   trunk/src/org_gnome_phone_Manager.xml
   trunk/src/phonemgr-object.c
   trunk/src/phonemgr-object.h

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Fri May 30 13:54:00 2008
@@ -47,7 +47,7 @@
 		evo_pc_file="libebook-1.2",
 		evo_pc_file="libebook-1.0")
 
-PKG_CHECK_MODULES(PHONEMGR, gtk+-2.0 >= 2.10 glib-2.0
+PKG_CHECK_MODULES(PHONEMGR, gtk+-2.0 >= 2.10 glib-2.0 >= 2.13.0
 	gstreamer-0.10 gdk-pixbuf-2.0 gconf-2.0
 	$GNOME_BLUETOOTH_REQS libglade-2.0 $evo_pc_file
 	gmodule-2.0 dbus-glib-1 gnome-icon-theme >= 2.19.1

Modified: trunk/src/app.h
==============================================================================
--- trunk/src/app.h	(original)
+++ trunk/src/app.h	Fri May 30 13:54:00 2008
@@ -67,6 +67,7 @@
 	gulong  reconnector;
 	gulong  popup_cb;
 	gulong  battery_cb;
+	gulong  network_cb;
 } MyApp;
 
 typedef struct _message {

Modified: trunk/src/connection.c
==============================================================================
--- trunk/src/connection.c	(original)
+++ trunk/src/connection.c	Fri May 30 13:54:00 2008
@@ -183,6 +183,7 @@
 		case PHONEMGR_LISTENER_DISCONNECTING:
 			g_message ("Closing serial port connection");
 			phonemgr_object_emit_number_batteries_changed (app->object, 0);
+			phonemgr_object_emit_network_registration_changed (app->object, 0, 0, 0, 0);
 			break;
 		case PHONEMGR_LISTENER_ERROR:
 			set_icon_state (app);
@@ -223,6 +224,12 @@
 	phonemgr_object_emit_battery_state_changed (app->object, 0, percent, on_ac);
 }
 
+static void
+on_network (PhonemgrListener *listener, int mcc, int mnc, int lac, int cid, MyApp *app)
+{
+	phonemgr_object_emit_network_registration_changed (app->object, mcc, mnc, lac, cid);
+}
+
 void
 reconnect_phone (MyApp *app)
 {
@@ -271,13 +278,10 @@
 			G_CALLBACK (on_message), (gpointer) app);
 	app->battery_cb = g_signal_connect (G_OBJECT (app->listener), "battery",
 						G_CALLBACK (on_battery), (gpointer) app);
-#if GLIB_CHECK_VERSION(2,13,0)
+	app->network_cb = g_signal_connect (G_OBJECT (app->listener), "network",
+					    G_CALLBACK (on_network), app);
 	app->reconnector = g_timeout_add_seconds (20, (GSourceFunc)attempt_reconnect,
 						  (gpointer)app);
-#else
-	app->reconnector = g_timeout_add (20 * 1000, (GSourceFunc)attempt_reconnect,
-					  (gpointer)app);
-#endif
 
 	gdk_threads_init ();
 	app->connecting_mutex = g_mutex_new ();

Modified: trunk/src/org_gnome_phone_Manager.xml
==============================================================================
--- trunk/src/org_gnome_phone_Manager.xml	(original)
+++ trunk/src/org_gnome_phone_Manager.xml	Fri May 30 13:54:00 2008
@@ -11,5 +11,11 @@
     <signal name="NumberBatteriesChanged">
       <arg type="u" name="NumBatteries" />
     </signal>
+    <signal name="NetworkRegistrationChanged">
+      <arg type="i" name="mcc" />
+      <arg type="i" name="mnc" />
+      <arg type="i" name="lac" />
+      <arg type="i" name="cid" />
+    </signal>
   </interface>
 </node>

Modified: trunk/src/phonemgr-object.c
==============================================================================
--- trunk/src/phonemgr-object.c	(original)
+++ trunk/src/phonemgr-object.c	Fri May 30 13:54:00 2008
@@ -30,6 +30,7 @@
 enum {
 	NUMBER_BATTERIES_CHANGED,
 	BATTERY_STATE_CHANGED,
+	NETWORK_REGISTRATION_CHANGED,
 	LAST_SIGNAL
 };
 
@@ -70,6 +71,15 @@
 			      G_TYPE_NONE,
 			      3,
 			      G_TYPE_UINT, G_TYPE_UINT, G_TYPE_BOOLEAN);
+	phonemgr_object_signals[NETWORK_REGISTRATION_CHANGED] =
+		g_signal_new ("network-registration-changed",
+			      G_OBJECT_CLASS_TYPE (klass),
+			      G_SIGNAL_RUN_FIRST,
+			      G_STRUCT_OFFSET (PhonemgrObjectClass, network_registration_changed),
+			      NULL, NULL,
+			      phonemgr_marshal_VOID__INT_INT_INT_INT,
+			      G_TYPE_NONE, 4,
+			      G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
 
 	dbus_g_object_type_install_info (phonemgr_object_get_type (),
 					 &dbus_glib_phonemgr_object_object_info);
@@ -99,6 +109,19 @@
 		       0, index, percentage, on_ac);
 }
 
+void
+phonemgr_object_emit_network_registration_changed (PhonemgrObject *o, int mcc, int mnc, int lac, int cid)
+{
+	o->mcc = mcc;
+	o->mnc = mnc;
+	o->lac = lac;
+	o->cid = cid;
+
+	g_signal_emit (G_OBJECT (o),
+		       phonemgr_object_signals[NETWORK_REGISTRATION_CHANGED],
+		       0, mcc, mnc, lac, cid);
+}
+
 gboolean
 phonemgr_object_coldplug (PhonemgrObject *o, GError **error)
 {
@@ -110,6 +133,11 @@
 			       phonemgr_object_signals[BATTERY_STATE_CHANGED],
 			       0, 0, o->percentage, o->on_ac);
 	}
+	if (o->mcc != 0) {
+		g_signal_emit (G_OBJECT (o),
+			       phonemgr_object_signals[NETWORK_REGISTRATION_CHANGED],
+			       0, o->mcc, o->mnc, o->lac, o->cid);
+	}
 	return TRUE;
 }
 

Modified: trunk/src/phonemgr-object.h
==============================================================================
--- trunk/src/phonemgr-object.h	(original)
+++ trunk/src/phonemgr-object.h	Fri May 30 13:54:00 2008
@@ -35,11 +35,20 @@
 					guint battery_index,
 					guint percentage,
 					gboolean on_ac);
+	void (* network_registration_changed) (PhonemgrObject *o,
+					       int mcc, int mnc, int lac, int cid);
 };
 
 struct _PhonemgrObject {
 	GObject parent;
 
+	/* Network registration */
+	int mcc;
+	int mnc;
+	int lac;
+	int cid;
+
+	/* Battery */
 	guint percentage;
 	guint on_ac : 1;
 	/* We can only have one battery */
@@ -48,6 +57,7 @@
 
 void phonemgr_object_emit_number_batteries_changed (PhonemgrObject *o, guint num_batteries);
 void phonemgr_object_emit_battery_state_changed (PhonemgrObject *o, guint index, guint percentage, gboolean on_ac);
+void phonemgr_object_emit_network_registration_changed (PhonemgrObject *o, int mcc, int mnc, int lac, int cid);
 
 gboolean phonemgr_object_coldplug (PhonemgrObject *o, GError **error);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]