libpurple/protocols/jabber/jabber.c

Mon, 02 Jun 2008 18:18:58 +0000

author
Michael Ruprecht <maiku@pidgin.im>
date
Mon, 02 Jun 2008 18:18:58 +0000
branch
soc.2008.vv
changeset 23715
0844f5e9ac8e
parent 23714
a08cf0090382
child 23716
e1a9c55075ba
permissions
-rw-r--r--

Fix crash bug when checking if a contact can do media when logging out.

2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2 * purple - Jabber Protocol Plugin
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
3 *
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
5 *
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
9 * (at your option) any later version.
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
10 *
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
14 * GNU General Public License for more details.
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
15 *
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19341
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
19 *
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
20 */
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
21 #include "internal.h"
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
22
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
23 #include "account.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
24 #include "accountopt.h"
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
25 #include "blist.h"
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
26 #include "cmds.h"
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10504
diff changeset
27 #include "connection.h"
15952
c087855dc551 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
28 #include "conversation.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
29 #include "debug.h"
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
30 #include "dnssrv.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
31 #include "message.h"
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
32 #include "notify.h"
8713
8a7baa8f8460 [gaim-migrate @ 9467]
Gary Kramlich <grim@pidgin.im>
parents: 8591
diff changeset
33 #include "pluginpref.h"
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
34 #include "proxy.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
35 #include "prpl.h"
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
36 #include "request.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
37 #include "server.h"
7095
17d2b54254f8 [gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents: 7072
diff changeset
38 #include "util.h"
9943
b54a762f60fa [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
39 #include "version.h"
15952
c087855dc551 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
40 #include "xmlnode.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
41
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
42 #include "auth.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
43 #include "buddy.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
44 #include "chat.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
45 #include "disco.h"
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15237
diff changeset
46 #include "google.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
47 #include "iq.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
48 #include "jutil.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
49 #include "message.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
50 #include "parser.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
51 #include "presence.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
52 #include "jabber.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
53 #include "roster.h"
17769
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
54 #include "ping.h"
9466
b6425eab60ca [gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents: 9414
diff changeset
55 #include "si.h"
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
56 #include "xdata.h"
17768
7be011945a1b added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents: 17767
diff changeset
57 #include "pep.h"
17817
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17815
diff changeset
58 #include "adhoccommands.h"
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
59 #include "jingle.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
60
23704
9b88c9b23aed Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents: 23701
diff changeset
61 #ifdef USE_VV
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
62 #include <gst/farsight/fs-conference-iface.h>
23714
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
63
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
64 #define XEP_0167_CAP "http://www.xmpp.org/extensions/xep-0167.html"
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
65 #define XEP_0180_CAP "http://www.xmpp.org/extensions/xep-0180.html"
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
66 #define GTALK_CAP "http://www.google.com/session/phone"
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
67
23700
e47be56bdd2b Fix compiling with the --disable-vv switch.
Michael Ruprecht <maiku@pidgin.im>
parents: 23698
diff changeset
68 #endif
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
69
17813
c5cc8ebf62c0 Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents: 17810
diff changeset
70 #define JABBER_CONNECT_STEPS (js->gsc ? 9 : 5)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
71
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
72 static PurplePlugin *my_protocol = NULL;
21623
722e905dd5b5 Fix #3669
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
73 GList *jabber_features = NULL;
4249
62583b5d3663 [gaim-migrate @ 4499]
Robert McQueen <robot101@debian.org>
parents: 4245
diff changeset
74
18912
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
75 static void jabber_unregister_account_cb(JabberStream *js);
4249
62583b5d3663 [gaim-migrate @ 4499]
Robert McQueen <robot101@debian.org>
parents: 4245
diff changeset
76
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
77 static void jabber_stream_init(JabberStream *js)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
78 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
79 char *open_stream;
3340
7e59a209931d [gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3337
diff changeset
80
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
81 open_stream = g_strdup_printf("<stream:stream to='%s' "
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
82 "xmlns='jabber:client' "
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
83 "xmlns:stream='http://etherx.jabber.org/streams' "
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
84 "version='1.0'>",
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7274
diff changeset
85 js->user->domain);
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13806
diff changeset
86 /* setup the parser fresh for each stream */
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13806
diff changeset
87 jabber_parser_setup(js);
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
88 jabber_send_raw(js, open_stream, -1);
14062
dd8d7eb8fa76 [gaim-migrate @ 16585]
Ethan Blanton <elb@pidgin.im>
parents: 14043
diff changeset
89 js->reinit = FALSE;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
90 g_free(open_stream);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
91 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
92
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
93 static void
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
94 jabber_session_initialized_cb(JabberStream *js, xmlnode *packet, gpointer data)
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
95 {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
96 const char *type = xmlnode_get_attrib(packet, "type");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
97 if(type && !strcmp(type, "result")) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
98 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
18912
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
99 if(js->unregistration)
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
100 jabber_unregister_account_cb(js);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
101 } else {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
102 purple_connection_error_reason (js->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
103 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
104 ("Error initializing session"));
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
105 }
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
106 }
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
107
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
108 static void jabber_session_init(JabberStream *js)
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
109 {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
110 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
111 xmlnode *session;
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
112
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
113 jabber_iq_set_callback(iq, jabber_session_initialized_cb, NULL);
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
114
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
115 session = xmlnode_new_child(iq->node, "session");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13806
diff changeset
116 xmlnode_set_namespace(session, "urn:ietf:params:xml:ns:xmpp-session");
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
117
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
118 jabber_iq_send(iq);
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
119 }
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
120
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
121 static void jabber_bind_result_cb(JabberStream *js, xmlnode *packet,
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
122 gpointer data)
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
123 {
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
124 const char *type = xmlnode_get_attrib(packet, "type");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
125 xmlnode *bind;
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
126
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
127 if(type && !strcmp(type, "result") &&
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
128 (bind = xmlnode_get_child_with_namespace(packet, "bind", "urn:ietf:params:xml:ns:xmpp-bind"))) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
129 xmlnode *jid;
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
130 char *full_jid;
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
131 if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) {
10289
18f2c2afebaf [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
132 JabberBuddy *my_jb = NULL;
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
133 jabber_id_free(js->user);
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
134 if(!(js->user = jabber_id_new(full_jid))) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
135 purple_connection_error_reason (js->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
136 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
137 _("Invalid response from server."));
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
138 }
10289
18f2c2afebaf [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
139 if((my_jb = jabber_buddy_find(js, full_jid, TRUE)))
18f2c2afebaf [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
140 my_jb->subscription |= JABBER_SUB_BOTH;
10504
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10490
diff changeset
141 g_free(full_jid);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
142 }
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
143 } else {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
144 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
145 char *msg = jabber_parse_error(js, packet, &reason);
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
146 purple_connection_error_reason (js->gc, reason, msg);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
147 g_free(msg);
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
148 }
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
149
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
150 jabber_session_init(js);
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
151 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
152
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
153 static void jabber_stream_features_parse(JabberStream *js, xmlnode *packet)
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
154 {
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
155 if(xmlnode_get_child(packet, "starttls")) {
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
156 if(jabber_process_starttls(js, packet))
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
157 return;
17830
ae563ca41109 Added an option to require SSL or TLS when connecting to an XMPP server.
Andreas Monitzer <am@adiumx.com>
parents: 17828
diff changeset
158 } else if(purple_account_get_bool(js->gc->account, "require_tls", FALSE) && !js->gsc) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
159 purple_connection_error_reason (js->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
160 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
161 _("You require encryption, but it is not available on this server."));
17830
ae563ca41109 Added an option to require SSL or TLS when connecting to an XMPP server.
Andreas Monitzer <am@adiumx.com>
parents: 17828
diff changeset
162 return;
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
163 }
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
164
10988
c164f2e5dfaa [gaim-migrate @ 12825]
Nathan Walp <nwalp@pidgin.im>
parents: 10941
diff changeset
165 if(js->registration) {
c164f2e5dfaa [gaim-migrate @ 12825]
Nathan Walp <nwalp@pidgin.im>
parents: 10941
diff changeset
166 jabber_register_start(js);
c164f2e5dfaa [gaim-migrate @ 12825]
Nathan Walp <nwalp@pidgin.im>
parents: 10941
diff changeset
167 } else if(xmlnode_get_child(packet, "mechanisms")) {
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
168 jabber_auth_start(js, packet);
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
169 } else if(xmlnode_get_child(packet, "bind")) {
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
170 xmlnode *bind, *resource;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
171 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET);
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
172 bind = xmlnode_new_child(iq->node, "bind");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13806
diff changeset
173 xmlnode_set_namespace(bind, "urn:ietf:params:xml:ns:xmpp-bind");
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
174 resource = xmlnode_new_child(bind, "resource");
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
175 xmlnode_insert_data(resource, js->user->resource, -1);
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
176
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
177 jabber_iq_set_callback(iq, jabber_bind_result_cb, NULL);
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
178
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
179 jabber_iq_send(iq);
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
180 } else /* if(xmlnode_get_child_with_namespace(packet, "auth")) */ {
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
181 /* If we get an empty stream:features packet, or we explicitly get
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
182 * an auth feature with namespace http://jabber.org/features/iq-auth
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
183 * we should revert back to iq:auth authentication, even though we're
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
184 * connecting to an XMPP server. */
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
185 js->auth_type = JABBER_AUTH_IQ_AUTH;
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
186 jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING);
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
187 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
188 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
189
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
190 static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet)
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
191 {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
192 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
193 char *msg = jabber_parse_error(js, packet, &reason);
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
194
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
195 purple_connection_error_reason (js->gc, reason, msg);
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
196
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
197 g_free(msg);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
198 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
199
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
200 static void tls_init(JabberStream *js);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
201
17828
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
202 void jabber_process_packet(JabberStream *js, xmlnode **packet)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
203 {
15980
77057c4f658a Minor code cleanup
Mark Doliner <markdoliner@pidgin.im>
parents: 15979
diff changeset
204 const char *xmlns;
77057c4f658a Minor code cleanup
Mark Doliner <markdoliner@pidgin.im>
parents: 15979
diff changeset
205
17828
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
206 purple_signal_emit(my_protocol, "jabber-receiving-xmlnode", js->gc, packet);
14358
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
207
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
208 /* if the signal leaves us with a null packet, we're done */
17828
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
209 if(NULL == *packet)
14358
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
210 return;
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
211
17828
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
212 xmlns = xmlnode_get_namespace(*packet);
15980
77057c4f658a Minor code cleanup
Mark Doliner <markdoliner@pidgin.im>
parents: 15979
diff changeset
213
17828
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
214 if(!strcmp((*packet)->name, "iq")) {
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
215 jabber_iq_parse(js, *packet);
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
216 } else if(!strcmp((*packet)->name, "presence")) {
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
217 jabber_presence_parse(js, *packet);
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
218 } else if(!strcmp((*packet)->name, "message")) {
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
219 jabber_message_parse(js, *packet);
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
220 } else if(!strcmp((*packet)->name, "stream:features")) {
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
221 jabber_stream_features_parse(js, *packet);
21623
722e905dd5b5 Fix #3669
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
222 } else if (!strcmp((*packet)->name, "features") && xmlns &&
15980
77057c4f658a Minor code cleanup
Mark Doliner <markdoliner@pidgin.im>
parents: 15979
diff changeset
223 !strcmp(xmlns, "http://etherx.jabber.org/streams")) {
17828
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
224 jabber_stream_features_parse(js, *packet);
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
225 } else if(!strcmp((*packet)->name, "stream:error") ||
21623
722e905dd5b5 Fix #3669
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
226 (!strcmp((*packet)->name, "error") && xmlns &&
15980
77057c4f658a Minor code cleanup
Mark Doliner <markdoliner@pidgin.im>
parents: 15979
diff changeset
227 !strcmp(xmlns, "http://etherx.jabber.org/streams")))
77057c4f658a Minor code cleanup
Mark Doliner <markdoliner@pidgin.im>
parents: 15979
diff changeset
228 {
17828
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
229 jabber_stream_handle_error(js, *packet);
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
230 } else if(!strcmp((*packet)->name, "challenge")) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
231 if(js->state == JABBER_STREAM_AUTHENTICATING)
17828
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
232 jabber_auth_handle_challenge(js, *packet);
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
233 } else if(!strcmp((*packet)->name, "success")) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
234 if(js->state == JABBER_STREAM_AUTHENTICATING)
17828
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
235 jabber_auth_handle_success(js, *packet);
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
236 } else if(!strcmp((*packet)->name, "failure")) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
237 if(js->state == JABBER_STREAM_AUTHENTICATING)
17828
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
238 jabber_auth_handle_failure(js, *packet);
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
239 } else if(!strcmp((*packet)->name, "proceed")) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
240 if(js->state == JABBER_STREAM_AUTHENTICATING && !js->gsc)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
241 tls_init(js);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
242 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
243 purple_debug(PURPLE_DEBUG_WARNING, "jabber", "Unknown packet: %s\n",
17828
6957bf9d7330 Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents: 17827
diff changeset
244 (*packet)->name);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
245 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
246 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
247
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
248 static int jabber_do_send(JabberStream *js, const char *data, int len)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
249 {
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
250 int ret;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
251
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
252 if (js->gsc)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
253 ret = purple_ssl_write(js->gsc, data, len);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
254 else
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
255 ret = write(js->fd, data, len);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
256
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
257 return ret;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
258 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
259
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
260 static void jabber_send_cb(gpointer data, gint source, PurpleInputCondition cond)
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
261 {
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
262 JabberStream *js = data;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
263 int ret, writelen;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
264 writelen = purple_circ_buffer_get_max_read(js->write_buffer);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
265
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
266 if (writelen == 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
267 purple_input_remove(js->writeh);
13746
790924f38349 [gaim-migrate @ 16155]
Mark Doliner <markdoliner@pidgin.im>
parents: 13546
diff changeset
268 js->writeh = 0;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
269 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
270 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
271
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
272 ret = jabber_do_send(js, js->write_buffer->outptr, writelen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
273
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
274 if (ret < 0 && errno == EAGAIN)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
275 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
276 else if (ret <= 0) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
277 purple_connection_error_reason (js->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
278 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
279 _("Write error"));
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
280 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
281 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
282
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
283 purple_circ_buffer_mark_read(js->write_buffer, ret);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
284 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
285
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
286 void jabber_send_raw(JabberStream *js, const char *data, int len)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
287 {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
288 int ret;
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
289
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
290 /* because printing a tab to debug every minute gets old */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
291 if(strcmp(data, "\t"))
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
292 purple_debug(PURPLE_DEBUG_MISC, "jabber", "Sending%s: %s\n",
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
293 js->gsc ? " (ssl)" : "", data);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
294
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
295 /* If we've got a security layer, we need to encode the data,
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
296 * splitting it on the maximum buffer length negotiated */
14668
7922f83d37df [gaim-migrate @ 17334]
Sean Egan <seanegan@pidgin.im>
parents: 14660
diff changeset
297
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
298 purple_signal_emit(my_protocol, "jabber-sending-text", js->gc, &data);
15412
def58941bcb9 [gaim-migrate @ 18143]
Sean Egan <seanegan@pidgin.im>
parents: 15363
diff changeset
299 if (data == NULL)
def58941bcb9 [gaim-migrate @ 18143]
Sean Egan <seanegan@pidgin.im>
parents: 15363
diff changeset
300 return;
14668
7922f83d37df [gaim-migrate @ 17334]
Sean Egan <seanegan@pidgin.im>
parents: 14660
diff changeset
301
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
302 #ifdef HAVE_CYRUS_SASL
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
303 if (js->sasl_maxbuf>0) {
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
304 int pos;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
305
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
306 if (!js->gsc && js->fd<0)
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
307 return;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
308 pos = 0;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
309 if (len == -1)
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
310 len = strlen(data);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
311 while (pos < len) {
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
312 int towrite;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
313 const char *out;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
314 unsigned olen;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
315
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
316 if ((len - pos) < js->sasl_maxbuf)
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
317 towrite = len - pos;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
318 else
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
319 towrite = js->sasl_maxbuf;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
320
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
321 sasl_encode(js->sasl, &data[pos], towrite, &out, &olen);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
322 pos += towrite;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
323
15783
e2f6e431f5a6 Simon Wilkinson noticed that this check was invalid and caused authentications to hang.
Daniel Atallah <datallah@pidgin.im>
parents: 15709
diff changeset
324 if (js->writeh == 0)
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
325 ret = jabber_do_send(js, out, olen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
326 else {
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
327 ret = -1;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
328 errno = EAGAIN;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
329 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
330
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
331 if (ret < 0 && errno != EAGAIN)
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
332 purple_connection_error_reason (js->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
333 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
334 _("Write error"));
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
335 else if (ret < olen) {
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
336 if (ret < 0)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
337 ret = 0;
13746
790924f38349 [gaim-migrate @ 16155]
Mark Doliner <markdoliner@pidgin.im>
parents: 13546
diff changeset
338 if (js->writeh == 0)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
339 js->writeh = purple_input_add(
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
340 js->gsc ? js->gsc->fd : js->fd,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
341 PURPLE_INPUT_WRITE,
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
342 jabber_send_cb, js);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
343 purple_circ_buffer_append(js->write_buffer,
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
344 out + ret, olen - ret);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
345 }
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
346 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
347 return;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
348 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
349 #endif
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
350
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
351 if (len == -1)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
352 len = strlen(data);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
353
13746
790924f38349 [gaim-migrate @ 16155]
Mark Doliner <markdoliner@pidgin.im>
parents: 13546
diff changeset
354 if (js->writeh == 0)
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
355 ret = jabber_do_send(js, data, len);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
356 else {
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
357 ret = -1;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
358 errno = EAGAIN;
2814
91cc1a0cdee0 [gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 2800
diff changeset
359 }
91cc1a0cdee0 [gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 2800
diff changeset
360
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
361 if (ret < 0 && errno != EAGAIN)
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
362 purple_connection_error_reason (js->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
363 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
364 _("Write error"));
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
365 else if (ret < len) {
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
366 if (ret < 0)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
367 ret = 0;
13746
790924f38349 [gaim-migrate @ 16155]
Mark Doliner <markdoliner@pidgin.im>
parents: 13546
diff changeset
368 if (js->writeh == 0)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
369 js->writeh = purple_input_add(
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
370 js->gsc ? js->gsc->fd : js->fd,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
371 PURPLE_INPUT_WRITE, jabber_send_cb, js);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
372 purple_circ_buffer_append(js->write_buffer,
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
373 data + ret, len - ret);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
374 }
14604
67a7c42a8654 [gaim-migrate @ 17263]
Sean Egan <seanegan@pidgin.im>
parents: 14498
diff changeset
375 return;
67a7c42a8654 [gaim-migrate @ 17263]
Sean Egan <seanegan@pidgin.im>
parents: 14498
diff changeset
376 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
377
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
378 int jabber_prpl_send_raw(PurpleConnection *gc, const char *buf, int len)
14604
67a7c42a8654 [gaim-migrate @ 17263]
Sean Egan <seanegan@pidgin.im>
parents: 14498
diff changeset
379 {
67a7c42a8654 [gaim-migrate @ 17263]
Sean Egan <seanegan@pidgin.im>
parents: 14498
diff changeset
380 JabberStream *js = (JabberStream*)gc->proto_data;
67a7c42a8654 [gaim-migrate @ 17263]
Sean Egan <seanegan@pidgin.im>
parents: 14498
diff changeset
381 jabber_send_raw(js, buf, len);
67a7c42a8654 [gaim-migrate @ 17263]
Sean Egan <seanegan@pidgin.im>
parents: 14498
diff changeset
382 return len;
2814
91cc1a0cdee0 [gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 2800
diff changeset
383 }
91cc1a0cdee0 [gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 2800
diff changeset
384
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
385 void jabber_send(JabberStream *js, xmlnode *packet)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
386 {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
387 char *txt;
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
388 int len;
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
389
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
390 purple_signal_emit(my_protocol, "jabber-sending-xmlnode", js->gc, &packet);
14358
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
391
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
392 /* if we get NULL back, we're done processing */
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
393 if(NULL == packet)
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
394 return;
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
395
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
396 txt = xmlnode_to_str(packet, &len);
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
397 jabber_send_raw(js, txt, len);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
398 g_free(txt);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
399 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
400
21974
daa6296d122d Send XMPP Pings to the server instead of whitespace for our keepalives. Timeout the connection if there's no response in 20 seconds
Sean Egan <seanegan@pidgin.im>
parents: 21929
diff changeset
401 static void jabber_pong_cb(JabberStream *js, xmlnode *packet, gpointer timeout)
daa6296d122d Send XMPP Pings to the server instead of whitespace for our keepalives. Timeout the connection if there's no response in 20 seconds
Sean Egan <seanegan@pidgin.im>
parents: 21929
diff changeset
402 {
22067
bb6fd6d794b5 purple_timeout_remove(), not g_source_remove(), must be used to remove a timeout added by purple_timeout_add(). The latter works when the glib run loop is being used but not when any other eventloop implementation is in use.
Evan Schoenberg <evands@pidgin.im>
parents: 21974
diff changeset
403 purple_timeout_remove(GPOINTER_TO_INT(timeout));
22096
0d28b254d322 Keep track of the keepalive timeout source so it can be removed when the account disconnects. This prevents a possible crash if the timeout fired after the account disconnected.
Evan Schoenberg <evands@pidgin.im>
parents: 22067
diff changeset
404 js->keepalive_timeout = -1;
21974
daa6296d122d Send XMPP Pings to the server instead of whitespace for our keepalives. Timeout the connection if there's no response in 20 seconds
Sean Egan <seanegan@pidgin.im>
parents: 21929
diff changeset
405 }
daa6296d122d Send XMPP Pings to the server instead of whitespace for our keepalives. Timeout the connection if there's no response in 20 seconds
Sean Egan <seanegan@pidgin.im>
parents: 21929
diff changeset
406
daa6296d122d Send XMPP Pings to the server instead of whitespace for our keepalives. Timeout the connection if there's no response in 20 seconds
Sean Egan <seanegan@pidgin.im>
parents: 21929
diff changeset
407 static gboolean jabber_pong_timeout(PurpleConnection *gc)
daa6296d122d Send XMPP Pings to the server instead of whitespace for our keepalives. Timeout the connection if there's no response in 20 seconds
Sean Egan <seanegan@pidgin.im>
parents: 21929
diff changeset
408 {
22101
747c8ade85aa Masca noticed that 0d28b254d322fb0006034065870603672e5666d2 made jabber.c not
Will Thompson <resiak@pidgin.im>
parents: 22096
diff changeset
409 JabberStream *js = gc->proto_data;
21974
daa6296d122d Send XMPP Pings to the server instead of whitespace for our keepalives. Timeout the connection if there's no response in 20 seconds
Sean Egan <seanegan@pidgin.im>
parents: 21929
diff changeset
410 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
daa6296d122d Send XMPP Pings to the server instead of whitespace for our keepalives. Timeout the connection if there's no response in 20 seconds
Sean Egan <seanegan@pidgin.im>
parents: 21929
diff changeset
411 _("Ping timeout"));
22096
0d28b254d322 Keep track of the keepalive timeout source so it can be removed when the account disconnects. This prevents a possible crash if the timeout fired after the account disconnected.
Evan Schoenberg <evands@pidgin.im>
parents: 22067
diff changeset
412 js->keepalive_timeout = -1;
21974
daa6296d122d Send XMPP Pings to the server instead of whitespace for our keepalives. Timeout the connection if there's no response in 20 seconds
Sean Egan <seanegan@pidgin.im>
parents: 21929
diff changeset
413 return FALSE;
daa6296d122d Send XMPP Pings to the server instead of whitespace for our keepalives. Timeout the connection if there's no response in 20 seconds
Sean Egan <seanegan@pidgin.im>
parents: 21929
diff changeset
414 }
daa6296d122d Send XMPP Pings to the server instead of whitespace for our keepalives. Timeout the connection if there's no response in 20 seconds
Sean Egan <seanegan@pidgin.im>
parents: 21929
diff changeset
415
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
416 void jabber_keepalive(PurpleConnection *gc)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
417 {
22096
0d28b254d322 Keep track of the keepalive timeout source so it can be removed when the account disconnects. This prevents a possible crash if the timeout fired after the account disconnected.
Evan Schoenberg <evands@pidgin.im>
parents: 22067
diff changeset
418 JabberStream *js = gc->proto_data;
21974
daa6296d122d Send XMPP Pings to the server instead of whitespace for our keepalives. Timeout the connection if there's no response in 20 seconds
Sean Egan <seanegan@pidgin.im>
parents: 21929
diff changeset
419
22587
661321b20a01 Only allow one keepalive_timeout at a time. This prevents us from starting a
Evan Schoenberg <evands@pidgin.im>
parents: 22580
diff changeset
420 if (js->keepalive_timeout == -1) {
661321b20a01 Only allow one keepalive_timeout at a time. This prevents us from starting a
Evan Schoenberg <evands@pidgin.im>
parents: 22580
diff changeset
421 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_GET);
661321b20a01 Only allow one keepalive_timeout at a time. This prevents us from starting a
Evan Schoenberg <evands@pidgin.im>
parents: 22580
diff changeset
422
661321b20a01 Only allow one keepalive_timeout at a time. This prevents us from starting a
Evan Schoenberg <evands@pidgin.im>
parents: 22580
diff changeset
423 xmlnode *ping = xmlnode_new_child(iq->node, "ping");
661321b20a01 Only allow one keepalive_timeout at a time. This prevents us from starting a
Evan Schoenberg <evands@pidgin.im>
parents: 22580
diff changeset
424 xmlnode_set_namespace(ping, "urn:xmpp:ping");
661321b20a01 Only allow one keepalive_timeout at a time. This prevents us from starting a
Evan Schoenberg <evands@pidgin.im>
parents: 22580
diff changeset
425
661321b20a01 Only allow one keepalive_timeout at a time. This prevents us from starting a
Evan Schoenberg <evands@pidgin.im>
parents: 22580
diff changeset
426 js->keepalive_timeout = purple_timeout_add_seconds(120, (GSourceFunc)(jabber_pong_timeout), gc);
661321b20a01 Only allow one keepalive_timeout at a time. This prevents us from starting a
Evan Schoenberg <evands@pidgin.im>
parents: 22580
diff changeset
427 jabber_iq_set_callback(iq, jabber_pong_cb, GINT_TO_POINTER(js->keepalive_timeout));
661321b20a01 Only allow one keepalive_timeout at a time. This prevents us from starting a
Evan Schoenberg <evands@pidgin.im>
parents: 22580
diff changeset
428 jabber_iq_send(iq);
661321b20a01 Only allow one keepalive_timeout at a time. This prevents us from starting a
Evan Schoenberg <evands@pidgin.im>
parents: 22580
diff changeset
429 }
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
430 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
431
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
432 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
433 jabber_recv_cb_ssl(gpointer data, PurpleSslConnection *gsc,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
434 PurpleInputCondition cond)
6764
a3f8025c0631 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
435 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
436 PurpleConnection *gc = data;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
437 JabberStream *js = gc->proto_data;
6764
a3f8025c0631 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
438 int len;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
439 static char buf[4096];
6768
64384a76f515 [gaim-migrate @ 7305]
Nathan Walp <nwalp@pidgin.im>
parents: 6764
diff changeset
440
14030
23144f1dc950 [gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents: 14004
diff changeset
441 /* TODO: It should be possible to make this check unnecessary */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
442 if(!PURPLE_CONNECTION_IS_VALID(gc)) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
443 purple_ssl_close(gsc);
6768
64384a76f515 [gaim-migrate @ 7305]
Nathan Walp <nwalp@pidgin.im>
parents: 6764
diff changeset
444 return;
64384a76f515 [gaim-migrate @ 7305]
Nathan Walp <nwalp@pidgin.im>
parents: 6764
diff changeset
445 }
64384a76f515 [gaim-migrate @ 7305]
Nathan Walp <nwalp@pidgin.im>
parents: 6764
diff changeset
446
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
447 while((len = purple_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) {
22277
7c386db62c81 Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents: 22225
diff changeset
448 gc->last_received = time(NULL);
6764
a3f8025c0631 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
449 buf[len] = '\0';
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
450 purple_debug(PURPLE_DEBUG_INFO, "jabber", "Recv (ssl)(%d): %s\n", len, buf);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
451 jabber_parser_process(js, buf, len);
14062
dd8d7eb8fa76 [gaim-migrate @ 16585]
Ethan Blanton <elb@pidgin.im>
parents: 14043
diff changeset
452 if(js->reinit)
dd8d7eb8fa76 [gaim-migrate @ 16585]
Ethan Blanton <elb@pidgin.im>
parents: 14043
diff changeset
453 jabber_stream_init(js);
13280
8d45d67480e6 [gaim-migrate @ 15645]
Greg Hudson <ghudson@mit.edu>
parents: 13275
diff changeset
454 }
8d45d67480e6 [gaim-migrate @ 15645]
Greg Hudson <ghudson@mit.edu>
parents: 13275
diff changeset
455
8d45d67480e6 [gaim-migrate @ 15645]
Greg Hudson <ghudson@mit.edu>
parents: 13275
diff changeset
456 if(errno == EAGAIN)
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
457 return;
13280
8d45d67480e6 [gaim-migrate @ 15645]
Greg Hudson <ghudson@mit.edu>
parents: 13275
diff changeset
458 else
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
459 purple_connection_error_reason (js->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
460 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
461 _("Read Error"));
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
462 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
463
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
464 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
465 jabber_recv_cb(gpointer data, gint source, PurpleInputCondition condition)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
466 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
467 PurpleConnection *gc = data;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
468 JabberStream *js = gc->proto_data;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
469 int len;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
470 static char buf[4096];
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
471
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
472 if(!PURPLE_CONNECTION_IS_VALID(gc))
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
473 return;
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
474
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
475 if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) {
22277
7c386db62c81 Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents: 22225
diff changeset
476 gc->last_received = time(NULL);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
477 #ifdef HAVE_CYRUS_SASL
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
478 if (js->sasl_maxbuf>0) {
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
479 const char *out;
14697
518c0fae208e [gaim-migrate @ 17381]
Daniel Atallah <datallah@pidgin.im>
parents: 14668
diff changeset
480 unsigned int olen;
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
481 sasl_decode(js->sasl, buf, len, &out, &olen);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
482 if (olen>0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
483 purple_debug(PURPLE_DEBUG_INFO, "jabber", "RecvSASL (%u): %s\n", olen, out);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
484 jabber_parser_process(js,out,olen);
14700
98dc3d9a69e3 [gaim-migrate @ 17384]
Sean Egan <seanegan@pidgin.im>
parents: 14697
diff changeset
485 if(js->reinit)
98dc3d9a69e3 [gaim-migrate @ 17384]
Sean Egan <seanegan@pidgin.im>
parents: 14697
diff changeset
486 jabber_stream_init(js);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
487 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
488 return;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
489 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
490 #endif
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
491 buf[len] = '\0';
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
492 purple_debug(PURPLE_DEBUG_INFO, "jabber", "Recv (%d): %s\n", len, buf);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
493 jabber_parser_process(js, buf, len);
14700
98dc3d9a69e3 [gaim-migrate @ 17384]
Sean Egan <seanegan@pidgin.im>
parents: 14697
diff changeset
494 if(js->reinit)
98dc3d9a69e3 [gaim-migrate @ 17384]
Sean Egan <seanegan@pidgin.im>
parents: 14697
diff changeset
495 jabber_stream_init(js);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
496 } else if(errno == EAGAIN) {
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
497 return;
7177
36ad58ff37d6 [gaim-migrate @ 7745]
Nathan Walp <nwalp@pidgin.im>
parents: 7147
diff changeset
498 } else {
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
499 purple_connection_error_reason (js->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
500 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
501 _("Read Error"));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
502 }
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
503 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
504
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
505 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
506 jabber_login_callback_ssl(gpointer data, PurpleSslConnection *gsc,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
507 PurpleInputCondition cond)
6764
a3f8025c0631 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
508 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
509 PurpleConnection *gc = data;
15023
c38f385a128a [gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
510 JabberStream *js;
c38f385a128a [gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
511
c38f385a128a [gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
512 /* TODO: It should be possible to make this check unnecessary */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
513 if(!PURPLE_CONNECTION_IS_VALID(gc)) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
514 purple_ssl_close(gsc);
15023
c38f385a128a [gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
515 return;
19993
867bd1dfe680 Clear the password when we get an auth. error and we're not saving passwords so that you don't need to go into the account settings to reset it. Fix #3083.
Daniel Atallah <datallah@pidgin.im>
parents: 19920
diff changeset
516 }
15023
c38f385a128a [gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
517
c38f385a128a [gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
518 js = gc->proto_data;
6764
a3f8025c0631 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
519
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
520 if(js->state == JABBER_STREAM_CONNECTING)
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
521 jabber_send_raw(js, "<?xml version='1.0' ?>", -1);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
522 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
523 purple_ssl_input_add(gsc, jabber_recv_cb_ssl, gc);
17813
c5cc8ebf62c0 Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents: 17810
diff changeset
524
c5cc8ebf62c0 Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents: 17810
diff changeset
525 /* Tell the app that we're doing encryption */
c5cc8ebf62c0 Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents: 17810
diff changeset
526 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING_ENCRYPTION);
6764
a3f8025c0631 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
527 }
a3f8025c0631 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
528
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
529
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
530 static void
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
531 jabber_login_callback(gpointer data, gint source, const gchar *error)
6764
a3f8025c0631 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
532 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
533 PurpleConnection *gc = data;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
534 JabberStream *js = gc->proto_data;
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
535
8783
7be6da5bc279 [gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents: 8778
diff changeset
536 if (source < 0) {
17643
870d08f93965 Better error message for when a Jabber connection fails
Mark Doliner <markdoliner@pidgin.im>
parents: 17052
diff changeset
537 gchar *tmp;
870d08f93965 Better error message for when a Jabber connection fails
Mark Doliner <markdoliner@pidgin.im>
parents: 17052
diff changeset
538 tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"),
870d08f93965 Better error message for when a Jabber connection fails
Mark Doliner <markdoliner@pidgin.im>
parents: 17052
diff changeset
539 error);
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
540 purple_connection_error_reason (gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
541 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
17643
870d08f93965 Better error message for when a Jabber connection fails
Mark Doliner <markdoliner@pidgin.im>
parents: 17052
diff changeset
542 g_free(tmp);
8783
7be6da5bc279 [gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents: 8778
diff changeset
543 return;
7be6da5bc279 [gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents: 8778
diff changeset
544 }
7be6da5bc279 [gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents: 8778
diff changeset
545
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
546 js->fd = source;
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
547
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
548 if(js->state == JABBER_STREAM_CONNECTING)
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
549 jabber_send_raw(js, "<?xml version='1.0' ?>", -1);
2300
06a3c10f4918 [gaim-migrate @ 2310]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 2289
diff changeset
550
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
551 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
552 gc->inpa = purple_input_add(js->fd, PURPLE_INPUT_READ, jabber_recv_cb, gc);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
553 }
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
554
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
555 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
556 jabber_ssl_connect_failure(PurpleSslConnection *gsc, PurpleSslErrorType error,
7426
c499c64731a1 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
557 gpointer data)
c499c64731a1 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
558 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
559 PurpleConnection *gc = data;
15668
c8831ae23d4c If jabber_ssl_connect_failure() is called because a connect attempt fails, but the user has already canceled the attempt by signing the account offline, this would previously crash. It now does not.
Evan Schoenberg <evands@pidgin.im>
parents: 15558
diff changeset
560 JabberStream *js;
7426
c499c64731a1 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
561
15668
c8831ae23d4c If jabber_ssl_connect_failure() is called because a connect attempt fails, but the user has already canceled the attempt by signing the account offline, this would previously crash. It now does not.
Evan Schoenberg <evands@pidgin.im>
parents: 15558
diff changeset
562 /* If the connection is already disconnected, we don't need to do anything else */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
563 if(!PURPLE_CONNECTION_IS_VALID(gc))
15668
c8831ae23d4c If jabber_ssl_connect_failure() is called because a connect attempt fails, but the user has already canceled the attempt by signing the account offline, this would previously crash. It now does not.
Evan Schoenberg <evands@pidgin.im>
parents: 15558
diff changeset
564 return;
c8831ae23d4c If jabber_ssl_connect_failure() is called because a connect attempt fails, but the user has already canceled the attempt by signing the account offline, this would previously crash. It now does not.
Evan Schoenberg <evands@pidgin.im>
parents: 15558
diff changeset
565
c8831ae23d4c If jabber_ssl_connect_failure() is called because a connect attempt fails, but the user has already canceled the attempt by signing the account offline, this would previously crash. It now does not.
Evan Schoenberg <evands@pidgin.im>
parents: 15558
diff changeset
566 js = gc->proto_data;
14312
6ce4512aa9a8 [gaim-migrate @ 16932]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
567 js->gsc = NULL;
6ce4512aa9a8 [gaim-migrate @ 16932]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
568
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
569 purple_connection_ssl_error (gc, error);
7426
c499c64731a1 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
570 }
c499c64731a1 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
571
7427
9a301e6b3902 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
572 static void tls_init(JabberStream *js)
9a301e6b3902 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
573 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
574 purple_input_remove(js->gc->inpa);
7427
9a301e6b3902 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
575 js->gc->inpa = 0;
18449
2d2df64f4303 applied changes from f9186fabb483b56a9d7e8fb7241b2520e9930413
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18235
diff changeset
576 js->gsc = purple_ssl_connect_with_host_fd(js->gc->account, js->fd,
22155
7c2034388bdb Now checking the hostname supplied by the user, or the host-part of the JID when no host name is given against the CN of the domain. This makes libpurple comply to the RFC. Fixes http://trac.adiumx.com/ticket/8787
Andreas Monitzer <am@adiumx.com>
parents: 22133
diff changeset
577 jabber_login_callback_ssl, jabber_ssl_connect_failure, js->certificate_CN, js->gc);
7427
9a301e6b3902 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
578 }
9a301e6b3902 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
579
22468
c0f99a22627f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22277
diff changeset
580 static void jabber_login_connect(JabberStream *js, const char *domain, const char *host, int port)
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
581 {
22468
c0f99a22627f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22277
diff changeset
582 /* host should be used in preference to domain to
c0f99a22627f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22277
diff changeset
583 * allow SASL authentication to work with FQDN of the server,
c0f99a22627f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22277
diff changeset
584 * but we use domain as fallback for when users enter IP address
c0f99a22627f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22277
diff changeset
585 * in connect server */
c0f99a22627f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22277
diff changeset
586 if (purple_ip_address_is_valid(host))
c0f99a22627f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22277
diff changeset
587 js->serverFQDN = g_strdup(domain);
c0f99a22627f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22277
diff changeset
588 else
c0f99a22627f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22277
diff changeset
589 js->serverFQDN = g_strdup(host);
15800
2d0ec4fe2681 pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents: 15783
diff changeset
590
17052
b064b8e0244b fix #699
Nathan Walp <nwalp@pidgin.im>
parents: 17008
diff changeset
591 if (purple_proxy_connect(js->gc, js->gc->account, host,
14899
c65f0b4fb351 [gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents: 14700
diff changeset
592 port, jabber_login_callback, js->gc) == NULL)
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
593 purple_connection_error_reason (js->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
594 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
595 _("Unable to create socket"));
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
596 }
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
597
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
598 static void srv_resolved_cb(PurpleSrvResponse *resp, int results, gpointer data)
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
599 {
13956
c3001d55c88f [gaim-migrate @ 16377]
Mark Doliner <markdoliner@pidgin.im>
parents: 13808
diff changeset
600 JabberStream *js;
c3001d55c88f [gaim-migrate @ 16377]
Mark Doliner <markdoliner@pidgin.im>
parents: 13808
diff changeset
601
14370
12ef3d4096ee [gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents: 14358
diff changeset
602 js = data;
12ef3d4096ee [gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents: 14358
diff changeset
603 js->srv_query_data = NULL;
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
604
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
605 if(results) {
17052
b064b8e0244b fix #699
Nathan Walp <nwalp@pidgin.im>
parents: 17008
diff changeset
606 jabber_login_connect(js, resp->hostname, resp->hostname, resp->port);
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
607 g_free(resp);
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
608 } else {
17052
b064b8e0244b fix #699
Nathan Walp <nwalp@pidgin.im>
parents: 17008
diff changeset
609 jabber_login_connect(js, js->user->domain, js->user->domain,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
610 purple_account_get_int(js->gc->account, "port", 5222));
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
611 }
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
612 }
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
613
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
614 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
615 jabber_login(PurpleAccount *account)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
616 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
617 PurpleConnection *gc = purple_account_get_connection(account);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
618 const char *connect_server = purple_account_get_string(account,
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
619 "connect_server", "");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
620 JabberStream *js;
10289
18f2c2afebaf [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
621 JabberBuddy *my_jb = NULL;
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
622
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
623 gc->flags |= PURPLE_CONNECTION_HTML;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
624 js = gc->proto_data = g_new0(JabberStream, 1);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
625 js->gc = gc;
8013
03f5b77cdaf0 [gaim-migrate @ 8693]
Olivier Blin <blino@users.sourceforge.net>
parents: 8011
diff changeset
626 js->fd = -1;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
627 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal,
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
628 g_free, g_free);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
629 js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal,
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
630 g_free, g_free);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
631 js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal,
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7095
diff changeset
632 g_free, (GDestroyNotify)jabber_buddy_free);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
633 js->chats = g_hash_table_new_full(g_str_hash, g_str_equal,
8396
8681756b4769 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8362
diff changeset
634 g_free, (GDestroyNotify)jabber_chat_free);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
635 js->user = jabber_id_new(purple_account_get_username(account));
7322
de15a9314c04 [gaim-migrate @ 7908]
Nathan Walp <nwalp@pidgin.im>
parents: 7310
diff changeset
636 js->next_id = g_random_int();
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
637 js->write_buffer = purple_circ_buffer_new(512);
22111
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22101
diff changeset
638 js->old_length = 0;
22096
0d28b254d322 Keep track of the keepalive timeout source so it can be removed when the account disconnects. This prevents a possible crash if the timeout fired after the account disconnected.
Evan Schoenberg <evands@pidgin.im>
parents: 22067
diff changeset
639 js->keepalive_timeout = -1;
22155
7c2034388bdb Now checking the hostname supplied by the user, or the host-part of the JID when no host name is given against the CN of the domain. This makes libpurple comply to the RFC. Fixes http://trac.adiumx.com/ticket/8787
Andreas Monitzer <am@adiumx.com>
parents: 22133
diff changeset
640 js->certificate_CN = g_strdup(connect_server[0] ? connect_server : js->user->domain);
5613
df1602bc1e05 [gaim-migrate @ 6019]
Nathan Walp <nwalp@pidgin.im>
parents: 5599
diff changeset
641
23704
9b88c9b23aed Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents: 23701
diff changeset
642 #ifdef USE_VV
23698
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
643 js->sessions = NULL;
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
644 #endif
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
645
7310
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
646 if(!js->user) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
647 purple_connection_error_reason (gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
648 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
649 _("Invalid XMPP ID"));
7310
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
650 return;
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
651 }
17008
502623177086 Handle people forgetting to enter a domain. Also, change 'server,' in the account options to 'domain,' which is its proper name, and hopefully less confusion
Sean Egan <seanegan@pidgin.im>
parents: 17007
diff changeset
652
502623177086 Handle people forgetting to enter a domain. Also, change 'server,' in the account options to 'domain,' which is its proper name, and hopefully less confusion
Sean Egan <seanegan@pidgin.im>
parents: 17007
diff changeset
653 if (!js->user->domain || *(js->user->domain) == '\0') {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
654 purple_connection_error_reason (gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
655 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
656 _("Invalid XMPP ID. Domain must be set."));
17008
502623177086 Handle people forgetting to enter a domain. Also, change 'server,' in the account options to 'domain,' which is its proper name, and hopefully less confusion
Sean Egan <seanegan@pidgin.im>
parents: 17007
diff changeset
657 return;
502623177086 Handle people forgetting to enter a domain. Also, change 'server,' in the account options to 'domain,' which is its proper name, and hopefully less confusion
Sean Egan <seanegan@pidgin.im>
parents: 17007
diff changeset
658 }
502623177086 Handle people forgetting to enter a domain. Also, change 'server,' in the account options to 'domain,' which is its proper name, and hopefully less confusion
Sean Egan <seanegan@pidgin.im>
parents: 17007
diff changeset
659
7147
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
660 if(!js->user->resource) {
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
661 char *me;
11939
995c54252658 [gaim-migrate @ 14230]
Etan Reisner <deryni@pidgin.im>
parents: 11837
diff changeset
662 js->user->resource = g_strdup("Home");
7147
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
663 if(!js->user->node) {
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
664 js->user->node = js->user->domain;
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
665 js->user->domain = g_strdup("jabber.org");
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
666 }
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
667 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain,
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
668 js->user->resource);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
669 purple_account_set_username(account, me);
7147
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
670 g_free(me);
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7124
diff changeset
671 }
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7124
diff changeset
672
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
673 if((my_jb = jabber_buddy_find(js, purple_account_get_username(account), TRUE)))
10289
18f2c2afebaf [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
674 my_jb->subscription |= JABBER_SUB_BOTH;
18f2c2afebaf [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
675
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
676 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING);
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
677
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
678 /* if they've got old-ssl mode going, we probably want to ignore SRV lookups */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
679 if(purple_account_get_bool(js->gc->account, "old_ssl", FALSE)) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
680 if(purple_ssl_is_supported()) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
681 js->gsc = purple_ssl_connect(js->gc->account,
22155
7c2034388bdb Now checking the hostname supplied by the user, or the host-part of the JID when no host name is given against the CN of the domain. This makes libpurple comply to the RFC. Fixes http://trac.adiumx.com/ticket/8787
Andreas Monitzer <am@adiumx.com>
parents: 22133
diff changeset
682 js->certificate_CN,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
683 purple_account_get_int(account, "port", 5223), jabber_login_callback_ssl,
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
684 jabber_ssl_connect_failure, js->gc);
7630
23e09fd7cbeb [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
685 } else {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
686 purple_connection_error_reason (js->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
687 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
688 _("SSL support unavailable"));
7630
23e09fd7cbeb [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
689 }
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
690 }
3770
5d476318f306 [gaim-migrate @ 3909]
Sean Egan <seanegan@pidgin.im>
parents: 3769
diff changeset
691
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
692 /* no old-ssl, so if they've specified a connect server, we'll use that, otherwise we'll
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
693 * invoke the magic of SRV lookups, to figure out host and port */
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
694 if(!js->gsc) {
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
695 if(connect_server[0]) {
17052
b064b8e0244b fix #699
Nathan Walp <nwalp@pidgin.im>
parents: 17008
diff changeset
696 jabber_login_connect(js, js->user->domain, connect_server, purple_account_get_int(account, "port", 5222));
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
697 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
698 js->srv_query_data = purple_srv_resolve("xmpp-client",
14370
12ef3d4096ee [gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents: 14358
diff changeset
699 "tcp", js->user->domain, srv_resolved_cb, js);
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
700 }
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
701 }
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
702 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
703
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
704
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
705 static gboolean
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
706 conn_close_cb(gpointer data)
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
707 {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
708 JabberStream *js = data;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
709 PurpleAccount *account = purple_connection_get_account(js->gc);
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10504
diff changeset
710
17810
c8d4297080cb Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <am@adiumx.com>
parents: 17806
diff changeset
711 jabber_parser_free(js);
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10504
diff changeset
712
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
713 purple_account_disconnect(account);
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10504
diff changeset
714
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
715 return FALSE;
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
716 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
717
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
718 static void
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
719 jabber_connection_schedule_close(JabberStream *js)
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
720 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
721 purple_timeout_add(0, conn_close_cb, js);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
722 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
723
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
724 static void
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
725 jabber_registration_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
726 {
17814
c47c22006b0d Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents: 17813
diff changeset
727 PurpleAccount *account = purple_connection_get_account(js->gc);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
728 const char *type = xmlnode_get_attrib(packet, "type");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
729 char *buf;
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
730 char *to = data;
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
731
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
732 if(!strcmp(type, "result")) {
17814
c47c22006b0d Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents: 17813
diff changeset
733 if(js->registration) {
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
734 buf = g_strdup_printf(_("Registration of %s@%s successful"),
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
735 js->user->node, js->user->domain);
17815
232d57a6b6df Simplified registration callback per request of Sean.
Andreas Monitzer <am@adiumx.com>
parents: 17814
diff changeset
736 if(account->registration_cb)
232d57a6b6df Simplified registration callback per request of Sean.
Andreas Monitzer <am@adiumx.com>
parents: 17814
diff changeset
737 (account->registration_cb)(account, TRUE, account->registration_cb_user_data);
17814
c47c22006b0d Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents: 17813
diff changeset
738 }
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
739 else
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
740 buf = g_strdup_printf(_("Registration to %s successful"),
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
741 to);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
742 purple_notify_info(NULL, _("Registration Successful"),
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
743 _("Registration Successful"), buf);
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
744 g_free(buf);
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
745 } else {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
746 char *msg = jabber_parse_error(js, packet, NULL);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
747
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
748 if(!msg)
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
749 msg = g_strdup(_("Unknown Error"));
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
750
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
751 purple_notify_error(NULL, _("Registration Failed"),
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
752 _("Registration Failed"), msg);
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
753 g_free(msg);
17815
232d57a6b6df Simplified registration callback per request of Sean.
Andreas Monitzer <am@adiumx.com>
parents: 17814
diff changeset
754 if(account->registration_cb)
232d57a6b6df Simplified registration callback per request of Sean.
Andreas Monitzer <am@adiumx.com>
parents: 17814
diff changeset
755 (account->registration_cb)(account, FALSE, account->registration_cb_user_data);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
756 }
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
757 g_free(to);
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
758 if(js->registration)
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
759 jabber_connection_schedule_close(js);
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
760 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
761
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
762 static void
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
763 jabber_unregistration_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
764 {
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
765 const char *type = xmlnode_get_attrib(packet, "type");
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
766 char *buf;
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
767 char *to = data;
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
768
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
769 if(!strcmp(type, "result")) {
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
770 buf = g_strdup_printf(_("Registration from %s successfully removed"),
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
771 to);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
772 purple_notify_info(NULL, _("Unregistration Successful"),
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
773 _("Unregistration Successful"), buf);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
774 g_free(buf);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
775 } else {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
776 char *msg = jabber_parse_error(js, packet, NULL);
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
777
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
778 if(!msg)
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
779 msg = g_strdup(_("Unknown Error"));
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
780
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
781 purple_notify_error(NULL, _("Unregistration Failed"),
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
782 _("Unregistration Failed"), msg);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
783 g_free(msg);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
784 }
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
785 g_free(to);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
786 }
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
787
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
788 typedef struct _JabberRegisterCBData {
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
789 JabberStream *js;
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
790 char *who;
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
791 } JabberRegisterCBData;
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
792
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
793 static void
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
794 jabber_register_cb(JabberRegisterCBData *cbdata, PurpleRequestFields *fields)
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
795 {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
796 GList *groups, *flds;
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
797 xmlnode *query, *y;
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
798 JabberIq *iq;
7264
bdb42afa3565 [gaim-migrate @ 7841]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
799 char *username;
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
800
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
801 iq = jabber_iq_new_query(cbdata->js, JABBER_IQ_SET, "jabber:iq:register");
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
802 query = xmlnode_get_child(iq->node, "query");
21668
3698b848759b The Jabber registration process depends upon having a non-NULL cbdata->who,
Evan Schoenberg <evands@pidgin.im>
parents: 21667
diff changeset
803 xmlnode_set_attrib(iq->node, "to", cbdata->who);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
804
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
805 for(groups = purple_request_fields_get_groups(fields); groups;
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
806 groups = groups->next) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
807 for(flds = purple_request_field_group_get_fields(groups->data);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
808 flds; flds = flds->next) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
809 PurpleRequestField *field = flds->data;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
810 const char *id = purple_request_field_get_id(field);
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
811 if(!strcmp(id,"unregister")) {
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
812 gboolean value = purple_request_field_bool_get_value(field);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
813 if(value) {
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
814 /* unregister from service. this doesn't include any of the fields, so remove them from the stanza by recreating it
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
815 (there's no "remove child" function for xmlnode) */
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
816 jabber_iq_free(iq);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
817 iq = jabber_iq_new_query(cbdata->js, JABBER_IQ_SET, "jabber:iq:register");
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
818 query = xmlnode_get_child(iq->node, "query");
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
819 xmlnode_set_attrib(iq->node,"to",cbdata->who);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
820 xmlnode_new_child(query, "remove");
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
821
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
822 jabber_iq_set_callback(iq, jabber_unregistration_result_cb, cbdata->who);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
823
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
824 jabber_iq_send(iq);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
825 g_free(cbdata);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
826 return;
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
827 }
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
828 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
829 const char *value = purple_request_field_string_get_value(field);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
830
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
831 if(!strcmp(id, "username")) {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
832 y = xmlnode_new_child(query, "username");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
833 } else if(!strcmp(id, "password")) {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
834 y = xmlnode_new_child(query, "password");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
835 } else if(!strcmp(id, "name")) {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
836 y = xmlnode_new_child(query, "name");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
837 } else if(!strcmp(id, "email")) {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
838 y = xmlnode_new_child(query, "email");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
839 } else if(!strcmp(id, "nick")) {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
840 y = xmlnode_new_child(query, "nick");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
841 } else if(!strcmp(id, "first")) {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
842 y = xmlnode_new_child(query, "first");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
843 } else if(!strcmp(id, "last")) {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
844 y = xmlnode_new_child(query, "last");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
845 } else if(!strcmp(id, "address")) {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
846 y = xmlnode_new_child(query, "address");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
847 } else if(!strcmp(id, "city")) {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
848 y = xmlnode_new_child(query, "city");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
849 } else if(!strcmp(id, "state")) {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
850 y = xmlnode_new_child(query, "state");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
851 } else if(!strcmp(id, "zip")) {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
852 y = xmlnode_new_child(query, "zip");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
853 } else if(!strcmp(id, "phone")) {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
854 y = xmlnode_new_child(query, "phone");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
855 } else if(!strcmp(id, "url")) {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
856 y = xmlnode_new_child(query, "url");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
857 } else if(!strcmp(id, "date")) {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
858 y = xmlnode_new_child(query, "date");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
859 } else {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
860 continue;
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
861 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
862 xmlnode_insert_data(y, value, -1);
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
863 if(cbdata->js->registration && !strcmp(id, "username")) {
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
864 if(cbdata->js->user->node)
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
865 g_free(cbdata->js->user->node);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
866 cbdata->js->user->node = g_strdup(value);
7264
bdb42afa3565 [gaim-migrate @ 7841]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
867 }
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
868 if(cbdata->js->registration && !strcmp(id, "password"))
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
869 purple_account_set_password(cbdata->js->gc->account, value);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
870 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
871 }
19897
8b5abbdebc87 merge of 'b0586b3697e8044ccd62a369b0c0f9125b2ef732'
Daniel Atallah <datallah@pidgin.im>
parents: 19895 19859
diff changeset
872 }
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
873
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
874 if(cbdata->js->registration) {
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
875 username = g_strdup_printf("%s@%s/%s", cbdata->js->user->node, cbdata->js->user->domain,
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
876 cbdata->js->user->resource);
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
877 purple_account_set_username(cbdata->js->gc->account, username);
21668
3698b848759b The Jabber registration process depends upon having a non-NULL cbdata->who,
Evan Schoenberg <evands@pidgin.im>
parents: 21667
diff changeset
878 g_free(username);
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
879 }
7264
bdb42afa3565 [gaim-migrate @ 7841]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
880
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
881 jabber_iq_set_callback(iq, jabber_registration_result_cb, cbdata->who);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
882
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
883 jabber_iq_send(iq);
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
884 g_free(cbdata);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
885 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
886
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
887 static void
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
888 jabber_register_cancel_cb(JabberRegisterCBData *cbdata, PurpleRequestFields *fields)
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
889 {
17814
c47c22006b0d Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents: 17813
diff changeset
890 PurpleAccount *account = purple_connection_get_account(cbdata->js->gc);
19894
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 19389
diff changeset
891 if(account && cbdata->js->registration) {
17814
c47c22006b0d Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents: 17813
diff changeset
892 if(account->registration_cb)
17815
232d57a6b6df Simplified registration callback per request of Sean.
Andreas Monitzer <am@adiumx.com>
parents: 17814
diff changeset
893 (account->registration_cb)(account, FALSE, account->registration_cb_user_data);
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
894 jabber_connection_schedule_close(cbdata->js);
20320
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20316
diff changeset
895 }
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
896 g_free(cbdata->who);
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
897 g_free(cbdata);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
898 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
899
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
900 static void jabber_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data)
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
901 {
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
902 xmlnode *query;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
903 JabberIq *iq;
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
904 char *to = data;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
905
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
906 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register");
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
907 query = xmlnode_get_child(iq->node, "query");
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
908 xmlnode_set_attrib(iq->node,"to",to);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
909
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
910 xmlnode_insert_child(query, result);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
911
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
912 jabber_iq_set_callback(iq, jabber_registration_result_cb, to);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
913 jabber_iq_send(iq);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
914 }
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
915
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
916 void jabber_register_parse(JabberStream *js, xmlnode *packet)
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
917 {
17814
c47c22006b0d Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents: 17813
diff changeset
918 PurpleAccount *account = purple_connection_get_account(js->gc);
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14324
diff changeset
919 const char *type;
21668
3698b848759b The Jabber registration process depends upon having a non-NULL cbdata->who,
Evan Schoenberg <evands@pidgin.im>
parents: 21667
diff changeset
920 const char *from;
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
921 PurpleRequestFields *fields;
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
922 PurpleRequestFieldGroup *group;
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
923 PurpleRequestField *field;
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
924 xmlnode *query, *x, *y;
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
925 char *instructions;
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
926 JabberRegisterCBData *cbdata;
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
927 gboolean registered = FALSE;
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
928
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14324
diff changeset
929 if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result"))
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14324
diff changeset
930 return;
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14324
diff changeset
931
21668
3698b848759b The Jabber registration process depends upon having a non-NULL cbdata->who,
Evan Schoenberg <evands@pidgin.im>
parents: 21667
diff changeset
932 from = xmlnode_get_attrib(packet, "from");
3698b848759b The Jabber registration process depends upon having a non-NULL cbdata->who,
Evan Schoenberg <evands@pidgin.im>
parents: 21667
diff changeset
933 if (!from)
3698b848759b The Jabber registration process depends upon having a non-NULL cbdata->who,
Evan Schoenberg <evands@pidgin.im>
parents: 21667
diff changeset
934 from = js->serverFQDN;
3698b848759b The Jabber registration process depends upon having a non-NULL cbdata->who,
Evan Schoenberg <evands@pidgin.im>
parents: 21667
diff changeset
935 g_return_if_fail(from != NULL);
3698b848759b The Jabber registration process depends upon having a non-NULL cbdata->who,
Evan Schoenberg <evands@pidgin.im>
parents: 21667
diff changeset
936
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
937 if(js->registration) {
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
938 /* get rid of the login thingy */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
939 purple_connection_set_state(js->gc, PURPLE_CONNECTED);
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
940 }
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
941
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
942 query = xmlnode_get_child(packet, "query");
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
943
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
944 if(xmlnode_get_child(query, "registered")) {
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
945 registered = TRUE;
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
946
17814
c47c22006b0d Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents: 17813
diff changeset
947 if(js->registration) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
948 purple_notify_error(NULL, _("Already Registered"),
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
949 _("Already Registered"), NULL);
17814
c47c22006b0d Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents: 17813
diff changeset
950 if(account->registration_cb)
17815
232d57a6b6df Simplified registration callback per request of Sean.
Andreas Monitzer <am@adiumx.com>
parents: 17814
diff changeset
951 (account->registration_cb)(account, FALSE, account->registration_cb_user_data);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
952 jabber_connection_schedule_close(js);
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
953 return;
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
954 }
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
955 }
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
956
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
957 if((x = xmlnode_get_child_with_namespace(packet, "x", "jabber:x:data"))) {
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
958 jabber_x_data_request(js, x, jabber_register_x_data_cb, g_strdup(from));
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
959 return;
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
960
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
961 } else if((x = xmlnode_get_child_with_namespace(packet, "x", "jabber:x:oob"))) {
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
962 xmlnode *url;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
963
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
964 if((url = xmlnode_get_child(x, "url"))) {
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
965 char *href;
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
966 if((href = xmlnode_get_data(url))) {
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
967 purple_notify_uri(NULL, href);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
968 g_free(href);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
969
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
970 if(js->registration) {
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
971 js->gc->wants_to_die = TRUE;
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
972 if(account->registration_cb) /* succeeded, but we have no login info */
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
973 (account->registration_cb)(account, TRUE, account->registration_cb_user_data);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
974 jabber_connection_schedule_close(js);
8398
dccdcef78405 [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
975 }
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
976 return;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
977 }
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
978 }
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
979 }
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
980
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
981 /* as a last resort, use the old jabber:iq:register syntax */
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
982
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
983 fields = purple_request_fields_new();
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
984 group = purple_request_field_group_new(NULL);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
985 purple_request_fields_add_group(fields, group);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
986
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
987 if(js->registration)
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
988 field = purple_request_field_string_new("username", _("Username"), js->user->node, FALSE);
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
989 else
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
990 field = purple_request_field_string_new("username", _("Username"), NULL, FALSE);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
991
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
992 purple_request_field_group_add_field(group, field);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
993
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
994 if(js->registration)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
995 field = purple_request_field_string_new("password", _("Password"),
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
996 purple_connection_get_password(js->gc), FALSE);
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
997 else
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
998 field = purple_request_field_string_new("password", _("Password"), NULL, FALSE);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
999
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1000 purple_request_field_string_set_masked(field, TRUE);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1001 purple_request_field_group_add_field(group, field);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1002
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1003 if(xmlnode_get_child(query, "name")) {
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1004 if(js->registration)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1005 field = purple_request_field_string_new("name", _("Name"),
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1006 purple_account_get_alias(js->gc->account), FALSE);
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1007 else
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1008 field = purple_request_field_string_new("name", _("Name"), NULL, FALSE);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1009 purple_request_field_group_add_field(group, field);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1010 }
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1011 if(xmlnode_get_child(query, "email")) {
23325
a374a26fe217 Use "email" and "Email" consistently. This is potentially controversial,
Richard Laager <rlaager@pidgin.im>
parents: 23097
diff changeset
1012 field = purple_request_field_string_new("email", _("Email"), NULL, FALSE);
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1013 purple_request_field_group_add_field(group, field);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1014 }
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1015 if(xmlnode_get_child(query, "nick")) {
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1016 field = purple_request_field_string_new("nick", _("Nickname"), NULL, FALSE);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1017 purple_request_field_group_add_field(group, field);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1018 }
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1019 if(xmlnode_get_child(query, "first")) {
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1020 field = purple_request_field_string_new("first", _("First name"), NULL, FALSE);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1021 purple_request_field_group_add_field(group, field);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1022 }
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1023 if(xmlnode_get_child(query, "last")) {
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1024 field = purple_request_field_string_new("last", _("Last name"), NULL, FALSE);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1025 purple_request_field_group_add_field(group, field);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1026 }
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1027 if(xmlnode_get_child(query, "address")) {
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1028 field = purple_request_field_string_new("address", _("Address"), NULL, FALSE);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1029 purple_request_field_group_add_field(group, field);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1030 }
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1031 if(xmlnode_get_child(query, "city")) {
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1032 field = purple_request_field_string_new("city", _("City"), NULL, FALSE);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1033 purple_request_field_group_add_field(group, field);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1034 }
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1035 if(xmlnode_get_child(query, "state")) {
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1036 field = purple_request_field_string_new("state", _("State"), NULL, FALSE);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1037 purple_request_field_group_add_field(group, field);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1038 }
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1039 if(xmlnode_get_child(query, "zip")) {
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1040 field = purple_request_field_string_new("zip", _("Postal code"), NULL, FALSE);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1041 purple_request_field_group_add_field(group, field);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1042 }
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1043 if(xmlnode_get_child(query, "phone")) {
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1044 field = purple_request_field_string_new("phone", _("Phone"), NULL, FALSE);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1045 purple_request_field_group_add_field(group, field);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1046 }
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1047 if(xmlnode_get_child(query, "url")) {
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1048 field = purple_request_field_string_new("url", _("URL"), NULL, FALSE);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1049 purple_request_field_group_add_field(group, field);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1050 }
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1051 if(xmlnode_get_child(query, "date")) {
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1052 field = purple_request_field_string_new("date", _("Date"), NULL, FALSE);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1053 purple_request_field_group_add_field(group, field);
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1054 }
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1055 if(registered) {
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1056 field = purple_request_field_bool_new("unregister", _("Unregister"), FALSE);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1057 purple_request_field_group_add_field(group, field);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1058 }
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1059
20320
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20316
diff changeset
1060 if((y = xmlnode_get_child(query, "instructions")))
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20316
diff changeset
1061 instructions = xmlnode_get_data(y);
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1062 else if(registered)
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1063 instructions = g_strdup(_("Please fill out the information below "
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1064 "to change your account registration."));
20320
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20316
diff changeset
1065 else
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20316
diff changeset
1066 instructions = g_strdup(_("Please fill out the information below "
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20316
diff changeset
1067 "to register your new account."));
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1068
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1069 cbdata = g_new0(JabberRegisterCBData, 1);
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1070 cbdata->js = js;
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1071 cbdata->who = g_strdup(from);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1072
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1073 if(js->registration)
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
1074 purple_request_fields(js->gc, _("Register New XMPP Account"),
16961
b6955f946f8f s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents: 16847
diff changeset
1075 _("Register New XMPP Account"), instructions, fields,
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1076 _("Register"), G_CALLBACK(jabber_register_cb),
16490
68c22924d66b Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents: 16302
diff changeset
1077 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb),
68c22924d66b Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents: 16302
diff changeset
1078 purple_connection_get_account(js->gc), NULL, NULL,
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
1079 cbdata);
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1080 else {
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1081 char *title = registered?g_strdup_printf(_("Change Account Registration at %s"), from)
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1082 :g_strdup_printf(_("Register New Account at %s"), from);
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
1083 purple_request_fields(js->gc, title,
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1084 title, instructions, fields,
21492
5f6d249bb601 Fixed whitespace and indentation in jabber_register_parse(). I'm seeing crashes while attempting to register, and it was difficult to follow the previous code with inconsistent and misleading indentation.
Evan Schoenberg <evands@pidgin.im>
parents: 21453
diff changeset
1085 (registered ? _("Change Registration") : _("Register")), G_CALLBACK(jabber_register_cb),
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1086 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb),
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1087 purple_connection_get_account(js->gc), NULL, NULL,
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
1088 cbdata);
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1089 g_free(title);
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1090 }
14140
fcb570e0b2db [gaim-migrate @ 16699]
Daniel Atallah <datallah@pidgin.im>
parents: 14115
diff changeset
1091
20320
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20316
diff changeset
1092 g_free(instructions);
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20316
diff changeset
1093 }
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1094
8016
d75a4e86f7c3 [gaim-migrate @ 8696]
Nathan Walp <nwalp@pidgin.im>
parents: 8013
diff changeset
1095 void jabber_register_start(JabberStream *js)
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1096 {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1097 JabberIq *iq;
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1098
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1099 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1100 jabber_iq_send(iq);
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1101 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1102
17806
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1103 void jabber_register_gateway(JabberStream *js, const char *gateway) {
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1104 JabberIq *iq;
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1105
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1106 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register");
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1107 xmlnode_set_attrib(iq->node, "to", gateway);
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1108 jabber_iq_send(iq);
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1109 }
ed4647f0915d Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents: 17803
diff changeset
1110
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
1111 void jabber_register_account(PurpleAccount *account)
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1112 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1113 PurpleConnection *gc = purple_account_get_connection(account);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1114 JabberStream *js;
10289
18f2c2afebaf [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
1115 JabberBuddy *my_jb = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1116 const char *connect_server = purple_account_get_string(account,
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1117 "connect_server", "");
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1118 const char *server;
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1119
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1120 js = gc->proto_data = g_new0(JabberStream, 1);
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1121 js->gc = gc;
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1122 js->registration = TRUE;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
1123 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal,
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
1124 g_free, g_free);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
1125 js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal,
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
1126 g_free, g_free);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1127 js->user = jabber_id_new(purple_account_get_username(account));
7322
de15a9314c04 [gaim-migrate @ 7908]
Nathan Walp <nwalp@pidgin.im>
parents: 7310
diff changeset
1128 js->next_id = g_random_int();
22111
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22101
diff changeset
1129 js->old_length = 0;
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1130
7310
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
1131 if(!js->user) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
1132 purple_connection_error_reason (gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
1133 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
1134 _("Invalid XMPP ID"));
7310
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
1135 return;
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
1136 }
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
1137
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1138 js->write_buffer = purple_circ_buffer_new(512);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
1139
7147
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1140 if(!js->user->resource) {
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1141 char *me;
11939
995c54252658 [gaim-migrate @ 14230]
Etan Reisner <deryni@pidgin.im>
parents: 11837
diff changeset
1142 js->user->resource = g_strdup("Home");
7147
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1143 if(!js->user->node) {
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1144 js->user->node = js->user->domain;
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1145 js->user->domain = g_strdup("jabber.org");
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1146 }
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1147 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain,
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1148 js->user->resource);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1149 purple_account_set_username(account, me);
7147
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1150 g_free(me);
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1151 }
27bf786502a6 [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1152
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1153 if((my_jb = jabber_buddy_find(js, purple_account_get_username(account), TRUE)))
10289
18f2c2afebaf [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
1154 my_jb->subscription |= JABBER_SUB_BOTH;
18f2c2afebaf [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
1155
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1156 server = connect_server[0] ? connect_server : js->user->domain;
22155
7c2034388bdb Now checking the hostname supplied by the user, or the host-part of the JID when no host name is given against the CN of the domain. This makes libpurple comply to the RFC. Fixes http://trac.adiumx.com/ticket/8787
Andreas Monitzer <am@adiumx.com>
parents: 22133
diff changeset
1157 js->certificate_CN = g_strdup(server);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1158
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1159 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING);
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1160
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1161 if(purple_account_get_bool(account, "old_ssl", FALSE)) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1162 if(purple_ssl_is_supported()) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1163 js->gsc = purple_ssl_connect(account, server,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1164 purple_account_get_int(account, "port", 5222),
7630
23e09fd7cbeb [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
1165 jabber_login_callback_ssl, jabber_ssl_connect_failure, gc);
23e09fd7cbeb [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
1166 } else {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
1167 purple_connection_error_reason (gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
1168 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
1169 _("SSL support unavailable"));
7630
23e09fd7cbeb [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
1170 }
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1171 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1172
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1173 if(!js->gsc) {
15069
c440281daadd [gaim-migrate @ 17788]
Ethan Blanton <elb@pidgin.im>
parents: 15023
diff changeset
1174 if (connect_server[0]) {
17052
b064b8e0244b fix #699
Nathan Walp <nwalp@pidgin.im>
parents: 17008
diff changeset
1175 jabber_login_connect(js, js->user->domain, server,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1176 purple_account_get_int(account,
15069
c440281daadd [gaim-migrate @ 17788]
Ethan Blanton <elb@pidgin.im>
parents: 15023
diff changeset
1177 "port", 5222));
c440281daadd [gaim-migrate @ 17788]
Ethan Blanton <elb@pidgin.im>
parents: 15023
diff changeset
1178 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1179 js->srv_query_data = purple_srv_resolve("xmpp-client",
15069
c440281daadd [gaim-migrate @ 17788]
Ethan Blanton <elb@pidgin.im>
parents: 15023
diff changeset
1180 "tcp",
c440281daadd [gaim-migrate @ 17788]
Ethan Blanton <elb@pidgin.im>
parents: 15023
diff changeset
1181 js->user->domain,
c440281daadd [gaim-migrate @ 17788]
Ethan Blanton <elb@pidgin.im>
parents: 15023
diff changeset
1182 srv_resolved_cb,
c440281daadd [gaim-migrate @ 17788]
Ethan Blanton <elb@pidgin.im>
parents: 15023
diff changeset
1183 js);
c440281daadd [gaim-migrate @ 17788]
Ethan Blanton <elb@pidgin.im>
parents: 15023
diff changeset
1184 }
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1185 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1186 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1187
18912
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1188 static void jabber_unregister_account_iq_cb(JabberStream *js, xmlnode *packet, gpointer data) {
18994
310e9d853e2b Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents: 18993
diff changeset
1189 PurpleAccount *account = purple_connection_get_account(js->gc);
18912
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1190 const char *type = xmlnode_get_attrib(packet,"type");
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1191 if(!strcmp(type,"error")) {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
1192 char *msg = jabber_parse_error(js, packet, NULL);
18912
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1193
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1194 purple_notify_error(js->gc, _("Error unregistering account"),
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1195 _("Error unregistering account"), msg);
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1196 g_free(msg);
18994
310e9d853e2b Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents: 18993
diff changeset
1197 if(js->unregistration_cb)
18995
6ba7743720cb Mixed up TRUE and FALSE.
Andreas Monitzer <am@adiumx.com>
parents: 18994
diff changeset
1198 js->unregistration_cb(account, FALSE, js->unregistration_user_data);
18912
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1199 } else if(!strcmp(type,"result")) {
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1200 purple_notify_info(js->gc, _("Account successfully unregistered"),
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1201 _("Account successfully unregistered"), NULL);
18994
310e9d853e2b Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents: 18993
diff changeset
1202 if(js->unregistration_cb)
18995
6ba7743720cb Mixed up TRUE and FALSE.
Andreas Monitzer <am@adiumx.com>
parents: 18994
diff changeset
1203 js->unregistration_cb(account, TRUE, js->unregistration_user_data);
18912
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1204 }
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1205 }
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1206
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1207 static void jabber_unregister_account_cb(JabberStream *js) {
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1208 JabberIq *iq;
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1209 xmlnode *query;
19994
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1210
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1211 g_return_if_fail(js->unregistration);
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1212
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1213 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register");
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1214
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1215 query = xmlnode_get_child_with_namespace(iq->node, "query", "jabber:iq:register");
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1216
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1217 xmlnode_new_child(query, "remove");
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1218 xmlnode_set_attrib(iq->node, "to", js->user->domain);
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1219
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1220 jabber_iq_set_callback(iq, jabber_unregister_account_iq_cb, NULL);
18912
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1221 jabber_iq_send(iq);
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1222 }
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1223
18994
310e9d853e2b Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents: 18993
diff changeset
1224 void jabber_unregister_account(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data) {
18912
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1225 PurpleConnection *gc = purple_account_get_connection(account);
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1226 JabberStream *js;
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1227
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1228 if(gc->state != PURPLE_CONNECTED) {
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1229 if(gc->state != PURPLE_CONNECTING)
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1230 jabber_login(account);
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1231 js = gc->proto_data;
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1232 js->unregistration = TRUE;
18994
310e9d853e2b Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents: 18993
diff changeset
1233 js->unregistration_cb = cb;
310e9d853e2b Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents: 18993
diff changeset
1234 js->unregistration_user_data = user_data;
18912
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1235 return;
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1236 }
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1237
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1238 js = gc->proto_data;
19994
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1239
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1240 if (js->unregistration) {
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1241 purple_debug_error("jabber", "Unregistration in process; ignoring duplicate request.\n");
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1242 return;
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1243 }
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1244
18912
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1245 js->unregistration = TRUE;
18994
310e9d853e2b Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents: 18993
diff changeset
1246 js->unregistration_cb = cb;
310e9d853e2b Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents: 18993
diff changeset
1247 js->unregistration_user_data = user_data;
19994
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1248
18912
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1249 jabber_unregister_account_cb(js);
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1250 }
606597744812 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents: 18755
diff changeset
1251
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
1252 void jabber_close(PurpleConnection *gc)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1253 {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1254 JabberStream *js = gc->proto_data;
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1255
23704
9b88c9b23aed Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents: 23701
diff changeset
1256 #ifdef USE_VV
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1257 /* Close all of the open media sessions on this stream */
23698
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
1258 GList *values = g_hash_table_get_values(js->sessions);
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
1259 GList *iter = values;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1260
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1261 for (; iter; iter = iter->next) {
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1262 JingleSession *session = (JingleSession *)iter->data;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1263 purple_media_hangup(session->media);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1264 }
23698
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
1265
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
1266 g_list_free(values);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1267 #endif
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1268
14004
ce5ce35df50b [gaim-migrate @ 16478]
Sean Egan <seanegan@pidgin.im>
parents: 14003
diff changeset
1269 /* Don't perform any actions on the ssl connection
ce5ce35df50b [gaim-migrate @ 16478]
Sean Egan <seanegan@pidgin.im>
parents: 14003
diff changeset
1270 * if we were forcibly disconnected because it will crash
ce5ce35df50b [gaim-migrate @ 16478]
Sean Egan <seanegan@pidgin.im>
parents: 14003
diff changeset
1271 * on some SSL backends.
13154
1a93fddf2a9a [gaim-migrate @ 15516]
Evan Schoenberg <evands@pidgin.im>
parents: 13051
diff changeset
1272 */
1a93fddf2a9a [gaim-migrate @ 15516]
Evan Schoenberg <evands@pidgin.im>
parents: 13051
diff changeset
1273 if (!gc->disconnect_timeout)
14003
5fab5dad7ab6 [gaim-migrate @ 16477]
Sean Egan <seanegan@pidgin.im>
parents: 13956
diff changeset
1274 jabber_send_raw(js, "</stream:stream>", -1);
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
1275
14370
12ef3d4096ee [gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents: 14358
diff changeset
1276 if (js->srv_query_data)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1277 purple_srv_cancel(js->srv_query_data);
14370
12ef3d4096ee [gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents: 14358
diff changeset
1278
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1279 if(js->gsc) {
13243
5a127fc7db90 [gaim-migrate @ 15608]
Evan Schoenberg <evands@pidgin.im>
parents: 13238
diff changeset
1280 #ifdef HAVE_OPENSSL
5a127fc7db90 [gaim-migrate @ 15608]
Evan Schoenberg <evands@pidgin.im>
parents: 13238
diff changeset
1281 if (!gc->disconnect_timeout)
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 13297
diff changeset
1282 #endif
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1283 purple_ssl_close(js->gsc);
8360
2976b7f18935 [gaim-migrate @ 9084]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1284 } else if (js->fd > 0) {
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1285 if(js->gc->inpa)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1286 purple_input_remove(js->gc->inpa);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1287 close(js->fd);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1288 }
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
1289
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
1290 jabber_buddy_remove_all_pending_buddy_info_requests(js);
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
1291
17810
c8d4297080cb Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <am@adiumx.com>
parents: 17806
diff changeset
1292 jabber_parser_free(js);
c8d4297080cb Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <am@adiumx.com>
parents: 17806
diff changeset
1293
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
1294 if(js->iq_callbacks)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
1295 g_hash_table_destroy(js->iq_callbacks);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
1296 if(js->disco_callbacks)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
1297 g_hash_table_destroy(js->disco_callbacks);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1298 if(js->buddies)
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1299 g_hash_table_destroy(js->buddies);
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1300 if(js->chats)
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1301 g_hash_table_destroy(js->chats);
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1302
8043
86a087e9624c [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8016
diff changeset
1303 while(js->chat_servers) {
86a087e9624c [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8016
diff changeset
1304 g_free(js->chat_servers->data);
86a087e9624c [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8016
diff changeset
1305 js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers);
86a087e9624c [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8016
diff changeset
1306 }
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1307
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
1308 while(js->user_directories) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
1309 g_free(js->user_directories->data);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
1310 js->user_directories = g_list_delete_link(js->user_directories, js->user_directories);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
1311 }
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1312
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1313 while(js->bs_proxies) {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1314 JabberBytestreamsStreamhost *sh = js->bs_proxies->data;
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1315 g_free(sh->jid);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1316 g_free(sh->host);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1317 g_free(sh->zeroconf);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1318 g_free(sh);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1319 js->bs_proxies = g_list_delete_link(js->bs_proxies, js->bs_proxies);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1320 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1321
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1322 g_free(js->stream_id);
7587
57f1a8a3542d [gaim-migrate @ 8205]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
1323 if(js->user)
57f1a8a3542d [gaim-migrate @ 8205]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
1324 jabber_id_free(js->user);
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1325 g_free(js->avatar_hash);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1326
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1327 purple_circ_buffer_destroy(js->write_buffer);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
1328 if(js->writeh)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1329 purple_input_remove(js->writeh);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
1330 #ifdef HAVE_CYRUS_SASL
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
1331 if(js->sasl)
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
1332 sasl_dispose(&js->sasl);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
1333 if(js->sasl_mechs)
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
1334 g_string_free(js->sasl_mechs, TRUE);
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1335 g_free(js->sasl_cb);
18449
2d2df64f4303 applied changes from f9186fabb483b56a9d7e8fb7241b2520e9930413
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18235
diff changeset
1336 #endif
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1337 g_free(js->serverFQDN);
17817
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17815
diff changeset
1338 while(js->commands) {
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17815
diff changeset
1339 JabberAdHocCommands *cmd = js->commands->data;
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17815
diff changeset
1340 g_free(cmd->jid);
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17815
diff changeset
1341 g_free(cmd->node);
17827
33575af6da8b Fixed copy/paste error.
Andreas Monitzer <am@adiumx.com>
parents: 17824
diff changeset
1342 g_free(cmd->name);
17817
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17815
diff changeset
1343 g_free(cmd);
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17815
diff changeset
1344 js->commands = g_list_delete_link(js->commands, js->commands);
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17815
diff changeset
1345 }
15198
08deb9b51708 [gaim-migrate @ 17922]
Sean Egan <seanegan@pidgin.im>
parents: 15185
diff changeset
1346 g_free(js->server_name);
22155
7c2034388bdb Now checking the hostname supplied by the user, or the host-part of the JID when no host name is given against the CN of the domain. This makes libpurple comply to the RFC. Fixes http://trac.adiumx.com/ticket/8787
Andreas Monitzer <am@adiumx.com>
parents: 22133
diff changeset
1347 g_free(js->certificate_CN);
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15205
diff changeset
1348 g_free(js->gmail_last_time);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15205
diff changeset
1349 g_free(js->gmail_last_tid);
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1350 g_free(js->old_msg);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1351 g_free(js->old_avatarhash);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1352 g_free(js->old_artist);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1353 g_free(js->old_title);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1354 g_free(js->old_source);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1355 g_free(js->old_uri);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1356 g_free(js->old_track);
23097
fd61a293d5e1 patch from Andrew Gaul to fix another memleak
Ka-Hing Cheung <khc@pidgin.im>
parents: 22759
diff changeset
1357 g_free(js->expected_rspauth);
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21668
diff changeset
1358
22096
0d28b254d322 Keep track of the keepalive timeout source so it can be removed when the account disconnects. This prevents a possible crash if the timeout fired after the account disconnected.
Evan Schoenberg <evands@pidgin.im>
parents: 22067
diff changeset
1359 if (js->keepalive_timeout != -1)
0d28b254d322 Keep track of the keepalive timeout source so it can be removed when the account disconnects. This prevents a possible crash if the timeout fired after the account disconnected.
Evan Schoenberg <evands@pidgin.im>
parents: 22067
diff changeset
1360 purple_timeout_remove(js->keepalive_timeout);
0d28b254d322 Keep track of the keepalive timeout source so it can be removed when the account disconnects. This prevents a possible crash if the timeout fired after the account disconnected.
Evan Schoenberg <evands@pidgin.im>
parents: 22067
diff changeset
1361
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1362 g_free(js);
11389
c1e05b75b0b0 [gaim-migrate @ 13617]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11387
diff changeset
1363
c1e05b75b0b0 [gaim-migrate @ 13617]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11387
diff changeset
1364 gc->proto_data = NULL;
5093
7761492245e6 [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1365 }
7761492245e6 [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1366
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1367 void jabber_stream_set_state(JabberStream *js, JabberStreamState state)
3105
8c23b0ec1036 [gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3074
diff changeset
1368 {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1369 js->state = state;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1370 switch(state) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1371 case JABBER_STREAM_OFFLINE:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1372 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1373 case JABBER_STREAM_CONNECTING:
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1374 purple_connection_update_progress(js->gc, _("Connecting"), 1,
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1375 JABBER_CONNECT_STEPS);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1376 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1377 case JABBER_STREAM_INITIALIZING:
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1378 purple_connection_update_progress(js->gc, _("Initializing Stream"),
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1379 js->gsc ? 5 : 2, JABBER_CONNECT_STEPS);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1380 jabber_stream_init(js);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1381 break;
17813
c5cc8ebf62c0 Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents: 17810
diff changeset
1382 case JABBER_STREAM_INITIALIZING_ENCRYPTION:
c5cc8ebf62c0 Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents: 17810
diff changeset
1383 purple_connection_update_progress(js->gc, _("Initializing SSL/TLS"),
c5cc8ebf62c0 Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents: 17810
diff changeset
1384 6, JABBER_CONNECT_STEPS);
c5cc8ebf62c0 Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents: 17810
diff changeset
1385 break;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1386 case JABBER_STREAM_AUTHENTICATING:
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1387 purple_connection_update_progress(js->gc, _("Authenticating"),
17813
c5cc8ebf62c0 Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents: 17810
diff changeset
1388 js->gsc ? 7 : 3, JABBER_CONNECT_STEPS);
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
1389 if(js->protocol_version == JABBER_PROTO_0_9 && js->registration) {
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
1390 jabber_register_start(js);
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
1391 } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) {
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
1392 jabber_auth_start_old(js);
8016
d75a4e86f7c3 [gaim-migrate @ 8696]
Nathan Walp <nwalp@pidgin.im>
parents: 8013
diff changeset
1393 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1394 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1395 case JABBER_STREAM_REINITIALIZING:
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1396 purple_connection_update_progress(js->gc, _("Re-initializing Stream"),
17813
c5cc8ebf62c0 Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents: 17810
diff changeset
1397 (js->gsc ? 8 : 4), JABBER_CONNECT_STEPS);
16847
cd87fc9c6856 this should fix jabber buddy icons (but it will re-introduce the behavior of overwriting your vCard whenever you sign in).
Nathan Walp <nwalp@pidgin.im>
parents: 16799
diff changeset
1398
14700
98dc3d9a69e3 [gaim-migrate @ 17384]
Sean Egan <seanegan@pidgin.im>
parents: 14697
diff changeset
1399 /* The stream will be reinitialized later, in jabber_recv_cb_ssl() */
98dc3d9a69e3 [gaim-migrate @ 17384]
Sean Egan <seanegan@pidgin.im>
parents: 14697
diff changeset
1400 js->reinit = TRUE;
16847
cd87fc9c6856 this should fix jabber buddy icons (but it will re-introduce the behavior of overwriting your vCard whenever you sign in).
Nathan Walp <nwalp@pidgin.im>
parents: 16799
diff changeset
1401
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1402 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1403 case JABBER_STREAM_CONNECTED:
16847
cd87fc9c6856 this should fix jabber buddy icons (but it will re-introduce the behavior of overwriting your vCard whenever you sign in).
Nathan Walp <nwalp@pidgin.im>
parents: 16799
diff changeset
1404 /* now we can alert the core that we're ready to send status */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1405 purple_connection_set_state(js->gc, PURPLE_CONNECTED);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
1406 jabber_disco_items_server(js);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1407 break;
3105
8c23b0ec1036 [gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3074
diff changeset
1408 }
8c23b0ec1036 [gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3074
diff changeset
1409 }
8c23b0ec1036 [gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3074
diff changeset
1410
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1411 char *jabber_get_next_id(JabberStream *js)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1412 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1413 return g_strdup_printf("purple%x", js->next_id++);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1414 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1415
14453
1cc75906700c [gaim-migrate @ 17098]
Mark Doliner <markdoliner@pidgin.im>
parents: 14375
diff changeset
1416
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
1417 void jabber_idle_set(PurpleConnection *gc, int idle)
3340
7e59a209931d [gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3337
diff changeset
1418 {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1419 JabberStream *js = gc->proto_data;
3340
7e59a209931d [gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3337
diff changeset
1420
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1421 js->idle = idle ? time(NULL) - idle : idle;
3314
12fa45677717 [gaim-migrate @ 3332]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3311
diff changeset
1422 }
12fa45677717 [gaim-migrate @ 3332]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3311
diff changeset
1423
17783
2687df1ca202 PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents: 17782
diff changeset
1424 void jabber_add_feature(const char *shortname, const char *namespace, JabberFeatureEnabled cb) {
2687df1ca202 PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents: 17782
diff changeset
1425 JabberFeature *feat;
19994
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1426
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1427 g_return_if_fail(shortname != NULL);
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1428 g_return_if_fail(namespace != NULL);
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1429
17783
2687df1ca202 PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents: 17782
diff changeset
1430 feat = g_new0(JabberFeature,1);
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1431 feat->shortname = g_strdup(shortname);
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1432 feat->namespace = g_strdup(namespace);
17783
2687df1ca202 PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents: 17782
diff changeset
1433 feat->is_enabled = cb;
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1434
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1435 /* try to remove just in case it already exists in the list */
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1436 jabber_remove_feature(shortname);
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1437
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1438 jabber_features = g_list_append(jabber_features, feat);
17770
e67998927a3c Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents: 17769
diff changeset
1439 }
e67998927a3c Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents: 17769
diff changeset
1440
17773
6956b763b3d1 Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <am@adiumx.com>
parents: 17770
diff changeset
1441 void jabber_remove_feature(const char *shortname) {
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1442 GList *feature;
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1443 for(feature = jabber_features; feature; feature = feature->next) {
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1444 JabberFeature *feat = (JabberFeature*)feature->data;
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1445 if(!strcmp(feat->shortname, shortname)) {
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1446 g_free(feat->shortname);
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1447 g_free(feat->namespace);
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1448
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1449 g_free(feature->data);
21623
722e905dd5b5 Fix #3669
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1450 jabber_features = g_list_delete_link(jabber_features, feature);
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1451 break;
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1452 }
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1453 }
17770
e67998927a3c Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents: 17769
diff changeset
1454 }
e67998927a3c Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents: 17769
diff changeset
1455
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
1456 const char *jabber_list_icon(PurpleAccount *a, PurpleBuddy *b)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1457 {
4687
91ad36873636 [gaim-migrate @ 4998]
Sean Egan <seanegan@pidgin.im>
parents: 4675
diff changeset
1458 return "jabber";
91ad36873636 [gaim-migrate @ 4998]
Sean Egan <seanegan@pidgin.im>
parents: 4675
diff changeset
1459 }
4916
11b8fd3f8ffc [gaim-migrate @ 5250]
Sean Egan <seanegan@pidgin.im>
parents: 4915
diff changeset
1460
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
1461 const char* jabber_list_emblem(PurpleBuddy *b)
4916
11b8fd3f8ffc [gaim-migrate @ 5250]
Sean Egan <seanegan@pidgin.im>
parents: 4915
diff changeset
1462 {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1463 JabberStream *js;
13486
4ea1a712aaa3 [gaim-migrate @ 15861]
Daniel Atallah <datallah@pidgin.im>
parents: 13385
diff changeset
1464 JabberBuddy *jb = NULL;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1465
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1466 if(!b->account->gc)
15558
6fb7a0ad8a0b clean up some compile warnings
Nathan Walp <nwalp@pidgin.im>
parents: 15524
diff changeset
1467 return NULL;
6fb7a0ad8a0b clean up some compile warnings
Nathan Walp <nwalp@pidgin.im>
parents: 15524
diff changeset
1468
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1469 js = b->account->gc->proto_data;
13486
4ea1a712aaa3 [gaim-migrate @ 15861]
Daniel Atallah <datallah@pidgin.im>
parents: 13385
diff changeset
1470 if(js)
4ea1a712aaa3 [gaim-migrate @ 15861]
Daniel Atallah <datallah@pidgin.im>
parents: 13385
diff changeset
1471 jb = jabber_buddy_find(js, b->name, FALSE);
5135
fbcfa5df4c5e [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
1472
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1473 if(!PURPLE_BUDDY_IS_ONLINE(b)) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1474 if(jb && (jb->subscription & JABBER_SUB_PENDING ||
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1475 !(jb->subscription & JABBER_SUB_TO)))
15524
8f365f9bf660 Emblems in the blist
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
1476 return "not-authorized";
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1477 }
15524
8f365f9bf660 Emblems in the blist
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
1478 return NULL;
4916
11b8fd3f8ffc [gaim-migrate @ 5250]
Sean Egan <seanegan@pidgin.im>
parents: 4915
diff changeset
1479 }
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1480
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
1481 char *jabber_status_text(PurpleBuddy *b)
2205
68c42ce8eba6 [gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 2170
diff changeset
1482 {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1483 char *ret = NULL;
18310
dbc5240f6bf5 Fix a crash when you have an IM window open on a jabber account and the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18235
diff changeset
1484 JabberBuddy *jb = NULL;
dbc5240f6bf5 Fix a crash when you have an IM window open on a jabber account and the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18235
diff changeset
1485
dbc5240f6bf5 Fix a crash when you have an IM window open on a jabber account and the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18235
diff changeset
1486 if (b->account->gc && b->account->gc->proto_data)
dbc5240f6bf5 Fix a crash when you have an IM window open on a jabber account and the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18235
diff changeset
1487 jb = jabber_buddy_find(b->account->gc->proto_data, b->name, FALSE);
5234
8320a1cb0274 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
1488
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1489 if(jb && !PURPLE_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1490 ret = g_strdup(_("Not Authorized"));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1491 } else if(jb && !PURPLE_BUDDY_IS_ONLINE(b) && jb->error_msg) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1492 ret = g_strdup(jb->error_msg);
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1493 } else {
7095
17d2b54254f8 [gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents: 7072
diff changeset
1494 char *stripped;
17d2b54254f8 [gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents: 7072
diff changeset
1495
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1496 if(!(stripped = purple_markup_strip_html(jabber_buddy_get_status_msg(jb)))) {
21195
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
1497 PurplePresence *presence = purple_buddy_get_presence(b);
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
1498 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
1499 PurpleStatus *status = purple_presence_get_status(presence, "tune");
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
1500 stripped = g_strdup(purple_status_get_attr_string(status, PURPLE_TUNE_TITLE));
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
1501 }
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1502 }
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1503
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1504 if(stripped) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1505 ret = g_markup_escape_text(stripped, -1);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1506 g_free(stripped);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1507 }
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1508 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1509
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1510 return ret;
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1511 }
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1512
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
1513 void jabber_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full)
4744
c3a5a15c01f7 [gaim-migrate @ 5059]
Sean Egan <seanegan@pidgin.im>
parents: 4732
diff changeset
1514 {
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1515 JabberBuddy *jb;
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1516
12970
c2f3b4dcf711 [gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents: 12948
diff changeset
1517 g_return_if_fail(b != NULL);
c2f3b4dcf711 [gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents: 12948
diff changeset
1518 g_return_if_fail(b->account != NULL);
c2f3b4dcf711 [gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents: 12948
diff changeset
1519 g_return_if_fail(b->account->gc != NULL);
c2f3b4dcf711 [gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents: 12948
diff changeset
1520 g_return_if_fail(b->account->gc->proto_data != NULL);
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1521
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1522 jb = jabber_buddy_find(b->account->gc->proto_data, b->name,
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1523 FALSE);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1524
8194
bf412cad6608 [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1525 if(jb) {
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1526 JabberBuddyResource *jbr = NULL;
21195
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
1527 PurplePresence *presence = purple_buddy_get_presence(b);
8194
bf412cad6608 [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1528 const char *sub;
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1529 GList *l;
19920
7b0d20da73d0 Don't put "Mood: \(null\) \(null\)" on XMPP buddies
Sean Egan <seanegan@pidgin.im>
parents: 19897
diff changeset
1530 const char *mood;
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1531
12948
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
1532 if (full) {
17780
749862fd4a87 Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents: 17779
diff changeset
1533 PurpleStatus *status;
749862fd4a87 Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents: 17779
diff changeset
1534 PurpleValue *value;
749862fd4a87 Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents: 17779
diff changeset
1535
12948
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
1536 if(jb->subscription & JABBER_SUB_FROM) {
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
1537 if(jb->subscription & JABBER_SUB_TO)
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
1538 sub = _("Both");
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
1539 else if(jb->subscription & JABBER_SUB_PENDING)
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
1540 sub = _("From (To pending)");
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
1541 else
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
1542 sub = _("From");
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
1543 } else {
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
1544 if(jb->subscription & JABBER_SUB_TO)
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
1545 sub = _("To");
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
1546 else if(jb->subscription & JABBER_SUB_PENDING)
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
1547 sub = _("None (To pending)");
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
1548 else
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
1549 sub = _("None");
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
1550 }
15205
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15198
diff changeset
1551
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1552 purple_notify_user_info_add_pair(user_info, _("Subscription"), sub);
17780
749862fd4a87 Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents: 17779
diff changeset
1553
21195
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
1554 status = purple_presence_get_active_status(presence);
17780
749862fd4a87 Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents: 17779
diff changeset
1555 value = purple_status_get_attr_value(status, "mood");
19920
7b0d20da73d0 Don't put "Mood: \(null\) \(null\)" on XMPP buddies
Sean Egan <seanegan@pidgin.im>
parents: 19897
diff changeset
1556 if (value && purple_value_get_type(value) == PURPLE_TYPE_STRING && (mood = purple_value_get_string(value))) {
17780
749862fd4a87 Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents: 17779
diff changeset
1557
749862fd4a87 Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents: 17779
diff changeset
1558 value = purple_status_get_attr_value(status, "moodtext");
749862fd4a87 Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents: 17779
diff changeset
1559 if(value && purple_value_get_type(value) == PURPLE_TYPE_STRING) {
749862fd4a87 Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents: 17779
diff changeset
1560 char *moodplustext = g_strdup_printf("%s (%s)",mood,purple_value_get_string(value));
749862fd4a87 Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents: 17779
diff changeset
1561
749862fd4a87 Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents: 17779
diff changeset
1562 purple_notify_user_info_add_pair(user_info, _("Mood"), moodplustext);
749862fd4a87 Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents: 17779
diff changeset
1563 g_free(moodplustext);
749862fd4a87 Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents: 17779
diff changeset
1564 } else
749862fd4a87 Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents: 17779
diff changeset
1565 purple_notify_user_info_add_pair(user_info, _("Mood"), mood);
21195
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
1566 }
22133
6eb22afb9701 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22111
diff changeset
1567 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
21195
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
1568 PurpleStatus *tune = purple_presence_get_status(presence, "tune");
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
1569 const char *title = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE);
22133
6eb22afb9701 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22111
diff changeset
1570 const char *artist = purple_status_get_attr_string(tune, PURPLE_TUNE_ARTIST);
6eb22afb9701 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22111
diff changeset
1571 const char *album = purple_status_get_attr_string(tune, PURPLE_TUNE_ALBUM);
6eb22afb9701 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22111
diff changeset
1572 char *playing = purple_util_format_song_info(title, artist, album, NULL);
6eb22afb9701 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22111
diff changeset
1573 if (playing) {
6eb22afb9701 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22111
diff changeset
1574 purple_notify_user_info_add_pair(user_info, _("Now Listening"), playing);
6eb22afb9701 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22111
diff changeset
1575 g_free(playing);
6eb22afb9701 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22111
diff changeset
1576 }
21195
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
1577 }
8194
bf412cad6608 [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1578 }
bf412cad6608 [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1579
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1580 for(l=jb->resources; l; l = l->next) {
8194
bf412cad6608 [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1581 char *text = NULL;
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1582 char *res = NULL;
15205
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15198
diff changeset
1583 char *label, *value;
12944
da8f60d43d88 [gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents: 12943
diff changeset
1584 const char *state;
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1585
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1586 jbr = l->data;
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1587
8194
bf412cad6608 [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1588 if(jbr->status) {
11646
88222bcf445b [gaim-migrate @ 13924]
Nathan Walp <nwalp@pidgin.im>
parents: 11610
diff changeset
1589 char *tmp;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1590 text = purple_strreplace(jbr->status, "\n", "<br />\n");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1591 tmp = purple_markup_strip_html(text);
11646
88222bcf445b [gaim-migrate @ 13924]
Nathan Walp <nwalp@pidgin.im>
parents: 11610
diff changeset
1592 g_free(text);
88222bcf445b [gaim-migrate @ 13924]
Nathan Walp <nwalp@pidgin.im>
parents: 11610
diff changeset
1593 text = g_markup_escape_text(tmp, -1);
88222bcf445b [gaim-migrate @ 13924]
Nathan Walp <nwalp@pidgin.im>
parents: 11610
diff changeset
1594 g_free(tmp);
8194
bf412cad6608 [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1595 }
bf412cad6608 [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1596
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1597 if(jbr->name)
11610
85f0e6e9dc5c [gaim-migrate @ 13881]
Nathan Walp <nwalp@pidgin.im>
parents: 11609
diff changeset
1598 res = g_strdup_printf(" (%s)", jbr->name);
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1599
12944
da8f60d43d88 [gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents: 12943
diff changeset
1600 state = jabber_buddy_state_get_name(jbr->state);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1601 if (text != NULL && !purple_utf8_strcasecmp(state, text)) {
12944
da8f60d43d88 [gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents: 12943
diff changeset
1602 g_free(text);
da8f60d43d88 [gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents: 12943
diff changeset
1603 text = NULL;
da8f60d43d88 [gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents: 12943
diff changeset
1604 }
da8f60d43d88 [gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents: 12943
diff changeset
1605
15205
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15198
diff changeset
1606 label = g_strdup_printf("%s%s",
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15198
diff changeset
1607 _("Status"), (res ? res : ""));
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15198
diff changeset
1608 value = g_strdup_printf("%s%s%s",
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15198
diff changeset
1609 state,
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15198
diff changeset
1610 (text ? ": " : ""),
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15198
diff changeset
1611 (text ? text : ""));
12944
da8f60d43d88 [gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents: 12943
diff changeset
1612
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1613 purple_notify_user_info_add_pair(user_info, label, value);
15205
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15198
diff changeset
1614
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15198
diff changeset
1615 g_free(label);
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15198
diff changeset
1616 g_free(value);
12944
da8f60d43d88 [gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents: 12943
diff changeset
1617 g_free(text);
da8f60d43d88 [gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents: 12943
diff changeset
1618 g_free(res);
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1619 }
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1620
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1621 if(!PURPLE_BUDDY_IS_ONLINE(b) && jb->error_msg) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1622 purple_notify_user_info_add_pair(user_info, _("Error"), jb->error_msg);
8194
bf412cad6608 [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1623 }
4745
24867c379d37 [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1624 }
4732
a0857625cadb [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4705
diff changeset
1625 }
a0857625cadb [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4705
diff changeset
1626
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
1627 GList *jabber_status_types(PurpleAccount *account)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1628 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1629 PurpleStatusType *type;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1630 GList *types = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1631 PurpleValue *priority_value;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1632
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1633 priority_value = purple_value_new(PURPLE_TYPE_INT);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1634 purple_value_set_int(priority_value, 1);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1635 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1636 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_ONLINE),
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1637 NULL, TRUE, TRUE, FALSE,
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1638 "priority", _("Priority"), priority_value,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1639 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1640 "mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1641 "moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
17803
882abe4d932e Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <am@adiumx.com>
parents: 17800
diff changeset
1642 "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
17824
52683dfc1f7d Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents: 17823
diff changeset
1643 "buzz", _("Allow Buzz"), purple_value_new(PURPLE_TYPE_BOOLEAN),
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1644 NULL);
9980
ea4241d66fd1 [gaim-migrate @ 10891]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1645 types = g_list_append(types, type);
ea4241d66fd1 [gaim-migrate @ 10891]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1646
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1647 priority_value = purple_value_new(PURPLE_TYPE_INT);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1648 purple_value_set_int(priority_value, 1);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1649 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1650 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_CHAT),
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1651 _("Chatty"), TRUE, TRUE, FALSE,
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1652 "priority", _("Priority"), priority_value,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1653 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1654 "mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1655 "moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
17803
882abe4d932e Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <am@adiumx.com>
parents: 17800
diff changeset
1656 "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
17824
52683dfc1f7d Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents: 17823
diff changeset
1657 "buzz", _("Allow Buzz"), purple_value_new(PURPLE_TYPE_BOOLEAN),
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1658 NULL);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1659 types = g_list_append(types, type);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1660
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1661 priority_value = purple_value_new(PURPLE_TYPE_INT);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1662 purple_value_set_int(priority_value, 0);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1663 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1664 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_AWAY),
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1665 NULL, TRUE, TRUE, FALSE,
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1666 "priority", _("Priority"), priority_value,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1667 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1668 "mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1669 "moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
17803
882abe4d932e Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <am@adiumx.com>
parents: 17800
diff changeset
1670 "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
17824
52683dfc1f7d Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents: 17823
diff changeset
1671 "buzz", _("Allow Buzz"), purple_value_new(PURPLE_TYPE_BOOLEAN),
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1672 NULL);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1673 types = g_list_append(types, type);
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1674
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1675 priority_value = purple_value_new(PURPLE_TYPE_INT);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1676 purple_value_set_int(priority_value, 0);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1677 type = purple_status_type_new_with_attrs(PURPLE_STATUS_EXTENDED_AWAY,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1678 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_XA),
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1679 NULL, TRUE, TRUE, FALSE,
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1680 "priority", _("Priority"), priority_value,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1681 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1682 "mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1683 "moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
17803
882abe4d932e Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <am@adiumx.com>
parents: 17800
diff changeset
1684 "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
17824
52683dfc1f7d Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents: 17823
diff changeset
1685 "buzz", _("Allow Buzz"), purple_value_new(PURPLE_TYPE_BOOLEAN),
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1686 NULL);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1687 types = g_list_append(types, type);
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1688
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1689 priority_value = purple_value_new(PURPLE_TYPE_INT);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1690 purple_value_set_int(priority_value, 0);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1691 type = purple_status_type_new_with_attrs(PURPLE_STATUS_UNAVAILABLE,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1692 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_DND),
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1693 _("Do Not Disturb"), TRUE, TRUE, FALSE,
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1694 "priority", _("Priority"), priority_value,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1695 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1696 "mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1697 "moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
17803
882abe4d932e Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <am@adiumx.com>
parents: 17800
diff changeset
1698 "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
17824
52683dfc1f7d Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents: 17823
diff changeset
1699 "buzz", _("Allow Buzz"), purple_value_new(PURPLE_TYPE_BOOLEAN),
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
1700 NULL);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1701 types = g_list_append(types, type);
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1702
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1703 /*
8166
0a109d9655c7 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8158
diff changeset
1704 if(js->protocol_version == JABBER_PROTO_0_9)
0a109d9655c7 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8158
diff changeset
1705 m = g_list_append(m, _("Invisible"));
10009
8a4fcc043f47 [gaim-migrate @ 10926]
Mark Doliner <markdoliner@pidgin.im>
parents: 9980
diff changeset
1706 */
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1707
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1708 type = purple_status_type_new_with_attrs(PURPLE_STATUS_OFFLINE,
12658
4aa7a873628d [gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents: 12646
diff changeset
1709 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_UNAVAILABLE),
4aa7a873628d [gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents: 12646
diff changeset
1710 NULL, FALSE, TRUE, FALSE,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1711 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
12658
4aa7a873628d [gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents: 12646
diff changeset
1712 NULL);
4aa7a873628d [gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents: 12646
diff changeset
1713 types = g_list_append(types, type);
4aa7a873628d [gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents: 12646
diff changeset
1714
21193
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20332
diff changeset
1715 type = purple_status_type_new_with_attrs(PURPLE_STATUS_TUNE,
21199
346f83590d69 Is there any reason these statuses were set to not saveable and
Mark Doliner <markdoliner@pidgin.im>
parents: 21195
diff changeset
1716 "tune", NULL, TRUE, TRUE, TRUE,
21193
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20332
diff changeset
1717 PURPLE_TUNE_ARTIST, _("Tune Artist"), purple_value_new(PURPLE_TYPE_STRING),
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20332
diff changeset
1718 PURPLE_TUNE_TITLE, _("Tune Title"), purple_value_new(PURPLE_TYPE_STRING),
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20332
diff changeset
1719 PURPLE_TUNE_ALBUM, _("Tune Album"), purple_value_new(PURPLE_TYPE_STRING),
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20332
diff changeset
1720 PURPLE_TUNE_GENRE, _("Tune Genre"), purple_value_new(PURPLE_TYPE_STRING),
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20332
diff changeset
1721 PURPLE_TUNE_COMMENT, _("Tune Comment"), purple_value_new(PURPLE_TYPE_STRING),
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20332
diff changeset
1722 PURPLE_TUNE_TRACK, _("Tune Track"), purple_value_new(PURPLE_TYPE_STRING),
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20332
diff changeset
1723 PURPLE_TUNE_TIME, _("Tune Time"), purple_value_new(PURPLE_TYPE_INT),
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20332
diff changeset
1724 PURPLE_TUNE_YEAR, _("Tune Year"), purple_value_new(PURPLE_TYPE_INT),
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20332
diff changeset
1725 PURPLE_TUNE_URL, _("Tune URL"), purple_value_new(PURPLE_TYPE_STRING),
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20332
diff changeset
1726 NULL);
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20332
diff changeset
1727 types = g_list_append(types, type);
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20332
diff changeset
1728
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1729 return types;
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1730 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1731
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
1732 static void
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
1733 jabber_password_change_result_cb(JabberStream *js, xmlnode *packet,
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
1734 gpointer data)
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1735 {
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1736 const char *type;
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1737
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1738 type = xmlnode_get_attrib(packet, "type");
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1739
9414
d35d704b5b74 [gaim-migrate @ 10229]
Nathan Walp <nwalp@pidgin.im>
parents: 9308
diff changeset
1740 if(type && !strcmp(type, "result")) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1741 purple_notify_info(js->gc, _("Password Changed"), _("Password Changed"),
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1742 _("Your password has been changed."));
21129
91280f050201 This patch prevents changing the saved account password for XMPP accounts
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 21076
diff changeset
1743
91280f050201 This patch prevents changing the saved account password for XMPP accounts
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 21076
diff changeset
1744 purple_account_set_password(js->gc->account, (char *)data);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1745 } else {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
1746 char *msg = jabber_parse_error(js, packet, NULL);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1747
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1748 purple_notify_error(js->gc, _("Error changing password"),
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1749 _("Error changing password"), msg);
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1750 g_free(msg);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1751 }
21129
91280f050201 This patch prevents changing the saved account password for XMPP accounts
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 21076
diff changeset
1752
91280f050201 This patch prevents changing the saved account password for XMPP accounts
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 21076
diff changeset
1753 g_free(data);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1754 }
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1755
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1756 static void jabber_password_change_cb(JabberStream *js,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1757 PurpleRequestFields *fields)
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1758 {
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1759 const char *p1, *p2;
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1760 JabberIq *iq;
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1761 xmlnode *query, *y;
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1762
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1763 p1 = purple_request_fields_get_string(fields, "password1");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1764 p2 = purple_request_fields_get_string(fields, "password2");
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1765
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1766 if(strcmp(p1, p2)) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1767 purple_notify_error(js->gc, NULL, _("New passwords do not match."), NULL);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1768 return;
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1769 }
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1770
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1771 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register");
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1772
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1773 xmlnode_set_attrib(iq->node, "to", js->user->domain);
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1774
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1775 query = xmlnode_get_child(iq->node, "query");
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1776
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1777 y = xmlnode_new_child(query, "username");
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1778 xmlnode_insert_data(y, js->user->node, -1);
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1779 y = xmlnode_new_child(query, "password");
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1780 xmlnode_insert_data(y, p1, -1);
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1781
21129
91280f050201 This patch prevents changing the saved account password for XMPP accounts
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 21076
diff changeset
1782 jabber_iq_set_callback(iq, jabber_password_change_result_cb, g_strdup(p1));
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1783
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1784 jabber_iq_send(iq);
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1785 }
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1786
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1787 static void jabber_password_change(PurplePluginAction *action)
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1788 {
9015
3c27e9074fa2 [gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents: 8993
diff changeset
1789
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1790 PurpleConnection *gc = (PurpleConnection *) action->context;
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1791 JabberStream *js = gc->proto_data;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1792 PurpleRequestFields *fields;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1793 PurpleRequestFieldGroup *group;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1794 PurpleRequestField *field;
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1795
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1796 fields = purple_request_fields_new();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1797 group = purple_request_field_group_new(NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1798 purple_request_fields_add_group(fields, group);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1799
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1800 field = purple_request_field_string_new("password1", _("Password"),
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1801 "", FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1802 purple_request_field_string_set_masked(field, TRUE);
18381
8192b072afa6 Make password fileds in Jabber's Change Password dialog required. Fixes #1907
Sean Egan <seanegan@pidgin.im>
parents: 18310
diff changeset
1803 purple_request_field_set_required(field, TRUE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1804 purple_request_field_group_add_field(group, field);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1805
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1806 field = purple_request_field_string_new("password2", _("Password (again)"),
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1807 "", FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1808 purple_request_field_string_set_masked(field, TRUE);
18381
8192b072afa6 Make password fileds in Jabber's Change Password dialog required. Fixes #1907
Sean Egan <seanegan@pidgin.im>
parents: 18310
diff changeset
1809 purple_request_field_set_required(field, TRUE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1810 purple_request_field_group_add_field(group, field);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1811
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
1812 purple_request_fields(js->gc, _("Change XMPP Password"),
16961
b6955f946f8f s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents: 16847
diff changeset
1813 _("Change XMPP Password"), _("Please enter your new password"),
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1814 fields, _("OK"), G_CALLBACK(jabber_password_change_cb),
16490
68c22924d66b Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents: 16302
diff changeset
1815 _("Cancel"), NULL,
19993
867bd1dfe680 Clear the password when we get an auth. error and we're not saving passwords so that you don't need to go into the account settings to reset it. Fix #3083.
Daniel Atallah <datallah@pidgin.im>
parents: 19920
diff changeset
1816 purple_connection_get_account(gc), NULL, NULL,
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
1817 js);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1818 }
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1819
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
1820 GList *jabber_actions(PurplePlugin *plugin, gpointer context)
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1821 {
17782
83af68644d0a Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <am@adiumx.com>
parents: 17780
diff changeset
1822 PurpleConnection *gc = (PurpleConnection *) context;
83af68644d0a Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <am@adiumx.com>
parents: 17780
diff changeset
1823 JabberStream *js = gc->proto_data;
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1824 GList *m = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1825 PurplePluginAction *act;
4333
f4c095774bc2 [gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents: 4316
diff changeset
1826
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1827 act = purple_plugin_action_new(_("Set User Info..."),
12286
08d994091c36 [gaim-migrate @ 14590]
Etan Reisner <deryni@pidgin.im>
parents: 12284
diff changeset
1828 jabber_setup_set_info);
9015
3c27e9074fa2 [gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents: 8993
diff changeset
1829 m = g_list_append(m, act);
4333
f4c095774bc2 [gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents: 4316
diff changeset
1830
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
1831 /* if (js->protocol_options & CHANGE_PASSWORD) { */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1832 act = purple_plugin_action_new(_("Change Password..."),
12286
08d994091c36 [gaim-migrate @ 14590]
Etan Reisner <deryni@pidgin.im>
parents: 12284
diff changeset
1833 jabber_password_change);
9015
3c27e9074fa2 [gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents: 8993
diff changeset
1834 m = g_list_append(m, act);
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
1835 /* } */
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1836
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1837 act = purple_plugin_action_new(_("Search for Users..."),
12286
08d994091c36 [gaim-migrate @ 14590]
Etan Reisner <deryni@pidgin.im>
parents: 12284
diff changeset
1838 jabber_user_search_begin);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
1839 m = g_list_append(m, act);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
1840
17783
2687df1ca202 PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents: 17782
diff changeset
1841 purple_debug_info("jabber", "jabber_actions: have pep: %s\n", js->pep?"YES":"NO");
2687df1ca202 PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents: 17782
diff changeset
1842
17782
83af68644d0a Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <am@adiumx.com>
parents: 17780
diff changeset
1843 if(js->pep)
83af68644d0a Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <am@adiumx.com>
parents: 17780
diff changeset
1844 jabber_pep_init_actions(&m);
17817
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17815
diff changeset
1845
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17815
diff changeset
1846 if(js->commands)
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17815
diff changeset
1847 jabber_adhoc_init_server_commands(js, &m);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
1848
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1849 return m;
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1850 }
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1851
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
1852 PurpleChat *jabber_find_blist_chat(PurpleAccount *account, const char *name)
7999
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1853 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1854 PurpleBlistNode *gnode, *cnode;
7999
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1855 JabberID *jid;
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1856
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1857 if(!(jid = jabber_id_new(name)))
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1858 return NULL;
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1859
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1860 for(gnode = purple_get_blist()->root; gnode; gnode = gnode->next) {
7999
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1861 for(cnode = gnode->child; cnode; cnode = cnode->next) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1862 PurpleChat *chat = (PurpleChat*)cnode;
7999
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1863 const char *room, *server;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1864 if(!PURPLE_BLIST_NODE_IS_CHAT(cnode))
7999
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1865 continue;
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1866
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1867 if(chat->account != account)
8011
e9ac8bfe26da [gaim-migrate @ 8691]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
1868 continue;
7999
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1869
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1870 if(!(room = g_hash_table_lookup(chat->components, "room")))
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1871 continue;
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1872 if(!(server = g_hash_table_lookup(chat->components, "server")))
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1873 continue;
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1874
8158
a62f04d81823 [gaim-migrate @ 8870]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1875 if(jid->node && jid->domain &&
a62f04d81823 [gaim-migrate @ 8870]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1876 !g_utf8_collate(room, jid->node) && !g_utf8_collate(server, jid->domain)) {
7999
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1877 jabber_id_free(jid);
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1878 return chat;
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1879 }
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1880 }
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1881 }
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1882 jabber_id_free(jid);
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1883 return NULL;
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1884 }
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1885
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
1886 void jabber_convo_closed(PurpleConnection *gc, const char *who)
8400
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1887 {
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1888 JabberStream *js = gc->proto_data;
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1889 JabberID *jid;
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1890 JabberBuddy *jb;
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1891 JabberBuddyResource *jbr;
23704
9b88c9b23aed Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents: 23701
diff changeset
1892 #ifdef USE_VV
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1893 JingleSession *session;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1894 #endif
8400
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1895 if(!(jid = jabber_id_new(who)))
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1896 return;
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1897
23704
9b88c9b23aed Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents: 23701
diff changeset
1898 #ifdef USE_VV
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1899 session = jabber_jingle_session_find_by_jid(js, who);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1900
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1901 if (session) {
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1902 purple_media_hangup(session->media);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1903 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1904
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1905 #endif
8400
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1906 if((jb = jabber_buddy_find(js, who, TRUE)) &&
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1907 (jbr = jabber_buddy_find_resource(jb, jid->resource))) {
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1908 if(jbr->thread_id) {
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1909 g_free(jbr->thread_id);
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1910 jbr->thread_id = NULL;
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1911 }
15709
b58646e3ce63 Sending XEP 85 'gone' messages
Sean Egan <seanegan@pidgin.im>
parents: 15668
diff changeset
1912 if(jbr->chat_states == JABBER_CHAT_STATES_SUPPORTED)
b58646e3ce63 Sending XEP 85 'gone' messages
Sean Egan <seanegan@pidgin.im>
parents: 15668
diff changeset
1913 jabber_message_conv_closed(js, who);
8400
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1914 }
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1915
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1916 jabber_id_free(jid);
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1917 }
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1918
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1919
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
1920 char *jabber_parse_error(JabberStream *js,
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
1921 xmlnode *packet,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
1922 PurpleConnectionError *reason)
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1923 {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1924 xmlnode *error;
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1925 const char *code = NULL, *text = NULL;
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13806
diff changeset
1926 const char *xmlns = xmlnode_get_namespace(packet);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1927 char *cdata = NULL;
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1928
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
1929 #define SET_REASON(x) \
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
1930 if(reason != NULL) { *reason = x; }
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
1931
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1932 if((error = xmlnode_get_child(packet, "error"))) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1933 cdata = xmlnode_get_data(error);
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1934 code = xmlnode_get_attrib(error, "code");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1935
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1936 /* Stanza errors */
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1937 if(xmlnode_get_child(error, "bad-request")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1938 text = _("Bad Request");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1939 } else if(xmlnode_get_child(error, "conflict")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1940 text = _("Conflict");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1941 } else if(xmlnode_get_child(error, "feature-not-implemented")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1942 text = _("Feature Not Implemented");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1943 } else if(xmlnode_get_child(error, "forbidden")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1944 text = _("Forbidden");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1945 } else if(xmlnode_get_child(error, "gone")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1946 text = _("Gone");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1947 } else if(xmlnode_get_child(error, "internal-server-error")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1948 text = _("Internal Server Error");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1949 } else if(xmlnode_get_child(error, "item-not-found")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1950 text = _("Item Not Found");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1951 } else if(xmlnode_get_child(error, "jid-malformed")) {
16961
b6955f946f8f s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents: 16847
diff changeset
1952 text = _("Malformed XMPP ID");
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1953 } else if(xmlnode_get_child(error, "not-acceptable")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1954 text = _("Not Acceptable");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1955 } else if(xmlnode_get_child(error, "not-allowed")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1956 text = _("Not Allowed");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1957 } else if(xmlnode_get_child(error, "not-authorized")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1958 text = _("Not Authorized");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1959 } else if(xmlnode_get_child(error, "payment-required")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1960 text = _("Payment Required");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1961 } else if(xmlnode_get_child(error, "recipient-unavailable")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1962 text = _("Recipient Unavailable");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1963 } else if(xmlnode_get_child(error, "redirect")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1964 /* XXX */
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1965 } else if(xmlnode_get_child(error, "registration-required")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1966 text = _("Registration Required");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1967 } else if(xmlnode_get_child(error, "remote-server-not-found")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1968 text = _("Remote Server Not Found");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1969 } else if(xmlnode_get_child(error, "remote-server-timeout")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1970 text = _("Remote Server Timeout");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1971 } else if(xmlnode_get_child(error, "resource-constraint")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1972 text = _("Server Overloaded");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1973 } else if(xmlnode_get_child(error, "service-unavailable")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1974 text = _("Service Unavailable");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1975 } else if(xmlnode_get_child(error, "subscription-required")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1976 text = _("Subscription Required");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1977 } else if(xmlnode_get_child(error, "unexpected-request")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1978 text = _("Unexpected Request");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1979 } else if(xmlnode_get_child(error, "undefined-condition")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1980 text = _("Unknown Error");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1981 }
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1982 } else if(xmlns && !strcmp(xmlns, "urn:ietf:params:xml:ns:xmpp-sasl")) {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
1983 /* Most common reason can be the default */
21284
69472e4a5458 Having read the XMPP SASL specification, these errors seem more accurate.
Will Thompson <resiak@pidgin.im>
parents: 21281
diff changeset
1984 SET_REASON(PURPLE_CONNECTION_ERROR_NETWORK_ERROR);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1985 if(xmlnode_get_child(packet, "aborted")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1986 text = _("Authorization Aborted");
13806
70aa4bd581e5 [gaim-migrate @ 16223]
Sean Egan <seanegan@pidgin.im>
parents: 13746
diff changeset
1987 } else if(xmlnode_get_child(packet, "incorrect-encoding")) {
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1988 text = _("Incorrect encoding in authorization");
13806
70aa4bd581e5 [gaim-migrate @ 16223]
Sean Egan <seanegan@pidgin.im>
parents: 13746
diff changeset
1989 } else if(xmlnode_get_child(packet, "invalid-authzid")) {
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1990 text = _("Invalid authzid");
13806
70aa4bd581e5 [gaim-migrate @ 16223]
Sean Egan <seanegan@pidgin.im>
parents: 13746
diff changeset
1991 } else if(xmlnode_get_child(packet, "invalid-mechanism")) {
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1992 text = _("Invalid Authorization Mechanism");
13806
70aa4bd581e5 [gaim-migrate @ 16223]
Sean Egan <seanegan@pidgin.im>
parents: 13746
diff changeset
1993 } else if(xmlnode_get_child(packet, "mechanism-too-weak")) {
21284
69472e4a5458 Having read the XMPP SASL specification, these errors seem more accurate.
Will Thompson <resiak@pidgin.im>
parents: 21281
diff changeset
1994 SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1995 text = _("Authorization mechanism too weak");
13806
70aa4bd581e5 [gaim-migrate @ 16223]
Sean Egan <seanegan@pidgin.im>
parents: 13746
diff changeset
1996 } else if(xmlnode_get_child(packet, "not-authorized")) {
21284
69472e4a5458 Having read the XMPP SASL specification, these errors seem more accurate.
Will Thompson <resiak@pidgin.im>
parents: 21281
diff changeset
1997 SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED);
19993
867bd1dfe680 Clear the password when we get an auth. error and we're not saving passwords so that you don't need to go into the account settings to reset it. Fix #3083.
Daniel Atallah <datallah@pidgin.im>
parents: 19920
diff changeset
1998 /* Clear the pasword if it isn't being saved */
867bd1dfe680 Clear the password when we get an auth. error and we're not saving passwords so that you don't need to go into the account settings to reset it. Fix #3083.
Daniel Atallah <datallah@pidgin.im>
parents: 19920
diff changeset
1999 if (!purple_account_get_remember_password(js->gc->account))
867bd1dfe680 Clear the password when we get an auth. error and we're not saving passwords so that you don't need to go into the account settings to reset it. Fix #3083.
Daniel Atallah <datallah@pidgin.im>
parents: 19920
diff changeset
2000 purple_account_set_password(js->gc->account, NULL);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2001 text = _("Not Authorized");
13806
70aa4bd581e5 [gaim-migrate @ 16223]
Sean Egan <seanegan@pidgin.im>
parents: 13746
diff changeset
2002 } else if(xmlnode_get_child(packet, "temporary-auth-failure")) {
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2003 text = _("Temporary Authentication Failure");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2004 } else {
21284
69472e4a5458 Having read the XMPP SASL specification, these errors seem more accurate.
Will Thompson <resiak@pidgin.im>
parents: 21281
diff changeset
2005 SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2006 text = _("Authentication Failure");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2007 }
15979
acfbd09bc217 Correctly handle the Jabber disconnection error for signing onto the
Mark Doliner <markdoliner@pidgin.im>
parents: 15977
diff changeset
2008 } else if(!strcmp(packet->name, "stream:error") ||
20929
8e72c1d47fbd Make sure that the xmlns isn't null before dereferencing it to fix CID 320.
Daniel Atallah <datallah@pidgin.im>
parents: 20404
diff changeset
2009 (!strcmp(packet->name, "error") && xmlns &&
15980
77057c4f658a Minor code cleanup
Mark Doliner <markdoliner@pidgin.im>
parents: 15979
diff changeset
2010 !strcmp(xmlns, "http://etherx.jabber.org/streams"))) {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
2011 /* Most common reason as default: */
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
2012 SET_REASON(PURPLE_CONNECTION_ERROR_NETWORK_ERROR);
8402
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2013 if(xmlnode_get_child(packet, "bad-format")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2014 text = _("Bad Format");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2015 } else if(xmlnode_get_child(packet, "bad-namespace-prefix")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2016 text = _("Bad Namespace Prefix");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2017 } else if(xmlnode_get_child(packet, "conflict")) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
2018 SET_REASON(PURPLE_CONNECTION_ERROR_NAME_IN_USE);
8402
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2019 text = _("Resource Conflict");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2020 } else if(xmlnode_get_child(packet, "connection-timeout")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2021 text = _("Connection Timeout");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2022 } else if(xmlnode_get_child(packet, "host-gone")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2023 text = _("Host Gone");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2024 } else if(xmlnode_get_child(packet, "host-unknown")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2025 text = _("Host Unknown");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2026 } else if(xmlnode_get_child(packet, "improper-addressing")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2027 text = _("Improper Addressing");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2028 } else if(xmlnode_get_child(packet, "internal-server-error")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2029 text = _("Internal Server Error");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2030 } else if(xmlnode_get_child(packet, "invalid-id")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2031 text = _("Invalid ID");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2032 } else if(xmlnode_get_child(packet, "invalid-namespace")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2033 text = _("Invalid Namespace");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2034 } else if(xmlnode_get_child(packet, "invalid-xml")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2035 text = _("Invalid XML");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2036 } else if(xmlnode_get_child(packet, "nonmatching-hosts")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2037 text = _("Non-matching Hosts");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2038 } else if(xmlnode_get_child(packet, "not-authorized")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2039 text = _("Not Authorized");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2040 } else if(xmlnode_get_child(packet, "policy-violation")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2041 text = _("Policy Violation");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2042 } else if(xmlnode_get_child(packet, "remote-connection-failed")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2043 text = _("Remote Connection Failed");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2044 } else if(xmlnode_get_child(packet, "resource-constraint")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2045 text = _("Resource Constraint");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2046 } else if(xmlnode_get_child(packet, "restricted-xml")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2047 text = _("Restricted XML");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2048 } else if(xmlnode_get_child(packet, "see-other-host")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2049 text = _("See Other Host");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2050 } else if(xmlnode_get_child(packet, "system-shutdown")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2051 text = _("System Shutdown");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2052 } else if(xmlnode_get_child(packet, "undefined-condition")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2053 text = _("Undefined Condition");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2054 } else if(xmlnode_get_child(packet, "unsupported-encoding")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2055 text = _("Unsupported Encoding");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2056 } else if(xmlnode_get_child(packet, "unsupported-stanza-type")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2057 text = _("Unsupported Stanza Type");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2058 } else if(xmlnode_get_child(packet, "unsupported-version")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2059 text = _("Unsupported Version");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2060 } else if(xmlnode_get_child(packet, "xml-not-well-formed")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2061 text = _("XML Not Well Formed");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2062 } else {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2063 text = _("Stream Error");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2064 }
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2065 }
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2066
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
2067 #undef SET_REASON
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
2068
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2069 if(text || cdata) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2070 char *ret = g_strdup_printf("%s%s%s", code ? code : "",
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2071 code ? ": " : "", text ? text : cdata);
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2072 g_free(cdata);
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2073 return ret;
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2074 } else {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2075 return NULL;
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2076 }
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2077 }
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2078
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2079 static PurpleCmdRet jabber_cmd_chat_config(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2080 const char *cmd, char **args, char **error, void *data)
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2081 {
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2082 JabberChat *chat = jabber_chat_find_by_conv(conv);
18986
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2083
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2084 if (!chat)
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2085 return PURPLE_CMD_RET_FAILED;
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2086
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2087 jabber_chat_request_room_configure(chat);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2088 return PURPLE_CMD_RET_OK;
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2089 }
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2090
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2091 static PurpleCmdRet jabber_cmd_chat_register(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2092 const char *cmd, char **args, char **error, void *data)
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2093 {
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2094 JabberChat *chat = jabber_chat_find_by_conv(conv);
18986
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2095
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2096 if (!chat)
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2097 return PURPLE_CMD_RET_FAILED;
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2098
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2099 jabber_chat_register(chat);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2100 return PURPLE_CMD_RET_OK;
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2101 }
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2102
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2103 static PurpleCmdRet jabber_cmd_chat_topic(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2104 const char *cmd, char **args, char **error, void *data)
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2105 {
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2106 JabberChat *chat = jabber_chat_find_by_conv(conv);
18986
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2107
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2108 if (!chat)
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2109 return PURPLE_CMD_RET_FAILED;
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2110
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2111 jabber_chat_change_topic(chat, args ? args[0] : NULL);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2112 return PURPLE_CMD_RET_OK;
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2113 }
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2114
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2115 static PurpleCmdRet jabber_cmd_chat_nick(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2116 const char *cmd, char **args, char **error, void *data)
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2117 {
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2118 JabberChat *chat = jabber_chat_find_by_conv(conv);
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2119
18986
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2120 if(!chat || !args || !args[0])
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2121 return PURPLE_CMD_RET_FAILED;
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2122
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2123 jabber_chat_change_nick(chat, args[0]);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2124 return PURPLE_CMD_RET_OK;
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2125 }
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2126
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2127 static PurpleCmdRet jabber_cmd_chat_part(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2128 const char *cmd, char **args, char **error, void *data)
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2129 {
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2130 JabberChat *chat = jabber_chat_find_by_conv(conv);
18986
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2131
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2132 if (!chat)
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2133 return PURPLE_CMD_RET_FAILED;
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2134
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2135 jabber_chat_part(chat, args ? args[0] : NULL);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2136 return PURPLE_CMD_RET_OK;
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2137 }
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2138
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2139 static PurpleCmdRet jabber_cmd_chat_ban(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2140 const char *cmd, char **args, char **error, void *data)
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2141 {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2142 JabberChat *chat = jabber_chat_find_by_conv(conv);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2143
18986
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2144 if(!chat || !args || !args[0])
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2145 return PURPLE_CMD_RET_FAILED;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2146
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2147 if(!jabber_chat_ban_user(chat, args[0], args[1])) {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2148 *error = g_strdup_printf(_("Unable to ban user %s"), args[0]);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2149 return PURPLE_CMD_RET_FAILED;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2150 }
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2151
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2152 return PURPLE_CMD_RET_OK;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2153 }
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2154
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2155 static PurpleCmdRet jabber_cmd_chat_affiliate(PurpleConversation *conv,
11393
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2156 const char *cmd, char **args, char **error, void *data)
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2157 {
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2158 JabberChat *chat = jabber_chat_find_by_conv(conv);
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2159
18986
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2160 if (!chat || !args || !args[0] || !args[1])
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2161 return PURPLE_CMD_RET_FAILED;
11393
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2162
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2163 if (strcmp(args[1], "owner") != 0 &&
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2164 strcmp(args[1], "admin") != 0 &&
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2165 strcmp(args[1], "member") != 0 &&
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2166 strcmp(args[1], "outcast") != 0 &&
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2167 strcmp(args[1], "none") != 0) {
11393
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2168 *error = g_strdup_printf(_("Unknown affiliation: \"%s\""), args[1]);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2169 return PURPLE_CMD_RET_FAILED;
11393
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2170 }
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2171
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2172 if (!jabber_chat_affiliate_user(chat, args[0], args[1])) {
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2173 *error = g_strdup_printf(_("Unable to affiliate user %s as \"%s\""), args[0], args[1]);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2174 return PURPLE_CMD_RET_FAILED;
11393
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2175 }
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2176
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2177 return PURPLE_CMD_RET_OK;
11393
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2178 }
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2179
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2180 static PurpleCmdRet jabber_cmd_chat_role(PurpleConversation *conv,
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2181 const char *cmd, char **args, char **error, void *data)
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2182 {
19217
ee1aa7e4c462 Fix uninitialized variable access.
Daniel Atallah <datallah@pidgin.im>
parents: 18986
diff changeset
2183 JabberChat *chat = jabber_chat_find_by_conv(conv);
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2184
18986
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2185 if (!chat || !args || !args[0] || !args[1])
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2186 return PURPLE_CMD_RET_FAILED;
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2187
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2188 if (strcmp(args[1], "moderator") != 0 &&
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2189 strcmp(args[1], "participant") != 0 &&
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2190 strcmp(args[1], "visitor") != 0 &&
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2191 strcmp(args[1], "none") != 0) {
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2192 *error = g_strdup_printf(_("Unknown role: \"%s\""), args[1]);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2193 return PURPLE_CMD_RET_FAILED;
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2194 }
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2195
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2196 if (!jabber_chat_role_user(chat, args[0], args[1])) {
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2197 *error = g_strdup_printf(_("Unable to set role \"%s\" for user: %s"),
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2198 args[1], args[0]);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2199 return PURPLE_CMD_RET_FAILED;
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2200 }
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2201
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2202 return PURPLE_CMD_RET_OK;
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2203 }
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2204
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2205 static PurpleCmdRet jabber_cmd_chat_invite(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2206 const char *cmd, char **args, char **error, void *data)
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2207 {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2208 if(!args || !args[0])
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2209 return PURPLE_CMD_RET_FAILED;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2210
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2211 jabber_chat_invite(purple_conversation_get_gc(conv),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2212 purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), args[1] ? args[1] : "",
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2213 args[0]);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2214
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2215 return PURPLE_CMD_RET_OK;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2216 }
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2217
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2218 static PurpleCmdRet jabber_cmd_chat_join(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2219 const char *cmd, char **args, char **error, void *data)
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2220 {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2221 JabberChat *chat = jabber_chat_find_by_conv(conv);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2222 GHashTable *components;
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2223
18986
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2224 if(!chat || !args || !args[0])
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2225 return PURPLE_CMD_RET_FAILED;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2226
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2227 components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2228
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2229 g_hash_table_replace(components, "room", args[0]);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2230 g_hash_table_replace(components, "server", chat->server);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2231 g_hash_table_replace(components, "handle", chat->handle);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2232 if(args[1])
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2233 g_hash_table_replace(components, "password", args[1]);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2234
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2235 jabber_chat_join(purple_conversation_get_gc(conv), components);
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2236
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2237 g_hash_table_destroy(components);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2238 return PURPLE_CMD_RET_OK;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2239 }
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2240
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2241 static PurpleCmdRet jabber_cmd_chat_kick(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2242 const char *cmd, char **args, char **error, void *data)
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2243 {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2244 JabberChat *chat = jabber_chat_find_by_conv(conv);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2245
18986
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2246 if(!chat || !args || !args[0])
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2247 return PURPLE_CMD_RET_FAILED;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2248
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2249 if(!jabber_chat_kick_user(chat, args[0], args[1])) {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2250 *error = g_strdup_printf(_("Unable to kick user %s"), args[0]);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2251 return PURPLE_CMD_RET_FAILED;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2252 }
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2253
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2254 return PURPLE_CMD_RET_OK;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2255 }
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2256
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2257 static PurpleCmdRet jabber_cmd_chat_msg(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2258 const char *cmd, char **args, char **error, void *data)
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2259 {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2260 JabberChat *chat = jabber_chat_find_by_conv(conv);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2261 char *who;
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2262
18986
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2263 if (!chat)
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2264 return PURPLE_CMD_RET_FAILED;
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2265
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2266 who = g_strdup_printf("%s@%s/%s", chat->room, chat->server, args[0]);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2267
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2268 jabber_message_send_im(purple_conversation_get_gc(conv), who, args[1], 0);
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2269
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2270 g_free(who);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2271 return PURPLE_CMD_RET_OK;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2272 }
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2273
17769
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
2274 static PurpleCmdRet jabber_cmd_ping(PurpleConversation *conv,
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
2275 const char *cmd, char **args, char **error, void *data)
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
2276 {
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
2277 if(!args || !args[0])
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
2278 return PURPLE_CMD_RET_FAILED;
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
2279
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
2280 if(!jabber_ping_jid(conv, args[0])) {
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
2281 *error = g_strdup_printf(_("Unable to ping user %s"), args[0]);
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
2282 return PURPLE_CMD_RET_FAILED;
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
2283 }
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
2284
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
2285 return PURPLE_CMD_RET_OK;
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
2286 }
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
2287
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2288 static gboolean _jabber_send_buzz(JabberStream *js, const char *username, char **error) {
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2289
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2290 JabberBuddy *jb;
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2291 JabberBuddyResource *jbr;
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2292 GList *iter;
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2293
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2294 if(!username)
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2295 return FALSE;
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2296
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2297 jb = jabber_buddy_find(js, username, FALSE);
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2298 if(!jb) {
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2299 *error = g_strdup_printf(_("Unable to buzz, because there is nothing known about user %s."), username);
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2300 return FALSE;
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2301 }
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2302
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2303 jbr = jabber_buddy_find_resource(jb, NULL);
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2304 if(!jbr) {
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2305 *error = g_strdup_printf(_("Unable to buzz, because user %s might be offline."), username);
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2306 return FALSE;
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2307 }
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2308
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2309 if(!jbr->caps) {
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2310 *error = g_strdup_printf(_("Unable to buzz, because there is nothing known about user %s."), username);
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2311 return FALSE;
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2312 }
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2313
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2314 for(iter = jbr->caps->features; iter; iter = g_list_next(iter)) {
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2315 if(!strcmp(iter->data, "http://www.xmpp.org/extensions/xep-0224.html#ns")) {
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2316 xmlnode *buzz, *msg = xmlnode_new("message");
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2317 gchar *to;
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2318
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2319 to = g_strdup_printf("%s/%s", username, jbr->name);
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2320 xmlnode_set_attrib(msg, "to", to);
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2321 g_free(to);
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2322
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2323 /* avoid offline storage */
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2324 xmlnode_set_attrib(msg, "type", "headline");
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2325
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2326 buzz = xmlnode_new_child(msg, "attention");
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2327 xmlnode_set_namespace(buzz, "http://www.xmpp.org/extensions/xep-0224.html#ns");
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2328
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2329 jabber_send(js, msg);
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2330 xmlnode_free(msg);
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2331
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2332 return TRUE;
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2333 }
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2334 }
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2335
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2336 *error = g_strdup_printf(_("Unable to buzz, because the user %s does not support it."), username);
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2337 return FALSE;
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2338 }
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2339
17822
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
2340 static PurpleCmdRet jabber_cmd_buzz(PurpleConversation *conv,
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
2341 const char *cmd, char **args, char **error, void *data)
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
2342 {
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
2343 JabberStream *js = conv->account->gc->proto_data;
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
2344
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
2345 if(!args || !args[0])
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
2346 return PURPLE_CMD_RET_FAILED;
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2347
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2348 return _jabber_send_buzz(js, args[0], error) ? PURPLE_CMD_RET_OK : PURPLE_CMD_RET_FAILED;
17822
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
2349 }
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
2350
20401
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2351 GList *jabber_attention_types(PurpleAccount *account)
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2352 {
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2353 static GList *types = NULL;
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2354
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2355 if (!types) {
22225
6cd802a8c5ad This adds accessor and mutator API for the PurpleAttentionType struct.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22155
diff changeset
2356 types = g_list_append(types, purple_attention_type_new("Buzz", _("Buzz"),
6cd802a8c5ad This adds accessor and mutator API for the PurpleAttentionType struct.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22155
diff changeset
2357 _("%s has buzzed you!"), _("Buzzing %s...")));
20401
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2358 }
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2359
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2360 return types;
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2361 }
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2362
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2363 gboolean jabber_send_attention(PurpleConnection *gc, const char *username, guint code)
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2364 {
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2365 JabberStream *js = gc->proto_data;
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2366 gchar *error = NULL;
20401
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2367
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2368 if (!_jabber_send_buzz(js, username, &error)) {
20401
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2369 purple_debug_error("jabber", "jabber_send_attention: jabber_cmd_buzz failed with error: %s\n", error ? error : "(NULL)");
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2370 g_free(error);
20401
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2371 return FALSE;
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2372 }
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2373
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
2374 return TRUE;
20401
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2375 }
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2376
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
2377
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
2378 gboolean jabber_offline_message(const PurpleBuddy *buddy)
12645
a907ba243930 [gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12600
diff changeset
2379 {
a907ba243930 [gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12600
diff changeset
2380 return TRUE;
a907ba243930 [gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12600
diff changeset
2381 }
a907ba243930 [gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12600
diff changeset
2382
23704
9b88c9b23aed Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents: 23701
diff changeset
2383 #ifdef USE_VV
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2384
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2385 static void
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2386 jabber_session_send_accept(JingleSession *session)
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2387 {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2388 JabberIq *result = jabber_iq_new(jabber_jingle_session_get_js(session),
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2389 JABBER_IQ_SET);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2390 xmlnode *jingle = jabber_jingle_session_create_session_accept(session);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2391 xmlnode_set_attrib(result->node, "to",
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2392 jabber_jingle_session_get_remote_jid(session));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2393
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2394 xmlnode_insert_child(result->node, jingle);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2395 jabber_iq_send(result);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2396 purple_debug_info("jabber", "Sent session accept, starting stream\n");
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2397 gst_element_set_state(purple_media_get_audio_pipeline(session->media), GST_STATE_PLAYING);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2398
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2399 session->session_started = TRUE;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2400 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2401
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2402 static void
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2403 jabber_session_send_content_accept(JingleSession *session)
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2404 {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2405 JabberIq *result = jabber_iq_new(jabber_jingle_session_get_js(session),
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2406 JABBER_IQ_SET);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2407 xmlnode *jingle = jabber_jingle_session_create_content_accept(session);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2408 xmlnode_set_attrib(result->node, "to",
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2409 jabber_jingle_session_get_remote_jid(session));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2410
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2411 xmlnode_insert_child(result->node, jingle);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2412 jabber_iq_send(result);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2413 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2414
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2415 static void
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2416 jabber_session_send_reject(JingleSession *session)
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2417 {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2418 JabberIq *result = jabber_iq_new(jabber_jingle_session_get_js(session),
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2419 JABBER_IQ_SET);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2420 xmlnode *jingle = jabber_jingle_session_create_terminate(session,
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2421 "decline", NULL);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2422 xmlnode_set_attrib(result->node, "to",
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2423 jabber_jingle_session_get_remote_jid(session));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2424 xmlnode_insert_child(result->node, jingle);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2425 jabber_iq_send(result);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2426 jabber_jingle_session_destroy(session);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2427 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2428
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2429 static void
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2430 jabber_session_send_terminate(JingleSession *session)
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2431 {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2432 JabberIq *result = jabber_iq_new(jabber_jingle_session_get_js(session),
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2433 JABBER_IQ_SET);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2434 xmlnode *jingle = jabber_jingle_session_create_terminate(session,
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2435 "no-error", NULL);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2436 xmlnode_set_attrib(result->node, "to",
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2437 jabber_jingle_session_get_remote_jid(session));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2438 xmlnode_insert_child(result->node, jingle);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2439 jabber_iq_send(result);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2440 jabber_jingle_session_destroy(session);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2441 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2442
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2443 /* callback called when new local transport candidate(s) are available on the
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2444 Farsight stream */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2445 static void
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2446 jabber_session_candidates_prepared(PurpleMedia *media, JingleSession *session)
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2447 {
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2448 if (!jabber_jingle_session_is_initiator(session)) {
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2449 /* create transport-info package */
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2450 JabberIq *result = jabber_iq_new(jabber_jingle_session_get_js(session),
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2451 JABBER_IQ_SET);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2452 xmlnode *jingle = jabber_jingle_session_create_transport_info(session);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2453 purple_debug_info("jabber", "jabber_session_candidates_prepared: %d candidates\n",
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2454 g_list_length(purple_media_get_local_audio_candidates(session->media)));
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2455 xmlnode_set_attrib(result->node, "to",
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2456 jabber_jingle_session_get_remote_jid(session));
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2457
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2458 xmlnode_insert_child(result->node, jingle);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2459 jabber_iq_send(result);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2460 }
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2461 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2462
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2463 /* callback called when a pair of transport candidates (local and remote)
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2464 has been established */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2465 static void
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2466 jabber_session_candidate_pair_established(PurpleMedia *media,
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2467 FsCandidate *native_candidate,
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2468 FsCandidate *remote_candidate,
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2469 JingleSession *session)
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2470 {
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2471 purple_debug_info("jabber", "jabber_candidate_pair_established called\n");
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2472 /* if we are the initiator, we should send a content-modify message */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2473 if (jabber_jingle_session_is_initiator(session)) {
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2474 JabberIq *result;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2475 xmlnode *jingle;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2476
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2477 purple_debug_info("jabber", "we are the initiator, let's send content-modify\n");
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2478
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2479 result = jabber_iq_new(jabber_jingle_session_get_js(session), JABBER_IQ_SET);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2480
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2481 /* shall change this to a "content-replace" */
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2482 jingle =
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2483 jabber_jingle_session_create_content_replace(session,
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2484 native_candidate,
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2485 remote_candidate);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2486 xmlnode_set_attrib(result->node, "to",
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2487 jabber_jingle_session_get_remote_jid(session));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2488 xmlnode_insert_child(result->node, jingle);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2489 jabber_iq_send(result);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2490 }
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2491 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2492
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2493 static gboolean
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2494 jabber_initiate_media_internal(JingleSession *session, const char *initiator, const char *remote_jid)
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2495 {
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2496 PurpleMedia *media = NULL;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2497
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2498 media = purple_media_manager_create_media(purple_media_manager_get(),
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2499 session->js->gc, "fsrtpconference", remote_jid);
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2500
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2501 if (!media) {
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2502 purple_debug_error("jabber", "Couldn't create fsrtpconference\n");
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2503 return FALSE;
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2504 }
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2505
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2506 /* this will need to be changed to "nice" once the libnice transmitter is finished */
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2507 if (!purple_media_add_stream(media, remote_jid, PURPLE_MEDIA_AUDIO, "rawudp")) {
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2508 purple_debug_error("jabber", "Couldn't create audio stream\n");
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2509 purple_media_reject(media);
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2510 return FALSE;
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2511 }
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2512
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2513 jabber_jingle_session_set_remote_jid(session, remote_jid);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2514 jabber_jingle_session_set_initiator(session, initiator);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2515 jabber_jingle_session_set_media(session, media);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2516
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2517 /* connect callbacks */
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2518 g_signal_connect_swapped(G_OBJECT(media), "accepted",
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2519 G_CALLBACK(jabber_session_send_accept), session);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2520 g_signal_connect_swapped(G_OBJECT(media), "reject",
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2521 G_CALLBACK(jabber_session_send_reject), session);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2522 g_signal_connect_swapped(G_OBJECT(media), "hangup",
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2523 G_CALLBACK(jabber_session_send_terminate), session);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2524 g_signal_connect(G_OBJECT(media), "candidates-prepared",
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2525 G_CALLBACK(jabber_session_candidates_prepared), session);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2526 g_signal_connect(G_OBJECT(media), "candidate-pair",
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2527 G_CALLBACK(jabber_session_candidate_pair_established), session);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2528
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2529 purple_media_ready(media);
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2530
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2531 return TRUE;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2532 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2533
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2534 static void
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2535 jabber_session_initiate_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2536 {
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2537 const char *from = xmlnode_get_attrib(packet, "from");
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2538 JingleSession *session = jabber_jingle_session_find_by_jid(js, from);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2539 PurpleMedia *media = session->media;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2540 JabberIq *result;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2541 xmlnode *jingle;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2542
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2543 if (!strcmp(xmlnode_get_attrib(packet, "type"), "error")) {
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2544 purple_media_got_hangup(media);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2545 return;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2546 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2547
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2548 /* catch errors */
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2549 if (xmlnode_get_child(packet, "error")) {
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2550 purple_media_got_hangup(media);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2551 return;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2552 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2553
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2554 /* create transport-info package */
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2555 result = jabber_iq_new(jabber_jingle_session_get_js(session), JABBER_IQ_SET);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2556 jingle = jabber_jingle_session_create_transport_info(session);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2557 purple_debug_info("jabber", "jabber_session_candidates_prepared: %d candidates\n",
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2558 g_list_length(purple_media_get_local_audio_candidates(session->media)));
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2559 xmlnode_set_attrib(result->node, "to",
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2560 jabber_jingle_session_get_remote_jid(session));
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2561
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2562 xmlnode_insert_child(result->node, jingle);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2563 jabber_iq_send(result);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2564 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2565
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2566 PurpleMedia *
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2567 jabber_initiate_media(PurpleConnection *gc, const char *who,
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2568 PurpleMediaStreamType type)
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2569 {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2570 /* create content negotiation */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2571 JabberStream *js = gc->proto_data;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2572 JabberIq *request = jabber_iq_new(js, JABBER_IQ_SET);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2573 xmlnode *jingle, *content, *description, *transport;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2574 GList *codecs;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2575 JingleSession *session;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2576 JabberBuddy *jb;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2577 JabberBuddyResource *jbr;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2578
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2579 char *jid = NULL, *me = NULL;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2580
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2581 /* construct JID to send to */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2582 jb = jabber_buddy_find(js, who, FALSE);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2583 if (!jb) {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2584 purple_debug_error("jabber", "Could not find Jabber buddy\n");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2585 return NULL;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2586 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2587 jbr = jabber_buddy_find_resource(jb, NULL);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2588 if (!jbr) {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2589 purple_debug_error("jabber", "Could not find buddy's resource\n");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2590 }
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2591
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2592 if ((strchr(who, '/') == NULL) && jbr && (jbr->name != NULL)) {
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2593 jid = g_strdup_printf("%s/%s", who, jbr->name);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2594 } else {
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2595 jid = g_strdup(who);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2596 }
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2597
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2598 session = jabber_jingle_session_create(js);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2599 /* set ourselves as initiator */
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2600 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, js->user->resource);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2601
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2602 if (!jabber_initiate_media_internal(session, me, jid)) {
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2603 g_free(jid);
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2604 g_free(me);
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2605 jabber_jingle_session_destroy(session);
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2606 return NULL;
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2607 }
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2608
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2609 g_free(jid);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2610 g_free(me);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2611
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2612 codecs = purple_media_get_local_audio_codecs(session->media);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2613
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2614 /* create request */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2615
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2616 xmlnode_set_attrib(request->node, "to",
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2617 jabber_jingle_session_get_remote_jid(session));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2618 jingle = xmlnode_new_child(request->node, "jingle");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2619 xmlnode_set_namespace(jingle, "urn:xmpp:tmp:jingle");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2620 xmlnode_set_attrib(jingle, "action", "session-initiate");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2621 /* get our JID and a session id... */
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2622 xmlnode_set_attrib(jingle, "initiator", jabber_jingle_session_get_initiator(session));
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2623 xmlnode_set_attrib(jingle, "sid", jabber_jingle_session_get_id(session));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2624
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2625 content = xmlnode_new_child(jingle, "content");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2626 xmlnode_set_attrib(content, "name", "audio-content");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2627 xmlnode_set_attrib(content, "profile", "RTP/AVP");
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2628
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2629 description = jabber_jingle_session_create_description(session);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2630 xmlnode_insert_child(content, description);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2631
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2632 transport = xmlnode_new_child(content, "transport");
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2633 xmlnode_set_namespace(transport, "urn:xmpp:tmp:jingle:transports:ice-udp");
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2634
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2635 jabber_iq_set_callback(request, jabber_session_initiate_result_cb, NULL);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2636
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2637 /* send request to other part */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2638 jabber_iq_send(request);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2639
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2640 fs_codec_list_destroy(codecs);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2641
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2642 return session->media;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2643 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2644
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2645 gboolean jabber_can_do_media(PurpleConnection *gc, const char *who,
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2646 PurpleMediaStreamType type)
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2647 {
23714
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2648 JabberStream *js = (JabberStream *) gc->proto_data;
23715
0844f5e9ac8e Fix crash bug when checking if a contact can do media when logging out.
Michael Ruprecht <maiku@pidgin.im>
parents: 23714
diff changeset
2649 JabberBuddy *jb;
0844f5e9ac8e Fix crash bug when checking if a contact can do media when logging out.
Michael Ruprecht <maiku@pidgin.im>
parents: 23714
diff changeset
2650
0844f5e9ac8e Fix crash bug when checking if a contact can do media when logging out.
Michael Ruprecht <maiku@pidgin.im>
parents: 23714
diff changeset
2651 if (!js) {
0844f5e9ac8e Fix crash bug when checking if a contact can do media when logging out.
Michael Ruprecht <maiku@pidgin.im>
parents: 23714
diff changeset
2652 purple_debug_error("jabber", "jabber_can_do_media: NULL stream\n");
0844f5e9ac8e Fix crash bug when checking if a contact can do media when logging out.
Michael Ruprecht <maiku@pidgin.im>
parents: 23714
diff changeset
2653 return FALSE;
0844f5e9ac8e Fix crash bug when checking if a contact can do media when logging out.
Michael Ruprecht <maiku@pidgin.im>
parents: 23714
diff changeset
2654 }
0844f5e9ac8e Fix crash bug when checking if a contact can do media when logging out.
Michael Ruprecht <maiku@pidgin.im>
parents: 23714
diff changeset
2655
0844f5e9ac8e Fix crash bug when checking if a contact can do media when logging out.
Michael Ruprecht <maiku@pidgin.im>
parents: 23714
diff changeset
2656 jb = jabber_buddy_find(js, who, FALSE);
0844f5e9ac8e Fix crash bug when checking if a contact can do media when logging out.
Michael Ruprecht <maiku@pidgin.im>
parents: 23714
diff changeset
2657
23714
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2658 if (!jb) {
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2659 purple_debug_error("jabber", "Could not find buddy\n");
23712
a775dab7e038 Create a proper media menu with options for audio, video, and
Michael Ruprecht <maiku@pidgin.im>
parents: 23710
diff changeset
2660 return FALSE;
23714
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2661 }
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2662 #if 0 /* These can be added once we support video */
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2663 /* XMPP will only support two-way media, AFAIK... */
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2664 if (type == (PURPLE_MEDIA_AUDIO | PURPLE_MEDIA_VIDEO)) {
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2665 purple_debug_info("jabber",
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2666 "Checking audio/video XEP support for %s\n", who);
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2667 return (jabber_buddy_has_capability(jb, XEP_0167_CAP) ||
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2668 jabber_buddy_has_capability(jb, GTALK_CAP)) &&
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2669 jabber_buddy_has_capability(jb, XEP_0180_CAP);
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2670 } else
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2671 #endif
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2672 if (type == (PURPLE_MEDIA_AUDIO)) {
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2673 purple_debug_info("jabber",
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2674 "Checking audio XEP support for %s\n", who);
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2675 return jabber_buddy_has_capability(jb, XEP_0167_CAP) ||
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2676 jabber_buddy_has_capability(jb, GTALK_CAP);
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2677 }
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2678 #if 0
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2679 else if (type == (PURPLE_MEDIA_VIDEO)) {
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2680 purple_debug_info("jabber",
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2681 "Checking video XEP support for %s\n", who);
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2682 return jabber_buddy_has_capability(jb, XEP_0180_CAP);
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2683 }
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2684 #endif
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
2685 return FALSE;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2686 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2687
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2688
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2689 void
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2690 jabber_handle_session_accept(JabberStream *js, xmlnode *packet)
19882
d8c2a2fc1fbf Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents: 19217
diff changeset
2691 {
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2692 JabberIq *result = jabber_iq_new(js, JABBER_IQ_RESULT);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2693 xmlnode *jingle = xmlnode_get_child(packet, "jingle");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2694 xmlnode *content = xmlnode_get_child(jingle, "content");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2695 const char *sid = xmlnode_get_attrib(jingle, "sid");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2696 const char *action = xmlnode_get_attrib(jingle, "action");
23698
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
2697 JingleSession *session = jabber_jingle_session_find_by_id(js, sid);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2698 GList *remote_codecs = NULL;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2699 GList *remote_transports = NULL;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2700 GList *codec_intersection;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2701 FsCodec *top = NULL;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2702 xmlnode *description = NULL;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2703 xmlnode *transport = NULL;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2704
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2705 /* We should probably check validity of the incoming XML... */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2706
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2707 xmlnode_set_attrib(result->node, "to",
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2708 jabber_jingle_session_get_remote_jid(session));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2709 jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id"));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2710
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2711 description = xmlnode_get_child(content, "description");
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2712 transport = xmlnode_get_child(content, "transport");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2713
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2714 /* fetch codecs from remote party */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2715 purple_debug_info("jabber", "get codecs from session-accept\n");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2716 remote_codecs = jabber_jingle_get_codecs(description);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2717 purple_debug_info("jabber", "get transport candidates from session accept\n");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2718 remote_transports = jabber_jingle_get_candidates(transport);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2719
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2720 purple_debug_info("jabber", "Got %d codecs from responder\n",
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2721 g_list_length(remote_codecs));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2722 purple_debug_info("jabber", "Got %d transport candidates from responder\n",
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2723 g_list_length(remote_transports));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2724
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2725 purple_debug_info("jabber", "Setting remote codecs on stream\n");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2726
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2727 purple_media_set_remote_audio_codecs(session->media,
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2728 jabber_jingle_session_get_remote_jid(session),
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2729 remote_codecs);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2730
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2731 codec_intersection = purple_media_get_negotiated_audio_codecs(session->media);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2732 purple_debug_info("jabber", "codec_intersection contains %d elems\n",
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2733 g_list_length(codec_intersection));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2734 /* get the top codec */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2735 if (g_list_length(codec_intersection) > 0) {
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2736 top = (FsCodec *) codec_intersection->data;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2737 purple_debug_info("jabber", "Found a suitable codec on stream = %d\n",
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2738 top->id);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2739
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2740 /* we have found a suitable codec, but we will not start the stream
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2741 just yet, wait for transport negotiation to complete... */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2742 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2743 /* if we also got transport candidates, add them to our streams
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2744 list of known remote candidates */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2745 if (g_list_length(remote_transports) > 0) {
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2746 purple_media_add_remote_audio_candidates(session->media,
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2747 jabber_jingle_session_get_remote_jid(session),
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2748 remote_transports);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2749 fs_candidate_list_destroy(remote_transports);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2750 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2751 if (g_list_length(codec_intersection) == 0 &&
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2752 g_list_length(remote_transports)) {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2753 /* we didn't get any candidates and the codec intersection is empty,
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2754 this means this was not a content-accept message and we couldn't
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2755 find any suitable codecs, should return error and hang up */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2756
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2757 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2758
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2759 g_list_free(codec_intersection);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2760
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2761 if (!strcmp(action, "session-accept")) {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2762 purple_media_got_accept(jabber_jingle_session_get_media(session));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2763 purple_debug_info("jabber", "Got session-accept, starting stream\n");
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2764 gst_element_set_state(purple_media_get_audio_pipeline(session->media), GST_STATE_PLAYING);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2765 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2766
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2767 jabber_iq_send(result);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2768
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2769 session->session_started = TRUE;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2770 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2771
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2772 void
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2773 jabber_handle_session_terminate(JabberStream *js, xmlnode *packet)
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2774 {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2775 JabberIq *result = jabber_iq_new(js, JABBER_IQ_SET);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2776 xmlnode *jingle = xmlnode_get_child(packet, "jingle");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2777 const char *sid = xmlnode_get_attrib(jingle, "sid");
23698
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
2778 JingleSession *session = jabber_jingle_session_find_by_id(js, sid);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2779
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2780 if(!session) {
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2781 purple_debug_error("jabber", "jabber_handle_session_terminate couldn't find session\n");
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2782 return;
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2783 }
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2784
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2785 xmlnode_set_attrib(result->node, "to",
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2786 jabber_jingle_session_get_remote_jid(session));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2787 xmlnode_set_attrib(result->node, "id", xmlnode_get_attrib(packet, "id"));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2788
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2789
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2790
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2791 /* maybe we should look at the reasoncode to determine if it was
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2792 a hangup or a reject, and call different callbacks to purple_media */
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2793 gst_element_set_state(purple_media_get_audio_pipeline(session->media), GST_STATE_NULL);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2794
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2795 purple_media_got_hangup(jabber_jingle_session_get_media(session));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2796 jabber_iq_send(result);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2797 jabber_jingle_session_destroy(session);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2798 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2799
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2800 void
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2801 jabber_handle_session_candidates(JabberStream *js, xmlnode *packet)
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2802 {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2803 JabberIq *result = jabber_iq_new(js, JABBER_IQ_RESULT);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2804 xmlnode *jingle = xmlnode_get_child(packet, "jingle");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2805 xmlnode *content = xmlnode_get_child(jingle, "content");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2806 xmlnode *transport = xmlnode_get_child(content, "transport");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2807 GList *remote_candidates = jabber_jingle_get_candidates(transport);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2808 const char *sid = xmlnode_get_attrib(jingle, "sid");
23698
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
2809 JingleSession *session = jabber_jingle_session_find_by_id(js, sid);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2810
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2811 if(!session)
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2812 purple_debug_error("jabber", "jabber_handle_session_candidates couldn't find session\n");
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2813
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2814 /* send acknowledement */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2815 xmlnode_set_attrib(result->node, "id", xmlnode_get_attrib(packet, "id"));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2816 xmlnode_set_attrib(result->node, "to", xmlnode_get_attrib(packet, "from"));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2817 jabber_iq_send(result);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2818
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2819 /* add candidates to our list of remote candidates */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2820 if (g_list_length(remote_candidates) > 0) {
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2821 purple_media_add_remote_audio_candidates(session->media,
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2822 xmlnode_get_attrib(packet, "from"),
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2823 remote_candidates);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2824 fs_candidate_list_destroy(remote_candidates);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2825 }
19882
d8c2a2fc1fbf Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents: 19217
diff changeset
2826 }
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2827
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2828 /* change this to content-replace */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2829 void
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2830 jabber_handle_session_content_replace(JabberStream *js, xmlnode *packet)
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2831 {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2832 xmlnode *jingle = xmlnode_get_child(packet, "jingle");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2833 const char *sid = xmlnode_get_attrib(jingle, "sid");
23698
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
2834 JingleSession *session = jabber_jingle_session_find_by_id(js, sid);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2835
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2836 if (!jabber_jingle_session_is_initiator(session) && session->session_started) {
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2837 JabberIq *result = jabber_iq_new(js, JABBER_IQ_RESULT);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2838 JabberIq *accept = jabber_iq_new(js, JABBER_IQ_SET);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2839 xmlnode *content_accept = NULL;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2840
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2841 /* send acknowledement */
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2842 xmlnode_set_attrib(result->node, "id", xmlnode_get_attrib(packet, "id"));
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2843 xmlnode_set_attrib(result->node, "to", xmlnode_get_attrib(packet, "from"));
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2844 jabber_iq_send(result);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2845
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2846 /* send content-accept */
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2847 content_accept = jabber_jingle_session_create_content_accept(session);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2848 xmlnode_set_attrib(accept->node, "id", xmlnode_get_attrib(packet, "id"));
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2849 xmlnode_set_attrib(accept->node, "to", xmlnode_get_attrib(packet, "from"));
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2850 xmlnode_insert_child(accept->node, content_accept);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2851
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2852 jabber_iq_send(accept);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2853 }
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2854 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2855
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2856 void
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2857 jabber_handle_session_initiate(JabberStream *js, xmlnode *packet)
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2858 {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2859 JingleSession *session = NULL;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2860 xmlnode *jingle = xmlnode_get_child(packet, "jingle");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2861 xmlnode *content = NULL;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2862 xmlnode *description = NULL;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2863 const char *sid = NULL;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2864 const char *initiator = NULL;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2865 GList *codecs = NULL;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2866 JabberIq *result = NULL;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2867
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2868 if (!jingle) {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2869 purple_debug_error("jabber", "Malformed request");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2870 return;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2871 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2872
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2873 sid = xmlnode_get_attrib(jingle, "sid");
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2874 initiator = xmlnode_get_attrib(jingle, "initiator");
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2875
23698
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
2876 if (jabber_jingle_session_find_by_id(js, sid)) {
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2877 /* This should only happen if you start a session with yourself */
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2878 purple_debug_error("jabber", "Jingle session with id={%s} already exists\n", sid);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2879 return;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2880 }
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2881 session = jabber_jingle_session_create_by_id(js, sid);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2882
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2883 /* init media */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2884 content = xmlnode_get_child(jingle, "content");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2885 if (!content) {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2886 purple_debug_error("jabber", "jingle tag must contain content tag\n");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2887 /* should send error here */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2888 return;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2889 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2890
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2891 description = xmlnode_get_child(content, "description");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2892
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2893 if (!description) {
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2894 purple_debug_error("jabber", "content tag must contain description tag\n");
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2895 /* we should create an error iq here */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2896 return;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2897 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2898
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2899 if (!jabber_initiate_media_internal(session, initiator, initiator)) {
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2900 purple_debug_error("jabber", "Couldn't start media session with %s\n", initiator);
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2901 jabber_jingle_session_destroy(session);
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2902 /* we should create an error iq here */
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2903 return;
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
2904 }
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2905
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2906 codecs = jabber_jingle_get_codecs(description);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2907
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
2908 purple_media_set_remote_audio_codecs(session->media, initiator, codecs);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2909
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2910 result = jabber_iq_new(js, JABBER_IQ_RESULT);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2911 jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id"));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2912 xmlnode_set_attrib(result->node, "to", xmlnode_get_attrib(packet, "from"));
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2913 jabber_iq_send(result);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2914 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
2915
22075
085f38d188de Fix some compilation problems when USE_FARSIGHT isn't defined.
Evan Schoenberg <evands@pidgin.im>
parents: 22069
diff changeset
2916 #endif
19882
d8c2a2fc1fbf Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents: 19217
diff changeset
2917
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
2918 void jabber_register_commands(void)
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2919 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2920 purple_cmd_register("config", "", PURPLE_CMD_P_PRPL,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2921 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2922 "prpl-jabber", jabber_cmd_chat_config,
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2923 _("config: Configure a chat room."), NULL);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2924 purple_cmd_register("configure", "", PURPLE_CMD_P_PRPL,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2925 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2926 "prpl-jabber", jabber_cmd_chat_config,
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2927 _("configure: Configure a chat room."), NULL);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2928 purple_cmd_register("nick", "s", PURPLE_CMD_P_PRPL,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2929 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2930 "prpl-jabber", jabber_cmd_chat_nick,
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2931 _("nick &lt;new nickname&gt;: Change your nickname."),
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2932 NULL);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2933 purple_cmd_register("part", "s", PURPLE_CMD_P_PRPL,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2934 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2935 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2936 jabber_cmd_chat_part, _("part [room]: Leave the room."),
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2937 NULL);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2938 purple_cmd_register("register", "", PURPLE_CMD_P_PRPL,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2939 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2940 "prpl-jabber", jabber_cmd_chat_register,
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2941 _("register: Register with a chat room."), NULL);
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2942 /* XXX: there needs to be a core /topic cmd, methinks */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2943 purple_cmd_register("topic", "s", PURPLE_CMD_P_PRPL,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2944 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2945 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2946 jabber_cmd_chat_topic,
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2947 _("topic [new topic]: View or change the topic."),
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2948 NULL);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2949 purple_cmd_register("ban", "ws", PURPLE_CMD_P_PRPL,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2950 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2951 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2952 jabber_cmd_chat_ban,
22759
1ab25e736b3d Correct some help strings for Jabber slash commands
Mark Doliner <markdoliner@pidgin.im>
parents: 22587
diff changeset
2953 _("ban &lt;user&gt; [reason]: Ban a user from the room."),
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2954 NULL);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2955 purple_cmd_register("affiliate", "ws", PURPLE_CMD_P_PRPL,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2956 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2957 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2958 jabber_cmd_chat_affiliate,
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2959 _("affiliate &lt;user&gt; &lt;owner|admin|member|outcast|none&gt;: Set a user's affiliation with the room."),
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2960 NULL);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2961 purple_cmd_register("role", "ws", PURPLE_CMD_P_PRPL,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2962 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2963 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2964 jabber_cmd_chat_role,
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2965 _("role &lt;user&gt; &lt;moderator|participant|visitor|none&gt;: Set a user's role in the room."),
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2966 NULL);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2967 purple_cmd_register("invite", "ws", PURPLE_CMD_P_PRPL,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2968 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2969 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2970 jabber_cmd_chat_invite,
11158
2660ab8f8a14 [gaim-migrate @ 13245]
Etan Reisner <deryni@pidgin.im>
parents: 11033
diff changeset
2971 _("invite &lt;user&gt; [message]: Invite a user to the room."),
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2972 NULL);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2973 purple_cmd_register("join", "ws", PURPLE_CMD_P_PRPL,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2974 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2975 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2976 jabber_cmd_chat_join,
22759
1ab25e736b3d Correct some help strings for Jabber slash commands
Mark Doliner <markdoliner@pidgin.im>
parents: 22587
diff changeset
2977 _("join: &lt;room&gt; [password]: Join a chat on this server."),
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2978 NULL);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2979 purple_cmd_register("kick", "ws", PURPLE_CMD_P_PRPL,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2980 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2981 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2982 jabber_cmd_chat_kick,
22759
1ab25e736b3d Correct some help strings for Jabber slash commands
Mark Doliner <markdoliner@pidgin.im>
parents: 22587
diff changeset
2983 _("kick &lt;user&gt; [reason]: Kick a user from the room."),
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2984 NULL);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2985 purple_cmd_register("msg", "ws", PURPLE_CMD_P_PRPL,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2986 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2987 "prpl-jabber", jabber_cmd_chat_msg,
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2988 _("msg &lt;user&gt; &lt;message&gt;: Send a private message to another user."),
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2989 NULL);
17769
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
2990 purple_cmd_register("ping", "w", PURPLE_CMD_P_PRPL,
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
2991 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM |
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
2992 PURPLE_CMD_FLAG_PRPL_ONLY,
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
2993 "prpl-jabber", jabber_cmd_ping,
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
2994 _("ping &lt;jid&gt;: Ping a user/component/server."),
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
2995 NULL);
17822
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
2996 purple_cmd_register("buzz", "s", PURPLE_CMD_P_PRPL,
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
2997 PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PRPL_ONLY,
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
2998 "prpl-jabber", jabber_cmd_buzz,
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
2999 _("buzz: Buzz a user to get their attention"), NULL);
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
3000 }
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
3001
16302
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
3002 void
eb633ebf84f2 This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents: 16180
diff changeset
3003 jabber_init_plugin(PurplePlugin *plugin)
14358
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
3004 {
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
3005 my_protocol = plugin;
14358
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
3006 }

mercurial