Merge branch 'mob' of git+ssh://localhost/srv/git/siplcs into mob
[siplcs.git] / src / core / sipe-cal.h
blob4362ab99a062376a39dbf7fd023216f922d1b633
1 /**
2 * @file sipe-cal.h
4 * pidgin-sipe
6 * Copyright (C) 2009 pier11 <pier11@operamail.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "xmlnode.h"
25 /* Calendar statuses */
26 #define SIPE_CAL_FREE 0
27 #define SIPE_CAL_TENTATIVE 1
28 #define SIPE_CAL_BUSY 2
29 #define SIPE_CAL_OOF 3
30 #define SIPE_CAL_NO_DATA 4
32 struct sipe_cal_event {
33 time_t start_time;
34 time_t end_time;
35 /* SIPE_CAL_* */
36 int cal_status;
37 char *subject;
38 char *location;
39 int is_meeting;
42 void
43 sipe_cal_event_free(struct sipe_cal_event* cal_event);
45 /**
46 * Returns hash of Calendar Event for comparison.
48 * Must be g_free()'d after use.
50 char *
51 sipe_cal_event_hash(struct sipe_cal_event* event);
53 /**
54 * Describes Calendar event in human readable form.
56 * Must be g_free()'d after use.
58 char *
59 sipe_cal_event_describe(struct sipe_cal_event* cal_event);
61 /**
62 * Converts struct tm to Epoch time_t considering timezone.
64 * @param tz as defined for TZ environment variable.
66 * Reference: see timegm(3) - Linux man page
68 time_t
69 sipe_mktime_tz(struct tm *tm,
70 const char* tz);
72 /**
73 * Converts hex representation of freebusy string as
74 * returned by Exchange Web Services to
75 * condenced and base64 encoded form
77 * Must be g_free()'d after use.
78 */
79 char *
80 sipe_cal_get_freebusy_base64(const char* freebusy_hex);
82 /** Contains buddy's working hours information */
83 struct sipe_cal_working_hours;
85 /**
86 * Parses Working Hours from passed XML piece
87 * and creates/fills struct sipe_cal_working_hours in struct sipe_buddy
89 void
90 sipe_cal_parse_working_hours(xmlnode *xn_working_hours,
91 struct sipe_buddy *buddy);
93 /**
94 * Frees struct sipe_cal_working_hours
96 void
97 sipe_cal_free_working_hours(struct sipe_cal_working_hours *wh);
99 /**
100 * Returns user calendar information in text form.
101 * Example: "Currently Busy. Free at 13:00"
103 char *
104 sipe_cal_get_description(struct sipe_buddy *buddy);
107 * Returns calendar status SIPE_CAL_* at time specified.
108 * Returns SIPE_CAL_NO_DATA if no calendar data availible.
110 * @param since (out) Returns beginning time of the status.
113 sipe_cal_get_status(struct sipe_buddy *buddy,
114 time_t time_in_question,
115 time_t *since);
118 * Returns calendar event at time in question.
119 * If conflict, takes last event in the following
120 * priority order: OOF, Busy, Tentative.
122 struct sipe_cal_event*
123 sipe_cal_get_event(GSList *cal_events,
124 time_t time_in_question);