core cleanup: introduce data structures for backend transport API
[siplcs.git] / src / core / sipe.h
blob45975ab27f47ceba92c6028b9ec5fb81962190f8
1 /**
2 * @file sipe.h
4 * pidgin-sipe
6 * Copyright (C) 2010 SIPE Project <http://sipe.sourceforge.net/>
7 * Copyright (C) 2008 Novell, Inc.
8 * Copyright (C) 2007 Anibal Avelar <avelar@gmail.com>
9 * Copyright (C) 2005 Thomas Butter <butter@uni-mannheim.de>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 * Interface dependencies:
29 * <time.h>
30 * <glib.h>
31 * "sip-sec.h"
34 /* Forward declarations */
35 struct sipmsg;
36 struct _PurpleAccount;
37 struct _PurpleCircBuffer;
38 struct _PurpleConnection;
39 struct _PurpleDnsQueryData;
40 struct _PurpleGroup;
41 struct _PurpleNetworkListenData;
42 struct _PurplePlugin;
43 struct _PurpleSrvQueryData;
44 struct _PurpleSslConnection;
45 struct sip_sec_context;
46 struct sipe_core_private;
47 struct sipe_service_data;
49 #define SIMPLE_BUF_INC 4096
51 #define SIPE_TYPING_RECV_TIMEOUT 6
52 #define SIPE_TYPING_SEND_TIMEOUT 4
54 struct sip_auth {
55 guint type;
56 struct sip_sec_context *gssapi_context;
57 gchar *gssapi_data;
58 gchar *opaque;
59 gchar *realm;
60 gchar *target;
61 int version;
62 int nc;
63 int retries;
64 int ntlm_num;
65 int expires;
68 /** MS-PRES publication */
69 struct sipe_publication {
70 gchar *category;
71 guint instance;
72 guint container;
73 guint version;
74 /** for 'state' category */
75 int availability;
76 /** for 'state:calendarState' category */
77 char *cal_event_hash;
78 /** for 'note' category */
79 gchar *note;
80 /** for 'calendarData' category; 300(Team) container */
81 char *working_hours_xml_str;
82 char *fb_start_str;
83 char *free_busy_base64;
86 /** MS-PRES container */
87 struct sipe_container {
88 guint id;
89 guint version;
90 GSList *members;
92 /** MS-PRES container member */
93 struct sipe_container_member {
94 /** user, domain, sameEnterprise, federated, publicCloud; everyone */
95 gchar *type;
96 gchar *value;
99 struct sip_connection {
100 gchar *inbuf;
101 int inbuflen;
102 int inbufused;
103 int inputhandler;
106 struct sipe_account_data {
107 /* back pointer to new data structure */
108 struct sipe_core_public *public;
109 /* same, but reduces need for casting and increases type safety */
110 struct sipe_core_private *private;
112 struct _PurpleConnection *gc;
113 gchar *username;
114 gchar *authdomain;
115 gchar *authuser;
116 gchar *password;
117 gchar *epid;
118 gchar *focus_factory_uri;
119 /** Allowed server events to subscribe. From register OK response. */
120 GSList *allow_events;
121 struct _PurpleSrvQueryData *srv_query_data;
122 const struct sipe_service_data *service_data;
123 int cseq;
124 int registerstatus; /* 0 nothing, 1 first registration send, 2 auth received, 3 registered */
125 struct sip_auth registrar;
126 struct sip_auth proxy;
127 struct sip_csta *csta; /* For RCC - Remote Call Control */
128 gboolean reregister_set; /* whether reregister timer set */
129 gboolean reauthenticate_set; /* whether reauthenticate timer set */
130 gboolean subscribed; /* whether subscribed to events, except buddies presence */
131 gboolean subscribed_buddies; /* whether subscribed to buddies presence */
132 gboolean access_level_set; /* whether basic access level set */
133 gboolean initial_state_published; /* whether we published our initial state */
134 GSList *our_publication_keys; /* [MS-PRES] */
135 GHashTable *our_publications; /* [MS-PRES] */
136 GHashTable *user_state_publications; /* [MS-PRES] */
137 GHashTable *subscriptions;
138 int contacts_delta;
139 int acl_delta;
140 int presence_method_version;
141 time_t do_not_publish[SIPE_ACTIVITY_NUM_TYPES];
142 gchar *status;
143 gboolean is_oof_note;
144 gchar *note;
145 time_t note_since;
146 time_t idle_switch;
147 gchar *contact;
148 gchar *server_version;
149 gboolean ocs2007; /*if there is support for batched category subscription [SIP-PRES]*/
150 gboolean batched_support; /*if there is support for batched subscription*/
151 GSList *containers; /* MS-PRES containers */
152 guint keepalive_timeout;
153 struct _PurpleAccount *account;
154 gchar *regcallid;
155 GSList *transactions;
156 GSList *sessions;
157 GSList *groups;
158 GHashTable *filetransfers;
159 gboolean auto_transport;
160 /* gchar *realhostname; */
161 int realport; /* port and hostname from SRV record */
162 gboolean processing_input;
163 struct sipe_calendar *cal;
164 gchar *email;
165 /** 2005 Custom XML piece.
166 * Possibly set by other point of presence or just other client at earlier time.
167 * It should be preserved/modified, not overwritten. This implies subscription
168 * to self-contasct.
169 * This XML keeps OC2005:
170 * - User note
171 * - OOF flag
172 * - User status
174 gchar *user_states;
176 /* transport-related state. This will be moved to backend... */
177 /* struct sipe_transport_connection *transport; */
178 sipe_transport_type transport;
179 struct _PurpleSslConnection *gsc;
180 int fd;
181 int port; /* client port */
182 guint tx_handler;
183 struct _PurpleCircBuffer *txbuf;
184 struct sip_connection rx_conn;
185 time_t last_keepalive;
188 struct sipe_auth_job {
189 gchar * who;
190 struct sipe_account_data * sip;
193 struct transaction;
195 typedef gboolean (*TransCallback) (struct sipe_account_data *, struct sipmsg *, struct transaction *);
197 struct transaction_payload {
198 GDestroyNotify destroy;
199 void *data;
202 struct transaction {
203 time_t time;
204 int retries;
205 int transport; /* 0 = tcp, 1 = udp */
206 int fd;
207 /** Not yet perfect, but surely better then plain CSeq
208 * Format is: <Call-ID><CSeq>
209 * (RFC3261 17.2.3 for matching server transactions: Request-URI, To tag, From tag, Call-ID, CSeq, and top Via)
211 gchar *key;
212 struct sipmsg *msg;
213 TransCallback callback;
214 struct transaction_payload *payload;
217 typedef void (*Action) (struct sipe_core_private *, void *);
220 * Do schedule action for execution in the future.
221 * Non repetitive execution.
223 * @param name of action (will be copied)
224 * @param timeout in seconds
225 * @param action callback function
226 * @param destroy payload destroy function
227 * @param sipe_core_private
228 * @param payload callback data (can be NULL, otherwise caller must allocate memory)
230 void
231 sipe_schedule_action(const gchar *name,
232 int timeout,
233 Action action,
234 GDestroyNotify destroy,
235 struct sipe_core_private *sipe_private,
236 void *payload);
238 struct sipe_group {
239 gchar *name;
240 int id;
241 struct _PurpleGroup *purple_group;
244 struct group_user_context {
245 gchar * group_name;
246 gchar * user_name;
249 GSList * slist_insert_unique_sorted(GSList *list, gpointer data, GCompareFunc func);
252 * Publishes self status
253 * based on own calendar information,
254 * our Calendar information - FreeBusy, WorkingHours,
255 * OOF note.
257 * For 2007+
259 void
260 publish_calendar_status_self(struct sipe_core_private *sipe_private,
261 void *unused);
264 * For 2005-
266 void
267 send_presence_soap(struct sipe_account_data *sip,
268 gboolean do_publish_calendar);
271 * THE BIG SPLIT - temporary interfaces
273 * Previously private functions in sipe.c that are
274 * - waiting to be factored out to an appropriate module
275 * - are needed by the already created new modules
278 /* pier11:
280 * Since SIP (RFC3261) is extensible by its design,
281 * and MS specs prove just that (they all are defined as SIP extensions),
282 * it make sense to split functionality by extension (or close extension group).
283 * For example: conference, presence (MS-PRES), etc.
285 * This way our code will not be monolithic, but potentially _reusable_. May be
286 * a top of other SIP core, and/or other front-end (Telepathy framework?).
288 /* Forward declarations */
289 struct sip_session;
290 struct sip_dialog;
292 /* SIP send module? */
293 struct transaction *
294 send_sip_request(struct _PurpleConnection *gc, const gchar *method,
295 const gchar *url, const gchar *to, const gchar *addheaders,
296 const gchar *body, struct sip_dialog *dialog, TransCallback tc);
297 void
298 send_sip_response(struct _PurpleConnection *gc, struct sipmsg *msg, int code,
299 const char *text, const char *body);
300 void
301 sipe_invite(struct sipe_account_data *sip, struct sip_session *session,
302 const gchar *who, const gchar *msg_body, const gchar *msg_content_type,
303 const gchar *referred_by, const gboolean is_triggered);
304 /* ??? module */
305 gboolean process_subscribe_response(struct sipe_account_data *sip,
306 struct sipmsg *msg,
307 struct transaction *tc);
308 /* Chat module */
309 void
310 sipe_invite_to_chat(struct sipe_account_data *sip,
311 struct sip_session *session,
312 const gchar *who);
313 /* Session module? */
314 void
315 sipe_present_message_undelivered_err(struct sipe_account_data *sip,
316 struct sip_session *session,
317 int sip_error,
318 int sip_warning,
319 const gchar *who,
320 const gchar *message);
322 void
323 sipe_present_info(struct sipe_account_data *sip,
324 struct sip_session *session,
325 const gchar *message);
328 void
329 sipe_process_pending_invite_queue(struct sipe_account_data *sip,
330 struct sip_session *session);
332 void
333 sipe_im_process_queue (struct sipe_account_data * sip, struct sip_session * session);
336 /*** THE BIG SPLIT END ***/
338 #define SIPE_INVITE_TEXT "ms-text-format: %s; charset=UTF-8%s;ms-body=%s\r\n"
340 #define SIPE_SEND_TYPING \
341 "<?xml version=\"1.0\"?>"\
342 "<KeyboardActivity>"\
343 "<status status=\"type\" />"\
344 "</KeyboardActivity>"
347 * Publishes categories.
348 * @param uri (%s) Self URI. Ex.: sip:alice7@boston.local
349 * @param publications (%s) XML publications
351 #define SIPE_SEND_PRESENCE \
352 "<publish xmlns=\"http://schemas.microsoft.com/2006/09/sip/rich-presence\">"\
353 "<publications uri=\"%s\">"\
354 "%s"\
355 "</publications>"\
356 "</publish>"
359 * Publishes 'device' category.
360 * @param instance (%u) Ex.: 1938468728
361 * @param version (%u) Ex.: 1
362 * @param endpointId (%s) Ex.: C707E38E-1E10-5413-94D9-ECAC260A0269
363 * @param uri (%s) Self URI. Ex.: sip:alice7@boston.local
364 * @param timezone (%s) Ex.: 00:00:00+01:00
365 * @param machineName (%s) Ex.: BOSTON-OCS07
367 #define SIPE_PUB_XML_DEVICE \
368 "<publication categoryName=\"device\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
369 "<device xmlns=\"http://schemas.microsoft.com/2006/09/sip/device\" endpointId=\"%s\">"\
370 "<capabilities preferred=\"false\" uri=\"%s\">"\
371 "<text capture=\"true\" render=\"true\" publish=\"false\"/>"\
372 "<gifInk capture=\"false\" render=\"true\" publish=\"false\"/>"\
373 "<isfInk capture=\"false\" render=\"true\" publish=\"false\"/>"\
374 "</capabilities>"\
375 "<timezone>%s</timezone>"\
376 "<machineName>%s</machineName>"\
377 "</device>"\
378 "</publication>"
381 * Publishes 'machineState' category.
382 * @param instance (%u) Ex.: 926460663
383 * @param version (%u) Ex.: 22
384 * @param availability (%d) Ex.: 3500
385 * @param instance (%u) Ex.: 926460663
386 * @param version (%u) Ex.: 22
387 * @param availability (%d) Ex.: 3500
389 #define SIPE_PUB_XML_STATE_MACHINE \
390 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
391 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"false\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"machineState\">"\
392 "<availability>%d</availability>"\
393 "<endpointLocation/>"\
394 "</state>"\
395 "</publication>"\
396 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"endpoint\">"\
397 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"false\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"machineState\">"\
398 "<availability>%d</availability>"\
399 "<endpointLocation/>"\
400 "</state>"\
401 "</publication>"
404 * Publishes 'userState' category.
405 * @param instance (%u) User. Ex.: 536870912
406 * @param version (%u) User Container 2. Ex.: 22
407 * @param availability (%d) User Container 2. Ex.: 15500
408 * @param instance (%u) User. Ex.: 536870912
409 * @param version (%u) User Container 3.Ex.: 22
410 * @param availability (%d) User Container 3. Ex.: 15500
412 #define SIPE_PUB_XML_STATE_USER \
413 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"static\">"\
414 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"userState\">"\
415 "<availability>%d</availability>"\
416 "<endpointLocation/>"\
417 "</state>"\
418 "</publication>"\
419 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"static\">"\
420 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"userState\">"\
421 "<availability>%d</availability>"\
422 "<endpointLocation/>"\
423 "</state>"\
424 "</publication>"
427 * An availability XML entry for SIPE_PUB_XML_STATE_CALENDAR
428 * @param availability (%d) Ex.: 6500
430 #define SIPE_PUB_XML_STATE_CALENDAR_AVAIL \
431 "<availability>%d</availability>"
433 * An activity XML entry for SIPE_PUB_XML_STATE_CALENDAR
434 * @param token (%s) Ex.: in-a-meeting
435 * @param minAvailability_attr (%s) Ex.: minAvailability="6500"
436 * @param maxAvailability_attr (%s) Ex.: maxAvailability="8999" or none
438 #define SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY \
439 "<activity token=\"%s\" %s %s></activity>"
441 * Publishes 'calendarState' category.
442 * @param instance (%u) Ex.: 1339299275
443 * @param version (%u) Ex.: 1
444 * @param uri (%s) Ex.: john@contoso.com
445 * @param start_time_str (%s) Ex.: 2008-01-11T19:00:00Z
446 * @param availability (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_AVAIL
447 * @param activity (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY
448 * @param meeting_subject (%s) Ex.: Customer Meeting
449 * @param meeting_location (%s) Ex.: Conf Room 100
451 * @param instance (%u) Ex.: 1339299275
452 * @param version (%u) Ex.: 1
453 * @param uri (%s) Ex.: john@contoso.com
454 * @param start_time_str (%s) Ex.: 2008-01-11T19:00:00Z
455 * @param availability (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_AVAIL
456 * @param activity (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY
457 * @param meeting_subject (%s) Ex.: Customer Meeting
458 * @param meeting_location (%s) Ex.: Conf Room 100
460 #define SIPE_PUB_XML_STATE_CALENDAR \
461 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
462 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"false\" uri=\"%s\" startTime=\"%s\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"calendarState\">"\
463 "%s"\
464 "%s"\
465 "<endpointLocation/>"\
466 "<meetingSubject>%s</meetingSubject>"\
467 "<meetingLocation>%s</meetingLocation>"\
468 "</state>"\
469 "</publication>"\
470 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"endpoint\">"\
471 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"false\" uri=\"%s\" startTime=\"%s\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"calendarState\">"\
472 "%s"\
473 "%s"\
474 "<endpointLocation/>"\
475 "<meetingSubject>%s</meetingSubject>"\
476 "<meetingLocation>%s</meetingLocation>"\
477 "</state>"\
478 "</publication>"
481 * Publishes to clear 'calendarState' category
482 * @param instance (%u) Ex.: 1251210982
483 * @param version (%u) Ex.: 1
485 #define SIPE_PUB_XML_STATE_CALENDAR_CLEAR \
486 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\" expires=\"0\"/>"\
487 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"endpoint\" expires=\"0\"/>"
490 * Publishes to clear any category
491 * @param category_name (%s) Ex.: state
492 * @param instance (%u) Ex.: 536870912
493 * @param container (%u) Ex.: 3
494 * @param version (%u) Ex.: 1
495 * @param expireType (%s) Ex.: static
497 #define SIPE_PUB_XML_PUBLICATION_CLEAR \
498 "<publication categoryName=\"%s\" instance=\"%u\" container=\"%u\" version=\"%u\" expireType=\"%s\" expires=\"0\"/>"
501 * Publishes 'note' category.
502 * @param instance (%u) Ex.: 2135971629; 0 for personal
503 * @param container (%u) Ex.: 200
504 * @param version (%u) Ex.: 2
505 * @param type (%s) Ex.: personal or OOF
506 * @param startTime_attr (%s) Ex.: startTime="2008-01-11T19:00:00Z"
507 * @param endTime_attr (%s) Ex.: endTime="2008-01-15T19:00:00Z"
508 * @param body (%s) Ex.: In the office
510 #define SIPE_PUB_XML_NOTE \
511 "<publication categoryName=\"note\" instance=\"%u\" container=\"%u\" version=\"%d\" expireType=\"static\">"\
512 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
513 "<body type=\"%s\" uri=\"\"%s%s>%s</body>"\
514 "</note>"\
515 "</publication>"
518 * Publishes 'calendarData' category's WorkingHours.
520 * @param version (%u) Ex.: 1
521 * @param email (%s) Ex.: alice@cosmo.local
522 * @param working_hours_xml_str (%s) Ex.: <WorkingHours xmlns=.....
524 * @param version (%u)
526 * @param version (%u)
527 * @param email (%s)
528 * @param working_hours_xml_str (%s)
530 * @param version (%u)
531 * @param email (%s)
532 * @param working_hours_xml_str (%s)
534 * @param version (%u)
535 * @param email (%s)
536 * @param working_hours_xml_str (%s)
538 * @param version (%u)
540 #define SIPE_PUB_XML_WORKING_HOURS \
541 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"1\" version=\"%d\" expireType=\"static\">"\
542 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
543 "</calendarData>"\
544 "</publication>"\
545 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"100\" version=\"%d\" expireType=\"static\">"\
546 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
547 "</publication>"\
548 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"200\" version=\"%d\" expireType=\"static\">"\
549 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
550 "</calendarData>"\
551 "</publication>"\
552 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"300\" version=\"%d\" expireType=\"static\">"\
553 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
554 "</calendarData>"\
555 "</publication>"\
556 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"400\" version=\"%d\" expireType=\"static\">"\
557 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
558 "</calendarData>"\
559 "</publication>"\
560 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"32000\" version=\"%d\" expireType=\"static\">"\
561 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
562 "</publication>"
565 * Publishes 'calendarData' category's FreeBusy.
567 * @param instance (%u) Ex.: 1300372959
568 * @param version (%u) Ex.: 1
570 * @param instance (%u) Ex.: 1300372959
571 * @param version (%u) Ex.: 1
573 * @param instance (%u) Ex.: 1300372959
574 * @param version (%u) Ex.: 1
575 * @param email (%s) Ex.: alice@cosmo.local
576 * @param fb_start_time_str (%s) Ex.: 2009-12-03T00:00:00Z
577 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAAAAAA.....
579 * @param instance (%u) Ex.: 1300372959
580 * @param version (%u) Ex.: 1
581 * @param email (%s) Ex.: alice@cosmo.local
582 * @param fb_start_time_str (%s) Ex.: 2009-12-03T00:00:00Z
583 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAAAAAA.....
585 * @param instance (%u) Ex.: 1300372959
586 * @param version (%u) Ex.: 1
587 * @param email (%s) Ex.: alice@cosmo.local
588 * @param fb_start_time_str (%s) Ex.: 2009-12-03T00:00:00Z
589 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAAAAAA.....
591 * @param instance (%u) Ex.: 1300372959
592 * @param version (%u) Ex.: 1
594 #define SIPE_PUB_XML_FREE_BUSY \
595 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"1\" version=\"%d\" expireType=\"endpoint\">"\
596 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
597 "</publication>"\
598 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"100\" version=\"%d\" expireType=\"endpoint\">"\
599 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
600 "</publication>"\
601 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"200\" version=\"%d\" expireType=\"endpoint\">"\
602 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
603 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
604 "</calendarData>"\
605 "</publication>"\
606 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"300\" version=\"%d\" expireType=\"endpoint\">"\
607 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
608 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
609 "</calendarData>"\
610 "</publication>"\
611 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"400\" version=\"%d\" expireType=\"endpoint\">"\
612 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
613 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
614 "</calendarData>"\
615 "</publication>"\
616 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"32000\" version=\"%d\" expireType=\"endpoint\">"\
617 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
618 "</publication>"
621 #define sipe_soap(method, body) \
622 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
623 "<SOAP-ENV:Body>" \
624 "<m:" method " xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
625 body \
626 "</m:" method ">" \
627 "</SOAP-ENV:Body>" \
628 "</SOAP-ENV:Envelope>"
630 #define SIPE_SOAP_SET_CONTACT sipe_soap("setContact", \
631 "<m:displayName>%s</m:displayName>"\
632 "<m:groups>%s</m:groups>"\
633 "<m:subscribed>%s</m:subscribed>"\
634 "<m:URI>%s</m:URI>"\
635 "<m:externalURI />"\
636 "<m:deltaNum>%d</m:deltaNum>")
638 #define SIPE_SOAP_DEL_CONTACT sipe_soap("deleteContact", \
639 "<m:URI>%s</m:URI>"\
640 "<m:deltaNum>%d</m:deltaNum>")
642 #define SIPE_SOAP_ADD_GROUP sipe_soap("addGroup", \
643 "<m:name>%s</m:name>"\
644 "<m:externalURI />"\
645 "<m:deltaNum>%d</m:deltaNum>")
647 #define SIPE_SOAP_MOD_GROUP sipe_soap("modifyGroup", \
648 "<m:groupID>%d</m:groupID>"\
649 "<m:name>%s</m:name>"\
650 "<m:externalURI />"\
651 "<m:deltaNum>%d</m:deltaNum>")
653 #define SIPE_SOAP_DEL_GROUP sipe_soap("deleteGroup", \
654 "<m:groupID>%d</m:groupID>"\
655 "<m:deltaNum>%d</m:deltaNum>")
657 // first/mask arg is sip:user@domain.com
658 // second/rights arg is AA for allow, BD for deny
659 #define SIPE_SOAP_ALLOW_DENY sipe_soap("setACE", \
660 "<m:type>USER</m:type>"\
661 "<m:mask>%s</m:mask>"\
662 "<m:rights>%s</m:rights>"\
663 "<m:deltaNum>%d</m:deltaNum>")
666 * Calendar publication entry. 2005 systems.
668 * @param legacy_dn (%s) Ex.: /o=EXCHANGE/ou=BTUK02/cn=Recipients/cn=AHHBTT
669 * @param fb_start_time_str (%s) Ex.: 2009-12-06T17:15:00Z
670 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAA......
672 #define SIPE_SOAP_SET_PRESENCE_CALENDAR \
673 "<calendarInfo xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" mailboxId=\"%s\" startTime=\"%s\" granularity=\"PT15M\">%s</calendarInfo>"
675 * Note publication entry. 2005 systems.
677 * @param note (%s) Ex.: Working from home
679 #define SIPE_SOAP_SET_PRESENCE_NOTE_XML "<note>%s</note>"
681 * Note's OOF publication entry. 2005 systems.
683 #define SIPE_SOAP_SET_PRESENCE_OOF_XML "<oof></oof>"
685 * States publication entry for User State. 2005 systems.
687 * @param avail (%d) Availability 2007-style. Ex.: 9500
688 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
689 * @param device_id (%s) epid. Ex.: 4c77e6ec72
690 * @param activity_token (%s) Ex.: do-not-disturb
692 #define SIPE_SOAP_SET_PRESENCE_STATES \
693 "<states>"\
694 "<state avail=\"%d\" since=\"%s\" validWith=\"any-device\" deviceId=\"%s\" set=\"manual\" xsi:type=\"userState\">%s</state>"\
695 "</states>"
697 * Presentity publication entry. 2005 systems.
699 * @param uri (%s) SIP URI without 'sip:' prefix. Ex.: fox@atlanta.local
700 * @param aggr_availability (%d) Ex.: 300
701 * @param aggr_activity (%d) Ex.: 600
702 * @param host_name (%s) Uppercased. Ex.: ATLANTA
703 * @param note_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_NOTE_XML
704 * @param oof_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_OOF_XML
705 * @param states_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_STATES
706 * @param calendar_info_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_CALENDAR
707 * @param device_id (%s) epid. Ex.: 4c77e6ec72
708 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
709 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
710 * @param user_input (%s) active, idle
712 #define SIPE_SOAP_SET_PRESENCE sipe_soap("setPresence", \
713 "<m:presentity xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" m:uri=\"sip:%s\">"\
714 "<m:availability m:aggregate=\"%d\"/>"\
715 "<m:activity m:aggregate=\"%d\"/>"\
716 "<deviceName xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" name=\"%s\"/>"\
717 "<rtc:devicedata xmlns:rtc=\"http://schemas.microsoft.com/winrtc/2002/11/sip\" namespace=\"rtcService\">"\
718 "<![CDATA[<caps><renders_gif/><renders_isf/></caps>]]></rtc:devicedata>"\
719 "<userInfo xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\">"\
720 "%s%s" \
721 "%s" \
722 "</userInfo>"\
723 "%s" \
724 "<device xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" deviceId=\"%s\" since=\"%s\" >"\
725 "<userInput since=\"%s\" >%s</userInput>"\
726 "</device>"\
727 "</m:presentity>")
729 #define SIPE_SOAP_SEARCH_CONTACT \
730 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
731 "<SOAP-ENV:Body>" \
732 "<m:directorySearch xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
733 "<m:filter m:href=\"#searchArray\"/>"\
734 "<m:maxResults>%d</m:maxResults>"\
735 "</m:directorySearch>"\
736 "<m:Array xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\" m:id=\"searchArray\">"\
737 "%s"\
738 "</m:Array>"\
739 "</SOAP-ENV:Body>"\
740 "</SOAP-ENV:Envelope>"
742 #define SIPE_SOAP_SEARCH_ROW "<m:row m:attrib=\"%s\" m:value=\"%s\"/>"