purple: work around broken dbus-server.h
[siplcs.git] / src / core / sipe-cal.h
blobabf2d3e326cfc74f33703af695c5a934ffe8ddaa
1 /**
2 * @file sipe-cal.h
4 * pidgin-sipe
6 * Copyright (C) 2010-2015 SIPE Project <http://sipe.sourceforge.net/>
7 * Copyright (C) 2009 pier11 <pier11@operamail.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 /* Forward declarations */
25 struct sipe_buddy;
26 struct sipe_core_private;
27 struct sipe_http_request;
28 struct sipe_http_session;
29 struct _sipe_xml;
31 /* Calendar statuses */
32 #define SIPE_CAL_FREE 0
33 #define SIPE_CAL_TENTATIVE 1
34 #define SIPE_CAL_BUSY 2
35 #define SIPE_CAL_OOF 3
36 #define SIPE_CAL_NO_DATA 4
38 /* Default granularity of FreeBusy data is 15 minutes */
39 #define SIPE_FREE_BUSY_GRANULARITY_SEC (15*60)
40 /* FreeBusy stream duration in seconds. Defaults to 4 days */
41 #define SIPE_FREE_BUSY_PERIOD_SEC (4*(24*60*60))
43 struct sipe_cal_event {
44 time_t start_time;
45 time_t end_time;
46 /* SIPE_CAL_* */
47 int cal_status;
48 char *subject;
49 char *location;
50 int is_meeting;
53 /** For extracting our Calendar information from
54 * external sources like Exchange, Lotus Domino.
56 struct sipe_calendar {
57 struct sipe_core_private *sipe_private;
59 int state;
60 char *email;
61 char *legacy_dn;
62 int is_ews_disabled;
63 int is_domino_disabled;
64 int is_updated;
65 gboolean retry;
67 char *as_url;
68 char *oof_url;
69 char *oab_url;
70 char *domino_url;
72 char *oof_state; /* Enabled, Disabled, Scheduled */
73 char *oof_note;
74 time_t oof_start;
75 time_t oof_end;
76 time_t updated;
77 gboolean published;
79 struct sipe_http_session *session;
80 struct sipe_http_request *request;
82 time_t fb_start;
83 /* hex form */
84 char *free_busy;
85 char *working_hours_xml_str;
86 GSList *cal_events;
89 void
90 sipe_cal_event_free(struct sipe_cal_event* cal_event);
92 void
93 sipe_cal_events_free(GSList *cal_events);
95 void
96 sipe_cal_calendar_free(struct sipe_calendar *cal);
98 void
99 sipe_cal_calendar_init(struct sipe_core_private *sipe_private);
102 * Returns hash of Calendar Event for comparison.
104 * Must be g_free()'d after use.
106 char *
107 sipe_cal_event_hash(struct sipe_cal_event* event);
110 * Dump calendar event in human readable form to debug log.
112 void
113 sipe_cal_event_debug(const struct sipe_cal_event *cal_event,
114 const gchar *label);
117 * Converts struct tm to Epoch time_t considering timezone.
119 * @param tz as defined for TZ environment variable.
121 * Reference: see timegm(3) - Linux man page
123 time_t
124 sipe_mktime_tz(struct tm *tm,
125 const char* tz);
128 * Converts hex representation of freebusy string as
129 * returned by Exchange Web Services to
130 * condenced and base64 encoded form
132 * Must be g_free()'d after use.
134 char *
135 sipe_cal_get_freebusy_base64(const char* freebusy_hex);
137 /** Contains buddy's working hours information */
138 struct sipe_cal_working_hours;
141 * Parses Working Hours from passed XML piece
142 * and creates/fills struct sipe_cal_working_hours in struct sipe_buddy
144 void
145 sipe_cal_parse_working_hours(const struct _sipe_xml *xn_working_hours,
146 struct sipe_buddy *buddy);
149 * Frees struct sipe_cal_working_hours
151 void
152 sipe_cal_free_working_hours(struct sipe_cal_working_hours *wh);
155 * Returns user calendar information in text form.
156 * Example: "Currently Busy. Free at 13:00"
158 char *
159 sipe_cal_get_description(struct sipe_buddy *buddy);
162 * Returns calendar status SIPE_CAL_* at time specified.
163 * Returns SIPE_CAL_NO_DATA if no calendar data availible.
165 * @param since (out) Returns beginning time of the status.
168 sipe_cal_get_status(struct sipe_buddy *buddy,
169 time_t time_in_question,
170 time_t *since);
173 * Returns calendar event at time in question.
174 * If conflict, takes last event in the following
175 * priority order: OOF, Busy, Tentative.
177 struct sipe_cal_event*
178 sipe_cal_get_event(GSList *cal_events,
179 time_t time_in_question);
182 * Publish presence information
184 void sipe_cal_presence_publish(struct sipe_core_private *sipe_private,
185 gboolean do_publish_calendar);
188 * Schedule calendar update
190 void sipe_cal_delayed_calendar_update(struct sipe_core_private *sipe_private);