From 02b7ccf7207a77469e16562414eded9068b4809d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 6 Oct 2010 22:35:46 -0600 Subject: Adding in the geoclue lib --- configure.ac | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 74b9e70..4f7ff2e 100644 --- a/configure.ac +++ b/configure.ac @@ -38,12 +38,14 @@ DBUSMENUGTK_REQUIRED_VERSION=0.1.1 GIO_REQUIRED_VERSION=2.25.11 # Note: the GIO check below also ensures the proper glib with gsettings support is present INDICATOR_DISPLAY_OBJECTS=0.1.10 +GEOCLUE_REQUIRED_VERSION=0.12.0 PKG_CHECK_MODULES(INDICATOR, indicator >= $INDICATOR_REQUIRED_VERSION dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS - gio-2.0 >= $GIO_REQUIRED_VERSION) + gio-2.0 >= $GIO_REQUIRED_VERSION + geoclue >= $GEOCLUE_REQUIRED_VERSION) AC_SUBST(INDICATOR_CFLAGS) AC_SUBST(INDICATOR_LIBS) -- cgit v1.2.3 From bbd7c80b46c485e8e40544a5038712cd5b74e125 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 6 Oct 2010 22:51:51 -0600 Subject: Start setting up the connection --- src/datetime-service.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/datetime-service.c b/src/datetime-service.c index d75d4ed..3c922c9 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -30,6 +30,9 @@ with this program. If not, see . #include #include +#include +#include + #include "datetime-interface.h" #include "dbus-shared.h" @@ -46,6 +49,10 @@ static DbusmenuMenuitem * date = NULL; static DbusmenuMenuitem * calendar = NULL; static DbusmenuMenuitem * settings = NULL; +/* Geoclue trackers */ +static GeoclueMasterClient * geo_master = NULL; +static GeoclueAddress * geo_address = NULL; + /* Updates the label in the date menuitem */ static gboolean update_datetime (gpointer user_data) @@ -233,6 +240,15 @@ setup_timer (void) return; } +/* Callback from creating the client */ +static void +geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * path, GError * error, gpointer user_data) +{ + + + return; +} + /* Repsonds to the service object saying it's time to shutdown. It stops the mainloop. */ static void @@ -265,6 +281,10 @@ main (int argc, char ** argv) dbusmenu_server_set_root(server, root); build_menus(root); + /* Setup geoclue */ + GeoclueMaster * master = geoclue_master_get_default(); + geoclue_master_create_client_async(master, geo_create_client, NULL); + /* Setup dbus interface */ dbus = g_object_new(DATETIME_INTERFACE_TYPE, NULL); @@ -277,6 +297,7 @@ main (int argc, char ** argv) mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); + g_object_unref(G_OBJECT(master)); g_object_unref(G_OBJECT(dbus)); g_object_unref(G_OBJECT(service)); g_object_unref(G_OBJECT(server)); -- cgit v1.2.3 From 9e8f668bb0d8187da6d9cae61a702b412170ead2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 6 Oct 2010 22:55:03 -0600 Subject: Create the address link in a callback as well --- src/datetime-service.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/datetime-service.c b/src/datetime-service.c index 3c922c9..b32faa1 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -240,11 +240,22 @@ setup_timer (void) return; } +/* Callback from creating the address */ +static void +geo_create_address (GeoclueMasterClient * master, GeoclueAddress * address, GError * error, gpointer user_data) +{ + geo_address = address; + return; +} + /* Callback from creating the client */ static void geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * path, GError * error, gpointer user_data) { + g_debug("Created Geoclue client at: %s", path); + geo_master = client; + geoclue_master_client_create_address_async(geo_master, geo_create_address, NULL); return; } -- cgit v1.2.3 From a385a3e6dd6dd059f4b7130b513a017dea2ff327 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 6 Oct 2010 23:00:28 -0600 Subject: Setting up a basic address callback --- src/datetime-service.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/datetime-service.c b/src/datetime-service.c index b32faa1..7ab6b63 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -240,11 +240,23 @@ setup_timer (void) return; } +/* Callback from getting the address */ +static void +geo_address_cb (GeoclueAddress * address, int timestamp, GHashTable * addy_data, GeoclueAccuracy * accuracy, GError * error, gpointer user_data) +{ + g_debug("Geoclue timezone is: %s", (gchar *)g_hash_table_lookup(addy_data, "timezone")); + return; +} + /* Callback from creating the address */ static void geo_create_address (GeoclueMasterClient * master, GeoclueAddress * address, GError * error, gpointer user_data) { + g_debug("Created Geoclue Address"); geo_address = address; + + geoclue_address_get_address_async(geo_address, geo_address_cb, NULL); + return; } -- cgit v1.2.3 From 54eacfe376c81914781f367c928bbd14f09b0fb8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 6 Oct 2010 23:02:51 -0600 Subject: Putting in some error catches --- src/datetime-service.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/datetime-service.c b/src/datetime-service.c index 7ab6b63..420148d 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -244,6 +244,11 @@ setup_timer (void) static void geo_address_cb (GeoclueAddress * address, int timestamp, GHashTable * addy_data, GeoclueAccuracy * accuracy, GError * error, gpointer user_data) { + if (error != NULL) { + g_warning("Unable to get Geoclue address: %s", error->message); + return; + } + g_debug("Geoclue timezone is: %s", (gchar *)g_hash_table_lookup(addy_data, "timezone")); return; } @@ -252,6 +257,11 @@ geo_address_cb (GeoclueAddress * address, int timestamp, GHashTable * addy_data, static void geo_create_address (GeoclueMasterClient * master, GeoclueAddress * address, GError * error, gpointer user_data) { + if (error != NULL) { + g_warning("Unable to create GeoClue address: %s", error->message); + return; + } + g_debug("Created Geoclue Address"); geo_address = address; -- cgit v1.2.3 From 2fb4d57632b33592b9ce56563a50a47be2b2544f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 6 Oct 2010 23:08:11 -0600 Subject: Setting up our requirements for providers --- src/datetime-service.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/datetime-service.c b/src/datetime-service.c index 420148d..712bbd6 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -270,6 +270,16 @@ geo_create_address (GeoclueMasterClient * master, GeoclueAddress * address, GErr return; } +/* Callback from setting requirements */ +static void +geo_req_set (GeoclueMasterClient * master, GError * error, gpointer user_data) +{ + if (error != NULL) { + g_warning("Unable to set Geoclue requirements: %s", error->message); + } + return; +} + /* Callback from creating the client */ static void geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * path, GError * error, gpointer user_data) @@ -277,6 +287,10 @@ geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * g_debug("Created Geoclue client at: %s", path); geo_master = client; + + geoclue_master_client_set_requirements_async(geo_master, GEOCLUE_ACCURACY_LEVEL_REGION, 0, + FALSE, GEOCLUE_RESOURCE_ALL, geo_req_set, NULL); + geoclue_master_client_create_address_async(geo_master, geo_create_address, NULL); return; -- cgit v1.2.3 From 90339ca506cda5ee32b15d5273827abbb0fff55b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 7 Oct 2010 09:49:31 -0600 Subject: Make a menuitem for setting a specific timezone --- src/datetime-service.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/datetime-service.c b/src/datetime-service.c index 712bbd6..de17065 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -48,6 +48,7 @@ static DatetimeInterface * dbus = NULL; static DbusmenuMenuitem * date = NULL; static DbusmenuMenuitem * calendar = NULL; static DbusmenuMenuitem * settings = NULL; +static DbusmenuMenuitem * tzchange = NULL; /* Geoclue trackers */ static GeoclueMasterClient * geo_master = NULL; @@ -167,6 +168,11 @@ build_menus (DbusmenuMenuitem * root) dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_append(root, separator); + tzchange = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(tzchange, DBUSMENU_MENUITEM_PROP_LABEL, "Set specific timezone"); + dbusmenu_menuitem_property_set_bool(tzchange, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + dbusmenu_menuitem_child_append(root, tzchange); + settings = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (settings, DBUSMENU_MENUITEM_PROP_LABEL, _("Time & Date Settings...")); /* insensitive until we check for available apps */ -- cgit v1.2.3 From 32c2357c2aa4033d612a52a56767bb375814fdab Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 7 Oct 2010 10:03:23 -0600 Subject: Caching the system timezone so we can compare against it --- src/datetime-service.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/datetime-service.c b/src/datetime-service.c index de17065..0ca4051 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -43,6 +43,7 @@ static GMainLoop * mainloop = NULL; static DbusmenuServer * server = NULL; static DbusmenuMenuitem * root = NULL; static DatetimeInterface * dbus = NULL; +static gchar * current_timezone = NULL; /* Global Items */ static DbusmenuMenuitem * date = NULL; @@ -54,6 +55,38 @@ static DbusmenuMenuitem * tzchange = NULL; static GeoclueMasterClient * geo_master = NULL; static GeoclueAddress * geo_address = NULL; +/* Update the current timezone */ +static void +update_current_timezone (void) { + /* Clear old data */ + if (current_timezone != NULL) { + g_free(current_timezone); + current_timezone = NULL; + } + + GError * error = NULL; + gchar * tempzone = NULL; + if (!g_file_get_contents(TIMEZONE_FILE, &tempzone, NULL, &error)) { + g_warning("Unable to read timezone file '" TIMEZONE_FILE "': %s", error->message); + g_error_free(error); + return; + } + + /* This shouldn't happen, so let's make it a big boom! */ + g_return_if_fail(tempzone != NULL); + + /* Note: this really makes sense as strstrip works in place + so we end up with something a little odd without the dup + so we have the dup to make sure everything is as expected + for everyone else. */ + current_timezone = g_strdup(g_strstrip(tempzone)); + g_free(tempzone); + + g_debug("System timezone is: %s", current_timezone); + + return; +} + /* Updates the label in the date menuitem */ static gboolean update_datetime (gpointer user_data) @@ -328,6 +361,9 @@ main (int argc, char ** argv) bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); textdomain (GETTEXT_PACKAGE); + /* Cache the timezone */ + update_current_timezone(); + /* Building the base menu */ server = dbusmenu_server_new(MENU_OBJ); root = dbusmenu_menuitem_new(); -- cgit v1.2.3 From d929aed8fbc3fc80a51df43f586c5cac122d8bc5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 7 Oct 2010 10:05:40 -0600 Subject: Timezone changed, recache --- src/datetime-service.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/datetime-service.c b/src/datetime-service.c index 0ca4051..dffe002 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -221,6 +221,7 @@ build_menus (DbusmenuMenuitem * root) static void timezone_changed (GFileMonitor * monitor, GFile * file, GFile * otherfile, GFileMonitorEvent event, gpointer user_data) { + update_current_timezone(); datetime_interface_update(DATETIME_INTERFACE(user_data)); update_datetime(NULL); setup_timer(); -- cgit v1.2.3 From a60a4a596ba5acacf766ea63837a6334cb66dbf5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 7 Oct 2010 10:28:49 -0600 Subject: Caching the geoclue timezone --- src/datetime-service.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/datetime-service.c b/src/datetime-service.c index dffe002..7f37ac2 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -54,6 +54,7 @@ static DbusmenuMenuitem * tzchange = NULL; /* Geoclue trackers */ static GeoclueMasterClient * geo_master = NULL; static GeoclueAddress * geo_address = NULL; +static gchar * geo_timezone = NULL; /* Update the current timezone */ static void @@ -290,6 +291,17 @@ geo_address_cb (GeoclueAddress * address, int timestamp, GHashTable * addy_data, } g_debug("Geoclue timezone is: %s", (gchar *)g_hash_table_lookup(addy_data, "timezone")); + + if (geo_timezone != NULL) { + g_free(geo_timezone); + geo_timezone = NULL; + } + + gpointer tz_hash = g_hash_table_lookup(addy_data, "timezone"); + if (tz_hash != NULL) { + geo_timezone = g_strdup((gchar *)tz_hash); + } + return; } -- cgit v1.2.3 From 27bd0190002c6facbd662c19ffb4be5b1d995441 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 7 Oct 2010 14:11:36 -0600 Subject: Create a way for to see if the timezones are the same. --- src/datetime-service.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/datetime-service.c b/src/datetime-service.c index 7f37ac2..e821dfc 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -56,6 +56,39 @@ static GeoclueMasterClient * geo_master = NULL; static GeoclueAddress * geo_address = NULL; static gchar * geo_timezone = NULL; +/* Check to see if our timezones are the same */ +static void +check_timezone_sync (void) { + gboolean in_sync = FALSE; + + if (geo_timezone == NULL) { + in_sync = TRUE; + } + + if (current_timezone == NULL) { + in_sync = TRUE; + } + + if (!in_sync && g_strcmp0(geo_timezone, current_timezone) == 0) { + in_sync = TRUE; + } + + if (in_sync) { + g_debug("Timezones in sync"); + dbusmenu_menuitem_property_set_bool(tzchange, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + } else { + g_debug("Timezones are different"); + gchar * label = g_strdup_printf(_("Change timezone to: %s"), geo_timezone); + + dbusmenu_menuitem_property_set(tzchange, DBUSMENU_MENUITEM_PROP_LABEL, label); + dbusmenu_menuitem_property_set_bool(tzchange, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + + g_free(label); + } + + return; +} + /* Update the current timezone */ static void update_current_timezone (void) { @@ -85,6 +118,8 @@ update_current_timezone (void) { g_debug("System timezone is: %s", current_timezone); + check_timezone_sync(); + return; } @@ -302,6 +337,8 @@ geo_address_cb (GeoclueAddress * address, int timestamp, GHashTable * addy_data, geo_timezone = g_strdup((gchar *)tz_hash); } + check_timezone_sync(); + return; } -- cgit v1.2.3 From ab293db1e9f909b47b867f86ea2c222ad343c497 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 7 Oct 2010 14:15:03 -0600 Subject: Make it so that we don't hcange the menuitem if we don't have one, but also, after it's built check it's state. --- src/datetime-service.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/datetime-service.c b/src/datetime-service.c index e821dfc..c24b223 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -75,15 +75,21 @@ check_timezone_sync (void) { if (in_sync) { g_debug("Timezones in sync"); - dbusmenu_menuitem_property_set_bool(tzchange, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); } else { g_debug("Timezones are different"); - gchar * label = g_strdup_printf(_("Change timezone to: %s"), geo_timezone); + } + + if (tzchange != NULL) { + if (in_sync) { + dbusmenu_menuitem_property_set_bool(tzchange, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + } else { + gchar * label = g_strdup_printf(_("Change timezone to: %s"), geo_timezone); - dbusmenu_menuitem_property_set(tzchange, DBUSMENU_MENUITEM_PROP_LABEL, label); - dbusmenu_menuitem_property_set_bool(tzchange, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + dbusmenu_menuitem_property_set(tzchange, DBUSMENU_MENUITEM_PROP_LABEL, label); + dbusmenu_menuitem_property_set_bool(tzchange, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - g_free(label); + g_free(label); + } } return; @@ -241,6 +247,7 @@ build_menus (DbusmenuMenuitem * root) dbusmenu_menuitem_property_set(tzchange, DBUSMENU_MENUITEM_PROP_LABEL, "Set specific timezone"); dbusmenu_menuitem_property_set_bool(tzchange, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); dbusmenu_menuitem_child_append(root, tzchange); + check_timezone_sync(); settings = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (settings, DBUSMENU_MENUITEM_PROP_LABEL, _("Time & Date Settings...")); -- cgit v1.2.3 From 4fff55e013d9ed5ba0dba12abe1a7f0f53c18547 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 7 Oct 2010 15:15:08 -0600 Subject: Adding in OOBS support --- configure.ac | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4f7ff2e..d75e574 100644 --- a/configure.ac +++ b/configure.ac @@ -39,13 +39,15 @@ GIO_REQUIRED_VERSION=2.25.11 # Note: the GIO check below also ensures the proper glib with gsettings support is present INDICATOR_DISPLAY_OBJECTS=0.1.10 GEOCLUE_REQUIRED_VERSION=0.12.0 +OOBS_REQUIRED_VERSION=2.31.0 PKG_CHECK_MODULES(INDICATOR, indicator >= $INDICATOR_REQUIRED_VERSION dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS gio-2.0 >= $GIO_REQUIRED_VERSION - geoclue >= $GEOCLUE_REQUIRED_VERSION) + geoclue >= $GEOCLUE_REQUIRED_VERSION + liboobs-1 >= $OOBS_REQUIRED_VERSION) AC_SUBST(INDICATOR_CFLAGS) AC_SUBST(INDICATOR_LIBS) -- cgit v1.2.3 From 30be9336b690e1d8b221ac9f03387ce39aa687b3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 7 Oct 2010 15:17:35 -0600 Subject: Setting up a callback for clicking ot set the timezone --- src/datetime-service.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/datetime-service.c b/src/datetime-service.c index c24b223..fb8a862 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -129,6 +129,14 @@ update_current_timezone (void) { return; } +/* Set the timezone to the Geoclue discovered one */ +static void +quick_set_tz (DbusmenuMenuitem * menuitem, guint timestamp, const gchar *command) +{ + + +} + /* Updates the label in the date menuitem */ static gboolean update_datetime (gpointer user_data) @@ -246,6 +254,7 @@ build_menus (DbusmenuMenuitem * root) tzchange = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(tzchange, DBUSMENU_MENUITEM_PROP_LABEL, "Set specific timezone"); dbusmenu_menuitem_property_set_bool(tzchange, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + g_signal_connect(G_OBJECT(tzchange), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL); dbusmenu_menuitem_child_append(root, tzchange); check_timezone_sync(); -- cgit v1.2.3 From 62f947b4b613cd6ee0a5d296eeefc488b4ba0ae6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 7 Oct 2010 15:20:58 -0600 Subject: Setting the geoclue timezone quickly --- src/datetime-service.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/datetime-service.c b/src/datetime-service.c index fb8a862..60fa7eb 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -33,6 +33,8 @@ with this program. If not, see . #include #include +#include + #include "datetime-interface.h" #include "dbus-shared.h" @@ -133,8 +135,10 @@ update_current_timezone (void) { static void quick_set_tz (DbusmenuMenuitem * menuitem, guint timestamp, const gchar *command) { - - + OobsTimeConfig * timeconfig = OOBS_TIME_CONFIG(oobs_time_config_get()); + oobs_time_config_set_timezone(timeconfig, geo_timezone); + g_object_unref(G_OBJECT(timeconfig)); + return; } /* Updates the label in the date menuitem */ -- cgit v1.2.3 From 95d2587e7467162a9382b600f0ea1912690c7082 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 7 Oct 2010 15:41:02 -0600 Subject: Make a little more robust and actually commit our results. --- src/datetime-service.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/datetime-service.c b/src/datetime-service.c index 60fa7eb..b4a1135 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -131,13 +131,34 @@ update_current_timezone (void) { return; } +/* See how our timezone setting went */ +static void +quick_set_tz_cb (OobsObject * obj, OobsResult result, gpointer user_data) +{ + if (result == OOBS_RESULT_OK) { + g_debug("Timezone set"); + } else { + g_warning("Unable to quick set timezone"); + } + return; +} + /* Set the timezone to the Geoclue discovered one */ static void quick_set_tz (DbusmenuMenuitem * menuitem, guint timestamp, const gchar *command) { - OobsTimeConfig * timeconfig = OOBS_TIME_CONFIG(oobs_time_config_get()); + g_debug("Quick setting timezone to: %s", geo_timezone); + + g_return_if_fail(geo_timezone != NULL); + + OobsObject * obj = oobs_time_config_get(); + g_return_if_fail(obj != NULL); + + OobsTimeConfig * timeconfig = OOBS_TIME_CONFIG(obj); oobs_time_config_set_timezone(timeconfig, geo_timezone); - g_object_unref(G_OBJECT(timeconfig)); + + oobs_object_commit_async(obj, quick_set_tz_cb, NULL); + return; } -- cgit v1.2.3 From d2886daf97d85423d458830ec57c4024712b0b32 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 21 Oct 2010 17:36:01 -0400 Subject: Whitespace --- src/datetime-service.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/datetime-service.c b/src/datetime-service.c index b4a1135..4eee211 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -418,8 +418,13 @@ geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * geo_master = client; - geoclue_master_client_set_requirements_async(geo_master, GEOCLUE_ACCURACY_LEVEL_REGION, 0, - FALSE, GEOCLUE_RESOURCE_ALL, geo_req_set, NULL); + geoclue_master_client_set_requirements_async(geo_master, + GEOCLUE_ACCURACY_LEVEL_REGION, + 0, + FALSE, + GEOCLUE_RESOURCE_ALL, + geo_req_set, + NULL); geoclue_master_client_create_address_async(geo_master, geo_create_address, NULL); -- cgit v1.2.3 From cc5d5780cb01c1ceebc1da10f1329b16eab27749 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 22 Oct 2010 09:12:20 -0400 Subject: Setting up callbacks for the signals off of the clients --- src/datetime-service.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/datetime-service.c b/src/datetime-service.c index 4eee211..7148c69 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -410,6 +410,23 @@ geo_req_set (GeoclueMasterClient * master, GError * error, gpointer user_data) return; } +/* Client is killing itself rather oddly */ +static void +geo_client_invalid (GeoclueMasterClient * client, gpointer user_data) +{ + + return; +} + +/* Address provider changed, we need to get that one */ +static void +geo_address_change (GeoclueMasterClient * client, gchar * a, gchar * b, gchar * c, gchar * d, gpointer user_data) +{ + + + return; +} + /* Callback from creating the client */ static void geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * path, GError * error, gpointer user_data) @@ -428,6 +445,9 @@ geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * geoclue_master_client_create_address_async(geo_master, geo_create_address, NULL); + g_signal_connect(G_OBJECT(client), "invalidated", G_CALLBACK(geo_client_invalid), NULL); + g_signal_connect(G_OBJECT(client), "address-provider-changed", G_CALLBACK(geo_address_change), NULL); + return; } -- cgit v1.2.3 From 1fdf38754c8f332a5b2e385b8f9d781e8669cf72 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 22 Oct 2010 09:22:00 -0400 Subject: Filling out the changing callbacks --- src/datetime-service.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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 . #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, -- cgit v1.2.3 From 1149b84d2b7b8c22f27f8acc507ed8af7342345f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 22 Oct 2010 09:31:37 -0400 Subject: Setting up a callback for the address changing. --- src/datetime-service.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/datetime-service.c b/src/datetime-service.c index 70c37cd..8a31940 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -399,6 +399,8 @@ geo_create_address (GeoclueMasterClient * master, GeoclueAddress * address, GErr geoclue_address_get_address_async(geo_address, geo_address_cb, NULL); + g_signal_connect(G_OBJECT(address), "address-changed", G_CALLBACK(geo_address_cb), NULL); + return; } -- cgit v1.2.3