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