Commit 3b1a7f57 authored by Jussi Kukkonen's avatar Jussi Kukkonen

fixes for localnet provider

parent c71f945e
...@@ -83,7 +83,7 @@ AC_SUBST(CONNECTIVITY_LIBS) ...@@ -83,7 +83,7 @@ AC_SUBST(CONNECTIVITY_LIBS)
AC_SUBST(CONNECTIVITY_CFLAGS) AC_SUBST(CONNECTIVITY_CFLAGS)
PROVIDER_SUBDIRS="example hostip geonames manual plazes" PROVIDER_SUBDIRS="example hostip geonames manual plazes localnet"
PKG_CHECK_MODULES(GYPSY, [ PKG_CHECK_MODULES(GYPSY, [
gypsy gypsy
...@@ -120,6 +120,7 @@ providers/hostip/Makefile ...@@ -120,6 +120,7 @@ providers/hostip/Makefile
providers/geonames/Makefile providers/geonames/Makefile
providers/manual/Makefile providers/manual/Makefile
providers/plazes/Makefile providers/plazes/Makefile
providers/localnet/Makefile
src/Makefile src/Makefile
]) ])
......
...@@ -133,6 +133,8 @@ get_mac_address () ...@@ -133,6 +133,8 @@ get_mac_address ()
pclose (in); pclose (in);
return NULL; return NULL;
} }
pclose (in); pclose (in);
return mac; return mac;
} }
...@@ -162,12 +164,12 @@ geoclue_localnet_read_keyfile (GeoclueLocalnet *localnet, char *filename) ...@@ -162,12 +164,12 @@ geoclue_localnet_read_keyfile (GeoclueLocalnet *localnet, char *filename)
GKeyFile *keyfile; GKeyFile *keyfile;
char **groups; char **groups;
char **g; char **g;
GError *error; GError *error = NULL;
keyfile = g_key_file_new (); keyfile = g_key_file_new ();
if (!g_key_file_load_from_file (keyfile, filename, if (!g_key_file_load_from_file (keyfile, filename,
G_KEY_FILE_NONE, &error)) { G_KEY_FILE_NONE, &error)) {
g_warning ("Error loading keyfile %s", filename); g_error ("Error loading keyfile %s: %s", filename, error->message);
g_error_free (error); g_error_free (error);
return FALSE; return FALSE;
} }
...@@ -182,18 +184,28 @@ geoclue_localnet_read_keyfile (GeoclueLocalnet *localnet, char *filename) ...@@ -182,18 +184,28 @@ geoclue_localnet_read_keyfile (GeoclueLocalnet *localnet, char *filename)
gateway->mac = *g; gateway->mac = *g;
gateway->address = address_details_new (); gateway->address = address_details_new ();
/* read all keys in the group as address fields */
keys = g_key_file_get_keys (keyfile, *g, keys = g_key_file_get_keys (keyfile, *g,
NULL, NULL); NULL, &error);
if (error) {
g_warning ("Could not load keys for group %s from %s: %s",
*g, filename, error->message);
g_error_free (error);
error = NULL;
}
k = keys; k = keys;
while (*k) { while (*k) {
char *value; char *value;
/*TODO error checks */
value = g_key_file_get_string (keyfile, *g, *k, NULL); value = g_key_file_get_string (keyfile, *g, *k, NULL);
g_hash_table_insert (gateway->address, *k, value); g_hash_table_insert (gateway->address,
*k, g_ascii_strup (value, -1));
g_free (value);
k++; k++;
} }
g_free (keys);
gateway->accuracy = gateway->accuracy =
geoclue_accuracy_new (get_accuracy_for_address (gateway->address), 0, 0); geoclue_accuracy_new (get_accuracy_for_address (gateway->address), 0, 0);
...@@ -202,6 +214,9 @@ geoclue_localnet_read_keyfile (GeoclueLocalnet *localnet, char *filename) ...@@ -202,6 +214,9 @@ geoclue_localnet_read_keyfile (GeoclueLocalnet *localnet, char *filename)
g++; g++;
} }
g_free (groups);
g_key_file_free (keyfile);
return TRUE; return TRUE;
} }
......
...@@ -107,7 +107,7 @@ get_accuracy_for_address (GHashTable *address) ...@@ -107,7 +107,7 @@ get_accuracy_for_address (GHashTable *address)
g_hash_table_lookup (address, GEOCLUE_ADDRESS_KEY_COUNTRYCODE)) { g_hash_table_lookup (address, GEOCLUE_ADDRESS_KEY_COUNTRYCODE)) {
return GEOCLUE_ACCURACY_LEVEL_COUNTRY; return GEOCLUE_ACCURACY_LEVEL_COUNTRY;
} }
return GEOCLUE_ACCURACY_LEVEL_STREET; return GEOCLUE_ACCURACY_LEVEL_NONE;
} }
static gboolean static gboolean
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment