annotate src/protocols/yahoo/yahoo.c @ 7747:3906c0957d4f

[gaim-migrate @ 8392] Felipe Contreras (revo) gives us i18n yahoo email notification committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Thu, 04 Dec 2003 12:20:30 +0000
parents 29bcd6e3da33
children a481ffe303d2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * gaim
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx>
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 *
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 * (at your option) any later version.
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 *
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 * GNU General Public License for more details.
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 *
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 *
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
22 #include "internal.h"
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
24 #include "account.h"
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5590
diff changeset
25 #include "accountopt.h"
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
26 #include "blist.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
27 #include "debug.h"
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 #include "multi.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
29 #include "notify.h"
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
30 #include "privacy.h"
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include "prpl.h"
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #include "proxy.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
33 #include "request.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
34 #include "server.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
35 #include "util.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
36
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
37 #include "sha.h"
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
38 #include "yahoo.h"
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
39 #include "yahoochat.h"
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
40 #include "yahoo_filexfer.h"
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
41 #include "md5.h"
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
43 extern char *yahoo_crypt(const char *, const char *);
2795
536bb833fdeb [gaim-migrate @ 2808]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2786
diff changeset
44
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
45 typedef struct
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
46 {
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
47 GaimConnection *gc;
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
48 char *name;
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
49 } YahooGetInfoData;
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
50
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
51
5493
3e8487580024 [gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
52 /* #define YAHOO_DEBUG */
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 #define USEROPT_MAIL 0
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
56 #define YAHOO_PAGER_HOST "scs.yahoo.com"
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 #define YAHOO_PAGER_PORT 5050
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
58 #define YAHOO_PROFILE_URL "http://profiles.yahoo.com/"
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60
6791
9927df765fae [gaim-migrate @ 7330]
Luke Schierer <lschiere@pidgin.im>
parents: 6787
diff changeset
61 static void yahoo_add_buddy(GaimConnection *gc, const char *who, GaimGroup *);
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
62
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
63 static struct yahoo_friend *yahoo_friend_new()
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
64 {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
65 struct yahoo_friend *ret;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
66
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
67 ret = g_new0(struct yahoo_friend, 1);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
68 ret->status = YAHOO_STATUS_OFFLINE;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
69
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
70 return ret;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
71 }
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
72
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
73 static void yahoo_friend_free(gpointer p)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
74 {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
75 struct yahoo_friend *f = p;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
76 if (f->msg)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
77 g_free(f->msg);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
78 if (f->game)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
79 g_free(f->game);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
80 g_free(f);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
81 }
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
82
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
83 struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 struct yahoo_packet *pkt = g_new0(struct yahoo_packet, 1);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 pkt->service = service;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 pkt->status = status;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 pkt->id = id;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 return pkt;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
94 void yahoo_packet_hash(struct yahoo_packet *pkt, int key, const char *value)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 pair->key = key;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 pair->value = g_strdup(value);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 pkt->hash = g_slist_append(pkt->hash, pair);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
102 int yahoo_packet_length(struct yahoo_packet *pkt)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 GSList *l;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 int len = 0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 l = pkt->hash;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 while (l) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 struct yahoo_pair *pair = l->data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 int tmp = pair->key;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 do {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 tmp /= 10;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 len++;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 } while (tmp);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 len += 2;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 len += strlen(pair->value);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 len += 2;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 l = l->next;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 return len;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 static void yahoo_packet_read(struct yahoo_packet *pkt, guchar *data, int len)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 int pos = 0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 while (pos + 1 < len) {
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6623
diff changeset
130 char key[64], *value = NULL, *esc;
2724
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
131 int accept;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 int x;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 x = 0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 while (pos + 1 < len) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 if (data[pos] == 0xc0 && data[pos + 1] == 0x80)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140 key[x++] = data[pos++];
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 key[x] = 0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 pos += 2;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 pair->key = strtol(key, NULL, 10);
2724
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
145 accept = x; /* if x is 0 there was no key, so don't accept it */
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146
3996
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
147 if (len - pos + 1 <= 0) {
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
148 /* Truncated. Garbage or something. */
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
149 accept = 0;
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
150 }
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
151
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
152 if (accept) {
2724
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
153 value = g_malloc(len - pos + 1);
3996
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
154 x = 0;
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
155 while (pos + 1 < len) {
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
156 if (data[pos] == 0xc0 && data[pos + 1] == 0x80)
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
157 break;
2724
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
158 value[x++] = data[pos++];
3996
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
159 }
2724
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
160 value[x] = 0;
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
161 pair->value = g_strdup(value);
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
162 g_free(value);
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
163 pkt->hash = g_slist_append(pkt->hash, pair);
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6623
diff changeset
164 esc = g_strescape(pair->value, NULL);
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
165 gaim_debug(GAIM_DEBUG_MISC, "yahoo",
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6623
diff changeset
166 "Key: %d \tValue: %s\n", pair->key, esc);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6623
diff changeset
167 g_free(esc);
2724
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
168 } else {
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
169 g_free(pair);
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
170 }
3996
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
171 pos += 2;
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
172
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
173 /* Skip over garbage we've noticed in the mail notifications */
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
174 if (data[0] == '9' && data[pos] == 0x01)
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
175 pos++;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
179 void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 GSList *l = pkt->hash;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 int pos = 0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 while (l) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185 struct yahoo_pair *pair = l->data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 guchar buf[100];
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188 g_snprintf(buf, sizeof(buf), "%d", pair->key);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 strcpy(data + pos, buf);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 pos += strlen(buf);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 data[pos++] = 0xc0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 data[pos++] = 0x80;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194 strcpy(data + pos, pair->value);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195 pos += strlen(pair->value);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196 data[pos++] = 0xc0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 data[pos++] = 0x80;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199 l = l->next;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 static void yahoo_packet_dump(guchar *data, int len)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 #ifdef YAHOO_DEBUG
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206 int i;
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
207
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
208 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "");
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
209
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210 for (i = 0; i + 1 < len; i += 2) {
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
211 if ((i % 16 == 0) && i) {
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
212 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n");
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
213 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "");
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
214 }
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
215
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
216 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x%02x ", data[i], data[i + 1]);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 if (i < len)
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
219 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x", data[i]);
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
220
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
221 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n");
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
222 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "");
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
223
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 for (i = 0; i < len; i++) {
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
225 if ((i % 16 == 0) && i) {
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
226 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n");
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
227 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "");
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
228 }
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
229
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
230 if (g_ascii_isprint(data[i]))
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
231 gaim_debug(GAIM_DEBUG_MISC, NULL, "%c ", data[i]);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 else
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
233 gaim_debug(GAIM_DEBUG_MISC, NULL, ". ");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234 }
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
235
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
236 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 #endif
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
239
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
240 int yahoo_send_packet(struct yahoo_data *yd, struct yahoo_packet *pkt)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
242 int pktlen = yahoo_packet_length(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 int len = YAHOO_PACKET_HDRLEN + pktlen;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 int ret;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 guchar *data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247 int pos = 0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 if (yd->fd < 0)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250 return -1;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 data = g_malloc0(len + 1);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
254 memcpy(data + pos, "YMSG", 4); pos += 4;
3467
79e0d2f8ad2b [gaim-migrate @ 3517]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
255 pos += yahoo_put16(data + pos, YAHOO_PROTO_VER);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 pos += yahoo_put16(data + pos, 0x0000);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257 pos += yahoo_put16(data + pos, pktlen);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 pos += yahoo_put16(data + pos, pkt->service);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 pos += yahoo_put32(data + pos, pkt->status);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 pos += yahoo_put32(data + pos, pkt->id);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 yahoo_packet_write(pkt, data + pos);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 yahoo_packet_dump(data, len);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 ret = write(yd->fd, data, len);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 g_free(data);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268 return ret;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
271 void yahoo_packet_free(struct yahoo_packet *pkt)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 while (pkt->hash) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 struct yahoo_pair *pair = pkt->hash->data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275 g_free(pair->value);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276 g_free(pair);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 pkt->hash = g_slist_remove(pkt->hash, pair);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 g_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
282 static void yahoo_update_status(GaimConnection *gc, const char *name, struct yahoo_friend *f)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
283 {
6840
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
284 int online = 1;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
285
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
286 if (!gc || !name || !f || !gaim_find_buddy(gaim_connection_get_account(gc), name))
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
287 return;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
288
6840
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
289 if (f->status == YAHOO_STATUS_OFFLINE)
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
290 online = 0;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
291
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
292 serv_got_update(gc, name, online, 0, 0, f->idle, f->away ? UC_UNAVAILABLE : 0);
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
293 }
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
294
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
295 static void yahoo_process_status(GaimConnection *gc, struct yahoo_packet *pkt)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297 struct yahoo_data *yd = gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 GSList *l = pkt->hash;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
299 struct yahoo_friend *f = NULL;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300 char *name = NULL;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
301
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
302
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 while (l) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 struct yahoo_pair *pair = l->data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 switch (pair->key) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307 case 0: /* we won't actually do anything with this */
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 case 1: /* we don't get the full buddy list here. */
2805
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
310 if (!yd->logged_in) {
7664
e4264f71fac7 [gaim-migrate @ 8308]
Luke Schierer <lschiere@pidgin.im>
parents: 7651
diff changeset
311 gaim_connection_set_display_name(gc, pair->value);
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
312 gaim_connection_set_state(gc, GAIM_CONNECTED);
2805
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
313 serv_finish_login(gc);
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
314 yd->logged_in = TRUE;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
316 /* this requests the list. i have a feeling that this is very evil
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
317 *
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
318 * scs.yahoo.com sends you the list before this packet without it being
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
319 * requested
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
320 *
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
321 * do_import(gc, NULL);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
322 * newpkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YAHOO_STATUS_OFFLINE, 0);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
323 * yahoo_send_packet(yd, newpkt);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
324 * yahoo_packet_free(newpkt);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
325 */
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
326
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
327 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
328 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
329 case 8: /* how many online buddies we have */
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
330 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
331 case 7: /* the current buddy */
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332 name = pair->value;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
333 f = g_hash_table_lookup(yd->friends, name);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
334 if (!f) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
335 f = yahoo_friend_new();
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
336 g_hash_table_insert(yd->friends, g_strdup(name), f);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
337 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339 case 10: /* state */
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
340 if (!f)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
341 break;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
342
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
343 f->status = strtol(pair->value, NULL, 10);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
344 if ((f->status >= YAHOO_STATUS_BRB) && (f->status <= YAHOO_STATUS_STEPPEDOUT))
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
345 f->away = 1;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
346 else
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
347 f->away = 0;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
348 if (f->status == YAHOO_STATUS_IDLE)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
349 f->idle = time(NULL);
6804
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6796
diff changeset
350 else
3ef17670e69f [gaim-migrate @ 7344]
Luke Schierer <lschiere@pidgin.im>
parents: 6796
diff changeset
351 f->idle = 0;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
352 if (f->status != YAHOO_STATUS_CUSTOM) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
353 g_free(f->msg);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
354 f->msg = NULL;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
355 }
6847
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
356
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
357 f->sms = 0;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359 case 19: /* custom message */
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
360 if (f) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
361 if (f->msg)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
362 g_free(f->msg);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
363 f->msg = g_strdup(pair->value);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
364 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365 break;
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
366 case 11: /* this is the buddy's session id */
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368 case 17: /* in chat? */
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
369 break;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
370 case 47: /* is custom status away or not? 2=idle*/
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
371 if (!f)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
372 break;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
373 f->away = strtol(pair->value, NULL, 10);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
374 if (f->away == 2)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
375 f->idle = time(NULL);
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
376 break;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
377 case 138: /* either we're not idle, or we are but won't say how long */
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
378 if (!f)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
379 break;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
380
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
381 if (f->idle)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
382 f->idle = -1;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
383 break;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
384 case 137: /* usually idle time in seconds, sometimes login time */
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
385 if (!f)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
386 break;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
387
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
388 if (f->status != YAHOO_STATUS_AVAILABLE)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
389 f->idle = time(NULL) - strtol(pair->value, NULL, 10);
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
390 break;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
391 case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
392 if (strtol(pair->value, NULL, 10) == 0) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
393 if (f)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
394 f->status = YAHOO_STATUS_OFFLINE;
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4731
diff changeset
395 serv_got_update(gc, name, 0, 0, 0, 0, 0);
2807
f01e6a425136 [gaim-migrate @ 2820]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2805
diff changeset
396 break;
2805
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
397 }
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
398
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
399 if (f)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
400 yahoo_update_status(gc, name, f);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
401 break;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
402 case 60: /* SMS */
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
403 if (f) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
404 f->sms = strtol(pair->value, NULL, 10);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
405 yahoo_update_status(gc, name, f);
2771
450f4f9d2f23 [gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2741
diff changeset
406 }
450f4f9d2f23 [gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2741
diff changeset
407 break;
2979
8e924e4aa256 [gaim-migrate @ 2992]
Rob Flynn <gaim@robflynn.com>
parents: 2951
diff changeset
408 case 16: /* Custom error message */
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5367
diff changeset
409 gaim_notify_error(gc, NULL, pair->value, NULL);
2951
b74f4f7165a1 [gaim-migrate @ 2964]
Rob Flynn <gaim@robflynn.com>
parents: 2918
diff changeset
410 break;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
411 default:
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
412 gaim_debug(GAIM_DEBUG_ERROR, "yahoo",
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
413 "Unknown status key %d\n", pair->key);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
414 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
415 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
416
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
417 l = l->next;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
418 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
419 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
420
6820
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
421 static void yahoo_do_group_check(GaimAccount *account, GHashTable *ht, const char *name, const char *group,
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
422 gboolean *export)
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
423 {
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
424 GaimBuddy *b;
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
425 GaimGroup *g;
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
426 GSList *list, *i;
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
427 gboolean onlist = 0;
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
428 char *oname = NULL;
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
429
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
430 if (!g_hash_table_lookup_extended(ht, name, (gpointer *) &oname, (gpointer *) &list))
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
431 list = gaim_find_buddies(account, name);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
432 else
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
433 g_hash_table_steal(ht, name);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
434
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
435 for (i = list; i; i = i->next) {
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
436 b = i->data;
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
437 g = gaim_find_buddys_group(b);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
438 if (!gaim_utf8_strcasecmp(group, g->name)) {
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
439 gaim_debug(GAIM_DEBUG_MISC, "yahoo",
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
440 "Oh good, %s is in the right group (%s).\n", name, group);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
441 list = g_slist_delete_link(list, i);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
442 onlist = 1;
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
443 break;
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
444 }
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
445 }
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
446
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
447 if (!onlist) {
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
448 gaim_debug(GAIM_DEBUG_MISC, "yahoo",
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
449 "Uhoh, %s isn't on the list (or not in this group), adding him to group %s.\n", name, group);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
450 if (!(g = gaim_find_group(group))) {
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
451 g = gaim_group_new(group);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
452 gaim_blist_add_group(g, NULL);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
453 }
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
454 b = gaim_buddy_new(account, name, NULL);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
455 gaim_blist_add_buddy(b, NULL, g, NULL);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
456 *export = TRUE;
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
457 }
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
458
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
459 if (list) {
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
460 if (!oname)
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
461 oname = g_strdup(name);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
462 g_hash_table_insert(ht, oname, list);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
463 } else if (oname)
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
464 g_free(oname);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
465 }
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
466
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
467 static void yahoo_do_group_cleanup(gpointer key, gpointer value, gpointer user_data)
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
468 {
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
469 char *name = key;
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
470 GSList *list = value, *i;
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
471 GaimBuddy *b;
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
472 GaimGroup *g;
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
473 gboolean *export = user_data;
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
474
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
475 if (list)
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
476 *export = TRUE;
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
477
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
478 for (i = list; i; i = i->next) {
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
479 b = i->data;
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
480 g = gaim_find_buddys_group(b);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
481 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "Deleting Buddy %s from group %s.\n", name, g->name);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
482 gaim_blist_remove_buddy(b);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
483 }
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
484 }
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
485
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
486 static char *_getcookie(char *rawcookie)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
487 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
488 char *cookie = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
489 char *tmpcookie;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
490 char *cookieend;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
491
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
492 if (strlen(rawcookie) < 2)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
493 return NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
494 tmpcookie = g_strdup(rawcookie+2);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
495 cookieend = strchr(tmpcookie, ';');
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
496
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
497 if (cookieend)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
498 *cookieend = '\0';
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
499
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
500 cookie = g_strdup(tmpcookie);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
501 g_free(tmpcookie);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
502
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
503 return cookie;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
504 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
505
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
506 static void yahoo_process_cookie(struct yahoo_data *yd, char *c)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
507 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
508 if (c[0] == 'Y') {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
509 if (yd->cookie_y)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
510 g_free(yd->cookie_y);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
511 yd->cookie_y = _getcookie(c);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
512 } else if (c[0] == 'T') {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
513 if (yd->cookie_t)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
514 g_free(yd->cookie_t);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
515 yd->cookie_t = _getcookie(c);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
516 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
517 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
518
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
519 static void yahoo_process_list(GaimConnection *gc, struct yahoo_packet *pkt)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
520 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
521 GSList *l = pkt->hash;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
522 gboolean export = FALSE;
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
523 gboolean got_serv_list = FALSE;
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6691
diff changeset
524 GaimBuddy *b;
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6691
diff changeset
525 GaimGroup *g;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
526 struct yahoo_friend *f = NULL;
6820
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
527 GaimAccount *account = gaim_connection_get_account(gc);
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
528 struct yahoo_data *yd = gc->proto_data;
6820
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
529 GHashTable *ht;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
530
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
531 char **lines;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
532 char **split;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
533 char **buddies;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
534 char **tmp, **bud;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
535
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
536 if (pkt->id)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
537 yd->session_id = pkt->id;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
538
6691
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
539 while (l) {
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
540 struct yahoo_pair *pair = l->data;
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
541 l = l->next;
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
542
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
543 switch (pair->key) {
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
544 case 87:
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
545 if (!yd->tmp_serv_blist)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
546 yd->tmp_serv_blist = g_string_new(pair->value);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
547 else
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
548 g_string_append(yd->tmp_serv_blist, pair->value);
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
549 break;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
550 case 88:
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
551 if (!yd->tmp_serv_ilist)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
552 yd->tmp_serv_ilist = g_string_new(pair->value);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
553 else
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
554 g_string_append(yd->tmp_serv_ilist, pair->value);
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
555 break;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
556 case 59: /* cookies, yum */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
557 yahoo_process_cookie(yd, pair->value);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
558 break;
6691
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
559 }
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
560 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
561
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
562 if (pkt->status != 0)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
563 return;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
564
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
565 if (yd->tmp_serv_blist) {
6820
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
566 ht = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_slist_free);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
567
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
568 lines = g_strsplit(yd->tmp_serv_blist->str, "\n", -1);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
569 for (tmp = lines; *tmp; tmp++) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
570 split = g_strsplit(*tmp, ":", 2);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
571 if (!split)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
572 continue;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
573 if (!split[0] || !split[1]) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
574 g_strfreev(split);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
575 continue;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
576 }
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
577 buddies = g_strsplit(split[1], ",", -1);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
578 for (bud = buddies; bud && *bud; bud++) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
579 if (!(f = g_hash_table_lookup(yd->friends, *bud))) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
580 f = yahoo_friend_new(*bud);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
581 g_hash_table_insert(yd->friends, g_strdup(*bud), f);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
582 }
6820
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
583 if (!(b = gaim_find_buddy(account, *bud))) {
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
584 if (!(g = gaim_find_group(split[0]))) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
585 g = gaim_group_new(split[0]);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
586 gaim_blist_add_group(g, NULL);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
587 }
6820
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
588 b = gaim_buddy_new(account, *bud, NULL);
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
589 gaim_blist_add_buddy(b, NULL, g, NULL);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
590 export = TRUE;
6820
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
591 }
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
592
6820
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
593 yahoo_do_group_check(account, ht, *bud, split[0], &export);
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
594 }
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
595 g_strfreev(buddies);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
596 g_strfreev(split);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
597 }
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
598 g_strfreev(lines);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
599
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
600 g_string_free(yd->tmp_serv_blist, TRUE);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
601 yd->tmp_serv_blist = NULL;
6820
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
602 g_hash_table_foreach(ht, yahoo_do_group_cleanup, &export);
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
603 g_hash_table_destroy(ht);
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
604 }
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
605
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
606
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
607 if (yd->tmp_serv_ilist) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
608 buddies = g_strsplit(yd->tmp_serv_ilist->str, ",", -1);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
609 for (bud = buddies; bud && *bud; bud++) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
610 /* The server is already ignoring the user */
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
611 got_serv_list = TRUE;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
612 gaim_privacy_deny_add(gc->account, *bud, 1);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
613 }
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
614 g_strfreev(buddies);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
615
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
616 g_string_free(yd->tmp_serv_ilist, TRUE);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
617 yd->tmp_serv_ilist = NULL;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
618 }
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
619
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
620 if (got_serv_list) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
621 gc->account->perm_deny = 4;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
622 serv_set_permit_deny(gc);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
623 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
624 if (export)
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4333
diff changeset
625 gaim_blist_save();
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
626 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
627
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
628 static void yahoo_process_notify(GaimConnection *gc, struct yahoo_packet *pkt)
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
629 {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
630 char *msg = NULL;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
631 char *from = NULL;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
632 char *stat = NULL;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
633 char *game = NULL;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
634 struct yahoo_friend *f = NULL;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
635 GSList *l = pkt->hash;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
636 struct yahoo_data *yd = (struct yahoo_data*) gc->proto_data;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
637
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
638 while (l) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
639 struct yahoo_pair *pair = l->data;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
640 if (pair->key == 4)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
641 from = pair->value;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
642 if (pair->key == 49)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
643 msg = pair->value;
3001
87fff45fa36b [gaim-migrate @ 3014]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
644 if (pair->key == 13)
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
645 stat = pair->value;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
646 if (pair->key == 14)
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
647 game = pair->value;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
648 l = l->next;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
649 }
3640
1c39909fb476 [gaim-migrate @ 3763]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
650
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
651 if (!from || !msg)
3640
1c39909fb476 [gaim-migrate @ 3763]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
652 return;
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
653
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4777
diff changeset
654 if (!g_ascii_strncasecmp(msg, "TYPING", strlen("TYPING"))) {
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
655 if (*stat == '1')
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
656 serv_got_typing(gc, from, 0, GAIM_TYPING);
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
657 else
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
658 serv_got_typing_stopped(gc, from);
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4777
diff changeset
659 } else if (!g_ascii_strncasecmp(msg, "GAME", strlen("GAME"))) {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6691
diff changeset
660 GaimBuddy *bud = gaim_find_buddy(gc->account, from);
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
661
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
662 if (!bud) {
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
663 gaim_debug(GAIM_DEBUG_WARNING, "yahoo",
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
664 "%s is playing a game, and doesn't want "
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
665 "you to know.\n", from);
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
666 }
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
667
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
668 f = g_hash_table_lookup(yd->friends, from);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
669 if (!f)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
670 return; /* if they're not on the list, don't bother */
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
671
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
672 if (f->game) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
673 g_free(f->game);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
674 f->game = NULL;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
675 }
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
676
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
677 if (*stat == '1') {
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
678 f->game = g_strdup(game);
3020
c3a29bd2a2d7 [gaim-migrate @ 3033]
Sean Egan <seanegan@gmail.com>
parents: 3019
diff changeset
679 if (bud)
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
680 yahoo_update_status(gc, from, f);
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
681 }
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
682 }
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
683 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
684
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
685 static void yahoo_process_message(GaimConnection *gc, struct yahoo_packet *pkt)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
686 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
687 char *msg = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
688 char *from = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
689 time_t tm = time(NULL);
6691
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
690 GSList *l = pkt->hash;
6069
5ca86172352a [gaim-migrate @ 6519]
Luke Schierer <lschiere@pidgin.im>
parents: 6061
diff changeset
691
6691
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
692 if (pkt->status <= 1 || pkt->status == 5) {
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
693 while (l) {
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
694 struct yahoo_pair *pair = l->data;
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
695 if (pair->key == 4)
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
696 from = pair->value;
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
697 if (pair->key == 15)
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
698 tm = strtol(pair->value, NULL, 10);
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
699 if (pair->key == 14) {
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
700 char *m;
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
701
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
702 msg = pair->value;
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
703
7478
3c21f3084ff0 [gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7475
diff changeset
704 gaim_str_strip_cr(msg);
6691
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
705 m = yahoo_codes_to_html(msg);
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6847
diff changeset
706 serv_got_im(gc, from, m, 0, tm);
6691
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
707 g_free(m);
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
708
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
709 tm = time(NULL);
6687
d524232faed8 [gaim-migrate @ 7213]
Luke Schierer <lschiere@pidgin.im>
parents: 6686
diff changeset
710 }
6691
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
711 l = l->next;
6687
d524232faed8 [gaim-migrate @ 7213]
Luke Schierer <lschiere@pidgin.im>
parents: 6686
diff changeset
712 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
713 } else if (pkt->status == 2) {
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5367
diff changeset
714 gaim_notify_error(gc, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5367
diff changeset
715 _("Your Yahoo! message did not get sent."), NULL);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
716 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
717 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
718
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
719 static void yahoo_buddy_added_us(GaimConnection *gc, struct yahoo_packet *pkt) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
720 char *id = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
721 char *who = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
722 char *msg = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
723 GSList *l = pkt->hash;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
724
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
725 while (l) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
726 struct yahoo_pair *pair = l->data;
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
727
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
728 switch (pair->key) {
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
729 case 1:
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
730 id = pair->value;
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
731 break;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
732 case 3:
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
733 who = pair->value;
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
734 break;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
735 case 15: /* time, for when they add us and we're offline */
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
736 break;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
737 case 14:
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
738 msg = pair->value;
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
739 break;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
740 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
741 l = l->next;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
742 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
743
2682
db2b0b733732 [gaim-migrate @ 2695]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
744 if (id)
7015
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 7013
diff changeset
745 gaim_account_notify_added(gc->account, id, who, NULL, msg);
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
746 }
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
747
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
748 static void yahoo_buddy_denied_our_add(GaimConnection *gc, struct yahoo_packet *pkt)
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
749 {
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
750 char *who = NULL;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
751 char *msg = NULL;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
752 GSList *l = pkt->hash;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
753 GString *buf = NULL;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
754 struct yahoo_data *yd = gc->proto_data;
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
755
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
756 while (l) {
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
757 struct yahoo_pair *pair = l->data;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
758
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
759 switch (pair->key) {
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
760 case 3:
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
761 who = pair->value;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
762 break;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
763 case 14:
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
764 msg = pair->value;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
765 break;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
766 }
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
767 l = l->next;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
768 }
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
769
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
770 if (who) {
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
771 buf = g_string_sized_new(0);
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
772 if (!msg)
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
773 g_string_printf(buf, _("%s has (retroactively) denied your request to add them to your list."), who);
2683
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
774 else
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
775 g_string_printf(buf, _("%s has (retroactively) denied your request to add them to your list for the following reason: %s."), who, msg);
6840
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
776 gaim_notify_info(gc, NULL, _("Add buddy rejected"), buf->str);
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
777 g_string_free(buf, TRUE);
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
778 g_hash_table_remove(yd->friends, who);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
779 serv_got_update(gc, who, 0, 0, 0, 0, 0);
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
780 }
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
781 }
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
782
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
783 static void yahoo_process_contact(GaimConnection *gc, struct yahoo_packet *pkt)
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
784 {
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
785
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
786
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
787 switch (pkt->status) {
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
788 case 1:
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
789 yahoo_process_status(gc, pkt);
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
790 return;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
791 case 3:
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
792 yahoo_buddy_added_us(gc, pkt);
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
793 break;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
794 case 7:
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
795 yahoo_buddy_denied_our_add(gc, pkt);
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
796 break;
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
797 default:
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
798 break;
2683
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
799 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
800 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
801
7747
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
802 #define OUT_CHARSET "utf-8"
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
803
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
804 static char *yahoo_decode(const char *text)
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
805 {
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
806 char *converted;
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
807 char *p, *n, *new;
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
808
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
809 n = new = g_malloc(strlen (text));
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
810
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
811 for (p = (char *)text; *p; p++, n++) {
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
812 if (*p == '\\') {
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
813 sscanf(p + 1, "%3o\n", (int *)n);
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
814 p += 3;
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
815 }
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
816 else
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
817 *n = *p;
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
818 }
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
819
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
820 *n = '\0';
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
821
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
822 converted = g_convert(new, n - new, OUT_CHARSET, "iso-8859-1", NULL, NULL, NULL);
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
823 g_free(new);
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
824
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
825 return converted;
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
826 }
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
827
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
828 static void yahoo_process_mail(GaimConnection *gc, struct yahoo_packet *pkt)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
829 {
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
830 GaimAccount *account = gaim_connection_get_account(gc);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
831 char *who = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
832 char *email = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
833 char *subj = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
834 int count = 0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
835 GSList *l = pkt->hash;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
836
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
837 if (!gaim_account_get_check_mail(account))
5521
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
838 return;
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
839
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
840 while (l) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
841 struct yahoo_pair *pair = l->data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
842 if (pair->key == 9)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
843 count = strtol(pair->value, NULL, 10);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
844 else if (pair->key == 43)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
845 who = pair->value;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
846 else if (pair->key == 42)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
847 email = pair->value;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
848 else if (pair->key == 18)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
849 subj = pair->value;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
850 l = l->next;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
851 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
852
4001
9178da61c19f [gaim-migrate @ 4201]
Luke Schierer <lschiere@pidgin.im>
parents: 3996
diff changeset
853 if (who && subj && email && *email) {
7747
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
854 char *dec_who = yahoo_decode(who);
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
855 char *dec_subj = yahoo_decode(subj);
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
856 char *from = g_strdup_printf("%s (%s)", dec_who, email);
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
857
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
858 gaim_notify_email(gc, dec_subj, from, gaim_account_get_username(account),
5521
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
859 "http://mail.yahoo.com/", NULL, NULL);
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
860
7747
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
861 g_free(dec_who);
3906c0957d4f [gaim-migrate @ 8392]
Luke Schierer <lschiere@pidgin.im>
parents: 7696
diff changeset
862 g_free(dec_subj);
2850
cbe6a1e63a72 [gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2813
diff changeset
863 g_free(from);
5521
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
864 } else if (count > 0) {
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
865 const char *to = gaim_account_get_username(account);
5521
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
866 const char *url = "http://mail.yahoo.com/";
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
867
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
868 gaim_notify_emails(gc, count, FALSE, NULL, NULL, &to, &url,
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
869 NULL, NULL);
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
870 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
871 }
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
872 /* This is the y64 alphabet... it's like base64, but has a . and a _ */
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
873 char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._";
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
874
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
875 /* This is taken from Sylpheed by Hiroyuki Yamamoto. We have our own tobase64 function
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
876 * in util.c, but it has a bug I don't feel like finding right now ;) */
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
877 void to_y64(unsigned char *out, const unsigned char *in, int inlen)
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
878 /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
879 {
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
880 for (; inlen >= 3; inlen -= 3)
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
881 {
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
882 *out++ = base64digits[in[0] >> 2];
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
883 *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)];
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
884 *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
885 *out++ = base64digits[in[2] & 0x3f];
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
886 in += 3;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
887 }
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
888 if (inlen > 0)
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
889 {
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
890 unsigned char fragment;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
891
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
892 *out++ = base64digits[in[0] >> 2];
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
893 fragment = (in[0] << 4) & 0x30;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
894 if (inlen > 1)
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
895 fragment |= in[1] >> 4;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
896 *out++ = base64digits[fragment];
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
897 *out++ = (inlen < 2) ? '-' : base64digits[(in[1] << 2) & 0x3c];
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
898 *out++ = '-';
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
899 }
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
900 *out = '\0';
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
901 }
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
902
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
903 static void yahoo_process_auth_old(GaimConnection *gc, const char *seed)
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
904 {
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
905 struct yahoo_packet *pack;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
906 GaimAccount *account = gaim_connection_get_account(gc);
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7209
diff changeset
907 const char *name = gaim_normalize(account, gaim_account_get_username(account));
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
908 const char *pass = gaim_account_get_password(account);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
909 struct yahoo_data *yd = gc->proto_data;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
910
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
911 /* So, Yahoo has stopped supporting its older clients in India, and undoubtedly
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
912 * will soon do so in the rest of the world.
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
913 *
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
914 * The new clients use this authentication method. I warn you in advance, it's
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
915 * bizzare, convoluted, inordinately complicated. It's also no more secure than
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
916 * crypt() was. The only purpose this scheme could serve is to prevent third
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
917 * part clients from connecting to their servers.
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
918 *
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
919 * Sorry, Yahoo.
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
920 */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
921
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
922 md5_byte_t result[16];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
923 md5_state_t ctx;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
924
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
925 char *crypt_result;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
926 char password_hash[25];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
927 char crypt_hash[25];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
928 char *hash_string_p = g_malloc(50 + strlen(name));
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
929 char *hash_string_c = g_malloc(50 + strlen(name));
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
930
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
931 char checksum;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
932
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
933 int sv;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
934
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
935 char result6[25];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
936 char result96[25];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
937
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
938 sv = seed[15];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
939 sv = sv % 8;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
940
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
941 md5_init(&ctx);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
942 md5_append(&ctx, pass, strlen(pass));
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
943 md5_finish(&ctx, result);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
944 to_y64(password_hash, result, 16);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
945
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
946 md5_init(&ctx);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
947 crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$");
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
948 md5_append(&ctx, crypt_result, strlen(crypt_result));
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
949 md5_finish(&ctx, result);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
950 to_y64(crypt_hash, result, 16);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
951
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
952 switch (sv) {
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
953 case 1:
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
954 case 6:
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
955 checksum = seed[seed[9] % 16];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
956 g_snprintf(hash_string_p, strlen(name) + 50,
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
957 "%c%s%s%s", checksum, name, seed, password_hash);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
958 g_snprintf(hash_string_c, strlen(name) + 50,
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
959 "%c%s%s%s", checksum, name, seed, crypt_hash);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
960 break;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
961 case 2:
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
962 case 7:
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
963 checksum = seed[seed[15] % 16];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
964 g_snprintf(hash_string_p, strlen(name) + 50,
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
965 "%c%s%s%s", checksum, seed, password_hash, name);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
966 g_snprintf(hash_string_c, strlen(name) + 50,
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
967 "%c%s%s%s", checksum, seed, crypt_hash, name);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
968 break;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
969 case 3:
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
970 checksum = seed[seed[1] % 16];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
971 g_snprintf(hash_string_p, strlen(name) + 50,
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
972 "%c%s%s%s", checksum, name, password_hash, seed);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
973 g_snprintf(hash_string_c, strlen(name) + 50,
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
974 "%c%s%s%s", checksum, name, crypt_hash, seed);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
975 break;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
976 case 4:
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
977 checksum = seed[seed[3] % 16];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
978 g_snprintf(hash_string_p, strlen(name) + 50,
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
979 "%c%s%s%s", checksum, password_hash, seed, name);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
980 g_snprintf(hash_string_c, strlen(name) + 50,
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
981 "%c%s%s%s", checksum, crypt_hash, seed, name);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
982 break;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
983 case 0:
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
984 case 5:
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
985 checksum = seed[seed[7] % 16];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
986 g_snprintf(hash_string_p, strlen(name) + 50,
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
987 "%c%s%s%s", checksum, password_hash, name, seed);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
988 g_snprintf(hash_string_c, strlen(name) + 50,
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
989 "%c%s%s%s", checksum, crypt_hash, name, seed);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
990 break;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
991 }
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
992
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
993 md5_init(&ctx);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
994 md5_append(&ctx, hash_string_p, strlen(hash_string_p));
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
995 md5_finish(&ctx, result);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
996 to_y64(result6, result, 16);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
997
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
998 md5_init(&ctx);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
999 md5_append(&ctx, hash_string_c, strlen(hash_string_c));
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1000 md5_finish(&ctx, result);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1001 to_y64(result96, result, 16);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1002
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1003 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1004 yahoo_packet_hash(pack, 0, name);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1005 yahoo_packet_hash(pack, 6, result6);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1006 yahoo_packet_hash(pack, 96, result96);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1007 yahoo_packet_hash(pack, 1, name);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1008
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1009 yahoo_send_packet(yd, pack);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1010
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1011 g_free(hash_string_p);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1012 g_free(hash_string_c);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1013
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1014 yahoo_packet_free(pack);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1015
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1016 }
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1017
6998
b11b2880bafd [gaim-migrate @ 7554]
Sean Egan <seanegan@gmail.com>
parents: 6989
diff changeset
1018 /* I'm dishing out some uber-mad props to Cerulean Studios for cracking this
b11b2880bafd [gaim-migrate @ 7554]
Sean Egan <seanegan@gmail.com>
parents: 6989
diff changeset
1019 * and sending the fix! Thanks guys. */
b11b2880bafd [gaim-migrate @ 7554]
Sean Egan <seanegan@gmail.com>
parents: 6989
diff changeset
1020
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1021 static void yahoo_process_auth_new(GaimConnection *gc, const char *seed)
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1022 {
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1023 struct yahoo_packet *pack = NULL;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1024 GaimAccount *account = gaim_connection_get_account(gc);
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7209
diff changeset
1025 const char *name = gaim_normalize(account, gaim_account_get_username(account));
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1026 const char *pass = gaim_account_get_password(account);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1027 struct yahoo_data *yd = gc->proto_data;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1028
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1029 md5_byte_t result[16];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1030 md5_state_t ctx;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1031
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1032 SHA_CTX ctx1;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1033 SHA_CTX ctx2;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1034
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1035 char *alphabet1 = "FBZDWAGHrJTLMNOPpRSKUVEXYChImkwQ";
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1036 char *alphabet2 = "F0E1D2C3B4A59687abcdefghijklmnop";
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1037
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1038 char *challenge_lookup = "qzec2tb3um1olpar8whx4dfgijknsvy5";
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1039 char *operand_lookup = "+|&%/*^-";
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1040 char *delimit_lookup = ",;";
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1041
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1042 char *password_hash = g_malloc0(25);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1043 char *crypt_hash = g_malloc0(25);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1044 char *crypt_result = NULL;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1045 char pass_hash_xor1[64];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1046 char pass_hash_xor2[64];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1047 char crypt_hash_xor1[64];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1048 char crypt_hash_xor2[64];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1049 char resp_6[100];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1050 char resp_96[100];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1051
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1052 unsigned char digest1[20];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1053 unsigned char digest2[20];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1054 unsigned char magic_key_char[4];
6989
56ae951450e5 [gaim-migrate @ 7545]
Nathan Walp <nwalp@pidgin.im>
parents: 6986
diff changeset
1055 const unsigned char *magic_ptr;
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1056
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1057 unsigned int magic[64];
7108
6faeeecab0dc [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
1058 unsigned int magic_work = 0;
7127
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1059
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1060 char comparison_src[20];
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1061 int x;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1062 int cnt = 0;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1063 int magic_cnt = 0;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1064 int magic_len;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1065
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1066 memset(&pass_hash_xor1, 0, 64);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1067 memset(&pass_hash_xor2, 0, 64);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1068 memset(&crypt_hash_xor1, 0, 64);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1069 memset(&crypt_hash_xor2, 0, 64);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1070 memset(&digest1, 0, 20);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1071 memset(&digest2, 0, 20);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1072 memset(&magic, 0, 64);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1073 memset(&resp_6, 0, 100);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1074 memset(&resp_96, 0, 100);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1075 memset(&magic_key_char, 0, 4);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1076
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1077 /*
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1078 * Magic: Phase 1. Generate what seems to be a 30
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1079 * byte value (could change if base64
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1080 * ends up differently? I don't remember and I'm
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1081 * tired, so use a 64 byte buffer.
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1082 */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1083
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1084 magic_ptr = seed;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1085
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1086 while (*magic_ptr != (int)NULL) {
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1087 char *loc;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1088
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1089 /* Ignore parentheses. */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1090
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1091 if (*magic_ptr == '(' || *magic_ptr == ')') {
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1092 magic_ptr++;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1093 continue;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1094 }
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1095
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1096 /* Characters and digits verify against
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1097 the challenge lookup.
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1098 */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1099
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1100 if (isalpha(*magic_ptr) || isdigit(*magic_ptr)) {
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1101 loc = strchr(challenge_lookup, *magic_ptr);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1102 if (!loc) {
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1103 /* This isn't good */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1104 }
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1105
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1106 /* Get offset into lookup table and lsh 3. */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1107
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1108 magic_work = loc - challenge_lookup;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1109 magic_work <<= 3;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1110
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1111 magic_ptr++;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1112 continue;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1113 } else {
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1114 unsigned int local_store;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1115
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1116 loc = strchr(operand_lookup, *magic_ptr);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1117 if (!loc) {
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1118 /* Also not good. */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1119 }
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1120
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1121 local_store = loc - operand_lookup;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1122
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1123 /* Oops; how did this happen? */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1124 if (magic_cnt >= 64)
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1125 break;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1126
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1127 magic[magic_cnt++] = magic_work | local_store;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1128 magic_ptr++;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1129 continue;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1130 }
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1131 }
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1132
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1133 magic_len = magic_cnt;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1134 magic_cnt = 0;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1135
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1136 /* Magic: Phase 2. Take generated magic value and
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1137 * sprinkle fairy dust on the values. */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1138
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1139 for (magic_cnt = magic_len-2; magic_cnt >= 0; magic_cnt--) {
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1140 unsigned char byte1;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1141 unsigned char byte2;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1142
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1143 /* Bad. Abort.
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1144 */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1145 if ((magic_cnt + 1 > magic_len) ||
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1146 (magic_cnt > magic_len))
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1147 break;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1148
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1149 byte1 = magic[magic_cnt];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1150 byte2 = magic[magic_cnt+1];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1151
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1152 byte1 *= 0xcd;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1153 byte1 ^= byte2;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1154
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1155 magic[magic_cnt+1] = byte1;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1156 }
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1157
7127
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1158 /* Magic: Phase 3. This computes 20 bytes. The first 4 bytes are used as our magic
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1159 * key (and may be changed later); the next 16 bytes are an MD5 sum of the magic key
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1160 * plus 3 bytes. The 3 bytes are found by looping, and they represent the offsets
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1161 * into particular functions we'll later call to potentially alter the magic key.
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1162 *
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1163 * %-)
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1164 */
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1165
7127
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1166 magic_cnt = 1;
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1167 x = 0;
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1168
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1169 do {
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1170 unsigned int bl = 0;
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1171 unsigned int cl = magic[magic_cnt++];
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1172
7127
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1173 if (magic_cnt >= magic_len)
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1174 break;
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1175
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1176 if (cl > 0x7F) {
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1177 if (cl < 0xe0)
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1178 bl = cl = (cl & 0x1f) << 6;
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1179 else {
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1180 bl = magic[magic_cnt++];
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1181 cl = (cl & 0x0f) << 6;
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1182 bl = ((bl & 0x3f) + cl) << 6;
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1183 }
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1184
7127
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1185 cl = magic[magic_cnt++];
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1186 bl = (cl & 0x3f) + bl;
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1187 } else
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1188 bl = cl;
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1189
7127
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1190 comparison_src[x++] = (bl & 0xff00) >> 8;
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1191 comparison_src[x++] = bl & 0xff;
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1192 } while (x < 20);
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1193
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1194 /* First four bytes are magic key. */
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1195 for (x = 0; x < 4; x++)
4c0b7e7118ee [gaim-migrate @ 7694]
Sean Egan <seanegan@gmail.com>
parents: 7118
diff changeset
1196 magic_key_char[x] = comparison_src[x];
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1197
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1198
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1199 /* Get password and crypt hashes as per usual. */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1200 md5_init(&ctx);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1201 md5_append(&ctx, pass, strlen(pass));
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1202 md5_finish(&ctx, result);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1203 to_y64(password_hash, result, 16);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1204
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1205 md5_init(&ctx);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1206 crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$");
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1207 md5_append(&ctx, crypt_result, strlen(crypt_result));
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1208 md5_finish(&ctx, result);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1209 to_y64(crypt_hash, result, 16);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1210
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1211 /* Our first authentication response is based off
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1212 * of the password hash. */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1213
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1214 for (x = 0; x < (int)strlen(password_hash); x++)
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1215 pass_hash_xor1[cnt++] = password_hash[x] ^ 0x36;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1216
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1217 if (cnt < 64)
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1218 memset(&(pass_hash_xor1[cnt]), 0x36, 64-cnt);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1219
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1220 cnt = 0;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1221
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1222 for (x = 0; x < (int)strlen(password_hash); x++)
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1223 pass_hash_xor2[cnt++] = password_hash[x] ^ 0x5c;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1224
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1225 if (cnt < 64)
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1226 memset(&(pass_hash_xor2[cnt]), 0x5c, 64-cnt);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1227
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1228 shaInit(&ctx1);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1229 shaInit(&ctx2);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1230
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1231 /* The first context gets the password hash XORed
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1232 * with 0x36 plus a magic value
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1233 * which we previously extrapolated from our
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1234 * challenge. */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1235
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1236 shaUpdate(&ctx1, pass_hash_xor1, 64);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1237 shaUpdate(&ctx1, magic_key_char, 4);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1238 shaFinal(&ctx1, digest1);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1239
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1240 /* The second context gets the password hash XORed
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1241 * with 0x5c plus the SHA-1 digest
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1242 * of the first context. */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1243
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1244 shaUpdate(&ctx2, pass_hash_xor2, 64);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1245 shaUpdate(&ctx2, digest1, 20);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1246 shaFinal(&ctx2, digest2);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1247
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1248 /* Now that we have digest2, use it to fetch
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1249 * characters from an alphabet to construct
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1250 * our first authentication response. */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1251
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1252 for (x = 0; x < 20; x += 2) {
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1253 unsigned int val = 0;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1254 unsigned int lookup = 0;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1255 char byte[6];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1256
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1257 memset(&byte, 0, 6);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1258
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1259 /* First two bytes of digest stuffed
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1260 * together.
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1261 */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1262
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1263 val = digest2[x];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1264 val <<= 8;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1265 val += digest2[x+1];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1266
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1267 lookup = (val >> 0x0b);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1268 lookup &= 0x1f;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1269 if (lookup >= strlen(alphabet1))
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1270 break;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1271 sprintf(byte, "%c", alphabet1[lookup]);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1272 strcat(resp_6, byte);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1273 strcat(resp_6, "=");
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1274
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1275 lookup = (val >> 0x06);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1276 lookup &= 0x1f;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1277 if (lookup >= strlen(alphabet2))
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1278 break;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1279 sprintf(byte, "%c", alphabet2[lookup]);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1280 strcat(resp_6, byte);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1281
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1282 lookup = (val >> 0x01);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1283 lookup &= 0x1f;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1284 if (lookup >= strlen(alphabet2))
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1285 break;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1286 sprintf(byte, "%c", alphabet2[lookup]);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1287 strcat(resp_6, byte);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1288
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1289 lookup = (val & 0x01);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1290 if (lookup >= strlen(delimit_lookup))
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1291 break;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1292 sprintf(byte, "%c", delimit_lookup[lookup]);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1293 strcat(resp_6, byte);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1294 }
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1295
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1296 /* Our second authentication response is based off
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1297 * of the crypto hash. */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1298
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1299 cnt = 0;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1300 memset(&digest1, 0, 20);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1301 memset(&digest2, 0, 20);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1302
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1303 for (x = 0; x < (int)strlen(crypt_hash); x++)
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1304 crypt_hash_xor1[cnt++] = crypt_hash[x] ^ 0x36;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1305
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1306 if (cnt < 64)
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1307 memset(&(crypt_hash_xor1[cnt]), 0x36, 64-cnt);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1308
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1309 cnt = 0;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1310
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1311 for (x = 0; x < (int)strlen(crypt_hash); x++)
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1312 crypt_hash_xor2[cnt++] = crypt_hash[x] ^ 0x5c;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1313
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1314 if (cnt < 64)
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1315 memset(&(crypt_hash_xor2[cnt]), 0x5c, 64-cnt);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1316
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1317 shaInit(&ctx1);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1318 shaInit(&ctx2);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1319
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1320 /* The first context gets the password hash XORed
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1321 * with 0x36 plus a magic value
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1322 * which we previously extrapolated from our
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1323 * challenge. */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1324
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1325 shaUpdate(&ctx1, crypt_hash_xor1, 64);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1326 shaUpdate(&ctx1, magic_key_char, 4);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1327 shaFinal(&ctx1, digest1);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1328
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1329 /* The second context gets the password hash XORed
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1330 * with 0x5c plus the SHA-1 digest
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1331 * of the first context. */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1332
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1333 shaUpdate(&ctx2, crypt_hash_xor2, 64);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1334 shaUpdate(&ctx2, digest1, 20);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1335 shaFinal(&ctx2, digest2);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1336
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1337 /* Now that we have digest2, use it to fetch
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1338 * characters from an alphabet to construct
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1339 * our first authentication response. */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1340
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1341 for (x = 0; x < 20; x += 2) {
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1342 unsigned int val = 0;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1343 unsigned int lookup = 0;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1344
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1345 char byte[6];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1346
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1347 memset(&byte, 0, 6);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1348
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1349 /* First two bytes of digest stuffed
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1350 * together. */
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1351
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1352 val = digest2[x];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1353 val <<= 8;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1354 val += digest2[x+1];
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1355
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1356 lookup = (val >> 0x0b);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1357 lookup &= 0x1f;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1358 if (lookup >= strlen(alphabet1))
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1359 break;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1360 sprintf(byte, "%c", alphabet1[lookup]);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1361 strcat(resp_96, byte);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1362 strcat(resp_96, "=");
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1363
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1364 lookup = (val >> 0x06);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1365 lookup &= 0x1f;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1366 if (lookup >= strlen(alphabet2))
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1367 break;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1368 sprintf(byte, "%c", alphabet2[lookup]);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1369 strcat(resp_96, byte);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1370
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1371 lookup = (val >> 0x01);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1372 lookup &= 0x1f;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1373 if (lookup >= strlen(alphabet2))
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1374 break;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1375 sprintf(byte, "%c", alphabet2[lookup]);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1376 strcat(resp_96, byte);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1377
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1378 lookup = (val & 0x01);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1379 if (lookup >= strlen(delimit_lookup))
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1380 break;
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1381 sprintf(byte, "%c", delimit_lookup[lookup]);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1382 strcat(resp_96, byte);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1383 }
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1384
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1385 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1386 yahoo_packet_hash(pack, 0, name);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1387 yahoo_packet_hash(pack, 6, resp_6);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1388 yahoo_packet_hash(pack, 96, resp_96);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1389 yahoo_packet_hash(pack, 1, name);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1390 yahoo_send_packet(yd, pack);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1391 yahoo_packet_free(pack);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1392
7424
c8b4a617ee5b [gaim-migrate @ 8026]
Ethan Blanton <elb@pidgin.im>
parents: 7423
diff changeset
1393 g_free(password_hash);
c8b4a617ee5b [gaim-migrate @ 8026]
Ethan Blanton <elb@pidgin.im>
parents: 7423
diff changeset
1394 g_free(crypt_hash);
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1395 }
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1396
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1397 static void yahoo_process_auth(GaimConnection *gc, struct yahoo_packet *pkt)
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1398 {
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1399 char *seed = NULL;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1400 char *sn = NULL;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1401 GSList *l = pkt->hash;
7010
eb3ed649252e [gaim-migrate @ 7573]
Sean Egan <seanegan@gmail.com>
parents: 6998
diff changeset
1402 int m = 0;
7043
35a567991f76 [gaim-migrate @ 7606]
Luke Schierer <lschiere@pidgin.im>
parents: 7015
diff changeset
1403 gchar *buf;
6761
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1404
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1405
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1406 while (l) {
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1407 struct yahoo_pair *pair = l->data;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1408 if (pair->key == 94)
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1409 seed = pair->value;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1410 if (pair->key == 1)
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1411 sn = pair->value;
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1412 if (pair->key == 13)
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1413 m = atoi(pair->value);
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1414 l = l->next;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1415 }
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1416
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1417 if (seed) {
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1418 switch (m) {
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1419 case 0:
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1420 yahoo_process_auth_old(gc, seed);
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1421 break;
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1422 case 1:
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1423 yahoo_process_auth_new(gc, seed);
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1424 break;
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1425 default:
7043
35a567991f76 [gaim-migrate @ 7606]
Luke Schierer <lschiere@pidgin.im>
parents: 7015
diff changeset
1426 buf = g_strdup_printf(_("The Yahoo server has requested the use of an unrecognized "
7129
8246bd3141ae [gaim-migrate @ 7696]
Luke Schierer <lschiere@pidgin.im>
parents: 7127
diff changeset
1427 "authentication method. This version of Gaim will likely not be able "
7043
35a567991f76 [gaim-migrate @ 7606]
Luke Schierer <lschiere@pidgin.im>
parents: 7015
diff changeset
1428 "to successfully sign on to Yahoo. Check %s for updates."), GAIM_WEBSITE);
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1429 gaim_notify_error(gc, "", _("Failed Yahoo! Authentication"),
7043
35a567991f76 [gaim-migrate @ 7606]
Luke Schierer <lschiere@pidgin.im>
parents: 7015
diff changeset
1430 buf);
35a567991f76 [gaim-migrate @ 7606]
Luke Schierer <lschiere@pidgin.im>
parents: 7015
diff changeset
1431 g_free(buf);
6986
6290e7aeabfe [gaim-migrate @ 7542]
Sean Egan <seanegan@gmail.com>
parents: 6982
diff changeset
1432 yahoo_process_auth_new(gc, seed); /* Can't hurt to try it anyway. */
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1433 }
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1434 }
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1435 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1436
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1437 static void ignore_buddy(GaimBuddy *b) {
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1438 GaimGroup *g;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1439 GaimConversation *c;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1440 GaimAccount *account;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1441 gchar *name;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1442
6792
62aec9fd7aca [gaim-migrate @ 7331]
Luke Schierer <lschiere@pidgin.im>
parents: 6791
diff changeset
1443 if (!b)
62aec9fd7aca [gaim-migrate @ 7331]
Luke Schierer <lschiere@pidgin.im>
parents: 6791
diff changeset
1444 return;
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1445
6792
62aec9fd7aca [gaim-migrate @ 7331]
Luke Schierer <lschiere@pidgin.im>
parents: 6791
diff changeset
1446 g = gaim_find_buddys_group(b);
62aec9fd7aca [gaim-migrate @ 7331]
Luke Schierer <lschiere@pidgin.im>
parents: 6791
diff changeset
1447 name = g_strdup(b->name);
62aec9fd7aca [gaim-migrate @ 7331]
Luke Schierer <lschiere@pidgin.im>
parents: 6791
diff changeset
1448 account = b->account;
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1449
6792
62aec9fd7aca [gaim-migrate @ 7331]
Luke Schierer <lschiere@pidgin.im>
parents: 6791
diff changeset
1450 gaim_debug(GAIM_DEBUG_INFO, "blist",
62aec9fd7aca [gaim-migrate @ 7331]
Luke Schierer <lschiere@pidgin.im>
parents: 6791
diff changeset
1451 "Removing '%s' from buddy list.\n", b->name);
62aec9fd7aca [gaim-migrate @ 7331]
Luke Schierer <lschiere@pidgin.im>
parents: 6791
diff changeset
1452 serv_remove_buddy(account->gc, name, g->name);
62aec9fd7aca [gaim-migrate @ 7331]
Luke Schierer <lschiere@pidgin.im>
parents: 6791
diff changeset
1453 gaim_blist_remove_buddy(b);
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1454
6792
62aec9fd7aca [gaim-migrate @ 7331]
Luke Schierer <lschiere@pidgin.im>
parents: 6791
diff changeset
1455 serv_add_deny(account->gc, name);
62aec9fd7aca [gaim-migrate @ 7331]
Luke Schierer <lschiere@pidgin.im>
parents: 6791
diff changeset
1456 gaim_blist_save();
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1457
6792
62aec9fd7aca [gaim-migrate @ 7331]
Luke Schierer <lschiere@pidgin.im>
parents: 6791
diff changeset
1458 c = gaim_find_conversation_with_account(name, account);
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1459
6792
62aec9fd7aca [gaim-migrate @ 7331]
Luke Schierer <lschiere@pidgin.im>
parents: 6791
diff changeset
1460 if (c != NULL)
62aec9fd7aca [gaim-migrate @ 7331]
Luke Schierer <lschiere@pidgin.im>
parents: 6791
diff changeset
1461 gaim_conversation_update(c, GAIM_CONV_UPDATE_REMOVE);
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1462
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1463 g_free(name);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1464 }
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1465
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1466 static void keep_buddy(GaimBuddy *b) {
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1467 gaim_privacy_deny_remove(b->account, b->name, 1);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1468 }
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1469
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1470 static void yahoo_process_ignore(GaimConnection *gc, struct yahoo_packet *pkt) {
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1471 GaimBuddy *b;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1472 GSList *l;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1473 gchar *who = NULL;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1474 gchar *sn = NULL;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1475 gchar buf[BUF_LONG];
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1476 gint ignore = 0;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1477 gint status = 0;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1478
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1479 for (l = pkt->hash; l; l = l->next) {
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1480 struct yahoo_pair *pair = l->data;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1481 switch (pair->key) {
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1482 case 0:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1483 who = pair->value;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1484 break;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1485 case 1:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1486 sn = pair->value;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1487 break;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1488 case 13:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1489 ignore = strtol(pair->value, NULL, 10);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1490 break;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1491 case 66:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1492 status = strtol(pair->value, NULL, 10);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1493 break;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1494 default:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1495 break;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1496 }
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1497 }
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1498
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1499 switch (status) {
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1500 case 12:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1501 b = gaim_find_buddy(gc->account, who);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1502 g_snprintf(buf, sizeof(buf), _("You have tried to ignore %s, but the "
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1503 "user is on your buddy list. Clicking \"Yes\" "
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1504 "will remove and ignore the buddy."), who);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1505 gaim_request_yes_no(gc, NULL, _("Ignore buddy?"), buf, 0, b,
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1506 G_CALLBACK(ignore_buddy),
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1507 G_CALLBACK(keep_buddy));
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1508 break;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1509 case 2:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1510 case 3:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1511 case 0:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1512 default:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1513 break;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1514 }
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1515 }
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1516
6761
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1517 static void yahoo_process_authresp(GaimConnection *gc, struct yahoo_packet *pkt)
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1518 {
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1519 GSList *l = pkt->hash;
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1520 int err = 0;
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1521 char *msg;
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1522
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1523 while (l) {
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1524 struct yahoo_pair *pair = l->data;
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1525
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1526 if (pair->key == 66)
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1527 err = strtol(pair->value, NULL, 10);
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1528
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1529 l = l->next;
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1530 }
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1531
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1532 switch (err) {
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1533 case 3:
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1534 msg = _("Invalid username.");
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1535 break;
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1536 case 13:
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1537 msg = _("Incorrect password.");
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1538 break;
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1539 default:
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1540 msg = _("Unknown error.");
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1541 }
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1542 gaim_connection_error(gc, msg);
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1543 }
ddbe06989d46 [gaim-migrate @ 7293]
Luke Schierer <lschiere@pidgin.im>
parents: 6760
diff changeset
1544
6840
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1545 static void yahoo_process_addbuddy(GaimConnection *gc, struct yahoo_packet *pkt)
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1546 {
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1547 int err = 0;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1548 char *who = NULL;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1549 char *group = NULL;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1550 char *buf;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1551 struct yahoo_friend *f;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1552 struct yahoo_data *yd = gc->proto_data;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1553 GSList *l = pkt->hash;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1554
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1555 while (l) {
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1556 struct yahoo_pair *pair = l->data;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1557
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1558 switch (pair->key) {
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1559 case 66:
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1560 err = strtol(pair->value, NULL, 10);
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1561 break;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1562 case 7:
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1563 who = pair->value;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1564 break;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1565 case 65:
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1566 group = pair->value;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1567 break;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1568 }
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1569
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1570 l = l->next;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1571 }
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1572
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1573 if (!who)
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1574 return;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1575 if (!group)
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1576 group = "";
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1577
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1578 if (!err || (err == 2)) { /* 0 = ok, 2 = already on serv list */
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1579 if (!g_hash_table_lookup(yd->friends, who)) {
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1580 f = yahoo_friend_new();
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1581 g_hash_table_insert(yd->friends, g_strdup(who), f);
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1582 yahoo_update_status(gc, who, f);
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1583 }
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1584 return;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1585 }
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1586
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1587 buf = g_strdup_printf(_("Could not add buddy %s to group %s to the server list on account %s."),
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1588 who, group, gaim_connection_get_display_name(gc));
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1589 gaim_notify_error(gc, NULL, _("Could not add buddy to server list"), buf);
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1590 g_free(buf);
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1591 }
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1592
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1593 static void yahoo_packet_process(GaimConnection *gc, struct yahoo_packet *pkt)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1594 {
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1595 switch (pkt->service) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1596 case YAHOO_SERVICE_LOGON:
2771
450f4f9d2f23 [gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2741
diff changeset
1597 case YAHOO_SERVICE_LOGOFF:
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1598 case YAHOO_SERVICE_ISAWAY:
2737
f61c1f3a6afa [gaim-migrate @ 2750]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2724
diff changeset
1599 case YAHOO_SERVICE_ISBACK:
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1600 case YAHOO_SERVICE_GAMELOGON:
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1601 case YAHOO_SERVICE_GAMELOGOFF:
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
1602 case YAHOO_SERVICE_CHATLOGON:
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
1603 case YAHOO_SERVICE_CHATLOGOFF:
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1604 yahoo_process_status(gc, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1605 break;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1606 case YAHOO_SERVICE_NOTIFY:
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1607 yahoo_process_notify(gc, pkt);
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1608 break;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1609 case YAHOO_SERVICE_MESSAGE:
2786
318f846120e2 [gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2772
diff changeset
1610 case YAHOO_SERVICE_GAMEMSG:
5939
3014de25a8a4 [gaim-migrate @ 6379]
Luke Schierer <lschiere@pidgin.im>
parents: 5921
diff changeset
1611 case YAHOO_SERVICE_CHATMSG:
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1612 yahoo_process_message(gc, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1613 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1614 case YAHOO_SERVICE_NEWMAIL:
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1615 yahoo_process_mail(gc, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1616 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1617 case YAHOO_SERVICE_NEWCONTACT:
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1618 yahoo_process_contact(gc, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1619 break;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
1620 case YAHOO_SERVICE_AUTHRESP:
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
1621 yahoo_process_authresp(gc, pkt);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
1622 break;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1623 case YAHOO_SERVICE_LIST:
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1624 yahoo_process_list(gc, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1625 break;
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1626 case YAHOO_SERVICE_AUTH:
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1627 yahoo_process_auth(gc, pkt);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1628 break;
6840
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1629 case YAHOO_SERVICE_ADDBUDDY:
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1630 yahoo_process_addbuddy(gc, pkt);
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
1631 break;
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1632 case YAHOO_SERVICE_IGNORECONTACT:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1633 yahoo_process_ignore(gc, pkt);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
1634 break;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1635 case YAHOO_SERVICE_CONFINVITE:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1636 case YAHOO_SERVICE_CONFADDINVITE:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1637 yahoo_process_conference_invite(gc, pkt);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1638 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1639 case YAHOO_SERVICE_CONFDECLINE:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1640 yahoo_process_conference_decline(gc, pkt);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1641 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1642 case YAHOO_SERVICE_CONFLOGON:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1643 yahoo_process_conference_logon(gc, pkt);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1644 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1645 case YAHOO_SERVICE_CONFLOGOFF:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1646 yahoo_process_conference_logoff(gc, pkt);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1647 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1648 case YAHOO_SERVICE_CONFMSG:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1649 yahoo_process_conference_message(gc, pkt);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1650 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1651 case YAHOO_SERVICE_CHATONLINE:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1652 yahoo_process_chat_online(gc, pkt);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1653 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1654 case YAHOO_SERVICE_CHATLOGOUT:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1655 yahoo_process_chat_logout(gc, pkt);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1656 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1657 case YAHOO_SERVICE_CHATGOTO:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1658 yahoo_process_chat_goto(gc, pkt);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1659 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1660 case YAHOO_SERVICE_CHATJOIN:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1661 yahoo_process_chat_join(gc, pkt);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1662 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1663 case YAHOO_SERVICE_CHATLEAVE: /* XXX is this right? */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1664 case YAHOO_SERVICE_CHATEXIT:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1665 yahoo_process_chat_exit(gc, pkt);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1666 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1667 case YAHOO_SERVICE_CHATINVITE: /* XXX never seen this one, might not do it right */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1668 case YAHOO_SERVICE_CHATADDINVITE:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1669 yahoo_process_chat_addinvite(gc, pkt);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1670 break;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1671 case YAHOO_SERVICE_COMMENT:
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1672 yahoo_process_chat_message(gc, pkt);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1673 break;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
1674 case YAHOO_SERVICE_P2PFILEXFER:
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
1675 case YAHOO_SERVICE_FILETRANSFER:
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
1676 yahoo_process_filetransfer(gc, pkt);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
1677 break;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1678 default:
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
1679 gaim_debug(GAIM_DEBUG_ERROR, "yahoo",
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1680 "Unhandled service 0x%02x\n", pkt->service);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1681 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1682 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1683 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1684
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1685 static void yahoo_pending(gpointer data, gint source, GaimInputCondition cond)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1686 {
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1687 GaimConnection *gc = data;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1688 struct yahoo_data *yd = gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1689 char buf[1024];
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1690 int len;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1691
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1692 len = read(yd->fd, buf, sizeof(buf));
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1693
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1694 if (len <= 0) {
6321
3613007cbb6e [gaim-migrate @ 6820]
Luke Schierer <lschiere@pidgin.im>
parents: 6115
diff changeset
1695 gaim_connection_error(gc, _("Unable to read"));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1696 return;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1697 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1698
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1699 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1700 memcpy(yd->rxqueue + yd->rxlen, buf, len);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1701 yd->rxlen += len;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1702
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1703 while (1) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1704 struct yahoo_packet *pkt;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1705 int pos = 0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1706 int pktlen;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1707
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1708 if (yd->rxlen < YAHOO_PACKET_HDRLEN)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1709 return;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1710
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1711 pos += 4; /* YMSG */
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1712 pos += 2;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1713 pos += 2;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1714
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1715 pktlen = yahoo_get16(yd->rxqueue + pos); pos += 2;
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
1716 gaim_debug(GAIM_DEBUG_MISC, "yahoo",
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1717 "%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1718
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1719 if (yd->rxlen < (YAHOO_PACKET_HDRLEN + pktlen))
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1720 return;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1721
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1722 yahoo_packet_dump(yd->rxqueue, YAHOO_PACKET_HDRLEN + pktlen);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1723
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1724 pkt = yahoo_packet_new(0, 0, 0);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1725
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1726 pkt->service = yahoo_get16(yd->rxqueue + pos); pos += 2;
3021
18f0e61a6caf [gaim-migrate @ 3034]
Sean Egan <seanegan@gmail.com>
parents: 3020
diff changeset
1727 pkt->status = yahoo_get32(yd->rxqueue + pos); pos += 4;
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
1728 gaim_debug(GAIM_DEBUG_MISC, "yahoo",
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1729 "Yahoo Service: 0x%02x Status: %d\n",
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1730 pkt->service, pkt->status);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1731 pkt->id = yahoo_get32(yd->rxqueue + pos); pos += 4;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1732
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1733 yahoo_packet_read(pkt, yd->rxqueue + pos, pktlen);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1734
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1735 yd->rxlen -= YAHOO_PACKET_HDRLEN + pktlen;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1736 if (yd->rxlen) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1737 char *tmp = g_memdup(yd->rxqueue + YAHOO_PACKET_HDRLEN + pktlen, yd->rxlen);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1738 g_free(yd->rxqueue);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1739 yd->rxqueue = tmp;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1740 } else {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1741 g_free(yd->rxqueue);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1742 yd->rxqueue = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1743 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1744
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1745 yahoo_packet_process(gc, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1746
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1747 yahoo_packet_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1748 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1749 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1750
7138
f189f8ccaa98 [gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents: 7134
diff changeset
1751 #ifndef YAHOO_WEBMESSENGER
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1752 static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1753 {
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1754 GaimConnection *gc = data;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1755 struct yahoo_data *yd;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1756 struct yahoo_packet *pkt;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1757
5590
011a0a975060 [gaim-migrate @ 5994]
Christian Hammond <chipx86@chipx86.com>
parents: 5583
diff changeset
1758 if (!g_list_find(gaim_connections_get_all(), gc)) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1759 close(source);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1760 return;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1761 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1762
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1763 if (source < 0) {
6321
3613007cbb6e [gaim-migrate @ 6820]
Luke Schierer <lschiere@pidgin.im>
parents: 6115
diff changeset
1764 gaim_connection_error(gc, _("Unable to connect"));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1765 return;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1766 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1767
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1768 yd = gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1769 yd->fd = source;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1770
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1771 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, 0);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1772
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7209
diff changeset
1773 yahoo_packet_hash(pkt, 1, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc))));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1774 yahoo_send_packet(yd, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1775
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1776 yahoo_packet_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1777
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1778 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1779 }
7138
f189f8ccaa98 [gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents: 7134
diff changeset
1780 #endif
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1781
7134
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1782 #ifdef YAHOO_WEBMESSENGER
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1783 static void yahoo_got_web_connected(gpointer data, gint source, GaimInputCondition cond)
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1784 {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1785 GaimConnection *gc = data;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1786 struct yahoo_data *yd;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1787 struct yahoo_packet *pkt;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1788
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1789 if (!g_list_find(gaim_connections_get_all(), gc)) {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1790 close(source);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1791 return;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1792 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1793
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1794 if (source < 0) {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1795 gaim_connection_error(gc, _("Unable to connect"));
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1796 return;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1797 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1798
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1799 yd = gc->proto_data;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1800 yd->fd = source;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1801
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1802 pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, 0);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1803
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7209
diff changeset
1804 yahoo_packet_hash(pkt, 0, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc))));
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7209
diff changeset
1805 yahoo_packet_hash(pkt, 1, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc))));
7134
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1806 yahoo_packet_hash(pkt, 6, yd->auth);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1807 yahoo_send_packet(yd, pkt);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1808
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1809 yahoo_packet_free(pkt);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1810 g_free(yd->auth);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1811 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1812 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1813
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1814 static void yahoo_web_pending(gpointer data, gint source, GaimInputCondition cond)
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1815 {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1816 GaimConnection *gc = data;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1817 GaimAccount *account = gaim_connection_get_account(gc);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1818 struct yahoo_data *yd = gc->proto_data;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1819 char buf[1024], buf2[256], *i = buf, *r = buf2;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1820 int len, o = 0;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1821
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1822 len = read(source, buf, sizeof(buf));
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1823
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1824 if (len <= 0 || strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302"))) {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1825 gaim_connection_error(gc, _("Unable to read"));
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1826 return;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1827 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1828
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1829 while ((i = strstr(i, "Set-Cookie: ")) && 0 < 2) {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1830 i += strlen("Set-Cookie: ");
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1831 for (;*i != ';'; r++, i++) {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1832 *r = *i;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1833 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1834 *r=';';
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1835 r++;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1836 *r=' ';
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1837 r++;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1838 o++;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1839 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1840 /* Get rid of that "; " */
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1841 *(r-2) = '\0';
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1842 yd->auth = g_strdup(buf2);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1843 gaim_input_remove(gc->inpa);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1844 close(source);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1845
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1846 /* Now we have our cookies to login with. I'll go get the milk. */
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1847 if (gaim_proxy_connect(account, "wcs1.msg.sc5.yahoo.com",
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1848 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT),
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1849 yahoo_got_web_connected, gc) != 0) {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1850 gaim_connection_error(gc, _("Connection problem"));
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1851 return;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1852 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1853 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1854
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1855 static void yahoo_got_cookies(gpointer data, gint source, GaimInputCondition cond)
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1856 {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1857 GaimConnection *gc = data;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1858 struct yahoo_data *yd = gc->proto_data;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1859 if (source < 0) {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1860 gaim_connection_error(gc, _("Unable to connect"));
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1861 return;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1862 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1863 write(source, yd->auth, strlen(yd->auth));
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1864 g_free(yd->auth);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1865 gc->inpa = gaim_input_add(source, GAIM_INPUT_READ, yahoo_web_pending, gc);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1866 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1867
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1868 static void yahoo_login_page_hash_iter(const char *key, const char *val, GString *url)
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1869 {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1870 if (!strcmp(key, "passwd"))
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1871 return;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1872 url = g_string_append_c(url, '&');
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1873 url = g_string_append(url, key);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1874 url = g_string_append_c(url, '=');
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1875 if (!strcmp(key, ".save") || !strcmp(key, ".js"))
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1876 url = g_string_append_c(url, '1');
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1877 else if (!strcmp(key, ".challenge"))
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1878 url = g_string_append(url, val);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1879 else
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1880 url = g_string_append(url, gaim_url_encode(val));
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1881 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1882
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1883 static GHashTable *yahoo_login_page_hash(const char *buf, size_t len)
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1884 {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1885 GHashTable *hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
7138
f189f8ccaa98 [gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents: 7134
diff changeset
1886 const char *c = buf;
f189f8ccaa98 [gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents: 7134
diff changeset
1887 char *d;
7134
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1888 char name[64], value[64];
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1889 while ((c < (buf + len)) && (c = strstr(c, "<input "))) {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1890 c = strstr(c, "name=\"") + strlen("name=\"");
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1891 for (d = name; *c!='"'; c++, d++)
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1892 *d = *c;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1893 *d = '\0';
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1894 d = strstr(c, "value=\"") + strlen("value=\"");
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1895 if (strchr(c, '>') < d)
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1896 break;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1897 for (c = d, d = value; *c!='"'; c++, d++)
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1898 *d = *c;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1899 *d = '\0';
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1900 g_hash_table_insert(hash, g_strdup(name), g_strdup(value));
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1901 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1902 return hash;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1903 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1904
7138
f189f8ccaa98 [gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents: 7134
diff changeset
1905 static void yahoo_login_page_cb(void *user_data, const char *buf, size_t len)
7134
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1906 {
7138
f189f8ccaa98 [gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents: 7134
diff changeset
1907 GaimConnection *gc = (GaimConnection *)user_data;
7134
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1908 GaimAccount *account = gaim_connection_get_account(gc);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1909 struct yahoo_data *yd = gc->proto_data;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1910 const char *sn = gaim_account_get_username(account);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1911 const char *pass = gaim_account_get_password(account);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1912 GHashTable *hash = yahoo_login_page_hash(buf, len);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1913 GString *url = g_string_new("GET /config/login?login=");
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1914 char md5[33], *hashp = md5, *chal;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1915 int i;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1916 md5_byte_t result[16];
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1917 md5_state_t ctx;
7191
4bd3892cded3 [gaim-migrate @ 7760]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7161
diff changeset
1918
4bd3892cded3 [gaim-migrate @ 7760]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7161
diff changeset
1919 url = g_string_append(url, sn);
4bd3892cded3 [gaim-migrate @ 7760]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7161
diff changeset
1920 url = g_string_append(url, "&passwd=");
4bd3892cded3 [gaim-migrate @ 7760]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7161
diff changeset
1921
7134
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1922 md5_init(&ctx);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1923 md5_append(&ctx, pass, strlen(pass));
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1924 md5_finish(&ctx, result);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1925 for (i = 0; i < 16; ++i) {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1926 g_snprintf(hashp, 3, "%02x", result[i]);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1927 hashp += 2;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1928 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1929 chal = g_strconcat(md5, g_hash_table_lookup(hash, ".challenge"), NULL);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1930 md5_init(&ctx);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1931 md5_append(&ctx, chal, strlen(chal));
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1932 md5_finish(&ctx, result);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1933 hashp = md5;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1934 for (i = 0; i < 16; ++i) {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1935 g_snprintf(hashp, 3, "%02x", result[i]);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1936 hashp += 2;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1937 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1938 /*
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1939 md5_init(&ctx);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1940 md5_append(&ctx, md5, strlen(md5));
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1941 md5_finish(&ctx, result);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1942 hashp = md5;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1943 for (i = 0; i < 16; ++i) {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1944 g_snprintf(hashp, 3, "%02x", result[i]);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1945 hashp += 2;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1946 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1947 */
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1948 g_free(chal);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1949
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1950 url = g_string_append(url, md5);
7138
f189f8ccaa98 [gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents: 7134
diff changeset
1951 g_hash_table_foreach(hash, (GHFunc)yahoo_login_page_hash_iter, url);
7134
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1952
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1953 url = g_string_append(url, "&.hash=1&.md5=1 HTTP/1.1\r\n"
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1954 "Host: login.yahoo.com\r\n\r\n");
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1955 g_hash_table_destroy(hash);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1956
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1957 yd->auth = g_string_free(url, FALSE);
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1958 if (gaim_proxy_connect(account, "login.yahoo.com", 80, yahoo_got_cookies, gc) != 0) {
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1959 gaim_connection_error(gc, _("Connection problem"));
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1960 return;
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1961 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1962 }
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1963
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1964 #endif /* YAHOO_WEBMESSENGER */
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1965
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1966 static void yahoo_login(GaimAccount *account) {
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1967 GaimConnection *gc = gaim_account_get_connection(account);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1968 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1969
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6623
diff changeset
1970 gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_NO_BGCOLOR;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6623
diff changeset
1971
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1972 gaim_connection_update_progress(gc, _("Connecting"), 1, 2);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1973
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1974 yd->fd = -1;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
1975 yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1976 yd->confs = NULL;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1977 yd->conf_id = 2;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1978
7134
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1979 #ifndef YAHOO_WEBMESSENGER
5681
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5638
diff changeset
1980 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", YAHOO_PAGER_HOST),
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1981 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT),
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1982 yahoo_got_connected, gc) != 0) {
6321
3613007cbb6e [gaim-migrate @ 6820]
Luke Schierer <lschiere@pidgin.im>
parents: 6115
diff changeset
1983 gaim_connection_error(gc, _("Connection problem"));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1984 return;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1985 }
7134
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1986 #else
7138
f189f8ccaa98 [gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents: 7134
diff changeset
1987 gaim_url_fetch(WEBMESSENGER_URL, TRUE, "Gaim/" VERSION, FALSE,
f189f8ccaa98 [gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents: 7134
diff changeset
1988 yahoo_login_page_cb, gc);
7134
67f9b43c402a [gaim-migrate @ 7701]
Sean Egan <seanegan@gmail.com>
parents: 7129
diff changeset
1989 #endif
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1990
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1991 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1992
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1993 static void yahoo_close(GaimConnection *gc) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1994 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1995
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
1996 g_hash_table_destroy(yd->friends);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
1997 g_slist_free(yd->confs);
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
1998 if (yd->chat_name)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
1999 g_free(yd->chat_name);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2000
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2001 if (yd->cookie_y)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2002 g_free(yd->cookie_y);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2003 if (yd->cookie_t)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2004 g_free(yd->cookie_t);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2005
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2006 if (yd->fd >= 0)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2007 close(yd->fd);
3720
34c95669952f [gaim-migrate @ 3853]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3642
diff changeset
2008
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2009 if (yd->rxqueue)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2010 g_free(yd->rxqueue);
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2686
diff changeset
2011 yd->rxlen = 0;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2012 if (gc->inpa)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2013 gaim_input_remove(gc->inpa);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2014 g_free(yd);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2015 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2016
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6691
diff changeset
2017 static const char *yahoo_list_icon(GaimAccount *a, GaimBuddy *b)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2018 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4634
diff changeset
2019 return "yahoo";
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2020 }
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
2021
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6691
diff changeset
2022 static void yahoo_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne)
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
2023 {
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
2024 int i = 0;
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
2025 char *emblems[4] = {NULL,NULL,NULL,NULL};
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2026 GaimAccount *account;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2027 GaimConnection *gc;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2028 struct yahoo_data *yd;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2029 struct yahoo_friend *f;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2030
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2031 if (!b || !(account = b->account) || !(gc = gaim_account_get_connection(account)) ||
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2032 !(yd = gc->proto_data))
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2033 return;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2034
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2035 f = g_hash_table_lookup(yd->friends, b->name);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2036 if (!f) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2037 *se = "notauthorized";
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2038 return;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2039 }
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2040
5068
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5002
diff changeset
2041 if (b->present == GAIM_BUDDY_OFFLINE) {
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
2042 *se = "offline";
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
2043 return;
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
2044 } else {
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2045 if (f->away)
6691
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
2046 emblems[i++] = "away";
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2047 if (f->sms)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2048 emblems[i++] = "wireless";
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2049 if (f->game)
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
2050 emblems[i++] = "game";
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
2051 }
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
2052 *se = emblems[0];
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
2053 *sw = emblems[1];
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
2054 *nw = emblems[2];
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
2055 *ne = emblems[3];
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
2056 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2057
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2058 static char *yahoo_get_status_string(enum yahoo_status a)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2059 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2060 switch (a) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2061 case YAHOO_STATUS_BRB:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2062 return _("Be Right Back");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2063 case YAHOO_STATUS_BUSY:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2064 return _("Busy");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2065 case YAHOO_STATUS_NOTATHOME:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2066 return _("Not At Home");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2067 case YAHOO_STATUS_NOTATDESK:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2068 return _("Not At Desk");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2069 case YAHOO_STATUS_NOTINOFFICE:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2070 return _("Not In Office");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2071 case YAHOO_STATUS_ONPHONE:
4606
864518c3767d [gaim-migrate @ 4894]
Luke Schierer <lschiere@pidgin.im>
parents: 4596
diff changeset
2072 return _("On The Phone");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2073 case YAHOO_STATUS_ONVACATION:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2074 return _("On Vacation");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2075 case YAHOO_STATUS_OUTTOLUNCH:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2076 return _("Out To Lunch");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2077 case YAHOO_STATUS_STEPPEDOUT:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2078 return _("Stepped Out");
2873
26be84883f91 [gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2856
diff changeset
2079 case YAHOO_STATUS_INVISIBLE:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2080 return _("Invisible");
4730
9d3b7b106def [gaim-migrate @ 5043]
Sean Egan <seanegan@gmail.com>
parents: 4729
diff changeset
2081 case YAHOO_STATUS_IDLE:
9d3b7b106def [gaim-migrate @ 5043]
Sean Egan <seanegan@gmail.com>
parents: 4729
diff changeset
2082 return _("Idle");
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2083 case YAHOO_STATUS_OFFLINE:
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2084 return _("Offline");
2879
5fc5123b7098 [gaim-migrate @ 2892]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2878
diff changeset
2085 default:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2086 return _("Online");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2087 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2088 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2089
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2090 static void yahoo_initiate_conference(GaimConnection *gc, const char *name)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2091 {
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2092 GHashTable *components;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2093 struct yahoo_data *yd;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2094 int id;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2095
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2096 yd = gc->proto_data;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2097 id = yd->conf_id;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2098
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2099 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: 6695
diff changeset
2100 g_hash_table_replace(components, g_strdup("room"),
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2101 g_strdup_printf("%s-%d", gaim_connection_get_display_name(gc), id));
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2102 g_hash_table_replace(components, g_strdup("topic"), g_strdup("Join my conference..."));
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2103 g_hash_table_replace(components, g_strdup("type"), g_strdup("Conference"));
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2104 yahoo_c_join(gc, components);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2105 g_hash_table_destroy(components);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2106
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2107 yahoo_c_invite(gc, id, "Join my conference...", name);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2108 }
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2109
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
2110 static void yahoo_game(GaimConnection *gc, const char *name) {
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2111 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2112 char *game = NULL;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2113 char *t;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2114 char url[256];
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2115 struct yahoo_friend *f;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2116
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2117 f = g_hash_table_lookup(yd->friends, name);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2118 if (!f)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2119 return;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2120
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2121 game = f->game;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2122 if (!game)
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2123 return;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2124
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2125 t = game = g_strdup(strstr(game, "ante?room="));
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2126 while (*t != '\t')
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2127 t++;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2128 *t = 0;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2129 g_snprintf(url, sizeof url, "http://games.yahoo.com/games/%s", game);
6465
fb64cc87bc96 [gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
2130 gaim_notify_uri(gc, url);
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2131 g_free(game);
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2132 }
4722
534eaa4ead94 [gaim-migrate @ 5034]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
2133
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6691
diff changeset
2134 static char *yahoo_status_text(GaimBuddy *b)
4722
534eaa4ead94 [gaim-migrate @ 5034]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
2135 {
534eaa4ead94 [gaim-migrate @ 5034]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
2136 struct yahoo_data *yd = (struct yahoo_data*)b->account->gc->proto_data;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2137 struct yahoo_friend *f = NULL;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2138 char *stripped = NULL;
6691
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
2139
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2140 f = g_hash_table_lookup(yd->friends, b->name);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2141 if (!f)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2142 return g_strdup(_("Not on server list"));
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2143
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2144 switch (f->status) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2145 case YAHOO_STATUS_AVAILABLE:
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2146 return NULL;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2147 case YAHOO_STATUS_IDLE:
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2148 if (f->idle == -1)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2149 return g_strdup(yahoo_get_status_string(f->status));
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2150 return NULL;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2151 case YAHOO_STATUS_CUSTOM:
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2152 if (!f->msg)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2153 return NULL;
7095
c8bf2da398e3 [gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents: 7094
diff changeset
2154 stripped = gaim_markup_strip_html(f->msg);
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2155 if (stripped) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2156 char *ret = g_markup_escape_text(stripped, strlen(stripped));
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2157 g_free(stripped);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2158 return ret;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2159 }
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2160 return NULL;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2161 default:
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2162 return g_strdup(yahoo_get_status_string(f->status));
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2163 }
4722
534eaa4ead94 [gaim-migrate @ 5034]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
2164 }
534eaa4ead94 [gaim-migrate @ 5034]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
2165
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6691
diff changeset
2166 static char *yahoo_tooltip_text(GaimBuddy *b)
4724
b9e7ccf21f9c [gaim-migrate @ 5037]
Sean Egan <seanegan@gmail.com>
parents: 4722
diff changeset
2167 {
b9e7ccf21f9c [gaim-migrate @ 5037]
Sean Egan <seanegan@gmail.com>
parents: 4722
diff changeset
2168 struct yahoo_data *yd = (struct yahoo_data*)b->account->gc->proto_data;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2169 struct yahoo_friend *f;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2170 char *escaped, *status, *ret;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2171
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2172 f = g_hash_table_lookup(yd->friends, b->name);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2173 if (!f)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2174 status = g_strdup(_("Not on server list"));
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2175 else
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2176 switch (f->status) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2177 case YAHOO_STATUS_IDLE:
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2178 if (f->idle == -1) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2179 status = g_strdup(yahoo_get_status_string(f->status));
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2180 break;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2181 }
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2182 return NULL;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2183 case YAHOO_STATUS_CUSTOM:
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2184 if (!f->msg)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2185 return NULL;
7095
c8bf2da398e3 [gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents: 7094
diff changeset
2186 status = gaim_markup_strip_html(f->msg);
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2187 break;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2188 default:
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2189 status = g_strdup(yahoo_get_status_string(f->status));
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2190 break;
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4732
diff changeset
2191 }
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2192
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2193 escaped = g_markup_escape_text(status, strlen(status));
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2194 ret = g_strdup_printf(_("<b>Status:</b> %s"), escaped);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2195 g_free(status);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2196 g_free(escaped);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2197
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2198 return ret;
4729
751c37a940dd [gaim-migrate @ 5042]
Nathan Walp <nwalp@pidgin.im>
parents: 4724
diff changeset
2199 }
751c37a940dd [gaim-migrate @ 5042]
Nathan Walp <nwalp@pidgin.im>
parents: 4724
diff changeset
2200
6796
f5f2669970a0 [gaim-migrate @ 7336]
Luke Schierer <lschiere@pidgin.im>
parents: 6795
diff changeset
2201 static void yahoo_addbuddyfrommenu_cb(GaimConnection *gc, const char *who)
f5f2669970a0 [gaim-migrate @ 7336]
Luke Schierer <lschiere@pidgin.im>
parents: 6795
diff changeset
2202 {
f5f2669970a0 [gaim-migrate @ 7336]
Luke Schierer <lschiere@pidgin.im>
parents: 6795
diff changeset
2203 yahoo_add_buddy(gc, who, NULL);
f5f2669970a0 [gaim-migrate @ 7336]
Luke Schierer <lschiere@pidgin.im>
parents: 6795
diff changeset
2204 }
f5f2669970a0 [gaim-migrate @ 7336]
Luke Schierer <lschiere@pidgin.im>
parents: 6795
diff changeset
2205
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
2206 static GList *yahoo_buddy_menu(GaimConnection *gc, const char *who)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2207 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2208 GList *m = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2209 struct proto_buddy_menu *pbm;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2210 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2211 static char buf2[1024];
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2212 struct yahoo_friend *f;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2213
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2214 f = g_hash_table_lookup(yd->friends, who);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2215
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2216 if (!f) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2217 pbm = g_new0(struct proto_buddy_menu, 1);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2218 pbm->label = _("Add Buddy");
6796
f5f2669970a0 [gaim-migrate @ 7336]
Luke Schierer <lschiere@pidgin.im>
parents: 6795
diff changeset
2219 pbm->callback = yahoo_addbuddyfrommenu_cb;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2220 pbm->gc = gc;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2221 m = g_list_append(m, pbm);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2222
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2223 return m;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2224 }
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2225
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2226 if (f->status == YAHOO_STATUS_OFFLINE)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2227 return NULL;
4722
534eaa4ead94 [gaim-migrate @ 5034]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
2228
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2229 pbm = g_new0(struct proto_buddy_menu, 1);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2230 pbm->label = _("Join in Chat");
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2231 pbm->callback = yahoo_chat_goto;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2232 pbm->gc = gc;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2233 m = g_list_append(m, pbm);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2234
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2235 pbm = g_new0(struct proto_buddy_menu, 1);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2236 pbm->label = _("Initiate Conference");
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2237 pbm->callback = yahoo_initiate_conference;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2238 pbm->gc = gc;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2239 m = g_list_append(m, pbm);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2240
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2241 /* FIXME: remove this when the ui does it for us. */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2242 pbm = g_new0(struct proto_buddy_menu, 1);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2243 pbm->label = _("Send File");
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2244 pbm->callback = yahoo_ask_send_file;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2245 pbm->gc = gc;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2246 m = g_list_append(m, pbm);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2247
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2248 if (f->game) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2249 char *game = f->game;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2250 char *room;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2251 char *t;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2252
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2253 if (!game)
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2254 return m;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2255
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2256 pbm = g_new0(struct proto_buddy_menu, 1);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2257 if (!(room = strstr(game, "&follow="))) /* skip ahead to the url */
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2258 return m;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2259 while (*room && *room != '\t') /* skip to the tab */
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2260 room++;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2261 t = room++; /* room as now at the name */
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2262 while (*t != '\n')
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2263 t++; /* replace the \n with a space */
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2264 *t = ' ';
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2265 g_snprintf(buf2, sizeof buf2, "%s", room);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2266 pbm->label = buf2;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2267 pbm->callback = yahoo_game;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2268 pbm->gc = gc;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2269 m = g_list_append(m, pbm);
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2270 }
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2271
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2272 return m;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2273 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2274
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
2275 static void yahoo_act_id(GaimConnection *gc, const char *entry)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2276 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2277 struct yahoo_data *yd = gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2278
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2279 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2280 yahoo_packet_hash(pkt, 3, entry);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2281 yahoo_send_packet(yd, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2282 yahoo_packet_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2283
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
2284 gaim_connection_set_display_name(gc, entry);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2285 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2286
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
2287 static void yahoo_show_act_id(GaimConnection *gc)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2288 {
5493
3e8487580024 [gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
2289 gaim_request_input(gc, NULL, _("Active which ID?"), NULL,
6035
8c44020a958e [gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents: 5939
diff changeset
2290 gaim_connection_get_display_name(gc), FALSE, FALSE,
5493
3e8487580024 [gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
2291 _("OK"), G_CALLBACK(yahoo_act_id),
3e8487580024 [gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
2292 _("Cancel"), NULL, gc);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2293 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2294
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
2295 static GList *yahoo_actions(GaimConnection *gc) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2296 GList *m = NULL;
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
2297 struct proto_actions_menu *pam;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2298
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
2299 pam = g_new0(struct proto_actions_menu, 1);
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
2300 pam->label = _("Activate ID");
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
2301 pam->callback = yahoo_show_act_id;
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
2302 pam->gc = gc;
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
2303 m = g_list_append(m, pam);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2304
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2305 return m;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2306 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2307
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7112
diff changeset
2308 static int yahoo_send_im(GaimConnection *gc, const char *who, const char *what, GaimConvImFlags flags)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2309 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2310 struct yahoo_data *yd = gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2311 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0);
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6623
diff changeset
2312 char *msg = yahoo_html_to_codes(what);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2313
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
2314 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2315 yahoo_packet_hash(pkt, 5, who);
3493
4b204c262376 [gaim-migrate @ 3553]
Luke Schierer <lschiere@pidgin.im>
parents: 3467
diff changeset
2316 yahoo_packet_hash(pkt, 14, msg);
6044
8642749e55ca [gaim-migrate @ 6494]
Mark Doliner <mark@kingant.net>
parents: 6035
diff changeset
2317 yahoo_packet_hash(pkt, 97, "1");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2318
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2319 yahoo_send_packet(yd, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2320
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2321 yahoo_packet_free(pkt);
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6623
diff changeset
2322
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6623
diff changeset
2323 g_free(msg);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6623
diff changeset
2324
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2325 return 1;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2326 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2327
6059
d8cd876e613e [gaim-migrate @ 6509]
Mark Doliner <mark@kingant.net>
parents: 6044
diff changeset
2328 int yahoo_send_typing(GaimConnection *gc, const char *who, int typ)
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
2329 {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
2330 struct yahoo_data *yd = gc->proto_data;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
2331 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0);
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
2332 yahoo_packet_hash(pkt, 49, "TYPING");
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
2333 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
2334 yahoo_packet_hash(pkt, 14, " ");
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
2335 yahoo_packet_hash(pkt, 13, typ == GAIM_TYPING ? "1" : "0");
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
2336 yahoo_packet_hash(pkt, 5, who);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
2337 yahoo_packet_hash(pkt, 1002, "1");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
2338
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
2339 yahoo_send_packet(yd, pkt);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
2340
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
2341 yahoo_packet_free(pkt);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
2342
3001
87fff45fa36b [gaim-migrate @ 3014]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2343 return 0;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
2344 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
2345
6059
d8cd876e613e [gaim-migrate @ 6509]
Mark Doliner <mark@kingant.net>
parents: 6044
diff changeset
2346 static void yahoo_set_away(GaimConnection *gc, const char *state, const char *msg)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2347 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2348 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2349 struct yahoo_packet *pkt;
2772
f9227268db25 [gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2771
diff changeset
2350 int service;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2351 char s[4];
6691
306790891ce7 [gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents: 6687
diff changeset
2352
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4044
diff changeset
2353 if (gc->away) {
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4044
diff changeset
2354 g_free(gc->away);
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4044
diff changeset
2355 gc->away = NULL;
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4044
diff changeset
2356 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2357
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2358 if (msg) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2359 yd->current_status = YAHOO_STATUS_CUSTOM;
6847
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2360 gc->away = g_strndup(msg, YAHOO_MAX_STATUS_MESSAGE_LENGTH);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2361 } else if (state) {
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4044
diff changeset
2362 gc->away = g_strdup("");
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2363 if (!strcmp(state, _("Available"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2364 yd->current_status = YAHOO_STATUS_AVAILABLE;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2365 } else if (!strcmp(state, _("Be Right Back"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2366 yd->current_status = YAHOO_STATUS_BRB;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2367 } else if (!strcmp(state, _("Busy"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2368 yd->current_status = YAHOO_STATUS_BUSY;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2369 } else if (!strcmp(state, _("Not At Home"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2370 yd->current_status = YAHOO_STATUS_NOTATHOME;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2371 } else if (!strcmp(state, _("Not At Desk"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2372 yd->current_status = YAHOO_STATUS_NOTATDESK;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2373 } else if (!strcmp(state, _("Not In Office"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2374 yd->current_status = YAHOO_STATUS_NOTINOFFICE;
4606
864518c3767d [gaim-migrate @ 4894]
Luke Schierer <lschiere@pidgin.im>
parents: 4596
diff changeset
2375 } else if (!strcmp(state, _("On The Phone"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2376 yd->current_status = YAHOO_STATUS_ONPHONE;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2377 } else if (!strcmp(state, _("On Vacation"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2378 yd->current_status = YAHOO_STATUS_ONVACATION;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2379 } else if (!strcmp(state, _("Out To Lunch"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2380 yd->current_status = YAHOO_STATUS_OUTTOLUNCH;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2381 } else if (!strcmp(state, _("Stepped Out"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2382 yd->current_status = YAHOO_STATUS_STEPPEDOUT;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2383 } else if (!strcmp(state, _("Invisible"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2384 yd->current_status = YAHOO_STATUS_INVISIBLE;
6847
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2385 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { /* this should never happen? */
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2386 if (gc->is_idle) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2387 yd->current_status = YAHOO_STATUS_IDLE;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2388 } else {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2389 yd->current_status = YAHOO_STATUS_AVAILABLE;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2390 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2391 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2392 } else if (gc->is_idle) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2393 yd->current_status = YAHOO_STATUS_IDLE;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2394 } else {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2395 yd->current_status = YAHOO_STATUS_AVAILABLE;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2396 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2397
2772
f9227268db25 [gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2771
diff changeset
2398 if (yd->current_status == YAHOO_STATUS_AVAILABLE)
f9227268db25 [gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2771
diff changeset
2399 service = YAHOO_SERVICE_ISBACK;
f9227268db25 [gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2771
diff changeset
2400 else
f9227268db25 [gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2771
diff changeset
2401 service = YAHOO_SERVICE_ISAWAY;
6847
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2402
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2403 pkt = yahoo_packet_new(service, YAHOO_STATUS_AVAILABLE, 0);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2404 g_snprintf(s, sizeof(s), "%d", yd->current_status);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2405 yahoo_packet_hash(pkt, 10, s);
6847
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2406
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2407 if ((yd->current_status == YAHOO_STATUS_CUSTOM) && gc->away)
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2408 yahoo_packet_hash(pkt, 19, gc->away);
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2409
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2410 if ((yd->current_status != YAHOO_STATUS_AVAILABLE) &&
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2411 (yd->current_status != YAHOO_STATUS_IDLE)) {
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2412 if (gc->is_idle)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2413 yahoo_packet_hash(pkt, 47, "2");
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2414 else
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2415 yahoo_packet_hash(pkt, 47, "1");
6686
0b286eace44c [gaim-migrate @ 7212]
Luke Schierer <lschiere@pidgin.im>
parents: 6657
diff changeset
2416 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2417
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2418 yahoo_send_packet(yd, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2419 yahoo_packet_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2420 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2421
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
2422 static void yahoo_set_idle(GaimConnection *gc, int idle)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2423 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2424 struct yahoo_data *yd = gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2425 struct yahoo_packet *pkt = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2426
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2427 if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) {
6847
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2428 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2429 yd->current_status = YAHOO_STATUS_IDLE;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2430 } else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2431 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2432 yd->current_status = YAHOO_STATUS_AVAILABLE;
6847
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2433 } else {
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2434 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2435 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2436
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2437 if (pkt) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2438 char buf[4];
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2439 g_snprintf(buf, sizeof(buf), "%d", yd->current_status);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2440 yahoo_packet_hash(pkt, 10, buf);
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2441 if (gc->away && yd->current_status == YAHOO_STATUS_CUSTOM) {
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2442 yahoo_packet_hash(pkt, 19, gc->away);
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2443 if (idle)
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2444 yahoo_packet_hash(pkt, 47, "2");
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2445 else
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2446 yahoo_packet_hash(pkt, 47, "1"); /* fixme when available messages are possible */
6847
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2447 } else if (idle && (yd->current_status != YAHOO_STATUS_AVAILABLE) &&
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2448 (yd->current_status != YAHOO_STATUS_IDLE)) {
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2449 yahoo_packet_hash(pkt, 47, "2");
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2450 } else if (!idle && (yd->current_status != YAHOO_STATUS_AVAILABLE) &&
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2451 (yd->current_status != YAHOO_STATUS_IDLE)) {
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2452 yahoo_packet_hash(pkt, 47, "1");
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2453 }
6847
7de1b559cbbb [gaim-migrate @ 7392]
Luke Schierer <lschiere@pidgin.im>
parents: 6840
diff changeset
2454
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2455 yahoo_send_packet(yd, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2456 yahoo_packet_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2457 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2458 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2459
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
2460 static GList *yahoo_away_states(GaimConnection *gc)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2461 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2462 GList *m = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2463
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2464 m = g_list_append(m, _("Available"));
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2465 m = g_list_append(m, _("Be Right Back"));
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2466 m = g_list_append(m, _("Busy"));
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2467 m = g_list_append(m, _("Not At Home"));
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2468 m = g_list_append(m, _("Not At Desk"));
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2469 m = g_list_append(m, _("Not In Office"));
4606
864518c3767d [gaim-migrate @ 4894]
Luke Schierer <lschiere@pidgin.im>
parents: 4596
diff changeset
2470 m = g_list_append(m, _("On The Phone"));
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2471 m = g_list_append(m, _("On Vacation"));
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2472 m = g_list_append(m, _("Out To Lunch"));
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2473 m = g_list_append(m, _("Stepped Out"));
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
2474 m = g_list_append(m, _("Invisible"));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2475 m = g_list_append(m, GAIM_AWAY_CUSTOM);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2476
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2477 return m;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2478 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2479
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
2480 static void yahoo_keepalive(GaimConnection *gc)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2481 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2482 struct yahoo_data *yd = gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2483 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2484 yahoo_send_packet(yd, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2485 yahoo_packet_free(pkt);
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2486
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2487 if (!yd->chat_online)
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2488 return;
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2489
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2490 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, 0);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2491 yahoo_packet_hash(pkt, 109, gaim_connection_get_display_name(gc));
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2492 yahoo_send_packet(yd, pkt);
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2493 yahoo_packet_free(pkt);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2494 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2495
6787
faa491042c66 [gaim-migrate @ 7326]
Christian Hammond <chipx86@chipx86.com>
parents: 6784
diff changeset
2496 static void yahoo_add_buddy(GaimConnection *gc, const char *who, GaimGroup *foo)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2497 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2498 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2499 struct yahoo_packet *pkt;
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6691
diff changeset
2500 GaimGroup *g;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2501 char *group = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2502
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2503 if (!yd->logged_in)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2504 return;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2505
6840
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2506 if (foo)
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2507 group = foo->name;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2508 if (!group) {
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2509 g = gaim_find_buddys_group(gaim_find_buddy(gc->account, who));
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2510 if (g)
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2511 group = g->name;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2512 else
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2513 group = "Buddies";
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2514 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2515
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2516 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0);
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
2517 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2518 yahoo_packet_hash(pkt, 7, who);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2519 yahoo_packet_hash(pkt, 65, group);
6820
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
2520 yahoo_packet_hash(pkt, 14, "");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2521 yahoo_send_packet(yd, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2522 yahoo_packet_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2523 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2524
6059
d8cd876e613e [gaim-migrate @ 6509]
Mark Doliner <mark@kingant.net>
parents: 6044
diff changeset
2525 static void yahoo_remove_buddy(GaimConnection *gc, const char *who, const char *group)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2526 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2527 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2528 struct yahoo_friend *f;
6795
40ba19133882 [gaim-migrate @ 7334]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6793
diff changeset
2529 struct yahoo_packet *pkt;
6840
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2530 GSList *buddies, *l;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2531 GaimGroup *g;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2532 gboolean remove = TRUE;
6784
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2533
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2534 if (!(f = g_hash_table_lookup(yd->friends, who)))
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2535 return;
ea3707dde7a3 [gaim-migrate @ 7323]
Luke Schierer <lschiere@pidgin.im>
parents: 6761
diff changeset
2536
6840
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2537 buddies = gaim_find_buddies(gaim_connection_get_account(gc), who);
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2538 for (l = buddies; l; l = l->next) {
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2539 g = gaim_find_buddys_group(l->data);
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2540 if (gaim_utf8_strcasecmp(group, g->name)) {
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2541 remove = FALSE;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2542 break;
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2543 }
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2544 }
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2545
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2546 g_slist_free(buddies);
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2547
b67670ac5584 [gaim-migrate @ 7385]
Luke Schierer <lschiere@pidgin.im>
parents: 6820
diff changeset
2548 if (remove)
6820
4b3fa146e995 [gaim-migrate @ 7364]
Luke Schierer <lschiere@pidgin.im>
parents: 6810
diff changeset
2549 g_hash_table_remove(yd->friends, who);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2550
6795
40ba19133882 [gaim-migrate @ 7334]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6793
diff changeset
2551 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0);
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
2552 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2553 yahoo_packet_hash(pkt, 7, who);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2554 yahoo_packet_hash(pkt, 65, group);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2555 yahoo_send_packet(yd, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2556 yahoo_packet_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2557 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2558
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2559 static void yahoo_add_deny(GaimConnection *gc, const char *who) {
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2560 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2561 struct yahoo_packet *pkt;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2562
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2563 if (!yd->logged_in)
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2564 return;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2565
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2566 if (gc->account->perm_deny != 4)
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2567 return;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2568
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2569 if (!who || who[0] == '\0')
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2570 return;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2571
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2572 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2573 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2574 yahoo_packet_hash(pkt, 7, who);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2575 yahoo_packet_hash(pkt, 13, "1");
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2576 yahoo_send_packet(yd, pkt);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2577 yahoo_packet_free(pkt);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2578 }
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2579
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2580 static void yahoo_rem_deny(GaimConnection *gc, const char *who) {
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2581 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2582 struct yahoo_packet *pkt;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2583
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2584 if (!yd->logged_in)
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2585 return;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2586
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2587 if (!who || who[0] == '\0')
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2588 return;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2589
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2590 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2591 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2592 yahoo_packet_hash(pkt, 7, who);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2593 yahoo_packet_hash(pkt, 13, "2");
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2594 yahoo_send_packet(yd, pkt);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2595 yahoo_packet_free(pkt);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2596 }
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2597
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2598 static void yahoo_set_permit_deny(GaimConnection *gc) {
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2599 GaimAccount *acct;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2600 GSList *deny;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2601
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2602 acct = gc->account;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2603
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2604 switch (acct->perm_deny) {
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2605 case 1:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2606 case 3:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2607 case 5:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2608 for (deny = acct->deny;deny;deny = deny->next)
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2609 yahoo_rem_deny(gc, deny->data);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2610 break;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2611 case 4:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2612 for (deny = acct->deny;deny;deny = deny->next)
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2613 yahoo_add_deny(gc, deny->data);
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2614 break;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2615 case 2:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2616 default:
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2617 break;
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2618 }
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2619 }
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2620
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
2621 static gboolean yahoo_unload_plugin(GaimPlugin *plugin)
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
2622 {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
2623 yahoo_dest_colorht();
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
2624 return TRUE;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
2625 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
2626
7094
2343c3aa1dec [gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
2627 static void yahoo_got_info(void *data, const char *url_text, size_t len)
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2628 {
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2629 YahooGetInfoData *info_data = (YahooGetInfoData *)data;
7094
2343c3aa1dec [gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
2630 char *stripped, *p;
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2631 char buf[1024];
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2632 gboolean found = FALSE;
7094
2343c3aa1dec [gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
2633 char *url_buffer;
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2634 GString *s;
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2635 int stripped_len;
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2636
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2637 gaim_debug_info("yahoo", "In yahoo_got_info\n");
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2638
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2639 /* we failed to grab the profile URL */
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2640 if (url_text == NULL || strcmp(url_text, "") == 0) {
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2641 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL,
7062
86ed8b2aa665 [gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents: 7043
diff changeset
2642 _("<html><body><b>Error retrieving profile</b></body></html>"),
86ed8b2aa665 [gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents: 7043
diff changeset
2643 NULL, NULL);
86ed8b2aa665 [gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents: 7043
diff changeset
2644
7161
3471c3b1e85c [gaim-migrate @ 7728]
Mark Doliner <mark@kingant.net>
parents: 7138
diff changeset
2645 g_free(info_data->name);
3471c3b1e85c [gaim-migrate @ 7728]
Mark Doliner <mark@kingant.net>
parents: 7138
diff changeset
2646 g_free(info_data);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2647 return;
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2648 }
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2649
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2650 /* we don't yet support the multiple link level of the warning page for
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2651 * 'adult' profiles, not to mention the fact that yahoo wants you to be
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2652 * logged in (on the website) to be able to view an 'adult' profile. for
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2653 * now, just tell them that we can't help them, and provide a link to the
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2654 * profile if they want to do the web browser thing.
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2655 */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2656 p = strstr(url_text, "Adult Profiles Warning Message");
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2657 if (p) {
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2658 g_snprintf(buf, 1024, "<html><body>%s%s<a href=\"%s%s\">%s%s</a></body></html>",
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2659 _("<b>Sorry, profiles marked as containing adult content are not supported at this time.</b><br><br>\n"),
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2660 _("If you wish to view this profile, you will need to visit this link in your web browser<br>"),
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2661 YAHOO_PROFILE_URL, info_data->name, YAHOO_PROFILE_URL, info_data->name);
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2662
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2663 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL,
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2664 buf, NULL, NULL);
7161
3471c3b1e85c [gaim-migrate @ 7728]
Mark Doliner <mark@kingant.net>
parents: 7138
diff changeset
2665
3471c3b1e85c [gaim-migrate @ 7728]
Mark Doliner <mark@kingant.net>
parents: 7138
diff changeset
2666 g_free(info_data->name);
3471c3b1e85c [gaim-migrate @ 7728]
Mark Doliner <mark@kingant.net>
parents: 7138
diff changeset
2667 g_free(info_data);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2668 return;
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2669 }
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2670
6630
889279abb909 [gaim-migrate @ 7154]
Luke Schierer <lschiere@pidgin.im>
parents: 6629
diff changeset
2671 /* at the moment we don't support profile pages with languages other than
889279abb909 [gaim-migrate @ 7154]
Luke Schierer <lschiere@pidgin.im>
parents: 6629
diff changeset
2672 * english. the problem is, that every user may choose his/her own profile
889279abb909 [gaim-migrate @ 7154]
Luke Schierer <lschiere@pidgin.im>
parents: 6629
diff changeset
2673 * language. this language has nothing to do with the preferences of the
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2674 * user which looks at the profile
6630
889279abb909 [gaim-migrate @ 7154]
Luke Schierer <lschiere@pidgin.im>
parents: 6629
diff changeset
2675 */
889279abb909 [gaim-migrate @ 7154]
Luke Schierer <lschiere@pidgin.im>
parents: 6629
diff changeset
2676 p = strstr(url_text, "Last Updated:");
889279abb909 [gaim-migrate @ 7154]
Luke Schierer <lschiere@pidgin.im>
parents: 6629
diff changeset
2677 if (!p) {
7550
ebf1f580d6a9 [gaim-migrate @ 8164]
Luke Schierer <lschiere@pidgin.im>
parents: 7478
diff changeset
2678 p = strstr(url_text, "Last Updated&nbsp;");
ebf1f580d6a9 [gaim-migrate @ 8164]
Luke Schierer <lschiere@pidgin.im>
parents: 7478
diff changeset
2679 }
ebf1f580d6a9 [gaim-migrate @ 8164]
Luke Schierer <lschiere@pidgin.im>
parents: 7478
diff changeset
2680 if (!p) {
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2681 g_snprintf(buf, 1024, "<html><body>%s%s<a href=\"%s%s\">%s%s</a></body></html>",
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2682 _("<b>Sorry, non-English profiles are not supported at this time.</b><br><br>\n"),
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2683 _("If you wish to view this profile, you will need to visit this link in your web browser<br>"),
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2684 YAHOO_PROFILE_URL, info_data->name, YAHOO_PROFILE_URL, info_data->name);
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2685
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2686 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL,
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2687 buf, NULL, NULL);
7161
3471c3b1e85c [gaim-migrate @ 7728]
Mark Doliner <mark@kingant.net>
parents: 7138
diff changeset
2688
3471c3b1e85c [gaim-migrate @ 7728]
Mark Doliner <mark@kingant.net>
parents: 7138
diff changeset
2689 g_free(info_data->name);
3471c3b1e85c [gaim-migrate @ 7728]
Mark Doliner <mark@kingant.net>
parents: 7138
diff changeset
2690 g_free(info_data);
6630
889279abb909 [gaim-migrate @ 7154]
Luke Schierer <lschiere@pidgin.im>
parents: 6629
diff changeset
2691 return;
889279abb909 [gaim-migrate @ 7154]
Luke Schierer <lschiere@pidgin.im>
parents: 6629
diff changeset
2692 }
889279abb909 [gaim-migrate @ 7154]
Luke Schierer <lschiere@pidgin.im>
parents: 6629
diff changeset
2693
7094
2343c3aa1dec [gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
2694 url_buffer = g_strdup(url_text);
2343c3aa1dec [gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
2695
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2696 /*
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2697 * gaim_markup_strip_html() doesn't strip out character entities like &nbsp;
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2698 * and &#183;
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2699 */
7094
2343c3aa1dec [gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
2700 while ((p = strstr(url_buffer, "&nbsp;")) != NULL) {
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2701 memmove(p, p + 6, strlen(p + 6));
7094
2343c3aa1dec [gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
2702 url_buffer[strlen(url_buffer) - 6] = '\0';
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2703 }
7094
2343c3aa1dec [gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
2704 while ((p = strstr(url_buffer, "&#183;")) != NULL) {
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2705 memmove(p, p + 6, strlen(p + 6));
7094
2343c3aa1dec [gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
2706 url_buffer[strlen(url_buffer) - 6] = '\0';
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2707 }
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2708
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2709 /* nuke the nasty \r's */
7094
2343c3aa1dec [gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
2710 while ((p = strchr(url_buffer, '\r')) != NULL) {
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2711 memmove(p, p + 1, strlen(p + 1));
7094
2343c3aa1dec [gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
2712 url_buffer[strlen(url_buffer) - 1] = '\0';
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2713 }
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2714
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2715 /* nuke the html, it's easier than trying to parse the horrid stuff */
7095
c8bf2da398e3 [gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents: 7094
diff changeset
2716 stripped = gaim_markup_strip_html(url_buffer);
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2717 stripped_len = strlen(stripped);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2718
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2719 gaim_debug_misc("yahoo", "stripped = %p\n", stripped);
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2720 gaim_debug_misc("yahoo", "url_buffer = %p\n", url_buffer);
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2721
7094
2343c3aa1dec [gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
2722 /* gonna re-use the memory we've already got for url_buffer */
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2723 /* no we're not */
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2724 s = g_string_sized_new(strlen(url_buffer));
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2725 g_string_append(s, "<html><body>\n");
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2726
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2727 /* extract their Yahoo! ID and put it in. Don't bother marking has_info as
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2728 * true, since the Yahoo! ID will always be there */
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2729 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, "Yahoo! ID:", 2, "\n", 0,
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2730 NULL, _("Yahoo! ID"), 0, NULL))
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2731 g_string_append_printf(s, "<b>%s:</b> %s<br>", _("Yahoo! ID"), info_data->name);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2732
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2733
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2734 /* extract their Email address and put it in */
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2735 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "My Email", 5, "\n", 0,
6657
7e2d2c8e88a8 [gaim-migrate @ 7182]
Luke Schierer <lschiere@pidgin.im>
parents: 6630
diff changeset
2736 "Private", _("Email"), 0, NULL);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2737
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2738 /* extract the Nickname if it exists */
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2739 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Nickname:", 1, "\n", '\n',
6573
cc41123c684a [gaim-migrate @ 7095]
Luke Schierer <lschiere@pidgin.im>
parents: 6546
diff changeset
2740 NULL, _("Nickname"), 0, NULL);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2741
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2742 /* extract their RealName and put it in */
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2743 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "RealName:", 1, "\n", '\n',
6623
156e6643f9db [gaim-migrate @ 7147]
Luke Schierer <lschiere@pidgin.im>
parents: 6622
diff changeset
2744 NULL, _("Realname"), 0, NULL);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2745
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2746 /* extract their Location and put it in */
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2747 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Location:", 2, "\n", '\n',
6573
cc41123c684a [gaim-migrate @ 7095]
Luke Schierer <lschiere@pidgin.im>
parents: 6546
diff changeset
2748 NULL, _("Location"), 0, NULL);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2749
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2750 /* extract their Age and put it in */
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2751 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Age:", 3, "\n", '\n',
6573
cc41123c684a [gaim-migrate @ 7095]
Luke Schierer <lschiere@pidgin.im>
parents: 6546
diff changeset
2752 NULL, _("Age"), 0, NULL);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2753
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2754 /* extract their MaritalStatus and put it in */
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2755 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "MaritalStatus:", 3, "\n", '\n',
6657
7e2d2c8e88a8 [gaim-migrate @ 7182]
Luke Schierer <lschiere@pidgin.im>
parents: 6630
diff changeset
2756 "No Answer", _("Marital Status"), 0, NULL);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2757
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2758 /* extract their Gender and put it in */
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2759 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Gender:", 3, "\n", '\n',
6657
7e2d2c8e88a8 [gaim-migrate @ 7182]
Luke Schierer <lschiere@pidgin.im>
parents: 6630
diff changeset
2760 "No Answer", _("Gender"), 0, NULL);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2761
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2762 /* extract their Occupation and put it in */
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2763 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Occupation:", 2, "\n", '\n',
6573
cc41123c684a [gaim-migrate @ 7095]
Luke Schierer <lschiere@pidgin.im>
parents: 6546
diff changeset
2764 NULL, _("Occupation"), 0, NULL);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2765
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2766 /* Hobbies, Latest News, and Favorite Quote are a bit different, since the
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2767 * values can contain embedded newlines... but any or all of them can also
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2768 * not appear. The way we delimit them is to successively look for the next
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2769 * one that _could_ appear, and if all else fails, we end the section by
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2770 * looking for the 'Links' heading, which is the next thing to follow this
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2771 * bunch.
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2772 */
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2773
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2774 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, "Hobbies:", 1, "Latest News",
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2775 '\n', NULL, _("Hobbies"), 0, NULL))
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2776 {
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2777 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, "Hobbies:", 1, "Favorite Quote",
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2778 '\n', NULL, _("Hobbies"), 0, NULL))
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2779 {
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2780 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Hobbies:", 1, "Links",
6573
cc41123c684a [gaim-migrate @ 7095]
Luke Schierer <lschiere@pidgin.im>
parents: 6546
diff changeset
2781 '\n', NULL, _("Hobbies"), 0, NULL);
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2782 }
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2783 else
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2784 found = TRUE;
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2785 }
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2786 else
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2787 found = TRUE;
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2788
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2789 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, "Latest News:", 1, "Favorite Quote",
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2790 '\n', NULL, _("Latest News"), 0, NULL))
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2791 {
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2792 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Latest News:", 1, "Links",
6573
cc41123c684a [gaim-migrate @ 7095]
Luke Schierer <lschiere@pidgin.im>
parents: 6546
diff changeset
2793 '\n', NULL, _("Latest News"), 0, NULL);
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2794 }
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2795 else
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2796 found = TRUE;
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2797
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2798 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Favorite Quote:", 0, "Links",
6573
cc41123c684a [gaim-migrate @ 7095]
Luke Schierer <lschiere@pidgin.im>
parents: 6546
diff changeset
2799 '\n', NULL, _("Favorite Quote"), 0, NULL);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2800
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2801 /* Home Page will either be "No home page specified",
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2802 * or "Home Page: " and a link. */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2803 p = strstr(stripped, "No home page specified");
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2804 if(!p)
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2805 {
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2806 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Home Page:", 1, " ", 0, NULL,
6573
cc41123c684a [gaim-migrate @ 7095]
Luke Schierer <lschiere@pidgin.im>
parents: 6546
diff changeset
2807 _("Home Page"), 1, NULL);
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2808 }
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2809
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2810 /* Cool Link {1,2,3} is also different. If "No cool link specified" exists,
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2811 * then we have none. If we have one however, we'll need to check and see if
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2812 * we have a second one. If we have a second one, we have to check to see if
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2813 * we have a third one.
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2814 */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2815 p = strstr(stripped,"No cool link specified");
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2816 if (!p)
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2817 {
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2818 if (gaim_markup_extract_info_field(stripped, stripped_len, s, "Cool Link 1:", 1, " ", 0, NULL,
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2819 _("Cool Link 1"), 1, NULL))
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2820 {
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2821 found = TRUE;
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2822 if (gaim_markup_extract_info_field(stripped, stripped_len, s, "Cool Link 2:", 1, " ", 0, NULL,
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2823 _("Cool Link 2"), 1, NULL))
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2824 gaim_markup_extract_info_field(stripped, stripped_len, s, "Cool Link 3:", 1, " ", 0, NULL,
6573
cc41123c684a [gaim-migrate @ 7095]
Luke Schierer <lschiere@pidgin.im>
parents: 6546
diff changeset
2825 _("Cool Link 3"), 1, NULL);
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2826 }
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2827 }
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2828
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2829 /* see if Member Since is there, and if so, extract it. */
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2830 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Member Since:", 1, "Last Updated:",
6573
cc41123c684a [gaim-migrate @ 7095]
Luke Schierer <lschiere@pidgin.im>
parents: 6546
diff changeset
2831 '\n', NULL, _("Member Since"), 0, NULL);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2832
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2833 /* extract the Last Updated date and put it in */
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2834 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Last Updated:", 1, "\n", '\n', NULL,
6573
cc41123c684a [gaim-migrate @ 7095]
Luke Schierer <lschiere@pidgin.im>
parents: 6546
diff changeset
2835 _("Last Updated"), 0, NULL);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2836
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2837 /* finish off the html */
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2838 g_string_append(s, "</body></html>\n");
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2839 g_free(stripped);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2840
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2841 if(found)
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2842 {
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2843 /* show it to the user */
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2844 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL,
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2845 s->str, NULL, NULL);
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2846 }
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2847 else
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2848 {
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2849 char *primary;
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2850 primary = g_strdup_printf(_("User information for %s unavailable"), info_data->name);
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2851 gaim_notify_error(info_data->gc, NULL, primary,
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2852 _("The user's profile is empty."));
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2853 g_free(primary);
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2854 }
7094
2343c3aa1dec [gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
2855
2343c3aa1dec [gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
2856 g_free(url_buffer);
7675
66d9440db6ec [gaim-migrate @ 8319]
Luke Schierer <lschiere@pidgin.im>
parents: 7664
diff changeset
2857 g_string_free(s, TRUE);
7161
3471c3b1e85c [gaim-migrate @ 7728]
Mark Doliner <mark@kingant.net>
parents: 7138
diff changeset
2858 g_free(info_data->name);
3471c3b1e85c [gaim-migrate @ 7728]
Mark Doliner <mark@kingant.net>
parents: 7138
diff changeset
2859 g_free(info_data);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2860 }
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2861
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2862 static void yahoo_get_info(GaimConnection *gc, const char *name)
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2863 {
7112
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2864 YahooGetInfoData *data;
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2865 char *url;
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2866
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2867 data = g_new0(YahooGetInfoData, 1);
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2868 data->gc = gc;
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2869 data->name = g_strdup(name);
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2870
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2871 url = g_strdup_printf("%s%s", YAHOO_PROFILE_URL, name);
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2872
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2873 gaim_url_fetch(url, FALSE, NULL, FALSE, yahoo_got_info, data);
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2874
cc1d09631513 [gaim-migrate @ 7679]
Luke Schierer <lschiere@pidgin.im>
parents: 7108
diff changeset
2875 g_free(url);
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2876 }
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2877
6793
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2878 static void yahoo_change_buddys_group(GaimConnection *gc, const char *who,
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2879 const char *old_group, const char *new_group)
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2880 {
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2881 struct yahoo_data *yd = gc->proto_data;
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2882 struct yahoo_packet *pkt;
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2883
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2884 /* Step 0: If they aren't on the server list anyway,
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2885 * don't bother letting the server know.
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2886 */
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2887 if (!g_hash_table_lookup(yd->friends, who))
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2888 return;
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2889
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2890 /* Step 1: Add buddy to new group. */
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2891 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0);
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2892 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2893 yahoo_packet_hash(pkt, 7, who);
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2894 yahoo_packet_hash(pkt, 65, new_group);
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2895 yahoo_packet_hash(pkt, 14, "");
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2896 yahoo_send_packet(yd, pkt);
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2897 yahoo_packet_free(pkt);
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2898
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2899 /* Step 2: Remove buddy from old group */
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2900 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0);
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2901 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2902 yahoo_packet_hash(pkt, 7, who);
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2903 yahoo_packet_hash(pkt, 65, old_group);
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2904 yahoo_send_packet(yd, pkt);
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2905 yahoo_packet_free(pkt);
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2906 }
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2907
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2908 static void yahoo_rename_group(GaimConnection *gc, const char *old_group,
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2909 const char *new_group, GList *whocares)
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2910 {
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2911 struct yahoo_data *yd = gc->proto_data;
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2912 struct yahoo_packet *pkt;
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2913
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2914 pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, YAHOO_STATUS_AVAILABLE, 0);
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2915 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2916 yahoo_packet_hash(pkt, 65, old_group);
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2917 yahoo_packet_hash(pkt, 67, new_group);
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2918 yahoo_send_packet(yd, pkt);
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2919 yahoo_packet_free(pkt);
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2920 }
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2921
7696
29bcd6e3da33 [gaim-migrate @ 8341]
Mark Doliner <mark@kingant.net>
parents: 7675
diff changeset
2922 #if 0
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2923 static gboolean yahoo_has_send_file(GaimConnection *gc, const char *who)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2924 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2925 return TRUE;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2926 }
7696
29bcd6e3da33 [gaim-migrate @ 8341]
Mark Doliner <mark@kingant.net>
parents: 7675
diff changeset
2927 #endif
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2928
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2929 static GaimPlugin *my_protocol = NULL;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2930
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2931 static GaimPluginProtocolInfo prpl_info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2932 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2933 GAIM_PROTO_YAHOO,
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2934 OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC,
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2935 NULL, /* user_splits */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2936 NULL, /* protocol_options */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2937 yahoo_list_icon,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2938 yahoo_list_emblems,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2939 yahoo_status_text,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2940 yahoo_tooltip_text,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2941 yahoo_away_states,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2942 yahoo_actions,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2943 yahoo_buddy_menu,
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2944 yahoo_c_info,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2945 yahoo_login,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2946 yahoo_close,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2947 yahoo_send_im,
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2948 NULL, /* set info */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2949 yahoo_send_typing,
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
2950 yahoo_get_info,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2951 yahoo_set_away,
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2952 NULL, /* get_away */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2953 NULL, /* set_dir */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2954 NULL, /* get_dir */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2955 NULL, /* dir_search */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2956 yahoo_set_idle,
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2957 NULL, /* change_passwd*/
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2958 yahoo_add_buddy,
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2959 NULL, /* add_buddies */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2960 yahoo_remove_buddy,
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2961 NULL, /*remove_buddies */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2962 NULL, /* add_permit */
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2963 yahoo_add_deny,
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2964 NULL, /* rem_permit */
6760
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2965 yahoo_rem_deny,
e7e21e5d1d16 [gaim-migrate @ 7292]
Luke Schierer <lschiere@pidgin.im>
parents: 6729
diff changeset
2966 yahoo_set_permit_deny,
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2967 NULL, /* warn */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2968 yahoo_c_join,
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2969 yahoo_c_invite,
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2970 yahoo_c_leave,
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2971 NULL, /* chat whisper */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2972 yahoo_c_send,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2973 yahoo_keepalive,
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2974 NULL, /* register_user */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2975 NULL, /* get_cb_info */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2976 NULL, /* get_cb_away */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2977 NULL, /* alias_buddy */
6793
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2978 yahoo_change_buddys_group,
3d84c933b939 [gaim-migrate @ 7332]
Luke Schierer <lschiere@pidgin.im>
parents: 6792
diff changeset
2979 yahoo_rename_group,
6729
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2980 NULL, /* buddy_free */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2981 NULL, /* convo_closed */
7b878ee8f064 [gaim-migrate @ 7256]
Luke Schierer <lschiere@pidgin.im>
parents: 6695
diff changeset
2982 NULL, /* normalize */
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2983 NULL, /* set_buddy_icon */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2984 NULL, /* void (*remove_group)(GaimConnection *gc, const char *group);*/
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2985 NULL, /* char *(*get_cb_real_name)(GaimConnection *gc, int id, const char *who); */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2986 #if 0
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2987 yahoo_ask_send_file,
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2988 yahoo_send_file,
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2989 yahoo_has_send_file
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
2990 #endif
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2991 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2992
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2993 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2994 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2995 2, /**< api_version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2996 GAIM_PLUGIN_PROTOCOL, /**< type */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2997 NULL, /**< ui_requirement */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2998 0, /**< flags */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
2999 NULL, /**< dependencies */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3000 GAIM_PRIORITY_DEFAULT, /**< priority */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3001
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3002 "prpl-yahoo", /**< id */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3003 "Yahoo", /**< name */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3004 VERSION, /**< version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3005 /** summary */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3006 N_("Yahoo Protocol Plugin"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3007 /** description */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3008 N_("Yahoo Protocol Plugin"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3009 NULL, /**< author */
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6321
diff changeset
3010 GAIM_WEBSITE, /**< homepage */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3011
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3012 NULL, /**< load */
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
3013 yahoo_unload_plugin, /**< unload */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3014 NULL, /**< destroy */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3015
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3016 NULL, /**< ui_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3017 &prpl_info /**< extra_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3018 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3019
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3020 static void
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
3021 init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3022 {
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5590
diff changeset
3023 GaimAccountOption *option;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3024
5685
43ea75092684 [gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
3025 option = gaim_account_option_string_new(_("Pager host"), "server",
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5590
diff changeset
3026 YAHOO_PAGER_HOST);
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5590
diff changeset
3027 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5590
diff changeset
3028 option);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3029
5685
43ea75092684 [gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
3030 option = gaim_account_option_int_new(_("Pager port"), "port",
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5590
diff changeset
3031 YAHOO_PAGER_PORT);
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5590
diff changeset
3032 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5590
diff changeset
3033 option);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
3034
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
3035 option = gaim_account_option_string_new(_("File transfer host"), "xfer_host", YAHOO_XFER_HOST);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
3036 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
3037
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
3038 option = gaim_account_option_int_new(_("File transfer port"), "xfer_port", YAHOO_XFER_PORT);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
3039 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents: 7631
diff changeset
3040
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3041 my_protocol = plugin;
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
3042
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
3043 yahoo_init_colorht();
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3044 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
3045
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
3046 GAIM_INIT_PLUGIN(yahoo, init_plugin, info);