aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-09-12 10:09:58 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-09-12 10:09:58 +0800
commite65e502c544e11c97832936881c43b90fc74d320 (patch)
tree0d7aaa5b9a1a2b0853254cbb323a0b29fff1fb7f /calendar/gui
parentff6d984bb6c9fd7fbba7a6382976260f0f2dfd8f (diff)
downloadgsoc2013-evolution-e65e502c544e11c97832936881c43b90fc74d320.tar.gz
gsoc2013-evolution-e65e502c544e11c97832936881c43b90fc74d320.tar.zst
gsoc2013-evolution-e65e502c544e11c97832936881c43b90fc74d320.zip
Added an use_description argument so that other alarms can fall back to
2001-09-11 Federico Mena Quintero <federico@ximian.com> * gui/alarm-notify/alarm-queue.c (display_notification): Added an use_description argument so that other alarms can fall back to this type. (audio_notification): Implemented. (remove_comp): Call remove_queued_alarm() here; there is no longer a destroy notification function for alarms so must we do this manually. (alarm_trigger_cb): Do not pass the alarm to the notification functions so that we can free it ourselves before all the alarms in the component get freed. (display_notification): Get the alarm here instead of getting it as an argument. (procedure_notification): Implemented. svn path=/trunk/; revision=12772
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.c158
-rw-r--r--calendar/gui/alarm-notify/notify-main.c2
2 files changed, 143 insertions, 17 deletions
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c
index 0b093b2a5b..7b7903900d 100644
--- a/calendar/gui/alarm-notify/alarm-queue.c
+++ b/calendar/gui/alarm-notify/alarm-queue.c
@@ -29,6 +29,8 @@
#include <libgnome/gnome-i18n.h>
#include <gtk/gtksignal.h>
#include <liboaf/liboaf.h>
+#include <libgnome/gnome-exec.h>
+#include <libgnome/gnome-sound.h>
#include <bonobo/bonobo-object.h>
#include <cal-util/timeutil.h>
#include "alarm.h"
@@ -90,7 +92,9 @@ typedef struct {
static gpointer midnight_refresh_id = NULL;
static void display_notification (time_t trigger, CompQueuedAlarms *cqa,
- gpointer alarm_id, CalComponentAlarm *alarm);
+ gpointer alarm_id, gboolean use_description);
+static void audio_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id);
+static void procedure_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id);
@@ -235,15 +239,15 @@ alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data)
g_assert (alarm != NULL);
cal_component_alarm_get_action (alarm, &action);
+ cal_component_alarm_free (alarm);
switch (action) {
case CAL_ALARM_AUDIO:
- /* FIXME: audio_notification (); */
- remove_queued_alarm (cqa, alarm_id);
+ audio_notification (trigger, cqa, alarm_id);
break;
case CAL_ALARM_DISPLAY:
- display_notification (trigger, cqa, alarm_id, alarm);
+ display_notification (trigger, cqa, alarm_id, TRUE);
break;
case CAL_ALARM_EMAIL:
@@ -252,16 +256,13 @@ alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data)
break;
case CAL_ALARM_PROCEDURE:
- /* FIXME: procedure_notification (); */
- remove_queued_alarm (cqa, alarm_id);
+ procedure_notification (trigger, cqa, alarm_id);
break;
default:
g_assert_not_reached ();
break;
}
-
- cal_component_alarm_free (alarm);
}
/* Adds the alarms in a CalComponentAlarms structure to the alarms queued for a
@@ -397,12 +398,13 @@ remove_comp (ClientAlarms *ca, const char *uid)
qa = l->data;
/* Get the next element here because the list element will go
- * away. Also, we do not free the qa here because it will be
- * freed by the destroy notification function.
+ * away in remove_queued_alarm(). The qa will be freed there as
+ * well.
*/
l = l->next;
alarm_remove (qa->alarm_id);
+ remove_queued_alarm (cqa, qa->alarm_id);
}
/* The list should be empty now, and thus the queued component alarms
@@ -578,7 +580,7 @@ notify_dialog_cb (AlarmNotifyResult result, int snooze_mins, gpointer data)
/* Performs notification of a display alarm */
static void
display_notification (time_t trigger, CompQueuedAlarms *cqa,
- gpointer alarm_id, CalComponentAlarm *alarm)
+ gpointer alarm_id, gboolean use_description)
{
CalComponent *comp;
CalComponentVType vtype;
@@ -586,8 +588,11 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
QueuedAlarm *qa;
const char *message;
struct notify_dialog_closure *c;
+ gboolean use_summary;
comp = cqa->alarms->comp;
+ qa = lookup_queued_alarm (cqa, alarm_id);
+ g_assert (qa != NULL);
vtype = cal_component_get_vtype (comp);
@@ -595,10 +600,25 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
* from the alarm, then the SUMMARY of the component.
*/
- cal_component_alarm_get_description (alarm, &text);
- if (text.value)
- message = text.value;
- else {
+ use_summary = TRUE;
+ message = NULL;
+
+ if (use_description) {
+ CalComponentAlarm *alarm;
+
+ alarm = cal_component_get_alarm (comp, qa->instance->auid);
+ g_assert (alarm != NULL);
+
+ cal_component_alarm_get_description (alarm, &text);
+ cal_component_alarm_free (alarm);
+
+ if (text.value) {
+ message = text.value;
+ use_summary = FALSE;
+ }
+ }
+
+ if (use_summary) {
cal_component_get_summary (comp, &text);
if (text.value)
message = text.value;
@@ -610,8 +630,6 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
c->cqa = cqa;
c->alarm_id = alarm_id;
- qa = lookup_queued_alarm (cqa, alarm_id);
-
if (!alarm_notify_dialog (trigger,
qa->instance->occur_start, qa->instance->occur_end,
vtype, message,
@@ -619,6 +637,112 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
g_message ("display_notification(): Could not create the alarm notify dialog");
}
+/* Performs notification of an audio alarm */
+static void
+audio_notification (time_t trigger, CompQueuedAlarms *cqa,
+ gpointer alarm_id)
+{
+ QueuedAlarm *qa;
+ CalComponent *comp;
+ CalComponentAlarm *alarm;
+ icalattach *attach;
+ const char *url;
+
+ comp = cqa->alarms->comp;
+ qa = lookup_queued_alarm (cqa, alarm_id);
+ g_assert (qa != NULL);
+
+ alarm = cal_component_get_alarm (comp, qa->instance->auid);
+ g_assert (alarm != NULL);
+
+ cal_component_alarm_get_attach (alarm, &attach);
+ cal_component_alarm_free (alarm);
+
+ /* If the alarm has no attachment, simply display a notification dialog. */
+ if (!attach)
+ goto fallback;
+
+ if (!icalattach_get_is_url (attach)) {
+ icalattach_unref (attach);
+ goto fallback;
+ }
+
+ url = icalattach_get_url (attach);
+ g_assert (url != NULL);
+
+ gnome_sound_play (url); /* this sucks */
+ icalattach_unref (attach);
+
+ remove_queued_alarm (cqa, alarm_id);
+ return;
+
+ fallback:
+
+ display_notification (trigger, cqa, alarm_id, FALSE);
+}
+
+/* Performs notification of a procedure alarm */
+static void
+procedure_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id)
+{
+ QueuedAlarm *qa;
+ CalComponent *comp;
+ CalComponentAlarm *alarm;
+ CalComponentText description;
+ icalattach *attach;
+ const char *url;
+ int result;
+
+ comp = cqa->alarms->comp;
+ qa = lookup_queued_alarm (cqa, alarm_id);
+ g_assert (qa != NULL);
+
+ alarm = cal_component_get_alarm (comp, qa->instance->auid);
+ g_assert (alarm != NULL);
+
+ cal_component_alarm_get_attach (alarm, &attach);
+ cal_component_alarm_get_description (alarm, &description);
+ cal_component_alarm_free (alarm);
+
+ /* If the alarm has no attachment, simply display a notification dialog. */
+ if (!attach)
+ goto fallback;
+
+ if (!icalattach_get_is_url (attach)) {
+ icalattach_unref (attach);
+ goto fallback;
+ }
+
+ url = icalattach_get_url (attach);
+ g_assert (url != NULL);
+
+ if (description.value) {
+ char *argv[2];
+
+ argv[0] = (char *) url;
+ argv[1] = (char *) description.value;
+ result = gnome_execute_async (NULL, 2, argv);
+ } else {
+ char *argv[1];
+
+ argv[0] = (char *) url;
+ result = gnome_execute_async (NULL, 1, argv);
+ }
+
+ icalattach_unref (attach);
+
+ /* Fall back to display notification if we got an error */
+ if (result < 0)
+ goto fallback;
+
+ remove_queued_alarm (cqa, alarm_id);
+ return;
+
+ fallback:
+
+ display_notification (trigger, cqa, alarm_id, FALSE);
+}
+
/**
diff --git a/calendar/gui/alarm-notify/notify-main.c b/calendar/gui/alarm-notify/notify-main.c
index b8b409632d..db0cd4e719 100644
--- a/calendar/gui/alarm-notify/notify-main.c
+++ b/calendar/gui/alarm-notify/notify-main.c
@@ -87,6 +87,8 @@ alarm_notify_factory_fn (BonoboGenericFactory *factory, void *data)
int
main (int argc, char **argv)
{
+ free (malloc (8));
+
bindtextdomain (PACKAGE, EVOLUTION_LOCALEDIR);
textdomain (PACKAGE);