diff options
author | Ted Gould <ted@gould.cx> | 2010-10-22 09:22:00 -0400 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-10-22 09:22:00 -0400 |
commit | 1fdf38754c8f332a5b2e385b8f9d781e8669cf72 (patch) | |
tree | 7d7f529f26610cc4db7ff29cc20d258552985aae /src/datetime-service.c | |
parent | cc5d5780cb01c1ceebc1da10f1329b16eab27749 (diff) | |
download | ayatana-indicator-datetime-1fdf38754c8f332a5b2e385b8f9d781e8669cf72.tar.gz ayatana-indicator-datetime-1fdf38754c8f332a5b2e385b8f9d781e8669cf72.tar.bz2 ayatana-indicator-datetime-1fdf38754c8f332a5b2e385b8f9d781e8669cf72.zip |
Filling out the changing callbacks
Diffstat (limited to 'src/datetime-service.c')
-rw-r--r-- | src/datetime-service.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/datetime-service.c b/src/datetime-service.c index 7148c69..70c37cd 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -38,6 +38,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "datetime-interface.h" #include "dbus-shared.h" +static void geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * path, GError * error, gpointer user_data); static void setup_timer (void); static IndicatorService * service = NULL; @@ -394,6 +395,7 @@ geo_create_address (GeoclueMasterClient * master, GeoclueAddress * address, GErr g_debug("Created Geoclue Address"); geo_address = address; + g_object_ref(G_OBJECT(geo_address)); geoclue_address_get_address_async(geo_address, geo_address_cb, NULL); @@ -414,6 +416,22 @@ geo_req_set (GeoclueMasterClient * master, GError * error, gpointer user_data) static void geo_client_invalid (GeoclueMasterClient * client, gpointer user_data) { + g_warning("Master client invalid, rebuilding."); + + if (geo_master != NULL) { + g_object_unref(G_OBJECT(geo_master)); + } + geo_master = NULL; + + GeoclueMaster * master = geoclue_master_get_default(); + geoclue_master_create_client_async(master, geo_create_client, NULL); + + if (geo_timezone != NULL) { + g_free(geo_timezone); + geo_timezone = NULL; + } + + check_timezone_sync(); return; } @@ -422,7 +440,21 @@ geo_client_invalid (GeoclueMasterClient * client, gpointer user_data) static void geo_address_change (GeoclueMasterClient * client, gchar * a, gchar * b, gchar * c, gchar * d, gpointer user_data) { + g_warning("Address provider changed. Let's change"); + + if (geo_address != NULL) { + g_object_unref(G_OBJECT(geo_address)); + } + geo_address = NULL; + geoclue_master_client_create_address_async(geo_master, geo_create_address, NULL); + + if (geo_timezone != NULL) { + g_free(geo_timezone); + geo_timezone = NULL; + } + + check_timezone_sync(); return; } @@ -434,6 +466,7 @@ geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * g_debug("Created Geoclue client at: %s", path); geo_master = client; + g_object_ref(G_OBJECT(geo_master)); geoclue_master_client_set_requirements_async(geo_master, GEOCLUE_ACCURACY_LEVEL_REGION, |