presence.2005: choose note vs. oof note based on time
[siplcs.git] / src / core / sipe.h
blob22560c5e3457e323329ac5fa8a8ffe1e3bee1693
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 gboolean is_oof_note;
202 gchar *note;
203 time_t note_since;
204 gboolean is_idle;
205 gboolean was_idle;
206 gchar *contact;
207 gchar *server_version;
208 gboolean ocs2007; /*if there is support for batched category subscription [SIP-PRES]*/
209 gboolean batched_support; /*if there is support for batched subscription*/
210 GSList *containers; /* MS-PRES containers */
211 GHashTable *buddies;
212 guint resendtimeout;
213 guint keepalive_timeout;
214 GSList *timeouts;
215 gboolean connecting;
216 PurpleAccount *account;
217 PurpleCircBuffer *txbuf;
218 guint tx_handler;
219 gchar *regcallid;
220 GSList *transactions;
221 GSList *sessions;
222 GSList *openconns;
223 GSList *groups;
224 sipe_transport_type transport;
225 gboolean auto_transport;
226 PurpleSslConnection *gsc;
227 struct sockaddr *serveraddr;
228 gchar *realhostname;
229 int realport; /* port and hostname from SRV record */
230 gboolean processing_input;
231 struct sipe_ews *ews;
232 gchar *email;
233 /** 2005 Custom XML piece.
234 * Possibly set by other point of presence or just other client at earlier time.
235 * It should be preserved/modified, not overwritten. This implies subscription
236 * to self-contasct.
237 * This XML keeps OC2005:
238 * - User note
239 * - OOF flag
240 * - User status
242 xmlnode *user_info;
245 struct sip_connection {
246 int fd;
247 gchar *inbuf;
248 int inbuflen;
249 int inbufused;
250 int inputhandler;
253 struct sipe_auth_job {
254 gchar * who;
255 struct sipe_account_data * sip;
258 struct transaction;
260 typedef gboolean (*TransCallback) (struct sipe_account_data *, struct sipmsg *, struct transaction *);
262 struct transaction_payload {
263 GDestroyNotify destroy;
264 void *data;
267 struct transaction {
268 time_t time;
269 int retries;
270 int transport; /* 0 = tcp, 1 = udp */
271 int fd;
272 /** Not yet perfect, but surely better then plain CSeq
273 * Format is: <Call-ID><CSeq>
274 * (RFC3261 17.2.3 for matching server transactions: Request-URI, To tag, From tag, Call-ID, CSeq, and top Via)
276 gchar *key;
277 struct sipmsg *msg;
278 TransCallback callback;
279 struct transaction_payload *payload;
282 typedef void (*Action) (struct sipe_account_data *, void *);
285 * Do schedule action for execution in the future.
286 * Non repetitive execution.
288 * @param name of action (will be copied)
289 * @param timeout in seconds
290 * @param action callback function
291 * @param destroy payload destroy function
292 * @param sip
293 * @param payload callback data (can be NULL, otherwise caller must allocate memory)
295 void
296 sipe_schedule_action(const gchar *name,
297 int timeout,
298 Action action,
299 GDestroyNotify destroy,
300 struct sipe_account_data *sip,
301 void *payload);
303 struct sipe_group {
304 gchar *name;
305 int id;
306 PurpleGroup *purple_group;
309 struct group_user_context {
310 gchar * group_name;
311 gchar * user_name;
314 GSList * slist_insert_unique_sorted(GSList *list, gpointer data, GCompareFunc func);
316 GList *sipe_actions(PurplePlugin *plugin, gpointer context);
318 gboolean purple_init_plugin(PurplePlugin *plugin);
321 * Publishes self status
322 * based on own calendar information,
323 * our Calendar information - FreeBusy, WorkingHours,
324 * OOF note.
326 * For 2007+
328 void
329 publish_calendar_status_self(struct sipe_account_data *sip);
332 * For 2005-
334 void
335 send_presence_soap(struct sipe_account_data *sip,
336 gboolean do_publish_calendar);
339 * THE BIG SPLIT - temporary interfaces
341 * Previously private functions in sipe.c that are
342 * - waiting to be factored out to an appropriate module
343 * - are needed by the already created new modules
346 /* pier11:
348 * Since SIP (RFC3261) is extensible by its design,
349 * and MS specs prove just that (they all are defined as SIP extensions),
350 * it make sense to split functionality by extension (or close extension group).
351 * For example: conference, presence (MS-PRES), etc.
353 * This way our code will not be monolithic, but potentially _reusable_. May be
354 * a top of other SIP core, and/or other front-end (Telepathy framework?).
356 /* Forward declarations */
357 struct sip_session;
358 struct sip_dialog;
360 /* SIP send module? */
361 struct transaction *
362 send_sip_request(PurpleConnection *gc, const gchar *method,
363 const gchar *url, const gchar *to, const gchar *addheaders,
364 const gchar *body, struct sip_dialog *dialog, TransCallback tc);
365 void
366 send_sip_response(PurpleConnection *gc, struct sipmsg *msg, int code,
367 const char *text, const char *body);
368 void
369 sipe_invite(struct sipe_account_data *sip, struct sip_session *session,
370 const gchar *who, const gchar *msg_body,
371 const gchar *referred_by, const gboolean is_triggered);
372 /* ??? module */
373 gboolean process_subscribe_response(struct sipe_account_data *sip,
374 struct sipmsg *msg,
375 struct transaction *tc);
376 /* Chat module */
377 void
378 sipe_invite_to_chat(struct sipe_account_data *sip,
379 struct sip_session *session,
380 const gchar *who);
381 /* Session module? */
382 void
383 sipe_present_message_undelivered_err(struct sipe_account_data *sip,
384 struct sip_session *session,
385 int sip_error,
386 const gchar *who,
387 const gchar *message);
389 void
390 sipe_present_info(struct sipe_account_data *sip,
391 struct sip_session *session,
392 const gchar *message);
395 void
396 sipe_process_pending_invite_queue(struct sipe_account_data *sip,
397 struct sip_session *session);
399 /*** THE BIG SPLIT END ***/
401 #define SIPE_XML_DATE_PATTERN "%Y-%m-%dT%H:%M:%SZ"
403 #define SIPE_INVITE_TEXT "ms-text-format: text/plain; charset=UTF-8%s;ms-body=%s\r\n"
405 #define SIPE_SEND_TYPING \
406 "<?xml version=\"1.0\"?>"\
407 "<KeyboardActivity>"\
408 "<status status=\"type\" />"\
409 "</KeyboardActivity>"
412 * Publishes categories.
413 * @param uri (%s) Self URI. Ex.: sip:alice7@boston.local
414 * @param publications (%s) XML publications
416 #define SIPE_SEND_PRESENCE \
417 "<publish xmlns=\"http://schemas.microsoft.com/2006/09/sip/rich-presence\">"\
418 "<publications uri=\"%s\">"\
419 "%s"\
420 "</publications>"\
421 "</publish>"
424 * Publishes 'device' category.
425 * @param instance (%u) Ex.: 1938468728
426 * @param version (%u) Ex.: 1
427 * @param endpointId (%s) Ex.: C707E38E-1E10-5413-94D9-ECAC260A0269
428 * @param uri (%s) Self URI. Ex.: sip:alice7@boston.local
429 * @param timezone (%s) Ex.: 00:00:00+01:00
430 * @param machineName (%s) Ex.: BOSTON-OCS07
432 #define SIPE_PUB_XML_DEVICE \
433 "<publication categoryName=\"device\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
434 "<device xmlns=\"http://schemas.microsoft.com/2006/09/sip/device\" endpointId=\"%s\">"\
435 "<capabilities preferred=\"false\" uri=\"%s\">"\
436 "<text capture=\"true\" render=\"true\" publish=\"false\"/>"\
437 "<gifInk capture=\"false\" render=\"true\" publish=\"false\"/>"\
438 "<isfInk capture=\"false\" render=\"true\" publish=\"false\"/>"\
439 "</capabilities>"\
440 "<timezone>%s</timezone>"\
441 "<machineName>%s</machineName>"\
442 "</device>"\
443 "</publication>"
446 * Publishes 'machineState' category.
447 * @param instance (%u) Ex.: 926460663
448 * @param version (%u) Ex.: 22
449 * @param availability (%d) Ex.: 3500
450 * @param instance (%u) Ex.: 926460663
451 * @param version (%u) Ex.: 22
452 * @param availability (%d) Ex.: 3500
454 #define SIPE_PUB_XML_STATE_MACHINE \
455 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
456 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"false\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"machineState\">"\
457 "<availability>%d</availability>"\
458 "<endpointLocation/>"\
459 "</state>"\
460 "</publication>"\
461 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"endpoint\">"\
462 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"false\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"machineState\">"\
463 "<availability>%d</availability>"\
464 "<endpointLocation/>"\
465 "</state>"\
466 "</publication>"
469 * Publishes 'userState' category.
470 * @param instance (%u) User. Ex.: 536870912
471 * @param version (%u) User Container 2. Ex.: 22
472 * @param availability (%d) User Container 2. Ex.: 15500
473 * @param instance (%u) User. Ex.: 536870912
474 * @param version (%u) User Container 3.Ex.: 22
475 * @param availability (%d) User Container 3. Ex.: 15500
477 #define SIPE_PUB_XML_STATE_USER \
478 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"static\">"\
479 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"userState\">"\
480 "<availability>%d</availability>"\
481 "<endpointLocation/>"\
482 "</state>"\
483 "</publication>"\
484 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"static\">"\
485 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"userState\">"\
486 "<availability>%d</availability>"\
487 "<endpointLocation/>"\
488 "</state>"\
489 "</publication>"
492 * An availability XML entry for SIPE_PUB_XML_STATE_CALENDAR
493 * @param availability (%d) Ex.: 6500
495 #define SIPE_PUB_XML_STATE_CALENDAR_AVAIL \
496 "<availability>%d</availability>"
498 * An activity XML entry for SIPE_PUB_XML_STATE_CALENDAR
499 * @param token (%s) Ex.: in-a-meeting
500 * @param minAvailability_attr (%s) Ex.: minAvailability="6500"
501 * @param maxAvailability_attr (%s) Ex.: maxAvailability="8999" or none
503 #define SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY \
504 "<activity token=\"%s\" %s %s></activity>"
506 * Publishes 'calendarState' category.
507 * @param instance (%u) Ex.: 1339299275
508 * @param version (%u) Ex.: 1
509 * @param uri (%s) Ex.: john@contoso.com
510 * @param start_time_str (%s) Ex.: 2008-01-11T19:00:00Z
511 * @param availability (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_AVAIL
512 * @param activity (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY
513 * @param meeting_subject (%s) Ex.: Customer Meeting
514 * @param meeting_location (%s) Ex.: Conf Room 100
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 #define SIPE_PUB_XML_STATE_CALENDAR \
526 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
527 "<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\">"\
528 "%s"\
529 "%s"\
530 "<endpointLocation/>"\
531 "<meetingSubject>%s</meetingSubject>"\
532 "<meetingLocation>%s</meetingLocation>"\
533 "</state>"\
534 "</publication>"\
535 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" 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>"
546 * Publishes to clear 'calendarState' category
547 * @param instance (%u) Ex.: 1251210982
548 * @param version (%u) Ex.: 1
550 #define SIPE_PUB_XML_STATE_CALENDAR_CLEAR \
551 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\" expires=\"0\"/>"\
552 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"endpoint\" expires=\"0\"/>"
555 * Publishes to clear any category
556 * @param category_name (%s) Ex.: state
557 * @param instance (%u) Ex.: 536870912
558 * @param container (%u) Ex.: 3
559 * @param version (%u) Ex.: 1
560 * @param expireType (%s) Ex.: static
562 #define SIPE_PUB_XML_PUBLICATION_CLEAR \
563 "<publication categoryName=\"%s\" instance=\"%u\" container=\"%u\" version=\"%u\" expireType=\"%s\" expires=\"0\"/>"
566 * Publishes 'note' category.
567 * @param instance (%u) Ex.: 2135971629; 0 for personal
568 * @param version (%u) Ex.: 2
569 * @param type (%s) Ex.: personal or OOF
570 * @param body (%s) Ex.: In the office
572 * @param instance (%u) Ex.: 2135971629; 0 for personal
573 * @param version (%u) Ex.: 2
574 * @param type (%s) Ex.: personal or OOF
575 * @param body (%s) Ex.: In the office
577 * @param instance (%u) Ex.: 2135971629; 0 for personal
578 * @param version (%u) Ex.: 2
579 * @param type (%s) Ex.: personal or OOF
580 * @param body (%s) Ex.: In the office
582 #define SIPE_PUB_XML_NOTE \
583 "<publication categoryName=\"note\" instance=\"%u\" container=\"200\" version=\"%d\" expireType=\"static\">"\
584 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
585 "<body type=\"%s\" uri=\"\">%s</body>"\
586 "</note>"\
587 "</publication>"\
588 "<publication categoryName=\"note\" instance=\"%u\" container=\"300\" version=\"%d\" expireType=\"static\">"\
589 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
590 "<body type=\"%s\" uri=\"\">%s</body>"\
591 "</note>"\
592 "</publication>"\
593 "<publication categoryName=\"note\" instance=\"%u\" container=\"400\" version=\"%d\" expireType=\"static\">"\
594 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
595 "<body type=\"%s\" uri=\"\">%s</body>"\
596 "</note>"\
597 "</publication>"
600 * Publishes 'calendarData' category's WorkingHours.
602 * @param version (%u) Ex.: 1
603 * @param email (%s) Ex.: alice@cosmo.local
604 * @param working_hours_xml_str (%s) Ex.: <WorkingHours xmlns=.....
606 * @param version (%u)
608 * @param version (%u)
609 * @param email (%s)
610 * @param working_hours_xml_str (%s)
612 * @param version (%u)
613 * @param email (%s)
614 * @param working_hours_xml_str (%s)
616 * @param version (%u)
617 * @param email (%s)
618 * @param working_hours_xml_str (%s)
620 * @param version (%u)
622 #define SIPE_PUB_XML_WORKING_HOURS \
623 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"1\" version=\"%d\" expireType=\"static\">"\
624 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
625 "</calendarData>"\
626 "</publication>"\
627 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"100\" version=\"%d\" expireType=\"static\">"\
628 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
629 "</publication>"\
630 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"200\" 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=\"300\" version=\"%d\" expireType=\"static\">"\
635 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
636 "</calendarData>"\
637 "</publication>"\
638 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"400\" version=\"%d\" expireType=\"static\">"\
639 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
640 "</calendarData>"\
641 "</publication>"\
642 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"32000\" version=\"%d\" expireType=\"static\">"\
643 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
644 "</publication>"
647 * Publishes 'calendarData' category's FreeBusy.
649 * @param instance (%u) Ex.: 1300372959
650 * @param version (%u) Ex.: 1
652 * @param instance (%u) Ex.: 1300372959
653 * @param version (%u) Ex.: 1
655 * @param instance (%u) Ex.: 1300372959
656 * @param version (%u) Ex.: 1
657 * @param email (%s) Ex.: alice@cosmo.local
658 * @param fb_start_time_str (%s) Ex.: 2009-12-03T00:00:00Z
659 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAAAAAA.....
661 * @param instance (%u) Ex.: 1300372959
662 * @param version (%u) Ex.: 1
663 * @param email (%s) Ex.: alice@cosmo.local
664 * @param fb_start_time_str (%s) Ex.: 2009-12-03T00:00:00Z
665 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAAAAAA.....
667 * @param instance (%u) Ex.: 1300372959
668 * @param version (%u) Ex.: 1
669 * @param email (%s) Ex.: alice@cosmo.local
670 * @param fb_start_time_str (%s) Ex.: 2009-12-03T00:00:00Z
671 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAAAAAA.....
673 * @param instance (%u) Ex.: 1300372959
674 * @param version (%u) Ex.: 1
676 #define SIPE_PUB_XML_FREE_BUSY \
677 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"1\" version=\"%d\" expireType=\"endpoint\">"\
678 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
679 "</publication>"\
680 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"100\" version=\"%d\" expireType=\"endpoint\">"\
681 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
682 "</publication>"\
683 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"200\" version=\"%d\" expireType=\"endpoint\">"\
684 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
685 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
686 "</calendarData>"\
687 "</publication>"\
688 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"300\" version=\"%d\" expireType=\"endpoint\">"\
689 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
690 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
691 "</calendarData>"\
692 "</publication>"\
693 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"400\" version=\"%d\" expireType=\"endpoint\">"\
694 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
695 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
696 "</calendarData>"\
697 "</publication>"\
698 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"32000\" version=\"%d\" expireType=\"endpoint\">"\
699 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
700 "</publication>"
703 #define sipe_soap(method, body) \
704 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
705 "<SOAP-ENV:Body>" \
706 "<m:" method " xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
707 body \
708 "</m:" method ">" \
709 "</SOAP-ENV:Body>" \
710 "</SOAP-ENV:Envelope>"
712 #define SIPE_SOAP_SET_CONTACT sipe_soap("setContact", \
713 "<m:displayName>%s</m:displayName>"\
714 "<m:groups>%s</m:groups>"\
715 "<m:subscribed>%s</m:subscribed>"\
716 "<m:URI>%s</m:URI>"\
717 "<m:externalURI />"\
718 "<m:deltaNum>%d</m:deltaNum>")
720 #define SIPE_SOAP_DEL_CONTACT sipe_soap("deleteContact", \
721 "<m:URI>%s</m:URI>"\
722 "<m:deltaNum>%d</m:deltaNum>")
724 #define SIPE_SOAP_ADD_GROUP sipe_soap("addGroup", \
725 "<m:name>%s</m:name>"\
726 "<m:externalURI />"\
727 "<m:deltaNum>%d</m:deltaNum>")
729 #define SIPE_SOAP_MOD_GROUP sipe_soap("modifyGroup", \
730 "<m:groupID>%d</m:groupID>"\
731 "<m:name>%s</m:name>"\
732 "<m:externalURI />"\
733 "<m:deltaNum>%d</m:deltaNum>")
735 #define SIPE_SOAP_DEL_GROUP sipe_soap("deleteGroup", \
736 "<m:groupID>%d</m:groupID>"\
737 "<m:deltaNum>%d</m:deltaNum>")
739 // first/mask arg is sip:user@domain.com
740 // second/rights arg is AA for allow, BD for deny
741 #define SIPE_SOAP_ALLOW_DENY sipe_soap("setACE", \
742 "<m:type>USER</m:type>"\
743 "<m:mask>%s</m:mask>"\
744 "<m:rights>%s</m:rights>"\
745 "<m:deltaNum>%d</m:deltaNum>")
748 * Calendar publication entry. 2005 systems.
750 * @param legacy_dn (%s) Ex.: /o=EXCHANGE/ou=BTUK02/cn=Recipients/cn=AHHBTT
751 * @param fb_start_time_str (%s) Ex.: 2009-12-06T17:15:00Z
752 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAA......
754 #define SIPE_SOAP_SET_PRESENCE_CALENDAR \
755 "<calendarInfo xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" mailboxId=\"%s\" startTime=\"%s\" granularity=\"PT15M\">%s</calendarInfo>"
757 * Note publication entry. 2005 systems.
759 * @param note (%s) Ex.: Working from home
761 #define SIPE_SOAP_SET_PRESENCE_NOTE_XML "<note>%s</note>"
763 * Note's OOF publication entry. 2005 systems.
765 #define SIPE_SOAP_SET_PRESENCE_OOF_XML "<oof></oof>"
767 * States publication entry for User State. 2005 systems.
769 * @param avail (%d) Availability 2007-style. Ex.: 9500
770 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
771 * @param device_id (%s) epid. Ex.: 4c77e6ec72
772 * @param activity_token (%s) Ex.: do-not-disturb
774 #define SIPE_SOAP_SET_PRESENCE_STATES \
775 "<states>"\
776 "<state avail=\"%d\" since=\"%s\" validWith=\"any-device\" deviceId=\"%s\" set=\"manual\" xsi:type=\"userState\">%s</state>"\
777 "</states>"
779 * Presentity publication entry. 2005 systems.
781 * @param uri (%s) SIP URI without 'sip:' prefix. Ex.: fox@atlanta.local
782 * @param aggr_availability (%d) Ex.: 300
783 * @param aggr_activity (%d) Ex.: 600
784 * @param host_name (%s) Uppercased. Ex.: ATLANTA
785 * @param note_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_NOTE_XML
786 * @param oof_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_OOF_XML
787 * @param states_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_STATES
788 * @param calendar_info_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_CALENDAR
789 * @param device_id (%s) epid. Ex.: 4c77e6ec72
790 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
791 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
792 * @param user_input (%s) active, idle
794 #define SIPE_SOAP_SET_PRESENCE sipe_soap("setPresence", \
795 "<m:presentity xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" m:uri=\"sip:%s\">"\
796 "<m:availability m:aggregate=\"%d\"/>"\
797 "<m:activity m:aggregate=\"%d\"/>"\
798 "<deviceName xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" name=\"%s\"/>"\
799 "<rtc:devicedata xmlns:rtc=\"http://schemas.microsoft.com/winrtc/2002/11/sip\" namespace=\"rtcService\">"\
800 "<![CDATA[<caps><renders_gif/><renders_isf/></caps>]]></rtc:devicedata>"\
801 "<userInfo xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\">"\
802 "%s%s" \
803 "%s" \
804 "</userInfo>"\
805 "%s" \
806 "<device xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" deviceId=\"%s\" since=\"%s\" >"\
807 "<userInput since=\"%s\" >%s</userInput>"\
808 "</device>"\
809 "</m:presentity>")
811 #define SIPE_SOAP_SEARCH_CONTACT \
812 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
813 "<SOAP-ENV:Body>" \
814 "<m:directorySearch xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
815 "<m:filter m:href=\"#searchArray\"/>"\
816 "<m:maxResults>%d</m:maxResults>"\
817 "</m:directorySearch>"\
818 "<m:Array xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\" m:id=\"searchArray\">"\
819 "%s"\
820 "</m:Array>"\
821 "</SOAP-ENV:Body>"\
822 "</SOAP-ENV:Envelope>"
824 #define SIPE_SOAP_SEARCH_ROW "<m:row m:attrib=\"%s\" m:value=\"%s\"/>"
826 #endif /* _PIDGIN_SIPE_H */