libpurple/protocols/jabber/jabber.c

Tue, 10 Sep 2013 22:32:40 +0200

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Tue, 10 Sep 2013 22:32:40 +0200
changeset 34332
876483829700
parent 34304
faf0414a8b51
child 34338
c652670afac5
permissions
-rw-r--r--

Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters

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 *
28322
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28266
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28266
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28266
diff changeset
6 * source distribution.
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
7 *
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
9 * 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
10 * the Free Software Foundation; either version 2 of the License, or
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
11 * (at your option) any later version.
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
12 *
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
16 * GNU General Public License for more details.
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
17 *
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
19 * 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
20 * 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
21 *
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
22 */
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
23 #include "internal.h"
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
24
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
25 #include "account.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
26 #include "accountopt.h"
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
27 #include "blist.h"
27286
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
28 #include "core.h"
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
29 #include "cmds.h"
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10504
diff changeset
30 #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
31 #include "conversation.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
32 #include "debug.h"
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
33 #include "dnssrv.h"
34227
6d016a081401 HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34111
diff changeset
34 #include "http.h"
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25328
diff changeset
35 #include "imgstore.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
36 #include "message.h"
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
37 #include "notify.h"
8713
8a7baa8f8460 [gaim-migrate @ 9467]
Gary Kramlich <grim@pidgin.im>
parents: 8591
diff changeset
38 #include "pluginpref.h"
25290
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
39 #include "privacy.h"
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
40 #include "proxy.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
41 #include "prpl.h"
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
42 #include "request.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
43 #include "server.h"
25532
10e7f850b235 Patch from Paul Aurich to fix reporting idle when reconnecting only when we're
Marcus Lundblad <malu@pidgin.im>
parents: 25531
diff changeset
44 #include "status.h"
7095
17d2b54254f8 [gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents: 7072
diff changeset
45 #include "util.h"
9943
b54a762f60fa [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
46 #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
47 #include "xmlnode.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
48
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
49 #include "auth.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
50 #include "buddy.h"
26072
e8fce2b2b9fe propagate from branch 'im.pidgin.pidgin' (head b4bbfacd7f2050d87deeda12ea7bb3adc3608cb7)
Paul Aurich <darkrain42@pidgin.im>
parents: 26042 25804
diff changeset
51 #include "caps.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
52 #include "chat.h"
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23325
diff changeset
53 #include "data.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
54 #include "disco.h"
29913
58f5122fbcd3 First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <malu@pidgin.im>
parents: 29910
diff changeset
55 #include "google/google.h"
58f5122fbcd3 First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <malu@pidgin.im>
parents: 29910
diff changeset
56 #include "google/google_roster.h"
58f5122fbcd3 First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <malu@pidgin.im>
parents: 29910
diff changeset
57 #include "google/google_session.h"
28879
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
58 #include "ibb.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
59 #include "iq.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
60 #include "jutil.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
61 #include "message.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
62 #include "parser.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
63 #include "presence.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
64 #include "jabber.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
65 #include "roster.h"
17769
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
66 #include "ping.h"
9466
b6425eab60ca [gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents: 9414
diff changeset
67 #include "si.h"
29412
c27d9bb60878 Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
68 #include "usermood.h"
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
69 #include "xdata.h"
17768
7be011945a1b added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents: 17767
diff changeset
70 #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
71 #include "adhoccommands.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
72
26143
673b6665624d Restructure Jingle code to more easily support multiple application types.
Michael Ruprecht <maiku@pidgin.im>
parents: 26117
diff changeset
73 #include "jingle/jingle.h"
673b6665624d Restructure Jingle code to more easily support multiple application types.
Michael Ruprecht <maiku@pidgin.im>
parents: 26117
diff changeset
74 #include "jingle/rtp.h"
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23325
diff changeset
75
29771
b276f3e127af jabber: Don't ping more often than once a minute.
Paul Aurich <darkrain42@pidgin.im>
parents: 29749
diff changeset
76 #define PING_TIMEOUT 60
30056
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
77 /* Send a whitespace keepalive to the server if we haven't sent
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
78 * anything in the last 120 seconds
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
79 */
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
80 #define DEFAULT_INACTIVITY_TIME 120
29771
b276f3e127af jabber: Don't ping more often than once a minute.
Paul Aurich <darkrain42@pidgin.im>
parents: 29749
diff changeset
81
21623
722e905dd5b5 Fix #3669
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
82 GList *jabber_features = NULL;
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
83 GList *jabber_identities = NULL;
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
84
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
85 static GHashTable *jabber_cmds = NULL; /* PurplePlugin * => GSList of ids */
4249
62583b5d3663 [gaim-migrate @ 4499]
Robert McQueen <robot101@debian.org>
parents: 4245
diff changeset
86
29844
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
87 static gint plugin_ref = 0;
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
88
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
89 static void jabber_unregister_account_cb(JabberStream *js);
23910
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
90 static void try_srv_connect(JabberStream *js);
4249
62583b5d3663 [gaim-migrate @ 4499]
Robert McQueen <robot101@debian.org>
parents: 4245
diff changeset
91
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
92 static void jabber_stream_init(JabberStream *js)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
93 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
94 char *open_stream;
3340
7e59a209931d [gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3337
diff changeset
95
29865
3a23d291568e jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <darkrain42@pidgin.im>
parents: 29864
diff changeset
96 if (js->stream_id) {
3a23d291568e jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <darkrain42@pidgin.im>
parents: 29864
diff changeset
97 g_free(js->stream_id);
3a23d291568e jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <darkrain42@pidgin.im>
parents: 29864
diff changeset
98 js->stream_id = NULL;
3a23d291568e jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <darkrain42@pidgin.im>
parents: 29864
diff changeset
99 }
3a23d291568e jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <darkrain42@pidgin.im>
parents: 29864
diff changeset
100
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
101 open_stream = g_strdup_printf("<stream:stream to='%s' "
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
102 "xmlns='" NS_XMPP_CLIENT "' "
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
103 "xmlns:stream='" NS_XMPP_STREAMS "' "
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
104 "version='1.0'>",
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7274
diff changeset
105 js->user->domain);
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13806
diff changeset
106 /* setup the parser fresh for each stream */
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13806
diff changeset
107 jabber_parser_setup(js);
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
108 jabber_send_raw(js, open_stream, -1);
14062
dd8d7eb8fa76 [gaim-migrate @ 16585]
Ethan Blanton <elb@pidgin.im>
parents: 14043
diff changeset
109 js->reinit = FALSE;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
110 g_free(open_stream);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
111 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
112
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
113 static void
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
114 jabber_session_initialized_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
115 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
116 xmlnode *packet, gpointer data)
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
117 {
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
118 if (type == JABBER_IQ_RESULT) {
25799
f2b56ff62042 Wait until receiving the roster to tell the core we're logged in
Paul Aurich <darkrain42@pidgin.im>
parents: 25798
diff changeset
119 jabber_disco_items_server(js);
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
120 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
121 jabber_unregister_account_cb(js);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
122 } else {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
123 purple_connection_error(js->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
124 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
125 ("Error initializing session"));
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
126 }
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
127 }
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
128
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
129 static void jabber_session_init(JabberStream *js)
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
130 {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
131 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
132 xmlnode *session;
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
133
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
134 jabber_iq_set_callback(iq, jabber_session_initialized_cb, NULL);
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
135
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
136 session = xmlnode_new_child(iq->node, "session");
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
137 xmlnode_set_namespace(session, NS_XMPP_SESSION);
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
138
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
139 jabber_iq_send(iq);
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
140 }
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
141
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
142 static void jabber_bind_result_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
143 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
144 xmlnode *packet, gpointer data)
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
145 {
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
146 xmlnode *bind;
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
147
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
148 if (type == JABBER_IQ_RESULT &&
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
149 (bind = xmlnode_get_child_with_namespace(packet, "bind", NS_XMPP_BIND))) {
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
150 xmlnode *jid;
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
151 char *full_jid;
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
152 if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
153 jabber_id_free(js->user);
28070
df31e9d5ad88 jabber: Stop fall-through on connection error.
Paul Aurich <darkrain42@pidgin.im>
parents: 28064
diff changeset
154
df31e9d5ad88 jabber: Stop fall-through on connection error.
Paul Aurich <darkrain42@pidgin.im>
parents: 28064
diff changeset
155 js->user = jabber_id_new(full_jid);
df31e9d5ad88 jabber: Stop fall-through on connection error.
Paul Aurich <darkrain42@pidgin.im>
parents: 28064
diff changeset
156 if (js->user == NULL) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
157 purple_connection_error(js->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
158 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
159 _("Invalid response from server"));
28070
df31e9d5ad88 jabber: Stop fall-through on connection error.
Paul Aurich <darkrain42@pidgin.im>
parents: 28064
diff changeset
160 g_free(full_jid);
df31e9d5ad88 jabber: Stop fall-through on connection error.
Paul Aurich <darkrain42@pidgin.im>
parents: 28064
diff changeset
161 return;
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
162 }
28070
df31e9d5ad88 jabber: Stop fall-through on connection error.
Paul Aurich <darkrain42@pidgin.im>
parents: 28064
diff changeset
163
28071
a0706162fefd jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents: 28070
diff changeset
164 js->user_jb = jabber_buddy_find(js, full_jid, TRUE);
a0706162fefd jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents: 28070
diff changeset
165 js->user_jb->subscription |= JABBER_SUB_BOTH;
24430
77ba88ca54a6 Set the connection display name to the server-assigned full jid for XMPP
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
166
77ba88ca54a6 Set the connection display name to the server-assigned full jid for XMPP
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
167 purple_connection_set_display_name(js->gc, full_jid);
77ba88ca54a6 Set the connection display name to the server-assigned full jid for XMPP
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
168
10504
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10490
diff changeset
169 g_free(full_jid);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
170 }
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
171 } else {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
172 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
173 char *msg = jabber_parse_error(js, packet, &reason);
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
174 purple_connection_error(js->gc, reason, msg);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
175 g_free(msg);
30013
e9b97a2ae2a6 jabber: If binding fails, don't continue trying to initialize the session.
Paul Aurich <darkrain42@pidgin.im>
parents: 29979
diff changeset
176
e9b97a2ae2a6 jabber: If binding fails, don't continue trying to initialize the session.
Paul Aurich <darkrain42@pidgin.im>
parents: 29979
diff changeset
177 return;
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
178 }
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
179
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
180 jabber_session_init(js);
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
181 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
182
24819
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
183 static char *jabber_prep_resource(char *input) {
25600
251e085b3cfa Grab only the "short" hostname on systems (like Fedora/RedHat, but others too)
Matěj Cepl <mcepl@redhat.com>
parents: 25573
diff changeset
184 char hostname[256], /* current hostname */
251e085b3cfa Grab only the "short" hostname on systems (like Fedora/RedHat, but others too)
Matěj Cepl <mcepl@redhat.com>
parents: 25573
diff changeset
185 *dot = NULL;
24819
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
186
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
187 /* Empty resource == don't send any */
25304
75bdc442f70c Slightly modified version of a fix fqueze proposed for a crash with the empty
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 25290
diff changeset
188 if (input == NULL || *input == '\0')
24819
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
189 return NULL;
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
190
24833
d2257d9b0ffa Avoid needlessly calling gethostname() if __HOSTNAME__ doesn't appear in the
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 24828
diff changeset
191 if (strstr(input, "__HOSTNAME__") == NULL)
24850
0237007e4424 darkrain again
Ka-Hing Cheung <khc@pidgin.im>
parents: 24833
diff changeset
192 return g_strdup(input);
24833
d2257d9b0ffa Avoid needlessly calling gethostname() if __HOSTNAME__ doesn't appear in the
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 24828
diff changeset
193
24819
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
194 /* Replace __HOSTNAME__ with hostname */
24824
2da1f210b9a2 me likes this better, References #5565
Ka-Hing Cheung <khc@pidgin.im>
parents: 24820
diff changeset
195 if (gethostname(hostname, sizeof(hostname) - 1)) {
2da1f210b9a2 me likes this better, References #5565
Ka-Hing Cheung <khc@pidgin.im>
parents: 24820
diff changeset
196 purple_debug_warning("jabber", "gethostname: %s\n", g_strerror(errno));
2da1f210b9a2 me likes this better, References #5565
Ka-Hing Cheung <khc@pidgin.im>
parents: 24820
diff changeset
197 /* according to glibc doc, the only time an error is returned
2da1f210b9a2 me likes this better, References #5565
Ka-Hing Cheung <khc@pidgin.im>
parents: 24820
diff changeset
198 is if the hostname is longer than the buffer, in which case
2da1f210b9a2 me likes this better, References #5565
Ka-Hing Cheung <khc@pidgin.im>
parents: 24820
diff changeset
199 glibc 2.2+ would still fill the buffer with partial
2da1f210b9a2 me likes this better, References #5565
Ka-Hing Cheung <khc@pidgin.im>
parents: 24820
diff changeset
200 hostname, so maybe we want to detect that and use it
2da1f210b9a2 me likes this better, References #5565
Ka-Hing Cheung <khc@pidgin.im>
parents: 24820
diff changeset
201 instead
2da1f210b9a2 me likes this better, References #5565
Ka-Hing Cheung <khc@pidgin.im>
parents: 24820
diff changeset
202 */
31963
4b77c9940154 Change another hostname lookup fallback to use g_strlcpy.
Ethan Blanton <elb@pidgin.im>
parents: 31928
diff changeset
203 g_strlcpy(hostname, "localhost", sizeof(hostname));
24819
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
204 }
24824
2da1f210b9a2 me likes this better, References #5565
Ka-Hing Cheung <khc@pidgin.im>
parents: 24820
diff changeset
205 hostname[sizeof(hostname) - 1] = '\0';
24819
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
206
25600
251e085b3cfa Grab only the "short" hostname on systems (like Fedora/RedHat, but others too)
Matěj Cepl <mcepl@redhat.com>
parents: 25573
diff changeset
207 /* We want only the short hostname, not the FQDN - this will prevent the
251e085b3cfa Grab only the "short" hostname on systems (like Fedora/RedHat, but others too)
Matěj Cepl <mcepl@redhat.com>
parents: 25573
diff changeset
208 * resource string from being unreasonably long on systems which stuff the
251e085b3cfa Grab only the "short" hostname on systems (like Fedora/RedHat, but others too)
Matěj Cepl <mcepl@redhat.com>
parents: 25573
diff changeset
209 * whole FQDN in the hostname */
251e085b3cfa Grab only the "short" hostname on systems (like Fedora/RedHat, but others too)
Matěj Cepl <mcepl@redhat.com>
parents: 25573
diff changeset
210 if((dot = strchr(hostname, '.')))
30687
93133347cbcf < QuLogic> on line 208 of jabber.c, should that be *dot?
Paul Aurich <darkrain42@pidgin.im>
parents: 30587
diff changeset
211 *dot = '\0';
25600
251e085b3cfa Grab only the "short" hostname on systems (like Fedora/RedHat, but others too)
Matěj Cepl <mcepl@redhat.com>
parents: 25573
diff changeset
212
24819
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
213 return purple_strreplace(input, "__HOSTNAME__", hostname);
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
214 }
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
215
30156
6ec7dbe44c83 jabber: I never understood why this was in auth.c anyway...
Paul Aurich <darkrain42@pidgin.im>
parents: 30155
diff changeset
216 static gboolean
6ec7dbe44c83 jabber: I never understood why this was in auth.c anyway...
Paul Aurich <darkrain42@pidgin.im>
parents: 30155
diff changeset
217 jabber_process_starttls(JabberStream *js, xmlnode *packet)
6ec7dbe44c83 jabber: I never understood why this was in auth.c anyway...
Paul Aurich <darkrain42@pidgin.im>
parents: 30155
diff changeset
218 {
6ec7dbe44c83 jabber: I never understood why this was in auth.c anyway...
Paul Aurich <darkrain42@pidgin.im>
parents: 30155
diff changeset
219 PurpleAccount *account;
6ec7dbe44c83 jabber: I never understood why this was in auth.c anyway...
Paul Aurich <darkrain42@pidgin.im>
parents: 30155
diff changeset
220 xmlnode *starttls;
6ec7dbe44c83 jabber: I never understood why this was in auth.c anyway...
Paul Aurich <darkrain42@pidgin.im>
parents: 30155
diff changeset
221
6ec7dbe44c83 jabber: I never understood why this was in auth.c anyway...
Paul Aurich <darkrain42@pidgin.im>
parents: 30155
diff changeset
222 account = purple_connection_get_account(js->gc);
6ec7dbe44c83 jabber: I never understood why this was in auth.c anyway...
Paul Aurich <darkrain42@pidgin.im>
parents: 30155
diff changeset
223
30820
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
224 #if 0
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
225 /*
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
226 * This code DOES NOT EXIST, will never be enabled by default, and
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
227 * will never ever be supported (by me).
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
228 * It's literally *only* for developer testing.
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
229 */
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
230 {
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
231 const gchar *connection_security = purple_account_get_string(account, "connection_security", JABBER_DEFAULT_REQUIRE_TLS);
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
232 if (!g_str_equal(connection_security, "none") &&
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
233 purple_ssl_is_supported()) {
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
234 jabber_send_raw(js,
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
235 "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>", -1);
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
236 return TRUE;
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
237 }
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
238 }
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
239 #else
30458
66c86178c6fc We've already checked for the existance of the starttls node, so we know
Mark Doliner <markdoliner@pidgin.im>
parents: 30448
diff changeset
240 if(purple_ssl_is_supported()) {
66c86178c6fc We've already checked for the existance of the starttls node, so we know
Mark Doliner <markdoliner@pidgin.im>
parents: 30448
diff changeset
241 jabber_send_raw(js,
66c86178c6fc We've already checked for the existance of the starttls node, so we know
Mark Doliner <markdoliner@pidgin.im>
parents: 30448
diff changeset
242 "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>", -1);
66c86178c6fc We've already checked for the existance of the starttls node, so we know
Mark Doliner <markdoliner@pidgin.im>
parents: 30448
diff changeset
243 return TRUE;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31128
diff changeset
244 } else {
30821
6213c18c2774 Let's make it clear that means locally
Paul Aurich <darkrain42@pidgin.im>
parents: 30820
diff changeset
245 purple_debug_warning("jabber", "No libpurple TLS/SSL support found.");
30458
66c86178c6fc We've already checked for the existance of the starttls node, so we know
Mark Doliner <markdoliner@pidgin.im>
parents: 30448
diff changeset
246 }
30820
647b57aa1a3a jabber: Commit some non-existent code.
Paul Aurich <darkrain42@pidgin.im>
parents: 30816
diff changeset
247 #endif
30458
66c86178c6fc We've already checked for the existance of the starttls node, so we know
Mark Doliner <markdoliner@pidgin.im>
parents: 30448
diff changeset
248
66c86178c6fc We've already checked for the existance of the starttls node, so we know
Mark Doliner <markdoliner@pidgin.im>
parents: 30448
diff changeset
249 starttls = xmlnode_get_child(packet, "starttls");
66c86178c6fc We've already checked for the existance of the starttls node, so we know
Mark Doliner <markdoliner@pidgin.im>
parents: 30448
diff changeset
250 if(xmlnode_get_child(starttls, "required")) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
251 purple_connection_error(js->gc,
30156
6ec7dbe44c83 jabber: I never understood why this was in auth.c anyway...
Paul Aurich <darkrain42@pidgin.im>
parents: 30155
diff changeset
252 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
6ec7dbe44c83 jabber: I never understood why this was in auth.c anyway...
Paul Aurich <darkrain42@pidgin.im>
parents: 30155
diff changeset
253 _("Server requires TLS/SSL, but no TLS/SSL support was found."));
30458
66c86178c6fc We've already checked for the existance of the starttls node, so we know
Mark Doliner <markdoliner@pidgin.im>
parents: 30448
diff changeset
254 return TRUE;
66c86178c6fc We've already checked for the existance of the starttls node, so we know
Mark Doliner <markdoliner@pidgin.im>
parents: 30448
diff changeset
255 }
66c86178c6fc We've already checked for the existance of the starttls node, so we know
Mark Doliner <markdoliner@pidgin.im>
parents: 30448
diff changeset
256
30740
017077f79a0f jabber: Unify "Require TLS" and "Use old-style (port 5223) SSL" settings
Paul Aurich <darkrain42@pidgin.im>
parents: 30723
diff changeset
257 if (g_str_equal("require_tls", purple_account_get_string(account, "connection_security", JABBER_DEFAULT_REQUIRE_TLS))) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
258 purple_connection_error(js->gc,
30458
66c86178c6fc We've already checked for the existance of the starttls node, so we know
Mark Doliner <markdoliner@pidgin.im>
parents: 30448
diff changeset
259 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
30156
6ec7dbe44c83 jabber: I never understood why this was in auth.c anyway...
Paul Aurich <darkrain42@pidgin.im>
parents: 30155
diff changeset
260 _("You require encryption, but no TLS/SSL support was found."));
30458
66c86178c6fc We've already checked for the existance of the starttls node, so we know
Mark Doliner <markdoliner@pidgin.im>
parents: 30448
diff changeset
261 return TRUE;
30156
6ec7dbe44c83 jabber: I never understood why this was in auth.c anyway...
Paul Aurich <darkrain42@pidgin.im>
parents: 30155
diff changeset
262 }
6ec7dbe44c83 jabber: I never understood why this was in auth.c anyway...
Paul Aurich <darkrain42@pidgin.im>
parents: 30155
diff changeset
263
6ec7dbe44c83 jabber: I never understood why this was in auth.c anyway...
Paul Aurich <darkrain42@pidgin.im>
parents: 30155
diff changeset
264 return FALSE;
6ec7dbe44c83 jabber: I never understood why this was in auth.c anyway...
Paul Aurich <darkrain42@pidgin.im>
parents: 30155
diff changeset
265 }
6ec7dbe44c83 jabber: I never understood why this was in auth.c anyway...
Paul Aurich <darkrain42@pidgin.im>
parents: 30155
diff changeset
266
23618
8497c2f5e62d * using libpurple's internal SASL mechanisms during BOSH authentication phase
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23613
diff changeset
267 void jabber_stream_features_parse(JabberStream *js, xmlnode *packet)
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
268 {
30740
017077f79a0f jabber: Unify "Require TLS" and "Use old-style (port 5223) SSL" settings
Paul Aurich <darkrain42@pidgin.im>
parents: 30723
diff changeset
269 PurpleAccount *account = purple_connection_get_account(js->gc);
017077f79a0f jabber: Unify "Require TLS" and "Use old-style (port 5223) SSL" settings
Paul Aurich <darkrain42@pidgin.im>
parents: 30723
diff changeset
270 const char *connection_security =
017077f79a0f jabber: Unify "Require TLS" and "Use old-style (port 5223) SSL" settings
Paul Aurich <darkrain42@pidgin.im>
parents: 30723
diff changeset
271 purple_account_get_string(account, "connection_security", JABBER_DEFAULT_REQUIRE_TLS);
017077f79a0f jabber: Unify "Require TLS" and "Use old-style (port 5223) SSL" settings
Paul Aurich <darkrain42@pidgin.im>
parents: 30723
diff changeset
272
017077f79a0f jabber: Unify "Require TLS" and "Use old-style (port 5223) SSL" settings
Paul Aurich <darkrain42@pidgin.im>
parents: 30723
diff changeset
273 if (xmlnode_get_child(packet, "starttls")) {
017077f79a0f jabber: Unify "Require TLS" and "Use old-style (port 5223) SSL" settings
Paul Aurich <darkrain42@pidgin.im>
parents: 30723
diff changeset
274 if (jabber_process_starttls(js, packet)) {
28623
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28610
diff changeset
275 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING_ENCRYPTION);
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
276 return;
28623
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28610
diff changeset
277 }
30740
017077f79a0f jabber: Unify "Require TLS" and "Use old-style (port 5223) SSL" settings
Paul Aurich <darkrain42@pidgin.im>
parents: 30723
diff changeset
278 } else if (g_str_equal(connection_security, "require_tls") && !jabber_stream_is_ssl(js)) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
279 purple_connection_error(js->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
280 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
281 _("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
282 return;
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
283 }
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
284
10988
c164f2e5dfaa [gaim-migrate @ 12825]
Nathan Walp <nwalp@pidgin.im>
parents: 10941
diff changeset
285 if(js->registration) {
c164f2e5dfaa [gaim-migrate @ 12825]
Nathan Walp <nwalp@pidgin.im>
parents: 10941
diff changeset
286 jabber_register_start(js);
c164f2e5dfaa [gaim-migrate @ 12825]
Nathan Walp <nwalp@pidgin.im>
parents: 10941
diff changeset
287 } else if(xmlnode_get_child(packet, "mechanisms")) {
28623
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28610
diff changeset
288 jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING);
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
289 jabber_auth_start(js, packet);
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
290 } else if(xmlnode_get_child(packet, "bind")) {
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
291 xmlnode *bind, *resource;
24819
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
292 char *requested_resource;
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
293 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET);
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
294 bind = xmlnode_new_child(iq->node, "bind");
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
295 xmlnode_set_namespace(bind, NS_XMPP_BIND);
24819
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
296 requested_resource = jabber_prep_resource(js->user->resource);
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
297
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
298 if (requested_resource != NULL) {
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
299 resource = xmlnode_new_child(bind, "resource");
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
300 xmlnode_insert_data(resource, requested_resource, -1);
25087
b26db53e5b66 Use g_free instead of free.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24850
diff changeset
301 g_free(requested_resource);
24819
95e726e2bc06 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24693
diff changeset
302 }
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
303
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
304 jabber_iq_set_callback(iq, jabber_bind_result_cb, NULL);
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
305
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
306 jabber_iq_send(iq);
29096
362b96f6f3da jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents: 29094
diff changeset
307 } else if (xmlnode_get_child_with_namespace(packet, "ver", NS_ROSTER_VERSIONING)) {
362b96f6f3da jabber: Roster Versioning support.
Paul Aurich <darkrain42@pidgin.im>
parents: 29094
diff changeset
308 js->server_caps |= JABBER_CAP_ROSTER_VERSIONING;
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
309 } else /* if(xmlnode_get_child_with_namespace(packet, "auth")) */ {
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
310 /* 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
311 * an auth feature with namespace http://jabber.org/features/iq-auth
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
312 * 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
313 * connecting to an XMPP server. */
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
314 jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING);
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28832
diff changeset
315 jabber_auth_start_old(js);
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
316 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
317 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
318
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
319 static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet)
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
320 {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
321 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
322 char *msg = jabber_parse_error(js, packet, &reason);
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
323
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
324 purple_connection_error(js->gc, reason, msg);
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
325
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
326 g_free(msg);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
327 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
328
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
329 static void tls_init(JabberStream *js);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
330
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
331 void jabber_process_packet(JabberStream *js, xmlnode **packet)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
332 {
29864
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
333 const char *name;
15980
77057c4f658a Minor code cleanup
Mark Doliner <markdoliner@pidgin.im>
parents: 15979
diff changeset
334 const char *xmlns;
77057c4f658a Minor code cleanup
Mark Doliner <markdoliner@pidgin.im>
parents: 15979
diff changeset
335
28832
4e4b609b85e4 jabber: Use purple_connection_get_prpl() instead of jabber_plugin.
Paul Aurich <darkrain42@pidgin.im>
parents: 28830
diff changeset
336 purple_signal_emit(purple_connection_get_prpl(js->gc), "jabber-receiving-xmlnode", js->gc, packet);
14358
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
337
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
338 /* 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
339 if(NULL == *packet)
14358
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
340 return;
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
341
29864
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
342 name = (*packet)->name;
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
343 xmlns = xmlnode_get_namespace(*packet);
15980
77057c4f658a Minor code cleanup
Mark Doliner <markdoliner@pidgin.im>
parents: 15979
diff changeset
344
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
345 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
346 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
347 } 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
348 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
349 } 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
350 jabber_message_parse(js, *packet);
29864
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
351 } else if (purple_strequal(xmlns, NS_XMPP_STREAMS)) {
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
352 if (g_str_equal(name, "features"))
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
353 jabber_stream_features_parse(js, *packet);
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
354 else if (g_str_equal(name, "error"))
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
355 jabber_stream_handle_error(js, *packet);
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
356 } else if (purple_strequal(xmlns, NS_XMPP_SASL)) {
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
357 if (js->state != JABBER_STREAM_AUTHENTICATING)
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
358 purple_debug_warning("jabber", "Ignoring spurious SASL stanza %s\n", name);
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
359 else {
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
360 if (g_str_equal(name, "challenge"))
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
361 jabber_auth_handle_challenge(js, *packet);
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
362 else if (g_str_equal(name, "success"))
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
363 jabber_auth_handle_success(js, *packet);
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
364 else if (g_str_equal(name, "failure"))
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
365 jabber_auth_handle_failure(js, *packet);
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
366 }
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
367 } else if (purple_strequal(xmlns, NS_XMPP_TLS)) {
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
368 if (js->state != JABBER_STREAM_INITIALIZING_ENCRYPTION || js->gsc)
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
369 purple_debug_warning("jabber", "Ignoring spurious %s\n", name);
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
370 else {
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
371 if (g_str_equal(name, "proceed"))
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
372 tls_init(js);
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
373 /* TODO: Handle <failure/>, I guess? */
76caf53857f5 jabber: The parser is namespace-aware, so don't match on "stream:features".
Paul Aurich <darkrain42@pidgin.im>
parents: 29853
diff changeset
374 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
375 } else {
28828
7c1855f037e7 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 28827
diff changeset
376 purple_debug_warning("jabber", "Unknown packet: %s\n", (*packet)->name);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
377 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
378 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
379
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
380 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
381 {
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
382 int ret;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
383
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
384 if (js->gsc)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
385 ret = purple_ssl_write(js->gsc, data, len);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
386 else
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
387 ret = write(js->fd, data, len);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
388
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
389 return ret;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
390 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
391
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
392 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
393 {
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
394 JabberStream *js = data;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
395 int ret, writelen;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
396 writelen = purple_circ_buffer_get_max_read(js->write_buffer);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
397
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
398 if (writelen == 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
399 purple_input_remove(js->writeh);
13746
790924f38349 [gaim-migrate @ 16155]
Mark Doliner <markdoliner@pidgin.im>
parents: 13546
diff changeset
400 js->writeh = 0;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
401 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
402 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
403
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
404 ret = jabber_do_send(js, js->write_buffer->outptr, writelen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
405
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
406 if (ret < 0 && errno == EAGAIN)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
407 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
408 else if (ret <= 0) {
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
409 gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"),
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
410 g_strerror(errno));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
411 purple_connection_error(js->gc,
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
412 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
413 g_free(tmp);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
414 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
415 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
416
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
417 purple_circ_buffer_mark_read(js->write_buffer, ret);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
418 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
419
23519
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
420 static gboolean do_jabber_send_raw(JabberStream *js, const char *data, int len)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
421 {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
422 int ret;
23519
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
423 gboolean success = TRUE;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
424
30155
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
425 g_return_val_if_fail(len > 0, FALSE);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
426
30056
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
427 if (js->state == JABBER_STREAM_CONNECTED)
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
428 jabber_stream_restart_inactivity_timer(js);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
429
13746
790924f38349 [gaim-migrate @ 16155]
Mark Doliner <markdoliner@pidgin.im>
parents: 13546
diff changeset
430 if (js->writeh == 0)
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
431 ret = jabber_do_send(js, data, len);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
432 else {
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
433 ret = -1;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
434 errno = EAGAIN;
2814
91cc1a0cdee0 [gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 2800
diff changeset
435 }
91cc1a0cdee0 [gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 2800
diff changeset
436
23519
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
437 if (ret < 0 && errno != EAGAIN) {
29262
6ec383410c8e jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 29222
diff changeset
438 PurpleAccount *account = purple_connection_get_account(js->gc);
6ec383410c8e jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 29222
diff changeset
439 /*
6ec383410c8e jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 29222
diff changeset
440 * The server may have closed the socket (on a stream error), so if
6ec383410c8e jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 29222
diff changeset
441 * we're disconnecting, don't generate (possibly another) error that
6ec383410c8e jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 29222
diff changeset
442 * (for some UIs) would mask the first.
6ec383410c8e jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 29222
diff changeset
443 */
32722
50ed95d90d55 Add purple_account_is_disconnecting() accessor function.
Andrew Victor <andrew.victor@mxit.com>
parents: 32721
diff changeset
444 if (!purple_account_is_disconnecting(account)) {
29262
6ec383410c8e jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 29222
diff changeset
445 gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"),
6ec383410c8e jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 29222
diff changeset
446 g_strerror(errno));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
447 purple_connection_error(js->gc,
29262
6ec383410c8e jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 29222
diff changeset
448 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
6ec383410c8e jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 29222
diff changeset
449 g_free(tmp);
6ec383410c8e jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 29222
diff changeset
450 }
6ec383410c8e jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 29222
diff changeset
451
23519
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
452 success = FALSE;
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
453 } else if (ret < len) {
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
454 if (ret < 0)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
455 ret = 0;
13746
790924f38349 [gaim-migrate @ 16155]
Mark Doliner <markdoliner@pidgin.im>
parents: 13546
diff changeset
456 if (js->writeh == 0)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
457 js->writeh = purple_input_add(
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
458 js->gsc ? js->gsc->fd : js->fd,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
459 PURPLE_INPUT_WRITE, jabber_send_cb, js);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
460 purple_circ_buffer_append(js->write_buffer,
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
461 data + ret, len - ret);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
462 }
23519
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
463
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
464 return success;
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
465 }
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
466
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
467 void jabber_send_raw(JabberStream *js, const char *data, int len)
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
468 {
30155
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
469 PurpleConnection *gc;
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
470 PurpleAccount *account;
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
471
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
472 gc = js->gc;
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
473 account = purple_connection_get_account(gc);
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
474
23519
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
475 /* because printing a tab to debug every minute gets old */
25328
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
476 if(strcmp(data, "\t")) {
28827
76ec9a15f1a8 jabber: Print account name on sent stanzas in the debug log.
Paul Aurich <darkrain42@pidgin.im>
parents: 28760
diff changeset
477 const char *username;
25328
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
478 char *text = NULL, *last_part = NULL, *tag_start = NULL;
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
479
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
480 /* Because debug logs with plaintext passwords make me sad */
31128
116e599c707f jabber: Print out plaintext-equivalent passwords when PURPLE_UNSAFE_DEBUG is set.
Paul Aurich <darkrain42@pidgin.im>
parents: 30845
diff changeset
481 if (!purple_debug_is_unsafe() && js->state != JABBER_STREAM_CONNECTED &&
25328
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
482 /* Either <auth> or <query><password>... */
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
483 (((tag_start = strstr(data, "<auth ")) &&
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
484 strstr(data, "xmlns='" NS_XMPP_SASL "'")) ||
25328
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
485 ((tag_start = strstr(data, "<query ")) &&
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
486 strstr(data, "xmlns='jabber:iq:auth'>") &&
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
487 (tag_start = strstr(tag_start, "<password>"))))) {
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
488 char *data_start, *tag_end = strchr(tag_start, '>');
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
489 text = g_strdup(data);
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
490
25739
a10f2ed69334 *** Plucked rev b786784e (datallah@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25727
diff changeset
491 /* Better to print out some wacky debugging than crash
a10f2ed69334 *** Plucked rev b786784e (datallah@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25727
diff changeset
492 * due to a plugin sending bad xml */
a10f2ed69334 *** Plucked rev b786784e (datallah@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25727
diff changeset
493 if (tag_end == NULL)
a10f2ed69334 *** Plucked rev b786784e (datallah@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25727
diff changeset
494 tag_end = tag_start;
a10f2ed69334 *** Plucked rev b786784e (datallah@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25727
diff changeset
495
25328
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
496 data_start = text + (tag_end - data) + 1;
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
497
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
498 last_part = strchr(data_start, '<');
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
499 *data_start = '\0';
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
500 }
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
501
30155
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
502 username = purple_connection_get_display_name(gc);
28827
76ec9a15f1a8 jabber: Print account name on sent stanzas in the debug log.
Paul Aurich <darkrain42@pidgin.im>
parents: 28760
diff changeset
503 if (!username)
30155
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
504 username = purple_account_get_username(account);
28827
76ec9a15f1a8 jabber: Print account name on sent stanzas in the debug log.
Paul Aurich <darkrain42@pidgin.im>
parents: 28760
diff changeset
505
76ec9a15f1a8 jabber: Print account name on sent stanzas in the debug log.
Paul Aurich <darkrain42@pidgin.im>
parents: 28760
diff changeset
506 purple_debug_misc("jabber", "Sending%s (%s): %s%s%s\n",
76ec9a15f1a8 jabber: Print account name on sent stanzas in the debug log.
Paul Aurich <darkrain42@pidgin.im>
parents: 28760
diff changeset
507 jabber_stream_is_ssl(js) ? " (ssl)" : "", username,
76ec9a15f1a8 jabber: Print account name on sent stanzas in the debug log.
Paul Aurich <darkrain42@pidgin.im>
parents: 28760
diff changeset
508 text ? text : data,
25328
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
509 last_part ? "password removed" : "",
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
510 last_part ? last_part : "");
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
511
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
512 g_free(text);
95d3adda6822 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <darkrain42@pidgin.im>
parents: 25304
diff changeset
513 }
23519
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
514
30155
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
515 purple_signal_emit(purple_connection_get_prpl(gc), "jabber-sending-text", gc, &data);
23519
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
516 if (data == NULL)
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
517 return;
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
518
30155
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
519 if (len == -1)
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
520 len = strlen(data);
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
521
23519
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
522 /* If we've got a security layer, we need to encode the data,
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
523 * splitting it on the maximum buffer length negotiated */
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
524 #ifdef HAVE_CYRUS_SASL
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
525 if (js->sasl_maxbuf>0) {
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
526 int pos = 0;
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
527
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
528 if (!js->gsc && js->fd<0)
30153
3cee3e2efd03 jabber: I don't see how this is possible, and it looks like an error to me.
Paul Aurich <darkrain42@pidgin.im>
parents: 30150
diff changeset
529 g_return_if_reached();
23519
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
530
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
531 while (pos < len) {
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
532 int towrite;
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
533 const char *out;
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
534 unsigned olen;
30155
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
535 int rc;
23519
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
536
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
537 towrite = MIN((len - pos), js->sasl_maxbuf);
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
538
30155
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
539 rc = sasl_encode(js->sasl, &data[pos], towrite,
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
540 &out, &olen);
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
541 if (rc != SASL_OK) {
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
542 gchar *error =
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
543 g_strdup_printf(_("SASL error: %s"),
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
544 sasl_errdetail(js->sasl));
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
545 purple_debug_error("jabber",
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
546 "sasl_encode error %d: %s\n", rc,
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
547 sasl_errdetail(js->sasl));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
548 purple_connection_error(gc,
30155
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
549 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
550 error);
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
551 g_free(error);
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
552 return;
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
553 }
23519
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
554 pos += towrite;
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
555
30155
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
556 /* do_jabber_send_raw returns FALSE when it throws a
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
557 * connection error.
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
558 */
23519
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
559 if (!do_jabber_send_raw(js, out, olen))
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
560 break;
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
561 }
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
562 return;
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
563 }
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
564 #endif
7cbd7ed333d3 Cleanup some duplication and simplify this.
Daniel Atallah <datallah@pidgin.im>
parents: 23428
diff changeset
565
28064
6b6e3949132f jabber: Remove js->use_bosh
Paul Aurich <darkrain42@pidgin.im>
parents: 28049
diff changeset
566 if (js->bosh)
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34238
diff changeset
567 jabber_bosh_connection_send(js->bosh, data);
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
568 else
23955
18bd5d80fb7b explicit merge of '8d5884281cfb1c7a26fe80c919e38fa13f7a0c4b'
Paul Aurich <darkrain42@pidgin.im>
parents: 23619 23954
diff changeset
569 do_jabber_send_raw(js, data, len);
14604
67a7c42a8654 [gaim-migrate @ 17263]
Sean Egan <seanegan@pidgin.im>
parents: 14498
diff changeset
570 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
571
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
572 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
573 {
30155
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
574 JabberStream *js = purple_connection_get_protocol_data(gc);
30448
736dde71e3ec jabber: Stricter checks on the send_raw prpl function.
Paul Aurich <darkrain42@pidgin.im>
parents: 30156
diff changeset
575
736dde71e3ec jabber: Stricter checks on the send_raw prpl function.
Paul Aurich <darkrain42@pidgin.im>
parents: 30156
diff changeset
576 g_return_val_if_fail(js != NULL, -1);
736dde71e3ec jabber: Stricter checks on the send_raw prpl function.
Paul Aurich <darkrain42@pidgin.im>
parents: 30156
diff changeset
577 /* TODO: It's probably worthwhile to restrict this to when the account
736dde71e3ec jabber: Stricter checks on the send_raw prpl function.
Paul Aurich <darkrain42@pidgin.im>
parents: 30156
diff changeset
578 * state is CONNECTED, but I can /almost/ envision reasons for wanting
736dde71e3ec jabber: Stricter checks on the send_raw prpl function.
Paul Aurich <darkrain42@pidgin.im>
parents: 30156
diff changeset
579 * to do things during the connection process.
736dde71e3ec jabber: Stricter checks on the send_raw prpl function.
Paul Aurich <darkrain42@pidgin.im>
parents: 30156
diff changeset
580 */
736dde71e3ec jabber: Stricter checks on the send_raw prpl function.
Paul Aurich <darkrain42@pidgin.im>
parents: 30156
diff changeset
581
14604
67a7c42a8654 [gaim-migrate @ 17263]
Sean Egan <seanegan@pidgin.im>
parents: 14498
diff changeset
582 jabber_send_raw(js, buf, len);
34304
faf0414a8b51 Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34297
diff changeset
583 return (len < 0 ? (int)strlen(buf) : len);
2814
91cc1a0cdee0 [gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 2800
diff changeset
584 }
91cc1a0cdee0 [gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 2800
diff changeset
585
27225
48c94daedc1c Use the jabber-sending-xmlnode signal to send all XMPP stanzas.
Paul Aurich <darkrain42@pidgin.im>
parents: 27223
diff changeset
586 void jabber_send_signal_cb(PurpleConnection *pc, xmlnode **packet,
48c94daedc1c Use the jabber-sending-xmlnode signal to send all XMPP stanzas.
Paul Aurich <darkrain42@pidgin.im>
parents: 27223
diff changeset
587 gpointer unused)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
588 {
27924
ef40c7484edc Set the namespace properly on stanzas for BOSH.
Paul Aurich <darkrain42@pidgin.im>
parents: 27918
diff changeset
589 JabberStream *js;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
590 char *txt;
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
591 int len;
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
592
27225
48c94daedc1c Use the jabber-sending-xmlnode signal to send all XMPP stanzas.
Paul Aurich <darkrain42@pidgin.im>
parents: 27223
diff changeset
593 if (NULL == packet)
14358
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
594 return;
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
595
30587
dacecb57b543 jabber: g_return-ify some PURPLE_CONNECTION_IS_VALID checks
Paul Aurich <darkrain42@pidgin.im>
parents: 30512
diff changeset
596 g_return_if_fail(PURPLE_CONNECTION_IS_VALID(pc));
14358
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
597
27924
ef40c7484edc Set the namespace properly on stanzas for BOSH.
Paul Aurich <darkrain42@pidgin.im>
parents: 27918
diff changeset
598 js = purple_connection_get_protocol_data(pc);
28974
c781d3082146 Add some safety to jabber_send_signal_cb in case someone else was listening
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 28928
diff changeset
599
c781d3082146 Add some safety to jabber_send_signal_cb in case someone else was listening
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 28928
diff changeset
600 if (NULL == js)
c781d3082146 Add some safety to jabber_send_signal_cb in case someone else was listening
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 28928
diff changeset
601 return;
c781d3082146 Add some safety to jabber_send_signal_cb in case someone else was listening
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 28928
diff changeset
602
28064
6b6e3949132f jabber: Remove js->use_bosh
Paul Aurich <darkrain42@pidgin.im>
parents: 28049
diff changeset
603 if (js->bosh)
27924
ef40c7484edc Set the namespace properly on stanzas for BOSH.
Paul Aurich <darkrain42@pidgin.im>
parents: 27918
diff changeset
604 if (g_str_equal((*packet)->name, "message") ||
ef40c7484edc Set the namespace properly on stanzas for BOSH.
Paul Aurich <darkrain42@pidgin.im>
parents: 27918
diff changeset
605 g_str_equal((*packet)->name, "iq") ||
ef40c7484edc Set the namespace properly on stanzas for BOSH.
Paul Aurich <darkrain42@pidgin.im>
parents: 27918
diff changeset
606 g_str_equal((*packet)->name, "presence"))
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
607 xmlnode_set_namespace(*packet, NS_XMPP_CLIENT);
27225
48c94daedc1c Use the jabber-sending-xmlnode signal to send all XMPP stanzas.
Paul Aurich <darkrain42@pidgin.im>
parents: 27223
diff changeset
608 txt = xmlnode_to_str(*packet, &len);
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
609 jabber_send_raw(js, txt, len);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
610 g_free(txt);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
611 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
612
27225
48c94daedc1c Use the jabber-sending-xmlnode signal to send all XMPP stanzas.
Paul Aurich <darkrain42@pidgin.im>
parents: 27223
diff changeset
613 void jabber_send(JabberStream *js, xmlnode *packet)
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
614 {
28832
4e4b609b85e4 jabber: Use purple_connection_get_prpl() instead of jabber_plugin.
Paul Aurich <darkrain42@pidgin.im>
parents: 28830
diff changeset
615 purple_signal_emit(purple_connection_get_prpl(js->gc), "jabber-sending-xmlnode", js->gc, &packet);
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
616 }
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
617
25555
dd0cb987435f Make the XMPP keepalive use jabber_ping_jid instead of building it itself.
Paul Aurich <darkrain42@pidgin.im>
parents: 25552
diff changeset
618 static gboolean jabber_keepalive_timeout(PurpleConnection *gc)
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
619 {
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
620 JabberStream *js = purple_connection_get_protocol_data(gc);
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
621 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
622 _("Ping timed out"));
27304
b2dc447b8c0b The XMPP keepalive timeout handle needs to be a guint.
Paul Aurich <darkrain42@pidgin.im>
parents: 27293
diff changeset
623 js->keepalive_timeout = 0;
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
624 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
625 }
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
626
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
627 void jabber_keepalive(PurpleConnection *gc)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
628 {
29771
b276f3e127af jabber: Don't ping more often than once a minute.
Paul Aurich <darkrain42@pidgin.im>
parents: 29749
diff changeset
629 JabberStream *js = purple_connection_get_protocol_data(gc);
b276f3e127af jabber: Don't ping more often than once a minute.
Paul Aurich <darkrain42@pidgin.im>
parents: 29749
diff changeset
630 time_t now = time(NULL);
b276f3e127af jabber: Don't ping more often than once a minute.
Paul Aurich <darkrain42@pidgin.im>
parents: 29749
diff changeset
631
b276f3e127af jabber: Don't ping more often than once a minute.
Paul Aurich <darkrain42@pidgin.im>
parents: 29749
diff changeset
632 if (js->keepalive_timeout == 0 && (now - js->last_ping) >= PING_TIMEOUT) {
b276f3e127af jabber: Don't ping more often than once a minute.
Paul Aurich <darkrain42@pidgin.im>
parents: 29749
diff changeset
633 js->last_ping = now;
b276f3e127af jabber: Don't ping more often than once a minute.
Paul Aurich <darkrain42@pidgin.im>
parents: 29749
diff changeset
634
27143
977add4a215e Stop trying to be clever with XMPP keepalive pings.
Paul Aurich <darkrain42@pidgin.im>
parents: 27110
diff changeset
635 jabber_keepalive_ping(js);
25555
dd0cb987435f Make the XMPP keepalive use jabber_ping_jid instead of building it itself.
Paul Aurich <darkrain42@pidgin.im>
parents: 25552
diff changeset
636 js->keepalive_timeout = purple_timeout_add_seconds(120,
dd0cb987435f Make the XMPP keepalive use jabber_ping_jid instead of building it itself.
Paul Aurich <darkrain42@pidgin.im>
parents: 25552
diff changeset
637 (GSourceFunc)(jabber_keepalive_timeout), gc);
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
638 }
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
639 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
640
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
641 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
642 jabber_recv_cb_ssl(gpointer data, PurpleSslConnection *gsc,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
643 PurpleInputCondition cond)
6764
a3f8025c0631 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
644 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
645 PurpleConnection *gc = data;
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
646 JabberStream *js = purple_connection_get_protocol_data(gc);
6764
a3f8025c0631 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
647 int len;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
648 static char buf[4096];
6768
64384a76f515 [gaim-migrate @ 7305]
Nathan Walp <nwalp@pidgin.im>
parents: 6764
diff changeset
649
14030
23144f1dc950 [gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents: 14004
diff changeset
650 /* 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
651 if(!PURPLE_CONNECTION_IS_VALID(gc)) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
652 purple_ssl_close(gsc);
30587
dacecb57b543 jabber: g_return-ify some PURPLE_CONNECTION_IS_VALID checks
Paul Aurich <darkrain42@pidgin.im>
parents: 30512
diff changeset
653 g_return_if_reached();
6768
64384a76f515 [gaim-migrate @ 7305]
Nathan Walp <nwalp@pidgin.im>
parents: 6764
diff changeset
654 }
64384a76f515 [gaim-migrate @ 7305]
Nathan Walp <nwalp@pidgin.im>
parents: 6764
diff changeset
655
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
656 while((len = purple_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) {
32679
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
657 purple_connection_update_last_received(gc);
6764
a3f8025c0631 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
658 buf[len] = '\0';
34297
0f1f0b8c84f8 Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34269
diff changeset
659 purple_debug_misc("jabber", "Recv (ssl)(%d): %s", len, buf);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
660 jabber_parser_process(js, buf, len);
14062
dd8d7eb8fa76 [gaim-migrate @ 16585]
Ethan Blanton <elb@pidgin.im>
parents: 14043
diff changeset
661 if(js->reinit)
dd8d7eb8fa76 [gaim-migrate @ 16585]
Ethan Blanton <elb@pidgin.im>
parents: 14043
diff changeset
662 jabber_stream_init(js);
13280
8d45d67480e6 [gaim-migrate @ 15645]
Greg Hudson <ghudson@mit.edu>
parents: 13275
diff changeset
663 }
8d45d67480e6 [gaim-migrate @ 15645]
Greg Hudson <ghudson@mit.edu>
parents: 13275
diff changeset
664
23539
19dd5b0bbe76 Only check for EAGAIN if read returned less than 0. This fixes a bug
Mark Doliner <markdoliner@pidgin.im>
parents: 23532
diff changeset
665 if(len < 0 && errno == EAGAIN)
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
666 return;
23539
19dd5b0bbe76 Only check for EAGAIN if read returned less than 0. This fixes a bug
Mark Doliner <markdoliner@pidgin.im>
parents: 23532
diff changeset
667 else {
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
668 gchar *tmp;
23539
19dd5b0bbe76 Only check for EAGAIN if read returned less than 0. This fixes a bug
Mark Doliner <markdoliner@pidgin.im>
parents: 23532
diff changeset
669 if (len == 0)
33740
261e15fb8b91 Fix a few warnings
Daniel Atallah <datallah@pidgin.im>
parents: 31997
diff changeset
670 tmp = g_strdup(_("Server closed the connection"));
23539
19dd5b0bbe76 Only check for EAGAIN if read returned less than 0. This fixes a bug
Mark Doliner <markdoliner@pidgin.im>
parents: 23532
diff changeset
671 else
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
672 tmp = g_strdup_printf(_("Lost connection with server: %s"),
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
673 g_strerror(errno));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
674 purple_connection_error(js->gc,
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
675 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
676 g_free(tmp);
23539
19dd5b0bbe76 Only check for EAGAIN if read returned less than 0. This fixes a bug
Mark Doliner <markdoliner@pidgin.im>
parents: 23532
diff changeset
677 }
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
678 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
679
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
680 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
681 jabber_recv_cb(gpointer data, gint source, PurpleInputCondition condition)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
682 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
683 PurpleConnection *gc = data;
30155
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
684 JabberStream *js = purple_connection_get_protocol_data(gc);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
685 int len;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
686 static char buf[4096];
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
687
30587
dacecb57b543 jabber: g_return-ify some PURPLE_CONNECTION_IS_VALID checks
Paul Aurich <darkrain42@pidgin.im>
parents: 30512
diff changeset
688 g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc));
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
689
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
690 if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) {
32679
fd936a0b84f7 Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
691 purple_connection_update_last_received(gc);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
692 #ifdef HAVE_CYRUS_SASL
30155
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
693 if (js->sasl_maxbuf > 0) {
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
694 const char *out;
14697
518c0fae208e [gaim-migrate @ 17381]
Daniel Atallah <datallah@pidgin.im>
parents: 14668
diff changeset
695 unsigned int olen;
30155
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
696 int rc;
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
697
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
698 rc = sasl_decode(js->sasl, buf, len, &out, &olen);
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
699 if (rc != SASL_OK) {
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
700 gchar *error =
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
701 g_strdup_printf(_("SASL error: %s"),
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
702 sasl_errdetail(js->sasl));
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
703 purple_debug_error("jabber",
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
704 "sasl_decode_error %d: %s\n", rc,
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
705 sasl_errdetail(js->sasl));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
706 purple_connection_error(gc,
30155
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
707 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
708 error);
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
709 } else if (olen > 0) {
28828
7c1855f037e7 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 28827
diff changeset
710 purple_debug_info("jabber", "RecvSASL (%u): %s\n", olen, out);
30155
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
711 jabber_parser_process(js, out, olen);
8e22b8cc78ee jabber: A bunch of paranoia-induced Cyrus SASL changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 30153
diff changeset
712 if (js->reinit)
14700
98dc3d9a69e3 [gaim-migrate @ 17384]
Sean Egan <seanegan@pidgin.im>
parents: 14697
diff changeset
713 jabber_stream_init(js);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
714 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
715 return;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
716 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
717 #endif
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
718 buf[len] = '\0';
34297
0f1f0b8c84f8 Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34269
diff changeset
719 purple_debug_misc("jabber", "Recv (%d): %s", len, buf);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
720 jabber_parser_process(js, buf, len);
14700
98dc3d9a69e3 [gaim-migrate @ 17384]
Sean Egan <seanegan@pidgin.im>
parents: 14697
diff changeset
721 if(js->reinit)
98dc3d9a69e3 [gaim-migrate @ 17384]
Sean Egan <seanegan@pidgin.im>
parents: 14697
diff changeset
722 jabber_stream_init(js);
23539
19dd5b0bbe76 Only check for EAGAIN if read returned less than 0. This fixes a bug
Mark Doliner <markdoliner@pidgin.im>
parents: 23532
diff changeset
723 } else if(len < 0 && errno == EAGAIN) {
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
724 return;
7177
36ad58ff37d6 [gaim-migrate @ 7745]
Nathan Walp <nwalp@pidgin.im>
parents: 7147
diff changeset
725 } else {
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
726 gchar *tmp;
23539
19dd5b0bbe76 Only check for EAGAIN if read returned less than 0. This fixes a bug
Mark Doliner <markdoliner@pidgin.im>
parents: 23532
diff changeset
727 if (len == 0)
33740
261e15fb8b91 Fix a few warnings
Daniel Atallah <datallah@pidgin.im>
parents: 31997
diff changeset
728 tmp = g_strdup(_("Server closed the connection"));
23539
19dd5b0bbe76 Only check for EAGAIN if read returned less than 0. This fixes a bug
Mark Doliner <markdoliner@pidgin.im>
parents: 23532
diff changeset
729 else
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
730 tmp = g_strdup_printf(_("Lost connection with server: %s"),
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
731 g_strerror(errno));
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
732 purple_connection_error(js->gc,
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
733 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
734 g_free(tmp);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
735 }
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
736 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
737
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
738 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
739 jabber_login_callback_ssl(gpointer data, PurpleSslConnection *gsc,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
740 PurpleInputCondition cond)
6764
a3f8025c0631 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
741 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
742 PurpleConnection *gc = data;
15023
c38f385a128a [gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
743 JabberStream *js;
c38f385a128a [gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
744
c38f385a128a [gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
745 /* 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
746 if(!PURPLE_CONNECTION_IS_VALID(gc)) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
747 purple_ssl_close(gsc);
30587
dacecb57b543 jabber: g_return-ify some PURPLE_CONNECTION_IS_VALID checks
Paul Aurich <darkrain42@pidgin.im>
parents: 30512
diff changeset
748 g_return_if_reached();
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
749 }
15023
c38f385a128a [gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
750
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
751 js = purple_connection_get_protocol_data(gc);
6764
a3f8025c0631 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
752
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
753 if(js->state == JABBER_STREAM_CONNECTING)
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
754 jabber_send_raw(js, "<?xml version='1.0' ?>", -1);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
755 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
756 purple_ssl_input_add(gsc, jabber_recv_cb_ssl, gc);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
757
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
758 /* 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
759 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING_ENCRYPTION);
6764
a3f8025c0631 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
760 }
a3f8025c0631 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
761
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27143
diff changeset
762 static void
27605
b03b418413b0 A couple more s/GSList/GList/ changes as fallout from the last change.
Etan Reisner <deryni@pidgin.im>
parents: 27603
diff changeset
763 txt_resolved_cb(GList *responses, gpointer data)
23607
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23604
diff changeset
764 {
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 24871
diff changeset
765 JabberStream *js = data;
30845
ded677aa7cf6 jabber: Handle a corner case better by throwing an error instead of stalling
Paul Aurich <darkrain42@pidgin.im>
parents: 30838
diff changeset
766 gboolean found = FALSE;
26766
854a2eaa3862 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents: 26765
diff changeset
767
24871
60f1695a34e8 Track the TXT query in the js object so it will be cancelleable
Paul Aurich <darkrain42@pidgin.im>
parents: 24870
diff changeset
768 js->srv_query_data = NULL;
60f1695a34e8 Track the TXT query in the js object so it will be cancelleable
Paul Aurich <darkrain42@pidgin.im>
parents: 24870
diff changeset
769
26766
854a2eaa3862 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents: 26765
diff changeset
770 while (responses) {
854a2eaa3862 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents: 26765
diff changeset
771 PurpleTxtResponse *resp = responses->data;
23608
42569940482d * small bugfix in jabber_ipc_add_feature()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23607
diff changeset
772 gchar **token;
26766
854a2eaa3862 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents: 26765
diff changeset
773 token = g_strsplit(purple_txt_response_get_content(resp), "=", 2);
23608
42569940482d * small bugfix in jabber_ipc_add_feature()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23607
diff changeset
774 if (!strcmp(token[0], "_xmpp-client-xbosh")) {
42569940482d * small bugfix in jabber_ipc_add_feature()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23607
diff changeset
775 purple_debug_info("jabber","Found alternative connection method using %s at %s.\n", token[0], token[1]);
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34238
diff changeset
776 js->bosh = jabber_bosh_connection_new(js, token[1]);
23608
42569940482d * small bugfix in jabber_ipc_add_feature()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23607
diff changeset
777 g_strfreev(token);
42569940482d * small bugfix in jabber_ipc_add_feature()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23607
diff changeset
778 break;
42569940482d * small bugfix in jabber_ipc_add_feature()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23607
diff changeset
779 }
42569940482d * small bugfix in jabber_ipc_add_feature()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23607
diff changeset
780 g_strfreev(token);
26766
854a2eaa3862 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents: 26765
diff changeset
781 purple_txt_response_destroy(resp);
27605
b03b418413b0 A couple more s/GSList/GList/ changes as fallout from the last change.
Etan Reisner <deryni@pidgin.im>
parents: 27603
diff changeset
782 responses = g_list_delete_link(responses, responses);
23607
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23604
diff changeset
783 }
26766
854a2eaa3862 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents: 26765
diff changeset
784
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34238
diff changeset
785 if (js->bosh)
30845
ded677aa7cf6 jabber: Handle a corner case better by throwing an error instead of stalling
Paul Aurich <darkrain42@pidgin.im>
parents: 30838
diff changeset
786 found = TRUE;
ded677aa7cf6 jabber: Handle a corner case better by throwing an error instead of stalling
Paul Aurich <darkrain42@pidgin.im>
parents: 30838
diff changeset
787
ded677aa7cf6 jabber: Handle a corner case better by throwing an error instead of stalling
Paul Aurich <darkrain42@pidgin.im>
parents: 30838
diff changeset
788 if (!found) {
ded677aa7cf6 jabber: Handle a corner case better by throwing an error instead of stalling
Paul Aurich <darkrain42@pidgin.im>
parents: 30838
diff changeset
789 purple_debug_warning("jabber", "Unable to find alternative XMPP connection "
ded677aa7cf6 jabber: Handle a corner case better by throwing an error instead of stalling
Paul Aurich <darkrain42@pidgin.im>
parents: 30838
diff changeset
790 "methods after failing to connect directly.\n");
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
791 purple_connection_error(js->gc,
30845
ded677aa7cf6 jabber: Handle a corner case better by throwing an error instead of stalling
Paul Aurich <darkrain42@pidgin.im>
parents: 30838
diff changeset
792 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
ded677aa7cf6 jabber: Handle a corner case better by throwing an error instead of stalling
Paul Aurich <darkrain42@pidgin.im>
parents: 30838
diff changeset
793 _("Unable to connect"));
ded677aa7cf6 jabber: Handle a corner case better by throwing an error instead of stalling
Paul Aurich <darkrain42@pidgin.im>
parents: 30838
diff changeset
794 return;
23611
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23608
diff changeset
795 }
26765
fc156c427d59 First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents: 26764
diff changeset
796
26766
854a2eaa3862 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents: 26765
diff changeset
797 if (responses) {
27605
b03b418413b0 A couple more s/GSList/GList/ changes as fallout from the last change.
Etan Reisner <deryni@pidgin.im>
parents: 27603
diff changeset
798 g_list_foreach(responses, (GFunc)purple_txt_response_destroy, NULL);
b03b418413b0 A couple more s/GSList/GList/ changes as fallout from the last change.
Etan Reisner <deryni@pidgin.im>
parents: 27603
diff changeset
799 g_list_free(responses);
26766
854a2eaa3862 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents: 26765
diff changeset
800 }
23607
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23604
diff changeset
801 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
802
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
803 static void
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
804 jabber_login_callback(gpointer data, gint source, const gchar *error)
6764
a3f8025c0631 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
805 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
806 PurpleConnection *gc = data;
29222
022a4164460c jabber: Pedantically this bothered me, but changing the message to
Paul Aurich <darkrain42@pidgin.im>
parents: 29221
diff changeset
807 JabberStream *js = purple_connection_get_protocol_data(gc);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
808
8783
7be6da5bc279 [gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents: 8778
diff changeset
809 if (source < 0) {
23910
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
810 if (js->srv_rec != NULL) {
29222
022a4164460c jabber: Pedantically this bothered me, but changing the message to
Paul Aurich <darkrain42@pidgin.im>
parents: 29221
diff changeset
811 purple_debug_error("jabber", "Unable to connect to server: %s. Trying next SRV record or connecting directly.\n", error);
23910
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
812 try_srv_connect(js);
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
813 } else {
29222
022a4164460c jabber: Pedantically this bothered me, but changing the message to
Paul Aurich <darkrain42@pidgin.im>
parents: 29221
diff changeset
814 purple_debug_info("jabber","Couldn't connect directly to %s. Trying to find alternative connection methods, like BOSH.\n", js->user->domain);
32300
59a31f9f67fc Clean up SRV/TXT query functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32277
diff changeset
815 js->srv_query_data = purple_txt_resolve(
31680
d3902c687705 Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <datallah@pidgin.im>
parents: 31515
diff changeset
816 purple_connection_get_account(gc), "_xmppconnect",
27898
4a6450d92e11 Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents: 27872
diff changeset
817 js->user->domain, txt_resolved_cb, js);
23910
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
818 }
8783
7be6da5bc279 [gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents: 8778
diff changeset
819 return;
7be6da5bc279 [gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents: 8778
diff changeset
820 }
7be6da5bc279 [gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents: 8778
diff changeset
821
23910
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
822 g_free(js->srv_rec);
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
823 js->srv_rec = NULL;
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
824
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
825 js->fd = source;
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
826
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
827 if(js->state == JABBER_STREAM_CONNECTING)
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
828 jabber_send_raw(js, "<?xml version='1.0' ?>", -1);
2300
06a3c10f4918 [gaim-migrate @ 2310]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 2289
diff changeset
829
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
830 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING);
32684
edefbf316da1 Jabber: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents: 32679
diff changeset
831 js->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
832 }
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
833
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
834 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
835 jabber_ssl_connect_failure(PurpleSslConnection *gsc, PurpleSslErrorType error,
7426
c499c64731a1 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
836 gpointer data)
c499c64731a1 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
837 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
838 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
839 JabberStream *js;
7426
c499c64731a1 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
840
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
841 /* If the connection is already disconnected, we don't need to do anything else */
30587
dacecb57b543 jabber: g_return-ify some PURPLE_CONNECTION_IS_VALID checks
Paul Aurich <darkrain42@pidgin.im>
parents: 30512
diff changeset
842 g_return_if_fail(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
843
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
844 js = purple_connection_get_protocol_data(gc);
14312
6ce4512aa9a8 [gaim-migrate @ 16932]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
845 js->gsc = NULL;
6ce4512aa9a8 [gaim-migrate @ 16932]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
846
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
847 purple_connection_ssl_error (gc, error);
7426
c499c64731a1 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
848 }
c499c64731a1 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
849
7427
9a301e6b3902 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
850 static void tls_init(JabberStream *js)
9a301e6b3902 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
851 {
32684
edefbf316da1 Jabber: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents: 32679
diff changeset
852 purple_input_remove(js->inpa);
edefbf316da1 Jabber: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents: 32679
diff changeset
853 js->inpa = 0;
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32624
diff changeset
854 js->gsc = purple_ssl_connect_with_host_fd(purple_connection_get_account(js->gc), 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
855 jabber_login_callback_ssl, jabber_ssl_connect_failure, js->certificate_CN, js->gc);
27918
b32f476d9e35 Clear out the fd when we pass it off to the SSL subsystem
Paul Aurich <darkrain42@pidgin.im>
parents: 27898
diff changeset
856 /* The fd is no longer our concern */
b32f476d9e35 Clear out the fd when we pass it off to the SSL subsystem
Paul Aurich <darkrain42@pidgin.im>
parents: 27898
diff changeset
857 js->fd = -1;
7427
9a301e6b3902 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
858 }
9a301e6b3902 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
859
23910
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
860 static gboolean jabber_login_connect(JabberStream *js, const char *domain, const char *host, int port,
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
861 gboolean fatal_failure)
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
862 {
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
863 /* 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
864 * 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
865 * 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
866 * in connect server */
23910
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
867 g_free(js->serverFQDN);
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
868 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
869 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
870 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
871 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
872
27872
80d354ef1295 To make grim happy (or more upset).
Paul Aurich <darkrain42@pidgin.im>
parents: 27863
diff changeset
873 if (purple_proxy_connect(js->gc, purple_connection_get_account(js->gc),
80d354ef1295 To make grim happy (or more upset).
Paul Aurich <darkrain42@pidgin.im>
parents: 27863
diff changeset
874 host, port, jabber_login_callback, js->gc) == NULL) {
23910
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
875 if (fatal_failure) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
876 purple_connection_error(js->gc,
23910
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
877 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27605
diff changeset
878 _("Unable to connect"));
23910
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
879 }
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
880
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
881 return FALSE;
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
882 }
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
883
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
884 return TRUE;
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
885 }
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
886
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
887 static void try_srv_connect(JabberStream *js)
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
888 {
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
889 while (js->srv_rec != NULL && js->srv_rec_idx < js->max_srv_rec_idx) {
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
890 PurpleSrvResponse *tmp_resp = js->srv_rec + (js->srv_rec_idx++);
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
891 if (jabber_login_connect(js, tmp_resp->hostname, tmp_resp->hostname, tmp_resp->port, FALSE))
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
892 return;
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
893 }
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
894
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
895 g_free(js->srv_rec);
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
896 js->srv_rec = NULL;
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
897
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
898 /* Fall back to the defaults (I'm not sure if we should actually do this) */
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
899 jabber_login_connect(js, js->user->domain, js->user->domain,
27872
80d354ef1295 To make grim happy (or more upset).
Paul Aurich <darkrain42@pidgin.im>
parents: 27863
diff changeset
900 purple_account_get_int(purple_connection_get_account(js->gc), "port", 5222),
27898
4a6450d92e11 Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents: 27872
diff changeset
901 TRUE);
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
902 }
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
903
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
904 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
905 {
23910
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
906 JabberStream *js = data;
14370
12ef3d4096ee [gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents: 14358
diff changeset
907 js->srv_query_data = NULL;
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
908
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
909 if(results) {
23910
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
910 js->srv_rec = resp;
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
911 js->srv_rec_idx = 0;
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
912 js->max_srv_rec_idx = results;
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
913 try_srv_connect(js);
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
914 } else {
17052
b064b8e0244b fix #699
Nathan Walp <nwalp@pidgin.im>
parents: 17008
diff changeset
915 jabber_login_connect(js, js->user->domain, js->user->domain,
27872
80d354ef1295 To make grim happy (or more upset).
Paul Aurich <darkrain42@pidgin.im>
parents: 27863
diff changeset
916 purple_account_get_int(purple_connection_get_account(js->gc), "port", 5222),
27898
4a6450d92e11 Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents: 27872
diff changeset
917 TRUE);
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
918 }
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
919 }
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
920
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
921 static JabberStream *
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
922 jabber_stream_new(PurpleAccount *account)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
923 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
924 PurpleConnection *gc = purple_account_get_connection(account);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
925 JabberStream *js;
25532
10e7f850b235 Patch from Paul Aurich to fix reporting idle when reconnecting only when we're
Marcus Lundblad <malu@pidgin.im>
parents: 25531
diff changeset
926 PurplePresence *presence;
31487
6159afdf4553 disapproval of revision 'a47ab1a2fcf24f136b572c4ede8024299e18aff0'
Mark Doliner <markdoliner@pidgin.im>
parents: 31486
diff changeset
927 gchar *user;
27860
2b75b87699c8 Support connecting to IDNA XMPP domains.
Paul Aurich <darkrain42@pidgin.im>
parents: 27850
diff changeset
928 gchar *slash;
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
929
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
930 js = g_new0(JabberStream, 1);
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
931 purple_connection_set_protocol_data(gc, js);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
932 js->gc = gc;
8013
03f5b77cdaf0 [gaim-migrate @ 8693]
Olivier Blin <blino@users.sourceforge.net>
parents: 8011
diff changeset
933 js->fd = -1;
34269
26b4c9a54166 HTTP: Use PurpleHttpConnectionSet instead of GSLists of PurpleHttpConnection structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34268
diff changeset
934 js->http_conns = purple_http_connection_set_new();
27860
2b75b87699c8 Support connecting to IDNA XMPP domains.
Paul Aurich <darkrain42@pidgin.im>
parents: 27850
diff changeset
935
31487
6159afdf4553 disapproval of revision 'a47ab1a2fcf24f136b572c4ede8024299e18aff0'
Mark Doliner <markdoliner@pidgin.im>
parents: 31486
diff changeset
936 user = g_strdup(purple_account_get_username(account));
27860
2b75b87699c8 Support connecting to IDNA XMPP domains.
Paul Aurich <darkrain42@pidgin.im>
parents: 27850
diff changeset
937 /* jabber_id_new doesn't accept "user@domain/" as valid */
31487
6159afdf4553 disapproval of revision 'a47ab1a2fcf24f136b572c4ede8024299e18aff0'
Mark Doliner <markdoliner@pidgin.im>
parents: 31486
diff changeset
938 slash = strchr(user, '/');
27860
2b75b87699c8 Support connecting to IDNA XMPP domains.
Paul Aurich <darkrain42@pidgin.im>
parents: 27850
diff changeset
939 if (slash && *(slash + 1) == '\0')
2b75b87699c8 Support connecting to IDNA XMPP domains.
Paul Aurich <darkrain42@pidgin.im>
parents: 27850
diff changeset
940 *slash = '\0';
31487
6159afdf4553 disapproval of revision 'a47ab1a2fcf24f136b572c4ede8024299e18aff0'
Mark Doliner <markdoliner@pidgin.im>
parents: 31486
diff changeset
941 js->user = jabber_id_new(user);
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
942
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
943 if (!js->user) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
944 purple_connection_error(gc,
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
945 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
946 _("Invalid XMPP ID"));
31487
6159afdf4553 disapproval of revision 'a47ab1a2fcf24f136b572c4ede8024299e18aff0'
Mark Doliner <markdoliner@pidgin.im>
parents: 31486
diff changeset
947 g_free(user);
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
948 /* Destroying the connection will free the JabberStream */
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
949 return NULL;
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
950 }
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
951
29979
f7f4478c8d19 jabber: Check at connection time that the user specified a JID with a node.
Paul Aurich <darkrain42@pidgin.im>
parents: 29910
diff changeset
952 if (!js->user->node || *(js->user->node) == '\0') {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
953 purple_connection_error(gc,
29979
f7f4478c8d19 jabber: Check at connection time that the user specified a JID with a node.
Paul Aurich <darkrain42@pidgin.im>
parents: 29910
diff changeset
954 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
f7f4478c8d19 jabber: Check at connection time that the user specified a JID with a node.
Paul Aurich <darkrain42@pidgin.im>
parents: 29910
diff changeset
955 _("Invalid XMPP ID. Username portion must be set."));
31487
6159afdf4553 disapproval of revision 'a47ab1a2fcf24f136b572c4ede8024299e18aff0'
Mark Doliner <markdoliner@pidgin.im>
parents: 31486
diff changeset
956 g_free(user);
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
957 /* Destroying the connection will free the JabberStream */
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
958 return NULL;
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
959 }
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
960
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
961 if (!js->user->domain || *(js->user->domain) == '\0') {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
962 purple_connection_error(gc,
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
963 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
964 _("Invalid XMPP ID. Domain must be set."));
31487
6159afdf4553 disapproval of revision 'a47ab1a2fcf24f136b572c4ede8024299e18aff0'
Mark Doliner <markdoliner@pidgin.im>
parents: 31486
diff changeset
965 g_free(user);
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
966 /* Destroying the connection will free the JabberStream */
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
967 return NULL;
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
968 }
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
969
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
970 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
971 g_free, (GDestroyNotify)jabber_buddy_free);
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
972
30838
4742e16d437b jabber: Set a connection display name even when using legacy auth
Paul Aurich <darkrain42@pidgin.im>
parents: 30821
diff changeset
973 /* This is overridden during binding, but we need it here
4742e16d437b jabber: Set a connection display name even when using legacy auth
Paul Aurich <darkrain42@pidgin.im>
parents: 30821
diff changeset
974 * in case the server only does legacy non-sasl auth!.
4742e16d437b jabber: Set a connection display name even when using legacy auth
Paul Aurich <darkrain42@pidgin.im>
parents: 30821
diff changeset
975 */
31487
6159afdf4553 disapproval of revision 'a47ab1a2fcf24f136b572c4ede8024299e18aff0'
Mark Doliner <markdoliner@pidgin.im>
parents: 31486
diff changeset
976 purple_connection_set_display_name(gc, user);
6159afdf4553 disapproval of revision 'a47ab1a2fcf24f136b572c4ede8024299e18aff0'
Mark Doliner <markdoliner@pidgin.im>
parents: 31486
diff changeset
977
6159afdf4553 disapproval of revision 'a47ab1a2fcf24f136b572c4ede8024299e18aff0'
Mark Doliner <markdoliner@pidgin.im>
parents: 31486
diff changeset
978 js->user_jb = jabber_buddy_find(js, user, TRUE);
6159afdf4553 disapproval of revision 'a47ab1a2fcf24f136b572c4ede8024299e18aff0'
Mark Doliner <markdoliner@pidgin.im>
parents: 31486
diff changeset
979 g_free(user);
28071
a0706162fefd jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents: 28070
diff changeset
980 if (!js->user_jb) {
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
981 /* This basically *can't* fail, but for good measure... */
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
982 purple_connection_error(gc,
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
983 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
984 _("Invalid XMPP ID"));
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
985 /* Destroying the connection will free the JabberStream */
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
986 g_return_val_if_reached(NULL);
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
987 }
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
988
28071
a0706162fefd jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents: 28070
diff changeset
989 js->user_jb->subscription |= JABBER_SUB_BOTH;
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
990
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
991 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal,
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
992 g_free, g_free);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
993 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
994 g_free, (GDestroyNotify)jabber_chat_free);
7322
de15a9314c04 [gaim-migrate @ 7908]
Nathan Walp <nwalp@pidgin.im>
parents: 7310
diff changeset
995 js->next_id = g_random_int();
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
996 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
997 js->old_length = 0;
27304
b2dc447b8c0b The XMPP keepalive timeout handle needs to be a guint.
Paul Aurich <darkrain42@pidgin.im>
parents: 27293
diff changeset
998 js->keepalive_timeout = 0;
30056
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
999 js->max_inactivity = DEFAULT_INACTIVITY_TIME;
26080
bfe333bf2ae8 Jabber: Default protocol version to 1.0.
Paul Aurich <darkrain42@pidgin.im>
parents: 26074
diff changeset
1000 /* Set the default protocol version to 1.0. Overridden in parser.c. */
29849
d7b910200dc5 jabber: Treat the version properly.
Paul Aurich <darkrain42@pidgin.im>
parents: 29848
diff changeset
1001 js->protocol_version.major = 1;
d7b910200dc5 jabber: Treat the version properly.
Paul Aurich <darkrain42@pidgin.im>
parents: 29848
diff changeset
1002 js->protocol_version.minor = 0;
23698
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
1003 js->sessions = NULL;
26286
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26269
diff changeset
1004 js->stun_ip = NULL;
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26269
diff changeset
1005 js->stun_port = 0;
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26269
diff changeset
1006 js->stun_query = NULL;
28445
c3dbe0b64f44 Some unfinished code to take advantage of Google's relays
Marcus Lundblad <malu@pidgin.im>
parents: 28379
diff changeset
1007 js->google_relay_token = NULL;
c3dbe0b64f44 Some unfinished code to take advantage of Google's relays
Marcus Lundblad <malu@pidgin.im>
parents: 28379
diff changeset
1008 js->google_relay_host = NULL;
5613
df1602bc1e05 [gaim-migrate @ 6019]
Nathan Walp <nwalp@pidgin.im>
parents: 5599
diff changeset
1009
25531
b348ceba3289 Set idle time on JabberStream when logging in
Marcus Lundblad <malu@pidgin.im>
parents: 25497
diff changeset
1010 /* if we are idle, set idle-ness on the stream (this could happen if we get
b348ceba3289 Set idle time on JabberStream when logging in
Marcus Lundblad <malu@pidgin.im>
parents: 25497
diff changeset
1011 disconnected and the reconnects while being idle. I don't think it makes
b348ceba3289 Set idle time on JabberStream when logging in
Marcus Lundblad <malu@pidgin.im>
parents: 25497
diff changeset
1012 sense to do this when registering a new account... */
25532
10e7f850b235 Patch from Paul Aurich to fix reporting idle when reconnecting only when we're
Marcus Lundblad <malu@pidgin.im>
parents: 25531
diff changeset
1013 presence = purple_account_get_presence(account);
10e7f850b235 Patch from Paul Aurich to fix reporting idle when reconnecting only when we're
Marcus Lundblad <malu@pidgin.im>
parents: 25531
diff changeset
1014 if (purple_presence_is_idle(presence))
10e7f850b235 Patch from Paul Aurich to fix reporting idle when reconnecting only when we're
Marcus Lundblad <malu@pidgin.im>
parents: 25531
diff changeset
1015 js->idle = purple_presence_get_idle_time(presence);
5613
df1602bc1e05 [gaim-migrate @ 6019]
Nathan Walp <nwalp@pidgin.im>
parents: 5599
diff changeset
1016
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1017 return js;
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1018 }
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1019
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1020 static void
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1021 jabber_stream_connect(JabberStream *js)
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1022 {
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1023 PurpleConnection *gc = js->gc;
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1024 PurpleAccount *account = purple_connection_get_account(gc);
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1025 const char *connect_server = purple_account_get_string(account,
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1026 "connect_server", "");
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1027 const char *bosh_url = purple_account_get_string(account,
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1028 "bosh_url", "");
10289
18f2c2afebaf [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
1029
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1030 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING);
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1031
27397
690965a5ff24 Make "BOSH URL" its own account option.
Paul Aurich <darkrain42@pidgin.im>
parents: 27361
diff changeset
1032 /* If both BOSH and a Connect Server are specified, we prefer BOSH. I'm not
690965a5ff24 Make "BOSH URL" its own account option.
Paul Aurich <darkrain42@pidgin.im>
parents: 27361
diff changeset
1033 * attached to that choice, though.
690965a5ff24 Make "BOSH URL" its own account option.
Paul Aurich <darkrain42@pidgin.im>
parents: 27361
diff changeset
1034 */
690965a5ff24 Make "BOSH URL" its own account option.
Paul Aurich <darkrain42@pidgin.im>
parents: 27361
diff changeset
1035 if (*bosh_url) {
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34238
diff changeset
1036 js->bosh = jabber_bosh_connection_new(js, bosh_url);
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34238
diff changeset
1037 if (!js->bosh) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
1038 purple_connection_error(gc,
25803
04c2dbd49ac2 Allow the user to specify their own BOSH url in the Connect Server option
Paul Aurich <darkrain42@pidgin.im>
parents: 25802
diff changeset
1039 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
27397
690965a5ff24 Make "BOSH URL" its own account option.
Paul Aurich <darkrain42@pidgin.im>
parents: 27361
diff changeset
1040 _("Malformed BOSH URL"));
25803
04c2dbd49ac2 Allow the user to specify their own BOSH url in the Connect Server option
Paul Aurich <darkrain42@pidgin.im>
parents: 25802
diff changeset
1041 }
27397
690965a5ff24 Make "BOSH URL" its own account option.
Paul Aurich <darkrain42@pidgin.im>
parents: 27361
diff changeset
1042
24870
98e6bafdf33f Add option for forcing BOSH (useful for debugging)
Paul Aurich <darkrain42@pidgin.im>
parents: 24868
diff changeset
1043 return;
98e6bafdf33f Add option for forcing BOSH (useful for debugging)
Paul Aurich <darkrain42@pidgin.im>
parents: 24868
diff changeset
1044 }
98e6bafdf33f Add option for forcing BOSH (useful for debugging)
Paul Aurich <darkrain42@pidgin.im>
parents: 24868
diff changeset
1045
27397
690965a5ff24 Make "BOSH URL" its own account option.
Paul Aurich <darkrain42@pidgin.im>
parents: 27361
diff changeset
1046 js->certificate_CN = g_strdup(connect_server[0] ? connect_server : js->user->domain);
690965a5ff24 Make "BOSH URL" its own account option.
Paul Aurich <darkrain42@pidgin.im>
parents: 27361
diff changeset
1047
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
1048 /* if they've got old-ssl mode going, we probably want to ignore SRV lookups */
30740
017077f79a0f jabber: Unify "Require TLS" and "Use old-style (port 5223) SSL" settings
Paul Aurich <darkrain42@pidgin.im>
parents: 30723
diff changeset
1049 if (g_str_equal("old_ssl", purple_account_get_string(account, "connection_security", JABBER_DEFAULT_REQUIRE_TLS))) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1050 if(purple_ssl_is_supported()) {
27898
4a6450d92e11 Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents: 27872
diff changeset
1051 js->gsc = purple_ssl_connect(account, js->certificate_CN,
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1052 purple_account_get_int(account, "port", 5223),
27898
4a6450d92e11 Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents: 27872
diff changeset
1053 jabber_login_callback_ssl, jabber_ssl_connect_failure, gc);
25804
f18ad58795a2 Don't fallback (under any conditions) from old-style SSL to other connections
Paul Aurich <darkrain42@pidgin.im>
parents: 25803
diff changeset
1054 if (!js->gsc) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
1055 purple_connection_error(gc,
25804
f18ad58795a2 Don't fallback (under any conditions) from old-style SSL to other connections
Paul Aurich <darkrain42@pidgin.im>
parents: 25803
diff changeset
1056 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
f18ad58795a2 Don't fallback (under any conditions) from old-style SSL to other connections
Paul Aurich <darkrain42@pidgin.im>
parents: 25803
diff changeset
1057 _("Unable to establish SSL connection"));
f18ad58795a2 Don't fallback (under any conditions) from old-style SSL to other connections
Paul Aurich <darkrain42@pidgin.im>
parents: 25803
diff changeset
1058 }
7630
23e09fd7cbeb [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
1059 } else {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31997
diff changeset
1060 purple_connection_error(gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
1061 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 20332
diff changeset
1062 _("SSL support unavailable"));
7630
23e09fd7cbeb [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
1063 }
25804
f18ad58795a2 Don't fallback (under any conditions) from old-style SSL to other connections
Paul Aurich <darkrain42@pidgin.im>
parents: 25803
diff changeset
1064
f18ad58795a2 Don't fallback (under any conditions) from old-style SSL to other connections
Paul Aurich <darkrain42@pidgin.im>
parents: 25803
diff changeset
1065 return;
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
1066 }
3770
5d476318f306 [gaim-migrate @ 3909]
Sean Egan <seanegan@pidgin.im>
parents: 3769
diff changeset
1067
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
1068 /* 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
1069 * invoke the magic of SRV lookups, to figure out host and port */
26072
e8fce2b2b9fe propagate from branch 'im.pidgin.pidgin' (head b4bbfacd7f2050d87deeda12ea7bb3adc3608cb7)
Paul Aurich <darkrain42@pidgin.im>
parents: 26042 25804
diff changeset
1070 if(connect_server[0]) {
27898
4a6450d92e11 Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents: 27872
diff changeset
1071 jabber_login_connect(js, js->user->domain, connect_server,
4a6450d92e11 Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents: 27872
diff changeset
1072 purple_account_get_int(account, "port", 5222), TRUE);
25804
f18ad58795a2 Don't fallback (under any conditions) from old-style SSL to other connections
Paul Aurich <darkrain42@pidgin.im>
parents: 25803
diff changeset
1073 } else {
32300
59a31f9f67fc Clean up SRV/TXT query functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32277
diff changeset
1074 js->srv_query_data = purple_srv_resolve(account, "xmpp-client",
27898
4a6450d92e11 Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents: 27872
diff changeset
1075 "tcp", js->user->domain, srv_resolved_cb, js);
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
1076 }
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
1077 }
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
1078
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
1079 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1080 jabber_login(PurpleAccount *account)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1081 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1082 PurpleConnection *gc = purple_account_get_connection(account);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1083 JabberStream *js;
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1084 PurpleStoredImage *image;
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1085
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32624
diff changeset
1086 purple_connection_set_flags(gc, PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY);
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1087 js = jabber_stream_new(account);
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1088 if (js == NULL)
7310
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
1089 return;
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1090
29370
9ff8f3bdd0f5 jabber: Update the default FT proxy (if it's still set as the previous, broken, default).
Paul Aurich <darkrain42@pidgin.im>
parents: 29345
diff changeset
1091 /* TODO: Remove this at some point. Added 2010-02-14 (v2.6.6) */
9ff8f3bdd0f5 jabber: Update the default FT proxy (if it's still set as the previous, broken, default).
Paul Aurich <darkrain42@pidgin.im>
parents: 29345
diff changeset
1092 if (g_str_equal("proxy.jabber.org", purple_account_get_string(account, "ft_proxies", "")))
9ff8f3bdd0f5 jabber: Update the default FT proxy (if it's still set as the previous, broken, default).
Paul Aurich <darkrain42@pidgin.im>
parents: 29345
diff changeset
1093 purple_account_set_string(account, "ft_proxies", JABBER_DEFAULT_FT_PROXIES);
9ff8f3bdd0f5 jabber: Update the default FT proxy (if it's still set as the previous, broken, default).
Paul Aurich <darkrain42@pidgin.im>
parents: 29345
diff changeset
1094
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1095 /*
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1096 * Calculate the avatar hash for our current image so we know (when we
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1097 * fetch our vCard and PEP avatar) if we should send our avatar to the
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1098 * server.
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1099 */
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1100 image = purple_buddy_icons_find_account_icon(account);
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1101 if (image != NULL) {
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1102 js->initial_avatar_hash =
29910
f1c6e586e5c1 jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <malu@pidgin.im>
parents: 29865
diff changeset
1103 jabber_calculate_data_hash(purple_imgstore_get_data(image),
f1c6e586e5c1 jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <malu@pidgin.im>
parents: 29865
diff changeset
1104 purple_imgstore_get_size(image), "sha1");
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1105 purple_imgstore_unref(image);
7310
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
1106 }
26286
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26269
diff changeset
1107
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1108 jabber_stream_connect(js);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1109 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1110
11387
257041d4ee60 [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
1111
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1112 static gboolean
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1113 conn_close_cb(gpointer data)
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1114 {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1115 JabberStream *js = data;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1116 PurpleAccount *account = purple_connection_get_account(js->gc);
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10504
diff changeset
1117
17810
c8d4297080cb Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <am@adiumx.com>
parents: 17806
diff changeset
1118 jabber_parser_free(js);
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10504
diff changeset
1119
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1120 purple_account_disconnect(account);
10740
a1cb6b819a21 [gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents: 10504
diff changeset
1121
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1122 return FALSE;
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1123 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1124
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1125 static void
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1126 jabber_connection_schedule_close(JabberStream *js)
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1127 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1128 purple_timeout_add(0, conn_close_cb, js);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1129 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1130
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1131 static void
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1132 jabber_registration_result_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1133 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1134 xmlnode *packet, gpointer data)
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1135 {
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
1136 PurpleAccount *account = purple_connection_get_account(js->gc);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1137 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
1138 char *to = data;
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1139
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1140 if (type == JABBER_IQ_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
1141 if(js->registration) {
27525
579b9d64b364 A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27397
diff changeset
1142 buf = g_strdup_printf(_("Registration of %s@%s successful"),
27587
fac3003790f2 Indentation fix.
Etan Reisner <deryni@pidgin.im>
parents: 27304
diff changeset
1143 js->user->node, js->user->domain);
32721
3a64afbc2da2 Introduce purple_account_register_completed() to handle the invoking of any
Andrew Victor <andrew.victor@mxit.com>
parents: 32698
diff changeset
1144 purple_account_register_completed(account, TRUE);
25604
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1145 } else {
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1146 g_return_if_fail(to != NULL);
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
1147 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
1148 to);
25604
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1149 }
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1150 purple_notify_info(NULL, _("Registration Successful"),
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1151 _("Registration Successful"), buf);
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1152 g_free(buf);
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1153 } else {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
1154 char *msg = jabber_parse_error(js, packet, NULL);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1155
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1156 if(!msg)
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1157 msg = g_strdup(_("Unknown Error"));
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1158
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1159 purple_notify_error(NULL, _("Registration Failed"),
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1160 _("Registration Failed"), msg);
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1161 g_free(msg);
32721
3a64afbc2da2 Introduce purple_account_register_completed() to handle the invoking of any
Andrew Victor <andrew.victor@mxit.com>
parents: 32698
diff changeset
1162 purple_account_register_completed(account, FALSE);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1163 }
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
1164 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
1165 if(js->registration)
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1166 jabber_connection_schedule_close(js);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1167 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1168
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1169 static void
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1170 jabber_unregistration_result_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1171 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1172 xmlnode *packet, gpointer data)
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1173 {
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1174 char *buf;
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1175 char *to = data;
25604
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1176
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1177 /* This function is never called for unregistering our XMPP account from
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1178 * the server, so there should always be a 'to' address. */
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1179 g_return_if_fail(to != NULL);
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1180
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1181 if (type == JABBER_IQ_RESULT) {
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1182 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
1183 to);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1184 purple_notify_info(NULL, _("Unregistration Successful"),
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1185 _("Unregistration Successful"), buf);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1186 g_free(buf);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1187 } else {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
1188 char *msg = jabber_parse_error(js, packet, NULL);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
1189
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1190 if(!msg)
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1191 msg = g_strdup(_("Unknown Error"));
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
1192
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1193 purple_notify_error(NULL, _("Unregistration Failed"),
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1194 _("Unregistration Failed"), msg);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1195 g_free(msg);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1196 }
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1197 g_free(to);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1198 }
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1199
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
1200 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
1201 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
1202 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
1203 } 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
1204
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1205 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
1206 jabber_register_cb(JabberRegisterCBData *cbdata, PurpleRequestFields *fields)
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1207 {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1208 GList *groups, *flds;
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1209 xmlnode *query, *y;
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1210 JabberIq *iq;
7264
bdb42afa3565 [gaim-migrate @ 7841]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
1211 char *username;
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1212
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
1213 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
1214 query = xmlnode_get_child(iq->node, "query");
25604
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1215 if (cbdata->who)
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1216 xmlnode_set_attrib(iq->node, "to", cbdata->who);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1217
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1218 for(groups = purple_request_fields_get_groups(fields); groups;
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1219 groups = groups->next) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1220 for(flds = purple_request_field_group_get_fields(groups->data);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1221 flds; flds = flds->next) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1222 PurpleRequestField *field = flds->data;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1223 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
1224 if(!strcmp(id,"unregister")) {
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1225 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
1226 if(value) {
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1227 /* 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
1228 (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
1229 jabber_iq_free(iq);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1230 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
1231 query = xmlnode_get_child(iq->node, "query");
25604
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1232 if (cbdata->who)
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1233 xmlnode_set_attrib(iq->node,"to",cbdata->who);
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1234 xmlnode_new_child(query, "remove");
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
1235
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1236 jabber_iq_set_callback(iq, jabber_unregistration_result_cb, cbdata->who);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
1237
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1238 jabber_iq_send(iq);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1239 g_free(cbdata);
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1240 return;
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1241 }
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1242 } else {
28656
d003bf9b787e A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28623
diff changeset
1243 const char *ids[] = {"username", "password", "name", "email", "nick", "first",
d003bf9b787e A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28623
diff changeset
1244 "last", "address", "city", "state", "zip", "phone", "url", "date",
d003bf9b787e A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28623
diff changeset
1245 NULL};
28610
c914f0e55687 Prevent a NULL sprintf(%s) when no resource is assigned to an account during inband registration. Fixes #10420.
Daniel Atallah <datallah@pidgin.im>
parents: 28583
diff changeset
1246 const char *value = purple_request_field_string_get_value(field);
28656
d003bf9b787e A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28623
diff changeset
1247 int i;
d003bf9b787e A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28623
diff changeset
1248 for (i = 0; ids[i]; i++) {
d003bf9b787e A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28623
diff changeset
1249 if (!strcmp(id, ids[i]))
d003bf9b787e A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28623
diff changeset
1250 break;
d003bf9b787e A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28623
diff changeset
1251 }
d003bf9b787e A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28623
diff changeset
1252
d003bf9b787e A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28623
diff changeset
1253 if (!ids[i])
28610
c914f0e55687 Prevent a NULL sprintf(%s) when no resource is assigned to an account during inband registration. Fixes #10420.
Daniel Atallah <datallah@pidgin.im>
parents: 28583
diff changeset
1254 continue;
28656
d003bf9b787e A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28623
diff changeset
1255 y = xmlnode_new_child(query, ids[i]);
28610
c914f0e55687 Prevent a NULL sprintf(%s) when no resource is assigned to an account during inband registration. Fixes #10420.
Daniel Atallah <datallah@pidgin.im>
parents: 28583
diff changeset
1256 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
1257 if(cbdata->js->registration && !strcmp(id, "username")) {
25604
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1258 g_free(cbdata->js->user->node);
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1259 cbdata->js->user->node = g_strdup(value);
28610
c914f0e55687 Prevent a NULL sprintf(%s) when no resource is assigned to an account during inband registration. Fixes #10420.
Daniel Atallah <datallah@pidgin.im>
parents: 28583
diff changeset
1260 }
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1261 if(cbdata->js->registration && !strcmp(id, "password"))
34029
059c1270db1f Remove the silly destroy argument from purple_account_set_password and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34028
diff changeset
1262 purple_account_set_password(purple_connection_get_account(cbdata->js->gc), value, NULL, NULL);
28610
c914f0e55687 Prevent a NULL sprintf(%s) when no resource is assigned to an account during inband registration. Fixes #10420.
Daniel Atallah <datallah@pidgin.im>
parents: 28583
diff changeset
1263 }
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1264 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1265 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1266
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
1267 if(cbdata->js->registration) {
28610
c914f0e55687 Prevent a NULL sprintf(%s) when no resource is assigned to an account during inband registration. Fixes #10420.
Daniel Atallah <datallah@pidgin.im>
parents: 28583
diff changeset
1268 username = g_strdup_printf("%s@%s%s%s", cbdata->js->user->node, cbdata->js->user->domain,
29035
7e9ba5e8177b *** Plucked rev 941f01ed2234f8e476b7260fbd6ea873583387f7 (f05c54b03e6bbfdbff38c01697fbd353a969e05e):
Daniel Atallah <datallah@pidgin.im>
parents: 28984
diff changeset
1269 cbdata->js->user->resource ? "/" : "",
7e9ba5e8177b *** Plucked rev 941f01ed2234f8e476b7260fbd6ea873583387f7 (f05c54b03e6bbfdbff38c01697fbd353a969e05e):
Daniel Atallah <datallah@pidgin.im>
parents: 28984
diff changeset
1270 cbdata->js->user->resource ? cbdata->js->user->resource : "");
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32624
diff changeset
1271 purple_account_set_username(purple_connection_get_account(cbdata->js->gc), username);
21668
3698b848759b The Jabber registration process depends upon having a non-NULL cbdata->who,
Evan Schoenberg <evands@pidgin.im>
parents: 21667
diff changeset
1272 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
1273 }
7264
bdb42afa3565 [gaim-migrate @ 7841]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
1274
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
1275 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
1276
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1277 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
1278 g_free(cbdata);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1279 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1280
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1281 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
1282 jabber_register_cancel_cb(JabberRegisterCBData *cbdata, PurpleRequestFields *fields)
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1283 {
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
1284 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
1285 if(account && cbdata->js->registration) {
32721
3a64afbc2da2 Introduce purple_account_register_completed() to handle the invoking of any
Andrew Victor <andrew.victor@mxit.com>
parents: 32698
diff changeset
1286 purple_account_register_completed(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
1287 jabber_connection_schedule_close(cbdata->js);
20320
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20316
diff changeset
1288 }
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
1289 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
1290 g_free(cbdata);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1291 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1292
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1293 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
1294 {
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1295 xmlnode *query;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1296 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
1297 char *to = data;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1298
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1299 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
1300 query = xmlnode_get_child(iq->node, "query");
25604
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1301 if (to)
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1302 xmlnode_set_attrib(iq->node,"to",to);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1303
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1304 xmlnode_insert_child(query, result);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1305
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
1306 jabber_iq_set_callback(iq, jabber_registration_result_cb, to);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1307 jabber_iq_send(iq);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1308 }
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1309
26924
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1310 static const struct {
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1311 const char *name;
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1312 const char *label;
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1313 } registration_fields[] = {
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1314 { "email", N_("Email") },
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1315 { "nick", N_("Nickname") },
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1316 { "first", N_("First name") },
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1317 { "last", N_("Last name") },
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1318 { "address", N_("Address") },
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1319 { "city", N_("City") },
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1320 { "state", N_("State") },
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1321 { "zip", N_("Postal code") },
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1322 { "phone", N_("Phone") },
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1323 { "url", N_("URL") },
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1324 { "date", N_("Date") },
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1325 { NULL, NULL }
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1326 };
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1327
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
1328 void jabber_register_parse(JabberStream *js, const char *from, JabberIqType type,
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
1329 const char *id, xmlnode *query)
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1330 {
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
1331 PurpleAccount *account = purple_connection_get_account(js->gc);
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
1332 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
1333 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
1334 PurpleRequestField *field;
26927
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1335 xmlnode *x, *y, *node;
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
1336 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
1337 JabberRegisterCBData *cbdata;
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1338 gboolean registered = FALSE;
26924
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1339 int i;
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1340
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
1341 if (type != JABBER_IQ_RESULT)
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14324
diff changeset
1342 return;
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14324
diff changeset
1343
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
1344 if(js->registration) {
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1345 /* get rid of the login thingy */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1346 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
1347 }
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1348
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
1349 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
1350 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
1351
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
1352 if(js->registration) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1353 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
1354 _("Already Registered"), NULL);
32721
3a64afbc2da2 Introduce purple_account_register_completed() to handle the invoking of any
Andrew Victor <andrew.victor@mxit.com>
parents: 32698
diff changeset
1355 purple_account_register_completed(account, FALSE);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1356 jabber_connection_schedule_close(js);
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1357 return;
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1358 }
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
1359 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
1360
25573
6937721bb0a1 The jabber_register_parse function was looking for the <x> node as a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25552
diff changeset
1361 if((x = xmlnode_get_child_with_namespace(query, "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
1362 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
1363 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
1364
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
1365 } else if((x = xmlnode_get_child_with_namespace(query, "x", NS_OOB_X_DATA))) {
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
1366 xmlnode *url;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1367
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
1368 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
1369 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
1370 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
1371 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
1372 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
1373
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
1374 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
1375 js->gc->wants_to_die = TRUE;
32721
3a64afbc2da2 Introduce purple_account_register_completed() to handle the invoking of any
Andrew Victor <andrew.victor@mxit.com>
parents: 32698
diff changeset
1376 /* succeeded, but we have no login info */
3a64afbc2da2 Introduce purple_account_register_completed() to handle the invoking of any
Andrew Victor <andrew.victor@mxit.com>
parents: 32698
diff changeset
1377 purple_account_register_completed(account, 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
1378 jabber_connection_schedule_close(js);
8398
dccdcef78405 [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
1379 }
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
1380 return;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1381 }
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1382 }
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
1383 }
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1384
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
1385 /* 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
1386
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
1387 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
1388 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
1389 purple_request_fields_add_group(fields, group);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1390
26927
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1391 if((node = xmlnode_get_child(query, "username"))) {
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1392 char *data = xmlnode_get_data(node);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26086
diff changeset
1393 if(js->registration)
26927
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1394 field = purple_request_field_string_new("username", _("Username"), data ? data : js->user->node, FALSE);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26086
diff changeset
1395 else
26927
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1396 field = purple_request_field_string_new("username", _("Username"), data, FALSE);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26086
diff changeset
1397
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26086
diff changeset
1398 purple_request_field_group_add_field(group, field);
26927
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1399 g_free(data);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26086
diff changeset
1400 }
26927
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1401 if((node = xmlnode_get_child(query, "password"))) {
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26086
diff changeset
1402 if(js->registration)
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26086
diff changeset
1403 field = purple_request_field_string_new("password", _("Password"),
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26086
diff changeset
1404 purple_connection_get_password(js->gc), FALSE);
26927
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1405 else {
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1406 char *data = xmlnode_get_data(node);
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1407 field = purple_request_field_string_new("password", _("Password"), data, FALSE);
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1408 g_free(data);
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1409 }
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26086
diff changeset
1410
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26086
diff changeset
1411 purple_request_field_string_set_masked(field, TRUE);
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26086
diff changeset
1412 purple_request_field_group_add_field(group, field);
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26086
diff changeset
1413 }
26924
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1414
26927
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1415 if((node = 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
1416 if(js->registration)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1417 field = purple_request_field_string_new("name", _("Name"),
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32624
diff changeset
1418 purple_account_get_alias(purple_connection_get_account(js->gc)), FALSE);
26927
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1419 else {
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1420 char *data = xmlnode_get_data(node);
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1421 field = purple_request_field_string_new("name", _("Name"), data, FALSE);
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1422 g_free(data);
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1423 }
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
1424 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
1425 }
26924
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1426
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1427 for (i = 0; registration_fields[i].name != NULL; ++i) {
26927
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1428 if ((node = xmlnode_get_child(query, registration_fields[i].name))) {
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1429 char *data = xmlnode_get_data(node);
26924
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1430 field = purple_request_field_string_new(registration_fields[i].name,
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1431 _(registration_fields[i].label),
26927
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1432 data, FALSE);
26924
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1433 purple_request_field_group_add_field(group, field);
26927
4676609b1855 Use defaults provided by the server where applicable and when available
Paul Aurich <darkrain42@pidgin.im>
parents: 26924
diff changeset
1434 g_free(data);
26924
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1435 }
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
1436 }
26924
fb6574724452 This is a little less...repetitious
Paul Aurich <darkrain42@pidgin.im>
parents: 26922
diff changeset
1437
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1438 if(registered) {
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1439 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
1440 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
1441 }
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1442
20320
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20316
diff changeset
1443 if((y = xmlnode_get_child(query, "instructions")))
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20316
diff changeset
1444 instructions = xmlnode_get_data(y);
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1445 else if(registered)
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1446 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
1447 "to change your account registration."));
20320
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20316
diff changeset
1448 else
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20316
diff changeset
1449 instructions = g_strdup(_("Please fill out the information below "
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20316
diff changeset
1450 "to register your new account."));
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1451
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
1452 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
1453 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
1454 cbdata->who = g_strdup(from);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1455
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
1456 if(js->registration)
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
1457 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
1458 _("Register New XMPP Account"), instructions, fields,
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1459 _("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
1460 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb),
34332
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34304
diff changeset
1461 purple_request_cpar_from_connection(js->gc),
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
1462 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
1463 else {
25604
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1464 char *title;
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1465 g_return_if_fail(from != NULL);
c963986ac373 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <darkrain42@pidgin.im>
parents: 25600
diff changeset
1466 title = registered ? g_strdup_printf(_("Change Account Registration at %s"), from)
18755
8c4ddce1fb46 Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1467 :g_strdup_printf(_("Register New Account at %s"), from);
34332
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34304
diff changeset
1468 purple_request_fields(js->gc, title, title, instructions,
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34304
diff changeset
1469 fields, (registered ? _("Change Registration") :
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34304
diff changeset
1470 _("Register")), G_CALLBACK(jabber_register_cb),
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34304
diff changeset
1471 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb),
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34304
diff changeset
1472 purple_request_cpar_from_connection(js->gc), 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
1473 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
1474 }
14140
fcb570e0b2db [gaim-migrate @ 16699]
Daniel Atallah <datallah@pidgin.im>
parents: 14115
diff changeset
1475
20320
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20316
diff changeset
1476 g_free(instructions);
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20316
diff changeset
1477 }
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1478
8016
d75a4e86f7c3 [gaim-migrate @ 8696]
Nathan Walp <nwalp@pidgin.im>
parents: 8013
diff changeset
1479 void jabber_register_start(JabberStream *js)
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1480 {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1481 JabberIq *iq;
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1482
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1483 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
1484 jabber_iq_send(iq);
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1485 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1486
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
1487 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
1488 JabberIq *iq;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
1489
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
1490 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
1491 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
1492 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
1493 }
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
1494
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
1495 void jabber_register_account(PurpleAccount *account)
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1496 {
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1497 JabberStream *js;
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1498
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1499 js = jabber_stream_new(account);
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1500 if (js == NULL)
7310
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
1501 return;
27850
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1502
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1503 js->registration = TRUE;
3087baaf7831 Refactor jabber_login and jabber_register_account
Paul Aurich <darkrain42@pidgin.im>
parents: 27779
diff changeset
1504 jabber_stream_connect(js);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1505 }
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1506
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1507 static void
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1508 jabber_unregister_account_iq_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1509 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1510 xmlnode *packet, gpointer data)
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1511 {
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
1512 PurpleAccount *account = purple_connection_get_account(js->gc);
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1513
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1514 if (type == JABBER_IQ_ERROR) {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
1515 char *msg = jabber_parse_error(js, packet, NULL);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
1516
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
1517 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
1518 _("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
1519 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
1520 if(js->unregistration_cb)
18995
6ba7743720cb Mixed up TRUE and FALSE.
Andreas Monitzer <am@adiumx.com>
parents: 18994
diff changeset
1521 js->unregistration_cb(account, FALSE, js->unregistration_user_data);
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1522 } else {
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
1523 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
1524 _("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
1525 if(js->unregistration_cb)
18995
6ba7743720cb Mixed up TRUE and FALSE.
Andreas Monitzer <am@adiumx.com>
parents: 18994
diff changeset
1526 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
1527 }
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
1528 }
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
1529
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
1530 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
1531 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
1532 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
1533
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1534 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
1535
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1536 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
1537
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1538 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
1539
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1540 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
1541 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
1542
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1543 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
1544 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
1545 }
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
1546
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
1547 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
1548 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
1549 JabberStream *js;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
1550
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32624
diff changeset
1551 if (purple_connection_get_state(gc) != PURPLE_CONNECTED) {
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32624
diff changeset
1552 if (purple_connection_get_state(gc) != PURPLE_CONNECTING)
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
1553 jabber_login(account);
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
1554 js = purple_connection_get_protocol_data(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
1555 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
1556 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
1557 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
1558 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
1559 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
1560
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
1561 js = purple_connection_get_protocol_data(gc);
19994
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1562
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1563 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
1564 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
1565 return;
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1566 }
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1567
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
1568 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
1569 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
1570 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
1571
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
1572 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
1573 }
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
1574
25727
1440163769e6 *** Plucked rev 4831edb9 (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25726
diff changeset
1575 /* TODO: As Will pointed out in IRC, after being notified by the core to
1440163769e6 *** Plucked rev 4831edb9 (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25726
diff changeset
1576 * shutdown, we should async. wait for the server to send us the stream
1440163769e6 *** Plucked rev 4831edb9 (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25726
diff changeset
1577 * termination before destorying everything. That seems like it would require
1440163769e6 *** Plucked rev 4831edb9 (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25726
diff changeset
1578 * changing the semantics of prpl->close(), so it's a good idea for 3.0.0.
1440163769e6 *** Plucked rev 4831edb9 (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25726
diff changeset
1579 */
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
1580 void jabber_close(PurpleConnection *gc)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1581 {
29264
ea88690768fe jabber: Remove a funky workaround for an (old) OpenSSL crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 29263
diff changeset
1582 JabberStream *js = purple_connection_get_protocol_data(gc);
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1583
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1584 /* Close all of the open Jingle sessions on this stream */
26143
673b6665624d Restructure Jingle code to more easily support multiple application types.
Michael Ruprecht <maiku@pidgin.im>
parents: 26117
diff changeset
1585 jingle_terminate_sessions(js);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 23696
diff changeset
1586
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34238
diff changeset
1587 if (js->bosh) {
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34238
diff changeset
1588 jabber_bosh_connection_destroy(js->bosh);
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34238
diff changeset
1589 js->bosh = NULL;
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34238
diff changeset
1590 } else if ((js->gsc && js->gsc->fd > 0) || js->fd > 0)
14003
5fab5dad7ab6 [gaim-migrate @ 16477]
Sean Egan <seanegan@pidgin.im>
parents: 13956
diff changeset
1591 jabber_send_raw(js, "</stream:stream>", -1);
3311
cdbc5795c717 [gaim-migrate @ 3329]
Nathan Walp <nwalp@pidgin.im>
parents: 3260
diff changeset
1592
14370
12ef3d4096ee [gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents: 14358
diff changeset
1593 if (js->srv_query_data)
32300
59a31f9f67fc Clean up SRV/TXT query functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32277
diff changeset
1594 purple_srv_txt_query_destroy(js->srv_query_data);
14370
12ef3d4096ee [gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents: 14358
diff changeset
1595
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1596 if(js->gsc) {
29264
ea88690768fe jabber: Remove a funky workaround for an (old) OpenSSL crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 29263
diff changeset
1597 purple_ssl_close(js->gsc);
8360
2976b7f18935 [gaim-migrate @ 9084]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1598 } else if (js->fd > 0) {
32684
edefbf316da1 Jabber: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents: 32679
diff changeset
1599 if(js->inpa) {
edefbf316da1 Jabber: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents: 32679
diff changeset
1600 purple_input_remove(js->inpa);
edefbf316da1 Jabber: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents: 32679
diff changeset
1601 js->inpa = 0;
edefbf316da1 Jabber: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents: 32679
diff changeset
1602 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1603 close(js->fd);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1604 }
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
1605
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
1606 jabber_buddy_remove_all_pending_buddy_info_requests(js);
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
1607
17810
c8d4297080cb Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <am@adiumx.com>
parents: 17806
diff changeset
1608 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
1609
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
1610 if(js->iq_callbacks)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
1611 g_hash_table_destroy(js->iq_callbacks);
7072
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1612 if(js->buddies)
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1613 g_hash_table_destroy(js->buddies);
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1614 if(js->chats)
f42abfd8486e [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
1615 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
1616
8043
86a087e9624c [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8016
diff changeset
1617 while(js->chat_servers) {
86a087e9624c [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8016
diff changeset
1618 g_free(js->chat_servers->data);
86a087e9624c [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8016
diff changeset
1619 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
1620 }
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
1621
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
1622 while(js->user_directories) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
1623 g_free(js->user_directories->data);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
1624 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
1625 }
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
1626
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
1627 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
1628 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
1629 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
1630 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
1631 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
1632 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
1633 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
1634 }
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
1635
34269
26b4c9a54166 HTTP: Use PurpleHttpConnectionSet instead of GSLists of PurpleHttpConnection structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34268
diff changeset
1636 purple_http_connection_set_destroy(js->http_conns);
24012
913d6f18cb95 Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <datallah@pidgin.im>
parents: 23911
diff changeset
1637
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
1638 g_free(js->stream_id);
7587
57f1a8a3542d [gaim-migrate @ 8205]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
1639 if(js->user)
57f1a8a3542d [gaim-migrate @ 8205]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
1640 jabber_id_free(js->user);
25811
57012229a242 Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents: 25808
diff changeset
1641 g_free(js->initial_avatar_hash);
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
1642 g_free(js->avatar_hash);
24716
047f5075ca58 Entity Capabilities must be per-JabberStream
Paul Aurich <darkrain42@pidgin.im>
parents: 24715
diff changeset
1643 g_free(js->caps_hash);
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
1644
30032
02bd634e0591 jabber: Stifle an assertion warning.
Paul Aurich <darkrain42@pidgin.im>
parents: 30013
diff changeset
1645 if (js->write_buffer)
02bd634e0591 jabber: Stifle an assertion warning.
Paul Aurich <darkrain42@pidgin.im>
parents: 30013
diff changeset
1646 purple_circ_buffer_destroy(js->write_buffer);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13154
diff changeset
1647 if(js->writeh)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1648 purple_input_remove(js->writeh);
28866
e3d867ce000b jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
1649 if (js->auth_mech && js->auth_mech->dispose)
e3d867ce000b jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
1650 js->auth_mech->dispose(js);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
1651 #ifdef HAVE_CYRUS_SASL
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
1652 if(js->sasl)
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
1653 sasl_dispose(&js->sasl);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
1654 if(js->sasl_mechs)
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 12394
diff changeset
1655 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
1656 g_free(js->sasl_cb);
30723
96e248b07586 jabber: Fix a pernicious race condition in our cyrus auth code
Paul Aurich <darkrain42@pidgin.im>
parents: 30688
diff changeset
1657 /* Note: _not_ g_free. See auth_cyrus.c:jabber_sasl_cb_secret */
96e248b07586 jabber: Fix a pernicious race condition in our cyrus auth code
Paul Aurich <darkrain42@pidgin.im>
parents: 30688
diff changeset
1658 free(js->sasl_secret);
18449
2d2df64f4303 applied changes from f9186fabb483b56a9d7e8fb7241b2520e9930413
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18235
diff changeset
1659 #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
1660 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
1661 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
1662 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
1663 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
1664 g_free(cmd->node);
17827
33575af6da8b Fixed copy/paste error.
Andreas Monitzer <am@adiumx.com>
parents: 17824
diff changeset
1665 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
1666 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
1667 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
1668 }
15198
08deb9b51708 [gaim-migrate @ 17922]
Sean Egan <seanegan@pidgin.im>
parents: 15185
diff changeset
1669 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
1670 g_free(js->certificate_CN);
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15205
diff changeset
1671 g_free(js->gmail_last_time);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15205
diff changeset
1672 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
1673 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
1674 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
1675 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
1676 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
1677 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
1678 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
1679 g_free(js->old_track);
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
1680
28046
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27924
diff changeset
1681 if (js->vcard_timer != 0)
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27924
diff changeset
1682 purple_timeout_remove(js->vcard_timer);
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27924
diff changeset
1683
27304
b2dc447b8c0b The XMPP keepalive timeout handle needs to be a guint.
Paul Aurich <darkrain42@pidgin.im>
parents: 27293
diff changeset
1684 if (js->keepalive_timeout != 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
1685 purple_timeout_remove(js->keepalive_timeout);
30056
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
1686 if (js->inactivity_timer != 0)
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
1687 purple_timeout_remove(js->inactivity_timer);
23910
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
1688
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
1689 g_free(js->srv_rec);
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
1690 js->srv_rec = NULL;
f8989c154a60 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <datallah@pidgin.im>
parents: 23539
diff changeset
1691
26286
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26269
diff changeset
1692 g_free(js->stun_ip);
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26269
diff changeset
1693 js->stun_ip = NULL;
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26269
diff changeset
1694
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26269
diff changeset
1695 /* cancel DNS query for STUN, if one is ongoing */
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26269
diff changeset
1696 if (js->stun_query) {
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26269
diff changeset
1697 purple_dnsquery_destroy(js->stun_query);
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26269
diff changeset
1698 js->stun_query = NULL;
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26269
diff changeset
1699 }
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27143
diff changeset
1700
28445
c3dbe0b64f44 Some unfinished code to take advantage of Google's relays
Marcus Lundblad <malu@pidgin.im>
parents: 28379
diff changeset
1701 /* remove Google relay-related stuff */
c3dbe0b64f44 Some unfinished code to take advantage of Google's relays
Marcus Lundblad <malu@pidgin.im>
parents: 28379
diff changeset
1702 g_free(js->google_relay_token);
c3dbe0b64f44 Some unfinished code to take advantage of Google's relays
Marcus Lundblad <malu@pidgin.im>
parents: 28379
diff changeset
1703 g_free(js->google_relay_host);
c3dbe0b64f44 Some unfinished code to take advantage of Google's relays
Marcus Lundblad <malu@pidgin.im>
parents: 28379
diff changeset
1704
23911
f54fe603e84a Fix a stupid mistake in the previous commit.
Daniel Atallah <datallah@pidgin.im>
parents: 23910
diff changeset
1705 g_free(js);
f54fe603e84a Fix a stupid mistake in the previous commit.
Daniel Atallah <datallah@pidgin.im>
parents: 23910
diff changeset
1706
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
1707 purple_connection_set_protocol_data(gc, NULL);
5093
7761492245e6 [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1708 }
7761492245e6 [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1709
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1710 void jabber_stream_set_state(JabberStream *js, JabberStreamState state)
3105
8c23b0ec1036 [gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3074
diff changeset
1711 {
28623
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28610
diff changeset
1712 #define JABBER_CONNECT_STEPS ((js->gsc || js->state == JABBER_STREAM_INITIALIZING_ENCRYPTION) ? 9 : 5)
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28610
diff changeset
1713
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1714 js->state = state;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1715 switch(state) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1716 case JABBER_STREAM_OFFLINE:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1717 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1718 case JABBER_STREAM_CONNECTING:
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1719 purple_connection_update_progress(js->gc, _("Connecting"), 1,
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1720 JABBER_CONNECT_STEPS);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1721 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1722 case JABBER_STREAM_INITIALIZING:
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1723 purple_connection_update_progress(js->gc, _("Initializing Stream"),
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1724 js->gsc ? 5 : 2, JABBER_CONNECT_STEPS);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1725 jabber_stream_init(js);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1726 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
1727 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
1728 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
1729 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
1730 break;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1731 case JABBER_STREAM_AUTHENTICATING:
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1732 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
1733 js->gsc ? 7 : 3, JABBER_CONNECT_STEPS);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1734 break;
28379
df144a809a92 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
1735 case JABBER_STREAM_POST_AUTH:
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1736 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
1737 (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
1738
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1739 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1740 case JABBER_STREAM_CONNECTED:
27278
b34a1cea4872 Use js->state to track whether the roster has been retrieved.
Paul Aurich <darkrain42@pidgin.im>
parents: 27231
diff changeset
1741 /* Send initial presence */
b34a1cea4872 Use js->state to track whether the roster has been retrieved.
Paul Aurich <darkrain42@pidgin.im>
parents: 27231
diff changeset
1742 jabber_presence_send(js, TRUE);
30056
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
1743 /* Start up the inactivity timer */
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
1744 jabber_stream_restart_inactivity_timer(js);
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
1745
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1746 purple_connection_set_state(js->gc, PURPLE_CONNECTED);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1747 break;
3105
8c23b0ec1036 [gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3074
diff changeset
1748 }
28623
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28610
diff changeset
1749
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28610
diff changeset
1750 #undef JABBER_CONNECT_STEPS
3105
8c23b0ec1036 [gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3074
diff changeset
1751 }
8c23b0ec1036 [gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3074
diff changeset
1752
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1753 char *jabber_get_next_id(JabberStream *js)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1754 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1755 return g_strdup_printf("purple%x", js->next_id++);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1756 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1757
14453
1cc75906700c [gaim-migrate @ 17098]
Mark Doliner <markdoliner@pidgin.im>
parents: 14375
diff changeset
1758
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
1759 void jabber_idle_set(PurpleConnection *gc, int idle)
3340
7e59a209931d [gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3337
diff changeset
1760 {
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
1761 JabberStream *js = purple_connection_get_protocol_data(gc);
3340
7e59a209931d [gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3337
diff changeset
1762
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1763 js->idle = idle ? time(NULL) - idle : idle;
26946
d33862e3c96f propagate from branch 'im.pidgin.pidgin' (head a495982a23a92e75616731c8f41a2b007670d0da)
Paul Aurich <darkrain42@pidgin.im>
parents: 26945 26874
diff changeset
1764
24676
27ea4d447838 A first stab at supporting the upcoming new use-case in XMPP XEP-0012
Marcus Lundblad <malu@pidgin.im>
parents: 24430
diff changeset
1765 /* send out an updated prescence */
27ea4d447838 A first stab at supporting the upcoming new use-case in XMPP XEP-0012
Marcus Lundblad <malu@pidgin.im>
parents: 24430
diff changeset
1766 purple_debug_info("jabber", "sending updated presence for idle\n");
26959
8482365bb2ec Fix merging.
Paul Aurich <darkrain42@pidgin.im>
parents: 26958
diff changeset
1767 jabber_presence_send(js, FALSE);
3314
12fa45677717 [gaim-migrate @ 3332]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3311
diff changeset
1768 }
12fa45677717 [gaim-migrate @ 3332]
Jim Seymour <jseymour@users.sourceforge.net>
parents: 3311
diff changeset
1769
27175
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1770 void jabber_blocklist_parse_push(JabberStream *js, const char *from,
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1771 JabberIqType type, const char *id,
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1772 xmlnode *child)
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1773 {
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1774 JabberIq *result;
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1775 xmlnode *item;
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1776 PurpleAccount *account;
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1777 gboolean is_block;
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1778
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1779 if (!jabber_is_own_account(js, from)) {
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1780 xmlnode *error, *x;
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1781 result = jabber_iq_new(js, JABBER_IQ_ERROR);
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1782 xmlnode_set_attrib(result->node, "id", id);
27182
641a77b2ee97 No, I had that right the first time; if it's not our account, then there *is* a from and we need to route the IQ to the proper place.
Paul Aurich <darkrain42@pidgin.im>
parents: 27181
diff changeset
1783 if (from)
641a77b2ee97 No, I had that right the first time; if it's not our account, then there *is* a from and we need to route the IQ to the proper place.
Paul Aurich <darkrain42@pidgin.im>
parents: 27181
diff changeset
1784 xmlnode_set_attrib(result->node, "to", from);
27175
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1785
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1786 error = xmlnode_new_child(result->node, "error");
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1787 xmlnode_set_attrib(error, "type", "cancel");
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1788 x = xmlnode_new_child(error, "not-allowed");
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
1789 xmlnode_set_namespace(x, NS_XMPP_STANZAS);
27175
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1790
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1791 jabber_iq_send(result);
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1792 return;
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1793 }
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1794
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1795 account = purple_connection_get_account(js->gc);
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1796 is_block = g_str_equal(child->name, "block");
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1797
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1798 item = xmlnode_get_child(child, "item");
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1799 if (!is_block && item == NULL) {
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1800 /* Unblock everyone */
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1801 purple_debug_info("jabber", "Received unblock push. Unblocking everyone.\n");
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1802
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1803 while (account->deny != NULL) {
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1804 purple_privacy_deny_remove(account, account->deny->data, TRUE);
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1805 }
27181
1a3c15400f3e Avoid an assertion failure and add an error case.
Paul Aurich <darkrain42@pidgin.im>
parents: 27176
diff changeset
1806 } else if (item == NULL) {
1a3c15400f3e Avoid an assertion failure and add an error case.
Paul Aurich <darkrain42@pidgin.im>
parents: 27176
diff changeset
1807 /* An empty <block/> is bogus */
1a3c15400f3e Avoid an assertion failure and add an error case.
Paul Aurich <darkrain42@pidgin.im>
parents: 27176
diff changeset
1808 xmlnode *error, *x;
1a3c15400f3e Avoid an assertion failure and add an error case.
Paul Aurich <darkrain42@pidgin.im>
parents: 27176
diff changeset
1809 result = jabber_iq_new(js, JABBER_IQ_ERROR);
1a3c15400f3e Avoid an assertion failure and add an error case.
Paul Aurich <darkrain42@pidgin.im>
parents: 27176
diff changeset
1810 xmlnode_set_attrib(result->node, "id", id);
1a3c15400f3e Avoid an assertion failure and add an error case.
Paul Aurich <darkrain42@pidgin.im>
parents: 27176
diff changeset
1811
1a3c15400f3e Avoid an assertion failure and add an error case.
Paul Aurich <darkrain42@pidgin.im>
parents: 27176
diff changeset
1812 error = xmlnode_new_child(result->node, "error");
1a3c15400f3e Avoid an assertion failure and add an error case.
Paul Aurich <darkrain42@pidgin.im>
parents: 27176
diff changeset
1813 xmlnode_set_attrib(error, "type", "modify");
1a3c15400f3e Avoid an assertion failure and add an error case.
Paul Aurich <darkrain42@pidgin.im>
parents: 27176
diff changeset
1814 x = xmlnode_new_child(error, "bad-request");
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
1815 xmlnode_set_namespace(x, NS_XMPP_STANZAS);
27181
1a3c15400f3e Avoid an assertion failure and add an error case.
Paul Aurich <darkrain42@pidgin.im>
parents: 27176
diff changeset
1816
1a3c15400f3e Avoid an assertion failure and add an error case.
Paul Aurich <darkrain42@pidgin.im>
parents: 27176
diff changeset
1817 jabber_iq_send(result);
1a3c15400f3e Avoid an assertion failure and add an error case.
Paul Aurich <darkrain42@pidgin.im>
parents: 27176
diff changeset
1818 return;
27175
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1819 } else {
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1820 for ( ; item; item = xmlnode_get_next_twin(item)) {
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1821 const char *jid = xmlnode_get_attrib(item, "jid");
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1822 if (jid == NULL || *jid == '\0')
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1823 continue;
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1824
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1825 if (is_block)
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1826 purple_privacy_deny_add(account, jid, TRUE);
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1827 else
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1828 purple_privacy_deny_remove(account, jid, TRUE);
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1829 }
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1830 }
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1831
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1832 result = jabber_iq_new(js, JABBER_IQ_RESULT);
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1833 xmlnode_set_attrib(result->node, "id", id);
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1834 jabber_iq_send(result);
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1835 }
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1836
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1837 static void jabber_blocklist_parse(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1838 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
1839 xmlnode *packet, gpointer data)
25290
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1840 {
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1841 xmlnode *blocklist, *item;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1842 PurpleAccount *account;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1843
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1844 blocklist = xmlnode_get_child_with_namespace(packet,
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
1845 "blocklist", NS_SIMPLE_BLOCKING);
25290
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1846 account = purple_connection_get_account(js->gc);
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1847
27176
0af9ce7c0694 The server list is definitive for who is blocked.
Paul Aurich <darkrain42@pidgin.im>
parents: 27175
diff changeset
1848 if (type == JABBER_IQ_ERROR || blocklist == NULL)
25290
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1849 return;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1850
27175
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1851 /* This is the only privacy method supported by XEP-0191 */
32623
547eacef0b63 Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32617
diff changeset
1852 purple_account_set_privacy_type(account, PURPLE_PRIVACY_DENY_USERS);
27175
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1853
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1854 /*
27176
0af9ce7c0694 The server list is definitive for who is blocked.
Paul Aurich <darkrain42@pidgin.im>
parents: 27175
diff changeset
1855 * TODO: When account->deny is something more than a hash table, this can
0af9ce7c0694 The server list is definitive for who is blocked.
Paul Aurich <darkrain42@pidgin.im>
parents: 27175
diff changeset
1856 * be re-written to find the set intersection and difference.
27175
e027ae421bf3 Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <darkrain42@pidgin.im>
parents: 27156
diff changeset
1857 */
27176
0af9ce7c0694 The server list is definitive for who is blocked.
Paul Aurich <darkrain42@pidgin.im>
parents: 27175
diff changeset
1858 while (account->deny)
0af9ce7c0694 The server list is definitive for who is blocked.
Paul Aurich <darkrain42@pidgin.im>
parents: 27175
diff changeset
1859 purple_privacy_deny_remove(account, account->deny->data, TRUE);
0af9ce7c0694 The server list is definitive for who is blocked.
Paul Aurich <darkrain42@pidgin.im>
parents: 27175
diff changeset
1860
25290
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1861 item = xmlnode_get_child(blocklist, "item");
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1862 while (item != NULL) {
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1863 const char *jid = xmlnode_get_attrib(item, "jid");
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1864 purple_privacy_deny_add(account, jid, TRUE);
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1865 item = xmlnode_get_next_twin(item);
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1866 }
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1867 }
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1868
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1869 void jabber_request_block_list(JabberStream *js)
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1870 {
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1871 JabberIq *iq;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1872 xmlnode *blocklist;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1873
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1874 iq = jabber_iq_new(js, JABBER_IQ_GET);
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1875
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1876 blocklist = xmlnode_new_child(iq->node, "blocklist");
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
1877 xmlnode_set_namespace(blocklist, NS_SIMPLE_BLOCKING);
25290
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1878
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1879 jabber_iq_set_callback(iq, jabber_blocklist_parse, NULL);
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1880
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1881 jabber_iq_send(iq);
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1882 }
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1883
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1884 void jabber_add_deny(PurpleConnection *gc, const char *who)
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1885 {
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1886 JabberStream *js;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1887 JabberIq *iq;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1888 xmlnode *block, *item;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1889
29094
1d72af8f11dd jabber: Clean up this code a little.
Paul Aurich <darkrain42@pidgin.im>
parents: 29085
diff changeset
1890 g_return_if_fail(who != NULL && *who != '\0');
1d72af8f11dd jabber: Clean up this code a little.
Paul Aurich <darkrain42@pidgin.im>
parents: 29085
diff changeset
1891
1d72af8f11dd jabber: Clean up this code a little.
Paul Aurich <darkrain42@pidgin.im>
parents: 29085
diff changeset
1892 js = purple_connection_get_protocol_data(gc);
25290
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1893 if (js == NULL)
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1894 return;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1895
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1896 if (js->server_caps & JABBER_CAP_GOOGLE_ROSTER)
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1897 {
29094
1d72af8f11dd jabber: Clean up this code a little.
Paul Aurich <darkrain42@pidgin.im>
parents: 29085
diff changeset
1898 jabber_google_roster_add_deny(js, who);
25290
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1899 return;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1900 }
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1901
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1902 if (!(js->server_caps & JABBER_CAP_BLOCKING))
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1903 {
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1904 purple_notify_error(NULL, _("Server doesn't support blocking"),
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1905 _("Server doesn't support blocking"), NULL);
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1906 return;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1907 }
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1908
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1909 iq = jabber_iq_new(js, JABBER_IQ_SET);
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1910
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1911 block = xmlnode_new_child(iq->node, "block");
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
1912 xmlnode_set_namespace(block, NS_SIMPLE_BLOCKING);
25290
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1913
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1914 item = xmlnode_new_child(block, "item");
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1915 xmlnode_set_attrib(item, "jid", who);
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1916
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1917 jabber_iq_send(iq);
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1918 }
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1919
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1920 void jabber_rem_deny(PurpleConnection *gc, const char *who)
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1921 {
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1922 JabberStream *js;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1923 JabberIq *iq;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1924 xmlnode *unblock, *item;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1925
29094
1d72af8f11dd jabber: Clean up this code a little.
Paul Aurich <darkrain42@pidgin.im>
parents: 29085
diff changeset
1926 g_return_if_fail(who != NULL && *who != '\0');
1d72af8f11dd jabber: Clean up this code a little.
Paul Aurich <darkrain42@pidgin.im>
parents: 29085
diff changeset
1927
1d72af8f11dd jabber: Clean up this code a little.
Paul Aurich <darkrain42@pidgin.im>
parents: 29085
diff changeset
1928 js = purple_connection_get_protocol_data(gc);
25290
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1929 if (js == NULL)
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1930 return;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1931
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1932 if (js->server_caps & JABBER_CAP_GOOGLE_ROSTER)
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1933 {
29094
1d72af8f11dd jabber: Clean up this code a little.
Paul Aurich <darkrain42@pidgin.im>
parents: 29085
diff changeset
1934 jabber_google_roster_rem_deny(js, who);
25290
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1935 return;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1936 }
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1937
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1938 if (!(js->server_caps & JABBER_CAP_BLOCKING))
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1939 return;
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1940
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1941 iq = jabber_iq_new(js, JABBER_IQ_SET);
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1942
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1943 unblock = xmlnode_new_child(iq->node, "unblock");
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
1944 xmlnode_set_namespace(unblock, NS_SIMPLE_BLOCKING);
25290
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1945
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1946 item = xmlnode_new_child(unblock, "item");
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1947 xmlnode_set_attrib(item, "jid", who);
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1948
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1949 jabber_iq_send(iq);
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1950 }
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 25242
diff changeset
1951
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
1952 void jabber_add_feature(const char *namespace, JabberFeatureEnabled cb) {
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
1953 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
1954
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19993
diff changeset
1955 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
1956
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
1957 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
1958 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
1959 feat->is_enabled = cb;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
1960
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1961 /* try to remove just in case it already exists in the list */
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
1962 jabber_remove_feature(namespace);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
1963
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1964 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
1965 }
e67998927a3c Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents: 17769
diff changeset
1966
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
1967 void jabber_remove_feature(const char *namespace) {
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1968 GList *feature;
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1969 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
1970 JabberFeature *feat = (JabberFeature*)feature->data;
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
1971 if(!strcmp(feat->namespace, namespace)) {
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1972 g_free(feat->namespace);
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1973 g_free(feature->data);
21623
722e905dd5b5 Fix #3669
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1974 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
1975 break;
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1976 }
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17775
diff changeset
1977 }
17770
e67998927a3c Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents: 17769
diff changeset
1978 }
e67998927a3c Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents: 17769
diff changeset
1979
24737
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
1980 static void jabber_features_destroy(void)
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
1981 {
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
1982 while (jabber_features) {
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
1983 JabberFeature *feature = jabber_features->data;
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
1984 g_free(feature->namespace);
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
1985 g_free(feature);
28760
a7129c0e7108 jabber: Oops. --leaks.
Paul Aurich <darkrain42@pidgin.im>
parents: 28734
diff changeset
1986 jabber_features = g_list_delete_link(jabber_features, jabber_features);
24737
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
1987 }
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
1988 }
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
1989
30512
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
1990 gint
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
1991 jabber_identity_compare(gconstpointer a, gconstpointer b)
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
1992 {
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
1993 const JabberIdentity *ac;
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
1994 const JabberIdentity *bc;
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
1995 gint cat_cmp;
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
1996 gint typ_cmp;
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
1997
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
1998 ac = a;
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
1999 bc = b;
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2000
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2001 if ((cat_cmp = strcmp(ac->category, bc->category)) == 0) {
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2002 if ((typ_cmp = strcmp(ac->type, bc->type)) == 0) {
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2003 if (!ac->lang && !bc->lang) {
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2004 return 0;
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2005 } else if (ac->lang && !bc->lang) {
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2006 return 1;
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2007 } else if (!ac->lang && bc->lang) {
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2008 return -1;
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2009 } else {
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2010 return strcmp(ac->lang, bc->lang);
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2011 }
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2012 } else {
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2013 return typ_cmp;
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2014 }
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2015 } else {
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2016 return cat_cmp;
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2017 }
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2018 }
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2019
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2020 void jabber_add_identity(const gchar *category, const gchar *type,
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2021 const gchar *lang, const gchar *name)
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2022 {
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
2023 GList *identity;
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
2024 JabberIdentity *ident;
30512
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2025
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
2026 /* both required according to XEP-0030 */
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
2027 g_return_if_fail(category != NULL);
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
2028 g_return_if_fail(type != NULL);
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27143
diff changeset
2029
30512
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2030 /* Check if this identity is already there... */
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2031 for (identity = jabber_identities; identity; identity = identity->next) {
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2032 JabberIdentity *id = identity->data;
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2033 if (g_str_equal(id->category, category) &&
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2034 g_str_equal(id->type, type) &&
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2035 purple_strequal(id->lang, lang))
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
2036 return;
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
2037 }
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
2038
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
2039 ident = g_new0(JabberIdentity, 1);
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
2040 ident->category = g_strdup(category);
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
2041 ident->type = g_strdup(type);
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
2042 ident->lang = g_strdup(lang);
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
2043 ident->name = g_strdup(name);
30512
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2044 jabber_identities = g_list_insert_sorted(jabber_identities, ident,
f0f51b3a3f30 jabber: Move another function out of caps.c...
Paul Aurich <darkrain42@pidgin.im>
parents: 30474
diff changeset
2045 jabber_identity_compare);
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
2046 }
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
2047
24737
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
2048 static void jabber_identities_destroy(void)
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
2049 {
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
2050 while (jabber_identities) {
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
2051 JabberIdentity *id = jabber_identities->data;
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
2052 g_free(id->category);
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
2053 g_free(id->type);
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
2054 g_free(id->lang);
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
2055 g_free(id->name);
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
2056 g_free(id);
28760
a7129c0e7108 jabber: Oops. --leaks.
Paul Aurich <darkrain42@pidgin.im>
parents: 28734
diff changeset
2057 jabber_identities = g_list_delete_link(jabber_identities, jabber_identities);
24737
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
2058 }
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
2059 }
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
2060
26533
5c74696c34d1 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents: 26531
diff changeset
2061 gboolean jabber_stream_is_ssl(JabberStream *js)
5c74696c34d1 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents: 26531
diff changeset
2062 {
5c74696c34d1 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents: 26531
diff changeset
2063 return (js->bosh && jabber_bosh_connection_is_ssl(js->bosh)) ||
5c74696c34d1 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents: 26531
diff changeset
2064 (!js->bosh && js->gsc);
5c74696c34d1 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents: 26531
diff changeset
2065 }
5c74696c34d1 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents: 26531
diff changeset
2066
30056
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2067 static gboolean
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2068 inactivity_cb(gpointer data)
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2069 {
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2070 JabberStream *js = data;
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2071
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2072 /* We want whatever is sent to set this. It's okay because
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2073 * the eventloop unsets it via the return FALSE.
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2074 */
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2075 js->inactivity_timer = 0;
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2076
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2077 if (js->bosh)
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2078 jabber_bosh_connection_send_keepalive(js->bosh);
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2079 else
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2080 jabber_send_raw(js, "\t", 1);
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2081
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2082 return FALSE;
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2083 }
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2084
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2085 void jabber_stream_restart_inactivity_timer(JabberStream *js)
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2086 {
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2087 if (js->inactivity_timer != 0) {
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2088 purple_timeout_remove(js->inactivity_timer);
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2089 js->inactivity_timer = 0;
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2090 }
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2091
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2092 g_return_if_fail(js->max_inactivity > 0);
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2093
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2094 js->inactivity_timer =
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2095 purple_timeout_add_seconds(js->max_inactivity,
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2096 inactivity_cb, js);
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2097 }
24dcb476e62b jabber: Send whitespace keepalives every two minutes of (outgoing) silence.
Paul Aurich <darkrain42@pidgin.im>
parents: 30036
diff changeset
2098
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
2099 const char *jabber_list_icon(PurpleAccount *a, PurpleBuddy *b)
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
2100 {
4687
91ad36873636 [gaim-migrate @ 4998]
Sean Egan <seanegan@pidgin.im>
parents: 4675
diff changeset
2101 return "jabber";
91ad36873636 [gaim-migrate @ 4998]
Sean Egan <seanegan@pidgin.im>
parents: 4675
diff changeset
2102 }
4916
11b8fd3f8ffc [gaim-migrate @ 5250]
Sean Egan <seanegan@pidgin.im>
parents: 4915
diff changeset
2103
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
2104 const char* jabber_list_emblem(PurpleBuddy *b)
4916
11b8fd3f8ffc [gaim-migrate @ 5250]
Sean Egan <seanegan@pidgin.im>
parents: 4915
diff changeset
2105 {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
2106 JabberStream *js;
13486
4ea1a712aaa3 [gaim-migrate @ 15861]
Daniel Atallah <datallah@pidgin.im>
parents: 13385
diff changeset
2107 JabberBuddy *jb = NULL;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2108 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(b));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
2109
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2110 if(!gc)
15558
6fb7a0ad8a0b clean up some compile warnings
Nathan Walp <nwalp@pidgin.im>
parents: 15524
diff changeset
2111 return NULL;
6fb7a0ad8a0b clean up some compile warnings
Nathan Walp <nwalp@pidgin.im>
parents: 15524
diff changeset
2112
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
2113 js = purple_connection_get_protocol_data(gc);
13486
4ea1a712aaa3 [gaim-migrate @ 15861]
Daniel Atallah <datallah@pidgin.im>
parents: 13385
diff changeset
2114 if(js)
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2115 jb = jabber_buddy_find(js, purple_buddy_get_name(b), FALSE);
5135
fbcfa5df4c5e [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
2116
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2117 if(!PURPLE_BUDDY_IS_ONLINE(b)) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
2118 if(jb && (jb->subscription & JABBER_SUB_PENDING ||
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
2119 !(jb->subscription & JABBER_SUB_TO)))
15524
8f365f9bf660 Emblems in the blist
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
2120 return "not-authorized";
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
2121 }
27292
1e8a952548f9 Whitespace + a change cluttering up the diff with im.pidgin.pidgin
Paul Aurich <darkrain42@pidgin.im>
parents: 27291
diff changeset
2122
25577
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2123 if (jb) {
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2124 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, NULL);
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2125 if (jbr) {
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31128
diff changeset
2126 const gchar *client_type =
25577
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2127 jabber_resource_get_identity_category_type(jbr, "client");
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31128
diff changeset
2128
25577
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2129 if (client_type) {
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2130 if (strcmp(client_type, "phone") == 0) {
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2131 return "mobile";
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2132 } else if (strcmp(client_type, "web") == 0) {
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2133 return "external";
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2134 } else if (strcmp(client_type, "handheld") == 0) {
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2135 return "hiptop";
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2136 } else if (strcmp(client_type, "bot") == 0) {
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2137 return "bot";
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2138 }
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2139 /* the default value "pc" falls through and has no emblem */
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2140 }
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2141 }
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25573
diff changeset
2142 }
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31128
diff changeset
2143
15524
8f365f9bf660 Emblems in the blist
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
2144 return NULL;
4916
11b8fd3f8ffc [gaim-migrate @ 5250]
Sean Egan <seanegan@pidgin.im>
parents: 4915
diff changeset
2145 }
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
2146
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
2147 char *jabber_status_text(PurpleBuddy *b)
2205
68c42ce8eba6 [gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 2170
diff changeset
2148 {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
2149 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
2150 JabberBuddy *jb = NULL;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2151 PurpleAccount *account = purple_buddy_get_account(b);
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2152 PurpleConnection *gc = purple_account_get_connection(account);
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2153
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
2154 if (gc && purple_connection_get_protocol_data(gc))
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
2155 jb = jabber_buddy_find(purple_connection_get_protocol_data(gc), purple_buddy_get_name(b), FALSE);
5234
8320a1cb0274 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
2156
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2157 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
2158 ret = g_strdup(_("Not Authorized"));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2159 } 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
2160 ret = g_strdup(jb->error_msg);
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2161 } else {
26868
5c99daf94155 Retrieve status message to display in Buddy List from PurplePresence.
Paul Aurich <darkrain42@pidgin.im>
parents: 26860
diff changeset
2162 PurplePresence *presence = purple_buddy_get_presence(b);
27775
b8569a76e02e Don't pre-escape jbr->status. Almost every place required it in unescaped
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27697
diff changeset
2163 PurpleStatus *status = purple_presence_get_active_status(presence);
27779
ad70fa8a4ae2 merge of 'fd813a8f4960b8769f6f6915d9f62df8b3992280'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27756 27775
diff changeset
2164 const char *message;
ad70fa8a4ae2 merge of 'fd813a8f4960b8769f6f6915d9f62df8b3992280'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27756 27775
diff changeset
2165
ad70fa8a4ae2 merge of 'fd813a8f4960b8769f6f6915d9f62df8b3992280'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27756 27775
diff changeset
2166 if((message = purple_status_get_attr_string(status, "message"))) {
ad70fa8a4ae2 merge of 'fd813a8f4960b8769f6f6915d9f62df8b3992280'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27756 27775
diff changeset
2167 ret = g_markup_escape_text(message, -1);
ad70fa8a4ae2 merge of 'fd813a8f4960b8769f6f6915d9f62df8b3992280'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27756 27775
diff changeset
2168 } else if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
ad70fa8a4ae2 merge of 'fd813a8f4960b8769f6f6915d9f62df8b3992280'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27756 27775
diff changeset
2169 PurpleStatus *status = purple_presence_get_status(presence, "tune");
ad70fa8a4ae2 merge of 'fd813a8f4960b8769f6f6915d9f62df8b3992280'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27756 27775
diff changeset
2170 const char *title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE);
ad70fa8a4ae2 merge of 'fd813a8f4960b8769f6f6915d9f62df8b3992280'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27756 27775
diff changeset
2171 const char *artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST);
ad70fa8a4ae2 merge of 'fd813a8f4960b8769f6f6915d9f62df8b3992280'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27756 27775
diff changeset
2172 const char *album = purple_status_get_attr_string(status, PURPLE_TUNE_ALBUM);
ad70fa8a4ae2 merge of 'fd813a8f4960b8769f6f6915d9f62df8b3992280'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27756 27775
diff changeset
2173 ret = purple_util_format_song_info(title, artist, album, NULL);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
2174 }
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
2175 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
2176
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
2177 return ret;
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2178 }
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2179
25840
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2180 static void
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27143
diff changeset
2181 jabber_tooltip_add_resource_text(JabberBuddyResource *jbr,
25840
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2182 PurpleNotifyUserInfo *user_info, gboolean multiple_resources)
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2183 {
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2184 char *text = NULL;
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2185 char *res = NULL;
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2186 char *label, *value;
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2187 const char *state;
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2188
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2189 if(jbr->status) {
27775
b8569a76e02e Don't pre-escape jbr->status. Almost every place required it in unescaped
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27697
diff changeset
2190 text = g_markup_escape_text(jbr->status, -1);
25840
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2191 }
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2192
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2193 if(jbr->name)
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2194 res = g_strdup_printf(" (%s)", jbr->name);
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2195
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2196 state = jabber_buddy_state_get_name(jbr->state);
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2197 if (text != NULL && !purple_utf8_strcasecmp(state, text)) {
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2198 g_free(text);
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2199 text = NULL;
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2200 }
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2201
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2202 label = g_strdup_printf("%s%s", _("Status"), (res ? res : ""));
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2203 value = g_strdup_printf("%s%s%s", state, (text ? ": " : ""), (text ? text : ""));
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2204
32191
a4668d9dc8d1 Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
2205 purple_notify_user_info_add_pair_html(user_info, label, value);
25840
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2206 g_free(label);
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2207 g_free(value);
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2208 g_free(text);
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27143
diff changeset
2209
25840
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2210 /* if the resource is idle, show that */
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2211 /* only show it if there is more than one resource available for
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2212 the buddy, since the "general" idleness will be shown anyway,
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2213 this way we can see see the idleness of lower-priority resources */
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2214 if (jbr->idle && multiple_resources) {
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27143
diff changeset
2215 gchar *idle_str =
25840
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2216 purple_str_seconds_to_string(time(NULL) - jbr->idle);
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2217 label = g_strdup_printf("%s%s", _("Idle"), (res ? res : ""));
32162
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
2218 purple_notify_user_info_add_pair_plaintext(user_info, label, idle_str);
25840
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2219 g_free(idle_str);
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2220 g_free(label);
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2221 }
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2222 g_free(res);
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2223 }
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2224
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
2225 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
2226 {
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
2227 JabberBuddy *jb;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2228 PurpleAccount *account;
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2229 PurpleConnection *gc;
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
2230 JabberStream *js;
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
2231
12970
c2f3b4dcf711 [gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents: 12948
diff changeset
2232 g_return_if_fail(b != NULL);
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2233
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2234 account = purple_buddy_get_account(b);
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2235 g_return_if_fail(account != NULL);
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
2236
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2237 gc = purple_account_get_connection(account);
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2238 g_return_if_fail(gc != NULL);
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
2239
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
2240 js = purple_connection_get_protocol_data(gc);
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
2241 g_return_if_fail(js != NULL);
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
2242
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
2243 jb = jabber_buddy_find(js, purple_buddy_get_name(b), FALSE);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
2244
8194
bf412cad6608 [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
2245 if(jb) {
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
2246 JabberBuddyResource *jbr = NULL;
21195
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
2247 PurplePresence *presence = purple_buddy_get_presence(b);
8194
bf412cad6608 [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
2248 const char *sub;
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
2249 GList *l;
19920
7b0d20da73d0 Don't put "Mood: \(null\) \(null\)" on XMPP buddies
Sean Egan <seanegan@pidgin.im>
parents: 19897
diff changeset
2250 const char *mood;
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27143
diff changeset
2251 gboolean multiple_resources =
25836
ed37c7a05f8a Only show idle time for idle resources in tooltip text when there is more than
Marcus Lundblad <malu@pidgin.im>
parents: 25532
diff changeset
2252 jb->resources && g_list_next(jb->resources);
25840
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2253 JabberBuddyResource *top_jbr = jabber_buddy_find_resource(jb, NULL);
25842
8da3a69dfa55 Remove some unused variables
Marcus Lundblad <malu@pidgin.im>
parents: 25841
diff changeset
2254
25840
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2255 /* resource-specific info for the top resource */
25843
67bc9c8a4b8d Avoid crashing when showing the tooltip of an offline buddy, oops :)
Marcus Lundblad <malu@pidgin.im>
parents: 25842
diff changeset
2256 if (top_jbr) {
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27143
diff changeset
2257 jabber_tooltip_add_resource_text(top_jbr, user_info,
25843
67bc9c8a4b8d Avoid crashing when showing the tooltip of an offline buddy, oops :)
Marcus Lundblad <malu@pidgin.im>
parents: 25842
diff changeset
2258 multiple_resources);
67bc9c8a4b8d Avoid crashing when showing the tooltip of an offline buddy, oops :)
Marcus Lundblad <malu@pidgin.im>
parents: 25842
diff changeset
2259 }
25842
8da3a69dfa55 Remove some unused variables
Marcus Lundblad <malu@pidgin.im>
parents: 25841
diff changeset
2260
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
2261 for(l=jb->resources; l; l = l->next) {
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
2262 jbr = l->data;
25840
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2263 /* the remaining resources */
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2264 if (jbr != top_jbr) {
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2265 jabber_tooltip_add_resource_text(jbr, user_info,
f703af7527a6 Always show the top resource first in the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25838
diff changeset
2266 multiple_resources);
12944
da8f60d43d88 [gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents: 12943
diff changeset
2267 }
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
2268 }
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
2269
12948
0867a553ed26 [gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents: 12944
diff changeset
2270 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
2271 PurpleStatus *status;
23413
b0b23ab674f0 The status type says that mood and moodtext are strings, so we don't
Mark Doliner <markdoliner@pidgin.im>
parents: 23325
diff changeset
2272
24912
9ae8349f0353 Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@pidgin.im>
parents: 24907
diff changeset
2273 status = purple_presence_get_status(presence, "mood");
9ae8349f0353 Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@pidgin.im>
parents: 24907
diff changeset
2274 mood = purple_status_get_attr_string(status, PURPLE_MOOD_NAME);
24905
dbe73df3dfa0 Check that mood is not the empty string, just to be safe.
Richard Laager <rlaager@pidgin.im>
parents: 24903
diff changeset
2275 if(mood && *mood) {
23413
b0b23ab674f0 The status type says that mood and moodtext are strings, so we don't
Mark Doliner <markdoliner@pidgin.im>
parents: 23325
diff changeset
2276 const char *moodtext;
29412
c27d9bb60878 Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
2277 /* find the mood */
c27d9bb60878 Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
2278 PurpleMood *moods = jabber_get_moods(account);
c27d9bb60878 Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
2279 const char *description = NULL;
c27d9bb60878 Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
2280
c27d9bb60878 Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
2281 for (; moods->mood ; moods++) {
c27d9bb60878 Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
2282 if (purple_strequal(moods->mood, mood)) {
c27d9bb60878 Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
2283 description = moods->description;
c27d9bb60878 Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
2284 break;
c27d9bb60878 Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
2285 }
c27d9bb60878 Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
2286 }
c27d9bb60878 Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
2287
24912
9ae8349f0353 Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@pidgin.im>
parents: 24907
diff changeset
2288 moodtext = purple_status_get_attr_string(status, PURPLE_MOOD_COMMENT);
24903
638ef56eb3c5 Do not show "Mood: mood ()" when there is no text.
Richard Laager <rlaager@pidgin.im>
parents: 24430
diff changeset
2289 if(moodtext && *moodtext) {
29412
c27d9bb60878 Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
2290 char *moodplustext =
c27d9bb60878 Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
2291 g_strdup_printf("%s (%s)", description ? _(description) : mood, moodtext);
23413
b0b23ab674f0 The status type says that mood and moodtext are strings, so we don't
Mark Doliner <markdoliner@pidgin.im>
parents: 23325
diff changeset
2292
32191
a4668d9dc8d1 Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
2293 purple_notify_user_info_add_pair_html(user_info, _("Mood"), moodplustext);
17780
749862fd4a87 Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents: 17779
diff changeset
2294 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
2295 } else
32191
a4668d9dc8d1 Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
2296 purple_notify_user_info_add_pair_html(user_info, _("Mood"),
29412
c27d9bb60878 Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
2297 description ? _(description) : mood);
21195
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
2298 }
22133
6eb22afb9701 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22111
diff changeset
2299 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
2300 PurpleStatus *tune = purple_presence_get_status(presence, "tune");
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
2301 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
2302 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
2303 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
2304 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
2305 if (playing) {
32191
a4668d9dc8d1 Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
2306 purple_notify_user_info_add_pair_html(user_info, _("Now Listening"), playing);
22133
6eb22afb9701 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22111
diff changeset
2307 g_free(playing);
6eb22afb9701 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22111
diff changeset
2308 }
21195
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 21193
diff changeset
2309 }
25838
db906dc27472 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25836
diff changeset
2310
db906dc27472 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25836
diff changeset
2311 if(jb->subscription & JABBER_SUB_FROM) {
db906dc27472 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25836
diff changeset
2312 if(jb->subscription & JABBER_SUB_TO)
db906dc27472 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25836
diff changeset
2313 sub = _("Both");
db906dc27472 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25836
diff changeset
2314 else if(jb->subscription & JABBER_SUB_PENDING)
db906dc27472 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25836
diff changeset
2315 sub = _("From (To pending)");
db906dc27472 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25836
diff changeset
2316 else
db906dc27472 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25836
diff changeset
2317 sub = _("From");
db906dc27472 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25836
diff changeset
2318 } else {
db906dc27472 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25836
diff changeset
2319 if(jb->subscription & JABBER_SUB_TO)
db906dc27472 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25836
diff changeset
2320 sub = _("To");
db906dc27472 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25836
diff changeset
2321 else if(jb->subscription & JABBER_SUB_PENDING)
db906dc27472 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25836
diff changeset
2322 sub = _("None (To pending)");
db906dc27472 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25836
diff changeset
2323 else
db906dc27472 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25836
diff changeset
2324 sub = _("None");
8194
bf412cad6608 [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
2325 }
bf412cad6608 [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
2326
32191
a4668d9dc8d1 Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
2327 purple_notify_user_info_add_pair_html(user_info, _("Subscription"), sub);
25838
db906dc27472 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <malu@pidgin.im>
parents: 25836
diff changeset
2328
11609
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
2329 }
6757f295785e [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
2330
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2331 if(!PURPLE_BUDDY_IS_ONLINE(b) && jb->error_msg) {
32191
a4668d9dc8d1 Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
2332 purple_notify_user_info_add_pair_html(user_info, _("Error"), jb->error_msg);
8194
bf412cad6608 [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
2333 }
4745
24867c379d37 [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
2334 }
4732
a0857625cadb [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4705
diff changeset
2335 }
a0857625cadb [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4705
diff changeset
2336
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
2337 GList *jabber_status_types(PurpleAccount *account)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
2338 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2339 PurpleStatusType *type;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
2340 GList *types = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2341 PurpleValue *priority_value;
24396
7f2eddefcbf3 Updated support for XEP-0224.
Marcus Lundblad <malu@pidgin.im>
parents: 24254
diff changeset
2342 PurpleValue *buzz_enabled;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
2343
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2344 priority_value = purple_value_new(PURPLE_TYPE_INT);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2345 purple_value_set_int(priority_value, 1);
24396
7f2eddefcbf3 Updated support for XEP-0224.
Marcus Lundblad <malu@pidgin.im>
parents: 24254
diff changeset
2346 buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
7f2eddefcbf3 Updated support for XEP-0224.
Marcus Lundblad <malu@pidgin.im>
parents: 24254
diff changeset
2347 purple_value_set_boolean(buzz_enabled, TRUE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2348 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2349 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_ONLINE),
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2350 NULL, TRUE, TRUE, FALSE,
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2351 "priority", _("Priority"), priority_value,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2352 "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
2353 "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
2354 "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
2355 "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
24396
7f2eddefcbf3 Updated support for XEP-0224.
Marcus Lundblad <malu@pidgin.im>
parents: 24254
diff changeset
2356 "buzz", _("Allow Buzz"), buzz_enabled,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2357 NULL);
24907
13118548c74c Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@pidgin.im>
parents: 24905
diff changeset
2358 types = g_list_prepend(types, type);
9980
ea4241d66fd1 [gaim-migrate @ 10891]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
2359
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31128
diff changeset
2360
29407
e4140d21900d Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <malu@pidgin.im>
parents: 29304
diff changeset
2361 type = purple_status_type_new_with_attrs(PURPLE_STATUS_MOOD,
e4140d21900d Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <malu@pidgin.im>
parents: 29304
diff changeset
2362 "mood", NULL, TRUE, TRUE, TRUE,
e4140d21900d Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <malu@pidgin.im>
parents: 29304
diff changeset
2363 PURPLE_MOOD_NAME, _("Mood Name"), purple_value_new(PURPLE_TYPE_STRING),
e4140d21900d Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <malu@pidgin.im>
parents: 29304
diff changeset
2364 PURPLE_MOOD_COMMENT, _("Mood Comment"), purple_value_new(PURPLE_TYPE_STRING),
e4140d21900d Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <malu@pidgin.im>
parents: 29304
diff changeset
2365 NULL);
e4140d21900d Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <malu@pidgin.im>
parents: 29304
diff changeset
2366 types = g_list_prepend(types, type);
e4140d21900d Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <malu@pidgin.im>
parents: 29304
diff changeset
2367
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2368 priority_value = purple_value_new(PURPLE_TYPE_INT);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2369 purple_value_set_int(priority_value, 1);
25956
71e85c4df8ed Patch from Darkrain42 to avoid a double-free on status values
Marcus Lundblad <malu@pidgin.im>
parents: 25954
diff changeset
2370 buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
71e85c4df8ed Patch from Darkrain42 to avoid a double-free on status values
Marcus Lundblad <malu@pidgin.im>
parents: 25954
diff changeset
2371 purple_value_set_boolean(buzz_enabled, TRUE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2372 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2373 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_CHAT),
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2374 _("Chatty"), TRUE, TRUE, FALSE,
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2375 "priority", _("Priority"), priority_value,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2376 "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
2377 "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
2378 "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
2379 "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
24396
7f2eddefcbf3 Updated support for XEP-0224.
Marcus Lundblad <malu@pidgin.im>
parents: 24254
diff changeset
2380 "buzz", _("Allow Buzz"), buzz_enabled,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2381 NULL);
24907
13118548c74c Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@pidgin.im>
parents: 24905
diff changeset
2382 types = g_list_prepend(types, type);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
2383
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2384 priority_value = purple_value_new(PURPLE_TYPE_INT);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2385 purple_value_set_int(priority_value, 0);
25956
71e85c4df8ed Patch from Darkrain42 to avoid a double-free on status values
Marcus Lundblad <malu@pidgin.im>
parents: 25954
diff changeset
2386 buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
71e85c4df8ed Patch from Darkrain42 to avoid a double-free on status values
Marcus Lundblad <malu@pidgin.im>
parents: 25954
diff changeset
2387 purple_value_set_boolean(buzz_enabled, TRUE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2388 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2389 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_AWAY),
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2390 NULL, TRUE, TRUE, FALSE,
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2391 "priority", _("Priority"), priority_value,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2392 "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
2393 "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
2394 "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
2395 "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
2396 "buzz", _("Allow Buzz"), buzz_enabled,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2397 NULL);
24907
13118548c74c Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@pidgin.im>
parents: 24905
diff changeset
2398 types = g_list_prepend(types, type);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
2399
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2400 priority_value = purple_value_new(PURPLE_TYPE_INT);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2401 purple_value_set_int(priority_value, 0);
25956
71e85c4df8ed Patch from Darkrain42 to avoid a double-free on status values
Marcus Lundblad <malu@pidgin.im>
parents: 25954
diff changeset
2402 buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
71e85c4df8ed Patch from Darkrain42 to avoid a double-free on status values
Marcus Lundblad <malu@pidgin.im>
parents: 25954
diff changeset
2403 purple_value_set_boolean(buzz_enabled, TRUE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2404 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
2405 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_XA),
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2406 NULL, TRUE, TRUE, FALSE,
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2407 "priority", _("Priority"), priority_value,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2408 "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
2409 "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
2410 "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
2411 "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
2412 "buzz", _("Allow Buzz"), buzz_enabled,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2413 NULL);
24907
13118548c74c Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@pidgin.im>
parents: 24905
diff changeset
2414 types = g_list_prepend(types, type);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
2415
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2416 priority_value = purple_value_new(PURPLE_TYPE_INT);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2417 purple_value_set_int(priority_value, 0);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2418 type = purple_status_type_new_with_attrs(PURPLE_STATUS_UNAVAILABLE,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2419 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_DND),
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2420 _("Do Not Disturb"), TRUE, TRUE, FALSE,
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2421 "priority", _("Priority"), priority_value,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2422 "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
2423 "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
2424 "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
2425 "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12554
diff changeset
2426 NULL);
24907
13118548c74c Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@pidgin.im>
parents: 24905
diff changeset
2427 types = g_list_prepend(types, type);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
2428
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
2429 /*
8166
0a109d9655c7 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8158
diff changeset
2430 if(js->protocol_version == JABBER_PROTO_0_9)
24907
13118548c74c Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@pidgin.im>
parents: 24905
diff changeset
2431 "Invisible"
10009
8a4fcc043f47 [gaim-migrate @ 10926]
Mark Doliner <markdoliner@pidgin.im>
parents: 9980
diff changeset
2432 */
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
2433
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2434 type = purple_status_type_new_with_attrs(PURPLE_STATUS_OFFLINE,
12658
4aa7a873628d [gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents: 12646
diff changeset
2435 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_UNAVAILABLE),
25552
ffd94785b2ad For some reason, all these statuses were set to saveable=FALSE. With the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25328
diff changeset
2436 NULL, TRUE, TRUE, FALSE,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2437 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
12658
4aa7a873628d [gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents: 12646
diff changeset
2438 NULL);
24907
13118548c74c Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@pidgin.im>
parents: 24905
diff changeset
2439 types = g_list_prepend(types, type);
12658
4aa7a873628d [gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents: 12646
diff changeset
2440
21193
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20332
diff changeset
2441 type = purple_status_type_new_with_attrs(PURPLE_STATUS_TUNE,
24693
9ab5d932ab6c I don't know why we'd want the TUNE status to be saveable.
Richard Laager <rlaager@pidgin.im>
parents: 24430
diff changeset
2442 "tune", NULL, FALSE, 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
2443 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
2444 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
2445 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
2446 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
2447 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
2448 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
2449 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
2450 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
2451 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
2452 NULL);
24907
13118548c74c Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@pidgin.im>
parents: 24905
diff changeset
2453 types = g_list_prepend(types, type);
21193
e918a1846d03 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20332
diff changeset
2454
24907
13118548c74c Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@pidgin.im>
parents: 24905
diff changeset
2455 return g_list_reverse(types);
2086
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
2456 }
007508451e2c [gaim-migrate @ 2096]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
2457
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
2458 static void
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
2459 jabber_password_change_result_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
2460 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
2461 xmlnode *packet, gpointer data)
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2462 {
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26686
diff changeset
2463 if (type == JABBER_IQ_RESULT) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2464 purple_notify_info(js->gc, _("Password Changed"), _("Password Changed"),
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2465 _("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
2466
34029
059c1270db1f Remove the silly destroy argument from purple_account_set_password and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34028
diff changeset
2467 purple_account_set_password(purple_connection_get_account(js->gc), (const char *)data, NULL, NULL);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2468 } else {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
2469 char *msg = jabber_parse_error(js, packet, NULL);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2470
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2471 purple_notify_error(js->gc, _("Error changing password"),
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2472 _("Error changing password"), msg);
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2473 g_free(msg);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2474 }
21129
91280f050201 This patch prevents changing the saved account password for XMPP accounts
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 21076
diff changeset
2475
91280f050201 This patch prevents changing the saved account password for XMPP accounts
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 21076
diff changeset
2476 g_free(data);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2477 }
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2478
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2479 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
2480 PurpleRequestFields *fields)
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2481 {
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2482 const char *p1, *p2;
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2483 JabberIq *iq;
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2484 xmlnode *query, *y;
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2485
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2486 p1 = purple_request_fields_get_string(fields, "password1");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2487 p2 = purple_request_fields_get_string(fields, "password2");
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2488
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2489 if(strcmp(p1, p2)) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2490 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
2491 return;
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2492 }
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2493
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2494 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
2495
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2496 xmlnode_set_attrib(iq->node, "to", js->user->domain);
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2497
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2498 query = xmlnode_get_child(iq->node, "query");
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2499
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2500 y = xmlnode_new_child(query, "username");
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2501 xmlnode_insert_data(y, js->user->node, -1);
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2502 y = xmlnode_new_child(query, "password");
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2503 xmlnode_insert_data(y, p1, -1);
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2504
21129
91280f050201 This patch prevents changing the saved account password for XMPP accounts
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 21076
diff changeset
2505 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
2506
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2507 jabber_iq_send(iq);
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2508 }
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2509
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2510 static void jabber_password_change(PurplePluginAction *action)
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2511 {
9015
3c27e9074fa2 [gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents: 8993
diff changeset
2512
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2513 PurpleConnection *gc = (PurpleConnection *) action->context;
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
2514 JabberStream *js = purple_connection_get_protocol_data(gc);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2515 PurpleRequestFields *fields;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2516 PurpleRequestFieldGroup *group;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2517 PurpleRequestField *field;
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2518
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2519 fields = purple_request_fields_new();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2520 group = purple_request_field_group_new(NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2521 purple_request_fields_add_group(fields, group);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2522
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2523 field = purple_request_field_string_new("password1", _("Password"),
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2524 "", FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2525 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
2526 purple_request_field_set_required(field, TRUE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2527 purple_request_field_group_add_field(group, field);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2528
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2529 field = purple_request_field_string_new("password2", _("Password (again)"),
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2530 "", FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2531 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
2532 purple_request_field_set_required(field, TRUE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2533 purple_request_field_group_add_field(group, field);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2534
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
2535 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
2536 _("Change XMPP Password"), _("Please enter your new password"),
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2537 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
2538 _("Cancel"), NULL,
34332
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34304
diff changeset
2539 purple_request_cpar_from_connection(gc), js);
7124
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2540 }
0cde72d7248c [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
2541
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
2542 GList *jabber_actions(PurplePlugin *plugin, gpointer context)
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2543 {
17782
83af68644d0a Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <am@adiumx.com>
parents: 17780
diff changeset
2544 PurpleConnection *gc = (PurpleConnection *) context;
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
2545 JabberStream *js = purple_connection_get_protocol_data(gc);
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2546 GList *m = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2547 PurplePluginAction *act;
4333
f4c095774bc2 [gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents: 4316
diff changeset
2548
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2549 act = purple_plugin_action_new(_("Set User Info..."),
12286
08d994091c36 [gaim-migrate @ 14590]
Etan Reisner <deryni@pidgin.im>
parents: 12284
diff changeset
2550 jabber_setup_set_info);
9015
3c27e9074fa2 [gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents: 8993
diff changeset
2551 m = g_list_append(m, act);
4333
f4c095774bc2 [gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents: 4316
diff changeset
2552
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
2553 /* if (js->protocol_options & CHANGE_PASSWORD) { */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2554 act = purple_plugin_action_new(_("Change Password..."),
12286
08d994091c36 [gaim-migrate @ 14590]
Etan Reisner <deryni@pidgin.im>
parents: 12284
diff changeset
2555 jabber_password_change);
9015
3c27e9074fa2 [gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents: 8993
diff changeset
2556 m = g_list_append(m, act);
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
2557 /* } */
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2558
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2559 act = purple_plugin_action_new(_("Search for Users..."),
12286
08d994091c36 [gaim-migrate @ 14590]
Etan Reisner <deryni@pidgin.im>
parents: 12284
diff changeset
2560 jabber_user_search_begin);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
2561 m = g_list_append(m, act);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
2562
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
2563 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
2564
17782
83af68644d0a Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <am@adiumx.com>
parents: 17780
diff changeset
2565 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
2566 jabber_pep_init_actions(&m);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
2567
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
2568 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
2569 jabber_adhoc_init_server_commands(js, &m);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
2570
2956
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2571 return m;
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2572 }
1836bfe768df [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2573
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
2574 PurpleChat *jabber_find_blist_chat(PurpleAccount *account, const char *name)
7999
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2575 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2576 PurpleBlistNode *gnode, *cnode;
7999
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2577 JabberID *jid;
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2578
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2579 if(!(jid = jabber_id_new(name)))
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2580 return NULL;
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2581
24945
6678a8c83797 Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24571
diff changeset
2582 for(gnode = purple_blist_get_root(); gnode;
6678a8c83797 Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24571
diff changeset
2583 gnode = purple_blist_node_get_sibling_next(gnode)) {
6678a8c83797 Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24571
diff changeset
2584 for(cnode = purple_blist_node_get_first_child(gnode);
6678a8c83797 Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24571
diff changeset
2585 cnode;
6678a8c83797 Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24571
diff changeset
2586 cnode = purple_blist_node_get_sibling_next(cnode)) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2587 PurpleChat *chat = (PurpleChat*)cnode;
7999
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2588 const char *room, *server;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2589 GHashTable *components;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2590 if(!PURPLE_BLIST_NODE_IS_CHAT(cnode))
7999
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2591 continue;
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2592
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2593 if (purple_chat_get_account(chat) != account)
8011
e9ac8bfe26da [gaim-migrate @ 8691]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
2594 continue;
7999
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2595
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2596 components = purple_chat_get_components(chat);
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2597 if(!(room = g_hash_table_lookup(components, "room")))
7999
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2598 continue;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24254
diff changeset
2599 if(!(server = g_hash_table_lookup(components, "server")))
7999
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2600 continue;
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2601
31441
84ef3d484bd4 jabber: Use a straight equality check instead of collate
Paul Aurich <darkrain42@pidgin.im>
parents: 31294
diff changeset
2602 /* FIXME: Collate is wrong in a few cases here; this should be prepped */
8158
a62f04d81823 [gaim-migrate @ 8870]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
2603 if(jid->node && jid->domain &&
a62f04d81823 [gaim-migrate @ 8870]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
2604 !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
2605 jabber_id_free(jid);
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2606 return chat;
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2607 }
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2608 }
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2609 }
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2610 jabber_id_free(jid);
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2611 return NULL;
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2612 }
f3f95e0c956a [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
2613
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
2614 void jabber_convo_closed(PurpleConnection *gc, const char *who)
8400
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2615 {
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
2616 JabberStream *js = purple_connection_get_protocol_data(gc);
8400
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2617 JabberID *jid;
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2618 JabberBuddy *jb;
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2619 JabberBuddyResource *jbr;
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2620
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2621 if(!(jid = jabber_id_new(who)))
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2622 return;
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2623
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2624 if((jb = jabber_buddy_find(js, who, TRUE)) &&
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2625 (jbr = jabber_buddy_find_resource(jb, jid->resource))) {
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2626 if(jbr->thread_id) {
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2627 g_free(jbr->thread_id);
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2628 jbr->thread_id = NULL;
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2629 }
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2630 }
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2631
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2632 jabber_id_free(jid);
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2633 }
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
2634
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2635
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
2636 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
2637 xmlnode *packet,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
2638 PurpleConnectionError *reason)
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2639 {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2640 xmlnode *error;
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2641 const char *code = NULL, *text = NULL;
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13806
diff changeset
2642 const char *xmlns = xmlnode_get_namespace(packet);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2643 char *cdata = NULL;
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2644
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
2645 #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
2646 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
2647
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2648 if((error = xmlnode_get_child(packet, "error"))) {
30816
732b1d828b03 jabber: Catch resource conflict IQ stanza errors returned by server
Paul Aurich <darkrain42@pidgin.im>
parents: 30777
diff changeset
2649 xmlnode *t = xmlnode_get_child_with_namespace(error, "text", NS_XMPP_STANZAS);
732b1d828b03 jabber: Catch resource conflict IQ stanza errors returned by server
Paul Aurich <darkrain42@pidgin.im>
parents: 30777
diff changeset
2650 if (t)
732b1d828b03 jabber: Catch resource conflict IQ stanza errors returned by server
Paul Aurich <darkrain42@pidgin.im>
parents: 30777
diff changeset
2651 cdata = xmlnode_get_data(t);
732b1d828b03 jabber: Catch resource conflict IQ stanza errors returned by server
Paul Aurich <darkrain42@pidgin.im>
parents: 30777
diff changeset
2652 #if 0
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2653 cdata = xmlnode_get_data(error);
30816
732b1d828b03 jabber: Catch resource conflict IQ stanza errors returned by server
Paul Aurich <darkrain42@pidgin.im>
parents: 30777
diff changeset
2654 #endif
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2655 code = xmlnode_get_attrib(error, "code");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2656
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2657 /* Stanza errors */
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2658 if(xmlnode_get_child(error, "bad-request")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2659 text = _("Bad Request");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2660 } else if(xmlnode_get_child(error, "conflict")) {
30816
732b1d828b03 jabber: Catch resource conflict IQ stanza errors returned by server
Paul Aurich <darkrain42@pidgin.im>
parents: 30777
diff changeset
2661 SET_REASON(PURPLE_CONNECTION_ERROR_NAME_IN_USE);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2662 text = _("Conflict");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2663 } else if(xmlnode_get_child(error, "feature-not-implemented")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2664 text = _("Feature Not Implemented");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2665 } else if(xmlnode_get_child(error, "forbidden")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2666 text = _("Forbidden");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2667 } else if(xmlnode_get_child(error, "gone")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2668 text = _("Gone");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2669 } else if(xmlnode_get_child(error, "internal-server-error")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2670 text = _("Internal Server Error");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2671 } else if(xmlnode_get_child(error, "item-not-found")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2672 text = _("Item Not Found");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2673 } 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
2674 text = _("Malformed XMPP ID");
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2675 } else if(xmlnode_get_child(error, "not-acceptable")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2676 text = _("Not Acceptable");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2677 } else if(xmlnode_get_child(error, "not-allowed")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2678 text = _("Not Allowed");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2679 } else if(xmlnode_get_child(error, "not-authorized")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2680 text = _("Not Authorized");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2681 } else if(xmlnode_get_child(error, "payment-required")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2682 text = _("Payment Required");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2683 } else if(xmlnode_get_child(error, "recipient-unavailable")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2684 text = _("Recipient Unavailable");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2685 } else if(xmlnode_get_child(error, "redirect")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2686 /* XXX */
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2687 } else if(xmlnode_get_child(error, "registration-required")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2688 text = _("Registration Required");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2689 } else if(xmlnode_get_child(error, "remote-server-not-found")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2690 text = _("Remote Server Not Found");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2691 } else if(xmlnode_get_child(error, "remote-server-timeout")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2692 text = _("Remote Server Timeout");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2693 } else if(xmlnode_get_child(error, "resource-constraint")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2694 text = _("Server Overloaded");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2695 } else if(xmlnode_get_child(error, "service-unavailable")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2696 text = _("Service Unavailable");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2697 } else if(xmlnode_get_child(error, "subscription-required")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2698 text = _("Subscription Required");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2699 } else if(xmlnode_get_child(error, "unexpected-request")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2700 text = _("Unexpected Request");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2701 } else if(xmlnode_get_child(error, "undefined-condition")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2702 text = _("Unknown Error");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2703 }
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
2704 } else if(xmlns && !strcmp(xmlns, 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
2705 /* 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
2706 SET_REASON(PURPLE_CONNECTION_ERROR_NETWORK_ERROR);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2707 if(xmlnode_get_child(packet, "aborted")) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2708 text = _("Authorization Aborted");
13806
70aa4bd581e5 [gaim-migrate @ 16223]
Sean Egan <seanegan@pidgin.im>
parents: 13746
diff changeset
2709 } else if(xmlnode_get_child(packet, "incorrect-encoding")) {
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2710 text = _("Incorrect encoding in authorization");
13806
70aa4bd581e5 [gaim-migrate @ 16223]
Sean Egan <seanegan@pidgin.im>
parents: 13746
diff changeset
2711 } else if(xmlnode_get_child(packet, "invalid-authzid")) {
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2712 text = _("Invalid authzid");
13806
70aa4bd581e5 [gaim-migrate @ 16223]
Sean Egan <seanegan@pidgin.im>
parents: 13746
diff changeset
2713 } else if(xmlnode_get_child(packet, "invalid-mechanism")) {
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2714 text = _("Invalid Authorization Mechanism");
13806
70aa4bd581e5 [gaim-migrate @ 16223]
Sean Egan <seanegan@pidgin.im>
parents: 13746
diff changeset
2715 } 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
2716 SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2717 text = _("Authorization mechanism too weak");
13806
70aa4bd581e5 [gaim-migrate @ 16223]
Sean Egan <seanegan@pidgin.im>
parents: 13746
diff changeset
2718 } 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
2719 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
2720 /* Clear the pasword if it isn't being saved */
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32624
diff changeset
2721 if (!purple_account_get_remember_password(purple_connection_get_account(js->gc)))
34029
059c1270db1f Remove the silly destroy argument from purple_account_set_password and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34028
diff changeset
2722 purple_account_set_password(purple_connection_get_account(js->gc), NULL, NULL, NULL);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2723 text = _("Not Authorized");
13806
70aa4bd581e5 [gaim-migrate @ 16223]
Sean Egan <seanegan@pidgin.im>
parents: 13746
diff changeset
2724 } else if(xmlnode_get_child(packet, "temporary-auth-failure")) {
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2725 text = _("Temporary Authentication Failure");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2726 } else {
21284
69472e4a5458 Having read the XMPP SASL specification, these errors seem more accurate.
Will Thompson <resiak@pidgin.im>
parents: 21281
diff changeset
2727 SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2728 text = _("Authentication Failure");
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2729 }
15979
acfbd09bc217 Correctly handle the Jabber disconnection error for signing onto the
Mark Doliner <markdoliner@pidgin.im>
parents: 15977
diff changeset
2730 } 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
2731 (!strcmp(packet->name, "error") && xmlns &&
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
2732 !strcmp(xmlns, NS_XMPP_STREAMS))) {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
2733 /* Most common reason as default: */
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
2734 SET_REASON(PURPLE_CONNECTION_ERROR_NETWORK_ERROR);
8402
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2735 if(xmlnode_get_child(packet, "bad-format")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2736 text = _("Bad Format");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2737 } else if(xmlnode_get_child(packet, "bad-namespace-prefix")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2738 text = _("Bad Namespace Prefix");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2739 } else if(xmlnode_get_child(packet, "conflict")) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21211
diff changeset
2740 SET_REASON(PURPLE_CONNECTION_ERROR_NAME_IN_USE);
8402
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2741 text = _("Resource Conflict");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2742 } else if(xmlnode_get_child(packet, "connection-timeout")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2743 text = _("Connection Timeout");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2744 } else if(xmlnode_get_child(packet, "host-gone")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2745 text = _("Host Gone");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2746 } else if(xmlnode_get_child(packet, "host-unknown")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2747 text = _("Host Unknown");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2748 } else if(xmlnode_get_child(packet, "improper-addressing")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2749 text = _("Improper Addressing");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2750 } else if(xmlnode_get_child(packet, "internal-server-error")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2751 text = _("Internal Server Error");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2752 } else if(xmlnode_get_child(packet, "invalid-id")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2753 text = _("Invalid ID");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2754 } else if(xmlnode_get_child(packet, "invalid-namespace")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2755 text = _("Invalid Namespace");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2756 } else if(xmlnode_get_child(packet, "invalid-xml")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2757 text = _("Invalid XML");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2758 } else if(xmlnode_get_child(packet, "nonmatching-hosts")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2759 text = _("Non-matching Hosts");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2760 } else if(xmlnode_get_child(packet, "not-authorized")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2761 text = _("Not Authorized");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2762 } else if(xmlnode_get_child(packet, "policy-violation")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2763 text = _("Policy Violation");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2764 } else if(xmlnode_get_child(packet, "remote-connection-failed")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2765 text = _("Remote Connection Failed");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2766 } else if(xmlnode_get_child(packet, "resource-constraint")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2767 text = _("Resource Constraint");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2768 } else if(xmlnode_get_child(packet, "restricted-xml")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2769 text = _("Restricted XML");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2770 } else if(xmlnode_get_child(packet, "see-other-host")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2771 text = _("See Other Host");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2772 } else if(xmlnode_get_child(packet, "system-shutdown")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2773 text = _("System Shutdown");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2774 } else if(xmlnode_get_child(packet, "undefined-condition")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2775 text = _("Undefined Condition");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2776 } else if(xmlnode_get_child(packet, "unsupported-encoding")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2777 text = _("Unsupported Encoding");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2778 } else if(xmlnode_get_child(packet, "unsupported-stanza-type")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2779 text = _("Unsupported Stanza Type");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2780 } else if(xmlnode_get_child(packet, "unsupported-version")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2781 text = _("Unsupported Version");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2782 } else if(xmlnode_get_child(packet, "xml-not-well-formed")) {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2783 text = _("XML Not Well Formed");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2784 } else {
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2785 text = _("Stream Error");
111951d7c7f4 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
2786 }
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2787 }
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2788
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
2789 #undef SET_REASON
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
2790
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2791 if(text || cdata) {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2792 char *ret = g_strdup_printf("%s%s%s", code ? code : "",
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2793 code ? ": " : "", text ? text : cdata);
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2794 g_free(cdata);
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2795 return ret;
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2796 } else {
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2797 return NULL;
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2798 }
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2799 }
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
2800
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2801 static PurpleCmdRet jabber_cmd_chat_config(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2802 const char *cmd, char **args, char **error, void *data)
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2803 {
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2804 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
2805
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2806 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
2807 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
2808
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2809 jabber_chat_request_room_configure(chat);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2810 return PURPLE_CMD_RET_OK;
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2811 }
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2812
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2813 static PurpleCmdRet jabber_cmd_chat_register(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2814 const char *cmd, char **args, char **error, void *data)
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2815 {
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2816 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
2817
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2818 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
2819 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
2820
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2821 jabber_chat_register(chat);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2822 return PURPLE_CMD_RET_OK;
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2823 }
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2824
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2825 static PurpleCmdRet jabber_cmd_chat_topic(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2826 const char *cmd, char **args, char **error, void *data)
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2827 {
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2828 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
2829
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2830 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
2831 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
2832
26859
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2833 if (args && args[0] && *args[0])
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2834 jabber_chat_change_topic(chat, args[0]);
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2835 else {
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2836 const char *cur = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(conv));
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2837 char *buf, *tmp, *tmp2;
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2838
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2839 if (cur) {
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2840 tmp = g_markup_escape_text(cur, -1);
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2841 tmp2 = purple_markup_linkify(tmp);
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2842 buf = g_strdup_printf(_("current topic is: %s"), tmp2);
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2843 g_free(tmp);
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2844 g_free(tmp2);
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2845 } else
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2846 buf = g_strdup(_("No topic is set"));
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2847 purple_conv_chat_write(PURPLE_CONV_CHAT(conv), "", buf,
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2848 PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2849 g_free(buf);
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2850 }
8175186cf34a Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents: 26798
diff changeset
2851
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2852 return PURPLE_CMD_RET_OK;
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2853 }
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2854
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2855 static PurpleCmdRet jabber_cmd_chat_nick(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2856 const char *cmd, char **args, char **error, void *data)
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2857 {
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2858 JabberChat *chat = jabber_chat_find_by_conv(conv);
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2859
18986
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2860 if(!chat || !args || !args[0])
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2861 return PURPLE_CMD_RET_FAILED;
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2862
28734
886d6c5e8f9a jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <darkrain42@pidgin.im>
parents: 28702
diff changeset
2863 if (!jabber_resourceprep_validate(args[0])) {
886d6c5e8f9a jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <darkrain42@pidgin.im>
parents: 28702
diff changeset
2864 *error = g_strdup(_("Invalid nickname"));
886d6c5e8f9a jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <darkrain42@pidgin.im>
parents: 28702
diff changeset
2865 return PURPLE_CMD_RET_FAILED;
886d6c5e8f9a jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <darkrain42@pidgin.im>
parents: 28702
diff changeset
2866 }
886d6c5e8f9a jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <darkrain42@pidgin.im>
parents: 28702
diff changeset
2867
886d6c5e8f9a jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <darkrain42@pidgin.im>
parents: 28702
diff changeset
2868 if (jabber_chat_change_nick(chat, args[0]))
886d6c5e8f9a jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <darkrain42@pidgin.im>
parents: 28702
diff changeset
2869 return PURPLE_CMD_RET_OK;
886d6c5e8f9a jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <darkrain42@pidgin.im>
parents: 28702
diff changeset
2870 else
886d6c5e8f9a jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <darkrain42@pidgin.im>
parents: 28702
diff changeset
2871 return PURPLE_CMD_RET_FAILED;
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2872 }
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2873
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2874 static PurpleCmdRet jabber_cmd_chat_part(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2875 const char *cmd, char **args, char **error, void *data)
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2876 {
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2877 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
2878
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2879 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
2880 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
2881
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2882 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
2883 return PURPLE_CMD_RET_OK;
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2884 }
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
2885
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2886 static PurpleCmdRet jabber_cmd_chat_ban(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2887 const char *cmd, char **args, char **error, void *data)
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2888 {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2889 JabberChat *chat = jabber_chat_find_by_conv(conv);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2890
18986
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
2891 if(!chat || !args || !args[0])
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2892 return PURPLE_CMD_RET_FAILED;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2893
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2894 if(!jabber_chat_ban_user(chat, args[0], args[1])) {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2895 *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
2896 return PURPLE_CMD_RET_FAILED;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2897 }
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2898
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2899 return PURPLE_CMD_RET_OK;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2900 }
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2901
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2902 static PurpleCmdRet jabber_cmd_chat_affiliate(PurpleConversation *conv,
11393
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2903 const char *cmd, char **args, char **error, void *data)
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2904 {
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2905 JabberChat *chat = jabber_chat_find_by_conv(conv);
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2906
27027
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2907 if (!chat || !args || !args[0])
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2908 return PURPLE_CMD_RET_FAILED;
11393
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2909
27027
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2910 if (strcmp(args[0], "owner") != 0 &&
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2911 strcmp(args[0], "admin") != 0 &&
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2912 strcmp(args[0], "member") != 0 &&
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2913 strcmp(args[0], "outcast") != 0 &&
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2914 strcmp(args[0], "none") != 0) {
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2915 *error = g_strdup_printf(_("Unknown affiliation: \"%s\""), args[0]);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2916 return PURPLE_CMD_RET_FAILED;
11393
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2917 }
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2918
27027
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2919 if (args[1]) {
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2920 int i;
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2921 char **nicks = g_strsplit(args[1], " ", -1);
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2922
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2923 for (i = 0; nicks[i]; ++i)
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2924 if (!jabber_chat_affiliate_user(chat, nicks[i], args[0])) {
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2925 *error = g_strdup_printf(_("Unable to affiliate user %s as \"%s\""), nicks[i], args[0]);
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2926 g_strfreev(nicks);
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2927 return PURPLE_CMD_RET_FAILED;
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2928 }
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2929
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2930 g_strfreev(nicks);
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2931 } else {
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2932 jabber_chat_affiliation_list(chat, args[0]);
11393
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2933 }
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2934
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2935 return PURPLE_CMD_RET_OK;
11393
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2936 }
71e7a8e33810 [gaim-migrate @ 13623]
Ken Tossell
parents: 11389
diff changeset
2937
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2938 static PurpleCmdRet jabber_cmd_chat_role(PurpleConversation *conv,
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2939 const char *cmd, char **args, char **error, void *data)
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2940 {
19217
ee1aa7e4c462 Fix uninitialized variable access.
Daniel Atallah <datallah@pidgin.im>
parents: 18986
diff changeset
2941 JabberChat *chat = jabber_chat_find_by_conv(conv);
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2942
27027
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2943 if (!chat || !args || !args[0])
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2944 return PURPLE_CMD_RET_FAILED;
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2945
27027
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2946 if (strcmp(args[0], "moderator") != 0 &&
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2947 strcmp(args[0], "participant") != 0 &&
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2948 strcmp(args[0], "visitor") != 0 &&
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2949 strcmp(args[0], "none") != 0) {
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2950 *error = g_strdup_printf(_("Unknown role: \"%s\""), args[0]);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2951 return PURPLE_CMD_RET_FAILED;
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2952 }
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2953
27027
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2954 if (args[1]) {
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2955 int i;
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2956 char **nicks = g_strsplit(args[1], " ", -1);
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2957
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2958 for (i = 0; nicks[i]; i++)
29400
8d8ad40c9c7d jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
Paul Aurich <darkrain42@pidgin.im>
parents: 29398
diff changeset
2959 if (!jabber_chat_role_user(chat, nicks[i], args[0], NULL)) {
27027
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2960 *error = g_strdup_printf(_("Unable to set role \"%s\" for user: %s"),
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2961 args[0], nicks[i]);
29398
3c31c5db18e9 jabber: Possible leaks--;
Paul Aurich <darkrain42@pidgin.im>
parents: 29370
diff changeset
2962 g_strfreev(nicks);
27027
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2963 return PURPLE_CMD_RET_FAILED;
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2964 }
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2965
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2966 g_strfreev(nicks);
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2967 } else {
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
2968 jabber_chat_role_list(chat, args[0]);
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2969 }
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2970 return PURPLE_CMD_RET_OK;
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2971 }
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
2972
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2973 static PurpleCmdRet jabber_cmd_chat_invite(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2974 const char *cmd, char **args, char **error, void *data)
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2975 {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2976 if(!args || !args[0])
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2977 return PURPLE_CMD_RET_FAILED;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2978
32698
154e4a2a6287 Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32684
diff changeset
2979 jabber_chat_invite(purple_conversation_get_connection(conv),
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2980 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
2981 args[0]);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2982
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2983 return PURPLE_CMD_RET_OK;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2984 }
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2985
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2986 static PurpleCmdRet jabber_cmd_chat_join(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
2987 const char *cmd, char **args, char **error, void *data)
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2988 {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2989 JabberChat *chat = jabber_chat_find_by_conv(conv);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2990 GHashTable *components;
31967
8ca00a04051e jabber: Fix /join behavior. Closes #14205.
Paul Aurich <darkrain42@pidgin.im>
parents: 31928
diff changeset
2991 JabberID *jid = NULL;
31510
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
2992 const char *room = NULL, *server = NULL, *handle = NULL;
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
2993
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
2994 if (!chat || !args || !args[0])
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2995 return PURPLE_CMD_RET_FAILED;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2996
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
2997 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
2998
31967
8ca00a04051e jabber: Fix /join behavior. Closes #14205.
Paul Aurich <darkrain42@pidgin.im>
parents: 31928
diff changeset
2999 if (strchr(args[0], '@'))
8ca00a04051e jabber: Fix /join behavior. Closes #14205.
Paul Aurich <darkrain42@pidgin.im>
parents: 31928
diff changeset
3000 jid = jabber_id_new(args[0]);
31510
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3001 if (jid) {
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3002 room = jid->node;
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3003 server = jid->domain;
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3004 handle = jid->resource ? jid->resource : chat->handle;
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3005 } else {
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3006 /* If jabber_id_new failed, the user may have just passed in
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3007 * a room name. For backward compatibility, handle that here.
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3008 */
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3009 if (strchr(args[0], '@')) {
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3010 *error = g_strdup(_("Invalid XMPP ID"));
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3011 return PURPLE_CMD_RET_FAILED;
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3012 }
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3013
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3014 room = args[0];
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3015 server = chat->server;
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3016 handle = chat->handle;
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3017 }
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3018
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3019 g_hash_table_insert(components, "room", (gpointer)room);
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3020 g_hash_table_insert(components, "server", (gpointer)server);
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3021 g_hash_table_insert(components, "handle", (gpointer)handle);
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3022
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3023 if (args[1])
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3024 g_hash_table_insert(components, "password", args[1]);
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3025
32698
154e4a2a6287 Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32684
diff changeset
3026 jabber_chat_join(purple_conversation_get_connection(conv), components);
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3027
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3028 g_hash_table_destroy(components);
31510
38bc213239a3 jabber: Add support for joining a room based not on the current server.
Paul Aurich <darkrain42@pidgin.im>
parents: 31447
diff changeset
3029 jabber_id_free(jid);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3030 return PURPLE_CMD_RET_OK;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3031 }
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3032
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3033 static PurpleCmdRet jabber_cmd_chat_kick(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3034 const char *cmd, char **args, char **error, void *data)
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3035 {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3036 JabberChat *chat = jabber_chat_find_by_conv(conv);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3037
18986
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
3038 if(!chat || !args || !args[0])
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3039 return PURPLE_CMD_RET_FAILED;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3040
29400
8d8ad40c9c7d jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
Paul Aurich <darkrain42@pidgin.im>
parents: 29398
diff changeset
3041 if(!jabber_chat_role_user(chat, args[0], "none", args[1])) {
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3042 *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
3043 return PURPLE_CMD_RET_FAILED;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3044 }
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3045
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3046 return PURPLE_CMD_RET_OK;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3047 }
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3048
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3049 static PurpleCmdRet jabber_cmd_chat_msg(PurpleConversation *conv,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3050 const char *cmd, char **args, char **error, void *data)
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3051 {
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3052 JabberChat *chat = jabber_chat_find_by_conv(conv);
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3053 char *who;
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3054
18986
5542a465de12 Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents: 18381
diff changeset
3055 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
3056 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
3057
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3058 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
3059
32698
154e4a2a6287 Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32684
diff changeset
3060 jabber_message_send_im(purple_conversation_get_connection(conv), who, args[1], 0);
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3061
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3062 g_free(who);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3063 return PURPLE_CMD_RET_OK;
9152
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3064 }
ff7aaa305cbd [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
3065
17769
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
3066 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
3067 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
3068 {
26089
804e625addbc Fix merge (i.e. reapply my changes here).
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
3069 PurpleAccount *account;
804e625addbc Fix merge (i.e. reapply my changes here).
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
3070 PurpleConnection *pc;
804e625addbc Fix merge (i.e. reapply my changes here).
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
3071
17769
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
3072 if(!args || !args[0])
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
3073 return PURPLE_CMD_RET_FAILED;
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
3074
26089
804e625addbc Fix merge (i.e. reapply my changes here).
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
3075 account = purple_conversation_get_account(conv);
804e625addbc Fix merge (i.e. reapply my changes here).
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
3076 pc = purple_account_get_connection(account);
804e625addbc Fix merge (i.e. reapply my changes here).
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
3077
804e625addbc Fix merge (i.e. reapply my changes here).
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
3078 if(!jabber_ping_jid(purple_connection_get_protocol_data(pc), args[0])) {
17769
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
3079 *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
3080 return PURPLE_CMD_RET_FAILED;
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
3081 }
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
3082
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
3083 return PURPLE_CMD_RET_OK;
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
3084 }
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
3085
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3086 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
3087
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3088 JabberBuddy *jb;
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3089 JabberBuddyResource *jbr;
24428
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3090 PurpleConnection *gc = js->gc;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
3091 PurpleBuddy *buddy =
25975
fcd84c6c9909 Print alias (if known) in some error/info messages when failing to buzz
Marcus Lundblad <malu@pidgin.im>
parents: 25973
diff changeset
3092 purple_find_buddy(purple_connection_get_account(gc), username);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
3093 const gchar *alias =
25975
fcd84c6c9909 Print alias (if known) in some error/info messages when failing to buzz
Marcus Lundblad <malu@pidgin.im>
parents: 25973
diff changeset
3094 buddy ? purple_buddy_get_contact_alias(buddy) : username;
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3095
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3096 if(!username)
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3097 return FALSE;
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3098
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3099 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
3100 if(!jb) {
25975
fcd84c6c9909 Print alias (if known) in some error/info messages when failing to buzz
Marcus Lundblad <malu@pidgin.im>
parents: 25973
diff changeset
3101 *error = g_strdup_printf(_("Unable to buzz, because there is nothing "
fcd84c6c9909 Print alias (if known) in some error/info messages when failing to buzz
Marcus Lundblad <malu@pidgin.im>
parents: 25973
diff changeset
3102 "known about %s."), alias);
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3103 return FALSE;
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3104 }
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3105
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3106 jbr = jabber_buddy_find_resource(jb, NULL);
24428
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3107 if (!jbr) {
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
3108 *error = g_strdup_printf(_("Unable to buzz, because %s might be offline."),
25975
fcd84c6c9909 Print alias (if known) in some error/info messages when failing to buzz
Marcus Lundblad <malu@pidgin.im>
parents: 25973
diff changeset
3109 alias);
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3110 return FALSE;
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3111 }
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3112
28979
191942cc7747 jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents: 28928
diff changeset
3113 if (jabber_resource_has_capability(jbr, NS_ATTENTION)) {
24428
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3114 xmlnode *buzz, *msg = xmlnode_new("message");
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3115 gchar *to;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
3116
24428
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3117 to = g_strdup_printf("%s/%s", username, jbr->name);
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3118 xmlnode_set_attrib(msg, "to", to);
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3119 g_free(to);
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3120
24428
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3121 /* avoid offline storage */
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3122 xmlnode_set_attrib(msg, "type", "headline");
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3123
24428
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3124 buzz = xmlnode_new_child(msg, "attention");
28979
191942cc7747 jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents: 28928
diff changeset
3125 xmlnode_set_namespace(buzz, NS_ATTENTION);
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3126
24428
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3127 jabber_send(js, msg);
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3128 xmlnode_free(msg);
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3129
24428
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3130 return TRUE;
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3131 } else {
25975
fcd84c6c9909 Print alias (if known) in some error/info messages when failing to buzz
Marcus Lundblad <malu@pidgin.im>
parents: 25973
diff changeset
3132 *error = g_strdup_printf(_("Unable to buzz, because %s does "
26086
f26f6451c701 Use "does" here sounds more natural to me
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
3133 "not support it or does not wish to receive buzzes now."), alias);
24428
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3134 return FALSE;
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3135 }
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3136 }
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3137
17822
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
3138 static PurpleCmdRet jabber_cmd_buzz(PurpleConversation *conv,
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
3139 const char *cmd, char **args, char **error, void *data)
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
3140 {
32617
c74b4bd27e37 Use purple_conversation accessor methods.
Andrew Victor <andrew.victor@mxit.com>
parents: 32300
diff changeset
3141 PurpleAccount *account = purple_conversation_get_account(conv);
32624
f957ad287bcc Convert code to use the purple_account accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
3142 JabberStream *js = purple_connection_get_protocol_data(purple_account_get_connection(account));
24428
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3143 const gchar *who;
26048
9eeed41d0004 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <malu@pidgin.im>
parents: 25948
diff changeset
3144 gchar *description;
9eeed41d0004 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <malu@pidgin.im>
parents: 25948
diff changeset
3145 PurpleBuddy *buddy;
9eeed41d0004 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <malu@pidgin.im>
parents: 25948
diff changeset
3146 const char *alias;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31128
diff changeset
3147 PurpleAttentionType *attn =
32617
c74b4bd27e37 Use purple_conversation accessor methods.
Andrew Victor <andrew.victor@mxit.com>
parents: 32300
diff changeset
3148 purple_get_attention_type_from_code(account, 0);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
3149
24428
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3150 if (!args || !args[0]) {
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3151 /* use the buddy from conversation, if it's a one-to-one conversation */
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3152 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) {
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3153 who = purple_conversation_get_name(conv);
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3154 } else {
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3155 return PURPLE_CMD_RET_FAILED;
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3156 }
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3157 } else {
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3158 who = args[0];
002e089bfb28 Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <malu@pidgin.im>
parents: 24397
diff changeset
3159 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
3160
32617
c74b4bd27e37 Use purple_conversation accessor methods.
Andrew Victor <andrew.victor@mxit.com>
parents: 32300
diff changeset
3161 buddy = purple_find_buddy(account, who);
26048
9eeed41d0004 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <malu@pidgin.im>
parents: 25948
diff changeset
3162 if (buddy != NULL)
9eeed41d0004 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <malu@pidgin.im>
parents: 25948
diff changeset
3163 alias = purple_buddy_get_contact_alias(buddy);
9eeed41d0004 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <malu@pidgin.im>
parents: 25948
diff changeset
3164 else
9eeed41d0004 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <malu@pidgin.im>
parents: 25948
diff changeset
3165 alias = who;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31128
diff changeset
3166
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31128
diff changeset
3167 description =
26048
9eeed41d0004 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <malu@pidgin.im>
parents: 25948
diff changeset
3168 g_strdup_printf(purple_attention_type_get_outgoing_desc(attn), alias);
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31128
diff changeset
3169 purple_conversation_write(conv, NULL, description,
26048
9eeed41d0004 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <malu@pidgin.im>
parents: 25948
diff changeset
3170 PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_SYSTEM, time(NULL));
9eeed41d0004 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <malu@pidgin.im>
parents: 25948
diff changeset
3171 g_free(description);
9eeed41d0004 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <malu@pidgin.im>
parents: 25948
diff changeset
3172 return _jabber_send_buzz(js, who, error) ? PURPLE_CMD_RET_OK : PURPLE_CMD_RET_FAILED;
17822
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
3173 }
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
3174
20401
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
3175 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
3176 {
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
3177 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
3178
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
3179 if (!types) {
22225
6cd802a8c5ad This adds accessor and mutator API for the PurpleAttentionType struct.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22155
diff changeset
3180 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
3181 _("%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
3182 }
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
3183
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
3184 return types;
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
3185 }
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
3186
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
3187 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
3188 {
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
3189 JabberStream *js = purple_connection_get_protocol_data(gc);
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3190 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
3191
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3192 if (!_jabber_send_buzz(js, username, &error)) {
29787
645de6afcc0a jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <malu@pidgin.im>
parents: 29771
diff changeset
3193 PurpleAccount *account = purple_connection_get_account(gc);
645de6afcc0a jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <malu@pidgin.im>
parents: 29771
diff changeset
3194 PurpleConversation *conv =
645de6afcc0a jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <malu@pidgin.im>
parents: 29771
diff changeset
3195 purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, username, account);
20401
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
3196 purple_debug_error("jabber", "jabber_send_attention: jabber_cmd_buzz failed with error: %s\n", error ? error : "(NULL)");
29787
645de6afcc0a jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <malu@pidgin.im>
parents: 29771
diff changeset
3197
645de6afcc0a jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <malu@pidgin.im>
parents: 29771
diff changeset
3198 if (conv) {
645de6afcc0a jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <malu@pidgin.im>
parents: 29771
diff changeset
3199 purple_conversation_write(conv, username, error, PURPLE_MESSAGE_ERROR,
645de6afcc0a jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <malu@pidgin.im>
parents: 29771
diff changeset
3200 time(NULL));
645de6afcc0a jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <malu@pidgin.im>
parents: 29771
diff changeset
3201 }
645de6afcc0a jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <malu@pidgin.im>
parents: 29771
diff changeset
3202
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3203 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
3204 return FALSE;
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
3205 }
20930
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3206
bb8c78265f58 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <datallah@pidgin.im>
parents: 20929
diff changeset
3207 return TRUE;
20401
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
3208 }
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
3209
8aaa593a6269 Comment a partial implementation of the libpurple attention API for
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20332
diff changeset
3210
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
3211 gboolean jabber_offline_message(const PurpleBuddy *buddy)
12645
a907ba243930 [gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12600
diff changeset
3212 {
a907ba243930 [gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12600
diff changeset
3213 return TRUE;
a907ba243930 [gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12600
diff changeset
3214 }
a907ba243930 [gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12600
diff changeset
3215
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3216 #ifdef USE_VV
26668
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26666
diff changeset
3217 gboolean
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26666
diff changeset
3218 jabber_audio_enabled(JabberStream *js, const char *namespace)
26665
16f54aa7c7d1 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <darkrain42@pidgin.im>
parents: 26663
diff changeset
3219 {
16f54aa7c7d1 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <darkrain42@pidgin.im>
parents: 26663
diff changeset
3220 PurpleMediaManager *manager = purple_media_manager_get();
16f54aa7c7d1 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <darkrain42@pidgin.im>
parents: 26663
diff changeset
3221 PurpleMediaCaps caps = purple_media_manager_get_ui_caps(manager);
16f54aa7c7d1 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <darkrain42@pidgin.im>
parents: 26663
diff changeset
3222
16f54aa7c7d1 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <darkrain42@pidgin.im>
parents: 26663
diff changeset
3223 return (caps & (PURPLE_MEDIA_CAPS_AUDIO | PURPLE_MEDIA_CAPS_AUDIO_SINGLE_DIRECTION));
16f54aa7c7d1 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <darkrain42@pidgin.im>
parents: 26663
diff changeset
3224 }
16f54aa7c7d1 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <darkrain42@pidgin.im>
parents: 26663
diff changeset
3225
27202
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 27193
diff changeset
3226 gboolean
26668
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26666
diff changeset
3227 jabber_video_enabled(JabberStream *js, const char *namespace)
26665
16f54aa7c7d1 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <darkrain42@pidgin.im>
parents: 26663
diff changeset
3228 {
16f54aa7c7d1 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <darkrain42@pidgin.im>
parents: 26663
diff changeset
3229 PurpleMediaManager *manager = purple_media_manager_get();
16f54aa7c7d1 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <darkrain42@pidgin.im>
parents: 26663
diff changeset
3230 PurpleMediaCaps caps = purple_media_manager_get_ui_caps(manager);
16f54aa7c7d1 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <darkrain42@pidgin.im>
parents: 26663
diff changeset
3231
16f54aa7c7d1 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <darkrain42@pidgin.im>
parents: 26663
diff changeset
3232 return (caps & (PURPLE_MEDIA_CAPS_VIDEO | PURPLE_MEDIA_CAPS_VIDEO_SINGLE_DIRECTION));
16f54aa7c7d1 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <darkrain42@pidgin.im>
parents: 26663
diff changeset
3233 }
16f54aa7c7d1 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <darkrain42@pidgin.im>
parents: 26663
diff changeset
3234
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3235 typedef struct {
26746
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26699
diff changeset
3236 PurpleAccount *account;
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3237 gchar *who;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3238 PurpleMediaSessionType type;
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27143
diff changeset
3239
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3240 } JabberMediaRequest;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3241
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3242 static void
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3243 jabber_media_cancel_cb(JabberMediaRequest *request,
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3244 PurpleRequestFields *fields)
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3245 {
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3246 g_free(request->who);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3247 g_free(request);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3248 }
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3249
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3250 static void
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3251 jabber_media_ok_cb(JabberMediaRequest *request, PurpleRequestFields *fields)
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3252 {
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3253 PurpleRequestField *field =
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3254 purple_request_fields_get_field(fields, "resource");
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3255 int selected_id = purple_request_field_choice_get_value(field);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3256 GList *labels = purple_request_field_choice_get_labels(field);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3257 gchar *who = g_strdup_printf("%s/%s", request->who,
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3258 (gchar*)g_list_nth_data(labels, selected_id));
26746
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26699
diff changeset
3259 jabber_initiate_media(request->account, who, request->type);
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3260
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3261 g_free(who);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3262 g_free(request->who);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3263 g_free(request);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3264 }
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3265 #endif
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3266
26495
52846ebe1c7d Don't assume a PurpleMedia instance will be created immediately.
Michael Ruprecht <maiku@pidgin.im>
parents: 26455
diff changeset
3267 gboolean
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27143
diff changeset
3268 jabber_initiate_media(PurpleAccount *account, const char *who,
26108
8d0fd2f195aa Changed PurpleMediaStreamType to PurpleMediaSessionType.
Michael Ruprecht <maiku@pidgin.im>
parents: 26106
diff changeset
3269 PurpleMediaSessionType type)
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
3270 {
26454
94130b583e0b Clean up usage of USE_VV in the XMPP protocol.
Michael Ruprecht <maiku@pidgin.im>
parents: 26399
diff changeset
3271 #ifdef USE_VV
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
3272 PurpleConnection *gc = purple_account_get_connection(account);
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
3273 JabberStream *js = purple_connection_get_protocol_data(gc);
26205
f20bb7e9e311 Support initiating voice calls to GTalk and Gmail.
Michael Ruprecht <maiku@pidgin.im>
parents: 26186
diff changeset
3274 JabberBuddy *jb;
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3275 JabberBuddyResource *jbr = NULL;
33790
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3276 char *resource = NULL;
26205
f20bb7e9e311 Support initiating voice calls to GTalk and Gmail.
Michael Ruprecht <maiku@pidgin.im>
parents: 26186
diff changeset
3277
f20bb7e9e311 Support initiating voice calls to GTalk and Gmail.
Michael Ruprecht <maiku@pidgin.im>
parents: 26186
diff changeset
3278 if (!js) {
f20bb7e9e311 Support initiating voice calls to GTalk and Gmail.
Michael Ruprecht <maiku@pidgin.im>
parents: 26186
diff changeset
3279 purple_debug_error("jabber",
f20bb7e9e311 Support initiating voice calls to GTalk and Gmail.
Michael Ruprecht <maiku@pidgin.im>
parents: 26186
diff changeset
3280 "jabber_initiate_media: NULL stream\n");
26495
52846ebe1c7d Don't assume a PurpleMedia instance will be created immediately.
Michael Ruprecht <maiku@pidgin.im>
parents: 26455
diff changeset
3281 return FALSE;
26205
f20bb7e9e311 Support initiating voice calls to GTalk and Gmail.
Michael Ruprecht <maiku@pidgin.im>
parents: 26186
diff changeset
3282 }
f20bb7e9e311 Support initiating voice calls to GTalk and Gmail.
Michael Ruprecht <maiku@pidgin.im>
parents: 26186
diff changeset
3283
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3284 jb = jabber_buddy_find(js, who, FALSE);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3285
33790
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3286 if(!jb || !jb->resources ||
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3287 (((resource = jabber_get_resource(who)) != NULL)
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3288 && (jbr = jabber_buddy_find_resource(jb, resource)) == NULL)) {
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3289 /* no resources online, we're trying to initiate with someone
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3290 * whose presence we're not subscribed to, or
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3291 * someone who is offline. Let's inform the user */
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3292 char *msg;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3293
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3294 if(!jb) {
26647
89bcc7bce53e Minor grammatical message fixes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26643
diff changeset
3295 msg = g_strdup_printf(_("Unable to initiate media with %s: invalid JID"), who);
33790
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3296 } else if(jb->subscription & JABBER_SUB_TO && !jb->resources) {
26647
89bcc7bce53e Minor grammatical message fixes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26643
diff changeset
3297 msg = g_strdup_printf(_("Unable to initiate media with %s: user is not online"), who);
33790
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3298 } else if(resource) {
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3299 msg = g_strdup_printf(_("Unable to initiate media with %s: resource is not online"), who);
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3300 } else {
26647
89bcc7bce53e Minor grammatical message fixes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26643
diff changeset
3301 msg = g_strdup_printf(_("Unable to initiate media with %s: not subscribed to user presence"), who);
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3302 }
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3303
26746
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26699
diff changeset
3304 purple_notify_error(account, _("Media Initiation Failed"),
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3305 _("Media Initiation Failed"), msg);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3306 g_free(msg);
33790
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3307 g_free(resource);
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3308 return FALSE;
33790
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3309 } else if(jbr != NULL) {
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3310 /* they've specified a resource, no need to ask or
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3311 * default or anything, just do it */
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3312
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3313 g_free(resource);
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3314
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3315 if (type & PURPLE_MEDIA_AUDIO &&
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3316 !jabber_resource_has_capability(jbr,
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3317 JINGLE_APP_RTP_SUPPORT_AUDIO) &&
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3318 jabber_resource_has_capability(jbr, NS_GOOGLE_VOICE))
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3319 return jabber_google_session_initiate(js, who, type);
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3320 else
270d16117280 Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 33740
diff changeset
3321 return jingle_rtp_initiate_media(js, who, type);
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3322 } else if(!jb->resources->next) {
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3323 /* only 1 resource online (probably our most common case)
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3324 * so no need to ask who to initiate with */
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3325 gchar *name;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3326 gboolean result;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3327 jbr = jb->resources->data;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3328 name = g_strdup_printf("%s/%s", who, jbr->name);
26746
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26699
diff changeset
3329 result = jabber_initiate_media(account, name, type);
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3330 g_free(name);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3331 return result;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3332 } else {
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3333 /* we've got multiple resources,
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3334 * we need to pick one to initiate with */
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3335 GList *l;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3336 char *msg;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3337 PurpleRequestFields *fields;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3338 PurpleRequestField *field = purple_request_field_choice_new(
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3339 "resource", _("Resource"), 0);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3340 PurpleRequestFieldGroup *group;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3341 JabberMediaRequest *request;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3342
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3343 for(l = jb->resources; l; l = l->next)
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3344 {
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3345 JabberBuddyResource *ljbr = l->data;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3346 PurpleMediaCaps caps;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3347 gchar *name;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3348 name = g_strdup_printf("%s/%s", who, ljbr->name);
26746
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26699
diff changeset
3349 caps = jabber_get_media_caps(account, name);
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3350 g_free(name);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3351
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3352 if ((type & PURPLE_MEDIA_AUDIO) &&
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3353 (type & PURPLE_MEDIA_VIDEO)) {
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3354 if (caps & PURPLE_MEDIA_CAPS_AUDIO_VIDEO) {
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3355 jbr = ljbr;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3356 purple_request_field_choice_add(
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3357 field, jbr->name);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3358 }
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3359 } else if (type & (PURPLE_MEDIA_AUDIO) &&
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3360 (caps & PURPLE_MEDIA_CAPS_AUDIO)) {
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3361 jbr = ljbr;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3362 purple_request_field_choice_add(
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3363 field, jbr->name);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3364 }else if (type & (PURPLE_MEDIA_VIDEO) &&
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3365 (caps & PURPLE_MEDIA_CAPS_VIDEO)) {
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3366 jbr = ljbr;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3367 purple_request_field_choice_add(
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3368 field, jbr->name);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3369 }
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3370 }
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3371
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3372 if (jbr == NULL) {
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3373 purple_debug_error("jabber",
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3374 "No resources available\n");
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3375 return FALSE;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3376 }
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3377
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3378 if (g_list_length(purple_request_field_choice_get_labels(
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3379 field)) <= 1) {
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3380 gchar *name;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3381 gboolean result;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3382 purple_request_field_destroy(field);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3383 name = g_strdup_printf("%s/%s", who, jbr->name);
26746
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26699
diff changeset
3384 result = jabber_initiate_media(account, name, type);
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3385 g_free(name);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3386 return result;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3387 }
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3388
26647
89bcc7bce53e Minor grammatical message fixes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26643
diff changeset
3389 msg = g_strdup_printf(_("Please select the resource of %s with which you would like to start a media session."), who);
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3390 fields = purple_request_fields_new();
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3391 group = purple_request_field_group_new(NULL);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3392 request = g_new0(JabberMediaRequest, 1);
26746
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26699
diff changeset
3393 request->account = account;
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3394 request->who = g_strdup(who);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3395 request->type = type;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3396
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3397 purple_request_field_group_add_field(group, field);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3398 purple_request_fields_add_group(fields, group);
26746
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26699
diff changeset
3399 purple_request_fields(account, _("Select a Resource"), msg,
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26699
diff changeset
3400 NULL, fields, _("Initiate Media"),
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3401 G_CALLBACK(jabber_media_ok_cb), _("Cancel"),
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3402 G_CALLBACK(jabber_media_cancel_cb),
34332
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34304
diff changeset
3403 purple_request_cpar_from_account(account),
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34304
diff changeset
3404 request);
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3405
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3406 g_free(msg);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3407 return TRUE;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3408 }
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3409 #endif
26495
52846ebe1c7d Don't assume a PurpleMedia instance will be created immediately.
Michael Ruprecht <maiku@pidgin.im>
parents: 26455
diff changeset
3410 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
3411 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
3412
26746
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26699
diff changeset
3413 PurpleMediaCaps jabber_get_media_caps(PurpleAccount *account, 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
3414 {
26454
94130b583e0b Clean up usage of USE_VV in the XMPP protocol.
Michael Ruprecht <maiku@pidgin.im>
parents: 26399
diff changeset
3415 #ifdef USE_VV
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
3416 PurpleConnection *gc = purple_account_get_connection(account);
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
3417 JabberStream *js = purple_connection_get_protocol_data(gc);
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
3418 JabberBuddy *jb;
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3419 JabberBuddyResource *jbr;
29345
5932dfc04845 Oops, just realized that caps can be reset in certain situations, and we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29344
diff changeset
3420 PurpleMediaCaps total = PURPLE_MEDIA_CAPS_NONE;
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3421 gchar *resource;
29344
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3422 GList *specific = NULL, *l;
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
3423
0844f5e9ac8e Fix crash bug when checking if a contact can do media when logging out.
Michael Ruprecht <maiku@pidgin.im>
parents: 23714
diff changeset
3424 if (!js) {
26632
e4fb60cb05a7 Demote debug error to info.
Michael Ruprecht <maiku@pidgin.im>
parents: 26495
diff changeset
3425 purple_debug_info("jabber",
e4fb60cb05a7 Demote debug error to info.
Michael Ruprecht <maiku@pidgin.im>
parents: 26495
diff changeset
3426 "jabber_can_do_media: NULL stream\n");
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
3427 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
3428 }
0844f5e9ac8e Fix crash bug when checking if a contact can do media when logging out.
Michael Ruprecht <maiku@pidgin.im>
parents: 23714
diff changeset
3429
29344
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3430 jb = jabber_buddy_find(js, who, FALSE);
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3431
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3432 if (!jb || !jb->resources) {
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3433 /* no resources online, we're trying to get caps for someone
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3434 * whose presence we're not subscribed to, or
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3435 * someone who is offline. */
29345
5932dfc04845 Oops, just realized that caps can be reset in certain situations, and we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29344
diff changeset
3436 return total;
29344
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3437
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3438 } else if ((resource = jabber_get_resource(who)) != NULL) {
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3439 /* they've specified a resource, no need to ask or
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3440 * default or anything, just do it */
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3441 jbr = jabber_buddy_find_resource(jb, resource);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3442 g_free(resource);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3443
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3444 if (!jbr) {
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3445 purple_debug_error("jabber", "jabber_get_media_caps:"
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3446 " Can't find resource %s\n", who);
29345
5932dfc04845 Oops, just realized that caps can be reset in certain situations, and we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29344
diff changeset
3447 return total;
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3448 }
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3449
29344
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3450 l = specific = g_list_prepend(specific, jbr);
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3451
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3452 } else {
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3453 /* we've got multiple resources, combine their caps */
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3454 l = jb->resources;
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3455 }
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3456
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3457 for (; l; l = l->next) {
29345
5932dfc04845 Oops, just realized that caps can be reset in certain situations, and we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29344
diff changeset
3458 PurpleMediaCaps caps = PURPLE_MEDIA_CAPS_NONE;
29344
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3459 jbr = l->data;
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3460
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3461 if (jabber_resource_has_capability(jbr,
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3462 JINGLE_APP_RTP_SUPPORT_AUDIO))
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3463 caps |= PURPLE_MEDIA_CAPS_AUDIO_SINGLE_DIRECTION |
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3464 PURPLE_MEDIA_CAPS_AUDIO;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3465 if (jabber_resource_has_capability(jbr,
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3466 JINGLE_APP_RTP_SUPPORT_VIDEO))
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3467 caps |= PURPLE_MEDIA_CAPS_VIDEO_SINGLE_DIRECTION |
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3468 PURPLE_MEDIA_CAPS_VIDEO;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3469 if (caps & PURPLE_MEDIA_CAPS_AUDIO && caps &
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3470 PURPLE_MEDIA_CAPS_VIDEO)
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3471 caps |= PURPLE_MEDIA_CAPS_AUDIO_VIDEO;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3472 if (caps != PURPLE_MEDIA_CAPS_NONE) {
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3473 if (!jabber_resource_has_capability(jbr,
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3474 JINGLE_TRANSPORT_ICEUDP) &&
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3475 !jabber_resource_has_capability(jbr,
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3476 JINGLE_TRANSPORT_RAWUDP)) {
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3477 purple_debug_info("jingle-rtp", "Buddy doesn't "
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3478 "support the same transport types\n");
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3479 caps = PURPLE_MEDIA_CAPS_NONE;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3480 } else
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3481 caps |= PURPLE_MEDIA_CAPS_MODIFY_SESSION |
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3482 PURPLE_MEDIA_CAPS_CHANGE_DIRECTION;
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3483 }
28979
191942cc7747 jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents: 28928
diff changeset
3484 if (jabber_resource_has_capability(jbr, NS_GOOGLE_VOICE)) {
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26632
diff changeset
3485 caps |= PURPLE_MEDIA_CAPS_AUDIO;
28979
191942cc7747 jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents: 28928
diff changeset
3486 if (jabber_resource_has_capability(jbr, NS_GOOGLE_VIDEO))
27202
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 27193
diff changeset
3487 caps |= PURPLE_MEDIA_CAPS_AUDIO_VIDEO;
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 27193
diff changeset
3488 }
29345
5932dfc04845 Oops, just realized that caps can be reset in certain situations, and we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29344
diff changeset
3489
5932dfc04845 Oops, just realized that caps can be reset in certain situations, and we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29344
diff changeset
3490 total |= caps;
23714
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 23712
diff changeset
3491 }
26170
829055c78478 Choose the transport type according to the responder's caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 26167
diff changeset
3492
29344
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3493 if (specific) {
362c4882de89 Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29264
diff changeset
3494 g_list_free(specific);
26170
829055c78478 Choose the transport type according to the responder's caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 26167
diff changeset
3495 }
26316
950c0d491c0d Change purple_prpl_can_do_media to purple_prpl_get_media_caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 26292
diff changeset
3496
29345
5932dfc04845 Oops, just realized that caps can be reset in certain situations, and we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29344
diff changeset
3497 return total;
26454
94130b583e0b Clean up usage of USE_VV in the XMPP protocol.
Michael Ruprecht <maiku@pidgin.im>
parents: 26399
diff changeset
3498 #else
94130b583e0b Clean up usage of USE_VV in the XMPP protocol.
Michael Ruprecht <maiku@pidgin.im>
parents: 26399
diff changeset
3499 return PURPLE_MEDIA_CAPS_NONE;
94130b583e0b Clean up usage of USE_VV in the XMPP protocol.
Michael Ruprecht <maiku@pidgin.im>
parents: 26399
diff changeset
3500 #endif
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
3501 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22646
diff changeset
3502
28879
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3503 gboolean jabber_can_receive_file(PurpleConnection *gc, const char *who)
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3504 {
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
3505 JabberStream *js = purple_connection_get_protocol_data(gc);
28879
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3506
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3507 if (js) {
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3508 JabberBuddy *jb = jabber_buddy_find(js, who, FALSE);
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3509 GList *iter;
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3510 gboolean has_resources_without_caps = FALSE;
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3511
28928
7c6adca0766f jabber: don't crash when right-clicking on buddies non on the local roster
Marcus Lundblad <malu@pidgin.im>
parents: 28879
diff changeset
3512 /* if we didn't find a JabberBuddy, we don't have presence for this
7c6adca0766f jabber: don't crash when right-clicking on buddies non on the local roster
Marcus Lundblad <malu@pidgin.im>
parents: 28879
diff changeset
3513 buddy, let's assume they can receive files, disco should tell us
7c6adca0766f jabber: don't crash when right-clicking on buddies non on the local roster
Marcus Lundblad <malu@pidgin.im>
parents: 28879
diff changeset
3514 when actually trying */
7c6adca0766f jabber: don't crash when right-clicking on buddies non on the local roster
Marcus Lundblad <malu@pidgin.im>
parents: 28879
diff changeset
3515 if (jb == NULL)
7c6adca0766f jabber: don't crash when right-clicking on buddies non on the local roster
Marcus Lundblad <malu@pidgin.im>
parents: 28879
diff changeset
3516 return TRUE;
7c6adca0766f jabber: don't crash when right-clicking on buddies non on the local roster
Marcus Lundblad <malu@pidgin.im>
parents: 28879
diff changeset
3517
28879
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3518 /* find out if there is any resources without caps */
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3519 for (iter = jb->resources; iter ; iter = g_list_next(iter)) {
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3520 JabberBuddyResource *jbr = (JabberBuddyResource *) iter->data;
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3521
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3522 if (!jabber_resource_know_capabilities(jbr)) {
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3523 has_resources_without_caps = TRUE;
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3524 }
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3525 }
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3526
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3527 if (has_resources_without_caps) {
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31128
diff changeset
3528 /* there is at least one resource which we don't have caps for,
28879
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3529 let's assume they can receive files... */
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3530 return TRUE;
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3531 } else {
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3532 /* we have caps for all the resources, see if at least one has
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3533 right caps */
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3534 for (iter = jb->resources; iter ; iter = g_list_next(iter)) {
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3535 JabberBuddyResource *jbr = (JabberBuddyResource *) iter->data;
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3536
30474
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30458
diff changeset
3537 if (jabber_resource_has_capability(jbr, NS_SI_FILE_TRANSFER)
28879
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3538 && (jabber_resource_has_capability(jbr,
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
3539 NS_BYTESTREAMS)
28979
191942cc7747 jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents: 28928
diff changeset
3540 || jabber_resource_has_capability(jbr, NS_IBB))) {
28879
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3541 return TRUE;
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3542 }
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3543 }
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3544 return FALSE;
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3545 }
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3546 } else {
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3547 return TRUE;
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3548 }
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3549 }
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28832
diff changeset
3550
29843
5caad147921f jabber: Fix the type signature of jabber_cmd_mood
Paul Aurich <darkrain42@pidgin.im>
parents: 29827
diff changeset
3551 static PurpleCmdRet
29827
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3552 jabber_cmd_mood(PurpleConversation *conv,
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3553 const char *cmd, char **args, char **error, void *data)
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3554 {
32617
c74b4bd27e37 Use purple_conversation accessor methods.
Andrew Victor <andrew.victor@mxit.com>
parents: 32300
diff changeset
3555 PurpleAccount *account = purple_conversation_get_account(conv);
32624
f957ad287bcc Convert code to use the purple_account accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
3556 JabberStream *js = purple_connection_get_protocol_data(purple_account_get_connection(account));
29827
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3557
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3558 if (js->pep) {
32984
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3559 gboolean ret;
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3560
30628
7000a6dbfdb3 I'm pretty sure this is a logical operation, not bitwise.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30587
diff changeset
3561 if (!args || !args[0]) {
32984
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3562 /* No arguments; unset mood */
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3563 ret = jabber_mood_set(js, NULL, NULL);
29827
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3564 } else {
32984
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3565 /* At least one argument. Relying on the list of arguments
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3566 * being NULL-terminated.
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3567 */
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3568 ret = jabber_mood_set(js, args[0], args[1]);
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3569 if (!ret) {
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3570 /* Let's try again */
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3571 char *tmp = g_strjoin(" ", args[0], args[1], NULL);
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3572 ret = jabber_mood_set(js, "undefined", tmp);
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3573 g_free(tmp);
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3574 }
29827
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3575 }
29843
5caad147921f jabber: Fix the type signature of jabber_cmd_mood
Paul Aurich <darkrain42@pidgin.im>
parents: 29827
diff changeset
3576
32984
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3577 if (ret) {
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3578 return PURPLE_CMD_RET_OK;
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3579 } else {
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3580 purple_conversation_write(conv, NULL,
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3581 _("Failed to specify mood"),
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3582 PURPLE_MESSAGE_ERROR, time(NULL));
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3583 return PURPLE_CMD_RET_FAILED;
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3584 }
29827
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3585 } else {
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3586 /* account does not support PEP, can't set a mood */
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3587 purple_conversation_write(conv, NULL,
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3588 _("Account does not support PEP, can't set mood"),
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3589 PURPLE_MESSAGE_ERROR, time(NULL));
29843
5caad147921f jabber: Fix the type signature of jabber_cmd_mood
Paul Aurich <darkrain42@pidgin.im>
parents: 29827
diff changeset
3590 return PURPLE_CMD_RET_FAILED;
29827
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3591 }
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3592 }
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3593
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3594 static void jabber_register_commands(PurplePlugin *plugin)
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
3595 {
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3596 GSList *commands = NULL;
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3597 PurpleCmdId id;
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3598 id = purple_cmd_register("config", "", PURPLE_CMD_P_PRPL,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3599 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3600 "prpl-jabber", jabber_cmd_chat_config,
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3601 _("config: Configure a chat room."), NULL);
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3602 commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3603
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3604 id = purple_cmd_register("configure", "", PURPLE_CMD_P_PRPL,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3605 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3606 "prpl-jabber", jabber_cmd_chat_config,
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3607 _("configure: Configure a chat room."), NULL);
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3608 commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3609
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3610 id = purple_cmd_register("nick", "s", PURPLE_CMD_P_PRPL,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3611 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3612 "prpl-jabber", jabber_cmd_chat_nick,
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3613 _("nick &lt;new nickname&gt;: Change your nickname."),
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3614 NULL);
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3615 commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3616
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3617 id = purple_cmd_register("part", "s", PURPLE_CMD_P_PRPL,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3618 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
3619 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
28702
245346a2b0a9 jabber: Correct the /part command's help.
Paul Aurich <darkrain42@pidgin.im>
parents: 28656
diff changeset
3620 jabber_cmd_chat_part, _("part [message]: Leave the room."),
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3621 NULL);
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3622 commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3623
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3624 id = purple_cmd_register("register", "", PURPLE_CMD_P_PRPL,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3625 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3626 "prpl-jabber", jabber_cmd_chat_register,
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3627 _("register: Register with a chat room."), NULL);
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3628 commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3629
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
3630 /* XXX: there needs to be a core /topic cmd, methinks */
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3631 id = purple_cmd_register("topic", "s", PURPLE_CMD_P_PRPL,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3632 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
3633 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3634 jabber_cmd_chat_topic,
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3635 _("topic [new topic]: View or change the topic."),
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3636 NULL);
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3637 commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3638
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3639 id = purple_cmd_register("ban", "ws", PURPLE_CMD_P_PRPL,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3640 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
3641 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3642 jabber_cmd_chat_ban,
22759
1ab25e736b3d Correct some help strings for Jabber slash commands
Mark Doliner <markdoliner@pidgin.im>
parents: 22587
diff changeset
3643 _("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
3644 NULL);
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3645 commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3646
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3647 id = purple_cmd_register("affiliate", "ws", PURPLE_CMD_P_PRPL,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3648 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
3649 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
3650 jabber_cmd_chat_affiliate,
27027
f3129efa65ea Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents: 27002
diff changeset
3651 _("affiliate &lt;owner|admin|member|outcast|none&gt; [nick1] [nick2] ...: Get the users with an affiliation or set users' affiliation with the room."),
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
3652 NULL);
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3653 commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3654
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3655 id = purple_cmd_register("role", "ws", PURPLE_CMD_P_PRPL,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3656 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
3657 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
3658 jabber_cmd_chat_role,
27933
9e7789d3a809 Fix two strings as pointed out on translators@
Paul Aurich <darkrain42@pidgin.im>
parents: 27931
diff changeset
3659 _("role &lt;moderator|participant|visitor|none&gt; [nick1] [nick2] ...: Get the users with a role or set users' role with the room."),
13238
b98439d90903 [gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents: 13201
diff changeset
3660 NULL);
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3661 commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3662
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3663 id = purple_cmd_register("invite", "ws", PURPLE_CMD_P_PRPL,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3664 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
3665 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3666 jabber_cmd_chat_invite,
11158
2660ab8f8a14 [gaim-migrate @ 13245]
Etan Reisner <deryni@pidgin.im>
parents: 11033
diff changeset
3667 _("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
3668 NULL);
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3669 commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3670
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3671 id = purple_cmd_register("join", "ws", PURPLE_CMD_P_PRPL,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3672 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
3673 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3674 jabber_cmd_chat_join,
31967
8ca00a04051e jabber: Fix /join behavior. Closes #14205.
Paul Aurich <darkrain42@pidgin.im>
parents: 31928
diff changeset
3675 _("join: &lt;room[@server]&gt; [password]: Join a chat."),
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3676 NULL);
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3677 commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3678
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3679 id = purple_cmd_register("kick", "ws", PURPLE_CMD_P_PRPL,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3680 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
3681 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3682 jabber_cmd_chat_kick,
22759
1ab25e736b3d Correct some help strings for Jabber slash commands
Mark Doliner <markdoliner@pidgin.im>
parents: 22587
diff changeset
3683 _("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
3684 NULL);
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3685 commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3686
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3687 id = purple_cmd_register("msg", "ws", PURPLE_CMD_P_PRPL,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
3688 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
9597
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3689 "prpl-jabber", jabber_cmd_chat_msg,
c6f672b593cb [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
3690 _("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
3691 NULL);
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3692 commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3693
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3694 id = 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
3695 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
3696 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
3697 "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
3698 _("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
3699 NULL);
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3700 commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3701
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3702 id = purple_cmd_register("buzz", "w", PURPLE_CMD_P_PRPL,
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26041
diff changeset
3703 PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PRPL_ONLY |
24429
31217eabccee Register the /buzz command using PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS.
Marcus Lundblad <malu@pidgin.im>
parents: 24428
diff changeset
3704 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS,
17822
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
3705 "prpl-jabber", jabber_cmd_buzz,
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
3706 _("buzz: Buzz a user to get their attention"), NULL);
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3707 commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
29827
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3708
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3709 id = purple_cmd_register("mood", "ws", PURPLE_CMD_P_PRPL,
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3710 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM |
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3711 PURPLE_CMD_FLAG_PRPL_ONLY | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS,
324821bfa1af jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <malu@pidgin.im>
parents: 29787
diff changeset
3712 "prpl-jabber", jabber_cmd_mood,
32984
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32722
diff changeset
3713 _("mood &lt;mood&gt; [text]: Set current user mood"), NULL);
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3714 commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3715
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3716 g_hash_table_insert(jabber_cmds, plugin, commands);
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
3717 }
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
3718
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3719 static void cmds_free_func(gpointer value)
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3720 {
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3721 GSList *commands = value;
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3722 while (commands) {
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3723 purple_cmd_unregister(GPOINTER_TO_UINT(commands->data));
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3724 commands = g_slist_delete_link(commands, commands);
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3725 }
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3726 }
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3727
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3728 static void jabber_unregister_commands(PurplePlugin *plugin)
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3729 {
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3730 g_hash_table_remove(jabber_cmds, plugin);
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3731 }
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3732
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3733 /* IPC functions */
23598
54fe227bf99e * adding documentation for IPC function contact_has_feature
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23597
diff changeset
3734
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3735 /**
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3736 * IPC function for determining if a contact supports a certain feature.
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3737 *
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3738 * @param account The PurpleAccount
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3739 * @param jid The full JID of the contact.
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3740 * @param feature The feature's namespace.
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3741 *
23598
54fe227bf99e * adding documentation for IPC function contact_has_feature
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23597
diff changeset
3742 * @return TRUE if supports feature; else FALSE.
54fe227bf99e * adding documentation for IPC function contact_has_feature
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23597
diff changeset
3743 */
23597
ec0bcdfa1da1 * adding IPC function 'contact_has_feature'
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23596
diff changeset
3744 static gboolean
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3745 jabber_ipc_contact_has_feature(PurpleAccount *account, const gchar *jid,
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3746 const gchar *feature)
23597
ec0bcdfa1da1 * adding IPC function 'contact_has_feature'
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23596
diff changeset
3747 {
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3748 PurpleConnection *gc = purple_account_get_connection(account);
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3749 JabberStream *js;
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3750 JabberBuddy *jb;
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3751 JabberBuddyResource *jbr;
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3752 gchar *resource;
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3753
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3754 if (!purple_account_is_connected(account))
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3755 return FALSE;
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
3756 js = purple_connection_get_protocol_data(gc);
24721
227944e5d0d6 constify, ifdef out an old-caps remnant, and rewrite a little
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
3757
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27143
diff changeset
3758 if (!(resource = jabber_get_resource(jid)) ||
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3759 !(jb = jabber_buddy_find(js, jid, FALSE)) ||
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3760 !(jbr = jabber_buddy_find_resource(jb, resource))) {
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3761 g_free(resource);
24721
227944e5d0d6 constify, ifdef out an old-caps remnant, and rewrite a little
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
3762 return FALSE;
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3763 }
24721
227944e5d0d6 constify, ifdef out an old-caps remnant, and rewrite a little
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
3764
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3765 g_free(resource);
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3766
24802
eb481e98ac6a Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents: 24737
diff changeset
3767 return jabber_resource_has_capability(jbr, feature);
23596
164fbee281c1 * fixing a bug in jabber_caps_compare()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
3768 }
164fbee281c1 * fixing a bug in jabber_caps_compare()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
3769
23599
ac402ffdcbec * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23598
diff changeset
3770 static void
24721
227944e5d0d6 constify, ifdef out an old-caps remnant, and rewrite a little
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
3771 jabber_ipc_add_feature(const gchar *feature)
23599
ac402ffdcbec * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23598
diff changeset
3772 {
24721
227944e5d0d6 constify, ifdef out an old-caps remnant, and rewrite a little
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
3773 if (!feature)
227944e5d0d6 constify, ifdef out an old-caps remnant, and rewrite a little
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
3774 return;
23600
ca657199f39a * IPC work
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23599
diff changeset
3775 jabber_add_feature(feature, 0);
24721
227944e5d0d6 constify, ifdef out an old-caps remnant, and rewrite a little
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
3776
227944e5d0d6 constify, ifdef out an old-caps remnant, and rewrite a little
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
3777 /* send presence with new caps info for all connected accounts */
23601
f7e44345f4b9 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23600
diff changeset
3778 jabber_caps_broadcast_change();
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
3779 }
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
3780
29844
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3781 static void
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3782 jabber_do_init(void)
14358
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
3783 {
27286
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
3784 GHashTable *ui_info = purple_core_get_ui_info();
27293
5234a1fe1531 Avoid an assertion when the UI doesn't have a get_ui_info ui_op
Paul Aurich <darkrain42@pidgin.im>
parents: 27292
diff changeset
3785 const gchar *ui_type;
27756
cc054031e076 Identify clients in XMPP caps based on the ui_info hash. Closes #9672.
Paul Aurich <darkrain42@pidgin.im>
parents: 27755
diff changeset
3786 const gchar *type = "pc"; /* default client type, if unknown or
27286
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
3787 unspecified */
27756
cc054031e076 Identify clients in XMPP caps based on the ui_info hash. Closes #9672.
Paul Aurich <darkrain42@pidgin.im>
parents: 27755
diff changeset
3788 const gchar *ui_name = NULL;
29847
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3789 #ifdef HAVE_CYRUS_SASL
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3790 /* We really really only want to do this once per process */
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3791 static gboolean sasl_initialized = FALSE;
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3792 #ifdef _WIN32
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3793 UINT old_error_mode;
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3794 gchar *sasldir;
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3795 #endif
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3796 int ret;
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3797 #endif
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3798
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3799 /* XXX - If any other plugin wants SASL this won't be good ... */
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3800 #ifdef HAVE_CYRUS_SASL
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3801 if (!sasl_initialized) {
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3802 sasl_initialized = TRUE;
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3803 #ifdef _WIN32
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3804 sasldir = g_build_filename(wpurple_install_dir(), "sasl2", NULL);
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3805 sasl_set_path(SASL_PATH_TYPE_PLUGIN, sasldir);
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3806 g_free(sasldir);
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3807 /* Suppress error popups for failing to load sasl plugins */
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3808 old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS);
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3809 #endif
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3810 if ((ret = sasl_client_init(NULL)) != SASL_OK) {
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3811 purple_debug_error("xmpp", "Error (%d) initializing SASL.\n", ret);
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3812 }
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3813 #ifdef _WIN32
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3814 /* Restore the original error mode */
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3815 SetErrorMode(old_error_mode);
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3816 #endif
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3817 }
c4713809ccce jabber: Only initialize SASL once, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29845
diff changeset
3818 #endif
27286
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
3819
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3820 jabber_cmds = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, cmds_free_func);
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3821
27293
5234a1fe1531 Avoid an assertion when the UI doesn't have a get_ui_info ui_op
Paul Aurich <darkrain42@pidgin.im>
parents: 27292
diff changeset
3822 ui_type = ui_info ? g_hash_table_lookup(ui_info, "client_type") : NULL;
27286
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
3823 if (ui_type) {
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
3824 if (strcmp(ui_type, "pc") == 0 ||
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
3825 strcmp(ui_type, "console") == 0 ||
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
3826 strcmp(ui_type, "phone") == 0 ||
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
3827 strcmp(ui_type, "handheld") == 0 ||
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
3828 strcmp(ui_type, "web") == 0 ||
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
3829 strcmp(ui_type, "bot") == 0) {
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
3830 type = ui_type;
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
3831 }
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
3832 }
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
3833
27756
cc054031e076 Identify clients in XMPP caps based on the ui_info hash. Closes #9672.
Paul Aurich <darkrain42@pidgin.im>
parents: 27755
diff changeset
3834 if (ui_info)
cc054031e076 Identify clients in XMPP caps based on the ui_info hash. Closes #9672.
Paul Aurich <darkrain42@pidgin.im>
parents: 27755
diff changeset
3835 ui_name = g_hash_table_lookup(ui_info, "name");
cc054031e076 Identify clients in XMPP caps based on the ui_info hash. Closes #9672.
Paul Aurich <darkrain42@pidgin.im>
parents: 27755
diff changeset
3836 if (ui_name == NULL)
cc054031e076 Identify clients in XMPP caps based on the ui_info hash. Closes #9672.
Paul Aurich <darkrain42@pidgin.im>
parents: 27755
diff changeset
3837 ui_name = PACKAGE;
cc054031e076 Identify clients in XMPP caps based on the ui_info hash. Closes #9672.
Paul Aurich <darkrain42@pidgin.im>
parents: 27755
diff changeset
3838
cc054031e076 Identify clients in XMPP caps based on the ui_info hash. Closes #9672.
Paul Aurich <darkrain42@pidgin.im>
parents: 27755
diff changeset
3839 jabber_add_identity("client", type, NULL, ui_name);
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
3840
23597
ec0bcdfa1da1 * adding IPC function 'contact_has_feature'
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23596
diff changeset
3841 /* initialize jabber_features list */
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
3842 jabber_add_feature(NS_LAST_ACTIVITY, 0);
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
3843 jabber_add_feature(NS_OOB_IQ_DATA, 0);
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
3844 jabber_add_feature(NS_ENTITY_TIME, 0);
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
3845 jabber_add_feature("jabber:iq:version", 0);
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
3846 jabber_add_feature("jabber:x:conference", 0);
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
3847 jabber_add_feature(NS_BYTESTREAMS, 0);
25798
7fabdc4d3a2b Fix advertised capabilities (caps, chatstates, entity time)
Paul Aurich <darkrain42@pidgin.im>
parents: 25797
diff changeset
3848 jabber_add_feature("http://jabber.org/protocol/caps", 0);
7fabdc4d3a2b Fix advertised capabilities (caps, chatstates, entity time)
Paul Aurich <darkrain42@pidgin.im>
parents: 25797
diff changeset
3849 jabber_add_feature("http://jabber.org/protocol/chatstates", 0);
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
3850 jabber_add_feature(NS_DISCO_INFO, 0);
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
3851 jabber_add_feature(NS_DISCO_ITEMS, 0);
28979
191942cc7747 jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents: 28928
diff changeset
3852 jabber_add_feature(NS_IBB, 0);
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
3853 jabber_add_feature("http://jabber.org/protocol/muc", 0);
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
3854 jabber_add_feature("http://jabber.org/protocol/muc#user", 0);
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23428
diff changeset
3855 jabber_add_feature("http://jabber.org/protocol/si", 0);
30474
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30458
diff changeset
3856 jabber_add_feature(NS_SI_FILE_TRANSFER, 0);
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28982
diff changeset
3857 jabber_add_feature(NS_XHTML_IM, 0);
28979
191942cc7747 jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents: 28928
diff changeset
3858 jabber_add_feature(NS_PING, 0);
26659
918350344dc7 Fix merge: Move the Jingle features to jabber.c
Paul Aurich <darkrain42@pidgin.im>
parents: 26658
diff changeset
3859
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3860 /* Buzz/Attention */
28979
191942cc7747 jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents: 28928
diff changeset
3861 jabber_add_feature(NS_ATTENTION, jabber_buzz_isenabled);
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3862
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3863 /* Bits Of Binary */
28979
191942cc7747 jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents: 28928
diff changeset
3864 jabber_add_feature(NS_BOB, 0);
27028
1a2ef7ddb463 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 27027
diff changeset
3865
26659
918350344dc7 Fix merge: Move the Jingle features to jabber.c
Paul Aurich <darkrain42@pidgin.im>
parents: 26658
diff changeset
3866 /* Jingle features! */
918350344dc7 Fix merge: Move the Jingle features to jabber.c
Paul Aurich <darkrain42@pidgin.im>
parents: 26658
diff changeset
3867 jabber_add_feature(JINGLE, 0);
26666
4c95bdba5627 Advertise ICEUDP only when libnice is available
Paul Aurich <darkrain42@pidgin.im>
parents: 26665
diff changeset
3868
26665
16f54aa7c7d1 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <darkrain42@pidgin.im>
parents: 26663
diff changeset
3869 #ifdef USE_VV
28980
4a0f7340b539 jabber: Add the missing file and fix up the Google session namespaces
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
3870 jabber_add_feature(NS_GOOGLE_PROTOCOL_SESSION, jabber_audio_enabled);
28979
191942cc7747 jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents: 28928
diff changeset
3871 jabber_add_feature(NS_GOOGLE_VOICE, jabber_audio_enabled);
191942cc7747 jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents: 28928
diff changeset
3872 jabber_add_feature(NS_GOOGLE_VIDEO, jabber_video_enabled);
191942cc7747 jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents: 28928
diff changeset
3873 jabber_add_feature(NS_GOOGLE_CAMERA, jabber_video_enabled);
28561
a2dd00ce03eb Advertise jingle rtp, and only advertise rawudp if VV is enabled
Will Thompson <resiak@pidgin.im>
parents: 28379
diff changeset
3874 jabber_add_feature(JINGLE_APP_RTP, 0);
26668
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26666
diff changeset
3875 jabber_add_feature(JINGLE_APP_RTP_SUPPORT_AUDIO, jabber_audio_enabled);
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26666
diff changeset
3876 jabber_add_feature(JINGLE_APP_RTP_SUPPORT_VIDEO, jabber_video_enabled);
28561
a2dd00ce03eb Advertise jingle rtp, and only advertise rawudp if VV is enabled
Will Thompson <resiak@pidgin.im>
parents: 28379
diff changeset
3877 jabber_add_feature(JINGLE_TRANSPORT_RAWUDP, 0);
26960
6ab1af0e17f7 merge of '8482365bb2ecec16d6e7161069a6000c330727e8'
Paul Aurich <darkrain42@pidgin.im>
parents: 26959 26675
diff changeset
3878 jabber_add_feature(JINGLE_TRANSPORT_ICEUDP, 0);
29541
37f0297ff3ad Rebroadcast XMPP caps whenever the UI caps change.
Michael Ruprecht <maiku@pidgin.im>
parents: 28656
diff changeset
3879
37f0297ff3ad Rebroadcast XMPP caps whenever the UI caps change.
Michael Ruprecht <maiku@pidgin.im>
parents: 28656
diff changeset
3880 g_signal_connect(G_OBJECT(purple_media_manager_get()), "ui-caps-changed",
37f0297ff3ad Rebroadcast XMPP caps whenever the UI caps change.
Michael Ruprecht <maiku@pidgin.im>
parents: 28656
diff changeset
3881 G_CALLBACK(jabber_caps_broadcast_change), NULL);
26665
16f54aa7c7d1 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <darkrain42@pidgin.im>
parents: 26663
diff changeset
3882 #endif
26659
918350344dc7 Fix merge: Move the Jingle features to jabber.c
Paul Aurich <darkrain42@pidgin.im>
parents: 26658
diff changeset
3883
29844
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3884 /* reverse order of unload_plugin */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3885 jabber_iq_init();
29848
999c0235bbc6 jabber: Heavily refactor jabber_presence_parse(). It's still not short enough.
Paul Aurich <darkrain42@pidgin.im>
parents: 29847
diff changeset
3886 jabber_presence_init();
29844
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3887 jabber_caps_init();
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3888 /* PEP things should be init via jabber_pep_init, not here */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3889 jabber_pep_init();
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3890 jabber_data_init();
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3891 jabber_bosh_init();
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3892
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3893 /* TODO: Implement adding and retrieving own features via IPC API */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3894
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3895 jabber_ibb_init();
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3896 jabber_si_init();
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3897
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28832
diff changeset
3898 jabber_auth_init();
29844
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3899 }
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3900
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3901 static void
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3902 jabber_do_uninit(void)
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3903 {
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3904 /* reverse order of jabber_do_init */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3905 jabber_bosh_uninit();
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3906 jabber_data_uninit();
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3907 jabber_si_uninit();
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3908 jabber_ibb_uninit();
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3909 /* PEP things should be uninit via jabber_pep_uninit, not here */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3910 jabber_pep_uninit();
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3911 jabber_caps_uninit();
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3912 jabber_presence_uninit();
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3913 jabber_iq_uninit();
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3914
30036
747b4a361046 jabber: --more leaks
Paul Aurich <darkrain42@pidgin.im>
parents: 30035
diff changeset
3915 #ifdef USE_VV
747b4a361046 jabber: --more leaks
Paul Aurich <darkrain42@pidgin.im>
parents: 30035
diff changeset
3916 g_signal_handlers_disconnect_by_func(G_OBJECT(purple_media_manager_get()),
747b4a361046 jabber: --more leaks
Paul Aurich <darkrain42@pidgin.im>
parents: 30035
diff changeset
3917 G_CALLBACK(jabber_caps_broadcast_change), NULL);
747b4a361046 jabber: --more leaks
Paul Aurich <darkrain42@pidgin.im>
parents: 30035
diff changeset
3918 #endif
747b4a361046 jabber: --more leaks
Paul Aurich <darkrain42@pidgin.im>
parents: 30035
diff changeset
3919
29844
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3920 jabber_auth_uninit();
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3921 jabber_features_destroy();
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3922 jabber_identities_destroy();
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3923
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3924 g_hash_table_destroy(jabber_cmds);
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3925 jabber_cmds = NULL;
29844
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3926 }
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3927
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3928 void jabber_plugin_init(PurplePlugin *plugin)
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3929 {
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3930 ++plugin_ref;
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3931
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3932 if (plugin_ref == 1)
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3933 jabber_do_init();
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28832
diff changeset
3934
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3935 jabber_register_commands(plugin);
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
3936
23597
ec0bcdfa1da1 * adding IPC function 'contact_has_feature'
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23596
diff changeset
3937 /* IPC functions */
ec0bcdfa1da1 * adding IPC function 'contact_has_feature'
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23596
diff changeset
3938 purple_plugin_ipc_register(plugin, "contact_has_feature", PURPLE_CALLBACK(jabber_ipc_contact_has_feature),
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3939 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER,
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3940 purple_value_new(PURPLE_TYPE_BOOLEAN), 3,
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24721
diff changeset
3941 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_ACCOUNT),
23597
ec0bcdfa1da1 * adding IPC function 'contact_has_feature'
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23596
diff changeset
3942 purple_value_new(PURPLE_TYPE_STRING),
ec0bcdfa1da1 * adding IPC function 'contact_has_feature'
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23596
diff changeset
3943 purple_value_new(PURPLE_TYPE_STRING));
27103
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 27028
diff changeset
3944
23600
ca657199f39a * IPC work
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23599
diff changeset
3945 purple_plugin_ipc_register(plugin, "add_feature", PURPLE_CALLBACK(jabber_ipc_add_feature),
ca657199f39a * IPC work
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23599
diff changeset
3946 purple_marshal_VOID__POINTER,
ca657199f39a * IPC work
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23599
diff changeset
3947 NULL, 1,
ca657199f39a * IPC work
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23599
diff changeset
3948 purple_value_new(PURPLE_TYPE_STRING));
27223
d41e83f82148 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <darkrain42@pidgin.im>
parents: 27221
diff changeset
3949
d41e83f82148 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <darkrain42@pidgin.im>
parents: 27221
diff changeset
3950 purple_plugin_ipc_register(plugin, "register_namespace_watcher",
d41e83f82148 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <darkrain42@pidgin.im>
parents: 27221
diff changeset
3951 PURPLE_CALLBACK(jabber_iq_signal_register),
d41e83f82148 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <darkrain42@pidgin.im>
parents: 27221
diff changeset
3952 purple_marshal_VOID__POINTER_POINTER,
d41e83f82148 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <darkrain42@pidgin.im>
parents: 27221
diff changeset
3953 NULL, 2,
d41e83f82148 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <darkrain42@pidgin.im>
parents: 27221
diff changeset
3954 purple_value_new(PURPLE_TYPE_STRING), /* node */
d41e83f82148 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <darkrain42@pidgin.im>
parents: 27221
diff changeset
3955 purple_value_new(PURPLE_TYPE_STRING)); /* namespace */
d41e83f82148 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <darkrain42@pidgin.im>
parents: 27221
diff changeset
3956
d41e83f82148 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <darkrain42@pidgin.im>
parents: 27221
diff changeset
3957 purple_plugin_ipc_register(plugin, "unregister_namespace_watcher",
d41e83f82148 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <darkrain42@pidgin.im>
parents: 27221
diff changeset
3958 PURPLE_CALLBACK(jabber_iq_signal_unregister),
d41e83f82148 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <darkrain42@pidgin.im>
parents: 27221
diff changeset
3959 purple_marshal_VOID__POINTER_POINTER,
d41e83f82148 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <darkrain42@pidgin.im>
parents: 27221
diff changeset
3960 NULL, 2,
d41e83f82148 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <darkrain42@pidgin.im>
parents: 27221
diff changeset
3961 purple_value_new(PURPLE_TYPE_STRING), /* node */
d41e83f82148 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <darkrain42@pidgin.im>
parents: 27221
diff changeset
3962 purple_value_new(PURPLE_TYPE_STRING)); /* namespace */
29844
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3963
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3964 purple_signal_register(plugin, "jabber-register-namespace-watcher",
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3965 purple_marshal_VOID__POINTER_POINTER,
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3966 NULL, 2,
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3967 purple_value_new(PURPLE_TYPE_STRING), /* node */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3968 purple_value_new(PURPLE_TYPE_STRING)); /* namespace */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3969
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3970 purple_signal_register(plugin, "jabber-unregister-namespace-watcher",
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3971 purple_marshal_VOID__POINTER_POINTER,
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3972 NULL, 2,
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3973 purple_value_new(PURPLE_TYPE_STRING), /* node */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3974 purple_value_new(PURPLE_TYPE_STRING)); /* namespace */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3975
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3976 purple_signal_connect(plugin, "jabber-register-namespace-watcher",
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3977 plugin, PURPLE_CALLBACK(jabber_iq_signal_register), NULL);
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3978 purple_signal_connect(plugin, "jabber-unregister-namespace-watcher",
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3979 plugin, PURPLE_CALLBACK(jabber_iq_signal_unregister), NULL);
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3980
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3981
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3982 purple_signal_register(plugin, "jabber-receiving-xmlnode",
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3983 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3984 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3985 purple_value_new_outgoing(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE));
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3986
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3987 purple_signal_register(plugin, "jabber-sending-xmlnode",
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3988 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3989 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3990 purple_value_new_outgoing(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE));
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3991
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3992 /*
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3993 * Do not remove this or the plugin will fail. Completely. You have been
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3994 * warned!
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3995 */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3996 purple_signal_connect_priority(plugin, "jabber-sending-xmlnode",
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3997 plugin, PURPLE_CALLBACK(jabber_send_signal_cb),
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3998 NULL, PURPLE_SIGNAL_PRIORITY_HIGHEST);
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
3999
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4000 purple_signal_register(plugin, "jabber-sending-text",
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4001 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4002 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4003 purple_value_new_outgoing(PURPLE_TYPE_STRING));
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4004
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4005 purple_signal_register(plugin, "jabber-receiving-message",
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4006 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER_POINTER,
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4007 purple_value_new(PURPLE_TYPE_BOOLEAN), 6,
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4008 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4009 purple_value_new(PURPLE_TYPE_STRING), /* type */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4010 purple_value_new(PURPLE_TYPE_STRING), /* id */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4011 purple_value_new(PURPLE_TYPE_STRING), /* from */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4012 purple_value_new(PURPLE_TYPE_STRING), /* to */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4013 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE));
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4014
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4015 purple_signal_register(plugin, "jabber-receiving-iq",
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4016 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER,
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4017 purple_value_new(PURPLE_TYPE_BOOLEAN), 5,
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4018 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4019 purple_value_new(PURPLE_TYPE_STRING), /* type */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4020 purple_value_new(PURPLE_TYPE_STRING), /* id */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4021 purple_value_new(PURPLE_TYPE_STRING), /* from */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4022 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE));
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4023
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4024 purple_signal_register(plugin, "jabber-watched-iq",
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4025 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER,
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4026 purple_value_new(PURPLE_TYPE_BOOLEAN), 5,
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4027 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4028 purple_value_new(PURPLE_TYPE_STRING), /* type */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4029 purple_value_new(PURPLE_TYPE_STRING), /* id */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4030 purple_value_new(PURPLE_TYPE_STRING), /* from */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4031 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE)); /* child */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4032
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4033 purple_signal_register(plugin, "jabber-receiving-presence",
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4034 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER,
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4035 purple_value_new(PURPLE_TYPE_BOOLEAN), 4,
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4036 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4037 purple_value_new(PURPLE_TYPE_STRING), /* type */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4038 purple_value_new(PURPLE_TYPE_STRING), /* from */
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4039 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE));
14358
aaaca5a49c92 [gaim-migrate @ 16986]
Ian Goldberg
parents: 14356
diff changeset
4040 }
24737
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
4041
29844
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4042 void jabber_plugin_uninit(PurplePlugin *plugin)
24737
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
4043 {
29844
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4044 g_return_if_fail(plugin_ref > 0);
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4045
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4046 purple_signals_unregister_by_instance(plugin);
28832
4e4b609b85e4 jabber: Use purple_connection_get_prpl() instead of jabber_plugin.
Paul Aurich <darkrain42@pidgin.im>
parents: 28830
diff changeset
4047 purple_plugin_ipc_unregister_all(plugin);
27103
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 27028
diff changeset
4048
29845
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
4049 jabber_unregister_commands(plugin);
5684cbe452f7 jabber: And fix up the commands now to be per-plugin
Paul Aurich <darkrain42@pidgin.im>
parents: 29844
diff changeset
4050
29844
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4051 --plugin_ref;
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4052 if (plugin_ref == 0)
6c6e346e1390 jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <darkrain42@pidgin.im>
parents: 29843
diff changeset
4053 jabber_do_uninit();
24737
b8a96a07e7ac Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
4054 }

mercurial