Coding style and whitespace cleanup.
[platform/upstream/evolution-data-server.git] / calendar / libecal / e-cal-util.h
1 /* Evolution calendar utilities and types
2  *
3  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
4  *
5  * Author: Federico Mena-Quintero <federico@ximian.com>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of version 2 of the GNU Lesser General Public
9  * License as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20
21 #ifndef E_CAL_UTIL_H
22 #define E_CAL_UTIL_H
23
24 #include <libical/ical.h>
25 #include <time.h>
26 #include <glib.h>
27 #include <libecal/e-cal-component.h>
28 #include <libecal/e-cal-recur.h>
29
30 G_BEGIN_DECLS
31
32 \f
33
34 /* Instance of a calendar object.  This can be an actual occurrence, a
35  * recurrence, or an alarm trigger of a `real' calendar object.
36  */
37 typedef struct {
38         gchar *uid;                     /* UID of the object */
39         time_t start;                   /* Start time of instance */
40         time_t end;                     /* End time of instance */
41 } CalObjInstance;
42
43 void cal_obj_instance_list_free (GList *list);
44
45 /* Used for modifying objects */
46 typedef enum {
47         CALOBJ_MOD_THIS          = 1 << 0,
48         CALOBJ_MOD_THISANDPRIOR  = 1 << 1,
49         CALOBJ_MOD_THISANDFUTURE = 1 << 2,
50         CALOBJ_MOD_ALL           = 0x07
51 } CalObjModType;
52
53 /* Used for mode stuff */
54 typedef enum {
55         CAL_MODE_INVALID = -1,
56         CAL_MODE_LOCAL   = 1 << 0,
57         CAL_MODE_REMOTE  = 1 << 1,
58         CAL_MODE_ANY     = 0x07
59 } CalMode;
60
61 #define cal_mode_to_corba(mode) \
62         (mode == CAL_MODE_LOCAL   ? GNOME_Evolution_Calendar_MODE_LOCAL  : \
63          mode == CAL_MODE_REMOTE  ? GNOME_Evolution_Calendar_MODE_REMOTE : \
64          GNOME_Evolution_Calendar_MODE_ANY)
65
66 void cal_obj_uid_list_free (GList *list);
67
68 icalcomponent *e_cal_util_new_top_level (void);
69 icalcomponent *e_cal_util_new_component (icalcomponent_kind kind);
70
71 icalcomponent *e_cal_util_parse_ics_string (const gchar *string);
72 icalcomponent *e_cal_util_parse_ics_file (const gchar *filename);
73
74 ECalComponentAlarms *e_cal_util_generate_alarms_for_comp (ECalComponent *comp,
75                                                        time_t start,
76                                                        time_t end,
77                                                        ECalComponentAlarmAction *omit,
78                                                        ECalRecurResolveTimezoneFn resolve_tzid,
79                                                        gpointer user_data,
80                                                        icaltimezone *default_timezone);
81 gint e_cal_util_generate_alarms_for_list (GList *comps,
82                                        time_t start,
83                                        time_t end,
84                                        ECalComponentAlarmAction *omit,
85                                        GSList **comp_alarms,
86                                        ECalRecurResolveTimezoneFn resolve_tzid,
87                                        gpointer user_data,
88                                        icaltimezone *default_timezone);
89
90 const gchar *e_cal_util_priority_to_string (gint priority);
91 gint e_cal_util_priority_from_string (const gchar *string);
92
93 void e_cal_util_add_timezones_from_component (icalcomponent *vcal_comp,
94                                             icalcomponent *icalcomp);
95
96 gboolean e_cal_util_component_is_instance (icalcomponent *icalcomp);
97 gboolean e_cal_util_component_has_alarms (icalcomponent *icalcomp);
98 gboolean e_cal_util_component_has_organizer (icalcomponent *icalcomp);
99 gboolean e_cal_util_component_has_recurrences (icalcomponent *icalcomp);
100 gboolean e_cal_util_component_has_rdates (icalcomponent *icalcomp);
101 gboolean e_cal_util_component_has_rrules (icalcomponent *icalcomp);
102 gboolean e_cal_util_component_has_attendee (icalcomponent *icalcomp);
103 gboolean e_cal_util_event_dates_match (icalcomponent *icalcomp1, icalcomponent *icalcomp2);
104 /* The static capabilities to be supported by backends */
105 #define CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT             "no-alarm-repeat"
106 #define CAL_STATIC_CAPABILITY_NO_AUDIO_ALARMS             "no-audio-alarms"
107 #define CAL_STATIC_CAPABILITY_NO_DISPLAY_ALARMS           "no-display-alarms"
108 #define CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS             "no-email-alarms"
109 #define CAL_STATIC_CAPABILITY_NO_PROCEDURE_ALARMS         "no-procedure-alarms"
110 #define CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT          "no-task-assignment"
111 #define CAL_STATIC_CAPABILITY_NO_THISANDFUTURE            "no-thisandfuture"
112 #define CAL_STATIC_CAPABILITY_NO_THISANDPRIOR             "no-thisandprior"
113 #define CAL_STATIC_CAPABILITY_NO_TRANSPARENCY             "no-transparency"
114 #define CAL_STATIC_CAPABILITY_ONE_ALARM_ONLY              "one-alarm-only"
115 #define CAL_STATIC_CAPABILITY_ORGANIZER_MUST_ATTEND       "organizer-must-attend"
116 #define CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS "organizer-not-email-address"
117 #define CAL_STATIC_CAPABILITY_REMOVE_ALARMS               "remove-alarms"
118 #define CAL_STATIC_CAPABILITY_CREATE_MESSAGES             "create-messages"
119 #define CAL_STATIC_CAPABILITY_SAVE_SCHEDULES              "save-schedules"
120 #define CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK      "no-conv-to-assign-task"
121 #define CAL_STATIC_CAPABILITY_NO_CONV_TO_RECUR            "no-conv-to-recur"
122 #define CAL_STATIC_CAPABILITY_NO_GEN_OPTIONS              "no-general-options"
123 #define CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS            "require-send-options"
124 #define CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER       "recurrences-no-master-object"
125 #define CAL_STATIC_CAPABILITY_ORGANIZER_MUST_ACCEPT      "organizer-must-accept"
126 #define CAL_STATIC_CAPABILITY_DELEGATE_SUPPORTED         "delegate-support"
127 #define CAL_STATIC_CAPABILITY_NO_ORGANIZER               "no-organizer"
128 #define CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY           "delegate-to-many"
129 #define CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING     "has-unaccepted-meeting"
130 #define CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED         "refresh-supported"
131
132 /* Recurrent events. Management for instances */
133 icalcomponent *e_cal_util_construct_instance (icalcomponent *icalcomp,
134                                             struct icaltimetype rid);
135 void           e_cal_util_remove_instances (icalcomponent *icalcomp,
136                                           struct icaltimetype rid,
137                                           CalObjModType mod);
138
139 gchar *e_cal_util_get_system_timezone_location (void);
140 icaltimezone *e_cal_util_get_system_timezone (void);
141
142 G_END_DECLS
143
144 #endif