notify: store ucPC2PCAVEncryption value form server
[siplcs.git] / src / core / sip-soap.c
blob06f17811a4854b51e8bab32ae071965f0bd689bc
1 /**
2 * @file sip-soap.c
4 * pidgin-sipe
6 * Copyright (C) 2011-2015 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
33 #include <glib.h>
35 #include "sip-soap.h"
36 #include "sip-transport.h"
37 #include "sipe-backend.h"
38 #include "sipe-core.h"
39 #include "sipe-core-private.h"
40 #include "sipe-utils.h"
42 void sip_soap_raw_request_cb(struct sipe_core_private *sipe_private,
43 const gchar *from,
44 const gchar *soap,
45 SoapTransCallback callback,
46 struct transaction_payload *payload)
48 gchar *contact = get_contact(sipe_private);
49 gchar *hdr = g_strdup_printf("Contact: %s\r\n"
50 "Content-Type: application/SOAP+xml\r\n",
51 contact);
53 struct transaction *trans = sip_transport_service(sipe_private,
54 from,
55 hdr,
56 soap,
57 callback);
58 trans->payload = payload;
60 g_free(contact);
61 g_free(hdr);
64 /**
65 * delta_num != NULL: use user sip: URI as from, include deltanum and increment it
66 * delta_num == NULL; use sip: URI generated from domain name as from
68 static void sip_soap_request_full(struct sipe_core_private *sipe_private,
69 const gchar *method,
70 const gchar *request,
71 const gchar *additional,
72 guint *deltanum,
73 SoapTransCallback callback,
74 struct transaction_payload *payload)
76 gchar *from = deltanum ?
77 sip_uri_self(sipe_private) :
78 sip_uri_from_name(sipe_private->public.sip_domain);
79 gchar *delta = deltanum ?
80 g_strdup_printf("<m:deltaNum>%d</m:deltaNum>", (*deltanum)++) :
81 g_strdup("");
82 gchar *soap = g_strdup_printf("<s:Envelope"
83 " xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\""
84 " xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\""
85 ">"
86 "<s:Body>"
87 "<m:%s>"
88 "%s"
89 "%s"
90 "</m:%s>"
91 "%s"
92 "</s:Body>"
93 "</s:Envelope>",
94 method,
95 request,
96 delta,
97 method,
98 additional ? additional : "");
99 sip_soap_raw_request_cb(sipe_private, from, soap, callback, payload);
100 g_free(soap);
101 g_free(delta);
102 g_free(from);
105 void sip_soap_request_cb(struct sipe_core_private *sipe_private,
106 const gchar *method,
107 const gchar *request,
108 SoapTransCallback callback,
109 struct transaction_payload *payload)
111 sip_soap_request_full(sipe_private,
112 method,
113 request,
114 NULL,
115 &sipe_private->deltanum_contacts,
116 callback,
117 payload);
120 void sip_soap_request(struct sipe_core_private *sipe_private,
121 const gchar *method,
122 const gchar *request)
124 sip_soap_request_cb(sipe_private,
125 method,
126 request,
127 NULL,
128 NULL);
131 /* This is the only user of deltanum_acl */
132 void sip_soap_ocs2005_setacl(struct sipe_core_private *sipe_private,
133 const gchar *who,
134 gboolean allow)
136 gchar *request = g_strdup_printf("<m:type>USER</m:type>"
137 "<m:mask>%s</m:mask>"
138 "<m:rights>%s</m:rights>",
139 who,
140 allow ? "AA" : "BD");
141 sip_soap_request_full(sipe_private,
142 "setACE",
143 request,
144 NULL,
145 &sipe_private->deltanum_acl,
146 NULL,
147 NULL);
148 g_free(request);
152 * This request is special:
153 * a) it is send from domain URI and not the users
154 * b) it has XML nodes outside the [MS-PRES] method node
155 * c) doesn't use deltaNum
157 void sip_soap_directory_search(struct sipe_core_private *sipe_private,
158 guint max,
159 const gchar *rows,
160 SoapTransCallback callback,
161 struct transaction_payload *payload)
163 gchar *request = g_strdup_printf("<m:filter m:href=\"#searchArray\"/>"
164 "<m:maxResults>%d</m:maxResults>",
165 max);
166 gchar *additional = g_strdup_printf("<m:Array m:id=\"searchArray\">"
167 "%s"
168 "</m:Array>",
169 rows);
170 sip_soap_request_full(sipe_private,
171 "directorySearch",
172 request,
173 additional,
174 NULL,
175 callback,
176 payload);
177 g_free(additional);
178 g_free(request);
182 Local Variables:
183 mode: c
184 c-file-style: "bsd"
185 indent-tabs-mode: t
186 tab-width: 8
187 End: