[PATCH] plazes: Use lower-case MAC address

Bastien Nocera hadess at hadess.net
Wed Aug 25 05:42:57 PDT 2010


As the service does not recognise upper-case ones.
---
 providers/plazes/geoclue-plazes.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/providers/plazes/geoclue-plazes.c b/providers/plazes/geoclue-plazes.c
index 1f3ecd3..b0843ff 100644
--- a/providers/plazes/geoclue-plazes.c
+++ b/providers/plazes/geoclue-plazes.c
@@ -102,6 +102,16 @@ geoclue_plazes_set_status (GeocluePlazes *self, GeoclueStatus status)
     }
 }
 
+static char *
+mac_strdown (char *mac)
+{
+	guint i;
+	for (i = 0; mac[i] != '\0' ; i++) {
+		if (g_ascii_isalpha (mac[i]))
+			mac[i] = g_ascii_tolower (mac[i]);
+	}
+	return mac;
+}
 /* Position interface implementation */
 
 static gboolean 
@@ -135,22 +145,23 @@ geoclue_plazes_get_position (GcIfacePosition        *iface,
 		geoclue_plazes_set_status (plazes, GEOCLUE_STATUS_ERROR);
 		return FALSE;
 	}
-	
-    geoclue_plazes_set_status (plazes, GEOCLUE_STATUS_ACQUIRING);
+	mac = mac_strdown (mac);
+
+	geoclue_plazes_set_status (plazes, GEOCLUE_STATUS_ACQUIRING);
 
 	if (!gc_web_service_query (plazes->web_service, error,
-	                           PLAZES_KEY_MAC, mac, 
+	                           PLAZES_KEY_MAC, mac,
 	                           (char *)0)) {
 		g_free (mac);
         // did not get a reply; we can try again later
 		geoclue_plazes_set_status (plazes, GEOCLUE_STATUS_AVAILABLE);
-		g_set_error (error, GEOCLUE_ERROR, 
-		             GEOCLUE_ERROR_NOT_AVAILABLE, 
+		g_set_error (error, GEOCLUE_ERROR,
+		             GEOCLUE_ERROR_NOT_AVAILABLE,
 		             "Did not get reply from server");
 		return FALSE;
 	}
 	g_free (mac);
-	
+
 	if (latitude && gc_web_service_get_double (plazes->web_service, 
 	                                           latitude, PLAZES_LAT_XPATH)) {
 		*fields |= GEOCLUE_POSITION_FIELDS_LATITUDE;
-- 
1.7.0.1


--=-DWbzNuZfOqTCt1FOL8s6--



More information about the GeoClue mailing list