aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-09-11 07:00:17 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-09-11 07:00:17 +0800
commit7eca7e459091e7f4fcea9223dff71fd179305cb5 (patch)
treec07e1610e5574e6e8a65d28c431ed0cf1c58502b
parentd2b81b2d4e2d3effce4ad6f5f0993910677825ba (diff)
downloadgsoc2013-evolution-7eca7e459091e7f4fcea9223dff71fd179305cb5.tar.gz
gsoc2013-evolution-7eca7e459091e7f4fcea9223dff71fd179305cb5.tar.zst
gsoc2013-evolution-7eca7e459091e7f4fcea9223dff71fd179305cb5.zip
Handle the new icalattach type instead of struct icalattachtype.
2001-09-10 Federico Mena Quintero <federico@ximian.com> * cal-util/cal-component.c (cal_component_alarm_get_attach): Handle the new icalattach type instead of struct icalattachtype. (cal_component_alarm_set_attach): Likewise. * gui/dialogs/alarm-options.c (alarm_to_aalarm_widgets): Likewise. (alarm_to_palarm_widgets): Likewise. (aalarm_widgets_to_alarm): Likewise. (palarm_widgets_to_alarm): Likewise. svn path=/trunk/; revision=12749
-rw-r--r--calendar/ChangeLog11
-rw-r--r--calendar/cal-util/cal-component.c16
-rw-r--r--calendar/cal-util/cal-component.h4
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.c406
-rw-r--r--calendar/gui/dialogs/alarm-options.c40
5 files changed, 38 insertions, 439 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index fdf6a2d2ef..2db3ecb34d 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,14 @@
+2001-09-10 Federico Mena Quintero <federico@ximian.com>
+
+ * cal-util/cal-component.c (cal_component_alarm_get_attach):
+ Handle the new icalattach type instead of struct icalattachtype.
+ (cal_component_alarm_set_attach): Likewise.
+
+ * gui/dialogs/alarm-options.c (alarm_to_aalarm_widgets): Likewise.
+ (alarm_to_palarm_widgets): Likewise.
+ (aalarm_widgets_to_alarm): Likewise.
+ (palarm_widgets_to_alarm): Likewise.
+
2001-09-05 Ettore Perazzoli <ettore@ximian.com>
[Fix #958, ShellComponents should not be created by factories, for
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c
index c7800f0456..d74c1238b2 100644
--- a/calendar/cal-util/cal-component.c
+++ b/calendar/cal-util/cal-component.c
@@ -4573,12 +4573,12 @@ cal_component_alarm_set_action (CalComponentAlarm *alarm, CalAlarmAction action)
/**
* cal_component_alarm_get_attach:
* @alarm: An alarm.
- * @attach: Return value for the attachment; should be freed using icalattachtype_free().
+ * @attach: Return value for the attachment; should be freed using icalattach_unref().
*
* Queries the attachment property of an alarm.
**/
void
-cal_component_alarm_get_attach (CalComponentAlarm *alarm, struct icalattachtype **attach)
+cal_component_alarm_get_attach (CalComponentAlarm *alarm, icalattach **attach)
{
g_return_if_fail (alarm != NULL);
g_return_if_fail (attach != NULL);
@@ -4586,12 +4586,8 @@ cal_component_alarm_get_attach (CalComponentAlarm *alarm, struct icalattachtype
g_assert (alarm->icalcomp != NULL);
if (alarm->attach) {
- *attach = icalattachtype_new ();
- **attach = icalproperty_get_attach (alarm->attach);
- /* FIXME: This is bogus in libical; icalattachtype is supposed
- * to be refcounted but the property functions return it by
- * value.
- */
+ *attach = icalproperty_get_attach (alarm->attach);
+ icalattach_ref (*attach);
} else
*attach = NULL;
}
@@ -4604,7 +4600,7 @@ cal_component_alarm_get_attach (CalComponentAlarm *alarm, struct icalattachtype
* Sets the attachment property of an alarm.
**/
void
-cal_component_alarm_set_attach (CalComponentAlarm *alarm, struct icalattachtype *attach)
+cal_component_alarm_set_attach (CalComponentAlarm *alarm, icalattach *attach)
{
g_return_if_fail (alarm != NULL);
@@ -4617,7 +4613,7 @@ cal_component_alarm_set_attach (CalComponentAlarm *alarm, struct icalattachtype
}
if (attach) {
- alarm->attach = icalproperty_new_attach (*attach);
+ alarm->attach = icalproperty_new_attach (attach);
icalcomponent_add_property (alarm->icalcomp, alarm->attach);
}
}
diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h
index b0545397b4..ef38483c68 100644
--- a/calendar/cal-util/cal-component.h
+++ b/calendar/cal-util/cal-component.h
@@ -437,8 +437,8 @@ const char *cal_component_alarm_get_uid (CalComponentAlarm *alarm);
void cal_component_alarm_get_action (CalComponentAlarm *alarm, CalAlarmAction *action);
void cal_component_alarm_set_action (CalComponentAlarm *alarm, CalAlarmAction action);
-void cal_component_alarm_get_attach (CalComponentAlarm *alarm, struct icalattachtype **attach);
-void cal_component_alarm_set_attach (CalComponentAlarm *alarm, struct icalattachtype *attach);
+void cal_component_alarm_get_attach (CalComponentAlarm *alarm, icalattach **attach);
+void cal_component_alarm_set_attach (CalComponentAlarm *alarm, icalattach *attach);
void cal_component_alarm_get_description (CalComponentAlarm *alarm, CalComponentText *description);
void cal_component_alarm_set_description (CalComponentAlarm *alarm, CalComponentText *description);
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c
index a2035c8b61..0b093b2a5b 100644
--- a/calendar/gui/alarm-notify/alarm-queue.c
+++ b/calendar/gui/alarm-notify/alarm-queue.c
@@ -795,409 +795,3 @@ alarm_queue_remove_client (CalClient *client)
g_hash_table_remove (client_alarms_hash, client);
}
-
-
-
-#if 0
-
-/* Sends a mail notification of an alarm trigger */
-static void
-mail_notification (char *mail_address, char *text, time_t app_time)
-{
- pid_t pid;
- int p [2];
- char *command;
-
- pipe (p);
- pid = fork ();
- if (pid == 0){
- int dev_null;
-
- dev_null = open ("/dev/null", O_RDWR);
- dup2 (p [0], 0);
- dup2 (dev_null, 1);
- dup2 (dev_null, 2);
- execl ("/usr/lib/sendmail", "/usr/lib/sendmail",
- mail_address, NULL);
- _exit (127);
- }
- command = g_strconcat ("To: ", mail_address, "\n",
- "Subject: ", _("Reminder of your appointment at "),
- ctime (&app_time), "\n\n", text, "\n", NULL);
- write (p [1], command, strlen (command));
- close (p [1]);
- close (p [0]);
- g_free (command);
-}
-
-static int
-max_open_files (void)
-{
- static int files;
-
- if (files)
- return files;
-
- files = sysconf (_SC_OPEN_MAX);
- if (files != -1)
- return files;
-#ifdef OPEN_MAX
- return files = OPEN_MAX;
-#else
- return files = 256;
-#endif
-}
-
-/* Executes a program as a notification of an alarm trigger */
-static void
-program_notification (char *command, int close_standard)
-{
- struct sigaction ignore, save_intr, save_quit;
- int status = 0, i;
- pid_t pid;
-
- ignore.sa_handler = SIG_IGN;
- sigemptyset (&ignore.sa_mask);
- ignore.sa_flags = 0;
-
- sigaction (SIGINT, &ignore, &save_intr);
- sigaction (SIGQUIT, &ignore, &save_quit);
-
- if ((pid = fork ()) < 0){
- fprintf (stderr, "\n\nfork () = -1\n");
- return;
- }
- if (pid == 0){
- pid = fork ();
- if (pid == 0){
- const int top = max_open_files ();
- sigaction (SIGINT, &save_intr, NULL);
- sigaction (SIGQUIT, &save_quit, NULL);
-
- for (i = (close_standard ? 0 : 3); i < top; i++)
- close (i);
-
- /* FIXME: As an excercise to the reader, copy the
- * code from mc to setup shell properly instead of
- * /bin/sh. Yes, this comment is larger than a cut and paste.
- */
- execl ("/bin/sh", "/bin/sh", "-c", command, (char *) 0);
-
- _exit (127);
- } else {
- _exit (127);
- }
- }
- wait (&status);
- sigaction (SIGINT, &save_intr, NULL);
- sigaction (SIGQUIT, &save_quit, NULL);
-}
-
-/* Queues a snooze alarm */
-static void
-snooze (GnomeCalendar *gcal, CalComponent *comp, time_t occur, int snooze_mins, gboolean audio)
-{
- time_t now, trigger;
- struct tm tm;
- CalAlarmInstance ai;
-
- now = time (NULL);
- tm = *localtime (&now);
- tm.tm_min += snooze_mins;
-
- trigger = mktime (&tm);
- if (trigger == -1) {
- g_message ("snooze(): produced invalid time_t; not queueing alarm!");
- return;
- }
-
-#if 0
- cal_component_get_uid (comp, &ai.uid);
- ai.type = audio ? ALARM_AUDIO : ALARM_DISPLAY;
-#endif
- ai.trigger = trigger;
- ai.occur = occur;
-
- setup_alarm (gcal, &ai);
-}
-
-struct alarm_notify_closure {
- GnomeCalendar *gcal;
- CalComponent *comp;
- time_t occur;
-};
-
-/* Callback used for the result of the alarm notification dialog */
-static void
-display_notification_cb (AlarmNotifyResult result, int snooze_mins, gpointer data)
-{
- struct alarm_notify_closure *c;
-
- c = data;
-
- switch (result) {
- case ALARM_NOTIFY_CLOSE:
- break;
-
- case ALARM_NOTIFY_SNOOZE:
- snooze (c->gcal, c->comp, c->occur, snooze_mins, FALSE);
- break;
-
- case ALARM_NOTIFY_EDIT:
- gnome_calendar_edit_object (c->gcal, c->comp);
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- gtk_object_unref (GTK_OBJECT (c->comp));
- g_free (c);
-}
-
-/* Present a display notification of an alarm trigger */
-static void
-display_notification (time_t trigger, time_t occur, CalComponent *comp, GnomeCalendar *gcal)
-{
- gboolean result;
- struct alarm_notify_closure *c;
-
- gtk_object_ref (GTK_OBJECT (comp));
-
- c = g_new (struct alarm_notify_closure, 1);
- c->gcal = gcal;
- c->comp = comp;
- c->occur = occur;
-
- result = alarm_notify_dialog (trigger, occur, comp, display_notification_cb, c);
- if (!result) {
- g_message ("display_notification(): could not display the alarm notification dialog");
- g_free (c);
- gtk_object_unref (GTK_OBJECT (comp));
- }
-}
-
-/* Present an audible notification of an alarm trigger */
-static void
-audio_notification (time_t trigger, time_t occur, CalComponent *comp, GnomeCalendar *gcal)
-{
- g_message ("AUDIO NOTIFICATION!");
- /* FIXME */
-}
-
-/* Callback function used when an alarm is triggered */
-static void
-trigger_alarm_cb (gpointer alarm_id, time_t trigger, gpointer data)
-{
- struct trigger_alarm_closure *c;
- GnomeCalendarPrivate *priv;
- CalComponent *comp;
- CalClientGetStatus status;
- const char *uid;
- ObjectAlarms *oa;
- GList *l;
-
- c = data;
- priv = c->gcal->priv;
-
- /* Fetch the object */
-
- status = cal_client_get_object (priv->client, c->uid, &comp);
-
- switch (status) {
- case CAL_CLIENT_GET_SUCCESS:
- /* Go on */
- break;
- case CAL_CLIENT_GET_SYNTAX_ERROR:
- case CAL_CLIENT_GET_NOT_FOUND:
- g_message ("trigger_alarm_cb(): syntax error in fetched object");
- return;
- }
-
- g_assert (comp != NULL);
-
- /* Present notification */
-
- switch (c->type) {
- case CAL_COMPONENT_ALARM_EMAIL:
-#if 0
- g_assert (ico->malarm.enabled);
- mail_notification (ico->malarm.data, ico->summary, c->occur);
-#endif
- break;
-
- case CAL_COMPONENT_ALARM_PROCEDURE:
-#if 0
- g_assert (ico->palarm.enabled);
- program_notification (ico->palarm.data, FALSE);
-#endif
- break;
-
- case CAL_COMPONENT_ALARM_DISPLAY:
-#if 0
- g_assert (ico->dalarm.enabled);
-#endif
- display_notification (trigger, c->occur, comp, c->gcal);
- break;
-
- case CAL_COMPONENT_ALARM_AUDIO:
-#if 0
- g_assert (ico->aalarm.enabled);
-#endif
- audio_notification (trigger, c->occur, comp, c->gcal);
- break;
-
- default:
- break;
- }
-
- /* Remove the alarm from the hash table */
- cal_component_get_uid (comp, &uid);
- oa = g_hash_table_lookup (priv->alarms, uid);
- g_assert (oa != NULL);
-
- l = g_list_find (oa->alarm_ids, alarm_id);
- g_assert (l != NULL);
-
- oa->alarm_ids = g_list_remove_link (oa->alarm_ids, l);
- g_list_free_1 (l);
-
- if (!oa->alarm_ids) {
- g_hash_table_remove (priv->alarms, uid);
- g_free (oa->uid);
- g_free (oa);
- }
-
- gtk_object_unref (GTK_OBJECT (comp));
-}
-
-#endif
-
-#if 0
-
-static void
-stop_beeping (GtkObject* object, gpointer data)
-{
- guint timer_tag, beep_tag;
- timer_tag = GPOINTER_TO_INT (gtk_object_get_data (object, "timer_tag"));
- beep_tag = GPOINTER_TO_INT (gtk_object_get_data (object, "beep_tag"));
-
- if (beep_tag > 0) {
- gtk_timeout_remove (beep_tag);
- gtk_object_set_data (object, "beep_tag", GINT_TO_POINTER (0));
- }
- if (timer_tag > 0) {
- gtk_timeout_remove (timer_tag);
- gtk_object_set_data (object, "timer_tag", GINT_TO_POINTER (0));
- }
-}
-
-static gint
-start_beeping (gpointer data)
-{
- gdk_beep ();
-
- return TRUE;
-}
-
-static gint
-timeout_beep (gpointer data)
-{
- stop_beeping (data, NULL);
- return FALSE;
-}
-
-void
-calendar_notify (time_t activation_time, CalendarAlarm *which, void *data)
-{
- iCalObject *ico = data;
- guint beep_tag, timer_tag;
- int ret;
- gchar* snooze_button = (enable_snooze ? _("Snooze") : NULL);
- time_t now, diff;
-
- if (&ico->aalarm == which){
- time_t app = ico->aalarm.trigger + ico->aalarm.offset;
- GtkWidget *w;
- char *msg;
-
- msg = g_strconcat (_("Reminder of your appointment at "),
- ctime (&app), "`",
- ico->summary, "'", NULL);
-
- /* Idea: we need Snooze option :-) */
- w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO, _("Ok"), snooze_button, NULL);
- beep_tag = gtk_timeout_add (1000, start_beeping, NULL);
- if (enable_aalarm_timeout)
- timer_tag = gtk_timeout_add (audio_alarm_timeout*1000,
- timeout_beep, w);
- else
- timer_tag = 0;
- gtk_object_set_data (GTK_OBJECT (w), "timer_tag",
- GINT_TO_POINTER (timer_tag));
- gtk_object_set_data (GTK_OBJECT (w), "beep_tag",
- GINT_TO_POINTER (beep_tag));
- gtk_widget_ref (w);
- gtk_window_set_modal (GTK_WINDOW (w), FALSE);
- ret = gnome_dialog_run (GNOME_DIALOG (w));
- switch (ret) {
- case 1:
- stop_beeping (GTK_OBJECT (w), NULL);
- now = time (NULL);
- diff = now - which->trigger;
- which->trigger = which->trigger + diff + snooze_secs;
- which->offset = which->offset - diff - snooze_secs;
- alarm_add (which, &calendar_notify, data);
- break;
- default:
- stop_beeping (GTK_OBJECT (w), NULL);
- break;
- }
-
- gtk_widget_unref (w);
- return;
- }
-
- if (&ico->palarm == which){
- execute (ico->palarm.data, 0);
- return;
- }
-
- if (&ico->malarm == which){
- time_t app = ico->malarm.trigger + ico->malarm.offset;
-
- mail_notify (ico->malarm.data, ico->summary, app);
- return;
- }
-
- if (&ico->dalarm == which){
- time_t app = ico->dalarm.trigger + ico->dalarm.offset;
- GtkWidget *w;
- char *msg;
-
- if (beep_on_display)
- gdk_beep ();
- msg = g_strconcat (_("Reminder of your appointment at "),
- ctime (&app), "`",
- ico->summary, "'", NULL);
- w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO,
- _("Ok"), snooze_button, NULL);
- gtk_window_set_modal (GTK_WINDOW (w), FALSE);
- ret = gnome_dialog_run (GNOME_DIALOG (w));
- switch (ret) {
- case 1:
- now = time (NULL);
- diff = now - which->trigger;
- which->trigger = which->trigger + diff + snooze_secs;
- which->offset = which->offset - diff - snooze_secs;
- alarm_add (which, &calendar_notify, data);
- break;
- default:
- break;
- }
-
- return;
- }
-}
-
-#endif
diff --git a/calendar/gui/dialogs/alarm-options.c b/calendar/gui/dialogs/alarm-options.c
index c1d152c341..1835e8fa9d 100644
--- a/calendar/gui/dialogs/alarm-options.c
+++ b/calendar/gui/dialogs/alarm-options.c
@@ -205,7 +205,7 @@ init_widgets (Dialog *dialog)
static void
alarm_to_aalarm_widgets (Dialog *dialog, CalComponentAlarm *alarm)
{
- struct icalattachtype *attach;
+ icalattach *attach;
char *url;
cal_component_alarm_get_attach (alarm, &attach);
@@ -219,16 +219,14 @@ alarm_to_aalarm_widgets (Dialog *dialog, CalComponentAlarm *alarm)
url = NULL;
- if (icalattachtype_get_base64 (attach))
- g_message ("alarm_to_aalarm_widgets(): FIXME: we don't support base64 data yet");
- else if (icalattachtype_get_binary (attach))
- g_message ("alarm_to_aalarm_widgets(): FIXME: we don't support binary data yet");
+ if (icalattach_get_is_url (attach))
+ url = icalattach_get_url (attach);
else
- url = icalattachtype_get_url (attach);
+ g_message ("alarm_to_aalarm_widgets(): FIXME: we don't support inline data yet");
e_dialog_editable_set (dialog->aalarm_attach, url);
- icalattachtype_free (attach);
+ icalattach_unref (attach);
}
/* Fills the display alarm widgets with the values from the alarm component */
@@ -253,7 +251,7 @@ alarm_to_malarm_widgets (Dialog *dialog, CalComponentAlarm *alarm)
static void
alarm_to_palarm_widgets (Dialog *dialog, CalComponentAlarm *alarm)
{
- struct icalattachtype *attach;
+ icalattach *attach;
CalComponentText description;
cal_component_alarm_get_attach (alarm, &attach);
@@ -262,10 +260,14 @@ alarm_to_palarm_widgets (Dialog *dialog, CalComponentAlarm *alarm)
if (attach) {
char *url;
- url = icalattachtype_get_url (attach);
- e_dialog_editable_set (dialog->palarm_program, url);
+ if (icalattach_get_is_url (attach)) {
+ url = icalattach_get_url (attach);
+ e_dialog_editable_set (dialog->palarm_program, url);
+ } else
+ g_message ("alarm_to_palarm_widgets(): Don't know what to do with non-URL "
+ "attachments");
- icalattachtype_free (attach);
+ icalattach_unref (attach);
}
e_dialog_editable_set (dialog->palarm_args, description.value);
@@ -443,16 +445,14 @@ static void
aalarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm)
{
char *url;
- struct icalattachtype *attach;
-
- attach = icalattachtype_new ();
+ icalattach *attach;
url = e_dialog_editable_get (dialog->aalarm_attach);
- icalattachtype_set_url (attach, url ? url : "");
+ attach = icalattach_new_from_url (url ? url : "");
g_free (url);
cal_component_alarm_set_attach (alarm, attach);
- icalattachtype_free (attach);
+ icalattach_unref (attach);
}
/* Fills the display alarm data with the values from the widgets */
@@ -482,18 +482,16 @@ static void
palarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm)
{
char *program;
- struct icalattachtype *attach;
+ icalattach *attach;
char *str;
CalComponentText description;
- attach = icalattachtype_new ();
-
program = e_dialog_editable_get (dialog->palarm_program);
- icalattachtype_set_url (attach, program ? program : "");
+ attach = icalattach_new_from_url (program ? program : "");
g_free (program);
cal_component_alarm_set_attach (alarm, attach);
- icalattachtype_free (attach);
+ icalattach_unref (attach);
str = e_dialog_editable_get (dialog->palarm_args);
description.value = str;