6 * Copyright (C) 2010 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 */
26 struct sipe_core_private
;
29 /* Calendar statuses */
30 #define SIPE_CAL_FREE 0
31 #define SIPE_CAL_TENTATIVE 1
32 #define SIPE_CAL_BUSY 2
33 #define SIPE_CAL_OOF 3
34 #define SIPE_CAL_NO_DATA 4
36 /* Default granularity of FreeBusy data is 15 minutes */
37 #define SIPE_FREE_BUSY_GRANULARITY_SEC (15*60)
38 /* FreeBusy stream duration in seconds. Defaults to 4 days */
39 #define SIPE_FREE_BUSY_PERIOD_SEC (4*(24*60*60))
41 struct sipe_cal_event
{
51 /** For extracting our Calendar information from
52 * external sources like Exchange, Lotus Domino.
54 struct sipe_calendar
{
55 struct sipe_core_private
*sipe_private
;
61 int auto_disco_method
;
63 int is_domino_disabled
;
71 char *oof_state
; /* Enabled, Disabled, Scheduled */
78 HttpSession
*http_session
;
84 char *working_hours_xml_str
;
89 sipe_cal_event_free(struct sipe_cal_event
* cal_event
);
92 sipe_cal_events_free(GSList
*cal_events
);
95 sipe_cal_calendar_free(struct sipe_calendar
*cal
);
98 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.
107 sipe_cal_event_hash(struct sipe_cal_event
* event
);
110 * Describes Calendar event in human readable form.
112 * Must be g_free()'d after use.
115 sipe_cal_event_describe(struct sipe_cal_event
* cal_event
);
118 * Converts struct tm to Epoch time_t considering timezone.
120 * @param tz as defined for TZ environment variable.
122 * Reference: see timegm(3) - Linux man page
125 sipe_mktime_tz(struct tm
*tm
,
129 * Converts hex representation of freebusy string as
130 * returned by Exchange Web Services to
131 * condenced and base64 encoded form
133 * Must be g_free()'d after use.
136 sipe_cal_get_freebusy_base64(const char* freebusy_hex
);
138 /** Contains buddy's working hours information */
139 struct sipe_cal_working_hours
;
142 * Parses Working Hours from passed XML piece
143 * and creates/fills struct sipe_cal_working_hours in struct sipe_buddy
146 sipe_cal_parse_working_hours(const struct _sipe_xml
*xn_working_hours
,
147 struct sipe_buddy
*buddy
);
150 * Frees struct sipe_cal_working_hours
153 sipe_cal_free_working_hours(struct sipe_cal_working_hours
*wh
);
156 * Returns user calendar information in text form.
157 * Example: "Currently Busy. Free at 13:00"
160 sipe_cal_get_description(struct sipe_buddy
*buddy
);
163 * Returns calendar status SIPE_CAL_* at time specified.
164 * Returns SIPE_CAL_NO_DATA if no calendar data availible.
166 * @param since (out) Returns beginning time of the status.
169 sipe_cal_get_status(struct sipe_buddy
*buddy
,
170 time_t time_in_question
,
174 * Returns calendar event at time in question.
175 * If conflict, takes last event in the following
176 * priority order: OOF, Busy, Tentative.
178 struct sipe_cal_event
*
179 sipe_cal_get_event(GSList
*cal_events
,
180 time_t time_in_question
);