annotate src/protocols/jabber/chat.c @ 11454:201617d49573

[gaim-migrate @ 13693] This commit includes a number of changes: 1. Aliases are now used consistently in chats. If the prpl uses unique screen names for chats (e.g. Jabber), then aliases are not used at all. 2. The chat list is now colorized to match the colors used in the chat itself. 3. Buddies are bolded in the chat user list. 4. Buddies are sorted above non-buddies in the chat user list. 5. The chat user list is ellipsized when possible (i.e. on GTK+ 2.6.0 or above). 6. I've accepted patch #1178248, by Matt Amato to add "buddy-added" and "buddy-removed" signals. These were used in my implementation of #3 and #4, to update the GUI when users are added or removed from the buddy list. 7. I've added a "blist-node-aliased" signal that is emitted when a buddy, contact, or chat is aliased. 8. Since it was hard to separate and I need it at some point, I'm letting it slip in... I've changed GaimConversation.log to be a GList named logs. This way, we can have multiple logs for a single conversation. This will be necessary to implement unnamed chat logging in some reasonable fasion (see my notes in the TODO file). committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Tue, 06 Sep 2005 03:04:07 +0000
parents 1e756e251dc3
children fc464a0abccc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
2 * gaim - Jabber Protocol Plugin
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * GNU General Public License for more details.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 #include "internal.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 #include "debug.h"
9713
db62420a53a2 [gaim-migrate @ 10574]
Mark Doliner <mark@kingant.net>
parents: 9554
diff changeset
23 #include "prpl.h" /* for proto_chat_entry */
7310
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
24 #include "notify.h"
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
25 #include "request.h"
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
26 #include "roomlist.h"
7971
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
27 #include "util.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
28
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
29 #include "chat.h"
7895
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
30 #include "iq.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
31 #include "message.h"
7073
82e980962926 [gaim-migrate @ 7638]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
32 #include "presence.h"
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
33 #include "xdata.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
34
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
35 GList *jabber_chat_info(GaimConnection *gc)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37 GList *m = NULL;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
38 struct proto_chat_entry *pce;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
40 pce = g_new0(struct proto_chat_entry, 1);
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7400
diff changeset
41 pce->label = _("_Room:");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
42 pce->identifier = "room";
10959
b6cafdeda2a8 [gaim-migrate @ 12761]
Nathan Walp <nwalp@pidgin.im>
parents: 10941
diff changeset
43 pce->required = TRUE;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
44 m = g_list_append(m, pce);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
45
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
46 pce = g_new0(struct proto_chat_entry, 1);
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7400
diff changeset
47 pce->label = _("_Server:");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
48 pce->identifier = "server";
10959
b6cafdeda2a8 [gaim-migrate @ 12761]
Nathan Walp <nwalp@pidgin.im>
parents: 10941
diff changeset
49 pce->required = TRUE;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
50 m = g_list_append(m, pce);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
51
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
52 pce = g_new0(struct proto_chat_entry, 1);
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7400
diff changeset
53 pce->label = _("_Handle:");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
54 pce->identifier = "handle";
10959
b6cafdeda2a8 [gaim-migrate @ 12761]
Nathan Walp <nwalp@pidgin.im>
parents: 10941
diff changeset
55 pce->required = TRUE;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
56 m = g_list_append(m, pce);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
57
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
58 pce = g_new0(struct proto_chat_entry, 1);
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7400
diff changeset
59 pce->label = _("_Password:");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
60 pce->identifier = "password";
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
61 pce->secret = TRUE;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
62 m = g_list_append(m, pce);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
63
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
64 return m;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
65 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
66
9754
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
67 GHashTable *jabber_chat_info_defaults(GaimConnection *gc, const char *chat_name)
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
68 {
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
69 GHashTable *defaults;
9770
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
70 JabberStream *js = gc->proto_data;
9754
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
71
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
72 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
73
9770
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
74 g_hash_table_insert(defaults, "handle", g_strdup(js->user->node));
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
75
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
76 if (js->chat_servers)
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
77 g_hash_table_insert(defaults, "server", g_strdup(js->chat_servers->data));
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
78 else
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
79 g_hash_table_insert(defaults, "server", g_strdup("conference.jabber.org"));
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
80
9754
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
81 if (chat_name != NULL) {
9760
cee4e4cae56a [gaim-migrate @ 10628]
Nathan Walp <nwalp@pidgin.im>
parents: 9754
diff changeset
82 JabberID *jid = jabber_id_new(chat_name);
cee4e4cae56a [gaim-migrate @ 10628]
Nathan Walp <nwalp@pidgin.im>
parents: 9754
diff changeset
83 if(jid) {
cee4e4cae56a [gaim-migrate @ 10628]
Nathan Walp <nwalp@pidgin.im>
parents: 9754
diff changeset
84 g_hash_table_insert(defaults, "room", g_strdup(jid->node));
cee4e4cae56a [gaim-migrate @ 10628]
Nathan Walp <nwalp@pidgin.im>
parents: 9754
diff changeset
85 if(jid->domain)
9770
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
86 g_hash_table_replace(defaults, "server", g_strdup(jid->domain));
9760
cee4e4cae56a [gaim-migrate @ 10628]
Nathan Walp <nwalp@pidgin.im>
parents: 9754
diff changeset
87 jabber_id_free(jid);
cee4e4cae56a [gaim-migrate @ 10628]
Nathan Walp <nwalp@pidgin.im>
parents: 9754
diff changeset
88 }
9754
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
89 }
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
90
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
91 return defaults;
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
92 }
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
93
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
94 JabberChat *jabber_chat_find(JabberStream *js, const char *room,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
95 const char *server)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
96 {
10607
bf4c9ce533ab [gaim-migrate @ 12043]
Nathan Walp <nwalp@pidgin.im>
parents: 10504
diff changeset
97 JabberChat *chat = NULL;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
98 char *room_jid;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
99
10607
bf4c9ce533ab [gaim-migrate @ 12043]
Nathan Walp <nwalp@pidgin.im>
parents: 10504
diff changeset
100 if(NULL != js->chats)
bf4c9ce533ab [gaim-migrate @ 12043]
Nathan Walp <nwalp@pidgin.im>
parents: 10504
diff changeset
101 {
bf4c9ce533ab [gaim-migrate @ 12043]
Nathan Walp <nwalp@pidgin.im>
parents: 10504
diff changeset
102 room_jid = g_strdup_printf("%s@%s", room, server);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
103
10607
bf4c9ce533ab [gaim-migrate @ 12043]
Nathan Walp <nwalp@pidgin.im>
parents: 10504
diff changeset
104 chat = g_hash_table_lookup(js->chats, jabber_normalize(NULL, room_jid));
bf4c9ce533ab [gaim-migrate @ 12043]
Nathan Walp <nwalp@pidgin.im>
parents: 10504
diff changeset
105 g_free(room_jid);
bf4c9ce533ab [gaim-migrate @ 12043]
Nathan Walp <nwalp@pidgin.im>
parents: 10504
diff changeset
106 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
107
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
108 return chat;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
109 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
110
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
111 struct _find_by_id_data {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
112 int id;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
113 JabberChat *chat;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
114 };
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
115
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
116 void find_by_id_foreach_cb(gpointer key, gpointer value, gpointer user_data)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
117 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
118 JabberChat *chat = value;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
119 struct _find_by_id_data *fbid = user_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
120
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
121 if(chat->id == fbid->id)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
122 fbid->chat = chat;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
123 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
124
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
125 JabberChat *jabber_chat_find_by_id(JabberStream *js, int id)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
126 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
127 JabberChat *chat;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
128 struct _find_by_id_data *fbid = g_new0(struct _find_by_id_data, 1);
7073
82e980962926 [gaim-migrate @ 7638]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
129 fbid->id = id;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
130 g_hash_table_foreach(js->chats, find_by_id_foreach_cb, fbid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
131 chat = fbid->chat;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
132 g_free(fbid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
133 return chat;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
134 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
135
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
136 JabberChat *jabber_chat_find_by_conv(GaimConversation *conv)
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
137 {
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
138 GaimAccount *account = gaim_conversation_get_account(conv);
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
139 GaimConnection *gc = gaim_account_get_connection(account);
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
140 JabberStream *js = gc->proto_data;
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
141 int id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv));
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
142
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
143 return jabber_chat_find_by_id(js, id);
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
144 }
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
145
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
146 void jabber_chat_invite(GaimConnection *gc, int id, const char *msg,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
147 const char *name)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
148 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
149 JabberStream *js = gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
150 JabberChat *chat;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
151 xmlnode *message, *body, *x, *invite;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
152 char *room_jid;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
153
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
154 chat = jabber_chat_find_by_id(js, id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
155 if(!chat)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
156 return;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
157
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
158 message = xmlnode_new("message");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
159
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
160 room_jid = g_strdup_printf("%s@%s", chat->room, chat->server);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
161
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
162 if(chat->muc) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
163 xmlnode_set_attrib(message, "to", room_jid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
164 x = xmlnode_new_child(message, "x");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
165 xmlnode_set_attrib(x, "xmlns", "http://jabber.org/protocol/muc#user");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
166 invite = xmlnode_new_child(x, "invite");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
167 xmlnode_set_attrib(invite, "to", name);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
168 body = xmlnode_new_child(invite, "reason");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
169 xmlnode_insert_data(body, msg, -1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
170 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
171 xmlnode_set_attrib(message, "to", name);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
172 body = xmlnode_new_child(message, "body");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
173 xmlnode_insert_data(body, msg, -1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
174 x = xmlnode_new_child(message, "x");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
175 xmlnode_set_attrib(x, "jid", room_jid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
176 xmlnode_set_attrib(x, "xmlns", "jabber:x:conference");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
177 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
178
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
179 jabber_send(js, message);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
180 xmlnode_free(message);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
181 g_free(room_jid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
182 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
183
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
184 void jabber_chat_member_free(JabberChatMember *jcm);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
185
9917
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
186 char *jabber_get_chat_name(GHashTable *data) {
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
187 char *room, *server, *chat_name = NULL;
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
188
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
189 room = g_hash_table_lookup(data, "room");
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
190 server = g_hash_table_lookup(data, "server");
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
191
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
192 if (room && server) {
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
193 chat_name = g_strdup_printf("%s@%s", room, server);
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
194 }
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
195 return chat_name;
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
196 }
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
197
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
198 void jabber_chat_join(GaimConnection *gc, GHashTable *data)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
199 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
200 JabberChat *chat;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
201 char *room, *server, *handle, *passwd;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
202 xmlnode *presence, *x;
7262
85fcaff1505d [gaim-migrate @ 7839]
Nathan Walp <nwalp@pidgin.im>
parents: 7118
diff changeset
203 char *tmp, *room_jid, *full_jid;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
204 JabberStream *js = gc->proto_data;
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
205 GaimPresence *gpresence;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
206 GaimStatus *status;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
207 JabberBuddyState state;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
208 const char *msg;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
209 int priority;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
210
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
211 room = g_hash_table_lookup(data, "room");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
212 server = g_hash_table_lookup(data, "server");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
213 handle = g_hash_table_lookup(data, "handle");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
214 passwd = g_hash_table_lookup(data, "password");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
215
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
216 if(!room || !server)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
217 return;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
218
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
219 if(!handle)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
220 handle = js->user->node;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
221
7310
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
222 if(!jabber_nodeprep_validate(room)) {
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
223 char *buf = g_strdup_printf(_("%s is not a valid room name"), room);
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
224 gaim_notify_error(gc, _("Invalid Room Name"), _("Invalid Room Name"),
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
225 buf);
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
226 g_free(buf);
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
227 return;
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
228 } else if(!jabber_nameprep_validate(server)) {
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
229 char *buf = g_strdup_printf(_("%s is not a valid server name"), server);
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
230 gaim_notify_error(gc, _("Invalid Server Name"),
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
231 _("Invalid Server Name"), buf);
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
232 g_free(buf);
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
233 return;
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
234 } else if(!jabber_resourceprep_validate(handle)) {
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
235 char *buf = g_strdup_printf(_("%s is not a valid room handle"), handle);
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
236 gaim_notify_error(gc, _("Invalid Room Handle"),
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
237 _("Invalid Room Handle"), buf);
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
238 }
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
239
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
240 if(jabber_chat_find(js, room, server))
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
241 return;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
242
7262
85fcaff1505d [gaim-migrate @ 7839]
Nathan Walp <nwalp@pidgin.im>
parents: 7118
diff changeset
243 tmp = g_strdup_printf("%s@%s", room, server);
7322
ab828b8c3f22 [gaim-migrate @ 7908]
Nathan Walp <nwalp@pidgin.im>
parents: 7310
diff changeset
244 room_jid = g_strdup(jabber_normalize(NULL, tmp));
7262
85fcaff1505d [gaim-migrate @ 7839]
Nathan Walp <nwalp@pidgin.im>
parents: 7118
diff changeset
245 g_free(tmp);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
246
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
247 chat = g_new0(JabberChat, 1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
248 chat->js = gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
249
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
250 chat->room = g_strdup(room);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
251 chat->server = g_strdup(server);
8400
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
252 chat->handle = g_strdup(handle);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
253
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
254 chat->members = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
255 (GDestroyNotify)jabber_chat_member_free);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
256
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
257 g_hash_table_insert(js->chats, room_jid, chat);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
258
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
259 gpresence = gaim_account_get_presence(gc->account);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
260 status = gaim_presence_get_active_status(gpresence);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
261
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
262 gaim_status_to_jabber(status, &state, &msg, &priority);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
263
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
264 presence = jabber_presence_create(state, msg, priority);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
265 full_jid = g_strdup_printf("%s/%s", room_jid, handle);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
266 xmlnode_set_attrib(presence, "to", full_jid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
267 g_free(full_jid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
268
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
269 x = xmlnode_new_child(presence, "x");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
270 xmlnode_set_attrib(x, "xmlns", "http://jabber.org/protocol/muc");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
271
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
272 if(passwd && *passwd) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
273 xmlnode *password = xmlnode_new_child(x, "password");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
274 xmlnode_insert_data(password, passwd, -1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
275 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
276
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
277 jabber_send(js, presence);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
278 xmlnode_free(presence);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
279 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
280
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
281 void jabber_chat_leave(GaimConnection *gc, int id)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
282 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
283 JabberStream *js = gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
284 JabberChat *chat = jabber_chat_find_by_id(js, id);
7974
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
285
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
286
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
287 if(!chat)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
288 return;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
289
7974
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
290 jabber_chat_part(chat, NULL);
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
291
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
292 chat->conv = NULL;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
293 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
294
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
295 void jabber_chat_destroy(JabberChat *chat)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
296 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
297 JabberStream *js = chat->js;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
298 char *room_jid = g_strdup_printf("%s@%s", chat->room, chat->server);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
299
7322
ab828b8c3f22 [gaim-migrate @ 7908]
Nathan Walp <nwalp@pidgin.im>
parents: 7310
diff changeset
300 g_hash_table_remove(js->chats, jabber_normalize(NULL, room_jid));
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
301 g_free(room_jid);
8396
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
302 }
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
303
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
304 void jabber_chat_free(JabberChat *chat)
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
305 {
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
306 if(chat->config_dialog_handle)
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
307 gaim_request_close(chat->config_dialog_type, chat->config_dialog_handle);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
308
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
309 g_free(chat->room);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
310 g_free(chat->server);
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10474
diff changeset
311 g_free(chat->handle);
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10474
diff changeset
312 g_hash_table_destroy(chat->members);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
313 g_free(chat);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
314 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
315
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
316 gboolean jabber_chat_find_buddy(GaimConversation *conv, const char *name)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
317 {
9554
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9152
diff changeset
318 return gaim_conv_chat_find_user(GAIM_CONV_CHAT(conv), name);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
319 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
320
7398
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
321 char *jabber_chat_buddy_real_name(GaimConnection *gc, int id, const char *who)
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
322 {
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
323 JabberStream *js = gc->proto_data;
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
324 JabberChat *chat;
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
325
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
326 chat = jabber_chat_find_by_id(js, id);
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
327
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
328 if(!chat)
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
329 return NULL;
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
330
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
331 return g_strdup_printf("%s@%s/%s", chat->room, chat->server, who);
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
332 }
7895
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
333
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
334 static void jabber_chat_room_configure_x_data_cb(JabberStream *js, xmlnode *result, gpointer data)
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
335 {
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
336 JabberChat *chat = data;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
337 xmlnode *query;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
338 JabberIq *iq;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
339 char *to = g_strdup_printf("%s@%s", chat->room, chat->server);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
340
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
341 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "http://jabber.org/protocol/muc#owner");
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
342 xmlnode_set_attrib(iq->node, "to", to);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
343 g_free(to);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
344
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
345 query = xmlnode_get_child(iq->node, "query");
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
346
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
347 xmlnode_insert_child(query, result);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
348
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
349 jabber_iq_send(iq);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
350 }
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
351
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
352 static void jabber_chat_room_configure_cb(JabberStream *js, xmlnode *packet, gpointer data)
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
353 {
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
354 xmlnode *query, *x;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
355 const char *type = xmlnode_get_attrib(packet, "type");
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
356 const char *from = xmlnode_get_attrib(packet, "from");
7926
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
357 char *msg;
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
358 JabberChat *chat;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
359 JabberID *jid;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
360
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
361 if(!type || !from)
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
362 return;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
363
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
364
7926
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
365
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
366 if(!strcmp(type, "result")) {
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
367 jid = jabber_id_new(from);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
368
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
369 if(!jid)
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
370 return;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
371
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
372 chat = jabber_chat_find(js, jid->node, jid->domain);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
373 jabber_id_free(jid);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
374
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
375 if(!chat)
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
376 return;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
377
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
378 if(!(query = xmlnode_get_child(packet, "query")))
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
379 return;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
380
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8120
diff changeset
381 for(x = xmlnode_get_child(query, "x"); x; x = xmlnode_get_next_twin(x)) {
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
382 const char *xmlns;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
383 if(!(xmlns = xmlnode_get_attrib(x, "xmlns")))
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
384 continue;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
385
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
386 if(!strcmp(xmlns, "jabber:x:data")) {
8396
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
387 chat->config_dialog_type = GAIM_REQUEST_FIELDS;
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
388 chat->config_dialog_handle = jabber_x_data_request(js, x, jabber_chat_room_configure_x_data_cb, chat);
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
389 return;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
390 }
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
391 }
7926
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
392 } else if(!strcmp(type, "error")) {
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
393 char *msg = jabber_parse_error(js, packet);
7926
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
394
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
395 gaim_notify_error(js->gc, _("Configuration error"), _("Configuration error"), msg);
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
396
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
397 if(msg)
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
398 g_free(msg);
7926
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
399 return;
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
400 }
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
401
7926
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
402 msg = g_strdup_printf("Unable to configure room %s", from);
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
403
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
404 gaim_notify_info(js->gc, _("Unable to configure"), _("Unable to configure"), msg);
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
405 g_free(msg);
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
406
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
407 }
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
408
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
409 void jabber_chat_request_room_configure(JabberChat *chat) {
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
410 JabberIq *iq;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
411 xmlnode *query;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
412 char *room_jid;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
413
7895
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
414 if(!chat)
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
415 return;
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
416
8396
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
417 chat->config_dialog_handle = NULL;
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
418
7955
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
419 if(!chat->muc) {
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
420 gaim_notify_error(chat->js->gc, _("Room Configuration Error"), _("Room Configuration Error"),
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
421 _("This room is not capable of being configured"));
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
422 return;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
423 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
424
10474
ae1fa1218e5c [gaim-migrate @ 11761]
Nathan Walp <nwalp@pidgin.im>
parents: 10094
diff changeset
425 iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET,
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
426 "http://jabber.org/protocol/muc#owner");
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
427 query = xmlnode_get_child(iq->node, "query");
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
428 room_jid = g_strdup_printf("%s@%s", chat->room, chat->server);
7895
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
429
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
430 xmlnode_set_attrib(iq->node, "to", room_jid);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
431
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
432 jabber_iq_set_callback(iq, jabber_chat_room_configure_cb, NULL);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
433
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
434 jabber_iq_send(iq);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
435
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
436 g_free(room_jid);
7895
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
437 }
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
438
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
439 void jabber_chat_create_instant_room(JabberChat *chat) {
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
440 JabberIq *iq;
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
441 xmlnode *query, *x;
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
442 char *room_jid;
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
443
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
444 if(!chat)
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
445 return;
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
446
8396
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
447 chat->config_dialog_handle = NULL;
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
448
7895
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
449 iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET,
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
450 "http://jabber.org/protocol/muc#owner");
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
451 query = xmlnode_get_child(iq->node, "query");
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
452 x = xmlnode_new_child(query, "x");
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
453 room_jid = g_strdup_printf("%s@%s", chat->room, chat->server);
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
454
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
455 xmlnode_set_attrib(iq->node, "to", room_jid);
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
456 xmlnode_set_attrib(x, "xmlns", "jabber:x:data");
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
457 xmlnode_set_attrib(x, "type", "submit");
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
458
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
459 jabber_iq_send(iq);
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
460
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
461 g_free(room_jid);
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
462 }
7955
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
463
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
464 static void jabber_chat_register_x_data_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
465 {
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
466 const char *type = xmlnode_get_attrib(packet, "type");
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
467
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
468 if(type && !strcmp(type, "error")) {
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
469 char *msg = jabber_parse_error(js, packet);
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
470
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
471 gaim_notify_error(js->gc, _("Registration error"), _("Registration error"), msg);
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
472
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
473 if(msg)
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
474 g_free(msg);
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
475 return;
7955
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
476 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
477 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
478
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
479 static void jabber_chat_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data)
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
480 {
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
481 JabberChat *chat = data;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
482 xmlnode *query;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
483 JabberIq *iq;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
484 char *to = g_strdup_printf("%s@%s", chat->room, chat->server);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
485
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
486 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register");
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
487 xmlnode_set_attrib(iq->node, "to", to);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
488 g_free(to);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
489
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
490 query = xmlnode_get_child(iq->node, "query");
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
491
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
492 xmlnode_insert_child(query, result);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
493
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
494 jabber_iq_set_callback(iq, jabber_chat_register_x_data_result_cb, NULL);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
495
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
496 jabber_iq_send(iq);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
497 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
498
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
499 static void jabber_chat_register_cb(JabberStream *js, xmlnode *packet, gpointer data)
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
500 {
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
501 xmlnode *query, *x;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
502 const char *type = xmlnode_get_attrib(packet, "type");
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
503 const char *from = xmlnode_get_attrib(packet, "from");
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
504 char *msg;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
505 JabberChat *chat;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
506 JabberID *jid;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
507
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
508 if(!type || !from)
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
509 return;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
510
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
511 if(!strcmp(type, "result")) {
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
512 jid = jabber_id_new(from);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
513
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
514 if(!jid)
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
515 return;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
516
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
517 chat = jabber_chat_find(js, jid->node, jid->domain);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
518 jabber_id_free(jid);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
519
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
520 if(!chat)
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
521 return;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
522
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
523 if(!(query = xmlnode_get_child(packet, "query")))
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
524 return;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
525
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8120
diff changeset
526 for(x = xmlnode_get_child(query, "x"); x; x = xmlnode_get_next_twin(x)) {
7955
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
527 const char *xmlns;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
528
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
529 if(!(xmlns = xmlnode_get_attrib(x, "xmlns")))
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
530 continue;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
531
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
532 if(!strcmp(xmlns, "jabber:x:data")) {
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
533 jabber_x_data_request(js, x, jabber_chat_register_x_data_cb, chat);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
534 return;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
535 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
536 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
537 } else if(!strcmp(type, "error")) {
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
538 char *msg = jabber_parse_error(js, packet);
7955
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
539
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
540 gaim_notify_error(js->gc, _("Registration error"), _("Registration error"), msg);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
541
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
542 if(msg)
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
543 g_free(msg);
7955
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
544 return;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
545 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
546
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
547 msg = g_strdup_printf("Unable to configure room %s", from);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
548
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
549 gaim_notify_info(js->gc, _("Unable to configure"), _("Unable to configure"), msg);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
550 g_free(msg);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
551
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
552 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
553
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
554 void jabber_chat_register(JabberChat *chat)
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
555 {
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
556 JabberIq *iq;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
557 char *room_jid;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
558
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
559 if(!chat)
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
560 return;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
561
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
562 room_jid = g_strdup_printf("%s@%s", chat->room, chat->server);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
563
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
564 iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, "jabber:iq:register");
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
565 xmlnode_set_attrib(iq->node, "to", room_jid);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
566 g_free(room_jid);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
567
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
568 jabber_iq_set_callback(iq, jabber_chat_register_cb, NULL);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
569
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
570 jabber_iq_send(iq);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
571 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
572
7971
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
573 /* merge this with the function below when we get everyone on the same page wrt /commands */
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
574 void jabber_chat_change_topic(JabberChat *chat, const char *topic)
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
575 {
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
576 if(topic && *topic) {
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
577 JabberMessage *jm;
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
578 jm = g_new0(JabberMessage, 1);
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
579 jm->js = chat->js;
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
580 jm->type = JABBER_MESSAGE_GROUPCHAT;
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
581 jm->subject = gaim_markup_strip_html(topic);
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
582 jm->to = g_strdup_printf("%s@%s", chat->room, chat->server);
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
583 jabber_message_send(jm);
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
584 jabber_message_free(jm);
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
585 } else {
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
586 const char *cur = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(chat->conv));
9762
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9760
diff changeset
587 char *buf, *tmp, *tmp2;
7955
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
588
9762
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9760
diff changeset
589 if(cur) {
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10607
diff changeset
590 tmp = g_markup_escape_text(cur, -1);
9762
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9760
diff changeset
591 tmp2 = gaim_markup_linkify(tmp);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9760
diff changeset
592 buf = g_strdup_printf(_("current topic is: %s"), tmp2);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9760
diff changeset
593 g_free(tmp);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9760
diff changeset
594 g_free(tmp2);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9760
diff changeset
595 } else
7971
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
596 buf = g_strdup(_("No topic is set"));
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
597 gaim_conv_chat_write(GAIM_CONV_CHAT(chat->conv), "", buf,
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
598 GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG, time(NULL));
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
599 g_free(buf);
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
600 }
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
601
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
602 }
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
603
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
604 void jabber_chat_set_topic(GaimConnection *gc, int id, const char *topic)
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
605 {
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
606 JabberStream *js = gc->proto_data;
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
607 JabberChat *chat = jabber_chat_find_by_id(js, id);
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
608
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
609 if(!chat)
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
610 return;
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
611
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
612 jabber_chat_change_topic(chat, topic);
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
613 }
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
614
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
615
7972
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
616 void jabber_chat_change_nick(JabberChat *chat, const char *nick)
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
617 {
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
618 xmlnode *presence;
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
619 char *full_jid;
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
620 GaimPresence *gpresence;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
621 GaimStatus *status;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
622 JabberBuddyState state;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
623 const char *msg;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
624 int priority;
7972
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
625
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
626 if(!chat->muc) {
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
627 gaim_conv_chat_write(GAIM_CONV_CHAT(chat->conv), "",
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
628 _("Nick changing not supported in non-MUC chatrooms"),
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
629 GAIM_MESSAGE_SYSTEM, time(NULL));
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
630 return;
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
631 }
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
632
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
633 gpresence = gaim_account_get_presence(chat->js->gc->account);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
634 status = gaim_presence_get_active_status(gpresence);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
635
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
636 gaim_status_to_jabber(status, &state, &msg, &priority);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
637
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
638 presence = jabber_presence_create(state, msg, priority);
7972
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
639 full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, nick);
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
640 xmlnode_set_attrib(presence, "to", full_jid);
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
641 g_free(full_jid);
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
642
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
643 jabber_send(chat->js, presence);
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
644 xmlnode_free(presence);
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
645 }
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
646
7974
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
647 void jabber_chat_part(JabberChat *chat, const char *msg)
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
648 {
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
649 char *room_jid;
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
650 xmlnode *presence;
7972
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
651
8537
dc818b62379e [gaim-migrate @ 9276]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
652 room_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server,
dc818b62379e [gaim-migrate @ 9276]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
653 chat->handle);
7974
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
654 presence = xmlnode_new("presence");
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
655 xmlnode_set_attrib(presence, "to", room_jid);
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
656 xmlnode_set_attrib(presence, "type", "unavailable");
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
657 if(msg) {
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
658 xmlnode *status = xmlnode_new_child(presence, "status");
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
659 xmlnode_insert_data(status, msg, -1);
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
660 }
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
661 jabber_send(chat->js, presence);
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
662 xmlnode_free(presence);
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
663 g_free(room_jid);
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
664 }
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
665
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
666 static void roomlist_disco_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
667 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
668 xmlnode *query;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
669 xmlnode *item;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
670 const char *type;
7974
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
671
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
672 if(!js->roomlist)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
673 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
674
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
675 if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result")) {
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
676 char *err = jabber_parse_error(js,packet);
10091
4e376556566e [gaim-migrate @ 11107]
Mark Doliner <mark@kingant.net>
parents: 10045
diff changeset
677 gaim_notify_error(js->gc, _("Error"),
10094
2a7780fadbb9 [gaim-migrate @ 11112]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
678 _("Error retrieving room list"), err);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
679 gaim_roomlist_set_in_progress(js->roomlist, FALSE);
8120
81a63a9bff88 [gaim-migrate @ 8824]
Nathan Walp <nwalp@pidgin.im>
parents: 8113
diff changeset
680 gaim_roomlist_unref(js->roomlist);
81a63a9bff88 [gaim-migrate @ 8824]
Nathan Walp <nwalp@pidgin.im>
parents: 8113
diff changeset
681 js->roomlist = NULL;
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
682 g_free(err);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
683 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
684 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
685
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
686 if(!(query = xmlnode_get_child(packet, "query"))) {
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
687 char *err = jabber_parse_error(js, packet);
10091
4e376556566e [gaim-migrate @ 11107]
Mark Doliner <mark@kingant.net>
parents: 10045
diff changeset
688 gaim_notify_error(js->gc, _("Error"),
10094
2a7780fadbb9 [gaim-migrate @ 11112]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
689 _("Error retrieving room list"), err);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
690 gaim_roomlist_set_in_progress(js->roomlist, FALSE);
8120
81a63a9bff88 [gaim-migrate @ 8824]
Nathan Walp <nwalp@pidgin.im>
parents: 8113
diff changeset
691 gaim_roomlist_unref(js->roomlist);
81a63a9bff88 [gaim-migrate @ 8824]
Nathan Walp <nwalp@pidgin.im>
parents: 8113
diff changeset
692 js->roomlist = NULL;
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
693 g_free(err);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
694 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
695 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
696
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8120
diff changeset
697 for(item = xmlnode_get_child(query, "item"); item;
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8120
diff changeset
698 item = xmlnode_get_next_twin(item)) {
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
699 const char *name;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
700 GaimRoomlistRoom *room;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
701 JabberID *jid;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
702
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
703 if(!(jid = jabber_id_new(xmlnode_get_attrib(item, "jid"))))
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
704 continue;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
705 name = xmlnode_get_attrib(item, "name");
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
706
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
707
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
708 room = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_ROOM, jid->node, NULL);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
709 gaim_roomlist_room_add_field(js->roomlist, room, jid->node);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
710 gaim_roomlist_room_add_field(js->roomlist, room, jid->domain);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
711 gaim_roomlist_room_add_field(js->roomlist, room, name ? name : "");
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
712 gaim_roomlist_room_add(js->roomlist, room);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
713
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
714 jabber_id_free(jid);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
715 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
716 gaim_roomlist_set_in_progress(js->roomlist, FALSE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
717 gaim_roomlist_unref(js->roomlist);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
718 js->roomlist = NULL;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
719 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
720
10045
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
721 static void roomlist_cancel_cb(JabberStream *js, const char *server) {
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
722 if(js->roomlist) {
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
723 gaim_roomlist_set_in_progress(js->roomlist, FALSE);
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
724 gaim_roomlist_unref(js->roomlist);
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
725 js->roomlist = NULL;
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
726 }
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
727 }
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
728
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
729 static void roomlist_ok_cb(JabberStream *js, const char *server)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
730 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
731 JabberIq *iq;
10045
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
732
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
733 if(!js->roomlist)
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
734 return;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
735
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
736 if(!server || !*server) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
737 gaim_notify_error(js->gc, _("Invalid Server"), _("Invalid Server"), NULL);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
738 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
739 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
740
10045
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
741 gaim_roomlist_set_in_progress(js->roomlist, TRUE);
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
742
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
743 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#items");
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
744
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
745 xmlnode_set_attrib(iq->node, "to", server);
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
746
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
747 jabber_iq_set_callback(iq, roomlist_disco_result_cb, NULL);
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
748
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
749 jabber_iq_send(iq);
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
750 }
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
751
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
752 GaimRoomlist *jabber_roomlist_get_list(GaimConnection *gc)
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
753 {
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
754 JabberStream *js = gc->proto_data;
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
755 GList *fields = NULL;
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
756 GaimRoomlistField *f;
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
757
9913
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
758 if(js->roomlist)
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
759 gaim_roomlist_unref(js->roomlist);
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
760
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
761 js->roomlist = gaim_roomlist_new(gaim_connection_get_account(js->gc));
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
762
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
763 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", "room", TRUE);
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
764 fields = g_list_append(fields, f);
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
765
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
766 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", "server", TRUE);
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
767 fields = g_list_append(fields, f);
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
768
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
769 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, _("Description"), "description", FALSE);
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
770 fields = g_list_append(fields, f);
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
771
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
772 gaim_roomlist_set_fields(js->roomlist, fields);
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
773
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
774
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
775 gaim_request_input(gc, _("Enter a Conference Server"), _("Enter a Conference Server"),
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
776 _("Select a conference server to query"),
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
777 js->chat_servers ? js->chat_servers->data : "conference.jabber.org",
8697
725413cc9fb9 [gaim-migrate @ 9450]
Mark Doliner <mark@kingant.net>
parents: 8537
diff changeset
778 FALSE, FALSE, NULL,
10045
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
779 _("Find Rooms"), GAIM_CALLBACK(roomlist_ok_cb),
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
780 _("Cancel"), GAIM_CALLBACK(roomlist_cancel_cb), js);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
781
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
782 return js->roomlist;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
783 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
784
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
785 void jabber_roomlist_cancel(GaimRoomlist *list)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
786 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
787 GaimConnection *gc;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
788 JabberStream *js;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
789
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
790 gc = gaim_account_get_connection(list->account);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
791 js = gc->proto_data;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
792
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
793 gaim_roomlist_set_in_progress(list, FALSE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
794
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
795 if (js->roomlist == list) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
796 js->roomlist = NULL;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
797 gaim_roomlist_unref(list);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
798 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
799 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
800
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
801 void jabber_chat_member_free(JabberChatMember *jcm)
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
802 {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
803 g_free(jcm->handle);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
804 g_free(jcm->jid);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
805 g_free(jcm);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
806 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
807
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
808 void jabber_chat_track_handle(JabberChat *chat, const char *handle,
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
809 const char *jid, const char *affiliation, const char *role)
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
810 {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
811 JabberChatMember *jcm = g_new0(JabberChatMember, 1);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
812
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
813 jcm->handle = g_strdup(handle);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
814 jcm->jid = g_strdup(jid);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
815
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
816 g_hash_table_replace(chat->members, jcm->handle, jcm);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
817
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
818 /* XXX: keep track of role and affiliation */
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
819 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
820
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
821 void jabber_chat_remove_handle(JabberChat *chat, const char *handle)
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
822 {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
823 g_hash_table_remove(chat->members, handle);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
824 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
825
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
826 gboolean jabber_chat_ban_user(JabberChat *chat, const char *who, const char *why)
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
827 {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
828 JabberIq *iq;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
829 JabberChatMember *jcm = g_hash_table_lookup(chat->members, who);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
830 char *to;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
831 xmlnode *query, *item, *reason;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
832
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
833 if(!jcm || !jcm->jid)
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
834 return FALSE;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
835
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
836 iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET,
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
837 "http://jabber.org/protocol/muc#admin");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
838
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
839 to = g_strdup_printf("%s@%s", chat->room, chat->server);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
840 xmlnode_set_attrib(iq->node, "to", to);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
841 g_free(to);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
842
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
843 query = xmlnode_get_child(iq->node, "query");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
844 item = xmlnode_new_child(query, "item");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
845 xmlnode_set_attrib(item, "jid", jcm->jid);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
846 xmlnode_set_attrib(item, "affiliation", "outcast");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
847 if(why) {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
848 reason = xmlnode_new_child(item, "reason");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
849 xmlnode_insert_data(reason, why, -1);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
850 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
851
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
852 jabber_iq_send(iq);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
853
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
854 return TRUE;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
855 }
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
856
11393
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
857 gboolean jabber_chat_affiliate_user(JabberChat *chat, const char *who, const char *affiliation)
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
858 {
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
859 JabberIq *iq;
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
860 JabberChatMember *jcm = g_hash_table_lookup(chat->members, who);
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
861 char *to;
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
862 xmlnode *query, *item;
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
863
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
864 if (!jcm || !jcm->jid)
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
865 return FALSE;
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
866
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
867 iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET,
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
868 "http://jabber.org/protocol/muc#admin");
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
869
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
870 to = g_strdup_printf("%s@%s", chat->room, chat->server);
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
871 xmlnode_set_attrib(iq->node, "to", to);
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
872 g_free(to);
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
873
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
874 query = xmlnode_get_child(iq->node, "query");
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
875 item = xmlnode_new_child(query, "item");
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
876 xmlnode_set_attrib(item, "jid", jcm->jid);
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
877 xmlnode_set_attrib(item, "affiliation", affiliation);
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
878
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
879 jabber_iq_send(iq);
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
880
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
881 return TRUE;
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11392
diff changeset
882 }
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
883
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
884 gboolean jabber_chat_kick_user(JabberChat *chat, const char *who, const char *why)
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
885 {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
886 JabberIq *iq;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
887 JabberChatMember *jcm = g_hash_table_lookup(chat->members, who);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
888 char *to;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
889 xmlnode *query, *item, *reason;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
890
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
891 if(!jcm || !jcm->jid)
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
892 return FALSE;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
893
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
894 iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET,
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
895 "http://jabber.org/protocol/muc#admin");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
896
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
897 to = g_strdup_printf("%s@%s", chat->room, chat->server);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
898 xmlnode_set_attrib(iq->node, "to", to);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
899 g_free(to);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
900
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
901 query = xmlnode_get_child(iq->node, "query");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
902 item = xmlnode_new_child(query, "item");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
903 xmlnode_set_attrib(item, "jid", jcm->jid);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
904 xmlnode_set_attrib(item, "role", "none");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
905 if(why) {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
906 reason = xmlnode_new_child(item, "reason");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
907 xmlnode_insert_data(reason, why, -1);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
908 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
909
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
910 jabber_iq_send(iq);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
911
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
912 return TRUE;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
913 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
914
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
915 static void jabber_chat_disco_traffic_cb(JabberStream *js, xmlnode *packet, gpointer data)
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
916 {
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
917 JabberChat *chat;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
918 xmlnode *query, *x, *error;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
919 int id = GPOINTER_TO_INT(data);
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
920
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
921 if(!(chat = jabber_chat_find_by_id(js, id)))
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
922 return;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
923
11392
e8890f996cc1 [gaim-migrate @ 13621]
Nathan Walp <nwalp@pidgin.im>
parents: 10959
diff changeset
924 /* defaults, in case the conference server doesn't
e8890f996cc1 [gaim-migrate @ 13621]
Nathan Walp <nwalp@pidgin.im>
parents: 10959
diff changeset
925 * support this request */
e8890f996cc1 [gaim-migrate @ 13621]
Nathan Walp <nwalp@pidgin.im>
parents: 10959
diff changeset
926 chat->xhtml = TRUE;
e8890f996cc1 [gaim-migrate @ 13621]
Nathan Walp <nwalp@pidgin.im>
parents: 10959
diff changeset
927
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
928 if((error = xmlnode_get_child(packet, "error"))) {
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
929 return;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
930 }
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
931
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
932 if(!(query = xmlnode_get_child(packet, "query")))
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
933 return;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
934
11392
e8890f996cc1 [gaim-migrate @ 13621]
Nathan Walp <nwalp@pidgin.im>
parents: 10959
diff changeset
935 chat->xhtml = FALSE;
e8890f996cc1 [gaim-migrate @ 13621]
Nathan Walp <nwalp@pidgin.im>
parents: 10959
diff changeset
936
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
937 for(x = xmlnode_get_child(query, "feature"); x; x = xmlnode_get_next_twin(x)) {
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
938 const char *var = xmlnode_get_attrib(x, "var");
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
939
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
940 if(var && !strcmp(var, "http://jabber.org/protocol/xhtml-im")) {
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
941 chat->xhtml = TRUE;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
942 }
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
943 }
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
944 }
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
945
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
946 void jabber_chat_disco_traffic(JabberChat *chat)
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
947 {
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
948 JabberIq *iq;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
949 xmlnode *query;
11392
e8890f996cc1 [gaim-migrate @ 13621]
Nathan Walp <nwalp@pidgin.im>
parents: 10959
diff changeset
950 char *room_jid;
e8890f996cc1 [gaim-migrate @ 13621]
Nathan Walp <nwalp@pidgin.im>
parents: 10959
diff changeset
951
e8890f996cc1 [gaim-migrate @ 13621]
Nathan Walp <nwalp@pidgin.im>
parents: 10959
diff changeset
952 room_jid = g_strdup_printf("%s@%s", chat->room, chat->server);
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
953
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
954 iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET,
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
955 "http://jabber.org/protocol/disco#info");
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
956
11392
e8890f996cc1 [gaim-migrate @ 13621]
Nathan Walp <nwalp@pidgin.im>
parents: 10959
diff changeset
957 xmlnode_set_attrib(iq->node, "to", room_jid);
e8890f996cc1 [gaim-migrate @ 13621]
Nathan Walp <nwalp@pidgin.im>
parents: 10959
diff changeset
958
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
959 query = xmlnode_get_child(iq->node, "query");
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
960
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
961 xmlnode_set_attrib(query, "node", "http://jabber.org/protocol/muc#traffic");
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
962
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
963 jabber_iq_set_callback(iq, jabber_chat_disco_traffic_cb, GINT_TO_POINTER(chat->id));
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
964
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
965 jabber_iq_send(iq);
11392
e8890f996cc1 [gaim-migrate @ 13621]
Nathan Walp <nwalp@pidgin.im>
parents: 10959
diff changeset
966
e8890f996cc1 [gaim-migrate @ 13621]
Nathan Walp <nwalp@pidgin.im>
parents: 10959
diff changeset
967 g_free(room_jid);
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
968 }
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
969
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
970
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
971