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