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