diff options
Diffstat (limited to 'calendar/gui/alarm-notify')
-rw-r--r-- | calendar/gui/alarm-notify/Makefile.am | 10 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/alarm-notify.c | 33 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/alarm-notify.h | 3 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/alarm-queue.c | 1 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/alarm.c | 5 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/alarm.h | 3 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/config-data.c | 28 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/notify-main.c | 10 |
8 files changed, 62 insertions, 31 deletions
diff --git a/calendar/gui/alarm-notify/Makefile.am b/calendar/gui/alarm-notify/Makefile.am index c15181ad9c..82fdeeb77e 100644 --- a/calendar/gui/alarm-notify/Makefile.am +++ b/calendar/gui/alarm-notify/Makefile.am @@ -18,9 +18,9 @@ evolution_alarm_notify_CPPFLAGS = \ -DEVOLUTION_ICONDIR=\""$(icondir)"\" \ -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ -DEVOLUTION_LIBEXECDIR=\""$(privlibexecdir)"\" \ + $(EVOLUTION_DATA_SERVER_CFLAGS) \ $(GNOME_PLATFORM_CFLAGS) \ - $(CAMEL_CFLAGS) \ - $(EVOLUTION_CALENDAR_CFLAGS) \ + $(LIBNOTIFY_CFLAGS) \ $(CANBERRA_CFLAGS) ui_DATA = \ @@ -44,10 +44,10 @@ evolution_alarm_notify_SOURCES = \ evolution_alarm_notify_LDADD = \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ - $(CAMEL_LIBS) \ - $(EVOLUTION_CALENDAR_LIBS) \ - $(CANBERRA_LIBS) \ + $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) \ + $(LIBNOTIFY_LIBS) \ + $(CANBERRA_LIBS) \ $(EVOLUTIONALARMNOTIFYICON) if OS_WIN32 diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c index 3256e39780..3b5402b4a6 100644 --- a/calendar/gui/alarm-notify/alarm-notify.c +++ b/calendar/gui/alarm-notify/alarm-notify.c @@ -39,6 +39,8 @@ #define APPLICATION_ID "org.gnome.EvolutionAlarmNotify" +#define APPLICATION_ID "org.gnome.EvolutionAlarmNotify" + struct _AlarmNotifyPrivate { /* Mapping from EUri's to LoadedClient structures */ /* FIXME do we need per source type uri hashes? or perhaps we @@ -55,7 +57,13 @@ typedef struct { GList *removals; } ProcessRemovalsData; -G_DEFINE_TYPE (AlarmNotify, alarm_notify, GTK_TYPE_APPLICATION) +/* Forward Declarations */ +static void alarm_notify_initable_init (GInitableIface *interface); + +G_DEFINE_TYPE_WITH_CODE ( + AlarmNotify, alarm_notify, GTK_TYPE_APPLICATION, + G_IMPLEMENT_INTERFACE ( + G_TYPE_INITABLE, alarm_notify_initable_init)) static void process_removal_in_hash (const gchar *uri, @@ -264,6 +272,15 @@ alarm_notify_activate (GApplication *application) * if there are no handlers connected to this signal. */ } +static gboolean +alarm_notify_initable (GInitable *initable, + GCancellable *cancellable, + GError **error) +{ + /* XXX Just return TRUE for now. We'll have use for this soon. */ + return TRUE; +} + static void alarm_notify_class_init (AlarmNotifyClass *class) { @@ -281,6 +298,13 @@ alarm_notify_class_init (AlarmNotifyClass *class) } static void +alarm_notify_initable_init (GInitableIface *interface) +{ + /* XXX Awkward name since we're missing an 'E' prefix. */ + interface->init = alarm_notify_initable; +} + +static void alarm_notify_init (AlarmNotify *an) { gint ii; @@ -317,10 +341,11 @@ alarm_notify_get_selected_calendars (AlarmNotify *an) * Returns: a newly-created #AlarmNotify **/ AlarmNotify * -alarm_notify_new (void) +alarm_notify_new (GCancellable *cancellable, + GError **error) { - return g_object_new ( - TYPE_ALARM_NOTIFY, + return g_initable_new ( + TYPE_ALARM_NOTIFY, cancellable, error, "application-id", APPLICATION_ID, NULL); } diff --git a/calendar/gui/alarm-notify/alarm-notify.h b/calendar/gui/alarm-notify/alarm-notify.h index 51837d21d5..f95a4d6b33 100644 --- a/calendar/gui/alarm-notify/alarm-notify.h +++ b/calendar/gui/alarm-notify/alarm-notify.h @@ -65,7 +65,8 @@ struct _AlarmNotifyClass { }; GType alarm_notify_get_type (void); -AlarmNotify * alarm_notify_new (void); +AlarmNotify * alarm_notify_new (GCancellable *cancellable, + GError **error); void alarm_notify_add_calendar (AlarmNotify *an, ECalClientSourceType source_type, ESource *source, diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index d7a1346a8e..8a4ae2face 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -970,7 +970,6 @@ query_objects_removed_cb (ECalClientView *view, message_push ((Message *) msg); } - /* Notification functions */ diff --git a/calendar/gui/alarm-notify/alarm.c b/calendar/gui/alarm-notify/alarm.c index 968eb95959..a05498532b 100644 --- a/calendar/gui/alarm-notify/alarm.c +++ b/calendar/gui/alarm-notify/alarm.c @@ -36,7 +36,6 @@ #include "alarm.h" #include "config-data.h" - /* Our glib timeout */ static guint timeout_id; @@ -54,8 +53,6 @@ typedef struct { static void setup_timeout (void); - - /* Removes the head alarm from the queue. Does not touch the timeout_id. */ static void pop_alarm (void) @@ -199,8 +196,6 @@ queue_alarm (AlarmRecord *ar) setup_timeout (); } - - /** * alarm_add: * @trigger: Time at which alarm will trigger. diff --git a/calendar/gui/alarm-notify/alarm.h b/calendar/gui/alarm-notify/alarm.h index 7a14db5d03..54a6e4c720 100644 --- a/calendar/gui/alarm-notify/alarm.h +++ b/calendar/gui/alarm-notify/alarm.h @@ -29,7 +29,6 @@ #include <time.h> #include <glib.h> - typedef void (* AlarmFunction) (gpointer alarm_id, time_t trigger, gpointer data); typedef void (* AlarmDestroyNotify) (gpointer alarm_id, gpointer data); @@ -40,6 +39,4 @@ gpointer alarm_add (time_t trigger, AlarmFunction alarm_fn, gpointer data, AlarmDestroyNotify destroy_notify_fn); void alarm_remove (gpointer alarm); - - #endif diff --git a/calendar/gui/alarm-notify/config-data.c b/calendar/gui/alarm-notify/config-data.c index aa8755973a..4f30a4e4f3 100644 --- a/calendar/gui/alarm-notify/config-data.c +++ b/calendar/gui/alarm-notify/config-data.c @@ -37,8 +37,6 @@ static GConfClient *conf_client = NULL; static GSetting *calendar_settings = NULL; static ESourceList *calendar_source_list = NULL, *tasks_source_list = NULL; - - /* Copied from ../calendar-config.c; returns whether the locale has 'am' and * 'pm' strings defined. */ @@ -261,16 +259,25 @@ config_data_set_last_notification_time (ECalClient *cal, if (cal) { ESource *source = e_client_get_source (E_CLIENT (cal)); if (source) { - GTimeVal tmval = {0}; - gchar *as_text; + const gchar *prop_str; + GTimeVal curr_tv = {0}; + + prop_str = e_source_get_property (source, "last-notified"); + if (!prop_str || !g_time_val_from_iso8601 (prop_str, &curr_tv)) + curr_tv.tv_sec = 0; - tmval.tv_sec = (glong) t; - as_text = g_time_val_to_iso8601 (&tmval); + if (t > (time_t) curr_tv.tv_sec || (time_t) curr_tv.tv_sec > now) { + GTimeVal tmval = {0}; + gchar *as_text; - if (as_text) { - e_source_set_property (source, "last-notified", as_text); - g_free (as_text); - return; + tmval.tv_sec = (glong) t; + as_text = g_time_val_to_iso8601 (&tmval); + + if (as_text) { + e_source_set_property (source, "last-notified", as_text); + g_free (as_text); + /* pass through, thus the global last notification time is also changed */ + } } } } @@ -317,7 +324,6 @@ config_data_get_last_notification_time (ECalClient *cal) value = g_settings_get_int (calendar_settings, "last-notification-time"); now = time (NULL); - if (val > now) val = now; diff --git a/calendar/gui/alarm-notify/notify-main.c b/calendar/gui/alarm-notify/notify-main.c index 225dde4c26..b1775d8d23 100644 --- a/calendar/gui/alarm-notify/notify-main.c +++ b/calendar/gui/alarm-notify/notify-main.c @@ -27,6 +27,7 @@ #include <config.h> #endif +#include <stdlib.h> #include <glib/gi18n.h> #include "alarm-notify.h" @@ -50,6 +51,7 @@ main (gint argc, { AlarmNotify *alarm_notify_service; gint exit_status; + GError *error = NULL; #ifdef G_OS_WIN32 gchar *path; @@ -87,7 +89,13 @@ main (gint argc, g_warning ("Could not set PATH for Evolution Alarm Notifier"); #endif - alarm_notify_service = alarm_notify_new (); + alarm_notify_service = alarm_notify_new (NULL, &error); + + if (error != NULL) { + g_printerr ("%s\n", error->message); + g_error_free (error); + exit (EXIT_FAILURE); + } exit_status = g_application_run ( G_APPLICATION (alarm_notify_service), argc, argv); |