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
36 #include "circbuffer.h"
48 #define SIPE_UNUSED_PARAMETER __attribute__((unused))
50 #define SIMPLE_BUF_INC 4096
52 #define SIPE_TYPING_RECV_TIMEOUT 6
53 #define SIPE_TYPING_SEND_TIMEOUT 4
55 #define PURPLE_WEBSITE "http://pidgin.sf.im/"
63 gboolean resubscribed
;
68 SipSecContext gssapi_context
;
83 } sipe_transport_type
;
85 struct sipe_service_data
{
87 const char *transport
;
88 sipe_transport_type type
;
91 /** MS-PRES container */
92 struct sipe_publication
{
99 /** MS-PRES container */
100 struct sipe_container
{
105 /** MS-PRES container member */
106 struct sipe_container_member
{
107 /** user, domain, sameEnterprise, federated, publicCloud; everyone */
112 struct sipe_account_data
{
113 PurpleConnection
*gc
;
120 gchar
*focus_factory_uri
;
121 /** Allowed server events to subscribe. From register OK response. */
122 GSList
*allow_events
;
123 PurpleDnsQueryData
*query_data
;
124 PurpleSrvQueryData
*srv_query_data
;
125 const struct sipe_service_data
*service_data
;
126 PurpleNetworkListenData
*listen_data
;
130 time_t last_keepalive
;
131 int registerstatus
; /* 0 nothing, 1 first registration send, 2 auth received, 3 registered */
132 struct sip_auth registrar
;
133 struct sip_auth proxy
;
134 gboolean reregister_set
; /* whether reregister timer set */
135 gboolean reauthenticate_set
; /* whether reauthenticate timer set */
136 gboolean subscribed
; /* whether subscribed to events, except buddies presence */
137 gboolean subscribed_buddies
; /* whether subscribed to buddies presence */
138 gboolean access_level_set
; /* whether basic access level set */
139 GSList
*our_publication_keys
; /* [MS-PRES] */
140 GHashTable
*our_publications
; /* [MS-PRES] */
146 int presence_method_version
;
150 gboolean msrtc_event_categories
; /*if there is support for batched category subscription [SIP-PRES]*/
151 gboolean batched_support
; /*if there is support for batched subscription*/
152 GSList
*containers
; /* MS-PRES containers */
155 guint keepalive_timeout
;
158 PurpleAccount
*account
;
159 PurpleCircBuffer
*txbuf
;
162 GSList
*transactions
;
166 sipe_transport_type transport
;
167 gboolean auto_transport
;
168 PurpleSslConnection
*gsc
;
169 struct sockaddr
*serveraddr
;
171 int realport
; /* port and hostname from SRV record */
172 gboolean processing_input
;
175 struct sip_connection
{
183 struct sipe_auth_job
{
185 struct sipe_account_data
* sip
;
190 typedef gboolean (*TransCallback
) (struct sipe_account_data
*, struct sipmsg
*, struct transaction
*);
195 int transport
; /* 0 = tcp, 1 = udp */
197 /** Not yet perfect, but surely better then plain CSeq
198 * Format is: <Call-ID><CSeq>
199 * (RFC3261 17.2.3 for matching server transactions: Request-URI, To tag, From tag, Call-ID, CSeq, and top Via)
203 TransCallback callback
;
210 PurpleGroup
*purple_group
;
213 struct group_user_context
{
218 GSList
* slist_insert_unique_sorted(GSList
*list
, gpointer data
, GCompareFunc func
);
220 GList
*sipe_actions(PurplePlugin
*plugin
, gpointer context
);
222 gboolean
purple_init_plugin(PurplePlugin
*plugin
);
225 * THE BIG SPLIT - temporary interfaces
227 * Previously private functions in sipe.c that are
228 * - waiting to be factored out to an appropriate module
229 * - are needed by the already created new modules
234 * Since SIP (RFC3261) is extensible by its design,
235 * and MS specs prove just that (they all are defined as SIP extensions),
236 * it make sense to split functionality by extension (or close extension group).
237 * For example: conference, presence (MS-PRES), etc.
239 * This way our code will not be monolithic, but potentially _reusable_. May be
240 * a top of other SIP core, and/or other front-end (Telepathy framework?).
242 /* Forward declarations */
246 /* SIP send module? */
248 send_sip_request(PurpleConnection
*gc
, const gchar
*method
,
249 const gchar
*url
, const gchar
*to
, const gchar
*addheaders
,
250 const gchar
*body
, struct sip_dialog
*dialog
, TransCallback tc
);
252 send_sip_response(PurpleConnection
*gc
, struct sipmsg
*msg
, int code
,
253 const char *text
, const char *body
);
255 sipe_invite(struct sipe_account_data
*sip
, struct sip_session
*session
,
256 const gchar
*who
, const gchar
*msg_body
,
257 const gchar
*referred_by
, const gboolean is_triggered
);
259 gboolean
process_subscribe_response(struct sipe_account_data
*sip
,
261 struct transaction
*tc
);
264 sipe_invite_to_chat(struct sipe_account_data
*sip
,
265 struct sip_session
*session
,
267 /* Session module? */
269 sipe_present_message_undelivered_err(struct sipe_account_data
*sip
,
270 struct sip_session
*session
,
272 const gchar
*message
);
275 sipe_present_info(struct sipe_account_data
*sip
,
276 struct sip_session
*session
,
277 const gchar
*message
);
281 sipe_process_pending_invite_queue(struct sipe_account_data
*sip
,
282 struct sip_session
*session
);
284 /*** THE BIG SPLIT END ***/
286 #define SIPE_INVITE_TEXT "ms-text-format: text/plain; charset=UTF-8%s;ms-body=%s\r\n"
288 #define SIPE_SEND_TYPING \
289 "<?xml version=\"1.0\"?>"\
290 "<KeyboardActivity>"\
291 "<status status=\"type\" />"\
292 "</KeyboardActivity>"
294 #define SIPE_SEND_PRESENCE \
295 "<publish xmlns=\"http://schemas.microsoft.com/2006/09/sip/rich-presence\">"\
296 "<publications uri=\"%s\">"\
297 "<publication categoryName=\"state\" instance=\"906391354\" container=\"2\" version=\"%d\" expireType=\"endpoint\">"\
298 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"false\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"machineState\">"\
299 "<availability>%d</availability>"\
300 "<endpointLocation></endpointLocation>"\
303 "<publication categoryName=\"state\" instance=\"906391356\" container=\"0\" version=\"%d\" expireType=\"endpoint\">"\
304 "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" manual=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"userState\">"\
305 "<availability>%d</availability>"\
306 "<endpointLocation></endpointLocation>"\
309 "<publication categoryName=\"note\" instance=\"0\" container=\"400\" version=\"%d\" expireType=\"static\">"\
310 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
311 "<body type=\"personal\" uri=\"\">%s</body>"\
314 "<publication categoryName=\"note\" instance=\"0\" container=\"200\" version=\"%d\" expireType=\"static\">"\
315 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
316 "<body type=\"personal\" uri=\"\">%s</body>"\
319 "<publication categoryName=\"note\" instance=\"0\" container=\"300\" version=\"%d\" expireType=\"static\">"\
320 "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\">"\
321 "<body type=\"personal\" uri=\"\">%s</body>"\
328 #define SIPE_SEND_CLEAR_PRESENCE \
329 "<publish xmlns=\"http://schemas.microsoft.com/2006/09/sip/rich-presence\">"\
330 "<publications uri=\"%s\">"\
331 "<publication categoryName=\"state\" instance=\"906391354\" container=\"2\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
332 "<publication categoryName=\"state\" instance=\"906391356\" container=\"0\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
333 "<publication categoryName=\"note\" instance=\"0\" container=\"300\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
334 "<publication categoryName=\"note\" instance=\"0\" container=\"200\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
335 "<publication categoryName=\"note\" instance=\"0\" container=\"400\" version=\"1\" expireType=\"static\" expires=\"0\" />"\
340 #define sipe_soap(method, body) \
341 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
343 "<m:" method " xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
347 "</SOAP-ENV:Envelope>"
349 #define SIPE_SOAP_SET_CONTACT sipe_soap("setContact", \
350 "<m:displayName>%s</m:displayName>"\
351 "<m:groups>%s</m:groups>"\
352 "<m:subscribed>%s</m:subscribed>"\
355 "<m:deltaNum>%d</m:deltaNum>")
357 #define SIPE_SOAP_DEL_CONTACT sipe_soap("deleteContact", \
359 "<m:deltaNum>%d</m:deltaNum>")
361 #define SIPE_SOAP_ADD_GROUP sipe_soap("addGroup", \
362 "<m:name>%s</m:name>"\
364 "<m:deltaNum>%d</m:deltaNum>")
366 #define SIPE_SOAP_MOD_GROUP sipe_soap("modifyGroup", \
367 "<m:groupID>%d</m:groupID>"\
368 "<m:name>%s</m:name>"\
370 "<m:deltaNum>%d</m:deltaNum>")
372 #define SIPE_SOAP_DEL_GROUP sipe_soap("deleteGroup", \
373 "<m:groupID>%d</m:groupID>"\
374 "<m:deltaNum>%d</m:deltaNum>")
376 // first/mask arg is sip:user@domain.com
377 // second/rights arg is AA for allow, BD for deny
378 #define SIPE_SOAP_ALLOW_DENY sipe_soap("setACE", \
379 "<m:type>USER</m:type>"\
380 "<m:mask>%s</m:mask>"\
381 "<m:rights>%s</m:rights>"\
382 "<m:deltaNum>%d</m:deltaNum>")
384 #define SIPE_SOAP_SET_PRESENCE sipe_soap("setPresence", \
385 "<m:presentity m:uri=\"%s\">"\
386 "<m:availability m:aggregate=\"%d\"/>"\
387 "<m:activity m:aggregate=\"%d\" m:note=\"%s\"/>"\
388 "<deviceName xmlns=\"http://schemas.microsoft.com/2002/09/sip/client/presence\" name=\"USER-DESKTOP\"/>"\
389 "<rtc:devicedata xmlns:rtc=\"http://schemas.microsoft.com/2002/09/sip/client/presence\" namespace=\"rtcService\">"\
390 "<![CDATA[<caps><renders_gif/><renders_isf/></caps>]]></rtc:devicedata>"\
393 #define SIPE_SOAP_SEARCH_CONTACT \
394 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
396 "<m:directorySearch xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\">" \
397 "<m:filter m:href=\"#searchArray\"/>"\
398 "<m:maxResults>%d</m:maxResults>"\
399 "</m:directorySearch>"\
400 "<m:Array xmlns:m=\"http://schemas.microsoft.com/winrtc/2002/11/sip\" m:id=\"searchArray\">"\
404 "</SOAP-ENV:Envelope>"
406 #define SIPE_SOAP_SEARCH_ROW "<m:row m:attrib=\"%s\" m:value=\"%s\"/>"
408 #endif /* _PIDGIN_SIPE_H */