annotate libpurple/protocols/jabber/chat.c @ 32514:c6943fd38d44

Remove deprecated and unused PurplePluginProtocolInfo.get_cb_away.
author andrew.victor@mxit.com
date Mon, 05 Sep 2011 21:11:07 +0000
parents 3caef255ad47
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
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;
32456
3caef255ad47 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents: 32393
diff changeset
73 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
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
143 PurpleAccount *account = purple_conversation_get_account(conv);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
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;
32456
3caef255ad47 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents: 32393
diff changeset
149 js = purple_connection_get_protocol_data(gc);
22644
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
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 {
32456
3caef255ad47 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents: 32393
diff changeset
157 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
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;
31679
ba6a4a0f8f50 jabber: Treat the presence storm on joining a room as not new arrivals.
thijs@adium.im
parents: 30745
diff changeset
240 chat->joined = 0;
28741
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
241
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
242 chat->room = g_strdup(room);
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
243 chat->server = g_strdup(server);
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
244 chat->handle = g_strdup(handle);
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
245
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
246 /* Copy the data hash table to chat->components */
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
247 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
248 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
249 if (data == NULL) {
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("handle"), g_strdup(handle));
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("room"), g_strdup(room));
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("server"), g_strdup(server));
63dc67b32577 jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents: 28741
diff changeset
253 /* 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
254 } else {
63dc67b32577 jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents: 28741
diff changeset
255 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
256 }
28741
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
257
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
258 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
259 (GDestroyNotify)jabber_chat_member_free);
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
260
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
261 jid = g_strdup_printf("%s@%s", room, server);
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
262 g_hash_table_insert(js->chats, jid, chat);
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
263
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
264 return chat;
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
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
267 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
268 const char *server, const char *handle,
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
269 const char *password, GHashTable *data)
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
270 {
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
271 JabberChat *chat;
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
272
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
273 PurpleConnection *gc;
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
274 PurpleAccount *account;
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
275 PurpleStatus *status;
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
276
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 xmlnode *presence, *x;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 JabberBuddyState state;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 char *msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 int priority;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281
28741
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
282 char *jid;
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
283
31757
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
284 char *history_maxchars;
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
285 char *history_maxstanzas;
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
286 char *history_seconds;
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
287 char *history_since;
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
288
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
289 struct tm history_since_datetime;
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
290 const char *history_since_string = NULL;
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
291
28741
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
292 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
293 if (chat == NULL)
ef513141e960 jabber: Reduce these from assertions to checks.
Paul Aurich <paul@darkrain42.org>
parents: 28742
diff changeset
294 return NULL;
28741
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
295
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
296 gc = js->gc;
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
297 account = purple_connection_get_account(gc);
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
298 status = purple_account_get_active_status(account);
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
299 purple_status_to_jabber(status, &state, &msg, &priority);
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
300
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
301 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
302 g_free(msg);
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
303
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
304 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
305 xmlnode_set_attrib(presence, "to", jid);
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
306 g_free(jid);
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
307
31757
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
308 history_maxchars = g_hash_table_lookup(data, "history_maxchars");
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
309 history_maxstanzas = g_hash_table_lookup(data, "history_maxstanzas");
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
310 history_seconds = g_hash_table_lookup(data, "history_seconds");
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
311 history_since = g_hash_table_lookup(data, "history_since");
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
312
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
313 if (history_since) {
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
314 if (purple_str_to_time(history_since, TRUE, &history_since_datetime, NULL, NULL) != 0) {
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
315 history_since_string = purple_utf8_strftime("%Y-%m-%dT%H:%M:%SZ", &history_since_datetime);
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
316 } else {
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
317 history_since_string = NULL;
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
318
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
319 purple_debug_error("jabber", "Invalid date format for history_since"
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
320 " while requesting history: %s", history_since);
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
321 }
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
322 }
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
323
28741
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
324 x = xmlnode_new_child(presence, "x");
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
325 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
326
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
327 if (password && *password) {
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
328 xmlnode *p = xmlnode_new_child(x, "password");
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
329 xmlnode_insert_data(p, password, -1);
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
330 }
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
331
31757
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
332 if ((history_maxchars && *history_maxchars)
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
333 || (history_maxstanzas && *history_maxstanzas)
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
334 || (history_seconds && *history_seconds)
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
335 || (history_since_string && *history_since_string)) {
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
336
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
337 xmlnode *history = xmlnode_new_child(x, "history");
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
338
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
339 if (history_maxchars && *history_maxchars) {
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
340 xmlnode_set_attrib(history, "maxchars", history_maxchars);
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
341 }
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
342 if (history_maxstanzas && *history_maxstanzas) {
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
343 xmlnode_set_attrib(history, "maxstanzas", history_maxstanzas);
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
344 }
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
345 if (history_seconds && *history_seconds) {
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
346 xmlnode_set_attrib(history, "seconds", history_seconds);
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
347 }
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
348 if (history_since_string && *history_since_string) {
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
349 xmlnode_set_attrib(history, "since", history_since_string);
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
350 }
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
351 }
f178a7df417a jabber: Support for requesting limited history when joining a MUC.
Paul Aurich <paul@darkrain42.org>
parents: 31679
diff changeset
352
28741
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
353 jabber_send(js, presence);
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
354 xmlnode_free(presence);
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
355
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
356 return chat;
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
357 }
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
358
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
359 void jabber_chat_join(PurpleConnection *gc, GHashTable *data)
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
360 {
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
361 char *room, *server, *handle, *passwd;
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
362 JabberID *jid;
32456
3caef255ad47 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents: 32393
diff changeset
363 JabberStream *js = purple_connection_get_protocol_data(gc);
28741
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
364 char *tmp;
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
365
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 room = g_hash_table_lookup(data, "room");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 server = g_hash_table_lookup(data, "server");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368 handle = g_hash_table_lookup(data, "handle");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 passwd = g_hash_table_lookup(data, "password");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 if(!room || !server)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 if(!handle)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 handle = js->user->node;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377 if(!jabber_nodeprep_validate(room)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 char *buf = g_strdup_printf(_("%s is not a valid room name"), room);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
379 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
380 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
381 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
382 g_free(buf);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383 return;
27546
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27014
diff changeset
384 } else if(!jabber_domain_validate(server)) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 char *buf = g_strdup_printf(_("%s is not a valid server name"), server);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
386 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
387 _("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
388 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
389 g_free(buf);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 } else if(!jabber_resourceprep_validate(handle)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 char *buf = g_strdup_printf(_("%s is not a valid room handle"), handle);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
393 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
394 _("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
395 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
396 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
397 return;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399
28741
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
400 /* 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
401 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
402 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
403 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
404
28741
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
405 if (jid == NULL) {
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
406 /* TODO: Error message */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407
28741
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
408 g_return_if_reached();
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410
28741
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
411 /*
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
412 * 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
413 * this room!
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
414 */
724e77faee1a jabber: Refactor the chat-joining code
Paul Aurich <paul@darkrain42.org>
parents: 28659
diff changeset
415 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
416 jabber_id_free(jid);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
419 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
420 {
32456
3caef255ad47 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents: 32393
diff changeset
421 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
422 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
423
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 if(!chat)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427 jabber_chat_part(chat, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428
23262
5793bcea224c Fix the chat-room rejoining bug where the list appears empty.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23161
diff changeset
429 chat->left = TRUE;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 }
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 void jabber_chat_destroy(JabberChat *chat)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434 JabberStream *js = chat->js;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435 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
436
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
437 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
438 g_free(room_jid);
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441 void jabber_chat_free(JabberChat *chat)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
443 if(chat->config_dialog_handle)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
444 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
445
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446 g_free(chat->room);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447 g_free(chat->server);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 g_free(chat->handle);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 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
450 g_hash_table_destroy(chat->components);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451 g_free(chat);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
454 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
455 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
456 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
457 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
459 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
460 {
32456
3caef255ad47 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents: 32393
diff changeset
461 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
462 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
463 JabberChatMember *jcm;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465 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
466
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
467 if(!chat)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469
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
470 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
471 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
472 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
473
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
474
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 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
476 }
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 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
479 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480 JabberChat *chat = data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 xmlnode *query;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483 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
484
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485 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
486 xmlnode_set_attrib(iq->node, "to", to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487 g_free(to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491 xmlnode_insert_child(query, result);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495
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
496 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
497 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
498 xmlnode *packet, gpointer data)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
500 xmlnode *query, *x;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 char *msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502 JabberChat *chat;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 JabberID *jid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504
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
505 if (!from)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507
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
508 if (type == JABBER_IQ_RESULT) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 jid = jabber_id_new(from);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511 if(!jid)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514 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
515 jabber_id_free(jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517 if(!chat)
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 if(!(query = xmlnode_get_child(packet, "query")))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
521 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523 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
524 const char *xmlns;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525 if(!(xmlns = xmlnode_get_namespace(x)))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 if(!strcmp(xmlns, "jabber:x:data")) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
529 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
530 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
531 return;
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 }
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
534 } 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
535 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
536
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
537 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
538
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539 if(msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
541 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
542 }
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 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
545
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
546 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
547 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551 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
552 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553 char *room_jid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
554
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555 if(!chat)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556 return;
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 chat->config_dialog_handle = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560 if(!chat->muc) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
561 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
562 _("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
563 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 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
567 "http://jabber.org/protocol/muc#owner");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568 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
569
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
570 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
571
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
572 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
573
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576 g_free(room_jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579 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
580 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581 xmlnode *query, *x;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582 char *room_jid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
584 if(!chat)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
585 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587 chat->config_dialog_handle = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589 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
590 "http://jabber.org/protocol/muc#owner");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
591 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
592 x = xmlnode_new_child(query, "x");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593 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
594
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595 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
596 xmlnode_set_namespace(x, "jabber:x:data");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
597 xmlnode_set_attrib(x, "type", "submit");
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 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
600
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
601 g_free(room_jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
602 }
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 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
605 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
606 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
607 xmlnode *packet, gpointer data)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608 {
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
609 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
610 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
611
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
612 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
613
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
614 if(msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
615 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
616 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
617 }
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
620 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
621 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
622 JabberChat *chat = data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
623 xmlnode *query;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
625 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
626
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
627 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
628 xmlnode_set_attrib(iq->node, "to", to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
629 g_free(to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
630
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
631 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
632
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
633 xmlnode_insert_child(query, result);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
634
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
635 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
636
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
637 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
638 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
639
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
640 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
641 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
642 xmlnode *packet, gpointer data)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
643 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
644 xmlnode *query, *x;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645 char *msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
646 JabberChat *chat;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
647 JabberID *jid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
648
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
649 if (!from)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
650 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
651
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
652 if (type == JABBER_IQ_RESULT) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653 jid = jabber_id_new(from);
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(!jid)
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 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
659 jabber_id_free(jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
660
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
661 if(!chat)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
662 return;
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 if(!(query = xmlnode_get_child(packet, "query")))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
665 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
666
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667 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
668 const char *xmlns;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
669
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
670 if(!(xmlns = xmlnode_get_namespace(x)))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
671 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
672
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
673 if(!strcmp(xmlns, "jabber:x:data")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
674 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
675 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
676 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
677 }
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
678 } 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
679 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
680
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
681 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
682
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
683 if(msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
684 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
685 return;
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
688 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
689
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
690 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
691 g_free(msg);
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 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
694
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
695 void jabber_chat_register(JabberChat *chat)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
696 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
697 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
698 char *room_jid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
699
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
700 if(!chat)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
701 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
702
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
703 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
704
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
705 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
706 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
707 g_free(room_jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
708
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
709 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
710
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
711 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
712 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
713
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
714 /* 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
715 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
716 {
26766
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
717 JabberMessage *jm;
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
718
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
719 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
720 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
721 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
722 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
723
26766
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
724 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
725 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
726 else
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
727 jm->subject = g_strdup("");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
728
26766
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
729 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
730 jabber_message_free(jm);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
731 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
732
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
733 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
734 {
26766
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
735 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
736 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
737
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
738 if(!chat)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
739 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
740
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
741 jabber_chat_change_topic(chat, topic);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
742 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
743
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
744
28793
a335d1bab20e jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents: 28775
diff changeset
745 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
746 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
747 xmlnode *presence;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
748 char *full_jid;
28793
a335d1bab20e jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents: 28775
diff changeset
749 PurpleAccount *account;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
750 PurpleStatus *status;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
751 JabberBuddyState state;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
752 char *msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
753 int priority;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
754
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
755 if(!chat->muc) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
756 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
757 _("Nick changing not supported in non-MUC chatrooms"),
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
758 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
759 return FALSE;
15374
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
28793
a335d1bab20e jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents: 28775
diff changeset
762 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
763 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
764
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
765 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
766
17563
95affacf6f82 Added the ability to define extensions to caps
Andreas Monitzer <pidgin@monitzer.com>
parents: 16962
diff changeset
767 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
768 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
769 xmlnode_set_attrib(presence, "to", full_jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
770 g_free(full_jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
771 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
772
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
773 jabber_send(chat->js, presence);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
774 xmlnode_free(presence);
28793
a335d1bab20e jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents: 28775
diff changeset
775
a335d1bab20e jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
Paul Aurich <paul@darkrain42.org>
parents: 28775
diff changeset
776 return TRUE;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
777 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
778
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
779 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
780 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
781 char *room_jid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
782 xmlnode *presence;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
783
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
784 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
785 chat->handle);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
786 presence = xmlnode_new("presence");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
787 xmlnode_set_attrib(presence, "to", room_jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
788 xmlnode_set_attrib(presence, "type", "unavailable");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
789 if(msg) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
790 xmlnode *status = xmlnode_new_child(presence, "status");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
791 xmlnode_insert_data(status, msg, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
792 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
793 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
794
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
795 xmlnode_free(presence);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
796 g_free(room_jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
798
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
799 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
800 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
801 xmlnode *packet, gpointer data)
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 xmlnode *query;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
804 xmlnode *item;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
805
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
806 if(!js->roomlist)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
807 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
808
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
809 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
810 char *err = jabber_parse_error(js, packet, NULL);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
811 purple_notify_error(js->gc, _("Error"),
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
812 _("Error retrieving room list"), err);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
813 purple_roomlist_set_in_progress(js->roomlist, FALSE);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
814 purple_roomlist_unref(js->roomlist);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
815 js->roomlist = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
816 g_free(err);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
817 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
818 }
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 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
821 char *err = jabber_parse_error(js, packet, NULL);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
822 purple_notify_error(js->gc, _("Error"),
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
823 _("Error retrieving room list"), err);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
824 purple_roomlist_set_in_progress(js->roomlist, FALSE);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
825 purple_roomlist_unref(js->roomlist);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
826 js->roomlist = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
827 g_free(err);
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
831 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
832 item = xmlnode_get_next_twin(item)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
833 const char *name;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
834 PurpleRoomlistRoom *room;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
835 JabberID *jid;
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 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
838 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
839 name = xmlnode_get_attrib(item, "name");
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
842 room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, jid->node, NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
843 purple_roomlist_room_add_field(js->roomlist, room, jid->node);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
844 purple_roomlist_room_add_field(js->roomlist, room, jid->domain);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
845 purple_roomlist_room_add_field(js->roomlist, room, name ? name : "");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
846 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
847
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
848 jabber_id_free(jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
849 }
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
850 purple_roomlist_set_in_progress(js->roomlist, FALSE);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
851 purple_roomlist_unref(js->roomlist);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
852 js->roomlist = NULL;
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855 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
856 if(js->roomlist) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
857 purple_roomlist_set_in_progress(js->roomlist, FALSE);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
858 purple_roomlist_unref(js->roomlist);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
859 js->roomlist = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
860 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
861 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
862
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
863 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
864 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
865 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
866
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
867 if(!js->roomlist)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
868 return;
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 if(!server || !*server) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
871 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
872 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
873 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
874 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
875
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
876 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
877
29031
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28793
diff changeset
878 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
879
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
880 xmlnode_set_attrib(iq->node, "to", server);
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 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
883
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
884 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
885 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
886
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
887 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
888 {
32393
5dafa68c8eb0 Some struct hiding. What a pain.
Mark Doliner <mark@kingant.net>
parents: 31757
diff changeset
889 GList *fields = purple_roomlist_room_get_fields(room);
5dafa68c8eb0 Some struct hiding. What a pain.
Mark Doliner <mark@kingant.net>
parents: 31757
diff changeset
890 return g_strdup_printf("%s@%s", (char*)fields->data, (char*)fields->next->data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
891 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
892
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
893 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
894 {
32456
3caef255ad47 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents: 32393
diff changeset
895 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
896 GList *fields = NULL;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
897 PurpleRoomlistField *f;
15374
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 if(js->roomlist)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
900 purple_roomlist_unref(js->roomlist);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
901
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
902 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
903
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
904 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
905 fields = g_list_append(fields, f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
906
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
907 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
908 fields = g_list_append(fields, f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
909
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
910 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
911 fields = g_list_append(fields, f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
912
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
913 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
914
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
915
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
916 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
917 _("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
918 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
919 FALSE, FALSE, NULL,
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
920 _("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
921 _("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
922 purple_connection_get_account(gc), NULL, NULL,
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
923 js);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
924
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
925 return js->roomlist;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
926 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
927
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
928 void jabber_roomlist_cancel(PurpleRoomlist *list)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
929 {
32393
5dafa68c8eb0 Some struct hiding. What a pain.
Mark Doliner <mark@kingant.net>
parents: 31757
diff changeset
930 PurpleAccount *account;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
931 PurpleConnection *gc;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
932 JabberStream *js;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
933
32393
5dafa68c8eb0 Some struct hiding. What a pain.
Mark Doliner <mark@kingant.net>
parents: 31757
diff changeset
934 account = purple_roomlist_get_account(list);
5dafa68c8eb0 Some struct hiding. What a pain.
Mark Doliner <mark@kingant.net>
parents: 31757
diff changeset
935 gc = purple_account_get_connection(account);
32456
3caef255ad47 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents: 32393
diff changeset
936 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
937
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
938 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
939
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
940 if (js->roomlist == list) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
941 js->roomlist = NULL;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
942 purple_roomlist_unref(list);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
943 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
944 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
945
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946 void jabber_chat_member_free(JabberChatMember *jcm)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
947 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
948 g_free(jcm->handle);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
949 g_free(jcm->jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
950 g_free(jcm);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
951 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
952
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
953 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
954 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
955 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
956 JabberChatMember *jcm = g_new0(JabberChatMember, 1);
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 jcm->handle = g_strdup(handle);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
959 jcm->jid = g_strdup(jid);
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 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
962
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
963 /* XXX: keep track of role and affiliation */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
964 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
965
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
966 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
967 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
968 g_hash_table_remove(chat->members, handle);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
969 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
970
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
971 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
972 {
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 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
974 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
975 char *to;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
976 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
977 xmlnode *query, *item, *reason;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
978
19676
e68694150fd8 Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents: 16962
diff changeset
979 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
980 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
981 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
982 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
983 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
984 else
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
985 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
987 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
988 "http://jabber.org/protocol/muc#admin");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
989
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
990 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
991 xmlnode_set_attrib(iq->node, "to", to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
992 g_free(to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
993
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
994 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
995 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
996 xmlnode_set_attrib(item, "jid", jid);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
997 xmlnode_set_attrib(item, "affiliation", "outcast");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998 if(why) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
999 reason = xmlnode_new_child(item, "reason");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1000 xmlnode_insert_data(reason, why, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1001 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1002
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1003 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1004
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1005 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1007
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008 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
1009 {
19676
e68694150fd8 Add the ability to affiliate people in an xmpp chat room even if
Mark Doliner <mark@kingant.net>
parents: 16962
diff changeset
1010 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
1011 const char *jid;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1012 char *to;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1013 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1014 xmlnode *query, *item;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1015
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1016 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
1017 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
1018 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
1019 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
1020 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
1021 else
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1022 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1023
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1024 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
1025 "http://jabber.org/protocol/muc#admin");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1026
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1027 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
1028 xmlnode_set_attrib(iq->node, "to", to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029 g_free(to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1030
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1031 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1032 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
1033 xmlnode_set_attrib(item, "jid", jid);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1034 xmlnode_set_attrib(item, "affiliation", affiliation);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1035
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1036 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1037
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1038 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1039 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1040
26884
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1041 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
1042 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
1043 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
1044 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
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 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
1047 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
1048 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
1049 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
1050
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1051 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
1052 return;
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1053
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1054 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
1055 return;
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1056
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1057 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
1058 return;
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1059
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1060 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
1061
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1062 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
1063 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
1064 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
1065 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
1066 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
1067 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
1068 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
1069 }
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1070 } else {
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1071 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
1072 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
1073 }
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1074
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1075 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
1076 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
1077
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1078 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
1079 }
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1080
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1081 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
1082 {
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1083 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
1084 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
1085 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
1086
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1087 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
1088 "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
1089
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1090 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
1091 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
1092
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1093 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
1094 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
1095 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
1096
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1097 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
1098 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
1099
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 TRUE;
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
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
1103 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
1104 const char *role, const char *why)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1105 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1106 char *to;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1107 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1108 xmlnode *query, *item;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1109 JabberChatMember *jcm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1110
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1111 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
1112
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1113 if (!jcm || !jcm->handle)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1114 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1115
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1116 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
1117 "http://jabber.org/protocol/muc#admin");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1118
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1119 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
1120 xmlnode_set_attrib(iq->node, "to", to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1121 g_free(to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1122
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1123 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1124 item = xmlnode_new_child(query, "item");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1125 xmlnode_set_attrib(item, "nick", jcm->handle);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1126 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
1127 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
1128 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
1129 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
1130 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1131
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1132 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1133
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1134 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1135 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1136
26884
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1137 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
1138 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
1139 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
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 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
1142 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
1143 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
1144 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
1145
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1146 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
1147 return;
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1148
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1149 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
1150 return;
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1151
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1152 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
1153 return;
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1154
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1155 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
1156
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1157 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
1158 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
1159 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
1160 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
1161 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
1162 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
1163 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
1164 }
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1165 } else {
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1166 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
1167 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
1168 }
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1169
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1170 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
1171 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
1172
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1173 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
1174 }
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1175
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1176 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
1177 {
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1178 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
1179 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
1180 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
1181
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1182 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
1183 "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
1184
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1185 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
1186 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
1187
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1188 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
1189 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
1190 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
1191
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1192 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
1193 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
1194
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1195 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
1196 }
af2b87aa82ee Add ability to list roles/affiliations in a chat via slash-commands and
Paul Aurich <paul@darkrain42.org>
parents: 26766
diff changeset
1197
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
1198 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
1199 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
1200 xmlnode *packet, gpointer data)
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 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
1203 #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
1204 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
1205 #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
1206 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
1207
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
1208 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
1209 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1210
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1211 /* 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
1212 * support this request */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1213 chat->xhtml = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1214
20333
53afc5cce143 applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents: 19696
diff changeset
1215 /* 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
1216 * 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
1217 #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
1218 if (type == JABBER_IQ_ERROR) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1219 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1220 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1221
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1222 if(!(query = xmlnode_get_child(packet, "query")))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1223 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1224
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1225 chat->xhtml = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1226
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1227 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
1228 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
1229
29031
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28793
diff changeset
1230 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
1231 chat->xhtml = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1232 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1233 }
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
1234 #endif
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1235 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1236
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1237 void jabber_chat_disco_traffic(JabberChat *chat)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1238 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1239 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1240 xmlnode *query;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1241 char *room_jid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1242
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1243 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
1244
29031
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28793
diff changeset
1245 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
1246
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23988
diff changeset
1247 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
1248
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1249 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1250
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1251 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
1252
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1253 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
1254
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1255 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1256
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1257 g_free(room_jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1258 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1259
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
1260 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
1261 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
1262 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
1263 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
1264 } JabberChatCapsData;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1265
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
1266 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
1267 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
1268 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
1269 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
1270 {
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26884
diff changeset
1271 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
1272 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
1273 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
1274 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
1275 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
1276 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
1277
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
1278 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
1279 *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
1280 } 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
1281 *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
1282 }
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26884
diff changeset
1283 }
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26884
diff changeset
1284
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26884
diff changeset
1285 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
1286 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
1287 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
1288 {
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26884
diff changeset
1289 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
1290 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
1291 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
1292 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
1293
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26884
diff changeset
1294 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
1295 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
1296
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26884
diff changeset
1297 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
1298 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
1299 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
1300 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
1301
27014
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26956
diff changeset
1302 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
1303 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
1304 } 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
1305 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
1306 }
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26884
diff changeset
1307 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
1308 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
1309 }
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26884
diff changeset
1310
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26884
diff changeset
1311 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
1312 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
1313 {
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26884
diff changeset
1314 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
1315 }