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