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