buddy: fix use after free in process_buddy_photo_response()
[siplcs.git] / src / core / sipe-cal.h
blob92a5cd6f97b050458f107753842c835efcca109d
1 /**
2 * @file sipe-cal.h
4 * pidgin-sipe
6 * Copyright (C) 2010-11 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 http_conn_auth;
26 struct http_conn_struct;
27 struct http_session_struct;
28 struct sipe_buddy;
29 struct sipe_core_private;
30 struct _sipe_xml;
32 /* Calendar statuses */
33 #define SIPE_CAL_FREE 0
34 #define SIPE_CAL_TENTATIVE 1
35 #define SIPE_CAL_BUSY 2
36 #define SIPE_CAL_OOF 3
37 #define SIPE_CAL_NO_DATA 4
39 /* Default granularity of FreeBusy data is 15 minutes */
40 #define SIPE_FREE_BUSY_GRANULARITY_SEC (15*60)
41 /* FreeBusy stream duration in seconds. Defaults to 4 days */
42 #define SIPE_FREE_BUSY_PERIOD_SEC (4*(24*60*60))
44 struct sipe_cal_event {
45 time_t start_time;
46 time_t end_time;
47 /* SIPE_CAL_* */
48 int cal_status;
49 char *subject;
50 char *location;
51 int is_meeting;
54 /** For extracting our Calendar information from
55 * external sources like Exchange, Lotus Domino.
57 struct sipe_calendar {
58 struct sipe_core_private *sipe_private;
60 int state;
61 char *email;
62 char *legacy_dn;
63 struct http_conn_auth *auth;
64 int auto_disco_method;
65 int is_ews_disabled;
66 int is_domino_disabled;
67 int is_updated;
69 char *as_url;
70 char *oof_url;
71 char *oab_url;
72 char *domino_url;
74 char *oof_state; /* Enabled, Disabled, Scheduled */
75 char *oof_note;
76 time_t oof_start;
77 time_t oof_end;
78 time_t updated;
79 gboolean published;
81 struct http_session_struct *http_session;
82 struct http_conn_struct *http_conn;
84 time_t fb_start;
85 /* hex form */
86 char *free_busy;
87 char *working_hours_xml_str;
88 GSList *cal_events;
91 void
92 sipe_cal_event_free(struct sipe_cal_event* cal_event);
94 void
95 sipe_cal_events_free(GSList *cal_events);
97 void
98 sipe_cal_calendar_free(struct sipe_calendar *cal);
100 gboolean
101 sipe_cal_calendar_init(struct sipe_core_private *sipe_private,
102 gboolean *has_url);
105 * Returns hash of Calendar Event for comparison.
107 * Must be g_free()'d after use.
109 char *
110 sipe_cal_event_hash(struct sipe_cal_event* event);
113 * Describes Calendar event in human readable form.
115 * Must be g_free()'d after use.
117 char *
118 sipe_cal_event_describe(struct sipe_cal_event* cal_event);
121 * Converts struct tm to Epoch time_t considering timezone.
123 * @param tz as defined for TZ environment variable.
125 * Reference: see timegm(3) - Linux man page
127 time_t
128 sipe_mktime_tz(struct tm *tm,
129 const char* tz);
132 * Converts hex representation of freebusy string as
133 * returned by Exchange Web Services to
134 * condenced and base64 encoded form
136 * Must be g_free()'d after use.
138 char *
139 sipe_cal_get_freebusy_base64(const char* freebusy_hex);
141 /** Contains buddy's working hours information */
142 struct sipe_cal_working_hours;
145 * Parses Working Hours from passed XML piece
146 * and creates/fills struct sipe_cal_working_hours in struct sipe_buddy
148 void
149 sipe_cal_parse_working_hours(const struct _sipe_xml *xn_working_hours,
150 struct sipe_buddy *buddy);
153 * Frees struct sipe_cal_working_hours
155 void
156 sipe_cal_free_working_hours(struct sipe_cal_working_hours *wh);
159 * Returns user calendar information in text form.
160 * Example: "Currently Busy. Free at 13:00"
162 char *
163 sipe_cal_get_description(struct sipe_buddy *buddy);
166 * Returns calendar status SIPE_CAL_* at time specified.
167 * Returns SIPE_CAL_NO_DATA if no calendar data availible.
169 * @param since (out) Returns beginning time of the status.
172 sipe_cal_get_status(struct sipe_buddy *buddy,
173 time_t time_in_question,
174 time_t *since);
177 * Returns calendar event at time in question.
178 * If conflict, takes last event in the following
179 * priority order: OOF, Busy, Tentative.
181 struct sipe_cal_event*
182 sipe_cal_get_event(GSList *cal_events,
183 time_t time_in_question);
186 * Publish presence information
188 void sipe_cal_presence_publish(struct sipe_core_private *sipe_private,
189 gboolean do_publish_calendar);
192 * Schedule calendar update
194 void sipe_cal_delayed_calendar_update(struct sipe_core_private *sipe_private);