aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/alarm-notify
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui/alarm-notify')
-rw-r--r--calendar/gui/alarm-notify/.cvsignore10
-rw-r--r--calendar/gui/alarm-notify/GNOME_Evolution_Calendar_AlarmNotify.oaf.in24
-rw-r--r--calendar/gui/alarm-notify/Makefile.am91
-rw-r--r--calendar/gui/alarm-notify/alarm-notify-dialog.c412
-rw-r--r--calendar/gui/alarm-notify/alarm-notify-dialog.h44
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.c417
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.glade220
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.h65
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.c1031
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.h34
-rw-r--r--calendar/gui/alarm-notify/alarm.c305
-rw-r--r--calendar/gui/alarm-notify/alarm.h42
-rw-r--r--calendar/gui/alarm-notify/config-data.c112
-rw-r--r--calendar/gui/alarm-notify/config-data.h31
-rw-r--r--calendar/gui/alarm-notify/notify-main.c205
-rw-r--r--calendar/gui/alarm-notify/save.c315
-rw-r--r--calendar/gui/alarm-notify/save.h39
17 files changed, 0 insertions, 3397 deletions
diff --git a/calendar/gui/alarm-notify/.cvsignore b/calendar/gui/alarm-notify/.cvsignore
deleted file mode 100644
index 1f2b546c7c..0000000000
--- a/calendar/gui/alarm-notify/.cvsignore
+++ /dev/null
@@ -1,10 +0,0 @@
-.deps
-.libs
-Makefile
-Makefile.in
-evolution-calendar-stubs.c
-evolution-calendar-skels.c
-evolution-calendar-common.c
-evolution-calendar.h
-evolution-alarm-notify
-GNOME_Evolution_Calendar_AlarmNotify.oaf
diff --git a/calendar/gui/alarm-notify/GNOME_Evolution_Calendar_AlarmNotify.oaf.in b/calendar/gui/alarm-notify/GNOME_Evolution_Calendar_AlarmNotify.oaf.in
deleted file mode 100644
index 86f5c71493..0000000000
--- a/calendar/gui/alarm-notify/GNOME_Evolution_Calendar_AlarmNotify.oaf.in
+++ /dev/null
@@ -1,24 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Calendar_AlarmNotify_Factory"
- type="exe"
- location="evolution-alarm-notify">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
-
- <oaf_attribute name="description" type="string"
- _value="Factory for the alarm notification service"/>
-
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Calendar_AlarmNotify"
- type="factory"
- location="OAFIID:GNOME_Evolution_Calendar_AlarmNotify_Factory">
-
- <oaf_attribute name="description" type="string"
- _value="Alarm notification service"/>
-</oaf_server>
-
-</oaf_info>
diff --git a/calendar/gui/alarm-notify/Makefile.am b/calendar/gui/alarm-notify/Makefile.am
deleted file mode 100644
index 959319fc1d..0000000000
--- a/calendar/gui/alarm-notify/Makefile.am
+++ /dev/null
@@ -1,91 +0,0 @@
-CORBA_GENERATED = \
- evolution-calendar.h \
- evolution-calendar-common.c \
- evolution-calendar-skels.c \
- evolution-calendar-stubs.c
-
-idls = $(top_srcdir)/calendar/idl/evolution-calendar.idl
-
-idl_flags = `$(GNOME_CONFIG) --cflags idl` -I $(datadir)/idl
-
-$(CORBA_GENERATED): $(idls)
- $(ORBIT_IDL) $(idl_flags) $(top_srcdir)/calendar/idl/evolution-calendar.idl
-
-bin_PROGRAMS = evolution-alarm-notify
-
-noinst_LIBRARIES = libalarm.a
-
-libalarm_a_SOURCES = \
- alarm.c \
- alarm.h
-
-INCLUDES = \
- -DG_LOG_DOMAIN=\"evolution-alarm-notify\" \
- -I$(top_srcdir) \
- -I$(top_srcdir)/calendar \
- -I$(top_builddir)/calendar \
- -I$(top_srcdir)/libical/src/libical \
- -I$(top_builddir)/libical/src/libical \
- -I$(top_srcdir)/widgets \
- -I$(includedir) \
- $(BONOBO_VFS_GNOME_CFLAGS) \
- $(BONOBO_CONF_CFLAGS) \
- $(BONOBO_HTML_GNOME_CFLAGS) \
- $(EXTRA_GNOME_CFLAGS) \
- -DEVOLUTION_DATADIR=\""$(datadir)"\" \
- -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \
- -DEVOLUTION_ICONSDIR=\""$(iconsdir)"\" \
- -DEVOLUTION_LOCALEDIR=\""$(localedir)"\"
-
-iconsdir = $(datadir)/images/evolution
-
-gladedir = $(datadir)/evolution/glade
-
-glade_DATA = \
- alarm-notify.glade
-
-evolution_alarm_notify_SOURCES = \
- $(CORBA_GENERATED) \
- alarm-notify.c \
- alarm-notify.h \
- alarm-notify-dialog.c \
- alarm-notify-dialog.h \
- alarm-queue.c \
- alarm-queue.h \
- config-data.c \
- config-data.h \
- notify-main.c \
- save.c \
- save.h
-
-evolution_alarm_notify_LDADD = \
- libalarm.a \
- $(top_builddir)/calendar/cal-client/libcal-client.la \
- $(top_builddir)/calendar/cal-util/libcal-util.la \
- $(top_builddir)/libical/src/libical/libical-evolution.la \
- $(top_builddir)/libwombat/libwombat.la \
- $(top_builddir)/e-util/libeutil.la \
- $(BONOBO_CONF_LIBS) \
- $(BONOBO_VFS_GNOME_LIBS) \
- $(BONOBO_HTML_GNOME_LIBS) \
- $(EXTRA_GNOME_LIBS) \
- $(GAL_LIBS) \
- $(INTLLIBS)
-
-evolution_alarm_notify_LDFLAGS = -export-dynamic
-
-oafdir = $(datadir)/oaf
-oaf_in_files = \
- GNOME_Evolution_Calendar_AlarmNotify.oaf.in
-
-oaf_DATA = $(oaf_in_files:.oaf.in=.oaf)
-
-@XML_I18N_MERGE_OAF_RULE@
-
-EXTRA_DIST = \
- $(oaf_DATA) \
- $(oaf_in_files) \
- $(glade_DATA)
-
-BUILT_SOURCES = $(CORBA_GENERATED)
-CLEANFILES = $(BUILT_SOURCES)
diff --git a/calendar/gui/alarm-notify/alarm-notify-dialog.c b/calendar/gui/alarm-notify/alarm-notify-dialog.c
deleted file mode 100644
index 2ad6783cf9..0000000000
--- a/calendar/gui/alarm-notify/alarm-notify-dialog.c
+++ /dev/null
@@ -1,412 +0,0 @@
-/* Evolution calendar - alarm notification dialog
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Author: Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include <stdio.h>
-#include <string.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkspinbutton.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkwindow.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnome/gnome-i18n.h>
-#include <libgnomeui/gnome-winhints.h>
-#include <libgnomeui/gnome-window-icon.h>
-#include <glade/glade.h>
-#include <e-util/e-time-utils.h>
-#include <gal/util/e-unicode-i18n.h>
-#include <gal/widgets/e-unicode.h>
-#include <gal/widgets/e-scroll-frame.h>
-#include <gtkhtml/gtkhtml.h>
-#include <gtkhtml/gtkhtml-stream.h>
-#include "cal-util/timeutil.h"
-#include "alarm-notify-dialog.h"
-#include "config-data.h"
-
-
-GtkWidget *make_html_display (gchar *widget_name, char *s1, char *s2, int scroll, int shadow);
-
-/* The useful contents of the alarm notify dialog */
-typedef struct {
- GladeXML *xml;
-
- GtkWidget *dialog;
- GtkWidget *close;
- GtkWidget *snooze;
- GtkWidget *edit;
- GtkWidget *heading;
- GtkWidget *message;
- GtkWidget *snooze_time;
- GtkWidget *html;
-
- AlarmNotifyFunc func;
- gpointer func_data;
-} AlarmNotify;
-
-
-
-/* Callback used when the notify dialog is destroyed */
-static void
-dialog_destroy_cb (GtkObject *object, gpointer data)
-{
- AlarmNotify *an;
-
- an = data;
- gtk_object_unref (GTK_OBJECT (an->xml));
- g_free (an);
-}
-
-/* Delete_event handler for the alarm notify dialog */
-static gint
-delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
-{
- AlarmNotify *an;
-
- an = data;
- g_assert (an->func != NULL);
-
- (* an->func) (ALARM_NOTIFY_CLOSE, -1, an->func_data);
-
- gtk_widget_destroy (widget);
- return TRUE;
-}
-
-/* Callback for the close button */
-static void
-close_clicked_cb (GtkWidget *widget, gpointer data)
-{
- AlarmNotify *an;
-
- an = data;
- g_assert (an->func != NULL);
-
- (* an->func) (ALARM_NOTIFY_CLOSE, -1, an->func_data);
-
- gtk_widget_destroy (an->dialog);
-}
-
-/* Callback for the snooze button */
-static void
-snooze_clicked_cb (GtkWidget *widget, gpointer data)
-{
- AlarmNotify *an;
- int snooze_time;
-
- an = data;
- g_assert (an->func != NULL);
-
- snooze_time = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (an->snooze_time));
- (* an->func) (ALARM_NOTIFY_SNOOZE, snooze_time, an->func_data);
-
- gtk_widget_destroy (an->dialog);
-}
-
-/* Callback for the edit button */
-static void
-edit_clicked_cb (GtkWidget *widget, gpointer data)
-{
- AlarmNotify *an;
-
- an = data;
- g_assert (an->func != NULL);
-
- (* an->func) (ALARM_NOTIFY_EDIT, -1, an->func_data);
-
- gtk_widget_destroy (an->dialog);
-}
-
-static void
-url_requested_cb (GtkHTML *html, const char *url, GtkHTMLStream *stream, gpointer data)
-{
-
- if (!strncmp ("file:///", url, strlen ("file:///"))) {
- FILE *fp;
- const char *filename = url + strlen ("file://");
- char buf[4096];
- size_t len;
-
- fp = fopen (filename, "r");
-
- if (fp == NULL) {
- g_warning ("Error opening image: %s\n", url);
- gtk_html_stream_close (stream, GTK_HTML_STREAM_ERROR);
- return;
- }
-
- while ((len = fread (buf, 1, sizeof(buf), fp)) > 0)
- gtk_html_stream_write (stream, buf, len);
-
- if (feof (fp)) {
- fclose (fp);
- gtk_html_stream_close (stream, GTK_HTML_STREAM_OK);
- return;
- }
-
- fclose (fp);
- }
-
- g_warning ("Error loading image");
- gtk_html_stream_close (stream, GTK_HTML_STREAM_ERROR);
- return;
-}
-
-GtkWidget *
-make_html_display (gchar *widget_name, char *s1, char *s2, int scroll, int shadow)
-{
- GtkWidget *html, *frame;
-
- gtk_widget_push_visual(gdk_rgb_get_visual());
- gtk_widget_push_colormap(gdk_rgb_get_cmap());
-
- html = gtk_html_new();
-
- gtk_html_set_default_content_type (GTK_HTML (html),
- "charset=utf-8");
- gtk_html_load_empty (GTK_HTML (html));
-
- gtk_signal_connect (GTK_OBJECT (html), "url_requested",
- GTK_SIGNAL_FUNC (url_requested_cb),
- NULL);
-
- gtk_widget_pop_colormap();
- gtk_widget_pop_visual();
-
- frame = e_scroll_frame_new(NULL, NULL);
-
- e_scroll_frame_set_policy(E_SCROLL_FRAME(frame),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
-
-
- e_scroll_frame_set_shadow_type (E_SCROLL_FRAME (frame),
- GTK_SHADOW_IN);
-
- gtk_widget_set_usize (frame, 300, 200);
-
- gtk_container_add(GTK_CONTAINER (frame), html);
-
- gtk_widget_show_all(frame);
-
- gtk_object_set_user_data(GTK_OBJECT (frame), html);
- return frame;
-}
-
-static void
-write_times (GtkHTMLStream *stream, char *start, char *end)
-{
- if (start)
- gtk_html_stream_printf (stream, "<b>%s</b> %s<br>", U_("Starting:"), start);
- if (end)
- gtk_html_stream_printf (stream, "<b>%s</b> %s<br>", U_("Ending:"), end);
-
-}
-
-/* Converts a time_t to a string, relative to the specified timezone */
-static char *
-timet_to_str_with_zone (time_t t, icaltimezone *zone)
-{
- struct icaltimetype itt;
- struct tm tm;
- char buf[256];
-
- if (t == -1)
- return g_strdup (_("invalid time"));
-
- itt = icaltime_from_timet_with_zone (t, FALSE, zone);
- tm = icaltimetype_to_tm (&itt);
-
- e_time_format_date_and_time (&tm, config_data_get_24_hour_format (),
- FALSE, FALSE, buf, sizeof (buf));
- return g_strdup (buf);
-}
-
-/* Creates a heading for the alarm notification dialog */
-static void
-write_html_heading (GtkHTMLStream *stream, const char *message,
- CalComponentVType vtype, time_t occur_start, time_t occur_end)
-{
- char *buf;
- char *start, *end;
- char *bg_path = "file://" EVOLUTION_ICONSDIR "/bcg.png";
- char *image_path = "file://" EVOLUTION_ICONSDIR "/alarm.png";
- icaltimezone *current_zone;
-
- /* Stringize the times */
-
- current_zone = config_data_get_timezone ();
-
- buf = timet_to_str_with_zone (occur_start, current_zone);
- start = e_utf8_from_locale_string (buf);
- g_free (buf);
-
- buf = timet_to_str_with_zone (occur_end, current_zone);
- end = e_utf8_from_locale_string (buf);
- g_free (buf);
-
- /* Write the header */
-
- gtk_html_stream_printf (stream,
- "<HTML><BODY background=\"%s\">"
- "<TABLE WIDTH=\"100%%\">"
- "<TR>"
- "<TD><IMG SRC=\"%s\" ALIGN=\"top\" BORDER=\"0\"></TD>"
- "<TD><H1>%s</H1></TD>"
- "</TR>"
- "</TABLE>",
- bg_path,
- image_path,
- U_("Evolution Alarm"));
-
- gtk_html_stream_printf (stream, "<br><br><font size=\"+2\">%s</font><br><br>", message);
-
- /* Write the times */
-
- switch (vtype) {
- case CAL_COMPONENT_EVENT:
- write_times (stream, start, end);
- break;
-
- case CAL_COMPONENT_TODO:
- write_times (stream, start, end);
- break;
-
- default:
- /* Only VEVENTs and VTODOs can have alarms */
- g_assert_not_reached ();
- break;
- }
-
- g_free (start);
- g_free (end);
-}
-
-/**
- * alarm_notify_dialog:
- * @trigger: Trigger time for the alarm.
- * @occur_start: Start of occurrence time for the event.
- * @occur_end: End of occurrence time for the event.
- * @vtype: Type of the component which corresponds to the alarm.
- * @message; Message to display in the dialog; usually comes from the component.
- * @func: Function to be called when a dialog action is invoked.
- * @func_data: Closure data for @func.
- *
- * Runs the alarm notification dialog. The specified @func will be used to
- * notify the client about result of the actions in the dialog.
- *
- * Return value: TRUE on success, FALSE if the dialog could not be created.
- **/
-gboolean
-alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
- CalComponentVType vtype, const char *message,
- AlarmNotifyFunc func, gpointer func_data)
-{
- AlarmNotify *an;
- GtkHTMLStream *stream;
- icaltimezone *current_zone;
- char *buf, *title;
-
- g_return_val_if_fail (trigger != -1, FALSE);
-
- /* Only VEVENTs or VTODOs can have alarms */
- g_return_val_if_fail (vtype == CAL_COMPONENT_EVENT || vtype == CAL_COMPONENT_TODO, FALSE);
- g_return_val_if_fail (message != NULL, FALSE);
- g_return_val_if_fail (func != NULL, FALSE);
-
- an = g_new0 (AlarmNotify, 1);
-
- an->func = func;
- an->func_data = func_data;
-
- an->xml = glade_xml_new (EVOLUTION_GLADEDIR "/alarm-notify.glade", NULL);
- if (!an->xml) {
- g_message ("alarm_notify_dialog(): Could not load the Glade XML file!");
- g_free (an);
- return FALSE;
- }
-
- an->dialog = glade_xml_get_widget (an->xml, "alarm-notify");
- an->close = glade_xml_get_widget (an->xml, "close");
- an->snooze = glade_xml_get_widget (an->xml, "snooze");
- an->edit = glade_xml_get_widget (an->xml, "edit");
- an->heading = glade_xml_get_widget (an->xml, "heading");
- an->message = glade_xml_get_widget (an->xml, "message");
- an->snooze_time = glade_xml_get_widget (an->xml, "snooze-time");
- an->html = gtk_object_get_user_data (GTK_OBJECT (glade_xml_get_widget (an->xml, "frame")));
-
- if (!(an->dialog && an->close && an->snooze && an->edit && an->heading && an->message
- && an->snooze_time)) {
- g_message ("alarm_notify_dialog(): Could not find all widgets in Glade file!");
- gtk_object_unref (GTK_OBJECT (an->xml));
- g_free (an);
- return FALSE;
- }
-
- gtk_object_set_data (GTK_OBJECT (an->dialog), "alarm-notify", an);
- gtk_signal_connect (GTK_OBJECT (an->dialog), "destroy",
- GTK_SIGNAL_FUNC (dialog_destroy_cb), an);
-
- /* Title */
-
- current_zone = config_data_get_timezone ();
-
- buf = timet_to_str_with_zone (trigger, current_zone);
- title = g_strdup_printf (_("Alarm on %s"), buf);
- g_free (buf);
-
- gtk_window_set_title (GTK_WINDOW (an->dialog), title);
- g_free (title);
-
- /* html heading */
- stream = gtk_html_begin (GTK_HTML (an->html));
- write_html_heading (stream, message, vtype, occur_start, occur_end);
- gtk_html_stream_close (stream, GTK_HTML_STREAM_OK);
-
- /* Connect actions */
-
- gtk_signal_connect (GTK_OBJECT (an->dialog), "delete_event",
- GTK_SIGNAL_FUNC (delete_event_cb),
- an);
-
- gtk_signal_connect (GTK_OBJECT (an->close), "clicked",
- GTK_SIGNAL_FUNC (close_clicked_cb),
- an);
-
- gtk_signal_connect (GTK_OBJECT (an->snooze), "clicked",
- GTK_SIGNAL_FUNC (snooze_clicked_cb),
- an);
-
- gtk_signal_connect (GTK_OBJECT (an->edit), "clicked",
- GTK_SIGNAL_FUNC (edit_clicked_cb),
- an);
-
- /* Run! */
-
- if (!GTK_WIDGET_REALIZED (an->dialog))
- gtk_widget_realize (an->dialog);
-
- gnome_win_hints_set_state (an->dialog, WIN_STATE_STICKY);
- gnome_win_hints_set_layer (an->dialog, WIN_LAYER_ONTOP);
- gnome_window_icon_set_from_file (GTK_WINDOW (an->dialog), EVOLUTION_ICONSDIR "/alarm.png");
-
- gtk_widget_show (an->dialog);
- return TRUE;
-}
-
diff --git a/calendar/gui/alarm-notify/alarm-notify-dialog.h b/calendar/gui/alarm-notify/alarm-notify-dialog.h
deleted file mode 100644
index 812463de8d..0000000000
--- a/calendar/gui/alarm-notify/alarm-notify-dialog.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Evolution calendar - alarm notification dialog
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Author: Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef ALARM_NOTIFY_DIALOG_H
-#define ALARM_NOTIFY_DIALOG_H
-
-#include <time.h>
-#include <glib.h>
-#include <cal-util/cal-component.h>
-
-
-
-typedef enum {
- ALARM_NOTIFY_CLOSE,
- ALARM_NOTIFY_SNOOZE,
- ALARM_NOTIFY_EDIT
-} AlarmNotifyResult;
-
-typedef void (* AlarmNotifyFunc) (AlarmNotifyResult result, int snooze_mins, gpointer data);
-
-gboolean alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
- CalComponentVType vtype, const char *message,
- AlarmNotifyFunc func, gpointer func_data);
-
-
-
-#endif
diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c
deleted file mode 100644
index 23b6378a7b..0000000000
--- a/calendar/gui/alarm-notify/alarm-notify.c
+++ /dev/null
@@ -1,417 +0,0 @@
-/* Evolution calendar - Alarm notification service object
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Author: Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <libgnomevfs/gnome-vfs.h>
-#include <cal-client/cal-client.h>
-#include "alarm-notify.h"
-#include "alarm-queue.h"
-#include "save.h"
-
-
-
-/* A loaded client */
-typedef struct {
- /* The actual client */
- CalClient *client;
-
- /* The URI of the client in gnome-vfs's format. This *is* the key that
- * is stored in the uri_client_hash hash table below.
- */
- GnomeVFSURI *uri;
-
- /* Number of times clients have requested this URI to be added to the
- * alarm notification system.
- */
- int refcount;
-} LoadedClient;
-
-/* Private part of the AlarmNotify structure */
-struct _AlarmNotifyPrivate {
- /* Mapping from GnomeVFSURIs to LoadedClient structures */
- GHashTable *uri_client_hash;
-};
-
-
-
-static void alarm_notify_class_init (AlarmNotifyClass *class);
-static void alarm_notify_init (AlarmNotify *an);
-static void alarm_notify_destroy (GtkObject *object);
-
-static void AlarmNotify_addCalendar (PortableServer_Servant servant,
- const CORBA_char *str_uri,
- CORBA_Environment *ev);
-static void AlarmNotify_removeCalendar (PortableServer_Servant servant,
- const CORBA_char *str_uri,
- CORBA_Environment *ev);
-
-
-static BonoboXObjectClass *parent_class;
-
-
-
-BONOBO_X_TYPE_FUNC_FULL (AlarmNotify,
- GNOME_Evolution_Calendar_AlarmNotify,
- BONOBO_X_OBJECT_TYPE,
- alarm_notify);
-
-/* Class initialization function for the alarm notify service */
-static void
-alarm_notify_class_init (AlarmNotifyClass *class)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) class;
-
- parent_class = gtk_type_class (BONOBO_X_OBJECT_TYPE);
-
- class->epv.addCalendar = AlarmNotify_addCalendar;
- class->epv.removeCalendar = AlarmNotify_removeCalendar;
-
- object_class->destroy = alarm_notify_destroy;
-}
-
-/* Object initialization function for the alarm notify system */
-static void
-alarm_notify_init (AlarmNotify *an)
-{
- AlarmNotifyPrivate *priv;
-
- priv = g_new0 (AlarmNotifyPrivate, 1);
- an->priv = priv;
-
- priv->uri_client_hash = g_hash_table_new (gnome_vfs_uri_hash, gnome_vfs_uri_hequal);
-}
-
-/* Callback used from g_hash-table_forach(), used to destroy a loade client */
-static void
-destroy_loaded_client_cb (gpointer key, gpointer value, gpointer data)
-{
- LoadedClient *lc;
-
- lc = value;
-
- gtk_object_unref (GTK_OBJECT (lc->client));
- gnome_vfs_uri_unref (lc->uri);
- g_free (lc);
-}
-
-/* Destroy handler for the alarm notify system */
-static void
-alarm_notify_destroy (GtkObject *object)
-{
- AlarmNotify *an;
- AlarmNotifyPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_ALARM_NOTIFY (object));
-
- an = ALARM_NOTIFY (object);
- priv = an->priv;
-
- g_hash_table_foreach (priv->uri_client_hash, destroy_loaded_client_cb, NULL);
-
- g_hash_table_destroy (priv->uri_client_hash);
- priv->uri_client_hash = NULL;
-
- g_free (priv);
- an->priv = NULL;
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-
-
-/* CORBA servant implementation */
-
-/* Looks for a canonicalized URI inside an array of URIs; returns the index
- * within the array or -1 if not found.
- */
-static int
-find_uri_index (GPtrArray *uris, const char *str_uri)
-{
- int i;
-
- for (i = 0; i < uris->len; i++) {
- char *uri;
-
- uri = uris->pdata[i];
- if (strcmp (uri, str_uri) == 0)
- break;
- }
-
- if (i == uris->len)
- return -1;
- else
- return i;
-}
-
-/* Frees an array of URIs and the URIs within it. */
-static void
-free_uris (GPtrArray *uris)
-{
- int i;
-
- for (i = 0; i < uris->len; i++) {
- char *uri;
-
- uri = uris->pdata[i];
- g_free (uri);
- }
-
- g_ptr_array_free (uris, TRUE);
-}
-
-/* Adds an URI to the list of calendars to load on startup */
-static void
-add_uri_to_load (GnomeVFSURI *uri)
-{
- char *str_uri;
- GPtrArray *loaded_uris;
- int i;
-
- /* Canonicalize the URI */
- str_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
- g_assert (str_uri != NULL);
-
- loaded_uris = get_calendars_to_load ();
- if (!loaded_uris) {
- g_message ("add_uri_to_load(): Could not get the list of calendars to load; "
- "will not add `%s'", str_uri);
- g_free (str_uri);
- return;
- }
-
- /* Look for the URI in the list of calendars to load */
-
- i = find_uri_index (loaded_uris, str_uri);
-
- /* We only need to add the URI if we didn't find it among the list of
- * calendars.
- */
- if (i != -1) {
- g_free (str_uri);
- free_uris (loaded_uris);
- return;
- }
-
- g_ptr_array_add (loaded_uris, str_uri);
- save_calendars_to_load (loaded_uris);
-
- free_uris (loaded_uris);
-}
-
-/* Removes an URI from the list of calendars to load on startup */
-static void
-remove_uri_to_load (GnomeVFSURI *uri)
-{
- char *str_uri;
- GPtrArray *loaded_uris;
- char *loaded_uri;
- int i;
-
- /* Canonicalize the URI */
- str_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
- g_assert (str_uri != NULL);
-
- loaded_uris = get_calendars_to_load ();
- if (!loaded_uris) {
- g_message ("remove_uri_to_load(): Could not get the list of calendars to load; "
- "will not add `%s'", str_uri);
- g_free (str_uri);
- return;
- }
-
- /* Look for the URI in the list of calendars to load */
-
- i = find_uri_index (loaded_uris, str_uri);
- g_free (str_uri);
-
- /* If we didn't find it, there is no need to remove it */
- if (i == -1) {
- free_uris (loaded_uris);
- return;
- }
-
- loaded_uri = loaded_uris->pdata[i];
- g_free (loaded_uri);
-
- g_ptr_array_remove_index (loaded_uris, i);
- save_calendars_to_load (loaded_uris);
-
- free_uris (loaded_uris);
-}
-
-/* AlarmNotify::addCalendar method */
-static void
-AlarmNotify_addCalendar (PortableServer_Servant servant,
- const CORBA_char *str_uri,
- CORBA_Environment *ev)
-{
- AlarmNotify *an;
-
- an = ALARM_NOTIFY (bonobo_object_from_servant (servant));
- alarm_notify_add_calendar (an, str_uri, TRUE, ev);
-}
-
-/* AlarmNotify::removeCalendar method */
-static void
-AlarmNotify_removeCalendar (PortableServer_Servant servant,
- const CORBA_char *str_uri,
- CORBA_Environment *ev)
-{
- AlarmNotify *an;
- AlarmNotifyPrivate *priv;
- LoadedClient *lc;
- GnomeVFSURI *uri;
-
- an = ALARM_NOTIFY (bonobo_object_from_servant (servant));
- priv = an->priv;
-
- uri = gnome_vfs_uri_new (str_uri);
- if (!uri) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_GNOME_Evolution_Calendar_AlarmNotify_InvalidURI,
- NULL);
- return;
- }
-
- remove_uri_to_load (uri);
-
- lc = g_hash_table_lookup (priv->uri_client_hash, uri);
- gnome_vfs_uri_unref (uri);
-
- if (!lc) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_GNOME_Evolution_Calendar_AlarmNotify_NotFound,
- NULL);
- return;
- }
-
- g_assert (lc->refcount > 0);
-
- lc->refcount--;
- if (lc->refcount > 0)
- return;
-
- g_hash_table_remove (priv->uri_client_hash, lc->uri);
-
- gtk_object_unref (GTK_OBJECT (lc->client));
- gnome_vfs_uri_unref (lc->uri);
- g_free (lc);
-}
-
-
-
-/**
- * alarm_notify_new:
- *
- * Creates a new #AlarmNotify object.
- *
- * Return value: A newly-created #AlarmNotify, or NULL if its corresponding
- * CORBA object could not be created.
- **/
-AlarmNotify *
-alarm_notify_new (void)
-{
- AlarmNotify *an;
-
- an = gtk_type_new (TYPE_ALARM_NOTIFY);
- return an;
-}
-
-/**
- * alarm_notify_add_calendar:
- * @an: An alarm notification service.
- * @uri: URI of the calendar to load.
- * @load_afterwards: Whether this calendar should be loaded in the future
- * when the alarm daemon starts up.
- * @ev: CORBA environment for exceptions.
- *
- * Tells the alarm notification service to load a calendar and start monitoring
- * its alarms. It can optionally be made to save the URI of this calendar so
- * that it can be loaded in the future when the alarm daemon starts up.
- **/
-void
-alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_afterwards,
- CORBA_Environment *ev)
-{
- AlarmNotifyPrivate *priv;
- GnomeVFSURI *uri;
- CalClient *client;
- LoadedClient *lc;
-
- g_return_if_fail (an != NULL);
- g_return_if_fail (IS_ALARM_NOTIFY (an));
- g_return_if_fail (str_uri != NULL);
- g_return_if_fail (ev != NULL);
-
- priv = an->priv;
-
- uri = gnome_vfs_uri_new (str_uri);
- if (!uri) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_GNOME_Evolution_Calendar_AlarmNotify_InvalidURI,
- NULL);
- return;
- }
-
- if (load_afterwards)
- add_uri_to_load (uri);
-
- lc = g_hash_table_lookup (priv->uri_client_hash, uri);
-
- if (lc) {
- gnome_vfs_uri_unref (uri);
- g_assert (lc->refcount > 0);
- lc->refcount++;
- return;
- }
-
- client = cal_client_new ();
-
- if (client) {
- if (cal_client_open_calendar (client, str_uri, FALSE)) {
- lc = g_new (LoadedClient, 1);
- lc->client = client;
- lc->uri = uri;
- lc->refcount = 1;
- g_hash_table_insert (priv->uri_client_hash, uri, lc);
-
- alarm_queue_add_client (client);
- } else {
- gtk_object_unref (GTK_OBJECT (client));
- client = NULL;
- }
- }
-
- if (!client) {
- gnome_vfs_uri_unref (uri);
-
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_GNOME_Evolution_Calendar_AlarmNotify_BackendContactError,
- NULL);
- return;
- }
-}
diff --git a/calendar/gui/alarm-notify/alarm-notify.glade b/calendar/gui/alarm-notify/alarm-notify.glade
deleted file mode 100644
index e71828ca53..0000000000
--- a/calendar/gui/alarm-notify/alarm-notify.glade
+++ /dev/null
@@ -1,220 +0,0 @@
-<?xml version="1.0"?>
-<GTK-Interface>
-
-<project>
- <name>Evolution Calendar</name>
- <program_name>evolution-calendar</program_name>
- <directory></directory>
- <source_directory>src</source_directory>
- <pixmaps_directory>pixmaps</pixmaps_directory>
- <language>C</language>
- <gnome_support>True</gnome_support>
- <gettext_support>True</gettext_support>
-</project>
-
-<widget>
- <class>GtkWindow</class>
- <name>alarm-notify</name>
- <title></title>
- <type>GTK_WINDOW_DIALOG</type>
- <position>GTK_WIN_POS_CENTER</position>
- <modal>False</modal>
- <allow_shrink>False</allow_shrink>
- <allow_grow>False</allow_grow>
- <auto_shrink>False</auto_shrink>
-
- <widget>
- <class>GtkVBox</class>
- <name>vbox2</name>
- <border_width>4</border_width>
- <homogeneous>False</homogeneous>
- <spacing>4</spacing>
-
- <widget>
- <class>GtkHBox</class>
- <name>hbox3</name>
- <homogeneous>False</homogeneous>
- <spacing>8</spacing>
- <child>
- <padding>0</padding>
- <expand>True</expand>
- <fill>True</fill>
- </child>
-
- <widget>
- <class>GtkVBox</class>
- <name>vbox5</name>
- <homogeneous>False</homogeneous>
- <spacing>4</spacing>
- <child>
- <padding>0</padding>
- <expand>True</expand>
- <fill>True</fill>
- </child>
-
- <widget>
- <class>GtkLabel</class>
- <name>heading</name>
- <label></label>
- <justify>GTK_JUSTIFY_LEFT</justify>
- <wrap>True</wrap>
- <xalign>0</xalign>
- <yalign>0.5</yalign>
- <xpad>0</xpad>
- <ypad>0</ypad>
- <child>
- <padding>0</padding>
- <expand>False</expand>
- <fill>False</fill>
- </child>
- </widget>
-
- <widget>
- <class>GtkLabel</class>
- <name>message</name>
- <label></label>
- <justify>GTK_JUSTIFY_LEFT</justify>
- <wrap>True</wrap>
- <xalign>0</xalign>
- <yalign>0.5</yalign>
- <xpad>0</xpad>
- <ypad>0</ypad>
- <child>
- <padding>0</padding>
- <expand>False</expand>
- <fill>False</fill>
- </child>
- </widget>
-
- <widget>
- <class>Custom</class>
- <name>frame</name>
- <creation_function>make_html_display</creation_function>
- <int1>0</int1>
- <int2>0</int2>
- <last_modification_time>Thu, 11 Oct 2001 08:19:04 GMT</last_modification_time>
- <child>
- <padding>0</padding>
- <expand>True</expand>
- <fill>True</fill>
- </child>
- </widget>
- </widget>
-
- <widget>
- <class>GtkVBox</class>
- <name>vbox4</name>
- <homogeneous>False</homogeneous>
- <spacing>4</spacing>
- <child>
- <padding>0</padding>
- <expand>True</expand>
- <fill>True</fill>
- </child>
-
- <widget>
- <class>GtkButton</class>
- <name>close</name>
- <can_focus>True</can_focus>
- <label>C_lose</label>
- <relief>GTK_RELIEF_NORMAL</relief>
- <child>
- <padding>0</padding>
- <expand>False</expand>
- <fill>False</fill>
- </child>
- </widget>
-
- <widget>
- <class>GtkButton</class>
- <name>snooze</name>
- <can_focus>True</can_focus>
- <label>Snoo_ze</label>
- <relief>GTK_RELIEF_NORMAL</relief>
- <child>
- <padding>0</padding>
- <expand>False</expand>
- <fill>False</fill>
- </child>
- </widget>
-
- <widget>
- <class>GtkButton</class>
- <name>edit</name>
- <can_focus>True</can_focus>
- <label>_Edit appointment</label>
- <relief>GTK_RELIEF_NORMAL</relief>
- <child>
- <padding>0</padding>
- <expand>False</expand>
- <fill>False</fill>
- </child>
- </widget>
- </widget>
- </widget>
-
- <widget>
- <class>GtkHSeparator</class>
- <name>hseparator1</name>
- <child>
- <padding>0</padding>
- <expand>True</expand>
- <fill>True</fill>
- </child>
- </widget>
-
- <widget>
- <class>GtkHBox</class>
- <name>hbox4</name>
- <homogeneous>False</homogeneous>
- <spacing>4</spacing>
- <child>
- <padding>0</padding>
- <expand>True</expand>
- <fill>True</fill>
- </child>
-
- <widget>
- <class>GtkLabel</class>
- <name>label4</name>
- <label>Snooze time (minutes)</label>
- <justify>GTK_JUSTIFY_CENTER</justify>
- <wrap>False</wrap>
- <xalign>0</xalign>
- <yalign>0.5</yalign>
- <xpad>0</xpad>
- <ypad>0</ypad>
- <child>
- <padding>0</padding>
- <expand>False</expand>
- <fill>False</fill>
- </child>
- </widget>
-
- <widget>
- <class>GtkSpinButton</class>
- <name>snooze-time</name>
- <can_focus>True</can_focus>
- <climb_rate>1</climb_rate>
- <digits>0</digits>
- <numeric>False</numeric>
- <update_policy>GTK_UPDATE_ALWAYS</update_policy>
- <snap>False</snap>
- <wrap>False</wrap>
- <value>5</value>
- <lower>1</lower>
- <upper>1440</upper>
- <step>1</step>
- <page>5</page>
- <page_size>5</page_size>
- <child>
- <padding>0</padding>
- <expand>False</expand>
- <fill>False</fill>
- </child>
- </widget>
- </widget>
- </widget>
-</widget>
-
-</GTK-Interface>
diff --git a/calendar/gui/alarm-notify/alarm-notify.h b/calendar/gui/alarm-notify/alarm-notify.h
deleted file mode 100644
index 858c3a7d87..0000000000
--- a/calendar/gui/alarm-notify/alarm-notify.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Evolution calendar - Alarm notification service object
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 2000 Ximian, Inc.
- *
- * Author: Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef ALARM_NOTIFY_H
-#define ALARM_NOTIFY_H
-
-#include <bonobo/bonobo-xobject.h>
-#include "evolution-calendar.h"
-
-
-
-#define TYPE_ALARM_NOTIFY (alarm_notify_get_type ())
-#define ALARM_NOTIFY(obj) (GTK_CHECK_CAST ((obj), TYPE_ALARM_NOTIFY, AlarmNotify))
-#define ALARM_NOTIFY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_ALARM_NOTIFY, \
- AlarmNotifyClass))
-#define IS_ALARM_NOTIFY(obj) (GTK_CHECK_TYPE ((obj), TYPE_ALARM_NOTIFY))
-#define IS_ALARM_NOTIFY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_ALARM_NOTIFY))
-
-typedef struct _AlarmNotify AlarmNotify;
-typedef struct _AlarmNotifyClass AlarmNotifyClass;
-
-typedef struct _AlarmNotifyPrivate AlarmNotifyPrivate;
-
-struct _AlarmNotify {
- BonoboXObject xobject;
-
- /* Private data */
- AlarmNotifyPrivate *priv;
-};
-
-struct _AlarmNotifyClass {
- BonoboXObjectClass parent_class;
-
- POA_GNOME_Evolution_Calendar_AlarmNotify__epv epv;
-};
-
-GtkType alarm_notify_get_type (void);
-
-AlarmNotify *alarm_notify_new (void);
-
-void alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_afterwards,
- CORBA_Environment *ev);
-
-
-
-
-#endif
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c
deleted file mode 100644
index fd22649e71..0000000000
--- a/calendar/gui/alarm-notify/alarm-queue.c
+++ /dev/null
@@ -1,1031 +0,0 @@
-/* Evolution calendar - Alarm queueing engine
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Authors: Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-#include <liboaf/liboaf.h>
-#include <bonobo/bonobo-object.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkbox.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkcheckbutton.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnome/gnome-i18n.h>
-#include <libgnome/gnome-exec.h>
-#include <libgnome/gnome-sound.h>
-#include <libgnomeui/gnome-dialog.h>
-#include <libgnomeui/gnome-dialog-util.h>
-#include <libgnomeui/gnome-dialog.h>
-#include <libgnomeui/gnome-stock.h>
-#include <libgnomeui/gnome-uidefs.h>
-#include <cal-util/timeutil.h>
-#include "alarm.h"
-#include "alarm-notify-dialog.h"
-#include "alarm-queue.h"
-#include "config-data.h"
-#include "save.h"
-
-
-
-/* Whether the queueing system has been initialized */
-static gboolean alarm_queue_inited;
-
-/* When the alarm queue system is inited, this gets set to the last time an
- * alarm notification was issued. This lets us present any notifications that
- * should have happened while the alarm daemon was not running.
- */
-static time_t saved_notification_time;
-
-/* Clients we are monitoring for alarms */
-static GHashTable *client_alarms_hash = NULL;
-
-/* Structure that stores a client we are monitoring */
-typedef struct {
- /* Monitored client */
- CalClient *client;
-
- /* Number of times this client has been registered */
- int refcount;
-
- /* Hash table of component UID -> CompQueuedAlarms. If an element is
- * present here, then it means its cqa->queued_alarms contains at least
- * one queued alarm. When all the alarms for a component have been
- * dequeued, the CompQueuedAlarms structure is removed from the hash
- * table. Thus a CQA exists <=> it has queued alarms.
- */
- GHashTable *uid_alarms_hash;
-} ClientAlarms;
-
-/* Pair of a CalComponentAlarms and the mapping from queued alarm IDs to the
- * actual alarm instance structures.
- */
-typedef struct {
- /* The parent client alarms structure */
- ClientAlarms *parent_client;
-
- /* The actual component and its alarm instances */
- CalComponentAlarms *alarms;
-
- /* List of QueuedAlarm structures */
- GSList *queued_alarms;
-} CompQueuedAlarms;
-
-/* Pair of a queued alarm ID and the alarm trigger instance it refers to */
-typedef struct {
- /* Alarm ID from alarm.h */
- gpointer alarm_id;
-
- /* Instance from our parent CompQueuedAlarms->alarms->alarms list */
- CalAlarmInstance *instance;
-
- /* Whether this is a snoozed queued alarm or a normal one */
- guint snooze : 1;
-} QueuedAlarm;
-
-/* Alarm ID for the midnight refresh function */
-static gpointer midnight_refresh_id = NULL;
-
-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);
-
-
-
-/* Alarm queue engine */
-
-static void load_alarms_for_today (ClientAlarms *ca);
-static void midnight_refresh_cb (gpointer alarm_id, time_t trigger, gpointer data);
-
-/* Queues an alarm trigger for midnight so that we can load the next day's worth
- * of alarms.
- */
-static void
-queue_midnight_refresh (void)
-{
- time_t midnight;
- icaltimezone *zone;
-
- g_assert (midnight_refresh_id == NULL);
-
- zone = config_data_get_timezone ();
-
- midnight = time_day_end_with_zone (time (NULL), zone);
-
- midnight_refresh_id = alarm_add (midnight, midnight_refresh_cb, NULL, NULL);
- if (!midnight_refresh_id) {
- g_message ("queue_midnight_refresh(): Could not set up the midnight refresh alarm!");
- /* FIXME: what to do? */
- }
-}
-
-/* Loads a client's alarms; called from g_hash_table_foreach() */
-static void
-add_client_alarms_cb (gpointer key, gpointer value, gpointer data)
-{
- ClientAlarms *ca;
-
- ca = value;
- load_alarms_for_today (ca);
-}
-
-/* Loads the alarms for the new day every midnight */
-static void
-midnight_refresh_cb (gpointer alarm_id, time_t trigger, gpointer data)
-{
- /* Re-load the alarms for all clients */
-
- g_hash_table_foreach (client_alarms_hash, add_client_alarms_cb, NULL);
-
- /* Re-schedule the midnight update */
-
- midnight_refresh_id = NULL;
- queue_midnight_refresh ();
-}
-
-/* Looks up a client in the client alarms hash table */
-static ClientAlarms *
-lookup_client (CalClient *client)
-{
- return g_hash_table_lookup (client_alarms_hash, client);
-}
-
-/* Looks up a queued alarm based on its alarm ID */
-static QueuedAlarm *
-lookup_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id)
-{
- GSList *l;
- QueuedAlarm *qa;
-
- qa = NULL;
-
- for (l = cqa->queued_alarms; l; l = l->next) {
- qa = l->data;
- if (qa->alarm_id == alarm_id)
- break;
- }
-
- g_assert (l != NULL);
- return qa;
-}
-
-/* Removes an alarm from the list of alarms of a component. If the alarm was
- * the last one listed for the component, it removes the component itself.
- */
-static void
-remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id)
-{
- QueuedAlarm *qa;
- const char *uid;
- GSList *l;
-
- qa = NULL;
-
- for (l = cqa->queued_alarms; l; l = l->next) {
- qa = l->data;
- if (qa->alarm_id == alarm_id)
- break;
- }
-
- g_assert (l != NULL);
-
- cqa->queued_alarms = g_slist_remove_link (cqa->queued_alarms, l);
- g_slist_free_1 (l);
-
- g_free (qa);
-
- /* If this was the last queued alarm for this component, remove the
- * component itself.
- */
-
- if (cqa->queued_alarms != NULL)
- return;
-
- cal_component_get_uid (cqa->alarms->comp, &uid);
- g_hash_table_remove (cqa->parent_client->uid_alarms_hash, uid);
- cqa->parent_client = NULL;
-
- cal_component_alarms_free (cqa->alarms);
- cqa->alarms = NULL;
-
- g_free (cqa);
-}
-
-/* Callback used when an alarm triggers */
-static void
-alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data)
-{
- CompQueuedAlarms *cqa;
- CalComponent *comp;
- QueuedAlarm *qa;
- CalComponentAlarm *alarm;
- CalAlarmAction action;
-
- cqa = data;
- comp = cqa->alarms->comp;
-
- save_notification_time (trigger);
-
- qa = lookup_queued_alarm (cqa, alarm_id);
-
- /* Decide what to do based on the alarm action. We use the trigger that
- * is passed to us instead of the one from the instance structure
- * because this may be a snoozed alarm instead of an original
- * occurrence.
- */
-
- alarm = cal_component_get_alarm (comp, qa->instance->auid);
- g_assert (alarm != NULL);
-
- cal_component_alarm_get_action (alarm, &action);
- cal_component_alarm_free (alarm);
-
- switch (action) {
- case CAL_ALARM_AUDIO:
- audio_notification (trigger, cqa, alarm_id);
- break;
-
- case CAL_ALARM_DISPLAY:
- display_notification (trigger, cqa, alarm_id, TRUE);
- break;
-
- case CAL_ALARM_EMAIL:
- mail_notification (trigger, cqa, alarm_id);
- break;
-
- case CAL_ALARM_PROCEDURE:
- procedure_notification (trigger, cqa, alarm_id);
- break;
-
- default:
- g_assert_not_reached ();
- break;
- }
-}
-
-/* Adds the alarms in a CalComponentAlarms structure to the alarms queued for a
- * particular client. Also puts the triggers in the alarm timer queue.
- */
-static void
-add_component_alarms (ClientAlarms *ca, CalComponentAlarms *alarms)
-{
- const char *uid;
- CompQueuedAlarms *cqa;
- GSList *l;
-
- /* No alarms? */
- if (alarms->alarms == NULL) {
- cal_component_alarms_free (alarms);
- return;
- }
-
- cqa = g_new (CompQueuedAlarms, 1);
- cqa->parent_client = ca;
- cqa->alarms = alarms;
-
- cqa->queued_alarms = NULL;
-
- for (l = alarms->alarms; l; l = l->next) {
- CalAlarmInstance *instance;
- gpointer alarm_id;
- QueuedAlarm *qa;
-
- instance = l->data;
-
- alarm_id = alarm_add (instance->trigger, alarm_trigger_cb, cqa, NULL);
- if (!alarm_id) {
- g_message ("add_component_alarms(): Could not schedule a trigger for "
- "%ld, discarding...", (long) instance->trigger);
- continue;
- }
-
- qa = g_new (QueuedAlarm, 1);
- qa->alarm_id = alarm_id;
- qa->instance = instance;
- qa->snooze = FALSE;
-
- cqa->queued_alarms = g_slist_prepend (cqa->queued_alarms, qa);
- }
-
- cal_component_get_uid (alarms->comp, &uid);
-
- /* If we failed to add all the alarms, then we should get rid of the cqa */
- if (cqa->queued_alarms == NULL) {
- g_message ("add_component_alarms(): Could not add any of the alarms "
- "for the component `%s'; discarding it...", uid);
-
- cal_component_alarms_free (cqa->alarms);
- cqa->alarms = NULL;
-
- g_free (cqa);
- return;
- }
-
- cqa->queued_alarms = g_slist_reverse (cqa->queued_alarms);
- g_hash_table_insert (ca->uid_alarms_hash, (char *) uid, cqa);
-}
-
-/* Loads the alarms of a client for a given range of time */
-static void
-load_alarms (ClientAlarms *ca, time_t start, time_t end)
-{
- GSList *comp_alarms;
- GSList *l;
-
- comp_alarms = cal_client_get_alarms_in_range (ca->client, start, end);
-
- for (l = comp_alarms; l; l = l->next) {
- CalComponentAlarms *alarms;
-
- alarms = l->data;
- add_component_alarms (ca, alarms);
- }
-
- g_slist_free (comp_alarms);
-}
-
-/* Loads today's remaining alarms for a client */
-static void
-load_alarms_for_today (ClientAlarms *ca)
-{
- time_t now, day_end;
- icaltimezone *zone;
-
- now = time (NULL);
-
- zone = config_data_get_timezone ();
-
- day_end = time_day_end_with_zone (now, zone);
- load_alarms (ca, now, day_end);
-}
-
-/* Adds any alarms that should have occurred while the alarm daemon was not
- * running.
- */
-static void
-load_missed_alarms (ClientAlarms *ca)
-{
- time_t now;
-
- now = time (NULL);
-
- g_assert (saved_notification_time != -1);
-
- /* We add 1 to the saved_notification_time to make the time ranges
- * half-open; we do not want to display the "last" displayed alarm
- * twice, once when it occurs and once when the alarm daemon restarts.
- */
- load_alarms (ca, saved_notification_time + 1, now);
-}
-
-/* Called when a calendar client finished loading; we load its alarms */
-static void
-cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data)
-{
- ClientAlarms *ca;
-
- ca = data;
-
- if (status != CAL_CLIENT_OPEN_SUCCESS)
- return;
-
- load_alarms_for_today (ca);
- load_missed_alarms (ca);
-}
-
-/* Looks up a component's queued alarm structure in a client alarms structure */
-static CompQueuedAlarms *
-lookup_comp_queued_alarms (ClientAlarms *ca, const char *uid)
-{
- return g_hash_table_lookup (ca->uid_alarms_hash, uid);
-}
-
-/* Removes a component an its alarms */
-static void
-remove_comp (ClientAlarms *ca, const char *uid)
-{
- CompQueuedAlarms *cqa;
- GSList *l;
-
- cqa = lookup_comp_queued_alarms (ca, uid);
- if (!cqa)
- return;
-
- /* If a component is present, then it means we must have alarms queued
- * for it.
- */
- g_assert (cqa->queued_alarms != NULL);
-
- for (l = cqa->queued_alarms; l;) {
- QueuedAlarm *qa;
-
- qa = l->data;
-
- /* Get the next element here because the list element will go
- * 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
- * structure should have been freed and removed from the hash table.
- */
- g_assert (lookup_comp_queued_alarms (ca, uid) == NULL);
-}
-
-/* Called when a calendar component changes; we must reload its corresponding
- * alarms.
- */
-static void
-obj_updated_cb (CalClient *client, const char *uid, gpointer data)
-{
- ClientAlarms *ca;
- time_t now, day_end;
- CalComponentAlarms *alarms;
- gboolean found;
- icaltimezone *zone;
-
- ca = data;
-
- remove_comp (ca, uid);
-
- now = time (NULL);
-
- zone = config_data_get_timezone ();
-
- day_end = time_day_end_with_zone (now, zone);
-
- found = cal_client_get_alarms_for_object (ca->client, uid, now, day_end, &alarms);
-
- if (!found)
- return;
-
- add_component_alarms (ca, alarms);
-}
-
-/* Called when a calendar component is removed; we must delete its corresponding
- * alarms.
- */
-static void
-obj_removed_cb (CalClient *client, const char *uid, gpointer data)
-{
- ClientAlarms *ca;
-
- ca = data;
-
- remove_comp (ca, uid);
-}
-
-
-
-/* Notification functions */
-
-/* Creates a snooze alarm based on an existing one. The snooze offset is
- * compued with respect to the current time.
- */
-static void
-create_snooze (CompQueuedAlarms *cqa, gpointer alarm_id, int snooze_mins)
-{
- QueuedAlarm *orig_qa, *qa;
- CalAlarmInstance *instance;
- time_t t;
- gpointer new_id;
-
- orig_qa = lookup_queued_alarm (cqa, alarm_id);
-
- t = time (NULL);
- t += snooze_mins * 60;
-
- new_id = alarm_add (t, alarm_trigger_cb, cqa, NULL);
- if (!new_id) {
- g_message ("create_snooze(): Could not schedule a trigger for "
- "%ld, discarding...", (long) t);
- return;
- }
-
- instance = g_new (CalAlarmInstance, 1);
- instance->auid = orig_qa->instance->auid;
- instance->trigger = t;
- instance->occur_start = orig_qa->instance->occur_start;
- instance->occur_end = orig_qa->instance->occur_end;
-
- cqa->alarms->alarms = g_slist_prepend (cqa->alarms->alarms, instance);
-
- qa = g_new (QueuedAlarm, 1);
- qa->alarm_id = new_id;
- qa->instance = instance;
- qa->snooze = TRUE;
-
- cqa->queued_alarms = g_slist_prepend (cqa->queued_alarms, qa);
-}
-
-/* Launches a component editor for a component */
-static void
-edit_component (CompQueuedAlarms *cqa)
-{
- CalComponent *comp;
- const char *uid;
- const char *uri;
- CORBA_Environment ev;
- GNOME_Evolution_Calendar_CompEditorFactory factory;
-
- comp = cqa->alarms->comp;
- cal_component_get_uid (comp, &uid);
-
- uri = cal_client_get_uri (cqa->parent_client->client);
-
- /* Get the factory */
-
- CORBA_exception_init (&ev);
- factory = oaf_activate_from_id ("OAFIID:GNOME_Evolution_Calendar_CompEditorFactory",
- 0, NULL, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("edit_component(): Could not activate the component editor factory");
- CORBA_exception_free (&ev);
- return;
- }
- CORBA_exception_free (&ev);
-
- /* Edit the component */
-
- CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_CompEditorFactory_editExisting (factory, uri, (char *) uid, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("edit_component(): Exception while editing the component");
-
- CORBA_exception_free (&ev);
-
- /* Get rid of the factory */
-
- CORBA_exception_init (&ev);
- bonobo_object_release_unref (factory, &ev);
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("edit_component(): Could not unref the calendar component factory");
-
- CORBA_exception_free (&ev);
-}
-
-struct notify_dialog_closure {
- CompQueuedAlarms *cqa;
- gpointer alarm_id;
-};
-
-/* Callback used from the alarm notify dialog */
-static void
-notify_dialog_cb (AlarmNotifyResult result, int snooze_mins, gpointer data)
-{
- struct notify_dialog_closure *c;
-
- c = data;
-
- switch (result) {
- case ALARM_NOTIFY_SNOOZE:
- create_snooze (c->cqa, c->alarm_id, snooze_mins);
- break;
-
- case ALARM_NOTIFY_EDIT:
- edit_component (c->cqa);
- break;
-
- case ALARM_NOTIFY_CLOSE:
- /* Do nothing */
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- remove_queued_alarm (c->cqa, c->alarm_id);
- g_free (c);
-}
-
-/* Performs notification of a display alarm */
-static void
-display_notification (time_t trigger, CompQueuedAlarms *cqa,
- gpointer alarm_id, gboolean use_description)
-{
- CalComponent *comp;
- CalComponentVType vtype;
- CalComponentText text;
- 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);
-
- /* Pick a sensible notification message. First we try the DESCRIPTION
- * from the alarm, then the SUMMARY of the component.
- */
-
- 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;
- else
- message = _("No description available.");
- }
-
- c = g_new (struct notify_dialog_closure, 1);
- c->cqa = cqa;
- c->alarm_id = alarm_id;
-
- if (!alarm_notify_dialog (trigger,
- qa->instance->occur_start, qa->instance->occur_end,
- vtype, message,
- notify_dialog_cb, c))
- 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;
-
- 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 (attach && icalattach_get_is_url (attach)) {
- const char *url;
-
- url = icalattach_get_url (attach);
- g_assert (url != NULL);
-
- gnome_sound_play (url); /* this sucks */
- }
-
- if (attach)
- icalattach_unref (attach);
-
- /* We present a notification message in addition to playing the sound */
- display_notification (trigger, cqa, alarm_id, FALSE);
-}
-
-/* Performs notification of a mail alarm */
-static void
-mail_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id)
-{
- GtkWidget *dialog;
-
- /* FIXME */
-
- display_notification (trigger, cqa, alarm_id, FALSE);
-
- dialog = gnome_warning_dialog (_("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."));
- gnome_dialog_run (GNOME_DIALOG (dialog));
-}
-
-/* Performs notification of a procedure alarm */
-static gboolean
-procedure_notification_dialog (const char *cmd, const char *url)
-{
- GtkWidget *dialog, *label, *checkbox;
- char *str;
- int btn;
-
- if (is_blessed_program (url))
- return TRUE;
-
- dialog = gnome_dialog_new (_("Warning"),
- GNOME_STOCK_BUTTON_YES,
- GNOME_STOCK_BUTTON_NO,
- 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);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox),
- label, TRUE, TRUE, 4);
- g_free (str);
-
- checkbox = gtk_check_button_new_with_label
- (_("Do not ask me about this program again."));
- gtk_widget_show (checkbox);
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox),
- checkbox, TRUE, TRUE, 4);
-
- /* Run the dialog */
- btn = gnome_dialog_run (GNOME_DIALOG (dialog));
- if (btn == GNOME_YES && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)))
- save_blessed_program (url);
- gnome_dialog_close (GNOME_DIALOG (dialog));
-
- return (btn == GNOME_YES);
-}
-
-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;
- char *cmd;
- 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);
-
- /* Ask for confirmation before executing the stuff */
- if (description.value)
- cmd = g_strconcat (url, " ", description.value, NULL);
- else
- cmd = (char *) url;
-
- result = 0;
- if (procedure_notification_dialog (cmd, url))
- result = gnome_execute_shell (NULL, cmd);
-
- if (cmd != (char *) url)
- g_free (cmd);
-
- 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);
-}
-
-
-
-/**
- * alarm_queue_init:
- *
- * Initializes the alarm queueing system. This should be called near the
- * beginning of the program.
- **/
-void
-alarm_queue_init (void)
-{
- g_return_if_fail (alarm_queue_inited == FALSE);
-
- client_alarms_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
- queue_midnight_refresh ();
-
- saved_notification_time = get_saved_notification_time ();
- if (saved_notification_time == -1) {
- saved_notification_time = time (NULL);
- save_notification_time (saved_notification_time);
- }
-
- alarm_queue_inited = TRUE;
-}
-
-/**
- * alarm_queue_done:
- *
- * Shuts down the alarm queueing system. This should be called near the end
- * of the program. All the monitored calendar clients should already have been
- * unregistered with alarm_queue_remove_client().
- **/
-void
-alarm_queue_done (void)
-{
- g_return_if_fail (alarm_queue_inited);
-
- /* All clients must be unregistered by now */
- g_return_if_fail (g_hash_table_size (client_alarms_hash) == 0);
-
- g_hash_table_destroy (client_alarms_hash);
- client_alarms_hash = NULL;
-
- g_assert (midnight_refresh_id != NULL);
- alarm_remove (midnight_refresh_id);
- midnight_refresh_id = NULL;
-
- alarm_queue_inited = FALSE;
-}
-
-/**
- * alarm_queue_add_client:
- * @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
- * be removed with alarm_queue_remove_client() when receiving notifications
- * from it is no longer desired.
- *
- * A client can be added any number of times to the alarm queueing system,
- * but any single alarm trigger will only be presented once for a particular
- * client. The client must still be removed the same number of times from the
- * queueing system when it is no longer wanted.
- **/
-void
-alarm_queue_add_client (CalClient *client)
-{
- ClientAlarms *ca;
-
- g_return_if_fail (alarm_queue_inited);
- g_return_if_fail (client != NULL);
- g_return_if_fail (IS_CAL_CLIENT (client));
-
- ca = lookup_client (client);
- if (ca) {
- ca->refcount++;
- return;
- }
-
- ca = g_new (ClientAlarms, 1);
-
- ca->client = client;
- gtk_object_ref (GTK_OBJECT (ca->client));
-
- ca->refcount = 1;
- g_hash_table_insert (client_alarms_hash, client, ca);
-
- ca->uid_alarms_hash = g_hash_table_new (g_str_hash, g_str_equal);
-
- if (cal_client_get_load_state (client) != CAL_CLIENT_LOAD_LOADED)
- gtk_signal_connect (GTK_OBJECT (client), "cal_opened",
- GTK_SIGNAL_FUNC (cal_opened_cb), ca);
-
- gtk_signal_connect (GTK_OBJECT (client), "obj_updated",
- GTK_SIGNAL_FUNC (obj_updated_cb), ca);
- gtk_signal_connect (GTK_OBJECT (client), "obj_removed",
- GTK_SIGNAL_FUNC (obj_removed_cb), ca);
-
- if (cal_client_get_load_state (client) == CAL_CLIENT_LOAD_LOADED) {
- load_alarms_for_today (ca);
- load_missed_alarms (ca);
- }
-}
-
-/* Called from g_hash_table_foreach(); adds a component UID to a list */
-static void
-add_uid_cb (gpointer key, gpointer value, gpointer data)
-{
- GSList **uids;
- const char *uid;
-
- uids = data;
- uid = key;
-
- *uids = g_slist_prepend (*uids, (char *) uid);
-}
-
-/* Removes all the alarms queued for a particular calendar client */
-static void
-remove_client_alarms (ClientAlarms *ca)
-{
- GSList *uids;
- GSList *l;
-
- /* First we build a list of UIDs so that we can remove them one by one */
-
- uids = NULL;
- g_hash_table_foreach (ca->uid_alarms_hash, add_uid_cb, &uids);
-
- for (l = uids; l; l = l->next) {
- const char *uid;
-
- uid = l->data;
-
- remove_comp (ca, uid);
- }
-
- g_slist_free (uids);
-
- /* The hash table should be empty now */
-
- g_assert (g_hash_table_size (ca->uid_alarms_hash) == 0);
-}
-
-/**
- * alarm_queue_remove_client:
- * @client: A calendar client.
- *
- * Removes a calendar client from the alarm queueing system.
- **/
-void
-alarm_queue_remove_client (CalClient *client)
-{
- ClientAlarms *ca;
-
- g_return_if_fail (alarm_queue_inited);
- g_return_if_fail (client != NULL);
- g_return_if_fail (IS_CAL_CLIENT (client));
-
- ca = lookup_client (client);
- g_return_if_fail (ca != NULL);
-
- g_assert (ca->refcount > 0);
- ca->refcount--;
-
- if (ca->refcount > 0)
- return;
-
- remove_client_alarms (ca);
-
- /* Clean up */
-
- gtk_signal_disconnect_by_data (GTK_OBJECT (ca->client), ca);
-
- gtk_object_unref (GTK_OBJECT (ca->client));
- ca->client = NULL;
-
- g_hash_table_destroy (ca->uid_alarms_hash);
- ca->uid_alarms_hash = NULL;
-
- g_free (ca);
-
- g_hash_table_remove (client_alarms_hash, client);
-}
diff --git a/calendar/gui/alarm-notify/alarm-queue.h b/calendar/gui/alarm-notify/alarm-queue.h
deleted file mode 100644
index a37119145f..0000000000
--- a/calendar/gui/alarm-notify/alarm-queue.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Evolution calendar - Alarm queueing engine
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Authors: Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef ALARM_QUEUE_H
-#define ALARM_QUEUE_H
-
-#include <cal-client/cal-client.h>
-
-
-void alarm_queue_init (void);
-void alarm_queue_done (void);
-
-void alarm_queue_add_client (CalClient *client);
-void alarm_queue_remove_client (CalClient *client);
-
-
-#endif
diff --git a/calendar/gui/alarm-notify/alarm.c b/calendar/gui/alarm-notify/alarm.c
deleted file mode 100644
index 8c6c4c59cd..0000000000
--- a/calendar/gui/alarm-notify/alarm.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/* Evolution calendar - Low-level alarm timer mechanism
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 2000 Ximian, Inc.
- *
- * Authors: Miguel de Icaza <miguel@ximian.com>
- * Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include <unistd.h>
-#include <time.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/time.h>
-#include <gdk/gdk.h>
-#include "alarm.h"
-
-
-
-/* Our glib timeout */
-static guint timeout_id;
-
-/* The list of pending alarms */
-static GList *alarms = NULL;
-
-/* A queued alarm structure */
-typedef struct {
- time_t trigger;
- AlarmFunction alarm_fn;
- gpointer data;
- AlarmDestroyNotify destroy_notify_fn;
-} AlarmRecord;
-
-static void setup_timeout (time_t now);
-
-
-
-/* Removes the head alarm from the queue. Does not touch the timeout_id. */
-static void
-pop_alarm (void)
-{
- AlarmRecord *ar;
- GList *l;
-
- g_assert (alarms != NULL);
-
- ar = alarms->data;
-
- l = alarms;
- alarms = g_list_remove_link (alarms, l);
- g_list_free_1 (l);
-
- g_free (ar);
-}
-
-/* Callback from the alarm timeout */
-static gboolean
-alarm_ready_cb (gpointer data)
-{
- time_t now;
-
- g_assert (alarms != NULL);
- timeout_id = 0;
-
- now = time (NULL);
-
- while (alarms) {
- AlarmRecord *notify_id, *ar;
- AlarmRecord ar_copy;
-
- ar = alarms->data;
-
- if (ar->trigger > now)
- break;
-
- notify_id = ar;
-
- ar_copy = *ar;
- ar = &ar_copy;
-
- pop_alarm (); /* This will free the original AlarmRecord; that's why we copy it */
-
- (* ar->alarm_fn) (notify_id, ar->trigger, ar->data);
-
- if (ar->destroy_notify_fn)
- (* ar->destroy_notify_fn) (notify_id, ar->data);
- }
-
- if (alarms) {
- /* We need this check because one of the alarm_fn above may have
- * re-entered and added an alarm of its own, so the timer will
- * already be set up.
- */
- if (timeout_id == 0)
- setup_timeout (now);
- } else
- g_assert (timeout_id == 0);
-
- return FALSE;
-}
-
-/* Sets up a timeout for the next minute. We do not need to be concerned with
- * timezones here, as this is just a periodic check on the alarm queue.
- */
-static void
-setup_timeout (time_t now)
-{
- time_t next, diff;
- struct tm tm;
-
- g_assert (timeout_id == 0);
- g_assert (alarms != NULL);
-
- tm = *localtime (&now);
- tm.tm_sec = 0;
- tm.tm_min++; /* next minute */
-
- next = mktime (&tm);
- g_assert (next != -1);
-
- diff = next - now;
-
- g_assert (diff >= 0);
- timeout_id = g_timeout_add (diff * 1000, alarm_ready_cb, NULL);
-}
-
-/* Used from g_list_insert_sorted(); compares the trigger times of two AlarmRecord structures. */
-static int
-compare_alarm_by_time (gconstpointer a, gconstpointer b)
-{
- const AlarmRecord *ara = a;
- const AlarmRecord *arb = b;
- time_t diff;
-
- diff = ara->trigger - arb->trigger;
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-/* Adds an alarm to the queue and sets up the timer */
-static void
-queue_alarm (AlarmRecord *ar)
-{
- time_t now;
- AlarmRecord *old_head;
-
- if (alarms) {
- g_assert (timeout_id != 0);
-
- old_head = alarms->data;
- } else {
- g_assert (timeout_id == 0);
-
- old_head = NULL;
- }
-
- alarms = g_list_insert_sorted (alarms, ar, compare_alarm_by_time);
-
- if (old_head == alarms->data)
- return;
-
- /* Set the timer for removal upon activation */
-
- if (!old_head) {
- now = time (NULL);
- setup_timeout (now);
- }
-}
-
-
-
-/**
- * alarm_add:
- * @trigger: Time at which alarm will trigger.
- * @alarm_fn: Callback for trigger.
- * @data: Closure data for callback.
- *
- * Adds an alarm to trigger at the specified time. The @alarm_fn will be called
- * with the provided data and the alarm will be removed from the trigger list.
- *
- * Return value: An identifier for this alarm; it can be used to remove the
- * alarm later with alarm_remove(). If the trigger time occurs in the past, then
- * the alarm will not be queued and the function will return NULL.
- **/
-gpointer
-alarm_add (time_t trigger, AlarmFunction alarm_fn, gpointer data,
- AlarmDestroyNotify destroy_notify_fn)
-{
- AlarmRecord *ar;
-
- g_return_val_if_fail (trigger != -1, NULL);
- g_return_val_if_fail (alarm_fn != NULL, NULL);
-
- ar = g_new (AlarmRecord, 1);
- ar->trigger = trigger;
- ar->alarm_fn = alarm_fn;
- ar->data = data;
- ar->destroy_notify_fn = destroy_notify_fn;
-
- queue_alarm (ar);
-
- return ar;
-}
-
-/**
- * alarm_remove:
- * @alarm: A queued alarm identifier.
- *
- * Removes an alarm from the alarm queue.
- **/
-void
-alarm_remove (gpointer alarm)
-{
- AlarmRecord *notify_id, *ar;
- AlarmRecord ar_copy;
- AlarmRecord *old_head;
- GList *l;
-
- g_return_if_fail (alarm != NULL);
-
- ar = alarm;
-
- l = g_list_find (alarms, ar);
- if (!l) {
- g_message ("alarm_remove(): Requested removal of nonexistent alarm!");
- return;
- }
-
- old_head = alarms->data;
-
- notify_id = ar;
-
- if (old_head == ar) {
- ar_copy = *ar;
- ar = &ar_copy;
- pop_alarm (); /* This will free the original AlarmRecord; that's why we copy it */
- } else {
- alarms = g_list_remove_link (alarms, l);
- g_list_free_1 (l);
- }
-
- /* Reset the timeout */
-
- g_assert (timeout_id != 0);
-
- if (!alarms) {
- g_source_remove (timeout_id);
- timeout_id = 0;
- }
-
- /* Notify about destructiono of the alarm */
-
- if (ar->destroy_notify_fn)
- (* ar->destroy_notify_fn) (notify_id, ar->data);
-
-}
-
-/**
- * alarm_done:
- *
- * Terminates the alarm timer mechanism. This should be called at the end of
- * the program.
- **/
-void
-alarm_done (void)
-{
- GList *l;
-
- if (timeout_id == 0) {
- g_assert (alarms == NULL);
- return;
- }
-
- g_assert (alarms != NULL);
-
- g_source_remove (timeout_id);
- timeout_id = 0;
-
- for (l = alarms; l; l = l->next) {
- AlarmRecord *ar;
-
- ar = l->data;
-
- if (ar->destroy_notify_fn)
- (* ar->destroy_notify_fn) (ar, ar->data);
-
- g_free (ar);
- }
-
- g_list_free (alarms);
- alarms = NULL;
-}
diff --git a/calendar/gui/alarm-notify/alarm.h b/calendar/gui/alarm-notify/alarm.h
deleted file mode 100644
index 23fde886c9..0000000000
--- a/calendar/gui/alarm-notify/alarm.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Evolution calendar - Low-level alarm timer mechanism
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 2000 Ximian, Inc.
- *
- * Authors: Miguel de Icaza <miguel@ximian.com>
- * Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef ALARM_H
-#define ALARM_H
-
-#include <time.h>
-#include <glib.h>
-
-
-
-typedef void (* AlarmFunction) (gpointer alarm_id, time_t trigger, gpointer data);
-typedef void (* AlarmDestroyNotify) (gpointer alarm_id, gpointer data);
-
-void alarm_done (void);
-
-gpointer alarm_add (time_t trigger, AlarmFunction alarm_fn, gpointer data,
- AlarmDestroyNotify destroy_notify_fn);
-void alarm_remove (gpointer alarm);
-
-
-
-#endif
diff --git a/calendar/gui/alarm-notify/config-data.c b/calendar/gui/alarm-notify/config-data.c
deleted file mode 100644
index 71170a3ad6..0000000000
--- a/calendar/gui/alarm-notify/config-data.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/* Evolution calendar - Configuration values for the alarm notification daemon
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Authors: Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "config-data.h"
-#include "save.h"
-
-
-
-/* Whether we have initied ourselves by reading the data from the configuration engine */
-static gboolean inited;
-
-/* Configuration values */
-static icaltimezone *local_timezone;
-static gboolean use_24_hour_format;
-
-
-
-/* Copied from ../calendar-config.c; returns whether the locale has 'am' and
- * 'pm' strings defined.
- */
-static gboolean
-locale_supports_12_hour_format (void)
-{
- char s[16];
- time_t t = 0;
-
- strftime (s, sizeof s, "%p", gmtime (&t));
- return s[0] != '\0';
-}
-
-/* Ensures that the configuration values have been read */
-static void
-ensure_inited (void)
-{
- Bonobo_ConfigDatabase db;
- char *location;
-
- if (inited)
- return;
-
- inited = TRUE;
-
- db = get_config_db ();
- if (db == CORBA_OBJECT_NIL) {
- /* This sucks */
- local_timezone = icaltimezone_get_utc_timezone ();
-
- /* This sucks as well */
- use_24_hour_format = TRUE;
-
- return;
- }
-
- location = bonobo_config_get_string_with_default (db,
- "/Calendar/Display/Timezone", "UTC", NULL);
- if (location && location[0]) {
- local_timezone = icaltimezone_get_builtin_timezone (location);
- } else {
- local_timezone = icaltimezone_get_utc_timezone ();
- }
- g_free (location);
-
- if (locale_supports_12_hour_format ()) {
- /* Wasn't the whole point of a configuration engine *NOT* to
- * have apps specify their own stupid defaults everywhere, but
- * just in a schema file?
- */
- use_24_hour_format = bonobo_config_get_boolean_with_default (
- db,
- "/Calendar/Display/Use24HourFormat", FALSE, NULL);
- } else
- use_24_hour_format = TRUE;
-
- discard_config_db (db);
-}
-
-icaltimezone *
-config_data_get_timezone (void)
-{
- ensure_inited ();
-
- return local_timezone;
-}
-
-gboolean
-config_data_get_24_hour_format (void)
-{
- ensure_inited ();
-
- return use_24_hour_format;
-}
diff --git a/calendar/gui/alarm-notify/config-data.h b/calendar/gui/alarm-notify/config-data.h
deleted file mode 100644
index 06a73ba562..0000000000
--- a/calendar/gui/alarm-notify/config-data.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Evolution calendar - Configuration values for the alarm notification daemon
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Authors: Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef CONFIG_DATA_H
-#define CONFIG_DATA_H
-
-#include <glib.h>
-#include <ical.h>
-
-icaltimezone *config_data_get_timezone (void);
-
-gboolean config_data_get_24_hour_format (void);
-
-#endif
diff --git a/calendar/gui/alarm-notify/notify-main.c b/calendar/gui/alarm-notify/notify-main.c
deleted file mode 100644
index 8b6daab254..0000000000
--- a/calendar/gui/alarm-notify/notify-main.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/* Evolution calendar - Alarm notification service main file
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 2000 Ximian, Inc.
- *
- * Author: Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <glib.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnome/gnome-i18n.h>
-#include <libgnomeui/gnome-init.h>
-#include <libgnomevfs/gnome-vfs-init.h>
-#include <glade/glade.h>
-#include <bonobo/bonobo-main.h>
-#include <bonobo/bonobo-generic-factory.h>
-#include <liboaf/liboaf.h>
-#include "alarm.h"
-#include "alarm-queue.h"
-#include "alarm-notify.h"
-#include "save.h"
-
-
-
-static GnomeClient *master_client = NULL;
-
-static BonoboGenericFactory *factory;
-
-static AlarmNotify *alarm_notify_service;
-
-
-/* Callback for the master client's "die" signal. We must terminate the daemon
- * since the session is ending.
- */
-static void
-client_die_cb (GnomeClient *client)
-{
- gtk_main_quit ();
-}
-
-/* Sees if a session manager is present. If so, it tells the SM how to restart
- * the daemon when the session starts. It also sets the die callback so that
- * the daemon can terminate properly when the session ends.
- */
-static void
-set_session_parameters (char **argv)
-{
- int flags;
- char *args[2];
-
- master_client = gnome_master_client ();
- flags = gnome_client_get_flags (master_client);
-
- if (!(flags & GNOME_CLIENT_IS_CONNECTED))
- return;
-
- /* The daemon should always be started up by the session manager when
- * the session starts. The daemon will take care of loading whatever
- * calendars it was told to load.
- */
- gnome_client_set_restart_style (master_client, GNOME_RESTART_ANYWAY);
-
- args[0] = argv[0];
- args[1] = NULL;
-
- gnome_client_set_restart_command (master_client, 1, args);
-
- gtk_signal_connect (GTK_OBJECT (master_client), "die",
- GTK_SIGNAL_FUNC (client_die_cb), NULL);
-}
-
-/* Creates the singleton alarm notify service object */
-static gboolean
-init_alarm_notify_service (void)
-{
- g_assert (alarm_notify_service == NULL);
-
- alarm_notify_service = alarm_notify_new ();
- return (alarm_notify_service != NULL);
-}
-
-/* Factory function for the alarm notify service; just creates and references a
- * singleton service object.
- */
-static BonoboObject *
-alarm_notify_factory_fn (BonoboGenericFactory *factory, void *data)
-{
- g_assert (alarm_notify_service != NULL);
-
- bonobo_object_ref (BONOBO_OBJECT (alarm_notify_service));
- return BONOBO_OBJECT (alarm_notify_service);
-}
-
-/* Loads the calendars that the alarm daemon has been told to load in the past */
-static void
-load_calendars (void)
-{
- GPtrArray *uris;
- int i;
-
- uris = get_calendars_to_load ();
- if (!uris) {
- g_message ("load_calendars(): Could not get the list of calendars to load");
- return;
- }
-
- for (i = 0; i < uris->len; i++) {
- char *uri;
- CORBA_Environment ev;
-
- uri = uris->pdata[i];
-
- CORBA_exception_init (&ev);
- alarm_notify_add_calendar (alarm_notify_service, uri, FALSE, &ev);
-
- if (ev._major == CORBA_USER_EXCEPTION) {
- char *ex_id;
-
- ex_id = CORBA_exception_id (&ev);
- if (strcmp (ex_id, ex_GNOME_Evolution_Calendar_AlarmNotify_InvalidURI) == 0)
- g_message ("load_calendars(): Invalid URI `%s'; will not load "
- "that calendar.", uri);
- else if (strcmp (ex_id,
- ex_GNOME_Evolution_Calendar_AlarmNotify_BackendContactError)
- == 0)
- g_message ("load_calendars(): Could not contact the backend "
- "while trying to load `%s'", uri);
- } else if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("load_calendars(): Exception while loading calendar `%s'", uri);
-
- CORBA_exception_free (&ev);
-
- g_free (uri);
- }
-
- g_ptr_array_free (uris, TRUE);
-}
-
-int
-main (int argc, char **argv)
-{
- free (malloc (8));
-
- bindtextdomain (PACKAGE, EVOLUTION_LOCALEDIR);
- textdomain (PACKAGE);
-
- if (gnome_init_with_popt_table ("evolution-alarm-notify", VERSION, argc, argv,
- oaf_popt_options, 0, NULL) != 0)
- g_error (_("Could not initialize GNOME"));
-
- oaf_init (argc, argv);
-
- if (bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE)
- g_error (_("Could not initialize Bonobo"));
-
- if (!gnome_vfs_init ())
- g_error (_("Could not initialize gnome-vfs"));
-
- glade_gnome_init ();
-
- alarm_queue_init ();
-
- if (!init_alarm_notify_service ())
- g_error (_("Could not create the alarm notify service"));
-
- factory = bonobo_generic_factory_new ("OAFIID:GNOME_Evolution_Calendar_AlarmNotify_Factory",
- alarm_notify_factory_fn, NULL);
- if (!factory)
- g_error (_("Could not create the alarm notify service factory"));
-
- set_session_parameters (argv);
-
- load_calendars ();
-
- bonobo_main ();
-
- bonobo_object_unref (BONOBO_OBJECT (factory));
- factory = NULL;
-
- /* FIXME: free the alarm_notify_service */
-
- alarm_queue_done ();
- alarm_done ();
-
- gnome_vfs_shutdown ();
-
- return 0;
-}
diff --git a/calendar/gui/alarm-notify/save.c b/calendar/gui/alarm-notify/save.c
deleted file mode 100644
index 92dc94b65a..0000000000
--- a/calendar/gui/alarm-notify/save.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/* Evolution calendar - Functions to save alarm notification times
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Authors: Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <bonobo/bonobo-arg.h>
-#include <bonobo/bonobo-exception.h>
-#include <bonobo/bonobo-moniker-util.h>
-#include "evolution-calendar.h"
-#include "save.h"
-
-
-
-/* Key names for the configuration values */
-
-#define KEY_LAST_NOTIFICATION_TIME "/Calendar/AlarmNotify/LastNotificationTime"
-#define KEY_NUM_CALENDARS_TO_LOAD "/Calendar/AlarmNotify/NumCalendarsToLoad"
-#define BASE_KEY_CALENDAR_TO_LOAD "/Calendar/AlarmNotify/CalendarToLoad"
-#define KEY_NUM_BLESSED_PROGRAMS "/Calendar/AlarmNotify/NumBlessedPrograms"
-#define BASE_KEY_BLESSED_PROGRAM "/Calendar/AlarmNotify/BlessedProgram"
-
-
-
-/* Tries to get the config database object; returns CORBA_OBJECT_NIL on failure. */
-Bonobo_ConfigDatabase
-get_config_db (void)
-{
- CORBA_Environment ev;
- Bonobo_ConfigDatabase db;
-
- CORBA_exception_init (&ev);
-
- db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
- if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
- g_message ("get_config_db(): Could not get the config database object");
- db = CORBA_OBJECT_NIL;
- }
-
- CORBA_exception_free (&ev);
- return db;
-}
-
-/* Syncs a database and unrefs it */
-void
-discard_config_db (Bonobo_ConfigDatabase db)
-{
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- Bonobo_ConfigDatabase_sync (db, &ev);
- if (BONOBO_EX (&ev))
- g_message ("discard_config_db(): Got an exception during the sync command");
-
- CORBA_exception_free (&ev);
-
- CORBA_exception_init (&ev);
-
- bonobo_object_release_unref (db, &ev);
- if (BONOBO_EX (&ev))
- g_message ("discard_config_db(): Could not release/unref the database");
-
- CORBA_exception_free (&ev);
-}
-
-/**
- * save_notification_time:
- * @t: A time value.
- *
- * Saves the last notification time so that it can be fetched the next time the
- * alarm daemon is run. This way the daemon can show alarms that should have
- * triggered while it was not running.
- **/
-void
-save_notification_time (time_t t)
-{
- Bonobo_ConfigDatabase db;
- CORBA_Environment ev;
-
- g_return_if_fail (t != -1);
-
- db = get_config_db ();
- if (db == CORBA_OBJECT_NIL)
- return;
-
- CORBA_exception_init (&ev);
-
- bonobo_config_set_long (db, KEY_LAST_NOTIFICATION_TIME, (long) t, &ev);
- if (BONOBO_EX (&ev))
- g_message ("save_notification_time(): Could not save the value");
-
- CORBA_exception_free (&ev);
-
- discard_config_db (db);
-}
-
-/**
- * get_saved_notification_time:
- *
- * Queries the last saved value for alarm notification times.
- *
- * Return value: The last saved value, or -1 if no value had been saved before.
- **/
-time_t
-get_saved_notification_time (void)
-{
- Bonobo_ConfigDatabase db;
- long t;
-
- db = get_config_db ();
- if (db == CORBA_OBJECT_NIL)
- return -1;
-
- t = bonobo_config_get_long_with_default (db, KEY_LAST_NOTIFICATION_TIME, -1, NULL);
-
- discard_config_db (db);
-
- return (time_t) t;
-}
-
-/**
- * save_calendars_to_load:
- * @uris: A list of URIs of calendars.
- *
- * Saves the list of calendars that should be loaded the next time the alarm
- * daemon starts up.
- **/
-void
-save_calendars_to_load (GPtrArray *uris)
-{
- Bonobo_ConfigDatabase db;
- CORBA_Environment ev;
- int len, i;
-
- g_return_if_fail (uris != NULL);
-
- db = get_config_db ();
- if (db == CORBA_OBJECT_NIL)
- return;
-
- len = uris->len;
-
- CORBA_exception_init (&ev);
-
- bonobo_config_set_long (db, KEY_NUM_CALENDARS_TO_LOAD, len, &ev);
- if (BONOBO_EX (&ev))
- g_warning ("Cannot save config key %s -- %s", KEY_NUM_CALENDARS_TO_LOAD, BONOBO_EX_ID (&ev));
-
- for (i = 0; i < len; i++) {
- const char *uri;
- char *key;
-
- uri = uris->pdata[i];
-
- key = g_strdup_printf ("%s%d", BASE_KEY_CALENDAR_TO_LOAD, i);
- bonobo_config_set_string (db, key, uri, &ev);
- if (BONOBO_EX (&ev))
- g_warning ("Cannot save config key %s -- %s", key, BONOBO_EX_ID (&ev));
- g_free (key);
- }
-
- CORBA_exception_free (&ev);
-
- discard_config_db (db);
-}
-
-/**
- * get_calendars_to_load:
- *
- * Gets the list of calendars that should be loaded when the alarm daemon starts
- * up.
- *
- * Return value: A list of URIs, or NULL if the value could not be retrieved.
- **/
-GPtrArray *
-get_calendars_to_load (void)
-{
- Bonobo_ConfigDatabase db;
- GPtrArray *uris;
- int len, i;
-
- db = get_config_db ();
- if (db == CORBA_OBJECT_NIL)
- return NULL;
-
- /* Getting the default value below is not necessarily an error, as we
- * may not have saved the list of calendar yet.
- */
-
- len = bonobo_config_get_long_with_default (db, KEY_NUM_CALENDARS_TO_LOAD, 0, NULL);
-
- uris = g_ptr_array_new ();
- g_ptr_array_set_size (uris, len);
-
- for (i = 0; i < len; i++) {
- char *key;
- gboolean used_default;
-
- key = g_strdup_printf ("%s%d", BASE_KEY_CALENDAR_TO_LOAD, i);
- uris->pdata[i] = bonobo_config_get_string_with_default (db, key, "", &used_default);
- if (used_default)
- g_message ("get_calendars_to_load(): Could not read calendar name %d", i);
-
- g_free (key);
- }
-
- return uris;
-}
-
-/**
- * save_blessed_program:
- * @program: a program name
- *
- * Saves a program name as "blessed"
- **/
-void
-save_blessed_program (const char *program)
-{
- Bonobo_ConfigDatabase db;
- CORBA_Environment ev;
- char *key;
- int len;
-
- g_return_if_fail (program != NULL);
-
- db = get_config_db ();
- if (db == CORBA_OBJECT_NIL)
- return;
-
- /* Up the number saved */
- len = bonobo_config_get_long_with_default (db, KEY_NUM_BLESSED_PROGRAMS, 0, NULL);
- len++;
-
- bonobo_config_set_long (db, KEY_NUM_BLESSED_PROGRAMS, len, &ev);
- if (BONOBO_EX (&ev))
- g_warning ("Cannot save config key %s -- %s", KEY_NUM_BLESSED_PROGRAMS, BONOBO_EX_ID (&ev));
-
- /* Save the program name */
- key = g_strdup_printf ("%s%d", BASE_KEY_BLESSED_PROGRAM, len - 1);
- bonobo_config_set_string (db, key, program, &ev);
- if (BONOBO_EX (&ev))
- g_warning ("Cannot save config key %s -- %s", key, BONOBO_EX_ID (&ev));
- g_free (key);
-
- CORBA_exception_free (&ev);
-
- discard_config_db (db);
-}
-
-/**
- * is_blessed_program:
- * @program: a program name
- *
- * Checks to see if a program is blessed
- *
- * Return value: TRUE if program is blessed, FALSE otherwise
- **/
-gboolean
-is_blessed_program (const char *program)
-{
- Bonobo_ConfigDatabase db;
- int len, i;
-
- g_return_val_if_fail (program != NULL, FALSE);
-
- db = get_config_db ();
- if (db == CORBA_OBJECT_NIL)
- return FALSE;
-
- /* Getting the default value below is not necessarily an error, as we
- * may not have saved the list of calendar yet.
- */
-
- len = bonobo_config_get_long_with_default (db, KEY_NUM_BLESSED_PROGRAMS, 0, NULL);
-
- for (i = 0; i < len; i++) {
- char *key, *value;
- gboolean used_default;
-
- key = g_strdup_printf ("%s%d", BASE_KEY_BLESSED_PROGRAM, i);
- value = bonobo_config_get_string_with_default (db, key, "", &used_default);
- if (used_default)
- g_message ("get_calendars_to_load(): Could not read calendar name %d", i);
-
- if (value != NULL && !strcmp (value, program)) {
- g_free (key);
- g_free (value);
- return TRUE;
- }
-
- g_free (key);
- g_free (value);
- }
-
- return FALSE;
-}
diff --git a/calendar/gui/alarm-notify/save.h b/calendar/gui/alarm-notify/save.h
deleted file mode 100644
index 50371e0a5b..0000000000
--- a/calendar/gui/alarm-notify/save.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Evolution calendar - Functions to save alarm notification times
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Authors: Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef SAVE_H
-#define SAVE_H
-
-#include <time.h>
-#include <bonobo-conf/bonobo-config-database.h>
-
-Bonobo_ConfigDatabase get_config_db (void);
-void discard_config_db (Bonobo_ConfigDatabase db);
-
-void save_notification_time (time_t t);
-time_t get_saved_notification_time (void);
-
-void save_calendars_to_load (GPtrArray *uris);
-GPtrArray *get_calendars_to_load (void);
-
-void save_blessed_program (const char *program);
-gboolean is_blessed_program (const char *program);
-
-#endif