aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-05-12 12:16:46 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2000-05-12 12:16:46 +0800
commit47c9fef15abc15c678e4cde60ee71d741dfe23bf (patch)
tree347e2e2ccc386409e254b6f25c4c94f98a9efafe /calendar
parentd55e9e0406875ffb47f40f57da3c6abaac90734a (diff)
downloadgsoc2013-evolution-47c9fef15abc15c678e4cde60ee71d741dfe23bf.tar.gz
gsoc2013-evolution-47c9fef15abc15c678e4cde60ee71d741dfe23bf.tar.zst
gsoc2013-evolution-47c9fef15abc15c678e4cde60ee71d741dfe23bf.zip
New function to add today's alarms for a single object.
2000-05-11 Federico Mena Quintero <federico@helixcode.com> * gui/gnome-cal.c (add_alarms_for_object): New function to add today's alarms for a single object. (gnome_calendar_object_updated_cb): Update the object's alarms. * idl/evolution-calendar.idl (Cal): Added a get_alarms_for_object() method. * pcs/cal.c (Cal_get_alarms_for_object): Implemented method. * pcs/cal-backend.c (cal_backend_get_alarms_for_object): New function. * pcs/cal-backend-imc.c (cal_backend_imc_get_alarms_for_object): Implemented. * cal-client/cal-client.c (cal_client_get_alarms_for_object): New function. svn path=/trunk/; revision=3003
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog100
-rw-r--r--calendar/cal-client/cal-client.c59
-rw-r--r--calendar/cal-client/cal-client.h4
-rw-r--r--calendar/gui/gnome-cal.c41
-rw-r--r--calendar/idl/evolution-calendar.idl9
-rw-r--r--calendar/pcs/cal-backend-imc.c40
-rw-r--r--calendar/pcs/cal-backend.c29
-rw-r--r--calendar/pcs/cal-backend.h7
-rw-r--r--calendar/pcs/cal.c53
9 files changed, 288 insertions, 54 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index c481733731..4a52717667 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,23 @@
+2000-05-11 Federico Mena Quintero <federico@helixcode.com>
+
+ * gui/gnome-cal.c (add_alarms_for_object): New function to add
+ today's alarms for a single object.
+ (gnome_calendar_object_updated_cb): Update the object's alarms.
+
+ * idl/evolution-calendar.idl (Cal): Added a
+ get_alarms_for_object() method.
+
+ * pcs/cal.c (Cal_get_alarms_for_object): Implemented method.
+
+ * pcs/cal-backend.c (cal_backend_get_alarms_for_object): New
+ function.
+
+ * pcs/cal-backend-imc.c (cal_backend_imc_get_alarms_for_object):
+ Implemented.
+
+ * cal-client/cal-client.c (cal_client_get_alarms_for_object): New
+ function.
+
2000-05-11 Dan Winship <danw@helixcode.com>
* gui/calendar-commands.c (calendar_control_activate): Now that we
@@ -181,7 +201,7 @@
2000-05-08 Damon Chaplin <damon@helixcode.com>
- * gui/e-week-view.c (e_week_view_remove_event_cb):
+ * gui/e-week-view.c (e_week_view_remove_event_cb):
* gui/e-day-view.c (e_day_view_remove_event_cb): don't set the ico->uid
to NULL or we won't find any other occurrences of the event. Set the
editing_event_day/num to -1 instead.
@@ -194,7 +214,7 @@
2000-05-07 Damon Chaplin <damon@helixcode.com>
- * gui/e-day-view.c (e_day_view_on_main_canvas_drag_data_received):
+ * gui/e-day-view.c (e_day_view_on_main_canvas_drag_data_received):
(e_day_view_on_top_canvas_drag_data_received): show the EText item,
just in case it hasn't moved, otherwise it won't appear.
@@ -211,7 +231,7 @@
2000-05-06 Damon Chaplin <damon@helixcode.com>
- * cal-util/timeutil.c (time_day_begin):
+ * cal-util/timeutil.c (time_day_begin):
(time_day_end): changed these so they just do a simple localtime(),
update the struct tm, then do a mktime(). I don't know why it used to
look at the tm_isdst flags etc. From a little test program I wrote
@@ -227,7 +247,7 @@
2000-05-06 Damon Chaplin <damon@helixcode.com>
- * gui/e-day-view.c:
+ * gui/e-day-view.c:
* gui/e-week-view.c: finish editing event when user hits Return key.
(e_week_view_on_text_item_event): stop event signals after doing any
other calls, since otherwise it will also stop any other resulting
@@ -258,7 +278,7 @@
* gui/gncal-week-view.[hc]:
* gui/layout.[hc]:
* gui/view-utils.[hc]: removed old calendar view files.
-
+
2000-05-06 Damon Chaplin <damon@helixcode.com>
* cal-util/calobj.[hc]: added guint ref_count to iCalObject struct,
@@ -266,14 +286,14 @@
stuff to use ref_counts but I haven't touched the pcs/ stuff. Maybe
just using ical_object_destroy() is OK there.
- * gui/gncal-todo.c:
- * gui/calendar-commands.c:
- * gui/eventedit.c:
- * gui/e-week-view.c:
+ * gui/gncal-todo.c:
+ * gui/calendar-commands.c:
+ * gui/eventedit.c:
+ * gui/e-week-view.c:
* gui/e-day-view.c: use refcounting for iCalObjects.
- * gui/e-day-view-main-item.c:
- * gui/e-day-view-top-item.c:
+ * gui/e-day-view-main-item.c:
+ * gui/e-day-view-top-item.c:
* gui/e-day-view.c: try not to ever draw outside the event, even when
the event is very small.
@@ -284,7 +304,7 @@
better to let the user do the resize/drag and then ask them what they
want to do - change the single occurrence or the entire series.
- * gui/e-day-view-time-item.c (e_day_view_time_item_show_popup_menu):
+ * gui/e-day-view-time-item.c (e_day_view_time_item_show_popup_menu):
use e_auto_kill_popup_menu_on_hide() to destroy the popup menu.
* gui/popup-menu.c: include e-gui-utils.h
@@ -296,7 +316,7 @@
* gui/calendar-commands.c: when we switch views, grab the focus.
- * gui/gnome-cal.c (gnome_calendar_tag_calendar):
+ * gui/gnome-cal.c (gnome_calendar_tag_calendar):
(gnome_calendar_mark_gtk_calendar_day): changed this so it uses
cal_client_get_events_in_range(), and doesn't load any objects.
Also just return if it isn't visible.
@@ -315,10 +335,10 @@
* pcs/cal-backend.c (save): output the '... saved' message before
freeing the string!
- * gui/gncal-todo.c (gncal_todo_update):
- * gui/e-week-view.c (e_week_view_update_event):
- * gui/e-day-view.c (e_day_view_update_event):
- * gui/calendar-commands.c (calendar_get_events_in_range):
+ * gui/gncal-todo.c (gncal_todo_update):
+ * gui/e-week-view.c (e_week_view_update_event):
+ * gui/e-day-view.c (e_day_view_update_event):
+ * gui/calendar-commands.c (calendar_get_events_in_range):
(calendar_iterate): free obj_string after it is parsed.
2000-05-02 Damon Chaplin <damon@helixcode.com>
@@ -329,7 +349,7 @@
* gui/popup-menu.c (popup_menu): added call to
e_auto_kill_popup_menu_on_hide() to destroy the menu.
- * gui/e-week-view.c (e_week_view_show_popup_menu):
+ * gui/e-week-view.c (e_week_view_show_popup_menu):
* gui/e-day-view.c (e_day_view_on_event_right_click): ico->user_data
isn't useful any more, since the event editor keeps its own iCalObject.
So for now we make the menu commands available even when the event is
@@ -339,18 +359,18 @@
* gui/eventedit.c (event_editor_destroy): destroy the iCalObject.
The event editor now uses its own independent iCalObject.
- * gui/e-week-view.c (e_week_view_on_unrecur_appointment):
+ * gui/e-week-view.c (e_week_view_on_unrecur_appointment):
* gui/e-day-view.c (e_day_view_on_unrecur_appointment): create a new
uid for the new single instance. I'm not sure what we should do about
the creation/last modification times of the objects.
-
- * gui/e-week-view.c (e_week_view_on_edit_appointment):
+
+ * gui/e-week-view.c (e_week_view_on_edit_appointment):
* gui/e-day-view.c (e_day_view_on_edit_appointment): duplicate the
iCalObject before passing it to the event editor, since it will change
the fields. If we don't duplicate it we won't know what has changed
when we get the "update_event" callback.
- * gui/e-week-view.c (e_week_view_key_press):
+ * gui/e-week-view.c (e_week_view_key_press):
* gui/e-day-view.c (e_day_view_key_press): set the created and last_mod
times of the new iCalObject. We may want to set the default alarm as
well.
@@ -366,7 +386,7 @@
* gui/calendar-commands.c (display_objedit): use the above function
to get the time for the new appointment.
- * gui/e-week-view.c:
+ * gui/e-week-view.c:
* gui/e-day-view.c: use a shallow copy of the ico when we update the
times (when resizing/dragging). Otherwise we won't detect that the
time has changed in the "update_event" callback.
@@ -390,7 +410,7 @@
It is used for optimization when we get the "object_changed" signal.
We have to do far less work if the dates are unchanged.
- * gui/e-week-view.c:
+ * gui/e-week-view.c:
* gui/e-day-view.c: only draw the selection when we have the keyboard
focus, since the user expects to be able to type in a new event when
the selection is shown. Also keep the selection when we lose focus,
@@ -399,9 +419,9 @@
Also quite a few changes to cope with the new client/server
architecture.
- * gui/e-day-view-top-item.c (e_day_view_top_item_draw):
- * gui/e-day-view-main-item.c (e_day_view_main_item_draw):
- * gui/e-week-view-main-item.c (e_week_view_main_item_draw_day):
+ * gui/e-day-view-top-item.c (e_day_view_top_item_draw):
+ * gui/e-day-view-main-item.c (e_day_view_main_item_draw):
+ * gui/e-week-view-main-item.c (e_week_view_main_item_draw_day):
only draw the selection if the widget has the keyboard focus.
* gui/gnome-cal.c (mark_gtk_calendar_day): fixed so it works with
@@ -511,15 +531,15 @@
* gui/Makefile.am: added new source files and pixmaps, and removed
old source files, which can be deleted.
- * gui/e-week-view-titles-item.[hc]:
- * gui/e-week-view-main-item.[hc]:
- * gui/e-week-view-event-item.[hc]:
+ * gui/e-week-view-titles-item.[hc]:
+ * gui/e-week-view-main-item.[hc]:
+ * gui/e-week-view-event-item.[hc]:
* gui/e-week-view.[hc]: new files implementing the week/month views.
- * gui/yearview.xpm:
- * gui/monthview.xpm:
- * gui/weekview.xpm:
- * gui/workweekview.xpm:
+ * gui/yearview.xpm:
+ * gui/monthview.xpm:
+ * gui/weekview.xpm:
+ * gui/workweekview.xpm:
* gui/dayview.xpm: new pixmaps for the toolbar buttons. These aren't
intended to be the final pixmaps.
@@ -714,11 +734,11 @@
* gui/gncal-todo.c (simple_todo_editor): calendar is a frame instead
of a window, now.
-
+
* gui/gnome-cal.c (gnome_calendar_new): same
-
+
* gui/goto.c (goto_dialog): same
-
+
2000-04-06 Seth Alves <alves@hungry.com>
* gui/calendar-commands.c (calendar_control_activate): removed
@@ -905,13 +925,13 @@
in the GnomeCalendar struct.
* gui/*.c: tracked change from Calendar * to CalClient
-
+
* gui/main.c: moved alarm_defaults from here to cal-util/calobj.c
(calendar_get_events_in_range): pulled this out of calendar.c and
fixed it up to use cal-client stuff. i'm not sure where to put it yet.
* gui/main.c (calendar_iterate): pulled this one out of calendar.c also
-
+
2000-03-07 Federico Mena Quintero <federico@helixcode.com>
* cal-client/Makefile.am: Removed cal-client-alarm.[ch] from the
@@ -967,7 +987,7 @@
2000-03-01 Federico Mena Quintero <federico@helixcode.com>
- * Makefile.am: Use the gnome-config flags for orbit-idl.
+ * Makefile.am: Use the gnome-config flags for orbit-idl.
Create a libcal-client library with the calendar client object.
2000-02-29 Federico Mena Quintero <federico@helixcode.com>
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
index 2e83345d27..97dda85acb 100644
--- a/calendar/cal-client/cal-client.c
+++ b/calendar/cal-client/cal-client.c
@@ -825,6 +825,65 @@ cal_client_get_alarms_in_range (CalClient *client, time_t start, time_t end)
}
/**
+ * cal_client_get_alarms_for_object:
+ * @client: A calendar client.
+ * @uid: Unique identifier for a calendar object.
+ * @start: Start time for query.
+ * @end: End time for query.
+ * @alarms: Return value for the list of alarm instances.
+ *
+ * Queries a calendar for the alarms of a particular object that trigger in the
+ * specified range of time.
+ *
+ * Return value: TRUE on success, FALSE if the object was not found.
+ **/
+gboolean
+cal_client_get_alarms_for_object (CalClient *client, const char *uid,
+ time_t start, time_t end,
+ GList **alarms)
+{
+ CalClientPrivate *priv;
+ CORBA_Environment ev;
+ Evolution_Calendar_CalAlarmInstanceSeq *seq;
+ gboolean retval;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE);
+
+ priv = client->priv;
+ if (priv->load_state != LOAD_STATE_LOADED)
+ return FALSE;
+
+ g_return_val_if_fail (uid != NULL, FALSE);
+ g_return_val_if_fail (start != -1 && end != -1, FALSE);
+ g_return_val_if_fail (start <= end, FALSE);
+ g_return_val_if_fail (alarms != NULL, FALSE);
+
+ *alarms = NULL;
+ retval = FALSE;
+
+ CORBA_exception_init (&ev);
+
+ seq = Evolution_Calendar_Cal_get_alarms_for_object (priv->cal, uid, start, end, &ev);
+ if (ev._major == CORBA_USER_EXCEPTION
+ && strcmp (CORBA_exception_id (&ev), ex_Evolution_Calendar_Cal_NotFound) == 0)
+ goto out;
+ else if (ev._major != CORBA_NO_EXCEPTION) {
+ g_message ("cal_client_get_alarms_for_object(): could not get the alarm range");
+ goto out;
+ }
+
+ retval = TRUE;
+ *alarms = build_alarm_instance_list (seq);
+ CORBA_free (seq);
+
+ out:
+ CORBA_exception_free (&ev);
+ return retval;
+
+}
+
+/**
* cal_client_update_object:
* @client: A calendar client.
* @uid: Unique identifier of object to update.
diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h
index 5bb672229d..12cbcc7c87 100644
--- a/calendar/cal-client/cal-client.h
+++ b/calendar/cal-client/cal-client.h
@@ -82,6 +82,10 @@ GList *cal_client_get_events_in_range (CalClient *client, time_t start, time_t e
GList *cal_client_get_alarms_in_range (CalClient *client, time_t start, time_t end);
+gboolean cal_client_get_alarms_for_object (CalClient *client, const char *uid,
+ time_t start, time_t end,
+ GList **alarms);
+
gboolean cal_client_update_object (CalClient *client, const char *uid, const char *calobj);
gboolean cal_client_remove_object (CalClient *client, const char *uid);
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 4c90414f16..3041d80d07 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -683,7 +683,7 @@ midnight_refresh_cb (gpointer alarm_id, time_t trigger, gpointer data)
/* Loads and queues the alarms from the current time up to midnight. */
static void
-load_alarms (GnomeCalendar *cal)
+load_alarms (GnomeCalendar *gcal)
{
time_t now;
time_t end_of_day;
@@ -694,17 +694,17 @@ load_alarms (GnomeCalendar *cal)
/* Queue alarms */
- alarms = cal_client_get_alarms_in_range (cal->client, now, end_of_day);
+ alarms = cal_client_get_alarms_in_range (gcal->client, now, end_of_day);
for (l = alarms; l; l = l->next)
- setup_alarm (cal, l->data);
+ setup_alarm (gcal, l->data);
cal_alarm_instance_list_free (alarms);
/* Queue the midnight alarm refresh */
- cal->midnight_alarm_refresh_id = alarm_add (end_of_day, midnight_refresh_cb, cal, NULL);
- if (!cal->midnight_alarm_refresh_id) {
+ gcal->midnight_alarm_refresh_id = alarm_add (end_of_day, midnight_refresh_cb, gcal, NULL);
+ if (!gcal->midnight_alarm_refresh_id) {
g_message ("load_alarms(): Could not set up the midnight refresh alarm!");
/* FIXME: what to do? */
}
@@ -754,6 +754,32 @@ remove_alarms_for_object (GnomeCalendar *gcal, const char *uid)
g_free (oa);
}
+/* Adds today's alarms for the specified object */
+static void
+add_alarms_for_object (GnomeCalendar *gcal, const char *uid)
+{
+ GList *alarms;
+ gboolean result;
+ time_t now, end_of_day;
+ GList *l;
+
+ now = time (NULL);
+ end_of_day = time_day_end (now);
+
+ result = cal_client_get_alarms_for_object (gcal->client, uid, now, end_of_day, &alarms);
+ if (!result) {
+ /* FIXME: should we warn here, or is it OK if the object
+ * disappeared in the meantime?
+ */
+ return;
+ }
+
+ for (l = alarms; l; l = l->next)
+ setup_alarm (gcal, l->data);
+
+ cal_alarm_instance_list_free (alarms);
+}
+
static void
gnome_calendar_object_updated_cb (GtkWidget *cal_client,
const char *uid,
@@ -763,7 +789,7 @@ gnome_calendar_object_updated_cb (GtkWidget *cal_client,
uid?uid:"<NULL>");
remove_alarms_for_object (gcal, uid);
- /* FIXME: put in new alarms */
+ add_alarms_for_object (gcal, uid);
/* FIXME: do we really want each view to reload the event itself?
Maybe we should keep track of events globally, maybe with ref
@@ -818,8 +844,7 @@ gnome_calendar_new (char *title)
gcal = GNOME_CALENDAR (retval);
gcal->selection_start_time = time_day_begin (time (NULL));
- gcal->selection_end_time = time_add_day (gcal->selection_start_time,
- 1);
+ gcal->selection_end_time = time_add_day (gcal->selection_start_time, 1);
gcal->client = cal_client_new ();
setup_widgets (gcal);
diff --git a/calendar/idl/evolution-calendar.idl b/calendar/idl/evolution-calendar.idl
index b08b8fd07f..29d0a79780 100644
--- a/calendar/idl/evolution-calendar.idl
+++ b/calendar/idl/evolution-calendar.idl
@@ -92,11 +92,18 @@ module Calendar {
raises (InvalidRange);
/* Gets the objects whose alarms trigger in the specified time
- * range.
+ * range.
*/
CalAlarmInstanceSeq get_alarms_in_range (in Time_t start, in Time_t end)
raises (InvalidRange);
+ /* Gets the alarms for the specified object that trigger in the
+ * specified time range.
+ */
+ CalAlarmInstanceSeq get_alarms_for_object (in CalObjUID uid,
+ in Time_t start, in Time_t end)
+ raises (NotFound, InvalidRange);
+
/* Updates an object by adding it if it does not exist or by
* changing an existing one.
*/
diff --git a/calendar/pcs/cal-backend-imc.c b/calendar/pcs/cal-backend-imc.c
index 9492ad1241..3c50078d12 100644
--- a/calendar/pcs/cal-backend-imc.c
+++ b/calendar/pcs/cal-backend-imc.c
@@ -78,6 +78,9 @@ static char *cal_backend_imc_get_object (CalBackend *backend, const char *uid);
static GList *cal_backend_imc_get_uids (CalBackend *backend, CalObjType type);
static GList *cal_backend_imc_get_events_in_range (CalBackend *backend, time_t start, time_t end);
static GList *cal_backend_imc_get_alarms_in_range (CalBackend *backend, time_t start, time_t end);
+static gboolean cal_backend_imc_get_alarms_for_object (CalBackend *backend, const char *uid,
+ time_t start, time_t end,
+ GList **alarms);
static gboolean cal_backend_imc_update_object (CalBackend *backend, const char *uid,
const char *calobj);
static gboolean cal_backend_imc_remove_object (CalBackend *backend, const char *uid);
@@ -138,6 +141,7 @@ cal_backend_imc_class_init (CalBackendIMCClass *class)
backend_class->get_uids = cal_backend_imc_get_uids;
backend_class->get_events_in_range = cal_backend_imc_get_events_in_range;
backend_class->get_alarms_in_range = cal_backend_imc_get_alarms_in_range;
+ backend_class->get_alarms_for_object = cal_backend_imc_get_alarms_for_object;
backend_class->update_object = cal_backend_imc_update_object;
backend_class->remove_object = cal_backend_imc_remove_object;
@@ -1147,6 +1151,42 @@ cal_backend_imc_get_alarms_in_range (CalBackend *backend, time_t start, time_t e
return alarms;
}
+/* Get_alarms_for_object handler for the IMC backend */
+static gboolean
+cal_backend_imc_get_alarms_for_object (CalBackend *backend, const char *uid,
+ time_t start, time_t end,
+ GList **alarms)
+{
+ CalBackendIMC *cbimc;
+ IMCPrivate *priv;
+ iCalObject *ico;
+
+ cbimc = CAL_BACKEND_IMC (backend);
+ priv = cbimc->priv;
+
+ g_return_val_if_fail (priv->loaded, FALSE);
+ g_return_val_if_fail (uid != NULL, FALSE);
+ g_return_val_if_fail (start != -1 && end != -1, FALSE);
+ g_return_val_if_fail (start <= end, FALSE);
+ g_return_val_if_fail (alarms != NULL, FALSE);
+
+ *alarms = NULL;
+
+ ico = lookup_object (cbimc, uid);
+ if (!ico)
+ return FALSE;
+
+ /* Only VEVENT and VTODO components can have alarms */
+
+ if (ico->type != ICAL_EVENT && ico->type != ICAL_TODO)
+ return TRUE;
+
+ *alarms = add_alarms_for_object (*alarms, ico, start, end);
+ *alarms = g_list_sort (*alarms, compare_instance_func);
+
+ return TRUE;
+}
+
/* Notifies a backend's clients that an object was updated */
static void
notify_update (CalBackendIMC *cbimc, const char *uid)
diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c
index e9c18d6f86..15cfb1e7bc 100644
--- a/calendar/pcs/cal-backend.c
+++ b/calendar/pcs/cal-backend.c
@@ -267,6 +267,35 @@ cal_backend_get_alarms_in_range (CalBackend *backend, time_t start, time_t end)
}
/**
+ * cal_backend_get_alarms_for_object:
+ * @backend: A calendar backend.
+ * @uid: Unique identifier for a calendar object.
+ * @start: Start time for query.
+ * @end: End time for query.
+ * @alarms: Return value for the list of alarm instances.
+ *
+ * Builds a sorted list of the alarms of the specified event that trigger in a
+ * particular time range.
+ *
+ * Return value: TRUE on success, FALSE if the object was not found.
+ **/
+gboolean
+cal_backend_get_alarms_for_object (CalBackend *backend, const char *uid,
+ time_t start, time_t end,
+ GList **alarms)
+{
+ g_return_val_if_fail (backend != NULL, FALSE);
+ g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE);
+ g_return_val_if_fail (uid != NULL, FALSE);
+ g_return_val_if_fail (start != -1 && end != -1, FALSE);
+ g_return_val_if_fail (start <= end, FALSE);
+ g_return_val_if_fail (alarms != NULL, FALSE);
+
+ g_assert (CLASS (backend)->get_alarms_for_object != NULL);
+ return (* CLASS (backend)->get_alarms_for_object) (backend, uid, start, end, alarms);
+}
+
+/**
* cal_backend_update_object:
* @backend: A calendar backend.
* @uid: Unique identifier of the object to update.
diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h
index 5ce9027415..2bbac4b3d4 100644
--- a/calendar/pcs/cal-backend.h
+++ b/calendar/pcs/cal-backend.h
@@ -68,6 +68,9 @@ struct _CalBackendClass {
GList *(* get_uids) (CalBackend *backend, CalObjType type);
GList *(* get_events_in_range) (CalBackend *backend, time_t start, time_t end);
GList *(* get_alarms_in_range) (CalBackend *backend, time_t start, time_t end);
+ gboolean (* get_alarms_for_object) (CalBackend *backend, const char *uid,
+ time_t start, time_t end,
+ GList **alarms);
gboolean (* update_object) (CalBackend *backend, const char *uid, const char *calobj);
gboolean (* remove_object) (CalBackend *backend, const char *uid);
};
@@ -90,6 +93,10 @@ GList *cal_backend_get_events_in_range (CalBackend *backend, time_t start, time_
GList *cal_backend_get_alarms_in_range (CalBackend *backend, time_t start, time_t end);
+gboolean cal_backend_get_alarms_for_object (CalBackend *backend, const char *uid,
+ time_t start, time_t end,
+ GList **alarms);
+
gboolean cal_backend_update_object (CalBackend *backend, const char *uid, const char *calobj);
gboolean cal_backend_remove_object (CalBackend *backend, const char *uid);
diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c
index 8fc1de51b2..13fab067f8 100644
--- a/calendar/pcs/cal.c
+++ b/calendar/pcs/cal.c
@@ -201,7 +201,7 @@ Cal_get_object (PortableServer_Servant servant,
/* Cal::get_uids method */
static Evolution_Calendar_CalObjUIDSeq *
Cal_get_uids (PortableServer_Servant servant,
- const Evolution_Calendar_CalObjType type,
+ Evolution_Calendar_CalObjType type,
CORBA_Environment *ev)
{
Cal *cal;
@@ -287,8 +287,8 @@ build_object_instance_seq (GList *list)
/* Cal::get_events_in_range method */
static Evolution_Calendar_CalObjInstanceSeq *
Cal_get_events_in_range (PortableServer_Servant servant,
- const Evolution_Calendar_Time_t start,
- const Evolution_Calendar_Time_t end,
+ Evolution_Calendar_Time_t start,
+ Evolution_Calendar_Time_t end,
CORBA_Environment *ev)
{
Cal *cal;
@@ -378,8 +378,8 @@ build_alarm_instance_seq (GList *alarms)
/* Cal::get_alarms_in_range method */
static Evolution_Calendar_CalAlarmInstanceSeq *
Cal_get_alarms_in_range (PortableServer_Servant servant,
- const Evolution_Calendar_Time_t start,
- const Evolution_Calendar_Time_t end,
+ Evolution_Calendar_Time_t start,
+ Evolution_Calendar_Time_t end,
CORBA_Environment *ev)
{
Cal *cal;
@@ -410,6 +410,48 @@ Cal_get_alarms_in_range (PortableServer_Servant servant,
return seq;
}
+/* Cal::get_alarms_for_object method */
+static Evolution_Calendar_CalAlarmInstanceSeq *
+Cal_get_alarms_for_object (PortableServer_Servant servant,
+ const Evolution_Calendar_CalObjUID uid,
+ Evolution_Calendar_Time_t start,
+ Evolution_Calendar_Time_t end,
+ CORBA_Environment *ev)
+{
+ Cal *cal;
+ CalPrivate *priv;
+ time_t t_start, t_end;
+ Evolution_Calendar_CalAlarmInstanceSeq *seq;
+ GList *alarms;
+ gboolean result;
+
+ cal = CAL (bonobo_object_from_servant (servant));
+ priv = cal->priv;
+
+ t_start = (time_t) start;
+ t_end = (time_t) end;
+
+ if (t_start > t_end || t_start == -1 || t_end == -1) {
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_Evolution_Calendar_Cal_InvalidRange,
+ NULL);
+ return NULL;
+ }
+
+ result = cal_backend_get_alarms_for_object (priv->backend, uid, t_start, t_end, &alarms);
+ if (!result) {
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_Evolution_Calendar_Cal_NotFound,
+ NULL);
+ return NULL;
+ }
+
+ seq = build_alarm_instance_seq (alarms);
+ cal_alarm_instance_list_free (alarms);
+
+ return seq;
+}
+
/* Cal::update_object method */
static void
Cal_update_object (PortableServer_Servant servant,
@@ -466,6 +508,7 @@ cal_get_epv (void)
epv->get_uids = Cal_get_uids;
epv->get_events_in_range = Cal_get_events_in_range;
epv->get_alarms_in_range = Cal_get_alarms_in_range;
+ epv->get_alarms_for_object = Cal_get_alarms_for_object;
epv->update_object = Cal_update_object;
epv->remove_object = Cal_remove_object;