ft: process content block situation
[siplcs.git] / src / core / sipe.h
blob7cfaf439485dbd415f2a735a6a844611506df4f9
1 /**
2 * @file sipe.h
4 * pidgin-sipe
6 * Copyright (C) 2008 Novell, Inc.
7 * Copyright (C) 2007 Anibal Avelar <avelar@gmail.com>
8 * Copyright (C) 2005 Thomas Butter <butter@uni-mannheim.de>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #ifndef _PIDGIN_SIPE_H
26 #define _PIDGIN_SIPE_H
28 #include <glib.h>
29 #include <time.h>
31 #ifdef _WIN32
32 #include "internal.h"
33 #endif
35 #include "cipher.h"
36 #include "circbuffer.h"
37 #include "dnsquery.h"
38 #include "dnssrv.h"
39 #include "network.h"
40 #include "proxy.h"
41 #include "prpl.h"
42 #include "sslconn.h"
44 #include "sipmsg.h"
45 #include "sip-sec.h"
46 #include "uuid.h"
48 #define SIPE_UNUSED_PARAMETER __attribute__((unused))
50 #define SIMPLE_BUF_INC 4096
52 #define SIPE_TYPING_RECV_TIMEOUT 6
53 #define SIPE_TYPING_SEND_TIMEOUT 4
56 /** Activity (token and description) 2007 */
57 typedef enum
59 SIPE_ACTIVITY_UNSET = 0,
60 SIPE_ACTIVITY_ONLINE,
61 SIPE_ACTIVITY_INACTIVE,
62 SIPE_ACTIVITY_BUSY,
63 SIPE_ACTIVITY_BUSYIDLE,
64 SIPE_ACTIVITY_DND,
65 SIPE_ACTIVITY_BRB,
66 SIPE_ACTIVITY_AWAY,
67 SIPE_ACTIVITY_LUNCH,
68 SIPE_ACTIVITY_OFFLINE,
69 SIPE_ACTIVITY_ON_PHONE,
70 SIPE_ACTIVITY_IN_CONF,
71 SIPE_ACTIVITY_IN_MEETING,
72 SIPE_ACTIVITY_OOF,
73 SIPE_ACTIVITY_URGENT_ONLY,
74 SIPE_ACTIVITY_NUM_TYPES
75 } sipe_activity;
77 struct sipe_buddy {
78 gchar *name;
79 gchar *activity;
80 gchar *meeting_subject;
81 gchar *meeting_location;
82 /* Sipe internal format for Note is HTML.
83 * All incoming plain text should be html-escaped
84 * for example by g_markup_escape_text()
86 gchar *note;
87 gboolean is_oof_note;
88 time_t note_since;
90 /* Calendar related fields */
91 gchar *cal_start_time;
92 int cal_granularity;
93 gchar *cal_free_busy_base64;
94 gchar *cal_free_busy;
95 time_t cal_free_busy_published;
96 /* for 2005 systems */
97 int user_avail;
98 time_t user_avail_since;
99 time_t activity_since;
100 const char *last_non_cal_status_id;
101 gchar *last_non_cal_activity;
103 struct sipe_cal_working_hours *cal_working_hours;
105 gchar *device_name;
106 GSList *groups;
107 /** flag to control sending 'context' element in 2007 subscriptions */
108 gboolean just_added;
111 struct sip_auth {
112 SipSecAuthType type;
113 SipSecContext gssapi_context;
114 gchar *gssapi_data;
115 gchar *opaque;
116 gchar *realm;
117 gchar *target;
118 int nc;
119 int retries;
120 int ntlm_num;
121 int expires;
124 typedef enum {
125 SIPE_TRANSPORT_TLS,
126 SIPE_TRANSPORT_TCP,
127 SIPE_TRANSPORT_UDP,
128 } sipe_transport_type;
130 struct sipe_service_data {
131 const char *service;
132 const char *transport;
133 sipe_transport_type type;
136 /** MS-PRES publication */
137 struct sipe_publication {
138 gchar *category;
139 guint instance;
140 guint container;
141 guint version;
142 /** for 'state' category */
143 int availability;
144 /** for 'state:calendarState' category */
145 char *cal_event_hash;
146 /** for 'note' category */
147 gchar *note;
148 /** for 'calendarData' category; 300(Team) container */
149 char *working_hours_xml_str;
150 char *fb_start_str;
151 char *free_busy_base64;
154 /** MS-PRES container */
155 struct sipe_container {
156 guint id;
157 guint version;
158 GSList *members;
160 /** MS-PRES container member */
161 struct sipe_container_member {
162 /** user, domain, sameEnterprise, federated, publicCloud; everyone */
163 const gchar *type;
164 const gchar *value;
167 struct sipe_account_data {
168 PurpleConnection *gc;
169 gchar *sipdomain;
170 gchar *username;
171 gchar *authdomain;
172 gchar *authuser;
173 gchar *password;
174 gchar *epid;
175 gchar *focus_factory_uri;
176 /** Allowed server events to subscribe. From register OK response. */
177 GSList *allow_events;
178 PurpleDnsQueryData *query_data;
179 PurpleSrvQueryData *srv_query_data;
180 const struct sipe_service_data *service_data;
181 PurpleNetworkListenData *listen_data;
182 int fd;
183 int cseq;
184 time_t last_keepalive;
185 int registerstatus; /* 0 nothing, 1 first registration send, 2 auth received, 3 registered */
186 struct sip_auth registrar;
187 struct sip_auth proxy;
188 struct sip_csta *csta; /* For RCC - Remote Call Control */
189 gboolean reregister_set; /* whether reregister timer set */
190 gboolean reauthenticate_set; /* whether reauthenticate timer set */
191 gboolean subscribed; /* whether subscribed to events, except buddies presence */
192 gboolean subscribed_buddies; /* whether subscribed to buddies presence */
193 gboolean access_level_set; /* whether basic access level set */
194 gboolean initial_state_published; /* whether we published our initial state */
195 GSList *our_publication_keys; /* [MS-PRES] */
196 GHashTable *our_publications; /* [MS-PRES] */
197 GHashTable *user_state_publications; /* [MS-PRES] */
198 GHashTable *subscriptions;
199 int listenfd;
200 int listenport;
201 int listenpa;
202 int contacts_delta;
203 int acl_delta;
204 int presence_method_version;
205 time_t do_not_publish[SIPE_ACTIVITY_NUM_TYPES];
206 gchar *status;
207 gboolean is_oof_note;
208 gchar *note;
209 time_t note_since;
210 time_t idle_switch;
211 gchar *contact;
212 gchar *server_version;
213 gboolean ocs2007; /*if there is support for batched category subscription [SIP-PRES]*/
214 gboolean batched_support; /*if there is support for batched subscription*/
215 GSList *containers; /* MS-PRES containers */
216 GHashTable *buddies;
217 guint resendtimeout;
218 guint keepalive_timeout;
219 GSList *timeouts;
220 gboolean connecting;
221 PurpleAccount *account;
222 PurpleCircBuffer *txbuf;
223 guint tx_handler;
224 gchar *regcallid;
225 GSList *transactions;
226 GSList *sessions;
227 GSList *openconns;
228 GSList *groups;
229 GHashTable *filetransfers;
230 sipe_transport_type transport;
231 gboolean auto_transport;
232 PurpleSslConnection *gsc;
233 struct sockaddr *serveraddr;
234 gchar *realhostname;
235 int realport; /* port and hostname from SRV record */
236 gboolean processing_input;
237 struct sipe_ews *ews;
238 gchar *email;
239 /** 2005 Custom XML piece.
240 * Possibly set by other point of presence or just other client at earlier time.
241 * It should be preserved/modified, not overwritten. This implies subscription
242 * to self-contasct.
243 * This XML keeps OC2005:
244 * - User note
245 * - OOF flag
246 * - User status
248 xmlnode *user_info;
251 struct sip_connection {
252 int fd;
253 gchar *inbuf;
254 int inbuflen;
255 int inbufused;
256 int inputhandler;
259 struct sipe_auth_job {
260 gchar * who;
261 struct sipe_account_data * sip;
264 struct transaction;
266 typedef gboolean (*TransCallback) (struct sipe_account_data *, struct sipmsg *, struct transaction *);
268 struct transaction_payload {
269 GDestroyNotify destroy;
270 void *data;
273 struct transaction {
274 time_t time;
275 int retries;
276 int transport; /* 0 = tcp, 1 = udp */
277 int fd;
278 /** Not yet perfect, but surely better then plain CSeq
279 * Format is: <Call-ID><CSeq>
280 * (RFC3261 17.2.3 for matching server transactions: Request-URI, To tag, From tag, Call-ID, CSeq, and top Via)
282 gchar *key;
283 struct sipmsg *msg;
284 TransCallback callback;
285 struct transaction_payload *payload;
288 typedef void (*Action) (struct sipe_account_data *, void *);
291 * Do schedule action for execution in the future.
292 * Non repetitive execution.
294 * @param name of action (will be copied)
295 * @param timeout in seconds
296 * @param action callback function
297 * @param destroy payload destroy function
298 * @param sip
299 * @param payload callback data (can be NULL, otherwise caller must allocate memory)
301 void
302 sipe_schedule_action(const gchar *name,
303 int timeout,
304 Action action,
305 GDestroyNotify destroy,
306 struct sipe_account_data *sip,
307 void *payload);
309 struct sipe_group {
310 gchar *name;
311 int id;
312 PurpleGroup *purple_group;
315 struct group_user_context {
316 gchar * group_name;
317 gchar * user_name;
320 GSList * slist_insert_unique_sorted(GSList *list, gpointer data, GCompareFunc func);
322 GList *sipe_actions(PurplePlugin *plugin, gpointer context);
324 gboolean purple_init_plugin(PurplePlugin *plugin);
327 * Publishes self status
328 * based on own calendar information,
329 * our Calendar information - FreeBusy, WorkingHours,
330 * OOF note.
332 * For 2007+
334 void
335 publish_calendar_status_self(struct sipe_account_data *sip);
338 * For 2005-
340 void
341 send_presence_soap(struct sipe_account_data *sip,
342 gboolean do_publish_calendar);
345 * THE BIG SPLIT - temporary interfaces
347 * Previously private functions in sipe.c that are
348 * - waiting to be factored out to an appropriate module
349 * - are needed by the already created new modules
352 /* pier11:
354 * Since SIP (RFC3261) is extensible by its design,
355 * and MS specs prove just that (they all are defined as SIP extensions),
356 * it make sense to split functionality by extension (or close extension group).
357 * For example: conference, presence (MS-PRES), etc.
359 * This way our code will not be monolithic, but potentially _reusable_. May be
360 * a top of other SIP core, and/or other front-end (Telepathy framework?).
362 /* Forward declarations */
363 struct sip_session;
364 struct sip_dialog;
366 /* SIP send module? */
367 struct transaction *
368 send_sip_request(PurpleConnection *gc, const gchar *method,
369 const gchar *url, const gchar *to, const gchar *addheaders,
370 const gchar *body, struct sip_dialog *dialog, TransCallback tc);
371 void
372 send_sip_response(PurpleConnection *gc, struct sipmsg *msg, int code,
373 const char *text, const char *body);
374 void
375 sipe_invite(struct sipe_account_data *sip, struct sip_session *session,
376 const gchar *who, const gchar *msg_body, const gchar *msg_content_type,
377 const gchar *referred_by, const gboolean is_triggered);
378 /* ??? module */
379 gboolean process_subscribe_response(struct sipe_account_data *sip,
380 struct sipmsg *msg,
381 struct transaction *tc);
382 /* Chat module */
383 void
384 sipe_invite_to_chat(struct sipe_account_data *sip,
385 struct sip_session *session,
386 const gchar *who);
387 /* Session module? */
388 void
389 sipe_present_message_undelivered_err(struct sipe_account_data *sip,
390 struct sip_session *session,
391 int sip_error,
392 int sip_warning,
393 const gchar *who,
394 const gchar *message);
396 void
397 sipe_present_info(struct sipe_account_data *sip,
398 struct sip_session *session,
399 const gchar *message);
402 void
403 sipe_process_pending_invite_queue(struct sipe_account_data *sip,
404 struct sip_session *session);
406 void
407 sipe_im_process_queue (struct sipe_account_data * sip, struct sip_session * session);
410 /*** THE BIG SPLIT END ***/
412 #define SIPE_INVITE_TEXT "ms-text-format: %s; charset=UTF-8%s;ms-body=%s\r\n"
414 #define SIPE_SEND_TYPING \
415 "<?xml version=\"1.0\"?>"\
416 "<KeyboardActivity>"\
417 "<status status=\"type\" />"\
418 "</KeyboardActivity>"
421 * Publishes categories.
422 * @param uri (%s) Self URI. Ex.: sip:alice7@boston.local
423 * @param publications (%s) XML publications
425 #define SIPE_SEND_PRESENCE \
426 "<publish xmlns=\"http://schemas.microsoft.com/2006/09/sip/rich-presence\">"\
427 "<publications uri=\"%s\">"\
428 "%s"\
429 "</publications>"\
430 "</publish>"
433 * Publishes 'device' category.
434 * @param instance (%u) Ex.: 1938468728
435 * @param version (%u) Ex.: 1
436 * @param endpointId (%s) Ex.: C707E38E-1E10-5413-94D9-ECAC260A0269
437 * @param uri (%s) Self URI. Ex.: sip:alice7@boston.local
438 * @param timezone (%s) Ex.: 00:00:00+01:00
439 * @param machineName (%s) Ex.: BOSTON-OCS07
441 #define SIPE_PUB_XML_DEVICE \
442 "<publication categoryName=\"device\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
443 "<device xmlns=\"http://schemas.microsoft.com/2006/09/sip/device\" endpointId=\"%s\">"\
444 "<capabilities preferred=\"false\" uri=\"%s\">"\
445 "<text capture=\"true\" render=\"true\" publish=\"false\"/>"\
446 "<gifInk capture=\"false\" render=\"true\" publish=\"false\"/>"\
447 "<isfInk capture=\"false\" render=\"true\" publish=\"false\"/>"\
448 "</capabilities>"\
449 "<timezone>%s</timezone>"\
450 "<machineName>%s</machineName>"\
451 "</device>"\
452 "</publication>"
455 * Publishes 'machineState' category.
456 * @param instance (%u) Ex.: 926460663
457 * @param version (%u) Ex.: 22
458 * @param availability (%d) Ex.: 3500
459 * @param instance (%u) Ex.: 926460663
460 * @param version (%u) Ex.: 22
461 * @param availability (%d) Ex.: 3500
463 #define SIPE_PUB_XML_STATE_MACHINE \
464 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
465 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"false\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"machineState\">"\
466 "<availability>%d</availability>"\
467 "<endpointLocation/>"\
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\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"machineState\">"\
472 "<availability>%d</availability>"\
473 "<endpointLocation/>"\
474 "</state>"\
475 "</publication>"
478 * Publishes 'userState' category.
479 * @param instance (%u) User. Ex.: 536870912
480 * @param version (%u) User Container 2. Ex.: 22
481 * @param availability (%d) User Container 2. Ex.: 15500
482 * @param instance (%u) User. Ex.: 536870912
483 * @param version (%u) User Container 3.Ex.: 22
484 * @param availability (%d) User Container 3. Ex.: 15500
486 #define SIPE_PUB_XML_STATE_USER \
487 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"static\">"\
488 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"userState\">"\
489 "<availability>%d</availability>"\
490 "<endpointLocation/>"\
491 "</state>"\
492 "</publication>"\
493 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"static\">"\
494 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"userState\">"\
495 "<availability>%d</availability>"\
496 "<endpointLocation/>"\
497 "</state>"\
498 "</publication>"
501 * An availability XML entry for SIPE_PUB_XML_STATE_CALENDAR
502 * @param availability (%d) Ex.: 6500
504 #define SIPE_PUB_XML_STATE_CALENDAR_AVAIL \
505 "<availability>%d</availability>"
507 * An activity XML entry for SIPE_PUB_XML_STATE_CALENDAR
508 * @param token (%s) Ex.: in-a-meeting
509 * @param minAvailability_attr (%s) Ex.: minAvailability="6500"
510 * @param maxAvailability_attr (%s) Ex.: maxAvailability="8999" or none
512 #define SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY \
513 "<activity token=\"%s\" %s %s></activity>"
515 * Publishes 'calendarState' category.
516 * @param instance (%u) Ex.: 1339299275
517 * @param version (%u) Ex.: 1
518 * @param uri (%s) Ex.: john@contoso.com
519 * @param start_time_str (%s) Ex.: 2008-01-11T19:00:00Z
520 * @param availability (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_AVAIL
521 * @param activity (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY
522 * @param meeting_subject (%s) Ex.: Customer Meeting
523 * @param meeting_location (%s) Ex.: Conf Room 100
525 * @param instance (%u) Ex.: 1339299275
526 * @param version (%u) Ex.: 1
527 * @param uri (%s) Ex.: john@contoso.com
528 * @param start_time_str (%s) Ex.: 2008-01-11T19:00:00Z
529 * @param availability (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_AVAIL
530 * @param activity (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY
531 * @param meeting_subject (%s) Ex.: Customer Meeting
532 * @param meeting_location (%s) Ex.: Conf Room 100
534 #define SIPE_PUB_XML_STATE_CALENDAR \
535 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
536 "<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\">"\
537 "%s"\
538 "%s"\
539 "<endpointLocation/>"\
540 "<meetingSubject>%s</meetingSubject>"\
541 "<meetingLocation>%s</meetingLocation>"\
542 "</state>"\
543 "</publication>"\
544 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"endpoint\">"\
545 "<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\">"\
546 "%s"\
547 "%s"\
548 "<endpointLocation/>"\
549 "<meetingSubject>%s</meetingSubject>"\
550 "<meetingLocation>%s</meetingLocation>"\
551 "</state>"\
552 "</publication>"
555 * Publishes to clear 'calendarState' category
556 * @param instance (%u) Ex.: 1251210982
557 * @param version (%u) Ex.: 1
559 #define SIPE_PUB_XML_STATE_CALENDAR_CLEAR \
560 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\" expires=\"0\"/>"\
561 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"endpoint\" expires=\"0\"/>"
564 * Publishes to clear any category
565 * @param category_name (%s) Ex.: state
566 * @param instance (%u) Ex.: 536870912
567 * @param container (%u) Ex.: 3
568 * @param version (%u) Ex.: 1
569 * @param expireType (%s) Ex.: static
571 #define SIPE_PUB_XML_PUBLICATION_CLEAR \
572 "<publication categoryName=\"%s\" instance=\"%u\" container=\"%u\" version=\"%u\" expireType=\"%s\" expires=\"0\"/>"
575 * Publishes 'note' category.
576 * @param instance (%u) Ex.: 2135971629; 0 for personal
577 * @param container (%u) Ex.: 200
578 * @param version (%u) Ex.: 2
579 * @param type (%s) Ex.: personal or OOF
580 * @param startTime_attr (%s) Ex.: startTime="2008-01-11T19:00:00Z"
581 * @param endTime_attr (%s) Ex.: endTime="2008-01-15T19:00:00Z"
582 * @param body (%s) Ex.: In the office
584 #define SIPE_PUB_XML_NOTE \
585 "<publication categoryName=\"note\" instance=\"%u\" container=\"%u\" version=\"%d\" expireType=\"static\">"\
586 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
587 "<body type=\"%s\" uri=\"\"%s%s>%s</body>"\
588 "</note>"\
589 "</publication>"
592 * Publishes 'calendarData' category's WorkingHours.
594 * @param version (%u) Ex.: 1
595 * @param email (%s) Ex.: alice@cosmo.local
596 * @param working_hours_xml_str (%s) Ex.: <WorkingHours xmlns=.....
598 * @param version (%u)
600 * @param version (%u)
601 * @param email (%s)
602 * @param working_hours_xml_str (%s)
604 * @param version (%u)
605 * @param email (%s)
606 * @param working_hours_xml_str (%s)
608 * @param version (%u)
609 * @param email (%s)
610 * @param working_hours_xml_str (%s)
612 * @param version (%u)
614 #define SIPE_PUB_XML_WORKING_HOURS \
615 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"1\" version=\"%d\" expireType=\"static\">"\
616 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
617 "</calendarData>"\
618 "</publication>"\
619 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"100\" version=\"%d\" expireType=\"static\">"\
620 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
621 "</publication>"\
622 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"200\" version=\"%d\" expireType=\"static\">"\
623 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
624 "</calendarData>"\
625 "</publication>"\
626 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"300\" version=\"%d\" expireType=\"static\">"\
627 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
628 "</calendarData>"\
629 "</publication>"\
630 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"400\" version=\"%d\" expireType=\"static\">"\
631 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
632 "</calendarData>"\
633 "</publication>"\
634 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"32000\" version=\"%d\" expireType=\"static\">"\
635 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
636 "</publication>"
639 * Publishes 'calendarData' category's FreeBusy.
641 * @param instance (%u) Ex.: 1300372959
642 * @param version (%u) Ex.: 1
644 * @param instance (%u) Ex.: 1300372959
645 * @param version (%u) Ex.: 1
647 * @param instance (%u) Ex.: 1300372959
648 * @param version (%u) Ex.: 1
649 * @param email (%s) Ex.: alice@cosmo.local
650 * @param fb_start_time_str (%s) Ex.: 2009-12-03T00:00:00Z
651 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAAAAAA.....
653 * @param instance (%u) Ex.: 1300372959
654 * @param version (%u) Ex.: 1
655 * @param email (%s) Ex.: alice@cosmo.local
656 * @param fb_start_time_str (%s) Ex.: 2009-12-03T00:00:00Z
657 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAAAAAA.....
659 * @param instance (%u) Ex.: 1300372959
660 * @param version (%u) Ex.: 1
661 * @param email (%s) Ex.: alice@cosmo.local
662 * @param fb_start_time_str (%s) Ex.: 2009-12-03T00:00:00Z
663 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAAAAAA.....
665 * @param instance (%u) Ex.: 1300372959
666 * @param version (%u) Ex.: 1
668 #define SIPE_PUB_XML_FREE_BUSY \
669 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"1\" version=\"%d\" expireType=\"endpoint\">"\
670 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
671 "</publication>"\
672 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"100\" version=\"%d\" expireType=\"endpoint\">"\
673 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
674 "</publication>"\
675 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"200\" version=\"%d\" expireType=\"endpoint\">"\
676 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
677 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
678 "</calendarData>"\
679 "</publication>"\
680 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"300\" version=\"%d\" expireType=\"endpoint\">"\
681 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
682 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
683 "</calendarData>"\
684 "</publication>"\
685 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"400\" version=\"%d\" expireType=\"endpoint\">"\
686 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
687 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
688 "</calendarData>"\
689 "</publication>"\
690 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"32000\" version=\"%d\" expireType=\"endpoint\">"\
691 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
692 "</publication>"
695 #define sipe_soap(method, body) \
696 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
697 "<SOAP-ENV:Body>" \
698 "<m:" method " xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
699 body \
700 "</m:" method ">" \
701 "</SOAP-ENV:Body>" \
702 "</SOAP-ENV:Envelope>"
704 #define SIPE_SOAP_SET_CONTACT sipe_soap("setContact", \
705 "<m:displayName>%s</m:displayName>"\
706 "<m:groups>%s</m:groups>"\
707 "<m:subscribed>%s</m:subscribed>"\
708 "<m:URI>%s</m:URI>"\
709 "<m:externalURI />"\
710 "<m:deltaNum>%d</m:deltaNum>")
712 #define SIPE_SOAP_DEL_CONTACT sipe_soap("deleteContact", \
713 "<m:URI>%s</m:URI>"\
714 "<m:deltaNum>%d</m:deltaNum>")
716 #define SIPE_SOAP_ADD_GROUP sipe_soap("addGroup", \
717 "<m:name>%s</m:name>"\
718 "<m:externalURI />"\
719 "<m:deltaNum>%d</m:deltaNum>")
721 #define SIPE_SOAP_MOD_GROUP sipe_soap("modifyGroup", \
722 "<m:groupID>%d</m:groupID>"\
723 "<m:name>%s</m:name>"\
724 "<m:externalURI />"\
725 "<m:deltaNum>%d</m:deltaNum>")
727 #define SIPE_SOAP_DEL_GROUP sipe_soap("deleteGroup", \
728 "<m:groupID>%d</m:groupID>"\
729 "<m:deltaNum>%d</m:deltaNum>")
731 // first/mask arg is sip:user@domain.com
732 // second/rights arg is AA for allow, BD for deny
733 #define SIPE_SOAP_ALLOW_DENY sipe_soap("setACE", \
734 "<m:type>USER</m:type>"\
735 "<m:mask>%s</m:mask>"\
736 "<m:rights>%s</m:rights>"\
737 "<m:deltaNum>%d</m:deltaNum>")
740 * Calendar publication entry. 2005 systems.
742 * @param legacy_dn (%s) Ex.: /o=EXCHANGE/ou=BTUK02/cn=Recipients/cn=AHHBTT
743 * @param fb_start_time_str (%s) Ex.: 2009-12-06T17:15:00Z
744 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAA......
746 #define SIPE_SOAP_SET_PRESENCE_CALENDAR \
747 "<calendarInfo xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" mailboxId=\"%s\" startTime=\"%s\" granularity=\"PT15M\">%s</calendarInfo>"
749 * Note publication entry. 2005 systems.
751 * @param note (%s) Ex.: Working from home
753 #define SIPE_SOAP_SET_PRESENCE_NOTE_XML "<note>%s</note>"
755 * Note's OOF publication entry. 2005 systems.
757 #define SIPE_SOAP_SET_PRESENCE_OOF_XML "<oof></oof>"
759 * States publication entry for User State. 2005 systems.
761 * @param avail (%d) Availability 2007-style. Ex.: 9500
762 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
763 * @param device_id (%s) epid. Ex.: 4c77e6ec72
764 * @param activity_token (%s) Ex.: do-not-disturb
766 #define SIPE_SOAP_SET_PRESENCE_STATES \
767 "<states>"\
768 "<state avail=\"%d\" since=\"%s\" validWith=\"any-device\" deviceId=\"%s\" set=\"manual\" xsi:type=\"userState\">%s</state>"\
769 "</states>"
771 * Presentity publication entry. 2005 systems.
773 * @param uri (%s) SIP URI without 'sip:' prefix. Ex.: fox@atlanta.local
774 * @param aggr_availability (%d) Ex.: 300
775 * @param aggr_activity (%d) Ex.: 600
776 * @param host_name (%s) Uppercased. Ex.: ATLANTA
777 * @param note_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_NOTE_XML
778 * @param oof_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_OOF_XML
779 * @param states_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_STATES
780 * @param calendar_info_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_CALENDAR
781 * @param device_id (%s) epid. Ex.: 4c77e6ec72
782 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
783 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
784 * @param user_input (%s) active, idle
786 #define SIPE_SOAP_SET_PRESENCE sipe_soap("setPresence", \
787 "<m:presentity xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" m:uri=\"sip:%s\">"\
788 "<m:availability m:aggregate=\"%d\"/>"\
789 "<m:activity m:aggregate=\"%d\"/>"\
790 "<deviceName xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" name=\"%s\"/>"\
791 "<rtc:devicedata xmlns:rtc=\"http://schemas.microsoft.com/winrtc/2002/11/sip\" namespace=\"rtcService\">"\
792 "<![CDATA[<caps><renders_gif/><renders_isf/></caps>]]></rtc:devicedata>"\
793 "<userInfo xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\">"\
794 "%s%s" \
795 "%s" \
796 "</userInfo>"\
797 "%s" \
798 "<device xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" deviceId=\"%s\" since=\"%s\" >"\
799 "<userInput since=\"%s\" >%s</userInput>"\
800 "</device>"\
801 "</m:presentity>")
803 #define SIPE_SOAP_SEARCH_CONTACT \
804 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
805 "<SOAP-ENV:Body>" \
806 "<m:directorySearch xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
807 "<m:filter m:href=\"#searchArray\"/>"\
808 "<m:maxResults>%d</m:maxResults>"\
809 "</m:directorySearch>"\
810 "<m:Array xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\" m:id=\"searchArray\">"\
811 "%s"\
812 "</m:Array>"\
813 "</SOAP-ENV:Body>"\
814 "</SOAP-ENV:Envelope>"
816 #define SIPE_SOAP_SEARCH_ROW "<m:row m:attrib=\"%s\" m:value=\"%s\"/>"
818 #endif /* _PIDGIN_SIPE_H */