Sun, 10 Aug 2025 23:44:08 +0800
Add Purple.Conversation.find_message_by_id
The method was added so that a protocol or plugin could easily lookup
for the reference for a message. This will be especially useful when a
protocol received a quoted message but only with an id.
|
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 |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
4 | * |
|
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
5 | * Pidgin is the legal property of its developers, whose names are too numerous |
|
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
7 | * source distribution. |
|
27217
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 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
|
10 | * 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
|
11 | * 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
|
12 | * (at your option) any later version. |
|
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 | * 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
|
15 | * 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
|
16 | * 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
|
17 | * 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
|
18 | * |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
20 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
21 | */ |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
22 | |
|
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 | /* 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
|
24 | * 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
|
25 | - 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
|
26 | - 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
|
27 | - 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
|
28 | - Administer MUCs |
|
27248
b8775a6b1be0
Hmm, this wasn't saved when I committed it.
Paul Aurich <darkrain42@pidgin.im>
parents:
27245
diff
changeset
|
29 | * Enumerate pubsub node contents. |
|
b8775a6b1be0
Hmm, this wasn't saved when I committed it.
Paul Aurich <darkrain42@pidgin.im>
parents:
27245
diff
changeset
|
30 | - 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
|
31 | * 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
|
32 | 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
|
33 | 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
|
34 | <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
|
35 | 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
|
36 | <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
|
37 | <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
|
38 | </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
|
39 | * 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
|
40 | */ |
|
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
|
41 | |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40360
diff
changeset
|
42 | #include <glib/gi18n-lib.h> |
|
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40360
diff
changeset
|
43 | |
|
40360
e21f3bbcc2a5
Update all of the pidgin code to include purple.h
Gary Kramlich <grim@reaperworld.com>
parents:
40222
diff
changeset
|
44 | #include <purple.h> |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
45 | |
|
40502
875489636847
pidgin.h phase3: create pidgin.h and force its usage
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
46 | #include <pidgin.h> |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
47 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
48 | #include "xmppdisco.h" |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
49 | #include "gtkdisco.h" |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
50 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
51 | /* Variables */ |
|
43286
1861a365a664
Replace PurplePlugin by GPluginPlugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42453
diff
changeset
|
52 | GPluginPlugin *my_plugin = NULL; |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
53 | static GHashTable *iq_callbacks = NULL; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
54 | static gboolean iq_listening = FALSE; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
55 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
56 | 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
|
57 | 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
|
58 | gpointer data); |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
59 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
60 | struct item_data { |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
61 | PidginDiscoList *list; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
62 | XmppDiscoService *parent; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
63 | char *name; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
64 | 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
|
65 | }; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
66 | |
|
27659
55a5f5b02393
Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents:
27566
diff
changeset
|
67 | 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
|
68 | { |
|
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 | * 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
|
71 | * 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
|
72 | * 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
|
73 | * (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
|
74 | */ |
|
55a5f5b02393
Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents:
27566
diff
changeset
|
75 | struct item_data *context; |
|
55a5f5b02393
Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents:
27566
diff
changeset
|
76 | PurpleConnection *pc; |
|
55a5f5b02393
Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents:
27566
diff
changeset
|
77 | XmppIqCallback cb; |
|
55a5f5b02393
Make the use of xmpp_iq_cb_data->context explicit.
Paul Aurich <darkrain42@pidgin.im>
parents:
27566
diff
changeset
|
78 | }; |
|
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 | |
|
41840
fe350460fb1c
Remove C99-obsoleted constructs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41499
diff
changeset
|
81 | static char * |
|
fe350460fb1c
Remove C99-obsoleted constructs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41499
diff
changeset
|
82 | generate_next_id(void) |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
83 | { |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
84 | static guint32 index = 0; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
85 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
86 | if (index == 0) { |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
87 | do { |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
88 | index = g_random_int(); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
89 | } while (index == 0); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
90 | } |
|
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 | 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
|
93 | } |
|
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 | static gboolean |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
96 | remove_iq_callbacks_by_pc(G_GNUC_UNUSED gpointer key, gpointer value, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
97 | gpointer user_data) |
|
27217
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); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
123 | if (!cb_data) { |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
124 | return FALSE; |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
125 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
126 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
127 | cb_data->cb(cb_data->pc, type, id, from, iq, cb_data->context); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
128 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
129 | g_hash_table_remove(iq_callbacks, id); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
130 | if (g_hash_table_size(iq_callbacks) == 0) { |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
131 | 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
|
132 | iq_listening = FALSE; |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
133 | purple_signal_disconnect(protocol, "jabber-receiving-iq", my_plugin, |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41078
diff
changeset
|
134 | G_CALLBACK(xmpp_iq_received)); |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
135 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
136 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
137 | /* Om nom nom nom */ |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
138 | return TRUE; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
139 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
140 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
141 | static void |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
142 | xmpp_iq_register_callback(PurpleConnection *pc, gchar *id, gpointer data, |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
143 | XmppIqCallback cb) |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
144 | { |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
145 | struct xmpp_iq_cb_data *cbdata = g_new0(struct xmpp_iq_cb_data, 1); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
146 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
147 | cbdata->context = data; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
148 | cbdata->cb = cb; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
149 | cbdata->pc = pc; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
150 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
151 | g_hash_table_insert(iq_callbacks, id, cbdata); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
152 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
153 | if (!iq_listening) { |
|
40799
fb206d19393f
Port the pidgin plugins from purple_protocols_ to purple_protocol_manager_
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
154 | PurpleProtocol *protocol = NULL; |
|
fb206d19393f
Port the pidgin plugins from purple_protocols_ to purple_protocol_manager_
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
155 | PurpleProtocolManager *manager = purple_protocol_manager_get_default(); |
|
fb206d19393f
Port the pidgin plugins from purple_protocols_ to purple_protocol_manager_
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
156 | protocol = purple_protocol_manager_find(manager, XMPP_PROTOCOL_ID); |
|
fb206d19393f
Port the pidgin plugins from purple_protocols_ to purple_protocol_manager_
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
157 | |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
158 | iq_listening = TRUE; |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
159 | purple_signal_connect(protocol, "jabber-receiving-iq", my_plugin, |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41078
diff
changeset
|
160 | G_CALLBACK(xmpp_iq_received), NULL); |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
161 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
162 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
163 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
164 | static void |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
165 | 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
|
166 | const char *node, XmppIqCallback cb) |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
167 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
168 | PurpleXmlNode *iq, *query; |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
169 | char *id = generate_next_id(); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
170 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
171 | 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
|
172 | 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
|
173 | 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
|
174 | 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
|
175 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
176 | 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
|
177 | purple_xmlnode_set_namespace(query, NS_DISCO_INFO); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
178 | if (node) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
179 | purple_xmlnode_set_attrib(query, "node", node); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
180 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
181 | |
|
27226
e86922c96573
Use the modified signal in more places.
Paul Aurich <darkrain42@pidgin.im>
parents:
27224
diff
changeset
|
182 | /* Steals id */ |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
183 | 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
|
184 | |
|
36623
caaadef03507
Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
185 | 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
|
186 | pc, &iq); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
187 | 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
|
188 | purple_xmlnode_free(iq); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
189 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
190 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
191 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
192 | static void |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
193 | 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
|
194 | const char *node, XmppIqCallback cb) |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
195 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
196 | PurpleXmlNode *iq, *query; |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
197 | char *id = generate_next_id(); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
198 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
199 | 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
|
200 | 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
|
201 | 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
|
202 | 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
|
203 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
204 | 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
|
205 | purple_xmlnode_set_namespace(query, NS_DISCO_ITEMS); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
206 | if (node) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
207 | purple_xmlnode_set_attrib(query, "node", node); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
208 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
209 | |
|
27226
e86922c96573
Use the modified signal in more places.
Paul Aurich <darkrain42@pidgin.im>
parents:
27224
diff
changeset
|
210 | /* Steals id */ |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
211 | 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
|
212 | |
|
36623
caaadef03507
Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
213 | 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
|
214 | pc, &iq); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
215 | 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
|
216 | purple_xmlnode_free(iq); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
217 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
218 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
219 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
220 | static XmppDiscoServiceType |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
221 | 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
|
222 | { |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
223 | const char *category, *type; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
224 | |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
225 | if (!identity) { |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
226 | return XMPP_DISCO_SERVICE_TYPE_OTHER; |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
227 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
228 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
229 | 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
|
230 | 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
|
231 | |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
232 | if (!category) { |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
233 | return XMPP_DISCO_SERVICE_TYPE_OTHER; |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
234 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
235 | |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
236 | if (purple_strequal(category, "conference")) { |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
237 | return XMPP_DISCO_SERVICE_TYPE_CHAT; |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
238 | } 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
|
239 | return XMPP_DISCO_SERVICE_TYPE_DIRECTORY; |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
240 | } 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
|
241 | return XMPP_DISCO_SERVICE_TYPE_GATEWAY; |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
242 | } else if (purple_strequal(category, "pubsub")) { |
|
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
243 | 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
|
244 | return XMPP_DISCO_SERVICE_TYPE_PUBSUB_COLLECTION; |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
245 | } 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
|
246 | return XMPP_DISCO_SERVICE_TYPE_PUBSUB_LEAF; |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
247 | } 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
|
248 | return XMPP_DISCO_SERVICE_TYPE_OTHER; |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
249 | } else { |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
250 | 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
|
251 | return XMPP_DISCO_SERVICE_TYPE_OTHER; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
252 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
253 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
254 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
255 | return XMPP_DISCO_SERVICE_TYPE_OTHER; |
|
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 struct { |
|
27312
07a772783c0f
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27263
diff
changeset
|
259 | const char *from; |
|
07a772783c0f
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27263
diff
changeset
|
260 | const char *to; |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
261 | } disco_type_mappings[] = { |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
262 | { "gadu-gadu", "gadu-gadu" }, /* the protocol is gg, but list_icon returns "gadu-gadu" */ |
|
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
263 | { "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
|
264 | { NULL, NULL } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
265 | }; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
266 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
267 | static const gchar * |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
268 | 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
|
269 | { |
|
27312
07a772783c0f
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27263
diff
changeset
|
270 | int i = 0; |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
271 | |
|
27312
07a772783c0f
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27263
diff
changeset
|
272 | 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
|
273 | |
|
27312
07a772783c0f
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27263
diff
changeset
|
274 | for ( ; disco_type_mappings[i].from; ++i) { |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
275 | 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
|
276 | return disco_type_mappings[i].to; |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
277 | } |
|
27312
07a772783c0f
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27263
diff
changeset
|
278 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
279 | |
|
27312
07a772783c0f
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27263
diff
changeset
|
280 | /* 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
|
281 | return str; |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
282 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
283 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
284 | static void |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
285 | got_info_cb(G_GNUC_UNUSED PurpleConnection *pc, const char *type, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
286 | G_GNUC_UNUSED const char *id, const char *from, PurpleXmlNode *iq, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
287 | gpointer data) |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
288 | { |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
289 | struct item_data *item_data = data; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
290 | 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
|
291 | PurpleXmlNode *query; |
|
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 | --list->fetch_count; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
294 | |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
295 | if (!list->in_progress) { |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
296 | goto out; |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
297 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
298 | |
|
38256
035f00c4fd87
Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38086
diff
changeset
|
299 | 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
|
300 | (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
|
301 | PurpleXmlNode *identity = purple_xmlnode_get_child(query, "identity"); |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
302 | XmppDiscoService *service = NULL; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
303 | PurpleXmlNode *feature; |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
304 | |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
305 | service = xmpp_disco_service_new(item_data->list); |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
306 | purple_debug_info("xmppdisco", "parent for %s is %p", from, item_data->parent); |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
307 | xmpp_disco_service_set_service_type(service, |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
308 | disco_service_type_from_identity(identity)); |
|
27217
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 (item_data->node) { |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
311 | if (item_data->name) { |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
312 | xmpp_disco_service_set_name(service, item_data->name); |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
313 | g_clear_pointer(&item_data->name, g_free); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
314 | } else { |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
315 | xmpp_disco_service_set_name(service, item_data->node); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
316 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
317 | |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
318 | xmpp_disco_service_set_node(service, item_data->node); |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
319 | g_clear_pointer(&item_data->node, g_free); |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
320 | |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
321 | if(xmpp_disco_service_get_service_type(service) == XMPP_DISCO_SERVICE_TYPE_PUBSUB_COLLECTION) { |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
322 | xmpp_disco_service_add_flags(service, XMPP_DISCO_BROWSE); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
323 | } |
|
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
324 | } else { |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
325 | xmpp_disco_service_set_name(service, from); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
326 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
327 | |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
328 | if(!xmpp_disco_service_get_node(service)) { |
|
27320
b4fa127ce203
Don't support adding JID+node items.
Paul Aurich <darkrain42@pidgin.im>
parents:
27312
diff
changeset
|
329 | /* Only support adding JIDs, not JID+node combos */ |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
330 | xmpp_disco_service_add_flags(service, XMPP_DISCO_ADD); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
331 | } |
|
27320
b4fa127ce203
Don't support adding JID+node items.
Paul Aurich <darkrain42@pidgin.im>
parents:
27312
diff
changeset
|
332 | |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
333 | if (item_data->name) { |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
334 | xmpp_disco_service_set_description(service, item_data->name); |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
335 | g_clear_pointer(&item_data->name, g_free); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
336 | } else if (identity) { |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
337 | xmpp_disco_service_set_description(service, |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
338 | purple_xmlnode_get_attrib(identity, "name")); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
339 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
340 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
341 | /* TODO: Overlap with service->name a bit */ |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
342 | xmpp_disco_service_set_jid(service, from); |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
343 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
344 | 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
|
345 | 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
|
346 | const char *var; |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
347 | 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
|
348 | continue; |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
349 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
350 | |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
351 | if (purple_strequal(var, NS_REGISTER)) { |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
352 | xmpp_disco_service_add_flags(service, XMPP_DISCO_REGISTER); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
353 | } else if (purple_strequal(var, NS_DISCO_ITEMS)) { |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
354 | xmpp_disco_service_add_flags(service, XMPP_DISCO_BROWSE); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
355 | } else if (purple_strequal(var, NS_MUC)) { |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
356 | xmpp_disco_service_add_flags(service, XMPP_DISCO_BROWSE); |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
357 | xmpp_disco_service_set_service_type(service, |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
358 | XMPP_DISCO_SERVICE_TYPE_CHAT); |
|
27217
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 | |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
362 | if(xmpp_disco_service_get_service_type(service) == XMPP_DISCO_SERVICE_TYPE_GATEWAY) { |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
363 | xmpp_disco_service_set_gateway_type(service, |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
364 | 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
|
365 | purple_xmlnode_get_attrib(identity, "type"))); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
366 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
367 | |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
368 | pidgin_disco_add_service(list, service, item_data->parent); |
|
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 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
371 | out: |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
372 | if (list->fetch_count == 0) { |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
373 | pidgin_disco_list_set_in_progress(list, FALSE); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
374 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
375 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
376 | g_free(item_data->name); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
377 | g_free(item_data->node); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
378 | g_free(item_data); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
379 | pidgin_disco_list_unref(list); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
380 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
381 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
382 | static void |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
383 | got_items_cb(PurpleConnection *pc, const char *type, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
384 | G_GNUC_UNUSED const char *id, G_GNUC_UNUSED const char *from, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
385 | PurpleXmlNode *iq, gpointer data) |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
386 | { |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
387 | struct item_data *item_data = data; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
388 | 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
|
389 | 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
|
390 | gboolean has_items = FALSE; |
|
27217
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 | --list->fetch_count; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
393 | |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
394 | if (!list->in_progress) { |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
395 | goto out; |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
396 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
397 | |
|
38256
035f00c4fd87
Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38086
diff
changeset
|
398 | 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
|
399 | (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
|
400 | PurpleXmlNode *item; |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
401 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
402 | 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
|
403 | 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
|
404 | 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
|
405 | 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
|
406 | 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
|
407 | |
|
27222
9daa676e9244
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents:
27218
diff
changeset
|
408 | 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
|
409 | |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
410 | if(xmpp_disco_service_get_service_type(item_data->parent) == XMPP_DISCO_SERVICE_TYPE_CHAT) { |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
411 | /* 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
|
412 | * 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
|
413 | * 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
|
414 | * |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
415 | * 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
|
416 | * 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
|
417 | */ |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
418 | XmppDiscoService *service = xmpp_disco_service_new(item_data->list); |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
419 | xmpp_disco_service_set_flags(service, XMPP_DISCO_ADD); |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
420 | xmpp_disco_service_set_service_type(service, |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
421 | XMPP_DISCO_SERVICE_TYPE_CHAT); |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
422 | |
|
42088
b8c81e2dab8f
disco: Move chat name to Description column
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42074
diff
changeset
|
423 | xmpp_disco_service_set_name(service, jid); |
|
b8c81e2dab8f
disco: Move chat name to Description column
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42074
diff
changeset
|
424 | xmpp_disco_service_set_description(service, name); |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
425 | xmpp_disco_service_set_jid(service, jid); |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
426 | xmpp_disco_service_set_node(service, node); |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
427 | 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
|
428 | } else { |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
429 | 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
|
430 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
431 | item_data2->list = item_data->list; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
432 | item_data2->parent = item_data->parent; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
433 | item_data2->name = g_strdup(name); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
434 | item_data2->node = g_strdup(node); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
435 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
436 | ++list->fetch_count; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
437 | pidgin_disco_list_ref(list); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
438 | 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
|
439 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
440 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
441 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
442 | |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
443 | if (!has_items) { |
|
27222
9daa676e9244
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents:
27218
diff
changeset
|
444 | pidgin_disco_add_service(list, NULL, item_data->parent); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
445 | } |
|
27222
9daa676e9244
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents:
27218
diff
changeset
|
446 | |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
447 | out: |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
448 | if (list->fetch_count == 0) { |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
449 | pidgin_disco_list_set_in_progress(list, FALSE); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
450 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
451 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
452 | g_free(item_data); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
453 | pidgin_disco_list_unref(list); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
454 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
455 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
456 | static void |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
457 | server_items_cb(PurpleConnection *pc, const char *type, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
458 | G_GNUC_UNUSED const char *id, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
459 | G_GNUC_UNUSED const char *from, PurpleXmlNode *iq, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
460 | gpointer data) |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
461 | { |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
462 | struct item_data *cb_data = data; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
463 | 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
|
464 | PurpleXmlNode *query; |
|
27217
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 | g_free(cb_data); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
467 | --list->fetch_count; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
468 | |
|
38256
035f00c4fd87
Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38086
diff
changeset
|
469 | 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
|
470 | (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
|
471 | PurpleXmlNode *item; |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
472 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
473 | 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
|
474 | 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
|
475 | 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
|
476 | 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
|
477 | 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
|
478 | struct item_data *item_data; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
479 | |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
480 | if (!jid) { |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
481 | continue; |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
482 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
483 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
484 | 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
|
485 | 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
|
486 | 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
|
487 | 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
|
488 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
489 | ++list->fetch_count; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
490 | 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
|
491 | 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
|
492 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
493 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
494 | |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
495 | if (list->fetch_count == 0) { |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
496 | pidgin_disco_list_set_in_progress(list, FALSE); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
497 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
498 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
499 | pidgin_disco_list_unref(list); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
500 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
501 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
502 | static void |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
503 | server_info_cb(PurpleConnection *pc, const char *type, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
504 | G_GNUC_UNUSED 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
|
505 | 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
|
506 | { |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
507 | struct item_data *cb_data = data; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
508 | 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
|
509 | PurpleXmlNode *query; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
510 | PurpleXmlNode *error; |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
511 | gboolean items = FALSE; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
512 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
513 | --list->fetch_count; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
514 | |
|
38256
035f00c4fd87
Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38086
diff
changeset
|
515 | 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
|
516 | (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
|
517 | PurpleXmlNode *feature; |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
518 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
519 | 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
|
520 | 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
|
521 | 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
|
522 | 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
|
523 | items = TRUE; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
524 | break; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
525 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
526 | } |
|
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
|
527 | |
|
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
|
528 | 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
|
529 | 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
|
530 | ++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
|
531 | 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
|
532 | } |
|
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
|
533 | 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
|
534 | 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
|
535 | 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
|
536 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
537 | } |
|
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
|
538 | else { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
539 | 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
|
540 | 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
|
541 | || 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
|
542 | 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
|
543 | _("Server does not exist"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33624
diff
changeset
|
544 | NULL, NULL); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
545 | } else { |
|
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
|
546 | 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
|
547 | _("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
|
548 | 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
|
549 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
550 | 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
|
551 | g_free(cb_data); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
552 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
553 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
554 | pidgin_disco_list_unref(list); |
|
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 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
557 | void xmpp_disco_start(PidginDiscoList *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 | struct item_data *cb_data; |
|
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 | g_return_if_fail(list != NULL); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
562 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
563 | ++list->fetch_count; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
564 | pidgin_disco_list_ref(list); |
|
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 | 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
|
567 | cb_data->list = list; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
568 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
569 | 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
|
570 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
571 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
572 | 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
|
573 | { |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
574 | PidginDiscoList *list = NULL; |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
575 | struct item_data *item_data; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
576 | |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
577 | g_return_if_fail(XMPP_DISCO_IS_SERVICE(service)); |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
578 | |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
579 | if(xmpp_disco_service_get_expanded(service)) { |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
580 | return; |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
581 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
582 | |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
583 | list = xmpp_disco_service_get_list(service); |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
584 | |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
585 | item_data = g_new0(struct item_data, 1); |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
586 | item_data->list = list; |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
587 | item_data->parent = service; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
588 | |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
589 | ++list->fetch_count; |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
590 | pidgin_disco_list_ref(list); |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
591 | |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
592 | pidgin_disco_list_set_in_progress(list, TRUE); |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
593 | |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
594 | xmpp_disco_items_do(list->pc, item_data, |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
595 | xmpp_disco_service_get_jid(service), |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
596 | xmpp_disco_service_get_node(service), |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
597 | got_items_cb); |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
598 | xmpp_disco_service_set_expanded(service, TRUE); |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
599 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
600 | |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
601 | void |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
602 | xmpp_disco_register_service(XmppDiscoService *service) |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
603 | { |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
604 | PidginDiscoList *list = NULL; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
605 | PurpleXmlNode *iq, *query; |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
606 | char *id = generate_next_id(); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
607 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
608 | 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
|
609 | purple_xmlnode_set_attrib(iq, "type", "get"); |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
610 | purple_xmlnode_set_attrib(iq, "to", xmpp_disco_service_get_jid(service)); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
611 | 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
|
612 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
33624
diff
changeset
|
613 | 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
|
614 | 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
|
615 | |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
616 | list = xmpp_disco_service_get_list(service); |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
617 | purple_signal_emit(purple_connection_get_protocol(list->pc), |
|
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
618 | "jabber-sending-xmlnode", list->pc, &iq); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
619 | 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
|
620 | purple_xmlnode_free(iq); |
|
41499
a80a41434f44
Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41473
diff
changeset
|
621 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
622 | g_free(id); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
623 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
624 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
625 | static void |
|
41473
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
626 | create_dialog(G_GNUC_UNUSED GSimpleAction *action, |
|
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
627 | G_GNUC_UNUSED GVariant *parameter, |
|
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
628 | G_GNUC_UNUSED gpointer data) |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
629 | { |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
630 | pidgin_disco_dialog_new(); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
631 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
632 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
633 | static void |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
634 | signed_off_cb(PurpleConnection *pc, G_GNUC_UNUSED gpointer data) |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
635 | { |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
636 | /* Deal with any dialogs */ |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
637 | pidgin_disco_signed_off_cb(pc); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
638 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
639 | /* 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
|
640 | 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
|
641 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
642 | |
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40799
diff
changeset
|
643 | static GPluginPluginInfo * |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
644 | xmpp_disco_query(G_GNUC_UNUSED GError **error) |
|
36754
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
645 | { |
|
41473
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
646 | GActionEntry entries[] = { |
|
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
647 | { |
|
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
648 | .name = "dialog", |
|
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
649 | .activate = create_dialog, |
|
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
650 | } |
|
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
651 | }; |
|
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
652 | GMenu *menu = NULL; |
|
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
653 | GSimpleActionGroup *group = NULL; |
|
36754
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
654 | const gchar * const authors[] = { |
|
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
655 | "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
|
656 | NULL |
|
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
657 | }; |
|
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
658 | |
|
41473
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
659 | group = g_simple_action_group_new(); |
|
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
660 | g_action_map_add_action_entries(G_ACTION_MAP(group), entries, |
|
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
661 | G_N_ELEMENTS(entries), NULL); |
|
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
662 | |
|
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
663 | menu = g_menu_new(); |
|
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
664 | g_menu_append(menu, _("XMPP Service Discovery"), "dialog"); |
|
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
665 | |
|
42453
1c13bc243b7d
Remove PidginPluginInfo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42172
diff
changeset
|
666 | return purple_plugin_info_new( |
|
36754
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
667 | "id", PLUGIN_ID, |
|
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
668 | "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
|
669 | "version", DISPLAY_VERSION, |
|
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
670 | "category", N_("Protocol utility"), |
|
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
671 | "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
|
672 | "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
|
673 | "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
|
674 | "authors", authors, |
|
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
675 | "website", PURPLE_WEBSITE, |
|
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
676 | "abi-version", PURPLE_ABI_VERSION, |
|
41473
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
677 | "action-group", group, |
|
f58243b85b2d
Convert the XMPP discovery plugin to the new GAction/GMenu plugin actions
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
678 | "action-menu", menu, |
|
36754
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
679 | NULL |
|
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
680 | ); |
|
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
681 | } |
|
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
682 | |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
683 | static gboolean |
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40799
diff
changeset
|
684 | xmpp_disco_load(GPluginPlugin *plugin, GError **error) |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
685 | { |
|
36754
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
686 | PurpleProtocol *xmpp_protocol; |
|
40799
fb206d19393f
Port the pidgin plugins from purple_protocols_ to purple_protocol_manager_
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
687 | PurpleProtocolManager *manager; |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
688 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
689 | my_plugin = plugin; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
690 | |
|
40799
fb206d19393f
Port the pidgin plugins from purple_protocols_ to purple_protocol_manager_
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
691 | manager = purple_protocol_manager_get_default(); |
|
fb206d19393f
Port the pidgin plugins from purple_protocols_ to purple_protocol_manager_
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
692 | xmpp_protocol = purple_protocol_manager_find(manager, XMPP_PROTOCOL_ID); |
|
36754
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
693 | if (NULL == xmpp_protocol) { |
|
39921
a9c92a82f4c8
Don't pass literals to g_set_error / g_error_new.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39801
diff
changeset
|
694 | g_set_error_literal(error, PLUGIN_DOMAIN, 0, |
|
a9c92a82f4c8
Don't pass literals to g_set_error / g_error_new.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39801
diff
changeset
|
695 | _("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
|
696 | return FALSE; |
|
36754
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36692
diff
changeset
|
697 | } |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
698 | |
|
42037
af20db93f2c2
Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41913
diff
changeset
|
699 | xmpp_disco_service_register(plugin); |
|
39801
2bbed8148402
Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38358
diff
changeset
|
700 | pidgin_disco_dialog_register(plugin); |
|
2bbed8148402
Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38358
diff
changeset
|
701 | |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
702 | purple_signal_connect(purple_connections_get_handle(), "signing-off", |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41078
diff
changeset
|
703 | plugin, G_CALLBACK(signed_off_cb), NULL); |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
704 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
705 | 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
|
706 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
707 | return TRUE; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
708 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
709 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
710 | static gboolean |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
711 | xmpp_disco_unload(GPluginPlugin *plugin, G_GNUC_UNUSED gboolean unload, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
42037
diff
changeset
|
712 | G_GNUC_UNUSED GError **error) |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
713 | { |
|
42172
7c2d151b410d
Use g_clear_* helpers where useful
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42088
diff
changeset
|
714 | g_clear_pointer(&iq_callbacks, g_hash_table_destroy); |
|
27217
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
715 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
716 | purple_signals_disconnect_by_handle(plugin); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
717 | pidgin_disco_dialogs_destroy_all(); |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
718 | |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
719 | return TRUE; |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
720 | } |
|
7509acac49de
Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
721 | |
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40799
diff
changeset
|
722 | GPLUGIN_NATIVE_PLUGIN_DECLARE(xmpp_disco) |