Thu, 24 Sep 2009 16:58:31 +0000
jabber: Don't crash when adding a buddy without a node (no '@'). Closes #10261.
Also add some assertions to jabber_chat_find so this doesn't cause a
crash in the future.
| 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 | |
| 10607 | 109 | chat = g_hash_table_lookup(js->chats, jabber_normalize(NULL, room_jid)); |
| 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); | |
| 176 | body = xmlnode_new_child(invite, "reason"); | |
| 177 | xmlnode_insert_data(body, msg, -1); | |
| 178 | } else { | |
| 179 | xmlnode_set_attrib(message, "to", name); | |
| 180 | body = xmlnode_new_child(message, "body"); | |
| 181 | xmlnode_insert_data(body, msg, -1); | |
| 182 | x = xmlnode_new_child(message, "x"); | |
| 183 | xmlnode_set_attrib(x, "jid", room_jid); | |
| 13808 | 184 | xmlnode_set_namespace(x, "jabber:x:conference"); |
| 7014 | 185 | } |
| 186 | ||
| 187 | jabber_send(js, message); | |
| 188 | xmlnode_free(message); | |
| 189 | g_free(room_jid); | |
| 190 | } | |
| 191 | ||
| 9152 | 192 | void jabber_chat_member_free(JabberChatMember *jcm); |
| 193 | ||
|
9917
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
194 | char *jabber_get_chat_name(GHashTable *data) { |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
195 | char *room, *server, *chat_name = NULL; |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
196 | |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
197 | room = g_hash_table_lookup(data, "room"); |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
198 | server = g_hash_table_lookup(data, "server"); |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
199 | |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
200 | if (room && server) { |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
201 | chat_name = g_strdup_printf("%s@%s", room, server); |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
202 | } |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
203 | return chat_name; |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
204 | } |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
205 | |
|
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
|
206 | 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
|
207 | { |
|
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
|
208 | 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
|
209 | 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
|
210 | } |
|
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
|
211 | |
| 15884 | 212 | void jabber_chat_join(PurpleConnection *gc, GHashTable *data) |
| 7014 | 213 | { |
| 214 | JabberChat *chat; | |
| 215 | char *room, *server, *handle, *passwd; | |
| 216 | xmlnode *presence, *x; | |
| 7262 | 217 | char *tmp, *room_jid, *full_jid; |
| 7014 | 218 | JabberStream *js = gc->proto_data; |
| 15884 | 219 | PurplePresence *gpresence; |
| 220 | PurpleStatus *status; | |
| 9954 | 221 | JabberBuddyState state; |
| 14525 | 222 | char *msg; |
| 9954 | 223 | int priority; |
| 7014 | 224 | |
| 225 | room = g_hash_table_lookup(data, "room"); | |
| 226 | server = g_hash_table_lookup(data, "server"); | |
| 227 | handle = g_hash_table_lookup(data, "handle"); | |
| 228 | passwd = g_hash_table_lookup(data, "password"); | |
| 229 | ||
| 8113 | 230 | if(!room || !server) |
| 7014 | 231 | return; |
| 232 | ||
| 8113 | 233 | if(!handle) |
| 234 | handle = js->user->node; | |
| 235 | ||
| 7310 | 236 | if(!jabber_nodeprep_validate(room)) { |
| 237 | char *buf = g_strdup_printf(_("%s is not a valid room name"), room); | |
| 15884 | 238 | purple_notify_error(gc, _("Invalid Room Name"), _("Invalid Room Name"), |
| 7310 | 239 | 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
|
240 | purple_serv_got_join_chat_failed(gc, data); |
| 7310 | 241 | g_free(buf); |
| 242 | return; | |
|
27728
03b2a20ba465
Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <darkrain42@pidgin.im>
parents:
27155
diff
changeset
|
243 | } else if(!jabber_domain_validate(server)) { |
| 7310 | 244 | char *buf = g_strdup_printf(_("%s is not a valid server name"), server); |
| 15884 | 245 | purple_notify_error(gc, _("Invalid Server Name"), |
| 7310 | 246 | _("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
|
247 | purple_serv_got_join_chat_failed(gc, data); |
| 7310 | 248 | g_free(buf); |
| 249 | return; | |
| 250 | } else if(!jabber_resourceprep_validate(handle)) { | |
| 251 | char *buf = g_strdup_printf(_("%s is not a valid room handle"), handle); | |
| 15884 | 252 | purple_notify_error(gc, _("Invalid Room Handle"), |
| 7310 | 253 | _("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
|
254 | 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
|
255 | 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
|
256 | return; |
| 7310 | 257 | } |
| 258 | ||
| 7014 | 259 | if(jabber_chat_find(js, room, server)) |
| 260 | return; | |
| 261 | ||
|
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
|
262 | tmp = g_strdup_printf("%s@%s", room, server); |
|
2b7db16e721a
As discussed on the devel list, purple_serv_got_join_chat_failed() and the
Evan Schoenberg <evands@pidgin.im>
parents:
22920
diff
changeset
|
263 | room_jid = g_strdup(jabber_normalize(NULL, 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
|
264 | 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
|
265 | |
| 7014 | 266 | chat = g_new0(JabberChat, 1); |
| 267 | chat->js = gc->proto_data; | |
| 268 | ||
| 269 | chat->room = g_strdup(room); | |
| 270 | chat->server = g_strdup(server); | |
| 8400 | 271 | chat->handle = g_strdup(handle); |
| 7014 | 272 | |
|
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
|
273 | /* Copy the data hash table to chat->components */ |
|
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
|
274 | chat->components = g_hash_table_new_full(g_str_hash, g_str_equal, |
|
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
|
275 | g_free, g_free); |
|
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
|
276 | g_hash_table_foreach(data, insert_in_hash_table, chat->components); |
|
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
|
277 | |
| 9152 | 278 | chat->members = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, |
| 279 | (GDestroyNotify)jabber_chat_member_free); | |
| 280 | ||
| 7014 | 281 | g_hash_table_insert(js->chats, room_jid, chat); |
| 282 | ||
| 15884 | 283 | gpresence = purple_account_get_presence(gc->account); |
| 284 | status = purple_presence_get_active_status(gpresence); | |
| 9954 | 285 | |
| 15884 | 286 | purple_status_to_jabber(status, &state, &msg, &priority); |
| 9954 | 287 | |
|
17770
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17007
diff
changeset
|
288 | presence = jabber_presence_create_js(js, state, msg, priority); |
| 7014 | 289 | full_jid = g_strdup_printf("%s/%s", room_jid, handle); |
| 290 | xmlnode_set_attrib(presence, "to", full_jid); | |
| 291 | g_free(full_jid); | |
| 14525 | 292 | g_free(msg); |
| 7014 | 293 | |
| 294 | x = xmlnode_new_child(presence, "x"); | |
| 13808 | 295 | xmlnode_set_namespace(x, "http://jabber.org/protocol/muc"); |
| 7014 | 296 | |
| 297 | if(passwd && *passwd) { | |
| 298 | xmlnode *password = xmlnode_new_child(x, "password"); | |
| 299 | xmlnode_insert_data(password, passwd, -1); | |
| 300 | } | |
| 301 | ||
| 302 | jabber_send(js, presence); | |
| 303 | xmlnode_free(presence); | |
| 304 | } | |
| 305 | ||
| 15884 | 306 | void jabber_chat_leave(PurpleConnection *gc, int id) |
| 7014 | 307 | { |
| 308 | JabberStream *js = gc->proto_data; | |
| 309 | JabberChat *chat = jabber_chat_find_by_id(js, id); | |
| 7974 | 310 | |
| 7014 | 311 | |
| 312 | if(!chat) | |
| 313 | return; | |
| 314 | ||
| 7974 | 315 | jabber_chat_part(chat, NULL); |
| 9152 | 316 | |
|
23403
a8704d47889f
Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
317 | chat->left = TRUE; |
| 7014 | 318 | } |
| 319 | ||
| 320 | void jabber_chat_destroy(JabberChat *chat) | |
| 321 | { | |
| 322 | JabberStream *js = chat->js; | |
| 323 | char *room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 324 | ||
| 7322 | 325 | g_hash_table_remove(js->chats, jabber_normalize(NULL, room_jid)); |
| 7014 | 326 | g_free(room_jid); |
| 8396 | 327 | } |
| 328 | ||
| 329 | void jabber_chat_free(JabberChat *chat) | |
| 330 | { | |
| 331 | if(chat->config_dialog_handle) | |
| 15884 | 332 | purple_request_close(chat->config_dialog_type, chat->config_dialog_handle); |
| 7014 | 333 | |
| 334 | g_free(chat->room); | |
| 335 | g_free(chat->server); | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10474
diff
changeset
|
336 | g_free(chat->handle); |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10474
diff
changeset
|
337 | 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
|
338 | g_hash_table_destroy(chat->components); |
| 7014 | 339 | g_free(chat); |
| 340 | } | |
| 341 | ||
| 15884 | 342 | gboolean jabber_chat_find_buddy(PurpleConversation *conv, const char *name) |
| 7014 | 343 | { |
| 15884 | 344 | return purple_conv_chat_find_user(PURPLE_CONV_CHAT(conv), name); |
| 7014 | 345 | } |
| 346 | ||
| 15884 | 347 | char *jabber_chat_buddy_real_name(PurpleConnection *gc, int id, const char *who) |
| 7398 | 348 | { |
| 349 | JabberStream *js = gc->proto_data; | |
| 350 | 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
|
351 | JabberChatMember *jcm; |
| 7398 | 352 | |
| 353 | chat = jabber_chat_find_by_id(js, id); | |
| 354 | ||
| 355 | if(!chat) | |
| 356 | return NULL; | |
| 357 | ||
|
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
|
358 | 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
|
359 | 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
|
360 | 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
|
361 | |
|
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
|
362 | |
| 7398 | 363 | return g_strdup_printf("%s@%s/%s", chat->room, chat->server, who); |
| 364 | } | |
| 7895 | 365 | |
| 7923 | 366 | static void jabber_chat_room_configure_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) |
| 367 | { | |
| 368 | JabberChat *chat = data; | |
| 369 | xmlnode *query; | |
| 370 | JabberIq *iq; | |
| 371 | char *to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 372 | ||
| 373 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "http://jabber.org/protocol/muc#owner"); | |
| 374 | xmlnode_set_attrib(iq->node, "to", to); | |
| 375 | g_free(to); | |
| 376 | ||
| 377 | query = xmlnode_get_child(iq->node, "query"); | |
| 378 | ||
| 379 | xmlnode_insert_child(query, result); | |
| 380 | ||
| 381 | jabber_iq_send(iq); | |
| 382 | } | |
| 383 | ||
|
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
|
384 | 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
|
385 | 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
|
386 | xmlnode *packet, gpointer data) |
| 7923 | 387 | { |
| 388 | xmlnode *query, *x; | |
| 7926 | 389 | char *msg; |
| 7923 | 390 | JabberChat *chat; |
| 391 | JabberID *jid; | |
| 392 | ||
|
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
|
393 | if (!from) |
| 7923 | 394 | return; |
| 395 | ||
|
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
|
396 | if (type == JABBER_IQ_RESULT) { |
| 7923 | 397 | jid = jabber_id_new(from); |
| 398 | ||
| 399 | if(!jid) | |
| 400 | return; | |
| 401 | ||
| 402 | chat = jabber_chat_find(js, jid->node, jid->domain); | |
| 403 | jabber_id_free(jid); | |
| 404 | ||
| 405 | if(!chat) | |
| 406 | return; | |
| 407 | ||
| 408 | if(!(query = xmlnode_get_child(packet, "query"))) | |
| 409 | return; | |
| 410 | ||
| 8135 | 411 | for(x = xmlnode_get_child(query, "x"); x; x = xmlnode_get_next_twin(x)) { |
| 7923 | 412 | const char *xmlns; |
| 13808 | 413 | if(!(xmlns = xmlnode_get_namespace(x))) |
| 7923 | 414 | continue; |
| 415 | ||
| 416 | if(!strcmp(xmlns, "jabber:x:data")) { | |
| 15884 | 417 | chat->config_dialog_type = PURPLE_REQUEST_FIELDS; |
| 8396 | 418 | chat->config_dialog_handle = jabber_x_data_request(js, x, jabber_chat_room_configure_x_data_cb, chat); |
| 7923 | 419 | return; |
| 420 | } | |
| 421 | } | |
|
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
|
422 | } 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
|
423 | char *msg = jabber_parse_error(js, packet, NULL); |
| 7926 | 424 | |
| 15884 | 425 | purple_notify_error(js->gc, _("Configuration error"), _("Configuration error"), msg); |
| 7926 | 426 | |
| 8401 | 427 | if(msg) |
| 428 | g_free(msg); | |
| 7926 | 429 | return; |
| 7923 | 430 | } |
| 431 | ||
| 7926 | 432 | msg = g_strdup_printf("Unable to configure room %s", from); |
| 433 | ||
| 15884 | 434 | purple_notify_info(js->gc, _("Unable to configure"), _("Unable to configure"), msg); |
| 7926 | 435 | g_free(msg); |
| 7923 | 436 | |
| 437 | } | |
| 438 | ||
| 439 | void jabber_chat_request_room_configure(JabberChat *chat) { | |
| 440 | JabberIq *iq; | |
| 441 | char *room_jid; | |
| 442 | ||
| 7895 | 443 | if(!chat) |
| 444 | return; | |
| 445 | ||
| 8396 | 446 | chat->config_dialog_handle = NULL; |
| 447 | ||
| 7955 | 448 | if(!chat->muc) { |
| 15884 | 449 | purple_notify_error(chat->js->gc, _("Room Configuration Error"), _("Room Configuration Error"), |
| 7955 | 450 | _("This room is not capable of being configured")); |
| 451 | return; | |
| 452 | } | |
| 453 | ||
| 10474 | 454 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, |
| 7923 | 455 | "http://jabber.org/protocol/muc#owner"); |
| 456 | room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 7895 | 457 | |
| 7923 | 458 | xmlnode_set_attrib(iq->node, "to", room_jid); |
| 459 | ||
| 460 | jabber_iq_set_callback(iq, jabber_chat_room_configure_cb, NULL); | |
| 461 | ||
| 462 | jabber_iq_send(iq); | |
| 463 | ||
| 464 | g_free(room_jid); | |
| 7895 | 465 | } |
| 466 | ||
| 467 | void jabber_chat_create_instant_room(JabberChat *chat) { | |
| 468 | JabberIq *iq; | |
| 469 | xmlnode *query, *x; | |
| 470 | char *room_jid; | |
| 471 | ||
| 472 | if(!chat) | |
| 473 | return; | |
| 474 | ||
| 8396 | 475 | chat->config_dialog_handle = NULL; |
| 476 | ||
| 7895 | 477 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, |
| 478 | "http://jabber.org/protocol/muc#owner"); | |
| 479 | query = xmlnode_get_child(iq->node, "query"); | |
| 480 | x = xmlnode_new_child(query, "x"); | |
| 481 | room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 482 | ||
| 483 | xmlnode_set_attrib(iq->node, "to", room_jid); | |
| 13808 | 484 | xmlnode_set_namespace(x, "jabber:x:data"); |
| 7895 | 485 | xmlnode_set_attrib(x, "type", "submit"); |
| 486 | ||
| 487 | jabber_iq_send(iq); | |
| 488 | ||
| 489 | g_free(room_jid); | |
| 490 | } | |
| 7955 | 491 | |
|
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
|
492 | 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
|
493 | 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
|
494 | 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
|
495 | xmlnode *packet, gpointer data) |
| 7955 | 496 | { |
|
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
|
497 | 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
|
498 | char *msg = jabber_parse_error(js, packet, NULL); |
| 8401 | 499 | |
| 15884 | 500 | purple_notify_error(js->gc, _("Registration error"), _("Registration error"), msg); |
| 8401 | 501 | |
| 502 | if(msg) | |
| 503 | g_free(msg); | |
| 504 | return; | |
| 7955 | 505 | } |
| 506 | } | |
| 507 | ||
| 508 | static void jabber_chat_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) | |
| 509 | { | |
| 510 | JabberChat *chat = data; | |
| 511 | xmlnode *query; | |
| 512 | JabberIq *iq; | |
| 513 | char *to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 514 | ||
| 515 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 516 | xmlnode_set_attrib(iq->node, "to", to); | |
| 517 | g_free(to); | |
| 518 | ||
| 519 | query = xmlnode_get_child(iq->node, "query"); | |
| 520 | ||
| 521 | xmlnode_insert_child(query, result); | |
| 522 | ||
| 523 | jabber_iq_set_callback(iq, jabber_chat_register_x_data_result_cb, NULL); | |
| 524 | ||
| 525 | jabber_iq_send(iq); | |
| 526 | } | |
| 527 | ||
|
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
|
528 | 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
|
529 | 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
|
530 | xmlnode *packet, gpointer data) |
| 7955 | 531 | { |
| 532 | xmlnode *query, *x; | |
| 533 | char *msg; | |
| 534 | JabberChat *chat; | |
| 535 | JabberID *jid; | |
| 536 | ||
|
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
|
537 | if (!from) |
| 7955 | 538 | return; |
| 539 | ||
|
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
|
540 | if (type == JABBER_IQ_RESULT) { |
| 7955 | 541 | jid = jabber_id_new(from); |
| 542 | ||
| 543 | if(!jid) | |
| 544 | return; | |
| 545 | ||
| 546 | chat = jabber_chat_find(js, jid->node, jid->domain); | |
| 547 | jabber_id_free(jid); | |
| 548 | ||
| 549 | if(!chat) | |
| 550 | return; | |
| 551 | ||
| 552 | if(!(query = xmlnode_get_child(packet, "query"))) | |
| 553 | return; | |
| 554 | ||
| 8135 | 555 | for(x = xmlnode_get_child(query, "x"); x; x = xmlnode_get_next_twin(x)) { |
| 7955 | 556 | const char *xmlns; |
| 557 | ||
| 13808 | 558 | if(!(xmlns = xmlnode_get_namespace(x))) |
| 7955 | 559 | continue; |
| 560 | ||
| 561 | if(!strcmp(xmlns, "jabber:x:data")) { | |
| 562 | jabber_x_data_request(js, x, jabber_chat_register_x_data_cb, chat); | |
| 563 | return; | |
| 564 | } | |
| 565 | } | |
|
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
|
566 | } 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
|
567 | char *msg = jabber_parse_error(js, packet, NULL); |
| 7955 | 568 | |
| 15884 | 569 | purple_notify_error(js->gc, _("Registration error"), _("Registration error"), msg); |
| 7955 | 570 | |
| 8401 | 571 | if(msg) |
| 572 | g_free(msg); | |
| 7955 | 573 | return; |
| 574 | } | |
| 575 | ||
| 576 | msg = g_strdup_printf("Unable to configure room %s", from); | |
| 577 | ||
| 15884 | 578 | purple_notify_info(js->gc, _("Unable to configure"), _("Unable to configure"), msg); |
| 7955 | 579 | g_free(msg); |
| 580 | ||
| 581 | } | |
| 582 | ||
| 583 | void jabber_chat_register(JabberChat *chat) | |
| 584 | { | |
| 585 | JabberIq *iq; | |
| 586 | char *room_jid; | |
| 587 | ||
| 588 | if(!chat) | |
| 589 | return; | |
| 590 | ||
| 591 | room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 592 | ||
| 593 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, "jabber:iq:register"); | |
| 594 | xmlnode_set_attrib(iq->node, "to", room_jid); | |
| 595 | g_free(room_jid); | |
| 596 | ||
| 597 | jabber_iq_set_callback(iq, jabber_chat_register_cb, NULL); | |
| 598 | ||
| 599 | jabber_iq_send(iq); | |
| 600 | } | |
| 601 | ||
| 7971 | 602 | /* merge this with the function below when we get everyone on the same page wrt /commands */ |
| 603 | void jabber_chat_change_topic(JabberChat *chat, const char *topic) | |
| 604 | { | |
|
26859
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
605 | JabberMessage *jm; |
|
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
606 | |
|
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
607 | 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
|
608 | 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
|
609 | 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
|
610 | jm->to = g_strdup_printf("%s@%s", chat->room, chat->server); |
| 7955 | 611 | |
|
26859
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
612 | 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
|
613 | 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
|
614 | else |
|
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
615 | jm->subject = g_strdup(""); |
| 7971 | 616 | |
|
26859
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
617 | 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
|
618 | jabber_message_free(jm); |
| 7971 | 619 | } |
| 620 | ||
| 15884 | 621 | void jabber_chat_set_topic(PurpleConnection *gc, int id, const char *topic) |
| 7971 | 622 | { |
|
26859
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
623 | JabberStream *js = purple_connection_get_protocol_data(gc); |
| 7971 | 624 | JabberChat *chat = jabber_chat_find_by_id(js, id); |
| 625 | ||
| 626 | if(!chat) | |
| 627 | return; | |
| 628 | ||
| 629 | jabber_chat_change_topic(chat, topic); | |
| 630 | } | |
| 631 | ||
| 632 | ||
| 7972 | 633 | void jabber_chat_change_nick(JabberChat *chat, const char *nick) |
| 634 | { | |
| 635 | xmlnode *presence; | |
| 636 | char *full_jid; | |
| 15884 | 637 | PurplePresence *gpresence; |
| 638 | PurpleStatus *status; | |
| 9954 | 639 | JabberBuddyState state; |
| 14525 | 640 | char *msg; |
| 9954 | 641 | int priority; |
| 7972 | 642 | |
| 643 | if(!chat->muc) { | |
| 15884 | 644 | purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "", |
| 7972 | 645 | _("Nick changing not supported in non-MUC chatrooms"), |
| 15884 | 646 | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 7972 | 647 | return; |
| 648 | } | |
| 649 | ||
| 15884 | 650 | gpresence = purple_account_get_presence(chat->js->gc->account); |
| 651 | status = purple_presence_get_active_status(gpresence); | |
| 9954 | 652 | |
| 15884 | 653 | purple_status_to_jabber(status, &state, &msg, &priority); |
| 9954 | 654 | |
|
17770
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17007
diff
changeset
|
655 | presence = jabber_presence_create_js(chat->js, state, msg, priority); |
| 7972 | 656 | full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, nick); |
| 657 | xmlnode_set_attrib(presence, "to", full_jid); | |
| 658 | g_free(full_jid); | |
| 14525 | 659 | g_free(msg); |
| 7972 | 660 | |
| 661 | jabber_send(chat->js, presence); | |
| 662 | xmlnode_free(presence); | |
| 663 | } | |
| 664 | ||
| 7974 | 665 | void jabber_chat_part(JabberChat *chat, const char *msg) |
| 666 | { | |
| 667 | char *room_jid; | |
| 668 | xmlnode *presence; | |
| 7972 | 669 | |
| 8537 | 670 | room_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, |
| 671 | chat->handle); | |
| 7974 | 672 | presence = xmlnode_new("presence"); |
| 673 | xmlnode_set_attrib(presence, "to", room_jid); | |
| 674 | xmlnode_set_attrib(presence, "type", "unavailable"); | |
| 675 | if(msg) { | |
| 676 | xmlnode *status = xmlnode_new_child(presence, "status"); | |
| 677 | xmlnode_insert_data(status, msg, -1); | |
| 678 | } | |
| 679 | 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
|
680 | |
| 7974 | 681 | xmlnode_free(presence); |
| 682 | g_free(room_jid); | |
| 683 | } | |
| 684 | ||
|
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
|
685 | 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
|
686 | 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
|
687 | xmlnode *packet, gpointer data) |
| 8113 | 688 | { |
| 689 | xmlnode *query; | |
| 690 | xmlnode *item; | |
| 7974 | 691 | |
| 8113 | 692 | if(!js->roomlist) |
| 693 | return; | |
| 694 | ||
|
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
|
695 | 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
|
696 | char *err = jabber_parse_error(js, packet, NULL); |
| 15884 | 697 | purple_notify_error(js->gc, _("Error"), |
|
10094
e80a87320835
[gaim-migrate @ 11112]
Mark Doliner <markdoliner@pidgin.im>
parents:
10091
diff
changeset
|
698 | _("Error retrieving room list"), err); |
| 15884 | 699 | purple_roomlist_set_in_progress(js->roomlist, FALSE); |
| 700 | purple_roomlist_unref(js->roomlist); | |
| 8120 | 701 | js->roomlist = NULL; |
| 8401 | 702 | g_free(err); |
| 8113 | 703 | return; |
| 704 | } | |
| 705 | ||
| 706 | 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
|
707 | char *err = jabber_parse_error(js, packet, NULL); |
| 15884 | 708 | purple_notify_error(js->gc, _("Error"), |
|
10094
e80a87320835
[gaim-migrate @ 11112]
Mark Doliner <markdoliner@pidgin.im>
parents:
10091
diff
changeset
|
709 | _("Error retrieving room list"), err); |
| 15884 | 710 | purple_roomlist_set_in_progress(js->roomlist, FALSE); |
| 711 | purple_roomlist_unref(js->roomlist); | |
| 8120 | 712 | js->roomlist = NULL; |
| 8401 | 713 | g_free(err); |
| 8113 | 714 | return; |
| 715 | } | |
| 716 | ||
| 8135 | 717 | for(item = xmlnode_get_child(query, "item"); item; |
| 718 | item = xmlnode_get_next_twin(item)) { | |
| 8113 | 719 | const char *name; |
| 15884 | 720 | PurpleRoomlistRoom *room; |
| 8113 | 721 | JabberID *jid; |
| 722 | ||
| 723 | if(!(jid = jabber_id_new(xmlnode_get_attrib(item, "jid")))) | |
| 724 | continue; | |
| 725 | name = xmlnode_get_attrib(item, "name"); | |
| 726 | ||
| 727 | ||
| 15884 | 728 | room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, jid->node, NULL); |
| 729 | purple_roomlist_room_add_field(js->roomlist, room, jid->node); | |
| 730 | purple_roomlist_room_add_field(js->roomlist, room, jid->domain); | |
| 731 | purple_roomlist_room_add_field(js->roomlist, room, name ? name : ""); | |
| 732 | purple_roomlist_room_add(js->roomlist, room); | |
| 8113 | 733 | |
| 734 | jabber_id_free(jid); | |
| 735 | } | |
| 15884 | 736 | purple_roomlist_set_in_progress(js->roomlist, FALSE); |
| 737 | purple_roomlist_unref(js->roomlist); | |
| 8113 | 738 | js->roomlist = NULL; |
| 739 | } | |
| 740 | ||
| 10045 | 741 | static void roomlist_cancel_cb(JabberStream *js, const char *server) { |
| 742 | if(js->roomlist) { | |
| 15884 | 743 | purple_roomlist_set_in_progress(js->roomlist, FALSE); |
| 744 | purple_roomlist_unref(js->roomlist); | |
| 10045 | 745 | js->roomlist = NULL; |
| 746 | } | |
| 747 | } | |
| 748 | ||
| 8113 | 749 | static void roomlist_ok_cb(JabberStream *js, const char *server) |
| 750 | { | |
| 751 | JabberIq *iq; | |
| 10045 | 752 | |
| 753 | if(!js->roomlist) | |
| 754 | return; | |
| 8113 | 755 | |
| 756 | if(!server || !*server) { | |
| 15884 | 757 | 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
|
758 | purple_roomlist_set_in_progress(js->roomlist, FALSE); |
| 8113 | 759 | return; |
| 760 | } | |
| 761 | ||
| 15884 | 762 | purple_roomlist_set_in_progress(js->roomlist, TRUE); |
| 10045 | 763 | |
| 764 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#items"); | |
| 765 | ||
| 766 | xmlnode_set_attrib(iq->node, "to", server); | |
| 767 | ||
| 768 | jabber_iq_set_callback(iq, roomlist_disco_result_cb, NULL); | |
| 769 | ||
| 770 | jabber_iq_send(iq); | |
| 771 | } | |
| 772 | ||
| 15884 | 773 | char *jabber_roomlist_room_serialize(PurpleRoomlistRoom *room) |
| 15185 | 774 | { |
| 775 | ||
| 776 | return g_strdup_printf("%s@%s", (char*)room->fields->data, (char*)room->fields->next->data); | |
| 777 | } | |
| 778 | ||
| 15884 | 779 | PurpleRoomlist *jabber_roomlist_get_list(PurpleConnection *gc) |
| 10045 | 780 | { |
| 781 | JabberStream *js = gc->proto_data; | |
| 782 | GList *fields = NULL; | |
| 15884 | 783 | PurpleRoomlistField *f; |
| 10045 | 784 | |
|
9913
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
785 | if(js->roomlist) |
| 15884 | 786 | purple_roomlist_unref(js->roomlist); |
|
9913
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
787 | |
| 15884 | 788 | 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
|
789 | |
| 15884 | 790 | 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
|
791 | fields = g_list_append(fields, f); |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
792 | |
| 15884 | 793 | 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
|
794 | fields = g_list_append(fields, f); |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
795 | |
| 15884 | 796 | 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
|
797 | fields = g_list_append(fields, f); |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
798 | |
| 15884 | 799 | purple_roomlist_set_fields(js->roomlist, fields); |
|
9913
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
800 | |
| 8113 | 801 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
802 | purple_request_input(gc, _("Enter a Conference Server"), _("Enter a Conference Server"), |
| 8113 | 803 | _("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
|
804 | js->chat_servers ? js->chat_servers->data : NULL, |
| 8697 | 805 | FALSE, FALSE, NULL, |
| 15884 | 806 | _("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
|
807 | _("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
|
808 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
809 | js); |
| 8113 | 810 | |
| 811 | return js->roomlist; | |
| 812 | } | |
| 813 | ||
| 15884 | 814 | void jabber_roomlist_cancel(PurpleRoomlist *list) |
| 8113 | 815 | { |
| 15884 | 816 | PurpleConnection *gc; |
| 8113 | 817 | JabberStream *js; |
| 818 | ||
| 15884 | 819 | gc = purple_account_get_connection(list->account); |
| 8113 | 820 | js = gc->proto_data; |
| 821 | ||
| 15884 | 822 | purple_roomlist_set_in_progress(list, FALSE); |
| 8113 | 823 | |
| 824 | if (js->roomlist == list) { | |
| 825 | js->roomlist = NULL; | |
| 15884 | 826 | purple_roomlist_unref(list); |
| 8113 | 827 | } |
| 828 | } | |
| 829 | ||
| 9152 | 830 | void jabber_chat_member_free(JabberChatMember *jcm) |
| 831 | { | |
| 832 | g_free(jcm->handle); | |
| 833 | g_free(jcm->jid); | |
| 834 | g_free(jcm); | |
| 835 | } | |
| 836 | ||
| 837 | void jabber_chat_track_handle(JabberChat *chat, const char *handle, | |
| 838 | const char *jid, const char *affiliation, const char *role) | |
| 839 | { | |
| 840 | JabberChatMember *jcm = g_new0(JabberChatMember, 1); | |
| 841 | ||
| 842 | jcm->handle = g_strdup(handle); | |
| 843 | jcm->jid = g_strdup(jid); | |
| 844 | ||
| 845 | g_hash_table_replace(chat->members, jcm->handle, jcm); | |
| 846 | ||
| 847 | /* XXX: keep track of role and affiliation */ | |
| 848 | } | |
| 849 | ||
| 850 | void jabber_chat_remove_handle(JabberChat *chat, const char *handle) | |
| 851 | { | |
| 852 | g_hash_table_remove(chat->members, handle); | |
| 853 | } | |
| 854 | ||
| 855 | gboolean jabber_chat_ban_user(JabberChat *chat, const char *who, const char *why) | |
| 856 | { | |
|
19854
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
857 | 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
|
858 | 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
|
859 | char *to; |
| 9152 | 860 | JabberIq *iq; |
| 861 | xmlnode *query, *item, *reason; | |
| 862 | ||
|
19854
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
863 | 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
|
864 | 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
|
865 | jid = 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
|
866 | else if (g_utf8_strchr(who, -1, '@') != NULL) |
|
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
867 | 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
|
868 | else |
| 9152 | 869 | return FALSE; |
| 870 | ||
| 871 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, | |
| 872 | "http://jabber.org/protocol/muc#admin"); | |
| 873 | ||
| 874 | to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 875 | xmlnode_set_attrib(iq->node, "to", to); | |
| 876 | g_free(to); | |
| 877 | ||
| 878 | query = xmlnode_get_child(iq->node, "query"); | |
| 879 | 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
|
880 | xmlnode_set_attrib(item, "jid", jid); |
| 9152 | 881 | xmlnode_set_attrib(item, "affiliation", "outcast"); |
| 882 | if(why) { | |
| 883 | reason = xmlnode_new_child(item, "reason"); | |
| 884 | xmlnode_insert_data(reason, why, -1); | |
| 885 | } | |
| 886 | ||
| 887 | jabber_iq_send(iq); | |
| 888 | ||
| 889 | return TRUE; | |
| 890 | } | |
| 8113 | 891 | |
| 11393 | 892 | gboolean jabber_chat_affiliate_user(JabberChat *chat, const char *who, const char *affiliation) |
| 893 | { | |
|
19854
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
894 | 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
|
895 | const char *jid; |
|
13238
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
896 | char *to; |
| 11393 | 897 | JabberIq *iq; |
| 898 | xmlnode *query, *item; | |
|
13238
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
899 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
900 | 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
|
901 | 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
|
902 | jid = 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
|
903 | else if (g_utf8_strchr(who, -1, '@') != NULL) |
|
b7971f8bd19a
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <markdoliner@pidgin.im>
parents:
17007
diff
changeset
|
904 | 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
|
905 | else |
| 11393 | 906 | return FALSE; |
| 907 | ||
| 908 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, | |
| 909 | "http://jabber.org/protocol/muc#admin"); | |
| 910 | ||
| 911 | to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 912 | xmlnode_set_attrib(iq->node, "to", to); | |
| 913 | g_free(to); | |
| 914 | ||
| 915 | query = xmlnode_get_child(iq->node, "query"); | |
| 916 | 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
|
917 | xmlnode_set_attrib(item, "jid", jid); |
| 11393 | 918 | xmlnode_set_attrib(item, "affiliation", affiliation); |
| 919 | ||
| 920 | jabber_iq_send(iq); | |
| 921 | ||
| 922 | return TRUE; | |
| 923 | } | |
| 8113 | 924 | |
|
27027
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
925 | 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
|
926 | 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
|
927 | 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
|
928 | 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
|
929 | { |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
930 | 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
|
931 | 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
|
932 | 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
|
933 | 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
|
934 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
935 | 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
|
936 | return; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
937 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
938 | 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
|
939 | return; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
940 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
941 | 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
|
942 | return; |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
943 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
944 | 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
|
945 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
946 | 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
|
947 | 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
|
948 | 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
|
949 | 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
|
950 | 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
|
951 | 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
|
952 | 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
|
953 | } |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
954 | } else { |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
955 | 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
|
956 | 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
|
957 | } |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
958 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
959 | 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
|
960 | 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
|
961 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
962 | 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
|
963 | } |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
964 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
965 | 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
|
966 | { |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
967 | 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
|
968 | 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
|
969 | 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
|
970 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
971 | 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
|
972 | "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
|
973 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
974 | 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
|
975 | 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
|
976 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
977 | 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
|
978 | 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
|
979 | 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
|
980 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
981 | 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
|
982 | 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
|
983 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
984 | 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
|
985 | } |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
986 | |
|
13238
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
987 | gboolean jabber_chat_role_user(JabberChat *chat, const char *who, const char *role) |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
988 | { |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
989 | char *to; |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
990 | JabberIq *iq; |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
991 | xmlnode *query, *item; |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
992 | JabberChatMember *jcm; |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
993 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
994 | jcm = g_hash_table_lookup(chat->members, who); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
995 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
996 | if (!jcm || !jcm->handle) |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
997 | return FALSE; |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
998 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
999 | 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
|
1000 | "http://jabber.org/protocol/muc#admin"); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1001 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1002 | 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
|
1003 | xmlnode_set_attrib(iq->node, "to", to); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1004 | g_free(to); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1005 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1006 | query = xmlnode_get_child(iq->node, "query"); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1007 | item = xmlnode_new_child(query, "item"); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1008 | xmlnode_set_attrib(item, "nick", jcm->handle); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1009 | xmlnode_set_attrib(item, "role", role); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1010 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1011 | jabber_iq_send(iq); |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1012 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1013 | return TRUE; |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1014 | } |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
12323
diff
changeset
|
1015 | |
|
27027
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1016 | 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
|
1017 | 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
|
1018 | 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
|
1019 | { |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1020 | 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
|
1021 | 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
|
1022 | 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
|
1023 | 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
|
1024 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1025 | 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
|
1026 | return; |
|
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 | 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
|
1029 | return; |
|
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 | 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
|
1032 | return; |
|
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 | 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
|
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 | 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
|
1037 | 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
|
1038 | 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
|
1039 | 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
|
1040 | 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
|
1041 | 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
|
1042 | 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
|
1043 | } |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1044 | } else { |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1045 | 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
|
1046 | 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
|
1047 | } |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1048 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1049 | 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
|
1050 | 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
|
1051 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1052 | 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
|
1053 | } |
|
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 | 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
|
1056 | { |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1057 | 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
|
1058 | 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
|
1059 | 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
|
1060 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1061 | 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
|
1062 | "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
|
1063 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1064 | 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
|
1065 | 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
|
1066 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1067 | 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
|
1068 | 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
|
1069 | 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
|
1070 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1071 | 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
|
1072 | 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
|
1073 | |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1074 | 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
|
1075 | } |
|
f3129efa65ea
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
1076 | |
| 9152 | 1077 | gboolean jabber_chat_kick_user(JabberChat *chat, const char *who, const char *why) |
| 1078 | { | |
| 1079 | JabberIq *iq; | |
| 1080 | JabberChatMember *jcm = g_hash_table_lookup(chat->members, who); | |
| 1081 | char *to; | |
| 1082 | xmlnode *query, *item, *reason; | |
| 1083 | ||
| 1084 | if(!jcm || !jcm->jid) | |
| 1085 | return FALSE; | |
| 1086 | ||
| 1087 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, | |
| 1088 | "http://jabber.org/protocol/muc#admin"); | |
| 1089 | ||
| 1090 | to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 1091 | xmlnode_set_attrib(iq->node, "to", to); | |
| 1092 | g_free(to); | |
| 1093 | ||
| 1094 | query = xmlnode_get_child(iq->node, "query"); | |
| 1095 | item = xmlnode_new_child(query, "item"); | |
| 1096 | xmlnode_set_attrib(item, "jid", jcm->jid); | |
| 1097 | xmlnode_set_attrib(item, "role", "none"); | |
| 1098 | if(why) { | |
| 1099 | reason = xmlnode_new_child(item, "reason"); | |
| 1100 | xmlnode_insert_data(reason, why, -1); | |
| 1101 | } | |
| 1102 | ||
| 1103 | jabber_iq_send(iq); | |
| 1104 | ||
| 1105 | return TRUE; | |
| 1106 | } | |
| 1107 | ||
|
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
|
1108 | 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
|
1109 | 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
|
1110 | xmlnode *packet, gpointer data) |
| 10941 | 1111 | { |
| 1112 | 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
|
1113 | #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
|
1114 | 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
|
1115 | #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
|
1116 | int chat_id = GPOINTER_TO_INT(data); |
| 10941 | 1117 | |
|
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
|
1118 | if(!(chat = jabber_chat_find_by_id(js, chat_id))) |
| 10941 | 1119 | return; |
| 1120 | ||
|
11392
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1121 | /* defaults, in case the conference server doesn't |
|
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1122 | * support this request */ |
|
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1123 | chat->xhtml = TRUE; |
|
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1124 | |
|
20225
684334efdc19
applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents:
19897
diff
changeset
|
1125 | /* 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
|
1126 | * 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
|
1127 | #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
|
1128 | if (type == JABBER_IQ_ERROR) { |
| 10941 | 1129 | return; |
| 1130 | } | |
| 1131 | ||
| 1132 | if(!(query = xmlnode_get_child(packet, "query"))) | |
| 1133 | return; | |
| 1134 | ||
|
11392
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1135 | chat->xhtml = FALSE; |
|
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1136 | |
| 10941 | 1137 | for(x = xmlnode_get_child(query, "feature"); x; x = xmlnode_get_next_twin(x)) { |
| 1138 | const char *var = xmlnode_get_attrib(x, "var"); | |
| 1139 | ||
| 1140 | if(var && !strcmp(var, "http://jabber.org/protocol/xhtml-im")) { | |
| 1141 | chat->xhtml = TRUE; | |
| 1142 | } | |
| 1143 | } | |
|
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
|
1144 | #endif |
| 10941 | 1145 | } |
| 1146 | ||
| 1147 | void jabber_chat_disco_traffic(JabberChat *chat) | |
| 1148 | { | |
| 1149 | JabberIq *iq; | |
| 1150 | xmlnode *query; | |
|
11392
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1151 | char *room_jid; |
|
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1152 | |
|
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1153 | room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); |
| 10941 | 1154 | |
| 1155 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, | |
| 1156 | "http://jabber.org/protocol/disco#info"); | |
| 1157 | ||
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24254
diff
changeset
|
1158 | xmlnode_set_attrib(iq->node, "to", room_jid); |
|
11392
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1159 | |
| 10941 | 1160 | query = xmlnode_get_child(iq->node, "query"); |
| 1161 | ||
| 1162 | xmlnode_set_attrib(query, "node", "http://jabber.org/protocol/muc#traffic"); | |
| 1163 | ||
| 1164 | jabber_iq_set_callback(iq, jabber_chat_disco_traffic_cb, GINT_TO_POINTER(chat->id)); | |
| 1165 | ||
| 1166 | jabber_iq_send(iq); | |
|
11392
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1167 | |
|
fcf358e5a309
[gaim-migrate @ 13621]
Zmitrok <zmitrok@users.sourceforge.net>
parents:
10959
diff
changeset
|
1168 | g_free(room_jid); |
| 10941 | 1169 | } |
| 9152 | 1170 | |
|
27110
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1171 | 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
|
1172 | 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
|
1173 | 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
|
1174 | 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
|
1175 | } JabberChatCapsData; |
| 9152 | 1176 | |
|
27110
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1177 | 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
|
1178 | 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
|
1179 | 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
|
1180 | 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
|
1181 | { |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1182 | 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
|
1183 | 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
|
1184 | 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
|
1185 | 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
|
1186 | 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
|
1187 | JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource); |
| 10941 | 1188 | |
|
27110
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1189 | 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
|
1190 | *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
|
1191 | } else { |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1192 | *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
|
1193 | } |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1194 | } |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1195 | |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1196 | gboolean |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1197 | 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
|
1198 | 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
|
1199 | { |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1200 | 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
|
1201 | 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
|
1202 | 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
|
1203 | 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
|
1204 | |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1205 | 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
|
1206 | 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
|
1207 | |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1208 | 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
|
1209 | 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
|
1210 | 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
|
1211 | 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
|
1212 | |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27110
diff
changeset
|
1213 | 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
|
1214 | 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
|
1215 | } else { |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1216 | 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
|
1217 | } |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1218 | 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
|
1219 | 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
|
1220 | } |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1221 | |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1222 | guint |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1223 | 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
|
1224 | { |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27027
diff
changeset
|
1225 | 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
|
1226 | } |