presence: added time dimention to not-republish
[siplcs.git] / src / core / sipe.h
blobcfce45125ae3f6ec446ae8ec712c2400b24b27c4
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 gchar *annotation;
83 gboolean is_oof_note;
85 /* Calendar related fields */
86 gchar *cal_start_time;
87 int cal_granularity;
88 gchar *cal_free_busy_base64;
89 gchar *cal_free_busy;
90 /* for 2005 systems */
91 int user_avail;
92 time_t user_avail_since;
93 time_t activity_since;
94 const char *last_non_cal_status_id;
95 gchar *last_non_cal_activity;
97 struct sipe_cal_working_hours *cal_working_hours;
99 gchar *device_name;
100 GSList *groups;
101 /** flag to control sending 'context' element in 2007 subscriptions */
102 gboolean just_added;
105 struct sip_auth {
106 SipSecAuthType type;
107 SipSecContext gssapi_context;
108 gchar *gssapi_data;
109 gchar *opaque;
110 gchar *realm;
111 gchar *target;
112 int nc;
113 int retries;
114 int ntlm_num;
115 int expires;
118 typedef enum {
119 SIPE_TRANSPORT_TLS,
120 SIPE_TRANSPORT_TCP,
121 SIPE_TRANSPORT_UDP,
122 } sipe_transport_type;
124 struct sipe_service_data {
125 const char *service;
126 const char *transport;
127 sipe_transport_type type;
130 /** MS-PRES publication */
131 struct sipe_publication {
132 gchar *category;
133 guint instance;
134 guint container;
135 guint version;
136 /** for 'state' category */
137 int availability;
138 /** for 'state:calendarState' category */
139 char *cal_event_hash;
140 /** for 'note' category */
141 gchar *note;
142 /** for 'calendarData' category; 300(Team) container */
143 char *working_hours_xml_str;
144 char *fb_start_str;
145 char *free_busy_base64;
148 /** MS-PRES container */
149 struct sipe_container {
150 guint id;
151 guint version;
152 GSList *members;
154 /** MS-PRES container member */
155 struct sipe_container_member {
156 /** user, domain, sameEnterprise, federated, publicCloud; everyone */
157 const gchar *type;
158 const gchar *value;
161 struct sipe_account_data {
162 PurpleConnection *gc;
163 gchar *sipdomain;
164 gchar *username;
165 gchar *authdomain;
166 gchar *authuser;
167 gchar *password;
168 gchar *epid;
169 gchar *focus_factory_uri;
170 /** Allowed server events to subscribe. From register OK response. */
171 GSList *allow_events;
172 PurpleDnsQueryData *query_data;
173 PurpleSrvQueryData *srv_query_data;
174 const struct sipe_service_data *service_data;
175 PurpleNetworkListenData *listen_data;
176 int fd;
177 int cseq;
178 time_t last_keepalive;
179 int registerstatus; /* 0 nothing, 1 first registration send, 2 auth received, 3 registered */
180 struct sip_auth registrar;
181 struct sip_auth proxy;
182 struct sip_csta *csta; /* For RCC - Remote Call Control */
183 gboolean reregister_set; /* whether reregister timer set */
184 gboolean reauthenticate_set; /* whether reauthenticate timer set */
185 gboolean subscribed; /* whether subscribed to events, except buddies presence */
186 gboolean subscribed_buddies; /* whether subscribed to buddies presence */
187 gboolean access_level_set; /* whether basic access level set */
188 gboolean initial_state_published; /* whether we published our initial state */
189 GSList *our_publication_keys; /* [MS-PRES] */
190 GHashTable *our_publications; /* [MS-PRES] */
191 GHashTable *user_state_publications; /* [MS-PRES] */
192 GHashTable *subscriptions;
193 int listenfd;
194 int listenport;
195 int listenpa;
196 int contacts_delta;
197 int acl_delta;
198 int presence_method_version;
199 time_t do_not_publish[SIPE_ACTIVITY_NUM_TYPES];
200 gchar *status;
201 gchar *note;
202 gboolean is_idle;
203 gboolean was_idle;
204 gchar *contact;
205 gchar *server_version;
206 gboolean ocs2007; /*if there is support for batched category subscription [SIP-PRES]*/
207 gboolean batched_support; /*if there is support for batched subscription*/
208 GSList *containers; /* MS-PRES containers */
209 GHashTable *buddies;
210 guint resendtimeout;
211 guint keepalive_timeout;
212 GSList *timeouts;
213 gboolean connecting;
214 PurpleAccount *account;
215 PurpleCircBuffer *txbuf;
216 guint tx_handler;
217 gchar *regcallid;
218 GSList *transactions;
219 GSList *sessions;
220 GSList *openconns;
221 GSList *groups;
222 sipe_transport_type transport;
223 gboolean auto_transport;
224 PurpleSslConnection *gsc;
225 struct sockaddr *serveraddr;
226 gchar *realhostname;
227 int realport; /* port and hostname from SRV record */
228 gboolean processing_input;
229 struct sipe_ews *ews;
230 gchar *email;
231 /** 2005 Custom XML piece.
232 * Possibly set by other point of presence or just other client at earlier time.
233 * It should be preserved/modified, not overwritten. This implies subscription
234 * to self-contasct.
235 * This XML keeps OC2005:
236 * - User note
237 * - OOF flag
238 * - User status
240 xmlnode *user_info;
243 struct sip_connection {
244 int fd;
245 gchar *inbuf;
246 int inbuflen;
247 int inbufused;
248 int inputhandler;
251 struct sipe_auth_job {
252 gchar * who;
253 struct sipe_account_data * sip;
256 struct transaction;
258 typedef gboolean (*TransCallback) (struct sipe_account_data *, struct sipmsg *, struct transaction *);
260 struct transaction_payload {
261 GDestroyNotify destroy;
262 void *data;
265 struct transaction {
266 time_t time;
267 int retries;
268 int transport; /* 0 = tcp, 1 = udp */
269 int fd;
270 /** Not yet perfect, but surely better then plain CSeq
271 * Format is: <Call-ID><CSeq>
272 * (RFC3261 17.2.3 for matching server transactions: Request-URI, To tag, From tag, Call-ID, CSeq, and top Via)
274 gchar *key;
275 struct sipmsg *msg;
276 TransCallback callback;
277 struct transaction_payload *payload;
280 typedef void (*Action) (struct sipe_account_data *, void *);
283 * Do schedule action for execution in the future.
284 * Non repetitive execution.
286 * @param name of action (will be copied)
287 * @param timeout in seconds
288 * @param action callback function
289 * @param destroy payload destroy function
290 * @param sip
291 * @param payload callback data (can be NULL, otherwise caller must allocate memory)
293 void
294 sipe_schedule_action(const gchar *name,
295 int timeout,
296 Action action,
297 GDestroyNotify destroy,
298 struct sipe_account_data *sip,
299 void *payload);
301 struct sipe_group {
302 gchar *name;
303 int id;
304 PurpleGroup *purple_group;
307 struct group_user_context {
308 gchar * group_name;
309 gchar * user_name;
312 GSList * slist_insert_unique_sorted(GSList *list, gpointer data, GCompareFunc func);
314 GList *sipe_actions(PurplePlugin *plugin, gpointer context);
316 gboolean purple_init_plugin(PurplePlugin *plugin);
319 * Publishes self status
320 * based on own calendar information,
321 * our Calendar information - FreeBusy, WorkingHours,
322 * OOF note.
324 * For 2007+
326 void
327 publish_calendar_status_self(struct sipe_account_data *sip);
330 * For 2005-
332 void
333 send_presence_soap(struct sipe_account_data *sip,
334 gboolean do_publish_calendar);
337 * THE BIG SPLIT - temporary interfaces
339 * Previously private functions in sipe.c that are
340 * - waiting to be factored out to an appropriate module
341 * - are needed by the already created new modules
344 /* pier11:
346 * Since SIP (RFC3261) is extensible by its design,
347 * and MS specs prove just that (they all are defined as SIP extensions),
348 * it make sense to split functionality by extension (or close extension group).
349 * For example: conference, presence (MS-PRES), etc.
351 * This way our code will not be monolithic, but potentially _reusable_. May be
352 * a top of other SIP core, and/or other front-end (Telepathy framework?).
354 /* Forward declarations */
355 struct sip_session;
356 struct sip_dialog;
358 /* SIP send module? */
359 struct transaction *
360 send_sip_request(PurpleConnection *gc, const gchar *method,
361 const gchar *url, const gchar *to, const gchar *addheaders,
362 const gchar *body, struct sip_dialog *dialog, TransCallback tc);
363 void
364 send_sip_response(PurpleConnection *gc, struct sipmsg *msg, int code,
365 const char *text, const char *body);
366 void
367 sipe_invite(struct sipe_account_data *sip, struct sip_session *session,
368 const gchar *who, const gchar *msg_body,
369 const gchar *referred_by, const gboolean is_triggered);
370 /* ??? module */
371 gboolean process_subscribe_response(struct sipe_account_data *sip,
372 struct sipmsg *msg,
373 struct transaction *tc);
374 /* Chat module */
375 void
376 sipe_invite_to_chat(struct sipe_account_data *sip,
377 struct sip_session *session,
378 const gchar *who);
379 /* Session module? */
380 void
381 sipe_present_message_undelivered_err(struct sipe_account_data *sip,
382 struct sip_session *session,
383 int sip_error,
384 const gchar *who,
385 const gchar *message);
387 void
388 sipe_present_info(struct sipe_account_data *sip,
389 struct sip_session *session,
390 const gchar *message);
393 void
394 sipe_process_pending_invite_queue(struct sipe_account_data *sip,
395 struct sip_session *session);
397 /*** THE BIG SPLIT END ***/
399 #define SIPE_XML_DATE_PATTERN "%Y-%m-%dT%H:%M:%SZ"
401 #define SIPE_INVITE_TEXT "ms-text-format: text/plain; charset=UTF-8%s;ms-body=%s\r\n"
403 #define SIPE_SEND_TYPING \
404 "<?xml version=\"1.0\"?>"\
405 "<KeyboardActivity>"\
406 "<status status=\"type\" />"\
407 "</KeyboardActivity>"
410 * Publishes categories.
411 * @param uri (%s) Self URI. Ex.: sip:alice7@boston.local
412 * @param publications (%s) XML publications
414 #define SIPE_SEND_PRESENCE \
415 "<publish xmlns=\"http://schemas.microsoft.com/2006/09/sip/rich-presence\">"\
416 "<publications uri=\"%s\">"\
417 "%s"\
418 "</publications>"\
419 "</publish>"
422 * Publishes 'device' category.
423 * @param instance (%u) Ex.: 1938468728
424 * @param version (%u) Ex.: 1
425 * @param endpointId (%s) Ex.: C707E38E-1E10-5413-94D9-ECAC260A0269
426 * @param uri (%s) Self URI. Ex.: sip:alice7@boston.local
427 * @param timezone (%s) Ex.: 00:00:00+01:00
428 * @param machineName (%s) Ex.: BOSTON-OCS07
430 #define SIPE_PUB_XML_DEVICE \
431 "<publication categoryName=\"device\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
432 "<device xmlns=\"http://schemas.microsoft.com/2006/09/sip/device\" endpointId=\"%s\">"\
433 "<capabilities preferred=\"false\" uri=\"%s\">"\
434 "<text capture=\"true\" render=\"true\" publish=\"false\"/>"\
435 "<gifInk capture=\"false\" render=\"true\" publish=\"false\"/>"\
436 "<isfInk capture=\"false\" render=\"true\" publish=\"false\"/>"\
437 "</capabilities>"\
438 "<timezone>%s</timezone>"\
439 "<machineName>%s</machineName>"\
440 "</device>"\
441 "</publication>"
444 * Publishes 'machineState' category.
445 * @param instance (%u) Ex.: 926460663
446 * @param version (%u) Ex.: 22
447 * @param availability (%d) Ex.: 3500
448 * @param instance (%u) Ex.: 926460663
449 * @param version (%u) Ex.: 22
450 * @param availability (%d) Ex.: 3500
452 #define SIPE_PUB_XML_STATE_MACHINE \
453 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
454 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"false\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"machineState\">"\
455 "<availability>%d</availability>"\
456 "<endpointLocation/>"\
457 "</state>"\
458 "</publication>"\
459 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"endpoint\">"\
460 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"false\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"machineState\">"\
461 "<availability>%d</availability>"\
462 "<endpointLocation/>"\
463 "</state>"\
464 "</publication>"
467 * Publishes 'userState' category.
468 * @param instance (%u) User. Ex.: 536870912
469 * @param version (%u) User Container 2. Ex.: 22
470 * @param availability (%d) User Container 2. Ex.: 15500
471 * @param instance (%u) User. Ex.: 536870912
472 * @param version (%u) User Container 3.Ex.: 22
473 * @param availability (%d) User Container 3. Ex.: 15500
475 #define SIPE_PUB_XML_STATE_USER \
476 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"static\">"\
477 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"userState\">"\
478 "<availability>%d</availability>"\
479 "<endpointLocation/>"\
480 "</state>"\
481 "</publication>"\
482 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"static\">"\
483 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"userState\">"\
484 "<availability>%d</availability>"\
485 "<endpointLocation/>"\
486 "</state>"\
487 "</publication>"
490 * An availability XML entry for SIPE_PUB_XML_STATE_CALENDAR
491 * @param availability (%d) Ex.: 6500
493 #define SIPE_PUB_XML_STATE_CALENDAR_AVAIL \
494 "<availability>%d</availability>"
496 * An activity XML entry for SIPE_PUB_XML_STATE_CALENDAR
497 * @param token (%s) Ex.: in-a-meeting
498 * @param minAvailability_attr (%s) Ex.: minAvailability="6500"
499 * @param maxAvailability_attr (%s) Ex.: maxAvailability="8999" or none
501 #define SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY \
502 "<activity token=\"%s\" %s %s></activity>"
504 * Publishes 'calendarState' category.
505 * @param instance (%u) Ex.: 1339299275
506 * @param version (%u) Ex.: 1
507 * @param uri (%s) Ex.: john@contoso.com
508 * @param start_time_str (%s) Ex.: 2008-01-11T19:00:00Z
509 * @param availability (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_AVAIL
510 * @param activity (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY
511 * @param meeting_subject (%s) Ex.: Customer Meeting
512 * @param meeting_location (%s) Ex.: Conf Room 100
514 * @param instance (%u) Ex.: 1339299275
515 * @param version (%u) Ex.: 1
516 * @param uri (%s) Ex.: john@contoso.com
517 * @param start_time_str (%s) Ex.: 2008-01-11T19:00:00Z
518 * @param availability (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_AVAIL
519 * @param activity (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY
520 * @param meeting_subject (%s) Ex.: Customer Meeting
521 * @param meeting_location (%s) Ex.: Conf Room 100
523 #define SIPE_PUB_XML_STATE_CALENDAR \
524 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
525 "<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\">"\
526 "%s"\
527 "%s"\
528 "<endpointLocation/>"\
529 "<meetingSubject>%s</meetingSubject>"\
530 "<meetingLocation>%s</meetingLocation>"\
531 "</state>"\
532 "</publication>"\
533 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"endpoint\">"\
534 "<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\">"\
535 "%s"\
536 "%s"\
537 "<endpointLocation/>"\
538 "<meetingSubject>%s</meetingSubject>"\
539 "<meetingLocation>%s</meetingLocation>"\
540 "</state>"\
541 "</publication>"
544 * Publishes to clear 'calendarState' category
545 * @param instance (%u) Ex.: 1251210982
546 * @param version (%u) Ex.: 1
548 #define SIPE_PUB_XML_STATE_CALENDAR_CLEAR \
549 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\" expires=\"0\"/>"\
550 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"endpoint\" expires=\"0\"/>"
553 * Publishes to clear any category
554 * @param category_name (%s) Ex.: state
555 * @param instance (%u) Ex.: 536870912
556 * @param container (%u) Ex.: 3
557 * @param version (%u) Ex.: 1
558 * @param expireType (%s) Ex.: static
560 #define SIPE_PUB_XML_PUBLICATION_CLEAR \
561 "<publication categoryName=\"%s\" instance=\"%u\" container=\"%u\" version=\"%u\" expireType=\"%s\" expires=\"0\"/>"
564 * Publishes 'note' category.
565 * @param instance (%u) Ex.: 2135971629; 0 for personal
566 * @param version (%u) Ex.: 2
567 * @param type (%s) Ex.: personal or OOF
568 * @param body (%s) Ex.: In the office
570 * @param instance (%u) Ex.: 2135971629; 0 for personal
571 * @param version (%u) Ex.: 2
572 * @param type (%s) Ex.: personal or OOF
573 * @param body (%s) Ex.: In the office
575 * @param instance (%u) Ex.: 2135971629; 0 for personal
576 * @param version (%u) Ex.: 2
577 * @param type (%s) Ex.: personal or OOF
578 * @param body (%s) Ex.: In the office
580 #define SIPE_PUB_XML_NOTE \
581 "<publication categoryName=\"note\" instance=\"%u\" container=\"200\" version=\"%d\" expireType=\"static\">"\
582 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
583 "<body type=\"%s\" uri=\"\">%s</body>"\
584 "</note>"\
585 "</publication>"\
586 "<publication categoryName=\"note\" instance=\"%u\" container=\"300\" version=\"%d\" expireType=\"static\">"\
587 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
588 "<body type=\"%s\" uri=\"\">%s</body>"\
589 "</note>"\
590 "</publication>"\
591 "<publication categoryName=\"note\" instance=\"%u\" container=\"400\" version=\"%d\" expireType=\"static\">"\
592 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
593 "<body type=\"%s\" uri=\"\">%s</body>"\
594 "</note>"\
595 "</publication>"
598 * Publishes 'calendarData' category's WorkingHours.
600 * @param version (%u) Ex.: 1
601 * @param email (%s) Ex.: alice@cosmo.local
602 * @param working_hours_xml_str (%s) Ex.: <WorkingHours xmlns=.....
604 * @param version (%u)
606 * @param version (%u)
607 * @param email (%s)
608 * @param working_hours_xml_str (%s)
610 * @param version (%u)
611 * @param email (%s)
612 * @param working_hours_xml_str (%s)
614 * @param version (%u)
615 * @param email (%s)
616 * @param working_hours_xml_str (%s)
618 * @param version (%u)
620 #define SIPE_PUB_XML_WORKING_HOURS \
621 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"1\" 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=\"100\" version=\"%d\" expireType=\"static\">"\
626 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
627 "</publication>"\
628 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"200\" version=\"%d\" expireType=\"static\">"\
629 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
630 "</calendarData>"\
631 "</publication>"\
632 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"300\" version=\"%d\" expireType=\"static\">"\
633 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
634 "</calendarData>"\
635 "</publication>"\
636 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"400\" version=\"%d\" expireType=\"static\">"\
637 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
638 "</calendarData>"\
639 "</publication>"\
640 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"32000\" version=\"%d\" expireType=\"static\">"\
641 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
642 "</publication>"
645 * Publishes 'calendarData' category's FreeBusy.
647 * @param instance (%u) Ex.: 1300372959
648 * @param version (%u) Ex.: 1
650 * @param instance (%u) Ex.: 1300372959
651 * @param version (%u) Ex.: 1
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
667 * @param email (%s) Ex.: alice@cosmo.local
668 * @param fb_start_time_str (%s) Ex.: 2009-12-03T00:00:00Z
669 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAAAAAA.....
671 * @param instance (%u) Ex.: 1300372959
672 * @param version (%u) Ex.: 1
674 #define SIPE_PUB_XML_FREE_BUSY \
675 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"1\" version=\"%d\" expireType=\"endpoint\">"\
676 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
677 "</publication>"\
678 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"100\" version=\"%d\" expireType=\"endpoint\">"\
679 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
680 "</publication>"\
681 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"200\" version=\"%d\" expireType=\"endpoint\">"\
682 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
683 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
684 "</calendarData>"\
685 "</publication>"\
686 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"300\" version=\"%d\" expireType=\"endpoint\">"\
687 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
688 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
689 "</calendarData>"\
690 "</publication>"\
691 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"400\" version=\"%d\" expireType=\"endpoint\">"\
692 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
693 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
694 "</calendarData>"\
695 "</publication>"\
696 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"32000\" version=\"%d\" expireType=\"endpoint\">"\
697 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
698 "</publication>"
701 #define sipe_soap(method, body) \
702 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
703 "<SOAP-ENV:Body>" \
704 "<m:" method " xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
705 body \
706 "</m:" method ">" \
707 "</SOAP-ENV:Body>" \
708 "</SOAP-ENV:Envelope>"
710 #define SIPE_SOAP_SET_CONTACT sipe_soap("setContact", \
711 "<m:displayName>%s</m:displayName>"\
712 "<m:groups>%s</m:groups>"\
713 "<m:subscribed>%s</m:subscribed>"\
714 "<m:URI>%s</m:URI>"\
715 "<m:externalURI />"\
716 "<m:deltaNum>%d</m:deltaNum>")
718 #define SIPE_SOAP_DEL_CONTACT sipe_soap("deleteContact", \
719 "<m:URI>%s</m:URI>"\
720 "<m:deltaNum>%d</m:deltaNum>")
722 #define SIPE_SOAP_ADD_GROUP sipe_soap("addGroup", \
723 "<m:name>%s</m:name>"\
724 "<m:externalURI />"\
725 "<m:deltaNum>%d</m:deltaNum>")
727 #define SIPE_SOAP_MOD_GROUP sipe_soap("modifyGroup", \
728 "<m:groupID>%d</m:groupID>"\
729 "<m:name>%s</m:name>"\
730 "<m:externalURI />"\
731 "<m:deltaNum>%d</m:deltaNum>")
733 #define SIPE_SOAP_DEL_GROUP sipe_soap("deleteGroup", \
734 "<m:groupID>%d</m:groupID>"\
735 "<m:deltaNum>%d</m:deltaNum>")
737 // first/mask arg is sip:user@domain.com
738 // second/rights arg is AA for allow, BD for deny
739 #define SIPE_SOAP_ALLOW_DENY sipe_soap("setACE", \
740 "<m:type>USER</m:type>"\
741 "<m:mask>%s</m:mask>"\
742 "<m:rights>%s</m:rights>"\
743 "<m:deltaNum>%d</m:deltaNum>")
746 * Calendar publication entry. 2005 systems.
748 * @param legacy_dn (%s) Ex.: /o=EXCHANGE/ou=BTUK02/cn=Recipients/cn=AHHBTT
749 * @param fb_start_time_str (%s) Ex.: 2009-12-06T17:15:00Z
750 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAA......
752 #define SIPE_SOAP_SET_PRESENCE_CALENDAR \
753 "<calendarInfo xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" mailboxId=\"%s\" startTime=\"%s\" granularity=\"PT15M\">%s</calendarInfo>"
755 * Note publication entry. 2005 systems.
757 * @param note (%s) Ex.: Working from home
759 #define SIPE_SOAP_SET_PRESENCE_NOTE_XML "<note>%s</note>"
761 * Note's OOF publication entry. 2005 systems.
763 #define SIPE_SOAP_SET_PRESENCE_OOF_XML "<oof></oof>"
765 * States publication entry for User State. 2005 systems.
767 * @param avail (%d) Availability 2007-style. Ex.: 9500
768 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
769 * @param device_id (%s) epid. Ex.: 4c77e6ec72
770 * @param activity_token (%s) Ex.: do-not-disturb
772 #define SIPE_SOAP_SET_PRESENCE_STATES \
773 "<states>"\
774 "<state avail=\"%d\" since=\"%s\" validWith=\"any-device\" deviceId=\"%s\" set=\"manual\" xsi:type=\"userState\">%s</state>"\
775 "</states>"
777 * Presentity publication entry. 2005 systems.
779 * @param uri (%s) SIP URI without 'sip:' prefix. Ex.: fox@atlanta.local
780 * @param aggr_availability (%d) Ex.: 300
781 * @param aggr_activity (%d) Ex.: 600
782 * @param host_name (%s) Uppercased. Ex.: ATLANTA
783 * @param note_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_NOTE_XML
784 * @param oof_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_OOF_XML
785 * @param states_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_STATES
786 * @param calendar_info_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_CALENDAR
787 * @param device_id (%s) epid. Ex.: 4c77e6ec72
788 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
789 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
790 * @param user_input (%s) active, idle
792 #define SIPE_SOAP_SET_PRESENCE sipe_soap("setPresence", \
793 "<m:presentity xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" m:uri=\"sip:%s\">"\
794 "<m:availability m:aggregate=\"%d\"/>"\
795 "<m:activity m:aggregate=\"%d\"/>"\
796 "<deviceName xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" name=\"%s\"/>"\
797 "<rtc:devicedata xmlns:rtc=\"http://schemas.microsoft.com/winrtc/2002/11/sip\" namespace=\"rtcService\">"\
798 "<![CDATA[<caps><renders_gif/><renders_isf/></caps>]]></rtc:devicedata>"\
799 "<userInfo xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\">"\
800 "%s%s" \
801 "%s" \
802 "</userInfo>"\
803 "%s" \
804 "<device xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" deviceId=\"%s\" since=\"%s\" >"\
805 "<userInput since=\"%s\" >%s</userInput>"\
806 "</device>"\
807 "</m:presentity>")
809 #define SIPE_SOAP_SEARCH_CONTACT \
810 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
811 "<SOAP-ENV:Body>" \
812 "<m:directorySearch xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
813 "<m:filter m:href=\"#searchArray\"/>"\
814 "<m:maxResults>%d</m:maxResults>"\
815 "</m:directorySearch>"\
816 "<m:Array xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\" m:id=\"searchArray\">"\
817 "%s"\
818 "</m:Array>"\
819 "</SOAP-ENV:Body>"\
820 "</SOAP-ENV:Envelope>"
822 #define SIPE_SOAP_SEARCH_ROW "<m:row m:attrib=\"%s\" m:value=\"%s\"/>"
824 #endif /* _PIDGIN_SIPE_H */