6 * Copyright (C) 2011 SIPE Project <http://sipe.sourceforge.net/>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * SOAP requests over SIP SERVICE messages
26 * Specification references:
28 * - [MS-SIP]: http://msdn.microsoft.com/en-us/library/cc246115.aspx
29 * - [MS-PRES]: http://msdn.microsoft.com/en-us/library/cc431501.aspx
36 #include "sip-transport.h"
37 #include "sipe-core.h"
38 #include "sipe-core-private.h"
39 #include "sipe-utils.h"
41 void sip_soap_raw_request_cb(struct sipe_core_private
*sipe_private
,
44 SoapTransCallback callback
,
45 struct transaction_payload
*payload
)
47 gchar
*contact
= get_contact(sipe_private
);
48 gchar
*hdr
= g_strdup_printf("Contact: %s\r\n"
49 "Content-Type: application/SOAP+xml\r\n",
52 struct transaction
*trans
= sip_transport_service(sipe_private
,
57 trans
->payload
= payload
;
64 * delta_num != NULL: use user sip: URI as from, include deltanum and increment it
65 * delta_num == NULL; use sip: URI generated from domain name as from
67 static void sip_soap_request_full(struct sipe_core_private
*sipe_private
,
70 const gchar
*additional
,
72 SoapTransCallback callback
,
73 struct transaction_payload
*payload
)
75 gchar
*from
= deltanum
?
76 sip_uri_self(sipe_private
) :
77 sip_uri_from_name(sipe_private
->public.sip_domain
);
78 gchar
*delta
= deltanum
?
79 g_strdup_printf("<m:deltaNum>%d</m:deltaNum>", (*deltanum
)++) :
81 gchar
*soap
= g_strdup_printf("<s:Envelope"
82 " xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\""
83 " xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\""
97 additional
? additional
: "");
98 sip_soap_raw_request_cb(sipe_private
, from
, soap
, callback
, payload
);
104 void sip_soap_request_cb(struct sipe_core_private
*sipe_private
,
106 const gchar
*request
,
107 SoapTransCallback callback
,
108 struct transaction_payload
*payload
)
110 sip_soap_request_full(sipe_private
,
114 &sipe_private
->deltanum_contacts
,
119 void sip_soap_request(struct sipe_core_private
*sipe_private
,
121 const gchar
*request
)
123 sip_soap_request_cb(sipe_private
,
130 /* This is the only user of deltanum_acl */
131 void sip_soap_ocs2005_setacl(struct sipe_core_private
*sipe_private
,
135 gchar
*request
= g_strdup_printf("<m:type>USER</m:type>"
136 "<m:mask>%s</m:mask>"
137 "<m:rights>%s</m:rights>",
139 allow
? "AA" : "BD");
140 sip_soap_request_full(sipe_private
,
144 &sipe_private
->deltanum_acl
,
151 * This request is special:
152 * a) it is send from domain URI and not the users
153 * b) it has XML nodes outside the [MS-PRES] method node
154 * c) doesn't use deltaNum
156 void sip_soap_directory_search(struct sipe_core_private
*sipe_private
,
159 SoapTransCallback callback
,
160 struct transaction_payload
*payload
)
162 gchar
*request
= g_strdup_printf("<m:filter m:href=\"#searchArray\"/>"
163 "<m:maxResults>%d</m:maxResults>",
165 gchar
*additional
= g_strdup_printf("<m:Array m:id=\"searchArray\">"
169 sip_soap_request_full(sipe_private
,