annotate src/protocols/jabber/chat.c @ 10941:cef48e318125

[gaim-migrate @ 12731] sick of having my tree be so far out of sync...here's all my jabber stuff most notable is the "iChat" buddy icon support committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Thu, 26 May 2005 04:13:06 +0000
parents c4cb90065e1d
children b6cafdeda2a8
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";
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
43 m = g_list_append(m, pce);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
44
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
45 pce = g_new0(struct proto_chat_entry, 1);
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7400
diff changeset
46 pce->label = _("_Server:");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
47 pce->identifier = "server";
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
48 m = g_list_append(m, pce);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
49
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
50 pce = g_new0(struct proto_chat_entry, 1);
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7400
diff changeset
51 pce->label = _("_Handle:");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
52 pce->identifier = "handle";
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
53 m = g_list_append(m, pce);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
54
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
55 pce = g_new0(struct proto_chat_entry, 1);
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7400
diff changeset
56 pce->label = _("_Password:");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
57 pce->identifier = "password";
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
58 pce->secret = TRUE;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
59 m = g_list_append(m, pce);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
60
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
61 return m;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
62 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
63
9754
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
64 GHashTable *jabber_chat_info_defaults(GaimConnection *gc, const char *chat_name)
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
65 {
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
66 GHashTable *defaults;
9770
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
67 JabberStream *js = gc->proto_data;
9754
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 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
70
9770
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
71 g_hash_table_insert(defaults, "handle", g_strdup(js->user->node));
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
72
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
73 if (js->chat_servers)
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
74 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
75 else
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
76 g_hash_table_insert(defaults, "server", g_strdup("conference.jabber.org"));
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
77
9754
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
78 if (chat_name != NULL) {
9760
cee4e4cae56a [gaim-migrate @ 10628]
Nathan Walp <nwalp@pidgin.im>
parents: 9754
diff changeset
79 JabberID *jid = jabber_id_new(chat_name);
cee4e4cae56a [gaim-migrate @ 10628]
Nathan Walp <nwalp@pidgin.im>
parents: 9754
diff changeset
80 if(jid) {
cee4e4cae56a [gaim-migrate @ 10628]
Nathan Walp <nwalp@pidgin.im>
parents: 9754
diff changeset
81 g_hash_table_insert(defaults, "room", g_strdup(jid->node));
cee4e4cae56a [gaim-migrate @ 10628]
Nathan Walp <nwalp@pidgin.im>
parents: 9754
diff changeset
82 if(jid->domain)
9770
41f302d41839 [gaim-migrate @ 10638]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
83 g_hash_table_replace(defaults, "server", g_strdup(jid->domain));
9760
cee4e4cae56a [gaim-migrate @ 10628]
Nathan Walp <nwalp@pidgin.im>
parents: 9754
diff changeset
84 jabber_id_free(jid);
cee4e4cae56a [gaim-migrate @ 10628]
Nathan Walp <nwalp@pidgin.im>
parents: 9754
diff changeset
85 }
9754
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
86 }
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
87
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
88 return defaults;
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
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
91 JabberChat *jabber_chat_find(JabberStream *js, const char *room,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
92 const char *server)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
93 {
10607
bf4c9ce533ab [gaim-migrate @ 12043]
Nathan Walp <nwalp@pidgin.im>
parents: 10504
diff changeset
94 JabberChat *chat = NULL;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
95 char *room_jid;
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 if(NULL != js->chats)
bf4c9ce533ab [gaim-migrate @ 12043]
Nathan Walp <nwalp@pidgin.im>
parents: 10504
diff changeset
98 {
bf4c9ce533ab [gaim-migrate @ 12043]
Nathan Walp <nwalp@pidgin.im>
parents: 10504
diff changeset
99 room_jid = g_strdup_printf("%s@%s", room, server);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
100
10607
bf4c9ce533ab [gaim-migrate @ 12043]
Nathan Walp <nwalp@pidgin.im>
parents: 10504
diff changeset
101 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
102 g_free(room_jid);
bf4c9ce533ab [gaim-migrate @ 12043]
Nathan Walp <nwalp@pidgin.im>
parents: 10504
diff changeset
103 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
104
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
105 return chat;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
106 }
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 struct _find_by_id_data {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
109 int id;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
110 JabberChat *chat;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
111 };
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
112
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
113 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
114 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
115 JabberChat *chat = value;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
116 struct _find_by_id_data *fbid = 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 if(chat->id == fbid->id)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
119 fbid->chat = chat;
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
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
122 JabberChat *jabber_chat_find_by_id(JabberStream *js, int id)
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 JabberChat *chat;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
125 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
126 fbid->id = id;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
127 g_hash_table_foreach(js->chats, find_by_id_foreach_cb, fbid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
128 chat = fbid->chat;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
129 g_free(fbid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
130 return chat;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
131 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
132
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
133 JabberChat *jabber_chat_find_by_conv(GaimConversation *conv)
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
134 {
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
135 GaimAccount *account = gaim_conversation_get_account(conv);
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
136 GaimConnection *gc = gaim_account_get_connection(account);
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
137 JabberStream *js = gc->proto_data;
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
138 int id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv));
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
139
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
140 return jabber_chat_find_by_id(js, id);
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
141 }
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8697
diff changeset
142
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
143 void jabber_chat_invite(GaimConnection *gc, int id, const char *msg,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
144 const char *name)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
145 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
146 JabberStream *js = gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
147 JabberChat *chat;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
148 xmlnode *message, *body, *x, *invite;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
149 char *room_jid;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
150
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
151 chat = jabber_chat_find_by_id(js, id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
152 if(!chat)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
153 return;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
154
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
155 message = xmlnode_new("message");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
156
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
157 room_jid = g_strdup_printf("%s@%s", chat->room, chat->server);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
158
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
159 if(chat->muc) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
160 xmlnode_set_attrib(message, "to", room_jid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
161 x = xmlnode_new_child(message, "x");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
162 xmlnode_set_attrib(x, "xmlns", "http://jabber.org/protocol/muc#user");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
163 invite = xmlnode_new_child(x, "invite");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
164 xmlnode_set_attrib(invite, "to", name);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
165 body = xmlnode_new_child(invite, "reason");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
166 xmlnode_insert_data(body, msg, -1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
167 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
168 xmlnode_set_attrib(message, "to", name);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
169 body = xmlnode_new_child(message, "body");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
170 xmlnode_insert_data(body, msg, -1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
171 x = xmlnode_new_child(message, "x");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
172 xmlnode_set_attrib(x, "jid", room_jid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
173 xmlnode_set_attrib(x, "xmlns", "jabber:x:conference");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
174 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
175
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
176 jabber_send(js, message);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
177 xmlnode_free(message);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
178 g_free(room_jid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
179 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
180
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
181 void jabber_chat_member_free(JabberChatMember *jcm);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
182
9917
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
183 char *jabber_get_chat_name(GHashTable *data) {
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
184 char *room, *server, *chat_name = NULL;
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
185
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
186 room = g_hash_table_lookup(data, "room");
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
187 server = g_hash_table_lookup(data, "server");
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 if (room && server) {
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
190 chat_name = g_strdup_printf("%s@%s", room, 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 return chat_name;
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
193 }
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9913
diff changeset
194
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
195 void jabber_chat_join(GaimConnection *gc, GHashTable *data)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
196 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
197 JabberChat *chat;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
198 char *room, *server, *handle, *passwd;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
199 xmlnode *presence, *x;
7262
85fcaff1505d [gaim-migrate @ 7839]
Nathan Walp <nwalp@pidgin.im>
parents: 7118
diff changeset
200 char *tmp, *room_jid, *full_jid;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
201 JabberStream *js = gc->proto_data;
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
202 GaimPresence *gpresence;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
203 GaimStatus *status;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
204 JabberBuddyState state;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
205 const char *msg;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
206 int priority;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
207
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
208 room = g_hash_table_lookup(data, "room");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
209 server = g_hash_table_lookup(data, "server");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
210 handle = g_hash_table_lookup(data, "handle");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
211 passwd = g_hash_table_lookup(data, "password");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
212
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
213 if(!room || !server)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
214 return;
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(!handle)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
217 handle = js->user->node;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
218
7310
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
219 if(!jabber_nodeprep_validate(room)) {
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
220 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
221 gaim_notify_error(gc, _("Invalid Room Name"), _("Invalid Room Name"),
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
222 buf);
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
223 g_free(buf);
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
224 return;
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
225 } else if(!jabber_nameprep_validate(server)) {
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
226 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
227 gaim_notify_error(gc, _("Invalid Server Name"),
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
228 _("Invalid Server Name"), buf);
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
229 g_free(buf);
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
230 return;
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
231 } else if(!jabber_resourceprep_validate(handle)) {
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
232 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
233 gaim_notify_error(gc, _("Invalid Room Handle"),
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
234 _("Invalid Room Handle"), buf);
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
235 }
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7294
diff changeset
236
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
237 if(jabber_chat_find(js, room, server))
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
238 return;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
239
7262
85fcaff1505d [gaim-migrate @ 7839]
Nathan Walp <nwalp@pidgin.im>
parents: 7118
diff changeset
240 tmp = g_strdup_printf("%s@%s", room, server);
7322
ab828b8c3f22 [gaim-migrate @ 7908]
Nathan Walp <nwalp@pidgin.im>
parents: 7310
diff changeset
241 room_jid = g_strdup(jabber_normalize(NULL, tmp));
7262
85fcaff1505d [gaim-migrate @ 7839]
Nathan Walp <nwalp@pidgin.im>
parents: 7118
diff changeset
242 g_free(tmp);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
243
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
244 chat = g_new0(JabberChat, 1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
245 chat->js = gc->proto_data;
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->room = g_strdup(room);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
248 chat->server = g_strdup(server);
8400
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
249 chat->handle = g_strdup(handle);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
250
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
251 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
252 (GDestroyNotify)jabber_chat_member_free);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
253
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
254 g_hash_table_insert(js->chats, room_jid, chat);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
255
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
256 gpresence = gaim_account_get_presence(gc->account);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
257 status = gaim_presence_get_active_status(gpresence);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
258
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
259 gaim_status_to_jabber(status, &state, &msg, &priority);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
260
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
261 presence = jabber_presence_create(state, msg, priority);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
262 full_jid = g_strdup_printf("%s/%s", room_jid, handle);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
263 xmlnode_set_attrib(presence, "to", full_jid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
264 g_free(full_jid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
265
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
266 x = xmlnode_new_child(presence, "x");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
267 xmlnode_set_attrib(x, "xmlns", "http://jabber.org/protocol/muc");
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 if(passwd && *passwd) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
270 xmlnode *password = xmlnode_new_child(x, "password");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
271 xmlnode_insert_data(password, passwd, -1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
272 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
273
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
274 jabber_send(js, presence);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
275 xmlnode_free(presence);
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
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
278 void jabber_chat_leave(GaimConnection *gc, int id)
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 JabberStream *js = gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
281 JabberChat *chat = jabber_chat_find_by_id(js, id);
7974
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
282
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
283
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
284 if(!chat)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
285 return;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
286
7974
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
287 jabber_chat_part(chat, NULL);
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
288
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
289 chat->conv = NULL;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
290 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
291
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
292 void jabber_chat_destroy(JabberChat *chat)
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 JabberStream *js = chat->js;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
295 char *room_jid = g_strdup_printf("%s@%s", chat->room, chat->server);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
296
7322
ab828b8c3f22 [gaim-migrate @ 7908]
Nathan Walp <nwalp@pidgin.im>
parents: 7310
diff changeset
297 g_hash_table_remove(js->chats, jabber_normalize(NULL, room_jid));
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
298 g_free(room_jid);
8396
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
299 }
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
300
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
301 void jabber_chat_free(JabberChat *chat)
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 if(chat->config_dialog_handle)
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
304 gaim_request_close(chat->config_dialog_type, chat->config_dialog_handle);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
305
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
306 g_free(chat->room);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
307 g_free(chat->server);
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10474
diff changeset
308 g_free(chat->handle);
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10474
diff changeset
309 g_hash_table_destroy(chat->members);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
310 g_free(chat);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
311 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
312
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
313 gboolean jabber_chat_find_buddy(GaimConversation *conv, const char *name)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
314 {
9554
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9152
diff changeset
315 return gaim_conv_chat_find_user(GAIM_CONV_CHAT(conv), name);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
316 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
317
7398
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
318 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
319 {
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
320 JabberStream *js = gc->proto_data;
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
321 JabberChat *chat;
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 chat = jabber_chat_find_by_id(js, id);
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
324
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
325 if(!chat)
d60e1629ffde [gaim-migrate @ 7994]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
326 return NULL;
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 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
329 }
7895
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
330
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
331 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
332 {
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
333 JabberChat *chat = data;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
334 xmlnode *query;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
335 JabberIq *iq;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
336 char *to = g_strdup_printf("%s@%s", chat->room, chat->server);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
337
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
338 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
339 xmlnode_set_attrib(iq->node, "to", to);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
340 g_free(to);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
341
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
342 query = xmlnode_get_child(iq->node, "query");
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
343
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
344 xmlnode_insert_child(query, result);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
345
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
346 jabber_iq_send(iq);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
347 }
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 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
350 {
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
351 xmlnode *query, *x;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
352 const char *type = xmlnode_get_attrib(packet, "type");
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
353 const char *from = xmlnode_get_attrib(packet, "from");
7926
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
354 char *msg;
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
355 JabberChat *chat;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
356 JabberID *jid;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
357
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
358 if(!type || !from)
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
359 return;
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
7926
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
362
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
363 if(!strcmp(type, "result")) {
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
364 jid = jabber_id_new(from);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
365
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
366 if(!jid)
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
367 return;
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 chat = jabber_chat_find(js, jid->node, jid->domain);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
370 jabber_id_free(jid);
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 if(!chat)
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
373 return;
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(!(query = xmlnode_get_child(packet, "query")))
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
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8120
diff changeset
378 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
379 const char *xmlns;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
380 if(!(xmlns = xmlnode_get_attrib(x, "xmlns")))
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
381 continue;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
382
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
383 if(!strcmp(xmlns, "jabber:x:data")) {
8396
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
384 chat->config_dialog_type = GAIM_REQUEST_FIELDS;
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
385 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
386 return;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
387 }
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
388 }
7926
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
389 } else if(!strcmp(type, "error")) {
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
390 char *msg = jabber_parse_error(js, packet);
7926
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
391
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
392 gaim_notify_error(js->gc, _("Configuration error"), _("Configuration error"), msg);
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
393
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
394 if(msg)
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
395 g_free(msg);
7926
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
396 return;
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
397 }
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
398
7926
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
399 msg = g_strdup_printf("Unable to configure room %s", from);
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
400
68900f9cb540 [gaim-migrate @ 8597]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
401 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
402 g_free(msg);
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
403
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
404 }
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
405
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
406 void jabber_chat_request_room_configure(JabberChat *chat) {
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
407 JabberIq *iq;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
408 xmlnode *query;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
409 char *room_jid;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
410
7895
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
411 if(!chat)
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
412 return;
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
413
8396
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
414 chat->config_dialog_handle = NULL;
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
415
7955
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
416 if(!chat->muc) {
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
417 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
418 _("This room is not capable of being configured"));
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
419 return;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
420 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
421
10474
ae1fa1218e5c [gaim-migrate @ 11761]
Nathan Walp <nwalp@pidgin.im>
parents: 10094
diff changeset
422 iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET,
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
423 "http://jabber.org/protocol/muc#owner");
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
424 query = xmlnode_get_child(iq->node, "query");
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
425 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
426
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
427 xmlnode_set_attrib(iq->node, "to", room_jid);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
428
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
429 jabber_iq_set_callback(iq, jabber_chat_room_configure_cb, NULL);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
430
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
431 jabber_iq_send(iq);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
432
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7895
diff changeset
433 g_free(room_jid);
7895
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
434 }
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
435
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
436 void jabber_chat_create_instant_room(JabberChat *chat) {
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
437 JabberIq *iq;
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
438 xmlnode *query, *x;
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
439 char *room_jid;
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
440
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
441 if(!chat)
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
442 return;
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
443
8396
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
444 chat->config_dialog_handle = NULL;
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8261
diff changeset
445
7895
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
446 iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET,
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
447 "http://jabber.org/protocol/muc#owner");
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
448 query = xmlnode_get_child(iq->node, "query");
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
449 x = xmlnode_new_child(query, "x");
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
450 room_jid = g_strdup_printf("%s@%s", chat->room, chat->server);
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
451
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
452 xmlnode_set_attrib(iq->node, "to", room_jid);
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
453 xmlnode_set_attrib(x, "xmlns", "jabber:x:data");
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
454 xmlnode_set_attrib(x, "type", "submit");
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
455
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
456 jabber_iq_send(iq);
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
457
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
458 g_free(room_jid);
ddd80ffd3815 [gaim-migrate @ 8555]
Nathan Walp <nwalp@pidgin.im>
parents: 7841
diff changeset
459 }
7955
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
460
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
461 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
462 {
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
463 const char *type = xmlnode_get_attrib(packet, "type");
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
464
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
465 if(type && !strcmp(type, "error")) {
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
466 char *msg = jabber_parse_error(js, packet);
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
467
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
468 gaim_notify_error(js->gc, _("Registration error"), _("Registration error"), msg);
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
469
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
470 if(msg)
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
471 g_free(msg);
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
472 return;
7955
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
473 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
474 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
475
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
476 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
477 {
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
478 JabberChat *chat = data;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
479 xmlnode *query;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
480 JabberIq *iq;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
481 char *to = g_strdup_printf("%s@%s", chat->room, chat->server);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
482
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
483 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
484 xmlnode_set_attrib(iq->node, "to", to);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
485 g_free(to);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
486
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
487 query = xmlnode_get_child(iq->node, "query");
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
488
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
489 xmlnode_insert_child(query, result);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
490
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
491 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
492
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
493 jabber_iq_send(iq);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
494 }
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 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
497 {
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
498 xmlnode *query, *x;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
499 const char *type = xmlnode_get_attrib(packet, "type");
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
500 const char *from = xmlnode_get_attrib(packet, "from");
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
501 char *msg;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
502 JabberChat *chat;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
503 JabberID *jid;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
504
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
505 if(!type || !from)
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
506 return;
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(!strcmp(type, "result")) {
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
509 jid = jabber_id_new(from);
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(!jid)
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
512 return;
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 chat = jabber_chat_find(js, jid->node, jid->domain);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
515 jabber_id_free(jid);
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 if(!chat)
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
518 return;
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(!(query = xmlnode_get_child(packet, "query")))
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
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8120
diff changeset
523 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
524 const char *xmlns;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
525
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
526 if(!(xmlns = xmlnode_get_attrib(x, "xmlns")))
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
527 continue;
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(!strcmp(xmlns, "jabber:x:data")) {
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
530 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
531 return;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
532 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
533 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
534 } else if(!strcmp(type, "error")) {
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
535 char *msg = jabber_parse_error(js, packet);
7955
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 gaim_notify_error(js->gc, _("Registration error"), _("Registration error"), msg);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
538
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
539 if(msg)
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
540 g_free(msg);
7955
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
541 return;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
542 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
543
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
544 msg = g_strdup_printf("Unable to configure room %s", from);
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 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
547 g_free(msg);
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 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
550
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
551 void jabber_chat_register(JabberChat *chat)
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 JabberIq *iq;
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
554 char *room_jid;
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 if(!chat)
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
557 return;
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 room_jid = g_strdup_printf("%s@%s", chat->room, chat->server);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
560
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
561 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
562 xmlnode_set_attrib(iq->node, "to", room_jid);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
563 g_free(room_jid);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
564
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
565 jabber_iq_set_callback(iq, jabber_chat_register_cb, NULL);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
566
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
567 jabber_iq_send(iq);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
568 }
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
569
7971
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
570 /* 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
571 void jabber_chat_change_topic(JabberChat *chat, const char *topic)
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
572 {
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
573 if(topic && *topic) {
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
574 JabberMessage *jm;
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
575 jm = g_new0(JabberMessage, 1);
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
576 jm->js = chat->js;
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
577 jm->type = JABBER_MESSAGE_GROUPCHAT;
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
578 jm->subject = gaim_markup_strip_html(topic);
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
579 jm->to = g_strdup_printf("%s@%s", chat->room, chat->server);
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
580 jabber_message_send(jm);
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
581 jabber_message_free(jm);
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
582 } else {
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
583 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
584 char *buf, *tmp, *tmp2;
7955
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7926
diff changeset
585
9762
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9760
diff changeset
586 if(cur) {
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10607
diff changeset
587 tmp = g_markup_escape_text(cur, -1);
9762
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9760
diff changeset
588 tmp2 = gaim_markup_linkify(tmp);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9760
diff changeset
589 buf = g_strdup_printf(_("current topic is: %s"), tmp2);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9760
diff changeset
590 g_free(tmp);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9760
diff changeset
591 g_free(tmp2);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9760
diff changeset
592 } else
7971
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
593 buf = g_strdup(_("No topic is set"));
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
594 gaim_conv_chat_write(GAIM_CONV_CHAT(chat->conv), "", buf,
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
595 GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG, time(NULL));
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
596 g_free(buf);
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
597 }
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
598
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
599 }
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 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
602 {
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
603 JabberStream *js = gc->proto_data;
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
604 JabberChat *chat = jabber_chat_find_by_id(js, id);
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 if(!chat)
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
607 return;
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 jabber_chat_change_topic(chat, topic);
6fca0d9cc98b [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
610 }
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
7972
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
613 void jabber_chat_change_nick(JabberChat *chat, const char *nick)
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
614 {
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
615 xmlnode *presence;
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
616 char *full_jid;
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
617 GaimPresence *gpresence;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
618 GaimStatus *status;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
619 JabberBuddyState state;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
620 const char *msg;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
621 int priority;
7972
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
622
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
623 if(!chat->muc) {
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
624 gaim_conv_chat_write(GAIM_CONV_CHAT(chat->conv), "",
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
625 _("Nick changing not supported in non-MUC chatrooms"),
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
626 GAIM_MESSAGE_SYSTEM, time(NULL));
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
627 return;
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
628 }
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
629
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
630 gpresence = gaim_account_get_presence(chat->js->gc->account);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
631 status = gaim_presence_get_active_status(gpresence);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
632
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
633 gaim_status_to_jabber(status, &state, &msg, &priority);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
634
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
635 presence = jabber_presence_create(state, msg, priority);
7972
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
636 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
637 xmlnode_set_attrib(presence, "to", full_jid);
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
638 g_free(full_jid);
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
639
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
640 jabber_send(chat->js, presence);
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
641 xmlnode_free(presence);
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
7974
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
644 void jabber_chat_part(JabberChat *chat, const char *msg)
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
645 {
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
646 char *room_jid;
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
647 xmlnode *presence;
7972
ac01b7d67ff9 [gaim-migrate @ 8649]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
648
8537
dc818b62379e [gaim-migrate @ 9276]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
649 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
650 chat->handle);
7974
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
651 presence = xmlnode_new("presence");
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
652 xmlnode_set_attrib(presence, "to", room_jid);
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
653 xmlnode_set_attrib(presence, "type", "unavailable");
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
654 if(msg) {
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
655 xmlnode *status = xmlnode_new_child(presence, "status");
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
656 xmlnode_insert_data(status, msg, -1);
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
657 }
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
658 jabber_send(chat->js, presence);
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
659 xmlnode_free(presence);
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
660 g_free(room_jid);
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
661 }
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
662
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
663 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
664 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
665 xmlnode *query;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
666 xmlnode *item;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
667 const char *type;
7974
415df6fa0395 [gaim-migrate @ 8651]
Nathan Walp <nwalp@pidgin.im>
parents: 7972
diff changeset
668
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
669 if(!js->roomlist)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
670 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
671
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
672 if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result")) {
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
673 char *err = jabber_parse_error(js,packet);
10091
4e376556566e [gaim-migrate @ 11107]
Mark Doliner <mark@kingant.net>
parents: 10045
diff changeset
674 gaim_notify_error(js->gc, _("Error"),
10094
2a7780fadbb9 [gaim-migrate @ 11112]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
675 _("Error retrieving room list"), err);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
676 gaim_roomlist_set_in_progress(js->roomlist, FALSE);
8120
81a63a9bff88 [gaim-migrate @ 8824]
Nathan Walp <nwalp@pidgin.im>
parents: 8113
diff changeset
677 gaim_roomlist_unref(js->roomlist);
81a63a9bff88 [gaim-migrate @ 8824]
Nathan Walp <nwalp@pidgin.im>
parents: 8113
diff changeset
678 js->roomlist = NULL;
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
679 g_free(err);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
680 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
681 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
682
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
683 if(!(query = xmlnode_get_child(packet, "query"))) {
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
684 char *err = jabber_parse_error(js, packet);
10091
4e376556566e [gaim-migrate @ 11107]
Mark Doliner <mark@kingant.net>
parents: 10045
diff changeset
685 gaim_notify_error(js->gc, _("Error"),
10094
2a7780fadbb9 [gaim-migrate @ 11112]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
686 _("Error retrieving room list"), err);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
687 gaim_roomlist_set_in_progress(js->roomlist, FALSE);
8120
81a63a9bff88 [gaim-migrate @ 8824]
Nathan Walp <nwalp@pidgin.im>
parents: 8113
diff changeset
688 gaim_roomlist_unref(js->roomlist);
81a63a9bff88 [gaim-migrate @ 8824]
Nathan Walp <nwalp@pidgin.im>
parents: 8113
diff changeset
689 js->roomlist = NULL;
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
690 g_free(err);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
691 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
692 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
693
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8120
diff changeset
694 for(item = xmlnode_get_child(query, "item"); item;
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8120
diff changeset
695 item = xmlnode_get_next_twin(item)) {
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
696 const char *name;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
697 GaimRoomlistRoom *room;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
698 JabberID *jid;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
699
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
700 if(!(jid = jabber_id_new(xmlnode_get_attrib(item, "jid"))))
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
701 continue;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
702 name = xmlnode_get_attrib(item, "name");
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
703
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
704
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
705 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
706 gaim_roomlist_room_add_field(js->roomlist, room, jid->node);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
707 gaim_roomlist_room_add_field(js->roomlist, room, jid->domain);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
708 gaim_roomlist_room_add_field(js->roomlist, room, name ? name : "");
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
709 gaim_roomlist_room_add(js->roomlist, room);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
710
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
711 jabber_id_free(jid);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
712 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
713 gaim_roomlist_set_in_progress(js->roomlist, FALSE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
714 gaim_roomlist_unref(js->roomlist);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
715 js->roomlist = NULL;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
716 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
717
10045
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
718 static void roomlist_cancel_cb(JabberStream *js, const char *server) {
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
719 if(js->roomlist) {
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
720 gaim_roomlist_set_in_progress(js->roomlist, FALSE);
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
721 gaim_roomlist_unref(js->roomlist);
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
722 js->roomlist = NULL;
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
723 }
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
724 }
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
725
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
726 static void roomlist_ok_cb(JabberStream *js, const char *server)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
727 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
728 JabberIq *iq;
10045
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
729
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
730 if(!js->roomlist)
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
731 return;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
732
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
733 if(!server || !*server) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
734 gaim_notify_error(js->gc, _("Invalid Server"), _("Invalid Server"), NULL);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
735 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
736 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
737
10045
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
738 gaim_roomlist_set_in_progress(js->roomlist, TRUE);
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
739
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
740 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
741
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
742 xmlnode_set_attrib(iq->node, "to", server);
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
743
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
744 jabber_iq_set_callback(iq, roomlist_disco_result_cb, NULL);
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
745
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
746 jabber_iq_send(iq);
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
747 }
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 GaimRoomlist *jabber_roomlist_get_list(GaimConnection *gc)
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 JabberStream *js = gc->proto_data;
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
752 GList *fields = NULL;
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
753 GaimRoomlistField *f;
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
754
9913
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
755 if(js->roomlist)
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
756 gaim_roomlist_unref(js->roomlist);
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
757
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
758 js->roomlist = gaim_roomlist_new(gaim_connection_get_account(js->gc));
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
759
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
760 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", "room", TRUE);
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
761 fields = g_list_append(fields, f);
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, "", "server", 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, _("Description"), "description", FALSE);
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 gaim_roomlist_set_fields(js->roomlist, fields);
0056843d512c [gaim-migrate @ 10805]
Luke Schierer <lschiere@pidgin.im>
parents: 9770
diff changeset
770
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
771
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
772 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
773 _("Select a conference server to query"),
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
774 js->chat_servers ? js->chat_servers->data : "conference.jabber.org",
8697
725413cc9fb9 [gaim-migrate @ 9450]
Mark Doliner <mark@kingant.net>
parents: 8537
diff changeset
775 FALSE, FALSE, NULL,
10045
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
776 _("Find Rooms"), GAIM_CALLBACK(roomlist_ok_cb),
ac98ece02b1f [gaim-migrate @ 11005]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
777 _("Cancel"), GAIM_CALLBACK(roomlist_cancel_cb), js);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
778
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
779 return js->roomlist;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
780 }
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 void jabber_roomlist_cancel(GaimRoomlist *list)
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 GaimConnection *gc;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
785 JabberStream *js;
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 gc = gaim_account_get_connection(list->account);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
788 js = gc->proto_data;
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 gaim_roomlist_set_in_progress(list, FALSE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
791
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
792 if (js->roomlist == list) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
793 js->roomlist = NULL;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
794 gaim_roomlist_unref(list);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
795 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
796 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
797
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
798 void jabber_chat_member_free(JabberChatMember *jcm)
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
799 {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
800 g_free(jcm->handle);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
801 g_free(jcm->jid);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
802 g_free(jcm);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
803 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
804
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
805 void jabber_chat_track_handle(JabberChat *chat, const char *handle,
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
806 const char *jid, const char *affiliation, const char *role)
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 JabberChatMember *jcm = g_new0(JabberChatMember, 1);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
809
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
810 jcm->handle = g_strdup(handle);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
811 jcm->jid = g_strdup(jid);
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 g_hash_table_replace(chat->members, jcm->handle, jcm);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
814
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
815 /* XXX: keep track of role and affiliation */
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
816 }
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 void jabber_chat_remove_handle(JabberChat *chat, const char *handle)
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 g_hash_table_remove(chat->members, handle);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
821 }
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 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
824 {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
825 JabberIq *iq;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
826 JabberChatMember *jcm = g_hash_table_lookup(chat->members, who);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
827 char *to;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
828 xmlnode *query, *item, *reason;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
829
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
830 if(!jcm || !jcm->jid)
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
831 return FALSE;
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 iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET,
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
834 "http://jabber.org/protocol/muc#admin");
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 to = g_strdup_printf("%s@%s", chat->room, chat->server);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
837 xmlnode_set_attrib(iq->node, "to", to);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
838 g_free(to);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
839
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
840 query = xmlnode_get_child(iq->node, "query");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
841 item = xmlnode_new_child(query, "item");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
842 xmlnode_set_attrib(item, "jid", jcm->jid);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
843 xmlnode_set_attrib(item, "affiliation", "outcast");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
844 if(why) {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
845 reason = xmlnode_new_child(item, "reason");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
846 xmlnode_insert_data(reason, why, -1);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
847 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
848
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
849 jabber_iq_send(iq);
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 return TRUE;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
852 }
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
853
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
854
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
855 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
856 {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
857 JabberIq *iq;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
858 JabberChatMember *jcm = g_hash_table_lookup(chat->members, who);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
859 char *to;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
860 xmlnode *query, *item, *reason;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
861
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
862 if(!jcm || !jcm->jid)
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
863 return FALSE;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
864
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
865 iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET,
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
866 "http://jabber.org/protocol/muc#admin");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
867
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
868 to = g_strdup_printf("%s@%s", chat->room, chat->server);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
869 xmlnode_set_attrib(iq->node, "to", to);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
870 g_free(to);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
871
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
872 query = xmlnode_get_child(iq->node, "query");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
873 item = xmlnode_new_child(query, "item");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
874 xmlnode_set_attrib(item, "jid", jcm->jid);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
875 xmlnode_set_attrib(item, "role", "none");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
876 if(why) {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
877 reason = xmlnode_new_child(item, "reason");
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
878 xmlnode_insert_data(reason, why, -1);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
879 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
880
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
881 jabber_iq_send(iq);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
882
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
883 return TRUE;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
884 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
885
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
886 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
887 {
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
888 JabberChat *chat;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
889 xmlnode *query, *x, *error;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
890 int id = GPOINTER_TO_INT(data);
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
891
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
892 if(!(chat = jabber_chat_find_by_id(js, id)))
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
893 return;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
894
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
895 if((error = xmlnode_get_child(packet, "error"))) {
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
896 /* defaults, in case the conference server doesn't
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
897 * support this request */
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
898 chat->xhtml = TRUE;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
899 return;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
900 }
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
901
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
902 if(!(query = xmlnode_get_child(packet, "query")))
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
903 return;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
904
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
905 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
906 const char *var = xmlnode_get_attrib(x, "var");
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
907
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
908 if(var && !strcmp(var, "http://jabber.org/protocol/xhtml-im")) {
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
909 chat->xhtml = TRUE;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
910 }
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
911 }
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
912 }
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
913
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
914 void jabber_chat_disco_traffic(JabberChat *chat)
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
915 {
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
916 JabberIq *iq;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
917 xmlnode *query;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
918
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
919 iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET,
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
920 "http://jabber.org/protocol/disco#info");
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
921
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
922 query = xmlnode_get_child(iq->node, "query");
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
923
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
924 xmlnode_set_attrib(query, "node", "http://jabber.org/protocol/muc#traffic");
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
925
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
926 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
927
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
928 jabber_iq_send(iq);
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
929 }
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
930
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
931
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10732
diff changeset
932