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 /** Correspond to multy-party conversation */
53 struct sip_im_session
{
54 gchar
*with
; /* For IM sessions only (not multi-party) . A URI.*/
56 /** Human readable chat name */
58 /** Call-Id identifying the conversation */
59 gchar
*callid
; /* For multiparty conversations */
60 /** Roster Manager URI */
61 gchar
*roster_manager
;
63 gboolean is_voting_in_progress
;
64 gboolean is_multiparty
;
67 struct sip_dialog
*focus_dialog
;
68 /** key is user (URI) */
70 //struct sip_dialog * dialog;
71 /** Link to purple chat or IM */
72 PurpleConversation
*conv
;
74 GSList
*outgoing_message_queue
;
75 /** Key is <Call-ID><CSeq><METHOD> */
76 GHashTable
*unconfirmed_messages
;
78 GSList
*pending_invite_queue
;
81 // dialog is the new term for call-leg
83 gchar
*with
; /* URI */
88 * 0 - didn't participate
97 GSList
*supported
; // counterparty capabilities
99 gboolean is_established
;
100 struct transaction
*outgoing_invite
;
108 gboolean resubscribed
;
113 SipSecContext gssapi_context
;
128 } sipe_transport_type
;
130 struct sipe_service_data
{
132 const char *transport
;
133 sipe_transport_type type
;
136 /** MS-PRES container */
137 struct sipe_container
{
142 /** MS-PRES container member */
143 struct sipe_container_member
{
144 /** user, domain, sameEnterprise, federated, publicCloud; everyone */
149 struct sipe_account_data
{
150 PurpleConnection
*gc
;
157 /** Allowed server events to subscribe. From register OK response. */
158 GSList
*allow_events
;
159 PurpleDnsQueryData
*query_data
;
160 PurpleSrvQueryData
*srv_query_data
;
161 const struct sipe_service_data
*service_data
;
162 PurpleNetworkListenData
*listen_data
;
166 time_t last_keepalive
;
167 int registerstatus
; /* 0 nothing, 1 first registration send, 2 auth received, 3 registered */
168 struct sip_auth registrar
;
169 struct sip_auth proxy
;
170 gboolean reregister_set
; /* whether reregister timer set */
171 gboolean reauthenticate_set
; /* whether reauthenticate timer set */
172 gboolean subscribed
; /* whether subscribed to events, except buddies presence */
173 gboolean subscribed_buddies
; /* whether subscribed to buddies presence */
174 gboolean access_level_set
; /* whether basic access level set */
180 int presence_method_version
;
184 gboolean msrtc_event_categories
; /*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 */
189 guint keepalive_timeout
;
192 PurpleAccount
*account
;
193 PurpleCircBuffer
*txbuf
;
196 GSList
*transactions
;
200 sipe_transport_type transport
;
201 gboolean auto_transport
;
202 PurpleSslConnection
*gsc
;
203 struct sockaddr_in serveraddr
;
205 int realport
; /* port and hostname from SRV record */
206 gboolean processing_input
;
209 struct sip_connection
{
217 struct sipe_auth_job
{
219 struct sipe_account_data
* sip
;
224 typedef gboolean (*TransCallback
) (struct sipe_account_data
*, struct sipmsg
*, struct transaction
*);
229 int transport
; /* 0 = tcp, 1 = udp */
233 TransCallback callback
;
240 PurpleGroup
*purple_group
;
243 struct group_user_context
{
248 GSList
* slist_insert_unique_sorted(GSList
*list
, gpointer data
, GCompareFunc func
);
250 GList
*sipe_actions(PurplePlugin
*plugin
, gpointer context
);
252 gboolean
purple_init_plugin(PurplePlugin
*plugin
);
254 #define SIPE_INVITE_TEXT "ms-text-format: text/plain; charset=UTF-8%s;ms-body=%s\r\n"
256 #define SIPE_SEND_TYPING \
257 "<?xml version=\"1.0\"?>"\
258 "<KeyboardActivity>"\
259 "<status status=\"type\" />"\
260 "</KeyboardActivity>"
262 #define SIPE_SEND_PRESENCE \
263 "<publish xmlns=\"http://schemas.microsoft.com/2006/09/sip/rich-presence\">"\
264 "<publications uri=\"%s\">"\
265 "<publication categoryName=\"state\" instance=\"906391354\" container=\"2\" version=\"%d\" expireType=\"endpoint\">"\
266 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"false\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"machineState\">"\
267 "<availability>%d</availability>"\
268 "<endpointLocation></endpointLocation>"\
271 "<publication categoryName=\"state\" instance=\"906391356\" container=\"0\" version=\"%d\" expireType=\"endpoint\">"\
272 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"userState\">"\
273 "<availability>%d</availability>"\
274 "<endpointLocation></endpointLocation>"\
277 "<publication categoryName=\"note\" instance=\"0\" container=\"400\" version=\"%d\" expireType=\"static\">"\
278 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
279 "<body type=\"personal\" uri=\"\">%s</body>"\
282 "<publication categoryName=\"note\" instance=\"0\" container=\"200\" version=\"%d\" expireType=\"static\">"\
283 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
284 "<body type=\"personal\" uri=\"\">%s</body>"\
287 "<publication categoryName=\"note\" instance=\"0\" container=\"300\" version=\"%d\" expireType=\"static\">"\
288 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
289 "<body type=\"personal\" uri=\"\">%s</body>"\
296 #define SIPE_SEND_CLEAR_PRESENCE \
297 "<publish xmlns=\"http://schemas.microsoft.com/2006/09/sip/rich-presence\">"\
298 "<publications uri=\"%s\">"\
299 "<publication categoryName=\"state\" instance=\"906391354\" container=\"2\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
300 "<publication categoryName=\"state\" instance=\"906391356\" container=\"0\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
301 "<publication categoryName=\"note\" instance=\"0\" container=\"300\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
302 "<publication categoryName=\"note\" instance=\"0\" container=\"200\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
303 "<publication categoryName=\"note\" instance=\"0\" container=\"400\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
308 #define sipe_soap(method, body) \
309 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
311 "<m:" method " xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
315 "</SOAP-ENV:Envelope>"
317 #define SIPE_SOAP_SET_CONTACT sipe_soap("setContact", \
318 "<m:displayName>%s</m:displayName>"\
319 "<m:groups>%s</m:groups>"\
320 "<m:subscribed>%s</m:subscribed>"\
323 "<m:deltaNum>%d</m:deltaNum>")
325 #define SIPE_SOAP_DEL_CONTACT sipe_soap("deleteContact", \
327 "<m:deltaNum>%d</m:deltaNum>")
329 #define SIPE_SOAP_ADD_GROUP sipe_soap("addGroup", \
330 "<m:name>%s</m:name>"\
332 "<m:deltaNum>%d</m:deltaNum>")
334 #define SIPE_SOAP_MOD_GROUP sipe_soap("modifyGroup", \
335 "<m:groupID>%d</m:groupID>"\
336 "<m:name>%s</m:name>"\
338 "<m:deltaNum>%d</m:deltaNum>")
340 #define SIPE_SOAP_DEL_GROUP sipe_soap("deleteGroup", \
341 "<m:groupID>%d</m:groupID>"\
342 "<m:deltaNum>%d</m:deltaNum>")
344 // first/mask arg is sip:user@domain.com
345 // second/rights arg is AA for allow, BD for deny
346 #define SIPE_SOAP_ALLOW_DENY sipe_soap("setACE", \
347 "<m:type>USER</m:type>"\
348 "<m:mask>%s</m:mask>"\
349 "<m:rights>%s</m:rights>"\
350 "<m:deltaNum>%d</m:deltaNum>")
352 #define SIPE_SOAP_SET_PRESENCE sipe_soap("setPresence", \
353 "<m:presentity m:uri=\"%s\">"\
354 "<m:availability m:aggregate=\"%d\"/>"\
355 "<m:activity m:aggregate=\"%d\" m:note=\"%s\"/>"\
356 "<deviceName xmlns=\"http://schemas.microsoft.com/2002/09/sip/client/presence\" name=\"USER-DESKTOP\"/>"\
357 "<rtc:devicedata xmlns:rtc=\"http://schemas.microsoft.com/2002/09/sip/client/presence\" namespace=\"rtcService\">"\
358 "<![CDATA[<caps><renders_gif/><renders_isf/></caps>]]></rtc:devicedata>"\
361 #define SIPE_SOAP_SEARCH_CONTACT \
362 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
364 "<m:directorySearch xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
365 "<m:filter m:href=\"#searchArray\"/>"\
366 "<m:maxResults>%d</m:maxResults>"\
367 "</m:directorySearch>"\
368 "<m:Array xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\" m:id=\"searchArray\">"\
372 "</SOAP-ENV:Envelope>"
374 #define SIPE_SOAP_SEARCH_ROW "<m:row m:attrib=\"%s\" m:value=\"%s\"/>"
376 #endif /* _PIDGIN_SIPE_H */