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