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