6 * Copyright (C) 2010 SIPE Project <http://sipe.sourceforge.net/>
7 * Copyright (C) 2008 Novell, Inc.
8 * Copyright (C) 2007 Anibal Avelar <avelar@gmail.com>
9 * Copyright (C) 2005 Thomas Butter <butter@uni-mannheim.de>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 * Interface dependencies:
34 /* Forward declarations */
36 struct _PurpleAccount
;
37 struct _PurpleCircBuffer
;
38 struct _PurpleConnection
;
39 struct _PurpleDnsQueryData
;
41 struct _PurpleNetworkListenData
;
43 struct _PurpleSrvQueryData
;
44 struct _PurpleSslConnection
;
45 struct sip_sec_context
;
46 enum sip_sec_auth_type
;
48 #define SIMPLE_BUF_INC 4096
50 #define SIPE_TYPING_RECV_TIMEOUT 6
51 #define SIPE_TYPING_SEND_TIMEOUT 4
54 /** Activity (token and description) 2007 */
57 SIPE_ACTIVITY_UNSET
= 0,
59 SIPE_ACTIVITY_INACTIVE
,
61 SIPE_ACTIVITY_BUSYIDLE
,
66 SIPE_ACTIVITY_OFFLINE
,
67 SIPE_ACTIVITY_ON_PHONE
,
68 SIPE_ACTIVITY_IN_CONF
,
69 SIPE_ACTIVITY_IN_MEETING
,
71 SIPE_ACTIVITY_URGENT_ONLY
,
72 SIPE_ACTIVITY_NUM_TYPES
78 gchar
*meeting_subject
;
79 gchar
*meeting_location
;
80 /* Sipe internal format for Note is HTML.
81 * All incoming plain text should be html-escaped
82 * for example by g_markup_escape_text()
88 /* Calendar related fields */
89 gchar
*cal_start_time
;
91 gchar
*cal_free_busy_base64
;
93 time_t cal_free_busy_published
;
94 /* for 2005 systems */
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
;
105 /** flag to control sending 'context' element in 2007 subscriptions */
110 enum sip_sec_auth_type type
;
111 struct sip_sec_context
*gssapi_context
;
127 } sipe_transport_type
;
129 struct sipe_service_data
{
131 const char *transport
;
132 sipe_transport_type type
;
135 /** MS-PRES publication */
136 struct sipe_publication
{
141 /** for 'state' category */
143 /** for 'state:calendarState' category */
144 char *cal_event_hash
;
145 /** for 'note' category */
147 /** for 'calendarData' category; 300(Team) container */
148 char *working_hours_xml_str
;
150 char *free_busy_base64
;
153 /** MS-PRES container */
154 struct sipe_container
{
159 /** MS-PRES container member */
160 struct sipe_container_member
{
161 /** user, domain, sameEnterprise, federated, publicCloud; everyone */
166 struct sipe_account_data
{
167 struct _PurpleConnection
*gc
;
174 gchar
*focus_factory_uri
;
175 /** Allowed server events to subscribe. From register OK response. */
176 GSList
*allow_events
;
177 struct _PurpleDnsQueryData
*query_data
;
178 struct _PurpleSrvQueryData
*srv_query_data
;
179 const struct sipe_service_data
*service_data
;
180 struct _PurpleNetworkListenData
*listen_data
;
183 time_t last_keepalive
;
184 int registerstatus
; /* 0 nothing, 1 first registration send, 2 auth received, 3 registered */
185 struct sip_auth registrar
;
186 struct sip_auth proxy
;
187 struct sip_csta
*csta
; /* For RCC - Remote Call Control */
188 gboolean reregister_set
; /* whether reregister timer set */
189 gboolean reauthenticate_set
; /* whether reauthenticate timer set */
190 gboolean subscribed
; /* whether subscribed to events, except buddies presence */
191 gboolean subscribed_buddies
; /* whether subscribed to buddies presence */
192 gboolean access_level_set
; /* whether basic access level set */
193 gboolean initial_state_published
; /* whether we published our initial state */
194 GSList
*our_publication_keys
; /* [MS-PRES] */
195 GHashTable
*our_publications
; /* [MS-PRES] */
196 GHashTable
*user_state_publications
; /* [MS-PRES] */
197 GHashTable
*subscriptions
;
203 int presence_method_version
;
204 time_t do_not_publish
[SIPE_ACTIVITY_NUM_TYPES
];
206 gboolean is_oof_note
;
211 gchar
*server_version
;
212 gboolean ocs2007
; /*if there is support for batched category subscription [SIP-PRES]*/
213 gboolean batched_support
; /*if there is support for batched subscription*/
214 GSList
*containers
; /* MS-PRES containers */
217 guint keepalive_timeout
;
220 struct _PurpleAccount
*account
;
221 struct _PurpleCircBuffer
*txbuf
;
224 GSList
*transactions
;
228 GHashTable
*filetransfers
;
229 sipe_transport_type transport
;
230 gboolean auto_transport
;
231 struct _PurpleSslConnection
*gsc
;
232 struct sockaddr
*serveraddr
;
234 int realport
; /* port and hostname from SRV record */
235 gboolean processing_input
;
236 struct sipe_ews
*ews
;
238 /** 2005 Custom XML piece.
239 * Possibly set by other point of presence or just other client at earlier time.
240 * It should be preserved/modified, not overwritten. This implies subscription
242 * This XML keeps OC2005:
250 struct sip_connection
{
258 struct sipe_auth_job
{
260 struct sipe_account_data
* sip
;
265 typedef gboolean (*TransCallback
) (struct sipe_account_data
*, struct sipmsg
*, struct transaction
*);
267 struct transaction_payload
{
268 GDestroyNotify destroy
;
275 int transport
; /* 0 = tcp, 1 = udp */
277 /** Not yet perfect, but surely better then plain CSeq
278 * Format is: <Call-ID><CSeq>
279 * (RFC3261 17.2.3 for matching server transactions: Request-URI, To tag, From tag, Call-ID, CSeq, and top Via)
283 TransCallback callback
;
284 struct transaction_payload
*payload
;
287 typedef void (*Action
) (struct sipe_account_data
*, void *);
290 * Do schedule action for execution in the future.
291 * Non repetitive execution.
293 * @param name of action (will be copied)
294 * @param timeout in seconds
295 * @param action callback function
296 * @param destroy payload destroy function
298 * @param payload callback data (can be NULL, otherwise caller must allocate memory)
301 sipe_schedule_action(const gchar
*name
,
304 GDestroyNotify destroy
,
305 struct sipe_account_data
*sip
,
311 struct _PurpleGroup
*purple_group
;
314 struct group_user_context
{
319 GSList
* slist_insert_unique_sorted(GSList
*list
, gpointer data
, GCompareFunc func
);
322 * Publishes self status
323 * based on own calendar information,
324 * our Calendar information - FreeBusy, WorkingHours,
330 publish_calendar_status_self(struct sipe_account_data
*sip
);
336 send_presence_soap(struct sipe_account_data
*sip
,
337 gboolean do_publish_calendar
);
340 * THE BIG SPLIT - temporary interfaces
342 * Previously private functions in sipe.c that are
343 * - waiting to be factored out to an appropriate module
344 * - are needed by the already created new modules
349 * Since SIP (RFC3261) is extensible by its design,
350 * and MS specs prove just that (they all are defined as SIP extensions),
351 * it make sense to split functionality by extension (or close extension group).
352 * For example: conference, presence (MS-PRES), etc.
354 * This way our code will not be monolithic, but potentially _reusable_. May be
355 * a top of other SIP core, and/or other front-end (Telepathy framework?).
357 /* Forward declarations */
361 /* SIP send module? */
363 send_sip_request(struct _PurpleConnection
*gc
, const gchar
*method
,
364 const gchar
*url
, const gchar
*to
, const gchar
*addheaders
,
365 const gchar
*body
, struct sip_dialog
*dialog
, TransCallback tc
);
367 send_sip_response(struct _PurpleConnection
*gc
, struct sipmsg
*msg
, int code
,
368 const char *text
, const char *body
);
370 sipe_invite(struct sipe_account_data
*sip
, struct sip_session
*session
,
371 const gchar
*who
, const gchar
*msg_body
, const gchar
*msg_content_type
,
372 const gchar
*referred_by
, const gboolean is_triggered
);
374 gboolean
process_subscribe_response(struct sipe_account_data
*sip
,
376 struct transaction
*tc
);
379 sipe_invite_to_chat(struct sipe_account_data
*sip
,
380 struct sip_session
*session
,
382 /* Session module? */
384 sipe_present_message_undelivered_err(struct sipe_account_data
*sip
,
385 struct sip_session
*session
,
389 const gchar
*message
);
392 sipe_present_info(struct sipe_account_data
*sip
,
393 struct sip_session
*session
,
394 const gchar
*message
);
398 sipe_process_pending_invite_queue(struct sipe_account_data
*sip
,
399 struct sip_session
*session
);
402 sipe_im_process_queue (struct sipe_account_data
* sip
, struct sip_session
* session
);
405 /*** THE BIG SPLIT END ***/
407 #define SIPE_INVITE_TEXT "ms-text-format: %s; charset=UTF-8%s;ms-body=%s\r\n"
409 #define SIPE_SEND_TYPING \
410 "<?xml version=\"1.0\"?>"\
411 "<KeyboardActivity>"\
412 "<status status=\"type\" />"\
413 "</KeyboardActivity>"
416 * Publishes categories.
417 * @param uri (%s) Self URI. Ex.: sip:alice7@boston.local
418 * @param publications (%s) XML publications
420 #define SIPE_SEND_PRESENCE \
421 "<publish xmlns=\"http://schemas.microsoft.com/2006/09/sip/rich-presence\">"\
422 "<publications uri=\"%s\">"\
428 * Publishes 'device' category.
429 * @param instance (%u) Ex.: 1938468728
430 * @param version (%u) Ex.: 1
431 * @param endpointId (%s) Ex.: C707E38E-1E10-5413-94D9-ECAC260A0269
432 * @param uri (%s) Self URI. Ex.: sip:alice7@boston.local
433 * @param timezone (%s) Ex.: 00:00:00+01:00
434 * @param machineName (%s) Ex.: BOSTON-OCS07
436 #define SIPE_PUB_XML_DEVICE \
437 "<publication categoryName=\"device\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
438 "<device xmlns=\"http://schemas.microsoft.com/2006/09/sip/device\" endpointId=\"%s\">"\
439 "<capabilities preferred=\"false\" uri=\"%s\">"\
440 "<text capture=\"true\" render=\"true\" publish=\"false\"/>"\
441 "<gifInk capture=\"false\" render=\"true\" publish=\"false\"/>"\
442 "<isfInk capture=\"false\" render=\"true\" publish=\"false\"/>"\
444 "<timezone>%s</timezone>"\
445 "<machineName>%s</machineName>"\
450 * Publishes 'machineState' category.
451 * @param instance (%u) Ex.: 926460663
452 * @param version (%u) Ex.: 22
453 * @param availability (%d) Ex.: 3500
454 * @param instance (%u) Ex.: 926460663
455 * @param version (%u) Ex.: 22
456 * @param availability (%d) Ex.: 3500
458 #define SIPE_PUB_XML_STATE_MACHINE \
459 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" 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/>"\
465 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"endpoint\">"\
466 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"false\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"machineState\">"\
467 "<availability>%d</availability>"\
468 "<endpointLocation/>"\
473 * Publishes 'userState' category.
474 * @param instance (%u) User. Ex.: 536870912
475 * @param version (%u) User Container 2. Ex.: 22
476 * @param availability (%d) User Container 2. Ex.: 15500
477 * @param instance (%u) User. Ex.: 536870912
478 * @param version (%u) User Container 3.Ex.: 22
479 * @param availability (%d) User Container 3. Ex.: 15500
481 #define SIPE_PUB_XML_STATE_USER \
482 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" 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/>"\
488 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"static\">"\
489 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"userState\">"\
490 "<availability>%d</availability>"\
491 "<endpointLocation/>"\
496 * An availability XML entry for SIPE_PUB_XML_STATE_CALENDAR
497 * @param availability (%d) Ex.: 6500
499 #define SIPE_PUB_XML_STATE_CALENDAR_AVAIL \
500 "<availability>%d</availability>"
502 * An activity XML entry for SIPE_PUB_XML_STATE_CALENDAR
503 * @param token (%s) Ex.: in-a-meeting
504 * @param minAvailability_attr (%s) Ex.: minAvailability="6500"
505 * @param maxAvailability_attr (%s) Ex.: maxAvailability="8999" or none
507 #define SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY \
508 "<activity token=\"%s\" %s %s></activity>"
510 * Publishes 'calendarState' category.
511 * @param instance (%u) Ex.: 1339299275
512 * @param version (%u) Ex.: 1
513 * @param uri (%s) Ex.: john@contoso.com
514 * @param start_time_str (%s) Ex.: 2008-01-11T19:00:00Z
515 * @param availability (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_AVAIL
516 * @param activity (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY
517 * @param meeting_subject (%s) Ex.: Customer Meeting
518 * @param meeting_location (%s) Ex.: Conf Room 100
520 * @param instance (%u) Ex.: 1339299275
521 * @param version (%u) Ex.: 1
522 * @param uri (%s) Ex.: john@contoso.com
523 * @param start_time_str (%s) Ex.: 2008-01-11T19:00:00Z
524 * @param availability (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_AVAIL
525 * @param activity (%s) XML string as SIPE_PUB_XML_STATE_CALENDAR_ACTIVITY
526 * @param meeting_subject (%s) Ex.: Customer Meeting
527 * @param meeting_location (%s) Ex.: Conf Room 100
529 #define SIPE_PUB_XML_STATE_CALENDAR \
530 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\">"\
531 "<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\">"\
534 "<endpointLocation/>"\
535 "<meetingSubject>%s</meetingSubject>"\
536 "<meetingLocation>%s</meetingLocation>"\
539 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"endpoint\">"\
540 "<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\">"\
543 "<endpointLocation/>"\
544 "<meetingSubject>%s</meetingSubject>"\
545 "<meetingLocation>%s</meetingLocation>"\
550 * Publishes to clear 'calendarState' category
551 * @param instance (%u) Ex.: 1251210982
552 * @param version (%u) Ex.: 1
554 #define SIPE_PUB_XML_STATE_CALENDAR_CLEAR \
555 "<publication categoryName=\"state\" instance=\"%u\" container=\"2\" version=\"%u\" expireType=\"endpoint\" expires=\"0\"/>"\
556 "<publication categoryName=\"state\" instance=\"%u\" container=\"3\" version=\"%u\" expireType=\"endpoint\" expires=\"0\"/>"
559 * Publishes to clear any category
560 * @param category_name (%s) Ex.: state
561 * @param instance (%u) Ex.: 536870912
562 * @param container (%u) Ex.: 3
563 * @param version (%u) Ex.: 1
564 * @param expireType (%s) Ex.: static
566 #define SIPE_PUB_XML_PUBLICATION_CLEAR \
567 "<publication categoryName=\"%s\" instance=\"%u\" container=\"%u\" version=\"%u\" expireType=\"%s\" expires=\"0\"/>"
570 * Publishes 'note' category.
571 * @param instance (%u) Ex.: 2135971629; 0 for personal
572 * @param container (%u) Ex.: 200
573 * @param version (%u) Ex.: 2
574 * @param type (%s) Ex.: personal or OOF
575 * @param startTime_attr (%s) Ex.: startTime="2008-01-11T19:00:00Z"
576 * @param endTime_attr (%s) Ex.: endTime="2008-01-15T19:00:00Z"
577 * @param body (%s) Ex.: In the office
579 #define SIPE_PUB_XML_NOTE \
580 "<publication categoryName=\"note\" instance=\"%u\" container=\"%u\" version=\"%d\" expireType=\"static\">"\
581 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
582 "<body type=\"%s\" uri=\"\"%s%s>%s</body>"\
587 * Publishes 'calendarData' category's WorkingHours.
589 * @param version (%u) Ex.: 1
590 * @param email (%s) Ex.: alice@cosmo.local
591 * @param working_hours_xml_str (%s) Ex.: <WorkingHours xmlns=.....
593 * @param version (%u)
595 * @param version (%u)
597 * @param working_hours_xml_str (%s)
599 * @param version (%u)
601 * @param working_hours_xml_str (%s)
603 * @param version (%u)
605 * @param working_hours_xml_str (%s)
607 * @param version (%u)
609 #define SIPE_PUB_XML_WORKING_HOURS \
610 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"1\" version=\"%d\" expireType=\"static\">"\
611 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
614 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"100\" version=\"%d\" expireType=\"static\">"\
615 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
617 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"200\" version=\"%d\" expireType=\"static\">"\
618 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
621 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"300\" version=\"%d\" expireType=\"static\">"\
622 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
625 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"400\" version=\"%d\" expireType=\"static\">"\
626 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">%s"\
629 "<publication categoryName=\"calendarData\" instance=\"0\" container=\"32000\" version=\"%d\" expireType=\"static\">"\
630 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
634 * Publishes 'calendarData' category's FreeBusy.
636 * @param instance (%u) Ex.: 1300372959
637 * @param version (%u) Ex.: 1
639 * @param instance (%u) Ex.: 1300372959
640 * @param version (%u) Ex.: 1
642 * @param instance (%u) Ex.: 1300372959
643 * @param version (%u) Ex.: 1
644 * @param email (%s) Ex.: alice@cosmo.local
645 * @param fb_start_time_str (%s) Ex.: 2009-12-03T00:00:00Z
646 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAAAAAA.....
648 * @param instance (%u) Ex.: 1300372959
649 * @param version (%u) Ex.: 1
650 * @param email (%s) Ex.: alice@cosmo.local
651 * @param fb_start_time_str (%s) Ex.: 2009-12-03T00:00:00Z
652 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAAAAAA.....
654 * @param instance (%u) Ex.: 1300372959
655 * @param version (%u) Ex.: 1
656 * @param email (%s) Ex.: alice@cosmo.local
657 * @param fb_start_time_str (%s) Ex.: 2009-12-03T00:00:00Z
658 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAAAAAA.....
660 * @param instance (%u) Ex.: 1300372959
661 * @param version (%u) Ex.: 1
663 #define SIPE_PUB_XML_FREE_BUSY \
664 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"1\" version=\"%d\" expireType=\"endpoint\">"\
665 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
667 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"100\" version=\"%d\" expireType=\"endpoint\">"\
668 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
670 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"200\" version=\"%d\" expireType=\"endpoint\">"\
671 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
672 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
675 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"300\" version=\"%d\" expireType=\"endpoint\">"\
676 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
677 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
680 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"400\" version=\"%d\" expireType=\"endpoint\">"\
681 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\" mailboxID=\"%s\">"\
682 "<freeBusy startTime=\"%s\" granularity=\"PT15M\" encodingVersion=\"1\">%s</freeBusy>"\
685 "<publication categoryName=\"calendarData\" instance=\"%u\" container=\"32000\" version=\"%d\" expireType=\"endpoint\">"\
686 "<calendarData xmlns=\"http://schemas.microsoft.com/2006/09/sip/calendarData\"/>"\
690 #define sipe_soap(method, body) \
691 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
693 "<m:" method " xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
697 "</SOAP-ENV:Envelope>"
699 #define SIPE_SOAP_SET_CONTACT sipe_soap("setContact", \
700 "<m:displayName>%s</m:displayName>"\
701 "<m:groups>%s</m:groups>"\
702 "<m:subscribed>%s</m:subscribed>"\
705 "<m:deltaNum>%d</m:deltaNum>")
707 #define SIPE_SOAP_DEL_CONTACT sipe_soap("deleteContact", \
709 "<m:deltaNum>%d</m:deltaNum>")
711 #define SIPE_SOAP_ADD_GROUP sipe_soap("addGroup", \
712 "<m:name>%s</m:name>"\
714 "<m:deltaNum>%d</m:deltaNum>")
716 #define SIPE_SOAP_MOD_GROUP sipe_soap("modifyGroup", \
717 "<m:groupID>%d</m:groupID>"\
718 "<m:name>%s</m:name>"\
720 "<m:deltaNum>%d</m:deltaNum>")
722 #define SIPE_SOAP_DEL_GROUP sipe_soap("deleteGroup", \
723 "<m:groupID>%d</m:groupID>"\
724 "<m:deltaNum>%d</m:deltaNum>")
726 // first/mask arg is sip:user@domain.com
727 // second/rights arg is AA for allow, BD for deny
728 #define SIPE_SOAP_ALLOW_DENY sipe_soap("setACE", \
729 "<m:type>USER</m:type>"\
730 "<m:mask>%s</m:mask>"\
731 "<m:rights>%s</m:rights>"\
732 "<m:deltaNum>%d</m:deltaNum>")
735 * Calendar publication entry. 2005 systems.
737 * @param legacy_dn (%s) Ex.: /o=EXCHANGE/ou=BTUK02/cn=Recipients/cn=AHHBTT
738 * @param fb_start_time_str (%s) Ex.: 2009-12-06T17:15:00Z
739 * @param free_busy_base64 (%s) Ex.: AAAAAAAAAAAAAAAAA......
741 #define SIPE_SOAP_SET_PRESENCE_CALENDAR \
742 "<calendarInfo xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" mailboxId=\"%s\" startTime=\"%s\" granularity=\"PT15M\">%s</calendarInfo>"
744 * Note publication entry. 2005 systems.
746 * @param note (%s) Ex.: Working from home
748 #define SIPE_SOAP_SET_PRESENCE_NOTE_XML "<note>%s</note>"
750 * Note's OOF publication entry. 2005 systems.
752 #define SIPE_SOAP_SET_PRESENCE_OOF_XML "<oof></oof>"
754 * States publication entry for User State. 2005 systems.
756 * @param avail (%d) Availability 2007-style. Ex.: 9500
757 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
758 * @param device_id (%s) epid. Ex.: 4c77e6ec72
759 * @param activity_token (%s) Ex.: do-not-disturb
761 #define SIPE_SOAP_SET_PRESENCE_STATES \
763 "<state avail=\"%d\" since=\"%s\" validWith=\"any-device\" deviceId=\"%s\" set=\"manual\" xsi:type=\"userState\">%s</state>"\
766 * Presentity publication entry. 2005 systems.
768 * @param uri (%s) SIP URI without 'sip:' prefix. Ex.: fox@atlanta.local
769 * @param aggr_availability (%d) Ex.: 300
770 * @param aggr_activity (%d) Ex.: 600
771 * @param host_name (%s) Uppercased. Ex.: ATLANTA
772 * @param note_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_NOTE_XML
773 * @param oof_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_OOF_XML
774 * @param states_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_STATES
775 * @param calendar_info_xml_str (%s) XML string as SIPE_SOAP_SET_PRESENCE_CALENDAR
776 * @param device_id (%s) epid. Ex.: 4c77e6ec72
777 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
778 * @param since_time_str (%s) Ex.: 2010-01-13T10:30:05Z
779 * @param user_input (%s) active, idle
781 #define SIPE_SOAP_SET_PRESENCE sipe_soap("setPresence", \
782 "<m:presentity xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" m:uri=\"sip:%s\">"\
783 "<m:availability m:aggregate=\"%d\"/>"\
784 "<m:activity m:aggregate=\"%d\"/>"\
785 "<deviceName xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" name=\"%s\"/>"\
786 "<rtc:devicedata xmlns:rtc=\"http://schemas.microsoft.com/winrtc/2002/11/sip\" namespace=\"rtcService\">"\
787 "<![CDATA[<caps><renders_gif/><renders_isf/></caps>]]></rtc:devicedata>"\
788 "<userInfo xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\">"\
793 "<device xmlns=\"http://schemas.microsoft.com/2002/09/sip/presence\" deviceId=\"%s\" since=\"%s\" >"\
794 "<userInput since=\"%s\" >%s</userInput>"\
798 #define SIPE_SOAP_SEARCH_CONTACT \
799 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
801 "<m:directorySearch xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
802 "<m:filter m:href=\"#searchArray\"/>"\
803 "<m:maxResults>%d</m:maxResults>"\
804 "</m:directorySearch>"\
805 "<m:Array xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\" m:id=\"searchArray\">"\
809 "</SOAP-ENV:Envelope>"
811 #define SIPE_SOAP_SEARCH_ROW "<m:row m:attrib=\"%s\" m:value=\"%s\"/>"