diff options
author | Federico Mena Quintero <federico@helixcode.com> | 2000-12-19 07:47:52 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2000-12-19 07:47:52 +0800 |
commit | 8d96fe16f15f653d0809603ccaecd677e5708d8d (patch) | |
tree | 56d1ccf4be7dcec8a7a09524f2d312ab1da004af /calendar/cal-client/cal-client.c | |
parent | a1d12a819a73754b94eeaf558aefa91e77f169f3 (diff) | |
download | gsoc2013-evolution-8d96fe16f15f653d0809603ccaecd677e5708d8d.tar.gz gsoc2013-evolution-8d96fe16f15f653d0809603ccaecd677e5708d8d.tar.zst gsoc2013-evolution-8d96fe16f15f653d0809603ccaecd677e5708d8d.zip |
Alarm instance generation support for the Wombat.
2000-12-18 Federico Mena Quintero <federico@helixcode.com>
Alarm instance generation support for the Wombat.
* idl/evolution-calendar.idl (Cal::CalAlarmInstance): Changed to
have an alarm UID, the trigger time, and the actual occurrence
time.
(Cal::CalComponentAlarms): New structure to hold a pair of a
component and its alarms that trigger in a particular range of
time.
(Cal::getAlarmsInRange): Changed to return a CalComponentAlarmsSeq.
* cal-util/cal-component.h (CalAlarmInstance): New C-side
structure to match the one on the IDL.
(CalComponentAlarms): Ditto.
(CalAlarmAction): Renamed from CalComponentAlarmAction.
(CalAlarmTriggerType): Renamed from CalComponentAlarmTriggerType.
Encoded the START and END parameters for the RELATED parameter in
this enum, too. Added a NONE value for invalid or missing trigger
specifications.
(CalComponentAlarmTriggerRelated): Removed.
(CalAlarmTrigger): Renamed from CalComponentAlarmTrigger. Renamed
the duration/time fields to rel_duration/abs_time, respectively.
* cal-util/cal-component.c (cal_component_alarm_get_trigger):
Changed to use the new trigger structure.
(cal_component_alarm_set_trigger): Likewise.
(cal_component_alarm_free_trigger): Removed function.
(cal_component_has_alarms): Count the elements in the
alarm_uid_hash instead of trying to fetch the first alarm subcomponent.
(cal_component_alarms_free): New function to free a
CalComponentAlarms structure.
(CalComponentAlarmPrivate): Added an uid property pointer.
(scan_alarm_property): Scan for the our extension UID property.
(cal_component_alarm_get_uid): New function.
* pcs/cal-backend.h (CalBackendClass): Changed the signatures of
the ::get_alarms_in_range() and ::get_alarms_for_object() methods.
* pcs/cal-backend.c (cal_backend_get_alarms_in_range): Changed
signature; use the new method.
(cal_backend_get_alarms_for_object): Likewise.
* pcs/cal-backend-file.c (compute_alarm_range): New spiffy
function to compute a range of time for alarm occurrences.
(add_alarm_occurrences_cb): New function to add alarms for a
particular occurrence of the component.
(generate_absolute_triggers): New function to add the absolute
alarm triggers.
(generate_alarms_for_comp): New function to generate all the alarm
instances for a component.
(cal_backend_file_get_alarms_in_range): Implemented.
* pcs/cal.c (Cal_get_alarms_in_range): Use the new CalBackend API.
(Cal_get_alarms_for_object): Likewise.
(build_alarm_instance_seq): Removed old function.
* cal-util/cal-util.c (cal_alarm_instance_list_free): Removed
function.
* cal-client/cal-client.c (build_component_alarms_list): New
function to demarshal the component alarms sequence.
(build_alarm_instance_list): New function to demarshal the alarm
instances sequence.
(cal_client_get_alarms_in_range): Updated for the new API.
(cal_client_get_alarms_for_object): Updated for the new API.
* gui/gnome-cal.c: Temporary #ifdef-ing out of alarm-related stuff
to make it build.
svn path=/trunk/; revision=7076
Diffstat (limited to 'calendar/cal-client/cal-client.c')
-rw-r--r-- | calendar/cal-client/cal-client.c | 146 |
1 files changed, 92 insertions, 54 deletions
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c index a75912275f..b3e8cd507d 100644 --- a/calendar/cal-client/cal-client.c +++ b/calendar/cal-client/cal-client.c @@ -622,7 +622,7 @@ cal_client_get_object (CalClient *client, const char *uid, CalComponent **comp) { CalClientPrivate *priv; CORBA_Environment ev; - GNOME_Evolution_Calendar_CalObj calobj_str; + GNOME_Evolution_Calendar_CalObj comp_str; CalClientGetStatus retval; icalcomponent *icalcomp; @@ -639,7 +639,7 @@ cal_client_get_object (CalClient *client, const char *uid, CalComponent **comp) *comp = NULL; CORBA_exception_init (&ev); - calobj_str = GNOME_Evolution_Calendar_Cal_getObject (priv->cal, (char *) uid, &ev); + comp_str = GNOME_Evolution_Calendar_Cal_getObject (priv->cal, (char *) uid, &ev); if (ev._major == CORBA_USER_EXCEPTION && strcmp (CORBA_exception_id (&ev), ex_GNOME_Evolution_Calendar_Cal_NotFound) == 0) @@ -649,8 +649,8 @@ cal_client_get_object (CalClient *client, const char *uid, CalComponent **comp) goto out; } - icalcomp = icalparser_parse_string (calobj_str); - CORBA_free (calobj_str); + icalcomp = icalparser_parse_string (comp_str); + CORBA_free (comp_str); if (!icalcomp) { retval = CAL_CLIENT_GET_SYNTAX_ERROR; @@ -1160,61 +1160,81 @@ cal_client_generate_instances (CalClient *client, CalObjType type, g_list_free (instances); } - -#if 0 -/* Translates the CORBA representation of an AlarmType */ -static enum AlarmType -uncorba_alarm_type (Evolution_Calendar_AlarmType corba_type) +/* Builds a list of CalAlarmInstance structures */ +static GSList * +build_alarm_instance_list (CalComponent *comp, GNOME_Evolution_Calendar_CalAlarmInstanceSeq *seq) { - switch (corba_type) { - case Evolution_Calendar_MAIL: - return ALARM_MAIL; + GSList *alarms; + int i; - case Evolution_Calendar_PROGRAM: - return ALARM_PROGRAM; + alarms = NULL; - case Evolution_Calendar_DISPLAY: - return ALARM_DISPLAY; + for (i = 0; i < seq->_length; i++) { + GNOME_Evolution_Calendar_CalAlarmInstance *corba_instance; + CalComponentAlarm *alarm; + const char *auid; + CalAlarmInstance *instance; - case Evolution_Calendar_AUDIO: - return ALARM_AUDIO; + corba_instance = seq->_buffer + i; - default: - g_assert_not_reached (); - return ALARM_DISPLAY; + /* Since we want the in-commponent auid, we look for the alarm + * in the component and fetch its "real" auid. + */ + + alarm = cal_component_get_alarm (comp, corba_instance->auid); + if (!alarm) + continue; + + auid = cal_component_alarm_get_uid (alarm); + cal_component_alarm_free (alarm); + + instance = g_new (CalAlarmInstance, 1); + instance->auid = auid; + instance->trigger = corba_instance->trigger; + instance->occur = corba_instance->occur; + + alarms = g_slist_prepend (alarms, instance); } + + return g_slist_reverse (alarms); } -#endif -/* Builds a GList of CalAlarmInstance structures from the CORBA sequence */ -static GList * -build_alarm_instance_list (GNOME_Evolution_Calendar_CalAlarmInstanceSeq *seq) +/* Builds a list of CalComponentAlarms structures */ +static GSList * +build_component_alarms_list (GNOME_Evolution_Calendar_CalComponentAlarmsSeq *seq) { - GList *list; + GSList *comp_alarms; int i; - /* Create the list in reverse order */ + comp_alarms = NULL; - list = NULL; for (i = 0; i < seq->_length; i++) { - GNOME_Evolution_Calendar_CalAlarmInstance *corba_ai; - CalAlarmInstance *ai; + GNOME_Evolution_Calendar_CalComponentAlarms *corba_alarms; + CalComponent *comp; + CalComponentAlarms *alarms; + icalcomponent *icalcomp; - corba_ai = &seq->_buffer[i]; - ai = g_new (CalAlarmInstance, 1); + corba_alarms = seq->_buffer + i; - ai->uid = g_strdup (corba_ai->uid); -#if 0 - ai->type = uncorba_alarm_type (corba_ai->type); -#endif - ai->trigger = corba_ai->trigger; - ai->occur = corba_ai->occur; + icalcomp = icalparser_parse_string (corba_alarms->calobj); + if (!icalcomp) + continue; + + comp = cal_component_new (); + if (!cal_component_set_icalcomponent (comp, icalcomp)) { + icalcomponent_free (icalcomp); + gtk_object_unref (GTK_OBJECT (comp)); + continue; + } + + alarms = g_new (CalComponentAlarms, 1); + alarms->comp = comp; + alarms->alarms = build_alarm_instance_list (comp, &corba_alarms->alarms); - list = g_list_prepend (list, ai); + comp_alarms = g_slist_prepend (comp_alarms, alarms); } - list = g_list_reverse (list); - return list; + return comp_alarms; } /** @@ -1226,15 +1246,16 @@ build_alarm_instance_list (GNOME_Evolution_Calendar_CalAlarmInstanceSeq *seq) * Queries a calendar for the alarms that trigger in the specified range of * time. * - * Return value: A list of #CalAlarmInstance structures. + * Return value: A list of #CalComponentAlarms structures. This should be freed + * using the cal_client_free_alarms() function. **/ -GList * +GSList * cal_client_get_alarms_in_range (CalClient *client, time_t start, time_t end) { CalClientPrivate *priv; CORBA_Environment ev; - GNOME_Evolution_Calendar_CalAlarmInstanceSeq *seq; - GList *alarms; + GNOME_Evolution_Calendar_CalComponentAlarmsSeq *seq; + GSList *alarms; g_return_val_if_fail (client != NULL, NULL); g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); @@ -1255,7 +1276,7 @@ cal_client_get_alarms_in_range (CalClient *client, time_t start, time_t end) } CORBA_exception_free (&ev); - alarms = build_alarm_instance_list (seq); + alarms = build_component_alarms_list (seq); CORBA_free (seq); return alarms; @@ -1264,10 +1285,11 @@ 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. + * @uid: Unique identifier for a calendar component. * @start: Start time for query. * @end: End time for query. - * @alarms: Return value for the list of alarm instances. + * @alarms: Return value for the component's alarm instances. Will return NULL + * if no instances occur within the specified time range. * * Queries a calendar for the alarms of a particular object that trigger in the * specified range of time. @@ -1277,12 +1299,14 @@ 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) + CalComponentAlarms **alarms) { CalClientPrivate *priv; CORBA_Environment ev; - GNOME_Evolution_Calendar_CalAlarmInstanceSeq *seq; + GNOME_Evolution_Calendar_CalComponentAlarms *corba_alarms; gboolean retval; + icalcomponent *icalcomp; + CalComponent *comp; g_return_val_if_fail (client != NULL, FALSE); g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); @@ -1300,7 +1324,8 @@ cal_client_get_alarms_for_object (CalClient *client, const char *uid, CORBA_exception_init (&ev); - seq = GNOME_Evolution_Calendar_Cal_getAlarmsForObject (priv->cal, (char *) uid, start, end, &ev); + corba_alarms = GNOME_Evolution_Calendar_Cal_getAlarmsForObject (priv->cal, (char *) uid, + start, end, &ev); if (ev._major == CORBA_USER_EXCEPTION && strcmp (CORBA_exception_id (&ev), ex_GNOME_Evolution_Calendar_Cal_NotFound) == 0) goto out; @@ -1309,14 +1334,27 @@ cal_client_get_alarms_for_object (CalClient *client, const char *uid, goto out; } + icalcomp = icalparser_parse_string (corba_alarms->calobj); + if (!icalcomp) + goto out; + + comp = cal_component_new (); + if (!cal_component_set_icalcomponent (comp, icalcomp)) { + icalcomponent_free (icalcomp); + gtk_object_unref (GTK_OBJECT (comp)); + goto out; + } + retval = TRUE; - *alarms = build_alarm_instance_list (seq); - CORBA_free (seq); + + *alarms = g_new (CalComponentAlarms, 1); + (*alarms)->comp = comp; + (*alarms)->alarms = build_alarm_instance_list (comp, &corba_alarms->alarms); + CORBA_free (corba_alarms); out: CORBA_exception_free (&ev); return retval; - } /** |