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
32 #include "circbuffer.h"
44 #define SIMPLE_BUF_INC 4096
46 #define SIPE_TYPING_RECV_TIMEOUT 6
47 #define SIPE_TYPING_SEND_TIMEOUT 4
49 #define PURPLE_WEBSITE "http://pidgin.sf.im/"
52 struct sip_im_session
{
54 struct sip_dialog
* dialog
;
55 struct transaction
* outgoing_invite
;
57 GSList
*outgoing_message_queue
;
58 /** Key is <Call-ID><CSeq><METHOD> */
59 GHashTable
*unconfirmed_messages
;
62 // dialog is the new term for call-leg
70 GSList
*supported
; // counterparty capabilities
79 gboolean resubscribed
;
84 SipSecContext gssapi_context
;
100 } sipe_transport_type
;
102 struct sipe_service_data
{
104 const char *transport
;
105 sipe_transport_type type
;
108 struct sipe_account_data
{
109 PurpleConnection
*gc
;
116 /** Allowed server events to subscribe. From register OK response. */
117 GSList
*allow_events
;
118 PurpleDnsQueryData
*query_data
;
119 PurpleSrvQueryData
*srv_query_data
;
120 const struct sipe_service_data
*service_data
;
121 PurpleNetworkListenData
*listen_data
;
124 time_t last_keepalive
;
125 int registerstatus
; /* 0 nothing, 1 first registration send, 2 auth received, 3 registered */
126 struct sip_auth registrar
;
127 struct sip_auth proxy
;
128 gboolean reregister_set
; /* whether reregister timer set */
129 gboolean reauthenticate_set
; /* whether reauthenticate timer set */
130 gboolean subscribed
; /* whether subscribed to events, except buddies presence */
131 gboolean subscribed_buddies
; /* whether subscribed to buddies presence */
137 int presence_method_version
;
141 gboolean msrtc_event_categories
; /*if there is support for batched category subscription [SIP-PRES]*/
142 gboolean batched_support
; /*if there is support for batched subscription*/
145 guint keepalive_timeout
;
148 PurpleAccount
*account
;
149 PurpleCircBuffer
*txbuf
;
152 GSList
*transactions
;
156 sipe_transport_type transport
;
157 gboolean auto_transport
;
158 PurpleSslConnection
*gsc
;
159 struct sockaddr_in serveraddr
;
161 int realport
; /* port and hostname from SRV record */
162 gboolean processing_input
;
165 struct sip_connection
{
173 struct sipe_auth_job
{
175 struct sipe_account_data
* sip
;
180 typedef gboolean (*TransCallback
) (struct sipe_account_data
*, struct sipmsg
*, struct transaction
*);
185 int transport
; /* 0 = tcp, 1 = udp */
189 TransCallback callback
;
196 PurpleGroup
*purple_group
;
199 struct group_user_context
{
204 GSList
* slist_insert_unique_sorted(GSList
*list
, gpointer data
, GCompareFunc func
);
206 GList
*sipe_actions(PurplePlugin
*plugin
, gpointer context
);
208 gboolean
purple_init_plugin(PurplePlugin
*plugin
);
210 #define SIPE_INVITE_TEXT "ms-text-format: text/plain; charset=UTF-8%s;ms-body=%s\r\n"
212 #define SIPE_SEND_TYPING \
213 "<?xml version=\"1.0\"?>"\
214 "<KeyboardActivity>"\
215 "<status status=\"type\" />"\
216 "</KeyboardActivity>"
218 #define SIPE_SEND_PRESENCE \
219 "<publish xmlns=\"http://schemas.microsoft.com/2006/09/sip/rich-presence\">"\
220 "<publications uri=\"%s\">"\
221 "<publication categoryName=\"state\" instance=\"906391354\" container=\"2\" version=\"%d\" expireType=\"endpoint\">"\
222 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"false\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"machineState\">"\
223 "<availability>%d</availability>"\
224 "<endpointLocation></endpointLocation>"\
227 "<publication categoryName=\"state\" instance=\"906391356\" container=\"0\" version=\"%d\" expireType=\"endpoint\">"\
228 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"userState\">"\
229 "<availability>%d</availability>"\
230 "<endpointLocation></endpointLocation>"\
233 "<publication categoryName=\"note\" instance=\"0\" container=\"400\" version=\"%d\" expireType=\"static\">"\
234 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
235 "<body type=\"personal\" uri=\"\">%s</body>"\
238 "<publication categoryName=\"note\" instance=\"0\" container=\"200\" version=\"%d\" expireType=\"static\">"\
239 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
240 "<body type=\"personal\" uri=\"\">%s</body>"\
243 "<publication categoryName=\"note\" instance=\"0\" container=\"300\" version=\"%d\" expireType=\"static\">"\
244 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
245 "<body type=\"personal\" uri=\"\">%s</body>"\
252 #define SIPE_SEND_CLEAR_PRESENCE \
253 "<publish xmlns=\"http://schemas.microsoft.com/2006/09/sip/rich-presence\">"\
254 "<publications uri=\"%s\">"\
255 "<publication categoryName=\"state\" instance=\"906391354\" container=\"2\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
256 "<publication categoryName=\"state\" instance=\"906391356\" container=\"0\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
257 "<publication categoryName=\"note\" instance=\"0\" container=\"300\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
258 "<publication categoryName=\"note\" instance=\"0\" container=\"200\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
259 "<publication categoryName=\"note\" instance=\"0\" container=\"400\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
264 #define sipe_soap(method, body) \
265 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
267 "<m:" method " xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
271 "</SOAP-ENV:Envelope>"
273 #define SIPE_SOAP_SET_CONTACT sipe_soap("setContact", \
274 "<m:displayName>%s</m:displayName>"\
275 "<m:groups>%s</m:groups>"\
276 "<m:subscribed>%s</m:subscribed>"\
279 "<m:deltaNum>%d</m:deltaNum>")
281 #define SIPE_SOAP_DEL_CONTACT sipe_soap("deleteContact", \
283 "<m:deltaNum>%d</m:deltaNum>")
285 #define SIPE_SOAP_ADD_GROUP sipe_soap("addGroup", \
286 "<m:name>%s</m:name>"\
288 "<m:deltaNum>%d</m:deltaNum>")
290 #define SIPE_SOAP_MOD_GROUP sipe_soap("modifyGroup", \
291 "<m:groupID>%d</m:groupID>"\
292 "<m:name>%s</m:name>"\
294 "<m:deltaNum>%d</m:deltaNum>")
296 #define SIPE_SOAP_DEL_GROUP sipe_soap("deleteGroup", \
297 "<m:groupID>%d</m:groupID>"\
298 "<m:deltaNum>%d</m:deltaNum>")
300 // first/mask arg is sip:user@domain.com
301 // second/rights arg is AA for allow, BD for deny
302 #define SIPE_SOAP_ALLOW_DENY sipe_soap("setACE", \
303 "<m:type>USER</m:type>"\
304 "<m:mask>%s</m:mask>"\
305 "<m:rights>%s</m:rights>"\
306 "<m:deltaNum>%d</m:deltaNum>")
308 #define SIPE_SOAP_SET_PRESENCE sipe_soap("setPresence", \
309 "<m:presentity m:uri=\"%s\">"\
310 "<m:availability m:aggregate=\"%d\"/>"\
311 "<m:activity m:aggregate=\"%d\" m:note=\"%s\"/>"\
312 "<deviceName xmlns=\"http://schemas.microsoft.com/2002/09/sip/client/presence\" name=\"USER-DESKTOP\"/>"\
313 "<rtc:devicedata xmlns:rtc=\"http://schemas.microsoft.com/2002/09/sip/client/presence\" namespace=\"rtcService\">"\
314 "<![CDATA[<caps><renders_gif/><renders_isf/></caps>]]></rtc:devicedata>"\
317 #define SIPE_SOAP_SEARCH_CONTACT \
318 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
320 "<m:directorySearch xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
321 "<m:filter m:href=\"#searchArray\"/>"\
322 "<m:maxResults>%d</m:maxResults>"\
323 "</m:directorySearch>"\
324 "<m:Array xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\" m:id=\"searchArray\">"\
328 "</SOAP-ENV:Envelope>"
330 #define SIPE_SOAP_SEARCH_ROW "<m:row m:attrib=\"%s\" m:value=\"%s\"/>"
332 #endif /* _PIDGIN_SIPE_H */