From 3bffd96b038194ceef081735197278b0c8cd080d Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 1 Nov 2010 11:40:59 +0100 Subject: stock_appontment-reminder icons renamed (reverts previous commit) --- calendar/gui/alarm-notify/alarm-queue.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'calendar/gui/alarm-notify/alarm-queue.c') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 752ce3749e..e8b3f86201 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -1390,9 +1390,9 @@ tray_icon_blink_cb (gpointer data) tray_blink_state = !tray_blink_state; if (tray_blink_state || tray_blink_countdown <= 0) - icon_name = "stock_appointment-reminder-excl"; + icon_name = "appointment-missed"; else - icon_name = "stock_appointment-reminder"; + icon_name = "appointment-soon"; if (tray_icon) gtk_status_icon_set_from_icon_name (tray_icon, icon_name); @@ -1479,7 +1479,7 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, if (tray_icon == NULL) { tray_icon = gtk_status_icon_new (); gtk_status_icon_set_from_icon_name ( - tray_icon, "stock_appointment-reminder"); + tray_icon, "appointment-soon"); g_signal_connect (G_OBJECT (tray_icon), "activate", G_CALLBACK (icon_activated), NULL); g_signal_connect (G_OBJECT (tray_icon), "popup-menu", @@ -1607,9 +1607,9 @@ popup_notification (time_t trigger, CompQueuedAlarms *cqa, } #ifdef HAVE_LIBNOTIFY_07 - n = notify_notification_new (summary, body, "stock_appointment-reminder"); + n = notify_notification_new (summary, body, "appointment-soon"); #else - n = notify_notification_new (summary, body, "stock_appointment-reminder", NULL); + n = notify_notification_new (summary, body, "appointment-soon", NULL); #endif /* HAVE_LIBNOTIFY_07 */ if (!notify_notification_show (n, NULL)) g_warning ("Could not send notification to daemon\n"); -- cgit From a1a842ac20eee58037c3c3db159f3d2768ca9efe Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 30 Nov 2010 16:18:42 +0100 Subject: Default to beginning of the day for the last alarm notification --- calendar/gui/alarm-notify/alarm-queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'calendar/gui/alarm-notify/alarm-queue.c') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index e8b3f86201..38db9368e6 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -1867,7 +1867,7 @@ alarm_queue_init (gpointer data) queue_midnight_refresh (); if (config_data_get_last_notification_time (NULL) == -1) { - time_t tmval = time (NULL); + time_t tmval = time_day_begin (time (NULL)); d(printf("%s:%d (alarm_queue_init) - Setting last notification time to %s\n",__FILE__, __LINE__, e_ctime(&tmval))); config_data_set_last_notification_time (NULL, tmval); } -- cgit From 5fd00f91ed46f9964032207c9797a348d2b6ca32 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 16 Dec 2010 18:04:52 +0100 Subject: Enable debugging of alarm-notify with ALARMS_DEBUG=1 environment variable --- calendar/gui/alarm-notify/alarm-queue.c | 170 ++++++++++++++++---------------- 1 file changed, 87 insertions(+), 83 deletions(-) (limited to 'calendar/gui/alarm-notify/alarm-queue.c') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 38db9368e6..dc21a7bbb9 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -49,8 +49,6 @@ #include "config-data.h" #include "util.h" -#define d(x) - /* The dialog with alarm nofications */ static AlarmNotificationsDialog *alarm_notifications_dialog = NULL; @@ -187,23 +185,28 @@ message_push (Message *msg) * use a static ring-buffer so we can call this twice * in a printf without getting nonsense results. */ -d (#define DEBUGGING_ON) -#ifdef DEBUGGING_ON static const gchar * e_ctime (const time_t *timep) { - static gchar *buffer[4] = { 0, }; - static gint next = 0; - const gchar *ret; + static gchar *buffer[4] = { 0, }; + static gint next = 0; + const gchar *ret; + + g_free (buffer[next]); + ret = buffer[next++] = g_strdup (ctime (timep)); + if (buffer[next - 1] && *buffer[next - 1]) { + gint len = strlen (buffer[next - 1]); + while (len > 0 && (buffer[next - 1][len - 1] == '\n' || buffer[next - 1][len - 1] == '\r' || g_ascii_isspace (buffer[next - 1][len - 1]))) + len--; - g_free (buffer[next]); - ret = buffer[next++] = g_strdup (ctime (timep)); - if (next >= G_N_ELEMENTS (buffer)) - next = 0; + buffer[next - 1][len - 1] = 0; + } - return ret; + if (next >= G_N_ELEMENTS (buffer)) + next = 0; + + return ret; } -#endif /* Queues an alarm trigger for midnight so that we can load the next day's worth * of alarms. @@ -221,11 +224,11 @@ queue_midnight_refresh (void) zone = config_data_get_timezone (); midnight = time_day_end_with_zone (time (NULL), zone); - d(printf("%s:%d (queue_midnight_refresh) - Refresh at %s \n",__FILE__, __LINE__, e_ctime(&midnight))); + debug (("Refresh at %s", e_ctime (&midnight))); midnight_refresh_id = alarm_add (midnight, midnight_refresh_cb, NULL, NULL); if (!midnight_refresh_id) { - d(printf("%s:%d (queue_midnight_refresh) - Could not setup the midnight refresh alarm\n",__FILE__, __LINE__)); + debug (("Could not setup the midnight refresh alarm")); /* FIXME: what to do? */ } } @@ -236,7 +239,7 @@ add_client_alarms_cb (gpointer key, gpointer value, gpointer data) { ClientAlarms *ca = (ClientAlarms *) value; - d(printf("%s:%d (add_client_alarms_cb) - Adding %p\n",__FILE__, __LINE__, ca)); + debug (("Adding %p", ca)); load_alarms_for_today (ca); } @@ -250,14 +253,14 @@ struct _midnight_refresh_msg { static void midnight_refresh_async (struct _midnight_refresh_msg *msg) { - d(printf("%s:%d (midnight_refresh_async) \n",__FILE__, __LINE__)); + debug (("...")); /* Re-load the alarms for all clients */ g_hash_table_foreach (client_alarms_hash, add_client_alarms_cb, NULL); /* Re-schedule the midnight update */ if (msg->remove && midnight_refresh_id != NULL) { - d(printf("%s:%d (midnight_refresh_async) - Reschedule the midnight update \n",__FILE__, __LINE__)); + debug (("Reschedule the midnight update")); alarm_remove (midnight_refresh_id); midnight_refresh_id = NULL; } @@ -315,7 +318,7 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, QueuedAlarm *qa=NULL; GSList *l; - d(printf("%s:%d (remove_queued_alarm) \n",__FILE__, __LINE__)); + debug (("...")); for (l = cqa->queued_alarms; l; l = l->next) { qa = l->data; @@ -344,7 +347,7 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, if (cqa->queued_alarms != NULL) return FALSE; - d(printf("%s:%d (remove_queued_alarm) - Last Component. Removing CQA- Free=%d\n",__FILE__, __LINE__, free_object)); + debug (("Last Component. Removing CQA- Free=%d", free_object)); if (free_object) { cqa->id = NULL; cqa->parent_client = NULL; @@ -407,7 +410,7 @@ alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data) comp = cqa->alarms->comp; config_data_set_last_notification_time (cqa->parent_client->client, trigger); - d(printf("%s:%d (alarm_trigger_cb) - Setting Last notification time to %s\n",__FILE__, __LINE__, ctime (&trigger))); + debug (("Setting Last notification time to %s", e_ctime (&trigger))); qa = lookup_queued_alarm (cqa, alarm_id); if (!qa) @@ -449,7 +452,7 @@ alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data) default: g_return_if_reached (); } - d(printf("%s:%d (alarm_trigger_cb) - Notification sent:%d\n",__FILE__, __LINE__, action)); + debug (("Notification sent: %d", action)); } /* Adds the alarms in a ECalComponentAlarms structure to the alarms queued for a @@ -464,7 +467,7 @@ add_component_alarms (ClientAlarms *ca, ECalComponentAlarms *alarms) /* No alarms? */ if (alarms == NULL || alarms->alarms == NULL) { - d(printf("%s:%d (add_component_alarms) - No alarms to add\n",__FILE__, __LINE__)); + debug (("No alarms to add")); if (alarms) e_cal_component_alarms_free (alarms); return; @@ -476,13 +479,13 @@ add_component_alarms (ClientAlarms *ca, ECalComponentAlarms *alarms) cqa->expecting_update = FALSE; cqa->queued_alarms = NULL; - d(printf("%s:%d (add_component_alarms) - Creating CQA %p\n",__FILE__, __LINE__, cqa)); + debug (("Creating CQA %p", cqa)); for (l = alarms->alarms; l; l = l->next) { ECalComponentAlarmInstance *instance; gpointer alarm_id; QueuedAlarm *qa; - d (time_t tnow = time (NULL)); + time_t tnow = time (NULL); instance = l->data; @@ -493,7 +496,7 @@ add_component_alarms (ClientAlarms *ca, ECalComponentAlarms *alarms) alarm_id = alarm_add (instance->trigger, alarm_trigger_cb, cqa, NULL); if (!alarm_id) { - d(printf("%s:%d (add_component_alarms) - Could not schedule a trigger for %s. Discarding \n",__FILE__, __LINE__, e_ctime(&(instance->trigger)))); + debug (("Could not schedule a trigger for %s. Discarding", e_ctime (&(instance->trigger)))); continue; } @@ -504,7 +507,7 @@ add_component_alarms (ClientAlarms *ca, ECalComponentAlarms *alarms) qa->snooze = FALSE; cqa->queued_alarms = g_slist_prepend (cqa->queued_alarms, qa); - d(printf("%s:%d (add_component_alarms) - Adding alarm %p %p at %s %s\n",__FILE__, __LINE__, qa, alarm_id, ctime (&(instance->trigger)), e_ctime(&tnow))); + debug (("Adding alarm %p %p at %s %s", qa, alarm_id, e_ctime (&(instance->trigger)), e_ctime (&tnow))); } id = e_cal_component_get_id (alarms->comp); @@ -513,14 +516,14 @@ add_component_alarms (ClientAlarms *ca, ECalComponentAlarms *alarms) if (cqa->queued_alarms == NULL) { e_cal_component_alarms_free (cqa->alarms); cqa->alarms = NULL; - d(printf("%s:%d (add_component_alarms) - Failed to add all : %p\n",__FILE__, __LINE__, cqa)); + debug (("Failed to add all : %p", cqa)); g_free (cqa); return; } cqa->queued_alarms = g_slist_reverse (cqa->queued_alarms); cqa->id = id; - d(printf("%s:%d (add_component_alarms) - Alarm added for %s\n",__FILE__, __LINE__, id->uid)); + debug (("Alarm added for %s", id->uid)); g_hash_table_insert (ca->uid_alarms_hash, cqa->id, cqa); } @@ -530,7 +533,7 @@ load_alarms (ClientAlarms *ca, time_t start, time_t end) { gchar *str_query, *iso_start, *iso_end; - d(printf("%s:%d (load_alarms) \n",__FILE__, __LINE__)); + debug (("...")); iso_start = isodate_from_time_t (start); if (!iso_start) @@ -549,7 +552,7 @@ load_alarms (ClientAlarms *ca, time_t start, time_t end) /* create the live query */ if (ca->query) { - d(printf("%s:%d (load_alarms) - Disconnecting old queries \n",__FILE__, __LINE__)); + debug (("Disconnecting old queries")); g_signal_handlers_disconnect_matched (ca->query, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); g_object_unref (ca->query); ca->query = NULL; @@ -559,7 +562,7 @@ load_alarms (ClientAlarms *ca, time_t start, time_t end) if (!e_cal_get_query (ca->client, str_query, &ca->query, NULL)) { g_warning (G_STRLOC ": Could not get query for client"); } else { - d(printf("%s:%d (load_alarms) - Setting Call backs \n",__FILE__, __LINE__)); + debug (("Setting Call backs")); g_signal_connect (G_OBJECT (ca->query), "objects_added", G_CALLBACK (query_objects_changed_cb), ca); @@ -590,11 +593,12 @@ load_alarms_for_today (ClientAlarms *ca) * half-open; we do not want to display the "last" displayed alarm * twice, once when it occurs and once when the alarm daemon restarts. */ - from = MAX (config_data_get_last_notification_time (ca->client) + 1, day_start); + from = config_data_get_last_notification_time (ca->client) + 1; + if (from <= 0) + from = MAX (from, day_start); day_end = time_day_end_with_zone (now, zone); - d(printf("%s:%d (load_alarms_for_today) - From %s to %s\n",__FILE__, __LINE__, - g_strdup (ctime (&from)), g_strdup (e_ctime (&day_end)))); + debug (("From %s to %s", e_ctime (&from), e_ctime (&day_end))); load_alarms (ca, from, day_end); } @@ -606,7 +610,7 @@ cal_opened_cb (ECal *client, const GError *error, gpointer data) ca = data; - d(printf("%s:%d (cal_opened_cb) - Opened Calendar %p (Status %d%s%s%s)\n",__FILE__, __LINE__, client, error ? error->code : 0, error ? " (" : "", error ? error->message : "", error ? ")" : "")); + debug (("Opened Calendar %p (Status %d%s%s%s)", client, error ? error->code : 0, error ? " (" : "", error ? error->message : "", error ? ")" : "")); if (error) return; @@ -625,7 +629,7 @@ remove_alarms (CompQueuedAlarms *cqa, gboolean free_object) { GSList *l; - d(printf("%s:%d (remove_alarms) - Removing for %p\n",__FILE__, __LINE__, cqa)); + debug (("Removing for %p", cqa)); for (l = cqa->queued_alarms; l;) { QueuedAlarm *qa; @@ -649,7 +653,7 @@ remove_comp (ClientAlarms *ca, ECalComponentId *id) { CompQueuedAlarms *cqa; - d(printf("%s:%d (remove_comp) - Removing uid %s\n",__FILE__, __LINE__, id->uid)); + debug (("Removing uid %s", id->uid)); if (id->rid && !(*(id->rid))) { g_free (id->rid); @@ -665,7 +669,7 @@ remove_comp (ClientAlarms *ca, ECalComponentId *id) */ g_return_if_fail (cqa->queued_alarms != NULL); - d(printf("%s:%d (remove_comp) - Removing CQA %p\n",__FILE__, __LINE__, cqa)); + debug (("Removing CQA %p", cqa)); remove_alarms (cqa, TRUE); } @@ -730,7 +734,7 @@ query_objects_changed_async (struct _query_msg *msg) day_end = time_day_end_with_zone (time (NULL), zone); - d(printf("%s:%d (query_objects_changed_async) - Querying for object between %s to %s\n",__FILE__, __LINE__, e_ctime(&from), e_ctime(&day_end))); + debug (("Querying for object between %s to %s", e_ctime (&from), e_ctime (&day_end))); for (l = objects; l != NULL; l = l->next) { ECalComponentId *id; @@ -743,7 +747,7 @@ query_objects_changed_async (struct _query_msg *msg) found = e_cal_get_alarms_for_object (ca->client, id, from, day_end, &alarms); if (!found) { - d(printf("%s:%d (query_objects_changed_async) - No Alarm found for client %p\n",__FILE__, __LINE__, ca->client)); + debug (("No Alarm found for client %p", ca->client)); tray_list_remove_cqa (lookup_comp_queued_alarms (ca, id)); remove_comp (ca, id); g_hash_table_remove (ca->uid_alarms_hash, id); @@ -755,14 +759,14 @@ query_objects_changed_async (struct _query_msg *msg) cqa = lookup_comp_queued_alarms (ca, id); if (!cqa) { - d(printf("%s:%d (query_objects_changed_async) - No currently queued alarms for %s\n",__FILE__, __LINE__, id->uid)); + debug (("No currently queued alarms for %s", id->uid)); add_component_alarms (ca, alarms); g_object_unref (comp); comp = NULL; continue; } - d(printf("%s:%d (query_objects_changed_async) - Alarm Already Exist for %s\n",__FILE__, __LINE__, id->uid)); + debug (("Alarm Already Exist for %s", id->uid)); /* if the alarms or the alarms list is empty remove it after updating the cqa structure */ if (alarms == NULL || alarms->alarms == NULL) { @@ -794,7 +798,7 @@ query_objects_changed_async (struct _query_msg *msg) alarm_id = alarm_add (instance->trigger, alarm_trigger_cb, cqa, NULL); if (!alarm_id) { - d(printf("%s:%d (query_objects_changed_async) -Unable to schedule trigger for %s \n",__FILE__, __LINE__, e_ctime(&(instance->trigger)))); + debug (("Unable to schedule trigger for %s", e_ctime (&(instance->trigger)))); continue; } @@ -804,7 +808,7 @@ query_objects_changed_async (struct _query_msg *msg) qa->snooze = FALSE; qa->orig_trigger = instance->trigger; cqa->queued_alarms = g_slist_prepend (cqa->queued_alarms, qa); - d(printf("%s:%d (query_objects_changed_async) - Adding %p to queue \n",__FILE__, __LINE__, qa)); + debug (("Adding %p to queue", qa)); } cqa->queued_alarms = g_slist_reverse (cqa->queued_alarms); @@ -842,7 +846,7 @@ query_objects_removed_async (struct _query_msg *msg) ca = msg->data; objects = msg->objects; - d(printf("%s:%d (query_objects_removed_async) - Removing %d objects\n",__FILE__, __LINE__, g_list_length(objects))); + debug (("Removing %d objects", g_list_length (objects))); for (l = objects; l != NULL; l = l->next) { /* If the alarm is already triggered remove it. */ @@ -892,14 +896,14 @@ create_snooze (CompQueuedAlarms *cqa, gpointer alarm_id, gint snooze_mins) new_id = alarm_add (t, alarm_trigger_cb, cqa, NULL); if (!new_id) { - d(printf("%s:%d (create_snooze) -Unable to schedule trigger for %s \n",__FILE__, __LINE__, e_ctime(&t))); + debug (("Unable to schedule trigger for %s", e_ctime (&t))); return; } orig_qa->instance->trigger = t; orig_qa->alarm_id = new_id; orig_qa->snooze = TRUE; - d(printf("%s:%d (create_snooze) - Adding a alarm at %s\n",__FILE__, __LINE__, e_ctime(&t))); + debug (("Adding a alarm at %s", e_ctime (&t))); } /* Launches a component editor for a component */ @@ -1010,7 +1014,7 @@ on_dialog_objs_removed_async (struct _query_msg *msg) TrayIconData *tray_data; GList *objects; - d(printf("%s:%d (on_dialog_objs_removed_async)\n",__FILE__, __LINE__)); + debug (("...")); tray_data = msg->data; objects = msg->objects; @@ -1059,7 +1063,7 @@ tray_list_remove_cqa_async (struct _tray_cqa_msg *msg) CompQueuedAlarms *cqa = msg->cqa; GList *list = tray_icons_list; - d(printf("%s:%d (tray_list_remove_cqa_async) - Removing CQA %p from tray list\n",__FILE__, __LINE__, cqa)); + debug (("Removing CQA %p from tray list", cqa)); while (list) { TrayIconData *tray_data = list->data; @@ -1068,7 +1072,7 @@ tray_list_remove_cqa_async (struct _tray_cqa_msg *msg) list = list->next; if (tray_data->cqa == cqa) { - d(printf("%s:%d (tray_list_remove_cqa_async) - Found.\n", __FILE__, __LINE__)); + debug (("Found")); tray_icons_list = g_list_delete_link (tray_icons_list, tmp); if (alarm_notifications_dialog) { model = gtk_tree_view_get_model (GTK_TREE_VIEW (alarm_notifications_dialog->treeview)); @@ -1078,7 +1082,7 @@ tray_list_remove_cqa_async (struct _tray_cqa_msg *msg) } } - d(printf("%s:%d (tray_list_remove_cqa_async) - %d alarms left.\n", __FILE__, __LINE__, g_list_length (tray_icons_list))); + debug (("%d alarms left", g_list_length (tray_icons_list))); if (alarm_notifications_dialog) { if (!g_list_length (tray_icons_list)) { @@ -1117,7 +1121,7 @@ tray_list_remove_async (Message *msg) { GList *list = tray_icons_list; - d(printf("%s:%d (tray_list_remove_async) - Removing %d alarms\n",__FILE__, __LINE__, g_list_length(list))); + debug (("Removing %d alarms", g_list_length (list))); while (list != NULL) { TrayIconData *tray_data = list->data; @@ -1168,7 +1172,7 @@ tray_list_remove_data_async (struct _tray_msg *msg) { TrayIconData *tray_data = msg->data; - d(printf("%s:%d (tray_list_remove_data_async) - Removing %p from tray list\n",__FILE__, __LINE__, tray_data)); + debug (("Removing %p from tray list", tray_data)); tray_icons_list = g_list_remove_all (tray_icons_list, tray_data); free_tray_icon_data (tray_data); @@ -1194,14 +1198,14 @@ notify_dialog_cb (AlarmNotifyResult result, gint snooze_mins, gpointer data) { TrayIconData *tray_data = data; - d(printf("%s:%d (notify_dialog_cb) - Received from dialog\n",__FILE__, __LINE__)); + debug (("Received from dialog")); g_signal_handlers_disconnect_matched (tray_data->query, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, on_dialog_objs_removed_cb, NULL); switch (result) { case ALARM_NOTIFY_SNOOZE: - d(printf("%s:%d (notify_dialog_cb) - Creating a snooze\n",__FILE__, __LINE__)); + debug (("Creating a snooze")); create_snooze (tray_data->cqa, tray_data->alarm_id, snooze_mins); tray_data->snooze_set = TRUE; tray_list_remove_data (tray_data); @@ -1243,7 +1247,7 @@ notify_dialog_cb (AlarmNotifyResult result, gint snooze_mins, gpointer data) break; case ALARM_NOTIFY_CLOSE: - d(printf("%s:%d (notify_dialog_cb) - Dialog close\n",__FILE__, __LINE__)); + debug (("Dialog close")); if (alarm_notifications_dialog) { GtkTreeIter iter; GtkTreeModel *model = @@ -1293,7 +1297,7 @@ open_alarm_dialog (TrayIconData *tray_data) { QueuedAlarm *qa; - d(printf("%s:%d (open_alarm_dialog) \n",__FILE__, __LINE__)); + debug (("...")); qa = lookup_queued_alarm (tray_data->cqa, tray_data->alarm_id); if (qa) { remove_tray_icon (); @@ -1334,7 +1338,7 @@ static gint tray_icon_clicked_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { if (event->type == GDK_BUTTON_PRESS) { - d(printf("%s:%d (tray_icon_clicked_cb) - left click and %d alarms\n",__FILE__, __LINE__, g_list_length (tray_icons_list))); + debug (("left click and %d alarms", g_list_length (tray_icons_list))); if (event->button == 1 && g_list_length (tray_icons_list) > 0) { GList *tmp; for (tmp = tray_icons_list; tmp; tmp = tmp->next) { @@ -1343,7 +1347,7 @@ tray_icon_clicked_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_da return TRUE; } else if (event->button == 3) { - d(printf("%s:%d (tray_icon_clicked_cb) - right click\n",__FILE__, __LINE__)); + debug (("right click")); remove_tray_icon (); return TRUE; @@ -1440,7 +1444,7 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, icaltimezone *current_zone; ECalComponentOrganizer organiser; - d(printf("%s:%d (display_notification)\n",__FILE__, __LINE__)); + debug (("...")); comp = cqa->alarms->comp; qa = lookup_queued_alarm (cqa, alarm_id); @@ -1562,7 +1566,7 @@ popup_notification (time_t trigger, CompQueuedAlarms *cqa, NotifyNotification *n; gchar *body; - d(printf("%s:%d (popup_notification)\n",__FILE__, __LINE__)); + debug (("...")); comp = cqa->alarms->comp; qa = lookup_queued_alarm (cqa, alarm_id); @@ -1635,7 +1639,7 @@ audio_notification (time_t trigger, CompQueuedAlarms *cqa, icalattach *attach; gint flag = 0; - d(printf("%s:%d (audio_notification)\n",__FILE__, __LINE__)); + debug (("...")); comp = cqa->alarms->comp; qa = lookup_queued_alarm (cqa, alarm_id); @@ -1689,7 +1693,7 @@ mail_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id) /* FIXME */ - d(printf("%s:%d (mail_notification)\n",__FILE__, __LINE__)); + debug (("...")); if (!e_cal_get_static_capability (cqa->parent_client->client, CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS)) @@ -1723,7 +1727,7 @@ procedure_notification_dialog (const gchar *cmd, const gchar *url) gchar *str; gint btn; - d(printf("%s:%d (procedure_notification_dialog)\n",__FILE__, __LINE__)); + debug (("...")); if (config_data_is_blessed_program (url)) return TRUE; @@ -1774,7 +1778,7 @@ procedure_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id gchar *cmd; gboolean result = TRUE; - d(printf("%s:%d (procedure_notification)\n",__FILE__, __LINE__)); + debug (("...")); comp = cqa->alarms->comp; qa = lookup_queued_alarm (cqa, alarm_id); @@ -1831,7 +1835,7 @@ check_midnight_refresh (gpointer user_data) time_t new_midnight; icaltimezone *zone; - d(printf("%s:%d (check_midnight_refresh)\n",__FILE__, __LINE__)); + debug (("...")); zone = config_data_get_timezone (); new_midnight = time_day_end_with_zone (time (NULL), zone); @@ -1861,14 +1865,14 @@ alarm_queue_init (gpointer data) an = data; g_return_if_fail (alarm_queue_inited == FALSE); - d(printf("%s:%d (alarm_queue_init)\n",__FILE__, __LINE__)); + debug (("...")); client_alarms_hash = g_hash_table_new (g_direct_hash, g_direct_equal); queue_midnight_refresh (); if (config_data_get_last_notification_time (NULL) == -1) { time_t tmval = time_day_begin (time (NULL)); - d(printf("%s:%d (alarm_queue_init) - Setting last notification time to %s\n",__FILE__, __LINE__, e_ctime(&tmval))); + debug (("Setting last notification time to %s", e_ctime (&tmval))); config_data_set_last_notification_time (NULL, tmval); } @@ -1887,12 +1891,12 @@ free_client_alarms_cb (gpointer key, gpointer value, gpointer user_data) { ClientAlarms *ca = value; - d(printf("%s:%d (free_client_alarms_cb) - %p\n",__FILE__, __LINE__, ca)); + debug (("ca=%p", ca)); if (ca) { remove_client_alarms (ca); if (ca->client) { - d(printf("%s:%d (free_client_alarms_cb) - Disconnecting Client \n",__FILE__, __LINE__)); + debug (("Disconnecting Client")); g_signal_handlers_disconnect_matched (ca->client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); @@ -1900,7 +1904,7 @@ free_client_alarms_cb (gpointer key, gpointer value, gpointer user_data) } if (ca->query) { - d(printf("%s:%d (free_client_alarms_cb) - Disconnecting Query \n",__FILE__, __LINE__)); + debug (("Disconnecting Query")); g_signal_handlers_disconnect_matched (ca->query, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); @@ -1931,7 +1935,7 @@ alarm_queue_done (void) /* All clients must be unregistered by now */ g_return_if_fail (g_hash_table_size (client_alarms_hash) == 0); - d(printf("%s:%d (alarm_queue_done)\n",__FILE__, __LINE__)); + debug (("...")); g_hash_table_foreach_remove (client_alarms_hash, (GHRFunc) free_client_alarms_cb, NULL); g_hash_table_destroy (client_alarms_hash); @@ -1994,7 +1998,7 @@ alarm_queue_add_async (struct _alarm_client_msg *msg) return; } - d(printf("%s:%d (alarm_queue_add_async) - %p\n",__FILE__, __LINE__, client)); + debug (("client=%p", client)); ca = g_new (ClientAlarms, 1); @@ -2052,7 +2056,7 @@ remove_cqa (ClientAlarms *ca, ECalComponentId *id, CompQueuedAlarms *cqa) */ g_return_if_fail (cqa->queued_alarms != NULL); - d(printf("%s:%d (remove_cqa) - removing %d alarms\n",__FILE__, __LINE__, g_slist_length(cqa->queued_alarms))); + debug (("removing %d alarms", g_slist_length (cqa->queued_alarms))); remove_alarms (cqa, TRUE); } @@ -2061,7 +2065,7 @@ remove_comp_by_id (gpointer key, gpointer value, gpointer userdata) { ClientAlarms *ca = (ClientAlarms *)userdata; - d(printf("%s:%d (remove_comp_by_id)\n",__FILE__, __LINE__)); + debug (("...")); /* if (!g_hash_table_size (ca->uid_alarms_hash)) */ /* return; */ @@ -2075,7 +2079,7 @@ remove_comp_by_id (gpointer key, gpointer value, gpointer userdata) { static void remove_client_alarms (ClientAlarms *ca) { - d(printf("%s:%d (remove_client_alarms) - size %d \n",__FILE__, __LINE__, g_hash_table_size (ca->uid_alarms_hash))); + debug (("size %d", g_hash_table_size (ca->uid_alarms_hash))); g_hash_table_foreach_remove (ca->uid_alarms_hash, (GHRFunc)remove_comp_by_id, ca); @@ -2102,12 +2106,12 @@ alarm_queue_remove_async (struct _alarm_client_msg *msg) ca = lookup_client (client); g_return_if_fail (ca != NULL); - d(printf("%s:%d (alarm_queue_remove_async) \n",__FILE__, __LINE__)); + debug (("...")); remove_client_alarms (ca); /* Clean up */ if (ca->client) { - d(printf("%s:%d (alarm_queue_remove_async) - Disconnecting Client \n",__FILE__, __LINE__)); + debug (("Disconnecting Client")); g_signal_handlers_disconnect_matched (ca->client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); @@ -2116,7 +2120,7 @@ alarm_queue_remove_async (struct _alarm_client_msg *msg) } if (ca->query) { - d(printf("%s:%d (alarm_queue_remove_async) - Disconnecting Query \n",__FILE__, __LINE__)); + debug (("Disconnecting Query")); g_signal_handlers_disconnect_matched (ca->query, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); @@ -2174,7 +2178,7 @@ update_cqa (CompQueuedAlarms *cqa, ECalComponent *newcomp) from = time_day_begin_with_zone (time (NULL), zone); to = time_day_end_with_zone (time (NULL), zone); - d(printf("%s:%d (update_cqa) - Generating alarms between %s and %s\n",__FILE__, __LINE__, e_ctime(&from), e_ctime(&to))); + debug (("Generating alarms between %s and %s", e_ctime (&from), e_ctime (&to))); alarms = e_cal_util_generate_alarms_for_comp (newcomp, from, to, omit, e_cal_resolve_tzid_cb, cqa->parent_client->client, zone); @@ -2193,7 +2197,7 @@ update_cqa (CompQueuedAlarms *cqa, ECalComponent *newcomp) if (alarm) { /* Need to update QueuedAlarms */ e_cal_component_alarm_free (alarm); if (alarms == NULL) { - d(printf("%s:%d (update_cqa) - No alarms found in the modified component\n",__FILE__, __LINE__)); + debug (("No alarms found in the modified component")); break; } update_qa (alarms, qa); @@ -2216,7 +2220,7 @@ update_qa (ECalComponentAlarms *alarms, QueuedAlarm *qa) ECalComponentAlarmInstance *al_inst; GSList *instance_list; - d(printf("%s:%d (update_qa)\n",__FILE__, __LINE__)); + debug (("...")); for (instance_list = alarms->alarms; instance_list; instance_list = instance_list->next) { al_inst = instance_list->data; if (al_inst->trigger == qa->orig_trigger) { /* FIXME if two or more alarm instances (audio, note) for same component have same trigger */ -- cgit From 21ab8044dab93b6367463593628ec42befda4f67 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 29 Jan 2011 10:50:53 -0500 Subject: Coding style and whitespace cleanup. --- calendar/gui/alarm-notify/alarm-queue.c | 140 +++++++++++++++++++++----------- 1 file changed, 91 insertions(+), 49 deletions(-) (limited to 'calendar/gui/alarm-notify/alarm-queue.c') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index dc21a7bbb9..3bdd60a1b7 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -123,19 +123,32 @@ typedef struct { static gpointer midnight_refresh_id = NULL; static time_t midnight = 0; -static void -remove_client_alarms (ClientAlarms *ca); -static void display_notification (time_t trigger, CompQueuedAlarms *cqa, - gpointer alarm_id, gboolean use_description); -static void audio_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id); -static void mail_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id); -static void procedure_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id); +static void remove_client_alarms (ClientAlarms *ca); +static void display_notification (time_t trigger, + CompQueuedAlarms *cqa, + gpointer alarm_id, + gboolean use_description); +static void audio_notification (time_t trigger, + CompQueuedAlarms *cqa, + gpointer alarm_id); +static void mail_notification (time_t trigger, + CompQueuedAlarms *cqa, + gpointer alarm_id); +static void procedure_notification (time_t trigger, + CompQueuedAlarms *cqa, + gpointer alarm_id); #ifdef HAVE_LIBNOTIFY -static void popup_notification (time_t trigger, CompQueuedAlarms *cqa, - gpointer alarm_id, gboolean use_description); +static void popup_notification (time_t trigger, + CompQueuedAlarms *cqa, + gpointer alarm_id, + gboolean use_description); #endif -static void query_objects_changed_cb (ECal *client, GList *objects, gpointer data); -static void query_objects_removed_cb (ECal *client, GList *objects, gpointer data); +static void query_objects_changed_cb (ECal *client, + GList *objects, + gpointer data); +static void query_objects_removed_cb (ECal *client, + GList *objects, + gpointer data); static void update_cqa (CompQueuedAlarms *cqa, ECalComponent *comp); static void update_qa (ECalComponentAlarms *alarms, QueuedAlarm *qa); @@ -196,7 +209,9 @@ e_ctime (const time_t *timep) ret = buffer[next++] = g_strdup (ctime (timep)); if (buffer[next - 1] && *buffer[next - 1]) { gint len = strlen (buffer[next - 1]); - while (len > 0 && (buffer[next - 1][len - 1] == '\n' || buffer[next - 1][len - 1] == '\r' || g_ascii_isspace (buffer[next - 1][len - 1]))) + while (len > 0 && (buffer[next - 1][len - 1] == '\n' || + buffer[next - 1][len - 1] == '\r' || + g_ascii_isspace (buffer[next - 1][len - 1]))) len--; buffer[next - 1][len - 1] = 0; @@ -485,20 +500,16 @@ add_component_alarms (ClientAlarms *ca, ECalComponentAlarms *alarms) ECalComponentAlarmInstance *instance; gpointer alarm_id; QueuedAlarm *qa; - time_t tnow = time (NULL); instance = l->data; - if (!has_known_notification (cqa->alarms->comp, instance->auid)) { - g_debug ("Could not recognize alarm's notification type, discarding."); + if (!has_known_notification (cqa->alarms->comp, instance->auid)) continue; - } - alarm_id = alarm_add (instance->trigger, alarm_trigger_cb, cqa, NULL); - if (!alarm_id) { - debug (("Could not schedule a trigger for %s. Discarding", e_ctime (&(instance->trigger)))); + alarm_id = alarm_add ( + instance->trigger, alarm_trigger_cb, cqa, NULL); + if (!alarm_id) continue; - } qa = g_new (QueuedAlarm, 1); qa->alarm_id = alarm_id; @@ -507,7 +518,6 @@ add_component_alarms (ClientAlarms *ca, ECalComponentAlarms *alarms) qa->snooze = FALSE; cqa->queued_alarms = g_slist_prepend (cqa->queued_alarms, qa); - debug (("Adding alarm %p %p at %s %s", qa, alarm_id, e_ctime (&(instance->trigger)), e_ctime (&tnow))); } id = e_cal_component_get_id (alarms->comp); @@ -545,15 +555,17 @@ load_alarms (ClientAlarms *ca, time_t start, time_t end) return; } - str_query = g_strdup_printf ("(has-alarms-in-range? (make-time \"%s\") (make-time \"%s\"))", - iso_start, iso_end); + str_query = g_strdup_printf ( + "(has-alarms-in-range? (make-time \"%s\") " + "(make-time \"%s\"))", iso_start, iso_end); g_free (iso_start); g_free (iso_end); /* create the live query */ if (ca->query) { debug (("Disconnecting old queries")); - g_signal_handlers_disconnect_matched (ca->query, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); + g_signal_handlers_disconnect_matched ( + ca->query, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); g_object_unref (ca->query); ca->query = NULL; } @@ -564,12 +576,15 @@ load_alarms (ClientAlarms *ca, time_t start, time_t end) } else { debug (("Setting Call backs")); - g_signal_connect (G_OBJECT (ca->query), "objects_added", - G_CALLBACK (query_objects_changed_cb), ca); - g_signal_connect (G_OBJECT (ca->query), "objects_modified", - G_CALLBACK (query_objects_changed_cb), ca); - g_signal_connect (G_OBJECT (ca->query), "objects_removed", - G_CALLBACK (query_objects_removed_cb), ca); + g_signal_connect ( + ca->query, "objects_added", + G_CALLBACK (query_objects_changed_cb), ca); + g_signal_connect ( + ca->query, "objects_modified", + G_CALLBACK (query_objects_changed_cb), ca); + g_signal_connect ( + ca->query, "objects_removed", + G_CALLBACK (query_objects_removed_cb), ca); e_cal_view_start (ca->query); } @@ -610,7 +625,6 @@ cal_opened_cb (ECal *client, const GError *error, gpointer data) ca = data; - debug (("Opened Calendar %p (Status %d%s%s%s)", client, error ? error->code : 0, error ? " (" : "", error ? error->message : "", error ? ")" : "")); if (error) return; @@ -767,7 +781,8 @@ query_objects_changed_async (struct _query_msg *msg) } debug (("Alarm Already Exist for %s", id->uid)); - /* if the alarms or the alarms list is empty remove it after updating the cqa structure */ + /* If the alarms or the alarms list is empty, + * remove it after updating the cqa structure. */ if (alarms == NULL || alarms->alarms == NULL) { /* update the cqa and its queued alarms for changes in summary and alarm_uid */ @@ -1075,7 +1090,8 @@ tray_list_remove_cqa_async (struct _tray_cqa_msg *msg) debug (("Found")); tray_icons_list = g_list_delete_link (tray_icons_list, tmp); if (alarm_notifications_dialog) { - model = gtk_tree_view_get_model (GTK_TREE_VIEW (alarm_notifications_dialog->treeview)); + model = gtk_tree_view_get_model ( + GTK_TREE_VIEW (alarm_notifications_dialog->treeview)); gtk_list_store_remove (GTK_LIST_STORE (model), &(tray_data->iter)); } free_tray_icon_data (tray_data); @@ -1091,11 +1107,14 @@ tray_list_remove_cqa_async (struct _tray_cqa_msg *msg) alarm_notifications_dialog = NULL; } else { GtkTreeIter iter; - GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (alarm_notifications_dialog->treeview)); + GtkTreeModel *model; GtkTreeSelection *sel; + model = gtk_tree_view_get_model ( + GTK_TREE_VIEW (alarm_notifications_dialog->treeview)); gtk_tree_model_get_iter_first (model, &iter); - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (alarm_notifications_dialog->treeview)); + sel = gtk_tree_view_get_selection ( + GTK_TREE_VIEW (alarm_notifications_dialog->treeview)); gtk_tree_selection_select_iter (sel, &iter); } } @@ -1133,7 +1152,9 @@ tray_list_remove_async (Message *msg) tray_icons_list = g_list_remove_link (tray_icons_list, list); status = remove_queued_alarm (tray_data->cqa, tray_data->alarm_id, FALSE, TRUE); if (status) { - g_hash_table_remove (tray_data->cqa->parent_client->uid_alarms_hash, tray_data->cqa->id); + g_hash_table_remove ( + tray_data->cqa->parent_client->uid_alarms_hash, + tray_data->cqa->id); e_cal_component_free_id (tray_data->cqa->id); g_free (tray_data->cqa); } @@ -1241,7 +1262,10 @@ notify_dialog_cb (AlarmNotifyResult result, gint snooze_mins, gpointer data) case ALARM_NOTIFY_DISMISS: if (alarm_notifications_dialog) { - GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (alarm_notifications_dialog->treeview)); + GtkTreeModel *model; + + model = gtk_tree_view_get_model ( + GTK_TREE_VIEW (alarm_notifications_dialog->treeview)); gtk_list_store_remove (GTK_LIST_STORE (model), &tray_data->iter); } break; @@ -1520,7 +1544,10 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, if (g_list_length (tray_icons_list) > 1) { gchar *tip; - tip = g_strdup_printf (ngettext ("You have %d alarm", "You have %d alarms", g_list_length (tray_icons_list)), g_list_length (tray_icons_list)); + tip = g_strdup_printf (ngettext ( + "You have %d alarm", "You have %d alarms", + g_list_length (tray_icons_list)), + g_list_length (tray_icons_list)); gtk_status_icon_set_tooltip_text (tray_icon, tip); } else { @@ -1599,15 +1626,23 @@ popup_notification (time_t trigger, CompQueuedAlarms *cqa, if (organiser.cn) { if (location) - body = g_strdup_printf ("%s\n%s %s\n%s %s", organiser.cn, _("Location:"), location, start_str, time_str); + body = g_strdup_printf ( + "%s\n%s %s\n%s %s", + organiser.cn, _("Location:"), + location, start_str, time_str); else - body = g_strdup_printf ("%s\n%s %s", organiser.cn, start_str, time_str); + body = g_strdup_printf ( + "%s\n%s %s", + organiser.cn, start_str, time_str); } else { if (location) - body = g_strdup_printf ("%s %s\n%s %s", _("Location:"), location, start_str, time_str); + body = g_strdup_printf ( + "%s %s\n%s %s", _("Location:"), + location, start_str, time_str); else - body = g_strdup_printf ("%s %s", start_str, time_str); + body = g_strdup_printf ( + "%s %s", start_str, time_str); } #ifdef HAVE_LIBNOTIFY_07 @@ -1759,7 +1794,8 @@ procedure_notification_dialog (const gchar *cmd, const gchar *url) /* Run the dialog */ btn = gtk_dialog_run (GTK_DIALOG (dialog)); - if (btn == GTK_RESPONSE_OK && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox))) + if (btn == GTK_RESPONSE_OK && + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox))) config_data_save_blessed_program (url); gtk_widget_destroy (dialog); @@ -1937,7 +1973,8 @@ alarm_queue_done (void) debug (("...")); - g_hash_table_foreach_remove (client_alarms_hash, (GHRFunc) free_client_alarms_cb, NULL); + g_hash_table_foreach_remove ( + client_alarms_hash, (GHRFunc) free_client_alarms_cb, NULL); g_hash_table_destroy (client_alarms_hash); client_alarms_hash = NULL; @@ -2007,7 +2044,8 @@ alarm_queue_add_async (struct _alarm_client_msg *msg) g_hash_table_insert (client_alarms_hash, client, ca); - ca->uid_alarms_hash = g_hash_table_new ((GHashFunc) hash_ids, (GEqualFunc) compare_ids); + ca->uid_alarms_hash = g_hash_table_new ( + (GHashFunc) hash_ids, (GEqualFunc) compare_ids); if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) { load_alarms_for_today (ca); @@ -2160,8 +2198,8 @@ alarm_queue_remove_client (ECal *client, gboolean immediately) message_push ((Message *) msg); } -/* Update non-time related variables for various structures on modification of an existing component - to be called only from query_objects_changed_cb */ +/* Update non-time related variables for various structures on modification + * of an existing component to be called only from query_objects_changed_cb */ static void update_cqa (CompQueuedAlarms *cqa, ECalComponent *newcomp) { @@ -2221,9 +2259,13 @@ update_qa (ECalComponentAlarms *alarms, QueuedAlarm *qa) GSList *instance_list; debug (("...")); - for (instance_list = alarms->alarms; instance_list; instance_list = instance_list->next) { + for (instance_list = alarms->alarms; + instance_list; + instance_list = instance_list->next) { al_inst = instance_list->data; - if (al_inst->trigger == qa->orig_trigger) { /* FIXME if two or more alarm instances (audio, note) for same component have same trigger */ + /* FIXME If two or more alarm instances (audio, note) + * for same component have same trigger... */ + if (al_inst->trigger == qa->orig_trigger) { g_free ((gchar *) qa->instance->auid); qa->instance->auid = g_strdup (al_inst->auid); break; -- cgit From b22ac14482bbf215e5ad457104580c624706feda Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 1 Mar 2011 13:04:09 -0500 Subject: Fix Gtk-Doc comment notation. Seeing lots of what I assume to be doxygen syntax in comment blocks. --- calendar/gui/alarm-notify/alarm-queue.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'calendar/gui/alarm-notify/alarm-queue.c') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 3bdd60a1b7..3f8cccb716 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -379,9 +379,10 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, /** * has_known_notification: * Test for notification method and returns if it knows it or not. - * @param comp Component with an alarm. - * @param alarm_uid ID of the alarm in the comp to test. - * @return TRUE when we know the notification type, FALSE otherwise. + * @comp: Component with an alarm. + * @alarm_uid: ID of the alarm in the comp to test. + * + * Returns: %TRUE when we know the notification type, %FALSE otherwise. */ static gboolean has_known_notification (ECalComponent *comp, const gchar *alarm_uid) @@ -2179,8 +2180,8 @@ alarm_queue_remove_async (struct _alarm_client_msg *msg) /** alarm_queue_remove_client * * asynchronously remove client from alarm queue. - * @param client Client to remove. - * @param immediately Indicates whether use thread or do it right now. + * @client: Client to remove. + * @immediately: Indicates whether use thread or do it right now. */ void -- cgit From cc4dd64854e652e4f6c8552069977088c87268bb Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 9 Mar 2011 08:56:56 +0100 Subject: Bug #637641 - Crash on audio alarms with invalid file URI set --- calendar/gui/alarm-notify/alarm-queue.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'calendar/gui/alarm-notify/alarm-queue.c') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 3f8cccb716..4f3233501c 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -1690,25 +1690,28 @@ audio_notification (time_t trigger, CompQueuedAlarms *cqa, if (attach && icalattach_get_is_url (attach)) { const gchar *url; - gchar *filename; - GError *error = NULL; url = icalattach_get_url (attach); - filename = g_filename_from_uri (url, NULL, &error); + if (url && *url) { + gchar *filename; + GError *error = NULL; - if (error != NULL) { - g_warning ("%s: %s", G_STRFUNC, error->message); - g_error_free (error); - } else if (g_file_test (filename, G_FILE_TEST_EXISTS)) { - flag = 1; + filename = g_filename_from_uri (url, NULL, &error); + + if (error != NULL) { + g_warning ("%s: %s", G_STRFUNC, error->message); + g_error_free (error); + } else if (filename && g_file_test (filename, G_FILE_TEST_EXISTS)) { #ifdef HAVE_CANBERRA - ca_context_play ( - ca_gtk_context_get (), 0, - CA_PROP_MEDIA_FILENAME, filename, NULL); + flag = 1; + ca_context_play ( + ca_gtk_context_get (), 0, + CA_PROP_MEDIA_FILENAME, filename, NULL); #endif - } + } - g_free (filename); + g_free (filename); + } } if (!flag) -- cgit From 4cfb84c573f21ca7519e24cff1c5742b715355c4 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 7 May 2011 12:22:36 -0400 Subject: Whitespace and coding style cleanups. --- calendar/gui/alarm-notify/alarm-queue.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'calendar/gui/alarm-notify/alarm-queue.c') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 4f3233501c..f3421ef31a 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -749,8 +749,6 @@ query_objects_changed_async (struct _query_msg *msg) day_end = time_day_end_with_zone (time (NULL), zone); - debug (("Querying for object between %s to %s", e_ctime (&from), e_ctime (&day_end))); - for (l = objects; l != NULL; l = l->next) { ECalComponentId *id; GSList *sl; -- cgit From 8a186c3588d3598857c36e2122fa68d01eba30fd Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 8 May 2011 13:24:42 -0400 Subject: Coding style cleanups. --- calendar/gui/alarm-notify/alarm-queue.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'calendar/gui/alarm-notify/alarm-queue.c') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index f3421ef31a..fd79d1f80c 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -1486,7 +1486,7 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, e_cal_component_get_description_list (comp, &text_list); if (text_list) { - text = *((ECalComponentText *)text_list->data); + text = *((ECalComponentText *) text_list->data); if (text.value) description = text.value; else @@ -2103,14 +2103,14 @@ remove_cqa (ClientAlarms *ca, ECalComponentId *id, CompQueuedAlarms *cqa) static gboolean remove_comp_by_id (gpointer key, gpointer value, gpointer userdata) { - ClientAlarms *ca = (ClientAlarms *)userdata; + ClientAlarms *ca = (ClientAlarms *) userdata; debug (("...")); /* if (!g_hash_table_size (ca->uid_alarms_hash)) */ /* return; */ - remove_cqa (ca, (ECalComponentId *)key, (CompQueuedAlarms *) value); + remove_cqa (ca, (ECalComponentId *) key, (CompQueuedAlarms *) value); return TRUE; } @@ -2121,7 +2121,7 @@ remove_client_alarms (ClientAlarms *ca) { debug (("size %d", g_hash_table_size (ca->uid_alarms_hash))); - g_hash_table_foreach_remove (ca->uid_alarms_hash, (GHRFunc)remove_comp_by_id, ca); + g_hash_table_foreach_remove (ca->uid_alarms_hash, (GHRFunc) remove_comp_by_id, ca); /* The hash table should be empty now */ g_return_if_fail (g_hash_table_size (ca->uid_alarms_hash) == 0); -- cgit From cb97c2dc8fd97b381af048f206333d5e557892ae Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 21 May 2011 10:02:58 -0400 Subject: Coding style and whitespace cleanup. --- calendar/gui/alarm-notify/alarm-queue.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'calendar/gui/alarm-notify/alarm-queue.c') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index fd79d1f80c..816183dc4a 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -187,10 +187,11 @@ create_thread_pool (void) static void message_push (Message *msg) { - /* This used be pushed through the thread pool. This fix is made to work-around - the crashers in dbus due to threading. The threading is not completely removed as - its better to have alarm daemon running in a thread rather than blocking main thread. - This is the reason the creation of thread pool is commented out */ + /* This used be pushed through the thread pool. This fix is made to + * work-around the crashers in dbus due to threading. The threading + * is not completely removed as its better to have alarm daemon + * running in a thread rather than blocking main thread. This is + * the reason the creation of thread pool is commented out. */ msg->func (msg); } @@ -784,7 +785,8 @@ query_objects_changed_async (struct _query_msg *msg) * remove it after updating the cqa structure. */ if (alarms == NULL || alarms->alarms == NULL) { - /* update the cqa and its queued alarms for changes in summary and alarm_uid */ + /* Update the cqa and its queued alarms + * for changes in summary and alarm_uid. */ update_cqa (cqa, comp); if (alarms) @@ -805,16 +807,12 @@ query_objects_changed_async (struct _query_msg *msg) instance = sl->data; - if (!has_known_notification (cqa->alarms->comp, instance->auid)) { - g_debug ("Could not recognize alarm's notification type, discarding."); + if (!has_known_notification (cqa->alarms->comp, instance->auid)) continue; - } alarm_id = alarm_add (instance->trigger, alarm_trigger_cb, cqa, NULL); - if (!alarm_id) { - debug (("Unable to schedule trigger for %s", e_ctime (&(instance->trigger)))); + if (!alarm_id) continue; - } qa = g_new (QueuedAlarm, 1); qa->alarm_id = alarm_id; @@ -1149,7 +1147,9 @@ tray_list_remove_async (Message *msg) gboolean status; tray_icons_list = g_list_remove_link (tray_icons_list, list); - status = remove_queued_alarm (tray_data->cqa, tray_data->alarm_id, FALSE, TRUE); + status = remove_queued_alarm ( + tray_data->cqa, + tray_data->alarm_id, FALSE, TRUE); if (status) { g_hash_table_remove ( tray_data->cqa->parent_client->uid_alarms_hash, -- cgit From 394e580dfdb04342c2e457ced400908e4dd5c88e Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 28 May 2011 10:18:56 -0400 Subject: Including directly is rarely needed. --- calendar/gui/alarm-notify/alarm-queue.c | 1 - 1 file changed, 1 deletion(-) (limited to 'calendar/gui/alarm-notify/alarm-queue.c') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 816183dc4a..42dc10c6e9 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -27,7 +27,6 @@ #endif #include -#include #include #include -- cgit From f014ab82c81078d60cb1df8c986305c2cc9948c2 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 4 Jun 2011 15:53:10 -0500 Subject: Coding style and whitespace cleanups. --- calendar/gui/alarm-notify/alarm-queue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'calendar/gui/alarm-notify/alarm-queue.c') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 42dc10c6e9..e8e5485e45 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -2120,7 +2120,8 @@ remove_client_alarms (ClientAlarms *ca) { debug (("size %d", g_hash_table_size (ca->uid_alarms_hash))); - g_hash_table_foreach_remove (ca->uid_alarms_hash, (GHRFunc) remove_comp_by_id, ca); + g_hash_table_foreach_remove ( + ca->uid_alarms_hash, (GHRFunc) remove_comp_by_id, ca); /* The hash table should be empty now */ g_return_if_fail (g_hash_table_size (ca->uid_alarms_hash) == 0); -- cgit From 38790d8478e906a5c59d0c4a5216f297f305bfeb Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 14 Jun 2011 08:54:20 +0200 Subject: Do not use deprecated EBook/ECal API --- calendar/gui/alarm-notify/alarm-queue.c | 318 ++++++++++++++++++-------------- 1 file changed, 177 insertions(+), 141 deletions(-) (limited to 'calendar/gui/alarm-notify/alarm-queue.c') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index e8e5485e45..fde985f8be 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -34,6 +34,7 @@ #include #endif +#include #include #include @@ -69,10 +70,10 @@ static AlarmNotify *an; /* Structure that stores a client we are monitoring */ typedef struct { /* Monitored client */ - ECal *client; + ECalClient *cal_client; - /* The live query to the calendar */ - ECalView *query; + /* The live view to the calendar */ + ECalClientView *view; /* Hash table of component UID -> CompQueuedAlarms. If an element is * present here, then it means its cqa->queued_alarms contains at least @@ -142,17 +143,17 @@ static void popup_notification (time_t trigger, gpointer alarm_id, gboolean use_description); #endif -static void query_objects_changed_cb (ECal *client, - GList *objects, +static void query_objects_modified_cb (ECalClientView *view, + const GSList *objects, gpointer data); -static void query_objects_removed_cb (ECal *client, - GList *objects, +static void query_objects_removed_cb (ECalClientView *view, + const GSList *uids, gpointer data); static void update_cqa (CompQueuedAlarms *cqa, ECalComponent *comp); static void update_qa (ECalComponentAlarms *alarms, QueuedAlarm *qa); static void tray_list_remove_cqa (CompQueuedAlarms *cqa); -static void on_dialog_objs_removed_cb (ECal *client, GList *objects, gpointer data); +static void on_dialog_objs_removed_cb (ECalClientView *view, const GSList *uids, gpointer data); /* Alarm queue engine */ @@ -299,9 +300,9 @@ midnight_refresh_cb (gpointer alarm_id, time_t trigger, gpointer data) /* Looks up a client in the client alarms hash table */ static ClientAlarms * -lookup_client (ECal *client) +lookup_client (ECalClient *cal_client) { - return g_hash_table_lookup (client_alarms_hash, client); + return g_hash_table_lookup (client_alarms_hash, cal_client); } /* Looks up a queued alarm based on its alarm ID */ @@ -347,10 +348,21 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, cqa->queued_alarms = g_slist_delete_link (cqa->queued_alarms, l); if (remove_alarm) { - cqa->expecting_update = TRUE; - e_cal_discard_alarm (cqa->parent_client->client, cqa->alarms->comp, - qa->instance->auid, NULL); - cqa->expecting_update = FALSE; + GError *error = NULL; + ECalComponentId *id = e_cal_component_get_id (cqa->alarms->comp); + if (id) { + cqa->expecting_update = TRUE; + e_cal_client_discard_alarm_sync (cqa->parent_client->cal_client, id->uid, id->rid, + qa->instance->auid, NULL, &error); + cqa->expecting_update = FALSE; + + if (error) { + if (!g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_NOT_SUPPORTED)) + g_debug ("%s: Failed to discard alarm: %s", G_STRFUNC, error->message); + g_error_free (error); + } + e_cal_component_free_id (id); + } } g_free (qa); @@ -425,7 +437,7 @@ alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data) cqa = data; comp = cqa->alarms->comp; - config_data_set_last_notification_time (cqa->parent_client->client, trigger); + config_data_set_last_notification_time (cqa->parent_client->cal_client, trigger); debug (("Setting Last notification time to %s", e_ctime (&trigger))); qa = lookup_queued_alarm (cqa, alarm_id); @@ -543,6 +555,7 @@ static void load_alarms (ClientAlarms *ca, time_t start, time_t end) { gchar *str_query, *iso_start, *iso_end; + GError *error = NULL; debug (("...")); @@ -563,31 +576,36 @@ load_alarms (ClientAlarms *ca, time_t start, time_t end) g_free (iso_end); /* create the live query */ - if (ca->query) { + if (ca->view) { debug (("Disconnecting old queries")); g_signal_handlers_disconnect_matched ( - ca->query, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); - g_object_unref (ca->query); - ca->query = NULL; + ca->view, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); + g_object_unref (ca->view); + ca->view = NULL; } - /* FIXME: handle errors */ - if (!e_cal_get_query (ca->client, str_query, &ca->query, NULL)) { - g_warning (G_STRLOC ": Could not get query for client"); + if (!e_cal_client_get_view_sync (ca->cal_client, str_query, &ca->view, NULL, &error)) { + g_debug ("%s: Could not get query for client: %s", error ? error->message : "Unknown error", G_STRFUNC); + if (error) + g_error_free (error); } else { debug (("Setting Call backs")); g_signal_connect ( - ca->query, "objects_added", - G_CALLBACK (query_objects_changed_cb), ca); + ca->view, "objects-added", + G_CALLBACK (query_objects_modified_cb), ca); g_signal_connect ( - ca->query, "objects_modified", - G_CALLBACK (query_objects_changed_cb), ca); + ca->view, "objects-modified", + G_CALLBACK (query_objects_modified_cb), ca); g_signal_connect ( - ca->query, "objects_removed", + ca->view, "objects-removed", G_CALLBACK (query_objects_removed_cb), ca); - e_cal_view_start (ca->query); + e_cal_client_view_start (ca->view, &error); + if (error) { + g_debug ("%s: Failed to start view: %s", G_STRFUNC, error->message); + g_error_free (error); + } } g_free (str_query); @@ -609,7 +627,7 @@ load_alarms_for_today (ClientAlarms *ca) * half-open; we do not want to display the "last" displayed alarm * twice, once when it occurs and once when the alarm daemon restarts. */ - from = config_data_get_last_notification_time (ca->client) + 1; + from = config_data_get_last_notification_time (ca->cal_client) + 1; if (from <= 0) from = MAX (from, day_start); @@ -618,20 +636,6 @@ load_alarms_for_today (ClientAlarms *ca) load_alarms (ca, from, day_end); } -/* Called when a calendar client finished loading; we load its alarms */ -static void -cal_opened_cb (ECal *client, const GError *error, gpointer data) -{ - ClientAlarms *ca; - - ca = data; - - if (error) - return; - - load_alarms_for_today (ca); -} - /* Looks up a component's queued alarm structure in a client alarms structure */ static CompQueuedAlarms * lookup_comp_queued_alarms (ClientAlarms *ca, const ECalComponentId *id) @@ -693,35 +697,71 @@ remove_comp (ClientAlarms *ca, ECalComponentId *id) */ struct _query_msg { Message header; - GList *objects; + GSList *objects; gpointer data; }; -static GList * -duplicate_ical (GList *in_list) +static GSList * +duplicate_ical (const GSList *in_list) { - GList *l, *out_list = NULL; + const GSList *l; + GSList *out_list = NULL; for (l = in_list; l; l = l->next) { - out_list = g_list_prepend (out_list, icalcomponent_new_clone (l->data)); + out_list = g_slist_prepend (out_list, icalcomponent_new_clone (l->data)); } - return g_list_reverse (out_list); + return g_slist_reverse (out_list); } -static GList * -duplicate_ecal (GList *in_list) +static GSList * +duplicate_ecal (const GSList *in_list) { - GList *l, *out_list = NULL; + const GSList *l; + GSList *out_list = NULL; for (l = in_list; l; l = l->next) { ECalComponentId *id, *old; old = l->data; id = g_new0 (ECalComponentId, 1); id->uid = g_strdup (old->uid); id->rid = g_strdup (old->rid); - out_list = g_list_prepend (out_list, id); + out_list = g_slist_prepend (out_list, id); + } + + return g_slist_reverse (out_list); +} + +static gboolean +get_alarms_for_object (ECalClient *cal_client, const ECalComponentId *id, time_t start, time_t end, ECalComponentAlarms **alarms) +{ + icalcomponent *icalcomp; + ECalComponent *comp; + ECalComponentAlarmAction omit[] = {-1}; + + g_return_val_if_fail (cal_client != NULL, FALSE); + g_return_val_if_fail (id != NULL, FALSE); + g_return_val_if_fail (alarms != NULL, FALSE); + g_return_val_if_fail (start >= 0 && end >= 0, FALSE); + g_return_val_if_fail (start <= end, FALSE); + + if (!e_cal_client_get_object_sync (cal_client, id->uid, id->rid, &icalcomp, NULL, NULL)) + return FALSE; + + if (!icalcomp) + return FALSE; + + comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (comp, icalcomp)) { + icalcomponent_free (icalcomp); + g_object_unref (comp); + return FALSE; } - return g_list_reverse (out_list); + *alarms = e_cal_util_generate_alarms_for_comp (comp, start, end, omit, e_cal_client_resolve_tzid_cb, + cal_client, e_cal_client_get_default_timezone (cal_client)); + + g_object_unref (comp); + + return TRUE; } static void @@ -733,13 +773,13 @@ query_objects_changed_async (struct _query_msg *msg) gboolean found; icaltimezone *zone; CompQueuedAlarms *cqa; - GList *l; - GList *objects; + GSList *l; + GSList *objects; ca = msg->data; objects = msg->objects; - from = config_data_get_last_notification_time (ca->client); + from = config_data_get_last_notification_time (ca->cal_client); if (from == -1) from = time (NULL); else @@ -757,10 +797,10 @@ query_objects_changed_async (struct _query_msg *msg) e_cal_component_set_icalcomponent (comp, l->data); id = e_cal_component_get_id (comp); - found = e_cal_get_alarms_for_object (ca->client, id, from, day_end, &alarms); + found = get_alarms_for_object (ca->cal_client, id, from, day_end, &alarms); if (!found) { - debug (("No Alarm found for client %p", ca->client)); + debug (("No Alarm found for client %p", ca->cal_client)); tray_list_remove_cqa (lookup_comp_queued_alarms (ca, id)); remove_comp (ca, id); g_hash_table_remove (ca->uid_alarms_hash, id); @@ -826,13 +866,13 @@ query_objects_changed_async (struct _query_msg *msg) g_object_unref (comp); comp = NULL; } - g_list_free (objects); + g_slist_free (objects); g_slice_free (struct _query_msg, msg); } static void -query_objects_changed_cb (ECal *client, GList *objects, gpointer data) +query_objects_modified_cb (ECalClientView *view, const GSList *objects, gpointer data) { struct _query_msg *msg; @@ -851,13 +891,13 @@ static void query_objects_removed_async (struct _query_msg *msg) { ClientAlarms *ca; - GList *l; - GList *objects; + GSList *l; + GSList *objects; ca = msg->data; objects = msg->objects; - debug (("Removing %d objects", g_list_length (objects))); + debug (("Removing %d objects", g_slist_length (objects))); for (l = objects; l != NULL; l = l->next) { /* If the alarm is already triggered remove it. */ @@ -867,19 +907,19 @@ query_objects_removed_async (struct _query_msg *msg) e_cal_component_free_id (l->data); } - g_list_free (objects); + g_slist_free (objects); g_slice_free (struct _query_msg, msg); } static void -query_objects_removed_cb (ECal *client, GList *objects, gpointer data) +query_objects_removed_cb (ECalClientView *view, const GSList *uids, gpointer data) { struct _query_msg *msg; msg = g_slice_new0 (struct _query_msg); msg->header.func = (MessageFunc) query_objects_removed_async; - msg->objects = duplicate_ecal (objects); + msg->objects = duplicate_ecal (uids); msg->data = data; message_push ((Message *) msg); @@ -919,7 +959,7 @@ create_snooze (CompQueuedAlarms *cqa, gpointer alarm_id, gint snooze_mins) /* Launches a component editor for a component */ static void -edit_component (ECal *client, ECalComponent *comp) +edit_component (ECalClient *cal_client, ECalComponent *comp) { ESource *source; gchar *command_line; @@ -931,19 +971,19 @@ edit_component (ECal *client, ECalComponent *comp) /* XXX Don't we have a function to construct these URIs? * How are other apps expected to know this stuff? */ - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (cal_client)); source_uid = e_source_peek_uid (source); e_cal_component_get_uid (comp, &comp_uid); - switch (e_cal_get_source_type (client)) { - case E_CAL_SOURCE_TYPE_EVENT: + switch (e_cal_client_get_source_type (cal_client)) { + case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: scheme = "calendar:"; break; - case E_CAL_SOURCE_TYPE_TODO: + case E_CAL_CLIENT_SOURCE_TYPE_TASKS: scheme = "task:"; break; - case E_CAL_SOURCE_TYPE_JOURNAL: + case E_CAL_CLIENT_SOURCE_TYPE_MEMOS: scheme = "memo:"; break; default: @@ -973,8 +1013,8 @@ typedef struct { CompQueuedAlarms *cqa; gpointer alarm_id; ECalComponent *comp; - ECal *client; - ECalView *query; + ECalClient *cal_client; + ECalClientView *view; GdkPixbuf *image; GtkTreeIter iter; } TrayIconData; @@ -999,13 +1039,13 @@ free_tray_icon_data (TrayIconData *tray_data) tray_data->location = NULL; } - g_object_unref (tray_data->client); - tray_data->client = NULL; + g_object_unref (tray_data->cal_client); + tray_data->cal_client = NULL; - g_signal_handlers_disconnect_matched (tray_data->query, G_SIGNAL_MATCH_FUNC, + g_signal_handlers_disconnect_matched (tray_data->view, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, on_dialog_objs_removed_cb, NULL); - g_object_unref (tray_data->query); - tray_data->query = NULL; + g_object_unref (tray_data->view); + tray_data->view = NULL; g_object_unref (tray_data->comp); tray_data->comp = NULL; @@ -1020,44 +1060,47 @@ free_tray_icon_data (TrayIconData *tray_data) static void on_dialog_objs_removed_async (struct _query_msg *msg) { - const gchar *our_uid; - GList *l; TrayIconData *tray_data; - GList *objects; + GSList *l, *objects; + ECalComponentId *our_id; debug (("...")); tray_data = msg->data; objects = msg->objects; - e_cal_component_get_uid (tray_data->comp, &our_uid); - g_return_if_fail (our_uid && *our_uid); + our_id = e_cal_component_get_id (tray_data->comp); + g_return_if_fail (our_id); for (l = objects; l != NULL; l = l->next) { - const gchar *uid = l->data; + ECalComponentId *id = l->data; - if (!uid) + if (!id) continue; - if (!strcmp (uid, our_uid)) { + if (g_strcmp0 (id->uid, our_id->uid) == 0&& g_strcmp0 (id->rid, our_id->rid) == 0) { tray_data->cqa = NULL; tray_data->alarm_id = NULL; tray_icons_list = g_list_remove (tray_icons_list, tray_data); tray_data = NULL; } + + e_cal_component_free_id (id); } + e_cal_component_free_id (our_id); + g_slist_free (objects); g_slice_free (struct _query_msg, msg); } static void -on_dialog_objs_removed_cb (ECal *client, GList *objects, gpointer data) +on_dialog_objs_removed_cb (ECalClientView *view, const GSList *uids, gpointer data) { struct _query_msg *msg; msg = g_slice_new0 (struct _query_msg); msg->header.func = (MessageFunc) on_dialog_objs_removed_async; - msg->objects = objects; + msg->objects = duplicate_ecal (uids); msg->data = data; message_push ((Message *) msg); @@ -1219,7 +1262,7 @@ notify_dialog_cb (AlarmNotifyResult result, gint snooze_mins, gpointer data) debug (("Received from dialog")); - g_signal_handlers_disconnect_matched (tray_data->query, G_SIGNAL_MATCH_FUNC, + g_signal_handlers_disconnect_matched (tray_data->view, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, on_dialog_objs_removed_cb, NULL); switch (result) { @@ -1254,7 +1297,7 @@ notify_dialog_cb (AlarmNotifyResult result, gint snooze_mins, gpointer data) break; case ALARM_NOTIFY_EDIT: - edit_component (tray_data->client, tray_data->comp); + edit_component (tray_data->cal_client, tray_data->comp); break; @@ -1530,11 +1573,11 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, tray_data->cqa = cqa; tray_data->alarm_id = alarm_id; tray_data->comp = g_object_ref (e_cal_component_clone (comp)); - tray_data->client = cqa->parent_client->client; - tray_data->query = g_object_ref (cqa->parent_client->query); + tray_data->cal_client = cqa->parent_client->cal_client; + tray_data->view = g_object_ref (cqa->parent_client->view); tray_data->blink_state = FALSE; tray_data->snooze_set = FALSE; - g_object_ref (tray_data->client); + g_object_ref (tray_data->cal_client); /* Task to add tray_data to the global tray_icon_list */ tray_list_add_new (tray_data); @@ -1558,7 +1601,7 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, g_free (time_str); g_free (str); - g_signal_connect (G_OBJECT (tray_data->query), "objects_removed", + g_signal_connect (G_OBJECT (tray_data->view), "objects_removed", G_CALLBACK (on_dialog_objs_removed_cb), tray_data); /* FIXME: We should remove this check */ @@ -1731,8 +1774,7 @@ mail_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id) debug (("...")); - if (!e_cal_get_static_capability (cqa->parent_client->client, - CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS)) + if (!e_client_check_capability (E_CLIENT (cqa->parent_client->cal_client), CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS)) return; dialog = gtk_dialog_new_with_buttons (_("Warning"), @@ -1932,20 +1974,20 @@ free_client_alarms_cb (gpointer key, gpointer value, gpointer user_data) if (ca) { remove_client_alarms (ca); - if (ca->client) { + if (ca->cal_client) { debug (("Disconnecting Client")); - g_signal_handlers_disconnect_matched (ca->client, G_SIGNAL_MATCH_DATA, + g_signal_handlers_disconnect_matched (ca->cal_client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); - g_object_unref (ca->client); + g_object_unref (ca->cal_client); } - if (ca->query) { + if (ca->view) { debug (("Disconnecting Query")); - g_signal_handlers_disconnect_matched (ca->query, G_SIGNAL_MATCH_DATA, + g_signal_handlers_disconnect_matched (ca->view, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); - g_object_unref (ca->query); + g_object_unref (ca->view); } g_hash_table_destroy (ca->uid_alarms_hash); @@ -2016,52 +2058,46 @@ hash_ids (gpointer a) struct _alarm_client_msg { Message header; - ECal *client; + ECalClient *cal_client; }; static void alarm_queue_add_async (struct _alarm_client_msg *msg) { ClientAlarms *ca; - ECal *client = msg->client; + ECalClient *cal_client = msg->cal_client; g_return_if_fail (alarm_queue_inited); - g_return_if_fail (client != NULL); - g_return_if_fail (E_IS_CAL (client)); + g_return_if_fail (cal_client != NULL); + g_return_if_fail (E_IS_CAL_CLIENT (cal_client)); - ca = lookup_client (client); + ca = lookup_client (cal_client); if (ca) { /* We already have it. Unref the passed one*/ - g_object_unref (client); + g_object_unref (cal_client); return; } - debug (("client=%p", client)); + debug (("client=%p", cal_client)); ca = g_new (ClientAlarms, 1); - ca->client = client; - ca->query = NULL; + ca->cal_client = cal_client; + ca->view = NULL; - g_hash_table_insert (client_alarms_hash, client, ca); + g_hash_table_insert (client_alarms_hash, cal_client, ca); ca->uid_alarms_hash = g_hash_table_new ( (GHashFunc) hash_ids, (GEqualFunc) compare_ids); - if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) { - load_alarms_for_today (ca); - } else { - g_signal_connect (client, "cal_opened_ex", - G_CALLBACK (cal_opened_cb), - ca); - } + load_alarms_for_today (ca); g_slice_free (struct _alarm_client_msg, msg); } /** * alarm_queue_add_client: - * @client: A calendar client. + * @cal_client: A calendar client. * * Adds a calendar client to the alarm queueing system. Alarm trigger * notifications will be presented at the appropriate times. The client should @@ -2074,13 +2110,13 @@ alarm_queue_add_async (struct _alarm_client_msg *msg) * queueing system when it is no longer wanted. **/ void -alarm_queue_add_client (ECal *client) +alarm_queue_add_client (ECalClient *cal_client) { struct _alarm_client_msg *msg; msg = g_slice_new0 (struct _alarm_client_msg); msg->header.func = (MessageFunc) alarm_queue_add_async; - msg->client = g_object_ref (client); + msg->cal_client = g_object_ref (cal_client); message_push ((Message *) msg); } @@ -2137,35 +2173,35 @@ static void alarm_queue_remove_async (struct _alarm_client_msg *msg) { ClientAlarms *ca; - ECal *client = msg->client; + ECalClient *cal_client = msg->cal_client; g_return_if_fail (alarm_queue_inited); - g_return_if_fail (client != NULL); - g_return_if_fail (E_IS_CAL (client)); + g_return_if_fail (cal_client != NULL); + g_return_if_fail (E_IS_CAL_CLIENT (cal_client)); - ca = lookup_client (client); + ca = lookup_client (cal_client); g_return_if_fail (ca != NULL); debug (("...")); remove_client_alarms (ca); /* Clean up */ - if (ca->client) { + if (ca->cal_client) { debug (("Disconnecting Client")); - g_signal_handlers_disconnect_matched (ca->client, G_SIGNAL_MATCH_DATA, + g_signal_handlers_disconnect_matched (ca->cal_client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); - g_object_unref (ca->client); - ca->client = NULL; + g_object_unref (ca->cal_client); + ca->cal_client = NULL; } - if (ca->query) { + if (ca->view) { debug (("Disconnecting Query")); - g_signal_handlers_disconnect_matched (ca->query, G_SIGNAL_MATCH_DATA, + g_signal_handlers_disconnect_matched (ca->view, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); - g_object_unref (ca->query); - ca->query = NULL; + g_object_unref (ca->view); + ca->view = NULL; } g_hash_table_destroy (ca->uid_alarms_hash); @@ -2173,7 +2209,7 @@ alarm_queue_remove_async (struct _alarm_client_msg *msg) g_free (ca); - g_hash_table_remove (client_alarms_hash, client); + g_hash_table_remove (client_alarms_hash, cal_client); g_slice_free (struct _alarm_client_msg, msg); } @@ -2181,18 +2217,18 @@ alarm_queue_remove_async (struct _alarm_client_msg *msg) /** alarm_queue_remove_client * * asynchronously remove client from alarm queue. - * @client: Client to remove. + * @cal_client: Client to remove. * @immediately: Indicates whether use thread or do it right now. */ void -alarm_queue_remove_client (ECal *client, gboolean immediately) +alarm_queue_remove_client (ECalClient *cal_client, gboolean immediately) { struct _alarm_client_msg *msg; msg = g_slice_new0 (struct _alarm_client_msg); msg->header.func = (MessageFunc) alarm_queue_remove_async; - msg->client = client; + msg->cal_client = cal_client; if (immediately) { alarm_queue_remove_async (msg); @@ -2220,7 +2256,7 @@ update_cqa (CompQueuedAlarms *cqa, ECalComponent *newcomp) debug (("Generating alarms between %s and %s", e_ctime (&from), e_ctime (&to))); alarms = e_cal_util_generate_alarms_for_comp (newcomp, from, to, omit, - e_cal_resolve_tzid_cb, cqa->parent_client->client, zone); + e_cal_client_resolve_tzid_cb, cqa->parent_client->cal_client, zone); /* Update auids in Queued Alarms*/ for (qa_list = cqa->queued_alarms; qa_list; qa_list = qa_list->next) { -- cgit From 444011c99f83b1b3afde86862e7efe7fc348744d Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Tue, 2 Aug 2011 11:29:12 +0200 Subject: Replace alarm by reminder for UI consistency. Fixes bug #340614 --- calendar/gui/alarm-notify/alarm-queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'calendar/gui/alarm-notify/alarm-queue.c') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index fde985f8be..7ba2ff9005 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -1586,7 +1586,7 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, gchar *tip; tip = g_strdup_printf (ngettext ( - "You have %d alarm", "You have %d alarms", + "You have %d reminder", "You have %d reminders", g_list_length (tray_icons_list)), g_list_length (tray_icons_list)); gtk_status_icon_set_tooltip_text (tray_icon, tip); -- cgit From f59681796df8fe0138a1754abbe8ec781bc1535e Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 1 Jul 2011 00:07:26 -0400 Subject: Coding style and whitespace cleanup. --- calendar/gui/alarm-notify/alarm-queue.c | 293 ++++++++++++++++++++------------ 1 file changed, 186 insertions(+), 107 deletions(-) (limited to 'calendar/gui/alarm-notify/alarm-queue.c') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 7ba2ff9005..c143429f8f 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -150,15 +150,21 @@ static void query_objects_removed_cb (ECalClientView *view, const GSList *uids, gpointer data); -static void update_cqa (CompQueuedAlarms *cqa, ECalComponent *comp); -static void update_qa (ECalComponentAlarms *alarms, QueuedAlarm *qa); -static void tray_list_remove_cqa (CompQueuedAlarms *cqa); -static void on_dialog_objs_removed_cb (ECalClientView *view, const GSList *uids, gpointer data); +static void update_cqa (CompQueuedAlarms *cqa, + ECalComponent *comp); +static void update_qa (ECalComponentAlarms *alarms, + QueuedAlarm *qa); +static void tray_list_remove_cqa (CompQueuedAlarms *cqa); +static void on_dialog_objs_removed_cb (ECalClientView *view, + const GSList *uids, + gpointer data); /* Alarm queue engine */ -static void load_alarms_for_today (ClientAlarms *ca); -static void midnight_refresh_cb (gpointer alarm_id, time_t trigger, gpointer data); +static void load_alarms_for_today (ClientAlarms *ca); +static void midnight_refresh_cb (gpointer alarm_id, + time_t trigger, + gpointer data); /* Simple asynchronous message dispatcher */ @@ -224,9 +230,8 @@ e_ctime (const time_t *timep) return ret; } -/* Queues an alarm trigger for midnight so that we can load the next day's worth - * of alarms. - */ +/* Queues an alarm trigger for midnight so that we can load the next + * day's worth of alarms. */ static void queue_midnight_refresh (void) { @@ -242,7 +247,8 @@ queue_midnight_refresh (void) debug (("Refresh at %s", e_ctime (&midnight))); - midnight_refresh_id = alarm_add (midnight, midnight_refresh_cb, NULL, NULL); + midnight_refresh_id = alarm_add ( + midnight, midnight_refresh_cb, NULL, NULL); if (!midnight_refresh_id) { debug (("Could not setup the midnight refresh alarm")); /* FIXME: what to do? */ @@ -251,7 +257,9 @@ queue_midnight_refresh (void) /* Loads a client's alarms; called from g_hash_table_foreach() */ static void -add_client_alarms_cb (gpointer key, gpointer value, gpointer data) +add_client_alarms_cb (gpointer key, + gpointer value, + gpointer data) { ClientAlarms *ca = (ClientAlarms *) value; @@ -287,7 +295,9 @@ midnight_refresh_async (struct _midnight_refresh_msg *msg) } static void -midnight_refresh_cb (gpointer alarm_id, time_t trigger, gpointer data) +midnight_refresh_cb (gpointer alarm_id, + time_t trigger, + gpointer data) { struct _midnight_refresh_msg *msg; @@ -307,7 +317,8 @@ lookup_client (ECalClient *cal_client) /* Looks up a queued alarm based on its alarm ID */ static QueuedAlarm * -lookup_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id) +lookup_queued_alarm (CompQueuedAlarms *cqa, + gpointer alarm_id) { GSList *l; QueuedAlarm *qa; @@ -328,8 +339,10 @@ lookup_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id) * the last one listed for the component, it removes the component itself. */ static gboolean -remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, - gboolean free_object, gboolean remove_alarm) +remove_queued_alarm (CompQueuedAlarms *cqa, + gpointer alarm_id, + gboolean free_object, + gboolean remove_alarm) { QueuedAlarm *qa=NULL; GSList *l; @@ -349,16 +362,21 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, if (remove_alarm) { GError *error = NULL; - ECalComponentId *id = e_cal_component_get_id (cqa->alarms->comp); + ECalComponentId *id; + + id = e_cal_component_get_id (cqa->alarms->comp); if (id) { cqa->expecting_update = TRUE; - e_cal_client_discard_alarm_sync (cqa->parent_client->cal_client, id->uid, id->rid, - qa->instance->auid, NULL, &error); + e_cal_client_discard_alarm_sync ( + cqa->parent_client->cal_client, id->uid, + id->rid, qa->instance->auid, NULL, &error); cqa->expecting_update = FALSE; if (error) { if (!g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_NOT_SUPPORTED)) - g_debug ("%s: Failed to discard alarm: %s", G_STRFUNC, error->message); + g_warning ( + "%s: Failed to discard alarm: %s", + G_STRFUNC, error->message); g_error_free (error); } e_cal_component_free_id (id); @@ -397,7 +415,8 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, * Returns: %TRUE when we know the notification type, %FALSE otherwise. */ static gboolean -has_known_notification (ECalComponent *comp, const gchar *alarm_uid) +has_known_notification (ECalComponent *comp, + const gchar *alarm_uid) { ECalComponentAlarm *alarm; ECalComponentAlarmAction action; @@ -413,20 +432,23 @@ has_known_notification (ECalComponent *comp, const gchar *alarm_uid) e_cal_component_alarm_free (alarm); switch (action) { - case E_CAL_COMPONENT_ALARM_AUDIO: - case E_CAL_COMPONENT_ALARM_DISPLAY: - case E_CAL_COMPONENT_ALARM_EMAIL: - case E_CAL_COMPONENT_ALARM_PROCEDURE: - return TRUE; - default: - break; + case E_CAL_COMPONENT_ALARM_AUDIO: + case E_CAL_COMPONENT_ALARM_DISPLAY: + case E_CAL_COMPONENT_ALARM_EMAIL: + case E_CAL_COMPONENT_ALARM_PROCEDURE: + return TRUE; + default: + break; } + return FALSE; } /* Callback used when an alarm triggers */ static void -alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data) +alarm_trigger_cb (gpointer alarm_id, + time_t trigger, + gpointer data) { CompQueuedAlarms *cqa; ECalComponent *comp; @@ -437,7 +459,8 @@ alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data) cqa = data; comp = cqa->alarms->comp; - config_data_set_last_notification_time (cqa->parent_client->cal_client, trigger); + config_data_set_last_notification_time ( + cqa->parent_client->cal_client, trigger); debug (("Setting Last notification time to %s", e_ctime (&trigger))); qa = lookup_queued_alarm (cqa, alarm_id); @@ -487,7 +510,8 @@ alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data) * particular client. Also puts the triggers in the alarm timer queue. */ static void -add_component_alarms (ClientAlarms *ca, ECalComponentAlarms *alarms) +add_component_alarms (ClientAlarms *ca, + ECalComponentAlarms *alarms) { ECalComponentId *id; CompQueuedAlarms *cqa; @@ -584,10 +608,14 @@ load_alarms (ClientAlarms *ca, time_t start, time_t end) ca->view = NULL; } - if (!e_cal_client_get_view_sync (ca->cal_client, str_query, &ca->view, NULL, &error)) { - g_debug ("%s: Could not get query for client: %s", error ? error->message : "Unknown error", G_STRFUNC); - if (error) - g_error_free (error); + e_cal_client_get_view_sync ( + ca->cal_client, str_query, &ca->view, NULL, &error); + + if (error != NULL) { + g_warning ( + "%s: Could not get query for client: %s", + G_STRFUNC, error->message); + g_error_free (error); } else { debug (("Setting Call backs")); @@ -602,8 +630,11 @@ load_alarms (ClientAlarms *ca, time_t start, time_t end) G_CALLBACK (query_objects_removed_cb), ca); e_cal_client_view_start (ca->view, &error); - if (error) { - g_debug ("%s: Failed to start view: %s", G_STRFUNC, error->message); + + if (error != NULL) { + g_warning ( + "%s: Failed to start view: %s", + G_STRFUNC, error->message); g_error_free (error); } } @@ -638,13 +669,15 @@ load_alarms_for_today (ClientAlarms *ca) /* Looks up a component's queued alarm structure in a client alarms structure */ static CompQueuedAlarms * -lookup_comp_queued_alarms (ClientAlarms *ca, const ECalComponentId *id) +lookup_comp_queued_alarms (ClientAlarms *ca, + const ECalComponentId *id) { return g_hash_table_lookup (ca->uid_alarms_hash, id); } static void -remove_alarms (CompQueuedAlarms *cqa, gboolean free_object) +remove_alarms (CompQueuedAlarms *cqa, + gboolean free_object) { GSList *l; @@ -663,12 +696,12 @@ remove_alarms (CompQueuedAlarms *cqa, gboolean free_object) alarm_remove (qa->alarm_id); remove_queued_alarm (cqa, qa->alarm_id, free_object, FALSE); } - } /* Removes a component an its alarms */ static void -remove_comp (ClientAlarms *ca, ECalComponentId *id) +remove_comp (ClientAlarms *ca, + ECalComponentId *id) { CompQueuedAlarms *cqa; @@ -707,7 +740,8 @@ duplicate_ical (const GSList *in_list) const GSList *l; GSList *out_list = NULL; for (l = in_list; l; l = l->next) { - out_list = g_slist_prepend (out_list, icalcomponent_new_clone (l->data)); + out_list = g_slist_prepend ( + out_list, icalcomponent_new_clone (l->data)); } return g_slist_reverse (out_list); @@ -731,7 +765,11 @@ duplicate_ecal (const GSList *in_list) } static gboolean -get_alarms_for_object (ECalClient *cal_client, const ECalComponentId *id, time_t start, time_t end, ECalComponentAlarms **alarms) +get_alarms_for_object (ECalClient *cal_client, + const ECalComponentId *id, + time_t start, + time_t end, + ECalComponentAlarms **alarms) { icalcomponent *icalcomp; ECalComponent *comp; @@ -743,7 +781,8 @@ get_alarms_for_object (ECalClient *cal_client, const ECalComponentId *id, time_t g_return_val_if_fail (start >= 0 && end >= 0, FALSE); g_return_val_if_fail (start <= end, FALSE); - if (!e_cal_client_get_object_sync (cal_client, id->uid, id->rid, &icalcomp, NULL, NULL)) + if (!e_cal_client_get_object_sync ( + cal_client, id->uid, id->rid, &icalcomp, NULL, NULL)) return FALSE; if (!icalcomp) @@ -756,8 +795,9 @@ get_alarms_for_object (ECalClient *cal_client, const ECalComponentId *id, time_t return FALSE; } - *alarms = e_cal_util_generate_alarms_for_comp (comp, start, end, omit, e_cal_client_resolve_tzid_cb, - cal_client, e_cal_client_get_default_timezone (cal_client)); + *alarms = e_cal_util_generate_alarms_for_comp ( + comp, start, end, omit, e_cal_client_resolve_tzid_cb, + cal_client, e_cal_client_get_default_timezone (cal_client)); g_object_unref (comp); @@ -872,7 +912,9 @@ query_objects_changed_async (struct _query_msg *msg) } static void -query_objects_modified_cb (ECalClientView *view, const GSList *objects, gpointer data) +query_objects_modified_cb (ECalClientView *view, + const GSList *objects, + gpointer data) { struct _query_msg *msg; @@ -913,7 +955,9 @@ query_objects_removed_async (struct _query_msg *msg) } static void -query_objects_removed_cb (ECalClientView *view, const GSList *uids, gpointer data) +query_objects_removed_cb (ECalClientView *view, + const GSList *uids, + gpointer data) { struct _query_msg *msg; @@ -932,7 +976,9 @@ query_objects_removed_cb (ECalClientView *view, const GSList *uids, gpointer dat * compued with respect to the current time. */ static void -create_snooze (CompQueuedAlarms *cqa, gpointer alarm_id, gint snooze_mins) +create_snooze (CompQueuedAlarms *cqa, + gpointer alarm_id, + gint snooze_mins) { QueuedAlarm *orig_qa; time_t t; @@ -959,7 +1005,8 @@ create_snooze (CompQueuedAlarms *cqa, gpointer alarm_id, gint snooze_mins) /* Launches a component editor for a component */ static void -edit_component (ECalClient *cal_client, ECalComponent *comp) +edit_component (ECalClient *cal_client, + ECalComponent *comp) { ESource *source; gchar *command_line; @@ -1042,8 +1089,9 @@ free_tray_icon_data (TrayIconData *tray_data) g_object_unref (tray_data->cal_client); tray_data->cal_client = NULL; - g_signal_handlers_disconnect_matched (tray_data->view, G_SIGNAL_MATCH_FUNC, - 0, 0, NULL, on_dialog_objs_removed_cb, NULL); + g_signal_handlers_disconnect_matched ( + tray_data->view, G_SIGNAL_MATCH_FUNC, + 0, 0, NULL, on_dialog_objs_removed_cb, NULL); g_object_unref (tray_data->view); tray_data->view = NULL; @@ -1094,7 +1142,9 @@ on_dialog_objs_removed_async (struct _query_msg *msg) } static void -on_dialog_objs_removed_cb (ECalClientView *view, const GSList *uids, gpointer data) +on_dialog_objs_removed_cb (ECalClientView *view, + const GSList *uids, + gpointer data) { struct _query_msg *msg; @@ -1256,14 +1306,17 @@ tray_list_remove_data (TrayIconData *data) } static void -notify_dialog_cb (AlarmNotifyResult result, gint snooze_mins, gpointer data) +notify_dialog_cb (AlarmNotifyResult result, + gint snooze_mins, + gpointer data) { TrayIconData *tray_data = data; debug (("Received from dialog")); - g_signal_handlers_disconnect_matched (tray_data->view, G_SIGNAL_MATCH_FUNC, - 0, 0, NULL, on_dialog_objs_removed_cb, NULL); + g_signal_handlers_disconnect_matched ( + tray_data->view, G_SIGNAL_MATCH_FUNC, + 0, 0, NULL, on_dialog_objs_removed_cb, NULL); switch (result) { case ALARM_NOTIFY_SNOOZE: @@ -1378,17 +1431,18 @@ open_alarm_dialog (TrayIconData *tray_data) GTK_TREE_VIEW (alarm_notifications_dialog->treeview)); tray_data->iter = add_alarm_to_notified_alarms_dialog ( - alarm_notifications_dialog, - tray_data->trigger, - qa->instance->occur_start, - qa->instance->occur_end, - e_cal_component_get_vtype (tray_data->comp), - tray_data->summary, - tray_data->description, - tray_data->location, - notify_dialog_cb, tray_data); - - gtk_tree_selection_select_iter (selection, &tray_data->iter); + alarm_notifications_dialog, + tray_data->trigger, + qa->instance->occur_start, + qa->instance->occur_end, + e_cal_component_get_vtype (tray_data->comp), + tray_data->summary, + tray_data->description, + tray_data->location, + notify_dialog_cb, tray_data); + + gtk_tree_selection_select_iter ( + selection, &tray_data->iter); } @@ -1400,7 +1454,9 @@ open_alarm_dialog (TrayIconData *tray_data) } static gint -tray_icon_clicked_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_data) +tray_icon_clicked_cb (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data) { if (event->type == GDK_BUTTON_PRESS) { debug (("left click and %d alarms", g_list_length (tray_icons_list))); @@ -1425,17 +1481,19 @@ tray_icon_clicked_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_da static void icon_activated (GtkStatusIcon *icon) { - GdkEventButton event; + GdkEventButton event; - event.type = GDK_BUTTON_PRESS; - event.button = 1; - event.time = gtk_get_current_event_time (); + event.type = GDK_BUTTON_PRESS; + event.button = 1; + event.time = gtk_get_current_event_time (); - tray_icon_clicked_cb (NULL, &event, NULL); + tray_icon_clicked_cb (NULL, &event, NULL); } static void -popup_menu (GtkStatusIcon *icon, guint button, guint activate_time) +popup_menu (GtkStatusIcon *icon, + guint button, + guint activate_time) { if (button == 3) { /* right click */ @@ -1496,8 +1554,10 @@ tray_list_add_new (TrayIconData *data) /* Performs notification of a display alarm */ static void -display_notification (time_t trigger, CompQueuedAlarms *cqa, - gpointer alarm_id, gboolean use_description) +display_notification (time_t trigger, + CompQueuedAlarms *cqa, + gpointer alarm_id, + gboolean use_description) { QueuedAlarm *qa; ECalComponent *comp; @@ -1621,8 +1681,10 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, #ifdef HAVE_LIBNOTIFY static void -popup_notification (time_t trigger, CompQueuedAlarms *cqa, - gpointer alarm_id, gboolean use_description) +popup_notification (time_t trigger, + CompQueuedAlarms *cqa, + gpointer alarm_id, + gboolean use_description) { QueuedAlarm *qa; ECalComponent *comp; @@ -1706,8 +1768,9 @@ popup_notification (time_t trigger, CompQueuedAlarms *cqa, /* Performs notification of an audio alarm */ static void -audio_notification (time_t trigger, CompQueuedAlarms *cqa, - gpointer alarm_id) +audio_notification (time_t trigger, + CompQueuedAlarms *cqa, + gpointer alarm_id) { QueuedAlarm *qa; ECalComponent *comp; @@ -1764,7 +1827,9 @@ audio_notification (time_t trigger, CompQueuedAlarms *cqa, /* Performs notification of a mail alarm */ static void -mail_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id) +mail_notification (time_t trigger, + CompQueuedAlarms *cqa, + gpointer alarm_id) { GtkWidget *container; GtkWidget *dialog; @@ -1774,17 +1839,20 @@ mail_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id) debug (("...")); - if (!e_client_check_capability (E_CLIENT (cqa->parent_client->cal_client), CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS)) + if (!e_client_check_capability ( + E_CLIENT (cqa->parent_client->cal_client), + CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS)) return; - dialog = gtk_dialog_new_with_buttons (_("Warning"), - NULL, 0, - GTK_STOCK_OK, GTK_RESPONSE_CANCEL, - NULL); - label = gtk_label_new (_("Evolution does not support calendar reminders with\n" - "email notifications yet, but this reminder was\n" - "configured to send an email. Evolution will display\n" - "a normal reminder dialog box instead.")); + dialog = gtk_dialog_new_with_buttons ( + _("Warning"), NULL, 0, + GTK_STOCK_OK, GTK_RESPONSE_CANCEL, + NULL); + label = gtk_label_new ( + _("Evolution does not support calendar reminders with\n" + "email notifications yet, but this reminder was\n" + "configured to send an email. Evolution will display\n" + "a normal reminder dialog box instead.")); gtk_widget_show (label); container = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); @@ -1810,17 +1878,18 @@ procedure_notification_dialog (const gchar *cmd, const gchar *url) if (config_data_is_blessed_program (url)) return TRUE; - dialog = gtk_dialog_new_with_buttons (_("Warning"), - NULL, 0, - GTK_STOCK_NO, GTK_RESPONSE_CANCEL, - GTK_STOCK_YES, GTK_RESPONSE_OK, - NULL); - - str = g_strdup_printf (_("An Evolution Calendar reminder is about to trigger. " - "This reminder is configured to run the following program:\n\n" - " %s\n\n" - "Are you sure you want to run this program?"), - cmd); + dialog = gtk_dialog_new_with_buttons ( + _("Warning"), NULL, 0, + GTK_STOCK_NO, GTK_RESPONSE_CANCEL, + GTK_STOCK_YES, GTK_RESPONSE_OK, + NULL); + + str = g_strdup_printf ( + _("An Evolution Calendar reminder is about to trigger. " + "This reminder is configured to run the following program:\n\n" + " %s\n\n" + "Are you sure you want to run this program?"), + cmd); label = gtk_label_new (str); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); @@ -1846,7 +1915,9 @@ procedure_notification_dialog (const gchar *cmd, const gchar *url) } static void -procedure_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id) +procedure_notification (time_t trigger, + CompQueuedAlarms *cqa, + gpointer alarm_id) { QueuedAlarm *qa; ECalComponent *comp; @@ -2123,7 +2194,9 @@ alarm_queue_add_client (ECalClient *cal_client) /* Removes a component an its alarms */ static void -remove_cqa (ClientAlarms *ca, ECalComponentId *id, CompQueuedAlarms *cqa) +remove_cqa (ClientAlarms *ca, + ECalComponentId *id, + CompQueuedAlarms *cqa) { /* If a component is present, then it means we must have alarms queued @@ -2136,7 +2209,10 @@ remove_cqa (ClientAlarms *ca, ECalComponentId *id, CompQueuedAlarms *cqa) } static gboolean -remove_comp_by_id (gpointer key, gpointer value, gpointer userdata) { +remove_comp_by_id (gpointer key, + gpointer value, + gpointer userdata) +{ ClientAlarms *ca = (ClientAlarms *) userdata; @@ -2222,7 +2298,8 @@ alarm_queue_remove_async (struct _alarm_client_msg *msg) */ void -alarm_queue_remove_client (ECalClient *cal_client, gboolean immediately) +alarm_queue_remove_client (ECalClient *cal_client, + gboolean immediately) { struct _alarm_client_msg *msg; @@ -2239,7 +2316,8 @@ alarm_queue_remove_client (ECalClient *cal_client, gboolean immediately) /* Update non-time related variables for various structures on modification * of an existing component to be called only from query_objects_changed_cb */ static void -update_cqa (CompQueuedAlarms *cqa, ECalComponent *newcomp) +update_cqa (CompQueuedAlarms *cqa, + ECalComponent *newcomp) { ECalComponent *oldcomp; ECalComponentAlarms *alarms = NULL; @@ -2255,8 +2333,9 @@ update_cqa (CompQueuedAlarms *cqa, ECalComponent *newcomp) to = time_day_end_with_zone (time (NULL), zone); debug (("Generating alarms between %s and %s", e_ctime (&from), e_ctime (&to))); - alarms = e_cal_util_generate_alarms_for_comp (newcomp, from, to, omit, - e_cal_client_resolve_tzid_cb, cqa->parent_client->cal_client, zone); + alarms = e_cal_util_generate_alarms_for_comp ( + newcomp, from, to, omit, e_cal_client_resolve_tzid_cb, + cqa->parent_client->cal_client, zone); /* Update auids in Queued Alarms*/ for (qa_list = cqa->queued_alarms; qa_list; qa_list = qa_list->next) { -- cgit From fcbbdfbd18e15b4ee8322a0217cf03a689a5e033 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 16 Aug 2011 11:25:56 -0400 Subject: Coding style and whitespace cleanup. --- calendar/gui/alarm-notify/alarm-queue.c | 38 +++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'calendar/gui/alarm-notify/alarm-queue.c') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index c143429f8f..d7a1346a8e 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -180,10 +180,10 @@ static void message_proxy (Message *msg) { g_return_if_fail (msg->func != NULL); - + * msg->func (msg); } - + * static gpointer create_thread_pool (void) { @@ -344,7 +344,7 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gboolean free_object, gboolean remove_alarm) { - QueuedAlarm *qa=NULL; + QueuedAlarm *qa = NULL; GSList *l; debug (("...")); @@ -576,7 +576,9 @@ add_component_alarms (ClientAlarms *ca, /* Loads the alarms of a client for a given range of time */ static void -load_alarms (ClientAlarms *ca, time_t start, time_t end) +load_alarms (ClientAlarms *ca, + time_t start, + time_t end) { gchar *str_query, *iso_start, *iso_end; GError *error = NULL; @@ -1609,10 +1611,12 @@ display_notification (time_t trigger, tray_icon = gtk_status_icon_new (); gtk_status_icon_set_from_icon_name ( tray_icon, "appointment-soon"); - g_signal_connect (G_OBJECT (tray_icon), "activate", - G_CALLBACK (icon_activated), NULL); - g_signal_connect (G_OBJECT (tray_icon), "popup-menu", - G_CALLBACK (popup_menu), NULL); + g_signal_connect ( + tray_icon, "activate", + G_CALLBACK (icon_activated), NULL); + g_signal_connect ( + tray_icon, "popup-menu", + G_CALLBACK (popup_menu), NULL); } current_zone = config_data_get_timezone (); @@ -1661,8 +1665,9 @@ display_notification (time_t trigger, g_free (time_str); g_free (str); - g_signal_connect (G_OBJECT (tray_data->view), "objects_removed", - G_CALLBACK (on_dialog_objs_removed_cb), tray_data); + g_signal_connect ( + tray_data->view, "objects_removed", + G_CALLBACK (on_dialog_objs_removed_cb), tray_data); /* FIXME: We should remove this check */ if (!config_data_get_notify_with_tray ()) { @@ -1864,7 +1869,8 @@ mail_notification (time_t trigger, /* Performs notification of a procedure alarm */ static gboolean -procedure_notification_dialog (const gchar *cmd, const gchar *url) +procedure_notification_dialog (const gchar *cmd, + const gchar *url) { GtkWidget *container; GtkWidget *dialog; @@ -2037,7 +2043,9 @@ alarm_queue_init (gpointer data) } static gboolean -free_client_alarms_cb (gpointer key, gpointer value, gpointer user_data) +free_client_alarms_cb (gpointer key, + gpointer value, + gpointer user_data) { ClientAlarms *ca = value; @@ -2101,7 +2109,8 @@ alarm_queue_done (void) } static gboolean -compare_ids (gpointer a, gpointer b) +compare_ids (gpointer a, + gpointer b) { ECalComponentId *id, *id1; @@ -2370,7 +2379,8 @@ update_cqa (CompQueuedAlarms *cqa, } static void -update_qa (ECalComponentAlarms *alarms, QueuedAlarm *qa) +update_qa (ECalComponentAlarms *alarms, + QueuedAlarm *qa) { ECalComponentAlarmInstance *al_inst; GSList *instance_list; -- cgit From 5ddad039926944120fa8f138f3a0039292d736de Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Thu, 29 Sep 2011 11:59:34 +0200 Subject: Remove Ctrl + l ( ) character from source files From ccc980da1fd84ebfca25cf8caf9a5d62333099fc Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Wed, 28 Sep 2011 10:18:18 +0200 Subject: [PATCH] Remove Ctrl + l ( ) character from source files The following commits git show aac3f2c8 git show 1510304c git show 13cabd9e git show 350a7a33 git show 9b7cc54d git show e6972011 git show 1d3a7938 git show 934524b9 git show b2954936 git show a7f677b5 git show 4369c400 git show d509f47a git show a6d5818f git show c3876df7 git show 4583098b git show 2831ada5 git show 4e1bce59 git show 1609f699 git show 4e4c1676 git show d6fade43 among others(?) introduced several occurrences of Ctrl + l ( ). Probably this was caused by the used editor. These control characters can be searched for using the following command [1]. $ git grep ^L [1] http://unstableme.blogspot.com/2009/10/grep-and-print-control-characters-in.html --- calendar/gui/alarm-notify/alarm-queue.c | 1 - 1 file changed, 1 deletion(-) (limited to 'calendar/gui/alarm-notify/alarm-queue.c') 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 */ -- cgit