[geoclue/f15/master] Update for NetworkManager 0.9

Daniel Williams dcbw at fedoraproject.org
Thu Mar 10 08:36:05 UTC 2011


commit 5316d4ea50aaec8403602471524f0a1392398a29
Author: Dan Williams <dcbw at redhat.com>
Date:   Thu Mar 10 02:37:17 2011 -0600

    Update for NetworkManager 0.9

 geoclue-unused-var.patch     |   14 +++
 geoclue-use-libnm-glib.patch |  206 ++++++++++++++++++++++++++++++++++++++++++
 geoclue.spec                 |   11 ++-
 3 files changed, 228 insertions(+), 3 deletions(-)
---
diff --git a/geoclue-unused-var.patch b/geoclue-unused-var.patch
new file mode 100644
index 0000000..21c5d05
--- /dev/null
+++ b/geoclue-unused-var.patch
@@ -0,0 +1,14 @@
+diff -up geoclue-0.12.0/src/master-provider.c.blah geoclue-0.12.0/src/master-provider.c
+--- geoclue-0.12.0/src/master-provider.c.blah	2011-03-07 17:32:55.926713653 -0600
++++ geoclue-0.12.0/src/master-provider.c	2011-03-07 17:33:02.177635505 -0600
+@@ -846,10 +846,6 @@ gc_master_provider_initialize_interfaces
+ static gboolean
+ gc_master_provider_initialize (GcMasterProvider *provider)
+ {
+-	GcMasterProviderPrivate *priv;
+-	 
+-	priv = GET_PRIVATE (provider);
+-	
+ 	if (!gc_master_provider_initialize_interfaces (provider)) {
+ 		return FALSE;
+ 	}
diff --git a/geoclue-use-libnm-glib.patch b/geoclue-use-libnm-glib.patch
new file mode 100644
index 0000000..14b2601
--- /dev/null
+++ b/geoclue-use-libnm-glib.patch
@@ -0,0 +1,206 @@
+diff -up geoclue-0.12.0/src/connectivity-networkmanager.c.use-libnm-glib geoclue-0.12.0/src/connectivity-networkmanager.c
+--- geoclue-0.12.0/src/connectivity-networkmanager.c.use-libnm-glib	2010-02-19 06:40:40.000000000 -0600
++++ geoclue-0.12.0/src/connectivity-networkmanager.c	2011-03-07 17:36:15.324220841 -0600
+@@ -27,11 +27,19 @@
+ 
+ 
+ #include <dbus/dbus-glib.h>
++#include <string.h>
++
++#include <netinet/in.h>
++#include <arpa/inet.h>
++
+ #include <NetworkManager.h> /*for DBus strings */
+ 
+-#ifdef HAVE_NETWORK_MANAGER
+ #include <nm-client.h>
+ #include <nm-device-wifi.h>
++#include <nm-setting-ip4-config.h>
++
++#if !defined(NM_CHECK_VERSION)
++#define NM_CHECK_VERSION(x,y,z) 0
+ #endif
+ 
+ #include "connectivity-networkmanager.h"
+@@ -48,7 +56,7 @@ static int
+ get_status (GeoclueConnectivity *iface)
+ {
+ 	GeoclueNetworkManager *nm = GEOCLUE_NETWORKMANAGER (iface);
+-	
++
+ 	return nm->status;
+ }
+ 
+@@ -57,7 +65,7 @@ get_ap_mac (GeoclueConnectivity *iface)
+ {
+ 	GeoclueNetworkManager *self = GEOCLUE_NETWORKMANAGER (iface);
+ 
+-	return self->cache_ap_mac;
++	return g_strdup (self->cache_ap_mac);
+ }
+ 
+ static void
+@@ -89,16 +97,12 @@ cache_ap_mac (GeoclueNetworkManager *sel
+ 	guint i;
+ 
+ 	devices = nm_client_get_devices (self->client);
+-	if (devices == NULL) {
+-		g_free (self->cache_ap_mac);
+-		self->cache_ap_mac = NULL;
+-	}
+ 
+ 	g_free (self->cache_ap_mac);
+ 	self->cache_ap_mac = NULL;
+ 	self->ap_strength = 0;
+ 
+-	for (i = 0; i < devices->len; i++) {
++	for (i = 0; devices != NULL && i < devices->len; i++) {
+ 		NMDevice *device = g_ptr_array_index (devices, i);
+ 		if (NM_IS_DEVICE_WIFI (device)) {
+ 			get_best_ap (self, device);
+@@ -107,19 +111,10 @@ cache_ap_mac (GeoclueNetworkManager *sel
+ }
+ 
+ static void
+-finalize (GObject *object)
+-{
+-	/* free everything */
+-	
+-	((GObjectClass *) geoclue_networkmanager_parent_class)->finalize (object);
+-}
+-
+-static void
+ dispose (GObject *object)
+ {
+ 	GeoclueNetworkManager *self = GEOCLUE_NETWORKMANAGER (object);
+ 	
+-	dbus_g_connection_unref (self->connection);
+ 	g_free (self->cache_ap_mac);
+ 	self->cache_ap_mac = NULL;
+ 	g_object_unref (self->client);
+@@ -132,7 +127,6 @@ geoclue_networkmanager_class_init (Geocl
+ {
+ 	GObjectClass *o_class = (GObjectClass *) klass;
+ 	
+-	o_class->finalize = finalize;
+ 	o_class->dispose = dispose;
+ }
+ 
+@@ -144,11 +138,20 @@ nmstate_to_geocluenetworkstatus (NMState
+ 			return GEOCLUE_CONNECTIVITY_UNKNOWN;
+ 		case NM_STATE_ASLEEP:
+ 		case NM_STATE_DISCONNECTED:
++#if NM_CHECK_VERSION(0,8,992)
++		case NM_STATE_DISCONNECTING:
++#endif
+ 			return GEOCLUE_CONNECTIVITY_OFFLINE;
+ 		case NM_STATE_CONNECTING:
+ 			return GEOCLUE_CONNECTIVITY_ACQUIRING;
++#if NM_CHECK_VERSION(0,8,992)
++		case NM_STATE_CONNECTED_LOCAL:
++		case NM_STATE_CONNECTED_SITE:
++		case NM_STATE_CONNECTED_GLOBAL:
++#else
+ 		case NM_STATE_CONNECTED:
++#endif
+ 			return GEOCLUE_CONNECTIVITY_ONLINE;
+ 		default:
+ 			g_warning ("Unknown NMStatus: %d", status);
+ 			return GEOCLUE_CONNECTIVITY_UNKNOWN;
+@@ -156,66 +158,52 @@ nmstate_to_geocluenetworkstatus (NMState
+ }
+ 
+ static void
+-geoclue_networkmanager_state_changed (DBusGProxy *proxy, 
+-                                      NMState status, 
+-                                      gpointer userdata)
++update_status (GeoclueNetworkManager *self, gboolean do_signal)
+ {
+-	GeoclueNetworkManager *self = GEOCLUE_NETWORKMANAGER (userdata);
+-	GeoclueNetworkStatus gc_status;
+-	
+-	gc_status = nmstate_to_geocluenetworkstatus (status);
+-	
+-	if (gc_status != self->status) {
++	GeoclueNetworkStatus old_status;
++	NMState state;
++
++	old_status = self->status;
++
++	if (nm_client_get_manager_running (self->client)) {
++		state = nm_client_get_state (self->client);
++		self->status = nmstate_to_geocluenetworkstatus (state);
+ 		cache_ap_mac (self);
+-		self->status = gc_status;
++	} else {
++		self->status = GEOCLUE_CONNECTIVITY_OFFLINE;
++	}
++
++	if ((self->status != old_status) && do_signal) {
+ 		geoclue_connectivity_emit_status_changed (GEOCLUE_CONNECTIVITY (self),
+ 		                                          self->status);
+ 	}
+ }
+ 
+-
+-#define NM_DBUS_SIGNAL_STATE_CHANGE "StateChange"
++static void
++nm_update_status_cb (GObject *obj, GParamSpec *spec, gpointer userdata)
++{
++	update_status (GEOCLUE_NETWORKMANAGER (userdata), TRUE);
++}
+ 
+ static void
+ geoclue_networkmanager_init (GeoclueNetworkManager *self)
+ {
+-	GError *error = NULL;
+-	DBusGProxy *proxy;
+-	NMState state;
+-	
+ 	self->status = GEOCLUE_CONNECTIVITY_UNKNOWN;
+-	
+-	self->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+-	if (self->connection == NULL) {
+-		g_warning ("%s was unable to create a connection to D-Bus: %s",
+-			   G_OBJECT_TYPE_NAME (self), error->message);
+-		g_error_free (error);
++	self->client = nm_client_new ();
++	if (self->client == NULL) {
++		g_warning ("%s was unable to create a connection to NetworkManager",
++			   G_OBJECT_TYPE_NAME (self));
+ 		return;
+ 	}
+-	
+-	proxy = dbus_g_proxy_new_for_name (self->connection, 
+-	                                   NM_DBUS_SERVICE,
+-	                                   NM_DBUS_PATH, 
+-	                                   NM_DBUS_INTERFACE);
+-	dbus_g_proxy_add_signal (proxy, NM_DBUS_SIGNAL_STATE_CHANGE, 
+-	                         G_TYPE_UINT, G_TYPE_INVALID);
+-	dbus_g_proxy_connect_signal (proxy, NM_DBUS_SIGNAL_STATE_CHANGE, 
+-	                             G_CALLBACK (geoclue_networkmanager_state_changed), 
+-	                             self, NULL);
+-	
+-	if (dbus_g_proxy_call (proxy, "state", &error, 
+-	                       G_TYPE_INVALID, 
+-	                       G_TYPE_UINT, &state, G_TYPE_INVALID)){
+-		self->status = nmstate_to_geocluenetworkstatus (state);
+-	} else {
+-		g_warning ("Could not get connectivity state from NetworkManager: %s", error->message);
+-		g_error_free (error);
+-	}
+ 
+-	self->client = nm_client_new ();
+-	cache_ap_mac (self);
+-}
++	g_signal_connect (G_OBJECT (self->client), "notify::running",
++	                  G_CALLBACK (nm_update_status_cb), self);
++	g_signal_connect (G_OBJECT (self->client), "notify::state",
++	                  G_CALLBACK (nm_update_status_cb), self);
+ 
++	/* get initial status */
++	update_status (self, FALSE);
++}
+ 
+ static void
+ geoclue_networkmanager_connectivity_init (GeoclueConnectivityInterface *iface)
diff --git a/geoclue.spec b/geoclue.spec
index a285549..db12949 100644
--- a/geoclue.spec
+++ b/geoclue.spec
@@ -1,6 +1,6 @@
 Name:          geoclue
 Version:       0.12.0
-Release:       4%{?dist}
+Release:       5%{?dist}
 Summary:       A modular geoinformation service
 
 Group:         System Environment/Libraries
@@ -8,7 +8,8 @@ License:       LGPLv2
 URL:           http://geoclue.freedesktop.org/
 Source0:       http://folks.o-hand.com/jku/geoclue-releases/%{name}-%{version}.tar.gz
 Patch0:        geoclue-nm08.patch
-Patch1:        geoclue-NMCrash.patch
+Patch1:        geoclue-use-libnm-glib.patch
+Patch2:        geoclue-unused-var.patch
 
 BuildRequires: dbus-devel
 BuildRequires: dbus-glib-devel
@@ -81,7 +82,8 @@ A gsmloc provider for geoclue
 %prep
 %setup -q
 %patch0 -p1 -b .nm08
-%patch1 -p1 -b .nmCrash
+%patch1 -p1 -b .use-libnm-glib
+%patch2 -p1 -b .unused-var
 
 # Need this for the NM-0.8 patch
 libtoolize
@@ -173,6 +175,9 @@ rm -rf $RPM_BUILD_ROOT
 %{_datadir}/dbus-1/services/org.freedesktop.Geoclue.Providers.Gsmloc.service
 
 %changelog
+* Thu Mar 10 2011 Dan Williams <dcbw at redhat.com> - 0.12.0-5
+- Updated for NetworkManager 0.9
+
 * Tue Feb 08 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.12.0-4
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
 


More information about the scm-commits mailing list