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