6 * Copyright (C) 2009 SIPE Project <http://sipe.sourceforge.net/>
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 /* Our publication type keys. OCS 2007+
24 * Format: SIPE_PUB_{Category}[_{SubSategory}]
31 * Unique to the device.
33 #define SIPE_PUB_DEVICE 0
38 * Availability, activity, end-point location, time zone, and device type.
39 * First hexadecimal digit is 0x3; remaining seven hexadecimal digits are unique per device.
41 #define SIPE_PUB_STATE_MACHINE 3
46 * Availability and activity.
49 #define SIPE_PUB_STATE_USER 2
54 * Availability, activity, meeting subject, and meeting location.
55 * First hexadecimal digit is 0x4; remaining seven hexadecimal digits are unique per device.
57 #define SIPE_PUB_STATE_CALENDAR 4
60 * Calendar state for an Out of Office meeting
62 * (??)Activity for when a user sets or removes an Out of Office message in Exchange.
63 * (+)user sets in Outlook for an Out of Office meeting
64 * First hexadecimal digit is 0x5; remaining seven hexadecimal digits are unique per device.
66 #define SIPE_PUB_STATE_CALENDAR_OOF 5
71 * Availability and activity for RCC call connect/disconnect or participant count changes from 0 to 2, 2 to N, N to 2, 2 to 0.
72 * First hexadecimal digit is 0x7; remaining seven hexadecimal digits are unique per device.
74 #define SIPE_PUB_STATE_PHONE 7
79 * Start time, granularity, and free/busy data.
80 * First hexadecimal digit is 0x4; last seven hexadecimal digits uniquely define the calendar.
82 #define SIPE_PUB_CALENDAR_DATA 400
87 * Out of Office note that a user sets in Outlook using the Out of Office assistant.
88 * First hexadecimal digit is 0x4; last seven hexadecimal digits uniquely define the calendar.
90 #define SIPE_PUB_NOTE_OOF 400
97 get_epid(struct sipe_account_data
*sip
);
102 * @return Call ID. Must be g_free()'d.
104 gchar
*gencallid(void);
109 * @return Tag. Must be g_free()'d.
114 * Generate conference-id
115 * 32 characters long. Value space is restricted to printable ASCII characters
117 * Ex.: 8386E6AEAAA41E4AA6627BA76D43B6D1
119 * @return conference-id. Must be g_free()'d.
121 gchar
*genconfid(void);
124 * Returns instance value for particular publication type.
125 * It should be consistent for the same endpoint
126 * but different between distinct endpoints.
128 * See defined constants for keys patterned SIPE_PUB_*
131 sipe_get_pub_instance(struct sipe_account_data
*sip
,
132 int publication_key
);
135 * Get contact information from SIPE account
137 * @param sip (in) SIPE account
139 * @return Contact. Must be g_free()'d.
141 gchar
*get_contact(const struct sipe_account_data
*sip
);
144 * Parses URI from SIP header
146 * @param hdr (in) To/From header
148 * @return URI with sip: prefix. Must be g_free()'d.
150 gchar
*parse_from(const gchar
*hdr
);
153 * Parses CSeq from SIP header
155 * @param hdr (in) CSeqm header
157 * @return int type CSeq value (i.e. without method).
159 int parse_cseq(const gchar
*hdr
);
162 * Create sip: URI from name
166 * @return URI with sip: prefix. Must be g_free()'d.
168 gchar
*sip_uri_from_name(const gchar
*name
);
171 * Create sip: URI from SIP account user name
173 * @param sip (in) SIP account data
175 * @return URI with sip: prefix. Must be g_free()'d.
177 #define sip_uri_self(sip) (sip_uri_from_name(sip->username))
180 * Create sip: URI from name or sip: URI
182 * @param string (in) name or sip: URI
184 * @return URI with sip: prefix. Must be g_free()'d.
186 gchar
*sip_uri(const gchar
*string
);
189 * Tries to figure out if contact alias which stored locally
190 * is just SIP URI, not a proper display name or local alias.
192 * @param uri SIP URI with 'sip:' prefix.
193 * @param alias as returned by purple.
196 sipe_is_bad_alias(const char *uri
,
200 * Find a XML node from the parent with the specified path
202 * @param parent (in) XML node to start search from
203 * @param ... (in) Names of the descendant nodes
205 * @return descendant XML node
207 xmlnode
* xmlnode_get_descendant(const xmlnode
*parent
, ...);
210 * Convert a XML attribute to an integer
211 * @param node (in) XML node
212 * @param attr (in) name of the attribute
213 * @param fallback (in) default value if the attribute doesn't exist
215 * @return attribute value converted to integer or the fallback value
217 gint
xmlnode_get_int_attrib(xmlnode
*node
,
222 * For glib < 2.8 compatibility
224 char *sipe_get_host_name(void);
227 * Checks if provided string is empty - NULL, zero size or just series of white spaces.
228 * Doesn't modify input string.
231 is_empty(const char *st
);
233 /** Returns newly allocated string. Must be g_free()'d */
235 replace(const char *st
,
237 const char *replace
);
240 * Replaces \r\n to \n
241 * Returns newly allocated string. Must be g_free()'d
244 fix_newlines(const char *st
);
247 * Tests two strings for equality.
249 * Unlike strcmp(), this function will not crash if one or both of the
250 * strings are @c NULL.
252 * Same as purple_strequal (defined only for 2.6) to maintain
253 * our backward compatibility.
255 * @param left A string
256 * @param right A string to compare with left
258 * @return @c TRUE if the strings are the same, else @c FALSE.
261 gboolean
sipe_strequal(const gchar
*left
, const gchar
*right
);
264 * Parses a timestamp in ISO8601 format and returns a time_t.
265 * Assumes UTC if no timezone specified
267 * @param timestamp The timestamp
270 sipe_utils_str_to_time(const char *timestamp
);
273 * Converts time_t to ISO8601 string.
276 * Must be g_free()'d after use.
278 * Example: 2010-02-03T23:59:59Z
281 sipe_utils_time_to_str(time_t timestamp
);
289 * Creates name-value pairs from given lines and appends them to @c list
291 * Lines must be in format 'name: value'
293 * @param list a list of @c sipnameval structures
294 * @param lines array of strings in format 'name: value'
296 * @return @c FALSE if any of @c lines has incorrect format, @c TRUE otherwise
299 sipe_utils_parse_lines(GSList
**list
, gchar
**lines
);
302 * Adds a name-value pair to @c list
304 * @param list a list of @c sipnameval structures
305 * @param name attribute's name
306 * @param value value of attribute @c name
308 * @return the new start of the GSList
311 sipe_utils_nameval_add(GSList
*list
, const gchar
*name
, const gchar
*value
);
314 * Finds a value of attribute @c name in @c list
316 * @param list a list of @c sipnameval structures
317 * @param name attribute to find
319 * @return value of @c name or NULL if @c name is not found
322 sipe_utils_nameval_find(const GSList
*list
, const gchar
*name
);
325 * Returns @c which occurrence of attribute @c name in @c list
327 * @c which is zero based, so 0 means first occurrence of @c name in @c list.
329 * @param list a list of @c sipnameval structures
330 * @param name attribute to find
331 * @param which specifies occurrence of @name in @c list
333 * @return value of @c name or NULL if @c name is not found
336 sipe_utils_nameval_find_instance(const GSList
*list
, const gchar
*name
, int which
);
339 * Frees memory allocated by @c list
341 * @param list a list of @c sipnameval structures
344 sipe_utils_nameval_free(GSList
*list
);