Mercurial > pidgin
annotate src/protocols/yahoo/yahoo.c @ 3001:87fff45fa36b
[gaim-migrate @ 3014]
Improved typing notification for Yahoo so that it sends and recieves notification that the user has stopped typing.
Also, combined serv_send_typing and serv_send_typing_stopped... expect the same with serv_got_typing_stopped.
committer: Tailor Script <tailor@pidgin.im>
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Mon, 04 Mar 2002 04:18:02 +0000 |
| parents | 7239a392486c |
| children | 304e8c376472 |
| rev | line source |
|---|---|
| 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 */ | |
| 22 | |
| 23 #ifdef HAVE_CONFIG_H | |
| 24 #include "config.h" | |
| 25 #endif | |
| 26 | |
| 27 | |
| 28 #include <netdb.h> | |
| 29 #include <unistd.h> | |
| 30 #include <errno.h> | |
| 31 #include <netinet/in.h> | |
| 32 #include <arpa/inet.h> | |
| 33 #include <string.h> | |
| 34 #include <stdlib.h> | |
| 35 #include <stdio.h> | |
| 36 #include <time.h> | |
| 37 #include <sys/socket.h> | |
| 38 #include <sys/stat.h> | |
| 39 #include <ctype.h> | |
| 40 #include "multi.h" | |
| 41 #include "prpl.h" | |
| 42 #include "gaim.h" | |
| 43 #include "proxy.h" | |
| 44 | |
|
2795
536bb833fdeb
[gaim-migrate @ 2808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2786
diff
changeset
|
45 extern char *yahoo_crypt(char *, char *); |
|
536bb833fdeb
[gaim-migrate @ 2808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2786
diff
changeset
|
46 |
| 2681 | 47 #include "pixmaps/status-away.xpm" |
| 48 #include "pixmaps/status-here.xpm" | |
| 49 #include "pixmaps/status-idle.xpm" | |
| 50 | |
| 2993 | 51 #define YAHOO_DEBUG |
| 2681 | 52 |
| 53 #define USEROPT_MAIL 0 | |
| 54 | |
| 55 #define USEROPT_PAGERHOST 3 | |
| 2951 | 56 #define YAHOO_PAGER_HOST "cs.yahoo.com" |
| 2681 | 57 #define USEROPT_PAGERPORT 4 |
| 58 #define YAHOO_PAGER_PORT 5050 | |
| 59 | |
|
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
60 enum yahoo_service { /* these are easier to see in hex */ |
| 2681 | 61 YAHOO_SERVICE_LOGON = 1, |
| 62 YAHOO_SERVICE_LOGOFF, | |
| 63 YAHOO_SERVICE_ISAWAY, | |
| 64 YAHOO_SERVICE_ISBACK, | |
|
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
65 YAHOO_SERVICE_IDLE, /* 5 (placemarker) */ |
| 2681 | 66 YAHOO_SERVICE_MESSAGE, |
| 67 YAHOO_SERVICE_IDACT, | |
| 68 YAHOO_SERVICE_IDDEACT, | |
| 69 YAHOO_SERVICE_MAILSTAT, | |
|
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
70 YAHOO_SERVICE_USERSTAT, /* 0xa */ |
| 2681 | 71 YAHOO_SERVICE_NEWMAIL, |
| 72 YAHOO_SERVICE_CHATINVITE, | |
| 73 YAHOO_SERVICE_CALENDAR, | |
| 74 YAHOO_SERVICE_NEWPERSONALMAIL, | |
| 75 YAHOO_SERVICE_NEWCONTACT, | |
|
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
76 YAHOO_SERVICE_ADDIDENT, /* 0x10 */ |
| 2681 | 77 YAHOO_SERVICE_ADDIGNORE, |
| 78 YAHOO_SERVICE_PING, | |
| 79 YAHOO_SERVICE_GROUPRENAME, | |
|
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
80 YAHOO_SERVICE_SYSMESSAGE = 0x14, |
|
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
81 YAHOO_SERVICE_PASSTHROUGH2 = 0x16, |
|
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
82 YAHOO_SERVICE_CONFINVITE = 0x18, |
| 2681 | 83 YAHOO_SERVICE_CONFLOGON, |
| 84 YAHOO_SERVICE_CONFDECLINE, | |
| 85 YAHOO_SERVICE_CONFLOGOFF, | |
| 86 YAHOO_SERVICE_CONFADDINVITE, | |
| 87 YAHOO_SERVICE_CONFMSG, | |
| 88 YAHOO_SERVICE_CHATLOGON, | |
| 89 YAHOO_SERVICE_CHATLOGOFF, | |
|
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
90 YAHOO_SERVICE_CHATMSG = 0x20, |
|
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
91 YAHOO_SERVICE_GAMELOGON = 0x28, |
|
2786
318f846120e2
[gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2772
diff
changeset
|
92 YAHOO_SERVICE_GAMELOGOFF, |
|
318f846120e2
[gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2772
diff
changeset
|
93 YAHOO_SERVICE_GAMEMSG = 0x2a, |
|
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
94 YAHOO_SERVICE_FILETRANSFER = 0x46, |
| 2993 | 95 YAHOO_SERVICE_TYPING = 0x4B, /* may have other uses too */ |
|
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
96 YAHOO_SERVICE_LIST = 0x55, |
|
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
97 YAHOO_SERVICE_ADDBUDDY = 0x83, |
|
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
98 YAHOO_SERVICE_REMBUDDY = 0x84 |
| 2681 | 99 }; |
| 100 | |
| 101 enum yahoo_status { | |
|
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
102 YAHOO_STATUS_AVAILABLE = 0, |
| 2681 | 103 YAHOO_STATUS_BRB, |
| 104 YAHOO_STATUS_BUSY, | |
| 105 YAHOO_STATUS_NOTATHOME, | |
| 106 YAHOO_STATUS_NOTATDESK, | |
| 107 YAHOO_STATUS_NOTINOFFICE, | |
| 108 YAHOO_STATUS_ONPHONE, | |
| 109 YAHOO_STATUS_ONVACATION, | |
| 110 YAHOO_STATUS_OUTTOLUNCH, | |
| 111 YAHOO_STATUS_STEPPEDOUT, | |
| 112 YAHOO_STATUS_INVISIBLE = 12, | |
| 113 YAHOO_STATUS_CUSTOM = 99, | |
| 114 YAHOO_STATUS_IDLE = 999, | |
| 2993 | 115 YAHOO_STATUS_OFFLINE = 0x5a55aa56, /* don't ask */ |
| 116 YAHOO_STATUS_TYPING = 0x16 | |
| 2681 | 117 }; |
| 118 | |
| 119 struct yahoo_data { | |
| 120 int fd; | |
| 121 guchar *rxqueue; | |
| 122 int rxlen; | |
| 123 GHashTable *hash; | |
| 124 int current_status; | |
| 125 gboolean logged_in; | |
| 126 }; | |
| 127 | |
| 128 struct yahoo_pair { | |
| 129 int key; | |
| 130 char *value; | |
| 131 }; | |
| 132 | |
| 133 struct yahoo_packet { | |
| 134 guint16 service; | |
| 135 guint32 status; | |
| 136 guint32 id; | |
| 137 GSList *hash; | |
| 138 }; | |
| 139 | |
| 140 static char *yahoo_name() { | |
| 141 return "Yahoo"; | |
| 142 } | |
| 143 | |
| 144 #define YAHOO_PACKET_HDRLEN (4 + 2 + 2 + 2 + 2 + 4 + 4) | |
| 145 | |
| 146 static struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id) | |
| 147 { | |
| 148 struct yahoo_packet *pkt = g_new0(struct yahoo_packet, 1); | |
| 149 | |
| 150 pkt->service = service; | |
| 151 pkt->status = status; | |
| 152 pkt->id = id; | |
| 153 | |
| 154 return pkt; | |
| 155 } | |
| 156 | |
| 157 static void yahoo_packet_hash(struct yahoo_packet *pkt, int key, char *value) | |
| 158 { | |
| 159 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); | |
| 160 pair->key = key; | |
| 161 pair->value = g_strdup(value); | |
| 162 pkt->hash = g_slist_append(pkt->hash, pair); | |
| 163 } | |
| 164 | |
| 165 static int yahoo_packet_length(struct yahoo_packet *pkt) | |
| 166 { | |
| 167 GSList *l; | |
| 168 | |
| 169 int len = 0; | |
| 170 | |
| 171 l = pkt->hash; | |
| 172 while (l) { | |
| 173 struct yahoo_pair *pair = l->data; | |
| 174 int tmp = pair->key; | |
| 175 do { | |
| 176 tmp /= 10; | |
| 177 len++; | |
| 178 } while (tmp); | |
| 179 len += 2; | |
| 180 len += strlen(pair->value); | |
| 181 len += 2; | |
| 182 l = l->next; | |
| 183 } | |
| 184 | |
| 185 return len; | |
| 186 } | |
| 187 | |
| 188 /* sometimes i wish prpls could #include things from other prpls. then i could just | |
| 189 * use the routines from libfaim and not have to admit to knowing how they work. */ | |
| 190 #define yahoo_put16(buf, data) ( \ | |
| 191 (*(buf) = (u_char)((data)>>8)&0xff), \ | |
| 192 (*((buf)+1) = (u_char)(data)&0xff), \ | |
| 193 2) | |
| 194 #define yahoo_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) | |
| 195 #define yahoo_put32(buf, data) ( \ | |
| 196 (*((buf)) = (u_char)((data)>>24)&0xff), \ | |
| 197 (*((buf)+1) = (u_char)((data)>>16)&0xff), \ | |
| 198 (*((buf)+2) = (u_char)((data)>>8)&0xff), \ | |
| 199 (*((buf)+3) = (u_char)(data)&0xff), \ | |
| 200 4) | |
| 201 #define yahoo_get32(buf) ((((*(buf))<<24)&0xff000000) + \ | |
| 202 (((*((buf)+1))<<16)&0x00ff0000) + \ | |
| 203 (((*((buf)+2))<< 8)&0x0000ff00) + \ | |
| 204 (((*((buf)+3) )&0x000000ff))) | |
| 205 | |
| 206 static void yahoo_packet_read(struct yahoo_packet *pkt, guchar *data, int len) | |
| 207 { | |
| 208 int pos = 0; | |
| 209 | |
| 210 while (pos + 1 < len) { | |
|
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
211 char key[64], *value = NULL; |
|
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
212 int accept; |
| 2681 | 213 int x; |
| 214 | |
| 215 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); | |
| 216 | |
| 217 x = 0; | |
| 218 while (pos + 1 < len) { | |
| 219 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) | |
| 220 break; | |
| 221 key[x++] = data[pos++]; | |
| 222 } | |
| 223 key[x] = 0; | |
| 224 pos += 2; | |
| 225 pair->key = strtol(key, NULL, 10); | |
|
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
226 accept = x; /* if x is 0 there was no key, so don't accept it */ |
| 2681 | 227 |
|
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
228 if (accept) |
|
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
229 value = g_malloc(len - pos + 1); |
| 2681 | 230 x = 0; |
| 231 while (pos + 1 < len) { | |
| 232 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) | |
| 233 break; | |
|
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
234 if (accept) |
|
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
235 value[x++] = data[pos++]; |
| 2681 | 236 } |
|
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
237 if (accept) |
|
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
238 value[x] = 0; |
| 2681 | 239 pos += 2; |
|
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
240 if (accept) { |
|
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
241 pair->value = g_strdup(value); |
|
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
242 g_free(value); |
|
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
243 pkt->hash = g_slist_append(pkt->hash, pair); |
|
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
244 debug_printf("Key: %d \tValue: %s\n", pair->key, pair->value); |
|
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
245 } else { |
|
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
246 g_free(pair); |
|
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
247 } |
| 2681 | 248 } |
| 249 } | |
| 250 | |
| 251 static void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data) | |
| 252 { | |
| 253 GSList *l = pkt->hash; | |
| 254 int pos = 0; | |
| 255 | |
| 256 while (l) { | |
| 257 struct yahoo_pair *pair = l->data; | |
| 258 guchar buf[100]; | |
| 259 | |
| 260 g_snprintf(buf, sizeof(buf), "%d", pair->key); | |
| 261 strcpy(data + pos, buf); | |
| 262 pos += strlen(buf); | |
| 263 data[pos++] = 0xc0; | |
| 264 data[pos++] = 0x80; | |
| 265 | |
| 266 strcpy(data + pos, pair->value); | |
| 267 pos += strlen(pair->value); | |
| 268 data[pos++] = 0xc0; | |
| 269 data[pos++] = 0x80; | |
| 270 | |
| 271 l = l->next; | |
| 272 } | |
| 273 } | |
| 274 | |
| 275 static void yahoo_packet_dump(guchar *data, int len) | |
| 276 { | |
| 277 #ifdef YAHOO_DEBUG | |
| 278 int i; | |
| 279 for (i = 0; i + 1 < len; i += 2) { | |
| 280 if ((i % 16 == 0) && i) | |
| 281 debug_printf("\n"); | |
| 282 debug_printf("%02x", data[i]); | |
| 283 debug_printf("%02x ", data[i+1]); | |
| 284 } | |
| 285 if (i < len) | |
| 286 debug_printf("%02x", data[i]); | |
| 287 debug_printf("\n"); | |
| 288 for (i = 0; i < len; i++) { | |
| 289 if ((i % 16 == 0) && i) | |
| 290 debug_printf("\n"); | |
| 291 if (isprint(data[i])) | |
| 292 debug_printf("%c ", data[i]); | |
| 293 else | |
| 294 debug_printf(". "); | |
| 295 } | |
| 296 debug_printf("\n"); | |
| 297 #endif | |
| 298 } | |
| 299 | |
| 300 static int yahoo_send_packet(struct yahoo_data *yd, struct yahoo_packet *pkt) | |
| 301 { | |
| 302 int pktlen = yahoo_packet_length(pkt); | |
| 303 int len = YAHOO_PACKET_HDRLEN + pktlen; | |
| 304 int ret; | |
| 305 | |
| 306 guchar *data; | |
| 307 int pos = 0; | |
| 308 | |
| 309 if (yd->fd < 0) | |
| 310 return -1; | |
| 311 | |
| 312 data = g_malloc0(len + 1); | |
| 313 | |
| 314 memcpy(data + pos, "YMSG", 4); pos += 4; | |
| 315 pos += yahoo_put16(data + pos, 0x0600); | |
| 316 pos += yahoo_put16(data + pos, 0x0000); | |
| 317 pos += yahoo_put16(data + pos, pktlen); | |
| 318 pos += yahoo_put16(data + pos, pkt->service); | |
| 319 pos += yahoo_put32(data + pos, pkt->status); | |
| 320 pos += yahoo_put32(data + pos, pkt->id); | |
| 321 | |
| 322 yahoo_packet_write(pkt, data + pos); | |
| 323 | |
| 324 yahoo_packet_dump(data, len); | |
| 325 ret = write(yd->fd, data, len); | |
| 326 | |
| 327 g_free(data); | |
| 328 | |
| 329 return ret; | |
| 330 } | |
| 331 | |
| 332 static void yahoo_packet_free(struct yahoo_packet *pkt) | |
| 333 { | |
| 334 while (pkt->hash) { | |
| 335 struct yahoo_pair *pair = pkt->hash->data; | |
| 336 g_free(pair->value); | |
| 337 g_free(pair); | |
| 338 pkt->hash = g_slist_remove(pkt->hash, pair); | |
| 339 } | |
| 340 g_free(pkt); | |
| 341 } | |
| 342 | |
|
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
343 static void yahoo_process_status(struct gaim_connection *gc, struct yahoo_packet *pkt) |
| 2681 | 344 { |
| 345 struct yahoo_data *yd = gc->proto_data; | |
| 346 GSList *l = pkt->hash; | |
| 347 struct yahoo_packet *newpkt; | |
| 348 char *name = NULL; | |
| 349 int state = 0; | |
| 350 char *msg = NULL; | |
| 351 | |
| 352 while (l) { | |
| 353 struct yahoo_pair *pair = l->data; | |
| 354 | |
| 355 switch (pair->key) { | |
| 356 case 0: /* we won't actually do anything with this */ | |
| 357 break; | |
| 358 case 1: /* we don't get the full buddy list here. */ | |
|
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
359 if (!yd->logged_in) { |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
360 account_online(gc); |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
361 serv_finish_login(gc); |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
362 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", pair->value); |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
363 do_import(gc, NULL); |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
364 yd->logged_in = TRUE; |
| 2681 | 365 |
|
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
366 /* this requests the list. i have a feeling that this is very evil */ |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
367 newpkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YAHOO_STATUS_OFFLINE, 0); |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
368 yahoo_send_packet(yd, newpkt); |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
369 yahoo_packet_free(newpkt); |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
370 } |
| 2681 | 371 break; |
| 372 case 8: /* how many online buddies we have */ | |
| 373 break; | |
| 374 case 7: /* the current buddy */ | |
| 375 name = pair->value; | |
| 376 break; | |
| 377 case 10: /* state */ | |
| 378 state = strtol(pair->value, NULL, 10); | |
| 379 break; | |
| 380 case 19: /* custom message */ | |
| 381 msg = pair->value; | |
| 382 break; | |
| 383 case 11: /* i didn't know what this was in the old protocol either */ | |
| 384 break; | |
| 385 case 17: /* in chat? */ | |
| 386 break; | |
|
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
387 case 13: /* in pager? */ |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
388 if (pkt->service == YAHOO_SERVICE_LOGOFF || |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
389 strtol(pair->value, NULL, 10) == 0) { |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
390 serv_got_update(gc, name, 0, 0, 0, 0, 0, 0); |
|
2807
f01e6a425136
[gaim-migrate @ 2820]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2805
diff
changeset
|
391 break; |
|
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
392 } |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
393 if (state == YAHOO_STATUS_AVAILABLE) |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
394 serv_got_update(gc, name, 1, 0, 0, 0, 0, 0); |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
395 else |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
396 serv_got_update(gc, name, 1, 0, 0, 0, (state << 1) | UC_UNAVAILABLE, 0); |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
397 if (state == YAHOO_STATUS_CUSTOM) { |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
398 gpointer val = g_hash_table_lookup(yd->hash, name); |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
399 if (val) { |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
400 g_free(val); |
|
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
401 g_hash_table_insert(yd->hash, name, |
|
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
402 msg ? g_strdup(msg) : g_malloc0(1)); |
|
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
403 } else |
|
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
404 g_hash_table_insert(yd->hash, g_strdup(name), |
|
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
405 msg ? g_strdup(msg) : g_malloc0(1)); |
|
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
406 } |
|
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
407 break; |
|
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
408 case 60: /* no clue */ |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
409 break; |
| 2979 | 410 case 16: /* Custom error message */ |
| 411 do_error_dialog(pair->value, "Gaim -- Yahoo! Error"); | |
| 2951 | 412 break; |
| 2681 | 413 default: |
|
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
414 debug_printf("unknown status key %d\n", pair->key); |
| 2681 | 415 break; |
| 416 } | |
| 417 | |
| 418 l = l->next; | |
| 419 } | |
| 420 } | |
| 421 | |
| 422 static void yahoo_process_list(struct gaim_connection *gc, struct yahoo_packet *pkt) | |
| 423 { | |
| 424 GSList *l = pkt->hash; | |
| 425 gboolean export = FALSE; | |
| 426 | |
| 427 while (l) { | |
| 428 char **lines; | |
| 429 char **split; | |
| 430 char **buddies; | |
| 431 char **tmp, **bud; | |
| 432 | |
| 433 struct yahoo_pair *pair = l->data; | |
| 434 l = l->next; | |
| 435 | |
| 436 if (pair->key != 87) | |
| 437 continue; | |
| 438 | |
| 439 lines = g_strsplit(pair->value, "\n", -1); | |
| 440 for (tmp = lines; *tmp; tmp++) { | |
| 441 split = g_strsplit(*tmp, ":", 2); | |
|
2697
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
442 if (!split) |
|
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
443 continue; |
|
2702
94b4271b9567
[gaim-migrate @ 2715]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2697
diff
changeset
|
444 if (!split[0] || !split[1]) { |
|
2697
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
445 g_strfreev(split); |
|
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
446 continue; |
|
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
447 } |
| 2681 | 448 buddies = g_strsplit(split[1], ",", -1); |
|
2697
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
449 for (bud = buddies; bud && *bud; bud++) |
| 2681 | 450 if (!find_buddy(gc, *bud)) { |
| 451 add_buddy(gc, split[0], *bud, *bud); | |
| 452 export = TRUE; | |
| 453 } | |
| 454 g_strfreev(buddies); | |
| 455 g_strfreev(split); | |
| 456 } | |
| 457 g_strfreev(lines); | |
| 458 } | |
| 459 | |
| 460 if (export) | |
| 461 do_export(gc); | |
| 462 } | |
| 463 | |
| 2993 | 464 static void yahoo_process_typing(struct gaim_connection *gc, struct yahoo_packet *pkt) |
| 465 { | |
| 466 char *msg = NULL; | |
| 467 char *from = NULL; | |
| 3001 | 468 char *typing = NULL; |
| 2993 | 469 GSList *l = pkt->hash; |
| 470 | |
| 471 while (l) { | |
| 472 struct yahoo_pair *pair = l->data; | |
| 473 if (pair->key == 4) | |
| 474 from = pair->value; | |
| 475 if (pair->key == 49) | |
| 476 msg = pair->value; | |
| 3001 | 477 if (pair->key == 13) |
| 478 typing = pair->value; | |
| 2993 | 479 l = l->next; |
| 480 } | |
| 3001 | 481 if (*typing == '1') |
| 482 serv_got_typing(gc, from, 0); | |
| 483 else | |
| 484 serv_got_typing_stopped(gc, from); | |
| 2993 | 485 } |
| 486 | |
| 2681 | 487 static void yahoo_process_message(struct gaim_connection *gc, struct yahoo_packet *pkt) |
| 488 { | |
| 489 char *msg = NULL; | |
| 490 char *from = NULL; | |
| 491 time_t tm = time(NULL); | |
| 492 GSList *l = pkt->hash; | |
| 493 | |
| 494 while (l) { | |
| 495 struct yahoo_pair *pair = l->data; | |
| 496 if (pair->key == 4) | |
| 497 from = pair->value; | |
| 498 if (pair->key == 14) | |
| 499 msg = pair->value; | |
| 500 if (pair->key == 15) | |
| 501 tm = strtol(pair->value, NULL, 10); | |
| 502 l = l->next; | |
| 503 } | |
| 504 | |
|
2878
7a10d1538092
[gaim-migrate @ 2891]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2876
diff
changeset
|
505 if (pkt->status <= 1) { |
|
2715
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
506 char *m; |
|
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
507 int i, j; |
| 2681 | 508 strip_linefeed(msg); |
|
2715
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
509 m = msg; |
|
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
510 for (i = 0, j = 0; m[i]; i++) { |
|
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
511 if (m[i] == 033) { |
|
2813
bda5b89ba2f9
[gaim-migrate @ 2826]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2807
diff
changeset
|
512 while (m[i] && (m[i] != 'm')) |
|
2715
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
513 i++; |
|
2813
bda5b89ba2f9
[gaim-migrate @ 2826]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2807
diff
changeset
|
514 if (!m[i]) |
|
bda5b89ba2f9
[gaim-migrate @ 2826]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2807
diff
changeset
|
515 i--; |
|
2715
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
516 continue; |
|
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
517 } |
|
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
518 msg[j++] = m[i]; |
|
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
519 } |
|
2813
bda5b89ba2f9
[gaim-migrate @ 2826]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2807
diff
changeset
|
520 msg[j] = 0; |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2850
diff
changeset
|
521 serv_got_im(gc, from, msg, 0, tm, -1); |
| 2681 | 522 } else if (pkt->status == 2) { |
| 523 do_error_dialog(_("Your message did not get sent."), _("Gaim - Error")); | |
| 524 } | |
| 525 } | |
| 526 | |
| 527 | |
| 528 static void yahoo_process_contact(struct gaim_connection *gc, struct yahoo_packet *pkt) | |
| 529 { | |
|
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
530 struct yahoo_data *yd = gc->proto_data; |
| 2681 | 531 char *id = NULL; |
| 532 char *who = NULL; | |
| 533 char *msg = NULL; | |
|
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
534 char *name = NULL; |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
535 int state = YAHOO_STATUS_AVAILABLE; |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
536 int online = FALSE; |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
537 |
| 2681 | 538 GSList *l = pkt->hash; |
| 539 | |
| 540 while (l) { | |
| 541 struct yahoo_pair *pair = l->data; | |
| 542 if (pair->key == 1) | |
| 543 id = pair->value; | |
| 544 else if (pair->key == 3) | |
| 545 who = pair->value; | |
| 546 else if (pair->key == 14) | |
| 547 msg = pair->value; | |
|
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
548 else if (pair->key == 7) |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
549 name = pair->value; |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
550 else if (pair->key == 10) |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
551 state = strtol(pair->value, NULL, 10); |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
552 else if (pair->key == 13) |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
553 online = strtol(pair->value, NULL, 10); |
| 2681 | 554 l = l->next; |
| 555 } | |
| 556 | |
|
2682
db2b0b733732
[gaim-migrate @ 2695]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
557 if (id) |
|
db2b0b733732
[gaim-migrate @ 2695]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
558 show_got_added(gc, id, who, NULL, msg); |
|
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
559 if (name) { |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
560 if (state == YAHOO_STATUS_AVAILABLE) |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
561 serv_got_update(gc, name, 1, 0, 0, 0, 0, 0); |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
562 else if (state == YAHOO_STATUS_IDLE) |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
563 serv_got_update(gc, name, 1, 0, 0, time(NULL) - 600, (state << 1), 0); |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
564 else |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
565 serv_got_update(gc, name, 1, 0, 0, 0, (state << 1) | UC_UNAVAILABLE, 0); |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
566 if (state == YAHOO_STATUS_CUSTOM) { |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
567 gpointer val = g_hash_table_lookup(yd->hash, name); |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
568 if (val) { |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
569 g_free(val); |
|
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
570 g_hash_table_insert(yd->hash, name, |
|
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
571 msg ? g_strdup(msg) : g_malloc0(1)); |
|
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
572 } else |
|
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
573 g_hash_table_insert(yd->hash, g_strdup(name), |
|
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
574 msg ? g_strdup(msg) : g_malloc0(1)); |
|
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
575 } |
|
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
576 } |
| 2681 | 577 } |
| 578 | |
| 579 static void yahoo_process_mail(struct gaim_connection *gc, struct yahoo_packet *pkt) | |
| 580 { | |
| 581 char *who = NULL; | |
| 582 char *email = NULL; | |
| 583 char *subj = NULL; | |
| 584 int count = 0; | |
| 585 GSList *l = pkt->hash; | |
| 586 | |
| 587 while (l) { | |
| 588 struct yahoo_pair *pair = l->data; | |
| 589 if (pair->key == 9) | |
| 590 count = strtol(pair->value, NULL, 10); | |
| 591 else if (pair->key == 43) | |
| 592 who = pair->value; | |
| 593 else if (pair->key == 42) | |
| 594 email = pair->value; | |
| 595 else if (pair->key == 18) | |
| 596 subj = pair->value; | |
| 597 l = l->next; | |
| 598 } | |
| 599 | |
|
2850
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
600 if (who && email && subj) { |
|
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
601 char *from = g_strdup_printf("%s (%s)", who, email); |
|
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
602 connection_has_mail(gc, -1, from, subj, "http://mail.yahoo.com/"); |
|
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
603 g_free(from); |
|
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
604 } else |
|
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
605 connection_has_mail(gc, count, NULL, NULL, "http://mail.yahoo.com/"); |
| 2681 | 606 } |
| 607 | |
| 608 static void yahoo_packet_process(struct gaim_connection *gc, struct yahoo_packet *pkt) | |
| 609 { | |
| 610 switch (pkt->service) | |
| 611 { | |
| 612 case YAHOO_SERVICE_LOGON: | |
|
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
613 case YAHOO_SERVICE_LOGOFF: |
| 2681 | 614 case YAHOO_SERVICE_ISAWAY: |
|
2737
f61c1f3a6afa
[gaim-migrate @ 2750]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2724
diff
changeset
|
615 case YAHOO_SERVICE_ISBACK: |
| 2681 | 616 yahoo_process_status(gc, pkt); |
| 617 break; | |
| 2993 | 618 case YAHOO_SERVICE_TYPING: |
| 619 yahoo_process_typing(gc, pkt); | |
| 620 break; | |
| 2681 | 621 case YAHOO_SERVICE_MESSAGE: |
|
2786
318f846120e2
[gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2772
diff
changeset
|
622 case YAHOO_SERVICE_GAMEMSG: |
| 2681 | 623 yahoo_process_message(gc, pkt); |
| 624 break; | |
| 625 case YAHOO_SERVICE_NEWMAIL: | |
| 626 yahoo_process_mail(gc, pkt); | |
| 627 break; | |
| 628 case YAHOO_SERVICE_NEWCONTACT: | |
| 629 yahoo_process_contact(gc, pkt); | |
| 630 break; | |
| 631 case YAHOO_SERVICE_LIST: | |
| 632 yahoo_process_list(gc, pkt); | |
| 633 break; | |
| 634 default: | |
|
2741
38cb5fa48bec
[gaim-migrate @ 2754]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2737
diff
changeset
|
635 debug_printf("unhandled service 0x%02x\n", pkt->service); |
| 2681 | 636 break; |
| 637 } | |
| 638 } | |
| 639 | |
| 640 static void yahoo_pending(gpointer data, gint source, GaimInputCondition cond) | |
| 641 { | |
| 642 struct gaim_connection *gc = data; | |
| 643 struct yahoo_data *yd = gc->proto_data; | |
| 644 char buf[1024]; | |
| 645 int len; | |
| 646 | |
| 647 len = read(yd->fd, buf, sizeof(buf)); | |
| 648 | |
| 649 if (len <= 0) { | |
| 650 hide_login_progress(gc, "Unable to read"); | |
| 651 signoff(gc); | |
| 652 return; | |
| 653 } | |
| 654 | |
| 655 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); | |
| 656 memcpy(yd->rxqueue + yd->rxlen, buf, len); | |
| 657 yd->rxlen += len; | |
| 658 | |
| 659 while (1) { | |
| 660 struct yahoo_packet *pkt; | |
| 661 int pos = 0; | |
| 662 int pktlen; | |
| 663 | |
| 664 if (yd->rxlen < YAHOO_PACKET_HDRLEN) | |
| 665 return; | |
| 666 | |
| 667 pos += 4; /* YMSG */ | |
| 668 pos += 2; | |
| 669 pos += 2; | |
| 670 | |
| 671 pktlen = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
| 672 debug_printf("%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen); | |
| 673 | |
| 674 if (yd->rxlen < (YAHOO_PACKET_HDRLEN + pktlen)) | |
| 675 return; | |
| 676 | |
| 677 yahoo_packet_dump(yd->rxqueue, YAHOO_PACKET_HDRLEN + pktlen); | |
| 678 | |
| 679 pkt = yahoo_packet_new(0, 0, 0); | |
| 680 | |
| 681 pkt->service = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
|
2741
38cb5fa48bec
[gaim-migrate @ 2754]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2737
diff
changeset
|
682 debug_printf("Yahoo Service: 0x%02x Status: %d\n", pkt->service, pkt->status); |
| 2681 | 683 pkt->status = yahoo_get32(yd->rxqueue + pos); pos += 4; |
| 684 pkt->id = yahoo_get32(yd->rxqueue + pos); pos += 4; | |
| 685 | |
| 686 yahoo_packet_read(pkt, yd->rxqueue + pos, pktlen); | |
| 687 | |
| 688 yd->rxlen -= YAHOO_PACKET_HDRLEN + pktlen; | |
| 689 if (yd->rxlen) { | |
| 690 char *tmp = g_memdup(yd->rxqueue + YAHOO_PACKET_HDRLEN + pktlen, yd->rxlen); | |
| 691 g_free(yd->rxqueue); | |
| 692 yd->rxqueue = tmp; | |
| 693 } else { | |
| 694 g_free(yd->rxqueue); | |
| 695 yd->rxqueue = NULL; | |
| 696 } | |
| 697 | |
| 698 yahoo_packet_process(gc, pkt); | |
| 699 | |
| 700 yahoo_packet_free(pkt); | |
| 701 } | |
| 702 } | |
| 703 | |
| 704 static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond) | |
| 705 { | |
| 706 struct gaim_connection *gc = data; | |
| 707 struct yahoo_data *yd; | |
| 708 struct yahoo_packet *pkt; | |
| 709 | |
| 710 if (!g_slist_find(connections, gc)) { | |
| 711 close(source); | |
| 712 return; | |
| 713 } | |
| 714 | |
| 715 if (source < 0) { | |
| 716 hide_login_progress(gc, "Unable to connect"); | |
| 717 signoff(gc); | |
| 718 return; | |
| 719 } | |
| 720 | |
| 721 yd = gc->proto_data; | |
| 722 yd->fd = source; | |
| 723 | |
| 724 pkt = yahoo_packet_new(YAHOO_SERVICE_LOGON, YAHOO_STATUS_AVAILABLE, 0); | |
| 725 | |
| 726 yahoo_packet_hash(pkt, 0, gc->username); | |
| 727 yahoo_packet_hash(pkt, 1, gc->username); | |
|
2795
536bb833fdeb
[gaim-migrate @ 2808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2786
diff
changeset
|
728 yahoo_packet_hash(pkt, 6, yahoo_crypt(gc->password, "$1$_2S43d5f$")); |
| 2681 | 729 |
| 730 yahoo_send_packet(yd, pkt); | |
| 731 | |
| 732 yahoo_packet_free(pkt); | |
| 733 | |
| 734 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); | |
| 735 } | |
| 736 | |
| 737 static void yahoo_login(struct aim_user *user) { | |
| 738 struct gaim_connection *gc = new_gaim_conn(user); | |
| 739 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1); | |
| 740 | |
| 741 set_login_progress(gc, 1, "Connecting"); | |
| 742 | |
| 743 yd->fd = -1; | |
| 744 yd->hash = g_hash_table_new(g_str_hash, g_str_equal); | |
| 745 | |
| 2951 | 746 if (!g_strncasecmp(user->proto_opt[USEROPT_PAGERHOST], "scs.yahoo.com", strlen("scs.yahoo.com"))) { |
| 747 /* As of this morning, Yahoo is no longer supporting its server at scs.yahoo.com | |
| 748 * I don't like to edit the preferences in a prpl, but we'll keep this here | |
| 749 * for a while until everybody's happy again. -5 Feb 2002*/ | |
| 750 debug_printf("Setting new Yahoo! server.\n"); | |
| 751 g_snprintf(user->proto_opt[USEROPT_PAGERHOST], strlen("cs.yahoo.com") + 1, "cs.yahoo.com"); | |
| 752 save_prefs(); | |
| 753 } | |
| 754 | |
| 755 if (proxy_connect(user->proto_opt[USEROPT_PAGERHOST][0] ? | |
| 2681 | 756 user->proto_opt[USEROPT_PAGERHOST] : YAHOO_PAGER_HOST, |
| 757 user->proto_opt[USEROPT_PAGERPORT][0] ? | |
| 758 atoi(user->proto_opt[USEROPT_PAGERPORT]) : YAHOO_PAGER_PORT, | |
|
2688
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2687
diff
changeset
|
759 yahoo_got_connected, gc) < 0) { |
| 2681 | 760 hide_login_progress(gc, "Connection problem"); |
| 761 signoff(gc); | |
| 762 return; | |
| 763 } | |
| 764 | |
| 765 } | |
| 766 | |
| 767 static gboolean yahoo_destroy_hash(gpointer key, gpointer val, gpointer data) | |
| 768 { | |
| 769 g_free(key); | |
| 770 g_free(val); | |
| 771 return TRUE; | |
| 772 } | |
| 773 | |
| 774 static void yahoo_close(struct gaim_connection *gc) { | |
| 775 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 776 g_hash_table_foreach_remove(yd->hash, yahoo_destroy_hash, NULL); | |
| 777 g_hash_table_destroy(yd->hash); | |
| 778 if (yd->fd >= 0) | |
| 779 close(yd->fd); | |
| 780 if (yd->rxqueue) | |
| 781 g_free(yd->rxqueue); | |
|
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2686
diff
changeset
|
782 yd->rxlen = 0; |
| 2681 | 783 if (gc->inpa) |
| 784 gaim_input_remove(gc->inpa); | |
| 785 g_free(yd); | |
| 786 } | |
| 787 | |
| 788 static char **yahoo_list_icon(int uc) | |
| 789 { | |
| 790 if ((uc >> 1) == YAHOO_STATUS_IDLE) | |
| 791 return status_idle_xpm; | |
| 792 else if (uc == 0) | |
| 793 return status_here_xpm; | |
| 794 return status_away_xpm; | |
| 795 } | |
| 796 | |
| 797 static char *yahoo_get_status_string(enum yahoo_status a) | |
| 798 { | |
| 799 switch (a) { | |
| 800 case YAHOO_STATUS_BRB: | |
| 801 return "Be Right Back"; | |
| 802 case YAHOO_STATUS_BUSY: | |
| 803 return "Busy"; | |
| 804 case YAHOO_STATUS_NOTATHOME: | |
| 805 return "Not At Home"; | |
| 806 case YAHOO_STATUS_NOTATDESK: | |
| 807 return "Not At Desk"; | |
| 808 case YAHOO_STATUS_NOTINOFFICE: | |
| 809 return "Not In Office"; | |
| 810 case YAHOO_STATUS_ONPHONE: | |
| 811 return "On Phone"; | |
| 812 case YAHOO_STATUS_ONVACATION: | |
| 813 return "On Vacation"; | |
| 814 case YAHOO_STATUS_OUTTOLUNCH: | |
| 815 return "Out To Lunch"; | |
| 816 case YAHOO_STATUS_STEPPEDOUT: | |
| 817 return "Stepped Out"; | |
|
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
818 case YAHOO_STATUS_INVISIBLE: |
|
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
819 return "Invisible"; |
|
2879
5fc5123b7098
[gaim-migrate @ 2892]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2878
diff
changeset
|
820 default: |
|
5fc5123b7098
[gaim-migrate @ 2892]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2878
diff
changeset
|
821 return "Online"; |
| 2681 | 822 } |
| 823 } | |
| 824 | |
| 825 static GList *yahoo_buddy_menu(struct gaim_connection *gc, char *who) | |
| 826 { | |
| 827 GList *m = NULL; | |
| 828 struct proto_buddy_menu *pbm; | |
| 829 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 830 struct buddy *b = find_buddy(gc, who); /* this should never be null. if it is, | |
| 831 segfault and get the bug report. */ | |
| 832 static char buf[1024]; | |
| 833 | |
| 834 if (!(b->uc & UC_UNAVAILABLE)) | |
| 835 return NULL; | |
|
2876
caec520fde0b
[gaim-migrate @ 2889]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2873
diff
changeset
|
836 if (b->uc >> 1 == YAHOO_STATUS_IDLE) |
|
caec520fde0b
[gaim-migrate @ 2889]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2873
diff
changeset
|
837 return NULL; |
| 2681 | 838 |
| 839 pbm = g_new0(struct proto_buddy_menu, 1); | |
| 840 if ((b->uc >> 1) != YAHOO_STATUS_CUSTOM) | |
| 841 g_snprintf(buf, sizeof buf, "Status: %s", yahoo_get_status_string(b->uc >> 1)); | |
| 842 else | |
| 843 g_snprintf(buf, sizeof buf, "Custom Status: %s", | |
| 844 (char *)g_hash_table_lookup(yd->hash, b->name)); | |
| 845 pbm->label = buf; | |
| 846 pbm->callback = NULL; | |
| 847 pbm->gc = gc; | |
| 848 m = g_list_append(m, pbm); | |
| 849 | |
| 850 return m; | |
| 851 } | |
| 852 | |
| 853 static GList *yahoo_user_opts() | |
| 854 { | |
| 855 GList *m = NULL; | |
| 856 struct proto_user_opt *puo; | |
| 857 | |
| 858 puo = g_new0(struct proto_user_opt, 1); | |
| 859 puo->label = "Pager Host:"; | |
| 860 puo->def = YAHOO_PAGER_HOST; | |
| 861 puo->pos = USEROPT_PAGERHOST; | |
| 862 m = g_list_append(m, puo); | |
| 863 | |
| 864 puo = g_new0(struct proto_user_opt, 1); | |
| 865 puo->label = "Pager Port:"; | |
| 866 puo->def = "5050"; | |
| 867 puo->pos = USEROPT_PAGERPORT; | |
| 868 m = g_list_append(m, puo); | |
| 869 | |
| 870 return m; | |
| 871 } | |
| 872 | |
| 873 static void yahoo_act_id(gpointer data, char *entry) | |
| 874 { | |
| 875 struct gaim_connection *gc = data; | |
| 876 struct yahoo_data *yd = gc->proto_data; | |
| 877 | |
| 878 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0); | |
| 879 yahoo_packet_hash(pkt, 3, entry); | |
| 880 yahoo_send_packet(yd, pkt); | |
| 881 yahoo_packet_free(pkt); | |
| 882 | |
| 883 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", entry); | |
| 884 } | |
| 885 | |
| 886 static void yahoo_do_action(struct gaim_connection *gc, char *act) | |
| 887 { | |
| 888 if (!strcmp(act, "Activate ID")) { | |
| 889 do_prompt_dialog("Activate which ID:", gc->displayname, gc, yahoo_act_id, NULL); | |
| 890 } | |
| 891 } | |
| 892 | |
| 893 static GList *yahoo_actions() { | |
| 894 GList *m = NULL; | |
| 895 | |
| 896 m = g_list_append(m, "Activate ID"); | |
| 897 | |
| 898 return m; | |
| 899 } | |
| 900 | |
| 901 static int yahoo_send_im(struct gaim_connection *gc, char *who, char *what, int flags) | |
| 902 { | |
| 903 struct yahoo_data *yd = gc->proto_data; | |
| 904 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0); | |
| 905 | |
| 906 yahoo_packet_hash(pkt, 1, gc->displayname); | |
| 907 yahoo_packet_hash(pkt, 5, who); | |
| 908 yahoo_packet_hash(pkt, 14, what); | |
| 909 | |
| 910 yahoo_send_packet(yd, pkt); | |
| 911 | |
| 912 yahoo_packet_free(pkt); | |
| 913 | |
| 914 return 1; | |
| 915 } | |
| 916 | |
| 3001 | 917 int yahoo_send_typing(struct gaim_connection *gc, char *who, int typ) |
| 2993 | 918 { |
| 919 struct yahoo_data *yd = gc->proto_data; | |
| 920 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_TYPING, YAHOO_STATUS_TYPING, 0);//x6431de4f); | |
| 921 | |
| 922 yahoo_packet_hash(pkt, 49, "TYPING"); | |
| 923 yahoo_packet_hash(pkt, 1, gc->displayname); | |
| 924 yahoo_packet_hash(pkt, 14, " "); | |
| 3001 | 925 yahoo_packet_hash(pkt, 13, typ ? "1" : "0"); |
| 2993 | 926 yahoo_packet_hash(pkt, 5, who); |
| 927 yahoo_packet_hash(pkt, 1002, "1"); | |
| 928 | |
| 929 yahoo_send_packet(yd, pkt); | |
| 930 | |
| 931 yahoo_packet_free(pkt); | |
| 932 | |
| 3001 | 933 return 0; |
| 2993 | 934 } |
| 935 | |
| 2681 | 936 static void yahoo_set_away(struct gaim_connection *gc, char *state, char *msg) |
| 937 { | |
| 938 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 939 struct yahoo_packet *pkt; | |
|
2772
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
940 int service; |
| 2681 | 941 char s[4]; |
| 942 | |
| 943 gc->away = NULL; | |
| 944 | |
| 945 if (msg) { | |
| 946 yd->current_status = YAHOO_STATUS_CUSTOM; | |
| 947 gc->away = ""; | |
| 948 } else if (state) { | |
| 949 gc->away = ""; | |
| 950 if (!strcmp(state, "Available")) { | |
| 951 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
| 952 gc->away = NULL; | |
| 953 } else if (!strcmp(state, "Be Right Back")) { | |
| 954 yd->current_status = YAHOO_STATUS_BRB; | |
| 955 } else if (!strcmp(state, "Busy")) { | |
| 956 yd->current_status = YAHOO_STATUS_BUSY; | |
| 957 } else if (!strcmp(state, "Not At Home")) { | |
| 958 yd->current_status = YAHOO_STATUS_NOTATHOME; | |
| 959 } else if (!strcmp(state, "Not At Desk")) { | |
| 960 yd->current_status = YAHOO_STATUS_NOTATDESK; | |
| 961 } else if (!strcmp(state, "Not In Office")) { | |
| 962 yd->current_status = YAHOO_STATUS_NOTINOFFICE; | |
| 963 } else if (!strcmp(state, "On Phone")) { | |
| 964 yd->current_status = YAHOO_STATUS_ONPHONE; | |
| 965 } else if (!strcmp(state, "On Vacation")) { | |
| 966 yd->current_status = YAHOO_STATUS_ONVACATION; | |
| 967 } else if (!strcmp(state, "Out To Lunch")) { | |
| 968 yd->current_status = YAHOO_STATUS_OUTTOLUNCH; | |
| 969 } else if (!strcmp(state, "Stepped Out")) { | |
| 970 yd->current_status = YAHOO_STATUS_STEPPEDOUT; | |
| 971 } else if (!strcmp(state, "Invisible")) { | |
| 972 yd->current_status = YAHOO_STATUS_INVISIBLE; | |
| 973 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { | |
| 974 if (gc->is_idle) { | |
| 975 yd->current_status = YAHOO_STATUS_IDLE; | |
| 976 } else { | |
| 977 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
| 978 } | |
| 979 gc->away = NULL; | |
| 980 } | |
| 981 } else if (gc->is_idle) { | |
| 982 yd->current_status = YAHOO_STATUS_IDLE; | |
| 983 } else { | |
| 984 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
| 985 } | |
| 986 | |
|
2772
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
987 if (yd->current_status == YAHOO_STATUS_AVAILABLE) |
|
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
988 service = YAHOO_SERVICE_ISBACK; |
|
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
989 else |
|
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
990 service = YAHOO_SERVICE_ISAWAY; |
|
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
991 pkt = yahoo_packet_new(service, yd->current_status, 0); |
| 2681 | 992 g_snprintf(s, sizeof(s), "%d", yd->current_status); |
| 993 yahoo_packet_hash(pkt, 10, s); | |
| 994 if (yd->current_status == YAHOO_STATUS_CUSTOM) | |
| 995 yahoo_packet_hash(pkt, 19, msg); | |
| 996 | |
| 997 yahoo_send_packet(yd, pkt); | |
| 998 yahoo_packet_free(pkt); | |
| 999 } | |
| 1000 | |
| 1001 static void yahoo_set_idle(struct gaim_connection *gc, int idle) | |
| 1002 { | |
| 1003 struct yahoo_data *yd = gc->proto_data; | |
| 1004 struct yahoo_packet *pkt = NULL; | |
| 1005 | |
| 1006 if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) { | |
| 1007 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_IDLE, 0); | |
| 1008 yd->current_status = YAHOO_STATUS_IDLE; | |
| 1009 } else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { | |
| 1010 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); | |
| 1011 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
| 1012 } | |
| 1013 | |
| 1014 if (pkt) { | |
| 1015 char buf[4]; | |
| 1016 g_snprintf(buf, sizeof(buf), "%d", yd->current_status); | |
| 1017 yahoo_packet_hash(pkt, 10, buf); | |
| 1018 yahoo_send_packet(yd, pkt); | |
| 1019 yahoo_packet_free(pkt); | |
| 1020 } | |
| 1021 } | |
| 1022 | |
| 1023 static GList *yahoo_away_states(struct gaim_connection *gc) | |
| 1024 { | |
| 1025 GList *m = NULL; | |
| 1026 | |
| 1027 m = g_list_append(m, "Available"); | |
| 1028 m = g_list_append(m, "Be Right Back"); | |
| 1029 m = g_list_append(m, "Busy"); | |
| 1030 m = g_list_append(m, "Not At Home"); | |
| 1031 m = g_list_append(m, "Not At Desk"); | |
| 1032 m = g_list_append(m, "Not In Office"); | |
| 1033 m = g_list_append(m, "On Phone"); | |
| 1034 m = g_list_append(m, "On Vacation"); | |
| 1035 m = g_list_append(m, "Out To Lunch"); | |
| 1036 m = g_list_append(m, "Stepped Out"); | |
| 1037 m = g_list_append(m, "Invisible"); | |
| 1038 m = g_list_append(m, GAIM_AWAY_CUSTOM); | |
| 1039 | |
| 1040 return m; | |
| 1041 } | |
| 1042 | |
| 1043 static void yahoo_keepalive(struct gaim_connection *gc) | |
| 1044 { | |
| 1045 struct yahoo_data *yd = gc->proto_data; | |
| 1046 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0); | |
| 1047 yahoo_send_packet(yd, pkt); | |
| 1048 yahoo_packet_free(pkt); | |
| 1049 } | |
| 1050 | |
| 1051 static void yahoo_add_buddy(struct gaim_connection *gc, char *who) | |
| 1052 { | |
| 1053 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 1054 struct yahoo_packet *pkt; | |
| 1055 struct group *g; | |
| 1056 char *group = NULL; | |
| 1057 | |
| 1058 if (!yd->logged_in) | |
| 1059 return; | |
| 1060 | |
| 1061 g = find_group_by_buddy(gc, who); | |
| 1062 if (g) | |
| 1063 group = g->name; | |
| 1064 else | |
| 1065 group = "Buddies"; | |
| 1066 | |
| 1067 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
| 1068 yahoo_packet_hash(pkt, 1, gc->displayname); | |
| 1069 yahoo_packet_hash(pkt, 7, who); | |
| 1070 yahoo_packet_hash(pkt, 65, group); | |
| 1071 yahoo_send_packet(yd, pkt); | |
| 1072 yahoo_packet_free(pkt); | |
| 1073 } | |
| 1074 | |
| 1075 static void yahoo_remove_buddy(struct gaim_connection *gc, char *who, char *group) | |
| 1076 { | |
| 1077 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 1078 | |
| 1079 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
| 1080 yahoo_packet_hash(pkt, 1, gc->displayname); | |
| 1081 yahoo_packet_hash(pkt, 7, who); | |
| 1082 yahoo_packet_hash(pkt, 65, group); | |
| 1083 yahoo_send_packet(yd, pkt); | |
| 1084 yahoo_packet_free(pkt); | |
| 1085 } | |
| 1086 | |
| 1087 static struct prpl *my_protocol = NULL; | |
| 1088 | |
| 1089 void yahoo_init(struct prpl *ret) { | |
| 1090 ret->protocol = PROTO_YAHOO; | |
| 1091 ret->options = OPT_PROTO_MAIL_CHECK; | |
| 1092 ret->name = yahoo_name; | |
| 1093 ret->user_opts = yahoo_user_opts; | |
| 1094 ret->login = yahoo_login; | |
| 1095 ret->close = yahoo_close; | |
| 1096 ret->buddy_menu = yahoo_buddy_menu; | |
| 1097 ret->list_icon = yahoo_list_icon; | |
| 1098 ret->actions = yahoo_actions; | |
| 1099 ret->do_action = yahoo_do_action; | |
| 1100 ret->send_im = yahoo_send_im; | |
| 1101 ret->away_states = yahoo_away_states; | |
| 1102 ret->set_away = yahoo_set_away; | |
| 1103 ret->set_idle = yahoo_set_idle; | |
| 1104 ret->keepalive = yahoo_keepalive; | |
| 1105 ret->add_buddy = yahoo_add_buddy; | |
| 1106 ret->remove_buddy = yahoo_remove_buddy; | |
| 2993 | 1107 ret->send_typing = yahoo_send_typing; |
| 2681 | 1108 |
| 1109 my_protocol = ret; | |
| 1110 } | |
| 1111 | |
| 1112 #ifndef STATIC | |
| 1113 | |
| 1114 char *gaim_plugin_init(GModule *handle) | |
| 1115 { | |
| 1116 load_protocol(yahoo_init, sizeof(struct prpl)); | |
| 1117 return NULL; | |
| 1118 } | |
| 1119 | |
| 1120 void gaim_plugin_remove() | |
| 1121 { | |
| 1122 struct prpl *p = find_prpl(PROTO_YAHOO); | |
| 1123 if (p == my_protocol) | |
| 1124 unload_protocol(p); | |
| 1125 } | |
| 1126 | |
| 1127 char *name() | |
| 1128 { | |
| 1129 return "Yahoo"; | |
| 1130 } | |
| 1131 | |
| 1132 char *description() | |
| 1133 { | |
| 1134 return PRPL_DESC("Yahoo"); | |
| 1135 } | |
| 1136 | |
| 1137 #endif |
