annotate src/protocols/yahoo/yahoochat.c @ 12264:2be62353f708

[gaim-migrate @ 14566] this was TRUE in oldstatus committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Tue, 29 Nov 2005 23:50:39 +0000
parents 4d3119205a33
children 27c4145c6daa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1 /*
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
2 * gaim
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
3 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7868
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7868
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7868
diff changeset
6 * source distribution.
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7868
diff changeset
7 *
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
8 * Some code copyright 2003 Tim Ringenbach <omarvo@hotmail.com>
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
9 * (marv on irc.freenode.net)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
10 * Some code borrowed from libyahoo2, copyright (C) 2002, Philip
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
11 * S Tellis <philip . tellis AT gmx . net>
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
12 *
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
13 * This program is free software; you can redistribute it and/or modify
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
14 * it under the terms of the GNU General Public License as published by
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
15 * the Free Software Foundation; either version 2 of the License, or
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
16 * (at your option) any later version.
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
17 *
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
18 * This program is distributed in the hope that it will be useful,
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
21 * GNU General Public License for more details.
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
22 *
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
23 * You should have received a copy of the GNU General Public License
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
24 * along with this program; if not, write to the Free Software
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
26 *
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
27 */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
28
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
29 #ifdef HAVE_CONFIG_H
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
30 #include "config.h"
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
31 #endif
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
32
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
33 #include "debug.h"
10937
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
34 #include "privacy.h"
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
35 #include "prpl.h"
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
36
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
37 #include "conversation.h"
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
38 #include "notify.h"
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
39 #include "util.h"
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
40 #include "internal.h"
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
41
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
42 #include "yahoo.h"
10392
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 9917
diff changeset
43 #include "yahoo_packet.h"
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
44 #include "yahoochat.h"
9376
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
45 #include "ycht.h"
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
46
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
47 #define YAHOO_CHAT_ID (1)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
48
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
49 /* prototype(s) */
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
50 static void yahoo_chat_leave(GaimConnection *gc, const char *room, const char *dn, gboolean logout);
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
51
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
52 /* special function to log us on to the yahoo chat service */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
53 static void yahoo_chat_online(GaimConnection *gc)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
54 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
55 struct yahoo_data *yd = gc->proto_data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
56 struct yahoo_packet *pkt;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
57
9376
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
58 if (yd->wm) {
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
59 ycht_connection_open(gc);
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
60 return;
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
61 }
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
62
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
63 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATONLINE, YAHOO_STATUS_AVAILABLE,0);
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
64 yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc),
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
65 109, gaim_connection_get_display_name(gc), 6, "abcde");
10392
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 9917
diff changeset
66 yahoo_packet_send_and_free(pkt, yd);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
67 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
68
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
69 /* this is slow, and different from the gaim_* version in that it (hopefully) won't add a user twice */
9376
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
70 void yahoo_chat_add_users(GaimConvChat *chat, GList *newusers)
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
71 {
9554
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9376
diff changeset
72 GList *i;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
73
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
74 for (i = newusers; i; i = i->next) {
9554
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9376
diff changeset
75 if (gaim_conv_chat_find_user(chat, i->data))
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
76 continue;
9846
c28d5b45624e [gaim-migrate @ 10724]
Mark Doliner <mark@kingant.net>
parents: 9782
diff changeset
77 gaim_conv_chat_add_user(chat, i->data, NULL, GAIM_CBFLAGS_NONE, TRUE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
78 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
79 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
80
9376
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
81 void yahoo_chat_add_user(GaimConvChat *chat, const char *user, const char *reason)
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
82 {
9554
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9376
diff changeset
83 if (gaim_conv_chat_find_user(chat, user))
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
84 return;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
85
9846
c28d5b45624e [gaim-migrate @ 10724]
Mark Doliner <mark@kingant.net>
parents: 9782
diff changeset
86 gaim_conv_chat_add_user(chat, user, reason, GAIM_CBFLAGS_NONE, TRUE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
87 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
88
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
89 static GaimConversation *yahoo_find_conference(GaimConnection *gc, const char *name)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
90 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
91 struct yahoo_data *yd;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
92 GSList *l;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
93
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
94 yd = gc->proto_data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
95
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
96 for (l = yd->confs; l; l = l->next) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
97 GaimConversation *c = l->data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
98 if (!gaim_utf8_strcasecmp(gaim_conversation_get_name(c), name))
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
99 return c;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
100 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
101 return NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
102 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
103
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
104
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
105 void yahoo_process_conference_invite(GaimConnection *gc, struct yahoo_packet *pkt)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
106 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
107 GSList *l;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
108 char *room = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
109 char *who = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
110 char *msg = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
111 GString *members = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
112 GHashTable *components;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
113
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
114 if (pkt->status == 2)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
115 return; /* XXX */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
116
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
117 members = g_string_sized_new(512);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
118
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
119 for (l = pkt->hash; l; l = l->next) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
120 struct yahoo_pair *pair = l->data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
121
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
122 switch (pair->key) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
123 case 1: /* us, but we already know who we are */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
124 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
125 case 57:
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
126 room = yahoo_string_decode(gc, pair->value, FALSE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
127 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
128 case 50: /* inviter */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
129 who = pair->value;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
130 g_string_append_printf(members, "%s\n", who);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
131 break;
9780
06e730382bbe [gaim-migrate @ 10648]
Mark Doliner <mark@kingant.net>
parents: 9768
diff changeset
132 case 52: /* invitee (me) */
06e730382bbe [gaim-migrate @ 10648]
Mark Doliner <mark@kingant.net>
parents: 9768
diff changeset
133 case 53: /* members */
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
134 g_string_append_printf(members, "%s\n", pair->value);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
135 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
136 case 58:
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
137 msg = yahoo_string_decode(gc, pair->value, FALSE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
138 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
139 case 13: /* ? */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
140 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
141 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
142 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
143
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
144 if (!room) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
145 g_string_free(members, TRUE);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
146 return;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
147 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
148
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
149 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
150 g_hash_table_replace(components, g_strdup("room"), room);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
151 if (msg)
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
152 g_hash_table_replace(components, g_strdup("topic"), msg);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
153 g_hash_table_replace(components, g_strdup("type"), g_strdup("Conference"));
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
154 if (members) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
155 g_hash_table_replace(components, g_strdup("members"), g_strdup(members->str));
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
156 }
10937
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
157 if (!yahoo_privacy_check(gc, who)) {
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
158 gaim_debug_info("yahoo",
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
159 "Invite to conference %s from %s has been dropped.\n", room, who);
11044
8bf376579177 [gaim-migrate @ 12958]
Richard Laager <rlaager@wiktel.com>
parents: 11043
diff changeset
160 g_string_free(members, TRUE);
10937
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
161 return;
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
162 }
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
163 serv_got_chat_invite(gc, room, who, msg, components);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
164
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
165 g_string_free(members, TRUE);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
166 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
167
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
168 void yahoo_process_conference_decline(GaimConnection *gc, struct yahoo_packet *pkt)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
169 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
170 GSList *l;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
171 char *room = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
172 char *who = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
173 char *msg = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
174
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
175 for (l = pkt->hash; l; l = l->next) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
176 struct yahoo_pair *pair = l->data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
177
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
178 switch (pair->key) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
179 case 57:
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
180 room = yahoo_string_decode(gc, pair->value, FALSE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
181 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
182 case 54:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
183 who = pair->value;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
184 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
185 case 14:
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
186 msg = yahoo_string_decode(gc, pair->value, FALSE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
187 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
188 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
189 }
11044
8bf376579177 [gaim-migrate @ 12958]
Richard Laager <rlaager@wiktel.com>
parents: 11043
diff changeset
190 if (!yahoo_privacy_check(gc, who)) {
8bf376579177 [gaim-migrate @ 12958]
Richard Laager <rlaager@wiktel.com>
parents: 11043
diff changeset
191 g_free(room);
8bf376579177 [gaim-migrate @ 12958]
Richard Laager <rlaager@wiktel.com>
parents: 11043
diff changeset
192 if (msg != NULL)
8bf376579177 [gaim-migrate @ 12958]
Richard Laager <rlaager@wiktel.com>
parents: 11043
diff changeset
193 g_free(msg);
8bf376579177 [gaim-migrate @ 12958]
Richard Laager <rlaager@wiktel.com>
parents: 11043
diff changeset
194 return;
8bf376579177 [gaim-migrate @ 12958]
Richard Laager <rlaager@wiktel.com>
parents: 11043
diff changeset
195 }
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
196
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
197 if (who && room) {
9575
d39eecc24a59 [gaim-migrate @ 10418]
Tim Ringenbach <marv@pidgin.im>
parents: 9554
diff changeset
198 /* make sure we're in the room before we process a decline message for it */
9576
1a9157d70ec0 [gaim-migrate @ 10419]
Tim Ringenbach <marv@pidgin.im>
parents: 9575
diff changeset
199 if(yahoo_find_conference(gc, room)) {
9575
d39eecc24a59 [gaim-migrate @ 10418]
Tim Ringenbach <marv@pidgin.im>
parents: 9554
diff changeset
200 char *tmp;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
201
9575
d39eecc24a59 [gaim-migrate @ 10418]
Tim Ringenbach <marv@pidgin.im>
parents: 9554
diff changeset
202 tmp = g_strdup_printf(_("%s declined your conference invitation to room \"%s\" because \"%s\"."),
d39eecc24a59 [gaim-migrate @ 10418]
Tim Ringenbach <marv@pidgin.im>
parents: 9554
diff changeset
203 who, room, msg?msg:"");
d39eecc24a59 [gaim-migrate @ 10418]
Tim Ringenbach <marv@pidgin.im>
parents: 9554
diff changeset
204 gaim_notify_info(gc, NULL, _("Invitation Rejected"), tmp);
d39eecc24a59 [gaim-migrate @ 10418]
Tim Ringenbach <marv@pidgin.im>
parents: 9554
diff changeset
205 g_free(tmp);
d39eecc24a59 [gaim-migrate @ 10418]
Tim Ringenbach <marv@pidgin.im>
parents: 9554
diff changeset
206 }
d39eecc24a59 [gaim-migrate @ 10418]
Tim Ringenbach <marv@pidgin.im>
parents: 9554
diff changeset
207
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
208 g_free(room);
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
209 if (msg)
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
210 g_free(msg);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
211 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
212 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
213
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
214 void yahoo_process_conference_logon(GaimConnection *gc, struct yahoo_packet *pkt)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
215 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
216 GSList *l;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
217 char *room = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
218 char *who = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
219 GaimConversation *c;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
220
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
221 for (l = pkt->hash; l; l = l->next) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
222 struct yahoo_pair *pair = l->data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
223
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
224 switch (pair->key) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
225 case 57:
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
226 room = yahoo_string_decode(gc, pair->value, FALSE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
227 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
228 case 53:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
229 who = pair->value;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
230 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
231 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
232 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
233
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
234 if (who && room) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
235 c = yahoo_find_conference(gc, room);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
236 if (c)
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6804
diff changeset
237 yahoo_chat_add_user(GAIM_CONV_CHAT(c), who, NULL);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
238 g_free(room);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
239 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
240 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
241
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
242 void yahoo_process_conference_logoff(GaimConnection *gc, struct yahoo_packet *pkt)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
243 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
244 GSList *l;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
245 char *room = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
246 char *who = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
247 GaimConversation *c;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
248
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
249 for (l = pkt->hash; l; l = l->next) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
250 struct yahoo_pair *pair = l->data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
251
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
252 switch (pair->key) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
253 case 57:
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
254 room = yahoo_string_decode(gc, pair->value, FALSE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
255 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
256 case 56:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
257 who = pair->value;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
258 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
259 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
260 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
261
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
262 if (who && room) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
263 c = yahoo_find_conference(gc, room);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
264 if (c)
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6804
diff changeset
265 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c), who, NULL);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
266 g_free(room);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
267 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
268 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
269
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
270 void yahoo_process_conference_message(GaimConnection *gc, struct yahoo_packet *pkt)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
271 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
272 GSList *l;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
273 char *room = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
274 char *who = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
275 char *msg = NULL;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
276 char *msg2;
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
277 int utf8 = 0;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
278 GaimConversation *c;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
279
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
280 for (l = pkt->hash; l; l = l->next) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
281 struct yahoo_pair *pair = l->data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
282
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
283 switch (pair->key) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
284 case 57:
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
285 room = yahoo_string_decode(gc, pair->value, FALSE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
286 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
287 case 3:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
288 who = pair->value;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
289 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
290 case 14:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
291 msg = pair->value;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
292 break;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
293 case 97:
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
294 utf8 = strtol(pair->value, NULL, 10);
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
295 break;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
296 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
297 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
298
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
299 if (room && who && msg) {
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
300 msg2 = yahoo_string_decode(gc, msg, utf8);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
301 c = yahoo_find_conference(gc, room);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
302 if (!c)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
303 return;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
304 msg = yahoo_codes_to_html(msg2);
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6804
diff changeset
305 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(c)), who, 0, msg, time(NULL));
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
306 g_free(msg);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
307 g_free(msg2);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
308 }
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
309 if (room)
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
310 g_free(room);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
311 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
312
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
313
8735
92cbf9713795 [gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents: 8584
diff changeset
314 /* this is a confirmation of yahoo_chat_online(); */
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
315 void yahoo_process_chat_online(GaimConnection *gc, struct yahoo_packet *pkt)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
316 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
317 struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
318
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
319 if (pkt->status == 1)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
320 yd->chat_online = 1;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
321 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
322
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
323 /* this is basicly the opposite of chat_online */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
324 void yahoo_process_chat_logout(GaimConnection *gc, struct yahoo_packet *pkt)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
325 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
326 struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data;
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
327 GSList *l;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
328
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
329 for (l = pkt->hash; l; l = l->next) {
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
330 struct yahoo_pair *pair = l->data;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
331
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
332 if (pair->key == 1)
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
333 if (g_ascii_strcasecmp(pair->value,
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
334 gaim_connection_get_display_name(gc)))
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
335 return;
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
336 }
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
337
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
338 if (pkt->status == 1) {
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
339 yd->chat_online = 0;
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
340 if (yd->in_chat)
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
341 yahoo_c_leave(gc, YAHOO_CHAT_ID);
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
342 }
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
343 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
344
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
345 void yahoo_process_chat_join(GaimConnection *gc, struct yahoo_packet *pkt)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
346 {
10937
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
347 GaimAccount *account = gaim_connection_get_account(gc);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
348 struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
349 GaimConversation *c = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
350 GSList *l;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
351 GList *members = NULL;
10937
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
352 GList *roomies = NULL;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
353 char *room = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
354 char *topic = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
355 char *someid, *someotherid, *somebase64orhashosomething, *somenegativenumber;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
356
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
357 if (pkt->status == -1) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
358 gaim_notify_error(gc, NULL, _("Failed to join chat"), _("Maybe the room is full?"));
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
359 return;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
360 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
361
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
362 for (l = pkt->hash; l; l = l->next) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
363 struct yahoo_pair *pair = l->data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
364
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
365 switch (pair->key) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
366
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
367 case 104:
8410
3c07b7d0084c [gaim-migrate @ 9140]
Luke Schierer <lschiere@pidgin.im>
parents: 8357
diff changeset
368 room = yahoo_string_decode(gc, pair->value, TRUE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
369 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
370 case 105:
8410
3c07b7d0084c [gaim-migrate @ 9140]
Luke Schierer <lschiere@pidgin.im>
parents: 8357
diff changeset
371 topic = yahoo_string_decode(gc, pair->value, TRUE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
372 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
373 case 128:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
374 someid = pair->value;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
375 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
376 case 108: /* number of joiners */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
377 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
378 case 129:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
379 someotherid = pair->value;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
380 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
381 case 130:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
382 somebase64orhashosomething = pair->value;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
383 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
384 case 126:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
385 somenegativenumber = pair->value;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
386 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
387 case 13: /* this is 1. maybe its the type of room? (normal, user created, private, etc?) */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
388 break;
8735
92cbf9713795 [gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents: 8584
diff changeset
389 case 61: /*this looks similar to 130 */
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
390 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
391
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
392 /* the previous section was just room info. this next section is
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
393 info about individual room members, (including us) */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
394
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
395 case 109: /* the yahoo id */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
396 members = g_list_append(members, pair->value);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
397 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
398 case 110: /* age */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
399 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
400 case 141: /* nickname */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
401 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
402 case 142: /* location */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
403 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
404 case 113: /* bitmask */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
405 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
406 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
407 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
408
9329
d42f3e4fd7ad [gaim-migrate @ 10137]
Tim Ringenbach <marv@pidgin.im>
parents: 9227
diff changeset
409 if (room && yd->chat_name && gaim_utf8_strcasecmp(room, yd->chat_name))
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
410 yahoo_chat_leave(gc, room,
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
411 gaim_connection_get_display_name(gc), FALSE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
412
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
413 c = gaim_find_chat(gc, YAHOO_CHAT_ID);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
414
9329
d42f3e4fd7ad [gaim-migrate @ 10137]
Tim Ringenbach <marv@pidgin.im>
parents: 9227
diff changeset
415 if (room && (!c || gaim_conv_chat_has_left(GAIM_CONV_CHAT(c))) && members &&
8357
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
416 ((g_list_length(members) > 1) ||
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
417 !g_ascii_strcasecmp(members->data, gaim_connection_get_display_name(gc)))) {
9554
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9376
diff changeset
418 int i;
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9376
diff changeset
419 GList *flags = NULL;
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9376
diff changeset
420 for (i = 0; i < g_list_length(members); i++)
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9376
diff changeset
421 flags = g_list_append(flags, GINT_TO_POINTER(GAIM_CBFLAGS_NONE));
8357
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
422 if (c && gaim_conv_chat_has_left(GAIM_CONV_CHAT(c))) {
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
423 /* this might be a hack, but oh well, it should nicely */
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
424 char *tmpmsg;
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
425
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
426 gaim_conversation_set_name(c, room);
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
427
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
428 c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room);
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
429 if (topic)
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
430 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic);
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
431 yd->in_chat = 1;
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
432 yd->chat_name = g_strdup(room);
11454
201617d49573 [gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents: 11318
diff changeset
433 gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members, NULL, flags, FALSE);
8357
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
434
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
435 tmpmsg = g_strdup_printf(_("You are now chatting in %s."), room);
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
436 gaim_conv_chat_write(GAIM_CONV_CHAT(c), "", tmpmsg, GAIM_MESSAGE_SYSTEM, time(NULL));
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
437 g_free(tmpmsg);
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
438 } else {
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
439 c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room);
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
440 if (topic)
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
441 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic);
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
442 yd->in_chat = 1;
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
443 yd->chat_name = g_strdup(room);
11454
201617d49573 [gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents: 11318
diff changeset
444 gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members, NULL, flags, FALSE);
8357
1f56ea865926 [gaim-migrate @ 9081]
Luke Schierer <lschiere@pidgin.im>
parents: 8113
diff changeset
445 }
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
446 } else if (c) {
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6804
diff changeset
447 yahoo_chat_add_users(GAIM_CONV_CHAT(c), members);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
448 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
449
11527
b1f8151e6ae5 [gaim-migrate @ 13776]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11454
diff changeset
450 if (account->deny && c) {
b1f8151e6ae5 [gaim-migrate @ 13776]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11454
diff changeset
451 GaimConversationUiOps *ops = gaim_conversation_get_ui_ops(c);
b1f8151e6ae5 [gaim-migrate @ 13776]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11454
diff changeset
452 for (l = account->deny; l != NULL; l = l->next) {
b1f8151e6ae5 [gaim-migrate @ 13776]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11454
diff changeset
453 for (roomies = members; roomies; roomies = roomies->next) {
b1f8151e6ae5 [gaim-migrate @ 13776]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11454
diff changeset
454 if (!gaim_utf8_strcasecmp((char *)l->data, roomies->data)) {
b1f8151e6ae5 [gaim-migrate @ 13776]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11454
diff changeset
455 gaim_debug_info("yahoo", "Ignoring room member %s in room %s\n" , roomies->data, room ? room : "");
b1f8151e6ae5 [gaim-migrate @ 13776]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11454
diff changeset
456 gaim_conv_chat_ignore(GAIM_CONV_CHAT(c),roomies->data);
b1f8151e6ae5 [gaim-migrate @ 13776]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11454
diff changeset
457 ops->chat_update_user(c, roomies->data);
b1f8151e6ae5 [gaim-migrate @ 13776]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11454
diff changeset
458 }
10937
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
459 }
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
460 }
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
461 }
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
462 g_list_free(roomies);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
463 g_list_free(members);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
464 g_free(room);
11527
b1f8151e6ae5 [gaim-migrate @ 13776]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11454
diff changeset
465 g_free(topic);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
466 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
467
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
468 void yahoo_process_chat_exit(GaimConnection *gc, struct yahoo_packet *pkt)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
469 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
470 char *who = NULL;
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
471 char *room = NULL;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
472 GSList *l;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
473 struct yahoo_data *yd;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
474
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
475 yd = gc->proto_data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
476
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
477 for (l = pkt->hash; l; l = l->next) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
478 struct yahoo_pair *pair = l->data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
479
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
480 if (pair->key == 104)
8410
3c07b7d0084c [gaim-migrate @ 9140]
Luke Schierer <lschiere@pidgin.im>
parents: 8357
diff changeset
481 room = yahoo_string_decode(gc, pair->value, TRUE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
482 if (pair->key == 109)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
483 who = pair->value;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
484 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
485
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
486 if (who && room) {
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
487 GaimConversation *c = gaim_find_chat(gc, YAHOO_CHAT_ID);
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
488 if (c && !gaim_utf8_strcasecmp(gaim_conversation_get_name(c), room))
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6804
diff changeset
489 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c), who, NULL);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
490
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
491 }
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
492 if (room)
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
493 g_free(room);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
494 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
495
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
496 void yahoo_process_chat_message(GaimConnection *gc, struct yahoo_packet *pkt)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
497 {
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
498 char *room = NULL, *who = NULL, *msg = NULL, *msg2;
8410
3c07b7d0084c [gaim-migrate @ 9140]
Luke Schierer <lschiere@pidgin.im>
parents: 8357
diff changeset
499 int msgtype = 1, utf8 = 1; /* default to utf8 */
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
500 GaimConversation *c = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
501 GSList *l;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
502
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
503 for (l = pkt->hash; l; l = l->next) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
504 struct yahoo_pair *pair = l->data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
505
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
506 switch (pair->key) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
507
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
508 case 97:
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
509 utf8 = strtol(pair->value, NULL, 10);
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
510 break;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
511 case 104:
8410
3c07b7d0084c [gaim-migrate @ 9140]
Luke Schierer <lschiere@pidgin.im>
parents: 8357
diff changeset
512 room = yahoo_string_decode(gc, pair->value, TRUE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
513 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
514 case 109:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
515 who = pair->value;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
516 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
517 case 117:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
518 msg = pair->value;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
519 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
520 case 124:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
521 msgtype = strtol(pair->value, NULL, 10);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
522 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
523 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
524 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
525
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
526 c = gaim_find_chat(gc, YAHOO_CHAT_ID);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
527 if (!who || !c) {
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
528 if (room)
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
529 g_free(room);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
530 /* we still get messages after we part, funny that */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
531 return;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
532 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
533
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
534 if (!msg) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
535 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "Got a message packet with no message.\nThis probably means something important, but we're ignoring it.\n");
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
536 return;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
537 }
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
538 msg2 = yahoo_string_decode(gc, msg, utf8);
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
539 msg = yahoo_codes_to_html(msg2);
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
540 g_free(msg2);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
541
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
542 if (msgtype == 2 || msgtype == 3) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
543 char *tmp;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
544 tmp = g_strdup_printf("/me %s", msg);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
545 g_free(msg);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
546 msg = tmp;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
547 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
548
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
549 serv_got_chat_in(gc, YAHOO_CHAT_ID, who, 0, msg, time(NULL));
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
550 g_free(msg);
11593
4b7fb30b8926 [gaim-migrate @ 13863]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11527
diff changeset
551 g_free(room);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
552 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
553
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
554 void yahoo_process_chat_addinvite(GaimConnection *gc, struct yahoo_packet *pkt)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
555 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
556 GSList *l;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
557 char *room = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
558 char *msg = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
559 char *who = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
560
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
561 for (l = pkt->hash; l; l = l->next) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
562 struct yahoo_pair *pair = l->data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
563
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
564 switch (pair->key) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
565 case 104:
8410
3c07b7d0084c [gaim-migrate @ 9140]
Luke Schierer <lschiere@pidgin.im>
parents: 8357
diff changeset
566 room = yahoo_string_decode(gc, pair->value, TRUE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
567 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
568 case 129: /* room id? */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
569 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
570 case 126: /* ??? */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
571 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
572 case 117:
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
573 msg = yahoo_string_decode(gc, pair->value, FALSE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
574 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
575 case 119:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
576 who = pair->value;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
577 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
578 case 118: /* us */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
579 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
580 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
581 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
582
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
583 if (room && who) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
584 GHashTable *components;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
585
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
586 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
587 g_hash_table_replace(components, g_strdup("room"), g_strdup(room));
10937
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
588 if (!yahoo_privacy_check(gc, who)) {
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
589 gaim_debug_info("yahoo",
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
590 "Invite to room %s from %s has been dropped.\n", room, who);
11044
8bf376579177 [gaim-migrate @ 12958]
Richard Laager <rlaager@wiktel.com>
parents: 11043
diff changeset
591 if (room != NULL)
8bf376579177 [gaim-migrate @ 12958]
Richard Laager <rlaager@wiktel.com>
parents: 11043
diff changeset
592 g_free(room);
8bf376579177 [gaim-migrate @ 12958]
Richard Laager <rlaager@wiktel.com>
parents: 11043
diff changeset
593 if (msg != NULL)
8bf376579177 [gaim-migrate @ 12958]
Richard Laager <rlaager@wiktel.com>
parents: 11043
diff changeset
594 g_free(msg);
10937
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
595 return;
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10647
diff changeset
596 }
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
597 serv_got_chat_invite(gc, room, who, msg, components);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
598 }
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
599 if (room)
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
600 g_free(room);
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
601 if (msg)
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
602 g_free(msg);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
603 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
604
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
605 void yahoo_process_chat_goto(GaimConnection *gc, struct yahoo_packet *pkt)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
606 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
607 if (pkt->status == -1)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
608 gaim_notify_error(gc, NULL, _("Failed to join buddy in chat"),
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
609 _("Maybe they're not in a chat?"));
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
610 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
611
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
612 /*
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
613 * Functions dealing with conferences
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
614 * I think conference names are always ascii.
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
615 */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
616
9782
68368058ee03 [gaim-migrate @ 10650]
Tim Ringenbach <marv@pidgin.im>
parents: 9780
diff changeset
617 void yahoo_conf_leave(struct yahoo_data *yd, const char *room, const char *dn, GList *who)
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
618 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
619 struct yahoo_packet *pkt;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
620 GList *w;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
621
9782
68368058ee03 [gaim-migrate @ 10650]
Tim Ringenbach <marv@pidgin.im>
parents: 9780
diff changeset
622 gaim_debug_misc("yahoo", "leaving conference %s\n", room);
68368058ee03 [gaim-migrate @ 10650]
Tim Ringenbach <marv@pidgin.im>
parents: 9780
diff changeset
623
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
624 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGOFF, YAHOO_STATUS_AVAILABLE, 0);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
625
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
626 yahoo_packet_hash_str(pkt, 1, dn);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
627 for (w = who; w; w = w->next) {
9554
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9376
diff changeset
628 const char *name = gaim_conv_chat_cb_get_name(w->data);
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
629 yahoo_packet_hash_str(pkt, 3, name);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
630 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
631
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
632 yahoo_packet_hash_str(pkt, 57, room);
10392
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 9917
diff changeset
633 yahoo_packet_send_and_free(pkt, yd);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
634 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
635
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
636 static int yahoo_conf_send(GaimConnection *gc, const char *dn, const char *room,
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
637 GList *members, const char *what)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
638 {
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
639 struct yahoo_data *yd = gc->proto_data;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
640 struct yahoo_packet *pkt;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
641 GList *who;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
642 char *msg, *msg2;
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
643 int utf8 = 1;
6804
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
644
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
645 msg = yahoo_html_to_codes(what);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
646 msg2 = yahoo_string_encode(gc, msg, &utf8);
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
647
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
648 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFMSG, YAHOO_STATUS_AVAILABLE, 0);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
649
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
650 yahoo_packet_hash_str(pkt, 1, dn);
9554
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9376
diff changeset
651 for (who = members; who; who = who->next) {
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9376
diff changeset
652 const char *name = gaim_conv_chat_cb_get_name(who->data);
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
653 yahoo_packet_hash_str(pkt, 53, name);
9554
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9376
diff changeset
654 }
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
655 yahoo_packet_hash(pkt, "ss", 57, room, 14, msg2);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
656 if (utf8)
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
657 yahoo_packet_hash_str(pkt, 97, "1"); /* utf-8 */
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
658
10392
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 9917
diff changeset
659 yahoo_packet_send_and_free(pkt, yd);
6804
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
660 g_free(msg);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
661 g_free(msg2);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
662
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
663 return 0;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
664 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
665
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
666 static void yahoo_conf_join(struct yahoo_data *yd, GaimConversation *c, const char *dn, const char *room,
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
667 const char *topic, const char *members)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
668 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
669 struct yahoo_packet *pkt;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
670 char **memarr = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
671 int i;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
672
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
673 if (members)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
674 memarr = g_strsplit(members, "\n", 0);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
675
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
676 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGON, YAHOO_STATUS_AVAILABLE, 0);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
677
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
678 yahoo_packet_hash(pkt, "sss", 1, dn, 3, dn, 57, room);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
679 if (memarr) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
680 for(i = 0 ; memarr[i]; i++) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
681 if (!strcmp(memarr[i], "") || !strcmp(memarr[i], dn))
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
682 continue;
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
683 yahoo_packet_hash_str(pkt, 3, memarr[i]);
9846
c28d5b45624e [gaim-migrate @ 10724]
Mark Doliner <mark@kingant.net>
parents: 9782
diff changeset
684 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c), memarr[i], NULL, GAIM_CBFLAGS_NONE, TRUE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
685 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
686 }
10392
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 9917
diff changeset
687 yahoo_packet_send_and_free(pkt, yd);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
688
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
689 if (memarr)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
690 g_strfreev(memarr);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
691 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
692
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
693 static void yahoo_conf_invite(GaimConnection *gc, GaimConversation *c,
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
694 const char *dn, const char *buddy, const char *room, const char *msg)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
695 {
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
696 struct yahoo_data *yd = gc->proto_data;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
697 struct yahoo_packet *pkt;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
698 GList *members;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
699 char *msg2 = NULL;
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
700
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
701 if (msg)
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
702 msg2 = yahoo_string_encode(gc, msg, NULL);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
703
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6804
diff changeset
704 members = gaim_conv_chat_get_users(GAIM_CONV_CHAT(c));
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
705
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
706 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFADDINVITE, YAHOO_STATUS_AVAILABLE, 0);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
707
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
708 yahoo_packet_hash(pkt, "sssss", 1, dn, 51, buddy, 57, room, 58, msg?msg2:"", 13, "0");
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
709 for(; members; members = members->next) {
9554
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9376
diff changeset
710 const char *name = gaim_conv_chat_cb_get_name(members->data);
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9376
diff changeset
711 if (!strcmp(name, dn))
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
712 continue;
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
713 yahoo_packet_hash(pkt, "ss", 52, name, 53, name);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
714 }
10392
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 9917
diff changeset
715
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 9917
diff changeset
716 yahoo_packet_send_and_free(pkt, yd);
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 9917
diff changeset
717 g_free(msg2);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
718 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
719
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
720 /*
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
721 * Functions dealing with chats
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
722 */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
723
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
724 static void yahoo_chat_leave(GaimConnection *gc, const char *room, const char *dn, gboolean logout)
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
725 {
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
726 struct yahoo_data *yd = gc->proto_data;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
727 struct yahoo_packet *pkt;
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
728 GaimConversation *c;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
729 char *eroom;
8410
3c07b7d0084c [gaim-migrate @ 9140]
Luke Schierer <lschiere@pidgin.im>
parents: 8357
diff changeset
730 gboolean utf8 = 1;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
731
9376
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
732 if (yd->wm) {
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
733 g_return_if_fail(yd->ycht != NULL);
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
734
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
735 ycht_chat_leave(yd->ycht, room, logout);
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
736 return;
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
737 }
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
738
8410
3c07b7d0084c [gaim-migrate @ 9140]
Luke Schierer <lschiere@pidgin.im>
parents: 8357
diff changeset
739 eroom = yahoo_string_encode(gc, room, &utf8);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
740
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
741 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATEXIT, YAHOO_STATUS_AVAILABLE, 0);
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
742 yahoo_packet_hash(pkt, "sss", 104, eroom, 109, dn, 108, "1");
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
743 yahoo_packet_hash_str(pkt, 112, "0"); /* what does this one mean? */
10392
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 9917
diff changeset
744 yahoo_packet_send_and_free(pkt, yd);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
745
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
746 yd->in_chat = 0;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
747 if (yd->chat_name) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
748 g_free(yd->chat_name);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
749 yd->chat_name = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
750 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
751
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
752 if ((c = gaim_find_chat(gc, YAHOO_CHAT_ID)))
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
753 serv_got_chat_left(gc, YAHOO_CHAT_ID);
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
754
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
755 if (!logout)
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
756 return;
11644
f4e58e94ced3 [gaim-migrate @ 13922]
Mark Doliner <mark@kingant.net>
parents: 11593
diff changeset
757
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
758 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATLOGOUT,
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
759 YAHOO_STATUS_AVAILABLE, 0);
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
760 yahoo_packet_hash_str(pkt, 1, dn);
10392
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 9917
diff changeset
761 yahoo_packet_send_and_free(pkt, yd);
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
762
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
763 yd->chat_online = 0;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
764 g_free(eroom);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
765 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
766
6804
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
767 /* borrowed from gtkconv.c */
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
768 static gboolean
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
769 meify(char *message, size_t len)
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
770 {
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
771 /*
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
772 * Read /me-ify: If the message (post-HTML) starts with /me,
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
773 * remove the "/me " part of it (including that space) and return TRUE.
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
774 */
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
775 char *c;
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
776 gboolean inside_html = 0;
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
777
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
778 /* Umm.. this would be very bad if this happens. */
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
779 g_return_val_if_fail(message != NULL, FALSE);
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
780
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
781 if (len == -1)
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
782 len = strlen(message);
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
783
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
784 for (c = message; *c != '\0'; c++, len--) {
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
785 if (inside_html) {
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
786 if (*c == '>')
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
787 inside_html = FALSE;
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
788 }
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
789 else {
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
790 if (*c == '<')
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
791 inside_html = TRUE;
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
792 else
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
793 break;
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
794 }
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
795 }
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
796
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
797 if (*c != '\0' && !g_ascii_strncasecmp(c, "/me ", 4)) {
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
798 memmove(c, c + 4, len - 3);
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
799 return TRUE;
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
800 }
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
801
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
802 return FALSE;
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
803 }
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
804
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12212
diff changeset
805 static int yahoo_chat_send(GaimConnection *gc, const char *dn, const char *room, const char *what, GaimMessageFlags flags)
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
806 {
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
807 struct yahoo_data *yd = gc->proto_data;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
808 struct yahoo_packet *pkt;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
809 int me = 0;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
810 char *msg1, *msg2, *room2;
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
811 gboolean utf8 = TRUE;
6804
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
812
9376
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
813 if (yd->wm) {
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
814 g_return_val_if_fail(yd->ycht != NULL, 1);
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
815
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
816 return ycht_chat_send(yd->ycht, room, what);
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
817 }
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
818
6804
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
819 msg1 = g_strdup(what);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
820
6804
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
821 if (meify(msg1, -1))
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
822 me = 1;
6804
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
823
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
824 msg2 = yahoo_html_to_codes(msg1);
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
825 g_free(msg1);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
826 msg1 = yahoo_string_encode(gc, msg2, &utf8);
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
827 g_free(msg2);
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
828 room2 = yahoo_string_encode(gc, room, NULL);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
829
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
830 pkt = yahoo_packet_new(YAHOO_SERVICE_COMMENT, YAHOO_STATUS_AVAILABLE, 0);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
831
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
832 yahoo_packet_hash(pkt, "sss", 1, dn, 104, room2, 117, msg1);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
833 if (me)
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
834 yahoo_packet_hash_str(pkt, 124, "2");
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
835 else
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
836 yahoo_packet_hash_str(pkt, 124, "1");
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
837 /* fixme: what about /think? (124=3) */
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
838 if (utf8)
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
839 yahoo_packet_hash_str(pkt, 97, "1");
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
840
10392
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 9917
diff changeset
841 yahoo_packet_send_and_free(pkt, yd);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
842 g_free(msg1);
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
843 g_free(room2);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
844
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
845 return 0;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
846 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
847
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
848 static void yahoo_chat_join(GaimConnection *gc, const char *dn, const char *room, const char *topic)
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
849 {
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
850 struct yahoo_data *yd = gc->proto_data;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
851 struct yahoo_packet *pkt;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
852 char *room2;
8410
3c07b7d0084c [gaim-migrate @ 9140]
Luke Schierer <lschiere@pidgin.im>
parents: 8357
diff changeset
853 gboolean utf8 = TRUE;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
854
9376
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
855 if (yd->wm) {
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
856 g_return_if_fail(yd->ycht != NULL);
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
857 ycht_chat_join(yd->ycht, room);
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
858 return;
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
859 }
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
860
8410
3c07b7d0084c [gaim-migrate @ 9140]
Luke Schierer <lschiere@pidgin.im>
parents: 8357
diff changeset
861 /* apparently room names are always utf8, or else always not utf8,
3c07b7d0084c [gaim-migrate @ 9140]
Luke Schierer <lschiere@pidgin.im>
parents: 8357
diff changeset
862 * so we don't have to actually pass the flag in the packet. Or something. */
3c07b7d0084c [gaim-migrate @ 9140]
Luke Schierer <lschiere@pidgin.im>
parents: 8357
diff changeset
863 room2 = yahoo_string_encode(gc, room, &utf8);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
864
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
865 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATJOIN, YAHOO_STATUS_AVAILABLE, 0);
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
866 yahoo_packet_hash(pkt, "ssss", 1, gaim_connection_get_display_name(gc),
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
867 62, "2", 104, room2, 129, "0");
10392
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 9917
diff changeset
868 yahoo_packet_send_and_free(pkt, yd);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
869 g_free(room2);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
870 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
871
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
872 static void yahoo_chat_invite(GaimConnection *gc, const char *dn, const char *buddy,
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
873 const char *room, const char *msg)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
874 {
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
875 struct yahoo_data *yd = gc->proto_data;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
876 struct yahoo_packet *pkt;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
877 char *room2, *msg2 = NULL;
8410
3c07b7d0084c [gaim-migrate @ 9140]
Luke Schierer <lschiere@pidgin.im>
parents: 8357
diff changeset
878 gboolean utf8 = TRUE;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
879
9376
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
880 if (yd->wm) {
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
881 g_return_if_fail(yd->ycht != NULL);
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
882 ycht_chat_send_invite(yd->ycht, room, buddy, msg);
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
883 return;
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
884 }
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
885
8410
3c07b7d0084c [gaim-migrate @ 9140]
Luke Schierer <lschiere@pidgin.im>
parents: 8357
diff changeset
886 room2 = yahoo_string_encode(gc, room, &utf8);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
887 if (msg)
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
888 msg2 = yahoo_string_encode(gc, msg, NULL);
11644
f4e58e94ced3 [gaim-migrate @ 13922]
Mark Doliner <mark@kingant.net>
parents: 11593
diff changeset
889
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
890 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATADDINVITE, YAHOO_STATUS_AVAILABLE, 0);
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
891 yahoo_packet_hash(pkt, "sssss", 1, dn, 118, buddy, 104, room2, 117, (msg2?msg2:""), 129, "0");
10392
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 9917
diff changeset
892 yahoo_packet_send_and_free(pkt, yd);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
893
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
894 g_free(room2);
10392
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 9917
diff changeset
895 g_free(msg2);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
896 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
897
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
898 void yahoo_chat_goto(GaimConnection *gc, const char *name)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
899 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
900 struct yahoo_data *yd;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
901 struct yahoo_packet *pkt;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
902
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
903 yd = gc->proto_data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
904
9376
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
905 if (yd->wm) {
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
906 g_return_if_fail(yd->ycht != NULL);
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
907 ycht_chat_goto_user(yd->ycht, name);
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
908 return;
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
909 }
3aa848ccf986 [gaim-migrate @ 10184]
Tim Ringenbach <marv@pidgin.im>
parents: 9329
diff changeset
910
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
911 if (!yd->chat_online)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
912 yahoo_chat_online(gc);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
913
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
914 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATGOTO, YAHOO_STATUS_AVAILABLE, 0);
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
915 yahoo_packet_hash(pkt, "sss", 109, name, 1, gaim_connection_get_display_name(gc), 62, "2");
10392
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 9917
diff changeset
916 yahoo_packet_send_and_free(pkt, yd);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
917 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
918 /*
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
919 * These are the functions registered with the core
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
920 * which get called for both chats and conferences.
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
921 */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
922
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
923 void yahoo_c_leave(GaimConnection *gc, int id)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
924 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
925 struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
926 GaimConversation *c;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
927
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
928 if (!yd)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
929 return;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
930
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
931 c = gaim_find_chat(gc, id);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
932 if (!c)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
933 return;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
934
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
935 if (id != YAHOO_CHAT_ID) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
936 yahoo_conf_leave(yd, gaim_conversation_get_name(c),
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6804
diff changeset
937 gaim_connection_get_display_name(gc), gaim_conv_chat_get_users(GAIM_CONV_CHAT(c)));
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
938 yd->confs = g_slist_remove(yd->confs, c);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
939 } else {
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
940 yahoo_chat_leave(gc, gaim_conversation_get_name(c), gaim_connection_get_display_name(gc), TRUE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
941 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
942
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
943 serv_got_chat_left(gc, id);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
944 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
945
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12212
diff changeset
946 int yahoo_c_send(GaimConnection *gc, int id, const char *what, GaimMessageFlags flags)
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
947 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
948 GaimConversation *c;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
949 int ret;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
950 struct yahoo_data *yd;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
951
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
952 yd = (struct yahoo_data *) gc->proto_data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
953 if (!yd)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
954 return -1;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
955
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
956 c = gaim_find_chat(gc, id);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
957 if (!c)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
958 return -1;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
959
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
960 if (id != YAHOO_CHAT_ID) {
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
961 ret = yahoo_conf_send(gc, gaim_connection_get_display_name(gc),
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6804
diff changeset
962 gaim_conversation_get_name(c), gaim_conv_chat_get_users(GAIM_CONV_CHAT(c)), what);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
963 } else {
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
964 ret = yahoo_chat_send(gc, gaim_connection_get_display_name(gc),
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12212
diff changeset
965 gaim_conversation_get_name(c), what, flags);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
966 if (!ret)
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6804
diff changeset
967 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(c)),
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
968 gaim_connection_get_display_name(gc), 0, what, time(NULL));
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
969 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
970 return ret;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
971 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
972
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
973 GList *yahoo_c_info(GaimConnection *gc)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
974 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
975 GList *m = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
976 struct proto_chat_entry *pce;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
977
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
978 pce = g_new0(struct proto_chat_entry, 1);
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7827
diff changeset
979 pce->label = _("_Room:");
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
980 pce->identifier = "room";
10954
ec90b7d126be [gaim-migrate @ 12754]
Mark Doliner <mark@kingant.net>
parents: 10937
diff changeset
981 pce->required = TRUE;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
982 m = g_list_append(m, pce);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
983
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
984 return m;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
985 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
986
9768
ea1f457b7fef [gaim-migrate @ 10636]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
987 GHashTable *yahoo_c_info_defaults(GaimConnection *gc, const char *chat_name)
ea1f457b7fef [gaim-migrate @ 10636]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
988 {
ea1f457b7fef [gaim-migrate @ 10636]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
989 GHashTable *defaults;
ea1f457b7fef [gaim-migrate @ 10636]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
990
ea1f457b7fef [gaim-migrate @ 10636]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
991 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
ea1f457b7fef [gaim-migrate @ 10636]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
992
ea1f457b7fef [gaim-migrate @ 10636]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
993 if (chat_name != NULL)
ea1f457b7fef [gaim-migrate @ 10636]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
994 g_hash_table_insert(defaults, "room", g_strdup(chat_name));
ea1f457b7fef [gaim-migrate @ 10636]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
995
ea1f457b7fef [gaim-migrate @ 10636]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
996 return defaults;
ea1f457b7fef [gaim-migrate @ 10636]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
997 }
ea1f457b7fef [gaim-migrate @ 10636]
Luke Schierer <lschiere@pidgin.im>
parents: 9713
diff changeset
998
9917
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
999 char *yahoo_get_chat_name(GHashTable *data)
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1000 {
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1001 return g_strdup(g_hash_table_lookup(data, "room"));
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1002 }
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1003
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1004 void yahoo_c_join(GaimConnection *gc, GHashTable *data)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1005 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1006 struct yahoo_data *yd;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1007 char *room, *topic, *members, *type;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1008 int id;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1009 GaimConversation *c;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1010
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1011 yd = (struct yahoo_data *) gc->proto_data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1012 if (!yd)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1013 return;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1014
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1015 room = g_hash_table_lookup(data, "room");
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1016 if (!room)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1017 return;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1018
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1019 topic = g_hash_table_lookup(data, "topic");
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1020 if (!topic)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1021 topic = "";
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1022
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1023 members = g_hash_table_lookup(data, "members");
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1024
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1025 if ((type = g_hash_table_lookup(data, "type")) && !strcmp(type, "Conference")) {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1026 id = yd->conf_id++;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1027 c = serv_got_joined_chat(gc, id, room);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1028 yd->confs = g_slist_prepend(yd->confs, c);
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6804
diff changeset
1029 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), gaim_connection_get_display_name(gc), topic);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1030 yahoo_conf_join(yd, c, gaim_connection_get_display_name(gc), room, topic, members);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1031 return;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1032 } else {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1033 if (yd->in_chat)
7186
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
1034 yahoo_chat_leave(gc, room,
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
1035 gaim_connection_get_display_name(gc),
0da869011d8a [gaim-migrate @ 7754]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
1036 FALSE);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1037 if (!yd->chat_online)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1038 yahoo_chat_online(gc);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
1039 yahoo_chat_join(gc, gaim_connection_get_display_name(gc), room, topic);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1040 return;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1041 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1042 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1043
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1044 void yahoo_c_invite(GaimConnection *gc, int id, const char *msg, const char *name)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1045 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1046 GaimConversation *c;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1047
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1048 c = gaim_find_chat(gc, id);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1049 if (!c || !c->name)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1050 return;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1051
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1052 if (id != YAHOO_CHAT_ID) {
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
1053 yahoo_conf_invite(gc, c, gaim_connection_get_display_name(gc), name,
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1054 gaim_conversation_get_name(c), msg);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1055 } else {
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7186
diff changeset
1056 yahoo_chat_invite(gc, gaim_connection_get_display_name(gc), name,
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1057 gaim_conversation_get_name(c), msg);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1058 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1059 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1060
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1061 struct yahoo_roomlist {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1062 int fd;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1063 int inpa;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1064 guchar *rxqueue;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1065 int rxlen;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1066 gboolean started;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1067 char *path;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1068 char *host;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1069 GaimRoomlist *list;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1070 GaimRoomlistRoom *cat;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1071 GaimRoomlistRoom *ucat;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1072 GMarkupParseContext *parse;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1073 };
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1074
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1075 static void yahoo_roomlist_destroy(struct yahoo_roomlist *yrl)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1076 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1077 if (yrl->inpa)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1078 gaim_input_remove(yrl->inpa);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1079 if (yrl->rxqueue)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1080 g_free(yrl->rxqueue);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1081 if (yrl->path)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1082 g_free(yrl->path);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1083 if (yrl->host)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1084 g_free(yrl->host);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1085 if (yrl->parse)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1086 g_markup_parse_context_free(yrl->parse);
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10394
diff changeset
1087 g_free(yrl);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1088 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1089
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1090 enum yahoo_room_type {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1091 yrt_yahoo,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1092 yrt_user,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1093 };
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1094
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1095 struct yahoo_chatxml_state {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1096 GaimRoomlist *list;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1097 struct yahoo_roomlist *yrl;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1098 GQueue *q;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1099 struct {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1100 enum yahoo_room_type type;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1101 char *name;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1102 char *topic;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1103 char *id;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1104 int users, voices, webcams;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1105 } room;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1106 };
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1107
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1108 struct yahoo_lobby {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1109 int count, users, voices, webcams;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1110 };
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1111
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1112 static struct yahoo_chatxml_state *yahoo_chatxml_state_new(GaimRoomlist *list, struct yahoo_roomlist *yrl)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1113 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1114 struct yahoo_chatxml_state *s;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1115
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1116 s = g_new0(struct yahoo_chatxml_state, 1);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1117 s->list = list;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1118 s->yrl = yrl;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1119 s->q = g_queue_new();
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1120
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1121 return s;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1122 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1123
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1124 static void yahoo_chatxml_state_destroy(struct yahoo_chatxml_state *s)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1125 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1126 g_queue_free(s->q);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1127 if (s->room.name)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1128 g_free(s->room.name);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1129 if (s->room.topic)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1130 g_free(s->room.topic);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1131 if (s->room.id)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1132 g_free(s->room.id);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1133 g_free(s);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1134 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1135
11644
f4e58e94ced3 [gaim-migrate @ 13922]
Mark Doliner <mark@kingant.net>
parents: 11593
diff changeset
1136 static void yahoo_chatlist_start_element(GMarkupParseContext *context,
f4e58e94ced3 [gaim-migrate @ 13922]
Mark Doliner <mark@kingant.net>
parents: 11593
diff changeset
1137 const gchar *ename, const gchar **anames,
f4e58e94ced3 [gaim-migrate @ 13922]
Mark Doliner <mark@kingant.net>
parents: 11593
diff changeset
1138 const gchar **avalues, gpointer user_data,
f4e58e94ced3 [gaim-migrate @ 13922]
Mark Doliner <mark@kingant.net>
parents: 11593
diff changeset
1139 GError **error)
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1140 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1141 struct yahoo_chatxml_state *s = user_data;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1142 GaimRoomlist *list = s->list;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1143 GaimRoomlistRoom *r;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1144 GaimRoomlistRoom *parent;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1145 int i;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1146
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1147 if (!strcmp(ename, "category")) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1148 const gchar *name = NULL, *id = NULL;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1149
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1150 for (i = 0; anames[i]; i++) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1151 if (!strcmp(anames[i], "id"))
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1152 id = avalues[i];
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1153 if (!strcmp(anames[i], "name"))
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1154 name = avalues[i];
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1155 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1156 if (!name || !id)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1157 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1158
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1159 parent = g_queue_peek_head(s->q);
8584
058efd3cb86f [gaim-migrate @ 9334]
Luke Schierer <lschiere@pidgin.im>
parents: 8410
diff changeset
1160 r = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_CATEGORY, name, parent);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1161 gaim_roomlist_room_add_field(list, r, (gpointer)name);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1162 gaim_roomlist_room_add_field(list, r, (gpointer)id);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1163 gaim_roomlist_room_add(list, r);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1164 g_queue_push_head(s->q, r);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1165 } else if (!strcmp(ename, "room")) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1166 s->room.users = s->room.voices = s->room.webcams = 0;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1167
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1168 for (i = 0; anames[i]; i++) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1169 if (!strcmp(anames[i], "id")) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1170 if (s->room.id)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1171 g_free(s->room.id);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1172 s->room.id = g_strdup(avalues[i]);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1173 } else if (!strcmp(anames[i], "name")) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1174 if (s->room.name)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1175 g_free(s->room.name);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1176 s->room.name = g_strdup(avalues[i]);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1177 } else if (!strcmp(anames[i], "topic")) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1178 if (s->room.topic)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1179 g_free(s->room.topic);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1180 s->room.topic = g_strdup(avalues[i]);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1181 } else if (!strcmp(anames[i], "type")) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1182 if (!strcmp("yahoo", avalues[i]))
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1183 s->room.type = yrt_yahoo;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1184 else
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1185 s->room.type = yrt_user;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1186 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1187 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1188
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1189 } else if (!strcmp(ename, "lobby")) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1190 struct yahoo_lobby *lob = g_new0(struct yahoo_lobby, 1);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1191
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1192 for (i = 0; anames[i]; i++) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1193 if (!strcmp(anames[i], "count")) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1194 lob->count = strtol(avalues[i], NULL, 10);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1195 } else if (!strcmp(anames[i], "users")) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1196 s->room.users += lob->users = strtol(avalues[i], NULL, 10);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1197 } else if (!strcmp(anames[i], "voices")) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1198 s->room.voices += lob->voices = strtol(avalues[i], NULL, 10);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1199 } else if (!strcmp(anames[i], "webcams")) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1200 s->room.webcams += lob->webcams = strtol(avalues[i], NULL, 10);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1201 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1202 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1203 g_queue_push_head(s->q, lob);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1204 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1205 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1206
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1207 static void yahoo_chatlist_end_element(GMarkupParseContext *context, const gchar *ename,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1208 gpointer user_data, GError **error)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1209 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1210 struct yahoo_chatxml_state *s = user_data;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1211
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1212 if (!strcmp(ename, "category")) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1213 g_queue_pop_head(s->q);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1214 } else if (!strcmp(ename, "room")) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1215 struct yahoo_lobby *lob;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1216 GaimRoomlistRoom *r, *l;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1217
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1218 if (s->room.type == yrt_yahoo)
8584
058efd3cb86f [gaim-migrate @ 9334]
Luke Schierer <lschiere@pidgin.im>
parents: 8410
diff changeset
1219 r = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_CATEGORY|GAIM_ROOMLIST_ROOMTYPE_ROOM,
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1220 s->room.name, s->yrl->cat);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1221 else
8584
058efd3cb86f [gaim-migrate @ 9334]
Luke Schierer <lschiere@pidgin.im>
parents: 8410
diff changeset
1222 r = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_CATEGORY|GAIM_ROOMLIST_ROOMTYPE_ROOM,
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1223 s->room.name, s->yrl->ucat);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1224
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1225 gaim_roomlist_room_add_field(s->list, r, s->room.name);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1226 gaim_roomlist_room_add_field(s->list, r, s->room.id);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1227 gaim_roomlist_room_add_field(s->list, r, GINT_TO_POINTER(s->room.users));
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1228 gaim_roomlist_room_add_field(s->list, r, GINT_TO_POINTER(s->room.voices));
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1229 gaim_roomlist_room_add_field(s->list, r, GINT_TO_POINTER(s->room.webcams));
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1230 gaim_roomlist_room_add_field(s->list, r, s->room.topic);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1231 gaim_roomlist_room_add(s->list, r);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1232
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1233 while ((lob = g_queue_pop_head(s->q))) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1234 char *name = g_strdup_printf("%s:%d", s->room.name, lob->count);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1235 l = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_ROOM, name, r);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1236
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1237 gaim_roomlist_room_add_field(s->list, l, name);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1238 gaim_roomlist_room_add_field(s->list, l, s->room.id);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1239 gaim_roomlist_room_add_field(s->list, l, GINT_TO_POINTER(lob->users));
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1240 gaim_roomlist_room_add_field(s->list, l, GINT_TO_POINTER(lob->voices));
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1241 gaim_roomlist_room_add_field(s->list, l, GINT_TO_POINTER(lob->webcams));
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1242 gaim_roomlist_room_add_field(s->list, l, s->room.topic);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1243 gaim_roomlist_room_add(s->list, l);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1244
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1245 g_free(name);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1246 g_free(lob);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1247 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1248 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1249 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1250
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1251 static GMarkupParser parser = {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1252 yahoo_chatlist_start_element,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1253 yahoo_chatlist_end_element,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1254 NULL,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1255 NULL,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1256 NULL
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1257 };
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1258
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1259 static void yahoo_roomlist_cleanup(GaimRoomlist *list, struct yahoo_roomlist *yrl)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1260 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1261 gaim_roomlist_set_in_progress(list, FALSE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1262
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1263 if (yrl) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1264 list->proto_data = g_list_remove(list->proto_data, yrl);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1265 yahoo_roomlist_destroy(yrl);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1266 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1267
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1268 gaim_roomlist_unref(list);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1269 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1270
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1271 static void yahoo_roomlist_pending(gpointer data, gint source, GaimInputCondition cond)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1272 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1273 struct yahoo_roomlist *yrl = data;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1274 GaimRoomlist *list = yrl->list;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1275 char buf[1024];
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1276 int len;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1277 guchar *start;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1278 struct yahoo_chatxml_state *s;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1279
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1280 len = read(yrl->fd, buf, sizeof(buf));
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1281
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1282 if (len <= 0) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1283 if (yrl->parse)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1284 g_markup_parse_context_end_parse(yrl->parse, NULL);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1285 yahoo_roomlist_cleanup(list, yrl);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1286 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1287 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1288
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1289 yrl->rxqueue = g_realloc(yrl->rxqueue, len + yrl->rxlen);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1290 memcpy(yrl->rxqueue + yrl->rxlen, buf, len);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1291 yrl->rxlen += len;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1292
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1293 if (!yrl->started) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1294 yrl->started = TRUE;
11318
519dc2186438 [gaim-migrate @ 13521]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11044
diff changeset
1295 start = (guchar *)g_strstr_len((char *)yrl->rxqueue, yrl->rxlen, "\r\n\r\n");
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1296 if (!start || (start - yrl->rxqueue + 4) >= yrl->rxlen)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1297 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1298 start += 4;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1299 } else {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1300 start = yrl->rxqueue;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1301 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1302
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1303 if (yrl->parse == NULL) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1304 s = yahoo_chatxml_state_new(list, yrl);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1305 yrl->parse = g_markup_parse_context_new(&parser, 0, s,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1306 (GDestroyNotify)yahoo_chatxml_state_destroy);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1307 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1308
11318
519dc2186438 [gaim-migrate @ 13521]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11044
diff changeset
1309 if (!g_markup_parse_context_parse(yrl->parse, (char *)start, (yrl->rxlen - (start - yrl->rxqueue)), NULL)) {
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1310
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1311 yahoo_roomlist_cleanup(list, yrl);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1312 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1313 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1314
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1315 yrl->rxlen = 0;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1316 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1317
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1318 static void yahoo_roomlist_got_connected(gpointer data, gint source, GaimInputCondition cond)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1319 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1320 struct yahoo_roomlist *yrl = data;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1321 GaimRoomlist *list = yrl->list;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1322 char *buf, *cookie;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1323 struct yahoo_data *yd = gaim_account_get_connection(list->account)->proto_data;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1324
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1325 if (source < 0) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1326 gaim_notify_error(gaim_account_get_connection(list->account), NULL, _("Unable to connect"), _("Fetching the room list failed."));
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1327 yahoo_roomlist_cleanup(list, yrl);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1328 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1329 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1330
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1331 yrl->fd = source;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1332
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1333 cookie = g_strdup_printf("Y=%s; T=%s", yd->cookie_y, yd->cookie_t);
10575
96307e1a47c9 [gaim-migrate @ 11968]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
1334 buf = g_strdup_printf("GET http://%s/%s HTTP/1.0\r\nHost: %s\r\nCookie: %s\r\n\r\n",
96307e1a47c9 [gaim-migrate @ 11968]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
1335 yrl->host, yrl->path, yrl->host, cookie);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1336 write(yrl->fd, buf, strlen(buf));
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1337 g_free(cookie);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1338 g_free(buf);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1339 yrl->inpa = gaim_input_add(yrl->fd, GAIM_INPUT_READ, yahoo_roomlist_pending, yrl);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1340
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1341 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1342
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1343 GaimRoomlist *yahoo_roomlist_get_list(GaimConnection *gc)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1344 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1345 struct yahoo_roomlist *yrl;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1346 GaimRoomlist *rl;
12212
c9a943c60c33 [gaim-migrate @ 14514]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11644
diff changeset
1347 const char *rll;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1348 char *url;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1349 GList *fields = NULL;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1350 GaimRoomlistField *f;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1351
12212
c9a943c60c33 [gaim-migrate @ 14514]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11644
diff changeset
1352 rll = gaim_account_get_string(gaim_connection_get_account(gc),
c9a943c60c33 [gaim-migrate @ 14514]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11644
diff changeset
1353 "room_list_locale", YAHOO_ROOMLIST_LOCALE);
c9a943c60c33 [gaim-migrate @ 14514]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11644
diff changeset
1354
c9a943c60c33 [gaim-migrate @ 14514]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11644
diff changeset
1355 if (rll != NULL && *rll != '\0') {
11043
629cbfd1ed6d [gaim-migrate @ 12957]
Richard Laager <rlaager@wiktel.com>
parents: 10954
diff changeset
1356 url = g_strdup_printf("%s?chatcat=0&intl=%s",
629cbfd1ed6d [gaim-migrate @ 12957]
Richard Laager <rlaager@wiktel.com>
parents: 10954
diff changeset
1357 gaim_account_get_string(gaim_connection_get_account(gc),
12212
c9a943c60c33 [gaim-migrate @ 14514]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11644
diff changeset
1358 "room_list", YAHOO_ROOMLIST_URL), rll);
11043
629cbfd1ed6d [gaim-migrate @ 12957]
Richard Laager <rlaager@wiktel.com>
parents: 10954
diff changeset
1359 } else {
629cbfd1ed6d [gaim-migrate @ 12957]
Richard Laager <rlaager@wiktel.com>
parents: 10954
diff changeset
1360 url = g_strdup_printf("%s?chatcat=0",
629cbfd1ed6d [gaim-migrate @ 12957]
Richard Laager <rlaager@wiktel.com>
parents: 10954
diff changeset
1361 gaim_account_get_string(gaim_connection_get_account(gc),
629cbfd1ed6d [gaim-migrate @ 12957]
Richard Laager <rlaager@wiktel.com>
parents: 10954
diff changeset
1362 "room_list", YAHOO_ROOMLIST_URL));
629cbfd1ed6d [gaim-migrate @ 12957]
Richard Laager <rlaager@wiktel.com>
parents: 10954
diff changeset
1363 }
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1364
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1365 yrl = g_new0(struct yahoo_roomlist, 1);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1366 rl = gaim_roomlist_new(gaim_connection_get_account(gc));
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1367 yrl->list = rl;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1368
9227
9171e528d7e5 [gaim-migrate @ 10023]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
1369 gaim_url_parse(url, &(yrl->host), NULL, &(yrl->path), NULL, NULL);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1370 g_free(url);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1371
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1372 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", "room", TRUE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1373 fields = g_list_append(fields, f);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1374
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1375 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", "id", TRUE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1376 fields = g_list_append(fields, f);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1377
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1378 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_INT, _("Users"), "users", FALSE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1379 fields = g_list_append(fields, f);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1380
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1381 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_INT, _("Voices"), "voices", FALSE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1382 fields = g_list_append(fields, f);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1383
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1384 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_INT, _("Webcams"), "webcams", FALSE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1385 fields = g_list_append(fields, f);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1386
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1387 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, _("Topic"), "topic", FALSE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1388 fields = g_list_append(fields, f);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1389
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1390 gaim_roomlist_set_fields(rl, fields);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1391
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1392 if (gaim_proxy_connect(gaim_connection_get_account(gc),
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1393 yrl->host, 80, yahoo_roomlist_got_connected, yrl) != 0)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1394 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1395 gaim_notify_error(gc, NULL, _("Connection problem"), _("Unable to fetch room list."));
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1396 yahoo_roomlist_cleanup(rl, yrl);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1397 return NULL;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1398 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1399
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1400 rl->proto_data = g_list_append(rl->proto_data, yrl);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1401
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1402 gaim_roomlist_set_in_progress(rl, TRUE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1403 return rl;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1404 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1405
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1406 void yahoo_roomlist_cancel(GaimRoomlist *list)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1407 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1408 GList *l, *k;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1409
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1410 k = l = list->proto_data;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1411 list->proto_data = NULL;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1412
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1413 gaim_roomlist_set_in_progress(list, FALSE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1414
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1415 for (; l; l = l->next) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1416 yahoo_roomlist_destroy(l->data);
10647
7d13c04387ad [gaim-migrate @ 12163]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10575
diff changeset
1417 gaim_roomlist_unref(list);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1418 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1419 g_list_free(k);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1420 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1421
8584
058efd3cb86f [gaim-migrate @ 9334]
Luke Schierer <lschiere@pidgin.im>
parents: 8410
diff changeset
1422 void yahoo_roomlist_expand_category(GaimRoomlist *list, GaimRoomlistRoom *category)
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1423 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1424 struct yahoo_roomlist *yrl;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1425 char *url;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1426 char *id;
12212
c9a943c60c33 [gaim-migrate @ 14514]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11644
diff changeset
1427 const char *rll;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1428
8584
058efd3cb86f [gaim-migrate @ 9334]
Luke Schierer <lschiere@pidgin.im>
parents: 8410
diff changeset
1429 if (category->type != GAIM_ROOMLIST_ROOMTYPE_CATEGORY)
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1430 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1431
8584
058efd3cb86f [gaim-migrate @ 9334]
Luke Schierer <lschiere@pidgin.im>
parents: 8410
diff changeset
1432 if (!(id = g_list_nth_data(category->fields, 1))) {
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1433 gaim_roomlist_set_in_progress(list, FALSE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1434 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1435 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1436
12212
c9a943c60c33 [gaim-migrate @ 14514]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11644
diff changeset
1437 rll = gaim_account_get_string(list->account, "room_list_locale",
c9a943c60c33 [gaim-migrate @ 14514]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11644
diff changeset
1438 YAHOO_ROOMLIST_LOCALE);
c9a943c60c33 [gaim-migrate @ 14514]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11644
diff changeset
1439
c9a943c60c33 [gaim-migrate @ 14514]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11644
diff changeset
1440 if (rll != NULL && *rll != '\0') {
11043
629cbfd1ed6d [gaim-migrate @ 12957]
Richard Laager <rlaager@wiktel.com>
parents: 10954
diff changeset
1441 url = g_strdup_printf("%s?chatroom_%s=0&intl=%s",
12212
c9a943c60c33 [gaim-migrate @ 14514]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11644
diff changeset
1442 gaim_account_get_string(list->account,"room_list",
c9a943c60c33 [gaim-migrate @ 14514]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11644
diff changeset
1443 YAHOO_ROOMLIST_URL), id, rll);
11043
629cbfd1ed6d [gaim-migrate @ 12957]
Richard Laager <rlaager@wiktel.com>
parents: 10954
diff changeset
1444 } else {
629cbfd1ed6d [gaim-migrate @ 12957]
Richard Laager <rlaager@wiktel.com>
parents: 10954
diff changeset
1445 url = g_strdup_printf("%s?chatroom_%s=0",
629cbfd1ed6d [gaim-migrate @ 12957]
Richard Laager <rlaager@wiktel.com>
parents: 10954
diff changeset
1446 gaim_account_get_string(list->account,"room_list",
629cbfd1ed6d [gaim-migrate @ 12957]
Richard Laager <rlaager@wiktel.com>
parents: 10954
diff changeset
1447 YAHOO_ROOMLIST_URL), id);
629cbfd1ed6d [gaim-migrate @ 12957]
Richard Laager <rlaager@wiktel.com>
parents: 10954
diff changeset
1448 }
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1449
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1450 yrl = g_new0(struct yahoo_roomlist, 1);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1451 yrl->list = list;
8584
058efd3cb86f [gaim-migrate @ 9334]
Luke Schierer <lschiere@pidgin.im>
parents: 8410
diff changeset
1452 yrl->cat = category;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1453 list->proto_data = g_list_append(list->proto_data, yrl);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1454
9227
9171e528d7e5 [gaim-migrate @ 10023]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
1455 gaim_url_parse(url, &(yrl->host), NULL, &(yrl->path), NULL, NULL);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1456 g_free(url);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1457
8584
058efd3cb86f [gaim-migrate @ 9334]
Luke Schierer <lschiere@pidgin.im>
parents: 8410
diff changeset
1458 yrl->ucat = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_CATEGORY, _("User Rooms"), yrl->cat);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1459 gaim_roomlist_room_add(list, yrl->ucat);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1460
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1461 if (gaim_proxy_connect(list->account,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1462 yrl->host, 80, yahoo_roomlist_got_connected, yrl) != 0)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1463 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1464 gaim_notify_error(gaim_account_get_connection(list->account),
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1465 NULL, _("Connection problem"), _("Unable to fetch room list."));
10647
7d13c04387ad [gaim-migrate @ 12163]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10575
diff changeset
1466 gaim_roomlist_ref(list);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1467 yahoo_roomlist_cleanup(list, yrl);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1468 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1469 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1470
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1471 gaim_roomlist_set_in_progress(list, TRUE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1472 gaim_roomlist_ref(list);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1473 }