diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2013-05-06 14:57:00 -0700 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2013-05-06 14:57:00 -0700 |
commit | 76422d4997401b8f278b7316a23a324655c12c92 (patch) | |
tree | 89ed21a2688bbcec5647960c23d6e5ecb683bb66 /src | |
parent | 5d8b176ab3c072faa259bfc3de2b8de103437463 (diff) | |
download | ayatana-indicator-datetime-76422d4997401b8f278b7316a23a324655c12c92.tar.gz ayatana-indicator-datetime-76422d4997401b8f278b7316a23a324655c12c92.tar.bz2 ayatana-indicator-datetime-76422d4997401b8f278b7316a23a324655c12c92.zip |
rename the 'DatetimeLocation' classes to the more accurate name 'DatetimeTimezone'
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 12 | ||||
-rw-r--r-- | src/datetime-service.c | 18 | ||||
-rw-r--r-- | src/location-file.h | 61 | ||||
-rw-r--r-- | src/location-geoclue.h | 61 | ||||
-rw-r--r-- | src/location.h | 68 | ||||
-rw-r--r-- | src/timezone-file.c (renamed from src/location-file.c) | 58 | ||||
-rw-r--r-- | src/timezone-file.h | 61 | ||||
-rw-r--r-- | src/timezone-geoclue.c (renamed from src/location-geoclue.c) | 64 | ||||
-rw-r--r-- | src/timezone-geoclue.h | 61 | ||||
-rw-r--r-- | src/timezone.c (renamed from src/location.c) | 26 | ||||
-rw-r--r-- | src/timezone.h | 68 |
11 files changed, 279 insertions, 279 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 2efff8f..67b085a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,12 +11,12 @@ indicator_datetime_service_SOURCES = \ datetime-interface.h \ gen-datetime-service.xml.c \ datetime-service.c \ - location.c \ - location.h \ - location-file.c \ - location-file.h \ - location-geoclue.c \ - location-geoclue.h \ + timezone.c \ + timezone.h \ + timezone-file.c \ + timezone-file.h \ + timezone-geoclue.c \ + timezone-geoclue.h \ utils.c \ utils.h \ dbus-shared.h \ diff --git a/src/datetime-service.c b/src/datetime-service.c index 35a5e53..0551068 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -45,9 +45,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "datetime-interface.h" #include "dbus-shared.h" -#include "location-file.h" -#include "location-geoclue.h" #include "settings-shared.h" +#include "timezone-file.h" +#include "timezone-geoclue.h" #include "utils.h" /* how often to check for clock skew */ @@ -91,8 +91,8 @@ static time_t start_time_appointments = (time_t) 0; static GSettings * conf = NULL; static ESourceRegistry * source_registry = NULL; static GList * appointment_sources = NULL; -static IndicatorDatetimeLocation * geo_location = NULL; -static IndicatorDatetimeLocation * tz_file = NULL; +static IndicatorDatetimeTimezone * geo_location = NULL; +static IndicatorDatetimeTimezone * tz_file = NULL; struct comp_instance { ECalComponent *comp; @@ -184,7 +184,7 @@ update_location_menu_items (void) /* maybe add geo_timezone */ if (geo_location != NULL) { - const char * geo_timezone = indicator_datetime_location_get_timezone (geo_location); + const char * geo_timezone = indicator_datetime_timezone_get_timezone (geo_location); if (geo_timezone && *geo_timezone) { const gboolean visible = g_settings_get_boolean (conf, SETTINGS_SHOW_DETECTED_S); gchar * name = get_current_zone_name (geo_timezone); @@ -195,7 +195,7 @@ update_location_menu_items (void) /* maybe add current_timezone */ if (tz_file != NULL) { - const char * tz = indicator_datetime_location_get_timezone (tz_file); + const char * tz = indicator_datetime_timezone_get_timezone (tz_file); if (tz && *tz) { const gboolean visible = g_settings_get_boolean (conf, SETTINGS_SHOW_DETECTED_S); gchar * name = get_current_zone_name (tz); @@ -704,7 +704,7 @@ update_appointment_menu_items (gpointer user_data __attribute__ ((unused))) g_list_free_full (comp_instances, (GDestroyNotify)comp_instance_free); comp_instances = NULL; - current_timezone = indicator_datetime_location_get_timezone (tz_file); + current_timezone = indicator_datetime_timezone_get_timezone (tz_file); // Generate instances for all sources for (s=appointment_sources; s!=NULL; s=s->next) { @@ -1233,7 +1233,7 @@ on_use_geoclue_changed_cb (GSettings *settings, } else if (use_geoclue && !geo_location) { - geo_location = indicator_datetime_location_geoclue_new (); + geo_location = indicator_datetime_timezone_geoclue_new (); g_signal_connect (geo_location, "notify::timezone", G_CALLBACK(update_location_menu_items), NULL); } @@ -1291,7 +1291,7 @@ main (int argc, char ** argv) dbus = g_object_new(DATETIME_INTERFACE_TYPE, NULL); /* Setup timezone watch */ - tz_file = indicator_datetime_location_file_new (TIMEZONE_FILE); + tz_file = indicator_datetime_timezone_file_new (TIMEZONE_FILE); g_signal_connect (tz_file, "notify::timezone", G_CALLBACK(on_timezone_changed), NULL); /* Set up the day timer */ diff --git a/src/location-file.h b/src/location-file.h deleted file mode 100644 index 8ed87ad..0000000 --- a/src/location-file.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * Authors: - * Charles Kerr <charles.kerr@canonical.com> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3, as published - * by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __INDICATOR_DATETIME_LOCATION_FILE__H__ -#define __INDICATOR_DATETIME_LOCATION_FILE__H__ - -#include <glib.h> -#include <glib-object.h> - -#include "location.h" /* parent class */ - -G_BEGIN_DECLS - -#define INDICATOR_TYPE_DATETIME_LOCATION_FILE (indicator_datetime_location_file_get_type()) -#define INDICATOR_DATETIME_LOCATION_FILE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), INDICATOR_TYPE_DATETIME_LOCATION_FILE, IndicatorDatetimeLocationFile)) -#define INDICATOR_DATETIME_LOCATION_FILE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), INDICATOR_TYPE_DATETIME_LOCATION_FILE, IndicatorDatetimeLocationFileClass)) -#define INDICATOR_IS_DATETIME_LOCATION_FILE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), INDICATOR_TYPE_DATETIME_LOCATION_FILE)) - -typedef struct _IndicatorDatetimeLocationFile IndicatorDatetimeLocationFile; -typedef struct _IndicatorDatetimeLocationFilePriv IndicatorDatetimeLocationFilePriv; -typedef struct _IndicatorDatetimeLocationFileClass IndicatorDatetimeLocationFileClass; - -GType indicator_datetime_location_file_get_type (void); - -/** - * An implementation of IndicatorDatetimeLocation which determines the timezone - * from monitoring a local file, such as /etc/timezone - */ -struct _IndicatorDatetimeLocationFile -{ - /*< private >*/ - IndicatorDatetimeLocation parent; - IndicatorDatetimeLocationFilePriv * priv; -}; - -struct _IndicatorDatetimeLocationFileClass -{ - IndicatorDatetimeLocationClass parent_class; -}; - -IndicatorDatetimeLocation * indicator_datetime_location_file_new (const char * filename); - -G_END_DECLS - -#endif /* __INDICATOR_DATETIME_LOCATION_FILE__H__ */ diff --git a/src/location-geoclue.h b/src/location-geoclue.h deleted file mode 100644 index 5b6d232..0000000 --- a/src/location-geoclue.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * Authors: - * Charles Kerr <charles.kerr@canonical.com> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3, as published - * by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __INDICATOR_DATETIME_LOCATION_GEOCLUE__H__ -#define __INDICATOR_DATETIME_LOCATION_GEOCLUE__H__ - -#include <glib.h> -#include <glib-object.h> - -#include "location.h" /* parent class */ - -G_BEGIN_DECLS - -#define INDICATOR_TYPE_DATETIME_LOCATION_GEOCLUE (indicator_datetime_location_geoclue_get_type()) -#define INDICATOR_DATETIME_LOCATION_GEOCLUE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), INDICATOR_TYPE_DATETIME_LOCATION_GEOCLUE, IndicatorDatetimeLocationGeoclue)) -#define INDICATOR_DATETIME_LOCATION_GEOCLUE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), INDICATOR_TYPE_DATETIME_LOCATION_GEOCLUE, IndicatorDatetimeLocationGeoclueClass)) -#define INDICATOR_IS_DATETIME_LOCATION_GEOCLUE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), INDICATOR_TYPE_DATETIME_LOCATION_GEOCLUE)) - -typedef struct _IndicatorDatetimeLocationGeoclue IndicatorDatetimeLocationGeoclue; -typedef struct _IndicatorDatetimeLocationGeocluePriv IndicatorDatetimeLocationGeocluePriv; -typedef struct _IndicatorDatetimeLocationGeoclueClass IndicatorDatetimeLocationGeoclueClass; - -GType indicator_datetime_location_geoclue_get_type (void); - -/** - * An implementation of IndicatorDatetimeLocation which determines the timezone - * from calling a GeoClue service over DBus. - */ -struct _IndicatorDatetimeLocationGeoclue -{ - /*< private >*/ - IndicatorDatetimeLocation parent; - IndicatorDatetimeLocationGeocluePriv * priv; -}; - -struct _IndicatorDatetimeLocationGeoclueClass -{ - IndicatorDatetimeLocationClass parent_class; -}; - -IndicatorDatetimeLocation * indicator_datetime_location_geoclue_new (void); - -G_END_DECLS - -#endif /* __INDICATOR_DATETIME_LOCATION_GEOCLUE__H__ */ diff --git a/src/location.h b/src/location.h deleted file mode 100644 index f9fd2ce..0000000 --- a/src/location.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * Authors: - * Charles Kerr <charles.kerr@canonical.com> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3, as published - * by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __INDICATOR_DATETIME_LOCATION__H__ -#define __INDICATOR_DATETIME_LOCATION__H__ - -#include <glib.h> -#include <glib-object.h> - -G_BEGIN_DECLS - -#define INDICATOR_TYPE_DATETIME_LOCATION (indicator_datetime_location_get_type()) -#define INDICATOR_DATETIME_LOCATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), INDICATOR_TYPE_DATETIME_LOCATION, IndicatorDatetimeLocation)) -#define INDICATOR_DATETIME_LOCATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), INDICATOR_TYPE_DATETIME_LOCATION, IndicatorDatetimeLocationClass)) -#define INDICATOR_DATETIME_LOCATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), INDICATOR_TYPE_DATETIME_LOCATION, IndicatorDatetimeLocationClass)) -#define INDICATOR_IS_DATETIME_LOCATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), INDICATOR_TYPE_DATETIME_LOCATION)) - -typedef struct _IndicatorDatetimeLocation IndicatorDatetimeLocation; -typedef struct _IndicatorDatetimeLocationClass IndicatorDatetimeLocationClass; - -GType indicator_datetime_location_get_type (void); - -/** - * Abstract Base Class for the mechanisms that determine timezone by location - */ -struct _IndicatorDatetimeLocation -{ - /*< private >*/ - GObject parent; -}; - -struct _IndicatorDatetimeLocationClass -{ - GObjectClass parent_class; - - /* virtual functions */ - const char * (*get_timezone) (IndicatorDatetimeLocation * self); -}; - -/*** -**** -***/ - -#define INDICATOR_DATETIME_LOCATION_PROPERTY_TIMEZONE "timezone" - -const char * indicator_datetime_location_get_timezone (IndicatorDatetimeLocation *); - -void indicator_datetime_location_notify_timezone (IndicatorDatetimeLocation *); - -G_END_DECLS - -#endif /* __INDICATOR_DATETIME_LOCATION__H__ */ diff --git a/src/location-file.c b/src/timezone-file.c index ff6fd47..c7c2cf6 100644 --- a/src/location-file.c +++ b/src/timezone-file.c @@ -23,7 +23,7 @@ #include <glib/gi18n-lib.h> #include <gio/gio.h> -#include "location-file.h" +#include "timezone-file.h" enum { @@ -34,7 +34,7 @@ enum static GParamSpec * properties[PROP_LAST] = { 0 }; -struct _IndicatorDatetimeLocationFilePriv +struct _IndicatorDatetimeTimezoneFilePriv { gchar * filename; GFile * file; @@ -42,18 +42,18 @@ struct _IndicatorDatetimeLocationFilePriv gchar * timezone; }; -typedef IndicatorDatetimeLocationFilePriv priv_t; +typedef IndicatorDatetimeTimezoneFilePriv priv_t; -G_DEFINE_TYPE (IndicatorDatetimeLocationFile, - indicator_datetime_location_file, - INDICATOR_TYPE_DATETIME_LOCATION) +G_DEFINE_TYPE (IndicatorDatetimeTimezoneFile, + indicator_datetime_timezone_file, + INDICATOR_TYPE_DATETIME_TIMEZONE) /*** **** ***/ static void -reload (IndicatorDatetimeLocationFile * self) +reload (IndicatorDatetimeTimezoneFile * self) { priv_t * p = self->priv; @@ -70,12 +70,12 @@ reload (IndicatorDatetimeLocationFile * self) g_strstrip (new_timezone); g_free (p->timezone); p->timezone = new_timezone; - indicator_datetime_location_notify_timezone (INDICATOR_DATETIME_LOCATION(self)); + indicator_datetime_timezone_notify_timezone (INDICATOR_DATETIME_TIMEZONE(self)); } } static void -set_filename (IndicatorDatetimeLocationFile * self, const char * filename) +set_filename (IndicatorDatetimeTimezoneFile * self, const char * filename) { GError * err; priv_t * p = self->priv; @@ -104,13 +104,13 @@ set_filename (IndicatorDatetimeLocationFile * self, const char * filename) } /*** -**** IndicatorDatetimeLocationClass funcs +**** IndicatorDatetimeTimezoneClass funcs ***/ static const char * -my_get_timezone (IndicatorDatetimeLocation * self) +my_get_timezone (IndicatorDatetimeTimezone * self) { - return INDICATOR_DATETIME_LOCATION_FILE(self)->priv->timezone; + return INDICATOR_DATETIME_TIMEZONE_FILE(self)->priv->timezone; } /*** @@ -123,7 +123,7 @@ my_get_property (GObject * o, GValue * value, GParamSpec * pspec) { - IndicatorDatetimeLocationFile * self = INDICATOR_DATETIME_LOCATION_FILE (o); + IndicatorDatetimeTimezoneFile * self = INDICATOR_DATETIME_TIMEZONE_FILE (o); switch (property_id) { @@ -142,7 +142,7 @@ my_set_property (GObject * o, const GValue * value, GParamSpec * pspec) { - IndicatorDatetimeLocationFile * self = INDICATOR_DATETIME_LOCATION_FILE (o); + IndicatorDatetimeTimezoneFile * self = INDICATOR_DATETIME_TIMEZONE_FILE (o); switch (property_id) { @@ -158,25 +158,25 @@ my_set_property (GObject * o, static void my_dispose (GObject * o) { - IndicatorDatetimeLocationFile * self = INDICATOR_DATETIME_LOCATION_FILE (o); + IndicatorDatetimeTimezoneFile * self = INDICATOR_DATETIME_TIMEZONE_FILE (o); priv_t * p = self->priv; g_clear_object (&p->monitor); g_clear_object (&p->file); - G_OBJECT_CLASS (indicator_datetime_location_file_parent_class)->dispose (o); + G_OBJECT_CLASS (indicator_datetime_timezone_file_parent_class)->dispose (o); } static void my_finalize (GObject * o) { - IndicatorDatetimeLocationFile * self = INDICATOR_DATETIME_LOCATION_FILE (o); + IndicatorDatetimeTimezoneFile * self = INDICATOR_DATETIME_TIMEZONE_FILE (o); priv_t * p = self->priv; g_free (p->filename); g_free (p->timezone); - G_OBJECT_CLASS (indicator_datetime_location_file_parent_class)->finalize (o); + G_OBJECT_CLASS (indicator_datetime_timezone_file_parent_class)->finalize (o); } /*** @@ -184,10 +184,10 @@ my_finalize (GObject * o) ***/ static void -indicator_datetime_location_file_class_init (IndicatorDatetimeLocationFileClass * klass) +indicator_datetime_timezone_file_class_init (IndicatorDatetimeTimezoneFileClass * klass) { GObjectClass * object_class; - IndicatorDatetimeLocationClass * location_class; + IndicatorDatetimeTimezoneClass * location_class; const GParamFlags flags = G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS; object_class = G_OBJECT_CLASS (klass); @@ -196,10 +196,10 @@ indicator_datetime_location_file_class_init (IndicatorDatetimeLocationFileClass object_class->set_property = my_set_property; object_class->get_property = my_get_property; - location_class = INDICATOR_DATETIME_LOCATION_CLASS (klass); + location_class = INDICATOR_DATETIME_TIMEZONE_CLASS (klass); location_class->get_timezone = my_get_timezone; - g_type_class_add_private (klass, sizeof (IndicatorDatetimeLocationFilePriv)); + g_type_class_add_private (klass, sizeof (IndicatorDatetimeTimezoneFilePriv)); /* install properties */ @@ -215,21 +215,21 @@ indicator_datetime_location_file_class_init (IndicatorDatetimeLocationFileClass } static void -indicator_datetime_location_file_init (IndicatorDatetimeLocationFile * self) +indicator_datetime_timezone_file_init (IndicatorDatetimeTimezoneFile * self) { self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - INDICATOR_TYPE_DATETIME_LOCATION_FILE, - IndicatorDatetimeLocationFilePriv); + INDICATOR_TYPE_DATETIME_TIMEZONE_FILE, + IndicatorDatetimeTimezoneFilePriv); } /*** **** Public ***/ -IndicatorDatetimeLocation * -indicator_datetime_location_file_new (const char * filename) +IndicatorDatetimeTimezone * +indicator_datetime_timezone_file_new (const char * filename) { - gpointer o = g_object_new (INDICATOR_TYPE_DATETIME_LOCATION_FILE, "filename", filename, NULL); + gpointer o = g_object_new (INDICATOR_TYPE_DATETIME_TIMEZONE_FILE, "filename", filename, NULL); - return INDICATOR_DATETIME_LOCATION (o); + return INDICATOR_DATETIME_TIMEZONE (o); } diff --git a/src/timezone-file.h b/src/timezone-file.h new file mode 100644 index 0000000..7186beb --- /dev/null +++ b/src/timezone-file.h @@ -0,0 +1,61 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * Authors: + * Charles Kerr <charles.kerr@canonical.com> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __INDICATOR_DATETIME_TIMEZONE_FILE__H__ +#define __INDICATOR_DATETIME_TIMEZONE_FILE__H__ + +#include <glib.h> +#include <glib-object.h> + +#include "timezone.h" /* parent class */ + +G_BEGIN_DECLS + +#define INDICATOR_TYPE_DATETIME_TIMEZONE_FILE (indicator_datetime_timezone_file_get_type()) +#define INDICATOR_DATETIME_TIMEZONE_FILE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), INDICATOR_TYPE_DATETIME_TIMEZONE_FILE, IndicatorDatetimeTimezoneFile)) +#define INDICATOR_DATETIME_TIMEZONE_FILE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), INDICATOR_TYPE_DATETIME_TIMEZONE_FILE, IndicatorDatetimeTimezoneFileClass)) +#define INDICATOR_IS_DATETIME_TIMEZONE_FILE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), INDICATOR_TYPE_DATETIME_TIMEZONE_FILE)) + +typedef struct _IndicatorDatetimeTimezoneFile IndicatorDatetimeTimezoneFile; +typedef struct _IndicatorDatetimeTimezoneFilePriv IndicatorDatetimeTimezoneFilePriv; +typedef struct _IndicatorDatetimeTimezoneFileClass IndicatorDatetimeTimezoneFileClass; + +GType indicator_datetime_timezone_file_get_type (void); + +/** + * An implementation of IndicatorDatetimeTimezone which determines the timezone + * from monitoring a local file, such as /etc/timezone + */ +struct _IndicatorDatetimeTimezoneFile +{ + /*< private >*/ + IndicatorDatetimeTimezone parent; + IndicatorDatetimeTimezoneFilePriv * priv; +}; + +struct _IndicatorDatetimeTimezoneFileClass +{ + IndicatorDatetimeTimezoneClass parent_class; +}; + +IndicatorDatetimeTimezone * indicator_datetime_timezone_file_new (const char * filename); + +G_END_DECLS + +#endif /* __INDICATOR_DATETIME_TIMEZONE_FILE__H__ */ diff --git a/src/location-geoclue.c b/src/timezone-geoclue.c index 87358fb..5271945 100644 --- a/src/location-geoclue.c +++ b/src/timezone-geoclue.c @@ -25,9 +25,9 @@ #include <geoclue/geoclue-master.h> #include <geoclue/geoclue-master-client.h> -#include "location-geoclue.h" +#include "timezone-geoclue.h" -struct _IndicatorDatetimeLocationGeocluePriv +struct _IndicatorDatetimeTimezoneGeocluePriv { GeoclueMaster * master; GeoclueMasterClient * client; @@ -35,20 +35,20 @@ struct _IndicatorDatetimeLocationGeocluePriv gchar * timezone; }; -typedef IndicatorDatetimeLocationGeocluePriv priv_t; +typedef IndicatorDatetimeTimezoneGeocluePriv priv_t; -G_DEFINE_TYPE (IndicatorDatetimeLocationGeoclue, - indicator_datetime_location_geoclue, - INDICATOR_TYPE_DATETIME_LOCATION) +G_DEFINE_TYPE (IndicatorDatetimeTimezoneGeoclue, + indicator_datetime_timezone_geoclue, + INDICATOR_TYPE_DATETIME_TIMEZONE) -static void geo_restart (IndicatorDatetimeLocationGeoclue * self); +static void geo_restart (IndicatorDatetimeTimezoneGeoclue * self); /*** **** ***/ static void -set_timezone (IndicatorDatetimeLocationGeoclue * self, const gchar * timezone) +set_timezone (IndicatorDatetimeTimezoneGeoclue * self, const gchar * timezone) { priv_t * p = self->priv; @@ -56,7 +56,7 @@ set_timezone (IndicatorDatetimeLocationGeoclue * self, const gchar * timezone) { g_free (p->timezone); p->timezone = g_strdup (timezone); - indicator_datetime_location_notify_timezone (INDICATOR_DATETIME_LOCATION(self)); + indicator_datetime_timezone_notify_timezone (INDICATOR_DATETIME_TIMEZONE(self)); } } @@ -75,7 +75,7 @@ on_address_changed (GeoclueAddress * address, } else { - IndicatorDatetimeLocationGeoclue * self = INDICATOR_DATETIME_LOCATION_GEOCLUE (gself); + IndicatorDatetimeTimezoneGeoclue * self = INDICATOR_DATETIME_TIMEZONE_GEOCLUE (gself); const char * timezone = g_hash_table_lookup (addy_data, "timezone"); set_timezone (self, timezone); } @@ -94,7 +94,7 @@ on_address_created (GeoclueMasterClient * master, } else { - priv_t * p = INDICATOR_DATETIME_LOCATION_GEOCLUE(gself)->priv; + priv_t * p = INDICATOR_DATETIME_TIMEZONE_GEOCLUE(gself)->priv; g_assert (p->address == NULL); p->address = g_object_ref (address); @@ -134,7 +134,7 @@ on_client_created (GeoclueMaster * master, } else { - IndicatorDatetimeLocationGeoclue * self = INDICATOR_DATETIME_LOCATION_GEOCLUE (gself); + IndicatorDatetimeTimezoneGeoclue * self = INDICATOR_DATETIME_TIMEZONE_GEOCLUE (gself); priv_t * p = self->priv; g_clear_object (&p->client); @@ -154,7 +154,7 @@ on_client_created (GeoclueMaster * master, } static void -geo_start (IndicatorDatetimeLocationGeoclue * self) +geo_start (IndicatorDatetimeTimezoneGeoclue * self) { priv_t * p = self->priv; @@ -164,7 +164,7 @@ geo_start (IndicatorDatetimeLocationGeoclue * self) } static void -geo_stop (IndicatorDatetimeLocationGeoclue * self) +geo_stop (IndicatorDatetimeTimezoneGeoclue * self) { priv_t * p = self->priv; @@ -184,7 +184,7 @@ geo_stop (IndicatorDatetimeLocationGeoclue * self) } static void -geo_restart (IndicatorDatetimeLocationGeoclue * self) +geo_restart (IndicatorDatetimeTimezoneGeoclue * self) { geo_stop (self); geo_start (self); @@ -195,54 +195,54 @@ geo_restart (IndicatorDatetimeLocationGeoclue * self) ***/ static const char * -my_get_timezone (IndicatorDatetimeLocation * self) +my_get_timezone (IndicatorDatetimeTimezone * self) { - return INDICATOR_DATETIME_LOCATION_GEOCLUE(self)->priv->timezone; + return INDICATOR_DATETIME_TIMEZONE_GEOCLUE(self)->priv->timezone; } static void my_dispose (GObject * o) { - geo_stop (INDICATOR_DATETIME_LOCATION_GEOCLUE (o)); + geo_stop (INDICATOR_DATETIME_TIMEZONE_GEOCLUE (o)); - G_OBJECT_CLASS (indicator_datetime_location_geoclue_parent_class)->dispose (o); + G_OBJECT_CLASS (indicator_datetime_timezone_geoclue_parent_class)->dispose (o); } static void my_finalize (GObject * o) { - IndicatorDatetimeLocationGeoclue * self = INDICATOR_DATETIME_LOCATION_GEOCLUE (o); + IndicatorDatetimeTimezoneGeoclue * self = INDICATOR_DATETIME_TIMEZONE_GEOCLUE (o); priv_t * p = self->priv; g_free (p->timezone); - G_OBJECT_CLASS (indicator_datetime_location_geoclue_parent_class)->finalize (o); + G_OBJECT_CLASS (indicator_datetime_timezone_geoclue_parent_class)->finalize (o); } static void -indicator_datetime_location_geoclue_class_init (IndicatorDatetimeLocationGeoclueClass * klass) +indicator_datetime_timezone_geoclue_class_init (IndicatorDatetimeTimezoneGeoclueClass * klass) { GObjectClass * object_class; - IndicatorDatetimeLocationClass * location_class; + IndicatorDatetimeTimezoneClass * location_class; object_class = G_OBJECT_CLASS (klass); object_class->dispose = my_dispose; object_class->finalize = my_finalize; - location_class = INDICATOR_DATETIME_LOCATION_CLASS (klass); + location_class = INDICATOR_DATETIME_TIMEZONE_CLASS (klass); location_class->get_timezone = my_get_timezone; - g_type_class_add_private (klass, sizeof (IndicatorDatetimeLocationGeocluePriv)); + g_type_class_add_private (klass, sizeof (IndicatorDatetimeTimezoneGeocluePriv)); } static void -indicator_datetime_location_geoclue_init (IndicatorDatetimeLocationGeoclue * self) +indicator_datetime_timezone_geoclue_init (IndicatorDatetimeTimezoneGeoclue * self) { priv_t * p; p = G_TYPE_INSTANCE_GET_PRIVATE (self, - INDICATOR_TYPE_DATETIME_LOCATION_GEOCLUE, - IndicatorDatetimeLocationGeocluePriv); + INDICATOR_TYPE_DATETIME_TIMEZONE_GEOCLUE, + IndicatorDatetimeTimezoneGeocluePriv); self->priv = p; geo_start (self); @@ -252,10 +252,10 @@ indicator_datetime_location_geoclue_init (IndicatorDatetimeLocationGeoclue * sel **** Public ***/ -IndicatorDatetimeLocation * -indicator_datetime_location_geoclue_new (void) +IndicatorDatetimeTimezone * +indicator_datetime_timezone_geoclue_new (void) { - gpointer o = g_object_new (INDICATOR_TYPE_DATETIME_LOCATION_GEOCLUE, NULL); + gpointer o = g_object_new (INDICATOR_TYPE_DATETIME_TIMEZONE_GEOCLUE, NULL); - return INDICATOR_DATETIME_LOCATION (o); + return INDICATOR_DATETIME_TIMEZONE (o); } diff --git a/src/timezone-geoclue.h b/src/timezone-geoclue.h new file mode 100644 index 0000000..fcb3ab7 --- /dev/null +++ b/src/timezone-geoclue.h @@ -0,0 +1,61 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * Authors: + * Charles Kerr <charles.kerr@canonical.com> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __INDICATOR_DATETIME_TIMEZONE_GEOCLUE__H__ +#define __INDICATOR_DATETIME_TIMEZONE_GEOCLUE__H__ + +#include <glib.h> +#include <glib-object.h> + +#include "timezone.h" /* parent class */ + +G_BEGIN_DECLS + +#define INDICATOR_TYPE_DATETIME_TIMEZONE_GEOCLUE (indicator_datetime_timezone_geoclue_get_type()) +#define INDICATOR_DATETIME_TIMEZONE_GEOCLUE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), INDICATOR_TYPE_DATETIME_TIMEZONE_GEOCLUE, IndicatorDatetimeTimezoneGeoclue)) +#define INDICATOR_DATETIME_TIMEZONE_GEOCLUE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), INDICATOR_TYPE_DATETIME_TIMEZONE_GEOCLUE, IndicatorDatetimeTimezoneGeoclueClass)) +#define INDICATOR_IS_DATETIME_TIMEZONE_GEOCLUE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), INDICATOR_TYPE_DATETIME_TIMEZONE_GEOCLUE)) + +typedef struct _IndicatorDatetimeTimezoneGeoclue IndicatorDatetimeTimezoneGeoclue; +typedef struct _IndicatorDatetimeTimezoneGeocluePriv IndicatorDatetimeTimezoneGeocluePriv; +typedef struct _IndicatorDatetimeTimezoneGeoclueClass IndicatorDatetimeTimezoneGeoclueClass; + +GType indicator_datetime_timezone_geoclue_get_type (void); + +/** + * An implementation of IndicatorDatetimeTimezone which determines the timezone + * from calling a GeoClue service over DBus. + */ +struct _IndicatorDatetimeTimezoneGeoclue +{ + /*< private >*/ + IndicatorDatetimeTimezone parent; + IndicatorDatetimeTimezoneGeocluePriv * priv; +}; + +struct _IndicatorDatetimeTimezoneGeoclueClass +{ + IndicatorDatetimeTimezoneClass parent_class; +}; + +IndicatorDatetimeTimezone * indicator_datetime_timezone_geoclue_new (void); + +G_END_DECLS + +#endif /* __INDICATOR_DATETIME_TIMEZONE_GEOCLUE__H__ */ diff --git a/src/location.c b/src/timezone.c index 12e25c3..9e671ed 100644 --- a/src/location.c +++ b/src/timezone.c @@ -17,10 +17,10 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "location.h" +#include "timezone.h" -G_DEFINE_TYPE (IndicatorDatetimeLocation, - indicator_datetime_location, +G_DEFINE_TYPE (IndicatorDatetimeTimezone, + indicator_datetime_timezone, G_TYPE_OBJECT) enum @@ -38,12 +38,12 @@ my_get_property (GObject * o, GValue * value, GParamSpec * pspec) { - IndicatorDatetimeLocation * self = INDICATOR_DATETIME_LOCATION (o); + IndicatorDatetimeTimezone * self = INDICATOR_DATETIME_TIMEZONE (o); switch (property_id) { case PROP_TIMEZONE: - g_value_set_string (value, indicator_datetime_location_get_timezone (self)); + g_value_set_string (value, indicator_datetime_timezone_get_timezone (self)); break; default: @@ -54,12 +54,12 @@ my_get_property (GObject * o, static void my_dispose (GObject * object) { - G_OBJECT_CLASS (indicator_datetime_location_parent_class)->dispose (object); + G_OBJECT_CLASS (indicator_datetime_timezone_parent_class)->dispose (object); } static void /* cppcheck-suppress unusedFunction */ -indicator_datetime_location_class_init (IndicatorDatetimeLocationClass * klass) +indicator_datetime_timezone_class_init (IndicatorDatetimeTimezoneClass * klass) { GObjectClass * object_class; const GParamFlags flags = G_PARAM_READABLE | G_PARAM_STATIC_STRINGS; @@ -82,7 +82,7 @@ indicator_datetime_location_class_init (IndicatorDatetimeLocationClass * klass) } static void -indicator_datetime_location_init (IndicatorDatetimeLocation * self G_GNUC_UNUSED) +indicator_datetime_timezone_init (IndicatorDatetimeTimezone * self G_GNUC_UNUSED) { } @@ -91,17 +91,17 @@ indicator_datetime_location_init (IndicatorDatetimeLocation * self G_GNUC_UNUSED ***/ const char * -indicator_datetime_location_get_timezone (IndicatorDatetimeLocation * self) +indicator_datetime_timezone_get_timezone (IndicatorDatetimeTimezone * self) { - g_return_val_if_fail (INDICATOR_IS_DATETIME_LOCATION (self), NULL); + g_return_val_if_fail (INDICATOR_IS_DATETIME_TIMEZONE (self), NULL); - return INDICATOR_DATETIME_LOCATION_GET_CLASS (self)->get_timezone (self); + return INDICATOR_DATETIME_TIMEZONE_GET_CLASS (self)->get_timezone (self); } void -indicator_datetime_location_notify_timezone (IndicatorDatetimeLocation * self) +indicator_datetime_timezone_notify_timezone (IndicatorDatetimeTimezone * self) { - g_return_if_fail (INDICATOR_IS_DATETIME_LOCATION (self)); + g_return_if_fail (INDICATOR_IS_DATETIME_TIMEZONE (self)); g_object_notify_by_pspec (G_OBJECT(self), properties[PROP_TIMEZONE]); } diff --git a/src/timezone.h b/src/timezone.h new file mode 100644 index 0000000..ac48e6e --- /dev/null +++ b/src/timezone.h @@ -0,0 +1,68 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * Authors: + * Charles Kerr <charles.kerr@canonical.com> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __INDICATOR_DATETIME_TIMEZONE__H__ +#define __INDICATOR_DATETIME_TIMEZONE__H__ + +#include <glib.h> +#include <glib-object.h> + +G_BEGIN_DECLS + +#define INDICATOR_TYPE_DATETIME_TIMEZONE (indicator_datetime_timezone_get_type()) +#define INDICATOR_DATETIME_TIMEZONE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), INDICATOR_TYPE_DATETIME_TIMEZONE, IndicatorDatetimeTimezone)) +#define INDICATOR_DATETIME_TIMEZONE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), INDICATOR_TYPE_DATETIME_TIMEZONE, IndicatorDatetimeTimezoneClass)) +#define INDICATOR_DATETIME_TIMEZONE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), INDICATOR_TYPE_DATETIME_TIMEZONE, IndicatorDatetimeTimezoneClass)) +#define INDICATOR_IS_DATETIME_TIMEZONE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), INDICATOR_TYPE_DATETIME_TIMEZONE)) + +typedef struct _IndicatorDatetimeTimezone IndicatorDatetimeTimezone; +typedef struct _IndicatorDatetimeTimezoneClass IndicatorDatetimeTimezoneClass; + +GType indicator_datetime_timezone_get_type (void); + +/** + * Abstract Base Class for the mechanisms that determine timezone by location + */ +struct _IndicatorDatetimeTimezone +{ + /*< private >*/ + GObject parent; +}; + +struct _IndicatorDatetimeTimezoneClass +{ + GObjectClass parent_class; + + /* virtual functions */ + const char * (*get_timezone) (IndicatorDatetimeTimezone * self); +}; + +/*** +**** +***/ + +#define INDICATOR_DATETIME_TIMEZONE_PROPERTY_TIMEZONE "timezone" + +const char * indicator_datetime_timezone_get_timezone (IndicatorDatetimeTimezone *); + +void indicator_datetime_timezone_notify_timezone (IndicatorDatetimeTimezone *); + +G_END_DECLS + +#endif /* __INDICATOR_DATETIME_TIMEZONE__H__ */ |