interface cleanup: decouple header files
[siplcs.git] / src / core / sipe.h
blob5fd863f7b171a61d63ea3ca083cd14f9206386b2
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 enum sip_sec_auth_type;
48 #define SIMPLE_BUF_INC 4096
50 #define SIPE_TYPING_RECV_TIMEOUT 6
51 #define SIPE_TYPING_SEND_TIMEOUT 4
54 /** Activity (token and description) 2007 */
55 typedef enum
57 SIPE_ACTIVITY_UNSET = 0,
58 SIPE_ACTIVITY_ONLINE,
59 SIPE_ACTIVITY_INACTIVE,
60 SIPE_ACTIVITY_BUSY,
61 SIPE_ACTIVITY_BUSYIDLE,
62 SIPE_ACTIVITY_DND,
63 SIPE_ACTIVITY_BRB,
64 SIPE_ACTIVITY_AWAY,
65 SIPE_ACTIVITY_LUNCH,
66 SIPE_ACTIVITY_OFFLINE,
67 SIPE_ACTIVITY_ON_PHONE,
68 SIPE_ACTIVITY_IN_CONF,
69 SIPE_ACTIVITY_IN_MEETING,
70 SIPE_ACTIVITY_OOF,
71 SIPE_ACTIVITY_URGENT_ONLY,
72 SIPE_ACTIVITY_NUM_TYPES
73 } sipe_activity;
75 struct sipe_buddy {
76 gchar *name;
77 gchar *activity;
78 gchar *meeting_subject;
79 gchar *meeting_location;
80 /* Sipe internal format for Note is HTML.
81 * All incoming plain text should be html-escaped
82 * for example by g_markup_escape_text()
84 gchar *note;
85 gboolean is_oof_note;
86 time_t note_since;
88 /* Calendar related fields */
89 gchar *cal_start_time;
90 int cal_granularity;
91 gchar *cal_free_busy_base64;
92 gchar *cal_free_busy;
93 time_t cal_free_busy_published;
94 /* for 2005 systems */
95 int user_avail;
96 time_t user_avail_since;
97 time_t activity_since;
98 const char *last_non_cal_status_id;
99 gchar *last_non_cal_activity;
101 struct sipe_cal_working_hours *cal_working_hours;
103 gchar *device_name;
104 GSList *groups;
105 /** flag to control sending 'context' element in 2007 subscriptions */
106 gboolean just_added;
109 struct sip_auth {
110 enum sip_sec_auth_type type;
111 struct sip_sec_context *gssapi_context;
112 gchar *gssapi_data;
113 gchar *opaque;
114 gchar *realm;
115 gchar *target;
116 int version;
117 int nc;
118 int retries;
119 int ntlm_num;
120 int expires;
123 typedef enum {
124 SIPE_TRANSPORT_TLS,
125 SIPE_TRANSPORT_TCP,
126 SIPE_TRANSPORT_UDP,
127 } sipe_transport_type;
129 struct sipe_service_data {
130 const char *service;
131 const char *transport;
132 sipe_transport_type type;
135 /** MS-PRES publication */
136 struct sipe_publication {
137 gchar *category;
138 guint instance;
139 guint container;
140 guint version;
141 /** for 'state' category */
142 int availability;
143 /** for 'state:calendarState' category */
144 char *cal_event_hash;
145 /** for 'note' category */
146 gchar *note;
147 /** for 'calendarData' category; 300(Team) container */
148 char *working_hours_xml_str;
149 char *fb_start_str;
150 char *free_busy_base64;
153 /** MS-PRES container */
154 struct sipe_container {
155 guint id;
156 guint version;
157 GSList *members;
159 /** MS-PRES container member */
160 struct sipe_container_member {
161 /** user, domain, sameEnterprise, federated, publicCloud; everyone */
162 const gchar *type;
163 const gchar *value;
166 struct sipe_account_data {
167 struct _PurpleConnection *gc;
168 gchar *sipdomain;
169 gchar *username;
170 gchar *authdomain;
171 gchar *authuser;
172 gchar *password;
173 gchar *epid;
174 gchar *focus_factory_uri;
175 /** Allowed server events to subscribe. From register OK response. */
176 GSList *allow_events;
177 struct _PurpleDnsQueryData *query_data;
178 struct _PurpleSrvQueryData *srv_query_data;
179 const struct sipe_service_data *service_data;
180 struct _PurpleNetworkListenData *listen_data;
181 int fd;
182 int cseq;
183 time_t last_keepalive;
184 int registerstatus; /* 0 nothing, 1 first registration send, 2 auth received, 3 registered */
185 struct sip_auth registrar;
186 struct sip_auth proxy;
187 struct sip_csta *csta; /* For RCC - Remote Call Control */
188 gboolean reregister_set; /* whether reregister timer set */
189 gboolean reauthenticate_set; /* whether reauthenticate timer set */
190 gboolean subscribed; /* whether subscribed to events, except buddies presence */
191 gboolean subscribed_buddies; /* whether subscribed to buddies presence */
192 gboolean access_level_set; /* whether basic access level set */
193 gboolean initial_state_published; /* whether we published our initial state */
194 GSList *our_publication_keys; /* [MS-PRES] */
195 GHashTable *our_publications; /* [MS-PRES] */
196 GHashTable *user_state_publications; /* [MS-PRES] */
197 GHashTable *subscriptions;
198 int listenfd;
199 int listenport;
200 int listenpa;
201 int contacts_delta;
202 int acl_delta;
203 int presence_method_version;
204 time_t do_not_publish[SIPE_ACTIVITY_NUM_TYPES];
205 gchar *status;
206 gboolean is_oof_note;
207 gchar *note;
208 time_t note_since;
209 time_t idle_switch;
210 gchar *contact;
211 gchar *server_version;
212 gboolean ocs2007; /*if there is support for batched category subscription [SIP-PRES]*/
213 gboolean batched_support; /*if there is support for batched subscription*/
214 GSList *containers; /* MS-PRES containers */
215 GHashTable *buddies;
216 guint resendtimeout;
217 guint keepalive_timeout;
218 GSList *timeouts;
219 gboolean connecting;
220 struct _PurpleAccount *account;
221 struct _PurpleCircBuffer *txbuf;
222 guint tx_handler;
223 gchar *regcallid;
224 GSList *transactions;
225 GSList *sessions;
226 GSList *openconns;
227 GSList *groups;
228 GHashTable *filetransfers;
229 sipe_transport_type transport;
230 gboolean auto_transport;
231 struct _PurpleSslConnection *gsc;
232 struct sockaddr *serveraddr;
233 gchar *realhostname;
234 int realport; /* port and hostname from SRV record */
235 gboolean processing_input;
236 struct sipe_ews *ews;
237 gchar *email;
238 /** 2005 Custom XML piece.
239 * Possibly set by other point of presence or just other client at earlier time.
240 * It should be preserved/modified, not overwritten. This implies subscription
241 * to self-contasct.
242 * This XML keeps OC2005:
243 * - User note
244 * - OOF flag
245 * - User status
247 gchar *user_states;
250 struct sip_connection {
251 int fd;
252 gchar *inbuf;
253 int inbuflen;
254 int inbufused;
255 int inputhandler;
258 struct sipe_auth_job {
259 gchar * who;
260 struct sipe_account_data * sip;
263 struct transaction;
265 typedef gboolean (*TransCallback) (struct sipe_account_data *, struct sipmsg *, struct transaction *);
267 struct transaction_payload {
268 GDestroyNotify destroy;
269 void *data;
272 struct transaction {
273 time_t time;
274 int retries;
275 int transport; /* 0 = tcp, 1 = udp */
276 int fd;
277 /** Not yet perfect, but surely better then plain CSeq
278 * Format is: <Call-ID><CSeq>
279 * (RFC3261 17.2.3 for matching server transactions: Request-URI, To tag, From tag, Call-ID, CSeq, and top Via)
281 gchar *key;
282 struct sipmsg *msg;
283 TransCallback callback;
284 struct transaction_payload *payload;
287 typedef void (*Action) (struct sipe_account_data *, void *);
290 * Do schedule action for execution in the future.
291 * Non repetitive execution.
293 * @param name of action (will be copied)
294 * @param timeout in seconds
295 * @param action callback function
296 * @param destroy payload destroy function
297 * @param sip
298 * @param payload callback data (can be NULL, otherwise caller must allocate memory)
300 void
301 sipe_schedule_action(const gchar *name,
302 int timeout,
303 Action action,
304 GDestroyNotify destroy,
305 struct sipe_account_data *sip,
306 void *payload);
308 struct sipe_group {
309 gchar *name;
310 int id;
311 struct _PurpleGroup *purple_group;
314 struct group_user_context {
315 gchar * group_name;
316 gchar * user_name;
319 GSList * slist_insert_unique_sorted(GSList *list, gpointer data, GCompareFunc func);
321 GList *sipe_actions(struct _PurplePlugin *plugin, gpointer context);
323 gboolean purple_init_plugin(struct _PurplePlugin *plugin);
326 * Publishes self status
327 * based on own calendar information,
328 * our Calendar information - FreeBusy, WorkingHours,
329 * OOF note.
331 * For 2007+
333 void
334 publish_calendar_status_self(struct sipe_account_data *sip);
337 * For 2005-
339 void
340 send_presence_soap(struct sipe_account_data *sip,
341 gboolean do_publish_calendar);
344 * THE BIG SPLIT - temporary interfaces
346 * Previously private functions in sipe.c that are
347 * - waiting to be factored out to an appropriate module
348 * - are needed by the already created new modules
351 /* pier11:
353 * Since SIP (RFC3261) is extensible by its design,
354 * and MS specs prove just that (they all are defined as SIP extensions),
355 * it make sense to split functionality by extension (or close extension group).
356 * For example: conference, presence (MS-PRES), etc.
358 * This way our code will not be monolithic, but potentially _reusable_. May be
359 * a top of other SIP core, and/or other front-end (Telepathy framework?).
361 /* Forward declarations */
362 struct sip_session;
363 struct sip_dialog;
365 /* SIP send module? */
366 struct transaction *
367 send_sip_request(struct _PurpleConnection *gc, const gchar *method,
368 const gchar *url, const gchar *to, const gchar *addheaders,
369 const gchar *body, struct sip_dialog *dialog, TransCallback tc);
370 void
371 send_sip_response(struct _PurpleConnection *gc, struct sipmsg *msg, int code,
372 const char *text, const char *body);
373 void
374 sipe_invite(struct sipe_account_data *sip, struct sip_session *session,
375 const gchar *who, const gchar *msg_body, const gchar *msg_content_type,
376 const gchar *referred_by, const gboolean is_triggered);
377 /* ??? module */
378 gboolean process_subscribe_response(struct sipe_account_data *sip,
379 struct sipmsg *msg,
380 struct transaction *tc);
381 /* Chat module */
382 void
383 sipe_invite_to_chat(struct sipe_account_data *sip,
384 struct sip_session *session,
385 const gchar *who);
386 /* Session module? */
387 void
388 sipe_present_message_undelivered_err(struct sipe_account_data *sip,
389 struct sip_session *session,
390 int sip_error,
391 int sip_warning,
392 const gchar *who,
393 const gchar *message);
395 void
396 sipe_present_info(struct sipe_account_data *sip,
397 struct sip_session *session,
398 const gchar *message);
401 void
402 sipe_process_pending_invite_queue(struct sipe_account_data *sip,
403 struct sip_session *session);
405 void
406 sipe_im_process_queue (struct sipe_account_data * sip, struct sip_session * session);
409 /*** THE BIG SPLIT END ***/
411 #define SIPE_INVITE_TEXT "ms-text-format: %s; charset=UTF-8%s;ms-body=%s\r\n"
413 #define SIPE_SEND_TYPING \
414 "<?xml version=\"1.0\"?>"\
415 "<KeyboardActivity>"\
416 "<status status=\"type\" />"\
417 "</KeyboardActivity>"
420 * Publishes categories.
421 * @param uri (%s) Self URI. Ex.: sip:alice7@boston.local
422 * @param publications (%s) XML publications
424 #define SIPE_SEND_PRESENCE \
425 "<publish xmlns=\"http://schemas.microsoft.com/2006/09/sip/rich-presence\">"\
426 "<publications uri=\"%s\">"\
427 "%s"\
428 "</publications>"\
429 "</publish>"
432 * Publishes 'device' category.
433 * @param instance (%u) Ex.: 1938468728
434 * @param version (%u) Ex.: 1
435 * @param endpointId (%s) Ex.: C707E38E-1E10-5413-94D9-ECAC260A0269
436 * @param uri (%s) Self URI. Ex.: sip:alice7@boston.local
437 * @param timezone (%s) Ex.: 00:00:00+01:00
438 * @param machineName (%s) Ex.: BOSTON-OCS07
440 #define SIPE_PUB_XML_DEVICE \
441 "<publication categoryName=\"device\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
442 "<device xmlns=\"http://schemas.microsoft.com/2006/09/sip/device\" endpointId=\"%s\">"\
443 "<capabilities preferred=\"false\" uri=\"%s\">"\
444 "<text capture=\"true\" render=\"true\" publish=\"false\"/>"\
445 "<gifInk capture=\"false\" render=\"true\" publish=\"false\"/>"\
446 "<isfInk capture=\"false\" render=\"true\" publish=\"false\"/>"\
447 "</capabilities>"\
448 "<timezone>%s</timezone>"\
449 "<machineName>%s</machineName>"\
450 "</device>"\
451 "</publication>"
454 * Publishes 'machineState' category.
455 * @param instance (%u) Ex.: 926460663
456 * @param version (%u) Ex.: 22
457 * @param availability (%d) Ex.: 3500
458 * @param instance (%u) Ex.: 926460663
459 * @param version (%u) Ex.: 22
460 * @param availability (%d) Ex.: 3500
462 #define SIPE_PUB_XML_STATE_MACHINE \
463 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
464 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"false\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"machineState\">"\
465 "<availability>%d</availability>"\
466 "<endpointLocation/>"\
467 "</state>"\
468 "</publication>"\
469 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"endpoint\">"\
470 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"false\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"machineState\">"\
471 "<availability>%d</availability>"\
472 "<endpointLocation/>"\
473 "</state>"\
474 "</publication>"
477 * Publishes 'userState' category.
478 * @param instance (%u) User. Ex.: 536870912
479 * @param version (%u) User Container 2. Ex.: 22
480 * @param availability (%d) User Container 2. Ex.: 15500
481 * @param instance (%u) User. Ex.: 536870912
482 * @param version (%u) User Container 3.Ex.: 22
483 * @param availability (%d) User Container 3. Ex.: 15500
485 #define SIPE_PUB_XML_STATE_USER \
486 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"static\">"\
487 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"userState\">"\
488 "<availability>%d</availability>"\
489 "<endpointLocation/>"\
490 "</state>"\
491 "</publication>"\
492 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"static\">"\
493 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"userState\">"\
494 "<availability>%d</availability>"\
495 "<endpointLocation/>"\
496 "</state>"\
497 "</publication>"
500 * An availability XML entry for SIPE_PUB_XML_STATE_CALENDAR
501 * @param availability (%d) Ex.: 6500
503 #define SIPE_PUB_XML_STATE_CALENDAR_AVAIL \
504 "<availability>%d</availability>"
506 * An activity XML entry for SIPE_PUB_XML_STATE_CALENDAR
507 * @param token (%s) Ex.: in-a-meeting
508 * @param minAvailability_attr (%s) Ex.: minAvailability="6500"
509 * @param maxAvailability_attr (%s) Ex.: maxAvailability="8999" or none
511 #define SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY \
512 "<activity token=\"%s\" %s %s></activity>"
514 * Publishes 'calendarState' category.
515 * @param instance (%u) Ex.: 1339299275
516 * @param version (%u) Ex.: 1
517 * @param uri (%s) Ex.: john@contoso.com
518 * @param start_time_str (%s) Ex.: 2008-01-11T19:00:00Z
519 * @param availability (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_AVAIL
520 * @param activity (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY
521 * @param meeting_subject (%s) Ex.: Customer Meeting
522 * @param meeting_location (%s) Ex.: Conf Room 100
524 * @param instance (%u) Ex.: 1339299275
525 * @param version (%u) Ex.: 1
526 * @param uri (%s) Ex.: john@contoso.com
527 * @param start_time_str (%s) Ex.: 2008-01-11T19:00:00Z
528 * @param availability (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_AVAIL
529 * @param activity (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY
530 * @param meeting_subject (%s) Ex.: Customer Meeting
531 * @param meeting_location (%s) Ex.: Conf Room 100
533 #define SIPE_PUB_XML_STATE_CALENDAR \
534 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
535 "<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\">"\
536 "%s"\
537 "%s"\
538 "<endpointLocation/>"\
539 "<meetingSubject>%s</meetingSubject>"\
540 "<meetingLocation>%s</meetingLocation>"\
541 "</state>"\
542 "</publication>"\
543 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"endpoint\">"\
544 "<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\">"\
545 "%s"\
546 "%s"\
547 "<endpointLocation/>"\
548 "<meetingSubject>%s</meetingSubject>"\
549 "<meetingLocation>%s</meetingLocation>"\
550 "</state>"\
551 "</publication>"
554 * Publishes to clear 'calendarState' category
555 * @param instance (%u) Ex.: 1251210982
556 * @param version (%u) Ex.: 1
558 #define SIPE_PUB_XML_STATE_CALENDAR_CLEAR \
559 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\" expires=\"0\"/>"\
560 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"endpoint\" expires=\"0\"/>"
563 * Publishes to clear any category
564 * @param category_name (%s) Ex.: state
565 * @param instance (%u) Ex.: 536870912
566 * @param container (%u) Ex.: 3
567 * @param version (%u) Ex.: 1
568 * @param expireType (%s) Ex.: static
570 #define SIPE_PUB_XML_PUBLICATION_CLEAR \
571 "<publication categoryName=\"%s\" instance=\"%u\" container=\"%u\" version=\"%u\" expireType=\"%s\" expires=\"0\"/>"
574 * Publishes 'note' category.
575 * @param instance (%u) Ex.: 2135971629; 0 for personal
576 * @param container (%u) Ex.: 200
577 * @param version (%u) Ex.: 2
578 * @param type (%s) Ex.: personal or OOF
579 * @param startTime_attr (%s) Ex.: startTime="2008-01-11T19:00:00Z"
580 * @param endTime_attr (%s) Ex.: endTime="2008-01-15T19:00:00Z"
581 * @param body (%s) Ex.: In the office
583 #define SIPE_PUB_XML_NOTE \
584 "<publication categoryName=\"note\" instance=\"%u\" container=\"%u\" version=\"%d\" expireType=\"static\">"\
585 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
586 "<body type=\"%s\" uri=\"\"%s%s>%s</body>"\
587 "</note>"\
588 "</publication>"
591 * Publishes 'calendarData' category's WorkingHours.
593 * @param version (%u) Ex.: 1
594 * @param email (%s) Ex.: alice@cosmo.local
595 * @param working_hours_xml_str (%s) Ex.: <WorkingHours xmlns=.....
597 * @param version (%u)
599 * @param version (%u)
600 * @param email (%s)
601 * @param working_hours_xml_str (%s)
603 * @param version (%u)
604 * @param email (%s)
605 * @param working_hours_xml_str (%s)
607 * @param version (%u)
608 * @param email (%s)
609 * @param working_hours_xml_str (%s)
611 * @param version (%u)
613 #define SIPE_PUB_XML_WORKING_HOURS \
614 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"1\" version=\"%d\" expireType=\"static\">"\
615 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
616 "</calendarData>"\
617 "</publication>"\
618 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"100\" version=\"%d\" expireType=\"static\">"\
619 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
620 "</publication>"\
621 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"200\" version=\"%d\" expireType=\"static\">"\
622 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
623 "</calendarData>"\
624 "</publication>"\
625 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"300\" version=\"%d\" expireType=\"static\">"\
626 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
627 "</calendarData>"\
628 "</publication>"\
629 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"400\" version=\"%d\" expireType=\"static\">"\
630 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
631 "</calendarData>"\
632 "</publication>"\
633 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"32000\" version=\"%d\" expireType=\"static\">"\
634 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
635 "</publication>"
638 * Publishes 'calendarData' category's FreeBusy.
640 * @param instance (%u) Ex.: 1300372959
641 * @param version (%u) Ex.: 1
643 * @param instance (%u) Ex.: 1300372959
644 * @param version (%u) Ex.: 1
646 * @param instance (%u) Ex.: 1300372959
647 * @param version (%u) Ex.: 1
648 * @param email (%s) Ex.: alice@cosmo.local
649 * @param fb_start_time_str (%s) Ex.: 2009-12-03T00:00:00Z
650 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAAAAAA.....
652 * @param instance (%u) Ex.: 1300372959
653 * @param version (%u) Ex.: 1
654 * @param email (%s) Ex.: alice@cosmo.local
655 * @param fb_start_time_str (%s) Ex.: 2009-12-03T00:00:00Z
656 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAAAAAA.....
658 * @param instance (%u) Ex.: 1300372959
659 * @param version (%u) Ex.: 1
660 * @param email (%s) Ex.: alice@cosmo.local
661 * @param fb_start_time_str (%s) Ex.: 2009-12-03T00:00:00Z
662 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAAAAAA.....
664 * @param instance (%u) Ex.: 1300372959
665 * @param version (%u) Ex.: 1
667 #define SIPE_PUB_XML_FREE_BUSY \
668 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"1\" version=\"%d\" expireType=\"endpoint\">"\
669 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
670 "</publication>"\
671 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"100\" version=\"%d\" expireType=\"endpoint\">"\
672 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
673 "</publication>"\
674 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"200\" version=\"%d\" expireType=\"endpoint\">"\
675 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
676 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
677 "</calendarData>"\
678 "</publication>"\
679 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"300\" version=\"%d\" expireType=\"endpoint\">"\
680 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
681 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
682 "</calendarData>"\
683 "</publication>"\
684 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"400\" version=\"%d\" expireType=\"endpoint\">"\
685 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
686 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
687 "</calendarData>"\
688 "</publication>"\
689 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"32000\" version=\"%d\" expireType=\"endpoint\">"\
690 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
691 "</publication>"
694 #define sipe_soap(method, body) \
695 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
696 "<SOAP-ENV:Body>" \
697 "<m:" method " xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
698 body \
699 "</m:" method ">" \
700 "</SOAP-ENV:Body>" \
701 "</SOAP-ENV:Envelope>"
703 #define SIPE_SOAP_SET_CONTACT sipe_soap("setContact", \
704 "<m:displayName>%s</m:displayName>"\
705 "<m:groups>%s</m:groups>"\
706 "<m:subscribed>%s</m:subscribed>"\
707 "<m:URI>%s</m:URI>"\
708 "<m:externalURI />"\
709 "<m:deltaNum>%d</m:deltaNum>")
711 #define SIPE_SOAP_DEL_CONTACT sipe_soap("deleteContact", \
712 "<m:URI>%s</m:URI>"\
713 "<m:deltaNum>%d</m:deltaNum>")
715 #define SIPE_SOAP_ADD_GROUP sipe_soap("addGroup", \
716 "<m:name>%s</m:name>"\
717 "<m:externalURI />"\
718 "<m:deltaNum>%d</m:deltaNum>")
720 #define SIPE_SOAP_MOD_GROUP sipe_soap("modifyGroup", \
721 "<m:groupID>%d</m:groupID>"\
722 "<m:name>%s</m:name>"\
723 "<m:externalURI />"\
724 "<m:deltaNum>%d</m:deltaNum>")
726 #define SIPE_SOAP_DEL_GROUP sipe_soap("deleteGroup", \
727 "<m:groupID>%d</m:groupID>"\
728 "<m:deltaNum>%d</m:deltaNum>")
730 // first/mask arg is sip:user@domain.com
731 // second/rights arg is AA for allow, BD for deny
732 #define SIPE_SOAP_ALLOW_DENY sipe_soap("setACE", \
733 "<m:type>USER</m:type>"\
734 "<m:mask>%s</m:mask>"\
735 "<m:rights>%s</m:rights>"\
736 "<m:deltaNum>%d</m:deltaNum>")
739 * Calendar publication entry. 2005 systems.
741 * @param legacy_dn (%s) Ex.: /o=EXCHANGE/ou=BTUK02/cn=Recipients/cn=AHHBTT
742 * @param fb_start_time_str (%s) Ex.: 2009-12-06T17:15:00Z
743 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAA......
745 #define SIPE_SOAP_SET_PRESENCE_CALENDAR \
746 "<calendarInfo xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" mailboxId=\"%s\" startTime=\"%s\" granularity=\"PT15M\">%s</calendarInfo>"
748 * Note publication entry. 2005 systems.
750 * @param note (%s) Ex.: Working from home
752 #define SIPE_SOAP_SET_PRESENCE_NOTE_XML "<note>%s</note>"
754 * Note's OOF publication entry. 2005 systems.
756 #define SIPE_SOAP_SET_PRESENCE_OOF_XML "<oof></oof>"
758 * States publication entry for User State. 2005 systems.
760 * @param avail (%d) Availability 2007-style. Ex.: 9500
761 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
762 * @param device_id (%s) epid. Ex.: 4c77e6ec72
763 * @param activity_token (%s) Ex.: do-not-disturb
765 #define SIPE_SOAP_SET_PRESENCE_STATES \
766 "<states>"\
767 "<state avail=\"%d\" since=\"%s\" validWith=\"any-device\" deviceId=\"%s\" set=\"manual\" xsi:type=\"userState\">%s</state>"\
768 "</states>"
770 * Presentity publication entry. 2005 systems.
772 * @param uri (%s) SIP URI without 'sip:' prefix. Ex.: fox@atlanta.local
773 * @param aggr_availability (%d) Ex.: 300
774 * @param aggr_activity (%d) Ex.: 600
775 * @param host_name (%s) Uppercased. Ex.: ATLANTA
776 * @param note_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_NOTE_XML
777 * @param oof_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_OOF_XML
778 * @param states_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_STATES
779 * @param calendar_info_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_CALENDAR
780 * @param device_id (%s) epid. Ex.: 4c77e6ec72
781 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
782 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
783 * @param user_input (%s) active, idle
785 #define SIPE_SOAP_SET_PRESENCE sipe_soap("setPresence", \
786 "<m:presentity xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" m:uri=\"sip:%s\">"\
787 "<m:availability m:aggregate=\"%d\"/>"\
788 "<m:activity m:aggregate=\"%d\"/>"\
789 "<deviceName xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" name=\"%s\"/>"\
790 "<rtc:devicedata xmlns:rtc=\"http://schemas.microsoft.com/winrtc/2002/11/sip\" namespace=\"rtcService\">"\
791 "<![CDATA[<caps><renders_gif/><renders_isf/></caps>]]></rtc:devicedata>"\
792 "<userInfo xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\">"\
793 "%s%s" \
794 "%s" \
795 "</userInfo>"\
796 "%s" \
797 "<device xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" deviceId=\"%s\" since=\"%s\" >"\
798 "<userInput since=\"%s\" >%s</userInput>"\
799 "</device>"\
800 "</m:presentity>")
802 #define SIPE_SOAP_SEARCH_CONTACT \
803 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
804 "<SOAP-ENV:Body>" \
805 "<m:directorySearch xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
806 "<m:filter m:href=\"#searchArray\"/>"\
807 "<m:maxResults>%d</m:maxResults>"\
808 "</m:directorySearch>"\
809 "<m:Array xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\" m:id=\"searchArray\">"\
810 "%s"\
811 "</m:Array>"\
812 "</SOAP-ENV:Body>"\
813 "</SOAP-ENV:Envelope>"
815 #define SIPE_SOAP_SEARCH_ROW "<m:row m:attrib=\"%s\" m:value=\"%s\"/>"