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