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"
43 #define SIMPLE_BUF_INC 4096
45 #define SIPE_TYPING_RECV_TIMEOUT 6
46 #define SIPE_TYPING_SEND_TIMEOUT 4
48 #define PURPLE_WEBSITE "http://pidgin.sf.im/"
51 struct sip_im_session
{
53 struct sip_dialog
* dialog
;
54 struct transaction
* outgoing_invite
;
56 GSList
*outgoing_message_queue
;
57 /** Key is <Call-ID><CSeq><METHOD> */
58 GHashTable
*unconfirmed_messages
;
61 // dialog is the new term for call-leg
69 GSList
*supported
; // counterparty capabilities
80 typedef enum sipe_auth_type
98 gchar
*digest_session_key
;
109 } sipe_transport_type
;
111 struct sipe_service_data
{
113 const char *transport
;
114 sipe_transport_type type
;
117 struct sipe_account_data
{
118 PurpleConnection
*gc
;
124 /** Allowed server events to subscribe. From register OK response. */
125 GSList
*allow_events
;
126 PurpleDnsQueryData
*query_data
;
127 PurpleSrvQueryData
*srv_query_data
;
128 const struct sipe_service_data
*service_data
;
129 PurpleNetworkListenData
*listen_data
;
132 time_t last_keepalive
;
133 int registerstatus
; /* 0 nothing, 1 first registration send, 2 auth received, 3 registered */
134 struct sip_auth registrar
;
135 struct sip_auth proxy
;
136 gboolean reregister_set
; /* whether reregister timer set */
137 gboolean reauthenticate_set
; /* whether reauthenticate timer set */
138 gboolean subscribed
; /* whether subscribed to events, except buddies presence */
139 gboolean subscribed_buddies
; /* whether subscribed to buddies presence */
145 int presence_method_version
;
149 gboolean msrtc_event_categories
; /*if there is support for batched category subscription [SIP-PRES]*/
152 guint keepalive_timeout
;
155 PurpleAccount
*account
;
156 PurpleCircBuffer
*txbuf
;
159 GSList
*transactions
;
163 sipe_transport_type transport
;
164 gboolean auto_transport
;
165 PurpleSslConnection
*gsc
;
166 struct sockaddr_in serveraddr
;
168 int realport
; /* port and hostname from SRV record */
169 gboolean processing_input
;
172 struct sip_connection
{
180 struct sipe_auth_job
{
182 struct sipe_account_data
* sip
;
185 struct scheduled_action
;
187 typedef gboolean (*Action
) (struct sipe_account_data
*, struct scheduled_action
*);
189 struct scheduled_action
{
192 * Format is <Event>[<Data>...]
193 * Example: <presence><sip:user@domain.com> or <registration>
196 guint timeout_handler
;
199 struct sipe_account_data
*sip
;
205 typedef gboolean (*TransCallback
) (struct sipe_account_data
*, struct sipmsg
*, struct transaction
*);
210 int transport
; /* 0 = tcp, 1 = udp */
214 TransCallback callback
;
221 PurpleGroup
*purple_group
;
224 struct group_user_context
{
229 GSList
* slist_insert_unique_sorted(GSList
*list
, gpointer data
, GCompareFunc func
);
231 gboolean
sipe_scheduled_exec(struct scheduled_action
*sched_action
);
233 void sipe_schedule_action(gchar
*name
, int timeout
, Action action
, struct sipe_account_data
*sip
, void * payload
);
235 GList
*sipe_actions(PurplePlugin
*plugin
, gpointer context
);
237 gboolean
purple_init_plugin(PurplePlugin
*plugin
);
239 #define SIPE_INVITE_TEXT "ms-text-format: text/plain; charset=UTF-8%s;ms-body=%s\r\n"
241 #define SIPE_SEND_TYPING \
242 "<?xml version=\"1.0\"?>"\
243 "<KeyboardActivity>"\
244 "<status status=\"type\" />"\
245 "</KeyboardActivity>"
247 #define SIPE_SEND_PRESENCE \
248 "<publish xmlns=\"http://schemas.microsoft.com/2006/09/sip/rich-presence\">"\
249 "<publications uri=\"%s\">"\
250 "<publication categoryName=\"state\" instance=\"906391354\" container=\"2\" version=\"%d\" expireType=\"endpoint\">"\
251 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"false\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"machineState\">"\
252 "<availability>%d</availability>"\
253 "<endpointLocation></endpointLocation>"\
256 "<publication categoryName=\"state\" instance=\"906391356\" container=\"0\" version=\"%d\" expireType=\"endpoint\">"\
257 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"userState\">"\
258 "<availability>%d</availability>"\
259 "<endpointLocation></endpointLocation>"\
262 "<publication categoryName=\"note\" instance=\"0\" container=\"400\" version=\"%d\" expireType=\"static\">"\
263 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
264 "<body type=\"personal\" uri=\"\">%s</body>"\
267 "<publication categoryName=\"note\" instance=\"0\" container=\"200\" version=\"%d\" expireType=\"static\">"\
268 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
269 "<body type=\"personal\" uri=\"\">%s</body>"\
272 "<publication categoryName=\"note\" instance=\"0\" container=\"300\" version=\"%d\" expireType=\"static\">"\
273 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
274 "<body type=\"personal\" uri=\"\">%s</body>"\
281 #define SIPE_SEND_CLEAR_PRESENCE \
282 "<publish xmlns=\"http://schemas.microsoft.com/2006/09/sip/rich-presence\">"\
283 "<publications uri=\"%s\">"\
284 "<publication categoryName=\"state\" instance=\"906391354\" container=\"2\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
285 "<publication categoryName=\"state\" instance=\"906391356\" container=\"0\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
286 "<publication categoryName=\"note\" instance=\"0\" container=\"300\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
287 "<publication categoryName=\"note\" instance=\"0\" container=\"200\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
288 "<publication categoryName=\"note\" instance=\"0\" container=\"400\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
293 #define sipe_soap(method, body) \
294 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
296 "<m:" method " xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
300 "</SOAP-ENV:Envelope>"
302 #define SIPE_SOAP_SET_CONTACT sipe_soap("setContact", \
303 "<m:displayName>%s</m:displayName>"\
304 "<m:groups>%s</m:groups>"\
305 "<m:subscribed>%s</m:subscribed>"\
308 "<m:deltaNum>%d</m:deltaNum>")
310 #define SIPE_SOAP_DEL_CONTACT sipe_soap("deleteContact", \
312 "<m:deltaNum>%d</m:deltaNum>")
314 #define SIPE_SOAP_ADD_GROUP sipe_soap("addGroup", \
315 "<m:name>%s</m:name>"\
317 "<m:deltaNum>%d</m:deltaNum>")
319 #define SIPE_SOAP_MOD_GROUP sipe_soap("modifyGroup", \
320 "<m:groupID>%d</m:groupID>"\
321 "<m:name>%s</m:name>"\
323 "<m:deltaNum>%d</m:deltaNum>")
325 #define SIPE_SOAP_DEL_GROUP sipe_soap("deleteGroup", \
326 "<m:groupID>%d</m:groupID>"\
327 "<m:deltaNum>%d</m:deltaNum>")
329 // first/mask arg is sip:user@domain.com
330 // second/rights arg is AA for allow, BD for deny
331 #define SIPE_SOAP_ALLOW_DENY sipe_soap("setACE", \
332 "<m:type>USER</m:type>"\
333 "<m:mask>%s</m:mask>"\
334 "<m:rights>%s</m:rights>"\
335 "<m:deltaNum>%d</m:deltaNum>")
337 #define SIPE_SOAP_SET_PRESENCE sipe_soap("setPresence", \
338 "<m:presentity m:uri=\"%s\">"\
339 "<m:availability m:aggregate=\"%d\"/>"\
340 "<m:activity m:aggregate=\"%d\" m:note=\"%s\"/>"\
341 "<deviceName xmlns=\"http://schemas.microsoft.com/2002/09/sip/client/presence\" name=\"USER-DESKTOP\"/>"\
342 "<rtc:devicedata xmlns:rtc=\"http://schemas.microsoft.com/2002/09/sip/client/presence\" namespace=\"rtcService\">"\
343 "<![CDATA[<caps><renders_gif/><renders_isf/></caps>]]></rtc:devicedata>"\
346 #define SIPE_SOAP_SEARCH_CONTACT \
347 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
349 "<m:directorySearch xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
350 "<m:filter m:href=\"#searchArray\"/>"\
351 "<m:maxResults>%d</m:maxResults>"\
352 "</m:directorySearch>"\
353 "<m:Array xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\" m:id=\"searchArray\">"\
357 "</SOAP-ENV:Envelope>"
359 #define SIPE_SOAP_SEARCH_ROW "<m:row m:attrib=\"%s\" m:value=\"%s\"/>"
361 #endif /* _PIDGIN_SIPE_H */