annotate libpurple/protocols/jabber/jabber.c @ 29557:a694731e8b3f

jabber: Move the initialization into the jabber plugin, and only initialize some things once. This would allow multiple plugins to use the jabber plugin /properly/ (and ref-counted!). Commands still need to be fixed.
author Paul Aurich <paul@darkrain42.org>
date Tue, 09 Mar 2010 18:59:08 +0000
parents 342ed5917f56
children d93676b59db1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2 * purple - Jabber Protocol Plugin
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
28048
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 27981
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 27981
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 27981
diff changeset
6 * source distribution.
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19200
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include "internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "account.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "accountopt.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "blist.h"
26982
007dff3cb9e4 Fixup after propagating new caps stuff
Marcus Lundblad <ml@update.uu.se>
parents: 26981
diff changeset
28 #include "core.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "cmds.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "connection.h"
15889
87ea711b9781 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
31 #include "conversation.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "dnssrv.h"
25353
9195955395b6 Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents: 24890
diff changeset
34 #include "imgstore.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include "message.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #include "notify.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 #include "pluginpref.h"
24855
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
38 #include "privacy.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 #include "proxy.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 #include "prpl.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 #include "request.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 #include "server.h"
25686
feea711ac242 Patch from Paul Aurich to fix reporting idle when reconnecting only when we're
Marcus Lundblad <ml@update.uu.se>
parents: 25685
diff changeset
43 #include "status.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 #include "util.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 #include "version.h"
15889
87ea711b9781 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
46 #include "xmlnode.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 #include "auth.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 #include "buddy.h"
25985
c4fd9222dda1 propagate from branch 'im.pidgin.pidgin' (head 303af74a38e7b313d4fb0be4d4054a16cb13d819)
Paul Aurich <paul@darkrain42.org>
parents: 25952 25678
diff changeset
50 #include "caps.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 #include "chat.h"
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23180
diff changeset
52 #include "data.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 #include "disco.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 #include "google.h"
28534
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
55 #include "ibb.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 #include "iq.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 #include "jutil.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 #include "message.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 #include "parser.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 #include "presence.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 #include "jabber.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 #include "roster.h"
17835
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 17834
diff changeset
63 #include "ping.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 #include "si.h"
29468
b052a711cfbd Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
65 #include "usermood.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 #include "xdata.h"
17834
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents: 17833
diff changeset
67 #include "pep.h"
17883
9a19c46adf66 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 <pidgin@monitzer.com>
parents: 17881
diff changeset
68 #include "adhoccommands.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23911
diff changeset
70 #include "jingle/jingle.h"
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23911
diff changeset
71 #include "jingle/rtp.h"
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23180
diff changeset
72
29492
0d3151a41134 jabber: Don't ping more often than once a minute.
Paul Aurich <paul@darkrain42.org>
parents: 29473
diff changeset
73 #define PING_TIMEOUT 60
0d3151a41134 jabber: Don't ping more often than once a minute.
Paul Aurich <paul@darkrain42.org>
parents: 29473
diff changeset
74
21538
4e5bef6c3379 Fix #3669
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
75 GList *jabber_features = NULL;
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
76 GList *jabber_identities = NULL;
28517
96ba7fd24177 jabber: Use purple_connection_get_prpl() instead of jabber_plugin.
Paul Aurich <paul@darkrain42.org>
parents: 28515
diff changeset
77 static GSList *jabber_cmds = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78
29557
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
79 static gint plugin_ref = 0;
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
80
18703
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
81 static void jabber_unregister_account_cb(JabberStream *js);
23598
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
82 static void try_srv_connect(JabberStream *js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 static void jabber_stream_init(JabberStream *js)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 char *open_stream;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 open_stream = g_strdup_printf("<stream:stream to='%s' "
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
89 "xmlns='" NS_XMPP_CLIENT "' "
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
90 "xmlns:stream='" NS_XMPP_STREAMS "' "
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 "version='1.0'>",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 js->user->domain);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 /* setup the parser fresh for each stream */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 jabber_parser_setup(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 jabber_send_raw(js, open_stream, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 js->reinit = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 g_free(open_stream);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 static void
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
101 jabber_session_initialized_cb(JabberStream *js, const char *from,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
102 JabberIqType type, const char *id,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
103 xmlnode *packet, gpointer data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 {
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
105 if (type == JABBER_IQ_RESULT) {
25673
af2b883df9a3 Wait until receiving the roster to tell the core we're logged in
Paul Aurich <paul@darkrain42.org>
parents: 25672
diff changeset
106 jabber_disco_items_server(js);
18703
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
107 if(js->unregistration)
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
108 jabber_unregister_account_cb(js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 } else {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
110 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 21355
diff changeset
111 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 20076
diff changeset
112 ("Error initializing session"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 static void jabber_session_init(JabberStream *js)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 xmlnode *session;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 jabber_iq_set_callback(iq, jabber_session_initialized_cb, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 session = xmlnode_new_child(iq->node, "session");
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
124 xmlnode_set_namespace(session, NS_XMPP_SESSION);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
129 static void jabber_bind_result_cb(JabberStream *js, const char *from,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
130 JabberIqType type, const char *id,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
131 xmlnode *packet, gpointer data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 xmlnode *bind;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
135 if (type == JABBER_IQ_RESULT &&
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
136 (bind = xmlnode_get_child_with_namespace(packet, "bind", NS_XMPP_BIND))) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 xmlnode *jid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 char *full_jid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 jabber_id_free(js->user);
27793
478a3866ea90 jabber: Stop fall-through on connection error.
Paul Aurich <paul@darkrain42.org>
parents: 27787
diff changeset
141
478a3866ea90 jabber: Stop fall-through on connection error.
Paul Aurich <paul@darkrain42.org>
parents: 27787
diff changeset
142 js->user = jabber_id_new(full_jid);
478a3866ea90 jabber: Stop fall-through on connection error.
Paul Aurich <paul@darkrain42.org>
parents: 27787
diff changeset
143 if (js->user == NULL) {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
144 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 21355
diff changeset
145 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
146 _("Invalid response from server"));
27793
478a3866ea90 jabber: Stop fall-through on connection error.
Paul Aurich <paul@darkrain42.org>
parents: 27787
diff changeset
147 g_free(full_jid);
478a3866ea90 jabber: Stop fall-through on connection error.
Paul Aurich <paul@darkrain42.org>
parents: 27787
diff changeset
148 return;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 }
27793
478a3866ea90 jabber: Stop fall-through on connection error.
Paul Aurich <paul@darkrain42.org>
parents: 27787
diff changeset
150
27794
eb2d17945ce3 jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <paul@darkrain42.org>
parents: 27793
diff changeset
151 js->user_jb = jabber_buddy_find(js, full_jid, TRUE);
eb2d17945ce3 jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <paul@darkrain42.org>
parents: 27793
diff changeset
152 js->user_jb->subscription |= JABBER_SUB_BOTH;
24216
a61c017d3a99 Set the connection display name to the server-assigned full jid for XMPP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24058
diff changeset
153
a61c017d3a99 Set the connection display name to the server-assigned full jid for XMPP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24058
diff changeset
154 purple_connection_set_display_name(js->gc, full_jid);
a61c017d3a99 Set the connection display name to the server-assigned full jid for XMPP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24058
diff changeset
155
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 g_free(full_jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 } else {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 21355
diff changeset
159 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
20814
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
160 char *msg = jabber_parse_error(js, packet, &reason);
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
161 purple_connection_error_reason(js->gc, reason, msg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 jabber_session_init(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167
24555
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
168 static char *jabber_prep_resource(char *input) {
25463
43055addf135 Grab only the "short" hostname on systems (like Fedora/RedHat, but others too)
mcepl@redhat.com
parents: 25432
diff changeset
169 char hostname[256], /* current hostname */
43055addf135 Grab only the "short" hostname on systems (like Fedora/RedHat, but others too)
mcepl@redhat.com
parents: 25432
diff changeset
170 *dot = NULL;
24555
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
171
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
172 /* Empty resource == don't send any */
24869
41e69c65b006 Slightly modified version of a fix fqueze proposed for a crash with the empty
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 24855
diff changeset
173 if (input == NULL || *input == '\0')
24555
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
174 return NULL;
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
175
24568
6b9552b09de0 Avoid needlessly calling gethostname() if __HOSTNAME__ doesn't appear in the
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 24563
diff changeset
176 if (strstr(input, "__HOSTNAME__") == NULL)
24585
fb5a11ec8be6 darkrain again
Ka-Hing Cheung <khc@hxbc.us>
parents: 24568
diff changeset
177 return g_strdup(input);
24568
6b9552b09de0 Avoid needlessly calling gethostname() if __HOSTNAME__ doesn't appear in the
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 24563
diff changeset
178
24555
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
179 /* Replace __HOSTNAME__ with hostname */
24560
9bb624e345aa me likes this better, References #5565
Ka-Hing Cheung <khc@hxbc.us>
parents: 24556
diff changeset
180 if (gethostname(hostname, sizeof(hostname) - 1)) {
9bb624e345aa me likes this better, References #5565
Ka-Hing Cheung <khc@hxbc.us>
parents: 24556
diff changeset
181 purple_debug_warning("jabber", "gethostname: %s\n", g_strerror(errno));
9bb624e345aa me likes this better, References #5565
Ka-Hing Cheung <khc@hxbc.us>
parents: 24556
diff changeset
182 /* according to glibc doc, the only time an error is returned
9bb624e345aa me likes this better, References #5565
Ka-Hing Cheung <khc@hxbc.us>
parents: 24556
diff changeset
183 is if the hostname is longer than the buffer, in which case
9bb624e345aa me likes this better, References #5565
Ka-Hing Cheung <khc@hxbc.us>
parents: 24556
diff changeset
184 glibc 2.2+ would still fill the buffer with partial
9bb624e345aa me likes this better, References #5565
Ka-Hing Cheung <khc@hxbc.us>
parents: 24556
diff changeset
185 hostname, so maybe we want to detect that and use it
9bb624e345aa me likes this better, References #5565
Ka-Hing Cheung <khc@hxbc.us>
parents: 24556
diff changeset
186 instead
9bb624e345aa me likes this better, References #5565
Ka-Hing Cheung <khc@hxbc.us>
parents: 24556
diff changeset
187 */
24555
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
188 strcpy(hostname, "localhost");
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
189 }
24560
9bb624e345aa me likes this better, References #5565
Ka-Hing Cheung <khc@hxbc.us>
parents: 24556
diff changeset
190 hostname[sizeof(hostname) - 1] = '\0';
24555
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
191
25463
43055addf135 Grab only the "short" hostname on systems (like Fedora/RedHat, but others too)
mcepl@redhat.com
parents: 25432
diff changeset
192 /* We want only the short hostname, not the FQDN - this will prevent the
43055addf135 Grab only the "short" hostname on systems (like Fedora/RedHat, but others too)
mcepl@redhat.com
parents: 25432
diff changeset
193 * resource string from being unreasonably long on systems which stuff the
43055addf135 Grab only the "short" hostname on systems (like Fedora/RedHat, but others too)
mcepl@redhat.com
parents: 25432
diff changeset
194 * whole FQDN in the hostname */
43055addf135 Grab only the "short" hostname on systems (like Fedora/RedHat, but others too)
mcepl@redhat.com
parents: 25432
diff changeset
195 if((dot = strchr(hostname, '.')))
43055addf135 Grab only the "short" hostname on systems (like Fedora/RedHat, but others too)
mcepl@redhat.com
parents: 25432
diff changeset
196 dot = '\0';
43055addf135 Grab only the "short" hostname on systems (like Fedora/RedHat, but others too)
mcepl@redhat.com
parents: 25432
diff changeset
197
24555
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
198 return purple_strreplace(input, "__HOSTNAME__", hostname);
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
199 }
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
200
25049
f775f6021654 * using libpurple's internal SASL mechanisms during BOSH authentication phase
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25044
diff changeset
201 void jabber_stream_features_parse(JabberStream *js, xmlnode *packet)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 if(xmlnode_get_child(packet, "starttls")) {
28327
c7aaad89a2f8 jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents: 28314
diff changeset
204 if(jabber_process_starttls(js, packet)) {
c7aaad89a2f8 jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents: 28314
diff changeset
205 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING_ENCRYPTION);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 return;
28327
c7aaad89a2f8 jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents: 28314
diff changeset
207 }
28515
4fd0baa32a9e jabber: Fix a few places where the default for require_tls was wrong.
Paul Aurich <paul@darkrain42.org>
parents: 28513
diff changeset
208 } else if(purple_account_get_bool(js->gc->account, "require_tls", JABBER_DEFAULT_REQUIRE_TLS) && !jabber_stream_is_ssl(js)) {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
209 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 21355
diff changeset
210 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 20076
diff changeset
211 _("You require encryption, but it is not available on this server."));
17896
a8420fd18545 Added an option to require SSL or TLS when connecting to an XMPP server.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17894
diff changeset
212 return;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 if(js->registration) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 jabber_register_start(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 } else if(xmlnode_get_child(packet, "mechanisms")) {
28327
c7aaad89a2f8 jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents: 28314
diff changeset
218 jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 jabber_auth_start(js, packet);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 } else if(xmlnode_get_child(packet, "bind")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 xmlnode *bind, *resource;
24555
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
222 char *requested_resource;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 bind = xmlnode_new_child(iq->node, "bind");
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
225 xmlnode_set_namespace(bind, NS_XMPP_BIND);
24555
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
226 requested_resource = jabber_prep_resource(js->user->resource);
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
227
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
228 if (requested_resource != NULL) {
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
229 resource = xmlnode_new_child(bind, "resource");
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
230 xmlnode_insert_data(resource, requested_resource, -1);
24666
641fe4c2b2a5 Use g_free instead of free.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24585
diff changeset
231 g_free(requested_resource);
24555
7ec139c84d36 Some improvements to XMPP resource handling:
Jonathan Sailor <jsailor@jesnetplus.com>
parents: 24464
diff changeset
232 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 jabber_iq_set_callback(iq, jabber_bind_result_cb, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 jabber_iq_send(iq);
28760
0f7025534fc5 jabber: Roster Versioning support.
Paul Aurich <paul@darkrain42.org>
parents: 28758
diff changeset
237 } else if (xmlnode_get_child_with_namespace(packet, "ver", NS_ROSTER_VERSIONING)) {
0f7025534fc5 jabber: Roster Versioning support.
Paul Aurich <paul@darkrain42.org>
parents: 28758
diff changeset
238 js->server_caps |= JABBER_CAP_ROSTER_VERSIONING;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 } else /* if(xmlnode_get_child_with_namespace(packet, "auth")) */ {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 /* If we get an empty stream:features packet, or we explicitly get
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 * an auth feature with namespace http://jabber.org/features/iq-auth
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 * we should revert back to iq:auth authentication, even though we're
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 * connecting to an XMPP server. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING);
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28517
diff changeset
245 jabber_auth_start_old(js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 21355
diff changeset
251 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
20814
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
252 char *msg = jabber_parse_error(js, packet, &reason);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
254 purple_connection_error_reason(js->gc, reason, msg);
20814
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
255
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 static void tls_init(JabberStream *js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260
17894
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
261 void jabber_process_packet(JabberStream *js, xmlnode **packet)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 {
15917
26593bef6568 Minor code cleanup
Mark Doliner <mark@kingant.net>
parents: 15916
diff changeset
263 const char *xmlns;
26593bef6568 Minor code cleanup
Mark Doliner <mark@kingant.net>
parents: 15916
diff changeset
264
28517
96ba7fd24177 jabber: Use purple_connection_get_prpl() instead of jabber_plugin.
Paul Aurich <paul@darkrain42.org>
parents: 28515
diff changeset
265 purple_signal_emit(purple_connection_get_prpl(js->gc), "jabber-receiving-xmlnode", js->gc, packet);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 /* if the signal leaves us with a null packet, we're done */
17894
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
268 if(NULL == *packet)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270
17894
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
271 xmlns = xmlnode_get_namespace(*packet);
15917
26593bef6568 Minor code cleanup
Mark Doliner <mark@kingant.net>
parents: 15916
diff changeset
272
17894
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
273 if(!strcmp((*packet)->name, "iq")) {
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
274 jabber_iq_parse(js, *packet);
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
275 } else if(!strcmp((*packet)->name, "presence")) {
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
276 jabber_presence_parse(js, *packet);
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
277 } else if(!strcmp((*packet)->name, "message")) {
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
278 jabber_message_parse(js, *packet);
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
279 } else if(!strcmp((*packet)->name, "stream:features")) {
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
280 jabber_stream_features_parse(js, *packet);
21538
4e5bef6c3379 Fix #3669
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
281 } else if (!strcmp((*packet)->name, "features") && xmlns &&
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
282 !strcmp(xmlns, NS_XMPP_STREAMS)) {
17894
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
283 jabber_stream_features_parse(js, *packet);
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
284 } else if(!strcmp((*packet)->name, "stream:error") ||
21538
4e5bef6c3379 Fix #3669
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
285 (!strcmp((*packet)->name, "error") && xmlns &&
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
286 !strcmp(xmlns, NS_XMPP_STREAMS)))
15917
26593bef6568 Minor code cleanup
Mark Doliner <mark@kingant.net>
parents: 15916
diff changeset
287 {
17894
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
288 jabber_stream_handle_error(js, *packet);
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
289 } else if(!strcmp((*packet)->name, "challenge")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 if(js->state == JABBER_STREAM_AUTHENTICATING)
17894
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
291 jabber_auth_handle_challenge(js, *packet);
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
292 } else if(!strcmp((*packet)->name, "success")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 if(js->state == JABBER_STREAM_AUTHENTICATING)
17894
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
294 jabber_auth_handle_success(js, *packet);
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
295 } else if(!strcmp((*packet)->name, "failure")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 if(js->state == JABBER_STREAM_AUTHENTICATING)
17894
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
297 jabber_auth_handle_failure(js, *packet);
bbd92ee894f2 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 <pidgin@monitzer.com>
parents: 17893
diff changeset
298 } else if(!strcmp((*packet)->name, "proceed")) {
28327
c7aaad89a2f8 jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents: 28314
diff changeset
299 if (js->state == JABBER_STREAM_INITIALIZING_ENCRYPTION && !js->gsc)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 tls_init(js);
28327
c7aaad89a2f8 jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents: 28314
diff changeset
301 else
c7aaad89a2f8 jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents: 28314
diff changeset
302 purple_debug_warning("jabber", "Ignoring spurious <proceed/>\n");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 } else {
28513
fa7f3426ed13 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <paul@darkrain42.org>
parents: 28512
diff changeset
304 purple_debug_warning("jabber", "Unknown packet: %s\n", (*packet)->name);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 static int jabber_do_send(JabberStream *js, const char *data, int len)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 int ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 if (js->gsc)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
313 ret = purple_ssl_write(js->gsc, data, len);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 ret = write(js->fd, data, len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 return ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
320 static void jabber_send_cb(gpointer data, gint source, PurpleInputCondition cond)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 JabberStream *js = data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 int ret, writelen;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
324 writelen = purple_circ_buffer_get_max_read(js->write_buffer);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 if (writelen == 0) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
327 purple_input_remove(js->writeh);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 js->writeh = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 ret = jabber_do_send(js, js->write_buffer->outptr, writelen);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 if (ret < 0 && errno == EAGAIN)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 else if (ret <= 0) {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
337 gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"),
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
338 g_strerror(errno));
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
339 purple_connection_error_reason(js->gc,
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
340 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
341 g_free(tmp);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
345 purple_circ_buffer_mark_read(js->write_buffer, ret);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347
23376
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
348 static gboolean do_jabber_send_raw(JabberStream *js, const char *data, int len)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 int ret;
23376
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
351 gboolean success = TRUE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 if (len == -1)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354 len = strlen(data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 if (js->writeh == 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357 ret = jabber_do_send(js, data, len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 ret = -1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 errno = EAGAIN;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362
23376
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
363 if (ret < 0 && errno != EAGAIN) {
28941
9cdf9bc6c1ed jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <paul@darkrain42.org>
parents: 28901
diff changeset
364 PurpleAccount *account = purple_connection_get_account(js->gc);
9cdf9bc6c1ed jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <paul@darkrain42.org>
parents: 28901
diff changeset
365 /*
9cdf9bc6c1ed jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <paul@darkrain42.org>
parents: 28901
diff changeset
366 * The server may have closed the socket (on a stream error), so if
9cdf9bc6c1ed jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <paul@darkrain42.org>
parents: 28901
diff changeset
367 * we're disconnecting, don't generate (possibly another) error that
9cdf9bc6c1ed jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <paul@darkrain42.org>
parents: 28901
diff changeset
368 * (for some UIs) would mask the first.
9cdf9bc6c1ed jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <paul@darkrain42.org>
parents: 28901
diff changeset
369 */
9cdf9bc6c1ed jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <paul@darkrain42.org>
parents: 28901
diff changeset
370 if (!account->disconnecting) {
9cdf9bc6c1ed jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <paul@darkrain42.org>
parents: 28901
diff changeset
371 gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"),
9cdf9bc6c1ed jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <paul@darkrain42.org>
parents: 28901
diff changeset
372 g_strerror(errno));
9cdf9bc6c1ed jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <paul@darkrain42.org>
parents: 28901
diff changeset
373 purple_connection_error_reason(js->gc,
9cdf9bc6c1ed jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <paul@darkrain42.org>
parents: 28901
diff changeset
374 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
9cdf9bc6c1ed jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <paul@darkrain42.org>
parents: 28901
diff changeset
375 g_free(tmp);
9cdf9bc6c1ed jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <paul@darkrain42.org>
parents: 28901
diff changeset
376 }
9cdf9bc6c1ed jabber: When doing writes while disconnecting, 'ignore' errors.
Paul Aurich <paul@darkrain42.org>
parents: 28901
diff changeset
377
23376
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
378 success = FALSE;
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
379 } else if (ret < len) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 if (ret < 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 ret = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 if (js->writeh == 0)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
383 js->writeh = purple_input_add(
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 js->gsc ? js->gsc->fd : js->fd,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
385 PURPLE_INPUT_WRITE, jabber_send_cb, js);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
386 purple_circ_buffer_append(js->write_buffer,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 data + ret, len - ret);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388 }
23376
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
389
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
390 return success;
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
391 }
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
392
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
393 void jabber_send_raw(JabberStream *js, const char *data, int len)
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
394 {
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
395 /* because printing a tab to debug every minute gets old */
24890
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
396 if(strcmp(data, "\t")) {
28512
562fd22dbe89 jabber: Print account name on sent stanzas in the debug log.
Paul Aurich <paul@darkrain42.org>
parents: 28438
diff changeset
397 const char *username;
24890
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
398 char *text = NULL, *last_part = NULL, *tag_start = NULL;
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
399
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
400 /* Because debug logs with plaintext passwords make me sad */
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
401 if(js->state != JABBER_STREAM_CONNECTED &&
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
402 /* Either <auth> or <query><password>... */
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
403 (((tag_start = strstr(data, "<auth ")) &&
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
404 strstr(data, "xmlns='" NS_XMPP_SASL "'")) ||
24890
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
405 ((tag_start = strstr(data, "<query ")) &&
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
406 strstr(data, "xmlns='jabber:iq:auth'>") &&
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
407 (tag_start = strstr(tag_start, "<password>"))))) {
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
408 char *data_start, *tag_end = strchr(tag_start, '>');
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
409 text = g_strdup(data);
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
410
25599
b9a90f34b780 *** Plucked rev b786784e (datallah@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents: 25587
diff changeset
411 /* Better to print out some wacky debugging than crash
b9a90f34b780 *** Plucked rev b786784e (datallah@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents: 25587
diff changeset
412 * due to a plugin sending bad xml */
b9a90f34b780 *** Plucked rev b786784e (datallah@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents: 25587
diff changeset
413 if (tag_end == NULL)
b9a90f34b780 *** Plucked rev b786784e (datallah@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents: 25587
diff changeset
414 tag_end = tag_start;
b9a90f34b780 *** Plucked rev b786784e (datallah@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents: 25587
diff changeset
415
24890
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
416 data_start = text + (tag_end - data) + 1;
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
417
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
418 last_part = strchr(data_start, '<');
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
419 *data_start = '\0';
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
420 }
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
421
28512
562fd22dbe89 jabber: Print account name on sent stanzas in the debug log.
Paul Aurich <paul@darkrain42.org>
parents: 28438
diff changeset
422 username = purple_connection_get_display_name(js->gc);
562fd22dbe89 jabber: Print account name on sent stanzas in the debug log.
Paul Aurich <paul@darkrain42.org>
parents: 28438
diff changeset
423 if (!username)
562fd22dbe89 jabber: Print account name on sent stanzas in the debug log.
Paul Aurich <paul@darkrain42.org>
parents: 28438
diff changeset
424 username = purple_account_get_username(purple_connection_get_account(js->gc));
562fd22dbe89 jabber: Print account name on sent stanzas in the debug log.
Paul Aurich <paul@darkrain42.org>
parents: 28438
diff changeset
425
562fd22dbe89 jabber: Print account name on sent stanzas in the debug log.
Paul Aurich <paul@darkrain42.org>
parents: 28438
diff changeset
426 purple_debug_misc("jabber", "Sending%s (%s): %s%s%s\n",
562fd22dbe89 jabber: Print account name on sent stanzas in the debug log.
Paul Aurich <paul@darkrain42.org>
parents: 28438
diff changeset
427 jabber_stream_is_ssl(js) ? " (ssl)" : "", username,
562fd22dbe89 jabber: Print account name on sent stanzas in the debug log.
Paul Aurich <paul@darkrain42.org>
parents: 28438
diff changeset
428 text ? text : data,
24890
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
429 last_part ? "password removed" : "",
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
430 last_part ? last_part : "");
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
431
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
432 g_free(text);
3a4070656d61 Don't log passwords for XMPP when using SASL PLAIN or old-style IQ Auth so
Paul Aurich <paul@darkrain42.org>
parents: 24869
diff changeset
433 }
23376
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
434
28517
96ba7fd24177 jabber: Use purple_connection_get_prpl() instead of jabber_plugin.
Paul Aurich <paul@darkrain42.org>
parents: 28515
diff changeset
435 purple_signal_emit(purple_connection_get_prpl(js->gc), "jabber-sending-text", js->gc, &data);
23376
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
436 if (data == NULL)
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
437 return;
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
438
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
439 /* If we've got a security layer, we need to encode the data,
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
440 * splitting it on the maximum buffer length negotiated */
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
441 #ifdef HAVE_CYRUS_SASL
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
442 if (js->sasl_maxbuf>0) {
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
443 int pos = 0;
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
444
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
445 if (!js->gsc && js->fd<0)
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
446 return;
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
447
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
448 if (len == -1)
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
449 len = strlen(data);
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
450
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
451 while (pos < len) {
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
452 int towrite;
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
453 const char *out;
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
454 unsigned olen;
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
455
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
456 towrite = MIN((len - pos), js->sasl_maxbuf);
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
457
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
458 sasl_encode(js->sasl, &data[pos], towrite, &out, &olen);
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
459 pos += towrite;
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
460
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
461 if (!do_jabber_send_raw(js, out, olen))
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
462 break;
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
463 }
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
464 return;
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
465 }
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
466 #endif
e12600d6b902 Cleanup some duplication and simplify this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23285
diff changeset
467
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468 if (len == -1)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 len = strlen(data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470
27787
53f0956f76dc jabber: Remove js->use_bosh
Paul Aurich <paul@darkrain42.org>
parents: 27778
diff changeset
471 if (js->bosh)
26448
d4af753e0e33 Pass all messages to BOSH as text, so they pass through the sending-text
Paul Aurich <paul@darkrain42.org>
parents: 26447
diff changeset
472 jabber_bosh_connection_send_raw(js->bosh, data);
25182
17b60b844803 Jabber BOSH: more fixes.
Paul Aurich <paul@darkrain42.org>
parents: 25181
diff changeset
473 else
25125
907ca9a36fe0 explicit merge of '714a7c7f903d11c96ffade34966121da549d998f'
Paul Aurich <paul@darkrain42.org>
parents: 25050 25124
diff changeset
474 do_jabber_send_raw(js, data, len);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476
16240
547c76fe2e7a 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@gmail.com>
parents: 16068
diff changeset
477 int jabber_prpl_send_raw(PurpleConnection *gc, const char *buf, int len)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479 JabberStream *js = (JabberStream*)gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480 jabber_send_raw(js, buf, len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 return len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483
27006
d31af94a715d Use the jabber-sending-xmlnode signal to send all XMPP stanzas.
Paul Aurich <paul@darkrain42.org>
parents: 27004
diff changeset
484 void jabber_send_signal_cb(PurpleConnection *pc, xmlnode **packet,
d31af94a715d Use the jabber-sending-xmlnode signal to send all XMPP stanzas.
Paul Aurich <paul@darkrain42.org>
parents: 27004
diff changeset
485 gpointer unused)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486 {
27663
e8e056876e39 Set the namespace properly on stanzas for BOSH.
Paul Aurich <paul@darkrain42.org>
parents: 27656
diff changeset
487 JabberStream *js;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488 char *txt;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489 int len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490
27006
d31af94a715d Use the jabber-sending-xmlnode signal to send all XMPP stanzas.
Paul Aurich <paul@darkrain42.org>
parents: 27004
diff changeset
491 if (NULL == packet)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493
28640
7622d3f86752 Add some safety to jabber_send_signal_cb in case someone else was listening
Stu Tomlinson <stu@nosnilmot.com>
parents: 28592
diff changeset
494 if (!PURPLE_CONNECTION_IS_VALID(pc))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496
27663
e8e056876e39 Set the namespace properly on stanzas for BOSH.
Paul Aurich <paul@darkrain42.org>
parents: 27656
diff changeset
497 js = purple_connection_get_protocol_data(pc);
28640
7622d3f86752 Add some safety to jabber_send_signal_cb in case someone else was listening
Stu Tomlinson <stu@nosnilmot.com>
parents: 28592
diff changeset
498
7622d3f86752 Add some safety to jabber_send_signal_cb in case someone else was listening
Stu Tomlinson <stu@nosnilmot.com>
parents: 28592
diff changeset
499 if (NULL == js)
7622d3f86752 Add some safety to jabber_send_signal_cb in case someone else was listening
Stu Tomlinson <stu@nosnilmot.com>
parents: 28592
diff changeset
500 return;
7622d3f86752 Add some safety to jabber_send_signal_cb in case someone else was listening
Stu Tomlinson <stu@nosnilmot.com>
parents: 28592
diff changeset
501
27787
53f0956f76dc jabber: Remove js->use_bosh
Paul Aurich <paul@darkrain42.org>
parents: 27778
diff changeset
502 if (js->bosh)
27663
e8e056876e39 Set the namespace properly on stanzas for BOSH.
Paul Aurich <paul@darkrain42.org>
parents: 27656
diff changeset
503 if (g_str_equal((*packet)->name, "message") ||
e8e056876e39 Set the namespace properly on stanzas for BOSH.
Paul Aurich <paul@darkrain42.org>
parents: 27656
diff changeset
504 g_str_equal((*packet)->name, "iq") ||
e8e056876e39 Set the namespace properly on stanzas for BOSH.
Paul Aurich <paul@darkrain42.org>
parents: 27656
diff changeset
505 g_str_equal((*packet)->name, "presence"))
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
506 xmlnode_set_namespace(*packet, NS_XMPP_CLIENT);
27006
d31af94a715d Use the jabber-sending-xmlnode signal to send all XMPP stanzas.
Paul Aurich <paul@darkrain42.org>
parents: 27004
diff changeset
507 txt = xmlnode_to_str(*packet, &len);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 jabber_send_raw(js, txt, len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 g_free(txt);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511
27006
d31af94a715d Use the jabber-sending-xmlnode signal to send all XMPP stanzas.
Paul Aurich <paul@darkrain42.org>
parents: 27004
diff changeset
512 void jabber_send(JabberStream *js, xmlnode *packet)
21859
e13609ce4548 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@gmail.com>
parents: 21814
diff changeset
513 {
28517
96ba7fd24177 jabber: Use purple_connection_get_prpl() instead of jabber_plugin.
Paul Aurich <paul@darkrain42.org>
parents: 28515
diff changeset
514 purple_signal_emit(purple_connection_get_prpl(js->gc), "jabber-sending-xmlnode", js->gc, &packet);
21859
e13609ce4548 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@gmail.com>
parents: 21814
diff changeset
515 }
e13609ce4548 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@gmail.com>
parents: 21814
diff changeset
516
25640
42dd7e591031 Make the XMPP keepalive use jabber_ping_jid instead of building it itself.
Paul Aurich <paul@darkrain42.org>
parents: 25412
diff changeset
517 static gboolean jabber_keepalive_timeout(PurpleConnection *gc)
21859
e13609ce4548 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@gmail.com>
parents: 21814
diff changeset
518 {
21973
966f98d4b04b Masca noticed that dc6923294f5f33ff7a52a998e1b9e9ad47be0211 made jabber.c not
Will Thompson <will.thompson@collabora.co.uk>
parents: 21964
diff changeset
519 JabberStream *js = gc->proto_data;
21859
e13609ce4548 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@gmail.com>
parents: 21814
diff changeset
520 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
521 _("Ping timed out"));
27069
08f5c5b12e7c The XMPP keepalive timeout handle needs to be a guint.
Paul Aurich <paul@darkrain42.org>
parents: 27055
diff changeset
522 js->keepalive_timeout = 0;
21859
e13609ce4548 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@gmail.com>
parents: 21814
diff changeset
523 return FALSE;
e13609ce4548 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@gmail.com>
parents: 21814
diff changeset
524 }
e13609ce4548 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@gmail.com>
parents: 21814
diff changeset
525
16240
547c76fe2e7a 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@gmail.com>
parents: 16068
diff changeset
526 void jabber_keepalive(PurpleConnection *gc)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527 {
29492
0d3151a41134 jabber: Don't ping more often than once a minute.
Paul Aurich <paul@darkrain42.org>
parents: 29473
diff changeset
528 JabberStream *js = purple_connection_get_protocol_data(gc);
0d3151a41134 jabber: Don't ping more often than once a minute.
Paul Aurich <paul@darkrain42.org>
parents: 29473
diff changeset
529 time_t now = time(NULL);
0d3151a41134 jabber: Don't ping more often than once a minute.
Paul Aurich <paul@darkrain42.org>
parents: 29473
diff changeset
530
0d3151a41134 jabber: Don't ping more often than once a minute.
Paul Aurich <paul@darkrain42.org>
parents: 29473
diff changeset
531 if (js->keepalive_timeout == 0 && (now - js->last_ping) >= PING_TIMEOUT) {
0d3151a41134 jabber: Don't ping more often than once a minute.
Paul Aurich <paul@darkrain42.org>
parents: 29473
diff changeset
532 js->last_ping = now;
0d3151a41134 jabber: Don't ping more often than once a minute.
Paul Aurich <paul@darkrain42.org>
parents: 29473
diff changeset
533
26917
6b0e150f2276 Stop trying to be clever with XMPP keepalive pings.
Paul Aurich <paul@darkrain42.org>
parents: 26874
diff changeset
534 jabber_keepalive_ping(js);
25640
42dd7e591031 Make the XMPP keepalive use jabber_ping_jid instead of building it itself.
Paul Aurich <paul@darkrain42.org>
parents: 25412
diff changeset
535 js->keepalive_timeout = purple_timeout_add_seconds(120,
42dd7e591031 Make the XMPP keepalive use jabber_ping_jid instead of building it itself.
Paul Aurich <paul@darkrain42.org>
parents: 25412
diff changeset
536 (GSourceFunc)(jabber_keepalive_timeout), gc);
22459
8ec6ac1b9e26 Only allow one keepalive_timeout at a time. This prevents us from starting a
Evan Schoenberg <evan.s@dreskin.net>
parents: 22443
diff changeset
537 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
541 jabber_recv_cb_ssl(gpointer data, PurpleSslConnection *gsc,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
542 PurpleInputCondition cond)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
544 PurpleConnection *gc = data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
545 JabberStream *js = gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546 int len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 static char buf[4096];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549 /* TODO: It should be possible to make this check unnecessary */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
550 if(!PURPLE_CONNECTION_IS_VALID(gc)) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
551 purple_ssl_close(gsc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
552 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
554
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
555 while((len = purple_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) {
22149
252b96b6a32c Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@gmail.com>
parents: 22097
diff changeset
556 gc->last_received = time(NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557 buf[len] = '\0';
28513
fa7f3426ed13 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <paul@darkrain42.org>
parents: 28512
diff changeset
558 purple_debug_info("jabber", "Recv (ssl)(%d): %s\n", len, buf);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559 jabber_parser_process(js, buf, len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560 if(js->reinit)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561 jabber_stream_init(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
563
23396
47b709962aab Only check for EAGAIN if read returned less than 0. This fixes a bug
Mark Doliner <mark@kingant.net>
parents: 23389
diff changeset
564 if(len < 0 && errno == EAGAIN)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565 return;
23396
47b709962aab Only check for EAGAIN if read returned less than 0. This fixes a bug
Mark Doliner <mark@kingant.net>
parents: 23389
diff changeset
566 else {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
567 gchar *tmp;
23396
47b709962aab Only check for EAGAIN if read returned less than 0. This fixes a bug
Mark Doliner <mark@kingant.net>
parents: 23389
diff changeset
568 if (len == 0)
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
569 tmp = g_strdup_printf(_("Server closed the connection"));
23396
47b709962aab Only check for EAGAIN if read returned less than 0. This fixes a bug
Mark Doliner <mark@kingant.net>
parents: 23389
diff changeset
570 else
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
571 tmp = g_strdup_printf(_("Lost connection with server: %s"),
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
572 g_strerror(errno));
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
573 purple_connection_error_reason(js->gc,
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
574 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
575 g_free(tmp);
23396
47b709962aab Only check for EAGAIN if read returned less than 0. This fixes a bug
Mark Doliner <mark@kingant.net>
parents: 23389
diff changeset
576 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
580 jabber_recv_cb(gpointer data, gint source, PurpleInputCondition condition)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
582 PurpleConnection *gc = data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583 JabberStream *js = gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
584 int len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
585 static char buf[4096];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
587 if(!PURPLE_CONNECTION_IS_VALID(gc))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590 if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) {
22149
252b96b6a32c Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@gmail.com>
parents: 22097
diff changeset
591 gc->last_received = time(NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
592 #ifdef HAVE_CYRUS_SASL
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593 if (js->sasl_maxbuf>0) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
594 const char *out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595 unsigned int olen;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
596 sasl_decode(js->sasl, buf, len, &out, &olen);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
597 if (olen>0) {
28513
fa7f3426ed13 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <paul@darkrain42.org>
parents: 28512
diff changeset
598 purple_debug_info("jabber", "RecvSASL (%u): %s\n", olen, out);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599 jabber_parser_process(js,out,olen);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
600 if(js->reinit)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
601 jabber_stream_init(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
602 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
603 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
604 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
605 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606 buf[len] = '\0';
28513
fa7f3426ed13 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <paul@darkrain42.org>
parents: 28512
diff changeset
607 purple_debug_info("jabber", "Recv (%d): %s\n", len, buf);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608 jabber_parser_process(js, buf, len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
609 if(js->reinit)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
610 jabber_stream_init(js);
23396
47b709962aab Only check for EAGAIN if read returned less than 0. This fixes a bug
Mark Doliner <mark@kingant.net>
parents: 23389
diff changeset
611 } else if(len < 0 && errno == EAGAIN) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
612 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
613 } else {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
614 gchar *tmp;
23396
47b709962aab Only check for EAGAIN if read returned less than 0. This fixes a bug
Mark Doliner <mark@kingant.net>
parents: 23389
diff changeset
615 if (len == 0)
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
616 tmp = g_strdup_printf(_("Server closed the connection"));
23396
47b709962aab Only check for EAGAIN if read returned less than 0. This fixes a bug
Mark Doliner <mark@kingant.net>
parents: 23389
diff changeset
617 else
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
618 tmp = g_strdup_printf(_("Lost connection with server: %s"),
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
619 g_strerror(errno));
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
620 purple_connection_error_reason(js->gc,
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
621 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
622 g_free(tmp);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
623 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
625
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
627 jabber_login_callback_ssl(gpointer data, PurpleSslConnection *gsc,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
628 PurpleInputCondition cond)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
629 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
630 PurpleConnection *gc = data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
631 JabberStream *js;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
632
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
633 /* TODO: It should be possible to make this check unnecessary */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
634 if(!PURPLE_CONNECTION_IS_VALID(gc)) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
635 purple_ssl_close(gsc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
636 return;
19999
da29f5c7dc1a 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 <daniel.atallah@gmail.com>
parents: 19723
diff changeset
637 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
638
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
639 js = gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
640
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
641 if(js->state == JABBER_STREAM_CONNECTING)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
642 jabber_send_raw(js, "<?xml version='1.0' ?>", -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
643 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
644 purple_ssl_input_add(gsc, jabber_recv_cb_ssl, gc);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
645
17879
108f3b42976f 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 <pidgin@monitzer.com>
parents: 17876
diff changeset
646 /* Tell the app that we're doing encryption */
108f3b42976f 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 <pidgin@monitzer.com>
parents: 17876
diff changeset
647 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING_ENCRYPTION);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
648 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
649
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26917
diff changeset
650 static void
27349
a71cc338f0fd A couple more s/GSList/GList/ changes as fallout from the last change.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27347
diff changeset
651 txt_resolved_cb(GList *responses, gpointer data)
25038
7768cad83127 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25035
diff changeset
652 {
25181
7de1f124f95a Jabber BOSH: Many fixes
Paul Aurich <paul@darkrain42.org>
parents: 25180
diff changeset
653 JabberStream *js = data;
26590
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26589
diff changeset
654
25180
1516525c86fa Track the TXT query in the js object so it will be cancelleable
Paul Aurich <paul@darkrain42.org>
parents: 25179
diff changeset
655 js->srv_query_data = NULL;
1516525c86fa Track the TXT query in the js object so it will be cancelleable
Paul Aurich <paul@darkrain42.org>
parents: 25179
diff changeset
656
26590
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26589
diff changeset
657 if (responses == NULL) {
28802
20f4bce8894d jabber: Print a better error message when all connection methods fail.
Paul Aurich <paul@darkrain42.org>
parents: 28760
diff changeset
658 purple_debug_warning("jabber", "Unable to find alternative XMPP connection "
28900
ddad759dc05b jabber: Newline at the end of this message.
Paul Aurich <paul@darkrain42.org>
parents: 28802
diff changeset
659 "methods after failing to connect directly.\n");
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
660 purple_connection_error_reason(js->gc,
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
661 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
28802
20f4bce8894d jabber: Print a better error message when all connection methods fail.
Paul Aurich <paul@darkrain42.org>
parents: 28760
diff changeset
662 _("Unable to connect"));
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26917
diff changeset
663 return;
25038
7768cad83127 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25035
diff changeset
664 }
26590
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26589
diff changeset
665
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26589
diff changeset
666 while (responses) {
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26589
diff changeset
667 PurpleTxtResponse *resp = responses->data;
25039
9f8951284a2e * small bugfix in jabber_ipc_add_feature()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25038
diff changeset
668 gchar **token;
26590
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26589
diff changeset
669 token = g_strsplit(purple_txt_response_get_content(resp), "=", 2);
25039
9f8951284a2e * small bugfix in jabber_ipc_add_feature()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25038
diff changeset
670 if (!strcmp(token[0], "_xmpp-client-xbosh")) {
9f8951284a2e * small bugfix in jabber_ipc_add_feature()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25038
diff changeset
671 purple_debug_info("jabber","Found alternative connection method using %s at %s.\n", token[0], token[1]);
25181
7de1f124f95a Jabber BOSH: Many fixes
Paul Aurich <paul@darkrain42.org>
parents: 25180
diff changeset
672 js->bosh = jabber_bosh_connection_init(js, token[1]);
25039
9f8951284a2e * small bugfix in jabber_ipc_add_feature()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25038
diff changeset
673 g_strfreev(token);
9f8951284a2e * small bugfix in jabber_ipc_add_feature()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25038
diff changeset
674 break;
9f8951284a2e * small bugfix in jabber_ipc_add_feature()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25038
diff changeset
675 }
9f8951284a2e * small bugfix in jabber_ipc_add_feature()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25038
diff changeset
676 g_strfreev(token);
26590
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26589
diff changeset
677 purple_txt_response_destroy(resp);
27349
a71cc338f0fd A couple more s/GSList/GList/ changes as fallout from the last change.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27347
diff changeset
678 responses = g_list_delete_link(responses, responses);
25038
7768cad83127 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25035
diff changeset
679 }
26590
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26589
diff changeset
680
25181
7de1f124f95a Jabber BOSH: Many fixes
Paul Aurich <paul@darkrain42.org>
parents: 25180
diff changeset
681 if (js->bosh) {
7de1f124f95a Jabber BOSH: Many fixes
Paul Aurich <paul@darkrain42.org>
parents: 25180
diff changeset
682 jabber_bosh_connection_connect(js->bosh);
25042
1cbe5a9f6efb * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25039
diff changeset
683 } else {
1cbe5a9f6efb * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25039
diff changeset
684 purple_debug_info("jabber","Didn't find an alternative connection method.\n");
1cbe5a9f6efb * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25039
diff changeset
685 }
26589
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26588
diff changeset
686
26590
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26589
diff changeset
687 if (responses) {
27349
a71cc338f0fd A couple more s/GSList/GList/ changes as fallout from the last change.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27347
diff changeset
688 g_list_foreach(responses, (GFunc)purple_txt_response_destroy, NULL);
a71cc338f0fd A couple more s/GSList/GList/ changes as fallout from the last change.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27347
diff changeset
689 g_list_free(responses);
26590
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26589
diff changeset
690 }
25038
7768cad83127 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25035
diff changeset
691 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
692
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
693 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
694 jabber_login_callback(gpointer data, gint source, const gchar *error)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
695 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
696 PurpleConnection *gc = data;
28901
4189f9e1627b jabber: Pedantically this bothered me, but changing the message to
Paul Aurich <paul@darkrain42.org>
parents: 28900
diff changeset
697 JabberStream *js = purple_connection_get_protocol_data(gc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
698
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
699 if (source < 0) {
23598
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
700 if (js->srv_rec != NULL) {
28901
4189f9e1627b jabber: Pedantically this bothered me, but changing the message to
Paul Aurich <paul@darkrain42.org>
parents: 28900
diff changeset
701 purple_debug_error("jabber", "Unable to connect to server: %s. Trying next SRV record or connecting directly.\n", error);
23598
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
702 try_srv_connect(js);
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
703 } else {
28901
4189f9e1627b jabber: Pedantically this bothered me, but changing the message to
Paul Aurich <paul@darkrain42.org>
parents: 28900
diff changeset
704 purple_debug_info("jabber","Couldn't connect directly to %s. Trying to find alternative connection methods, like BOSH.\n", js->user->domain);
27608
6f455daf3776 ASCII-ize the TXT query, too.
Paul Aurich <paul@darkrain42.org>
parents: 27607
diff changeset
705 js->srv_query_data = purple_txt_resolve("_xmppconnect",
27635
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27613
diff changeset
706 js->user->domain, txt_resolved_cb, js);
23598
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
707 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
708 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
709 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
710
23598
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
711 g_free(js->srv_rec);
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
712 js->srv_rec = NULL;
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
713
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
714 js->fd = source;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
715
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
716 if(js->state == JABBER_STREAM_CONNECTING)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
717 jabber_send_raw(js, "<?xml version='1.0' ?>", -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
718
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
719 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
720 gc->inpa = purple_input_add(js->fd, PURPLE_INPUT_READ, jabber_recv_cb, gc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
721 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
722
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
723 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
724 jabber_ssl_connect_failure(PurpleSslConnection *gsc, PurpleSslErrorType error,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
725 gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
726 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
727 PurpleConnection *gc = data;
15606
66dc2367b137 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 <evan.s@dreskin.net>
parents: 15497
diff changeset
728 JabberStream *js;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
729
15606
66dc2367b137 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 <evan.s@dreskin.net>
parents: 15497
diff changeset
730 /* If the connection is already disconnected, we don't need to do anything else */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
731 if(!PURPLE_CONNECTION_IS_VALID(gc))
15606
66dc2367b137 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 <evan.s@dreskin.net>
parents: 15497
diff changeset
732 return;
66dc2367b137 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 <evan.s@dreskin.net>
parents: 15497
diff changeset
733
66dc2367b137 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 <evan.s@dreskin.net>
parents: 15497
diff changeset
734 js = gc->proto_data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
735 js->gsc = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
736
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 20076
diff changeset
737 purple_connection_ssl_error (gc, error);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
738 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
739
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
740 static void tls_init(JabberStream *js)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
741 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
742 purple_input_remove(js->gc->inpa);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
743 js->gc->inpa = 0;
18929
67cb28c0ec89 applied changes from e52b685d84ca8874da6e3e71199829e513500642
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18163
diff changeset
744 js->gsc = purple_ssl_connect_with_host_fd(js->gc->account, js->fd,
22034
d63892ade0a6 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 <pidgin@monitzer.com>
parents: 22000
diff changeset
745 jabber_login_callback_ssl, jabber_ssl_connect_failure, js->certificate_CN, js->gc);
27656
96c38fe2cb00 Clear out the fd when we pass it off to the SSL subsystem
Paul Aurich <paul@darkrain42.org>
parents: 27635
diff changeset
746 /* The fd is no longer our concern */
96c38fe2cb00 Clear out the fd when we pass it off to the SSL subsystem
Paul Aurich <paul@darkrain42.org>
parents: 27635
diff changeset
747 js->fd = -1;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
748 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
749
23598
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
750 static gboolean jabber_login_connect(JabberStream *js, const char *domain, const char *host, int port,
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
751 gboolean fatal_failure)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
752 {
22337
dc47e908965f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents: 22149
diff changeset
753 /* host should be used in preference to domain to
dc47e908965f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents: 22149
diff changeset
754 * allow SASL authentication to work with FQDN of the server,
dc47e908965f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents: 22149
diff changeset
755 * but we use domain as fallback for when users enter IP address
dc47e908965f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents: 22149
diff changeset
756 * in connect server */
23598
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
757 g_free(js->serverFQDN);
22337
dc47e908965f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents: 22149
diff changeset
758 if (purple_ip_address_is_valid(host))
dc47e908965f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents: 22149
diff changeset
759 js->serverFQDN = g_strdup(domain);
dc47e908965f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents: 22149
diff changeset
760 else
dc47e908965f Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents: 22149
diff changeset
761 js->serverFQDN = g_strdup(host);
15765
51dd9ae01585 pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents: 15728
diff changeset
762
27613
5f17bfa9dc70 To make grim happy (or more upset).
Paul Aurich <paul@darkrain42.org>
parents: 27608
diff changeset
763 if (purple_proxy_connect(js->gc, purple_connection_get_account(js->gc),
5f17bfa9dc70 To make grim happy (or more upset).
Paul Aurich <paul@darkrain42.org>
parents: 27608
diff changeset
764 host, port, jabber_login_callback, js->gc) == NULL) {
23598
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
765 if (fatal_failure) {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
766 purple_connection_error_reason(js->gc,
23598
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
767 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27349
diff changeset
768 _("Unable to connect"));
23598
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
769 }
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
770
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
771 return FALSE;
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
772 }
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
773
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
774 return TRUE;
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
775 }
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
776
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
777 static void try_srv_connect(JabberStream *js)
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
778 {
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
779 while (js->srv_rec != NULL && js->srv_rec_idx < js->max_srv_rec_idx) {
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
780 PurpleSrvResponse *tmp_resp = js->srv_rec + (js->srv_rec_idx++);
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
781 if (jabber_login_connect(js, tmp_resp->hostname, tmp_resp->hostname, tmp_resp->port, FALSE))
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
782 return;
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
783 }
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
784
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
785 g_free(js->srv_rec);
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
786 js->srv_rec = NULL;
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
787
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
788 /* Fall back to the defaults (I'm not sure if we should actually do this) */
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
789 jabber_login_connect(js, js->user->domain, js->user->domain,
27613
5f17bfa9dc70 To make grim happy (or more upset).
Paul Aurich <paul@darkrain42.org>
parents: 27608
diff changeset
790 purple_account_get_int(purple_connection_get_account(js->gc), "port", 5222),
27635
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27613
diff changeset
791 TRUE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
792 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
793
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
794 static void srv_resolved_cb(PurpleSrvResponse *resp, int results, gpointer data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
795 {
23598
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
796 JabberStream *js = data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797 js->srv_query_data = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
798
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
799 if(results) {
23598
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
800 js->srv_rec = resp;
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
801 js->srv_rec_idx = 0;
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
802 js->max_srv_rec_idx = results;
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
803 try_srv_connect(js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
804 } else {
16996
37a2d6eadd34 fix #699
Nathan Walp <nwalp@pidgin.im>
parents: 16952
diff changeset
805 jabber_login_connect(js, js->user->domain, js->user->domain,
27613
5f17bfa9dc70 To make grim happy (or more upset).
Paul Aurich <paul@darkrain42.org>
parents: 27608
diff changeset
806 purple_account_get_int(purple_connection_get_account(js->gc), "port", 5222),
27635
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27613
diff changeset
807 TRUE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
808 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
809 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
810
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
811 static JabberStream *
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
812 jabber_stream_new(PurpleAccount *account)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
813 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
814 PurpleConnection *gc = purple_account_get_connection(account);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
815 JabberStream *js;
25686
feea711ac242 Patch from Paul Aurich to fix reporting idle when reconnecting only when we're
Marcus Lundblad <ml@update.uu.se>
parents: 25685
diff changeset
816 PurplePresence *presence;
27607
f95bcb5eb047 Support connecting to IDNA XMPP domains.
Paul Aurich <paul@darkrain42.org>
parents: 27599
diff changeset
817 gchar *user;
f95bcb5eb047 Support connecting to IDNA XMPP domains.
Paul Aurich <paul@darkrain42.org>
parents: 27599
diff changeset
818 gchar *slash;
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
819
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
820 js = gc->proto_data = g_new0(JabberStream, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
821 js->gc = gc;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
822 js->fd = -1;
27607
f95bcb5eb047 Support connecting to IDNA XMPP domains.
Paul Aurich <paul@darkrain42.org>
parents: 27599
diff changeset
823
f95bcb5eb047 Support connecting to IDNA XMPP domains.
Paul Aurich <paul@darkrain42.org>
parents: 27599
diff changeset
824 user = g_strdup(purple_account_get_username(account));
f95bcb5eb047 Support connecting to IDNA XMPP domains.
Paul Aurich <paul@darkrain42.org>
parents: 27599
diff changeset
825 /* jabber_id_new doesn't accept "user@domain/" as valid */
f95bcb5eb047 Support connecting to IDNA XMPP domains.
Paul Aurich <paul@darkrain42.org>
parents: 27599
diff changeset
826 slash = strchr(user, '/');
f95bcb5eb047 Support connecting to IDNA XMPP domains.
Paul Aurich <paul@darkrain42.org>
parents: 27599
diff changeset
827 if (slash && *(slash + 1) == '\0')
f95bcb5eb047 Support connecting to IDNA XMPP domains.
Paul Aurich <paul@darkrain42.org>
parents: 27599
diff changeset
828 *slash = '\0';
f95bcb5eb047 Support connecting to IDNA XMPP domains.
Paul Aurich <paul@darkrain42.org>
parents: 27599
diff changeset
829 js->user = jabber_id_new(user);
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
830
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
831 if (!js->user) {
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
832 purple_connection_error_reason(gc,
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
833 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
834 _("Invalid XMPP ID"));
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
835 /* Destroying the connection will free the JabberStream */
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
836 return NULL;
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
837 }
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
838
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
839 if (!js->user->domain || *(js->user->domain) == '\0') {
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
840 purple_connection_error_reason(gc,
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
841 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
842 _("Invalid XMPP ID. Domain must be set."));
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
843 /* Destroying the connection will free the JabberStream */
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
844 return NULL;
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
845 }
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
846
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
847 js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
848 g_free, (GDestroyNotify)jabber_buddy_free);
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
849
27794
eb2d17945ce3 jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <paul@darkrain42.org>
parents: 27793
diff changeset
850 js->user_jb = jabber_buddy_find(js, user, TRUE);
27607
f95bcb5eb047 Support connecting to IDNA XMPP domains.
Paul Aurich <paul@darkrain42.org>
parents: 27599
diff changeset
851 g_free(user);
27794
eb2d17945ce3 jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <paul@darkrain42.org>
parents: 27793
diff changeset
852 if (!js->user_jb) {
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
853 /* This basically *can't* fail, but for good measure... */
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
854 purple_connection_error_reason(gc,
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
855 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
856 _("Invalid XMPP ID"));
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
857 /* Destroying the connection will free the JabberStream */
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
858 g_return_val_if_reached(NULL);
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
859 }
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
860
27794
eb2d17945ce3 jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <paul@darkrain42.org>
parents: 27793
diff changeset
861 js->user_jb->subscription |= JABBER_SUB_BOTH;
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
862
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
863 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal,
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
864 g_free, g_free);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
865 js->chats = g_hash_table_new_full(g_str_hash, g_str_equal,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
866 g_free, (GDestroyNotify)jabber_chat_free);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
867 js->next_id = g_random_int();
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
868 js->write_buffer = purple_circ_buffer_new(512);
21977
cacc01b50a23 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <stu@nosnilmot.com>
parents: 21973
diff changeset
869 js->old_length = 0;
27069
08f5c5b12e7c The XMPP keepalive timeout handle needs to be a guint.
Paul Aurich <paul@darkrain42.org>
parents: 27055
diff changeset
870 js->keepalive_timeout = 0;
25993
6d7d360687bd Jabber: Default protocol version to 1.0.
Paul Aurich <paul@darkrain42.org>
parents: 25987
diff changeset
871 /* Set the default protocol version to 1.0. Overridden in parser.c. */
6d7d360687bd Jabber: Default protocol version to 1.0.
Paul Aurich <paul@darkrain42.org>
parents: 25987
diff changeset
872 js->protocol_version = JABBER_PROTO_1_0;
23798
16543025aed1 Moved jingle.c global variable "sessions" into JabberStream.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23797
diff changeset
873 js->sessions = NULL;
26080
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26063
diff changeset
874 js->stun_ip = NULL;
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26063
diff changeset
875 js->stun_port = 0;
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26063
diff changeset
876 js->stun_query = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
877
25685
a92df60855f3 Set idle time on JabberStream when logging in
Marcus Lundblad <ml@update.uu.se>
parents: 25255
diff changeset
878 /* if we are idle, set idle-ness on the stream (this could happen if we get
a92df60855f3 Set idle time on JabberStream when logging in
Marcus Lundblad <ml@update.uu.se>
parents: 25255
diff changeset
879 disconnected and the reconnects while being idle. I don't think it makes
a92df60855f3 Set idle time on JabberStream when logging in
Marcus Lundblad <ml@update.uu.se>
parents: 25255
diff changeset
880 sense to do this when registering a new account... */
25686
feea711ac242 Patch from Paul Aurich to fix reporting idle when reconnecting only when we're
Marcus Lundblad <ml@update.uu.se>
parents: 25685
diff changeset
881 presence = purple_account_get_presence(account);
feea711ac242 Patch from Paul Aurich to fix reporting idle when reconnecting only when we're
Marcus Lundblad <ml@update.uu.se>
parents: 25685
diff changeset
882 if (purple_presence_is_idle(presence))
feea711ac242 Patch from Paul Aurich to fix reporting idle when reconnecting only when we're
Marcus Lundblad <ml@update.uu.se>
parents: 25685
diff changeset
883 js->idle = purple_presence_get_idle_time(presence);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
884
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
885 return js;
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
886 }
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
887
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
888 static void
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
889 jabber_stream_connect(JabberStream *js)
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
890 {
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
891 PurpleConnection *gc = js->gc;
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
892 PurpleAccount *account = purple_connection_get_account(gc);
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
893 const char *connect_server = purple_account_get_string(account,
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
894 "connect_server", "");
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
895 const char *bosh_url = purple_account_get_string(account,
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
896 "bosh_url", "");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
897
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
898 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
899
27173
a9fdf9327652 Make "BOSH URL" its own account option.
Paul Aurich <paul@darkrain42.org>
parents: 27137
diff changeset
900 /* If both BOSH and a Connect Server are specified, we prefer BOSH. I'm not
a9fdf9327652 Make "BOSH URL" its own account option.
Paul Aurich <paul@darkrain42.org>
parents: 27137
diff changeset
901 * attached to that choice, though.
a9fdf9327652 Make "BOSH URL" its own account option.
Paul Aurich <paul@darkrain42.org>
parents: 27137
diff changeset
902 */
a9fdf9327652 Make "BOSH URL" its own account option.
Paul Aurich <paul@darkrain42.org>
parents: 27137
diff changeset
903 if (*bosh_url) {
a9fdf9327652 Make "BOSH URL" its own account option.
Paul Aurich <paul@darkrain42.org>
parents: 27137
diff changeset
904 js->bosh = jabber_bosh_connection_init(js, bosh_url);
a9fdf9327652 Make "BOSH URL" its own account option.
Paul Aurich <paul@darkrain42.org>
parents: 27137
diff changeset
905 if (js->bosh)
a9fdf9327652 Make "BOSH URL" its own account option.
Paul Aurich <paul@darkrain42.org>
parents: 27137
diff changeset
906 jabber_bosh_connection_connect(js->bosh);
a9fdf9327652 Make "BOSH URL" its own account option.
Paul Aurich <paul@darkrain42.org>
parents: 27137
diff changeset
907 else {
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
908 purple_connection_error_reason(gc,
25677
7d2e85f78aec Allow the user to specify their own BOSH url in the Connect Server option
Paul Aurich <paul@darkrain42.org>
parents: 25676
diff changeset
909 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
27173
a9fdf9327652 Make "BOSH URL" its own account option.
Paul Aurich <paul@darkrain42.org>
parents: 27137
diff changeset
910 _("Malformed BOSH URL"));
25677
7d2e85f78aec Allow the user to specify their own BOSH url in the Connect Server option
Paul Aurich <paul@darkrain42.org>
parents: 25676
diff changeset
911 }
27173
a9fdf9327652 Make "BOSH URL" its own account option.
Paul Aurich <paul@darkrain42.org>
parents: 27137
diff changeset
912
25179
514051f3b6cf Add option for forcing BOSH (useful for debugging)
Paul Aurich <paul@darkrain42.org>
parents: 25177
diff changeset
913 return;
514051f3b6cf Add option for forcing BOSH (useful for debugging)
Paul Aurich <paul@darkrain42.org>
parents: 25177
diff changeset
914 }
514051f3b6cf Add option for forcing BOSH (useful for debugging)
Paul Aurich <paul@darkrain42.org>
parents: 25177
diff changeset
915
27173
a9fdf9327652 Make "BOSH URL" its own account option.
Paul Aurich <paul@darkrain42.org>
parents: 27137
diff changeset
916 js->certificate_CN = g_strdup(connect_server[0] ? connect_server : js->user->domain);
a9fdf9327652 Make "BOSH URL" its own account option.
Paul Aurich <paul@darkrain42.org>
parents: 27137
diff changeset
917
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
918 /* if they've got old-ssl mode going, we probably want to ignore SRV lookups */
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
919 if(purple_account_get_bool(account, "old_ssl", FALSE)) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
920 if(purple_ssl_is_supported()) {
27635
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27613
diff changeset
921 js->gsc = purple_ssl_connect(account, js->certificate_CN,
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
922 purple_account_get_int(account, "port", 5223),
27635
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27613
diff changeset
923 jabber_login_callback_ssl, jabber_ssl_connect_failure, gc);
25678
97a4d71e0c3d Don't fallback (under any conditions) from old-style SSL to other connections
Paul Aurich <paul@darkrain42.org>
parents: 25677
diff changeset
924 if (!js->gsc) {
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
925 purple_connection_error_reason(gc,
25678
97a4d71e0c3d Don't fallback (under any conditions) from old-style SSL to other connections
Paul Aurich <paul@darkrain42.org>
parents: 25677
diff changeset
926 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
97a4d71e0c3d Don't fallback (under any conditions) from old-style SSL to other connections
Paul Aurich <paul@darkrain42.org>
parents: 25677
diff changeset
927 _("Unable to establish SSL connection"));
97a4d71e0c3d Don't fallback (under any conditions) from old-style SSL to other connections
Paul Aurich <paul@darkrain42.org>
parents: 25677
diff changeset
928 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
929 } else {
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
930 purple_connection_error_reason(gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 21355
diff changeset
931 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 20076
diff changeset
932 _("SSL support unavailable"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
933 }
25678
97a4d71e0c3d Don't fallback (under any conditions) from old-style SSL to other connections
Paul Aurich <paul@darkrain42.org>
parents: 25677
diff changeset
934
97a4d71e0c3d Don't fallback (under any conditions) from old-style SSL to other connections
Paul Aurich <paul@darkrain42.org>
parents: 25677
diff changeset
935 return;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
936 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
937
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
938 /* no old-ssl, so if they've specified a connect server, we'll use that, otherwise we'll
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
939 * invoke the magic of SRV lookups, to figure out host and port */
25985
c4fd9222dda1 propagate from branch 'im.pidgin.pidgin' (head 303af74a38e7b313d4fb0be4d4054a16cb13d819)
Paul Aurich <paul@darkrain42.org>
parents: 25952 25678
diff changeset
940 if(connect_server[0]) {
27635
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27613
diff changeset
941 jabber_login_connect(js, js->user->domain, connect_server,
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27613
diff changeset
942 purple_account_get_int(account, "port", 5222), TRUE);
25678
97a4d71e0c3d Don't fallback (under any conditions) from old-style SSL to other connections
Paul Aurich <paul@darkrain42.org>
parents: 25677
diff changeset
943 } else {
97a4d71e0c3d Don't fallback (under any conditions) from old-style SSL to other connections
Paul Aurich <paul@darkrain42.org>
parents: 25677
diff changeset
944 js->srv_query_data = purple_srv_resolve("xmpp-client",
27635
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27613
diff changeset
945 "tcp", js->user->domain, srv_resolved_cb, js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
947 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
948
16240
547c76fe2e7a 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@gmail.com>
parents: 16068
diff changeset
949 void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
950 jabber_login(PurpleAccount *account)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
951 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
952 PurpleConnection *gc = purple_account_get_connection(account);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
953 JabberStream *js;
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
954 PurpleStoredImage *image;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
955
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23180
diff changeset
956 gc->flags |= PURPLE_CONNECTION_HTML |
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23180
diff changeset
957 PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY;
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
958 js = jabber_stream_new(account);
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
959 if (js == NULL)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
960 return;
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
961
29047
031fd1cd88df jabber: Update the default FT proxy (if it's still set as the previous, broken, default).
Paul Aurich <paul@darkrain42.org>
parents: 29022
diff changeset
962 /* TODO: Remove this at some point. Added 2010-02-14 (v2.6.6) */
031fd1cd88df jabber: Update the default FT proxy (if it's still set as the previous, broken, default).
Paul Aurich <paul@darkrain42.org>
parents: 29022
diff changeset
963 if (g_str_equal("proxy.jabber.org", purple_account_get_string(account, "ft_proxies", "")))
031fd1cd88df jabber: Update the default FT proxy (if it's still set as the previous, broken, default).
Paul Aurich <paul@darkrain42.org>
parents: 29022
diff changeset
964 purple_account_set_string(account, "ft_proxies", JABBER_DEFAULT_FT_PROXIES);
031fd1cd88df jabber: Update the default FT proxy (if it's still set as the previous, broken, default).
Paul Aurich <paul@darkrain42.org>
parents: 29022
diff changeset
965
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
966 /*
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
967 * Calculate the avatar hash for our current image so we know (when we
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
968 * fetch our vCard and PEP avatar) if we should send our avatar to the
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
969 * server.
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
970 */
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
971 image = purple_buddy_icons_find_account_icon(account);
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
972 if (image != NULL) {
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
973 js->initial_avatar_hash =
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
974 jabber_calculate_data_sha1sum(purple_imgstore_get_data(image),
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
975 purple_imgstore_get_size(image));
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
976 purple_imgstore_unref(image);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
977 }
26080
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26063
diff changeset
978
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
979 jabber_stream_connect(js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
980 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
981
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
982
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
983 static gboolean
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
984 conn_close_cb(gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
985 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986 JabberStream *js = data;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
987 PurpleAccount *account = purple_connection_get_account(js->gc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
988
17876
7a3a66c6530a Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17872
diff changeset
989 jabber_parser_free(js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
990
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
991 purple_account_disconnect(account);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
992
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
993 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
994 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
995
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
996 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
997 jabber_connection_schedule_close(JabberStream *js)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
999 purple_timeout_add(0, conn_close_cb, js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1000 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1001
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1002 static void
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1003 jabber_registration_result_cb(JabberStream *js, const char *from,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1004 JabberIqType type, const char *id,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1005 xmlnode *packet, gpointer data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006 {
17880
ca0b86f3dbd2 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 <pidgin@monitzer.com>
parents: 17879
diff changeset
1007 PurpleAccount *account = purple_connection_get_account(js->gc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008 char *buf;
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1009 char *to = data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1010
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1011 if (type == JABBER_IQ_RESULT) {
17880
ca0b86f3dbd2 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 <pidgin@monitzer.com>
parents: 17879
diff changeset
1012 if(js->registration) {
27284
73c8e1964eef A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27173
diff changeset
1013 buf = g_strdup_printf(_("Registration of %s@%s successful"),
27331
46cc3674b13c Indentation fix.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27069
diff changeset
1014 js->user->node, js->user->domain);
17881
a8b1159fd95b Simplified registration callback per request of Sean.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17880
diff changeset
1015 if(account->registration_cb)
a8b1159fd95b Simplified registration callback per request of Sean.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17880
diff changeset
1016 (account->registration_cb)(account, TRUE, account->registration_cb_user_data);
25467
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1017 } else {
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1018 g_return_if_fail(to != NULL);
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1019 buf = g_strdup_printf(_("Registration to %s successful"),
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1020 to);
25467
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1021 }
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1022 purple_notify_info(NULL, _("Registration Successful"),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1023 _("Registration Successful"), buf);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1024 g_free(buf);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1025 } else {
20814
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
1026 char *msg = jabber_parse_error(js, packet, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1027
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1028 if(!msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029 msg = g_strdup(_("Unknown Error"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1030
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1031 purple_notify_error(NULL, _("Registration Failed"),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1032 _("Registration Failed"), msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1033 g_free(msg);
17881
a8b1159fd95b Simplified registration callback per request of Sean.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17880
diff changeset
1034 if(account->registration_cb)
a8b1159fd95b Simplified registration callback per request of Sean.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17880
diff changeset
1035 (account->registration_cb)(account, FALSE, account->registration_cb_user_data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1036 }
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1037 g_free(to);
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1038 if(js->registration)
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1039 jabber_connection_schedule_close(js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1040 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1042 static void
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1043 jabber_unregistration_result_cb(JabberStream *js, const char *from,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1044 JabberIqType type, const char *id,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1045 xmlnode *packet, gpointer data)
18695
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1046 {
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1047 char *buf;
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1048 char *to = data;
25467
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1049
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1050 /* This function is never called for unregistering our XMPP account from
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1051 * the server, so there should always be a 'to' address. */
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1052 g_return_if_fail(to != NULL);
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1053
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1054 if (type == JABBER_IQ_RESULT) {
18695
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1055 buf = g_strdup_printf(_("Registration from %s successfully removed"),
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1056 to);
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1057 purple_notify_info(NULL, _("Unregistration Successful"),
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1058 _("Unregistration Successful"), buf);
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1059 g_free(buf);
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1060 } else {
20814
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
1061 char *msg = jabber_parse_error(js, packet, NULL);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
1062
18695
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1063 if(!msg)
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1064 msg = g_strdup(_("Unknown Error"));
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
1065
18695
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1066 purple_notify_error(NULL, _("Unregistration Failed"),
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1067 _("Unregistration Failed"), msg);
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1068 g_free(msg);
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1069 }
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1070 g_free(to);
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1071 }
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1072
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1073 typedef struct _JabberRegisterCBData {
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1074 JabberStream *js;
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1075 char *who;
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1076 } JabberRegisterCBData;
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1077
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1078 static void
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1079 jabber_register_cb(JabberRegisterCBData *cbdata, PurpleRequestFields *fields)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1080 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1081 GList *groups, *flds;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1082 xmlnode *query, *y;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1083 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1084 char *username;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1085
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1086 iq = jabber_iq_new_query(cbdata->js, JABBER_IQ_SET, "jabber:iq:register");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1087 query = xmlnode_get_child(iq->node, "query");
25467
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1088 if (cbdata->who)
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1089 xmlnode_set_attrib(iq->node, "to", cbdata->who);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1090
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1091 for(groups = purple_request_fields_get_groups(fields); groups;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1092 groups = groups->next) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1093 for(flds = purple_request_field_group_get_fields(groups->data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1094 flds; flds = flds->next) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1095 PurpleRequestField *field = flds->data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1096 const char *id = purple_request_field_get_id(field);
18695
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1097 if(!strcmp(id,"unregister")) {
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1098 gboolean value = purple_request_field_bool_get_value(field);
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1099 if(value) {
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1100 /* unregister from service. this doesn't include any of the fields, so remove them from the stanza by recreating it
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1101 (there's no "remove child" function for xmlnode) */
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1102 jabber_iq_free(iq);
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1103 iq = jabber_iq_new_query(cbdata->js, JABBER_IQ_SET, "jabber:iq:register");
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1104 query = xmlnode_get_child(iq->node, "query");
25467
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1105 if (cbdata->who)
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1106 xmlnode_set_attrib(iq->node,"to",cbdata->who);
18695
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1107 xmlnode_new_child(query, "remove");
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
1108
18695
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1109 jabber_iq_set_callback(iq, jabber_unregistration_result_cb, cbdata->who);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
1110
18695
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1111 jabber_iq_send(iq);
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1112 g_free(cbdata);
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1113 return;
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1114 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1115 } else {
28360
ed88200c79ee A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28327
diff changeset
1116 const char *ids[] = {"username", "password", "name", "email", "nick", "first",
ed88200c79ee A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28327
diff changeset
1117 "last", "address", "city", "state", "zip", "phone", "url", "date",
ed88200c79ee A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28327
diff changeset
1118 NULL};
28314
53bf7fd37cb0 Prevent a NULL sprintf(%s) when no resource is assigned to an account during inband registration. Fixes #10420.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28292
diff changeset
1119 const char *value = purple_request_field_string_get_value(field);
28360
ed88200c79ee A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28327
diff changeset
1120 int i;
ed88200c79ee A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28327
diff changeset
1121 for (i = 0; ids[i]; i++) {
ed88200c79ee A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28327
diff changeset
1122 if (!strcmp(id, ids[i]))
ed88200c79ee A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28327
diff changeset
1123 break;
ed88200c79ee A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28327
diff changeset
1124 }
ed88200c79ee A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28327
diff changeset
1125
ed88200c79ee A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28327
diff changeset
1126 if (!ids[i])
28314
53bf7fd37cb0 Prevent a NULL sprintf(%s) when no resource is assigned to an account during inband registration. Fixes #10420.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28292
diff changeset
1127 continue;
28360
ed88200c79ee A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28327
diff changeset
1128 y = xmlnode_new_child(query, ids[i]);
28314
53bf7fd37cb0 Prevent a NULL sprintf(%s) when no resource is assigned to an account during inband registration. Fixes #10420.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28292
diff changeset
1129 xmlnode_insert_data(y, value, -1);
18695
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1130 if(cbdata->js->registration && !strcmp(id, "username")) {
25467
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1131 g_free(cbdata->js->user->node);
18695
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1132 cbdata->js->user->node = g_strdup(value);
28314
53bf7fd37cb0 Prevent a NULL sprintf(%s) when no resource is assigned to an account during inband registration. Fixes #10420.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28292
diff changeset
1133 }
18695
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1134 if(cbdata->js->registration && !strcmp(id, "password"))
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1135 purple_account_set_password(cbdata->js->gc->account, value);
28314
53bf7fd37cb0 Prevent a NULL sprintf(%s) when no resource is assigned to an account during inband registration. Fixes #10420.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28292
diff changeset
1136 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1137 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1138 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1139
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1140 if(cbdata->js->registration) {
28314
53bf7fd37cb0 Prevent a NULL sprintf(%s) when no resource is assigned to an account during inband registration. Fixes #10420.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28292
diff changeset
1141 username = g_strdup_printf("%s@%s%s%s", cbdata->js->user->node, cbdata->js->user->domain,
28731
3bf5dbff753b jabber: Complete the fix for a NULL printf() on registration on Windows. Closes #10420 again.
Paul Aurich <paul@darkrain42.org>
parents: 28650
diff changeset
1142 cbdata->js->user->resource ? "/" : "",
3bf5dbff753b jabber: Complete the fix for a NULL printf() on registration on Windows. Closes #10420 again.
Paul Aurich <paul@darkrain42.org>
parents: 28650
diff changeset
1143 cbdata->js->user->resource ? cbdata->js->user->resource : "");
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1144 purple_account_set_username(cbdata->js->gc->account, username);
21592
68b036c452f3 The Jabber registration process depends upon having a non-NULL cbdata->who,
Evan Schoenberg <evan.s@dreskin.net>
parents: 21591
diff changeset
1145 g_free(username);
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1146 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1147
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1148 jabber_iq_set_callback(iq, jabber_registration_result_cb, cbdata->who);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1149
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1150 jabber_iq_send(iq);
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1151 g_free(cbdata);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1152 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1153
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1154 static void
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1155 jabber_register_cancel_cb(JabberRegisterCBData *cbdata, PurpleRequestFields *fields)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1156 {
17880
ca0b86f3dbd2 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 <pidgin@monitzer.com>
parents: 17879
diff changeset
1157 PurpleAccount *account = purple_connection_get_account(cbdata->js->gc);
19489
b0733d5d7621 Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <pidgin@monitzer.com>
parents: 19277
diff changeset
1158 if(account && cbdata->js->registration) {
17880
ca0b86f3dbd2 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 <pidgin@monitzer.com>
parents: 17879
diff changeset
1159 if(account->registration_cb)
17881
a8b1159fd95b Simplified registration callback per request of Sean.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17880
diff changeset
1160 (account->registration_cb)(account, FALSE, account->registration_cb_user_data);
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1161 jabber_connection_schedule_close(cbdata->js);
20276
c1d3d25e8c49 Merged xmpp leak fixes
Evan Schoenberg <evan.s@dreskin.net>
parents: 20187
diff changeset
1162 }
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1163 g_free(cbdata->who);
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1164 g_free(cbdata);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1165 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1166
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1167 static void jabber_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1168 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1169 xmlnode *query;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1170 JabberIq *iq;
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1171 char *to = data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1172
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1173 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1174 query = xmlnode_get_child(iq->node, "query");
25467
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1175 if (to)
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1176 xmlnode_set_attrib(iq->node,"to",to);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1177
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1178 xmlnode_insert_child(query, result);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1179
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1180 jabber_iq_set_callback(iq, jabber_registration_result_cb, to);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1181 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1182 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1183
26612
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1184 static const struct {
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1185 const char *name;
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1186 const char *label;
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1187 } registration_fields[] = {
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1188 { "email", N_("Email") },
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1189 { "nick", N_("Nickname") },
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1190 { "first", N_("First name") },
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1191 { "last", N_("Last name") },
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1192 { "address", N_("Address") },
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1193 { "city", N_("City") },
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1194 { "state", N_("State") },
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1195 { "zip", N_("Postal code") },
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1196 { "phone", N_("Phone") },
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1197 { "url", N_("URL") },
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1198 { "date", N_("Date") },
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1199 { NULL, NULL }
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1200 };
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1201
25648
050052891c55 Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents: 25645
diff changeset
1202 void jabber_register_parse(JabberStream *js, const char *from, JabberIqType type,
050052891c55 Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents: 25645
diff changeset
1203 const char *id, xmlnode *query)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1204 {
17880
ca0b86f3dbd2 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 <pidgin@monitzer.com>
parents: 17879
diff changeset
1205 PurpleAccount *account = purple_connection_get_account(js->gc);
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1206 PurpleRequestFields *fields;
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1207 PurpleRequestFieldGroup *group;
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1208 PurpleRequestField *field;
26615
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1209 xmlnode *x, *y, *node;
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1210 char *instructions;
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1211 JabberRegisterCBData *cbdata;
18695
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1212 gboolean registered = FALSE;
26612
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1213 int i;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1214
25648
050052891c55 Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents: 25645
diff changeset
1215 if (type != JABBER_IQ_RESULT)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1216 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1217
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1218 if(js->registration) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1219 /* get rid of the login thingy */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1220 purple_connection_set_state(js->gc, PURPLE_CONNECTED);
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1221 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1222
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1223 if(xmlnode_get_child(query, "registered")) {
18695
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1224 registered = TRUE;
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1225
17880
ca0b86f3dbd2 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 <pidgin@monitzer.com>
parents: 17879
diff changeset
1226 if(js->registration) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1227 purple_notify_error(NULL, _("Already Registered"),
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1228 _("Already Registered"), NULL);
17880
ca0b86f3dbd2 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 <pidgin@monitzer.com>
parents: 17879
diff changeset
1229 if(account->registration_cb)
17881
a8b1159fd95b Simplified registration callback per request of Sean.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17880
diff changeset
1230 (account->registration_cb)(account, FALSE, account->registration_cb_user_data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1231 jabber_connection_schedule_close(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1232 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1233 }
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1234 }
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
1235
25432
256fbe98f6be The jabber_register_parse function was looking for the <x> node as a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25412
diff changeset
1236 if((x = xmlnode_get_child_with_namespace(query, "x", "jabber:x:data"))) {
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1237 jabber_x_data_request(js, x, jabber_register_x_data_cb, g_strdup(from));
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1238 return;
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1239
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
1240 } else if((x = xmlnode_get_child_with_namespace(query, "x", NS_OOB_X_DATA))) {
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1241 xmlnode *url;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1242
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1243 if((url = xmlnode_get_child(x, "url"))) {
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1244 char *href;
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1245 if((href = xmlnode_get_data(url))) {
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1246 purple_notify_uri(NULL, href);
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1247 g_free(href);
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1248
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1249 if(js->registration) {
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1250 js->gc->wants_to_die = TRUE;
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1251 if(account->registration_cb) /* succeeded, but we have no login info */
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1252 (account->registration_cb)(account, TRUE, account->registration_cb_user_data);
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1253 jabber_connection_schedule_close(js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1254 }
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1255 return;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1256 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1257 }
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1258 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1259
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1260 /* as a last resort, use the old jabber:iq:register syntax */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1261
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1262 fields = purple_request_fields_new();
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1263 group = purple_request_field_group_new(NULL);
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1264 purple_request_fields_add_group(fields, group);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1265
26615
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1266 if((node = xmlnode_get_child(query, "username"))) {
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1267 char *data = xmlnode_get_data(node);
26247
f5e613e05332 Applied disco-2.patch from nops with some modifications:
Paul Aurich <paul@darkrain42.org>
parents: 25981
diff changeset
1268 if(js->registration)
26615
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1269 field = purple_request_field_string_new("username", _("Username"), data ? data : js->user->node, FALSE);
26247
f5e613e05332 Applied disco-2.patch from nops with some modifications:
Paul Aurich <paul@darkrain42.org>
parents: 25981
diff changeset
1270 else
26615
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1271 field = purple_request_field_string_new("username", _("Username"), data, FALSE);
26247
f5e613e05332 Applied disco-2.patch from nops with some modifications:
Paul Aurich <paul@darkrain42.org>
parents: 25981
diff changeset
1272
f5e613e05332 Applied disco-2.patch from nops with some modifications:
Paul Aurich <paul@darkrain42.org>
parents: 25981
diff changeset
1273 purple_request_field_group_add_field(group, field);
26615
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1274 g_free(data);
26247
f5e613e05332 Applied disco-2.patch from nops with some modifications:
Paul Aurich <paul@darkrain42.org>
parents: 25981
diff changeset
1275 }
26615
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1276 if((node = xmlnode_get_child(query, "password"))) {
26247
f5e613e05332 Applied disco-2.patch from nops with some modifications:
Paul Aurich <paul@darkrain42.org>
parents: 25981
diff changeset
1277 if(js->registration)
f5e613e05332 Applied disco-2.patch from nops with some modifications:
Paul Aurich <paul@darkrain42.org>
parents: 25981
diff changeset
1278 field = purple_request_field_string_new("password", _("Password"),
f5e613e05332 Applied disco-2.patch from nops with some modifications:
Paul Aurich <paul@darkrain42.org>
parents: 25981
diff changeset
1279 purple_connection_get_password(js->gc), FALSE);
26615
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1280 else {
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1281 char *data = xmlnode_get_data(node);
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1282 field = purple_request_field_string_new("password", _("Password"), data, FALSE);
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1283 g_free(data);
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1284 }
26247
f5e613e05332 Applied disco-2.patch from nops with some modifications:
Paul Aurich <paul@darkrain42.org>
parents: 25981
diff changeset
1285
f5e613e05332 Applied disco-2.patch from nops with some modifications:
Paul Aurich <paul@darkrain42.org>
parents: 25981
diff changeset
1286 purple_request_field_string_set_masked(field, TRUE);
f5e613e05332 Applied disco-2.patch from nops with some modifications:
Paul Aurich <paul@darkrain42.org>
parents: 25981
diff changeset
1287 purple_request_field_group_add_field(group, field);
f5e613e05332 Applied disco-2.patch from nops with some modifications:
Paul Aurich <paul@darkrain42.org>
parents: 25981
diff changeset
1288 }
26612
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1289
26615
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1290 if((node = xmlnode_get_child(query, "name"))) {
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1291 if(js->registration)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1292 field = purple_request_field_string_new("name", _("Name"),
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1293 purple_account_get_alias(js->gc->account), FALSE);
26615
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1294 else {
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1295 char *data = xmlnode_get_data(node);
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1296 field = purple_request_field_string_new("name", _("Name"), data, FALSE);
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1297 g_free(data);
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1298 }
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1299 purple_request_field_group_add_field(group, field);
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1300 }
26612
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1301
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1302 for (i = 0; registration_fields[i].name != NULL; ++i) {
26615
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1303 if ((node = xmlnode_get_child(query, registration_fields[i].name))) {
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1304 char *data = xmlnode_get_data(node);
26612
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1305 field = purple_request_field_string_new(registration_fields[i].name,
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1306 _(registration_fields[i].label),
26615
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1307 data, FALSE);
26612
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1308 purple_request_field_group_add_field(group, field);
26615
5149ecc8f456 Use defaults provided by the server where applicable and when available
Paul Aurich <paul@darkrain42.org>
parents: 26612
diff changeset
1309 g_free(data);
26612
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1310 }
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1311 }
26612
28381a8889a8 This is a little less...repetitious
Paul Aurich <paul@darkrain42.org>
parents: 26610
diff changeset
1312
18695
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1313 if(registered) {
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1314 field = purple_request_field_bool_new("unregister", _("Unregister"), FALSE);
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1315 purple_request_field_group_add_field(group, field);
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1316 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1317
20276
c1d3d25e8c49 Merged xmpp leak fixes
Evan Schoenberg <evan.s@dreskin.net>
parents: 20187
diff changeset
1318 if((y = xmlnode_get_child(query, "instructions")))
c1d3d25e8c49 Merged xmpp leak fixes
Evan Schoenberg <evan.s@dreskin.net>
parents: 20187
diff changeset
1319 instructions = xmlnode_get_data(y);
18695
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1320 else if(registered)
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1321 instructions = g_strdup(_("Please fill out the information below "
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1322 "to change your account registration."));
20276
c1d3d25e8c49 Merged xmpp leak fixes
Evan Schoenberg <evan.s@dreskin.net>
parents: 20187
diff changeset
1323 else
c1d3d25e8c49 Merged xmpp leak fixes
Evan Schoenberg <evan.s@dreskin.net>
parents: 20187
diff changeset
1324 instructions = g_strdup(_("Please fill out the information below "
c1d3d25e8c49 Merged xmpp leak fixes
Evan Schoenberg <evan.s@dreskin.net>
parents: 20187
diff changeset
1325 "to register your new account."));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1326
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1327 cbdata = g_new0(JabberRegisterCBData, 1);
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1328 cbdata->js = js;
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1329 cbdata->who = g_strdup(from);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1330
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1331 if(js->registration)
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
1332 purple_request_fields(js->gc, _("Register New XMPP Account"),
16904
56042b2f8b64 s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@wiktel.com>
parents: 16811
diff changeset
1333 _("Register New XMPP Account"), instructions, fields,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1334 _("Register"), G_CALLBACK(jabber_register_cb),
16439
08db93bbd798 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 <evan.s@dreskin.net>
parents: 16240
diff changeset
1335 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb),
08db93bbd798 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 <evan.s@dreskin.net>
parents: 16240
diff changeset
1336 purple_connection_get_account(js->gc), NULL, NULL,
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
1337 cbdata);
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1338 else {
25467
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1339 char *title;
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1340 g_return_if_fail(from != NULL);
b90c26f391b0 Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Paul Aurich <paul@darkrain42.org>
parents: 25463
diff changeset
1341 title = registered ? g_strdup_printf(_("Change Account Registration at %s"), from)
18695
91eece1ad9bc Added the ability to unregister from a gateway.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18684
diff changeset
1342 :g_strdup_printf(_("Register New Account at %s"), from);
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
1343 purple_request_fields(js->gc, title,
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1344 title, instructions, fields,
21326
6ba02326c9e1 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 <evan.s@dreskin.net>
parents: 21284
diff changeset
1345 (registered ? _("Change Registration") : _("Register")), G_CALLBACK(jabber_register_cb),
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1346 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb),
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1347 purple_connection_get_account(js->gc), NULL, NULL,
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
1348 cbdata);
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1349 g_free(title);
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1350 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1351
20276
c1d3d25e8c49 Merged xmpp leak fixes
Evan Schoenberg <evan.s@dreskin.net>
parents: 20187
diff changeset
1352 g_free(instructions);
c1d3d25e8c49 Merged xmpp leak fixes
Evan Schoenberg <evan.s@dreskin.net>
parents: 20187
diff changeset
1353 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1354
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1355 void jabber_register_start(JabberStream *js)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1356 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1357 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1358
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1359 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1360 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1361 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1362
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1363 void jabber_register_gateway(JabberStream *js, const char *gateway) {
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1364 JabberIq *iq;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
1365
17872
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1366 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register");
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1367 xmlnode_set_attrib(iq->node, "to", gateway);
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1368 jabber_iq_send(iq);
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1369 }
8c3fbc353a9c Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17869
diff changeset
1370
16240
547c76fe2e7a 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@gmail.com>
parents: 16068
diff changeset
1371 void jabber_register_account(PurpleAccount *account)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1372 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1373 JabberStream *js;
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
1374
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
1375 js = jabber_stream_new(account);
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
1376 if (js == NULL)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1377 return;
27599
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
1378
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
1379 js->registration = TRUE;
409ef6d76bf6 Refactor jabber_login and jabber_register_account
Paul Aurich <paul@darkrain42.org>
parents: 27527
diff changeset
1380 jabber_stream_connect(js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1381 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1382
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1383 static void
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1384 jabber_unregister_account_iq_cb(JabberStream *js, const char *from,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1385 JabberIqType type, const char *id,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1386 xmlnode *packet, gpointer data)
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1387 {
18920
2a9d60d7af82 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 <pidgin@monitzer.com>
parents: 18919
diff changeset
1388 PurpleAccount *account = purple_connection_get_account(js->gc);
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1389
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1390 if (type == JABBER_IQ_ERROR) {
20814
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
1391 char *msg = jabber_parse_error(js, packet, NULL);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
1392
18703
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1393 purple_notify_error(js->gc, _("Error unregistering account"),
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1394 _("Error unregistering account"), msg);
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1395 g_free(msg);
18920
2a9d60d7af82 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 <pidgin@monitzer.com>
parents: 18919
diff changeset
1396 if(js->unregistration_cb)
18921
ba3b22cd280b Mixed up TRUE and FALSE.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18920
diff changeset
1397 js->unregistration_cb(account, FALSE, js->unregistration_user_data);
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1398 } else {
18703
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1399 purple_notify_info(js->gc, _("Account successfully unregistered"),
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1400 _("Account successfully unregistered"), NULL);
18920
2a9d60d7af82 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 <pidgin@monitzer.com>
parents: 18919
diff changeset
1401 if(js->unregistration_cb)
18921
ba3b22cd280b Mixed up TRUE and FALSE.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18920
diff changeset
1402 js->unregistration_cb(account, TRUE, js->unregistration_user_data);
18703
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1403 }
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1404 }
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1405
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1406 static void jabber_unregister_account_cb(JabberStream *js) {
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1407 JabberIq *iq;
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1408 xmlnode *query;
20000
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1409
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1410 g_return_if_fail(js->unregistration);
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1411
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1412 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register");
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1413
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1414 query = xmlnode_get_child_with_namespace(iq->node, "query", "jabber:iq:register");
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1415
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1416 xmlnode_new_child(query, "remove");
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1417 xmlnode_set_attrib(iq->node, "to", js->user->domain);
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1418
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1419 jabber_iq_set_callback(iq, jabber_unregister_account_iq_cb, NULL);
18703
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1420 jabber_iq_send(iq);
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1421 }
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1422
18920
2a9d60d7af82 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 <pidgin@monitzer.com>
parents: 18919
diff changeset
1423 void jabber_unregister_account(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data) {
18703
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1424 PurpleConnection *gc = purple_account_get_connection(account);
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1425 JabberStream *js;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
1426
18703
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1427 if(gc->state != PURPLE_CONNECTED) {
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1428 if(gc->state != PURPLE_CONNECTING)
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1429 jabber_login(account);
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1430 js = gc->proto_data;
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1431 js->unregistration = TRUE;
18920
2a9d60d7af82 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 <pidgin@monitzer.com>
parents: 18919
diff changeset
1432 js->unregistration_cb = cb;
2a9d60d7af82 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 <pidgin@monitzer.com>
parents: 18919
diff changeset
1433 js->unregistration_user_data = user_data;
18703
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1434 return;
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1435 }
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
1436
18703
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1437 js = gc->proto_data;
20000
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1438
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1439 if (js->unregistration) {
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1440 purple_debug_error("jabber", "Unregistration in process; ignoring duplicate request.\n");
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1441 return;
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1442 }
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1443
18703
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1444 js->unregistration = TRUE;
18920
2a9d60d7af82 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 <pidgin@monitzer.com>
parents: 18919
diff changeset
1445 js->unregistration_cb = cb;
2a9d60d7af82 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 <pidgin@monitzer.com>
parents: 18919
diff changeset
1446 js->unregistration_user_data = user_data;
20000
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1447
18703
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1448 jabber_unregister_account_cb(js);
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1449 }
033b128f7c21 Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <pidgin@monitzer.com>
parents: 18695
diff changeset
1450
25587
3b674151cd60 *** Plucked rev 4831edb9 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents: 25586
diff changeset
1451 /* TODO: As Will pointed out in IRC, after being notified by the core to
3b674151cd60 *** Plucked rev 4831edb9 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents: 25586
diff changeset
1452 * shutdown, we should async. wait for the server to send us the stream
3b674151cd60 *** Plucked rev 4831edb9 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents: 25586
diff changeset
1453 * termination before destorying everything. That seems like it would require
3b674151cd60 *** Plucked rev 4831edb9 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents: 25586
diff changeset
1454 * changing the semantics of prpl->close(), so it's a good idea for 3.0.0.
3b674151cd60 *** Plucked rev 4831edb9 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents: 25586
diff changeset
1455 */
16240
547c76fe2e7a 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@gmail.com>
parents: 16068
diff changeset
1456 void jabber_close(PurpleConnection *gc)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1457 {
28943
1cf9103727f2 jabber: Remove a funky workaround for an (old) OpenSSL crash.
Paul Aurich <paul@darkrain42.org>
parents: 28942
diff changeset
1458 JabberStream *js = purple_connection_get_protocol_data(gc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1459
23817
41d6d4217d21 Further decoupled Jingle code from jabber.c:
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23816
diff changeset
1460 /* Close all of the open Jingle sessions on this stream */
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23911
diff changeset
1461 jingle_terminate_sessions(js);
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23796
diff changeset
1462
28943
1cf9103727f2 jabber: Remove a funky workaround for an (old) OpenSSL crash.
Paul Aurich <paul@darkrain42.org>
parents: 28942
diff changeset
1463 if (js->bosh)
1cf9103727f2 jabber: Remove a funky workaround for an (old) OpenSSL crash.
Paul Aurich <paul@darkrain42.org>
parents: 28942
diff changeset
1464 jabber_bosh_connection_close(js->bosh);
1cf9103727f2 jabber: Remove a funky workaround for an (old) OpenSSL crash.
Paul Aurich <paul@darkrain42.org>
parents: 28942
diff changeset
1465 else if ((js->gsc && js->gsc->fd > 0) || js->fd > 0)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1466 jabber_send_raw(js, "</stream:stream>", -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1467
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1468 if (js->srv_query_data)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1469 purple_srv_cancel(js->srv_query_data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1470
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1471 if(js->gsc) {
28943
1cf9103727f2 jabber: Remove a funky workaround for an (old) OpenSSL crash.
Paul Aurich <paul@darkrain42.org>
parents: 28942
diff changeset
1472 purple_ssl_close(js->gsc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1473 } else if (js->fd > 0) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1474 if(js->gc->inpa)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1475 purple_input_remove(js->gc->inpa);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1476 close(js->fd);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1477 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1478
25182
17b60b844803 Jabber BOSH: more fixes.
Paul Aurich <paul@darkrain42.org>
parents: 25181
diff changeset
1479 if (js->bosh)
17b60b844803 Jabber BOSH: more fixes.
Paul Aurich <paul@darkrain42.org>
parents: 25181
diff changeset
1480 jabber_bosh_connection_destroy(js->bosh);
17b60b844803 Jabber BOSH: more fixes.
Paul Aurich <paul@darkrain42.org>
parents: 25181
diff changeset
1481
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1482 jabber_buddy_remove_all_pending_buddy_info_requests(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1483
17876
7a3a66c6530a Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17872
diff changeset
1484 jabber_parser_free(js);
7a3a66c6530a Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17872
diff changeset
1485
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1486 if(js->iq_callbacks)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1487 g_hash_table_destroy(js->iq_callbacks);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1488 if(js->buddies)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1489 g_hash_table_destroy(js->buddies);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1490 if(js->chats)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1491 g_hash_table_destroy(js->chats);
21603
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1492
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1493 while(js->chat_servers) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1494 g_free(js->chat_servers->data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1495 js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1496 }
21603
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1497
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1498 while(js->user_directories) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1499 g_free(js->user_directories->data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1500 js->user_directories = g_list_delete_link(js->user_directories, js->user_directories);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1501 }
21603
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1502
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1503 while(js->bs_proxies) {
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1504 JabberBytestreamsStreamhost *sh = js->bs_proxies->data;
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1505 g_free(sh->jid);
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1506 g_free(sh->host);
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1507 g_free(sh->zeroconf);
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1508 g_free(sh);
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1509 js->bs_proxies = g_list_delete_link(js->bs_proxies, js->bs_proxies);
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1510 }
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1511
23686
3c3032be12de Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23599
diff changeset
1512 while(js->url_datas) {
3c3032be12de Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23599
diff changeset
1513 purple_util_fetch_url_cancel(js->url_datas->data);
3c3032be12de Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23599
diff changeset
1514 js->url_datas = g_slist_delete_link(js->url_datas, js->url_datas);
3c3032be12de Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23599
diff changeset
1515 }
3c3032be12de Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23599
diff changeset
1516
21603
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1517 g_free(js->stream_id);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1518 if(js->user)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1519 jabber_id_free(js->user);
25426
2d92bbe6807b Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <paul@darkrain42.org>
parents: 25423
diff changeset
1520 g_free(js->initial_avatar_hash);
21603
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1521 g_free(js->avatar_hash);
25146
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25145
diff changeset
1522 g_free(js->caps_hash);
21603
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1523
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1524 purple_circ_buffer_destroy(js->write_buffer);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1525 if(js->writeh)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1526 purple_input_remove(js->writeh);
28707
c1d41b7484ff jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
1527 if (js->auth_mech && js->auth_mech->dispose)
c1d41b7484ff jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
1528 js->auth_mech->dispose(js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1529 #ifdef HAVE_CYRUS_SASL
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1530 if(js->sasl)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1531 sasl_dispose(&js->sasl);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1532 if(js->sasl_mechs)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1533 g_string_free(js->sasl_mechs, TRUE);
21603
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1534 g_free(js->sasl_cb);
18929
67cb28c0ec89 applied changes from e52b685d84ca8874da6e3e71199829e513500642
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18163
diff changeset
1535 #endif
21603
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1536 g_free(js->serverFQDN);
17883
9a19c46adf66 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 <pidgin@monitzer.com>
parents: 17881
diff changeset
1537 while(js->commands) {
9a19c46adf66 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 <pidgin@monitzer.com>
parents: 17881
diff changeset
1538 JabberAdHocCommands *cmd = js->commands->data;
9a19c46adf66 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 <pidgin@monitzer.com>
parents: 17881
diff changeset
1539 g_free(cmd->jid);
9a19c46adf66 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 <pidgin@monitzer.com>
parents: 17881
diff changeset
1540 g_free(cmd->node);
17893
11dd7969dd4b Fixed copy/paste error.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17890
diff changeset
1541 g_free(cmd->name);
17883
9a19c46adf66 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 <pidgin@monitzer.com>
parents: 17881
diff changeset
1542 g_free(cmd);
9a19c46adf66 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 <pidgin@monitzer.com>
parents: 17881
diff changeset
1543 js->commands = g_list_delete_link(js->commands, js->commands);
9a19c46adf66 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 <pidgin@monitzer.com>
parents: 17881
diff changeset
1544 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1545 g_free(js->server_name);
22034
d63892ade0a6 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 <pidgin@monitzer.com>
parents: 22000
diff changeset
1546 g_free(js->certificate_CN);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1547 g_free(js->gmail_last_time);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1548 g_free(js->gmail_last_tid);
21603
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1549 g_free(js->old_msg);
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1550 g_free(js->old_avatarhash);
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1551 g_free(js->old_artist);
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1552 g_free(js->old_title);
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1553 g_free(js->old_source);
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1554 g_free(js->old_uri);
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1555 g_free(js->old_track);
22931
9dc7e1d4da15 patch from Andrew Gaul to fix another memleak
Ka-Hing Cheung <khc@hxbc.us>
parents: 22619
diff changeset
1556 g_free(js->expected_rspauth);
21603
a4b6854737d5 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 <daniel.atallah@gmail.com>
parents: 21592
diff changeset
1557
27775
1ea1aee71848 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <paul@darkrain42.org>
parents: 27663
diff changeset
1558 if (js->vcard_timer != 0)
1ea1aee71848 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <paul@darkrain42.org>
parents: 27663
diff changeset
1559 purple_timeout_remove(js->vcard_timer);
1ea1aee71848 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <paul@darkrain42.org>
parents: 27663
diff changeset
1560
27069
08f5c5b12e7c The XMPP keepalive timeout handle needs to be a guint.
Paul Aurich <paul@darkrain42.org>
parents: 27055
diff changeset
1561 if (js->keepalive_timeout != 0)
21964
eaaac273d80c 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 <evan.s@dreskin.net>
parents: 21948
diff changeset
1562 purple_timeout_remove(js->keepalive_timeout);
23598
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
1563
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
1564 g_free(js->srv_rec);
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
1565 js->srv_rec = NULL;
224169be5830 Add support for using multiple "xmpp-client" records on a domain, by trying the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23396
diff changeset
1566
26080
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26063
diff changeset
1567 g_free(js->stun_ip);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26063
diff changeset
1568 js->stun_ip = NULL;
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26063
diff changeset
1569
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26063
diff changeset
1570 /* cancel DNS query for STUN, if one is ongoing */
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26063
diff changeset
1571 if (js->stun_query) {
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26063
diff changeset
1572 purple_dnsquery_destroy(js->stun_query);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26063
diff changeset
1573 js->stun_query = NULL;
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26063
diff changeset
1574 }
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26917
diff changeset
1575
23599
fa8567fa0ca0 Fix a stupid mistake in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23598
diff changeset
1576 g_free(js);
fa8567fa0ca0 Fix a stupid mistake in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23598
diff changeset
1577
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1578 gc->proto_data = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1579 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1580
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1581 void jabber_stream_set_state(JabberStream *js, JabberStreamState state)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1582 {
28327
c7aaad89a2f8 jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents: 28314
diff changeset
1583 #define JABBER_CONNECT_STEPS ((js->gsc || js->state == JABBER_STREAM_INITIALIZING_ENCRYPTION) ? 9 : 5)
c7aaad89a2f8 jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents: 28314
diff changeset
1584
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1585 js->state = state;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1586 switch(state) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1587 case JABBER_STREAM_OFFLINE:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1588 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1589 case JABBER_STREAM_CONNECTING:
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1590 purple_connection_update_progress(js->gc, _("Connecting"), 1,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1591 JABBER_CONNECT_STEPS);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1592 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1593 case JABBER_STREAM_INITIALIZING:
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1594 purple_connection_update_progress(js->gc, _("Initializing Stream"),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1595 js->gsc ? 5 : 2, JABBER_CONNECT_STEPS);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1596 jabber_stream_init(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1597 break;
17879
108f3b42976f 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 <pidgin@monitzer.com>
parents: 17876
diff changeset
1598 case JABBER_STREAM_INITIALIZING_ENCRYPTION:
108f3b42976f 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 <pidgin@monitzer.com>
parents: 17876
diff changeset
1599 purple_connection_update_progress(js->gc, _("Initializing SSL/TLS"),
108f3b42976f 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 <pidgin@monitzer.com>
parents: 17876
diff changeset
1600 6, JABBER_CONNECT_STEPS);
108f3b42976f 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 <pidgin@monitzer.com>
parents: 17876
diff changeset
1601 break;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1602 case JABBER_STREAM_AUTHENTICATING:
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1603 purple_connection_update_progress(js->gc, _("Authenticating"),
17879
108f3b42976f 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 <pidgin@monitzer.com>
parents: 17876
diff changeset
1604 js->gsc ? 7 : 3, JABBER_CONNECT_STEPS);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1605 break;
28096
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
1606 case JABBER_STREAM_POST_AUTH:
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1607 purple_connection_update_progress(js->gc, _("Re-initializing Stream"),
17879
108f3b42976f 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 <pidgin@monitzer.com>
parents: 17876
diff changeset
1608 (js->gsc ? 8 : 4), JABBER_CONNECT_STEPS);
16811
a77901ef0ebb 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: 16719
diff changeset
1609
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1610 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1611 case JABBER_STREAM_CONNECTED:
27495
c8390dc125c1 Use js->state to track whether the roster has been retrieved.
Paul Aurich <paul@darkrain42.org>
parents: 27014
diff changeset
1612 /* Send initial presence */
c8390dc125c1 Use js->state to track whether the roster has been retrieved.
Paul Aurich <paul@darkrain42.org>
parents: 27014
diff changeset
1613 jabber_presence_send(js, TRUE);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1614 purple_connection_set_state(js->gc, PURPLE_CONNECTED);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1615 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1616 }
28327
c7aaad89a2f8 jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents: 28314
diff changeset
1617
c7aaad89a2f8 jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents: 28314
diff changeset
1618 #undef JABBER_CONNECT_STEPS
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1619 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1620
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1621 char *jabber_get_next_id(JabberStream *js)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1622 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1623 return g_strdup_printf("purple%x", js->next_id++);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1624 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1625
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1626
16240
547c76fe2e7a 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@gmail.com>
parents: 16068
diff changeset
1627 void jabber_idle_set(PurpleConnection *gc, int idle)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1628 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1629 JabberStream *js = gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1630
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1631 js->idle = idle ? time(NULL) - idle : idle;
26705
fef989505ea2 propagate from branch 'im.pidgin.pidgin' (head 7281ad5ba8e68debd285e06dafebd991e980f3da)
Paul Aurich <paul@darkrain42.org>
parents: 26698 26699
diff changeset
1632
25198
e9b7e41dc816 A first stab at supporting the upcoming new use-case in XMPP XEP-0012
Marcus Lundblad <ml@update.uu.se>
parents: 24216
diff changeset
1633 /* send out an updated prescence */
e9b7e41dc816 A first stab at supporting the upcoming new use-case in XMPP XEP-0012
Marcus Lundblad <ml@update.uu.se>
parents: 24216
diff changeset
1634 purple_debug_info("jabber", "sending updated presence for idle\n");
26736
a0e48796defb Fix merging.
Paul Aurich <paul@darkrain42.org>
parents: 26735
diff changeset
1635 jabber_presence_send(js, FALSE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1636 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1637
26951
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1638 void jabber_blocklist_parse_push(JabberStream *js, const char *from,
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1639 JabberIqType type, const char *id,
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1640 xmlnode *child)
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1641 {
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1642 JabberIq *result;
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1643 xmlnode *item;
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1644 PurpleAccount *account;
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1645 gboolean is_block;
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1646
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1647 if (!jabber_is_own_account(js, from)) {
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1648 xmlnode *error, *x;
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1649 result = jabber_iq_new(js, JABBER_IQ_ERROR);
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1650 xmlnode_set_attrib(result->node, "id", id);
26958
c41698323c2f 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 <paul@darkrain42.org>
parents: 26957
diff changeset
1651 if (from)
c41698323c2f 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 <paul@darkrain42.org>
parents: 26957
diff changeset
1652 xmlnode_set_attrib(result->node, "to", from);
26951
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1653
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1654 error = xmlnode_new_child(result->node, "error");
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1655 xmlnode_set_attrib(error, "type", "cancel");
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1656 x = xmlnode_new_child(error, "not-allowed");
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
1657 xmlnode_set_namespace(x, NS_XMPP_STANZAS);
26951
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1658
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1659 jabber_iq_send(result);
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1660 return;
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1661 }
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1662
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1663 account = purple_connection_get_account(js->gc);
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1664 is_block = g_str_equal(child->name, "block");
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1665
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1666 item = xmlnode_get_child(child, "item");
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1667 if (!is_block && item == NULL) {
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1668 /* Unblock everyone */
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1669 purple_debug_info("jabber", "Received unblock push. Unblocking everyone.\n");
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1670
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1671 while (account->deny != NULL) {
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1672 purple_privacy_deny_remove(account, account->deny->data, TRUE);
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1673 }
26957
373141b35c52 Avoid an assertion failure and add an error case.
Paul Aurich <paul@darkrain42.org>
parents: 26952
diff changeset
1674 } else if (item == NULL) {
373141b35c52 Avoid an assertion failure and add an error case.
Paul Aurich <paul@darkrain42.org>
parents: 26952
diff changeset
1675 /* An empty <block/> is bogus */
373141b35c52 Avoid an assertion failure and add an error case.
Paul Aurich <paul@darkrain42.org>
parents: 26952
diff changeset
1676 xmlnode *error, *x;
373141b35c52 Avoid an assertion failure and add an error case.
Paul Aurich <paul@darkrain42.org>
parents: 26952
diff changeset
1677 result = jabber_iq_new(js, JABBER_IQ_ERROR);
373141b35c52 Avoid an assertion failure and add an error case.
Paul Aurich <paul@darkrain42.org>
parents: 26952
diff changeset
1678 xmlnode_set_attrib(result->node, "id", id);
373141b35c52 Avoid an assertion failure and add an error case.
Paul Aurich <paul@darkrain42.org>
parents: 26952
diff changeset
1679
373141b35c52 Avoid an assertion failure and add an error case.
Paul Aurich <paul@darkrain42.org>
parents: 26952
diff changeset
1680 error = xmlnode_new_child(result->node, "error");
373141b35c52 Avoid an assertion failure and add an error case.
Paul Aurich <paul@darkrain42.org>
parents: 26952
diff changeset
1681 xmlnode_set_attrib(error, "type", "modify");
373141b35c52 Avoid an assertion failure and add an error case.
Paul Aurich <paul@darkrain42.org>
parents: 26952
diff changeset
1682 x = xmlnode_new_child(error, "bad-request");
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
1683 xmlnode_set_namespace(x, NS_XMPP_STANZAS);
26957
373141b35c52 Avoid an assertion failure and add an error case.
Paul Aurich <paul@darkrain42.org>
parents: 26952
diff changeset
1684
373141b35c52 Avoid an assertion failure and add an error case.
Paul Aurich <paul@darkrain42.org>
parents: 26952
diff changeset
1685 jabber_iq_send(result);
373141b35c52 Avoid an assertion failure and add an error case.
Paul Aurich <paul@darkrain42.org>
parents: 26952
diff changeset
1686 return;
26951
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1687 } else {
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1688 for ( ; item; item = xmlnode_get_next_twin(item)) {
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1689 const char *jid = xmlnode_get_attrib(item, "jid");
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1690 if (jid == NULL || *jid == '\0')
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1691 continue;
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1692
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1693 if (is_block)
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1694 purple_privacy_deny_add(account, jid, TRUE);
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1695 else
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1696 purple_privacy_deny_remove(account, jid, TRUE);
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1697 }
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1698 }
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1699
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1700 result = jabber_iq_new(js, JABBER_IQ_RESULT);
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1701 xmlnode_set_attrib(result->node, "id", id);
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1702 jabber_iq_send(result);
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1703 }
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1704
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1705 static void jabber_blocklist_parse(JabberStream *js, const char *from,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1706 JabberIqType type, const char *id,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
1707 xmlnode *packet, gpointer data)
24855
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1708 {
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1709 xmlnode *blocklist, *item;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1710 PurpleAccount *account;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1711
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1712 blocklist = xmlnode_get_child_with_namespace(packet,
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
1713 "blocklist", NS_SIMPLE_BLOCKING);
24855
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1714 account = purple_connection_get_account(js->gc);
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1715
26952
1dcee141997d The server list is definitive for who is blocked.
Paul Aurich <paul@darkrain42.org>
parents: 26951
diff changeset
1716 if (type == JABBER_IQ_ERROR || blocklist == NULL)
24855
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1717 return;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1718
26951
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1719 /* This is the only privacy method supported by XEP-0191 */
26952
1dcee141997d The server list is definitive for who is blocked.
Paul Aurich <paul@darkrain42.org>
parents: 26951
diff changeset
1720 if (account->perm_deny != PURPLE_PRIVACY_DENY_USERS)
26951
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1721 account->perm_deny = PURPLE_PRIVACY_DENY_USERS;
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1722
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1723 /*
26952
1dcee141997d The server list is definitive for who is blocked.
Paul Aurich <paul@darkrain42.org>
parents: 26951
diff changeset
1724 * TODO: When account->deny is something more than a hash table, this can
1dcee141997d The server list is definitive for who is blocked.
Paul Aurich <paul@darkrain42.org>
parents: 26951
diff changeset
1725 * be re-written to find the set intersection and difference.
26951
10c91922bc1e Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Paul Aurich <paul@darkrain42.org>
parents: 26933
diff changeset
1726 */
26952
1dcee141997d The server list is definitive for who is blocked.
Paul Aurich <paul@darkrain42.org>
parents: 26951
diff changeset
1727 while (account->deny)
1dcee141997d The server list is definitive for who is blocked.
Paul Aurich <paul@darkrain42.org>
parents: 26951
diff changeset
1728 purple_privacy_deny_remove(account, account->deny->data, TRUE);
1dcee141997d The server list is definitive for who is blocked.
Paul Aurich <paul@darkrain42.org>
parents: 26951
diff changeset
1729
24855
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1730 item = xmlnode_get_child(blocklist, "item");
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1731 while (item != NULL) {
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1732 const char *jid = xmlnode_get_attrib(item, "jid");
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1733 purple_privacy_deny_add(account, jid, TRUE);
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1734 item = xmlnode_get_next_twin(item);
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1735 }
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1736 }
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1737
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1738 void jabber_request_block_list(JabberStream *js)
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1739 {
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1740 JabberIq *iq;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1741 xmlnode *blocklist;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1742
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1743 iq = jabber_iq_new(js, JABBER_IQ_GET);
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1744
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1745 blocklist = xmlnode_new_child(iq->node, "blocklist");
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
1746 xmlnode_set_namespace(blocklist, NS_SIMPLE_BLOCKING);
24855
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1747
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1748 jabber_iq_set_callback(iq, jabber_blocklist_parse, NULL);
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1749
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1750 jabber_iq_send(iq);
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1751 }
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1752
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1753 void jabber_add_deny(PurpleConnection *gc, const char *who)
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1754 {
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1755 JabberStream *js;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1756 JabberIq *iq;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1757 xmlnode *block, *item;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1758
28758
531f8367025e jabber: Clean up this code a little.
Paul Aurich <paul@darkrain42.org>
parents: 28744
diff changeset
1759 g_return_if_fail(who != NULL && *who != '\0');
531f8367025e jabber: Clean up this code a little.
Paul Aurich <paul@darkrain42.org>
parents: 28744
diff changeset
1760
531f8367025e jabber: Clean up this code a little.
Paul Aurich <paul@darkrain42.org>
parents: 28744
diff changeset
1761 js = purple_connection_get_protocol_data(gc);
24855
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1762 if (js == NULL)
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1763 return;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1764
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1765 if (js->server_caps & JABBER_CAP_GOOGLE_ROSTER)
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1766 {
28758
531f8367025e jabber: Clean up this code a little.
Paul Aurich <paul@darkrain42.org>
parents: 28744
diff changeset
1767 jabber_google_roster_add_deny(js, who);
24855
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1768 return;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1769 }
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1770
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1771 if (!(js->server_caps & JABBER_CAP_BLOCKING))
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1772 {
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1773 purple_notify_error(NULL, _("Server doesn't support blocking"),
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1774 _("Server doesn't support blocking"), NULL);
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1775 return;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1776 }
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1777
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1778 iq = jabber_iq_new(js, JABBER_IQ_SET);
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1779
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1780 block = xmlnode_new_child(iq->node, "block");
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
1781 xmlnode_set_namespace(block, NS_SIMPLE_BLOCKING);
24855
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1782
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1783 item = xmlnode_new_child(block, "item");
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1784 xmlnode_set_attrib(item, "jid", who);
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1785
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1786 jabber_iq_send(iq);
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1787 }
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1788
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1789 void jabber_rem_deny(PurpleConnection *gc, const char *who)
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1790 {
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1791 JabberStream *js;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1792 JabberIq *iq;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1793 xmlnode *unblock, *item;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1794
28758
531f8367025e jabber: Clean up this code a little.
Paul Aurich <paul@darkrain42.org>
parents: 28744
diff changeset
1795 g_return_if_fail(who != NULL && *who != '\0');
531f8367025e jabber: Clean up this code a little.
Paul Aurich <paul@darkrain42.org>
parents: 28744
diff changeset
1796
531f8367025e jabber: Clean up this code a little.
Paul Aurich <paul@darkrain42.org>
parents: 28744
diff changeset
1797 js = purple_connection_get_protocol_data(gc);
24855
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1798 if (js == NULL)
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1799 return;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1800
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1801 if (js->server_caps & JABBER_CAP_GOOGLE_ROSTER)
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1802 {
28758
531f8367025e jabber: Clean up this code a little.
Paul Aurich <paul@darkrain42.org>
parents: 28744
diff changeset
1803 jabber_google_roster_rem_deny(js, who);
24855
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1804 return;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1805 }
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1806
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1807 if (!(js->server_caps & JABBER_CAP_BLOCKING))
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1808 return;
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1809
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1810 iq = jabber_iq_new(js, JABBER_IQ_SET);
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1811
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1812 unblock = xmlnode_new_child(iq->node, "unblock");
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
1813 xmlnode_set_namespace(unblock, NS_SIMPLE_BLOCKING);
24855
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1814
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1815 item = xmlnode_new_child(unblock, "item");
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1816 xmlnode_set_attrib(item, "jid", who);
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1817
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1818 jabber_iq_send(iq);
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1819 }
0700833f0c5d Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <mark@kingant.net>
parents: 24807
diff changeset
1820
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1821 void jabber_add_feature(const char *namespace, JabberFeatureEnabled cb) {
17849
e49b259fc7dd PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17848
diff changeset
1822 JabberFeature *feat;
20000
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1823
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1824 g_return_if_fail(namespace != NULL);
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19999
diff changeset
1825
17849
e49b259fc7dd PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17848
diff changeset
1826 feat = g_new0(JabberFeature,1);
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
1827 feat->namespace = g_strdup(namespace);
17849
e49b259fc7dd PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17848
diff changeset
1828 feat->is_enabled = cb;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
1829
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
1830 /* try to remove just in case it already exists in the list */
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1831 jabber_remove_feature(namespace);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
1832
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
1833 jabber_features = g_list_append(jabber_features, feat);
17836
95affacf6f82 Added the ability to define extensions to caps
Andreas Monitzer <pidgin@monitzer.com>
parents: 17835
diff changeset
1834 }
95affacf6f82 Added the ability to define extensions to caps
Andreas Monitzer <pidgin@monitzer.com>
parents: 17835
diff changeset
1835
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1836 void jabber_remove_feature(const char *namespace) {
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
1837 GList *feature;
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
1838 for(feature = jabber_features; feature; feature = feature->next) {
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
1839 JabberFeature *feat = (JabberFeature*)feature->data;
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1840 if(!strcmp(feat->namespace, namespace)) {
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
1841 g_free(feat->namespace);
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
1842 g_free(feature->data);
21538
4e5bef6c3379 Fix #3669
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1843 jabber_features = g_list_delete_link(jabber_features, feature);
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
1844 break;
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
1845 }
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
1846 }
17836
95affacf6f82 Added the ability to define extensions to caps
Andreas Monitzer <pidgin@monitzer.com>
parents: 17835
diff changeset
1847 }
95affacf6f82 Added the ability to define extensions to caps
Andreas Monitzer <pidgin@monitzer.com>
parents: 17835
diff changeset
1848
25167
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1849 static void jabber_features_destroy(void)
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1850 {
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1851 while (jabber_features) {
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1852 JabberFeature *feature = jabber_features->data;
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1853 g_free(feature->namespace);
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1854 g_free(feature);
28438
c3be1de8abde jabber: Oops. --leaks.
Paul Aurich <paul@darkrain42.org>
parents: 28421
diff changeset
1855 jabber_features = g_list_delete_link(jabber_features, jabber_features);
25167
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1856 }
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1857 }
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1858
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
1859 void jabber_add_identity(const gchar *category, const gchar *type, const gchar *lang, const gchar *name) {
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1860 GList *identity;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1861 JabberIdentity *ident;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1862 /* both required according to XEP-0030 */
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1863 g_return_if_fail(category != NULL);
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1864 g_return_if_fail(type != NULL);
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26917
diff changeset
1865
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1866 for(identity = jabber_identities; identity; identity = identity->next) {
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1867 JabberIdentity *ident = (JabberIdentity*)identity->data;
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
1868 if (!strcmp(ident->category, category) &&
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
1869 !strcmp(ident->type, type) &&
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
1870 ((!ident->lang && !lang) || (ident->lang && lang && !strcmp(ident->lang, lang)))) {
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
1871 return;
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26917
diff changeset
1872 }
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1873 }
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
1874
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1875 ident = g_new0(JabberIdentity, 1);
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1876 ident->category = g_strdup(category);
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1877 ident->type = g_strdup(type);
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
1878 ident->lang = g_strdup(lang);
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1879 ident->name = g_strdup(name);
26768
966d2f2f86c8 Don't crash when the caps cb is NULL and don't corrupt jabber_identities
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1880 jabber_identities = g_list_prepend(jabber_identities, ident);
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1881 }
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
1882
25167
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1883 static void jabber_identities_destroy(void)
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1884 {
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1885 while (jabber_identities) {
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1886 JabberIdentity *id = jabber_identities->data;
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1887 g_free(id->category);
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1888 g_free(id->type);
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1889 g_free(id->lang);
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1890 g_free(id->name);
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1891 g_free(id);
28438
c3be1de8abde jabber: Oops. --leaks.
Paul Aurich <paul@darkrain42.org>
parents: 28421
diff changeset
1892 jabber_identities = g_list_delete_link(jabber_identities, jabber_identities);
25167
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1893 }
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1894 }
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
1895
26272
fcee93c74230 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <paul@darkrain42.org>
parents: 26270
diff changeset
1896 gboolean jabber_stream_is_ssl(JabberStream *js)
fcee93c74230 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <paul@darkrain42.org>
parents: 26270
diff changeset
1897 {
fcee93c74230 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <paul@darkrain42.org>
parents: 26270
diff changeset
1898 return (js->bosh && jabber_bosh_connection_is_ssl(js->bosh)) ||
fcee93c74230 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <paul@darkrain42.org>
parents: 26270
diff changeset
1899 (!js->bosh && js->gsc);
fcee93c74230 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <paul@darkrain42.org>
parents: 26270
diff changeset
1900 }
fcee93c74230 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <paul@darkrain42.org>
parents: 26270
diff changeset
1901
16240
547c76fe2e7a 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@gmail.com>
parents: 16068
diff changeset
1902 const char *jabber_list_icon(PurpleAccount *a, PurpleBuddy *b)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1903 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1904 return "jabber";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1905 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1906
16240
547c76fe2e7a 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@gmail.com>
parents: 16068
diff changeset
1907 const char* jabber_list_emblem(PurpleBuddy *b)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1908 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1909 JabberStream *js;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1910 JabberBuddy *jb = NULL;
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
1911 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(b));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1912
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
1913 if(!gc)
15497
0d4890637238 clean up some compile warnings
Nathan Walp <nwalp@pidgin.im>
parents: 15462
diff changeset
1914 return NULL;
0d4890637238 clean up some compile warnings
Nathan Walp <nwalp@pidgin.im>
parents: 15462
diff changeset
1915
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
1916 js = gc->proto_data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1917 if(js)
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
1918 jb = jabber_buddy_find(js, purple_buddy_get_name(b), FALSE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1919
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1920 if(!PURPLE_BUDDY_IS_ONLINE(b)) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1921 if(jb && (jb->subscription & JABBER_SUB_PENDING ||
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1922 !(jb->subscription & JABBER_SUB_TO)))
15462
0b6f337a46d5 Emblems in the blist
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
1923 return "not-authorized";
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1924 }
27054
dd7e7071d46d Whitespace + a change cluttering up the diff with im.pidgin.pidgin
Paul Aurich <paul@darkrain42.org>
parents: 27053
diff changeset
1925
25512
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1926 if (jb) {
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1927 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, NULL);
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1928 if (jbr) {
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1929 const gchar *client_type =
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1930 jabber_resource_get_identity_category_type(jbr, "client");
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1931
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1932 if (client_type) {
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1933 if (strcmp(client_type, "phone") == 0) {
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1934 return "mobile";
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1935 } else if (strcmp(client_type, "web") == 0) {
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1936 return "external";
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1937 } else if (strcmp(client_type, "handheld") == 0) {
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1938 return "hiptop";
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1939 } else if (strcmp(client_type, "bot") == 0) {
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1940 return "bot";
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1941 }
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1942 /* the default value "pc" falls through and has no emblem */
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1943 }
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1944 }
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1945 }
1d3274111180 Set a value "type" in the ui_info hash table
Marcus Lundblad <ml@update.uu.se>
parents: 25432
diff changeset
1946
15462
0b6f337a46d5 Emblems in the blist
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
1947 return NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1948 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1949
16240
547c76fe2e7a 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@gmail.com>
parents: 16068
diff changeset
1950 char *jabber_status_text(PurpleBuddy *b)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1951 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1952 char *ret = NULL;
18237
2a5c5d675789 Fix a crash when you have an IM window open on a jabber account and the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18163
diff changeset
1953 JabberBuddy *jb = NULL;
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
1954 PurpleAccount *account = purple_buddy_get_account(b);
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
1955 PurpleConnection *gc = purple_account_get_connection(account);
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
1956
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
1957 if (gc && gc->proto_data)
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
1958 jb = jabber_buddy_find(gc->proto_data, purple_buddy_get_name(b), FALSE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1959
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1960 if(jb && !PURPLE_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1961 ret = g_strdup(_("Not Authorized"));
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1962 } else if(jb && !PURPLE_BUDDY_IS_ONLINE(b) && jb->error_msg) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1963 ret = g_strdup(jb->error_msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1964 } else {
26691
803e05b3a871 Retrieve status message to display in Buddy List from PurplePresence.
Paul Aurich <paul@darkrain42.org>
parents: 26685
diff changeset
1965 PurplePresence *presence = purple_buddy_get_presence(b);
27487
7a2891487a00 Don't pre-escape jbr->status. Almost every place required it in unescaped
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27438
diff changeset
1966 PurpleStatus *status = purple_presence_get_active_status(presence);
27527
a12574d982a1 merge of '6bf1ed8cefd6bb5b980baf7501bcf6936634bd8d'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27517 27487
diff changeset
1967 const char *message;
a12574d982a1 merge of '6bf1ed8cefd6bb5b980baf7501bcf6936634bd8d'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27517 27487
diff changeset
1968
a12574d982a1 merge of '6bf1ed8cefd6bb5b980baf7501bcf6936634bd8d'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27517 27487
diff changeset
1969 if((message = purple_status_get_attr_string(status, "message"))) {
a12574d982a1 merge of '6bf1ed8cefd6bb5b980baf7501bcf6936634bd8d'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27517 27487
diff changeset
1970 ret = g_markup_escape_text(message, -1);
a12574d982a1 merge of '6bf1ed8cefd6bb5b980baf7501bcf6936634bd8d'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27517 27487
diff changeset
1971 } else if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
a12574d982a1 merge of '6bf1ed8cefd6bb5b980baf7501bcf6936634bd8d'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27517 27487
diff changeset
1972 PurpleStatus *status = purple_presence_get_status(presence, "tune");
a12574d982a1 merge of '6bf1ed8cefd6bb5b980baf7501bcf6936634bd8d'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27517 27487
diff changeset
1973 const char *title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE);
a12574d982a1 merge of '6bf1ed8cefd6bb5b980baf7501bcf6936634bd8d'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27517 27487
diff changeset
1974 const char *artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST);
a12574d982a1 merge of '6bf1ed8cefd6bb5b980baf7501bcf6936634bd8d'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27517 27487
diff changeset
1975 const char *album = purple_status_get_attr_string(status, PURPLE_TUNE_ALBUM);
a12574d982a1 merge of '6bf1ed8cefd6bb5b980baf7501bcf6936634bd8d'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27517 27487
diff changeset
1976 ret = purple_util_format_song_info(title, artist, album, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1977 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1978 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1979
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1980 return ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1981 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1982
25695
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
1983 static void
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26917
diff changeset
1984 jabber_tooltip_add_resource_text(JabberBuddyResource *jbr,
25695
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
1985 PurpleNotifyUserInfo *user_info, gboolean multiple_resources)
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
1986 {
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
1987 char *text = NULL;
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
1988 char *res = NULL;
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
1989 char *label, *value;
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
1990 const char *state;
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
1991
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
1992 if(jbr->status) {
27487
7a2891487a00 Don't pre-escape jbr->status. Almost every place required it in unescaped
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27438
diff changeset
1993 text = g_markup_escape_text(jbr->status, -1);
25695
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
1994 }
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
1995
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
1996 if(jbr->name)
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
1997 res = g_strdup_printf(" (%s)", jbr->name);
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
1998
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
1999 state = jabber_buddy_state_get_name(jbr->state);
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2000 if (text != NULL && !purple_utf8_strcasecmp(state, text)) {
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2001 g_free(text);
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2002 text = NULL;
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2003 }
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2004
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2005 label = g_strdup_printf("%s%s", _("Status"), (res ? res : ""));
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2006 value = g_strdup_printf("%s%s%s", state, (text ? ": " : ""), (text ? text : ""));
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2007
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2008 purple_notify_user_info_add_pair(user_info, label, value);
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2009 g_free(label);
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2010 g_free(value);
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2011 g_free(text);
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26917
diff changeset
2012
25695
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2013 /* if the resource is idle, show that */
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2014 /* only show it if there is more than one resource available for
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2015 the buddy, since the "general" idleness will be shown anyway,
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2016 this way we can see see the idleness of lower-priority resources */
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2017 if (jbr->idle && multiple_resources) {
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26917
diff changeset
2018 gchar *idle_str =
25695
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2019 purple_str_seconds_to_string(time(NULL) - jbr->idle);
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2020 label = g_strdup_printf("%s%s", _("Idle"), (res ? res : ""));
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2021 purple_notify_user_info_add_pair(user_info, label, idle_str);
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2022 g_free(idle_str);
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2023 g_free(label);
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2024 }
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2025 g_free(res);
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2026 }
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2027
16240
547c76fe2e7a 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@gmail.com>
parents: 16068
diff changeset
2028 void jabber_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2029 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2030 JabberBuddy *jb;
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
2031 PurpleAccount *account;
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
2032 PurpleConnection *gc;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2033
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2034 g_return_if_fail(b != NULL);
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
2035
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
2036 account = purple_buddy_get_account(b);
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
2037 g_return_if_fail(account != NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2038
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
2039 gc = purple_account_get_connection(account);
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
2040 g_return_if_fail(gc != NULL);
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
2041 g_return_if_fail(gc->proto_data != NULL);
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
2042
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
2043 jb = jabber_buddy_find(gc->proto_data, purple_buddy_get_name(b), FALSE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2044
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2045 if(jb) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2046 JabberBuddyResource *jbr = NULL;
20571
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20570
diff changeset
2047 PurplePresence *presence = purple_buddy_get_presence(b);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2048 const char *sub;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2049 GList *l;
19723
eedf2918aace Don't put "Mood: \(null\) \(null\)" on XMPP buddies
Sean Egan <seanegan@gmail.com>
parents: 19697
diff changeset
2050 const char *mood;
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26917
diff changeset
2051 gboolean multiple_resources =
25691
65f2c84f122f Only show idle time for idle resources in tooltip text when there is more than
Marcus Lundblad <ml@update.uu.se>
parents: 25686
diff changeset
2052 jb->resources && g_list_next(jb->resources);
25695
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2053 JabberBuddyResource *top_jbr = jabber_buddy_find_resource(jb, NULL);
25697
8202f850ca9e Remove some unused variables
Marcus Lundblad <ml@update.uu.se>
parents: 25696
diff changeset
2054
25695
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2055 /* resource-specific info for the top resource */
25698
1ad482221d70 Avoid crashing when showing the tooltip of an offline buddy, oops :)
Marcus Lundblad <ml@update.uu.se>
parents: 25697
diff changeset
2056 if (top_jbr) {
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26917
diff changeset
2057 jabber_tooltip_add_resource_text(top_jbr, user_info,
25698
1ad482221d70 Avoid crashing when showing the tooltip of an offline buddy, oops :)
Marcus Lundblad <ml@update.uu.se>
parents: 25697
diff changeset
2058 multiple_resources);
1ad482221d70 Avoid crashing when showing the tooltip of an offline buddy, oops :)
Marcus Lundblad <ml@update.uu.se>
parents: 25697
diff changeset
2059 }
25697
8202f850ca9e Remove some unused variables
Marcus Lundblad <ml@update.uu.se>
parents: 25696
diff changeset
2060
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2061 for(l=jb->resources; l; l = l->next) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2062 jbr = l->data;
25695
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2063 /* the remaining resources */
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2064 if (jbr != top_jbr) {
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2065 jabber_tooltip_add_resource_text(jbr, user_info,
e3f2b16f75da Always show the top resource first in the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25692
diff changeset
2066 multiple_resources);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2067 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2068 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2069
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2070 if (full) {
17846
2f067d8fb19a Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17845
diff changeset
2071 PurpleStatus *status;
23269
e7b6767f263b The status type says that mood and moodtext are strings, so we don't
Mark Doliner <mark@kingant.net>
parents: 23180
diff changeset
2072
29440
1fb503adb2ae Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@wiktel.com>
parents: 29435
diff changeset
2073 status = purple_presence_get_status(presence, "mood");
1fb503adb2ae Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@wiktel.com>
parents: 29435
diff changeset
2074 mood = purple_status_get_attr_string(status, PURPLE_MOOD_NAME);
29433
37be968cd42c Check that mood is not the empty string, just to be safe.
Richard Laager <rlaager@wiktel.com>
parents: 29431
diff changeset
2075 if(mood && *mood) {
23269
e7b6767f263b The status type says that mood and moodtext are strings, so we don't
Mark Doliner <mark@kingant.net>
parents: 23180
diff changeset
2076 const char *moodtext;
29468
b052a711cfbd Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
2077 /* find the mood */
b052a711cfbd Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
2078 PurpleMood *moods = jabber_get_moods(account);
b052a711cfbd Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
2079 const char *description = NULL;
b052a711cfbd Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
2080
b052a711cfbd Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
2081 for (; moods->mood ; moods++) {
b052a711cfbd Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
2082 if (purple_strequal(moods->mood, mood)) {
b052a711cfbd Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
2083 description = moods->description;
b052a711cfbd Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
2084 break;
b052a711cfbd Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
2085 }
b052a711cfbd Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
2086 }
b052a711cfbd Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
2087
29440
1fb503adb2ae Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@wiktel.com>
parents: 29435
diff changeset
2088 moodtext = purple_status_get_attr_string(status, PURPLE_MOOD_COMMENT);
29431
b0e7b4daf465 Do not show "Mood: mood ()" when there is no text.
Richard Laager <rlaager@wiktel.com>
parents: 24216
diff changeset
2089 if(moodtext && *moodtext) {
29468
b052a711cfbd Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
2090 char *moodplustext =
b052a711cfbd Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
2091 g_strdup_printf("%s (%s)", description ? _(description) : mood, moodtext);
23269
e7b6767f263b The status type says that mood and moodtext are strings, so we don't
Mark Doliner <mark@kingant.net>
parents: 23180
diff changeset
2092
17846
2f067d8fb19a Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17845
diff changeset
2093 purple_notify_user_info_add_pair(user_info, _("Mood"), moodplustext);
2f067d8fb19a Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17845
diff changeset
2094 g_free(moodplustext);
2f067d8fb19a Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17845
diff changeset
2095 } else
29468
b052a711cfbd Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
2096 purple_notify_user_info_add_pair(user_info, _("Mood"),
b052a711cfbd Show the translated mood message (again), if it matches one of the moods we
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
2097 description ? _(description) : mood);
20571
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20570
diff changeset
2098 }
22000
af0426c34c27 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21977
diff changeset
2099 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
20571
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20570
diff changeset
2100 PurpleStatus *tune = purple_presence_get_status(presence, "tune");
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20570
diff changeset
2101 const char *title = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE);
22000
af0426c34c27 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21977
diff changeset
2102 const char *artist = purple_status_get_attr_string(tune, PURPLE_TUNE_ARTIST);
af0426c34c27 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21977
diff changeset
2103 const char *album = purple_status_get_attr_string(tune, PURPLE_TUNE_ALBUM);
af0426c34c27 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21977
diff changeset
2104 char *playing = purple_util_format_song_info(title, artist, album, NULL);
af0426c34c27 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21977
diff changeset
2105 if (playing) {
af0426c34c27 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21977
diff changeset
2106 purple_notify_user_info_add_pair(user_info, _("Now Listening"), playing);
af0426c34c27 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21977
diff changeset
2107 g_free(playing);
af0426c34c27 Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21977
diff changeset
2108 }
20571
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20570
diff changeset
2109 }
25692
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2110
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2111 if(jb->subscription & JABBER_SUB_FROM) {
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2112 if(jb->subscription & JABBER_SUB_TO)
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2113 sub = _("Both");
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2114 else if(jb->subscription & JABBER_SUB_PENDING)
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2115 sub = _("From (To pending)");
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2116 else
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2117 sub = _("From");
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2118 } else {
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2119 if(jb->subscription & JABBER_SUB_TO)
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2120 sub = _("To");
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2121 else if(jb->subscription & JABBER_SUB_PENDING)
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2122 sub = _("None (To pending)");
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2123 else
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2124 sub = _("None");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2125 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2126
25692
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2127 purple_notify_user_info_add_pair(user_info, _("Subscription"), sub);
a8224eb86581 Show statuses per resource before other info the jabber prpl adds to the tooltip
Marcus Lundblad <ml@update.uu.se>
parents: 25691
diff changeset
2128
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2129 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2130
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2131 if(!PURPLE_BUDDY_IS_ONLINE(b) && jb->error_msg) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2132 purple_notify_user_info_add_pair(user_info, _("Error"), jb->error_msg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2133 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2134 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2135 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2136
16240
547c76fe2e7a 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@gmail.com>
parents: 16068
diff changeset
2137 GList *jabber_status_types(PurpleAccount *account)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2138 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2139 PurpleStatusType *type;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2140 GList *types = NULL;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2141 PurpleValue *priority_value;
25132
04d8a514d2bb Updated support for XEP-0224.
Marcus Lundblad <ml@update.uu.se>
parents: 24058
diff changeset
2142 PurpleValue *buzz_enabled;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2143
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2144 priority_value = purple_value_new(PURPLE_TYPE_INT);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2145 purple_value_set_int(priority_value, 1);
25132
04d8a514d2bb Updated support for XEP-0224.
Marcus Lundblad <ml@update.uu.se>
parents: 24058
diff changeset
2146 buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
04d8a514d2bb Updated support for XEP-0224.
Marcus Lundblad <ml@update.uu.se>
parents: 24058
diff changeset
2147 purple_value_set_boolean(buzz_enabled, TRUE);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2148 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2149 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_ONLINE),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2150 NULL, TRUE, TRUE, FALSE,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2151 "priority", _("Priority"), priority_value,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2152 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
2153 "mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
2154 "moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
17869
6842cc73b1b7 Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17866
diff changeset
2155 "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
25132
04d8a514d2bb Updated support for XEP-0224.
Marcus Lundblad <ml@update.uu.se>
parents: 24058
diff changeset
2156 "buzz", _("Allow Buzz"), buzz_enabled,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2157 NULL);
29435
11cb7f2bb6e8 Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@wiktel.com>
parents: 29433
diff changeset
2158 types = g_list_prepend(types, type);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2159
29463
f3654983e1da Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <ml@update.uu.se>
parents: 29458
diff changeset
2160
f3654983e1da Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <ml@update.uu.se>
parents: 29458
diff changeset
2161 type = purple_status_type_new_with_attrs(PURPLE_STATUS_MOOD,
f3654983e1da Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <ml@update.uu.se>
parents: 29458
diff changeset
2162 "mood", NULL, TRUE, TRUE, TRUE,
f3654983e1da Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <ml@update.uu.se>
parents: 29458
diff changeset
2163 PURPLE_MOOD_NAME, _("Mood Name"), purple_value_new(PURPLE_TYPE_STRING),
f3654983e1da Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <ml@update.uu.se>
parents: 29458
diff changeset
2164 PURPLE_MOOD_COMMENT, _("Mood Comment"), purple_value_new(PURPLE_TYPE_STRING),
f3654983e1da Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <ml@update.uu.se>
parents: 29458
diff changeset
2165 NULL);
f3654983e1da Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <ml@update.uu.se>
parents: 29458
diff changeset
2166 types = g_list_prepend(types, type);
f3654983e1da Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <ml@update.uu.se>
parents: 29458
diff changeset
2167
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2168 priority_value = purple_value_new(PURPLE_TYPE_INT);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2169 purple_value_set_int(priority_value, 1);
25221
7b93616f7982 Patch from Darkrain42 to avoid a double-free on status values
Marcus Lundblad <ml@update.uu.se>
parents: 25219
diff changeset
2170 buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
7b93616f7982 Patch from Darkrain42 to avoid a double-free on status values
Marcus Lundblad <ml@update.uu.se>
parents: 25219
diff changeset
2171 purple_value_set_boolean(buzz_enabled, TRUE);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2172 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2173 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_CHAT),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2174 _("Chatty"), TRUE, TRUE, FALSE,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2175 "priority", _("Priority"), priority_value,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2176 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
2177 "mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
2178 "moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
17869
6842cc73b1b7 Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17866
diff changeset
2179 "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
25132
04d8a514d2bb Updated support for XEP-0224.
Marcus Lundblad <ml@update.uu.se>
parents: 24058
diff changeset
2180 "buzz", _("Allow Buzz"), buzz_enabled,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2181 NULL);
29435
11cb7f2bb6e8 Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@wiktel.com>
parents: 29433
diff changeset
2182 types = g_list_prepend(types, type);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2183
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2184 priority_value = purple_value_new(PURPLE_TYPE_INT);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2185 purple_value_set_int(priority_value, 0);
25221
7b93616f7982 Patch from Darkrain42 to avoid a double-free on status values
Marcus Lundblad <ml@update.uu.se>
parents: 25219
diff changeset
2186 buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
7b93616f7982 Patch from Darkrain42 to avoid a double-free on status values
Marcus Lundblad <ml@update.uu.se>
parents: 25219
diff changeset
2187 purple_value_set_boolean(buzz_enabled, TRUE);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2188 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2189 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_AWAY),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2190 NULL, TRUE, TRUE, FALSE,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2191 "priority", _("Priority"), priority_value,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2192 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
2193 "mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
2194 "moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
17869
6842cc73b1b7 Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17866
diff changeset
2195 "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
2196 "buzz", _("Allow Buzz"), buzz_enabled,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2197 NULL);
29435
11cb7f2bb6e8 Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@wiktel.com>
parents: 29433
diff changeset
2198 types = g_list_prepend(types, type);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2199
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2200 priority_value = purple_value_new(PURPLE_TYPE_INT);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2201 purple_value_set_int(priority_value, 0);
25221
7b93616f7982 Patch from Darkrain42 to avoid a double-free on status values
Marcus Lundblad <ml@update.uu.se>
parents: 25219
diff changeset
2202 buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
7b93616f7982 Patch from Darkrain42 to avoid a double-free on status values
Marcus Lundblad <ml@update.uu.se>
parents: 25219
diff changeset
2203 purple_value_set_boolean(buzz_enabled, TRUE);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2204 type = purple_status_type_new_with_attrs(PURPLE_STATUS_EXTENDED_AWAY,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2205 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_XA),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2206 NULL, TRUE, TRUE, FALSE,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2207 "priority", _("Priority"), priority_value,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2208 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
2209 "mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
2210 "moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
17869
6842cc73b1b7 Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17866
diff changeset
2211 "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
2212 "buzz", _("Allow Buzz"), buzz_enabled,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2213 NULL);
29435
11cb7f2bb6e8 Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@wiktel.com>
parents: 29433
diff changeset
2214 types = g_list_prepend(types, type);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2215
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2216 priority_value = purple_value_new(PURPLE_TYPE_INT);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2217 purple_value_set_int(priority_value, 0);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2218 type = purple_status_type_new_with_attrs(PURPLE_STATUS_UNAVAILABLE,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2219 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_DND),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2220 _("Do Not Disturb"), TRUE, TRUE, FALSE,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2221 "priority", _("Priority"), priority_value,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2222 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
2223 "mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
2224 "moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
17869
6842cc73b1b7 Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17866
diff changeset
2225 "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2226 NULL);
29435
11cb7f2bb6e8 Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@wiktel.com>
parents: 29433
diff changeset
2227 types = g_list_prepend(types, type);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2228
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2229 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2230 if(js->protocol_version == JABBER_PROTO_0_9)
29435
11cb7f2bb6e8 Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@wiktel.com>
parents: 29433
diff changeset
2231 "Invisible"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2232 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2233
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2234 type = purple_status_type_new_with_attrs(PURPLE_STATUS_OFFLINE,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2235 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_UNAVAILABLE),
25412
b5c82724598c For some reason, all these statuses were set to saveable=FALSE. With the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24890
diff changeset
2236 NULL, TRUE, TRUE, FALSE,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2237 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2238 NULL);
29435
11cb7f2bb6e8 Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@wiktel.com>
parents: 29433
diff changeset
2239 types = g_list_prepend(types, type);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2240
20570
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20076
diff changeset
2241 type = purple_status_type_new_with_attrs(PURPLE_STATUS_TUNE,
24464
3a3d36791a47 I don't know why we'd want the TUNE status to be saveable.
Richard Laager <rlaager@wiktel.com>
parents: 24216
diff changeset
2242 "tune", NULL, FALSE, TRUE, TRUE,
20570
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20076
diff changeset
2243 PURPLE_TUNE_ARTIST, _("Tune Artist"), purple_value_new(PURPLE_TYPE_STRING),
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20076
diff changeset
2244 PURPLE_TUNE_TITLE, _("Tune Title"), purple_value_new(PURPLE_TYPE_STRING),
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20076
diff changeset
2245 PURPLE_TUNE_ALBUM, _("Tune Album"), purple_value_new(PURPLE_TYPE_STRING),
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20076
diff changeset
2246 PURPLE_TUNE_GENRE, _("Tune Genre"), purple_value_new(PURPLE_TYPE_STRING),
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20076
diff changeset
2247 PURPLE_TUNE_COMMENT, _("Tune Comment"), purple_value_new(PURPLE_TYPE_STRING),
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20076
diff changeset
2248 PURPLE_TUNE_TRACK, _("Tune Track"), purple_value_new(PURPLE_TYPE_STRING),
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20076
diff changeset
2249 PURPLE_TUNE_TIME, _("Tune Time"), purple_value_new(PURPLE_TYPE_INT),
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20076
diff changeset
2250 PURPLE_TUNE_YEAR, _("Tune Year"), purple_value_new(PURPLE_TYPE_INT),
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20076
diff changeset
2251 PURPLE_TUNE_URL, _("Tune URL"), purple_value_new(PURPLE_TYPE_STRING),
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20076
diff changeset
2252 NULL);
29435
11cb7f2bb6e8 Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@wiktel.com>
parents: 29433
diff changeset
2253 types = g_list_prepend(types, type);
20570
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20076
diff changeset
2254
29435
11cb7f2bb6e8 Add a PURPLE_STATUS_MOOD primitive and change ICQ to use it.
Richard Laager <rlaager@wiktel.com>
parents: 29433
diff changeset
2255 return g_list_reverse(types);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2256 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2257
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2258 static void
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
2259 jabber_password_change_result_cb(JabberStream *js, const char *from,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
2260 JabberIqType type, const char *id,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
2261 xmlnode *packet, gpointer data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2262 {
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 26464
diff changeset
2263 if (type == JABBER_IQ_RESULT) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2264 purple_notify_info(js->gc, _("Password Changed"), _("Password Changed"),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2265 _("Your password has been changed."));
21058
647b841ea945 This patch prevents changing the saved account password for XMPP accounts
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 21000
diff changeset
2266
647b841ea945 This patch prevents changing the saved account password for XMPP accounts
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 21000
diff changeset
2267 purple_account_set_password(js->gc->account, (char *)data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2268 } else {
20814
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
2269 char *msg = jabber_parse_error(js, packet, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2270
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2271 purple_notify_error(js->gc, _("Error changing password"),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2272 _("Error changing password"), msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2273 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2274 }
21058
647b841ea945 This patch prevents changing the saved account password for XMPP accounts
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 21000
diff changeset
2275
647b841ea945 This patch prevents changing the saved account password for XMPP accounts
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 21000
diff changeset
2276 g_free(data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2277 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2278
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2279 static void jabber_password_change_cb(JabberStream *js,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2280 PurpleRequestFields *fields)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2281 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2282 const char *p1, *p2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2283 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2284 xmlnode *query, *y;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2285
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2286 p1 = purple_request_fields_get_string(fields, "password1");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2287 p2 = purple_request_fields_get_string(fields, "password2");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2288
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2289 if(strcmp(p1, p2)) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2290 purple_notify_error(js->gc, NULL, _("New passwords do not match."), NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2291 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2292 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2293
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2294 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2295
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2296 xmlnode_set_attrib(iq->node, "to", js->user->domain);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2297
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2298 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2299
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2300 y = xmlnode_new_child(query, "username");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2301 xmlnode_insert_data(y, js->user->node, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2302 y = xmlnode_new_child(query, "password");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2303 xmlnode_insert_data(y, p1, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2304
21058
647b841ea945 This patch prevents changing the saved account password for XMPP accounts
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 21000
diff changeset
2305 jabber_iq_set_callback(iq, jabber_password_change_result_cb, g_strdup(p1));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2306
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2307 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2308 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2309
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2310 static void jabber_password_change(PurplePluginAction *action)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2311 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2312
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2313 PurpleConnection *gc = (PurpleConnection *) action->context;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2314 JabberStream *js = gc->proto_data;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2315 PurpleRequestFields *fields;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2316 PurpleRequestFieldGroup *group;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2317 PurpleRequestField *field;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2318
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2319 fields = purple_request_fields_new();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2320 group = purple_request_field_group_new(NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2321 purple_request_fields_add_group(fields, group);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2322
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2323 field = purple_request_field_string_new("password1", _("Password"),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2324 "", FALSE);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2325 purple_request_field_string_set_masked(field, TRUE);
18323
e3df2f61d03d Make password fileds in Jabber's Change Password dialog required. Fixes #1907
Sean Egan <seanegan@gmail.com>
parents: 18237
diff changeset
2326 purple_request_field_set_required(field, TRUE);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2327 purple_request_field_group_add_field(group, field);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2328
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2329 field = purple_request_field_string_new("password2", _("Password (again)"),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2330 "", FALSE);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2331 purple_request_field_string_set_masked(field, TRUE);
18323
e3df2f61d03d Make password fileds in Jabber's Change Password dialog required. Fixes #1907
Sean Egan <seanegan@gmail.com>
parents: 18237
diff changeset
2332 purple_request_field_set_required(field, TRUE);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2333 purple_request_field_group_add_field(group, field);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2334
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
2335 purple_request_fields(js->gc, _("Change XMPP Password"),
16904
56042b2f8b64 s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@wiktel.com>
parents: 16811
diff changeset
2336 _("Change XMPP Password"), _("Please enter your new password"),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2337 fields, _("OK"), G_CALLBACK(jabber_password_change_cb),
16439
08db93bbd798 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 <evan.s@dreskin.net>
parents: 16240
diff changeset
2338 _("Cancel"), NULL,
19999
da29f5c7dc1a 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 <daniel.atallah@gmail.com>
parents: 19723
diff changeset
2339 purple_connection_get_account(gc), NULL, NULL,
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
2340 js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2341 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2342
16240
547c76fe2e7a 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@gmail.com>
parents: 16068
diff changeset
2343 GList *jabber_actions(PurplePlugin *plugin, gpointer context)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2344 {
17848
5fc8a8a25008 Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents: 17846
diff changeset
2345 PurpleConnection *gc = (PurpleConnection *) context;
5fc8a8a25008 Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents: 17846
diff changeset
2346 JabberStream *js = gc->proto_data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2347 GList *m = NULL;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2348 PurplePluginAction *act;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2349
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2350 act = purple_plugin_action_new(_("Set User Info..."),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2351 jabber_setup_set_info);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2352 m = g_list_append(m, act);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2353
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2354 /* if (js->protocol_options & CHANGE_PASSWORD) { */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2355 act = purple_plugin_action_new(_("Change Password..."),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2356 jabber_password_change);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2357 m = g_list_append(m, act);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2358 /* } */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2359
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2360 act = purple_plugin_action_new(_("Search for Users..."),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2361 jabber_user_search_begin);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2362 m = g_list_append(m, act);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2363
17849
e49b259fc7dd PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17848
diff changeset
2364 purple_debug_info("jabber", "jabber_actions: have pep: %s\n", js->pep?"YES":"NO");
e49b259fc7dd PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17848
diff changeset
2365
17848
5fc8a8a25008 Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents: 17846
diff changeset
2366 if(js->pep)
5fc8a8a25008 Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents: 17846
diff changeset
2367 jabber_pep_init_actions(&m);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
2368
17883
9a19c46adf66 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 <pidgin@monitzer.com>
parents: 17881
diff changeset
2369 if(js->commands)
9a19c46adf66 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 <pidgin@monitzer.com>
parents: 17881
diff changeset
2370 jabber_adhoc_init_server_commands(js, &m);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2371
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2372 return m;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2373 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2374
16240
547c76fe2e7a 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@gmail.com>
parents: 16068
diff changeset
2375 PurpleChat *jabber_find_blist_chat(PurpleAccount *account, const char *name)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2376 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2377 PurpleBlistNode *gnode, *cnode;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2378 JabberID *jid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2379
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2380 if(!(jid = jabber_id_new(name)))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2381 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2382
25798
aa876d48b5b2 Some more struct hiding.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25141
diff changeset
2383 for(gnode = purple_blist_get_root(); gnode;
aa876d48b5b2 Some more struct hiding.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25141
diff changeset
2384 gnode = purple_blist_node_get_sibling_next(gnode)) {
aa876d48b5b2 Some more struct hiding.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25141
diff changeset
2385 for(cnode = purple_blist_node_get_first_child(gnode);
aa876d48b5b2 Some more struct hiding.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25141
diff changeset
2386 cnode;
aa876d48b5b2 Some more struct hiding.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25141
diff changeset
2387 cnode = purple_blist_node_get_sibling_next(cnode)) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2388 PurpleChat *chat = (PurpleChat*)cnode;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2389 const char *room, *server;
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
2390 GHashTable *components;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2391 if(!PURPLE_BLIST_NODE_IS_CHAT(cnode))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2392 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2393
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
2394 if (purple_chat_get_account(chat) != account)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2395 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2396
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
2397 components = purple_chat_get_components(chat);
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
2398 if(!(room = g_hash_table_lookup(components, "room")))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2399 continue;
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24058
diff changeset
2400 if(!(server = g_hash_table_lookup(components, "server")))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2401 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2402
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2403 if(jid->node && jid->domain &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2404 !g_utf8_collate(room, jid->node) && !g_utf8_collate(server, jid->domain)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2405 jabber_id_free(jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2406 return chat;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2407 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2408 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2409 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2410 jabber_id_free(jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2411 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2412 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2413
16240
547c76fe2e7a 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@gmail.com>
parents: 16068
diff changeset
2414 void jabber_convo_closed(PurpleConnection *gc, const char *who)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2415 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2416 JabberStream *js = gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2417 JabberID *jid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2418 JabberBuddy *jb;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2419 JabberBuddyResource *jbr;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2420
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2421 if(!(jid = jabber_id_new(who)))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2422 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2423
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2424 if((jb = jabber_buddy_find(js, who, TRUE)) &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2425 (jbr = jabber_buddy_find_resource(jb, jid->resource))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2426 if(jbr->thread_id) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2427 g_free(jbr->thread_id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2428 jbr->thread_id = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2429 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2430 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2431
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2432 jabber_id_free(jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2433 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2434
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2435
20814
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
2436 char *jabber_parse_error(JabberStream *js,
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
2437 xmlnode *packet,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 21355
diff changeset
2438 PurpleConnectionError *reason)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2439 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2440 xmlnode *error;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2441 const char *code = NULL, *text = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2442 const char *xmlns = xmlnode_get_namespace(packet);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2443 char *cdata = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2444
20814
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
2445 #define SET_REASON(x) \
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
2446 if(reason != NULL) { *reason = x; }
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
2447
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2448 if((error = xmlnode_get_child(packet, "error"))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2449 cdata = xmlnode_get_data(error);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2450 code = xmlnode_get_attrib(error, "code");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2451
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2452 /* Stanza errors */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2453 if(xmlnode_get_child(error, "bad-request")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2454 text = _("Bad Request");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2455 } else if(xmlnode_get_child(error, "conflict")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2456 text = _("Conflict");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2457 } else if(xmlnode_get_child(error, "feature-not-implemented")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2458 text = _("Feature Not Implemented");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2459 } else if(xmlnode_get_child(error, "forbidden")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2460 text = _("Forbidden");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2461 } else if(xmlnode_get_child(error, "gone")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2462 text = _("Gone");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2463 } else if(xmlnode_get_child(error, "internal-server-error")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2464 text = _("Internal Server Error");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2465 } else if(xmlnode_get_child(error, "item-not-found")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2466 text = _("Item Not Found");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2467 } else if(xmlnode_get_child(error, "jid-malformed")) {
16904
56042b2f8b64 s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@wiktel.com>
parents: 16811
diff changeset
2468 text = _("Malformed XMPP ID");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2469 } else if(xmlnode_get_child(error, "not-acceptable")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2470 text = _("Not Acceptable");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2471 } else if(xmlnode_get_child(error, "not-allowed")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2472 text = _("Not Allowed");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2473 } else if(xmlnode_get_child(error, "not-authorized")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2474 text = _("Not Authorized");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2475 } else if(xmlnode_get_child(error, "payment-required")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2476 text = _("Payment Required");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2477 } else if(xmlnode_get_child(error, "recipient-unavailable")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2478 text = _("Recipient Unavailable");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2479 } else if(xmlnode_get_child(error, "redirect")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2480 /* XXX */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2481 } else if(xmlnode_get_child(error, "registration-required")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2482 text = _("Registration Required");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2483 } else if(xmlnode_get_child(error, "remote-server-not-found")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2484 text = _("Remote Server Not Found");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2485 } else if(xmlnode_get_child(error, "remote-server-timeout")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2486 text = _("Remote Server Timeout");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2487 } else if(xmlnode_get_child(error, "resource-constraint")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2488 text = _("Server Overloaded");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2489 } else if(xmlnode_get_child(error, "service-unavailable")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2490 text = _("Service Unavailable");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2491 } else if(xmlnode_get_child(error, "subscription-required")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2492 text = _("Subscription Required");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2493 } else if(xmlnode_get_child(error, "unexpected-request")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2494 text = _("Unexpected Request");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2495 } else if(xmlnode_get_child(error, "undefined-condition")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2496 text = _("Unknown Error");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2497 }
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
2498 } else if(xmlns && !strcmp(xmlns, NS_XMPP_SASL)) {
20814
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
2499 /* Most common reason can be the default */
21363
b4833db5eed0 Having read the XMPP SASL specification, these errors seem more accurate.
Will Thompson <will.thompson@collabora.co.uk>
parents: 21360
diff changeset
2500 SET_REASON(PURPLE_CONNECTION_ERROR_NETWORK_ERROR);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2501 if(xmlnode_get_child(packet, "aborted")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2502 text = _("Authorization Aborted");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2503 } else if(xmlnode_get_child(packet, "incorrect-encoding")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2504 text = _("Incorrect encoding in authorization");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2505 } else if(xmlnode_get_child(packet, "invalid-authzid")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2506 text = _("Invalid authzid");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2507 } else if(xmlnode_get_child(packet, "invalid-mechanism")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2508 text = _("Invalid Authorization Mechanism");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2509 } else if(xmlnode_get_child(packet, "mechanism-too-weak")) {
21363
b4833db5eed0 Having read the XMPP SASL specification, these errors seem more accurate.
Will Thompson <will.thompson@collabora.co.uk>
parents: 21360
diff changeset
2510 SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2511 text = _("Authorization mechanism too weak");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2512 } else if(xmlnode_get_child(packet, "not-authorized")) {
21363
b4833db5eed0 Having read the XMPP SASL specification, these errors seem more accurate.
Will Thompson <will.thompson@collabora.co.uk>
parents: 21360
diff changeset
2513 SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED);
19999
da29f5c7dc1a 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 <daniel.atallah@gmail.com>
parents: 19723
diff changeset
2514 /* Clear the pasword if it isn't being saved */
da29f5c7dc1a 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 <daniel.atallah@gmail.com>
parents: 19723
diff changeset
2515 if (!purple_account_get_remember_password(js->gc->account))
da29f5c7dc1a 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 <daniel.atallah@gmail.com>
parents: 19723
diff changeset
2516 purple_account_set_password(js->gc->account, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2517 text = _("Not Authorized");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2518 } else if(xmlnode_get_child(packet, "temporary-auth-failure")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2519 text = _("Temporary Authentication Failure");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2520 } else {
21363
b4833db5eed0 Having read the XMPP SASL specification, these errors seem more accurate.
Will Thompson <will.thompson@collabora.co.uk>
parents: 21360
diff changeset
2521 SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2522 text = _("Authentication Failure");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2523 }
15916
4be5d38ee117 Correctly handle the Jabber disconnection error for signing onto the
Mark Doliner <mark@kingant.net>
parents: 15914
diff changeset
2524 } else if(!strcmp(packet->name, "stream:error") ||
20851
4888d00c50f0 Make sure that the xmlns isn't null before dereferencing it to fix CID 320.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20740
diff changeset
2525 (!strcmp(packet->name, "error") && xmlns &&
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
2526 !strcmp(xmlns, NS_XMPP_STREAMS))) {
20814
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
2527 /* Most common reason as default: */
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 21355
diff changeset
2528 SET_REASON(PURPLE_CONNECTION_ERROR_NETWORK_ERROR);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2529 if(xmlnode_get_child(packet, "bad-format")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2530 text = _("Bad Format");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2531 } else if(xmlnode_get_child(packet, "bad-namespace-prefix")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2532 text = _("Bad Namespace Prefix");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2533 } else if(xmlnode_get_child(packet, "conflict")) {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 21355
diff changeset
2534 SET_REASON(PURPLE_CONNECTION_ERROR_NAME_IN_USE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2535 text = _("Resource Conflict");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2536 } else if(xmlnode_get_child(packet, "connection-timeout")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2537 text = _("Connection Timeout");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2538 } else if(xmlnode_get_child(packet, "host-gone")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2539 text = _("Host Gone");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2540 } else if(xmlnode_get_child(packet, "host-unknown")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2541 text = _("Host Unknown");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2542 } else if(xmlnode_get_child(packet, "improper-addressing")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2543 text = _("Improper Addressing");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2544 } else if(xmlnode_get_child(packet, "internal-server-error")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2545 text = _("Internal Server Error");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2546 } else if(xmlnode_get_child(packet, "invalid-id")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2547 text = _("Invalid ID");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2548 } else if(xmlnode_get_child(packet, "invalid-namespace")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2549 text = _("Invalid Namespace");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2550 } else if(xmlnode_get_child(packet, "invalid-xml")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2551 text = _("Invalid XML");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2552 } else if(xmlnode_get_child(packet, "nonmatching-hosts")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2553 text = _("Non-matching Hosts");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2554 } else if(xmlnode_get_child(packet, "not-authorized")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2555 text = _("Not Authorized");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2556 } else if(xmlnode_get_child(packet, "policy-violation")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2557 text = _("Policy Violation");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2558 } else if(xmlnode_get_child(packet, "remote-connection-failed")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2559 text = _("Remote Connection Failed");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2560 } else if(xmlnode_get_child(packet, "resource-constraint")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2561 text = _("Resource Constraint");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2562 } else if(xmlnode_get_child(packet, "restricted-xml")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2563 text = _("Restricted XML");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2564 } else if(xmlnode_get_child(packet, "see-other-host")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2565 text = _("See Other Host");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2566 } else if(xmlnode_get_child(packet, "system-shutdown")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2567 text = _("System Shutdown");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2568 } else if(xmlnode_get_child(packet, "undefined-condition")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2569 text = _("Undefined Condition");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2570 } else if(xmlnode_get_child(packet, "unsupported-encoding")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2571 text = _("Unsupported Encoding");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2572 } else if(xmlnode_get_child(packet, "unsupported-stanza-type")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2573 text = _("Unsupported Stanza Type");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2574 } else if(xmlnode_get_child(packet, "unsupported-version")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2575 text = _("Unsupported Version");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2576 } else if(xmlnode_get_child(packet, "xml-not-well-formed")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2577 text = _("XML Not Well Formed");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2578 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2579 text = _("Stream Error");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2580 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2581 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2582
20814
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
2583 #undef SET_REASON
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
2584
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2585 if(text || cdata) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2586 char *ret = g_strdup_printf("%s%s%s", code ? code : "",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2587 code ? ": " : "", text ? text : cdata);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2588 g_free(cdata);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2589 return ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2590 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2591 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2592 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2593 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2594
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2595 static PurpleCmdRet jabber_cmd_chat_config(PurpleConversation *conv,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2596 const char *cmd, char **args, char **error, void *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2597 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2598 JabberChat *chat = jabber_chat_find_by_conv(conv);
18711
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2599
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2600 if (!chat)
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2601 return PURPLE_CMD_RET_FAILED;
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2602
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2603 jabber_chat_request_room_configure(chat);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2604 return PURPLE_CMD_RET_OK;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2605 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2606
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2607 static PurpleCmdRet jabber_cmd_chat_register(PurpleConversation *conv,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2608 const char *cmd, char **args, char **error, void *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2609 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2610 JabberChat *chat = jabber_chat_find_by_conv(conv);
18711
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2611
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2612 if (!chat)
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2613 return PURPLE_CMD_RET_FAILED;
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2614
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2615 jabber_chat_register(chat);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2616 return PURPLE_CMD_RET_OK;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2617 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2618
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2619 static PurpleCmdRet jabber_cmd_chat_topic(PurpleConversation *conv,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2620 const char *cmd, char **args, char **error, void *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2621 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2622 JabberChat *chat = jabber_chat_find_by_conv(conv);
18711
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2623
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2624 if (!chat)
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2625 return PURPLE_CMD_RET_FAILED;
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2626
26684
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2627 if (args && args[0] && *args[0])
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2628 jabber_chat_change_topic(chat, args[0]);
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2629 else {
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2630 const char *cur = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(conv));
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2631 char *buf, *tmp, *tmp2;
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2632
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2633 if (cur) {
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2634 tmp = g_markup_escape_text(cur, -1);
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2635 tmp2 = purple_markup_linkify(tmp);
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2636 buf = g_strdup_printf(_("current topic is: %s"), tmp2);
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2637 g_free(tmp);
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2638 g_free(tmp2);
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2639 } else
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2640 buf = g_strdup(_("No topic is set"));
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2641 purple_conv_chat_write(PURPLE_CONV_CHAT(conv), "", buf,
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2642 PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2643 g_free(buf);
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2644 }
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
2645
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2646 return PURPLE_CMD_RET_OK;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2647 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2648
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2649 static PurpleCmdRet jabber_cmd_chat_nick(PurpleConversation *conv,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2650 const char *cmd, char **args, char **error, void *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2651 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2652 JabberChat *chat = jabber_chat_find_by_conv(conv);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2653
18711
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2654 if(!chat || !args || !args[0])
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2655 return PURPLE_CMD_RET_FAILED;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2656
28421
a335d1bab20e jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents: 28396
diff changeset
2657 if (!jabber_resourceprep_validate(args[0])) {
a335d1bab20e jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents: 28396
diff changeset
2658 *error = g_strdup(_("Invalid nickname"));
a335d1bab20e jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents: 28396
diff changeset
2659 return PURPLE_CMD_RET_FAILED;
a335d1bab20e jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents: 28396
diff changeset
2660 }
a335d1bab20e jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents: 28396
diff changeset
2661
a335d1bab20e jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents: 28396
diff changeset
2662 if (jabber_chat_change_nick(chat, args[0]))
a335d1bab20e jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents: 28396
diff changeset
2663 return PURPLE_CMD_RET_OK;
a335d1bab20e jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents: 28396
diff changeset
2664 else
a335d1bab20e jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents: 28396
diff changeset
2665 return PURPLE_CMD_RET_FAILED;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2666 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2667
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2668 static PurpleCmdRet jabber_cmd_chat_part(PurpleConversation *conv,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2669 const char *cmd, char **args, char **error, void *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2670 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2671 JabberChat *chat = jabber_chat_find_by_conv(conv);
18711
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2672
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2673 if (!chat)
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2674 return PURPLE_CMD_RET_FAILED;
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2675
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2676 jabber_chat_part(chat, args ? args[0] : NULL);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2677 return PURPLE_CMD_RET_OK;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2678 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2679
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2680 static PurpleCmdRet jabber_cmd_chat_ban(PurpleConversation *conv,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2681 const char *cmd, char **args, char **error, void *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2682 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2683 JabberChat *chat = jabber_chat_find_by_conv(conv);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2684
18711
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2685 if(!chat || !args || !args[0])
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2686 return PURPLE_CMD_RET_FAILED;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2687
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2688 if(!jabber_chat_ban_user(chat, args[0], args[1])) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2689 *error = g_strdup_printf(_("Unable to ban user %s"), args[0]);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2690 return PURPLE_CMD_RET_FAILED;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2691 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2692
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2693 return PURPLE_CMD_RET_OK;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2694 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2695
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2696 static PurpleCmdRet jabber_cmd_chat_affiliate(PurpleConversation *conv,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2697 const char *cmd, char **args, char **error, void *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2698 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2699 JabberChat *chat = jabber_chat_find_by_conv(conv);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2700
26802
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2701 if (!chat || !args || !args[0])
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2702 return PURPLE_CMD_RET_FAILED;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2703
26802
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2704 if (strcmp(args[0], "owner") != 0 &&
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2705 strcmp(args[0], "admin") != 0 &&
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2706 strcmp(args[0], "member") != 0 &&
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2707 strcmp(args[0], "outcast") != 0 &&
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2708 strcmp(args[0], "none") != 0) {
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2709 *error = g_strdup_printf(_("Unknown affiliation: \"%s\""), args[0]);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2710 return PURPLE_CMD_RET_FAILED;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2711 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2712
26802
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2713 if (args[1]) {
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2714 int i;
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2715 char **nicks = g_strsplit(args[1], " ", -1);
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2716
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2717 for (i = 0; nicks[i]; ++i)
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2718 if (!jabber_chat_affiliate_user(chat, nicks[i], args[0])) {
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2719 *error = g_strdup_printf(_("Unable to affiliate user %s as \"%s\""), nicks[i], args[0]);
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2720 g_strfreev(nicks);
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2721 return PURPLE_CMD_RET_FAILED;
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2722 }
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2723
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2724 g_strfreev(nicks);
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2725 } else {
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2726 jabber_chat_affiliation_list(chat, args[0]);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2727 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2728
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2729 return PURPLE_CMD_RET_OK;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2730 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2731
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2732 static PurpleCmdRet jabber_cmd_chat_role(PurpleConversation *conv,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2733 const char *cmd, char **args, char **error, void *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2734 {
18855
28a7c9dbbc2b Fix uninitialized variable access.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18711
diff changeset
2735 JabberChat *chat = jabber_chat_find_by_conv(conv);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2736
26802
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2737 if (!chat || !args || !args[0])
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2738 return PURPLE_CMD_RET_FAILED;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2739
26802
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2740 if (strcmp(args[0], "moderator") != 0 &&
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2741 strcmp(args[0], "participant") != 0 &&
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2742 strcmp(args[0], "visitor") != 0 &&
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2743 strcmp(args[0], "none") != 0) {
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2744 *error = g_strdup_printf(_("Unknown role: \"%s\""), args[0]);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2745 return PURPLE_CMD_RET_FAILED;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2746 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2747
26802
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2748 if (args[1]) {
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2749 int i;
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2750 char **nicks = g_strsplit(args[1], " ", -1);
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2751
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2752 for (i = 0; nicks[i]; i++)
29070
c8b407fec879 jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
Paul Aurich <paul@darkrain42.org>
parents: 29068
diff changeset
2753 if (!jabber_chat_role_user(chat, nicks[i], args[0], NULL)) {
26802
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2754 *error = g_strdup_printf(_("Unable to set role \"%s\" for user: %s"),
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2755 args[0], nicks[i]);
29068
403a53ff9aa4 jabber: Possible leaks--;
Paul Aurich <paul@darkrain42.org>
parents: 29047
diff changeset
2756 g_strfreev(nicks);
26802
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2757 return PURPLE_CMD_RET_FAILED;
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2758 }
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2759
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2760 g_strfreev(nicks);
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2761 } else {
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
2762 jabber_chat_role_list(chat, args[0]);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2763 }
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2764 return PURPLE_CMD_RET_OK;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2765 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2766
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2767 static PurpleCmdRet jabber_cmd_chat_invite(PurpleConversation *conv,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2768 const char *cmd, char **args, char **error, void *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2769 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2770 if(!args || !args[0])
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2771 return PURPLE_CMD_RET_FAILED;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2772
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2773 jabber_chat_invite(purple_conversation_get_gc(conv),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2774 purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), args[1] ? args[1] : "",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2775 args[0]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2776
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2777 return PURPLE_CMD_RET_OK;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2778 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2779
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2780 static PurpleCmdRet jabber_cmd_chat_join(PurpleConversation *conv,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2781 const char *cmd, char **args, char **error, void *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2782 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2783 JabberChat *chat = jabber_chat_find_by_conv(conv);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2784 GHashTable *components;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2785
18711
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2786 if(!chat || !args || !args[0])
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2787 return PURPLE_CMD_RET_FAILED;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2788
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2789 components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2790
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2791 g_hash_table_replace(components, "room", args[0]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2792 g_hash_table_replace(components, "server", chat->server);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2793 g_hash_table_replace(components, "handle", chat->handle);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2794 if(args[1])
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2795 g_hash_table_replace(components, "password", args[1]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2796
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2797 jabber_chat_join(purple_conversation_get_gc(conv), components);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2798
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2799 g_hash_table_destroy(components);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2800 return PURPLE_CMD_RET_OK;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2801 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2802
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2803 static PurpleCmdRet jabber_cmd_chat_kick(PurpleConversation *conv,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2804 const char *cmd, char **args, char **error, void *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2805 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2806 JabberChat *chat = jabber_chat_find_by_conv(conv);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2807
18711
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2808 if(!chat || !args || !args[0])
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2809 return PURPLE_CMD_RET_FAILED;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2810
29070
c8b407fec879 jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
Paul Aurich <paul@darkrain42.org>
parents: 29068
diff changeset
2811 if(!jabber_chat_role_user(chat, args[0], "none", args[1])) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2812 *error = g_strdup_printf(_("Unable to kick user %s"), args[0]);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2813 return PURPLE_CMD_RET_FAILED;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2814 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2815
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2816 return PURPLE_CMD_RET_OK;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2817 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2818
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2819 static PurpleCmdRet jabber_cmd_chat_msg(PurpleConversation *conv,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2820 const char *cmd, char **args, char **error, void *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2821 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2822 JabberChat *chat = jabber_chat_find_by_conv(conv);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2823 char *who;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2824
18711
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2825 if (!chat)
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2826 return PURPLE_CMD_RET_FAILED;
259f8635eeff Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <mark@kingant.net>
parents: 18323
diff changeset
2827
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2828 who = g_strdup_printf("%s@%s/%s", chat->room, chat->server, args[0]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2829
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2830 jabber_message_send_im(purple_conversation_get_gc(conv), who, args[1], 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2831
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2832 g_free(who);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2833 return PURPLE_CMD_RET_OK;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2834 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2835
17835
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 17834
diff changeset
2836 static PurpleCmdRet jabber_cmd_ping(PurpleConversation *conv,
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 17834
diff changeset
2837 const char *cmd, char **args, char **error, void *data)
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 17834
diff changeset
2838 {
25980
d24b476cc60f Fix merge (i.e. reapply my changes here).
Paul Aurich <paul@darkrain42.org>
parents: 25979
diff changeset
2839 PurpleAccount *account;
d24b476cc60f Fix merge (i.e. reapply my changes here).
Paul Aurich <paul@darkrain42.org>
parents: 25979
diff changeset
2840 PurpleConnection *pc;
d24b476cc60f Fix merge (i.e. reapply my changes here).
Paul Aurich <paul@darkrain42.org>
parents: 25979
diff changeset
2841
17835
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 17834
diff changeset
2842 if(!args || !args[0])
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 17834
diff changeset
2843 return PURPLE_CMD_RET_FAILED;
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 17834
diff changeset
2844
25980
d24b476cc60f Fix merge (i.e. reapply my changes here).
Paul Aurich <paul@darkrain42.org>
parents: 25979
diff changeset
2845 account = purple_conversation_get_account(conv);
d24b476cc60f Fix merge (i.e. reapply my changes here).
Paul Aurich <paul@darkrain42.org>
parents: 25979
diff changeset
2846 pc = purple_account_get_connection(account);
d24b476cc60f Fix merge (i.e. reapply my changes here).
Paul Aurich <paul@darkrain42.org>
parents: 25979
diff changeset
2847
d24b476cc60f Fix merge (i.e. reapply my changes here).
Paul Aurich <paul@darkrain42.org>
parents: 25979
diff changeset
2848 if(!jabber_ping_jid(purple_connection_get_protocol_data(pc), args[0])) {
17835
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 17834
diff changeset
2849 *error = g_strdup_printf(_("Unable to ping user %s"), args[0]);
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 17834
diff changeset
2850 return PURPLE_CMD_RET_FAILED;
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 17834
diff changeset
2851 }
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 17834
diff changeset
2852
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 17834
diff changeset
2853 return PURPLE_CMD_RET_OK;
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 17834
diff changeset
2854 }
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 17834
diff changeset
2855
20852
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2856 static gboolean _jabber_send_buzz(JabberStream *js, const char *username, char **error) {
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2857
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2858 JabberBuddy *jb;
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2859 JabberBuddyResource *jbr;
25136
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2860 PurpleConnection *gc = js->gc;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
2861 PurpleBuddy *buddy =
25708
3f4bedafc86e Print alias (if known) in some error/info messages when failing to buzz
Marcus Lundblad <ml@update.uu.se>
parents: 25706
diff changeset
2862 purple_find_buddy(purple_connection_get_account(gc), username);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
2863 const gchar *alias =
25708
3f4bedafc86e Print alias (if known) in some error/info messages when failing to buzz
Marcus Lundblad <ml@update.uu.se>
parents: 25706
diff changeset
2864 buddy ? purple_buddy_get_contact_alias(buddy) : username;
20852
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2865
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2866 if(!username)
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2867 return FALSE;
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2868
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2869 jb = jabber_buddy_find(js, username, FALSE);
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2870 if(!jb) {
25708
3f4bedafc86e Print alias (if known) in some error/info messages when failing to buzz
Marcus Lundblad <ml@update.uu.se>
parents: 25706
diff changeset
2871 *error = g_strdup_printf(_("Unable to buzz, because there is nothing "
3f4bedafc86e Print alias (if known) in some error/info messages when failing to buzz
Marcus Lundblad <ml@update.uu.se>
parents: 25706
diff changeset
2872 "known about %s."), alias);
20852
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2873 return FALSE;
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2874 }
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2875
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2876 jbr = jabber_buddy_find_resource(jb, NULL);
25136
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2877 if (!jbr) {
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
2878 *error = g_strdup_printf(_("Unable to buzz, because %s might be offline."),
25708
3f4bedafc86e Print alias (if known) in some error/info messages when failing to buzz
Marcus Lundblad <ml@update.uu.se>
parents: 25706
diff changeset
2879 alias);
20852
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2880 return FALSE;
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2881 }
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2882
28645
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28592
diff changeset
2883 if (jabber_resource_has_capability(jbr, NS_ATTENTION)) {
25136
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2884 xmlnode *buzz, *msg = xmlnode_new("message");
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2885 gchar *to;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
2886
25136
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2887 to = g_strdup_printf("%s/%s", username, jbr->name);
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2888 xmlnode_set_attrib(msg, "to", to);
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2889 g_free(to);
20852
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2890
25136
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2891 /* avoid offline storage */
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2892 xmlnode_set_attrib(msg, "type", "headline");
20852
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2893
25136
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2894 buzz = xmlnode_new_child(msg, "attention");
28645
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28592
diff changeset
2895 xmlnode_set_namespace(buzz, NS_ATTENTION);
20852
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2896
25136
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2897 jabber_send(js, msg);
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2898 xmlnode_free(msg);
20852
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2899
25136
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2900 return TRUE;
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2901 } else {
25708
3f4bedafc86e Print alias (if known) in some error/info messages when failing to buzz
Marcus Lundblad <ml@update.uu.se>
parents: 25706
diff changeset
2902 *error = g_strdup_printf(_("Unable to buzz, because %s does "
25981
7ace7bf0bfad Use "does" here sounds more natural to me
Mark Doliner <mark@kingant.net>
parents: 25952
diff changeset
2903 "not support it or does not wish to receive buzzes now."), alias);
25136
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2904 return FALSE;
20852
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2905 }
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2906 }
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2907
17888
cca457b9158b disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents: 17887
diff changeset
2908 static PurpleCmdRet jabber_cmd_buzz(PurpleConversation *conv,
cca457b9158b disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents: 17887
diff changeset
2909 const char *cmd, char **args, char **error, void *data)
cca457b9158b disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents: 17887
diff changeset
2910 {
cca457b9158b disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents: 17887
diff changeset
2911 JabberStream *js = conv->account->gc->proto_data;
25136
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2912 const gchar *who;
29278
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2913 gchar *description;
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2914 PurpleBuddy *buddy;
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2915 const char *alias;
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2916 PurpleAttentionType *attn =
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2917 purple_get_attention_type_from_code(conv->account, 0);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
2918
25136
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2919 if (!args || !args[0]) {
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2920 /* use the buddy from conversation, if it's a one-to-one conversation */
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2921 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) {
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2922 who = purple_conversation_get_name(conv);
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2923 } else {
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2924 return PURPLE_CMD_RET_FAILED;
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2925 }
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2926 } else {
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2927 who = args[0];
a64d90cff01f Allow the /buzz command without argument (sends attention to the JID of the
Marcus Lundblad <ml@update.uu.se>
parents: 25133
diff changeset
2928 }
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
2929
29278
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2930 buddy = purple_find_buddy(conv->account, who);
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2931 if (buddy != NULL)
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2932 alias = purple_buddy_get_contact_alias(buddy);
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2933 else
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2934 alias = who;
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2935
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2936 description =
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2937 g_strdup_printf(purple_attention_type_get_outgoing_desc(attn), alias);
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2938 purple_conversation_write(conv, NULL, description,
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2939 PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_SYSTEM, time(NULL));
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2940 g_free(description);
68f6de7d1408 Make it work again after the merge from i.p.p.... :)
Marcus Lundblad <ml@update.uu.se>
parents: 29275
diff changeset
2941 return _jabber_send_buzz(js, who, error) ? PURPLE_CMD_RET_OK : PURPLE_CMD_RET_FAILED;
17888
cca457b9158b disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents: 17887
diff changeset
2942 }
cca457b9158b disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents: 17887
diff changeset
2943
20149
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2944 GList *jabber_attention_types(PurpleAccount *account)
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2945 {
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2946 static GList *types = NULL;
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2947
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2948 if (!types) {
22097
eab7d03edfcb This adds accessor and mutator API for the PurpleAttentionType struct.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22034
diff changeset
2949 types = g_list_append(types, purple_attention_type_new("Buzz", _("Buzz"),
eab7d03edfcb This adds accessor and mutator API for the PurpleAttentionType struct.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22034
diff changeset
2950 _("%s has buzzed you!"), _("Buzzing %s...")));
20149
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2951 }
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2952
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2953 return types;
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2954 }
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2955
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2956 gboolean jabber_send_attention(PurpleConnection *gc, const char *username, guint code)
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2957 {
20852
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2958 JabberStream *js = gc->proto_data;
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2959 gchar *error = NULL;
20149
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2960
20852
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2961 if (!_jabber_send_buzz(js, username, &error)) {
29503
7adebf6acc50 jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <ml@update.uu.se>
parents: 29492
diff changeset
2962 PurpleAccount *account = purple_connection_get_account(gc);
7adebf6acc50 jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <ml@update.uu.se>
parents: 29492
diff changeset
2963 PurpleConversation *conv =
7adebf6acc50 jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <ml@update.uu.se>
parents: 29492
diff changeset
2964 purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, username, account);
20149
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2965 purple_debug_error("jabber", "jabber_send_attention: jabber_cmd_buzz failed with error: %s\n", error ? error : "(NULL)");
29503
7adebf6acc50 jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <ml@update.uu.se>
parents: 29492
diff changeset
2966
7adebf6acc50 jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <ml@update.uu.se>
parents: 29492
diff changeset
2967 if (conv) {
7adebf6acc50 jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <ml@update.uu.se>
parents: 29492
diff changeset
2968 purple_conversation_write(conv, username, error, PURPLE_MESSAGE_ERROR,
7adebf6acc50 jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <ml@update.uu.se>
parents: 29492
diff changeset
2969 time(NULL));
7adebf6acc50 jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <ml@update.uu.se>
parents: 29492
diff changeset
2970 }
7adebf6acc50 jabber: Print an error message to the current conversation when failing to
Marcus Lundblad <ml@update.uu.se>
parents: 29492
diff changeset
2971
20852
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2972 g_free(error);
20149
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2973 return FALSE;
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2974 }
20852
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2975
6cc03752fe59 Fix CID 337, null pointer deref. Also plug a leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20851
diff changeset
2976 return TRUE;
20149
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2977 }
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2978
be2538a92099 Comment a partial implementation of the libpurple attention API for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20076
diff changeset
2979
16240
547c76fe2e7a 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@gmail.com>
parents: 16068
diff changeset
2980 gboolean jabber_offline_message(const PurpleBuddy *buddy)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2981 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2982 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2983 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2984
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
2985 #ifdef USE_VV
26457
20743d9bd62d Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <paul@darkrain42.org>
parents: 26454
diff changeset
2986 gboolean
20743d9bd62d Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <paul@darkrain42.org>
parents: 26454
diff changeset
2987 jabber_audio_enabled(JabberStream *js, const char *namespace)
26453
ecf6fd808d23 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <paul@darkrain42.org>
parents: 26451
diff changeset
2988 {
ecf6fd808d23 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <paul@darkrain42.org>
parents: 26451
diff changeset
2989 PurpleMediaManager *manager = purple_media_manager_get();
ecf6fd808d23 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <paul@darkrain42.org>
parents: 26451
diff changeset
2990 PurpleMediaCaps caps = purple_media_manager_get_ui_caps(manager);
ecf6fd808d23 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <paul@darkrain42.org>
parents: 26451
diff changeset
2991
ecf6fd808d23 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <paul@darkrain42.org>
parents: 26451
diff changeset
2992 return (caps & (PURPLE_MEDIA_CAPS_AUDIO | PURPLE_MEDIA_CAPS_AUDIO_SINGLE_DIRECTION));
ecf6fd808d23 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <paul@darkrain42.org>
parents: 26451
diff changeset
2993 }
ecf6fd808d23 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <paul@darkrain42.org>
parents: 26451
diff changeset
2994
26997
72bcdcb0629f Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26987
diff changeset
2995 gboolean
26457
20743d9bd62d Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <paul@darkrain42.org>
parents: 26454
diff changeset
2996 jabber_video_enabled(JabberStream *js, const char *namespace)
26453
ecf6fd808d23 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <paul@darkrain42.org>
parents: 26451
diff changeset
2997 {
ecf6fd808d23 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <paul@darkrain42.org>
parents: 26451
diff changeset
2998 PurpleMediaManager *manager = purple_media_manager_get();
ecf6fd808d23 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <paul@darkrain42.org>
parents: 26451
diff changeset
2999 PurpleMediaCaps caps = purple_media_manager_get_ui_caps(manager);
ecf6fd808d23 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <paul@darkrain42.org>
parents: 26451
diff changeset
3000
ecf6fd808d23 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <paul@darkrain42.org>
parents: 26451
diff changeset
3001 return (caps & (PURPLE_MEDIA_CAPS_VIDEO | PURPLE_MEDIA_CAPS_VIDEO_SINGLE_DIRECTION));
ecf6fd808d23 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <paul@darkrain42.org>
parents: 26451
diff changeset
3002 }
ecf6fd808d23 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <paul@darkrain42.org>
parents: 26451
diff changeset
3003
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3004 typedef struct {
26524
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3005 PurpleAccount *account;
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3006 gchar *who;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3007 PurpleMediaSessionType type;
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26917
diff changeset
3008
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3009 } JabberMediaRequest;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3010
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3011 static void
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3012 jabber_media_cancel_cb(JabberMediaRequest *request,
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3013 PurpleRequestFields *fields)
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3014 {
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3015 g_free(request->who);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3016 g_free(request);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3017 }
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3018
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3019 static void
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3020 jabber_media_ok_cb(JabberMediaRequest *request, PurpleRequestFields *fields)
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3021 {
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3022 PurpleRequestField *field =
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3023 purple_request_fields_get_field(fields, "resource");
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3024 int selected_id = purple_request_field_choice_get_value(field);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3025 GList *labels = purple_request_field_choice_get_labels(field);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3026 gchar *who = g_strdup_printf("%s/%s", request->who,
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3027 (gchar*)g_list_nth_data(labels, selected_id));
26524
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3028 jabber_initiate_media(request->account, who, request->type);
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3029
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3030 g_free(who);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3031 g_free(request->who);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3032 g_free(request);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3033 }
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3034 #endif
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3035
26365
34eb898478b4 Don't assume a PurpleMedia instance will be created immediately.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26335
diff changeset
3036 gboolean
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26917
diff changeset
3037 jabber_initiate_media(PurpleAccount *account, const char *who,
23869
551a462b346a Changed PurpleMediaStreamType to PurpleMediaSessionType.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23867
diff changeset
3038 PurpleMediaSessionType type)
23787
92e71f6e10d4 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23785
diff changeset
3039 {
26334
6f0200f1e497 Clean up usage of USE_VV in the XMPP protocol.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26279
diff changeset
3040 #ifdef USE_VV
26524
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3041 JabberStream *js = (JabberStream *)
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3042 purple_account_get_connection(account)->proto_data;
25005
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24986
diff changeset
3043 JabberBuddy *jb;
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3044 JabberBuddyResource *jbr = NULL;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3045 char *resource;
25005
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24986
diff changeset
3046
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24986
diff changeset
3047 if (!js) {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24986
diff changeset
3048 purple_debug_error("jabber",
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24986
diff changeset
3049 "jabber_initiate_media: NULL stream\n");
26365
34eb898478b4 Don't assume a PurpleMedia instance will be created immediately.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26335
diff changeset
3050 return FALSE;
25005
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24986
diff changeset
3051 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24986
diff changeset
3052
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3053
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3054 if((resource = jabber_get_resource(who)) != NULL) {
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3055 /* they've specified a resource, no need to ask or
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3056 * default or anything, just do it */
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3057
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3058 jb = jabber_buddy_find(js, who, FALSE);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3059 jbr = jabber_buddy_find_resource(jb, resource);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3060 g_free(resource);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3061
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3062 if (type & PURPLE_MEDIA_AUDIO &&
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3063 !jabber_resource_has_capability(jbr,
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3064 JINGLE_APP_RTP_SUPPORT_AUDIO) &&
28645
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28592
diff changeset
3065 jabber_resource_has_capability(jbr, NS_GOOGLE_VOICE))
26524
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3066 return jabber_google_session_initiate(js, who, type);
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3067 else
26524
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3068 return jingle_rtp_initiate_media(js, who, type);
25005
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24986
diff changeset
3069 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24986
diff changeset
3070
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3071 jb = jabber_buddy_find(js, who, FALSE);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3072
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3073 if(!jb || !jb->resources) {
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3074 /* no resources online, we're trying to initiate with someone
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3075 * whose presence we're not subscribed to, or
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3076 * someone who is offline. Let's inform the user */
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3077 char *msg;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3078
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3079 if(!jb) {
26436
28f1512b0f94 Minor grammatical message fixes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26432
diff changeset
3080 msg = g_strdup_printf(_("Unable to initiate media with %s: invalid JID"), who);
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3081 } else if(jb->subscription & JABBER_SUB_TO) {
26436
28f1512b0f94 Minor grammatical message fixes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26432
diff changeset
3082 msg = g_strdup_printf(_("Unable to initiate media with %s: user is not online"), who);
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3083 } else {
26436
28f1512b0f94 Minor grammatical message fixes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26432
diff changeset
3084 msg = g_strdup_printf(_("Unable to initiate media with %s: not subscribed to user presence"), who);
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3085 }
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3086
26524
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3087 purple_notify_error(account, _("Media Initiation Failed"),
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3088 _("Media Initiation Failed"), msg);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3089 g_free(msg);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3090 return FALSE;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3091 } else if(!jb->resources->next) {
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3092 /* only 1 resource online (probably our most common case)
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3093 * so no need to ask who to initiate with */
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3094 gchar *name;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3095 gboolean result;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3096 jbr = jb->resources->data;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3097 name = g_strdup_printf("%s/%s", who, jbr->name);
26524
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3098 result = jabber_initiate_media(account, name, type);
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3099 g_free(name);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3100 return result;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3101 } else {
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3102 /* we've got multiple resources,
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3103 * we need to pick one to initiate with */
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3104 GList *l;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3105 char *msg;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3106 PurpleRequestFields *fields;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3107 PurpleRequestField *field = purple_request_field_choice_new(
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3108 "resource", _("Resource"), 0);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3109 PurpleRequestFieldGroup *group;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3110 JabberMediaRequest *request;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3111
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3112 for(l = jb->resources; l; l = l->next)
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3113 {
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3114 JabberBuddyResource *ljbr = l->data;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3115 PurpleMediaCaps caps;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3116 gchar *name;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3117 name = g_strdup_printf("%s/%s", who, ljbr->name);
26524
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3118 caps = jabber_get_media_caps(account, name);
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3119 g_free(name);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3120
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3121 if ((type & PURPLE_MEDIA_AUDIO) &&
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3122 (type & PURPLE_MEDIA_VIDEO)) {
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3123 if (caps & PURPLE_MEDIA_CAPS_AUDIO_VIDEO) {
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3124 jbr = ljbr;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3125 purple_request_field_choice_add(
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3126 field, jbr->name);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3127 }
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3128 } else if (type & (PURPLE_MEDIA_AUDIO) &&
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3129 (caps & PURPLE_MEDIA_CAPS_AUDIO)) {
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3130 jbr = ljbr;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3131 purple_request_field_choice_add(
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3132 field, jbr->name);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3133 }else if (type & (PURPLE_MEDIA_VIDEO) &&
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3134 (caps & PURPLE_MEDIA_CAPS_VIDEO)) {
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3135 jbr = ljbr;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3136 purple_request_field_choice_add(
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3137 field, jbr->name);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3138 }
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3139 }
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3140
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3141 if (jbr == NULL) {
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3142 purple_debug_error("jabber",
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3143 "No resources available\n");
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3144 return FALSE;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3145 }
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3146
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3147 if (g_list_length(purple_request_field_choice_get_labels(
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3148 field)) <= 1) {
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3149 gchar *name;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3150 gboolean result;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3151 purple_request_field_destroy(field);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3152 name = g_strdup_printf("%s/%s", who, jbr->name);
26524
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3153 result = jabber_initiate_media(account, name, type);
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3154 g_free(name);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3155 return result;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3156 }
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3157
26436
28f1512b0f94 Minor grammatical message fixes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26432
diff changeset
3158 msg = g_strdup_printf(_("Please select the resource of %s with which you would like to start a media session."), who);
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3159 fields = purple_request_fields_new();
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3160 group = purple_request_field_group_new(NULL);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3161 request = g_new0(JabberMediaRequest, 1);
26524
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3162 request->account = account;
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3163 request->who = g_strdup(who);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3164 request->type = type;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3165
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3166 purple_request_field_group_add_field(group, field);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3167 purple_request_fields_add_group(fields, group);
26524
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3168 purple_request_fields(account, _("Select a Resource"), msg,
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3169 NULL, fields, _("Initiate Media"),
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3170 G_CALLBACK(jabber_media_ok_cb), _("Cancel"),
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3171 G_CALLBACK(jabber_media_cancel_cb),
26524
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3172 account, who, NULL, request);
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3173
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3174 g_free(msg);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3175 return TRUE;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3176 }
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3177 #endif
26365
34eb898478b4 Don't assume a PurpleMedia instance will be created immediately.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26335
diff changeset
3178 return FALSE;
23787
92e71f6e10d4 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23785
diff changeset
3179 }
92e71f6e10d4 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23785
diff changeset
3180
26524
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3181 PurpleMediaCaps jabber_get_media_caps(PurpleAccount *account, const char *who)
23787
92e71f6e10d4 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23785
diff changeset
3182 {
26334
6f0200f1e497 Clean up usage of USE_VV in the XMPP protocol.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26279
diff changeset
3183 #ifdef USE_VV
26524
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3184 JabberStream *js = (JabberStream *)
df9042312063 Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26477
diff changeset
3185 purple_account_get_connection(account)->proto_data;
23815
1f085713c281 Fix crash bug when checking if a contact can do media when logging out.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23814
diff changeset
3186 JabberBuddy *jb;
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3187 JabberBuddyResource *jbr;
29022
9e735d7e2f1d Oops, just realized that caps can be reset in certain situations, and we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29021
diff changeset
3188 PurpleMediaCaps total = PURPLE_MEDIA_CAPS_NONE;
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3189 gchar *resource;
29021
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3190 GList *specific = NULL, *l;
23815
1f085713c281 Fix crash bug when checking if a contact can do media when logging out.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23814
diff changeset
3191
1f085713c281 Fix crash bug when checking if a contact can do media when logging out.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23814
diff changeset
3192 if (!js) {
26418
da651b0f40a1 Demote debug error to info.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26365
diff changeset
3193 purple_debug_info("jabber",
da651b0f40a1 Demote debug error to info.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26365
diff changeset
3194 "jabber_can_do_media: NULL stream\n");
23815
1f085713c281 Fix crash bug when checking if a contact can do media when logging out.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23814
diff changeset
3195 return FALSE;
1f085713c281 Fix crash bug when checking if a contact can do media when logging out.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23814
diff changeset
3196 }
1f085713c281 Fix crash bug when checking if a contact can do media when logging out.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23814
diff changeset
3197
29021
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3198 jb = jabber_buddy_find(js, who, FALSE);
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3199
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3200 if (!jb || !jb->resources) {
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3201 /* no resources online, we're trying to get caps for someone
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3202 * whose presence we're not subscribed to, or
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3203 * someone who is offline. */
29022
9e735d7e2f1d Oops, just realized that caps can be reset in certain situations, and we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29021
diff changeset
3204 return total;
29021
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3205
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3206 } else if ((resource = jabber_get_resource(who)) != NULL) {
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3207 /* they've specified a resource, no need to ask or
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3208 * default or anything, just do it */
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3209 jbr = jabber_buddy_find_resource(jb, resource);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3210 g_free(resource);
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3211
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3212 if (!jbr) {
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3213 purple_debug_error("jabber", "jabber_get_media_caps:"
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3214 " Can't find resource %s\n", who);
29022
9e735d7e2f1d Oops, just realized that caps can be reset in certain situations, and we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29021
diff changeset
3215 return total;
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3216 }
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3217
29021
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3218 l = specific = g_list_prepend(specific, jbr);
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3219
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3220 } else {
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3221 /* we've got multiple resources, combine their caps */
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3222 l = jb->resources;
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3223 }
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3224
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3225 for (; l; l = l->next) {
29022
9e735d7e2f1d Oops, just realized that caps can be reset in certain situations, and we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29021
diff changeset
3226 PurpleMediaCaps caps = PURPLE_MEDIA_CAPS_NONE;
29021
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3227 jbr = l->data;
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3228
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3229 if (jabber_resource_has_capability(jbr,
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3230 JINGLE_APP_RTP_SUPPORT_AUDIO))
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3231 caps |= PURPLE_MEDIA_CAPS_AUDIO_SINGLE_DIRECTION |
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3232 PURPLE_MEDIA_CAPS_AUDIO;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3233 if (jabber_resource_has_capability(jbr,
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3234 JINGLE_APP_RTP_SUPPORT_VIDEO))
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3235 caps |= PURPLE_MEDIA_CAPS_VIDEO_SINGLE_DIRECTION |
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3236 PURPLE_MEDIA_CAPS_VIDEO;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3237 if (caps & PURPLE_MEDIA_CAPS_AUDIO && caps &
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3238 PURPLE_MEDIA_CAPS_VIDEO)
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3239 caps |= PURPLE_MEDIA_CAPS_AUDIO_VIDEO;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3240 if (caps != PURPLE_MEDIA_CAPS_NONE) {
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3241 if (!jabber_resource_has_capability(jbr,
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3242 JINGLE_TRANSPORT_ICEUDP) &&
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3243 !jabber_resource_has_capability(jbr,
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3244 JINGLE_TRANSPORT_RAWUDP)) {
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3245 purple_debug_info("jingle-rtp", "Buddy doesn't "
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3246 "support the same transport types\n");
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3247 caps = PURPLE_MEDIA_CAPS_NONE;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3248 } else
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3249 caps |= PURPLE_MEDIA_CAPS_MODIFY_SESSION |
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3250 PURPLE_MEDIA_CAPS_CHANGE_DIRECTION;
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3251 }
28645
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28592
diff changeset
3252 if (jabber_resource_has_capability(jbr, NS_GOOGLE_VOICE)) {
26432
0adf41b3de79 Add a resource selector when initiating media.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26418
diff changeset
3253 caps |= PURPLE_MEDIA_CAPS_AUDIO;
28645
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28592
diff changeset
3254 if (jabber_resource_has_capability(jbr, NS_GOOGLE_VIDEO))
26997
72bcdcb0629f Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26987
diff changeset
3255 caps |= PURPLE_MEDIA_CAPS_AUDIO_VIDEO;
72bcdcb0629f Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26987
diff changeset
3256 }
29022
9e735d7e2f1d Oops, just realized that caps can be reset in certain situations, and we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29021
diff changeset
3257
9e735d7e2f1d Oops, just realized that caps can be reset in certain situations, and we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29021
diff changeset
3258 total |= caps;
23814
d0ac3c438b71 Check remote JID's capabilities for audio and video XEP support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23812
diff changeset
3259 }
24970
99055b8db16b Choose the transport type according to the responder's caps.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24967
diff changeset
3260
29021
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3261 if (specific) {
7cab6dc6b79c Fix jabber_get_media_caps for buddies with a single resource that has no
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28943
diff changeset
3262 g_list_free(specific);
24970
99055b8db16b Choose the transport type according to the responder's caps.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24967
diff changeset
3263 }
26108
d6e23439b77c Change purple_prpl_can_do_media to purple_prpl_get_media_caps.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26086
diff changeset
3264
29022
9e735d7e2f1d Oops, just realized that caps can be reset in certain situations, and we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29021
diff changeset
3265 return total;
26334
6f0200f1e497 Clean up usage of USE_VV in the XMPP protocol.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26279
diff changeset
3266 #else
6f0200f1e497 Clean up usage of USE_VV in the XMPP protocol.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26279
diff changeset
3267 return PURPLE_MEDIA_CAPS_NONE;
6f0200f1e497 Clean up usage of USE_VV in the XMPP protocol.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26279
diff changeset
3268 #endif
23787
92e71f6e10d4 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23785
diff changeset
3269 }
92e71f6e10d4 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23785
diff changeset
3270
28534
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3271 gboolean jabber_can_receive_file(PurpleConnection *gc, const char *who)
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3272 {
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3273 JabberStream *js = gc->proto_data;
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3274
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3275 if (js) {
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3276 JabberBuddy *jb = jabber_buddy_find(js, who, FALSE);
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3277 GList *iter;
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3278 gboolean has_resources_without_caps = FALSE;
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3279
28592
923681c5406e jabber: don't crash when right-clicking on buddies non on the local roster
Marcus Lundblad <ml@update.uu.se>
parents: 28534
diff changeset
3280 /* if we didn't find a JabberBuddy, we don't have presence for this
923681c5406e jabber: don't crash when right-clicking on buddies non on the local roster
Marcus Lundblad <ml@update.uu.se>
parents: 28534
diff changeset
3281 buddy, let's assume they can receive files, disco should tell us
923681c5406e jabber: don't crash when right-clicking on buddies non on the local roster
Marcus Lundblad <ml@update.uu.se>
parents: 28534
diff changeset
3282 when actually trying */
923681c5406e jabber: don't crash when right-clicking on buddies non on the local roster
Marcus Lundblad <ml@update.uu.se>
parents: 28534
diff changeset
3283 if (jb == NULL)
923681c5406e jabber: don't crash when right-clicking on buddies non on the local roster
Marcus Lundblad <ml@update.uu.se>
parents: 28534
diff changeset
3284 return TRUE;
923681c5406e jabber: don't crash when right-clicking on buddies non on the local roster
Marcus Lundblad <ml@update.uu.se>
parents: 28534
diff changeset
3285
28534
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3286 /* find out if there is any resources without caps */
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3287 for (iter = jb->resources; iter ; iter = g_list_next(iter)) {
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3288 JabberBuddyResource *jbr = (JabberBuddyResource *) iter->data;
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3289
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3290 if (!jabber_resource_know_capabilities(jbr)) {
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3291 has_resources_without_caps = TRUE;
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3292 }
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3293 }
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3294
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3295 if (has_resources_without_caps) {
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3296 /* there is at least one resource which we don't have caps for,
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3297 let's assume they can receive files... */
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3298 return TRUE;
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3299 } else {
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3300 /* we have caps for all the resources, see if at least one has
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3301 right caps */
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3302 for (iter = jb->resources; iter ; iter = g_list_next(iter)) {
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3303 JabberBuddyResource *jbr = (JabberBuddyResource *) iter->data;
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3304
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3305 if (jabber_resource_has_capability(jbr,
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3306 "http://jabber.org/protocol/si/profile/file-transfer")
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3307 && (jabber_resource_has_capability(jbr,
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
3308 NS_BYTESTREAMS)
28645
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28592
diff changeset
3309 || jabber_resource_has_capability(jbr, NS_IBB))) {
28534
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3310 return TRUE;
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3311 }
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3312 }
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3313 return FALSE;
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3314 }
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3315 } else {
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3316 return TRUE;
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3317 }
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3318 }
738cd1adb3cf jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <ml@update.uu.se>
parents: 28517
diff changeset
3319
29556
342ed5917f56 jabber: Fix the type signature of jabber_cmd_mood
Paul Aurich <paul@darkrain42.org>
parents: 29549
diff changeset
3320 static PurpleCmdRet
29549
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3321 jabber_cmd_mood(PurpleConversation *conv,
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3322 const char *cmd, char **args, char **error, void *data)
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3323 {
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3324 JabberStream *js = conv->account->gc->proto_data;
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3325
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3326 if (js->pep) {
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3327 /* if no argument was given, unset mood */
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3328 if (!args | !args[0]) {
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3329 jabber_mood_set(js, NULL, NULL);
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3330 } else if (!args[1]) {
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3331 jabber_mood_set(js, args[0], NULL);
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3332 } else {
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3333 jabber_mood_set(js, args[0], args[1]);
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3334 }
29556
342ed5917f56 jabber: Fix the type signature of jabber_cmd_mood
Paul Aurich <paul@darkrain42.org>
parents: 29549
diff changeset
3335
342ed5917f56 jabber: Fix the type signature of jabber_cmd_mood
Paul Aurich <paul@darkrain42.org>
parents: 29549
diff changeset
3336 return PURPLE_CMD_RET_OK;
29549
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3337 } else {
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3338 /* account does not support PEP, can't set a mood */
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3339 purple_conversation_write(conv, NULL,
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3340 _("Account does not support PEP, can't set mood"),
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3341 PURPLE_MESSAGE_ERROR, time(NULL));
29556
342ed5917f56 jabber: Fix the type signature of jabber_cmd_mood
Paul Aurich <paul@darkrain42.org>
parents: 29549
diff changeset
3342 return PURPLE_CMD_RET_FAILED;
29549
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3343 }
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3344 }
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3345
16240
547c76fe2e7a 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@gmail.com>
parents: 16068
diff changeset
3346 void jabber_register_commands(void)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3347 {
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3348 PurpleCmdId id;
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3349 id = purple_cmd_register("config", "", PURPLE_CMD_P_PRPL,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3350 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3351 "prpl-jabber", jabber_cmd_chat_config,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3352 _("config: Configure a chat room."), NULL);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3353 jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3354
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3355 id = purple_cmd_register("configure", "", PURPLE_CMD_P_PRPL,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3356 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3357 "prpl-jabber", jabber_cmd_chat_config,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3358 _("configure: Configure a chat room."), NULL);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3359 jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3360
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3361 id = purple_cmd_register("nick", "s", PURPLE_CMD_P_PRPL,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3362 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3363 "prpl-jabber", jabber_cmd_chat_nick,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3364 _("nick &lt;new nickname&gt;: Change your nickname."),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3365 NULL);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3366 jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3367
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3368 id = purple_cmd_register("part", "s", PURPLE_CMD_P_PRPL,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3369 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3370 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
28396
4a0d69b9d8a8 jabber: Correct the /part command's help.
Paul Aurich <paul@darkrain42.org>
parents: 28360
diff changeset
3371 jabber_cmd_chat_part, _("part [message]: Leave the room."),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3372 NULL);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3373 jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3374
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3375 id = purple_cmd_register("register", "", PURPLE_CMD_P_PRPL,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3376 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3377 "prpl-jabber", jabber_cmd_chat_register,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3378 _("register: Register with a chat room."), NULL);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3379 jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3380
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3381 /* XXX: there needs to be a core /topic cmd, methinks */
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3382 id = purple_cmd_register("topic", "s", PURPLE_CMD_P_PRPL,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3383 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3384 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3385 jabber_cmd_chat_topic,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3386 _("topic [new topic]: View or change the topic."),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3387 NULL);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3388 jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3389
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3390 id = purple_cmd_register("ban", "ws", PURPLE_CMD_P_PRPL,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3391 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3392 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3393 jabber_cmd_chat_ban,
22619
9a84976c8e76 Correct some help strings for Jabber slash commands
Mark Doliner <mark@kingant.net>
parents: 22459
diff changeset
3394 _("ban &lt;user&gt; [reason]: Ban a user from the room."),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3395 NULL);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3396 jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3397
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3398 id = purple_cmd_register("affiliate", "ws", PURPLE_CMD_P_PRPL,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3399 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3400 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3401 jabber_cmd_chat_affiliate,
26802
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26777
diff changeset
3402 _("affiliate &lt;owner|admin|member|outcast|none&gt; [nick1] [nick2] ...: Get the users with an affiliation or set users' affiliation with the room."),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3403 NULL);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3404 jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3405
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3406 id = purple_cmd_register("role", "ws", PURPLE_CMD_P_PRPL,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3407 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3408 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3409 jabber_cmd_chat_role,
27971
23dda7e57bcf Fix two strings as pointed out on translators@
Paul Aurich <paul@darkrain42.org>
parents: 27969
diff changeset
3410 _("role &lt;moderator|participant|visitor|none&gt; [nick1] [nick2] ...: Get the users with a role or set users' role with the room."),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3411 NULL);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3412 jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3413
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3414 id = purple_cmd_register("invite", "ws", PURPLE_CMD_P_PRPL,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3415 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3416 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3417 jabber_cmd_chat_invite,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3418 _("invite &lt;user&gt; [message]: Invite a user to the room."),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3419 NULL);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3420 jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3421
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3422 id = purple_cmd_register("join", "ws", PURPLE_CMD_P_PRPL,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3423 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3424 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3425 jabber_cmd_chat_join,
22619
9a84976c8e76 Correct some help strings for Jabber slash commands
Mark Doliner <mark@kingant.net>
parents: 22459
diff changeset
3426 _("join: &lt;room&gt; [password]: Join a chat on this server."),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3427 NULL);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3428 jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3429
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3430 id = purple_cmd_register("kick", "ws", PURPLE_CMD_P_PRPL,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3431 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3432 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3433 jabber_cmd_chat_kick,
22619
9a84976c8e76 Correct some help strings for Jabber slash commands
Mark Doliner <mark@kingant.net>
parents: 22459
diff changeset
3434 _("kick &lt;user&gt; [reason]: Kick a user from the room."),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3435 NULL);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3436 jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3437
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3438 id = purple_cmd_register("msg", "ws", PURPLE_CMD_P_PRPL,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
3439 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3440 "prpl-jabber", jabber_cmd_chat_msg,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3441 _("msg &lt;user&gt; &lt;message&gt;: Send a private message to another user."),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3442 NULL);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3443 jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3444
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3445 id = purple_cmd_register("ping", "w", PURPLE_CMD_P_PRPL,
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
3446 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM |
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
3447 PURPLE_CMD_FLAG_PRPL_ONLY,
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
3448 "prpl-jabber", jabber_cmd_ping,
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
3449 _("ping &lt;jid&gt;: Ping a user/component/server."),
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17841
diff changeset
3450 NULL);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3451 jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3452
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3453 id = purple_cmd_register("buzz", "w", PURPLE_CMD_P_PRPL,
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25951
diff changeset
3454 PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PRPL_ONLY |
25137
b3ab1c23cdf6 Register the /buzz command using PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS.
Marcus Lundblad <ml@update.uu.se>
parents: 25136
diff changeset
3455 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS,
17888
cca457b9158b disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents: 17887
diff changeset
3456 "prpl-jabber", jabber_cmd_buzz,
cca457b9158b disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents: 17887
diff changeset
3457 _("buzz: Buzz a user to get their attention"), NULL);
27438
889bf9af9706 The last command registered wasn't added to the list, so was leaking at uninit.
Paul Aurich <paul@darkrain42.org>
parents: 27381
diff changeset
3458 jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
29549
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3459
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3460 id = purple_cmd_register("mood", "ws", PURPLE_CMD_P_PRPL,
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3461 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM |
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3462 PURPLE_CMD_FLAG_PRPL_ONLY | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS,
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3463 "prpl-jabber", jabber_cmd_mood,
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3464 _("mood: Set current user mood"), NULL);
2f73b0a78f4f jabber: Added a /mood command make up for the lost PurplePluginAction to
Marcus Lundblad <ml@update.uu.se>
parents: 29503
diff changeset
3465 jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3466 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3467
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3468 void jabber_unregister_commands(void)
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3469 {
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3470 while (jabber_cmds != NULL) {
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3471 purple_cmd_unregister(GPOINTER_TO_UINT(jabber_cmds->data));
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3472 jabber_cmds = g_slist_delete_link(jabber_cmds, jabber_cmds);
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3473 }
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3474 }
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3475
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3476 /* IPC functions */
25029
2bf9bf49cea8 * adding documentation for IPC function contact_has_feature
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25028
diff changeset
3477
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3478 /**
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3479 * IPC function for determining if a contact supports a certain feature.
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3480 *
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3481 * @param account The PurpleAccount
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3482 * @param jid The full JID of the contact.
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3483 * @param feature The feature's namespace.
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3484 *
25029
2bf9bf49cea8 * adding documentation for IPC function contact_has_feature
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25028
diff changeset
3485 * @return TRUE if supports feature; else FALSE.
2bf9bf49cea8 * adding documentation for IPC function contact_has_feature
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25028
diff changeset
3486 */
25028
e6f92c0f9770 * adding IPC function 'contact_has_feature'
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25027
diff changeset
3487 static gboolean
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3488 jabber_ipc_contact_has_feature(PurpleAccount *account, const gchar *jid,
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3489 const gchar *feature)
25028
e6f92c0f9770 * adding IPC function 'contact_has_feature'
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25027
diff changeset
3490 {
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3491 PurpleConnection *gc = purple_account_get_connection(account);
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3492 JabberStream *js;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3493 JabberBuddy *jb;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3494 JabberBuddyResource *jbr;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3495 gchar *resource;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3496
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3497 if (!purple_account_is_connected(account))
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3498 return FALSE;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3499 js = gc->proto_data;
25151
504c98a90ef5 constify, ifdef out an old-caps remnant, and rewrite a little
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
3500
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26917
diff changeset
3501 if (!(resource = jabber_get_resource(jid)) ||
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3502 !(jb = jabber_buddy_find(js, jid, FALSE)) ||
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3503 !(jbr = jabber_buddy_find_resource(jb, resource))) {
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3504 g_free(resource);
25151
504c98a90ef5 constify, ifdef out an old-caps remnant, and rewrite a little
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
3505 return FALSE;
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3506 }
25151
504c98a90ef5 constify, ifdef out an old-caps remnant, and rewrite a little
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
3507
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3508 g_free(resource);
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3509
25175
b1b1b75a922e Sprinkle jabber_resource_has_capability in places
Paul Aurich <paul@darkrain42.org>
parents: 25167
diff changeset
3510 return jabber_resource_has_capability(jbr, feature);
25027
45816181b7de * fixing a bug in jabber_caps_compare()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
3511 }
45816181b7de * fixing a bug in jabber_caps_compare()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
3512
25030
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25029
diff changeset
3513 static void
25151
504c98a90ef5 constify, ifdef out an old-caps remnant, and rewrite a little
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
3514 jabber_ipc_add_feature(const gchar *feature)
25030
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25029
diff changeset
3515 {
25151
504c98a90ef5 constify, ifdef out an old-caps remnant, and rewrite a little
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
3516 if (!feature)
504c98a90ef5 constify, ifdef out an old-caps remnant, and rewrite a little
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
3517 return;
25031
3f719eaa7fd1 * IPC work
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25030
diff changeset
3518 jabber_add_feature(feature, 0);
25151
504c98a90ef5 constify, ifdef out an old-caps remnant, and rewrite a little
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
3519
504c98a90ef5 constify, ifdef out an old-caps remnant, and rewrite a little
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
3520 /* send presence with new caps info for all connected accounts */
25032
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25031
diff changeset
3521 jabber_caps_broadcast_change();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3522 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3523
29557
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3524 static void
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3525 jabber_do_init(void)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3526 {
26982
007dff3cb9e4 Fixup after propagating new caps stuff
Marcus Lundblad <ml@update.uu.se>
parents: 26981
diff changeset
3527 GHashTable *ui_info = purple_core_get_ui_info();
27055
2d258a809609 Avoid an assertion when the UI doesn't have a get_ui_info ui_op
Paul Aurich <paul@darkrain42.org>
parents: 27054
diff changeset
3528 const gchar *ui_type;
27517
6b1eb8dbf86e Identify clients in XMPP caps based on the ui_info hash. Closes #9672.
Paul Aurich <paul@darkrain42.org>
parents: 27516
diff changeset
3529 const gchar *type = "pc"; /* default client type, if unknown or
26982
007dff3cb9e4 Fixup after propagating new caps stuff
Marcus Lundblad <ml@update.uu.se>
parents: 26981
diff changeset
3530 unspecified */
27517
6b1eb8dbf86e Identify clients in XMPP caps based on the ui_info hash. Closes #9672.
Paul Aurich <paul@darkrain42.org>
parents: 27516
diff changeset
3531 const gchar *ui_name = NULL;
26982
007dff3cb9e4 Fixup after propagating new caps stuff
Marcus Lundblad <ml@update.uu.se>
parents: 26981
diff changeset
3532
27055
2d258a809609 Avoid an assertion when the UI doesn't have a get_ui_info ui_op
Paul Aurich <paul@darkrain42.org>
parents: 27054
diff changeset
3533 ui_type = ui_info ? g_hash_table_lookup(ui_info, "client_type") : NULL;
26982
007dff3cb9e4 Fixup after propagating new caps stuff
Marcus Lundblad <ml@update.uu.se>
parents: 26981
diff changeset
3534 if (ui_type) {
007dff3cb9e4 Fixup after propagating new caps stuff
Marcus Lundblad <ml@update.uu.se>
parents: 26981
diff changeset
3535 if (strcmp(ui_type, "pc") == 0 ||
007dff3cb9e4 Fixup after propagating new caps stuff
Marcus Lundblad <ml@update.uu.se>
parents: 26981
diff changeset
3536 strcmp(ui_type, "console") == 0 ||
007dff3cb9e4 Fixup after propagating new caps stuff
Marcus Lundblad <ml@update.uu.se>
parents: 26981
diff changeset
3537 strcmp(ui_type, "phone") == 0 ||
007dff3cb9e4 Fixup after propagating new caps stuff
Marcus Lundblad <ml@update.uu.se>
parents: 26981
diff changeset
3538 strcmp(ui_type, "handheld") == 0 ||
007dff3cb9e4 Fixup after propagating new caps stuff
Marcus Lundblad <ml@update.uu.se>
parents: 26981
diff changeset
3539 strcmp(ui_type, "web") == 0 ||
007dff3cb9e4 Fixup after propagating new caps stuff
Marcus Lundblad <ml@update.uu.se>
parents: 26981
diff changeset
3540 strcmp(ui_type, "bot") == 0) {
007dff3cb9e4 Fixup after propagating new caps stuff
Marcus Lundblad <ml@update.uu.se>
parents: 26981
diff changeset
3541 type = ui_type;
007dff3cb9e4 Fixup after propagating new caps stuff
Marcus Lundblad <ml@update.uu.se>
parents: 26981
diff changeset
3542 }
007dff3cb9e4 Fixup after propagating new caps stuff
Marcus Lundblad <ml@update.uu.se>
parents: 26981
diff changeset
3543 }
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
3544
27517
6b1eb8dbf86e Identify clients in XMPP caps based on the ui_info hash. Closes #9672.
Paul Aurich <paul@darkrain42.org>
parents: 27516
diff changeset
3545 if (ui_info)
6b1eb8dbf86e Identify clients in XMPP caps based on the ui_info hash. Closes #9672.
Paul Aurich <paul@darkrain42.org>
parents: 27516
diff changeset
3546 ui_name = g_hash_table_lookup(ui_info, "name");
6b1eb8dbf86e Identify clients in XMPP caps based on the ui_info hash. Closes #9672.
Paul Aurich <paul@darkrain42.org>
parents: 27516
diff changeset
3547 if (ui_name == NULL)
6b1eb8dbf86e Identify clients in XMPP caps based on the ui_info hash. Closes #9672.
Paul Aurich <paul@darkrain42.org>
parents: 27516
diff changeset
3548 ui_name = PACKAGE;
6b1eb8dbf86e Identify clients in XMPP caps based on the ui_info hash. Closes #9672.
Paul Aurich <paul@darkrain42.org>
parents: 27516
diff changeset
3549
6b1eb8dbf86e Identify clients in XMPP caps based on the ui_info hash. Closes #9672.
Paul Aurich <paul@darkrain42.org>
parents: 27516
diff changeset
3550 jabber_add_identity("client", type, NULL, ui_name);
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
3551
25028
e6f92c0f9770 * adding IPC function 'contact_has_feature'
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25027
diff changeset
3552 /* initialize jabber_features list */
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
3553 jabber_add_feature(NS_LAST_ACTIVITY, 0);
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
3554 jabber_add_feature(NS_OOB_IQ_DATA, 0);
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
3555 jabber_add_feature(NS_ENTITY_TIME, 0);
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
3556 jabber_add_feature("jabber:iq:version", 0);
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
3557 jabber_add_feature("jabber:x:conference", 0);
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
3558 jabber_add_feature(NS_BYTESTREAMS, 0);
25672
69495c6f12af Fix advertised capabilities (caps, chatstates, entity time)
Paul Aurich <paul@darkrain42.org>
parents: 25671
diff changeset
3559 jabber_add_feature("http://jabber.org/protocol/caps", 0);
69495c6f12af Fix advertised capabilities (caps, chatstates, entity time)
Paul Aurich <paul@darkrain42.org>
parents: 25671
diff changeset
3560 jabber_add_feature("http://jabber.org/protocol/chatstates", 0);
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
3561 jabber_add_feature(NS_DISCO_INFO, 0);
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
3562 jabber_add_feature(NS_DISCO_ITEMS, 0);
28645
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28592
diff changeset
3563 jabber_add_feature(NS_IBB, 0);
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
3564 jabber_add_feature("http://jabber.org/protocol/muc", 0);
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
3565 jabber_add_feature("http://jabber.org/protocol/muc#user", 0);
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
3566 jabber_add_feature("http://jabber.org/protocol/si", 0);
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23285
diff changeset
3567 jabber_add_feature("http://jabber.org/protocol/si/profile/file-transfer", 0);
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28648
diff changeset
3568 jabber_add_feature(NS_XHTML_IM, 0);
28645
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28592
diff changeset
3569 jabber_add_feature(NS_PING, 0);
26447
1ecbda91458a Fix merge: Move the Jingle features to jabber.c
Paul Aurich <paul@darkrain42.org>
parents: 26446
diff changeset
3570
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3571 /* Buzz/Attention */
28645
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28592
diff changeset
3572 jabber_add_feature(NS_ATTENTION, jabber_buzz_isenabled);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3573
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3574 /* Bits Of Binary */
28645
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28592
diff changeset
3575 jabber_add_feature(NS_BOB, 0);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26802
diff changeset
3576
26447
1ecbda91458a Fix merge: Move the Jingle features to jabber.c
Paul Aurich <paul@darkrain42.org>
parents: 26446
diff changeset
3577 /* Jingle features! */
1ecbda91458a Fix merge: Move the Jingle features to jabber.c
Paul Aurich <paul@darkrain42.org>
parents: 26446
diff changeset
3578 jabber_add_feature(JINGLE, 0);
26454
9131368ba4be Advertise ICEUDP only when libnice is available
Paul Aurich <paul@darkrain42.org>
parents: 26453
diff changeset
3579
26453
ecf6fd808d23 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <paul@darkrain42.org>
parents: 26451
diff changeset
3580 #ifdef USE_VV
28646
9feec7d1d95c jabber: Add the missing file and fix up the Google session namespaces
Paul Aurich <paul@darkrain42.org>
parents: 28645
diff changeset
3581 jabber_add_feature(NS_GOOGLE_PROTOCOL_SESSION, jabber_audio_enabled);
28645
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28592
diff changeset
3582 jabber_add_feature(NS_GOOGLE_VOICE, jabber_audio_enabled);
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28592
diff changeset
3583 jabber_add_feature(NS_GOOGLE_VIDEO, jabber_video_enabled);
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28592
diff changeset
3584 jabber_add_feature(NS_GOOGLE_CAMERA, jabber_video_enabled);
28281
5f97830906bc Advertise jingle rtp, and only advertise rawudp if VV is enabled
Will Thompson <will.thompson@collabora.co.uk>
parents: 28096
diff changeset
3585 jabber_add_feature(JINGLE_APP_RTP, 0);
26457
20743d9bd62d Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <paul@darkrain42.org>
parents: 26454
diff changeset
3586 jabber_add_feature(JINGLE_APP_RTP_SUPPORT_AUDIO, jabber_audio_enabled);
20743d9bd62d Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <paul@darkrain42.org>
parents: 26454
diff changeset
3587 jabber_add_feature(JINGLE_APP_RTP_SUPPORT_VIDEO, jabber_video_enabled);
28281
5f97830906bc Advertise jingle rtp, and only advertise rawudp if VV is enabled
Will Thompson <will.thompson@collabora.co.uk>
parents: 28096
diff changeset
3588 jabber_add_feature(JINGLE_TRANSPORT_RAWUDP, 0);
26737
8b7d1aed6d59 merge of '8ddbfe5d6f5c2455497d11ccbfff769ed4e9fad4'
Paul Aurich <paul@darkrain42.org>
parents: 26736 26455
diff changeset
3589 jabber_add_feature(JINGLE_TRANSPORT_ICEUDP, 0);
29132
44e949b676f0 Rebroadcast XMPP caps whenever the UI caps change.
maiku@pidgin.im
parents: 28360
diff changeset
3590
44e949b676f0 Rebroadcast XMPP caps whenever the UI caps change.
maiku@pidgin.im
parents: 28360
diff changeset
3591 g_signal_connect(G_OBJECT(purple_media_manager_get()), "ui-caps-changed",
44e949b676f0 Rebroadcast XMPP caps whenever the UI caps change.
maiku@pidgin.im
parents: 28360
diff changeset
3592 G_CALLBACK(jabber_caps_broadcast_change), NULL);
26453
ecf6fd808d23 Advertise video/voice features only when the UI says it has those caps
Paul Aurich <paul@darkrain42.org>
parents: 26451
diff changeset
3593 #endif
26447
1ecbda91458a Fix merge: Move the Jingle features to jabber.c
Paul Aurich <paul@darkrain42.org>
parents: 26446
diff changeset
3594
29557
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3595 /* TODO: This needs to be per-plugin */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3596 jabber_register_commands();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3597
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3598 /* reverse order of unload_plugin */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3599 jabber_iq_init();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3600 jabber_caps_init();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3601 /* PEP things should be init via jabber_pep_init, not here */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3602 jabber_pep_init();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3603 jabber_data_init();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3604 jabber_bosh_init();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3605
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3606 /* TODO: Implement adding and retrieving own features via IPC API */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3607
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3608 jabber_ibb_init();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3609 jabber_si_init();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3610
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28517
diff changeset
3611 jabber_auth_init();
29557
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3612 }
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3613
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3614 static void
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3615 jabber_do_uninit(void)
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3616 {
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3617 /* reverse order of jabber_do_init */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3618 jabber_bosh_uninit();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3619 jabber_data_uninit();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3620 jabber_si_uninit();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3621 jabber_ibb_uninit();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3622 /* PEP things should be uninit via jabber_pep_uninit, not here */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3623 jabber_pep_uninit();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3624 jabber_caps_uninit();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3625 jabber_presence_uninit();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3626 jabber_iq_uninit();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3627
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3628 /* TODO: This needs to be per-main plugin */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3629 jabber_unregister_commands();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3630
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3631 jabber_auth_uninit();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3632 jabber_features_destroy();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3633 jabber_identities_destroy();
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3634 }
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3635
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3636 void jabber_plugin_init(PurplePlugin *plugin)
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3637 {
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3638 ++plugin_ref;
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3639
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3640 if (plugin_ref == 1)
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3641 jabber_do_init();
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28517
diff changeset
3642
25028
e6f92c0f9770 * adding IPC function 'contact_has_feature'
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25027
diff changeset
3643 /* IPC functions */
e6f92c0f9770 * adding IPC function 'contact_has_feature'
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25027
diff changeset
3644 purple_plugin_ipc_register(plugin, "contact_has_feature", PURPLE_CALLBACK(jabber_ipc_contact_has_feature),
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3645 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER,
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3646 purple_value_new(PURPLE_TYPE_BOOLEAN), 3,
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25151
diff changeset
3647 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_ACCOUNT),
25028
e6f92c0f9770 * adding IPC function 'contact_has_feature'
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25027
diff changeset
3648 purple_value_new(PURPLE_TYPE_STRING),
e6f92c0f9770 * adding IPC function 'contact_has_feature'
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25027
diff changeset
3649 purple_value_new(PURPLE_TYPE_STRING));
26870
92565c8e1e3a 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 <paul@darkrain42.org>
parents: 26803
diff changeset
3650
25031
3f719eaa7fd1 * IPC work
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25030
diff changeset
3651 purple_plugin_ipc_register(plugin, "add_feature", PURPLE_CALLBACK(jabber_ipc_add_feature),
3f719eaa7fd1 * IPC work
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25030
diff changeset
3652 purple_marshal_VOID__POINTER,
3f719eaa7fd1 * IPC work
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25030
diff changeset
3653 NULL, 1,
3f719eaa7fd1 * IPC work
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25030
diff changeset
3654 purple_value_new(PURPLE_TYPE_STRING));
27004
60cb86295f08 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <paul@darkrain42.org>
parents: 27002
diff changeset
3655
60cb86295f08 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <paul@darkrain42.org>
parents: 27002
diff changeset
3656 purple_plugin_ipc_register(plugin, "register_namespace_watcher",
60cb86295f08 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <paul@darkrain42.org>
parents: 27002
diff changeset
3657 PURPLE_CALLBACK(jabber_iq_signal_register),
60cb86295f08 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <paul@darkrain42.org>
parents: 27002
diff changeset
3658 purple_marshal_VOID__POINTER_POINTER,
60cb86295f08 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <paul@darkrain42.org>
parents: 27002
diff changeset
3659 NULL, 2,
60cb86295f08 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <paul@darkrain42.org>
parents: 27002
diff changeset
3660 purple_value_new(PURPLE_TYPE_STRING), /* node */
60cb86295f08 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <paul@darkrain42.org>
parents: 27002
diff changeset
3661 purple_value_new(PURPLE_TYPE_STRING)); /* namespace */
60cb86295f08 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <paul@darkrain42.org>
parents: 27002
diff changeset
3662
60cb86295f08 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <paul@darkrain42.org>
parents: 27002
diff changeset
3663 purple_plugin_ipc_register(plugin, "unregister_namespace_watcher",
60cb86295f08 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <paul@darkrain42.org>
parents: 27002
diff changeset
3664 PURPLE_CALLBACK(jabber_iq_signal_unregister),
60cb86295f08 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <paul@darkrain42.org>
parents: 27002
diff changeset
3665 purple_marshal_VOID__POINTER_POINTER,
60cb86295f08 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <paul@darkrain42.org>
parents: 27002
diff changeset
3666 NULL, 2,
60cb86295f08 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <paul@darkrain42.org>
parents: 27002
diff changeset
3667 purple_value_new(PURPLE_TYPE_STRING), /* node */
60cb86295f08 Examples for the namespace-(un)registering of IQs and added IPC versions
Paul Aurich <paul@darkrain42.org>
parents: 27002
diff changeset
3668 purple_value_new(PURPLE_TYPE_STRING)); /* namespace */
29557
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3669
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3670 purple_signal_register(plugin, "jabber-register-namespace-watcher",
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3671 purple_marshal_VOID__POINTER_POINTER,
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3672 NULL, 2,
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3673 purple_value_new(PURPLE_TYPE_STRING), /* node */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3674 purple_value_new(PURPLE_TYPE_STRING)); /* namespace */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3675
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3676 purple_signal_register(plugin, "jabber-unregister-namespace-watcher",
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3677 purple_marshal_VOID__POINTER_POINTER,
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3678 NULL, 2,
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3679 purple_value_new(PURPLE_TYPE_STRING), /* node */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3680 purple_value_new(PURPLE_TYPE_STRING)); /* namespace */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3681
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3682 purple_signal_connect(plugin, "jabber-register-namespace-watcher",
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3683 plugin, PURPLE_CALLBACK(jabber_iq_signal_register), NULL);
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3684 purple_signal_connect(plugin, "jabber-unregister-namespace-watcher",
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3685 plugin, PURPLE_CALLBACK(jabber_iq_signal_unregister), NULL);
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3686
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3687
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3688 purple_signal_register(plugin, "jabber-receiving-xmlnode",
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3689 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3690 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3691 purple_value_new_outgoing(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE));
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3692
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3693 purple_signal_register(plugin, "jabber-sending-xmlnode",
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3694 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3695 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3696 purple_value_new_outgoing(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE));
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3697
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3698 /*
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3699 * Do not remove this or the plugin will fail. Completely. You have been
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3700 * warned!
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3701 */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3702 purple_signal_connect_priority(plugin, "jabber-sending-xmlnode",
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3703 plugin, PURPLE_CALLBACK(jabber_send_signal_cb),
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3704 NULL, PURPLE_SIGNAL_PRIORITY_HIGHEST);
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3705
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3706 purple_signal_register(plugin, "jabber-sending-text",
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3707 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3708 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3709 purple_value_new_outgoing(PURPLE_TYPE_STRING));
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3710
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3711 purple_signal_register(plugin, "jabber-receiving-message",
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3712 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER_POINTER,
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3713 purple_value_new(PURPLE_TYPE_BOOLEAN), 6,
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3714 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3715 purple_value_new(PURPLE_TYPE_STRING), /* type */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3716 purple_value_new(PURPLE_TYPE_STRING), /* id */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3717 purple_value_new(PURPLE_TYPE_STRING), /* from */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3718 purple_value_new(PURPLE_TYPE_STRING), /* to */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3719 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE));
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3720
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3721 purple_signal_register(plugin, "jabber-receiving-iq",
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3722 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER,
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3723 purple_value_new(PURPLE_TYPE_BOOLEAN), 5,
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3724 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3725 purple_value_new(PURPLE_TYPE_STRING), /* type */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3726 purple_value_new(PURPLE_TYPE_STRING), /* id */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3727 purple_value_new(PURPLE_TYPE_STRING), /* from */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3728 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE));
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3729
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3730 purple_signal_register(plugin, "jabber-watched-iq",
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3731 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER,
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3732 purple_value_new(PURPLE_TYPE_BOOLEAN), 5,
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3733 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3734 purple_value_new(PURPLE_TYPE_STRING), /* type */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3735 purple_value_new(PURPLE_TYPE_STRING), /* id */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3736 purple_value_new(PURPLE_TYPE_STRING), /* from */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3737 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE)); /* child */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3738
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3739 purple_signal_register(plugin, "jabber-receiving-presence",
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3740 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER,
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3741 purple_value_new(PURPLE_TYPE_BOOLEAN), 4,
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3742 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3743 purple_value_new(PURPLE_TYPE_STRING), /* type */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3744 purple_value_new(PURPLE_TYPE_STRING), /* from */
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3745 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3746 }
25167
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
3747
29557
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3748 void jabber_plugin_uninit(PurplePlugin *plugin)
25167
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
3749 {
29557
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3750 g_return_if_fail(plugin_ref > 0);
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3751
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3752 purple_signals_unregister_by_instance(plugin);
28517
96ba7fd24177 jabber: Use purple_connection_get_prpl() instead of jabber_plugin.
Paul Aurich <paul@darkrain42.org>
parents: 28515
diff changeset
3753 purple_plugin_ipc_unregister_all(plugin);
26870
92565c8e1e3a 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 <paul@darkrain42.org>
parents: 26803
diff changeset
3754
29557
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3755 --plugin_ref;
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3756 if (plugin_ref == 0)
a694731e8b3f jabber: Move the initialization into the jabber plugin, and only initialize some things once.
Paul Aurich <paul@darkrain42.org>
parents: 29556
diff changeset
3757 jabber_do_uninit();
25167
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
3758 }