pidgin/plugins/disco/xmppdisco.c

Wed, 04 Jun 2025 23:47:08 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Wed, 04 Jun 2025 23:47:08 -0500
branch
release-2.x.y
changeset 43264
50facee54d1d
parent 38256
035f00c4fd87
permissions
-rw-r--r--

Remove the retro protocol plugins

This removes gadu-gadu, novell, sametime, silc, silc10, and zephyr as they are
all being migrated to retro-prpl.

Testing Done:
Ran `make distcheck` and built the windows installer and verified that both worked as expected and that the uninstaller didn't remove the files. I did have to clean my `win32-install-dir` as that had contained previous builds of the now deleted protocols.

Bugs closed: PIDGIN-18098

Reviewed at https://reviews.imfreedom.org/r/4019/

27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
1 /*
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
2 * Purple - XMPP Service Disco Browser
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
3 *
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
7 * (at your option) any later version.
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
8 *
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
12 * GNU General Public License for more details.
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
13 *
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
15 * along with this program; if not, write to the Free Software
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
17 *
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
18 */
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
19
27245
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
20 /* TODO list (a little bit of a brain dump):
27248
b8775a6b1be0 Hmm, this wasn't saved when I committed it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27245
diff changeset
21 * Support more actions than "register" and "add" based on context.
b8775a6b1be0 Hmm, this wasn't saved when I committed it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27245
diff changeset
22 - Subscribe to pubsub nodes (just...because?)
27245
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
23 - Execute ad-hoc commands
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
24 - Change 'Register' to 'Unregister' if we're registered?
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
25 - Administer MUCs
27248
b8775a6b1be0 Hmm, this wasn't saved when I committed it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27245
diff changeset
26 * Enumerate pubsub node contents.
b8775a6b1be0 Hmm, this wasn't saved when I committed it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27245
diff changeset
27 - PEP too? (useful development tool at times)
b8775a6b1be0 Hmm, this wasn't saved when I committed it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27245
diff changeset
28 * See if we can better handle the ad-hoc commands that ejabberd returns
b8775a6b1be0 Hmm, this wasn't saved when I committed it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27245
diff changeset
29 when disco'ing a server as an administrator:
27245
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
30 from disco#items:
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
31 <item jid='darkrain42.org' node='announce' name='Announcements'/>
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
32 disco#info:
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
33 <iq from='darkrain42.org' type='result'>
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
34 <query xmlns='http://jabber.org/protocol/disco#info' node='announce'/>
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
35 </iq>
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
36 * For services that are a JID w/o a node, handle fetching ad-hoc commands?
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
37 */
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
38
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
39 #include "internal.h"
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
40 #include "pidgin.h"
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
41
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
42 #include "debug.h"
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
43 #include "signals.h"
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
44 #include "version.h"
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
45
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
46 #include "gtkconv.h"
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
47 #include "gtkimhtml.h"
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
48 #include "gtkplugin.h"
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
49
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
50 #include "xmppdisco.h"
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
51 #include "gtkdisco.h"
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
52
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
53 /* Variables */
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
54 PurplePlugin *my_plugin = NULL;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
55 static GHashTable *iq_callbacks = NULL;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
56 static gboolean iq_listening = FALSE;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
57
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
58 typedef void (*XmppIqCallback)(PurpleConnection *pc, const char *type,
27312
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
59 const char *id, const char *from, xmlnode *iq,
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
60 gpointer data);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
61
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
62 struct item_data {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
63 PidginDiscoList *list;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
64 XmppDiscoService *parent;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
65 char *name;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
66 char *node; /* disco#info replies don't always include the node */
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
67 };
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
68
27659
55a5f5b02393 Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents: 27566
diff changeset
69 struct xmpp_iq_cb_data
55a5f5b02393 Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents: 27566
diff changeset
70 {
55a5f5b02393 Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents: 27566
diff changeset
71 /*
55a5f5b02393 Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents: 27566
diff changeset
72 * Every IQ callback in this plugin uses the same structure for the
55a5f5b02393 Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents: 27566
diff changeset
73 * callback data. It's a hack (it wouldn't scale), but it's used so that
55a5f5b02393 Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents: 27566
diff changeset
74 * it's easy to clean up all the callbacks when the account disconnects
55a5f5b02393 Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents: 27566
diff changeset
75 * (see remove_iq_callbacks_by_pc below).
55a5f5b02393 Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents: 27566
diff changeset
76 */
55a5f5b02393 Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents: 27566
diff changeset
77 struct item_data *context;
55a5f5b02393 Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents: 27566
diff changeset
78 PurpleConnection *pc;
55a5f5b02393 Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents: 27566
diff changeset
79 XmppIqCallback cb;
55a5f5b02393 Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents: 27566
diff changeset
80 };
55a5f5b02393 Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents: 27566
diff changeset
81
55a5f5b02393 Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents: 27566
diff changeset
82
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
83 static char*
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
84 generate_next_id()
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
85 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
86 static guint32 index = 0;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
87
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
88 if (index == 0) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
89 do {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
90 index = g_random_int();
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
91 } while (index == 0);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
92 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
93
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
94 return g_strdup_printf("purpledisco%x", index++);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
95 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
96
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
97 static gboolean
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
98 remove_iq_callbacks_by_pc(gpointer key, gpointer value, gpointer user_data)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
99 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
100 struct xmpp_iq_cb_data *cb_data = value;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
101
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
102 if (cb_data && cb_data->pc == user_data) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
103 struct item_data *item_data = cb_data->context;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
104
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
105 if (item_data) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
106 pidgin_disco_list_unref(item_data->list);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
107 g_free(item_data->name);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
108 g_free(item_data->node);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
109 g_free(item_data);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
110 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
111
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
112 return TRUE;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
113 } else
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
114 return FALSE;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
115 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
116
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
117 static gboolean
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
118 xmpp_iq_received(PurpleConnection *pc, const char *type, const char *id,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
119 const char *from, xmlnode *iq)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
120 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
121 struct xmpp_iq_cb_data *cb_data;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
122
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
123 cb_data = g_hash_table_lookup(iq_callbacks, id);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
124 if (!cb_data)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
125 return FALSE;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
126
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
127 cb_data->cb(cb_data->pc, type, id, from, iq, cb_data->context);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
128
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
129 g_hash_table_remove(iq_callbacks, id);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
130 if (g_hash_table_size(iq_callbacks) == 0) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
131 PurplePlugin *prpl = purple_connection_get_prpl(pc);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
132 iq_listening = FALSE;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
133 purple_signal_disconnect(prpl, "jabber-receiving-iq", my_plugin,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
134 PURPLE_CALLBACK(xmpp_iq_received));
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
135 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
136
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
137 /* Om nom nom nom */
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
138 return TRUE;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
139 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
140
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
141 static void
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
142 xmpp_iq_register_callback(PurpleConnection *pc, gchar *id, gpointer data,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
143 XmppIqCallback cb)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
144 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
145 struct xmpp_iq_cb_data *cbdata = g_new0(struct xmpp_iq_cb_data, 1);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
146
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
147 cbdata->context = data;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
148 cbdata->cb = cb;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
149 cbdata->pc = pc;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
150
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
151 g_hash_table_insert(iq_callbacks, id, cbdata);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
152
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
153 if (!iq_listening) {
27312
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
154 PurplePlugin *prpl = purple_plugins_find_with_id(XMPP_PLUGIN_ID);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
155 iq_listening = TRUE;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
156 purple_signal_connect(prpl, "jabber-receiving-iq", my_plugin,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
157 PURPLE_CALLBACK(xmpp_iq_received), NULL);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
158 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
159 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
160
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
161 static void
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
162 xmpp_disco_info_do(PurpleConnection *pc, gpointer cbdata, const char *jid,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
163 const char *node, XmppIqCallback cb)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
164 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
165 xmlnode *iq, *query;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
166 char *id = generate_next_id();
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
167
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
168 iq = xmlnode_new("iq");
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
169 xmlnode_set_attrib(iq, "type", "get");
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
170 xmlnode_set_attrib(iq, "to", jid);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
171 xmlnode_set_attrib(iq, "id", id);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
172
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
173 query = xmlnode_new_child(iq, "query");
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
174 xmlnode_set_namespace(query, NS_DISCO_INFO);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
175 if (node)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
176 xmlnode_set_attrib(query, "node", node);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
177
27226
e86922c96573 Use the modified signal in more places.
Paul Aurich <darkrain42@pidgin.im>
parents: 27224
diff changeset
178 /* Steals id */
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
179 xmpp_iq_register_callback(pc, id, cbdata, cb);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
180
27226
e86922c96573 Use the modified signal in more places.
Paul Aurich <darkrain42@pidgin.im>
parents: 27224
diff changeset
181 purple_signal_emit(purple_connection_get_prpl(pc), "jabber-sending-xmlnode",
e86922c96573 Use the modified signal in more places.
Paul Aurich <darkrain42@pidgin.im>
parents: 27224
diff changeset
182 pc, &iq);
e86922c96573 Use the modified signal in more places.
Paul Aurich <darkrain42@pidgin.im>
parents: 27224
diff changeset
183 if (iq != NULL)
e86922c96573 Use the modified signal in more places.
Paul Aurich <darkrain42@pidgin.im>
parents: 27224
diff changeset
184 xmlnode_free(iq);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
185 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
186
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
187 static void
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
188 xmpp_disco_items_do(PurpleConnection *pc, gpointer cbdata, const char *jid,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
189 const char *node, XmppIqCallback cb)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
190 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
191 xmlnode *iq, *query;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
192 char *id = generate_next_id();
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
193
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
194 iq = xmlnode_new("iq");
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
195 xmlnode_set_attrib(iq, "type", "get");
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
196 xmlnode_set_attrib(iq, "to", jid);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
197 xmlnode_set_attrib(iq, "id", id);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
198
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
199 query = xmlnode_new_child(iq, "query");
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
200 xmlnode_set_namespace(query, NS_DISCO_ITEMS);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
201 if (node)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
202 xmlnode_set_attrib(query, "node", node);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
203
27226
e86922c96573 Use the modified signal in more places.
Paul Aurich <darkrain42@pidgin.im>
parents: 27224
diff changeset
204 /* Steals id */
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
205 xmpp_iq_register_callback(pc, id, cbdata, cb);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
206
27226
e86922c96573 Use the modified signal in more places.
Paul Aurich <darkrain42@pidgin.im>
parents: 27224
diff changeset
207 purple_signal_emit(purple_connection_get_prpl(pc), "jabber-sending-xmlnode",
e86922c96573 Use the modified signal in more places.
Paul Aurich <darkrain42@pidgin.im>
parents: 27224
diff changeset
208 pc, &iq);
e86922c96573 Use the modified signal in more places.
Paul Aurich <darkrain42@pidgin.im>
parents: 27224
diff changeset
209 if (iq != NULL)
e86922c96573 Use the modified signal in more places.
Paul Aurich <darkrain42@pidgin.im>
parents: 27224
diff changeset
210 xmlnode_free(iq);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
211 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
212
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
213 static XmppDiscoServiceType
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
214 disco_service_type_from_identity(xmlnode *identity)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
215 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
216 const char *category, *type;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
218 if (!identity)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
219 return XMPP_DISCO_SERVICE_TYPE_OTHER;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
220
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
221 category = xmlnode_get_attrib(identity, "category");
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
222 type = xmlnode_get_attrib(identity, "type");
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
223
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
224 if (!category)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
225 return XMPP_DISCO_SERVICE_TYPE_OTHER;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
226
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38086
diff changeset
227 if (purple_strequal(category, "conference"))
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
228 return XMPP_DISCO_SERVICE_TYPE_CHAT;
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38086
diff changeset
229 else if (purple_strequal(category, "directory"))
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
230 return XMPP_DISCO_SERVICE_TYPE_DIRECTORY;
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38086
diff changeset
231 else if (purple_strequal(category, "gateway"))
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
232 return XMPP_DISCO_SERVICE_TYPE_GATEWAY;
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38086
diff changeset
233 else if (purple_strequal(category, "pubsub")) {
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38086
diff changeset
234 if (!type || purple_strequal(type, "collection"))
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
235 return XMPP_DISCO_SERVICE_TYPE_PUBSUB_COLLECTION;
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38086
diff changeset
236 else if (purple_strequal(type, "leaf"))
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
237 return XMPP_DISCO_SERVICE_TYPE_PUBSUB_LEAF;
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38086
diff changeset
238 else if (purple_strequal(type, "service"))
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
239 return XMPP_DISCO_SERVICE_TYPE_OTHER;
27218
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
240 else {
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
241 purple_debug_warning("xmppdisco", "Unknown pubsub type '%s'\n", type);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
242 return XMPP_DISCO_SERVICE_TYPE_OTHER;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
243 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
244 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
245
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
246 return XMPP_DISCO_SERVICE_TYPE_OTHER;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
247 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
248
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
249 static const struct {
27312
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
250 const char *from;
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
251 const char *to;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
252 } disco_type_mappings[] = {
27312
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
253 { "xmpp", "jabber" }, /* prpl-jabber (mentioned in case the prpl is renamed so this line will match) */
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
254 { NULL, NULL }
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
255 };
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
256
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
257 static const gchar *
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
258 disco_type_from_string(const gchar *str)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
259 {
27312
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
260 int i = 0;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
261
27312
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
262 g_return_val_if_fail(str != NULL, "");
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
263
27312
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
264 for ( ; disco_type_mappings[i].from; ++i) {
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
265 if (!strcasecmp(str, disco_type_mappings[i].from))
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
266 return disco_type_mappings[i].to;
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
267 }
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
268
27312
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
269 /* fallback to the string itself */
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
270 return str;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
271 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
272
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
273 static void
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
274 got_info_cb(PurpleConnection *pc, const char *type, const char *id,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
275 const char *from, xmlnode *iq, gpointer data)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
276 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
277 struct item_data *item_data = data;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
278 PidginDiscoList *list = item_data->list;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
279 xmlnode *query;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
280
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
281 --list->fetch_count;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
282
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
283 if (!list->in_progress)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
284 goto out;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
285
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38086
diff changeset
286 if (purple_strequal(type, "result") &&
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
287 (query = xmlnode_get_child(iq, "query"))) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
288 xmlnode *identity = xmlnode_get_child(query, "identity");
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
289 XmppDiscoService *service;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
290 xmlnode *feature;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
291
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
292 service = g_new0(XmppDiscoService, 1);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
293 service->list = item_data->list;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
294 purple_debug_info("xmppdisco", "parent for %s is %p\n", from, item_data->parent);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
295 service->parent = item_data->parent;
27320
b4fa127ce203 Don't support adding JID+node items.
Paul Aurich <darkrain42@pidgin.im>
parents: 27312
diff changeset
296 service->flags = 0;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
297 service->type = disco_service_type_from_identity(identity);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
298
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
299 if (item_data->node) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
300 if (item_data->name) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
301 service->name = item_data->name;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
302 item_data->name = NULL;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
303 } else
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
304 service->name = g_strdup(item_data->node);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
305
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
306 service->node = item_data->node;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
307 item_data->node = NULL;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
308
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
309 if (service->type == XMPP_DISCO_SERVICE_TYPE_PUBSUB_COLLECTION)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
310 service->flags |= XMPP_DISCO_BROWSE;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
311 } else
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
312 service->name = g_strdup(from);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
313
27320
b4fa127ce203 Don't support adding JID+node items.
Paul Aurich <darkrain42@pidgin.im>
parents: 27312
diff changeset
314 if (!service->node)
b4fa127ce203 Don't support adding JID+node items.
Paul Aurich <darkrain42@pidgin.im>
parents: 27312
diff changeset
315 /* Only support adding JIDs, not JID+node combos */
b4fa127ce203 Don't support adding JID+node items.
Paul Aurich <darkrain42@pidgin.im>
parents: 27312
diff changeset
316 service->flags |= XMPP_DISCO_ADD;
b4fa127ce203 Don't support adding JID+node items.
Paul Aurich <darkrain42@pidgin.im>
parents: 27312
diff changeset
317
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
318 if (item_data->name) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
319 service->description = item_data->name;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
320 item_data->name = NULL;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
321 } else if (identity)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
322 service->description = g_strdup(xmlnode_get_attrib(identity, "name"));
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
323
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
324 /* TODO: Overlap with service->name a bit */
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
325 service->jid = g_strdup(from);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
326
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
327 for (feature = xmlnode_get_child(query, "feature"); feature;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
328 feature = xmlnode_get_next_twin(feature)) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
329 const char *var;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
330 if (!(var = xmlnode_get_attrib(feature, "var")))
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
331 continue;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
332
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38086
diff changeset
333 if (purple_strequal(var, NS_REGISTER))
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
334 service->flags |= XMPP_DISCO_REGISTER;
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38086
diff changeset
335 else if (purple_strequal(var, NS_DISCO_ITEMS))
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
336 service->flags |= XMPP_DISCO_BROWSE;
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38086
diff changeset
337 else if (purple_strequal(var, NS_MUC)) {
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
338 service->flags |= XMPP_DISCO_BROWSE;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
339 service->type = XMPP_DISCO_SERVICE_TYPE_CHAT;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
340 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
341 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
342
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
343 if (service->type == XMPP_DISCO_SERVICE_TYPE_GATEWAY)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
344 service->gateway_type = g_strdup(disco_type_from_string(
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
345 xmlnode_get_attrib(identity, "type")));
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
346
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
347 pidgin_disco_add_service(list, service, service->parent);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
348 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
349
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
350 out:
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
351 if (list->fetch_count == 0)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
352 pidgin_disco_list_set_in_progress(list, FALSE);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
353
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
354 g_free(item_data->name);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
355 g_free(item_data->node);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
356 g_free(item_data);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
357 pidgin_disco_list_unref(list);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
358 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
359
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
360 static void
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
361 got_items_cb(PurpleConnection *pc, const char *type, const char *id,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
362 const char *from, xmlnode *iq, gpointer data)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
363 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
364 struct item_data *item_data = data;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
365 PidginDiscoList *list = item_data->list;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
366 xmlnode *query;
27222
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
367 gboolean has_items = FALSE;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
368
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
369 --list->fetch_count;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
370
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
371 if (!list->in_progress)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
372 goto out;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
373
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38086
diff changeset
374 if (purple_strequal(type, "result") &&
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
375 (query = xmlnode_get_child(iq, "query"))) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
376 xmlnode *item;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
377
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
378 for (item = xmlnode_get_child(query, "item"); item;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
379 item = xmlnode_get_next_twin(item)) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
380 const char *jid = xmlnode_get_attrib(item, "jid");
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
381 const char *name = xmlnode_get_attrib(item, "name");
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
382 const char *node = xmlnode_get_attrib(item, "node");
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
383
27222
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
384 has_items = TRUE;
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
385
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
386 if (item_data->parent->type == XMPP_DISCO_SERVICE_TYPE_CHAT) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
387 /* This is a hacky first-order approximation. Any MUC
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
388 * component that has a >1 level hierarchy (a Yahoo MUC
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
389 * transport component probably does) will violate this.
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
390 *
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
391 * On the other hand, this is better than querying all the
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
392 * chats at conference.jabber.org to enumerate them.
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
393 */
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
394 XmppDiscoService *service = g_new0(XmppDiscoService, 1);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
395 service->list = item_data->list;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
396 service->parent = item_data->parent;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
397 service->flags = XMPP_DISCO_ADD;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
398 service->type = XMPP_DISCO_SERVICE_TYPE_CHAT;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
399
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
400 service->name = g_strdup(name);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
401 service->jid = g_strdup(jid);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
402 service->node = g_strdup(node);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
403 pidgin_disco_add_service(list, service, item_data->parent);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
404 } else {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
405 struct item_data *item_data2 = g_new0(struct item_data, 1);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
406
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
407 item_data2->list = item_data->list;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
408 item_data2->parent = item_data->parent;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
409 item_data2->name = g_strdup(name);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
410 item_data2->node = g_strdup(node);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
411
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
412 ++list->fetch_count;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
413 pidgin_disco_list_ref(list);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
414 xmpp_disco_info_do(pc, item_data2, jid, node, got_info_cb);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
415 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
416 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
417 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
418
27222
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
419 if (!has_items)
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
420 pidgin_disco_add_service(list, NULL, item_data->parent);
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
421
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
422 out:
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
423 if (list->fetch_count == 0)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
424 pidgin_disco_list_set_in_progress(list, FALSE);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
425
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
426 g_free(item_data);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
427 pidgin_disco_list_unref(list);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
428 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
429
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
430 static void
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
431 server_items_cb(PurpleConnection *pc, const char *type, const char *id,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
432 const char *from, xmlnode *iq, gpointer data)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
433 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
434 struct item_data *cb_data = data;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
435 PidginDiscoList *list = cb_data->list;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
436 xmlnode *query;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
437
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
438 g_free(cb_data);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
439 --list->fetch_count;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
440
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38086
diff changeset
441 if (purple_strequal(type, "result") &&
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
442 (query = xmlnode_get_child(iq, "query"))) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
443 xmlnode *item;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
444
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
445 for (item = xmlnode_get_child(query, "item"); item;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
446 item = xmlnode_get_next_twin(item)) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
447 const char *jid = xmlnode_get_attrib(item, "jid");
27245
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
448 const char *name = xmlnode_get_attrib(item, "name");
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
449 const char *node = xmlnode_get_attrib(item, "node");
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
450 struct item_data *item_data;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
451
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
452 if (!jid)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
453 continue;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
454
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
455 item_data = g_new0(struct item_data, 1);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
456 item_data->list = list;
27245
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
457 item_data->name = g_strdup(name);
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
458 item_data->node = g_strdup(node);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
459
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
460 ++list->fetch_count;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
461 pidgin_disco_list_ref(list);
27245
34b893abb0d3 Fix an issue with the server responding with jid/node items as first-level children and add a TODO.
Paul Aurich <darkrain42@pidgin.im>
parents: 27226
diff changeset
462 xmpp_disco_info_do(pc, item_data, jid, node, got_info_cb);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
463 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
464 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
465
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
466 if (list->fetch_count == 0)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
467 pidgin_disco_list_set_in_progress(list, FALSE);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
468
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
469 pidgin_disco_list_unref(list);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
470 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
471
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
472 static void
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
473 server_info_cb(PurpleConnection *pc, const char *type, const char *id,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
474 const char *from, xmlnode *iq, gpointer data)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
475 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
476 struct item_data *cb_data = data;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
477 PidginDiscoList *list = cb_data->list;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
478 xmlnode *query;
27263
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
479 xmlnode *error;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
480 gboolean items = FALSE;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
481
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
482 --list->fetch_count;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
483
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38086
diff changeset
484 if (purple_strequal(type, "result") &&
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
485 (query = xmlnode_get_child(iq, "query"))) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
486 xmlnode *feature;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
487
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
488 for (feature = xmlnode_get_child(query, "feature"); feature;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
489 feature = xmlnode_get_next_twin(feature)) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
490 const char *var = xmlnode_get_attrib(feature, "var");
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
491 if (purple_strequal(var, NS_DISCO_ITEMS)) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
492 items = TRUE;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
493 break;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
494 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
495 }
27263
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
496
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
497 if (items) {
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
498 xmpp_disco_items_do(pc, cb_data, from, NULL /* node */, server_items_cb);
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
499 ++list->fetch_count;
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
500 pidgin_disco_list_ref(list);
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
501 }
27566
d62249fe6be1 If no disco#items feature was found (like with gmail.com), then our disco
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27320
diff changeset
502 else {
d62249fe6be1 If no disco#items feature was found (like with gmail.com), then our disco
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27320
diff changeset
503 pidgin_disco_list_set_in_progress(list, FALSE);
d62249fe6be1 If no disco#items feature was found (like with gmail.com), then our disco
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27320
diff changeset
504 g_free(cb_data);
d62249fe6be1 If no disco#items feature was found (like with gmail.com), then our disco
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27320
diff changeset
505 }
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
506 }
27263
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
507 else {
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
508 error = xmlnode_get_child(iq, "error");
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
509 if (xmlnode_get_child(error, "remote-server-not-found")
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
510 || xmlnode_get_child(error, "jid-malformed")) {
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
511 purple_notify_error(my_plugin, _("Error"),
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
512 _("Server does not exist"),
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
513 NULL);
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
514 }
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
515 else {
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
516 purple_notify_error(my_plugin, _("Error"),
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
517 _("Server does not support service discovery"),
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
518 NULL);
b16178424cd7 Make XMPP Disco plugin show better errors when getting a 404-like return.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27248
diff changeset
519 }
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
520 pidgin_disco_list_set_in_progress(list, FALSE);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
521 g_free(cb_data);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
522 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
523
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
524 pidgin_disco_list_unref(list);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
525 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
526
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
527 void xmpp_disco_start(PidginDiscoList *list)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
528 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
529 struct item_data *cb_data;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
530
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
531 g_return_if_fail(list != NULL);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
532
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
533 ++list->fetch_count;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
534 pidgin_disco_list_ref(list);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
535
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
536 cb_data = g_new0(struct item_data, 1);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
537 cb_data->list = list;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
538
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
539 xmpp_disco_info_do(list->pc, cb_data, list->server, NULL, server_info_cb);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
540 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
541
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
542 void xmpp_disco_service_expand(XmppDiscoService *service)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
543 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
544 struct item_data *item_data;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
545
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
546 g_return_if_fail(service != NULL);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
547
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
548 if (service->expanded)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
549 return;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
550
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
551 item_data = g_new0(struct item_data, 1);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
552 item_data->list = service->list;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
553 item_data->parent = service;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
554
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
555 ++service->list->fetch_count;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
556 pidgin_disco_list_ref(service->list);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
557
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
558 pidgin_disco_list_set_in_progress(service->list, TRUE);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
559
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
560 xmpp_disco_items_do(service->list->pc, item_data, service->jid, service->node,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
561 got_items_cb);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
562 service->expanded = TRUE;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
563 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
564
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
565 void xmpp_disco_service_register(XmppDiscoService *service)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
566 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
567 xmlnode *iq, *query;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
568 char *id = generate_next_id();
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
569
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
570 iq = xmlnode_new("iq");
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
571 xmlnode_set_attrib(iq, "type", "get");
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
572 xmlnode_set_attrib(iq, "to", service->jid);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
573 xmlnode_set_attrib(iq, "id", id);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
574
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
575 query = xmlnode_new_child(iq, "query");
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
576 xmlnode_set_namespace(query, NS_REGISTER);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
577
27226
e86922c96573 Use the modified signal in more places.
Paul Aurich <darkrain42@pidgin.im>
parents: 27224
diff changeset
578 purple_signal_emit(purple_connection_get_prpl(service->list->pc),
e86922c96573 Use the modified signal in more places.
Paul Aurich <darkrain42@pidgin.im>
parents: 27224
diff changeset
579 "jabber-sending-xmlnode", service->list->pc, &iq);
e86922c96573 Use the modified signal in more places.
Paul Aurich <darkrain42@pidgin.im>
parents: 27224
diff changeset
580 if (iq != NULL)
e86922c96573 Use the modified signal in more places.
Paul Aurich <darkrain42@pidgin.im>
parents: 27224
diff changeset
581 xmlnode_free(iq);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
582 g_free(id);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
583 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
584
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
585 static void
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
586 create_dialog(PurplePluginAction *action)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
587 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
588 pidgin_disco_dialog_new();
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
589 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
590
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
591 static GList *
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
592 actions(PurplePlugin *plugin, gpointer context)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
593 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
594 GList *l = NULL;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
595 PurplePluginAction *action = NULL;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
596
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
597 action = purple_plugin_action_new(_("XMPP Service Discovery"),
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
598 create_dialog);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
599 l = g_list_prepend(l, action);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
600
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
601 return l;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
602 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
603
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
604 static void
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
605 signed_off_cb(PurpleConnection *pc, gpointer unused)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
606 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
607 /* Deal with any dialogs */
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
608 pidgin_disco_signed_off_cb(pc);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
609
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
610 /* Remove all the IQ callbacks for this connection */
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
611 g_hash_table_foreach_remove(iq_callbacks, remove_iq_callbacks_by_pc, pc);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
612 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
613
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
614 static gboolean
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
615 plugin_load(PurplePlugin *plugin)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
616 {
27312
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
617 PurplePlugin *xmpp_prpl;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
618
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
619 my_plugin = plugin;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
620
27312
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
621 xmpp_prpl = purple_plugins_find_with_id(XMPP_PLUGIN_ID);
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
622 if (NULL == xmpp_prpl)
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27263
diff changeset
623 return FALSE;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
624
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
625 purple_signal_connect(purple_connections_get_handle(), "signing-off",
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
626 plugin, PURPLE_CALLBACK(signed_off_cb), NULL);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
627
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
628 iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
629
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
630 return TRUE;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
631 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
632
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
633 static gboolean
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
634 plugin_unload(PurplePlugin *plugin)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
635 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
636 g_hash_table_destroy(iq_callbacks);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
637 iq_callbacks = NULL;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
638
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
639 purple_signals_disconnect_by_handle(plugin);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
640 pidgin_disco_dialogs_destroy_all();
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
641
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
642 return TRUE;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
643 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
644
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
645 static PurplePluginInfo info =
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
646 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
647 PURPLE_PLUGIN_MAGIC,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
648 PURPLE_MAJOR_VERSION,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
649 PURPLE_MINOR_VERSION,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
650 PURPLE_PLUGIN_STANDARD,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
651 PIDGIN_PLUGIN_TYPE,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
652 0,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
653 NULL,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
654 PURPLE_PRIORITY_DEFAULT,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
655 "gtk-xmppdisco",
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
656 N_("XMPP Service Discovery"),
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
657 DISPLAY_VERSION,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
658 N_("Allows browsing and registering services."),
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
659 N_("This plugin is useful for registering with legacy transports or other "
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
660 "XMPP services."),
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
661 "Paul Aurich <paul@darkrain42.org>",
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
662 PURPLE_WEBSITE,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
663 plugin_load,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
664 plugin_unload,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
665 NULL, /**< destroy */
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
666 NULL, /**< ui_info */
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
667 NULL, /**< extra_info */
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
668 NULL, /**< prefs_info */
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
669 actions,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
670
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
671 /* padding */
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
672 NULL,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
673 NULL,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
674 NULL,
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
675 NULL
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
676 };
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
677
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
678 static void
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
679 init_plugin(PurplePlugin *plugin)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
680 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
681 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
682
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
683 PURPLE_INIT_PLUGIN(xmppdisco, init_plugin, info)

mercurial