Mercurial > pidgin.yaz
annotate libpurple/protocols/jabber/chat.c @ 30745:a0d6b85e9c42
jabber: Avoid an assertion warning
As noticed by Elliott
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 31 Jul 2010 20:18:59 +0000 |
parents | c8b407fec879 |
children | ba6a4a0f8f50 |
rev | line source |
---|---|
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
15823 | 2 * purple - Jabber Protocol Plugin |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
28398
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
28225
diff
changeset
|
4 * Purple is the legal property of its developers, whose names are too numerous |
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
28225
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
28225
diff
changeset
|
6 * source distribution. |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19676
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 #include "prpl.h" /* for proto_chat_entry */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 #include "notify.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include "request.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #include "roomlist.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #include "util.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "chat.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include "iq.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 #include "message.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 #include "presence.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 #include "xdata.h" |
23445
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23262
diff
changeset
|
36 #include "data.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 |
15823 | 38 GList *jabber_chat_info(PurpleConnection *gc) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 GList *m = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 struct proto_chat_entry *pce; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 pce = g_new0(struct proto_chat_entry, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 pce->label = _("_Room:"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 pce->identifier = "room"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 pce->required = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 m = g_list_append(m, pce); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 pce = g_new0(struct proto_chat_entry, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 pce->label = _("_Server:"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 pce->identifier = "server"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 pce->required = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 m = g_list_append(m, pce); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 pce = g_new0(struct proto_chat_entry, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 pce->label = _("_Handle:"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 pce->identifier = "handle"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 pce->required = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 m = g_list_append(m, pce); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 pce = g_new0(struct proto_chat_entry, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 pce->label = _("_Password:"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 pce->identifier = "password"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 pce->secret = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 m = g_list_append(m, pce); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 return m; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 |
15823 | 70 GHashTable *jabber_chat_info_defaults(PurpleConnection *gc, const char *chat_name) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 GHashTable *defaults; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 JabberStream *js = gc->proto_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
77 g_hash_table_insert(defaults, "handle", g_strdup(js->user->node)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
79 if (js->chat_servers) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 g_hash_table_insert(defaults, "server", g_strdup(js->chat_servers->data)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 if (chat_name != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 JabberID *jid = jabber_id_new(chat_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 if(jid) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 g_hash_table_insert(defaults, "room", g_strdup(jid->node)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 if(jid->domain) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 g_hash_table_replace(defaults, "server", g_strdup(jid->domain)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 if(jid->resource) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
89 g_hash_table_replace(defaults, "handle", g_strdup(jid->resource)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 jabber_id_free(jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
94 return defaults; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 JabberChat *jabber_chat_find(JabberStream *js, const char *room, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 const char *server) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 JabberChat *chat = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
101 |
28659
c42d5c23a9e8
jabber: Don't crash when adding a buddy without a node (no '@'). Closes #10261.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
102 g_return_val_if_fail(room != NULL, NULL); |
c42d5c23a9e8
jabber: Don't crash when adding a buddy without a node (no '@'). Closes #10261.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
103 g_return_val_if_fail(server != NULL, NULL); |
c42d5c23a9e8
jabber: Don't crash when adding a buddy without a node (no '@'). Closes #10261.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
104 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 if(NULL != js->chats) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 { |
22921
1003f1736be1
Close up scope of a variable, I'm just cleaning up my tree some.
Etan Reisner <pidgin@unreliablesource.net>
parents:
22753
diff
changeset
|
107 char *room_jid = g_strdup_printf("%s@%s", room, server); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 |
28756
08ffa726aea2
jabber: Remove useless jabber_normalize calls now that the data in the hash table
Paul Aurich <paul@darkrain42.org>
parents:
28752
diff
changeset
|
109 chat = g_hash_table_lookup(js->chats, room_jid); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
110 g_free(room_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 return chat; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 struct _find_by_id_data { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 int id; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 JabberChat *chat; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 static void find_by_id_foreach_cb(gpointer key, gpointer value, gpointer user_data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 JabberChat *chat = value; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 struct _find_by_id_data *fbid = user_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 if(chat->id == fbid->id) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 fbid->chat = chat; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 JabberChat *jabber_chat_find_by_id(JabberStream *js, int id) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 JabberChat *chat; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
133 struct _find_by_id_data *fbid = g_new0(struct _find_by_id_data, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
134 fbid->id = id; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 g_hash_table_foreach(js->chats, find_by_id_foreach_cb, fbid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 chat = fbid->chat; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 g_free(fbid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 return chat; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 |
15823 | 141 JabberChat *jabber_chat_find_by_conv(PurpleConversation *conv) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 { |
15823 | 143 PurpleAccount *account = purple_conversation_get_account(conv); |
144 PurpleConnection *gc = purple_account_get_connection(account); | |
22644
d14294a40d74
Do not crash from commands in a disconnected chat. Fixes #5208
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
145 JabberStream *js; |
d14294a40d74
Do not crash from commands in a disconnected chat. Fixes #5208
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
146 int id; |
d14294a40d74
Do not crash from commands in a disconnected chat. Fixes #5208
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
147 if (!gc) |
d14294a40d74
Do not crash from commands in a disconnected chat. Fixes #5208
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
148 return NULL; |
d14294a40d74
Do not crash from commands in a disconnected chat. Fixes #5208
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
149 js = gc->proto_data; |
d14294a40d74
Do not crash from commands in a disconnected chat. Fixes #5208
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
150 id = purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 return jabber_chat_find_by_id(js, id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 |
15823 | 154 void jabber_chat_invite(PurpleConnection *gc, int id, const char *msg, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 const char *name) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 JabberStream *js = gc->proto_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
158 JabberChat *chat; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
159 xmlnode *message, *body, *x, *invite; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 char *room_jid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 chat = jabber_chat_find_by_id(js, id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
163 if(!chat) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 message = xmlnode_new("message"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 if(chat->muc) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 xmlnode_set_attrib(message, "to", room_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 x = xmlnode_new_child(message, "x"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 xmlnode_set_namespace(x, "http://jabber.org/protocol/muc#user"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 invite = xmlnode_new_child(x, "invite"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 xmlnode_set_attrib(invite, "to", name); |
30745
a0d6b85e9c42
jabber: Avoid an assertion warning
Paul Aurich <paul@darkrain42.org>
parents:
29464
diff
changeset
|
176 if (msg) { |
a0d6b85e9c42
jabber: Avoid an assertion warning
Paul Aurich <paul@darkrain42.org>
parents:
29464
diff
changeset
|
177 body = xmlnode_new_child(invite, "reason"); |
a0d6b85e9c42
jabber: Avoid an assertion warning
Paul Aurich <paul@darkrain42.org>
parents:
29464
diff
changeset
|
178 xmlnode_insert_data(body, msg, -1); |
a0d6b85e9c42
jabber: Avoid an assertion warning
Paul Aurich <paul@darkrain42.org>
parents:
29464
diff
changeset
|
179 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 xmlnode_set_attrib(message, "to", name); |
28775
41992511531f
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents:
28756
diff
changeset
|
182 /* |
41992511531f
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents:
28756
diff
changeset
|
183 * Putting the reason into the body was an 'undocumented protocol, |
41992511531f
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents:
28756
diff
changeset
|
184 * ...not part of "groupchat 1.0"'. |
41992511531f
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents:
28756
diff
changeset
|
185 * http://xmpp.org/extensions/attic/jep-0045-1.16.html#invite |
41992511531f
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents:
28756
diff
changeset
|
186 * |
41992511531f
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents:
28756
diff
changeset
|
187 * Left here for compatibility. |
41992511531f
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents:
28756
diff
changeset
|
188 */ |
30745
a0d6b85e9c42
jabber: Avoid an assertion warning
Paul Aurich <paul@darkrain42.org>
parents:
29464
diff
changeset
|
189 if (msg) { |
a0d6b85e9c42
jabber: Avoid an assertion warning
Paul Aurich <paul@darkrain42.org>
parents:
29464
diff
changeset
|
190 body = xmlnode_new_child(message, "body"); |
a0d6b85e9c42
jabber: Avoid an assertion warning
Paul Aurich <paul@darkrain42.org>
parents:
29464
diff
changeset
|
191 xmlnode_insert_data(body, msg, -1); |
a0d6b85e9c42
jabber: Avoid an assertion warning
Paul Aurich <paul@darkrain42.org>
parents:
29464
diff
changeset
|
192 } |
28775
41992511531f
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents:
28756
diff
changeset
|
193 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 x = xmlnode_new_child(message, "x"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 xmlnode_set_attrib(x, "jid", room_jid); |
28775
41992511531f
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents:
28756
diff
changeset
|
196 |
41992511531f
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents:
28756
diff
changeset
|
197 /* The better place for it! XEP-0249 style. */ |
30745
a0d6b85e9c42
jabber: Avoid an assertion warning
Paul Aurich <paul@darkrain42.org>
parents:
29464
diff
changeset
|
198 if (msg) |
a0d6b85e9c42
jabber: Avoid an assertion warning
Paul Aurich <paul@darkrain42.org>
parents:
29464
diff
changeset
|
199 xmlnode_set_attrib(x, "reason", msg); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 xmlnode_set_namespace(x, "jabber:x:conference"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
203 jabber_send(js, message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
204 xmlnode_free(message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 g_free(room_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
207 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
208 void jabber_chat_member_free(JabberChatMember *jcm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 char *jabber_get_chat_name(GHashTable *data) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 char *room, *server, *chat_name = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 room = g_hash_table_lookup(data, "room"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 server = g_hash_table_lookup(data, "server"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 if (room && server) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
217 chat_name = g_strdup_printf("%s@%s", room, server); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
218 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 return chat_name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
220 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
221 |
23108
568a0957e835
g_hash_table_ref() / g_hash_table_unref() were added in too recent a glib version per Mark. Copy data to chat->components rather than using those.
Evan Schoenberg <evan.s@dreskin.net>
parents:
23105
diff
changeset
|
222 static void insert_in_hash_table(gpointer key, gpointer value, gpointer user_data) |
568a0957e835
g_hash_table_ref() / g_hash_table_unref() were added in too recent a glib version per Mark. Copy data to chat->components rather than using those.
Evan Schoenberg <evan.s@dreskin.net>
parents:
23105
diff
changeset
|
223 { |
568a0957e835
g_hash_table_ref() / g_hash_table_unref() were added in too recent a glib version per Mark. Copy data to chat->components rather than using those.
Evan Schoenberg <evan.s@dreskin.net>
parents:
23105
diff
changeset
|
224 GHashTable *hash_table = (GHashTable *)user_data; |
23110
53bf3c21b79d
The key and value need to be g_stdup()'d before adding to the hash table
Evan Schoenberg <evan.s@dreskin.net>
parents:
23108
diff
changeset
|
225 g_hash_table_insert(hash_table, g_strdup(key), g_strdup(value)); |
23108
568a0957e835
g_hash_table_ref() / g_hash_table_unref() were added in too recent a glib version per Mark. Copy data to chat->components rather than using those.
Evan Schoenberg <evan.s@dreskin.net>
parents:
23105
diff
changeset
|
226 } |
568a0957e835
g_hash_table_ref() / g_hash_table_unref() were added in too recent a glib version per Mark. Copy data to chat->components rather than using those.
Evan Schoenberg <evan.s@dreskin.net>
parents:
23105
diff
changeset
|
227 |
28741
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
228 static JabberChat *jabber_chat_new(JabberStream *js, const char *room, |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
229 const char *server, const char *handle, |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
230 const char *password, GHashTable *data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
232 JabberChat *chat; |
28741
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
233 char *jid; |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
234 |
28752
ef513141e960
jabber: Reduce these from assertions to checks.
Paul Aurich <paul@darkrain42.org>
parents:
28742
diff
changeset
|
235 if (jabber_chat_find(js, room, server) != NULL) |
ef513141e960
jabber: Reduce these from assertions to checks.
Paul Aurich <paul@darkrain42.org>
parents:
28742
diff
changeset
|
236 return NULL; |
28741
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
237 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
238 chat = g_new0(JabberChat, 1); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
239 chat->js = js; |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
240 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
241 chat->room = g_strdup(room); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
242 chat->server = g_strdup(server); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
243 chat->handle = g_strdup(handle); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
244 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
245 /* Copy the data hash table to chat->components */ |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
246 chat->components = g_hash_table_new_full(g_str_hash, g_str_equal, |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
247 g_free, g_free); |
28742
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28741
diff
changeset
|
248 if (data == NULL) { |
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28741
diff
changeset
|
249 g_hash_table_insert(chat->components, g_strdup("handle"), g_strdup(handle)); |
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28741
diff
changeset
|
250 g_hash_table_insert(chat->components, g_strdup("room"), g_strdup(room)); |
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28741
diff
changeset
|
251 g_hash_table_insert(chat->components, g_strdup("server"), g_strdup(server)); |
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28741
diff
changeset
|
252 /* g_hash_table_insert(chat->components, g_strdup("password"), g_strdup(server)); */ |
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28741
diff
changeset
|
253 } else { |
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28741
diff
changeset
|
254 g_hash_table_foreach(data, insert_in_hash_table, chat->components); |
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28741
diff
changeset
|
255 } |
28741
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
256 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
257 chat->members = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
258 (GDestroyNotify)jabber_chat_member_free); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
259 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
260 jid = g_strdup_printf("%s@%s", room, server); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
261 g_hash_table_insert(js->chats, jid, chat); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
262 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
263 return chat; |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
264 } |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
265 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
266 JabberChat *jabber_join_chat(JabberStream *js, const char *room, |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
267 const char *server, const char *handle, |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
268 const char *password, GHashTable *data) |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
269 { |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
270 JabberChat *chat; |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
271 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
272 PurpleConnection *gc; |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
273 PurpleAccount *account; |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
274 PurpleStatus *status; |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
275 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 xmlnode *presence, *x; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 JabberBuddyState state; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 char *msg; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
279 int priority; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 |
28741
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
281 char *jid; |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
282 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
283 chat = jabber_chat_new(js, room, server, handle, password, data); |
28752
ef513141e960
jabber: Reduce these from assertions to checks.
Paul Aurich <paul@darkrain42.org>
parents:
28742
diff
changeset
|
284 if (chat == NULL) |
ef513141e960
jabber: Reduce these from assertions to checks.
Paul Aurich <paul@darkrain42.org>
parents:
28742
diff
changeset
|
285 return NULL; |
28741
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
286 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
287 gc = js->gc; |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
288 account = purple_connection_get_account(gc); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
289 status = purple_account_get_active_status(account); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
290 purple_status_to_jabber(status, &state, &msg, &priority); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
291 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
292 presence = jabber_presence_create_js(js, state, msg, priority); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
293 g_free(msg); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
294 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
295 jid = g_strdup_printf("%s@%s/%s", room, server, handle); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
296 xmlnode_set_attrib(presence, "to", jid); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
297 g_free(jid); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
298 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
299 x = xmlnode_new_child(presence, "x"); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
300 xmlnode_set_namespace(x, "http://jabber.org/protocol/muc"); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
301 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
302 if (password && *password) { |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
303 xmlnode *p = xmlnode_new_child(x, "password"); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
304 xmlnode_insert_data(p, password, -1); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
305 } |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
306 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
307 jabber_send(js, presence); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
308 xmlnode_free(presence); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
309 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
310 return chat; |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
311 } |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
312 |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
313 void jabber_chat_join(PurpleConnection *gc, GHashTable *data) |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
314 { |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
315 char *room, *server, *handle, *passwd; |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
316 JabberID *jid; |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
317 JabberStream *js = gc->proto_data; |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
318 char *tmp; |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
319 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
320 room = g_hash_table_lookup(data, "room"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
321 server = g_hash_table_lookup(data, "server"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
322 handle = g_hash_table_lookup(data, "handle"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
323 passwd = g_hash_table_lookup(data, "password"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
324 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
325 if(!room || !server) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
326 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
327 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
328 if(!handle) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
329 handle = js->user->node; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 if(!jabber_nodeprep_validate(room)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
332 char *buf = g_strdup_printf(_("%s is not a valid room name"), room); |
15823 | 333 purple_notify_error(gc, _("Invalid Room Name"), _("Invalid Room Name"), |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
334 buf); |
23105
591ef3693345
As discussed on the devel list, purple_serv_got_join_chat_failed() and the
Evan Schoenberg <evan.s@dreskin.net>
parents:
22891
diff
changeset
|
335 purple_serv_got_join_chat_failed(gc, data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
336 g_free(buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
337 return; |
27546
e90fa379fcec
Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents:
27014
diff
changeset
|
338 } else if(!jabber_domain_validate(server)) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
339 char *buf = g_strdup_printf(_("%s is not a valid server name"), server); |
15823 | 340 purple_notify_error(gc, _("Invalid Server Name"), |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
341 _("Invalid Server Name"), buf); |
23105
591ef3693345
As discussed on the devel list, purple_serv_got_join_chat_failed() and the
Evan Schoenberg <evan.s@dreskin.net>
parents:
22891
diff
changeset
|
342 purple_serv_got_join_chat_failed(gc, data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 g_free(buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
344 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
345 } else if(!jabber_resourceprep_validate(handle)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 char *buf = g_strdup_printf(_("%s is not a valid room handle"), handle); |
15823 | 347 purple_notify_error(gc, _("Invalid Room Handle"), |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
348 _("Invalid Room Handle"), buf); |
23105
591ef3693345
As discussed on the devel list, purple_serv_got_join_chat_failed() and the
Evan Schoenberg <evan.s@dreskin.net>
parents:
22891
diff
changeset
|
349 purple_serv_got_join_chat_failed(gc, data); |
22737
8c3f6126759c
Fix a small memory leak when failing to join a jabber conference
Mark Doliner <mark@kingant.net>
parents:
22644
diff
changeset
|
350 g_free(buf); |
8c3f6126759c
Fix a small memory leak when failing to join a jabber conference
Mark Doliner <mark@kingant.net>
parents:
22644
diff
changeset
|
351 return; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
352 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
353 |
28741
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
354 /* Normalize the room and server parameters */ |
23105
591ef3693345
As discussed on the devel list, purple_serv_got_join_chat_failed() and the
Evan Schoenberg <evan.s@dreskin.net>
parents:
22891
diff
changeset
|
355 tmp = g_strdup_printf("%s@%s", room, server); |
28741
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
356 jid = jabber_id_new(tmp); |
23105
591ef3693345
As discussed on the devel list, purple_serv_got_join_chat_failed() and the
Evan Schoenberg <evan.s@dreskin.net>
parents:
22891
diff
changeset
|
357 g_free(tmp); |
591ef3693345
As discussed on the devel list, purple_serv_got_join_chat_failed() and the
Evan Schoenberg <evan.s@dreskin.net>
parents:
22891
diff
changeset
|
358 |
28741
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
359 if (jid == NULL) { |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
360 /* TODO: Error message */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 |
28741
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
362 g_return_if_reached(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
363 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
364 |
28741
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
365 /* |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
366 * Now that we've done all that nice core-interface stuff, let's join |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
367 * this room! |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
368 */ |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
369 jabber_join_chat(js, jid->node, jid->domain, handle, passwd, data); |
724e77faee1a
jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents:
28659
diff
changeset
|
370 jabber_id_free(jid); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
371 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
372 |
15823 | 373 void jabber_chat_leave(PurpleConnection *gc, int id) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
374 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
375 JabberStream *js = gc->proto_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
376 JabberChat *chat = jabber_chat_find_by_id(js, id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
377 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
378 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
379 if(!chat) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 jabber_chat_part(chat, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 |
23262
5793bcea224c
Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
384 chat->left = TRUE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
386 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
387 void jabber_chat_destroy(JabberChat *chat) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
388 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
389 JabberStream *js = chat->js; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
390 char *room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
391 |
28756
08ffa726aea2
jabber: Remove useless jabber_normalize calls now that the data in the hash table
Paul Aurich <paul@darkrain42.org>
parents:
28752
diff
changeset
|
392 g_hash_table_remove(js->chats, room_jid); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
393 g_free(room_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
394 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 void jabber_chat_free(JabberChat *chat) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
397 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
398 if(chat->config_dialog_handle) |
15823 | 399 purple_request_close(chat->config_dialog_type, chat->config_dialog_handle); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
400 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 g_free(chat->room); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 g_free(chat->server); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
403 g_free(chat->handle); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
404 g_hash_table_destroy(chat->members); |
23108
568a0957e835
g_hash_table_ref() / g_hash_table_unref() were added in too recent a glib version per Mark. Copy data to chat->components rather than using those.
Evan Schoenberg <evan.s@dreskin.net>
parents:
23105
diff
changeset
|
405 g_hash_table_destroy(chat->components); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
406 g_free(chat); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
407 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
408 |
15823 | 409 gboolean jabber_chat_find_buddy(PurpleConversation *conv, const char *name) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 { |
15823 | 411 return purple_conv_chat_find_user(PURPLE_CONV_CHAT(conv), name); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
413 |
15823 | 414 char *jabber_chat_buddy_real_name(PurpleConnection *gc, int id, const char *who) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 JabberStream *js = gc->proto_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
417 JabberChat *chat; |
23358
1be3301fa2a3
Return the real JID (if available) from the xmpp get_cb_real_name function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23262
diff
changeset
|
418 JabberChatMember *jcm; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 chat = jabber_chat_find_by_id(js, id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
422 if(!chat) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
423 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
424 |
23358
1be3301fa2a3
Return the real JID (if available) from the xmpp get_cb_real_name function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23262
diff
changeset
|
425 jcm = g_hash_table_lookup(chat->members, who); |
1be3301fa2a3
Return the real JID (if available) from the xmpp get_cb_real_name function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23262
diff
changeset
|
426 if (jcm != NULL && jcm->jid) |
1be3301fa2a3
Return the real JID (if available) from the xmpp get_cb_real_name function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23262
diff
changeset
|
427 return g_strdup(jcm->jid); |
25443
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23988
diff
changeset
|
428 |
23358
1be3301fa2a3
Return the real JID (if available) from the xmpp get_cb_real_name function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23262
diff
changeset
|
429 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 return g_strdup_printf("%s@%s/%s", chat->room, chat->server, who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
432 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
433 static void jabber_chat_room_configure_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
434 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
435 JabberChat *chat = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
436 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
437 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
438 char *to = g_strdup_printf("%s@%s", chat->room, chat->server); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
439 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
440 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "http://jabber.org/protocol/muc#owner"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
441 xmlnode_set_attrib(iq->node, "to", to); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
442 g_free(to); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
443 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
444 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
445 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
446 xmlnode_insert_child(query, result); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
447 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
448 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
449 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
451 static void jabber_chat_room_configure_cb(JabberStream *js, const char *from, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
452 JabberIqType type, const char *id, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
453 xmlnode *packet, gpointer data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
454 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
455 xmlnode *query, *x; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
456 char *msg; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
457 JabberChat *chat; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
458 JabberID *jid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
459 |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
460 if (!from) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
461 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
462 |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
463 if (type == JABBER_IQ_RESULT) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
464 jid = jabber_id_new(from); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
465 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
466 if(!jid) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
467 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
468 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
469 chat = jabber_chat_find(js, jid->node, jid->domain); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 jabber_id_free(jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
471 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
472 if(!chat) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
473 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
474 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
475 if(!(query = xmlnode_get_child(packet, "query"))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
476 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
477 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
478 for(x = xmlnode_get_child(query, "x"); x; x = xmlnode_get_next_twin(x)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
479 const char *xmlns; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
480 if(!(xmlns = xmlnode_get_namespace(x))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
481 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
482 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
483 if(!strcmp(xmlns, "jabber:x:data")) { |
15823 | 484 chat->config_dialog_type = PURPLE_REQUEST_FIELDS; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
485 chat->config_dialog_handle = jabber_x_data_request(js, x, jabber_chat_room_configure_x_data_cb, chat); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
486 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
487 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
488 } |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
489 } else if (type == JABBER_IQ_ERROR) { |
20814
bde477ec6a71
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents:
19696
diff
changeset
|
490 char *msg = jabber_parse_error(js, packet, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
491 |
15823 | 492 purple_notify_error(js->gc, _("Configuration error"), _("Configuration error"), msg); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
493 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
494 if(msg) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
495 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
496 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
497 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
498 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
499 msg = g_strdup_printf("Unable to configure room %s", from); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
500 |
15823 | 501 purple_notify_info(js->gc, _("Unable to configure"), _("Unable to configure"), msg); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
502 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
503 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
504 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
505 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
506 void jabber_chat_request_room_configure(JabberChat *chat) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
507 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
508 char *room_jid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
509 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
510 if(!chat) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
511 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
512 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
513 chat->config_dialog_handle = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
514 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
515 if(!chat->muc) { |
15823 | 516 purple_notify_error(chat->js->gc, _("Room Configuration Error"), _("Room Configuration Error"), |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
517 _("This room is not capable of being configured")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
518 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
519 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
520 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
521 iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
522 "http://jabber.org/protocol/muc#owner"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
523 room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
524 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
525 xmlnode_set_attrib(iq->node, "to", room_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
526 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
527 jabber_iq_set_callback(iq, jabber_chat_room_configure_cb, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
528 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
529 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
530 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
531 g_free(room_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
532 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
533 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
534 void jabber_chat_create_instant_room(JabberChat *chat) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
535 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
536 xmlnode *query, *x; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
537 char *room_jid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
538 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 if(!chat) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
540 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
541 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
542 chat->config_dialog_handle = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
543 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
544 iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
545 "http://jabber.org/protocol/muc#owner"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
546 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
547 x = xmlnode_new_child(query, "x"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
548 room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
549 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
550 xmlnode_set_attrib(iq->node, "to", room_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
551 xmlnode_set_namespace(x, "jabber:x:data"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
552 xmlnode_set_attrib(x, "type", "submit"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
553 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
554 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
555 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
556 g_free(room_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
557 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
558 |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
559 static void |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
560 jabber_chat_register_x_data_result_cb(JabberStream *js, const char *from, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
561 JabberIqType type, const char *id, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
562 xmlnode *packet, gpointer data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
563 { |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
564 if (type == JABBER_IQ_ERROR) { |
20814
bde477ec6a71
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents:
19696
diff
changeset
|
565 char *msg = jabber_parse_error(js, packet, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
566 |
15823 | 567 purple_notify_error(js->gc, _("Registration error"), _("Registration error"), msg); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
568 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
569 if(msg) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
570 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
571 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
572 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
573 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
575 static void jabber_chat_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
576 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
577 JabberChat *chat = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
578 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
579 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
580 char *to = g_strdup_printf("%s@%s", chat->room, chat->server); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
581 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
582 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
583 xmlnode_set_attrib(iq->node, "to", to); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
584 g_free(to); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
585 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
586 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
587 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
588 xmlnode_insert_child(query, result); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
589 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
590 jabber_iq_set_callback(iq, jabber_chat_register_x_data_result_cb, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
591 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
592 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
593 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
594 |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
595 static void jabber_chat_register_cb(JabberStream *js, const char *from, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
596 JabberIqType type, const char *id, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
597 xmlnode *packet, gpointer data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
598 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
599 xmlnode *query, *x; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
600 char *msg; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
601 JabberChat *chat; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
602 JabberID *jid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
603 |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
604 if (!from) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
605 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
606 |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
607 if (type == JABBER_IQ_RESULT) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
608 jid = jabber_id_new(from); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
609 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
610 if(!jid) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
611 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
612 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
613 chat = jabber_chat_find(js, jid->node, jid->domain); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
614 jabber_id_free(jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
615 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
616 if(!chat) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
617 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
618 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
619 if(!(query = xmlnode_get_child(packet, "query"))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
620 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
621 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
622 for(x = xmlnode_get_child(query, "x"); x; x = xmlnode_get_next_twin(x)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
623 const char *xmlns; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
624 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
625 if(!(xmlns = xmlnode_get_namespace(x))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
626 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
627 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
628 if(!strcmp(xmlns, "jabber:x:data")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
629 jabber_x_data_request(js, x, jabber_chat_register_x_data_cb, chat); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
630 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
631 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
632 } |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
633 } else if (type == JABBER_IQ_ERROR) { |
20814
bde477ec6a71
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents:
19696
diff
changeset
|
634 char *msg = jabber_parse_error(js, packet, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
635 |
15823 | 636 purple_notify_error(js->gc, _("Registration error"), _("Registration error"), msg); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
637 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
638 if(msg) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
639 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
640 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
641 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
642 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
643 msg = g_strdup_printf("Unable to configure room %s", from); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
644 |
15823 | 645 purple_notify_info(js->gc, _("Unable to configure"), _("Unable to configure"), msg); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
646 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
647 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
648 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
649 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
650 void jabber_chat_register(JabberChat *chat) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
651 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
652 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
653 char *room_jid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
654 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
655 if(!chat) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
656 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
657 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
658 room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
659 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
660 iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, "jabber:iq:register"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
661 xmlnode_set_attrib(iq->node, "to", room_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
662 g_free(room_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
663 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
664 jabber_iq_set_callback(iq, jabber_chat_register_cb, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
665 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
666 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
667 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
668 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
669 /* merge this with the function below when we get everyone on the same page wrt /commands */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
670 void jabber_chat_change_topic(JabberChat *chat, const char *topic) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
671 { |
26766
06da00c70eae
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
672 JabberMessage *jm; |
06da00c70eae
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
673 |
06da00c70eae
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
674 jm = g_new0(JabberMessage, 1); |
06da00c70eae
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
675 jm->js = chat->js; |
06da00c70eae
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
676 jm->type = JABBER_MESSAGE_GROUPCHAT; |
06da00c70eae
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
677 jm->to = g_strdup_printf("%s@%s", chat->room, chat->server); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
678 |
26766
06da00c70eae
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
679 if (topic && *topic) |
28196
fdf1f64de3a0
Set XMPP chat topic when it contains a < followed by a character. Closes #5712.
Paul Aurich <paul@darkrain42.org>
parents:
27546
diff
changeset
|
680 jm->subject = g_strdup(topic); |
26766
06da00c70eae
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
681 else |
06da00c70eae
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
682 jm->subject = g_strdup(""); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
683 |
26766
06da00c70eae
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
684 jabber_message_send(jm); |
06da00c70eae
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
685 jabber_message_free(jm); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
686 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
687 |
15823 | 688 void jabber_chat_set_topic(PurpleConnection *gc, int id, const char *topic) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
689 { |
26766
06da00c70eae
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
690 JabberStream *js = purple_connection_get_protocol_data(gc); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
691 JabberChat *chat = jabber_chat_find_by_id(js, id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
692 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
693 if(!chat) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
694 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
695 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
696 jabber_chat_change_topic(chat, topic); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
697 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
698 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
699 |
28793
a335d1bab20e
jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents:
28775
diff
changeset
|
700 gboolean jabber_chat_change_nick(JabberChat *chat, const char *nick) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
701 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
702 xmlnode *presence; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
703 char *full_jid; |
28793
a335d1bab20e
jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents:
28775
diff
changeset
|
704 PurpleAccount *account; |
15823 | 705 PurpleStatus *status; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
706 JabberBuddyState state; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
707 char *msg; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
708 int priority; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
709 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
710 if(!chat->muc) { |
15823 | 711 purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
712 _("Nick changing not supported in non-MUC chatrooms"), |
15823 | 713 PURPLE_MESSAGE_SYSTEM, time(NULL)); |
28793
a335d1bab20e
jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents:
28775
diff
changeset
|
714 return FALSE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
715 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
716 |
28793
a335d1bab20e
jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents:
28775
diff
changeset
|
717 account = purple_connection_get_account(chat->js->gc); |
a335d1bab20e
jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents:
28775
diff
changeset
|
718 status = purple_account_get_active_status(account); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
719 |
15823 | 720 purple_status_to_jabber(status, &state, &msg, &priority); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
721 |
17563
95affacf6f82
Added the ability to define extensions to caps
Andreas Monitzer <pidgin@monitzer.com>
parents:
16962
diff
changeset
|
722 presence = jabber_presence_create_js(chat->js, state, msg, priority); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
723 full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, nick); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
724 xmlnode_set_attrib(presence, "to", full_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
725 g_free(full_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
726 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
727 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
728 jabber_send(chat->js, presence); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
729 xmlnode_free(presence); |
28793
a335d1bab20e
jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents:
28775
diff
changeset
|
730 |
a335d1bab20e
jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents:
28775
diff
changeset
|
731 return TRUE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
732 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
733 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
734 void jabber_chat_part(JabberChat *chat, const char *msg) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
735 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
736 char *room_jid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
737 xmlnode *presence; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
738 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
739 room_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
740 chat->handle); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
741 presence = xmlnode_new("presence"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
742 xmlnode_set_attrib(presence, "to", room_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
743 xmlnode_set_attrib(presence, "type", "unavailable"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
744 if(msg) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
745 xmlnode *status = xmlnode_new_child(presence, "status"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
746 xmlnode_insert_data(status, msg, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
747 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
748 jabber_send(chat->js, presence); |
25443
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23988
diff
changeset
|
749 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
750 xmlnode_free(presence); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
751 g_free(room_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
752 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
753 |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
754 static void roomlist_disco_result_cb(JabberStream *js, const char *from, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
755 JabberIqType type, const char *id, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
756 xmlnode *packet, gpointer data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
757 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
758 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
759 xmlnode *item; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
760 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
761 if(!js->roomlist) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
762 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
763 |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
764 if (type == JABBER_IQ_ERROR) { |
20814
bde477ec6a71
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents:
19696
diff
changeset
|
765 char *err = jabber_parse_error(js, packet, NULL); |
15823 | 766 purple_notify_error(js->gc, _("Error"), |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
767 _("Error retrieving room list"), err); |
15823 | 768 purple_roomlist_set_in_progress(js->roomlist, FALSE); |
769 purple_roomlist_unref(js->roomlist); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
770 js->roomlist = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
771 g_free(err); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
772 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
773 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
774 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
775 if(!(query = xmlnode_get_child(packet, "query"))) { |
20814
bde477ec6a71
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents:
19696
diff
changeset
|
776 char *err = jabber_parse_error(js, packet, NULL); |
15823 | 777 purple_notify_error(js->gc, _("Error"), |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
778 _("Error retrieving room list"), err); |
15823 | 779 purple_roomlist_set_in_progress(js->roomlist, FALSE); |
780 purple_roomlist_unref(js->roomlist); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
781 js->roomlist = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
782 g_free(err); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
783 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
784 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
785 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
786 for(item = xmlnode_get_child(query, "item"); item; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
787 item = xmlnode_get_next_twin(item)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
788 const char *name; |
15823 | 789 PurpleRoomlistRoom *room; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
790 JabberID *jid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
791 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
792 if(!(jid = jabber_id_new(xmlnode_get_attrib(item, "jid")))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
793 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
794 name = xmlnode_get_attrib(item, "name"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
795 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
796 |
15823 | 797 room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, jid->node, NULL); |
798 purple_roomlist_room_add_field(js->roomlist, room, jid->node); | |
799 purple_roomlist_room_add_field(js->roomlist, room, jid->domain); | |
800 purple_roomlist_room_add_field(js->roomlist, room, name ? name : ""); | |
801 purple_roomlist_room_add(js->roomlist, room); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
802 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
803 jabber_id_free(jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
804 } |
15823 | 805 purple_roomlist_set_in_progress(js->roomlist, FALSE); |
806 purple_roomlist_unref(js->roomlist); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
807 js->roomlist = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
808 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
809 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
810 static void roomlist_cancel_cb(JabberStream *js, const char *server) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
811 if(js->roomlist) { |
15823 | 812 purple_roomlist_set_in_progress(js->roomlist, FALSE); |
813 purple_roomlist_unref(js->roomlist); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
814 js->roomlist = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
815 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
816 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
817 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
818 static void roomlist_ok_cb(JabberStream *js, const char *server) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
819 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
820 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
821 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
822 if(!js->roomlist) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
823 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
824 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
825 if(!server || !*server) { |
15823 | 826 purple_notify_error(js->gc, _("Invalid Server"), _("Invalid Server"), NULL); |
28225
22ae131b8a0c
jabber: Fix "Invalid Server" breaking roomlist dialog. Closes #8143.
Paul Aurich <paul@darkrain42.org>
parents:
28196
diff
changeset
|
827 purple_roomlist_set_in_progress(js->roomlist, FALSE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
828 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
829 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
830 |
15823 | 831 purple_roomlist_set_in_progress(js->roomlist, TRUE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
832 |
29031
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28793
diff
changeset
|
833 iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_ITEMS); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
834 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
835 xmlnode_set_attrib(iq->node, "to", server); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
836 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
837 jabber_iq_set_callback(iq, roomlist_disco_result_cb, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
838 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
839 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
840 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
841 |
15823 | 842 char *jabber_roomlist_room_serialize(PurpleRoomlistRoom *room) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
843 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
844 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
845 return g_strdup_printf("%s@%s", (char*)room->fields->data, (char*)room->fields->next->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
846 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
847 |
15823 | 848 PurpleRoomlist *jabber_roomlist_get_list(PurpleConnection *gc) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
849 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
850 JabberStream *js = gc->proto_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
851 GList *fields = NULL; |
15823 | 852 PurpleRoomlistField *f; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
853 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
854 if(js->roomlist) |
15823 | 855 purple_roomlist_unref(js->roomlist); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
856 |
15823 | 857 js->roomlist = purple_roomlist_new(purple_connection_get_account(js->gc)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
858 |
15823 | 859 f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "", "room", TRUE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
860 fields = g_list_append(fields, f); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
861 |
15823 | 862 f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "", "server", TRUE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
863 fields = g_list_append(fields, f); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
864 |
15823 | 865 f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, _("Description"), "description", FALSE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
866 fields = g_list_append(fields, f); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
867 |
15823 | 868 purple_roomlist_set_fields(js->roomlist, fields); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
869 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
870 |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
871 purple_request_input(gc, _("Enter a Conference Server"), _("Enter a Conference Server"), |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
872 _("Select a conference server to query"), |
16962
88444e60ea95
Removes 'jabber.org' defaults from XMPP. I think we had agreed this was a good idea.
Sean Egan <seanegan@gmail.com>
parents:
16442
diff
changeset
|
873 js->chat_servers ? js->chat_servers->data : NULL, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
874 FALSE, FALSE, NULL, |
15823 | 875 _("Find Rooms"), PURPLE_CALLBACK(roomlist_ok_cb), |
16442
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
876 _("Cancel"), PURPLE_CALLBACK(roomlist_cancel_cb), |
25443
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23988
diff
changeset
|
877 purple_connection_get_account(gc), NULL, NULL, |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
878 js); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
879 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
880 return js->roomlist; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
881 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
882 |
15823 | 883 void jabber_roomlist_cancel(PurpleRoomlist *list) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
884 { |
15823 | 885 PurpleConnection *gc; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
886 JabberStream *js; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
887 |
15823 | 888 gc = purple_account_get_connection(list->account); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
889 js = gc->proto_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
890 |
15823 | 891 purple_roomlist_set_in_progress(list, FALSE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
892 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
893 if (js->roomlist == list) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
894 js->roomlist = NULL; |
15823 | 895 purple_roomlist_unref(list); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
896 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
897 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
898 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
899 void jabber_chat_member_free(JabberChatMember *jcm) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
900 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
901 g_free(jcm->handle); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
902 g_free(jcm->jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
903 g_free(jcm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
904 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
905 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
906 void jabber_chat_track_handle(JabberChat *chat, const char *handle, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
907 const char *jid, const char *affiliation, const char *role) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
908 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
909 JabberChatMember *jcm = g_new0(JabberChatMember, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
910 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
911 jcm->handle = g_strdup(handle); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
912 jcm->jid = g_strdup(jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
913 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
914 g_hash_table_replace(chat->members, jcm->handle, jcm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
915 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
916 /* XXX: keep track of role and affiliation */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
917 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
918 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
919 void jabber_chat_remove_handle(JabberChat *chat, const char *handle) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
920 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
921 g_hash_table_remove(chat->members, handle); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
922 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
923 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
924 gboolean jabber_chat_ban_user(JabberChat *chat, const char *who, const char *why) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
925 { |
19676
e68694150fd8
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents:
16962
diff
changeset
|
926 JabberChatMember *jcm; |
e68694150fd8
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents:
16962
diff
changeset
|
927 const char *jid; |
e68694150fd8
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents:
16962
diff
changeset
|
928 char *to; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
929 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
930 xmlnode *query, *item, *reason; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
931 |
19676
e68694150fd8
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents:
16962
diff
changeset
|
932 jcm = g_hash_table_lookup(chat->members, who); |
e68694150fd8
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents:
16962
diff
changeset
|
933 if (jcm && jcm->jid) |
e68694150fd8
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents:
16962
diff
changeset
|
934 jid = jcm->jid; |
29111
4ab6f0479bc5
strchr() is safe when searching for an ASCII character in UTF8 strings.
Paul Aurich <paul@darkrain42.org>
parents:
29031
diff
changeset
|
935 else if (strchr(who, '@') != NULL) |
19676
e68694150fd8
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents:
16962
diff
changeset
|
936 jid = who; |
e68694150fd8
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents:
16962
diff
changeset
|
937 else |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
938 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
939 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
940 iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
941 "http://jabber.org/protocol/muc#admin"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
942 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
943 to = g_strdup_printf("%s@%s", chat->room, chat->server); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
944 xmlnode_set_attrib(iq->node, "to", to); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
945 g_free(to); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
946 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
947 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
948 item = xmlnode_new_child(query, "item"); |
19676
e68694150fd8
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents:
16962
diff
changeset
|
949 xmlnode_set_attrib(item, "jid", jid); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
950 xmlnode_set_attrib(item, "affiliation", "outcast"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
951 if(why) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
952 reason = xmlnode_new_child(item, "reason"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
953 xmlnode_insert_data(reason, why, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
954 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
955 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
956 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
957 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
958 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
959 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
960 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
961 gboolean jabber_chat_affiliate_user(JabberChat *chat, const char *who, const char *affiliation) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
962 { |
19676
e68694150fd8
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents:
16962
diff
changeset
|
963 JabberChatMember *jcm; |
e68694150fd8
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents:
16962
diff
changeset
|
964 const char *jid; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
965 char *to; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
966 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
967 xmlnode *query, *item; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
968 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
969 jcm = g_hash_table_lookup(chat->members, who); |
19676
e68694150fd8
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents:
16962
diff
changeset
|
970 if (jcm && jcm->jid) |
e68694150fd8
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents:
16962
diff
changeset
|
971 jid = jcm->jid; |
29111
4ab6f0479bc5
strchr() is safe when searching for an ASCII character in UTF8 strings.
Paul Aurich <paul@darkrain42.org>
parents:
29031
diff
changeset
|
972 else if (strchr(who, '@') != NULL) |
19676
e68694150fd8
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents:
16962
diff
changeset
|
973 jid = who; |
e68694150fd8
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents:
16962
diff
changeset
|
974 else |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
975 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
976 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
977 iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
978 "http://jabber.org/protocol/muc#admin"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
979 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
980 to = g_strdup_printf("%s@%s", chat->room, chat->server); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
981 xmlnode_set_attrib(iq->node, "to", to); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
982 g_free(to); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
983 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
984 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
985 item = xmlnode_new_child(query, "item"); |
19676
e68694150fd8
Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents:
16962
diff
changeset
|
986 xmlnode_set_attrib(item, "jid", jid); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
987 xmlnode_set_attrib(item, "affiliation", affiliation); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
988 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
989 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
990 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
991 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
992 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
993 |
26884
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
994 static void |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
995 jabber_chat_affiliation_list_cb(JabberStream *js, const char *from, |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
996 JabberIqType type, const char *id, |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
997 xmlnode *packet, gpointer data) |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
998 { |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
999 JabberChat *chat; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1000 xmlnode *query, *item; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1001 int chat_id = GPOINTER_TO_INT(data); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1002 GString *buf; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1003 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1004 if(!(chat = jabber_chat_find_by_id(js, chat_id))) |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1005 return; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1006 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1007 if (type == JABBER_IQ_ERROR) |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1008 return; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1009 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1010 if(!(query = xmlnode_get_child(packet, "query"))) |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1011 return; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1012 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1013 buf = g_string_new(_("Affiliations:")); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1014 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1015 item = xmlnode_get_child(query, "item"); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1016 if (item) { |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1017 for( ; item; item = xmlnode_get_next_twin(item)) { |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1018 const char *jid = xmlnode_get_attrib(item, "jid"); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1019 const char *affiliation = xmlnode_get_attrib(item, "affiliation"); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1020 if (jid && affiliation) |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1021 g_string_append_printf(buf, "\n%s %s", jid, affiliation); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1022 } |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1023 } else { |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1024 buf = g_string_append_c(buf, '\n'); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1025 buf = g_string_append_len(buf, _("No users found"), -1); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1026 } |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1027 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1028 purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "", buf->str, |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1029 PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL)); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1030 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1031 g_string_free(buf, TRUE); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1032 } |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1033 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1034 gboolean jabber_chat_affiliation_list(JabberChat *chat, const char *affiliation) |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1035 { |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1036 JabberIq *iq; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1037 char *room_jid; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1038 xmlnode *query, *item; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1039 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1040 iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1041 "http://jabber.org/protocol/muc#admin"); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1042 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1043 room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1044 xmlnode_set_attrib(iq->node, "to", room_jid); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1045 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1046 query = xmlnode_get_child(iq->node, "query"); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1047 item = xmlnode_new_child(query, "item"); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1048 xmlnode_set_attrib(item, "affiliation", affiliation); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1049 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1050 jabber_iq_set_callback(iq, jabber_chat_affiliation_list_cb, GINT_TO_POINTER(chat->id)); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1051 jabber_iq_send(iq); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1052 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1053 return TRUE; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1054 } |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1055 |
29464
c8b407fec879
jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
Paul Aurich <paul@darkrain42.org>
parents:
29111
diff
changeset
|
1056 gboolean jabber_chat_role_user(JabberChat *chat, const char *who, |
c8b407fec879
jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
Paul Aurich <paul@darkrain42.org>
parents:
29111
diff
changeset
|
1057 const char *role, const char *why) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1058 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1059 char *to; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1060 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1061 xmlnode *query, *item; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1062 JabberChatMember *jcm; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1063 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1064 jcm = g_hash_table_lookup(chat->members, who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1065 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1066 if (!jcm || !jcm->handle) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1067 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1068 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1069 iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1070 "http://jabber.org/protocol/muc#admin"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1071 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1072 to = g_strdup_printf("%s@%s", chat->room, chat->server); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1073 xmlnode_set_attrib(iq->node, "to", to); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1074 g_free(to); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1075 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1076 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1077 item = xmlnode_new_child(query, "item"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1078 xmlnode_set_attrib(item, "nick", jcm->handle); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1079 xmlnode_set_attrib(item, "role", role); |
29464
c8b407fec879
jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
Paul Aurich <paul@darkrain42.org>
parents:
29111
diff
changeset
|
1080 if (why) { |
c8b407fec879
jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
Paul Aurich <paul@darkrain42.org>
parents:
29111
diff
changeset
|
1081 xmlnode *reason = xmlnode_new_child(item, "reason"); |
c8b407fec879
jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
Paul Aurich <paul@darkrain42.org>
parents:
29111
diff
changeset
|
1082 xmlnode_insert_data(reason, why, -1); |
c8b407fec879
jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
Paul Aurich <paul@darkrain42.org>
parents:
29111
diff
changeset
|
1083 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1084 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1085 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1086 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1087 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1088 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1089 |
26884
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1090 static void jabber_chat_role_list_cb(JabberStream *js, const char *from, |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1091 JabberIqType type, const char *id, |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1092 xmlnode *packet, gpointer data) |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1093 { |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1094 JabberChat *chat; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1095 xmlnode *query, *item; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1096 int chat_id = GPOINTER_TO_INT(data); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1097 GString *buf; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1098 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1099 if(!(chat = jabber_chat_find_by_id(js, chat_id))) |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1100 return; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1101 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1102 if (type == JABBER_IQ_ERROR) |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1103 return; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1104 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1105 if(!(query = xmlnode_get_child(packet, "query"))) |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1106 return; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1107 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1108 buf = g_string_new(_("Roles:")); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1109 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1110 item = xmlnode_get_child(query, "item"); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1111 if (item) { |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1112 for( ; item; item = xmlnode_get_next_twin(item)) { |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1113 const char *jid = xmlnode_get_attrib(item, "jid"); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1114 const char *role = xmlnode_get_attrib(item, "role"); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1115 if (jid && role) |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1116 g_string_append_printf(buf, "\n%s %s", jid, role); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1117 } |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1118 } else { |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1119 buf = g_string_append_c(buf, '\n'); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1120 buf = g_string_append_len(buf, _("No users found"), -1); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1121 } |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1122 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1123 purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "", buf->str, |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1124 PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL)); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1125 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1126 g_string_free(buf, TRUE); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1127 } |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1128 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1129 gboolean jabber_chat_role_list(JabberChat *chat, const char *role) |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1130 { |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1131 JabberIq *iq; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1132 char *room_jid; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1133 xmlnode *query, *item; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1134 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1135 iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1136 "http://jabber.org/protocol/muc#admin"); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1137 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1138 room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1139 xmlnode_set_attrib(iq->node, "to", room_jid); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1140 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1141 query = xmlnode_get_child(iq->node, "query"); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1142 item = xmlnode_new_child(query, "item"); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1143 xmlnode_set_attrib(item, "role", role); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1144 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1145 jabber_iq_set_callback(iq, jabber_chat_role_list_cb, GINT_TO_POINTER(chat->id)); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1146 jabber_iq_send(iq); |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1147 |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1148 return TRUE; |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1149 } |
af2b87aa82ee
Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents:
26766
diff
changeset
|
1150 |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
1151 static void jabber_chat_disco_traffic_cb(JabberStream *js, const char *from, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
1152 JabberIqType type, const char *id, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
1153 xmlnode *packet, gpointer data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1154 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1155 JabberChat *chat; |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
1156 #if 0 |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
1157 xmlnode *query, *x; |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
1158 #endif |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
1159 int chat_id = GPOINTER_TO_INT(data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1160 |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
1161 if(!(chat = jabber_chat_find_by_id(js, chat_id))) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1162 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1163 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1164 /* defaults, in case the conference server doesn't |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1165 * support this request */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1166 chat->xhtml = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1167 |
20333
53afc5cce143
applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents:
19696
diff
changeset
|
1168 /* disabling this until more MUC servers support |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
1169 * announcing this */ |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
1170 #if 0 |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
1171 if (type == JABBER_IQ_ERROR) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1172 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1173 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1174 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1175 if(!(query = xmlnode_get_child(packet, "query"))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1176 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1177 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1178 chat->xhtml = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1179 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1180 for(x = xmlnode_get_child(query, "feature"); x; x = xmlnode_get_next_twin(x)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1181 const char *var = xmlnode_get_attrib(x, "var"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1182 |
29031
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28793
diff
changeset
|
1183 if(var && !strcmp(var, NS_XHTML_IM)) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1184 chat->xhtml = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1185 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1186 } |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
1187 #endif |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1188 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1189 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1190 void jabber_chat_disco_traffic(JabberChat *chat) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1191 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1192 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1193 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1194 char *room_jid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1195 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1196 room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1197 |
29031
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28793
diff
changeset
|
1198 iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, NS_DISCO_INFO); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1199 |
25443
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23988
diff
changeset
|
1200 xmlnode_set_attrib(iq->node, "to", room_jid); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1201 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1202 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1203 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1204 xmlnode_set_attrib(query, "node", "http://jabber.org/protocol/muc#traffic"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1205 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1206 jabber_iq_set_callback(iq, jabber_chat_disco_traffic_cb, GINT_TO_POINTER(chat->id)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1207 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1208 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1209 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1210 g_free(room_jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1211 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1212 |
26956
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1213 typedef struct { |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1214 const gchar *cap; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1215 gboolean *all_support; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1216 JabberBuddy *jb; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1217 } JabberChatCapsData; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1218 |
26956
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1219 static void |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1220 jabber_chat_all_participants_have_capability_foreach(gpointer key, |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1221 gpointer value, |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1222 gpointer user_data) |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1223 { |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1224 const gchar *cap = ((JabberChatCapsData *) user_data)->cap; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1225 gboolean *all_support = ((JabberChatCapsData *) user_data)->all_support; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1226 JabberBuddy *jb = ((JabberChatCapsData *) user_data)->jb; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1227 JabberChatMember *member = (JabberChatMember *) value; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1228 const gchar *resource = member->handle; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1229 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1230 |
26956
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1231 if (jbr) { |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1232 *all_support &= jabber_resource_has_capability(jbr, cap); |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1233 } else { |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1234 *all_support = FALSE; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1235 } |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1236 } |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1237 |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1238 gboolean |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1239 jabber_chat_all_participants_have_capability(const JabberChat *chat, |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1240 const gchar *cap) |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1241 { |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1242 gchar *chat_jid = NULL; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1243 JabberBuddy *jb = NULL; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1244 gboolean all_support = TRUE; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1245 JabberChatCapsData data; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1246 |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1247 chat_jid = g_strdup_printf("%s@%s", chat->room, chat->server); |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1248 jb = jabber_buddy_find(chat->js, chat_jid, FALSE); |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1249 |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1250 if (jb) { |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1251 data.cap = cap; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1252 data.all_support = &all_support; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1253 data.jb = jb; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1254 |
27014
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26956
diff
changeset
|
1255 g_hash_table_foreach(chat->members, |
26956
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1256 jabber_chat_all_participants_have_capability_foreach, &data); |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1257 } else { |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1258 all_support = FALSE; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1259 } |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1260 g_free(chat_jid); |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1261 return all_support; |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1262 } |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1263 |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1264 guint |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1265 jabber_chat_get_num_participants(const JabberChat *chat) |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1266 { |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1267 return g_hash_table_size(chat->members); |
eeee4309d3d8
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents:
26884
diff
changeset
|
1268 } |