Sat, 27 Sep 2003 19:17:21 +0000
[gaim-migrate @ 7538]
This is Mr. Holland's Opus. And by Mr. Holland I mean Robot101. He
rewrote the coreish IM image support so that the binary data gets
ripped out in the prpl and put in an imgstore instead of just being
passed in the same huge as char string as the actual message. This
is good because it's prpl agnostic, or something. It also means
we don't have a silly length of "-1" with pretty much every send or
receive IM function.
It should be crash free, bug free, and memleak free, but additional
testing is always a good thing.
If you like good stuff then you'll love this patch. But don't take
my word for it--ba dun dunt!
| 2681 | 1 | /* |
| 2 | * gaim | |
| 3 | * | |
| 4 | * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
| 5 | * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx> | |
| 6 | * | |
| 7 | * This program is free software; you can redistribute it and/or modify | |
| 8 | * it under the terms of the GNU General Public License as published by | |
| 9 | * the Free Software Foundation; either version 2 of the License, or | |
| 10 | * (at your option) any later version. | |
| 11 | * | |
| 12 | * This program is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | * GNU General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU General Public License | |
| 18 | * along with this program; if not, write to the Free Software | |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 20 | * | |
| 21 | */ | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
22 | #include "internal.h" |
| 2681 | 23 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
24 | #include "account.h" |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
25 | #include "accountopt.h" |
| 6760 | 26 | #include "blist.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
27 | #include "debug.h" |
| 2681 | 28 | #include "multi.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
29 | #include "notify.h" |
| 6760 | 30 | #include "privacy.h" |
| 2681 | 31 | #include "prpl.h" |
| 32 | #include "proxy.h" | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
33 | #include "request.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
34 | #include "server.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
35 | #include "util.h" |
|
6115
ac81410298f2
[gaim-migrate @ 6578]
Christian Hammond <chipx86@chipx86.com>
parents:
6069
diff
changeset
|
36 | #include "html.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
37 | |
| 6513 | 38 | #include "yahoo.h" |
| 6729 | 39 | #include "yahoochat.h" |
| 3147 | 40 | #include "md5.h" |
| 2681 | 41 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
42 | /* XXX */ |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
43 | #include "gtkinternal.h" |
|
6546
6a14dfe43d5c
[gaim-migrate @ 7068]
Mark Doliner <markdoliner@pidgin.im>
parents:
6516
diff
changeset
|
44 | #include "gaim.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
45 | #include "ui.h" |
| 3630 | 46 | |
| 5583 | 47 | extern char *yahoo_crypt(const char *, const char *); |
|
2795
b2e15894ab75
[gaim-migrate @ 2808]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2786
diff
changeset
|
48 | |
|
5493
f30de3b116ea
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
49 | /* #define YAHOO_DEBUG */ |
| 2681 | 50 | |
| 51 | #define USEROPT_MAIL 0 | |
| 52 | ||
| 3147 | 53 | #define YAHOO_PAGER_HOST "scs.yahoo.com" |
| 2681 | 54 | #define YAHOO_PAGER_PORT 5050 |
| 6514 | 55 | #define YAHOO_PROFILE_URL "http://profiles.yahoo.com/" |
| 2681 | 56 | |
| 6810 | 57 | #define YAHOO_PROTO_VER 0x000b |
| 3467 | 58 | |
| 2681 | 59 | #define YAHOO_PACKET_HDRLEN (4 + 2 + 2 + 2 + 2 + 4 + 4) |
| 60 | ||
| 6791 | 61 | static void yahoo_add_buddy(GaimConnection *gc, const char *who, GaimGroup *); |
| 6784 | 62 | |
| 63 | static struct yahoo_friend *yahoo_friend_new() | |
| 64 | { | |
| 65 | struct yahoo_friend *ret; | |
| 66 | ||
| 67 | ret = g_new0(struct yahoo_friend, 1); | |
| 68 | ret->status = YAHOO_STATUS_OFFLINE; | |
| 69 | ||
| 70 | return ret; | |
| 71 | } | |
| 72 | ||
| 73 | static void yahoo_friend_free(gpointer p) | |
| 74 | { | |
| 75 | struct yahoo_friend *f = p; | |
| 76 | if (f->msg) | |
| 77 | g_free(f->msg); | |
| 78 | if (f->game) | |
| 79 | g_free(f->game); | |
| 80 | g_free(f); | |
| 81 | } | |
| 82 | ||
| 6729 | 83 | struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id) |
| 2681 | 84 | { |
| 85 | struct yahoo_packet *pkt = g_new0(struct yahoo_packet, 1); | |
| 86 | ||
| 87 | pkt->service = service; | |
| 88 | pkt->status = status; | |
| 89 | pkt->id = id; | |
| 90 | ||
| 91 | return pkt; | |
| 92 | } | |
| 93 | ||
| 6729 | 94 | void yahoo_packet_hash(struct yahoo_packet *pkt, int key, const char *value) |
| 2681 | 95 | { |
| 96 | struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); | |
| 97 | pair->key = key; | |
| 98 | pair->value = g_strdup(value); | |
| 99 | pkt->hash = g_slist_append(pkt->hash, pair); | |
| 100 | } | |
| 101 | ||
| 102 | static int yahoo_packet_length(struct yahoo_packet *pkt) | |
| 103 | { | |
| 104 | GSList *l; | |
| 105 | ||
| 106 | int len = 0; | |
| 107 | ||
| 108 | l = pkt->hash; | |
| 109 | while (l) { | |
| 110 | struct yahoo_pair *pair = l->data; | |
| 111 | int tmp = pair->key; | |
| 112 | do { | |
| 113 | tmp /= 10; | |
| 114 | len++; | |
| 115 | } while (tmp); | |
| 116 | len += 2; | |
| 117 | len += strlen(pair->value); | |
| 118 | len += 2; | |
| 119 | l = l->next; | |
| 120 | } | |
| 121 | ||
| 122 | return len; | |
| 123 | } | |
| 124 | ||
| 125 | /* sometimes i wish prpls could #include things from other prpls. then i could just | |
| 126 | * use the routines from libfaim and not have to admit to knowing how they work. */ | |
| 127 | #define yahoo_put16(buf, data) ( \ | |
| 128 | (*(buf) = (u_char)((data)>>8)&0xff), \ | |
| 129 | (*((buf)+1) = (u_char)(data)&0xff), \ | |
| 130 | 2) | |
| 131 | #define yahoo_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) | |
| 132 | #define yahoo_put32(buf, data) ( \ | |
| 133 | (*((buf)) = (u_char)((data)>>24)&0xff), \ | |
| 134 | (*((buf)+1) = (u_char)((data)>>16)&0xff), \ | |
| 135 | (*((buf)+2) = (u_char)((data)>>8)&0xff), \ | |
| 136 | (*((buf)+3) = (u_char)(data)&0xff), \ | |
| 137 | 4) | |
| 138 | #define yahoo_get32(buf) ((((*(buf))<<24)&0xff000000) + \ | |
| 139 | (((*((buf)+1))<<16)&0x00ff0000) + \ | |
| 140 | (((*((buf)+2))<< 8)&0x0000ff00) + \ | |
| 141 | (((*((buf)+3) )&0x000000ff))) | |
| 142 | ||
| 143 | static void yahoo_packet_read(struct yahoo_packet *pkt, guchar *data, int len) | |
| 144 | { | |
| 145 | int pos = 0; | |
| 146 | ||
| 147 | while (pos + 1 < len) { | |
| 6629 | 148 | char key[64], *value = NULL, *esc; |
|
2724
d17b226540d3
[gaim-migrate @ 2737]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2723
diff
changeset
|
149 | int accept; |
| 2681 | 150 | int x; |
| 151 | ||
| 152 | struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); | |
| 153 | ||
| 154 | x = 0; | |
| 155 | while (pos + 1 < len) { | |
| 156 | if (data[pos] == 0xc0 && data[pos + 1] == 0x80) | |
| 157 | break; | |
| 158 | key[x++] = data[pos++]; | |
| 159 | } | |
| 160 | key[x] = 0; | |
| 161 | pos += 2; | |
| 162 | pair->key = strtol(key, NULL, 10); | |
|
2724
d17b226540d3
[gaim-migrate @ 2737]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2723
diff
changeset
|
163 | accept = x; /* if x is 0 there was no key, so don't accept it */ |
| 2681 | 164 | |
|
3996
5e58ec8c3b45
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
165 | if (len - pos + 1 <= 0) { |
|
5e58ec8c3b45
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
166 | /* Truncated. Garbage or something. */ |
|
5e58ec8c3b45
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
167 | accept = 0; |
|
5e58ec8c3b45
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
168 | } |
|
5e58ec8c3b45
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
169 | |
|
5e58ec8c3b45
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
170 | if (accept) { |
|
2724
d17b226540d3
[gaim-migrate @ 2737]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2723
diff
changeset
|
171 | value = g_malloc(len - pos + 1); |
|
3996
5e58ec8c3b45
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
172 | x = 0; |
|
5e58ec8c3b45
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
173 | while (pos + 1 < len) { |
|
5e58ec8c3b45
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
174 | if (data[pos] == 0xc0 && data[pos + 1] == 0x80) |
|
5e58ec8c3b45
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
175 | break; |
|
2724
d17b226540d3
[gaim-migrate @ 2737]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2723
diff
changeset
|
176 | value[x++] = data[pos++]; |
|
3996
5e58ec8c3b45
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
177 | } |
|
2724
d17b226540d3
[gaim-migrate @ 2737]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2723
diff
changeset
|
178 | value[x] = 0; |
|
d17b226540d3
[gaim-migrate @ 2737]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2723
diff
changeset
|
179 | pair->value = g_strdup(value); |
|
d17b226540d3
[gaim-migrate @ 2737]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2723
diff
changeset
|
180 | g_free(value); |
|
d17b226540d3
[gaim-migrate @ 2737]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2723
diff
changeset
|
181 | pkt->hash = g_slist_append(pkt->hash, pair); |
| 6629 | 182 | esc = g_strescape(pair->value, NULL); |
|
5220
f42438a0cc06
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
183 | gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
| 6629 | 184 | "Key: %d \tValue: %s\n", pair->key, esc); |
| 185 | g_free(esc); | |
|
2724
d17b226540d3
[gaim-migrate @ 2737]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2723
diff
changeset
|
186 | } else { |
|
d17b226540d3
[gaim-migrate @ 2737]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2723
diff
changeset
|
187 | g_free(pair); |
|
d17b226540d3
[gaim-migrate @ 2737]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2723
diff
changeset
|
188 | } |
|
3996
5e58ec8c3b45
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
189 | pos += 2; |
|
5e58ec8c3b45
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
190 | |
|
5e58ec8c3b45
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
191 | /* Skip over garbage we've noticed in the mail notifications */ |
|
5e58ec8c3b45
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
192 | if (data[0] == '9' && data[pos] == 0x01) |
|
5e58ec8c3b45
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
193 | pos++; |
| 2681 | 194 | } |
| 195 | } | |
| 196 | ||
| 197 | static void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data) | |
| 198 | { | |
| 199 | GSList *l = pkt->hash; | |
| 200 | int pos = 0; | |
| 201 | ||
| 202 | while (l) { | |
| 203 | struct yahoo_pair *pair = l->data; | |
| 204 | guchar buf[100]; | |
| 205 | ||
| 206 | g_snprintf(buf, sizeof(buf), "%d", pair->key); | |
| 207 | strcpy(data + pos, buf); | |
| 208 | pos += strlen(buf); | |
| 209 | data[pos++] = 0xc0; | |
| 210 | data[pos++] = 0x80; | |
| 211 | ||
| 212 | strcpy(data + pos, pair->value); | |
| 213 | pos += strlen(pair->value); | |
| 214 | data[pos++] = 0xc0; | |
| 215 | data[pos++] = 0x80; | |
| 216 | ||
| 217 | l = l->next; | |
| 218 | } | |
| 219 | } | |
| 220 | ||
| 221 | static void yahoo_packet_dump(guchar *data, int len) | |
| 222 | { | |
| 223 | #ifdef YAHOO_DEBUG | |
| 224 | int i; | |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
225 | |
|
5220
f42438a0cc06
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
226 | gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
227 | |
| 2681 | 228 | for (i = 0; i + 1 < len; i += 2) { |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
229 | if ((i % 16 == 0) && i) { |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
230 | gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
|
5220
f42438a0cc06
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
231 | gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
232 | } |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
233 | |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
234 | gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x%02x ", data[i], data[i + 1]); |
| 2681 | 235 | } |
| 236 | if (i < len) | |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
237 | gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x", data[i]); |
|
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"); |
|
5220
f42438a0cc06
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
240 | gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
241 | |
| 2681 | 242 | for (i = 0; i < len; i++) { |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
243 | if ((i % 16 == 0) && i) { |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
244 | gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
|
5220
f42438a0cc06
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
245 | gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
246 | } |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
247 | |
| 6686 | 248 | if (g_ascii_isprint(data[i])) |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
249 | gaim_debug(GAIM_DEBUG_MISC, NULL, "%c ", data[i]); |
| 2681 | 250 | else |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
251 | gaim_debug(GAIM_DEBUG_MISC, NULL, ". "); |
| 2681 | 252 | } |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
253 | |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
254 | gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
| 2681 | 255 | #endif |
| 256 | } | |
| 257 | ||
| 6729 | 258 | int yahoo_send_packet(struct yahoo_data *yd, struct yahoo_packet *pkt) |
| 2681 | 259 | { |
| 260 | int pktlen = yahoo_packet_length(pkt); | |
| 261 | int len = YAHOO_PACKET_HDRLEN + pktlen; | |
| 262 | int ret; | |
| 263 | ||
| 264 | guchar *data; | |
| 265 | int pos = 0; | |
| 266 | ||
| 267 | if (yd->fd < 0) | |
| 268 | return -1; | |
| 269 | ||
| 270 | data = g_malloc0(len + 1); | |
| 271 | ||
| 272 | memcpy(data + pos, "YMSG", 4); pos += 4; | |
| 3467 | 273 | pos += yahoo_put16(data + pos, YAHOO_PROTO_VER); |
| 2681 | 274 | pos += yahoo_put16(data + pos, 0x0000); |
| 275 | pos += yahoo_put16(data + pos, pktlen); | |
| 276 | pos += yahoo_put16(data + pos, pkt->service); | |
| 277 | pos += yahoo_put32(data + pos, pkt->status); | |
| 278 | pos += yahoo_put32(data + pos, pkt->id); | |
| 279 | ||
| 280 | yahoo_packet_write(pkt, data + pos); | |
| 281 | ||
| 282 | yahoo_packet_dump(data, len); | |
| 283 | ret = write(yd->fd, data, len); | |
| 284 | g_free(data); | |
| 285 | ||
| 286 | return ret; | |
| 287 | } | |
| 288 | ||
| 6729 | 289 | void yahoo_packet_free(struct yahoo_packet *pkt) |
| 2681 | 290 | { |
| 291 | while (pkt->hash) { | |
| 292 | struct yahoo_pair *pair = pkt->hash->data; | |
| 293 | g_free(pair->value); | |
| 294 | g_free(pair); | |
| 295 | pkt->hash = g_slist_remove(pkt->hash, pair); | |
| 296 | } | |
| 297 | g_free(pkt); | |
| 298 | } | |
| 299 | ||
| 6784 | 300 | static void yahoo_update_status(GaimConnection *gc, const char *name, struct yahoo_friend *f) |
| 301 | { | |
| 6840 | 302 | int online = 1; |
| 303 | ||
| 6784 | 304 | if (!gc || !name || !f || !gaim_find_buddy(gaim_connection_get_account(gc), name)) |
| 305 | return; | |
| 306 | ||
| 6840 | 307 | if (f->status == YAHOO_STATUS_OFFLINE) |
| 308 | online = 0; | |
| 309 | ||
| 310 | serv_got_update(gc, name, online, 0, 0, f->idle, f->away ? UC_UNAVAILABLE : 0); | |
| 6784 | 311 | } |
| 312 | ||
| 5583 | 313 | static void yahoo_process_status(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 314 | { |
| 315 | struct yahoo_data *yd = gc->proto_data; | |
| 316 | GSList *l = pkt->hash; | |
| 6784 | 317 | struct yahoo_friend *f = NULL; |
| 2681 | 318 | char *name = NULL; |
| 6784 | 319 | |
| 6686 | 320 | |
| 2681 | 321 | while (l) { |
| 322 | struct yahoo_pair *pair = l->data; | |
| 323 | ||
| 324 | switch (pair->key) { | |
| 325 | case 0: /* we won't actually do anything with this */ | |
| 326 | break; | |
| 327 | 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
|
328 | if (!yd->logged_in) { |
| 5583 | 329 | gaim_connection_set_state(gc, GAIM_CONNECTED); |
|
2805
31c7645db097
[gaim-migrate @ 2818]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2795
diff
changeset
|
330 | serv_finish_login(gc); |
| 5583 | 331 | gaim_connection_set_display_name(gc, pair->value); |
|
2805
31c7645db097
[gaim-migrate @ 2818]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2795
diff
changeset
|
332 | yd->logged_in = TRUE; |
| 2681 | 333 | |
| 3147 | 334 | /* this requests the list. i have a feeling that this is very evil |
| 335 | * | |
| 6686 | 336 | * scs.yahoo.com sends you the list before this packet without it being |
| 3147 | 337 | * requested |
| 338 | * | |
| 339 | * do_import(gc, NULL); | |
| 340 | * newpkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YAHOO_STATUS_OFFLINE, 0); | |
| 341 | * yahoo_send_packet(yd, newpkt); | |
| 342 | * yahoo_packet_free(newpkt); | |
| 343 | */ | |
| 344 | ||
| 345 | } | |
| 2681 | 346 | break; |
| 347 | case 8: /* how many online buddies we have */ | |
| 348 | break; | |
| 349 | case 7: /* the current buddy */ | |
| 350 | name = pair->value; | |
| 6784 | 351 | f = g_hash_table_lookup(yd->friends, name); |
| 352 | if (!f) { | |
| 353 | f = yahoo_friend_new(); | |
| 354 | g_hash_table_insert(yd->friends, g_strdup(name), f); | |
| 355 | } | |
| 2681 | 356 | break; |
| 357 | case 10: /* state */ | |
| 6784 | 358 | if (!f) |
| 359 | break; | |
| 360 | ||
| 361 | f->status = strtol(pair->value, NULL, 10); | |
| 362 | if ((f->status >= YAHOO_STATUS_BRB) && (f->status <= YAHOO_STATUS_STEPPEDOUT)) | |
| 363 | f->away = 1; | |
| 364 | else | |
| 365 | f->away = 0; | |
| 366 | if (f->status == YAHOO_STATUS_IDLE) | |
| 367 | f->idle = time(NULL); | |
| 6804 | 368 | else |
| 369 | f->idle = 0; | |
| 6784 | 370 | if (f->status != YAHOO_STATUS_CUSTOM) { |
| 371 | g_free(f->msg); | |
| 372 | f->msg = NULL; | |
| 373 | } | |
| 6847 | 374 | |
| 375 | f->sms = 0; | |
| 2681 | 376 | break; |
| 377 | case 19: /* custom message */ | |
| 6784 | 378 | if (f) { |
| 379 | if (f->msg) | |
| 380 | g_free(f->msg); | |
| 381 | f->msg = g_strdup(pair->value); | |
| 382 | } | |
| 2681 | 383 | break; |
| 6686 | 384 | case 11: /* this is the buddy's session id */ |
| 2681 | 385 | break; |
| 386 | case 17: /* in chat? */ | |
| 387 | break; | |
| 6784 | 388 | case 47: /* is custom status away or not? 2=idle*/ |
| 389 | if (!f) | |
| 390 | break; | |
| 391 | f->away = strtol(pair->value, NULL, 10); | |
| 392 | if (f->away == 2) | |
| 393 | f->idle = time(NULL); | |
| 6686 | 394 | break; |
| 6784 | 395 | case 138: /* either we're not idle, or we are but won't say how long */ |
| 396 | if (!f) | |
| 397 | break; | |
| 398 | ||
| 399 | if (f->idle) | |
| 400 | f->idle = -1; | |
| 401 | break; | |
| 402 | case 137: /* usually idle time in seconds, sometimes login time */ | |
| 403 | if (!f) | |
| 404 | break; | |
| 405 | ||
| 406 | if (f->status != YAHOO_STATUS_AVAILABLE) | |
| 407 | f->idle = time(NULL) - strtol(pair->value, NULL, 10); | |
| 6686 | 408 | break; |
| 409 | case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */ | |
| 6784 | 410 | if (strtol(pair->value, NULL, 10) == 0) { |
| 411 | if (f) | |
| 412 | f->status = YAHOO_STATUS_OFFLINE; | |
| 4732 | 413 | serv_got_update(gc, name, 0, 0, 0, 0, 0); |
|
2807
fe1ea0453890
[gaim-migrate @ 2820]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2805
diff
changeset
|
414 | break; |
|
2805
31c7645db097
[gaim-migrate @ 2818]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2795
diff
changeset
|
415 | } |
| 6784 | 416 | |
| 417 | if (f) | |
| 418 | yahoo_update_status(gc, name, f); | |
| 419 | break; | |
| 420 | case 60: /* SMS */ | |
| 421 | if (f) { | |
| 422 | f->sms = strtol(pair->value, NULL, 10); | |
| 423 | yahoo_update_status(gc, name, f); | |
|
2771
8c214f13da39
[gaim-migrate @ 2784]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2741
diff
changeset
|
424 | } |
|
8c214f13da39
[gaim-migrate @ 2784]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2741
diff
changeset
|
425 | break; |
| 2979 | 426 | case 16: /* Custom error message */ |
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5367
diff
changeset
|
427 | gaim_notify_error(gc, NULL, pair->value, NULL); |
| 2951 | 428 | break; |
| 2681 | 429 | default: |
|
5220
f42438a0cc06
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
430 | gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
431 | "Unknown status key %d\n", pair->key); |
| 2681 | 432 | break; |
| 433 | } | |
| 434 | ||
| 435 | l = l->next; | |
| 436 | } | |
| 437 | } | |
| 438 | ||
| 6820 | 439 | static void yahoo_do_group_check(GaimAccount *account, GHashTable *ht, const char *name, const char *group, |
| 440 | gboolean *export) | |
| 441 | { | |
| 442 | GaimBuddy *b; | |
| 443 | GaimGroup *g; | |
| 444 | GSList *list, *i; | |
| 445 | gboolean onlist = 0; | |
| 446 | char *oname = NULL; | |
| 447 | ||
| 448 | if (!g_hash_table_lookup_extended(ht, name, (gpointer *) &oname, (gpointer *) &list)) | |
| 449 | list = gaim_find_buddies(account, name); | |
| 450 | else | |
| 451 | g_hash_table_steal(ht, name); | |
| 452 | ||
| 453 | for (i = list; i; i = i->next) { | |
| 454 | b = i->data; | |
| 455 | g = gaim_find_buddys_group(b); | |
| 456 | if (!gaim_utf8_strcasecmp(group, g->name)) { | |
| 457 | gaim_debug(GAIM_DEBUG_MISC, "yahoo", | |
| 458 | "Oh good, %s is in the right group (%s).\n", name, group); | |
| 459 | list = g_slist_delete_link(list, i); | |
| 460 | onlist = 1; | |
| 461 | break; | |
| 462 | } | |
| 463 | } | |
| 464 | ||
| 465 | if (!onlist) { | |
| 466 | gaim_debug(GAIM_DEBUG_MISC, "yahoo", | |
| 467 | "Uhoh, %s isn't on the list (or not in this group), adding him to group %s.\n", name, group); | |
| 468 | if (!(g = gaim_find_group(group))) { | |
| 469 | g = gaim_group_new(group); | |
| 470 | gaim_blist_add_group(g, NULL); | |
| 471 | } | |
| 472 | b = gaim_buddy_new(account, name, NULL); | |
| 473 | gaim_blist_add_buddy(b, NULL, g, NULL); | |
| 474 | *export = TRUE; | |
| 475 | } | |
| 476 | ||
| 477 | if (list) { | |
| 478 | if (!oname) | |
| 479 | oname = g_strdup(name); | |
| 480 | g_hash_table_insert(ht, oname, list); | |
| 481 | } else if (oname) | |
| 482 | g_free(oname); | |
| 483 | } | |
| 484 | ||
| 485 | static void yahoo_do_group_cleanup(gpointer key, gpointer value, gpointer user_data) | |
| 486 | { | |
| 487 | char *name = key; | |
| 488 | GSList *list = value, *i; | |
| 489 | GaimBuddy *b; | |
| 490 | GaimGroup *g; | |
| 491 | gboolean *export = user_data; | |
| 492 | ||
| 493 | if (list) | |
| 494 | *export = TRUE; | |
| 495 | ||
| 496 | for (i = list; i; i = i->next) { | |
| 497 | b = i->data; | |
| 498 | g = gaim_find_buddys_group(b); | |
| 499 | gaim_debug(GAIM_DEBUG_MISC, "yahoo", "Deleting Buddy %s from group %s.\n", name, g->name); | |
| 500 | gaim_blist_remove_buddy(b); | |
| 501 | } | |
| 502 | } | |
| 503 | ||
| 5583 | 504 | static void yahoo_process_list(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 505 | { |
| 506 | GSList *l = pkt->hash; | |
| 507 | gboolean export = FALSE; | |
| 6760 | 508 | gboolean got_serv_list = FALSE; |
| 6695 | 509 | GaimBuddy *b; |
| 510 | GaimGroup *g; | |
| 6784 | 511 | struct yahoo_friend *f = NULL; |
| 6820 | 512 | GaimAccount *account = gaim_connection_get_account(gc); |
| 6784 | 513 | struct yahoo_data *yd = gc->proto_data; |
| 6820 | 514 | GHashTable *ht; |
| 6784 | 515 | |
| 516 | char **lines; | |
| 517 | char **split; | |
| 518 | char **buddies; | |
| 519 | char **tmp, **bud; | |
| 2681 | 520 | |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
521 | while (l) { |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
522 | struct yahoo_pair *pair = l->data; |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
523 | l = l->next; |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
524 | |
| 6760 | 525 | switch (pair->key) { |
| 526 | case 87: | |
| 6784 | 527 | if (!yd->tmp_serv_blist) |
| 528 | yd->tmp_serv_blist = g_string_new(pair->value); | |
| 529 | else | |
| 530 | g_string_append(yd->tmp_serv_blist, pair->value); | |
| 6760 | 531 | break; |
| 532 | case 88: | |
| 6784 | 533 | if (!yd->tmp_serv_ilist) |
| 534 | yd->tmp_serv_ilist = g_string_new(pair->value); | |
| 535 | else | |
| 536 | g_string_append(yd->tmp_serv_ilist, pair->value); | |
| 6760 | 537 | break; |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
538 | } |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
539 | } |
| 2681 | 540 | |
| 6784 | 541 | if (pkt->status != 0) |
| 542 | return; | |
| 543 | ||
| 544 | if (yd->tmp_serv_blist) { | |
| 6820 | 545 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_slist_free); |
| 546 | ||
| 6784 | 547 | lines = g_strsplit(yd->tmp_serv_blist->str, "\n", -1); |
| 548 | for (tmp = lines; *tmp; tmp++) { | |
| 549 | split = g_strsplit(*tmp, ":", 2); | |
| 550 | if (!split) | |
| 551 | continue; | |
| 552 | if (!split[0] || !split[1]) { | |
| 553 | g_strfreev(split); | |
| 554 | continue; | |
| 555 | } | |
| 556 | buddies = g_strsplit(split[1], ",", -1); | |
| 557 | for (bud = buddies; bud && *bud; bud++) { | |
| 558 | if (!(f = g_hash_table_lookup(yd->friends, *bud))) { | |
| 559 | f = yahoo_friend_new(*bud); | |
| 560 | g_hash_table_insert(yd->friends, g_strdup(*bud), f); | |
| 561 | } | |
| 6820 | 562 | if (!(b = gaim_find_buddy(account, *bud))) { |
| 6784 | 563 | if (!(g = gaim_find_group(split[0]))) { |
| 564 | g = gaim_group_new(split[0]); | |
| 565 | gaim_blist_add_group(g, NULL); | |
| 566 | } | |
| 6820 | 567 | b = gaim_buddy_new(account, *bud, NULL); |
| 6784 | 568 | gaim_blist_add_buddy(b, NULL, g, NULL); |
| 569 | export = TRUE; | |
| 6820 | 570 | } |
| 6784 | 571 | |
| 6820 | 572 | yahoo_do_group_check(account, ht, *bud, split[0], &export); |
| 6784 | 573 | } |
| 574 | g_strfreev(buddies); | |
| 575 | g_strfreev(split); | |
| 576 | } | |
| 577 | g_strfreev(lines); | |
| 578 | ||
| 579 | g_string_free(yd->tmp_serv_blist, TRUE); | |
| 580 | yd->tmp_serv_blist = NULL; | |
| 6820 | 581 | g_hash_table_foreach(ht, yahoo_do_group_cleanup, &export); |
| 582 | g_hash_table_destroy(ht); | |
| 6784 | 583 | } |
| 584 | ||
| 585 | ||
| 586 | if (yd->tmp_serv_ilist) { | |
| 587 | buddies = g_strsplit(yd->tmp_serv_ilist->str, ",", -1); | |
| 588 | for (bud = buddies; bud && *bud; bud++) { | |
| 589 | /* The server is already ignoring the user */ | |
| 590 | got_serv_list = TRUE; | |
| 591 | gaim_privacy_deny_add(gc->account, *bud, 1); | |
| 592 | } | |
| 593 | g_strfreev(buddies); | |
| 594 | ||
| 595 | g_string_free(yd->tmp_serv_ilist, TRUE); | |
| 596 | yd->tmp_serv_ilist = NULL; | |
| 597 | } | |
| 598 | ||
| 599 | if (got_serv_list) { | |
| 600 | gc->account->perm_deny = 4; | |
| 601 | serv_set_permit_deny(gc); | |
| 602 | } | |
| 2681 | 603 | if (export) |
| 4349 | 604 | gaim_blist_save(); |
| 2681 | 605 | } |
| 606 | ||
| 5583 | 607 | static void yahoo_process_notify(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2993 | 608 | { |
| 609 | char *msg = NULL; | |
| 610 | char *from = NULL; | |
| 3019 | 611 | char *stat = NULL; |
| 612 | char *game = NULL; | |
| 6784 | 613 | struct yahoo_friend *f = NULL; |
| 2993 | 614 | GSList *l = pkt->hash; |
| 3019 | 615 | struct yahoo_data *yd = (struct yahoo_data*) gc->proto_data; |
| 6784 | 616 | |
| 2993 | 617 | while (l) { |
| 618 | struct yahoo_pair *pair = l->data; | |
| 619 | if (pair->key == 4) | |
| 620 | from = pair->value; | |
| 621 | if (pair->key == 49) | |
| 622 | msg = pair->value; | |
| 3001 | 623 | if (pair->key == 13) |
| 3019 | 624 | stat = pair->value; |
| 625 | if (pair->key == 14) | |
| 626 | game = pair->value; | |
| 2993 | 627 | l = l->next; |
| 628 | } | |
| 3640 | 629 | |
| 6784 | 630 | if (!from || !msg) |
| 3640 | 631 | return; |
| 6686 | 632 | |
| 4793 | 633 | if (!g_ascii_strncasecmp(msg, "TYPING", strlen("TYPING"))) { |
| 3019 | 634 | if (*stat == '1') |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
635 | serv_got_typing(gc, from, 0, GAIM_TYPING); |
| 3019 | 636 | else |
| 637 | serv_got_typing_stopped(gc, from); | |
| 4793 | 638 | } else if (!g_ascii_strncasecmp(msg, "GAME", strlen("GAME"))) { |
| 6695 | 639 | GaimBuddy *bud = gaim_find_buddy(gc->account, from); |
| 6784 | 640 | |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
641 | if (!bud) { |
|
5220
f42438a0cc06
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
642 | gaim_debug(GAIM_DEBUG_WARNING, "yahoo", |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
643 | "%s is playing a game, and doesn't want " |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
644 | "you to know.\n", from); |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
645 | } |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
646 | |
| 6784 | 647 | f = g_hash_table_lookup(yd->friends, from); |
| 648 | if (!f) | |
| 649 | return; /* if they're not on the list, don't bother */ | |
| 650 | ||
| 651 | if (f->game) { | |
| 652 | g_free(f->game); | |
| 653 | f->game = NULL; | |
| 654 | } | |
| 655 | ||
| 3019 | 656 | if (*stat == '1') { |
| 6784 | 657 | f->game = g_strdup(game); |
| 3020 | 658 | if (bud) |
| 6784 | 659 | yahoo_update_status(gc, from, f); |
| 3019 | 660 | } |
| 661 | } | |
| 2993 | 662 | } |
| 663 | ||
| 5583 | 664 | static void yahoo_process_message(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 665 | { |
| 666 | char *msg = NULL; | |
| 667 | char *from = NULL; | |
| 668 | time_t tm = time(NULL); | |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
669 | GSList *l = pkt->hash; |
| 6069 | 670 | |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
671 | if (pkt->status <= 1 || pkt->status == 5) { |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
672 | while (l) { |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
673 | struct yahoo_pair *pair = l->data; |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
674 | if (pair->key == 4) |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
675 | from = pair->value; |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
676 | if (pair->key == 15) |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
677 | tm = strtol(pair->value, NULL, 10); |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
678 | if (pair->key == 14) { |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
679 | char *m; |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
680 | |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
681 | msg = pair->value; |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
682 | |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
683 | strip_linefeed(msg); |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
684 | m = yahoo_codes_to_html(msg); |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6847
diff
changeset
|
685 | serv_got_im(gc, from, m, 0, tm); |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
686 | g_free(m); |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
687 | |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
688 | tm = time(NULL); |
| 6687 | 689 | } |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
690 | l = l->next; |
| 6687 | 691 | } |
| 2681 | 692 | } else if (pkt->status == 2) { |
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5367
diff
changeset
|
693 | gaim_notify_error(gc, NULL, |
|
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5367
diff
changeset
|
694 | _("Your Yahoo! message did not get sent."), NULL); |
| 2681 | 695 | } |
| 696 | } | |
| 697 | ||
| 6686 | 698 | static void yahoo_buddy_added_us(GaimConnection *gc, struct yahoo_packet *pkt) { |
| 2681 | 699 | char *id = NULL; |
| 700 | char *who = NULL; | |
| 701 | char *msg = NULL; | |
| 702 | GSList *l = pkt->hash; | |
| 703 | ||
| 704 | while (l) { | |
| 705 | struct yahoo_pair *pair = l->data; | |
| 6686 | 706 | |
| 707 | switch (pair->key) { | |
| 708 | case 1: | |
| 2681 | 709 | id = pair->value; |
| 6686 | 710 | break; |
| 711 | case 3: | |
| 2681 | 712 | who = pair->value; |
| 6686 | 713 | break; |
| 714 | case 15: /* time, for when they add us and we're offline */ | |
| 715 | break; | |
| 716 | case 14: | |
| 2681 | 717 | msg = pair->value; |
| 6686 | 718 | break; |
| 719 | } | |
| 2681 | 720 | l = l->next; |
| 721 | } | |
| 722 | ||
|
2682
49c15f67d4b1
[gaim-migrate @ 2695]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2681
diff
changeset
|
723 | if (id) |
|
49c15f67d4b1
[gaim-migrate @ 2695]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2681
diff
changeset
|
724 | show_got_added(gc, id, who, NULL, msg); |
| 6686 | 725 | } |
| 726 | ||
| 727 | static void yahoo_buddy_denied_our_add(GaimConnection *gc, struct yahoo_packet *pkt) | |
| 728 | { | |
| 729 | char *who = NULL; | |
| 730 | char *msg = NULL; | |
| 731 | GSList *l = pkt->hash; | |
| 732 | GString *buf = NULL; | |
| 6784 | 733 | struct yahoo_data *yd = gc->proto_data; |
| 6686 | 734 | |
| 735 | while (l) { | |
| 736 | struct yahoo_pair *pair = l->data; | |
| 737 | ||
| 738 | switch (pair->key) { | |
| 739 | case 3: | |
| 740 | who = pair->value; | |
| 741 | break; | |
| 742 | case 14: | |
| 743 | msg = pair->value; | |
| 744 | break; | |
| 745 | } | |
| 746 | l = l->next; | |
| 747 | } | |
| 748 | ||
| 749 | if (who) { | |
| 750 | buf = g_string_sized_new(0); | |
| 751 | if (!msg) | |
| 752 | g_string_printf(buf, _("%s has (retroactively) denied your request to add them to your list."), who); | |
|
2683
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
753 | else |
| 6686 | 754 | g_string_printf(buf, _("%s has (retroactively) denied your request to add them to your list for the following reason: %s."), who, msg); |
| 6840 | 755 | gaim_notify_info(gc, NULL, _("Add buddy rejected"), buf->str); |
| 6686 | 756 | g_string_free(buf, TRUE); |
| 6784 | 757 | g_hash_table_remove(yd->friends, who); |
| 758 | serv_got_update(gc, who, 0, 0, 0, 0, 0); | |
| 6686 | 759 | } |
| 760 | } | |
| 761 | ||
| 762 | static void yahoo_process_contact(GaimConnection *gc, struct yahoo_packet *pkt) | |
| 763 | { | |
| 764 | ||
| 765 | ||
| 766 | switch (pkt->status) { | |
| 767 | case 1: | |
| 768 | yahoo_process_status(gc, pkt); | |
| 769 | return; | |
| 770 | case 3: | |
| 771 | yahoo_buddy_added_us(gc, pkt); | |
| 772 | break; | |
| 773 | case 7: | |
| 774 | yahoo_buddy_denied_our_add(gc, pkt); | |
| 775 | break; | |
| 776 | default: | |
| 777 | break; | |
|
2683
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
778 | } |
| 2681 | 779 | } |
| 780 | ||
| 5583 | 781 | static void yahoo_process_mail(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 782 | { |
| 5583 | 783 | GaimAccount *account = gaim_connection_get_account(gc); |
| 2681 | 784 | char *who = NULL; |
| 785 | char *email = NULL; | |
| 786 | char *subj = NULL; | |
| 787 | int count = 0; | |
| 788 | GSList *l = pkt->hash; | |
| 789 | ||
| 5583 | 790 | if (!gaim_account_get_check_mail(account)) |
|
5521
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
791 | return; |
|
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
792 | |
| 2681 | 793 | while (l) { |
| 794 | struct yahoo_pair *pair = l->data; | |
| 795 | if (pair->key == 9) | |
| 796 | count = strtol(pair->value, NULL, 10); | |
| 797 | else if (pair->key == 43) | |
| 798 | who = pair->value; | |
| 799 | else if (pair->key == 42) | |
| 800 | email = pair->value; | |
| 801 | else if (pair->key == 18) | |
| 802 | subj = pair->value; | |
| 803 | l = l->next; | |
| 804 | } | |
| 805 | ||
| 4001 | 806 | if (who && subj && email && *email) { |
| 2850 | 807 | char *from = g_strdup_printf("%s (%s)", who, email); |
|
5521
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
808 | |
| 5583 | 809 | gaim_notify_email(gc, subj, from, gaim_account_get_username(account), |
|
5521
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
810 | "http://mail.yahoo.com/", NULL, NULL); |
|
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
811 | |
| 2850 | 812 | g_free(from); |
|
5521
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
813 | } else if (count > 0) { |
| 5583 | 814 | const char *to = gaim_account_get_username(account); |
|
5521
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
815 | const char *url = "http://mail.yahoo.com/"; |
|
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
816 | |
|
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
817 | gaim_notify_emails(gc, count, FALSE, NULL, NULL, &to, &url, |
|
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
818 | NULL, NULL); |
|
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
819 | } |
| 2681 | 820 | } |
| 3147 | 821 | /* This is the y64 alphabet... it's like base64, but has a . and a _ */ |
| 822 | char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._"; | |
| 823 | ||
| 824 | /* This is taken from Sylpheed by Hiroyuki Yamamoto. We have our own tobase64 function | |
| 825 | * in util.c, but it has a bug I don't feel like finding right now ;) */ | |
| 826 | void to_y64(unsigned char *out, const unsigned char *in, int inlen) | |
| 827 | /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ | |
| 828 | { | |
| 829 | for (; inlen >= 3; inlen -= 3) | |
| 830 | { | |
| 831 | *out++ = base64digits[in[0] >> 2]; | |
| 832 | *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)]; | |
| 833 | *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)]; | |
| 834 | *out++ = base64digits[in[2] & 0x3f]; | |
| 835 | in += 3; | |
| 836 | } | |
| 837 | if (inlen > 0) | |
| 838 | { | |
| 839 | unsigned char fragment; | |
| 840 | ||
| 841 | *out++ = base64digits[in[0] >> 2]; | |
| 842 | fragment = (in[0] << 4) & 0x30; | |
| 843 | if (inlen > 1) | |
| 844 | fragment |= in[1] >> 4; | |
| 845 | *out++ = base64digits[fragment]; | |
| 846 | *out++ = (inlen < 2) ? '-' : base64digits[(in[1] << 2) & 0x3c]; | |
| 847 | *out++ = '-'; | |
| 848 | } | |
| 849 | *out = '\0'; | |
| 850 | } | |
| 851 | ||
| 5583 | 852 | static void yahoo_process_auth(GaimConnection *gc, struct yahoo_packet *pkt) |
| 3147 | 853 | { |
| 854 | char *seed = NULL; | |
| 855 | char *sn = NULL; | |
| 856 | GSList *l = pkt->hash; | |
| 857 | struct yahoo_data *yd = gc->proto_data; | |
| 6784 | 858 | GaimAccount *account = gaim_connection_get_account(gc); |
| 6761 | 859 | |
| 3147 | 860 | while (l) { |
| 861 | struct yahoo_pair *pair = l->data; | |
| 862 | if (pair->key == 94) | |
| 863 | seed = pair->value; | |
| 864 | if (pair->key == 1) | |
| 865 | sn = pair->value; | |
| 866 | l = l->next; | |
| 867 | } | |
| 868 | ||
| 869 | if (seed) { | |
| 870 | struct yahoo_packet *pack; | |
| 5921 | 871 | const char *name = normalize(gaim_account_get_username(account)); |
| 5583 | 872 | const char *pass = gaim_account_get_password(account); |
| 873 | ||
| 3147 | 874 | /* So, Yahoo has stopped supporting its older clients in India, and undoubtedly |
| 875 | * will soon do so in the rest of the world. | |
| 6686 | 876 | * |
| 3147 | 877 | * The new clients use this authentication method. I warn you in advance, it's |
| 878 | * bizzare, convoluted, inordinately complicated. It's also no more secure than | |
| 879 | * crypt() was. The only purpose this scheme could serve is to prevent third | |
| 880 | * part clients from connecting to their servers. | |
| 881 | * | |
| 882 | * Sorry, Yahoo. | |
| 883 | */ | |
| 884 | ||
| 885 | md5_byte_t result[16]; | |
| 886 | md5_state_t ctx; | |
| 5583 | 887 | |
| 3147 | 888 | char *crypt_result; |
| 5583 | 889 | char password_hash[25]; |
| 890 | char crypt_hash[25]; | |
| 3147 | 891 | char *hash_string_p = g_malloc(50 + strlen(sn)); |
| 892 | char *hash_string_c = g_malloc(50 + strlen(sn)); | |
| 893 | ||
| 894 | char checksum; | |
| 895 | ||
| 3157 | 896 | int sv; |
| 3147 | 897 | |
| 5583 | 898 | char result6[25]; |
| 899 | char result96[25]; | |
| 3147 | 900 | |
| 901 | sv = seed[15]; | |
| 3157 | 902 | sv = sv % 8; |
| 3147 | 903 | |
| 904 | md5_init(&ctx); | |
| 5583 | 905 | md5_append(&ctx, pass, strlen(pass)); |
| 3147 | 906 | md5_finish(&ctx, result); |
| 907 | to_y64(password_hash, result, 16); | |
| 908 | ||
| 909 | md5_init(&ctx); | |
| 5583 | 910 | crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$"); |
| 3147 | 911 | md5_append(&ctx, crypt_result, strlen(crypt_result)); |
| 912 | md5_finish(&ctx, result); | |
| 913 | to_y64(crypt_hash, result, 16); | |
| 3157 | 914 | |
| 915 | switch (sv) { | |
| 3147 | 916 | case 1: |
| 917 | case 6: | |
| 3157 | 918 | checksum = seed[seed[9] % 16]; |
| 3147 | 919 | g_snprintf(hash_string_p, strlen(sn) + 50, |
| 5583 | 920 | "%c%s%s%s", checksum, name, seed, password_hash); |
| 3157 | 921 | g_snprintf(hash_string_c, strlen(sn) + 50, |
| 5583 | 922 | "%c%s%s%s", checksum, name, seed, crypt_hash); |
| 3147 | 923 | break; |
| 924 | case 2: | |
| 925 | case 7: | |
| 3157 | 926 | checksum = seed[seed[15] % 16]; |
| 3147 | 927 | g_snprintf(hash_string_p, strlen(sn) + 50, |
| 5583 | 928 | "%c%s%s%s", checksum, seed, password_hash, name); |
| 3157 | 929 | g_snprintf(hash_string_c, strlen(sn) + 50, |
| 5583 | 930 | "%c%s%s%s", checksum, seed, crypt_hash, name); |
| 3157 | 931 | break; |
| 3147 | 932 | case 3: |
| 3157 | 933 | checksum = seed[seed[1] % 16]; |
| 3147 | 934 | g_snprintf(hash_string_p, strlen(sn) + 50, |
| 5583 | 935 | "%c%s%s%s", checksum, name, password_hash, seed); |
| 3157 | 936 | g_snprintf(hash_string_c, strlen(sn) + 50, |
| 5583 | 937 | "%c%s%s%s", checksum, name, crypt_hash, seed); |
| 3157 | 938 | break; |
| 939 | case 4: | |
| 940 | checksum = seed[seed[3] % 16]; | |
| 941 | g_snprintf(hash_string_p, strlen(sn) + 50, | |
| 5583 | 942 | "%c%s%s%s", checksum, password_hash, seed, name); |
| 3147 | 943 | g_snprintf(hash_string_c, strlen(sn) + 50, |
| 5583 | 944 | "%c%s%s%s", checksum, crypt_hash, seed, name); |
| 3157 | 945 | break; |
| 3147 | 946 | case 0: |
| 947 | case 5: | |
| 3157 | 948 | checksum = seed[seed[7] % 16]; |
| 3147 | 949 | g_snprintf(hash_string_p, strlen(sn) + 50, |
| 5583 | 950 | "%c%s%s%s", checksum, password_hash, name, seed); |
| 3157 | 951 | g_snprintf(hash_string_c, strlen(sn) + 50, |
| 5583 | 952 | "%c%s%s%s", checksum, crypt_hash, name, seed); |
| 3157 | 953 | break; |
| 3147 | 954 | } |
| 3157 | 955 | |
| 3147 | 956 | md5_init(&ctx); |
| 3157 | 957 | md5_append(&ctx, hash_string_p, strlen(hash_string_p)); |
| 3147 | 958 | md5_finish(&ctx, result); |
| 959 | to_y64(result6, result, 16); | |
| 960 | ||
| 961 | md5_init(&ctx); | |
| 962 | md5_append(&ctx, hash_string_c, strlen(hash_string_c)); | |
| 963 | md5_finish(&ctx, result); | |
| 964 | to_y64(result96, result, 16); | |
| 965 | ||
| 6784 | 966 | pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); |
| 5583 | 967 | yahoo_packet_hash(pack, 0, name); |
| 3147 | 968 | yahoo_packet_hash(pack, 6, result6); |
| 969 | yahoo_packet_hash(pack, 96, result96); | |
| 5583 | 970 | yahoo_packet_hash(pack, 1, name); |
| 3147 | 971 | |
| 972 | yahoo_send_packet(yd, pack); | |
| 973 | ||
| 974 | g_free(hash_string_p); | |
| 975 | g_free(hash_string_c); | |
| 976 | ||
| 977 | yahoo_packet_free(pack); | |
| 978 | } | |
| 979 | } | |
| 2681 | 980 | |
| 6760 | 981 | static void ignore_buddy(GaimBuddy *b) { |
| 982 | GaimGroup *g; | |
| 983 | GaimConversation *c; | |
| 984 | GaimAccount *account; | |
| 985 | gchar *name; | |
| 986 | ||
| 6792 | 987 | if (!b) |
| 988 | return; | |
| 6760 | 989 | |
| 6792 | 990 | g = gaim_find_buddys_group(b); |
| 991 | name = g_strdup(b->name); | |
| 992 | account = b->account; | |
| 6760 | 993 | |
| 6792 | 994 | gaim_debug(GAIM_DEBUG_INFO, "blist", |
| 995 | "Removing '%s' from buddy list.\n", b->name); | |
| 996 | serv_remove_buddy(account->gc, name, g->name); | |
| 997 | gaim_blist_remove_buddy(b); | |
| 6760 | 998 | |
| 6792 | 999 | serv_add_deny(account->gc, name); |
| 1000 | gaim_blist_save(); | |
| 6760 | 1001 | |
| 6792 | 1002 | c = gaim_find_conversation_with_account(name, account); |
| 6760 | 1003 | |
| 6792 | 1004 | if (c != NULL) |
| 1005 | gaim_conversation_update(c, GAIM_CONV_UPDATE_REMOVE); | |
| 6760 | 1006 | |
| 1007 | g_free(name); | |
| 1008 | } | |
| 1009 | ||
| 1010 | static void keep_buddy(GaimBuddy *b) { | |
| 1011 | gaim_privacy_deny_remove(b->account, b->name, 1); | |
| 1012 | } | |
| 1013 | ||
| 1014 | static void yahoo_process_ignore(GaimConnection *gc, struct yahoo_packet *pkt) { | |
| 1015 | GaimBuddy *b; | |
| 1016 | GSList *l; | |
| 1017 | gchar *who = NULL; | |
| 1018 | gchar *sn = NULL; | |
| 1019 | gchar buf[BUF_LONG]; | |
| 1020 | gint ignore = 0; | |
| 1021 | gint status = 0; | |
| 1022 | ||
| 1023 | for (l = pkt->hash; l; l = l->next) { | |
| 1024 | struct yahoo_pair *pair = l->data; | |
| 1025 | switch (pair->key) { | |
| 1026 | case 0: | |
| 1027 | who = pair->value; | |
| 1028 | break; | |
| 1029 | case 1: | |
| 1030 | sn = pair->value; | |
| 1031 | break; | |
| 1032 | case 13: | |
| 1033 | ignore = strtol(pair->value, NULL, 10); | |
| 1034 | break; | |
| 1035 | case 66: | |
| 1036 | status = strtol(pair->value, NULL, 10); | |
| 1037 | break; | |
| 1038 | default: | |
| 1039 | break; | |
| 1040 | } | |
| 1041 | } | |
| 1042 | ||
| 1043 | switch (status) { | |
| 1044 | case 12: | |
| 1045 | b = gaim_find_buddy(gc->account, who); | |
| 1046 | g_snprintf(buf, sizeof(buf), _("You have tried to ignore %s, but the " | |
| 1047 | "user is on your buddy list. Clicking \"Yes\" " | |
| 1048 | "will remove and ignore the buddy."), who); | |
| 1049 | gaim_request_yes_no(gc, NULL, _("Ignore buddy?"), buf, 0, b, | |
| 1050 | G_CALLBACK(ignore_buddy), | |
| 1051 | G_CALLBACK(keep_buddy)); | |
| 1052 | break; | |
| 1053 | case 2: | |
| 1054 | case 3: | |
| 1055 | case 0: | |
| 1056 | default: | |
| 1057 | break; | |
| 1058 | } | |
| 1059 | } | |
| 1060 | ||
| 6761 | 1061 | static void yahoo_process_authresp(GaimConnection *gc, struct yahoo_packet *pkt) |
| 1062 | { | |
| 1063 | GSList *l = pkt->hash; | |
| 1064 | int err = 0; | |
| 1065 | char *msg; | |
| 1066 | ||
| 1067 | while (l) { | |
| 1068 | struct yahoo_pair *pair = l->data; | |
| 1069 | ||
| 1070 | if (pair->key == 66) | |
| 1071 | err = strtol(pair->value, NULL, 10); | |
| 1072 | ||
| 1073 | l = l->next; | |
| 1074 | } | |
| 1075 | ||
| 1076 | switch (err) { | |
| 1077 | case 3: | |
| 1078 | msg = _("Invalid username."); | |
| 1079 | break; | |
| 1080 | case 13: | |
| 1081 | msg = _("Incorrect password."); | |
| 1082 | break; | |
| 1083 | default: | |
| 1084 | msg = _("Unknown error."); | |
| 1085 | } | |
| 1086 | ||
| 1087 | gaim_connection_error(gc, msg); | |
| 1088 | } | |
| 1089 | ||
| 6840 | 1090 | static void yahoo_process_addbuddy(GaimConnection *gc, struct yahoo_packet *pkt) |
| 1091 | { | |
| 1092 | int err = 0; | |
| 1093 | char *who = NULL; | |
| 1094 | char *group = NULL; | |
| 1095 | char *buf; | |
| 1096 | struct yahoo_friend *f; | |
| 1097 | struct yahoo_data *yd = gc->proto_data; | |
| 1098 | GSList *l = pkt->hash; | |
| 1099 | ||
| 1100 | while (l) { | |
| 1101 | struct yahoo_pair *pair = l->data; | |
| 1102 | ||
| 1103 | switch (pair->key) { | |
| 1104 | case 66: | |
| 1105 | err = strtol(pair->value, NULL, 10); | |
| 1106 | break; | |
| 1107 | case 7: | |
| 1108 | who = pair->value; | |
| 1109 | break; | |
| 1110 | case 65: | |
| 1111 | group = pair->value; | |
| 1112 | break; | |
| 1113 | } | |
| 1114 | ||
| 1115 | l = l->next; | |
| 1116 | } | |
| 1117 | ||
| 1118 | if (!who) | |
| 1119 | return; | |
| 1120 | if (!group) | |
| 1121 | group = ""; | |
| 1122 | ||
| 1123 | if (!err || (err == 2)) { /* 0 = ok, 2 = already on serv list */ | |
| 1124 | if (!g_hash_table_lookup(yd->friends, who)) { | |
| 1125 | f = yahoo_friend_new(); | |
| 1126 | g_hash_table_insert(yd->friends, g_strdup(who), f); | |
| 1127 | yahoo_update_status(gc, who, f); | |
| 1128 | } | |
| 1129 | return; | |
| 1130 | } | |
| 1131 | ||
| 1132 | buf = g_strdup_printf(_("Could not add buddy %s to group %s to the server list on account %s."), | |
| 1133 | who, group, gaim_connection_get_display_name(gc)); | |
| 1134 | gaim_notify_error(gc, NULL, _("Could not add buddy to server list"), buf); | |
| 1135 | g_free(buf); | |
| 1136 | } | |
| 1137 | ||
| 5583 | 1138 | static void yahoo_packet_process(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 1139 | { |
| 6760 | 1140 | switch (pkt->service) { |
| 2681 | 1141 | case YAHOO_SERVICE_LOGON: |
|
2771
8c214f13da39
[gaim-migrate @ 2784]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2741
diff
changeset
|
1142 | case YAHOO_SERVICE_LOGOFF: |
| 2681 | 1143 | case YAHOO_SERVICE_ISAWAY: |
|
2737
f7edb9c3f348
[gaim-migrate @ 2750]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2724
diff
changeset
|
1144 | case YAHOO_SERVICE_ISBACK: |
| 3019 | 1145 | case YAHOO_SERVICE_GAMELOGON: |
| 1146 | case YAHOO_SERVICE_GAMELOGOFF: | |
| 6686 | 1147 | case YAHOO_SERVICE_CHATLOGON: |
| 1148 | case YAHOO_SERVICE_CHATLOGOFF: | |
| 2681 | 1149 | yahoo_process_status(gc, pkt); |
| 1150 | break; | |
| 3019 | 1151 | case YAHOO_SERVICE_NOTIFY: |
| 1152 | yahoo_process_notify(gc, pkt); | |
| 2993 | 1153 | break; |
| 2681 | 1154 | case YAHOO_SERVICE_MESSAGE: |
| 2786 | 1155 | case YAHOO_SERVICE_GAMEMSG: |
| 5939 | 1156 | case YAHOO_SERVICE_CHATMSG: |
| 2681 | 1157 | yahoo_process_message(gc, pkt); |
| 1158 | break; | |
| 1159 | case YAHOO_SERVICE_NEWMAIL: | |
| 1160 | yahoo_process_mail(gc, pkt); | |
| 1161 | break; | |
| 1162 | case YAHOO_SERVICE_NEWCONTACT: | |
| 1163 | yahoo_process_contact(gc, pkt); | |
| 1164 | break; | |
| 6784 | 1165 | case YAHOO_SERVICE_AUTHRESP: |
| 1166 | yahoo_process_authresp(gc, pkt); | |
| 1167 | break; | |
| 2681 | 1168 | case YAHOO_SERVICE_LIST: |
| 1169 | yahoo_process_list(gc, pkt); | |
| 1170 | break; | |
| 3147 | 1171 | case YAHOO_SERVICE_AUTH: |
| 1172 | yahoo_process_auth(gc, pkt); | |
| 1173 | break; | |
| 6840 | 1174 | case YAHOO_SERVICE_ADDBUDDY: |
| 1175 | yahoo_process_addbuddy(gc, pkt); | |
| 1176 | break; | |
| 6760 | 1177 | case YAHOO_SERVICE_IGNORECONTACT: |
| 1178 | yahoo_process_ignore(gc, pkt); | |
| 1179 | break; | |
| 6729 | 1180 | case YAHOO_SERVICE_CONFINVITE: |
| 1181 | case YAHOO_SERVICE_CONFADDINVITE: | |
| 1182 | yahoo_process_conference_invite(gc, pkt); | |
| 1183 | break; | |
| 1184 | case YAHOO_SERVICE_CONFDECLINE: | |
| 1185 | yahoo_process_conference_decline(gc, pkt); | |
| 1186 | break; | |
| 1187 | case YAHOO_SERVICE_CONFLOGON: | |
| 1188 | yahoo_process_conference_logon(gc, pkt); | |
| 1189 | break; | |
| 1190 | case YAHOO_SERVICE_CONFLOGOFF: | |
| 1191 | yahoo_process_conference_logoff(gc, pkt); | |
| 1192 | break; | |
| 1193 | case YAHOO_SERVICE_CONFMSG: | |
| 1194 | yahoo_process_conference_message(gc, pkt); | |
| 1195 | break; | |
| 1196 | case YAHOO_SERVICE_CHATONLINE: | |
| 1197 | yahoo_process_chat_online(gc, pkt); | |
| 1198 | break; | |
| 1199 | case YAHOO_SERVICE_CHATLOGOUT: | |
| 1200 | yahoo_process_chat_logout(gc, pkt); | |
| 1201 | break; | |
| 1202 | case YAHOO_SERVICE_CHATGOTO: | |
| 1203 | yahoo_process_chat_goto(gc, pkt); | |
| 1204 | break; | |
| 1205 | case YAHOO_SERVICE_CHATJOIN: | |
| 1206 | yahoo_process_chat_join(gc, pkt); | |
| 1207 | break; | |
| 1208 | case YAHOO_SERVICE_CHATLEAVE: /* XXX is this right? */ | |
| 1209 | case YAHOO_SERVICE_CHATEXIT: | |
| 1210 | yahoo_process_chat_exit(gc, pkt); | |
| 1211 | break; | |
| 1212 | case YAHOO_SERVICE_CHATINVITE: /* XXX never seen this one, might not do it right */ | |
| 1213 | case YAHOO_SERVICE_CHATADDINVITE: | |
| 1214 | yahoo_process_chat_addinvite(gc, pkt); | |
| 1215 | break; | |
| 1216 | case YAHOO_SERVICE_COMMENT: | |
| 1217 | yahoo_process_chat_message(gc, pkt); | |
| 1218 | break; | |
| 2681 | 1219 | default: |
|
5220
f42438a0cc06
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
1220 | gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1221 | "Unhandled service 0x%02x\n", pkt->service); |
| 2681 | 1222 | break; |
| 1223 | } | |
| 1224 | } | |
| 1225 | ||
| 1226 | static void yahoo_pending(gpointer data, gint source, GaimInputCondition cond) | |
| 1227 | { | |
| 5583 | 1228 | GaimConnection *gc = data; |
| 2681 | 1229 | struct yahoo_data *yd = gc->proto_data; |
| 1230 | char buf[1024]; | |
| 1231 | int len; | |
| 1232 | ||
| 1233 | len = read(yd->fd, buf, sizeof(buf)); | |
| 1234 | ||
| 1235 | if (len <= 0) { | |
|
6321
0b54b2a172d1
[gaim-migrate @ 6820]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6115
diff
changeset
|
1236 | gaim_connection_error(gc, _("Unable to read")); |
| 2681 | 1237 | return; |
| 1238 | } | |
| 1239 | ||
| 1240 | yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); | |
| 1241 | memcpy(yd->rxqueue + yd->rxlen, buf, len); | |
| 1242 | yd->rxlen += len; | |
| 1243 | ||
| 1244 | while (1) { | |
| 1245 | struct yahoo_packet *pkt; | |
| 1246 | int pos = 0; | |
| 1247 | int pktlen; | |
| 1248 | ||
| 1249 | if (yd->rxlen < YAHOO_PACKET_HDRLEN) | |
| 1250 | return; | |
| 1251 | ||
| 1252 | pos += 4; /* YMSG */ | |
| 1253 | pos += 2; | |
| 1254 | pos += 2; | |
| 1255 | ||
| 1256 | pktlen = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
|
5220
f42438a0cc06
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
1257 | gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1258 | "%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen); |
| 2681 | 1259 | |
| 1260 | if (yd->rxlen < (YAHOO_PACKET_HDRLEN + pktlen)) | |
| 1261 | return; | |
| 1262 | ||
| 1263 | yahoo_packet_dump(yd->rxqueue, YAHOO_PACKET_HDRLEN + pktlen); | |
| 1264 | ||
| 1265 | pkt = yahoo_packet_new(0, 0, 0); | |
| 1266 | ||
| 1267 | pkt->service = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
| 3021 | 1268 | pkt->status = yahoo_get32(yd->rxqueue + pos); pos += 4; |
|
5220
f42438a0cc06
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
1269 | gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1270 | "Yahoo Service: 0x%02x Status: %d\n", |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1271 | pkt->service, pkt->status); |
| 2681 | 1272 | pkt->id = yahoo_get32(yd->rxqueue + pos); pos += 4; |
| 1273 | ||
| 1274 | yahoo_packet_read(pkt, yd->rxqueue + pos, pktlen); | |
| 1275 | ||
| 1276 | yd->rxlen -= YAHOO_PACKET_HDRLEN + pktlen; | |
| 1277 | if (yd->rxlen) { | |
| 1278 | char *tmp = g_memdup(yd->rxqueue + YAHOO_PACKET_HDRLEN + pktlen, yd->rxlen); | |
| 1279 | g_free(yd->rxqueue); | |
| 1280 | yd->rxqueue = tmp; | |
| 1281 | } else { | |
| 1282 | g_free(yd->rxqueue); | |
| 1283 | yd->rxqueue = NULL; | |
| 1284 | } | |
| 1285 | ||
| 1286 | yahoo_packet_process(gc, pkt); | |
| 1287 | ||
| 1288 | yahoo_packet_free(pkt); | |
| 1289 | } | |
| 1290 | } | |
| 1291 | ||
| 1292 | static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond) | |
| 1293 | { | |
| 5583 | 1294 | GaimConnection *gc = data; |
| 2681 | 1295 | struct yahoo_data *yd; |
| 1296 | struct yahoo_packet *pkt; | |
| 1297 | ||
|
5590
96f84b9aae41
[gaim-migrate @ 5994]
Christian Hammond <chipx86@chipx86.com>
parents:
5583
diff
changeset
|
1298 | if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 2681 | 1299 | close(source); |
| 1300 | return; | |
| 1301 | } | |
| 1302 | ||
| 1303 | if (source < 0) { | |
|
6321
0b54b2a172d1
[gaim-migrate @ 6820]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6115
diff
changeset
|
1304 | gaim_connection_error(gc, _("Unable to connect")); |
| 2681 | 1305 | return; |
| 1306 | } | |
| 1307 | ||
| 1308 | yd = gc->proto_data; | |
| 1309 | yd->fd = source; | |
| 1310 | ||
| 3147 | 1311 | pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, 0); |
| 2681 | 1312 | |
| 5921 | 1313 | yahoo_packet_hash(pkt, 1, normalize(gaim_account_get_username(gaim_connection_get_account(gc)))); |
| 2681 | 1314 | yahoo_send_packet(yd, pkt); |
| 1315 | ||
| 1316 | yahoo_packet_free(pkt); | |
| 1317 | ||
| 1318 | gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); | |
| 1319 | } | |
| 1320 | ||
| 5583 | 1321 | static void yahoo_login(GaimAccount *account) { |
| 1322 | GaimConnection *gc = gaim_account_get_connection(account); | |
| 2681 | 1323 | struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1); |
| 1324 | ||
| 6629 | 1325 | gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_NO_BGCOLOR; |
| 1326 | ||
| 5583 | 1327 | gaim_connection_update_progress(gc, _("Connecting"), 1, 2); |
| 2681 | 1328 | |
| 1329 | yd->fd = -1; | |
| 6784 | 1330 | yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free); |
| 6729 | 1331 | yd->confs = NULL; |
| 1332 | yd->conf_id = 2; | |
| 2681 | 1333 | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
1334 | if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", YAHOO_PAGER_HOST), |
| 5583 | 1335 | gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), |
| 1336 | yahoo_got_connected, gc) != 0) { | |
|
6321
0b54b2a172d1
[gaim-migrate @ 6820]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6115
diff
changeset
|
1337 | gaim_connection_error(gc, _("Connection problem")); |
| 2681 | 1338 | return; |
| 1339 | } | |
| 1340 | ||
| 1341 | } | |
| 1342 | ||
| 5583 | 1343 | static void yahoo_close(GaimConnection *gc) { |
| 2681 | 1344 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
| 6729 | 1345 | |
| 6784 | 1346 | g_hash_table_destroy(yd->friends); |
| 6729 | 1347 | g_slist_free(yd->confs); |
| 6784 | 1348 | if (yd->chat_name) |
| 1349 | g_free(yd->chat_name); | |
| 6729 | 1350 | |
| 2681 | 1351 | if (yd->fd >= 0) |
| 1352 | close(yd->fd); | |
|
3720
dbba62e0d603
[gaim-migrate @ 3853]
Herman Bloggs <herman@bluedigits.com>
parents:
3642
diff
changeset
|
1353 | |
| 2681 | 1354 | if (yd->rxqueue) |
| 1355 | g_free(yd->rxqueue); | |
|
2687
664e22f507cf
[gaim-migrate @ 2700]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2686
diff
changeset
|
1356 | yd->rxlen = 0; |
| 2681 | 1357 | if (gc->inpa) |
| 1358 | gaim_input_remove(gc->inpa); | |
| 1359 | g_free(yd); | |
| 1360 | } | |
| 1361 | ||
| 6695 | 1362 | static const char *yahoo_list_icon(GaimAccount *a, GaimBuddy *b) |
| 2681 | 1363 | { |
| 4687 | 1364 | return "yahoo"; |
| 2681 | 1365 | } |
| 4916 | 1366 | |
| 6695 | 1367 | static void yahoo_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
| 4916 | 1368 | { |
| 1369 | int i = 0; | |
| 1370 | char *emblems[4] = {NULL,NULL,NULL,NULL}; | |
| 6784 | 1371 | GaimAccount *account; |
| 1372 | GaimConnection *gc; | |
| 1373 | struct yahoo_data *yd; | |
| 1374 | struct yahoo_friend *f; | |
| 1375 | ||
| 1376 | if (!b || !(account = b->account) || !(gc = gaim_account_get_connection(account)) || | |
| 1377 | !(yd = gc->proto_data)) | |
| 1378 | return; | |
| 1379 | ||
| 1380 | f = g_hash_table_lookup(yd->friends, b->name); | |
| 1381 | if (!f) { | |
| 1382 | *se = "notauthorized"; | |
| 1383 | return; | |
| 1384 | } | |
| 1385 | ||
| 5068 | 1386 | if (b->present == GAIM_BUDDY_OFFLINE) { |
| 4916 | 1387 | *se = "offline"; |
| 1388 | return; | |
| 1389 | } else { | |
| 6784 | 1390 | if (f->away) |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1391 | emblems[i++] = "away"; |
| 6784 | 1392 | if (f->sms) |
| 1393 | emblems[i++] = "wireless"; | |
| 1394 | if (f->game) | |
| 4916 | 1395 | emblems[i++] = "game"; |
| 1396 | } | |
| 1397 | *se = emblems[0]; | |
| 1398 | *sw = emblems[1]; | |
| 1399 | *nw = emblems[2]; | |
| 1400 | *ne = emblems[3]; | |
| 1401 | } | |
| 2681 | 1402 | |
| 1403 | static char *yahoo_get_status_string(enum yahoo_status a) | |
| 1404 | { | |
| 1405 | switch (a) { | |
| 1406 | case YAHOO_STATUS_BRB: | |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1407 | return _("Be Right Back"); |
| 2681 | 1408 | case YAHOO_STATUS_BUSY: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1409 | return _("Busy"); |
| 2681 | 1410 | case YAHOO_STATUS_NOTATHOME: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1411 | return _("Not At Home"); |
| 2681 | 1412 | case YAHOO_STATUS_NOTATDESK: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1413 | return _("Not At Desk"); |
| 2681 | 1414 | case YAHOO_STATUS_NOTINOFFICE: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1415 | return _("Not In Office"); |
| 2681 | 1416 | case YAHOO_STATUS_ONPHONE: |
| 4606 | 1417 | return _("On The Phone"); |
| 2681 | 1418 | case YAHOO_STATUS_ONVACATION: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1419 | return _("On Vacation"); |
| 2681 | 1420 | case YAHOO_STATUS_OUTTOLUNCH: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1421 | return _("Out To Lunch"); |
| 2681 | 1422 | case YAHOO_STATUS_STEPPEDOUT: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1423 | return _("Stepped Out"); |
|
2873
9e56887eeb06
[gaim-migrate @ 2886]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2856
diff
changeset
|
1424 | case YAHOO_STATUS_INVISIBLE: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1425 | return _("Invisible"); |
| 4730 | 1426 | case YAHOO_STATUS_IDLE: |
| 1427 | return _("Idle"); | |
| 6784 | 1428 | case YAHOO_STATUS_OFFLINE: |
| 1429 | return _("Offline"); | |
|
2879
e417cf7111c4
[gaim-migrate @ 2892]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2878
diff
changeset
|
1430 | default: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1431 | return _("Online"); |
| 2681 | 1432 | } |
| 1433 | } | |
| 1434 | ||
| 6729 | 1435 | static void yahoo_initiate_conference(GaimConnection *gc, const char *name) |
| 1436 | { | |
| 1437 | GHashTable *components; | |
| 1438 | struct yahoo_data *yd; | |
| 1439 | int id; | |
| 1440 | ||
| 1441 | yd = gc->proto_data; | |
| 1442 | id = yd->conf_id; | |
| 1443 | ||
| 1444 | components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
| 1445 | g_hash_table_replace(components, g_strdup("room"), | |
| 1446 | g_strdup_printf("%s-%d", gaim_connection_get_display_name(gc), id)); | |
| 1447 | g_hash_table_replace(components, g_strdup("topic"), g_strdup("Join my conference...")); | |
| 1448 | g_hash_table_replace(components, g_strdup("type"), g_strdup("Conference")); | |
| 1449 | yahoo_c_join(gc, components); | |
| 1450 | g_hash_table_destroy(components); | |
| 1451 | ||
| 1452 | yahoo_c_invite(gc, id, "Join my conference...", name); | |
| 1453 | } | |
| 1454 | ||
| 5583 | 1455 | static void yahoo_game(GaimConnection *gc, const char *name) { |
| 3019 | 1456 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
| 6784 | 1457 | char *game = NULL; |
| 3019 | 1458 | char *t; |
| 1459 | char url[256]; | |
| 6784 | 1460 | struct yahoo_friend *f; |
| 3019 | 1461 | |
| 6784 | 1462 | f = g_hash_table_lookup(yd->friends, name); |
| 1463 | if (!f) | |
| 1464 | return; | |
| 1465 | ||
| 1466 | game = f->game; | |
| 3019 | 1467 | if (!game) |
| 1468 | return; | |
| 6784 | 1469 | |
| 3019 | 1470 | t = game = g_strdup(strstr(game, "ante?room=")); |
| 1471 | while (*t != '\t') | |
| 1472 | t++; | |
| 1473 | *t = 0; | |
| 1474 | 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
|
1475 | gaim_notify_uri(gc, url); |
| 3019 | 1476 | g_free(game); |
| 1477 | } | |
| 4722 | 1478 | |
| 6695 | 1479 | static char *yahoo_status_text(GaimBuddy *b) |
| 4722 | 1480 | { |
| 1481 | struct yahoo_data *yd = (struct yahoo_data*)b->account->gc->proto_data; | |
| 6784 | 1482 | struct yahoo_friend *f = NULL; |
| 1483 | char *stripped = NULL; | |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1484 | |
| 6784 | 1485 | f = g_hash_table_lookup(yd->friends, b->name); |
| 1486 | if (!f) | |
| 1487 | return g_strdup(_("Not on server list")); | |
| 1488 | ||
| 1489 | switch (f->status) { | |
| 1490 | case YAHOO_STATUS_AVAILABLE: | |
| 1491 | return NULL; | |
| 1492 | case YAHOO_STATUS_IDLE: | |
| 1493 | if (f->idle == -1) | |
| 1494 | return g_strdup(yahoo_get_status_string(f->status)); | |
| 1495 | return NULL; | |
| 1496 | case YAHOO_STATUS_CUSTOM: | |
| 1497 | if (!f->msg) | |
| 1498 | return NULL; | |
| 1499 | stripped = strip_html(f->msg); | |
| 1500 | if (stripped) { | |
| 1501 | char *ret = g_markup_escape_text(stripped, strlen(stripped)); | |
| 1502 | g_free(stripped); | |
| 1503 | return ret; | |
| 1504 | } | |
| 1505 | return NULL; | |
| 1506 | default: | |
| 1507 | return g_strdup(yahoo_get_status_string(f->status)); | |
| 1508 | } | |
| 1509 | ||
| 4729 | 1510 | return NULL; |
| 4722 | 1511 | } |
| 1512 | ||
| 6695 | 1513 | static char *yahoo_tooltip_text(GaimBuddy *b) |
| 4724 | 1514 | { |
| 1515 | struct yahoo_data *yd = (struct yahoo_data*)b->account->gc->proto_data; | |
| 6784 | 1516 | struct yahoo_friend *f; |
| 1517 | char *escaped, *status, *ret; | |
| 1518 | ||
| 1519 | f = g_hash_table_lookup(yd->friends, b->name); | |
| 1520 | if (!f) | |
| 1521 | status = g_strdup(_("Not on server list")); | |
| 1522 | else | |
| 1523 | switch (f->status) { | |
| 1524 | case YAHOO_STATUS_IDLE: | |
| 1525 | if (f->idle == -1) { | |
| 1526 | status = g_strdup(yahoo_get_status_string(f->status)); | |
| 1527 | break; | |
| 1528 | } | |
| 1529 | return NULL; | |
| 1530 | case YAHOO_STATUS_CUSTOM: | |
| 1531 | if (!f->msg) | |
| 1532 | return NULL; | |
| 1533 | status = strip_html(f->msg); | |
| 1534 | break; | |
| 1535 | default: | |
| 1536 | status = g_strdup(yahoo_get_status_string(f->status)); | |
| 1537 | break; | |
| 4745 | 1538 | } |
| 6784 | 1539 | |
| 1540 | escaped = g_markup_escape_text(status, strlen(status)); | |
| 1541 | ret = g_strdup_printf(_("<b>Status:</b> %s"), escaped); | |
| 1542 | g_free(status); | |
| 1543 | g_free(escaped); | |
| 1544 | ||
| 1545 | return ret; | |
| 4729 | 1546 | } |
| 1547 | ||
| 6796 | 1548 | static void yahoo_addbuddyfrommenu_cb(GaimConnection *gc, const char *who) |
| 1549 | { | |
| 1550 | yahoo_add_buddy(gc, who, NULL); | |
| 1551 | } | |
| 1552 | ||
| 5583 | 1553 | static GList *yahoo_buddy_menu(GaimConnection *gc, const char *who) |
| 2681 | 1554 | { |
| 1555 | GList *m = NULL; | |
| 1556 | struct proto_buddy_menu *pbm; | |
| 1557 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 3019 | 1558 | static char buf2[1024]; |
| 6784 | 1559 | struct yahoo_friend *f; |
| 1560 | ||
| 1561 | f = g_hash_table_lookup(yd->friends, who); | |
| 1562 | ||
| 1563 | if (!f) { | |
| 1564 | pbm = g_new0(struct proto_buddy_menu, 1); | |
| 1565 | pbm->label = _("Add Buddy"); | |
| 6796 | 1566 | pbm->callback = yahoo_addbuddyfrommenu_cb; |
| 6784 | 1567 | pbm->gc = gc; |
| 1568 | m = g_list_append(m, pbm); | |
| 1569 | ||
| 1570 | return m; | |
| 1571 | } | |
| 1572 | ||
| 1573 | if (f->status == YAHOO_STATUS_OFFLINE) | |
| 1574 | return NULL; | |
| 4722 | 1575 | |
| 6729 | 1576 | pbm = g_new0(struct proto_buddy_menu, 1); |
| 1577 | pbm->label = _("Join in Chat"); | |
| 1578 | pbm->callback = yahoo_chat_goto; | |
| 1579 | pbm->gc = gc; | |
| 1580 | m = g_list_append(m, pbm); | |
| 1581 | ||
| 1582 | pbm = g_new0(struct proto_buddy_menu, 1); | |
| 1583 | pbm->label = _("Initiate Conference"); | |
| 1584 | pbm->callback = yahoo_initiate_conference; | |
| 1585 | pbm->gc = gc; | |
| 1586 | m = g_list_append(m, pbm); | |
| 1587 | ||
| 6784 | 1588 | if (f->game) { |
| 1589 | char *game = f->game; | |
| 3019 | 1590 | char *room; |
| 6784 | 1591 | char *t; |
| 1592 | ||
| 3019 | 1593 | if (!game) |
| 1594 | return m; | |
| 6784 | 1595 | |
| 1596 | pbm = g_new0(struct proto_buddy_menu, 1); | |
| 1597 | if (!(room = strstr(game, "&follow="))) /* skip ahead to the url */ | |
| 1598 | return m; | |
| 1599 | while (*room && *room != '\t') /* skip to the tab */ | |
| 1600 | room++; | |
| 1601 | t = room++; /* room as now at the name */ | |
| 1602 | while (*t != '\n') | |
| 1603 | t++; /* replace the \n with a space */ | |
| 1604 | *t = ' '; | |
| 1605 | g_snprintf(buf2, sizeof buf2, "%s", room); | |
| 1606 | pbm->label = buf2; | |
| 1607 | pbm->callback = yahoo_game; | |
| 1608 | pbm->gc = gc; | |
| 1609 | m = g_list_append(m, pbm); | |
| 3019 | 1610 | } |
| 6729 | 1611 | |
| 2681 | 1612 | return m; |
| 1613 | } | |
| 1614 | ||
| 5583 | 1615 | static void yahoo_act_id(GaimConnection *gc, const char *entry) |
| 2681 | 1616 | { |
| 1617 | struct yahoo_data *yd = gc->proto_data; | |
| 1618 | ||
| 1619 | struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0); | |
| 1620 | yahoo_packet_hash(pkt, 3, entry); | |
| 1621 | yahoo_send_packet(yd, pkt); | |
| 1622 | yahoo_packet_free(pkt); | |
| 1623 | ||
| 5583 | 1624 | gaim_connection_set_display_name(gc, entry); |
| 2681 | 1625 | } |
| 1626 | ||
| 5583 | 1627 | static void yahoo_show_act_id(GaimConnection *gc) |
| 2681 | 1628 | { |
|
5493
f30de3b116ea
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1629 | gaim_request_input(gc, NULL, _("Active which ID?"), NULL, |
|
6035
b245be9cbe3b
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
5939
diff
changeset
|
1630 | gaim_connection_get_display_name(gc), FALSE, FALSE, |
|
5493
f30de3b116ea
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1631 | _("OK"), G_CALLBACK(yahoo_act_id), |
|
f30de3b116ea
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1632 | _("Cancel"), NULL, gc); |
| 2681 | 1633 | } |
| 1634 | ||
| 5583 | 1635 | static GList *yahoo_actions(GaimConnection *gc) { |
| 2681 | 1636 | GList *m = NULL; |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4201
diff
changeset
|
1637 | struct proto_actions_menu *pam; |
| 2681 | 1638 | |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4201
diff
changeset
|
1639 | pam = g_new0(struct proto_actions_menu, 1); |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4201
diff
changeset
|
1640 | pam->label = _("Activate ID"); |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4201
diff
changeset
|
1641 | pam->callback = yahoo_show_act_id; |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4201
diff
changeset
|
1642 | pam->gc = gc; |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4201
diff
changeset
|
1643 | m = g_list_append(m, pam); |
| 2681 | 1644 | |
| 1645 | return m; | |
| 1646 | } | |
| 1647 | ||
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6847
diff
changeset
|
1648 | static int yahoo_send_im(GaimConnection *gc, const char *who, const char *what, GaimImFlags flags) |
| 2681 | 1649 | { |
| 1650 | struct yahoo_data *yd = gc->proto_data; | |
| 1651 | struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0); | |
| 6629 | 1652 | char *msg = yahoo_html_to_codes(what); |
| 2681 | 1653 | |
| 5583 | 1654 | yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
| 2681 | 1655 | yahoo_packet_hash(pkt, 5, who); |
| 3493 | 1656 | yahoo_packet_hash(pkt, 14, msg); |
|
6044
7832d0fb043f
[gaim-migrate @ 6494]
Mark Doliner <markdoliner@pidgin.im>
parents:
6035
diff
changeset
|
1657 | yahoo_packet_hash(pkt, 97, "1"); |
| 2681 | 1658 | |
| 1659 | yahoo_send_packet(yd, pkt); | |
| 1660 | ||
| 1661 | yahoo_packet_free(pkt); | |
| 6629 | 1662 | |
| 1663 | g_free(msg); | |
| 1664 | ||
| 2681 | 1665 | return 1; |
| 1666 | } | |
| 1667 | ||
|
6059
9934c862ca14
[gaim-migrate @ 6509]
John Silvestri <john.silvestri@gmail.com>
parents:
6044
diff
changeset
|
1668 | int yahoo_send_typing(GaimConnection *gc, const char *who, int typ) |
| 2993 | 1669 | { |
| 1670 | struct yahoo_data *yd = gc->proto_data; | |
| 3019 | 1671 | struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0); |
| 2993 | 1672 | yahoo_packet_hash(pkt, 49, "TYPING"); |
| 5583 | 1673 | yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
| 2993 | 1674 | yahoo_packet_hash(pkt, 14, " "); |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
1675 | yahoo_packet_hash(pkt, 13, typ == GAIM_TYPING ? "1" : "0"); |
| 2993 | 1676 | yahoo_packet_hash(pkt, 5, who); |
| 1677 | yahoo_packet_hash(pkt, 1002, "1"); | |
| 1678 | ||
| 1679 | yahoo_send_packet(yd, pkt); | |
| 1680 | ||
| 1681 | yahoo_packet_free(pkt); | |
| 1682 | ||
| 3001 | 1683 | return 0; |
| 2993 | 1684 | } |
| 1685 | ||
|
6059
9934c862ca14
[gaim-migrate @ 6509]
John Silvestri <john.silvestri@gmail.com>
parents:
6044
diff
changeset
|
1686 | static void yahoo_set_away(GaimConnection *gc, const char *state, const char *msg) |
| 2681 | 1687 | { |
| 1688 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 1689 | struct yahoo_packet *pkt; | |
|
2772
f7659670fc0b
[gaim-migrate @ 2785]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2771
diff
changeset
|
1690 | int service; |
| 2681 | 1691 | char s[4]; |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1692 | |
|
4111
93b27900416e
[gaim-migrate @ 4326]
Robert McQueen <robot101@debian.org>
parents:
4044
diff
changeset
|
1693 | if (gc->away) { |
|
93b27900416e
[gaim-migrate @ 4326]
Robert McQueen <robot101@debian.org>
parents:
4044
diff
changeset
|
1694 | g_free(gc->away); |
|
93b27900416e
[gaim-migrate @ 4326]
Robert McQueen <robot101@debian.org>
parents:
4044
diff
changeset
|
1695 | gc->away = NULL; |
|
93b27900416e
[gaim-migrate @ 4326]
Robert McQueen <robot101@debian.org>
parents:
4044
diff
changeset
|
1696 | } |
| 2681 | 1697 | |
| 1698 | if (msg) { | |
| 1699 | yd->current_status = YAHOO_STATUS_CUSTOM; | |
| 6847 | 1700 | gc->away = g_strndup(msg, YAHOO_MAX_STATUS_MESSAGE_LENGTH); |
| 2681 | 1701 | } else if (state) { |
|
4111
93b27900416e
[gaim-migrate @ 4326]
Robert McQueen <robot101@debian.org>
parents:
4044
diff
changeset
|
1702 | gc->away = g_strdup(""); |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1703 | if (!strcmp(state, _("Available"))) { |
| 2681 | 1704 | yd->current_status = YAHOO_STATUS_AVAILABLE; |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1705 | } else if (!strcmp(state, _("Be Right Back"))) { |
| 2681 | 1706 | yd->current_status = YAHOO_STATUS_BRB; |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1707 | } else if (!strcmp(state, _("Busy"))) { |
| 2681 | 1708 | yd->current_status = YAHOO_STATUS_BUSY; |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1709 | } else if (!strcmp(state, _("Not At Home"))) { |
| 2681 | 1710 | yd->current_status = YAHOO_STATUS_NOTATHOME; |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1711 | } else if (!strcmp(state, _("Not At Desk"))) { |
| 2681 | 1712 | yd->current_status = YAHOO_STATUS_NOTATDESK; |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1713 | } else if (!strcmp(state, _("Not In Office"))) { |
| 2681 | 1714 | yd->current_status = YAHOO_STATUS_NOTINOFFICE; |
| 4606 | 1715 | } else if (!strcmp(state, _("On The Phone"))) { |
| 2681 | 1716 | yd->current_status = YAHOO_STATUS_ONPHONE; |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1717 | } else if (!strcmp(state, _("On Vacation"))) { |
| 2681 | 1718 | yd->current_status = YAHOO_STATUS_ONVACATION; |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1719 | } else if (!strcmp(state, _("Out To Lunch"))) { |
| 2681 | 1720 | yd->current_status = YAHOO_STATUS_OUTTOLUNCH; |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1721 | } else if (!strcmp(state, _("Stepped Out"))) { |
| 2681 | 1722 | yd->current_status = YAHOO_STATUS_STEPPEDOUT; |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1723 | } else if (!strcmp(state, _("Invisible"))) { |
| 2681 | 1724 | yd->current_status = YAHOO_STATUS_INVISIBLE; |
| 6847 | 1725 | } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { /* this should never happen? */ |
| 2681 | 1726 | if (gc->is_idle) { |
| 1727 | yd->current_status = YAHOO_STATUS_IDLE; | |
| 1728 | } else { | |
| 1729 | yd->current_status = YAHOO_STATUS_AVAILABLE; | |
| 1730 | } | |
| 1731 | } | |
| 1732 | } else if (gc->is_idle) { | |
| 1733 | yd->current_status = YAHOO_STATUS_IDLE; | |
| 1734 | } else { | |
| 1735 | yd->current_status = YAHOO_STATUS_AVAILABLE; | |
| 1736 | } | |
| 1737 | ||
|
2772
f7659670fc0b
[gaim-migrate @ 2785]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2771
diff
changeset
|
1738 | if (yd->current_status == YAHOO_STATUS_AVAILABLE) |
|
f7659670fc0b
[gaim-migrate @ 2785]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2771
diff
changeset
|
1739 | service = YAHOO_SERVICE_ISBACK; |
|
f7659670fc0b
[gaim-migrate @ 2785]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2771
diff
changeset
|
1740 | else |
|
f7659670fc0b
[gaim-migrate @ 2785]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2771
diff
changeset
|
1741 | service = YAHOO_SERVICE_ISAWAY; |
| 6847 | 1742 | |
| 1743 | pkt = yahoo_packet_new(service, YAHOO_STATUS_AVAILABLE, 0); | |
| 2681 | 1744 | g_snprintf(s, sizeof(s), "%d", yd->current_status); |
| 1745 | yahoo_packet_hash(pkt, 10, s); | |
| 6847 | 1746 | |
| 1747 | if ((yd->current_status == YAHOO_STATUS_CUSTOM) && gc->away) | |
| 1748 | yahoo_packet_hash(pkt, 19, gc->away); | |
| 1749 | ||
| 1750 | if ((yd->current_status != YAHOO_STATUS_AVAILABLE) && | |
| 1751 | (yd->current_status != YAHOO_STATUS_IDLE)) { | |
| 6784 | 1752 | if (gc->is_idle) |
| 1753 | yahoo_packet_hash(pkt, 47, "2"); | |
| 1754 | else | |
| 1755 | yahoo_packet_hash(pkt, 47, "1"); | |
| 6686 | 1756 | } |
| 2681 | 1757 | |
| 1758 | yahoo_send_packet(yd, pkt); | |
| 1759 | yahoo_packet_free(pkt); | |
| 1760 | } | |
| 1761 | ||
| 5583 | 1762 | static void yahoo_set_idle(GaimConnection *gc, int idle) |
| 2681 | 1763 | { |
| 1764 | struct yahoo_data *yd = gc->proto_data; | |
| 1765 | struct yahoo_packet *pkt = NULL; | |
| 1766 | ||
| 1767 | if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) { | |
| 6847 | 1768 | pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); |
| 2681 | 1769 | yd->current_status = YAHOO_STATUS_IDLE; |
| 1770 | } else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { | |
| 1771 | pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); | |
| 1772 | yd->current_status = YAHOO_STATUS_AVAILABLE; | |
| 6847 | 1773 | } else { |
| 6784 | 1774 | pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); |
| 2681 | 1775 | } |
| 1776 | ||
| 1777 | if (pkt) { | |
| 1778 | char buf[4]; | |
| 1779 | g_snprintf(buf, sizeof(buf), "%d", yd->current_status); | |
| 1780 | yahoo_packet_hash(pkt, 10, buf); | |
| 6784 | 1781 | if (gc->away && yd->current_status == YAHOO_STATUS_CUSTOM) { |
| 1782 | yahoo_packet_hash(pkt, 19, gc->away); | |
| 1783 | if (idle) | |
| 1784 | yahoo_packet_hash(pkt, 47, "2"); | |
| 1785 | else | |
| 1786 | yahoo_packet_hash(pkt, 47, "1"); /* fixme when available messages are possible */ | |
| 6847 | 1787 | } else if (idle && (yd->current_status != YAHOO_STATUS_AVAILABLE) && |
| 1788 | (yd->current_status != YAHOO_STATUS_IDLE)) { | |
| 1789 | yahoo_packet_hash(pkt, 47, "2"); | |
| 1790 | } else if (!idle && (yd->current_status != YAHOO_STATUS_AVAILABLE) && | |
| 1791 | (yd->current_status != YAHOO_STATUS_IDLE)) { | |
| 1792 | yahoo_packet_hash(pkt, 47, "1"); | |
| 6784 | 1793 | } |
| 6847 | 1794 | |
| 2681 | 1795 | yahoo_send_packet(yd, pkt); |
| 1796 | yahoo_packet_free(pkt); | |
| 1797 | } | |
| 1798 | } | |
| 1799 | ||
| 5583 | 1800 | static GList *yahoo_away_states(GaimConnection *gc) |
| 2681 | 1801 | { |
| 1802 | GList *m = NULL; | |
| 1803 | ||
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1804 | m = g_list_append(m, _("Available")); |
|
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1805 | m = g_list_append(m, _("Be Right Back")); |
|
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1806 | m = g_list_append(m, _("Busy")); |
|
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1807 | m = g_list_append(m, _("Not At Home")); |
|
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1808 | m = g_list_append(m, _("Not At Desk")); |
|
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1809 | m = g_list_append(m, _("Not In Office")); |
| 4606 | 1810 | 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
|
1811 | m = g_list_append(m, _("On Vacation")); |
|
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1812 | m = g_list_append(m, _("Out To Lunch")); |
|
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1813 | m = g_list_append(m, _("Stepped Out")); |
|
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
1814 | m = g_list_append(m, _("Invisible")); |
| 2681 | 1815 | m = g_list_append(m, GAIM_AWAY_CUSTOM); |
| 1816 | ||
| 1817 | return m; | |
| 1818 | } | |
| 1819 | ||
| 5583 | 1820 | static void yahoo_keepalive(GaimConnection *gc) |
| 2681 | 1821 | { |
| 1822 | struct yahoo_data *yd = gc->proto_data; | |
| 1823 | struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0); | |
| 1824 | yahoo_send_packet(yd, pkt); | |
| 1825 | yahoo_packet_free(pkt); | |
| 6729 | 1826 | |
| 1827 | if (!yd->chat_online) | |
| 1828 | return; | |
| 1829 | ||
| 1830 | pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, 0); | |
| 1831 | yahoo_packet_hash(pkt, 109, gaim_connection_get_display_name(gc)); | |
| 1832 | yahoo_send_packet(yd, pkt); | |
| 1833 | yahoo_packet_free(pkt); | |
| 2681 | 1834 | } |
| 1835 | ||
|
6787
7d8e0ba98f68
[gaim-migrate @ 7326]
Christian Hammond <chipx86@chipx86.com>
parents:
6784
diff
changeset
|
1836 | static void yahoo_add_buddy(GaimConnection *gc, const char *who, GaimGroup *foo) |
| 2681 | 1837 | { |
| 1838 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 1839 | struct yahoo_packet *pkt; | |
| 6695 | 1840 | GaimGroup *g; |
| 2681 | 1841 | char *group = NULL; |
| 1842 | ||
| 1843 | if (!yd->logged_in) | |
| 1844 | return; | |
| 1845 | ||
| 6840 | 1846 | if (foo) |
| 1847 | group = foo->name; | |
| 1848 | if (!group) { | |
| 1849 | g = gaim_find_buddys_group(gaim_find_buddy(gc->account, who)); | |
| 1850 | if (g) | |
| 1851 | group = g->name; | |
| 1852 | else | |
| 1853 | group = "Buddies"; | |
| 1854 | } | |
| 2681 | 1855 | |
| 1856 | pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
| 5583 | 1857 | yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
| 2681 | 1858 | yahoo_packet_hash(pkt, 7, who); |
| 1859 | yahoo_packet_hash(pkt, 65, group); | |
| 6820 | 1860 | yahoo_packet_hash(pkt, 14, ""); |
| 2681 | 1861 | yahoo_send_packet(yd, pkt); |
| 1862 | yahoo_packet_free(pkt); | |
| 1863 | } | |
| 1864 | ||
|
6059
9934c862ca14
[gaim-migrate @ 6509]
John Silvestri <john.silvestri@gmail.com>
parents:
6044
diff
changeset
|
1865 | static void yahoo_remove_buddy(GaimConnection *gc, const char *who, const char *group) |
| 2681 | 1866 | { |
| 1867 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 6784 | 1868 | struct yahoo_friend *f; |
|
6795
396b24cfeeb6
[gaim-migrate @ 7334]
Herman Bloggs <herman@bluedigits.com>
parents:
6793
diff
changeset
|
1869 | struct yahoo_packet *pkt; |
| 6840 | 1870 | GSList *buddies, *l; |
| 1871 | GaimGroup *g; | |
| 1872 | gboolean remove = TRUE; | |
| 6784 | 1873 | |
| 1874 | if (!(f = g_hash_table_lookup(yd->friends, who))) | |
| 1875 | return; | |
| 1876 | ||
| 6840 | 1877 | buddies = gaim_find_buddies(gaim_connection_get_account(gc), who); |
| 1878 | for (l = buddies; l; l = l->next) { | |
| 1879 | g = gaim_find_buddys_group(l->data); | |
| 1880 | if (gaim_utf8_strcasecmp(group, g->name)) { | |
| 1881 | remove = FALSE; | |
| 1882 | break; | |
| 1883 | } | |
| 1884 | } | |
| 1885 | ||
| 1886 | g_slist_free(buddies); | |
| 1887 | ||
| 1888 | if (remove) | |
| 6820 | 1889 | g_hash_table_remove(yd->friends, who); |
| 2681 | 1890 | |
|
6795
396b24cfeeb6
[gaim-migrate @ 7334]
Herman Bloggs <herman@bluedigits.com>
parents:
6793
diff
changeset
|
1891 | pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); |
| 5583 | 1892 | yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
| 2681 | 1893 | yahoo_packet_hash(pkt, 7, who); |
| 1894 | yahoo_packet_hash(pkt, 65, group); | |
| 1895 | yahoo_send_packet(yd, pkt); | |
| 1896 | yahoo_packet_free(pkt); | |
| 1897 | } | |
| 1898 | ||
| 6760 | 1899 | static void yahoo_add_deny(GaimConnection *gc, const char *who) { |
| 1900 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 1901 | struct yahoo_packet *pkt; | |
| 1902 | ||
| 1903 | if (!yd->logged_in) | |
| 1904 | return; | |
| 1905 | ||
| 1906 | if (gc->account->perm_deny != 4) | |
| 1907 | return; | |
| 1908 | ||
| 1909 | if (!who || who[0] == '\0') | |
| 1910 | return; | |
| 1911 | ||
| 1912 | pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); | |
| 1913 | yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
| 1914 | yahoo_packet_hash(pkt, 7, who); | |
| 1915 | yahoo_packet_hash(pkt, 13, "1"); | |
| 1916 | yahoo_send_packet(yd, pkt); | |
| 1917 | yahoo_packet_free(pkt); | |
| 1918 | } | |
| 1919 | ||
| 1920 | static void yahoo_rem_deny(GaimConnection *gc, const char *who) { | |
| 1921 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 1922 | struct yahoo_packet *pkt; | |
| 1923 | ||
| 1924 | if (!yd->logged_in) | |
| 1925 | return; | |
| 1926 | ||
| 1927 | if (!who || who[0] == '\0') | |
| 1928 | return; | |
| 1929 | ||
| 1930 | pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); | |
| 1931 | yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
| 1932 | yahoo_packet_hash(pkt, 7, who); | |
| 1933 | yahoo_packet_hash(pkt, 13, "2"); | |
| 1934 | yahoo_send_packet(yd, pkt); | |
| 1935 | yahoo_packet_free(pkt); | |
| 1936 | } | |
| 1937 | ||
| 1938 | static void yahoo_set_permit_deny(GaimConnection *gc) { | |
| 1939 | GaimAccount *acct; | |
| 1940 | GSList *deny; | |
| 1941 | ||
| 1942 | acct = gc->account; | |
| 1943 | ||
| 1944 | switch (acct->perm_deny) { | |
| 1945 | case 1: | |
| 1946 | case 3: | |
| 1947 | case 5: | |
| 1948 | for (deny = acct->deny;deny;deny = deny->next) | |
| 1949 | yahoo_rem_deny(gc, deny->data); | |
| 1950 | break; | |
| 1951 | case 4: | |
| 1952 | for (deny = acct->deny;deny;deny = deny->next) | |
| 1953 | yahoo_add_deny(gc, deny->data); | |
| 1954 | break; | |
| 1955 | case 2: | |
| 1956 | default: | |
| 1957 | break; | |
| 1958 | } | |
| 1959 | } | |
| 1960 | ||
| 6513 | 1961 | static gboolean yahoo_unload_plugin(GaimPlugin *plugin) |
| 1962 | { | |
| 1963 | yahoo_dest_colorht(); | |
| 1964 | return TRUE; | |
| 1965 | } | |
| 1966 | ||
| 6514 | 1967 | static void yahoo_got_info(gpointer data, char *url_text, unsigned long len) |
| 1968 | { | |
| 1969 | char *stripped,*p; | |
| 1970 | char buf[1024]; | |
| 1971 | ||
| 1972 | /* we failed to grab the profile URL */ | |
| 1973 | if (!url_text) { | |
| 1974 | g_show_info_text(NULL, NULL, 2, | |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
1975 | _("<html><body><b>Error retrieving profile</b></body></html>"), NULL); |
| 6514 | 1976 | return; |
| 1977 | } | |
| 1978 | ||
| 1979 | /* we don't yet support the multiple link level of the warning page for | |
| 1980 | * 'adult' profiles, not to mention the fact that yahoo wants you to be | |
| 1981 | * logged in (on the website) to be able to view an 'adult' profile. for | |
| 1982 | * now, just tell them that we can't help them, and provide a link to the | |
| 1983 | * profile if they want to do the web browser thing. | |
| 1984 | */ | |
| 1985 | p = strstr(url_text, "Adult Profiles Warning Message"); | |
| 1986 | if (p) { | |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
1987 | strcpy(buf, _("<b>Sorry, profiles marked as containing adult content are not supported at this time.</b><br><br>\n")); |
| 6514 | 1988 | info_extract_field(url_text, buf, ".idname=", 0, "%26", 0, NULL, |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
1989 | _("If you wish to view this profile, you will need to visit this link in your web browser"), |
| 6514 | 1990 | 1, YAHOO_PROFILE_URL); |
| 1991 | strcat(buf, "</body></html>\n"); | |
| 1992 | g_show_info_text(NULL, NULL, 2, buf, NULL); | |
| 1993 | return; | |
| 1994 | } | |
| 1995 | ||
| 6630 | 1996 | /* at the moment we don't support profile pages with languages other than |
| 1997 | * english. the problem is, that every user may choose his/her own profile | |
| 1998 | * language. this language has nothing to do with the preferences of the | |
| 1999 | * user which looks at the profile | |
| 2000 | */ | |
| 2001 | p = strstr(url_text, "Last Updated:"); | |
| 2002 | if (!p) { | |
| 2003 | strcpy(buf, _("<b>Sorry, non-English profiles are not supported at this time.</b><br><br>\n")); | |
| 2004 | info_extract_field(url_text, buf, "<title>", 0, "'s Yahoo! Profile", 0, NULL, | |
| 2005 | _("If you wish to view this profile, you will need to visit this link in your web browser"), | |
| 2006 | 1, YAHOO_PROFILE_URL); | |
| 2007 | strcat(buf, "</body></html>\n"); | |
| 2008 | g_show_info_text(NULL, NULL, 2, buf, NULL); | |
| 2009 | return; | |
| 2010 | } | |
| 2011 | ||
| 6514 | 2012 | /* strip_html() doesn't strip out character entities like and · |
| 2013 | */ | |
| 2014 | while ((p = strstr(url_text, " ")) != NULL) { | |
| 2015 | memmove(p, p + 6, strlen(p + 6)); | |
| 2016 | url_text[strlen(url_text) - 6] = '\0'; | |
| 2017 | } | |
| 2018 | while ((p = strstr(url_text, "·")) != NULL) { | |
| 2019 | memmove(p, p + 6, strlen(p + 6)); | |
| 2020 | url_text[strlen(url_text) - 6] = '\0'; | |
| 2021 | } | |
| 2022 | ||
| 2023 | /* nuke the nasty \r's */ | |
| 2024 | while ((p = strchr(url_text, '\r')) != NULL) { | |
| 2025 | memmove(p, p + 1, strlen(p + 1)); | |
| 2026 | url_text[strlen(url_text) - 1] = '\0'; | |
| 2027 | } | |
| 2028 | ||
| 2029 | /* nuke the html, it's easier than trying to parse the horrid stuff */ | |
| 2030 | stripped = strip_html(url_text); | |
| 2031 | ||
| 2032 | /* gonna re-use the memory we've already got for url_text */ | |
| 2033 | strcpy(url_text, "<html><body>\n"); | |
| 2034 | ||
| 2035 | /* extract their Yahoo! ID and put it in */ | |
| 2036 | info_extract_field(stripped, url_text, "Yahoo! ID:", 2, "\n", 0, | |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2037 | NULL, _("Yahoo! ID"), 0, NULL); |
| 6514 | 2038 | |
| 2039 | /* extract their Email address and put it in */ | |
| 2040 | info_extract_field(stripped, url_text, "My Email", 5, "\n", 0, | |
| 6657 | 2041 | "Private", _("Email"), 0, NULL); |
| 6514 | 2042 | |
| 2043 | /* extract the Nickname if it exists */ | |
| 2044 | info_extract_field(stripped, url_text, "Nickname:", 1, "\n", '\n', | |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2045 | NULL, _("Nickname"), 0, NULL); |
| 6514 | 2046 | |
| 2047 | /* extract their RealName and put it in */ | |
| 2048 | info_extract_field(stripped, url_text, "RealName:", 1, "\n", '\n', | |
|
6623
75ba9eb9d3f8
[gaim-migrate @ 7147]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6622
diff
changeset
|
2049 | NULL, _("Realname"), 0, NULL); |
| 6514 | 2050 | |
| 2051 | /* extract their Location and put it in */ | |
| 2052 | info_extract_field(stripped, url_text, "Location:", 2, "\n", '\n', | |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2053 | NULL, _("Location"), 0, NULL); |
| 6514 | 2054 | |
| 2055 | /* extract their Age and put it in */ | |
| 2056 | info_extract_field(stripped, url_text, "Age:", 3, "\n", '\n', | |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2057 | NULL, _("Age"), 0, NULL); |
| 6514 | 2058 | |
| 2059 | /* extract their MaritalStatus and put it in */ | |
| 2060 | info_extract_field(stripped, url_text, "MaritalStatus:", 3, "\n", '\n', | |
| 6657 | 2061 | "No Answer", _("Marital Status"), 0, NULL); |
| 6514 | 2062 | |
| 2063 | /* extract their Gender and put it in */ | |
| 2064 | info_extract_field(stripped, url_text, "Gender:", 3, "\n", '\n', | |
| 6657 | 2065 | "No Answer", _("Gender"), 0, NULL); |
| 6514 | 2066 | |
| 2067 | /* extract their Occupation and put it in */ | |
| 2068 | info_extract_field(stripped, url_text, "Occupation:", 2, "\n", '\n', | |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2069 | NULL, _("Occupation"), 0, NULL); |
| 6514 | 2070 | |
| 2071 | /* Hobbies, Latest News, and Favorite Quote are a bit different, since the | |
| 2072 | * values can contain embedded newlines... but any or all of them can also | |
| 2073 | * not appear. The way we delimit them is to successively look for the next | |
| 2074 | * one that _could_ appear, and if all else fails, we end the section by | |
| 2075 | * looking for the 'Links' heading, which is the next thing to follow this | |
| 2076 | * bunch. | |
| 2077 | */ | |
| 2078 | if (!info_extract_field(stripped, url_text, "Hobbies:", 1, "Latest News", | |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2079 | '\n', NULL, _("Hobbies"), 0, NULL)) |
| 6514 | 2080 | if (!info_extract_field(stripped, url_text, "Hobbies:", 1, "Favorite Quote", |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2081 | '\n', NULL, _("Hobbies"), 0, NULL)) |
| 6514 | 2082 | info_extract_field(stripped, url_text, "Hobbies:", 1, "Links", |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2083 | '\n', NULL, _("Hobbies"), 0, NULL); |
| 6514 | 2084 | if (!info_extract_field(stripped, url_text, "Latest News:", 1, "Favorite Quote", |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2085 | '\n', NULL, _("Latest News"), 0, NULL)) |
| 6514 | 2086 | info_extract_field(stripped, url_text, "Latest News:", 1, "Links", |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2087 | '\n', NULL, _("Latest News"), 0, NULL); |
| 6514 | 2088 | info_extract_field(stripped, url_text, "Favorite Quote:", 0, "Links", |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2089 | '\n', NULL, _("Favorite Quote"), 0, NULL); |
| 6514 | 2090 | |
| 2091 | /* Home Page will either be "No home page specified", | |
| 2092 | * or "Home Page: " and a link. */ | |
| 2093 | p = strstr(stripped, "No home page specified"); | |
| 2094 | if (!p) | |
| 2095 | info_extract_field(stripped, url_text, "Home Page:", 1, " ", 0, NULL, | |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2096 | _("Home Page"), 1, NULL); |
| 6514 | 2097 | |
| 2098 | /* Cool Link {1,2,3} is also different. If "No cool link specified" exists, | |
| 2099 | * then we have none. If we have one however, we'll need to check and see if | |
| 2100 | * we have a second one. If we have a second one, we have to check to see if | |
| 2101 | * we have a third one. | |
| 2102 | */ | |
| 2103 | p = strstr(stripped,"No cool link specified"); | |
| 2104 | if (!p) | |
| 2105 | if (info_extract_field(stripped, url_text, "Cool Link 1:", 1, " ", 0, NULL, | |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2106 | _("Cool Link 1"), 1, NULL)) |
| 6514 | 2107 | if (info_extract_field(stripped, url_text, "Cool Link 2:", 1, " ", 0, NULL, |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2108 | _("Cool Link 2"), 1, NULL)) |
| 6514 | 2109 | info_extract_field(stripped, url_text, "Cool Link 3:", 1, " ", 0, NULL, |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2110 | _("Cool Link 3"), 1, NULL); |
| 6514 | 2111 | |
| 2112 | /* see if Member Since is there, and if so, extract it. */ | |
| 2113 | info_extract_field(stripped, url_text, "Member Since:", 1, "Last Updated:", | |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2114 | '\n', NULL, _("Member Since"), 0, NULL); |
| 6514 | 2115 | |
| 2116 | /* extract the Last Updated date and put it in */ | |
| 2117 | info_extract_field(stripped, url_text, "Last Updated:", 1, "\n", '\n', NULL, | |
|
6573
a3d6102d1e65
[gaim-migrate @ 7095]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6546
diff
changeset
|
2118 | _("Last Updated"), 0, NULL); |
| 6514 | 2119 | |
| 2120 | /* finish off the html */ | |
| 2121 | strcat(url_text, "</body></html>\n"); | |
| 2122 | g_free(stripped); | |
| 2123 | ||
| 2124 | /* show it to the user */ | |
| 2125 | g_show_info_text(NULL, NULL, 2, url_text, NULL); | |
| 2126 | } | |
| 2127 | ||
| 2128 | static void yahoo_get_info(GaimConnection *gc, const char *name) | |
| 2129 | { | |
| 2130 | /* struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; */ | |
| 2131 | char url[256]; | |
| 2132 | g_snprintf(url, sizeof url, "%s%s", YAHOO_PROFILE_URL, name); | |
| 6516 | 2133 | grab_url(url, FALSE, yahoo_got_info, NULL, NULL, 0); |
| 6514 | 2134 | } |
| 2135 | ||
| 6793 | 2136 | static void yahoo_change_buddys_group(GaimConnection *gc, const char *who, |
| 2137 | const char *old_group, const char *new_group) | |
| 2138 | { | |
| 2139 | struct yahoo_data *yd = gc->proto_data; | |
| 2140 | struct yahoo_packet *pkt; | |
| 2141 | ||
| 2142 | /* Step 0: If they aren't on the server list anyway, | |
| 2143 | * don't bother letting the server know. | |
| 2144 | */ | |
| 2145 | if (!g_hash_table_lookup(yd->friends, who)) | |
| 2146 | return; | |
| 2147 | ||
| 2148 | /* Step 1: Add buddy to new group. */ | |
| 2149 | pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
| 2150 | yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
| 2151 | yahoo_packet_hash(pkt, 7, who); | |
| 2152 | yahoo_packet_hash(pkt, 65, new_group); | |
| 2153 | yahoo_packet_hash(pkt, 14, ""); | |
| 2154 | yahoo_send_packet(yd, pkt); | |
| 2155 | yahoo_packet_free(pkt); | |
| 2156 | ||
| 2157 | /* Step 2: Remove buddy from old group */ | |
| 2158 | pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
| 2159 | yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
| 2160 | yahoo_packet_hash(pkt, 7, who); | |
| 2161 | yahoo_packet_hash(pkt, 65, old_group); | |
| 2162 | yahoo_send_packet(yd, pkt); | |
| 2163 | yahoo_packet_free(pkt); | |
| 2164 | } | |
| 2165 | ||
| 2166 | static void yahoo_rename_group(GaimConnection *gc, const char *old_group, | |
| 2167 | const char *new_group, GList *whocares) | |
| 2168 | { | |
| 2169 | struct yahoo_data *yd = gc->proto_data; | |
| 2170 | struct yahoo_packet *pkt; | |
| 2171 | ||
| 2172 | pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, YAHOO_STATUS_AVAILABLE, 0); | |
| 2173 | yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
| 2174 | yahoo_packet_hash(pkt, 65, old_group); | |
| 2175 | yahoo_packet_hash(pkt, 67, new_group); | |
| 2176 | yahoo_send_packet(yd, pkt); | |
| 2177 | yahoo_packet_free(pkt); | |
| 2178 | } | |
| 2179 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2180 | static GaimPlugin *my_protocol = NULL; |
| 2681 | 2181 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2182 | static GaimPluginProtocolInfo prpl_info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2183 | { |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2184 | GAIM_PROTO_YAHOO, |
| 6729 | 2185 | OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC, |
| 2186 | NULL, /* user_splits */ | |
| 2187 | NULL, /* protocol_options */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2188 | yahoo_list_icon, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2189 | yahoo_list_emblems, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2190 | yahoo_status_text, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2191 | yahoo_tooltip_text, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2192 | yahoo_away_states, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2193 | yahoo_actions, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2194 | yahoo_buddy_menu, |
| 6729 | 2195 | yahoo_c_info, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2196 | yahoo_login, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2197 | yahoo_close, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2198 | yahoo_send_im, |
| 6729 | 2199 | NULL, /* set info */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2200 | yahoo_send_typing, |
| 6514 | 2201 | yahoo_get_info, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2202 | yahoo_set_away, |
| 6729 | 2203 | NULL, /* get_away */ |
| 2204 | NULL, /* set_dir */ | |
| 2205 | NULL, /* get_dir */ | |
| 2206 | NULL, /* dir_search */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2207 | yahoo_set_idle, |
| 6729 | 2208 | NULL, /* change_passwd*/ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2209 | yahoo_add_buddy, |
| 6729 | 2210 | NULL, /* add_buddies */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2211 | yahoo_remove_buddy, |
| 6729 | 2212 | NULL, /*remove_buddies */ |
| 2213 | NULL, /* add_permit */ | |
| 6760 | 2214 | yahoo_add_deny, |
| 6729 | 2215 | NULL, /* rem_permit */ |
| 6760 | 2216 | yahoo_rem_deny, |
| 2217 | yahoo_set_permit_deny, | |
| 6729 | 2218 | NULL, /* warn */ |
| 2219 | yahoo_c_join, | |
| 2220 | yahoo_c_invite, | |
| 2221 | yahoo_c_leave, | |
| 2222 | NULL, /* chat whisper */ | |
| 2223 | yahoo_c_send, | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2224 | yahoo_keepalive, |
| 6729 | 2225 | NULL, /* register_user */ |
| 2226 | NULL, /* get_cb_info */ | |
| 2227 | NULL, /* get_cb_away */ | |
| 2228 | NULL, /* alias_buddy */ | |
| 6793 | 2229 | yahoo_change_buddys_group, |
| 2230 | yahoo_rename_group, | |
| 6729 | 2231 | NULL, /* buddy_free */ |
| 2232 | NULL, /* convo_closed */ | |
| 2233 | NULL, /* normalize */ | |
| 2234 | NULL /* set_buddy_icon */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2235 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2236 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2237 | static GaimPluginInfo info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2238 | { |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2239 | 2, /**< api_version */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2240 | GAIM_PLUGIN_PROTOCOL, /**< type */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2241 | NULL, /**< ui_requirement */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2242 | 0, /**< flags */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2243 | NULL, /**< dependencies */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2244 | GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2245 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2246 | "prpl-yahoo", /**< id */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2247 | "Yahoo", /**< name */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2248 | VERSION, /**< version */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2249 | /** summary */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2250 | N_("Yahoo Protocol Plugin"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2251 | /** description */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2252 | N_("Yahoo Protocol Plugin"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2253 | NULL, /**< author */ |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
2254 | GAIM_WEBSITE, /**< homepage */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2255 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2256 | NULL, /**< load */ |
| 6513 | 2257 | yahoo_unload_plugin, /**< unload */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2258 | NULL, /**< destroy */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2259 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2260 | NULL, /**< ui_info */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2261 | &prpl_info /**< extra_info */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2262 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2263 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2264 | static void |
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2265 | init_plugin(GaimPlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2266 | { |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
2267 | GaimAccountOption *option; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2268 | |
|
5685
2523e4143d74
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
2269 | option = gaim_account_option_string_new(_("Pager host"), "server", |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
2270 | YAHOO_PAGER_HOST); |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
2271 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
2272 | option); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2273 | |
|
5685
2523e4143d74
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
2274 | option = gaim_account_option_int_new(_("Pager port"), "port", |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
2275 | YAHOO_PAGER_PORT); |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
2276 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
2277 | option); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2278 | my_protocol = plugin; |
| 6513 | 2279 | |
| 2280 | yahoo_init_colorht(); | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2281 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2282 | |
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2283 | GAIM_INIT_PLUGIN(yahoo, init_plugin, info); |