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