Tue, 31 Aug 2004 01:45:12 +0000
[gaim-migrate @ 10809]
view chat logs curtesy of datallah
committer: Luke Schierer <lschiere@pidgin.im>
| 7014 | 1 | /* |
| 2 | * gaim - Jabber Protocol Plugin | |
| 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 | |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 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" |
| 7014 | 34 | |
| 35 | GList *jabber_chat_info(GaimConnection *gc) | |
| 36 | { | |
| 37 | GList *m = NULL; | |
| 38 | struct proto_chat_entry *pce; | |
| 39 | ||
| 40 | pce = g_new0(struct proto_chat_entry, 1); | |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7400
diff
changeset
|
41 | pce->label = _("_Room:"); |
| 7014 | 42 | pce->identifier = "room"; |
| 43 | m = g_list_append(m, pce); | |
| 44 | ||
| 45 | pce = g_new0(struct proto_chat_entry, 1); | |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7400
diff
changeset
|
46 | pce->label = _("_Server:"); |
| 7014 | 47 | pce->identifier = "server"; |
| 48 | m = g_list_append(m, pce); | |
| 49 | ||
| 50 | pce = g_new0(struct proto_chat_entry, 1); | |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7400
diff
changeset
|
51 | pce->label = _("_Handle:"); |
| 7014 | 52 | pce->identifier = "handle"; |
| 53 | m = g_list_append(m, pce); | |
| 54 | ||
| 55 | pce = g_new0(struct proto_chat_entry, 1); | |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7400
diff
changeset
|
56 | pce->label = _("_Password:"); |
| 7014 | 57 | pce->identifier = "password"; |
| 58 | pce->secret = TRUE; | |
| 59 | m = g_list_append(m, pce); | |
| 60 | ||
| 61 | return m; | |
| 62 | } | |
| 63 | ||
|
9754
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
64 | GHashTable *jabber_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
65 | { |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
66 | GHashTable *defaults; |
|
9770
d61fe8dcb6d9
[gaim-migrate @ 10638]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9762
diff
changeset
|
67 | JabberStream *js = gc->proto_data; |
|
9754
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
68 | |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
69 | 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
|
70 | |
|
9770
d61fe8dcb6d9
[gaim-migrate @ 10638]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9762
diff
changeset
|
71 | g_hash_table_insert(defaults, "handle", g_strdup(js->user->node)); |
|
d61fe8dcb6d9
[gaim-migrate @ 10638]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9762
diff
changeset
|
72 | |
|
d61fe8dcb6d9
[gaim-migrate @ 10638]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9762
diff
changeset
|
73 | if (js->chat_servers) |
|
d61fe8dcb6d9
[gaim-migrate @ 10638]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9762
diff
changeset
|
74 | 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
|
75 | else |
|
d61fe8dcb6d9
[gaim-migrate @ 10638]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9762
diff
changeset
|
76 | g_hash_table_insert(defaults, "server", g_strdup("conference.jabber.org")); |
|
d61fe8dcb6d9
[gaim-migrate @ 10638]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9762
diff
changeset
|
77 | |
|
9754
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
78 | if (chat_name != NULL) { |
| 9760 | 79 | JabberID *jid = jabber_id_new(chat_name); |
| 80 | if(jid) { | |
| 81 | g_hash_table_insert(defaults, "room", g_strdup(jid->node)); | |
| 82 | if(jid->domain) | |
|
9770
d61fe8dcb6d9
[gaim-migrate @ 10638]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9762
diff
changeset
|
83 | g_hash_table_replace(defaults, "server", g_strdup(jid->domain)); |
| 9760 | 84 | jabber_id_free(jid); |
| 85 | } | |
|
9754
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
86 | } |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
87 | |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
88 | return defaults; |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
89 | } |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9713
diff
changeset
|
90 | |
| 7014 | 91 | JabberChat *jabber_chat_find(JabberStream *js, const char *room, |
| 92 | const char *server) | |
| 93 | { | |
| 94 | JabberChat *chat; | |
| 95 | char *room_jid; | |
| 96 | ||
| 97 | room_jid = g_strdup_printf("%s@%s", room, server); | |
| 98 | ||
| 7322 | 99 | chat = g_hash_table_lookup(js->chats, jabber_normalize(NULL, room_jid)); |
| 7014 | 100 | g_free(room_jid); |
| 101 | ||
| 102 | return chat; | |
| 103 | } | |
| 104 | ||
| 105 | struct _find_by_id_data { | |
| 106 | int id; | |
| 107 | JabberChat *chat; | |
| 108 | }; | |
| 109 | ||
| 110 | void find_by_id_foreach_cb(gpointer key, gpointer value, gpointer user_data) | |
| 111 | { | |
| 112 | JabberChat *chat = value; | |
| 113 | struct _find_by_id_data *fbid = user_data; | |
| 114 | ||
| 115 | if(chat->id == fbid->id) | |
| 116 | fbid->chat = chat; | |
| 117 | } | |
| 118 | ||
| 119 | JabberChat *jabber_chat_find_by_id(JabberStream *js, int id) | |
| 120 | { | |
| 121 | JabberChat *chat; | |
| 122 | struct _find_by_id_data *fbid = g_new0(struct _find_by_id_data, 1); | |
| 7073 | 123 | fbid->id = id; |
| 7014 | 124 | g_hash_table_foreach(js->chats, find_by_id_foreach_cb, fbid); |
| 125 | chat = fbid->chat; | |
| 126 | g_free(fbid); | |
| 127 | return chat; | |
| 128 | } | |
| 129 | ||
| 9130 | 130 | JabberChat *jabber_chat_find_by_conv(GaimConversation *conv) |
| 131 | { | |
| 132 | GaimAccount *account = gaim_conversation_get_account(conv); | |
| 133 | GaimConnection *gc = gaim_account_get_connection(account); | |
| 134 | JabberStream *js = gc->proto_data; | |
| 135 | int id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)); | |
| 136 | ||
| 137 | return jabber_chat_find_by_id(js, id); | |
| 138 | } | |
| 139 | ||
| 7014 | 140 | void jabber_chat_invite(GaimConnection *gc, int id, const char *msg, |
| 141 | const char *name) | |
| 142 | { | |
| 143 | JabberStream *js = gc->proto_data; | |
| 144 | JabberChat *chat; | |
| 145 | xmlnode *message, *body, *x, *invite; | |
| 146 | char *room_jid; | |
| 147 | ||
| 148 | chat = jabber_chat_find_by_id(js, id); | |
| 149 | if(!chat) | |
| 150 | return; | |
| 151 | ||
| 152 | message = xmlnode_new("message"); | |
| 153 | ||
| 154 | room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 155 | ||
| 156 | if(chat->muc) { | |
| 157 | xmlnode_set_attrib(message, "to", room_jid); | |
| 158 | x = xmlnode_new_child(message, "x"); | |
| 159 | xmlnode_set_attrib(x, "xmlns", "http://jabber.org/protocol/muc#user"); | |
| 160 | invite = xmlnode_new_child(x, "invite"); | |
| 161 | xmlnode_set_attrib(invite, "to", name); | |
| 162 | body = xmlnode_new_child(invite, "reason"); | |
| 163 | xmlnode_insert_data(body, msg, -1); | |
| 164 | } else { | |
| 165 | xmlnode_set_attrib(message, "to", name); | |
| 166 | body = xmlnode_new_child(message, "body"); | |
| 167 | xmlnode_insert_data(body, msg, -1); | |
| 168 | x = xmlnode_new_child(message, "x"); | |
| 169 | xmlnode_set_attrib(x, "jid", room_jid); | |
| 170 | xmlnode_set_attrib(x, "xmlns", "jabber:x:conference"); | |
| 171 | } | |
| 172 | ||
| 173 | jabber_send(js, message); | |
| 174 | xmlnode_free(message); | |
| 175 | g_free(room_jid); | |
| 176 | } | |
| 177 | ||
| 9152 | 178 | void jabber_chat_member_free(JabberChatMember *jcm); |
| 179 | ||
|
9917
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
180 | char *jabber_get_chat_name(GHashTable *data) { |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
181 | char *room, *server, *chat_name = NULL; |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
182 | |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
183 | room = g_hash_table_lookup(data, "room"); |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
184 | server = g_hash_table_lookup(data, "server"); |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
185 | |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
186 | if (room && server) { |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
187 | chat_name = g_strdup_printf("%s@%s", room, server); |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
188 | } |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
189 | return chat_name; |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
190 | } |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9913
diff
changeset
|
191 | |
| 7014 | 192 | void jabber_chat_join(GaimConnection *gc, GHashTable *data) |
| 193 | { | |
| 194 | JabberChat *chat; | |
| 195 | char *room, *server, *handle, *passwd; | |
| 196 | xmlnode *presence, *x; | |
| 7262 | 197 | char *tmp, *room_jid, *full_jid; |
| 7014 | 198 | JabberStream *js = gc->proto_data; |
| 199 | ||
| 200 | room = g_hash_table_lookup(data, "room"); | |
| 201 | server = g_hash_table_lookup(data, "server"); | |
| 202 | handle = g_hash_table_lookup(data, "handle"); | |
| 203 | passwd = g_hash_table_lookup(data, "password"); | |
| 204 | ||
| 8113 | 205 | if(!room || !server) |
| 7014 | 206 | return; |
| 207 | ||
| 8113 | 208 | if(!handle) |
| 209 | handle = js->user->node; | |
| 210 | ||
| 7310 | 211 | if(!jabber_nodeprep_validate(room)) { |
| 212 | char *buf = g_strdup_printf(_("%s is not a valid room name"), room); | |
| 213 | gaim_notify_error(gc, _("Invalid Room Name"), _("Invalid Room Name"), | |
| 214 | buf); | |
| 215 | g_free(buf); | |
| 216 | return; | |
| 217 | } else if(!jabber_nameprep_validate(server)) { | |
| 218 | char *buf = g_strdup_printf(_("%s is not a valid server name"), server); | |
| 219 | gaim_notify_error(gc, _("Invalid Server Name"), | |
| 220 | _("Invalid Server Name"), buf); | |
| 221 | g_free(buf); | |
| 222 | return; | |
| 223 | } else if(!jabber_resourceprep_validate(handle)) { | |
| 224 | char *buf = g_strdup_printf(_("%s is not a valid room handle"), handle); | |
| 225 | gaim_notify_error(gc, _("Invalid Room Handle"), | |
| 226 | _("Invalid Room Handle"), buf); | |
| 227 | } | |
| 228 | ||
| 7014 | 229 | if(jabber_chat_find(js, room, server)) |
| 230 | return; | |
| 231 | ||
| 7262 | 232 | tmp = g_strdup_printf("%s@%s", room, server); |
| 7322 | 233 | room_jid = g_strdup(jabber_normalize(NULL, tmp)); |
| 7262 | 234 | g_free(tmp); |
| 7014 | 235 | |
| 236 | chat = g_new0(JabberChat, 1); | |
| 237 | chat->js = gc->proto_data; | |
| 238 | ||
| 239 | chat->room = g_strdup(room); | |
| 240 | chat->server = g_strdup(server); | |
| 8400 | 241 | chat->handle = g_strdup(handle); |
| 7014 | 242 | |
| 9152 | 243 | chat->members = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, |
| 244 | (GDestroyNotify)jabber_chat_member_free); | |
| 245 | ||
| 7014 | 246 | g_hash_table_insert(js->chats, room_jid, chat); |
| 247 | ||
| 7073 | 248 | presence = jabber_presence_create(gc->away_state, gc->away); |
| 7014 | 249 | full_jid = g_strdup_printf("%s/%s", room_jid, handle); |
| 250 | xmlnode_set_attrib(presence, "to", full_jid); | |
| 251 | g_free(full_jid); | |
| 252 | ||
| 253 | x = xmlnode_new_child(presence, "x"); | |
| 254 | xmlnode_set_attrib(x, "xmlns", "http://jabber.org/protocol/muc"); | |
| 255 | ||
| 256 | if(passwd && *passwd) { | |
| 257 | xmlnode *password = xmlnode_new_child(x, "password"); | |
| 258 | xmlnode_insert_data(password, passwd, -1); | |
| 259 | } | |
| 260 | ||
| 261 | jabber_send(js, presence); | |
| 262 | xmlnode_free(presence); | |
| 263 | } | |
| 264 | ||
| 265 | void jabber_chat_leave(GaimConnection *gc, int id) | |
| 266 | { | |
| 267 | JabberStream *js = gc->proto_data; | |
| 268 | JabberChat *chat = jabber_chat_find_by_id(js, id); | |
| 7974 | 269 | |
| 7014 | 270 | |
| 271 | if(!chat) | |
| 272 | return; | |
| 273 | ||
| 7974 | 274 | jabber_chat_part(chat, NULL); |
| 9152 | 275 | |
| 276 | chat->conv = NULL; | |
| 7014 | 277 | } |
| 278 | ||
| 279 | void jabber_chat_destroy(JabberChat *chat) | |
| 280 | { | |
| 281 | JabberStream *js = chat->js; | |
| 282 | char *room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 283 | ||
| 7322 | 284 | g_hash_table_remove(js->chats, jabber_normalize(NULL, room_jid)); |
| 7014 | 285 | g_free(room_jid); |
| 8396 | 286 | } |
| 287 | ||
| 288 | void jabber_chat_free(JabberChat *chat) | |
| 289 | { | |
| 290 | if(chat->config_dialog_handle) | |
| 291 | gaim_request_close(chat->config_dialog_type, chat->config_dialog_handle); | |
| 7014 | 292 | |
| 293 | g_free(chat->room); | |
| 294 | g_free(chat->server); | |
| 295 | g_free(chat); | |
| 296 | } | |
| 297 | ||
| 298 | gboolean jabber_chat_find_buddy(GaimConversation *conv, const char *name) | |
| 299 | { | |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9152
diff
changeset
|
300 | return gaim_conv_chat_find_user(GAIM_CONV_CHAT(conv), name); |
| 7014 | 301 | } |
| 302 | ||
| 7398 | 303 | char *jabber_chat_buddy_real_name(GaimConnection *gc, int id, const char *who) |
| 304 | { | |
| 305 | JabberStream *js = gc->proto_data; | |
| 306 | JabberChat *chat; | |
| 307 | ||
| 308 | chat = jabber_chat_find_by_id(js, id); | |
| 309 | ||
| 310 | if(!chat) | |
| 311 | return NULL; | |
| 312 | ||
| 313 | return g_strdup_printf("%s@%s/%s", chat->room, chat->server, who); | |
| 314 | } | |
| 7895 | 315 | |
| 7923 | 316 | static void jabber_chat_room_configure_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) |
| 317 | { | |
| 318 | JabberChat *chat = data; | |
| 319 | xmlnode *query; | |
| 320 | JabberIq *iq; | |
| 321 | char *to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 322 | ||
| 323 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "http://jabber.org/protocol/muc#owner"); | |
| 324 | xmlnode_set_attrib(iq->node, "to", to); | |
| 325 | g_free(to); | |
| 326 | ||
| 327 | query = xmlnode_get_child(iq->node, "query"); | |
| 328 | ||
| 329 | xmlnode_insert_child(query, result); | |
| 330 | ||
| 331 | jabber_iq_send(iq); | |
| 332 | } | |
| 333 | ||
| 334 | static void jabber_chat_room_configure_cb(JabberStream *js, xmlnode *packet, gpointer data) | |
| 335 | { | |
| 336 | xmlnode *query, *x; | |
| 337 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 338 | const char *from = xmlnode_get_attrib(packet, "from"); | |
| 7926 | 339 | char *msg; |
| 7923 | 340 | JabberChat *chat; |
| 341 | JabberID *jid; | |
| 342 | ||
| 343 | if(!type || !from) | |
| 344 | return; | |
| 345 | ||
| 346 | ||
| 7926 | 347 | |
| 7923 | 348 | if(!strcmp(type, "result")) { |
| 349 | jid = jabber_id_new(from); | |
| 350 | ||
| 351 | if(!jid) | |
| 352 | return; | |
| 353 | ||
| 354 | chat = jabber_chat_find(js, jid->node, jid->domain); | |
| 355 | jabber_id_free(jid); | |
| 356 | ||
| 357 | if(!chat) | |
| 358 | return; | |
| 359 | ||
| 360 | if(!(query = xmlnode_get_child(packet, "query"))) | |
| 361 | return; | |
| 362 | ||
| 8135 | 363 | for(x = xmlnode_get_child(query, "x"); x; x = xmlnode_get_next_twin(x)) { |
| 7923 | 364 | const char *xmlns; |
| 365 | if(!(xmlns = xmlnode_get_attrib(x, "xmlns"))) | |
| 366 | continue; | |
| 367 | ||
| 368 | if(!strcmp(xmlns, "jabber:x:data")) { | |
| 8396 | 369 | chat->config_dialog_type = GAIM_REQUEST_FIELDS; |
| 370 | chat->config_dialog_handle = jabber_x_data_request(js, x, jabber_chat_room_configure_x_data_cb, chat); | |
| 7923 | 371 | return; |
| 372 | } | |
| 373 | } | |
| 7926 | 374 | } else if(!strcmp(type, "error")) { |
| 8401 | 375 | char *msg = jabber_parse_error(js, packet); |
| 7926 | 376 | |
| 377 | gaim_notify_error(js->gc, _("Configuration error"), _("Configuration error"), msg); | |
| 378 | ||
| 8401 | 379 | if(msg) |
| 380 | g_free(msg); | |
| 7926 | 381 | return; |
| 7923 | 382 | } |
| 383 | ||
| 7926 | 384 | msg = g_strdup_printf("Unable to configure room %s", from); |
| 385 | ||
| 386 | gaim_notify_info(js->gc, _("Unable to configure"), _("Unable to configure"), msg); | |
| 387 | g_free(msg); | |
| 7923 | 388 | |
| 389 | } | |
| 390 | ||
| 391 | void jabber_chat_request_room_configure(JabberChat *chat) { | |
| 392 | JabberIq *iq; | |
| 393 | xmlnode *query; | |
| 394 | char *room_jid; | |
| 395 | ||
| 7895 | 396 | if(!chat) |
| 397 | return; | |
| 398 | ||
| 8396 | 399 | chat->config_dialog_handle = NULL; |
| 400 | ||
| 7955 | 401 | if(!chat->muc) { |
| 402 | gaim_notify_error(chat->js->gc, _("Room Configuration Error"), _("Room Configuration Error"), | |
| 403 | _("This room is not capable of being configured")); | |
| 404 | return; | |
| 405 | } | |
| 406 | ||
| 7923 | 407 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, |
| 408 | "http://jabber.org/protocol/muc#owner"); | |
| 409 | query = xmlnode_get_child(iq->node, "query"); | |
| 410 | room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 7895 | 411 | |
| 7923 | 412 | xmlnode_set_attrib(iq->node, "to", room_jid); |
| 413 | ||
| 414 | jabber_iq_set_callback(iq, jabber_chat_room_configure_cb, NULL); | |
| 415 | ||
| 416 | jabber_iq_send(iq); | |
| 417 | ||
| 418 | g_free(room_jid); | |
| 7895 | 419 | } |
| 420 | ||
| 421 | void jabber_chat_create_instant_room(JabberChat *chat) { | |
| 422 | JabberIq *iq; | |
| 423 | xmlnode *query, *x; | |
| 424 | char *room_jid; | |
| 425 | ||
| 426 | if(!chat) | |
| 427 | return; | |
| 428 | ||
| 8396 | 429 | chat->config_dialog_handle = NULL; |
| 430 | ||
| 7895 | 431 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, |
| 432 | "http://jabber.org/protocol/muc#owner"); | |
| 433 | query = xmlnode_get_child(iq->node, "query"); | |
| 434 | x = xmlnode_new_child(query, "x"); | |
| 435 | room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 436 | ||
| 437 | xmlnode_set_attrib(iq->node, "to", room_jid); | |
| 438 | xmlnode_set_attrib(x, "xmlns", "jabber:x:data"); | |
| 439 | xmlnode_set_attrib(x, "type", "submit"); | |
| 440 | ||
| 441 | jabber_iq_send(iq); | |
| 442 | ||
| 443 | g_free(room_jid); | |
| 444 | } | |
| 7955 | 445 | |
| 446 | static void jabber_chat_register_x_data_result_cb(JabberStream *js, xmlnode *packet, gpointer data) | |
| 447 | { | |
| 448 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 449 | ||
| 450 | if(type && !strcmp(type, "error")) { | |
| 8401 | 451 | char *msg = jabber_parse_error(js, packet); |
| 452 | ||
| 453 | gaim_notify_error(js->gc, _("Registration error"), _("Registration error"), msg); | |
| 454 | ||
| 455 | if(msg) | |
| 456 | g_free(msg); | |
| 457 | return; | |
| 7955 | 458 | } |
| 459 | } | |
| 460 | ||
| 461 | static void jabber_chat_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) | |
| 462 | { | |
| 463 | JabberChat *chat = data; | |
| 464 | xmlnode *query; | |
| 465 | JabberIq *iq; | |
| 466 | char *to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 467 | ||
| 468 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 469 | xmlnode_set_attrib(iq->node, "to", to); | |
| 470 | g_free(to); | |
| 471 | ||
| 472 | query = xmlnode_get_child(iq->node, "query"); | |
| 473 | ||
| 474 | xmlnode_insert_child(query, result); | |
| 475 | ||
| 476 | jabber_iq_set_callback(iq, jabber_chat_register_x_data_result_cb, NULL); | |
| 477 | ||
| 478 | jabber_iq_send(iq); | |
| 479 | } | |
| 480 | ||
| 481 | static void jabber_chat_register_cb(JabberStream *js, xmlnode *packet, gpointer data) | |
| 482 | { | |
| 483 | xmlnode *query, *x; | |
| 484 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 485 | const char *from = xmlnode_get_attrib(packet, "from"); | |
| 486 | char *msg; | |
| 487 | JabberChat *chat; | |
| 488 | JabberID *jid; | |
| 489 | ||
| 490 | if(!type || !from) | |
| 491 | return; | |
| 492 | ||
| 493 | if(!strcmp(type, "result")) { | |
| 494 | jid = jabber_id_new(from); | |
| 495 | ||
| 496 | if(!jid) | |
| 497 | return; | |
| 498 | ||
| 499 | chat = jabber_chat_find(js, jid->node, jid->domain); | |
| 500 | jabber_id_free(jid); | |
| 501 | ||
| 502 | if(!chat) | |
| 503 | return; | |
| 504 | ||
| 505 | if(!(query = xmlnode_get_child(packet, "query"))) | |
| 506 | return; | |
| 507 | ||
| 8135 | 508 | for(x = xmlnode_get_child(query, "x"); x; x = xmlnode_get_next_twin(x)) { |
| 7955 | 509 | const char *xmlns; |
| 510 | ||
| 511 | if(!(xmlns = xmlnode_get_attrib(x, "xmlns"))) | |
| 512 | continue; | |
| 513 | ||
| 514 | if(!strcmp(xmlns, "jabber:x:data")) { | |
| 515 | jabber_x_data_request(js, x, jabber_chat_register_x_data_cb, chat); | |
| 516 | return; | |
| 517 | } | |
| 518 | } | |
| 519 | } else if(!strcmp(type, "error")) { | |
| 8401 | 520 | char *msg = jabber_parse_error(js, packet); |
| 7955 | 521 | |
| 522 | gaim_notify_error(js->gc, _("Registration error"), _("Registration error"), msg); | |
| 523 | ||
| 8401 | 524 | if(msg) |
| 525 | g_free(msg); | |
| 7955 | 526 | return; |
| 527 | } | |
| 528 | ||
| 529 | msg = g_strdup_printf("Unable to configure room %s", from); | |
| 530 | ||
| 531 | gaim_notify_info(js->gc, _("Unable to configure"), _("Unable to configure"), msg); | |
| 532 | g_free(msg); | |
| 533 | ||
| 534 | } | |
| 535 | ||
| 536 | void jabber_chat_register(JabberChat *chat) | |
| 537 | { | |
| 538 | JabberIq *iq; | |
| 539 | char *room_jid; | |
| 540 | ||
| 541 | if(!chat) | |
| 542 | return; | |
| 543 | ||
| 544 | room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 545 | ||
| 546 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, "jabber:iq:register"); | |
| 547 | xmlnode_set_attrib(iq->node, "to", room_jid); | |
| 548 | g_free(room_jid); | |
| 549 | ||
| 550 | jabber_iq_set_callback(iq, jabber_chat_register_cb, NULL); | |
| 551 | ||
| 552 | jabber_iq_send(iq); | |
| 553 | } | |
| 554 | ||
| 7971 | 555 | /* merge this with the function below when we get everyone on the same page wrt /commands */ |
| 556 | void jabber_chat_change_topic(JabberChat *chat, const char *topic) | |
| 557 | { | |
| 558 | if(topic && *topic) { | |
| 559 | JabberMessage *jm; | |
| 560 | jm = g_new0(JabberMessage, 1); | |
| 561 | jm->js = chat->js; | |
| 562 | jm->type = JABBER_MESSAGE_GROUPCHAT; | |
| 563 | jm->subject = gaim_markup_strip_html(topic); | |
| 564 | jm->to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 565 | jabber_message_send(jm); | |
| 566 | jabber_message_free(jm); | |
| 567 | } else { | |
| 568 | const char *cur = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(chat->conv)); | |
| 9762 | 569 | char *buf, *tmp, *tmp2; |
| 7955 | 570 | |
| 9762 | 571 | if(cur) { |
| 572 | tmp = gaim_escape_html(cur); | |
| 573 | tmp2 = gaim_markup_linkify(tmp); | |
| 574 | buf = g_strdup_printf(_("current topic is: %s"), tmp2); | |
| 575 | g_free(tmp); | |
| 576 | g_free(tmp2); | |
| 577 | } else | |
| 7971 | 578 | buf = g_strdup(_("No topic is set")); |
| 579 | gaim_conv_chat_write(GAIM_CONV_CHAT(chat->conv), "", buf, | |
| 580 | GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG, time(NULL)); | |
| 581 | g_free(buf); | |
| 582 | } | |
| 583 | ||
| 584 | } | |
| 585 | ||
| 586 | void jabber_chat_set_topic(GaimConnection *gc, int id, const char *topic) | |
| 587 | { | |
| 588 | JabberStream *js = gc->proto_data; | |
| 589 | JabberChat *chat = jabber_chat_find_by_id(js, id); | |
| 590 | ||
| 591 | if(!chat) | |
| 592 | return; | |
| 593 | ||
| 594 | jabber_chat_change_topic(chat, topic); | |
| 595 | } | |
| 596 | ||
| 597 | ||
| 7972 | 598 | void jabber_chat_change_nick(JabberChat *chat, const char *nick) |
| 599 | { | |
| 600 | xmlnode *presence; | |
| 601 | char *full_jid; | |
| 602 | ||
| 603 | if(!chat->muc) { | |
| 604 | gaim_conv_chat_write(GAIM_CONV_CHAT(chat->conv), "", | |
| 605 | _("Nick changing not supported in non-MUC chatrooms"), | |
| 606 | GAIM_MESSAGE_SYSTEM, time(NULL)); | |
| 607 | return; | |
| 608 | } | |
| 609 | ||
| 610 | presence = jabber_presence_create(chat->js->gc->away_state, chat->js->gc->away); | |
| 611 | full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, nick); | |
| 612 | xmlnode_set_attrib(presence, "to", full_jid); | |
| 613 | g_free(full_jid); | |
| 614 | ||
| 615 | jabber_send(chat->js, presence); | |
| 616 | xmlnode_free(presence); | |
| 617 | } | |
| 618 | ||
| 7974 | 619 | void jabber_chat_part(JabberChat *chat, const char *msg) |
| 620 | { | |
| 621 | char *room_jid; | |
| 622 | xmlnode *presence; | |
| 7972 | 623 | |
| 8537 | 624 | room_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, |
| 625 | chat->handle); | |
| 7974 | 626 | presence = xmlnode_new("presence"); |
| 627 | xmlnode_set_attrib(presence, "to", room_jid); | |
| 628 | xmlnode_set_attrib(presence, "type", "unavailable"); | |
| 629 | if(msg) { | |
| 630 | xmlnode *status = xmlnode_new_child(presence, "status"); | |
| 631 | xmlnode_insert_data(status, msg, -1); | |
| 632 | } | |
| 633 | jabber_send(chat->js, presence); | |
| 634 | xmlnode_free(presence); | |
| 635 | g_free(room_jid); | |
| 636 | } | |
| 637 | ||
| 8113 | 638 | static void roomlist_disco_result_cb(JabberStream *js, xmlnode *packet, gpointer data) |
| 639 | { | |
| 640 | xmlnode *query; | |
| 641 | xmlnode *item; | |
| 642 | const char *type; | |
| 7974 | 643 | |
| 8113 | 644 | if(!js->roomlist) |
| 645 | return; | |
| 646 | ||
| 647 | if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result")) { | |
| 8401 | 648 | char *err = jabber_parse_error(js,packet); |
| 649 | gaim_notify_error(js->gc, _("Roomlist Error"), | |
| 650 | _("Error retreiving roomlist"), err); | |
| 8113 | 651 | gaim_roomlist_set_in_progress(js->roomlist, FALSE); |
| 8120 | 652 | gaim_roomlist_unref(js->roomlist); |
| 653 | js->roomlist = NULL; | |
| 8401 | 654 | g_free(err); |
| 8113 | 655 | return; |
| 656 | } | |
| 657 | ||
| 658 | if(!(query = xmlnode_get_child(packet, "query"))) { | |
| 8401 | 659 | char *err = jabber_parse_error(js, packet); |
| 660 | gaim_notify_error(js->gc, _("Roomlist Error"), | |
| 661 | _("Error retreiving roomlist"), err); | |
| 8113 | 662 | gaim_roomlist_set_in_progress(js->roomlist, FALSE); |
| 8120 | 663 | gaim_roomlist_unref(js->roomlist); |
| 664 | js->roomlist = NULL; | |
| 8401 | 665 | g_free(err); |
| 8113 | 666 | return; |
| 667 | } | |
| 668 | ||
| 8135 | 669 | for(item = xmlnode_get_child(query, "item"); item; |
| 670 | item = xmlnode_get_next_twin(item)) { | |
| 8113 | 671 | const char *name; |
| 672 | GaimRoomlistRoom *room; | |
| 673 | JabberID *jid; | |
| 674 | ||
| 675 | if(!(jid = jabber_id_new(xmlnode_get_attrib(item, "jid")))) | |
| 676 | continue; | |
| 677 | name = xmlnode_get_attrib(item, "name"); | |
| 678 | ||
| 679 | ||
| 680 | room = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_ROOM, jid->node, NULL); | |
| 681 | gaim_roomlist_room_add_field(js->roomlist, room, jid->node); | |
| 682 | gaim_roomlist_room_add_field(js->roomlist, room, jid->domain); | |
| 683 | gaim_roomlist_room_add_field(js->roomlist, room, name ? name : ""); | |
| 684 | gaim_roomlist_room_add(js->roomlist, room); | |
| 685 | ||
| 686 | jabber_id_free(jid); | |
| 687 | } | |
| 688 | gaim_roomlist_set_in_progress(js->roomlist, FALSE); | |
| 689 | gaim_roomlist_unref(js->roomlist); | |
| 690 | js->roomlist = NULL; | |
| 691 | } | |
| 692 | ||
| 693 | static void roomlist_ok_cb(JabberStream *js, const char *server) | |
| 694 | { | |
| 695 | JabberIq *iq; | |
|
9913
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
696 | GList *fields = NULL; |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
697 | GaimRoomlistField *f; |
| 8113 | 698 | |
| 699 | if(!server || !*server) { | |
| 700 | gaim_notify_error(js->gc, _("Invalid Server"), _("Invalid Server"), NULL); | |
| 701 | return; | |
| 702 | } | |
| 703 | ||
|
9913
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
704 | if(js->roomlist) |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
705 | gaim_roomlist_unref(js->roomlist); |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
706 | |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
707 | js->roomlist = gaim_roomlist_new(gaim_connection_get_account(js->gc)); |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
708 | |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
709 | f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", "room", TRUE); |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
710 | fields = g_list_append(fields, f); |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
711 | |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
712 | f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", "server", TRUE); |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
713 | fields = g_list_append(fields, f); |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
714 | |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
715 | f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, _("Description"), "description", FALSE); |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
716 | fields = g_list_append(fields, f); |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
717 | |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
718 | gaim_roomlist_set_fields(js->roomlist, fields); |
|
2e773d9ba800
[gaim-migrate @ 10805]
Daniel Atallah <datallah@pidgin.im>
parents:
9770
diff
changeset
|
719 | |
| 8113 | 720 | gaim_roomlist_set_in_progress(js->roomlist, TRUE); |
| 721 | ||
| 722 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#items"); | |
| 723 | ||
| 724 | xmlnode_set_attrib(iq->node, "to", server); | |
| 725 | ||
| 726 | jabber_iq_set_callback(iq, roomlist_disco_result_cb, NULL); | |
| 727 | ||
| 728 | jabber_iq_send(iq); | |
| 729 | } | |
| 730 | ||
| 731 | GaimRoomlist *jabber_roomlist_get_list(GaimConnection *gc) | |
| 732 | { | |
| 733 | JabberStream *js = gc->proto_data; | |
| 734 | ||
| 735 | gaim_request_input(gc, _("Enter a Conference Server"), _("Enter a Conference Server"), | |
| 736 | _("Select a conference server to query"), | |
| 737 | js->chat_servers ? js->chat_servers->data : "conference.jabber.org", | |
| 8697 | 738 | FALSE, FALSE, NULL, |
| 739 | _("Find Rooms"), G_CALLBACK(roomlist_ok_cb), _("Cancel"), NULL, js); | |
| 8113 | 740 | |
| 741 | return js->roomlist; | |
| 742 | } | |
| 743 | ||
| 744 | void jabber_roomlist_cancel(GaimRoomlist *list) | |
| 745 | { | |
| 746 | GaimConnection *gc; | |
| 747 | JabberStream *js; | |
| 748 | ||
| 749 | gc = gaim_account_get_connection(list->account); | |
| 750 | js = gc->proto_data; | |
| 751 | ||
| 752 | gaim_roomlist_set_in_progress(list, FALSE); | |
| 753 | ||
| 754 | if (js->roomlist == list) { | |
| 755 | js->roomlist = NULL; | |
| 756 | gaim_roomlist_unref(list); | |
| 757 | } | |
| 758 | } | |
| 759 | ||
| 9152 | 760 | void jabber_chat_member_free(JabberChatMember *jcm) |
| 761 | { | |
| 762 | g_free(jcm->handle); | |
| 763 | g_free(jcm->jid); | |
| 764 | g_free(jcm); | |
| 765 | } | |
| 766 | ||
| 767 | void jabber_chat_track_handle(JabberChat *chat, const char *handle, | |
| 768 | const char *jid, const char *affiliation, const char *role) | |
| 769 | { | |
| 770 | JabberChatMember *jcm = g_new0(JabberChatMember, 1); | |
| 771 | ||
| 772 | jcm->handle = g_strdup(handle); | |
| 773 | jcm->jid = g_strdup(jid); | |
| 774 | ||
| 775 | g_hash_table_replace(chat->members, jcm->handle, jcm); | |
| 776 | ||
| 777 | /* XXX: keep track of role and affiliation */ | |
| 778 | } | |
| 779 | ||
| 780 | void jabber_chat_remove_handle(JabberChat *chat, const char *handle) | |
| 781 | { | |
| 782 | g_hash_table_remove(chat->members, handle); | |
| 783 | } | |
| 784 | ||
| 785 | gboolean jabber_chat_ban_user(JabberChat *chat, const char *who, const char *why) | |
| 786 | { | |
| 787 | JabberIq *iq; | |
| 788 | JabberChatMember *jcm = g_hash_table_lookup(chat->members, who); | |
| 789 | char *to; | |
| 790 | xmlnode *query, *item, *reason; | |
| 791 | ||
| 792 | if(!jcm || !jcm->jid) | |
| 793 | return FALSE; | |
| 794 | ||
| 795 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, | |
| 796 | "http://jabber.org/protocol/muc#admin"); | |
| 797 | ||
| 798 | to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 799 | xmlnode_set_attrib(iq->node, "to", to); | |
| 800 | g_free(to); | |
| 801 | ||
| 802 | query = xmlnode_get_child(iq->node, "query"); | |
| 803 | item = xmlnode_new_child(query, "item"); | |
| 804 | xmlnode_set_attrib(item, "jid", jcm->jid); | |
| 805 | xmlnode_set_attrib(item, "affiliation", "outcast"); | |
| 806 | if(why) { | |
| 807 | reason = xmlnode_new_child(item, "reason"); | |
| 808 | xmlnode_insert_data(reason, why, -1); | |
| 809 | } | |
| 810 | ||
| 811 | jabber_iq_send(iq); | |
| 812 | ||
| 813 | return TRUE; | |
| 814 | } | |
| 8113 | 815 | |
| 816 | ||
| 9152 | 817 | gboolean jabber_chat_kick_user(JabberChat *chat, const char *who, const char *why) |
| 818 | { | |
| 819 | JabberIq *iq; | |
| 820 | JabberChatMember *jcm = g_hash_table_lookup(chat->members, who); | |
| 821 | char *to; | |
| 822 | xmlnode *query, *item, *reason; | |
| 823 | ||
| 824 | if(!jcm || !jcm->jid) | |
| 825 | return FALSE; | |
| 826 | ||
| 827 | iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, | |
| 828 | "http://jabber.org/protocol/muc#admin"); | |
| 829 | ||
| 830 | to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 831 | xmlnode_set_attrib(iq->node, "to", to); | |
| 832 | g_free(to); | |
| 833 | ||
| 834 | query = xmlnode_get_child(iq->node, "query"); | |
| 835 | item = xmlnode_new_child(query, "item"); | |
| 836 | xmlnode_set_attrib(item, "jid", jcm->jid); | |
| 837 | xmlnode_set_attrib(item, "role", "none"); | |
| 838 | if(why) { | |
| 839 | reason = xmlnode_new_child(item, "reason"); | |
| 840 | xmlnode_insert_data(reason, why, -1); | |
| 841 | } | |
| 842 | ||
| 843 | jabber_iq_send(iq); | |
| 844 | ||
| 845 | return TRUE; | |
| 846 | } | |
| 847 | ||
| 848 | ||
| 849 |