Sat, 14 Aug 2010 05:17:38 +0000
Fix some "Dead nested assignment"s and then kill off some useless
variables related to them.
| 7014 | 1 | /* |
| 15884 | 2 | * purple - Jabber Protocol Plugin |
| 7014 | 3 | * |
|
28322
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28158
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too numerous |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28158
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28158
diff
changeset
|
6 | * source distribution. |
| 7014 | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19854
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7014 | 21 | * |
| 22 | */ | |
| 23 | #include "internal.h" | |
| 24 | #include "debug.h" | |
|
9713
bb37562302a1
[gaim-migrate @ 10574]
Mark Doliner <markdoliner@pidgin.im>
parents:
9554
diff
changeset
|
25 | #include "prpl.h" /* for proto_chat_entry */ |
| 7310 | 26 | #include "notify.h" |
| 8113 | 27 | #include "request.h" |
| 28 | #include "roomlist.h" | |
| 7971 | 29 | #include "util.h" |
| 7014 | 30 | |
| 31 | #include "chat.h" | |
| 7895 | 32 | #include "iq.h" |
| 7014 | 33 | #include "message.h" |
| 7073 | 34 | #include "presence.h" |
| 7923 | 35 | #include "xdata.h" |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23403
diff
changeset
|
36 | #include "data.h" |
| 7014 | 37 | |
| 15884 | 38 | GList *jabber_chat_info(PurpleConnection *gc) |
| 7014 | 39 | { |
| 40 | GList *m = NULL; | |
| 41 | struct proto_chat_entry *pce; | |
| 42 | ||
| 43 | pce = g_new0(struct proto_chat_entry, 1); | |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7400
diff
changeset
|
44 | pce->label = _("_Room:"); |
| 7014 | 45 | pce->identifier = "room"; |
| 10959 | 46 | pce->required = TRUE; |
| 7014 | 47 | m = g_list_append(m, pce); |
| 48 | ||
| 49 | pce = g_new0(struct proto_chat_entry, 1); | |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7400
diff
changeset
|
50 | pce->label = _("_Server:"); |
| 7014 | 51 | pce->identifier = "server"; |
| 10959 | 52 | pce->required = TRUE; |
| 7014 | 53 | m = g_list_append(m, pce); |
| 54 | ||
| 55 | pce = g_new0(struct proto_chat_entry, 1); | |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7400
diff
changeset
|
56 | pce->label = _("_Handle:"); |
| 7014 | 57 | pce->identifier = "handle"; |
| 10959 | 58 | pce->required = TRUE; |
| 7014 | 59 | m = g_list_append(m, pce); |
| 60 | ||
| 61 | pce = g_new0(struct proto_chat_entry, 1); | |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7400
diff
changeset
|
62 | pce->label = _("_Password:"); |
| 7014 | 63 | pce->identifier = "password"; |
| 64 | pce->secret = TRUE; | |
| 65 | m = g_list_append(m, pce); | |
| 66 | ||
| 67 | return m; | |
| 68 | } | |
| 69 | ||
| 15884 | 70 | GHashTable *jabber_chat_info_defaults(PurpleConnection *gc, const char *chat_name) |
|
9754
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
71 | { |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
72 | GHashTable *defaults; |
|
9770
d61fe8dcb6d9
[gaim-migrate @ 10638]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9762
diff
changeset
|
73 | JabberStream *js = gc->proto_data; |
|
9754
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
74 | |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
75 | defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
76 | |
|
9770
d61fe8dcb6d9
[gaim-migrate @ 10638]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9762
diff
changeset
|
77 | g_hash_table_insert(defaults, "handle", g_strdup(js->user->node)); |
|
d61fe8dcb6d9
[gaim-migrate @ 10638]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9762
diff
changeset
|
78 | |
|
d61fe8dcb6d9
[gaim-migrate @ 10638]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9762
diff
changeset
|
79 | if (js->chat_servers) |
|
d61fe8dcb6d9
[gaim-migrate @ 10638]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9762
diff
changeset
|
80 | g_hash_table_insert(defaults, "server", g_strdup(js->chat_servers->data)); |
|
d61fe8dcb6d9
[gaim-migrate @ 10638]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9762
diff
changeset
|
81 | |
|
9754
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
82 | if (chat_name != NULL) { |
| 9760 | 83 | JabberID *jid = jabber_id_new(chat_name); |
| 84 | if(jid) { | |
| 85 | g_hash_table_insert(defaults, "room", g_strdup(jid->node)); | |
| 86 | if(jid->domain) | |
|
9770
d61fe8dcb6d9
[gaim-migrate @ 10638]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9762
diff
changeset
|
87 | g_hash_table_replace(defaults, "server", g_strdup(jid->domain)); |
| 15185 | 88 | if(jid->resource) |
| 89 | g_hash_table_replace(defaults, "handle", g_strdup(jid->resource)); | |
| 9760 | 90 | jabber_id_free(jid); |
| 91 | } | |
|
9754
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
92 | } |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
93 | |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
94 | return defaults; |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
95 | } |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
96 | |
| 7014 | 97 | JabberChat *jabber_chat_find(JabberStream *js, const char *room, |
| 98 | const char *server) | |
| 99 | { | |
| 10607 | 100 | JabberChat *chat = NULL; |
| 7014 | 101 | |
|
28584
1226297d1ba9
jabber: Don't crash when adding a buddy without a node (no '@'). Closes #10261.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
102 | g_return_val_if_fail(room != NULL, NULL); |
|
1226297d1ba9
jabber: Don't crash when adding a buddy without a node (no '@'). Closes #10261.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
103 | g_return_val_if_fail(server != NULL, NULL); |
|
1226297d1ba9
jabber: Don't crash when adding a buddy without a node (no '@'). Closes #10261.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
104 | |
| 10607 | 105 | if(NULL != js->chats) |
| 106 | { | |
|
23130
7193be04646f
Close up scope of a variable, I'm just cleaning up my tree some.
Etan Reisner <deryni@pidgin.im>
parents:
22919
diff
changeset
|
107 | char *room_jid = g_strdup_printf("%s@%s", room, server); |
| 7014 | 108 | |
|
28687
9de3f49f3b30
jabber: Remove useless jabber_normalize calls now that the data in the hash table
Paul Aurich <darkrain42@pidgin.im>
parents:
28677
diff
changeset
|
109 | chat = g_hash_table_lookup(js->chats, room_jid); |
| 10607 | 110 | g_free(room_jid); |
| 111 | } | |
| 7014 | 112 | |
| 113 | return chat; | |
| 114 | } | |
| 115 | ||
| 116 | struct _find_by_id_data { | |
| 117 | int id; | |
| 118 | JabberChat *chat; | |
| 119 | }; | |
| 120 | ||
|
12323
f52908fb23b0
[gaim-migrate @ 14627]
Richard Laager <rlaager@pidgin.im>
parents:
11393
diff
changeset
|
121 | static void find_by_id_foreach_cb(gpointer key, gpointer value, gpointer user_data) |
| 7014 | 122 | { |
| 123 | JabberChat *chat = value; | |
| 124 | struct _find_by_id_data *fbid = user_data; | |
| 125 | ||
| 126 | if(chat->id == fbid->id) | |
| 127 | fbid->chat = chat; | |
| 128 | } | |
| 129 | ||
| 130 | JabberChat *jabber_chat_find_by_id(JabberStream *js, int id) | |
| 131 | { | |
| 132 | JabberChat *chat; | |
| 133 | struct _find_by_id_data *fbid = g_new0(struct _find_by_id_data, 1); | |
| 7073 | 134 | fbid->id = id; |
| 7014 | 135 | g_hash_table_foreach(js->chats, find_by_id_foreach_cb, fbid); |
| 136 | chat = fbid->chat; | |
| 137 | g_free(fbid); | |
| 138 | return chat; | |
| 139 | } | |
| 140 | ||
| 15884 | 141 | JabberChat *jabber_chat_find_by_conv(PurpleConversation *conv) |
| 9130 | 142 | { |
| 15884 | 143 | PurpleAccount *account = purple_conversation_get_account(conv); |
| 144 | PurpleConnection *gc = purple_account_get_connection(account); | |
|
22804
3a3bc5f12e52
Do not crash from commands in a disconnected chat. Fixes #5208
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
145 | JabberStream *js; |
|
3a3bc5f12e52
Do not crash from commands in a disconnected chat. Fixes #5208
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
146 | int id; |
|
3a3bc5f12e52
Do not crash from commands in a disconnected chat. Fixes #5208
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
147 | if (!gc) |
|
3a3bc5f12e52
Do not crash from commands in a disconnected chat. Fixes #5208
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
148 | return NULL; |
|
3a3bc5f12e52
Do not crash from commands in a disconnected chat. Fixes #5208
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
149 | js = gc->proto_data; |
|
3a3bc5f12e52
Do not crash from commands in a disconnected chat. Fixes #5208
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
150 | id = purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)); |
| 9130 | 151 | return jabber_chat_find_by_id(js, id); |
| 152 | } | |
| 153 | ||
| 15884 | 154 | void jabber_chat_invite(PurpleConnection *gc, int id, const char *msg, |
| 7014 | 155 | const char *name) |
| 156 | { | |
| 157 | JabberStream *js = gc->proto_data; | |
| 158 | JabberChat *chat; | |
| 159 | xmlnode *message, *body, *x, *invite; | |
| 160 | char *room_jid; | |
| 161 | ||
| 162 | chat = jabber_chat_find_by_id(js, id); | |
| 163 | if(!chat) | |
| 164 | return; | |
| 165 | ||
| 166 | message = xmlnode_new("message"); | |
| 167 | ||
| 168 | room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 169 | ||
| 170 | if(chat->muc) { | |
| 171 | xmlnode_set_attrib(message, "to", room_jid); | |
| 172 | x = xmlnode_new_child(message, "x"); | |
| 13808 | 173 | xmlnode_set_namespace(x, "http://jabber.org/protocol/muc#user"); |
| 7014 | 174 | invite = xmlnode_new_child(x, "invite"); |
| 175 | xmlnode_set_attrib(invite, "to", name); | |
|
30581
c63679097d60
jabber: Avoid an assertion warning
Paul Aurich <darkrain42@pidgin.im>
parents:
29400
diff
changeset
|
176 | if (msg) { |
|
c63679097d60
jabber: Avoid an assertion warning
Paul Aurich <darkrain42@pidgin.im>
parents:
29400
diff
changeset
|
177 | body = xmlnode_new_child(invite, "reason"); |
|
c63679097d60
jabber: Avoid an assertion warning
Paul Aurich <darkrain42@pidgin.im>
parents:
29400
diff
changeset
|
178 | xmlnode_insert_data(body, msg, -1); |
|
c63679097d60
jabber: Avoid an assertion warning
Paul Aurich <darkrain42@pidgin.im>
parents:
29400
diff
changeset
|
179 | } |
| 7014 | 180 | } else { |
| 181 | xmlnode_set_attrib(message, "to", name); | |
|
28703
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28687
diff
changeset
|
182 | /* |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28687
diff
changeset
|
183 | * Putting the reason into the body was an 'undocumented protocol, |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28687
diff
changeset
|
184 | * ...not part of "groupchat 1.0"'. |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28687
diff
changeset
|
185 | * http://xmpp.org/extensions/attic/jep-0045-1.16.html#invite |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28687
diff
changeset
|
186 | * |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28687
diff
changeset
|
187 | * Left here for compatibility. |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28687
diff
changeset
|
188 | */ |
|
30581
c63679097d60
jabber: Avoid an assertion warning
Paul Aurich <darkrain42@pidgin.im>
parents:
29400
diff
changeset
|
189 | if (msg) { |
|
c63679097d60
jabber: Avoid an assertion warning
Paul Aurich <darkrain42@pidgin.im>
parents:
29400
diff
changeset
|
190 | body = xmlnode_new_child(message, "body"); |
|
c63679097d60
jabber: Avoid an assertion warning
Paul Aurich <darkrain42@pidgin.im>
parents:
29400
diff
changeset
|
191 | xmlnode_insert_data(body, msg, -1); |
|
c63679097d60
jabber: Avoid an assertion warning
Paul Aurich <darkrain42@pidgin.im>
parents:
29400
diff
changeset
|
192 | } |
|
28703
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28687
diff
changeset
|
193 | |
| 7014 | 194 | x = xmlnode_new_child(message, "x"); |
| 195 | xmlnode_set_attrib(x, "jid", room_jid); | |
|
28703
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28687
diff
changeset
|
196 | |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28687
diff
changeset
|
197 | /* The better place for it! XEP-0249 style. */ |
|
30581
c63679097d60
jabber: Avoid an assertion warning
Paul Aurich <darkrain42@pidgin.im>
parents:
29400
diff
changeset
|
198 | if (msg) |
|
c63679097d60
jabber: Avoid an assertion warning
Paul Aurich <darkrain42@pidgin.im>
parents:
29400
diff
changeset
|
199 | xmlnode_set_attrib(x, "reason", msg); |
| 13808 | 200 | xmlnode_set_namespace(x, "jabber:x:conference"); |
| 7014 | 201 | } |
| 202 | ||
| 203 | jabber_send(js, message); | |
| 204 | xmlnode_free(message); | |
| 205 | g_free(room_jid); | |
| 206 | } | |
| 207 | ||
| 9152 | 208 | void jabber_chat_member_free(JabberChatMember *jcm); |
| 209 | ||
|
9917
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
210 | char *jabber_get_chat_name(GHashTable *data) { |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
211 | char *room, *server, *chat_name = NULL; |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
212 | |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
213 | room = g_hash_table_lookup(data, "room"); |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
214 | server = g_hash_table_lookup(data, "server"); |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
215 | |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
216 | if (room && server) { |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
217 | chat_name = g_strdup_printf("%s@%s", room, server); |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
218 | } |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
219 | return chat_name; |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
220 | } |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
221 | |
|
23273
c42eae02c76e
g_hash_table_ref() / g_hash_table_unref() were added in too recent a glib version per Mark. Copy data to chat->components rather than using those.
Evan Schoenberg <evands@pidgin.im>
parents:
23270
diff
changeset
|
222 | static void insert_in_hash_table(gpointer key, gpointer value, gpointer user_data) |
|
c42eae02c76e
g_hash_table_ref() / g_hash_table_unref() were added in too recent a glib version per Mark. Copy data to chat->components rather than using those.
Evan Schoenberg <evands@pidgin.im>
parents:
23270
diff
changeset
|
223 | { |
|
c42eae02c76e
g_hash_table_ref() / g_hash_table_unref() were added in too recent a glib version per Mark. Copy data to chat->components rather than using those.
Evan Schoenberg <evands@pidgin.im>
parents:
23270
diff
changeset
|
224 | GHashTable *hash_table = (GHashTable *)user_data; |
|
23275
c8599f5dac4c
The key and value need to be g_stdup()'d before adding to the hash table
Evan Schoenberg <evands@pidgin.im>
parents:
23273
diff
changeset
|
225 | g_hash_table_insert(hash_table, g_strdup(key), g_strdup(value)); |
|
23273
c42eae02c76e
g_hash_table_ref() / g_hash_table_unref() were added in too recent a glib version per Mark. Copy data to chat->components rather than using those.
Evan Schoenberg <evands@pidgin.im>
parents:
23270
diff
changeset
|
226 | } |
|
c42eae02c76e
g_hash_table_ref() / g_hash_table_unref() were added in too recent a glib version per Mark. Copy data to chat->components rather than using those.
Evan Schoenberg <evands@pidgin.im>
parents:
23270
diff
changeset
|
227 | |
|
28668
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
228 | static JabberChat *jabber_chat_new(JabberStream *js, const char *room, |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
229 | const char *server, const char *handle, |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
230 | const char *password, GHashTable *data) |
| 7014 | 231 | { |
| 232 | JabberChat *chat; | |
|
28668
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
233 | char *jid; |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
234 | |
|
28677
5615313acca3
jabber: Reduce these from assertions to checks.
Paul Aurich <darkrain42@pidgin.im>
parents:
28669
diff
changeset
|
235 | if (jabber_chat_find(js, room, server) != NULL) |
|
5615313acca3
jabber: Reduce these from assertions to checks.
Paul Aurich <darkrain42@pidgin.im>
parents:
28669
diff
changeset
|
236 | return NULL; |
|
28668
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
237 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
238 | chat = g_new0(JabberChat, 1); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
239 | chat->js = js; |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
240 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
241 | chat->room = g_strdup(room); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
242 | chat->server = g_strdup(server); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
243 | chat->handle = g_strdup(handle); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
244 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
245 | /* Copy the data hash table to chat->components */ |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
246 | chat->components = g_hash_table_new_full(g_str_hash, g_str_equal, |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
247 | g_free, g_free); |
|
28669
f67839ca0064
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <darkrain42@pidgin.im>
parents:
28668
diff
changeset
|
248 | if (data == NULL) { |
|
f67839ca0064
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <darkrain42@pidgin.im>
parents:
28668
diff
changeset
|
249 | g_hash_table_insert(chat->components, g_strdup("handle"), g_strdup(handle)); |
|
f67839ca0064
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <darkrain42@pidgin.im>
parents:
28668
diff
changeset
|
250 | g_hash_table_insert(chat->components, g_strdup("room"), g_strdup(room)); |
|
f67839ca0064
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <darkrain42@pidgin.im>
parents:
28668
diff
changeset
|
251 | g_hash_table_insert(chat->components, g_strdup("server"), g_strdup(server)); |
|
f67839ca0064
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <darkrain42@pidgin.im>
parents:
28668
diff
changeset
|
252 | /* g_hash_table_insert(chat->components, g_strdup("password"), g_strdup(server)); */ |
|
f67839ca0064
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <darkrain42@pidgin.im>
parents:
28668
diff
changeset
|
253 | } else { |
|
f67839ca0064
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <darkrain42@pidgin.im>
parents:
28668
diff
changeset
|
254 | g_hash_table_foreach(data, insert_in_hash_table, chat->components); |
|
f67839ca0064
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <darkrain42@pidgin.im>
parents:
28668
diff
changeset
|
255 | } |
|
28668
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
256 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
257 | chat->members = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
258 | (GDestroyNotify)jabber_chat_member_free); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
259 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
260 | jid = g_strdup_printf("%s@%s", room, server); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
261 | g_hash_table_insert(js->chats, jid, chat); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
262 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
263 | return chat; |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
264 | } |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
265 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
266 | JabberChat *jabber_join_chat(JabberStream *js, const char *room, |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
267 | const char *server, const char *handle, |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
268 | const char *password, GHashTable *data) |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
269 | { |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
270 | JabberChat *chat; |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
271 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
272 | PurpleConnection *gc; |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
273 | PurpleAccount *account; |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
274 | PurpleStatus *status; |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
275 | |
| 7014 | 276 | xmlnode *presence, *x; |
| 9954 | 277 | JabberBuddyState state; |
| 14525 | 278 | char *msg; |
| 9954 | 279 | int priority; |
| 7014 | 280 | |
|
28668
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
281 | char *jid; |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
282 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
283 | chat = jabber_chat_new(js, room, server, handle, password, data); |
|
28677
5615313acca3
jabber: Reduce these from assertions to checks.
Paul Aurich <darkrain42@pidgin.im>
parents:
28669
diff
changeset
|
284 | if (chat == NULL) |
|
5615313acca3
jabber: Reduce these from assertions to checks.
Paul Aurich <darkrain42@pidgin.im>
parents:
28669
diff
changeset
|
285 | return NULL; |
|
28668
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
286 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
287 | gc = js->gc; |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
288 | account = purple_connection_get_account(gc); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
289 | status = purple_account_get_active_status(account); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
290 | purple_status_to_jabber(status, &state, &msg, &priority); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
291 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
292 | presence = jabber_presence_create_js(js, state, msg, priority); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
293 | g_free(msg); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
294 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
295 | jid = g_strdup_printf("%s@%s/%s", room, server, handle); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
296 | xmlnode_set_attrib(presence, "to", jid); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
297 | g_free(jid); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
298 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
299 | x = xmlnode_new_child(presence, "x"); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
300 | xmlnode_set_namespace(x, "http://jabber.org/protocol/muc"); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
301 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
302 | if (password && *password) { |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
303 | xmlnode *p = xmlnode_new_child(x, "password"); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
304 | xmlnode_insert_data(p, password, -1); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
305 | } |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
306 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
307 | jabber_send(js, presence); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
308 | xmlnode_free(presence); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
309 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
310 | return chat; |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
311 | } |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
312 | |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
313 | void jabber_chat_join(PurpleConnection *gc, GHashTable *data) |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
314 | { |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
315 | char *room, *server, *handle, *passwd; |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
316 | JabberID *jid; |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
317 | JabberStream *js = gc->proto_data; |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
318 | char *tmp; |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
319 | |
| 7014 | 320 | room = g_hash_table_lookup(data, "room"); |
| 321 | server = g_hash_table_lookup(data, "server"); | |
| 322 | handle = g_hash_table_lookup(data, "handle"); | |
| 323 | passwd = g_hash_table_lookup(data, "password"); | |
| 324 | ||
| 8113 | 325 | if(!room || !server) |
| 7014 | 326 | return; |
| 327 | ||
| 8113 | 328 | if(!handle) |
| 329 | handle = js->user->node; | |
| 330 | ||
| 7310 | 331 | if(!jabber_nodeprep_validate(room)) { |
| 332 | char *buf = g_strdup_printf(_("%s is not a valid room name"), room); | |
| 15884 | 333 | purple_notify_error(gc, _("Invalid Room Name"), _("Invalid Room Name"), |
| 7310 | 334 | buf); |
|
23270
2b7db16e721a
As discussed on the devel list, purple_serv_got_join_chat_failed() and the
Evan Schoenberg <evands@pidgin.im>
parents:
22920
diff
changeset
|
335 | purple_serv_got_join_chat_failed(gc, data); |
| 7310 | 336 | g_free(buf); |
| 337 | return; | |
|
27728
03b2a20ba465
Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <darkrain42@pidgin.im>
parents:
27155
diff
changeset
|
338 | } else if(!jabber_domain_validate(server)) { |
| 7310 | 339 | char *buf = g_strdup_printf(_("%s is not a valid server name"), server); |
| 15884 | 340 | purple_notify_error(gc, _("Invalid Server Name"), |
| 7310 | 341 | _("Invalid Server Name"), buf); |
|
23270
2b7db16e721a
As discussed on the devel list, purple_serv_got_join_chat_failed() and the
Evan Schoenberg <evands@pidgin.im>
parents:
22920
diff
changeset
|
342 | purple_serv_got_join_chat_failed(gc, data); |
| 7310 | 343 | g_free(buf); |
| 344 | return; | |
| 345 | } else if(!jabber_resourceprep_validate(handle)) { | |
| 346 | char *buf = g_strdup_printf(_("%s is not a valid room handle"), handle); | |
| 15884 | 347 | purple_notify_error(gc, _("Invalid Room Handle"), |
| 7310 | 348 | _("Invalid Room Handle"), buf); |
|
23270
2b7db16e721a
As discussed on the devel list, purple_serv_got_join_chat_failed() and the
Evan Schoenberg <evands@pidgin.im>
parents:
22920
diff
changeset
|
349 | purple_serv_got_join_chat_failed(gc, data); |
|
22902
560976846e56
Fix a small memory leak when failing to join a jabber conference
Mark Doliner <markdoliner@pidgin.im>
parents:
22804
diff
changeset
|
350 | g_free(buf); |
|
560976846e56
Fix a small memory leak when failing to join a jabber conference
Mark Doliner <markdoliner@pidgin.im>
parents:
22804
diff
changeset
|
351 | return; |
| 7310 | 352 | } |
| 353 | ||
|
28668
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
354 | /* Normalize the room and server parameters */ |
|
23270
2b7db16e721a
As discussed on the devel list, purple_serv_got_join_chat_failed() and the
Evan Schoenberg <evands@pidgin.im>
parents:
22920
diff
changeset
|
355 | tmp = g_strdup_printf("%s@%s", room, server); |
|
28668
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
356 | jid = jabber_id_new(tmp); |
|
23270
2b7db16e721a
As discussed on the devel list, purple_serv_got_join_chat_failed() and the
Evan Schoenberg <evands@pidgin.im>
parents:
22920
diff
changeset
|
357 | g_free(tmp); |
|
2b7db16e721a
As discussed on the devel list, purple_serv_got_join_chat_failed() and the
Evan Schoenberg <evands@pidgin.im>
parents:
22920
diff
changeset
|
358 | |
|
28668
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
359 | if (jid == NULL) { |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
360 | /* TODO: Error message */ |
| 7014 | 361 | |
|
28668
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
362 | g_return_if_reached(); |
| 7014 | 363 | } |
| 364 | ||
|
28668
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
365 | /* |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
366 | * Now that we've done all that nice core-interface stuff, let's join |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
367 | * this room! |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
368 | */ |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
369 | jabber_join_chat(js, jid->node, jid->domain, handle, passwd, data); |
|
2f7479b4d0c0
jabber: Refactor the chat-joining code
Paul Aurich <darkrain42@pidgin.im>
parents:
28584
diff
changeset
|
370 | jabber_id_free(jid); |
| 7014 | 371 | } |
| 372 | ||
| 15884 | 373 | void jabber_chat_leave(PurpleConnection *gc, int id) |
| 7014 | 374 | { |
| 375 | JabberStream *js = gc->proto_data; | |
| 376 | JabberChat *chat = jabber_chat_find_by_id(js, id); | |
| 7974 | 377 | |
| 7014 | 378 | |
| 379 | if(!chat) | |
| 380 | return; | |
| 381 | ||
| 7974 | 382 | jabber_chat_part(chat, NULL); |
| 9152 | 383 | |
|
23403
a8704d47889f
Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
384 | chat->left = TRUE; |
| 7014 | 385 | } |
| 386 | ||
| 387 | void jabber_chat_destroy(JabberChat *chat) | |
| 388 | { | |
| 389 | JabberStream *js = chat->js; | |
| 390 | char *room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 391 | ||
|
28687
9de3f49f3b30
jabber: Remove useless jabber_normalize calls now that the data in the hash table
Paul Aurich <darkrain42@pidgin.im>
parents:
28677
diff
changeset
|
392 | g_hash_table_remove(js->chats, room_jid); |
| 7014 | 393 | g_free(room_jid); |
| 8396 | 394 | } |
| 395 | ||
| 396 | void jabber_chat_free(JabberChat *chat) | |
| 397 | { | |
| 398 | if(chat->config_dialog_handle) | |
| 15884 | 399 | purple_request_close(chat->config_dialog_type, chat->config_dialog_handle); |
| 7014 | 400 | |
| 401 | g_free(chat->room); | |
| 402 | g_free(chat->server); | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10474
diff
changeset
|
403 | g_free(chat->handle); |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10474
diff
changeset
|
404 | g_hash_table_destroy(chat->members); |
|
23273
c42eae02c76e
g_hash_table_ref() / g_hash_table_unref() were added in too recent a glib version per Mark. Copy data to chat->components rather than using those.
Evan Schoenberg <evands@pidgin.im>
parents:
23270
diff
changeset
|
405 | g_hash_table_destroy(chat->components); |
| 7014 | 406 | g_free(chat); |
| 407 | } | |
| 408 | ||
| 15884 | 409 | gboolean jabber_chat_find_buddy(PurpleConversation *conv, const char *name) |
| 7014 | 410 | { |
| 15884 | 411 | return purple_conv_chat_find_user(PURPLE_CONV_CHAT(conv), name); |
| 7014 | 412 | } |
| 413 | ||
| 15884 | 414 | char *jabber_chat_buddy_real_name(PurpleConnection *gc, int id, const char *who) |
| 7398 | 415 | { |
| 416 | JabberStream *js = gc->proto_data; | |
| 417 | JabberChat *chat; | |
|
23499
3d18632e27a3
Return the real JID (if available) from the xmpp get_cb_real_name function.
Daniel Atallah <datallah@pidgin.im>
parents:
23403
diff
changeset
|
418 | JabberChatMember *jcm; |
| 7398 | 419 | |
| 420 | chat = jabber_chat_find_by_id(js, id); | |
| 421 | ||
| 422 | if(!chat) | |
| 423 | return NULL; | |
| 424 | ||
|
23499
3d18632e27a3
Return the real JID (if available) from the xmpp get_cb_real_name function.
Daniel Atallah <datallah@pidgin.im>
parents:
23403
diff
changeset
|
425 | jcm = g_hash_table_lookup(chat->members, who); |
|
3d18632e27a3
Return the real JID (if available) from the xmpp get_cb_real_name function.
Daniel Atallah <datallah@pidgin.im>
parents:
23403
diff
changeset
|
426 | if (jcm != NULL && jcm->jid) |
|
3d18632e27a3
Return the real JID (if available) from the xmpp get_cb_real_name function.
Daniel Atallah <datallah@pidgin.im>
parents:
23403
diff
changeset
|
427 | return g_strdup(jcm->jid); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24254
diff
changeset
|
428 | |
|
23499
3d18632e27a3
Return the real JID (if available) from the xmpp get_cb_real_name function.
Daniel Atallah <datallah@pidgin.im>
parents:
23403
diff
changeset
|
429 | |
| 7398 | 430 | return g_strdup_printf("%s@%s/%s", chat->room, chat->server, who); |
| 431 | } | |
| 7895 | 432 | |
| 7923 | 433 | static void jabber_chat_room_configure_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) |
| 434 | { | |
| 435 | JabberChat *chat = data; | |
| 436 | xmlnode *query; | |
| 437 | JabberIq *iq; | |
| 438 | char *to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 439 | ||
| 440 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "http://jabber.org/protocol/muc#owner"); | |
| 441 | xmlnode_set_attrib(iq->node, "to", to); | |
| 442 | g_free(to); | |
| 443 | ||
| 444 | query = xmlnode_get_child(iq->node, "query"); | |
| 445 | ||
| 446 | xmlnode_insert_child(query, result); | |
| 447 | ||
| 448 | jabber_iq_send(iq); | |
| 449 | } | |
| 450 | ||
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
451 | static void jabber_chat_room_configure_cb(JabberStream *js, const char *from, |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
452 | JabberIqType type, const char *id, |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
453 | xmlnode *packet, gpointer data) |
| 7923 | 454 | { |
| 455 | xmlnode *query, *x; | |
| 7926 | 456 | char *msg; |
| 7923 | 457 | JabberChat *chat; |
| 458 | JabberID *jid; | |
| 459 | ||
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
460 | if (!from) |
| 7923 | 461 | return; |
| 462 | ||
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
463 | if (type == JABBER_IQ_RESULT) { |
| 7923 | 464 | jid = jabber_id_new(from); |
| 465 | ||
| 466 | if(!jid) | |
| 467 | return; | |
| 468 | ||
| 469 | chat = jabber_chat_find(js, jid->node, jid->domain); | |
| 470 | jabber_id_free(jid); | |
| 471 | ||
| 472 | if(!chat) | |
| 473 | return; | |
| 474 | ||
| 475 | if(!(query = xmlnode_get_child(packet, "query"))) | |
| 476 | return; | |
| 477 | ||
| 8135 | 478 | for(x = xmlnode_get_child(query, "x"); x; x = xmlnode_get_next_twin(x)) { |
| 7923 | 479 | const char *xmlns; |
| 13808 | 480 | if(!(xmlns = xmlnode_get_namespace(x))) |
| 7923 | 481 | continue; |
| 482 | ||
| 483 | if(!strcmp(xmlns, "jabber:x:data")) { | |
| 15884 | 484 | chat->config_dialog_type = PURPLE_REQUEST_FIELDS; |
| 8396 | 485 | chat->config_dialog_handle = jabber_x_data_request(js, x, jabber_chat_room_configure_x_data_cb, chat); |
| 7923 | 486 | return; |
| 487 | } | |
| 488 | } | |
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
489 | } else if (type == JABBER_IQ_ERROR) { |
|
21150
bedd1215fb5e
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
490 | char *msg = jabber_parse_error(js, packet, NULL); |
| 7926 | 491 | |
| 15884 | 492 | purple_notify_error(js->gc, _("Configuration error"), _("Configuration error"), msg); |
| 7926 | 493 | |
| 8401 | 494 | if(msg) |
| 495 | g_free(msg); | |
| 7926 | 496 | return; |
| 7923 | 497 | } |
| 498 | ||
| 7926 | 499 | msg = g_strdup_printf("Unable to configure room %s", from); |
| 500 | ||
| 15884 | 501 | purple_notify_info(js->gc, _("Unable to configure"), _("Unable to configure"), msg); |
| 7926 | 502 | g_free(msg); |
| 7923 | 503 | |
| 504 | } | |
| 505 | ||
| 506 | void jabber_chat_request_room_configure(JabberChat *chat) { | |
| 507 | JabberIq *iq; | |
| 508 | char *room_jid; | |
| 509 | ||
| 7895 | 510 | if(!chat) |
| 511 | return; | |
| 512 | ||
| 8396 | 513 | chat->config_dialog_handle = NULL; |
| 514 | ||
| 7955 | 515 | if(!chat->muc) { |
| 15884 | 516 | purple_notify_error(chat->js->gc, _("Room Configuration Error"), _("Room Configuration Error"), |
| 7955 | 517 | _("This room is not capable of being configured")); |
| 518 | return; | |
| 519 | } | |
| 520 | ||
| 10474 | 521 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, |
| 7923 | 522 | "http://jabber.org/protocol/muc#owner"); |
| 523 | room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 7895 | 524 | |
| 7923 | 525 | xmlnode_set_attrib(iq->node, "to", room_jid); |
| 526 | ||
| 527 | jabber_iq_set_callback(iq, jabber_chat_room_configure_cb, NULL); | |
| 528 | ||
| 529 | jabber_iq_send(iq); | |
| 530 | ||
| 531 | g_free(room_jid); | |
| 7895 | 532 | } |
| 533 | ||
| 534 | void jabber_chat_create_instant_room(JabberChat *chat) { | |
| 535 | JabberIq *iq; | |
| 536 | xmlnode *query, *x; | |
| 537 | char *room_jid; | |
| 538 | ||
| 539 | if(!chat) | |
| 540 | return; | |
| 541 | ||
| 8396 | 542 | chat->config_dialog_handle = NULL; |
| 543 | ||
| 7895 | 544 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, |
| 545 | "http://jabber.org/protocol/muc#owner"); | |
| 546 | query = xmlnode_get_child(iq->node, "query"); | |
| 547 | x = xmlnode_new_child(query, "x"); | |
| 548 | room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 549 | ||
| 550 | xmlnode_set_attrib(iq->node, "to", room_jid); | |
| 13808 | 551 | xmlnode_set_namespace(x, "jabber:x:data"); |
| 7895 | 552 | xmlnode_set_attrib(x, "type", "submit"); |
| 553 | ||
| 554 | jabber_iq_send(iq); | |
| 555 | ||
| 556 | g_free(room_jid); | |
| 557 | } | |
| 7955 | 558 | |
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
559 | static void |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
560 | jabber_chat_register_x_data_result_cb(JabberStream *js, const char *from, |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
561 | JabberIqType type, const char *id, |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
562 | xmlnode *packet, gpointer data) |
| 7955 | 563 | { |
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
564 | if (type == JABBER_IQ_ERROR) { |
|
21150
bedd1215fb5e
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
565 | char *msg = jabber_parse_error(js, packet, NULL); |
| 8401 | 566 | |
| 15884 | 567 | purple_notify_error(js->gc, _("Registration error"), _("Registration error"), msg); |
| 8401 | 568 | |
| 569 | if(msg) | |
| 570 | g_free(msg); | |
| 571 | return; | |
| 7955 | 572 | } |
| 573 | } | |
| 574 | ||
| 575 | static void jabber_chat_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) | |
| 576 | { | |
| 577 | JabberChat *chat = data; | |
| 578 | xmlnode *query; | |
| 579 | JabberIq *iq; | |
| 580 | char *to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 581 | ||
| 582 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 583 | xmlnode_set_attrib(iq->node, "to", to); | |
| 584 | g_free(to); | |
| 585 | ||
| 586 | query = xmlnode_get_child(iq->node, "query"); | |
| 587 | ||
| 588 | xmlnode_insert_child(query, result); | |
| 589 | ||
| 590 | jabber_iq_set_callback(iq, jabber_chat_register_x_data_result_cb, NULL); | |
| 591 | ||
| 592 | jabber_iq_send(iq); | |
| 593 | } | |
| 594 | ||
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
595 | static void jabber_chat_register_cb(JabberStream *js, const char *from, |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
596 | JabberIqType type, const char *id, |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
597 | xmlnode *packet, gpointer data) |
| 7955 | 598 | { |
| 599 | xmlnode *query, *x; | |
| 600 | char *msg; | |
| 601 | JabberChat *chat; | |
| 602 | JabberID *jid; | |
| 603 | ||
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
604 | if (!from) |
| 7955 | 605 | return; |
| 606 | ||
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
607 | if (type == JABBER_IQ_RESULT) { |
| 7955 | 608 | jid = jabber_id_new(from); |
| 609 | ||
| 610 | if(!jid) | |
| 611 | return; | |
| 612 | ||
| 613 | chat = jabber_chat_find(js, jid->node, jid->domain); | |
| 614 | jabber_id_free(jid); | |
| 615 | ||
| 616 | if(!chat) | |
| 617 | return; | |
| 618 | ||
| 619 | if(!(query = xmlnode_get_child(packet, "query"))) | |
| 620 | return; | |
| 621 | ||
| 8135 | 622 | for(x = xmlnode_get_child(query, "x"); x; x = xmlnode_get_next_twin(x)) { |
| 7955 | 623 | const char *xmlns; |
| 624 | ||
| 13808 | 625 | if(!(xmlns = xmlnode_get_namespace(x))) |
| 7955 | 626 | continue; |
| 627 | ||
| 628 | if(!strcmp(xmlns, "jabber:x:data")) { | |
| 629 | jabber_x_data_request(js, x, jabber_chat_register_x_data_cb, chat); | |
| 630 | return; | |
| 631 | } | |
| 632 | } | |
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
633 | } else if (type == JABBER_IQ_ERROR) { |
|
21150
bedd1215fb5e
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
634 | char *msg = jabber_parse_error(js, packet, NULL); |
| 7955 | 635 | |
| 15884 | 636 | purple_notify_error(js->gc, _("Registration error"), _("Registration error"), msg); |
| 7955 | 637 | |
| 8401 | 638 | if(msg) |
| 639 | g_free(msg); | |
| 7955 | 640 | return; |
| 641 | } | |
| 642 | ||
| 643 | msg = g_strdup_printf("Unable to configure room %s", from); | |
| 644 | ||
| 15884 | 645 | purple_notify_info(js->gc, _("Unable to configure"), _("Unable to configure"), msg); |
| 7955 | 646 | g_free(msg); |
| 647 | ||
| 648 | } | |
| 649 | ||
| 650 | void jabber_chat_register(JabberChat *chat) | |
| 651 | { | |
| 652 | JabberIq *iq; | |
| 653 | char *room_jid; | |
| 654 | ||
| 655 | if(!chat) | |
| 656 | return; | |
| 657 | ||
| 658 | room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 659 | ||
| 660 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, "jabber:iq:register"); | |
| 661 | xmlnode_set_attrib(iq->node, "to", room_jid); | |
| 662 | g_free(room_jid); | |
| 663 | ||
| 664 | jabber_iq_set_callback(iq, jabber_chat_register_cb, NULL); | |
| 665 | ||
| 666 | jabber_iq_send(iq); | |
| 667 | } | |
| 668 | ||
| 7971 | 669 | /* merge this with the function below when we get everyone on the same page wrt /commands */ |
| 670 | void jabber_chat_change_topic(JabberChat *chat, const char *topic) | |
| 671 | { | |
|
26859
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
672 | JabberMessage *jm; |
|
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
673 | |
|
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
674 | jm = g_new0(JabberMessage, 1); |
|
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
675 | jm->js = chat->js; |
|
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
676 | jm->type = JABBER_MESSAGE_GROUPCHAT; |
|
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
677 | jm->to = g_strdup_printf("%s@%s", chat->room, chat->server); |
| 7955 | 678 | |
|
26859
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
679 | if (topic && *topic) |
|
28130
a29344f04ec9
Set XMPP chat topic when it contains a < followed by a character. Closes #5712.
Paul Aurich <darkrain42@pidgin.im>
parents:
27728
diff
changeset
|
680 | jm->subject = g_strdup(topic); |
|
26859
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
681 | else |
|
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
682 | jm->subject = g_strdup(""); |
| 7971 | 683 | |
|
26859
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
684 | jabber_message_send(jm); |
|
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
685 | jabber_message_free(jm); |
| 7971 | 686 | } |
| 687 | ||
| 15884 | 688 | void jabber_chat_set_topic(PurpleConnection *gc, int id, const char *topic) |
| 7971 | 689 | { |
|
26859
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
690 | JabberStream *js = purple_connection_get_protocol_data(gc); |
| 7971 | 691 | JabberChat *chat = jabber_chat_find_by_id(js, id); |
| 692 | ||
| 693 | if(!chat) | |
| 694 | return; | |
| 695 | ||
| 696 | jabber_chat_change_topic(chat, topic); | |
| 697 | } | |
| 698 | ||
| 699 | ||
|
28734
886d6c5e8f9a
jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <darkrain42@pidgin.im>
parents:
28703
diff
changeset
|
700 | gboolean jabber_chat_change_nick(JabberChat *chat, const char *nick) |
| 7972 | 701 | { |
| 702 | xmlnode *presence; | |
| 703 | char *full_jid; | |
|
28734
886d6c5e8f9a
jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <darkrain42@pidgin.im>
parents:
28703
diff
changeset
|
704 | PurpleAccount *account; |
| 15884 | 705 | PurpleStatus *status; |
| 9954 | 706 | JabberBuddyState state; |
| 14525 | 707 | char *msg; |
| 9954 | 708 | int priority; |
| 7972 | 709 | |
| 710 | if(!chat->muc) { | |
| 15884 | 711 | purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "", |
| 7972 | 712 | _("Nick changing not supported in non-MUC chatrooms"), |
| 15884 | 713 | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
28734
886d6c5e8f9a
jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <darkrain42@pidgin.im>
parents:
28703
diff
changeset
|
714 | return FALSE; |
| 7972 | 715 | } |
| 716 | ||
|
28734
886d6c5e8f9a
jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <darkrain42@pidgin.im>
parents:
28703
diff
changeset
|
717 | account = purple_connection_get_account(chat->js->gc); |
|
886d6c5e8f9a
jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <darkrain42@pidgin.im>
parents:
28703
diff
changeset
|
718 | status = purple_account_get_active_status(account); |
| 9954 | 719 | |
| 15884 | 720 | purple_status_to_jabber(status, &state, &msg, &priority); |
| 9954 | 721 | |
|
17770
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17007
diff
changeset
|
722 | presence = jabber_presence_create_js(chat->js, state, msg, priority); |
| 7972 | 723 | full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, nick); |
| 724 | xmlnode_set_attrib(presence, "to", full_jid); | |
| 725 | g_free(full_jid); | |
| 14525 | 726 | g_free(msg); |
| 7972 | 727 | |
| 728 | jabber_send(chat->js, presence); | |
| 729 | xmlnode_free(presence); | |
|
28734
886d6c5e8f9a
jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <darkrain42@pidgin.im>
parents:
28703
diff
changeset
|
730 | |
|
886d6c5e8f9a
jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <darkrain42@pidgin.im>
parents:
28703
diff
changeset
|
731 | return TRUE; |
| 7972 | 732 | } |
| 733 | ||
| 7974 | 734 | void jabber_chat_part(JabberChat *chat, const char *msg) |
| 735 | { | |
| 736 | char *room_jid; | |
| 737 | xmlnode *presence; | |
| 7972 | 738 | |
| 8537 | 739 | room_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, |
| 740 | chat->handle); | |
| 7974 | 741 | presence = xmlnode_new("presence"); |
| 742 | xmlnode_set_attrib(presence, "to", room_jid); | |
| 743 | xmlnode_set_attrib(presence, "type", "unavailable"); | |
| 744 | if(msg) { | |
| 745 | xmlnode *status = xmlnode_new_child(presence, "status"); | |
| 746 | xmlnode_insert_data(status, msg, -1); | |
| 747 | } | |
| 748 | jabber_send(chat->js, presence); | |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24254
diff
changeset
|
749 | |
| 7974 | 750 | xmlnode_free(presence); |
| 751 | g_free(room_jid); | |
| 752 | } | |
| 753 | ||
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
754 | static void roomlist_disco_result_cb(JabberStream *js, const char *from, |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
755 | JabberIqType type, const char *id, |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
756 | xmlnode *packet, gpointer data) |
| 8113 | 757 | { |
| 758 | xmlnode *query; | |
| 759 | xmlnode *item; | |
| 7974 | 760 | |
| 8113 | 761 | if(!js->roomlist) |
| 762 | return; | |
| 763 | ||
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
764 | if (type == JABBER_IQ_ERROR) { |
|
21150
bedd1215fb5e
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
765 | char *err = jabber_parse_error(js, packet, NULL); |
| 15884 | 766 | purple_notify_error(js->gc, _("Error"), |
|
10094
e80a87320835
[gaim-migrate @ 11112]
Mark Doliner <markdoliner@pidgin.im>
parents:
10091
diff
changeset
|
767 | _("Error retrieving room list"), err); |
| 15884 | 768 | purple_roomlist_set_in_progress(js->roomlist, FALSE); |
| 769 | purple_roomlist_unref(js->roomlist); | |
| 8120 | 770 | js->roomlist = NULL; |
| 8401 | 771 | g_free(err); |
| 8113 | 772 | return; |
| 773 | } | |
| 774 | ||
| 775 | if(!(query = xmlnode_get_child(packet, "query"))) { | |
|
21150
bedd1215fb5e
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
776 | char *err = jabber_parse_error(js, packet, NULL); |
| 15884 | 777 | purple_notify_error(js->gc, _("Error"), |
|
10094
e80a87320835
[gaim-migrate @ 11112]
Mark Doliner <markdoliner@pidgin.im>
parents:
10091
diff
changeset
|
778 | _("Error retrieving room list"), err); |
| 15884 | 779 | purple_roomlist_set_in_progress(js->roomlist, FALSE); |
| 780 | purple_roomlist_unref(js->roomlist); | |
| 8120 | 781 | js->roomlist = NULL; |
| 8401 | 782 | g_free(err); |
| 8113 | 783 | return; |
| 784 | } | |
| 785 | ||
| 8135 | 786 | for(item = xmlnode_get_child(query, "item"); item; |
| 787 | item = xmlnode_get_next_twin(item)) { | |
| 8113 | 788 | const char *name; |
| 15884 | 789 | PurpleRoomlistRoom *room; |
| 8113 | 790 | JabberID *jid; |
| 791 | ||
| 792 | if(!(jid = jabber_id_new(xmlnode_get_attrib(item, "jid")))) | |
| 793 | continue; | |
| 794 | name = xmlnode_get_attrib(item, "name"); | |
| 795 | ||
| 796 | ||
| 15884 | 797 | room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, jid->node, NULL); |
| 798 | purple_roomlist_room_add_field(js->roomlist, room, jid->node); | |
| 799 | purple_roomlist_room_add_field(js->roomlist, room, jid->domain); | |
| 800 | purple_roomlist_room_add_field(js->roomlist, room, name ? name : ""); | |
| 801 | purple_roomlist_room_add(js->roomlist, room); | |
| 8113 | 802 | |
| 803 | jabber_id_free(jid); | |
| 804 | } | |
| 15884 | 805 | purple_roomlist_set_in_progress(js->roomlist, FALSE); |
| 806 | purple_roomlist_unref(js->roomlist); | |
| 8113 | 807 | js->roomlist = NULL; |
| 808 | } | |
| 809 | ||
| 10045 | 810 | static void roomlist_cancel_cb(JabberStream *js, const char *server) { |
| 811 | if(js->roomlist) { | |
| 15884 | 812 | purple_roomlist_set_in_progress(js->roomlist, FALSE); |
| 813 | purple_roomlist_unref(js->roomlist); | |
| 10045 | 814 | js->roomlist = NULL; |
| 815 | } | |
| 816 | } | |
| 817 | ||
| 8113 | 818 | static void roomlist_ok_cb(JabberStream *js, const char *server) |
| 819 | { | |
| 820 | JabberIq *iq; | |
| 10045 | 821 | |
| 822 | if(!js->roomlist) | |
| 823 | return; | |
| 8113 | 824 | |
| 825 | if(!server || !*server) { | |
| 15884 | 826 | purple_notify_error(js->gc, _("Invalid Server"), _("Invalid Server"), NULL); |
|
28158
0ec0690c2741
jabber: Fix "Invalid Server" breaking roomlist dialog. Closes #8143.
Paul Aurich <darkrain42@pidgin.im>
parents:
28130
diff
changeset
|
827 | purple_roomlist_set_in_progress(js->roomlist, FALSE); |
| 8113 | 828 | return; |
| 829 | } | |
| 830 | ||
| 15884 | 831 | purple_roomlist_set_in_progress(js->roomlist, TRUE); |
| 10045 | 832 | |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28734
diff
changeset
|
833 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_ITEMS); |
| 10045 | 834 | |
| 835 | xmlnode_set_attrib(iq->node, "to", server); | |
| 836 | ||
| 837 | jabber_iq_set_callback(iq, roomlist_disco_result_cb, NULL); | |
| 838 | ||
| 839 | jabber_iq_send(iq); | |
| 840 | } | |
| 841 | ||
| 15884 | 842 | char *jabber_roomlist_room_serialize(PurpleRoomlistRoom *room) |
| 15185 | 843 | { |
| 844 | ||
| 845 | return g_strdup_printf("%s@%s", (char*)room->fields->data, (char*)room->fields->next->data); | |
| 846 | } | |
| 847 | ||
| 15884 | 848 | PurpleRoomlist *jabber_roomlist_get_list(PurpleConnection *gc) |
| 10045 | 849 | { |
| 850 | JabberStream *js = gc->proto_data; | |
| 851 | GList *fields = NULL; | |
| 15884 | 852 | PurpleRoomlistField *f; |
| 10045 | 853 | |
|
9913
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
854 | if(js->roomlist) |
| 15884 | 855 | purple_roomlist_unref(js->roomlist); |
|
9913
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
856 | |
| 15884 | 857 | js->roomlist = purple_roomlist_new(purple_connection_get_account(js->gc)); |
|
9913
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
858 | |
| 15884 | 859 | f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "", "room", TRUE); |
|
9913
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
860 | fields = g_list_append(fields, f); |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
861 | |
| 15884 | 862 | f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "", "server", TRUE); |
|
9913
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
863 | fields = g_list_append(fields, f); |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
864 | |
| 15884 | 865 | f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, _("Description"), "description", FALSE); |
|
9913
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
866 | fields = g_list_append(fields, f); |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
867 | |
| 15884 | 868 | purple_roomlist_set_fields(js->roomlist, fields); |
|
9913
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
869 | |
| 8113 | 870 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
871 | purple_request_input(gc, _("Enter a Conference Server"), _("Enter a Conference Server"), |
| 8113 | 872 | _("Select a conference server to query"), |
|
17007
66c0fa6e5e2a
Removes 'jabber.org' defaults from XMPP. I think we had agreed this was a good idea.
Sean Egan <seanegan@pidgin.im>
parents:
16490
diff
changeset
|
873 | js->chat_servers ? js->chat_servers->data : NULL, |
| 8697 | 874 | FALSE, FALSE, NULL, |
| 15884 | 875 | _("Find Rooms"), PURPLE_CALLBACK(roomlist_ok_cb), |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
876 | _("Cancel"), PURPLE_CALLBACK(roomlist_cancel_cb), |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24254
diff
changeset
|
877 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
878 | js); |
| 8113 | 879 | |
| 880 | return js->roomlist; | |
| 881 | } | |
| 882 | ||
| 15884 | 883 | void jabber_roomlist_cancel(PurpleRoomlist *list) |
| 8113 | 884 | { |
| 15884 | 885 | PurpleConnection *gc; |
| 8113 | 886 | JabberStream *js; |
| 887 | ||
| 15884 | 888 | gc = purple_account_get_connection(list->account); |
| 8113 | 889 | js = gc->proto_data; |
| 890 | ||
| 15884 | 891 | purple_roomlist_set_in_progress(list, FALSE); |
| 8113 | 892 | |
| 893 | if (js->roomlist == list) { | |
| 894 | js->roomlist = NULL; | |
| 15884 | 895 | purple_roomlist_unref(list); |
| 8113 | 896 | } |
| 897 | } | |
| 898 | ||
| 9152 | 899 | void jabber_chat_member_free(JabberChatMember *jcm) |
| 900 | { | |
| 901 | g_free(jcm->handle); | |
| 902 | g_free(jcm->jid); | |
| 903 | g_free(jcm); | |
| 904 | } | |
| 905 | ||
| 906 | void jabber_chat_track_handle(JabberChat *chat, const char *handle, | |
| 907 | const char *jid, const char *affiliation, const char *role) | |
| 908 | { | |
| 909 | JabberChatMember *jcm = g_new0(JabberChatMember, 1); | |
| 910 | ||
| 911 | jcm->handle = g_strdup(handle); | |
| 912 | jcm->jid = g_strdup(jid); | |
| 913 | ||
| 914 | g_hash_table_replace(chat->members, jcm->handle, jcm); | |
| 915 | ||
| 916 | /* XXX: keep track of role and affiliation */ | |
| 917 | } | |
| 918 | ||
| 919 | void jabber_chat_remove_handle(JabberChat *chat, const char *handle) | |
| 920 | { | |
| 921 | g_hash_table_remove(chat->members, handle); | |
| 922 | } | |
| 923 | ||
| 924 | gboolean jabber_chat_ban_user(JabberChat *chat, const char *who, const char *why) | |
| 925 | { | |
|
19854
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
926 | JabberChatMember *jcm; |
|
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
927 | const char *jid; |
|
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
928 | char *to; |
| 9152 | 929 | JabberIq *iq; |
| 930 | xmlnode *query, *item, *reason; | |
| 931 | ||
|
19854
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
932 | jcm = g_hash_table_lookup(chat->members, who); |
|
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
933 | if (jcm && jcm->jid) |
|
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
934 | jid = jcm->jid; |
|
29059
8225f2507058
strchr() is safe when searching for an ASCII character in UTF8 strings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28984
diff
changeset
|
935 | else if (strchr(who, '@') != NULL) |
|
19854
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
936 | jid = who; |
|
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
937 | else |
| 9152 | 938 | return FALSE; |
| 939 | ||
| 940 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, | |
| 941 | "http://jabber.org/protocol/muc#admin"); | |
| 942 | ||
| 943 | to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 944 | xmlnode_set_attrib(iq->node, "to", to); | |
| 945 | g_free(to); | |
| 946 | ||
| 947 | query = xmlnode_get_child(iq->node, "query"); | |
| 948 | item = xmlnode_new_child(query, "item"); | |
|
19854
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
949 | xmlnode_set_attrib(item, "jid", jid); |
| 9152 | 950 | xmlnode_set_attrib(item, "affiliation", "outcast"); |
| 951 | if(why) { | |
| 952 | reason = xmlnode_new_child(item, "reason"); | |
| 953 | xmlnode_insert_data(reason, why, -1); | |
| 954 | } | |
| 955 | ||
| 956 | jabber_iq_send(iq); | |
| 957 | ||
| 958 | return TRUE; | |
| 959 | } | |
| 8113 | 960 | |
| 11393 | 961 | gboolean jabber_chat_affiliate_user(JabberChat *chat, const char *who, const char *affiliation) |
| 962 | { | |
|
19854
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
963 | JabberChatMember *jcm; |
|
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
964 | const char *jid; |
|
13238
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
965 | char *to; |
| 11393 | 966 | JabberIq *iq; |
| 967 | xmlnode *query, *item; | |
|
13238
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
968 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
969 | jcm = g_hash_table_lookup(chat->members, who); |
|
19854
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
970 | if (jcm && jcm->jid) |
|
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
971 | jid = jcm->jid; |
|
29059
8225f2507058
strchr() is safe when searching for an ASCII character in UTF8 strings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28984
diff
changeset
|
972 | else if (strchr(who, '@') != NULL) |
|
19854
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
973 | jid = who; |
|
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
974 | else |
| 11393 | 975 | return FALSE; |
| 976 | ||
| 977 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, | |
| 978 | "http://jabber.org/protocol/muc#admin"); | |
| 979 | ||
| 980 | to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 981 | xmlnode_set_attrib(iq->node, "to", to); | |
| 982 | g_free(to); | |
| 983 | ||
| 984 | query = xmlnode_get_child(iq->node, "query"); | |
| 985 | item = xmlnode_new_child(query, "item"); | |
|
19854
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
986 | xmlnode_set_attrib(item, "jid", jid); |
| 11393 | 987 | xmlnode_set_attrib(item, "affiliation", affiliation); |
| 988 | ||
| 989 | jabber_iq_send(iq); | |
| 990 | ||
| 991 | return TRUE; | |
| 992 | } | |
| 8113 | 993 | |
|
27027
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
994 | static void |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
995 | jabber_chat_affiliation_list_cb(JabberStream *js, const char *from, |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
996 | JabberIqType type, const char *id, |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
997 | xmlnode *packet, gpointer data) |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
998 | { |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
999 | JabberChat *chat; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1000 | xmlnode *query, *item; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1001 | int chat_id = GPOINTER_TO_INT(data); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1002 | GString *buf; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1003 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1004 | if(!(chat = jabber_chat_find_by_id(js, chat_id))) |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1005 | return; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1006 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1007 | if (type == JABBER_IQ_ERROR) |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1008 | return; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1009 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1010 | if(!(query = xmlnode_get_child(packet, "query"))) |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1011 | return; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1012 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1013 | buf = g_string_new(_("Affiliations:")); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1014 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1015 | item = xmlnode_get_child(query, "item"); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1016 | if (item) { |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1017 | for( ; item; item = xmlnode_get_next_twin(item)) { |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1018 | const char *jid = xmlnode_get_attrib(item, "jid"); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1019 | const char *affiliation = xmlnode_get_attrib(item, "affiliation"); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1020 | if (jid && affiliation) |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1021 | g_string_append_printf(buf, "\n%s %s", jid, affiliation); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1022 | } |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1023 | } else { |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1024 | buf = g_string_append_c(buf, '\n'); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1025 | buf = g_string_append_len(buf, _("No users found"), -1); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1026 | } |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1027 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1028 | purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "", buf->str, |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1029 | PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL)); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1030 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1031 | g_string_free(buf, TRUE); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1032 | } |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1033 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1034 | gboolean jabber_chat_affiliation_list(JabberChat *chat, const char *affiliation) |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1035 | { |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1036 | JabberIq *iq; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1037 | char *room_jid; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1038 | xmlnode *query, *item; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1039 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1040 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1041 | "http://jabber.org/protocol/muc#admin"); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1042 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1043 | room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1044 | xmlnode_set_attrib(iq->node, "to", room_jid); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1045 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1046 | query = xmlnode_get_child(iq->node, "query"); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1047 | item = xmlnode_new_child(query, "item"); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1048 | xmlnode_set_attrib(item, "affiliation", affiliation); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1049 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1050 | jabber_iq_set_callback(iq, jabber_chat_affiliation_list_cb, GINT_TO_POINTER(chat->id)); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1051 | jabber_iq_send(iq); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1052 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1053 | return TRUE; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1054 | } |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1055 | |
|
29400
8d8ad40c9c7d
jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
Paul Aurich <darkrain42@pidgin.im>
parents:
29059
diff
changeset
|
1056 | gboolean jabber_chat_role_user(JabberChat *chat, const char *who, |
|
8d8ad40c9c7d
jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
Paul Aurich <darkrain42@pidgin.im>
parents:
29059
diff
changeset
|
1057 | const char *role, const char *why) |
|
13238
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1058 | { |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1059 | char *to; |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1060 | JabberIq *iq; |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1061 | xmlnode *query, *item; |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1062 | JabberChatMember *jcm; |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1063 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1064 | jcm = g_hash_table_lookup(chat->members, who); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1065 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1066 | if (!jcm || !jcm->handle) |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1067 | return FALSE; |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1068 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1069 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1070 | "http://jabber.org/protocol/muc#admin"); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1071 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1072 | to = g_strdup_printf("%s@%s", chat->room, chat->server); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1073 | xmlnode_set_attrib(iq->node, "to", to); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1074 | g_free(to); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1075 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1076 | query = xmlnode_get_child(iq->node, "query"); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1077 | item = xmlnode_new_child(query, "item"); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1078 | xmlnode_set_attrib(item, "nick", jcm->handle); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1079 | xmlnode_set_attrib(item, "role", role); |
|
29400
8d8ad40c9c7d
jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
Paul Aurich <darkrain42@pidgin.im>
parents:
29059
diff
changeset
|
1080 | if (why) { |
|
8d8ad40c9c7d
jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
Paul Aurich <darkrain42@pidgin.im>
parents:
29059
diff
changeset
|
1081 | xmlnode *reason = xmlnode_new_child(item, "reason"); |
|
8d8ad40c9c7d
jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
Paul Aurich <darkrain42@pidgin.im>
parents:
29059
diff
changeset
|
1082 | xmlnode_insert_data(reason, why, -1); |
|
8d8ad40c9c7d
jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
Paul Aurich <darkrain42@pidgin.im>
parents:
29059
diff
changeset
|
1083 | } |
|
13238
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1084 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1085 | jabber_iq_send(iq); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1086 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1087 | return TRUE; |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1088 | } |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1089 | |
|
27027
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1090 | static void jabber_chat_role_list_cb(JabberStream *js, const char *from, |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1091 | JabberIqType type, const char *id, |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1092 | xmlnode *packet, gpointer data) |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1093 | { |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1094 | JabberChat *chat; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1095 | xmlnode *query, *item; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1096 | int chat_id = GPOINTER_TO_INT(data); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1097 | GString *buf; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1098 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1099 | if(!(chat = jabber_chat_find_by_id(js, chat_id))) |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1100 | return; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1101 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1102 | if (type == JABBER_IQ_ERROR) |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1103 | return; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1104 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1105 | if(!(query = xmlnode_get_child(packet, "query"))) |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1106 | return; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1107 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1108 | buf = g_string_new(_("Roles:")); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1109 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1110 | item = xmlnode_get_child(query, "item"); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1111 | if (item) { |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1112 | for( ; item; item = xmlnode_get_next_twin(item)) { |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1113 | const char *jid = xmlnode_get_attrib(item, "jid"); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1114 | const char *role = xmlnode_get_attrib(item, "role"); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1115 | if (jid && role) |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1116 | g_string_append_printf(buf, "\n%s %s", jid, role); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1117 | } |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1118 | } else { |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1119 | buf = g_string_append_c(buf, '\n'); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1120 | buf = g_string_append_len(buf, _("No users found"), -1); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1121 | } |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1122 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1123 | purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "", buf->str, |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1124 | PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL)); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1125 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1126 | g_string_free(buf, TRUE); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1127 | } |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1128 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1129 | gboolean jabber_chat_role_list(JabberChat *chat, const char *role) |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1130 | { |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1131 | JabberIq *iq; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1132 | char *room_jid; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1133 | xmlnode *query, *item; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1134 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1135 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1136 | "http://jabber.org/protocol/muc#admin"); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1137 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1138 | room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1139 | xmlnode_set_attrib(iq->node, "to", room_jid); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1140 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1141 | query = xmlnode_get_child(iq->node, "query"); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1142 | item = xmlnode_new_child(query, "item"); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1143 | xmlnode_set_attrib(item, "role", role); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1144 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1145 | jabber_iq_set_callback(iq, jabber_chat_role_list_cb, GINT_TO_POINTER(chat->id)); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1146 | jabber_iq_send(iq); |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1147 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1148 | return TRUE; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1149 | } |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1150 | |
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
1151 | static void jabber_chat_disco_traffic_cb(JabberStream *js, const char *from, |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
1152 | JabberIqType type, const char *id, |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
1153 | xmlnode *packet, gpointer data) |
| 10941 | 1154 | { |
| 1155 | JabberChat *chat; | |
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
1156 | #if 0 |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
1157 | xmlnode *query, *x; |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
1158 | #endif |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
1159 | int chat_id = GPOINTER_TO_INT(data); |
| 10941 | 1160 | |
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
1161 | if(!(chat = jabber_chat_find_by_id(js, chat_id))) |
| 10941 | 1162 | return; |
| 1163 | ||
|
11392
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1164 | /* defaults, in case the conference server doesn't |
|
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1165 | * support this request */ |
|
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1166 | chat->xhtml = TRUE; |
|
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1167 | |
|
20225
684334efdc19
applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents:
19897
diff
changeset
|
1168 | /* disabling this until more MUC servers support |
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
1169 | * announcing this */ |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
1170 | #if 0 |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
1171 | if (type == JABBER_IQ_ERROR) { |
| 10941 | 1172 | return; |
| 1173 | } | |
| 1174 | ||
| 1175 | if(!(query = xmlnode_get_child(packet, "query"))) | |
| 1176 | return; | |
| 1177 | ||
|
11392
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1178 | chat->xhtml = FALSE; |
|
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1179 | |
| 10941 | 1180 | for(x = xmlnode_get_child(query, "feature"); x; x = xmlnode_get_next_twin(x)) { |
| 1181 | const char *var = xmlnode_get_attrib(x, "var"); | |
| 1182 | ||
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28734
diff
changeset
|
1183 | if(var && !strcmp(var, NS_XHTML_IM)) { |
| 10941 | 1184 | chat->xhtml = TRUE; |
| 1185 | } | |
| 1186 | } | |
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
1187 | #endif |
| 10941 | 1188 | } |
| 1189 | ||
| 1190 | void jabber_chat_disco_traffic(JabberChat *chat) | |
| 1191 | { | |
| 1192 | JabberIq *iq; | |
| 1193 | xmlnode *query; | |
|
11392
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1194 | char *room_jid; |
|
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1195 | |
|
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1196 | room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); |
| 10941 | 1197 | |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28734
diff
changeset
|
1198 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, NS_DISCO_INFO); |
| 10941 | 1199 | |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24254
diff
changeset
|
1200 | xmlnode_set_attrib(iq->node, "to", room_jid); |
|
11392
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1201 | |
| 10941 | 1202 | query = xmlnode_get_child(iq->node, "query"); |
| 1203 | ||
| 1204 | xmlnode_set_attrib(query, "node", "http://jabber.org/protocol/muc#traffic"); | |
| 1205 | ||
| 1206 | jabber_iq_set_callback(iq, jabber_chat_disco_traffic_cb, GINT_TO_POINTER(chat->id)); | |
| 1207 | ||
| 1208 | jabber_iq_send(iq); | |
|
11392
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1209 | |
|
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1210 | g_free(room_jid); |
| 10941 | 1211 | } |
| 9152 | 1212 | |
|
27110
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1213 | typedef struct { |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1214 | const gchar *cap; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1215 | gboolean *all_support; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1216 | JabberBuddy *jb; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1217 | } JabberChatCapsData; |
| 9152 | 1218 | |
|
27110
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1219 | static void |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1220 | jabber_chat_all_participants_have_capability_foreach(gpointer key, |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1221 | gpointer value, |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1222 | gpointer user_data) |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1223 | { |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1224 | const gchar *cap = ((JabberChatCapsData *) user_data)->cap; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1225 | gboolean *all_support = ((JabberChatCapsData *) user_data)->all_support; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1226 | JabberBuddy *jb = ((JabberChatCapsData *) user_data)->jb; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1227 | JabberChatMember *member = (JabberChatMember *) value; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1228 | const gchar *resource = member->handle; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1229 | JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource); |
| 10941 | 1230 | |
|
27110
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1231 | if (jbr) { |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1232 | *all_support &= jabber_resource_has_capability(jbr, cap); |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1233 | } else { |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1234 | *all_support = FALSE; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1235 | } |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1236 | } |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1237 | |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1238 | gboolean |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1239 | jabber_chat_all_participants_have_capability(const JabberChat *chat, |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1240 | const gchar *cap) |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1241 | { |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1242 | gchar *chat_jid = NULL; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1243 | JabberBuddy *jb = NULL; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1244 | gboolean all_support = TRUE; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1245 | JabberChatCapsData data; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1246 | |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1247 | chat_jid = g_strdup_printf("%s@%s", chat->room, chat->server); |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1248 | jb = jabber_buddy_find(chat->js, chat_jid, FALSE); |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1249 | |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1250 | if (jb) { |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1251 | data.cap = cap; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1252 | data.all_support = &all_support; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1253 | data.jb = jb; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1254 | |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27110
diff
changeset
|
1255 | g_hash_table_foreach(chat->members, |
|
27110
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1256 | jabber_chat_all_participants_have_capability_foreach, &data); |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1257 | } else { |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1258 | all_support = FALSE; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1259 | } |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1260 | g_free(chat_jid); |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1261 | return all_support; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1262 | } |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1263 | |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1264 | guint |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1265 | jabber_chat_get_num_participants(const JabberChat *chat) |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1266 | { |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1267 | return g_hash_table_size(chat->members); |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1268 | } |