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