From 0a3ef04d1b421df60ad6876c9bae6265e9ba85da Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Tue, 9 Jan 2001 21:37:33 +0000 Subject: New interface for the alarm notification system. 2001-01-09 Federico Mena Quintero * idl/evolution-calendar.idl (AlarmNotify): New interface for the alarm notification system. * gui/alarm-notify: New directory for the alarm notification daemon and its auxiliary stuff. * gui/alarm-notify/alarm.[ch]: Moved over from gui/alarm.[ch]. * gui/alarm-notify/alarm-queue.[ch]: Moved over from gui/alarm-notify.[ch]. Renamed functions from alarm_notify_*() to alarm_queue_*(). * gui/alarm-notify/alarm-notify.[ch]: Implementation of the GNOME::Evolution::Calendar::AlarmNotify interface. * gui/Makefile.am (evolution_calendar_LDADD): Removed the LINK_FLAGS variable and reordered the libraries to remove some duplicated ones. (SUBDIRS): Added the alarm-notify directory. svn path=/trunk/; revision=7338 --- calendar/gui/alarm-notify/.cvsignore | 8 ++ calendar/gui/alarm-notify/Makefile.am | 50 ++++++++++ calendar/gui/alarm-notify/alarm-notify.c | 156 +++++++++++++++++++++++++++++++ calendar/gui/alarm-notify/alarm-notify.h | 66 +++++++++++++ calendar/gui/alarm-notify/alarm-queue.c | 54 +++++------ calendar/gui/alarm-notify/alarm-queue.h | 14 +-- calendar/gui/alarm-notify/notify-main.c | 81 ++++++++++++++++ 7 files changed, 395 insertions(+), 34 deletions(-) create mode 100644 calendar/gui/alarm-notify/.cvsignore create mode 100644 calendar/gui/alarm-notify/Makefile.am create mode 100644 calendar/gui/alarm-notify/alarm-notify.c create mode 100644 calendar/gui/alarm-notify/alarm-notify.h create mode 100644 calendar/gui/alarm-notify/notify-main.c (limited to 'calendar/gui/alarm-notify') diff --git a/calendar/gui/alarm-notify/.cvsignore b/calendar/gui/alarm-notify/.cvsignore new file mode 100644 index 0000000000..fa1c1f7c87 --- /dev/null +++ b/calendar/gui/alarm-notify/.cvsignore @@ -0,0 +1,8 @@ +.deps +.libs +Makefile +Makefile.in +evolution-calendar-stubs.c +evolution-calendar-skels.c +evolution-calendar-common.c +evolution-calendar.h diff --git a/calendar/gui/alarm-notify/Makefile.am b/calendar/gui/alarm-notify/Makefile.am new file mode 100644 index 0000000000..2bfdfa38df --- /dev/null +++ b/calendar/gui/alarm-notify/Makefile.am @@ -0,0 +1,50 @@ +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 + +INCLUDES = \ + -DG_LOG_DOMAIN=\"evolution-alarm-notify\" \ + -I$(top_srcdir) \ + -I$(top_srcdir)/calendar \ + -I$(top_srcdir)/libical/src/libical \ + -I$(top_builddir)/libical/src/libical \ + -I$(top_srcdir)/widgets \ + -I$(includedir) \ + $(BONOBO_VFS_GNOME_CFLAGS) \ + $(EXTRA_GNOME_CFLAGS) \ + -DEVOLUTION_DATADIR=\""$(datadir)"\" \ + -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ + -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" + +gladedir = $(datadir)/evolution/glade + +evolution_alarm_notify_SOURCES = \ + notify-main.c + +evolution_alarm_notify_LDADD = \ + $(top_builddir)/calendar/cal-client/libcal-client.la \ + $(top_builddir)/calendar/cal-util/libcal-util.la \ + $(top_builddir)/libical/src/libical/libical.la \ + $(BONOBO_VFS_GNOME_LIBS) \ + $(EXTRA_GNOME_LIBS) \ + $(INTLLIBS) + +oafdir = $(datadir)/oaf +oaf_DATA = GNOME_Evolution_Calendar_AlarmNotify.oafinfo + +EXTRA_DIST = \ + $(oaf_DATA) + +BUILT_SOURCES = $(CORBA_GENERATED) +CLEANFILES += $(BUILT_SOURCES) diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c new file mode 100644 index 0000000000..348bb61bd3 --- /dev/null +++ b/calendar/gui/alarm-notify/alarm-notify.c @@ -0,0 +1,156 @@ +/* Evolution calendar - Alarm notification service object + * + * Copyright (C) 2000 Helix Code, Inc. + * + * Author: Federico Mena-Quintero + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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 "alarm-notify.h" + + + +/* Private part of the AlarmNotify structure */ +struct _AlarmNotifyPrivate { + /* FIXME */ +}; + + + +static void alarm_notify_class_init (AlarmNotifyClass *class); +static void alarm_notify_init (AlarmNotify *an); +static void alarm_notify_destroy (GtkObject *object); + +static POA_GNOME_Evolution_Calendar_AlarmListener__vepv alarm_listener_vepv; + +static BonoboObjectClass *parent_class; + + + +/** + * alarm_notify_get_type: + * + * Registers the #AlarmNotify class if necessary, and returns the type ID + * associated to it. + * + * Return value: The type ID of the #AlarmNotify class. + **/ +GtkType +alarm_notify_get_type (void) +{ + static GtkType alarm_notify_type = 0; + + if (!alarm_notify_type) { + static const GtkTypeInfo alarm_notify_info = { + "AlarmNotify", + sizeof (AlarmNotify), + sizeof (AlarmNotifyClass), + (GtkClassInitFunc) alarm_notify_class_init, + (GtkObjectInitFunc) alarm_notify_init, + NULL, /* reserved_1 */ + NULL, /* reserved_2 */ + (GtkClassInitFunc) NULL + }; + + alarm_notify_type = gtk_type_unique (BONOBO_OBJECT_TYPE, &alarm_notify_info); + } + + return alarm_notify_type; +} + +/* CORBA class initialization function for the alarm notify service */ +static void +init_alarm_notify_corba_class (void) +{ + alarm_notify_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv (); + alarm_notify_vepv.GNOME_Evolution_Calendar_AlarmNotify_epv = alarm_notify_get_epv (); +} + +/* 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_OBJECT_TYPE); + + object_class->destroy = alarm_notify_destroy; + + init_alarm_notify_corba_class (); +} + +/* 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; + + /* FIXME */ +} + +/* 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; + + /* FIXME */ + + g_free (priv); + an->priv = NULL; + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + + + +/* CORBA servant implementation */ + +/** + * alarm_notify_get_epv: + * + * Creates an EPV for the AlarmNotify CORBA class. + * + * Return value: A newly-allocated EPV. + **/ +POA_GNOME_Evolution_Calendar_AlarmNotify__epv * +alarm_notify_get_epv (void) +{ + POA_GNOME_Evolution_Calendar_AlarmNotify__epv *epv; + + epv = g_new0 (POA_GNOME_Evolution_Calendar_AlarmNotify__epv, 1); + epv->addCalendar = AlarmNotify_addCalendar; + epv->removeCalendar = AlarmNotify_removeCalendar; + epv->die = AlarmNotify_die; + return epv; +} diff --git a/calendar/gui/alarm-notify/alarm-notify.h b/calendar/gui/alarm-notify/alarm-notify.h new file mode 100644 index 0000000000..98fbfd2b70 --- /dev/null +++ b/calendar/gui/alarm-notify/alarm-notify.h @@ -0,0 +1,66 @@ +/* Evolution calendar - Alarm notification service object + * + * Copyright (C) 2000 Helix Code, Inc. + * + * Author: Federico Mena-Quintero + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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 +#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 { + BonoboObject object; + + /* Private data */ + AlarmNotifyPrivate *priv; +}; + +struct _AlarmNotifyClass { + BonoboObjectClass parent_class; +}; + +GtkType alarm_notify_get_type (void); + +AlarmNotify *alarm_notify_construct (AlarmNotify *an, + GNOME_Evolution_Calendar_AlarmNotify corba_an); + +GNOME_Evolution_Calendar_AlarmNotify alarm_notify_corba_object_create (BonoboObject *object); +POA_GNOME_Evolution_Calendar_AlarmNotify__epv *alarm_notify_get_epv (void); + +AlarmNotify *alarm_notify_new (void); + + + + +#endif diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index d824b2a189..fc4b2a5652 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -1,4 +1,4 @@ -/* Evolution calendar - Alarm notification engine +/* Evolution calendar - Alarm queueing engine * * Copyright (C) 2000 Helix Code, Inc. * @@ -26,12 +26,12 @@ #include #include #include "alarm.h" -#include "alarm-notify.h" +#include "alarm-queue.h" -/* Whether the notification system has been initialized */ -static gboolean alarm_notify_inited; +/* Whether the queueing system has been initialized */ +static gboolean alarm_queue_inited; /* Clients we are monitoring for alarms */ static GHashTable *client_alarms_hash = NULL; @@ -98,7 +98,7 @@ queue_midnight_refresh (void) midnight_refresh_id = alarm_add (midnight, midnight_refresh_cb, NULL, NULL); if (!midnight_refresh_id) { - g_message ("alarm_notify_init(): Could not set up the midnight refresh alarm!"); + g_message ("queue_midnight_refresh(): Could not set up the midnight refresh alarm!"); /* FIXME: what to do? */ } } @@ -382,33 +382,33 @@ obj_removed_cb (CalClient *client, const char *uid, gpointer data) /** - * alarm_notify_init: + * alarm_queue_init: * - * Initializes the alarm notification system. This should be called near the + * Initializes the alarm queueing system. This should be called near the * beginning of the program, after calling alarm_init(). **/ void -alarm_notify_init (void) +alarm_queue_init (void) { - g_return_if_fail (alarm_notify_inited == FALSE); + g_return_if_fail (alarm_queue_inited == FALSE); client_alarms_hash = g_hash_table_new (g_direct_hash, g_direct_equal); queue_midnight_refresh (); - alarm_notify_inited = TRUE; + alarm_queue_inited = TRUE; } /** - * alarm_notify_done: + * alarm_queue_done: * - * Shuts down the alarm notification system. This should be called near the end + * 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_notify_remove_client(). + * unregistered with alarm_queue_remove_client(). **/ void -alarm_notify_done (void) +alarm_queue_done (void) { - g_return_if_fail (alarm_notify_inited); + 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); @@ -420,29 +420,29 @@ alarm_notify_done (void) alarm_remove (midnight_refresh_id); midnight_refresh_id = NULL; - alarm_notify_inited = FALSE; + alarm_queue_inited = FALSE; } /** - * alarm_notify_add_client: + * alarm_queue_add_client: * @client: A calendar client. * - * Adds a calendar client to the alarm notification system. Alarm trigger + * 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_notify_remove_client() when receiving notifications + * 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 notification system, + * 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 - * notification system when it is no longer wanted. + * queueing system when it is no longer wanted. **/ void -alarm_notify_add_client (CalClient *client) +alarm_queue_add_client (CalClient *client) { ClientAlarms *ca; - g_return_if_fail (alarm_notify_inited); + g_return_if_fail (alarm_queue_inited); g_return_if_fail (client != NULL); g_return_if_fail (IS_CAL_CLIENT (client)); @@ -516,17 +516,17 @@ remove_client_alarms (ClientAlarms *ca) } /** - * alarm_notify_remove_client: + * alarm_queue_remove_client: * @client: A calendar client. * - * Removes a calendar client from the alarm notification system. + * Removes a calendar client from the alarm queueing system. **/ void -alarm_notify_remove_client (CalClient *client) +alarm_queue_remove_client (CalClient *client) { ClientAlarms *ca; - g_return_if_fail (alarm_notify_inited); + g_return_if_fail (alarm_queue_inited); g_return_if_fail (client != NULL); g_return_if_fail (IS_CAL_CLIENT (client)); diff --git a/calendar/gui/alarm-notify/alarm-queue.h b/calendar/gui/alarm-notify/alarm-queue.h index f386a56ae4..ea1309a810 100644 --- a/calendar/gui/alarm-notify/alarm-queue.h +++ b/calendar/gui/alarm-notify/alarm-queue.h @@ -1,4 +1,4 @@ -/* Evolution calendar - Alarm notification engine +/* Evolution calendar - Alarm queueing engine * * Copyright (C) 2000 Helix Code, Inc. * @@ -19,17 +19,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef ALARM_NOTIFY_H -#define ALARM_NOTIFY_H +#ifndef ALARM_QUEUE_H +#define ALARM_QUEUE_H #include -void alarm_notify_init (void); -void alarm_notify_done (void); +void alarm_queue_init (void); +void alarm_queue_done (void); -void alarm_notify_add_client (CalClient *client); -void alarm_notify_remove_client (CalClient *client); +void alarm_queue_add_client (CalClient *client); +void alarm_queue_remove_client (CalClient *client); #endif diff --git a/calendar/gui/alarm-notify/notify-main.c b/calendar/gui/alarm-notify/notify-main.c new file mode 100644 index 0000000000..93123808b0 --- /dev/null +++ b/calendar/gui/alarm-notify/notify-main.c @@ -0,0 +1,81 @@ +/* Evolution calendar - Alarm notification service main file + * + * Copyright (C) 2000 Helix Code, Inc. + * + * Author: Federico Mena-Quintero + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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 +#include +#include +#include "alarm-notify.h" + + + +static BonoboGenericFactory *factory; + +static AlarmNotify *alarm_notify_service; + + +/* 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) +{ + if (!alarm_notify_service) { + alarm_notify_service = alarm_notify_new (); + if (!alarm_notify_service) + return NULL; + } + + bonobo_object_ref (BONOBO_OBJECT (alarm_notify_service)); + return BONOBO_OBJECT (alarm_notify_service); +} + +int +main (int argc, char **argv) +{ + + 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")); + + factory = bonobo_generic_factory_new ("OAFID:GNOME_Evolution_Calendar_AlarmNotify_Factory", + alarm_notify_factory_fn, NULL); + if (!factory) + g_error (_("Could not create the alarm notify service factory")); + + bonobo_main (); + + bonobo_object_unref (BONOBO_OBJECT (factory)); + factory = NULL; + + return 0; +} -- cgit v1.2.3