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