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