comparison src/protocols/yahoo/yahoo.c @ 9983:7286c1483ceb

[gaim-migrate @ 10894] This hopefully makes parsing user statuses work, and gives rid of all serv_got_update's. It's still incomplete, and still doesn't compile. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Wed, 08 Sep 2004 05:31:09 +0000
parents 920f6a5bcb4a
children e4a032202d49
comparison
equal deleted inserted replaced
9982:8db453e87678 9983:7286c1483ceb
315 } 315 }
316 316
317 static void yahoo_update_status(GaimConnection *gc, const char *name, YahooFriend *f) 317 static void yahoo_update_status(GaimConnection *gc, const char *name, YahooFriend *f)
318 { 318 {
319 gboolean online = TRUE; 319 gboolean online = TRUE;
320 char *status = NULL;
320 321
321 if (!gc || !name || !f || !gaim_find_buddy(gaim_connection_get_account(gc), name)) 322 if (!gc || !name || !f || !gaim_find_buddy(gaim_connection_get_account(gc), name))
322 return; 323 return;
323 324
324 if (f->status == YAHOO_STATUS_OFFLINE) 325 if (f->status == YAHOO_STATUS_OFFLINE)
325 online = FALSE; 326 online = FALSE;
326 327
327 serv_got_update(gc, name, online, 0, 0, f->idle, f->away ? UC_UNAVAILABLE : 0); 328 switch (f->status) {
329 case YAHOO_STATUS_AVAILABLE:
330 status = "available";
331 break;
332 case YAHOO_STATUS_BRB:
333 status = "brb";
334 break;
335 case YAHOO_STATUS_BUSY:
336 status = "busy";
337 break;
338 case YAHOO_STATUS_NOTATHOME:
339 status = "notathome";
340 break;
341 case YAHOO_STATUS_NOTATDESK:
342 status = "notatdesk";
343 break;
344 case YAHOO_STATUS_NOTINOFFICE:
345 status = "notinoffice";
346 break;
347 case YAHOO_STATUS_ONPHONE:
348 status = "onphone";
349 break;
350 case YAHOO_STATUS_ONVACATION:
351 status = "onvacation";
352 break;
353 case YAHOO_STATUS_OUTTOLUNCH:
354 status = "outtolunch";
355 break;
356 case YAHOO_STATUS_STEPPEDOUT:
357 status = "steppedout";
358 break;
359 case YAHOO_STATUS_INVISIBLE: /* this should never happen? */
360 status = "invisible";
361 break;
362 case YAHOO_STATUS_CUSTOM:
363 if (!f->away)
364 status = "avaiablewm";
365 else
366 status = "away";
367 break;
368 case YAHOO_STATUS_IDLE: /* FIXME: handle this */
369 break;
370 default:
371 gaim_debug_warning("yahoo", "Warning, unknown status %d\n", f->status);
372 break;
373 }
374
375 if (status) {
376 if (f->status == YAHOO_STATUS_CUSTOM)
377 gaim_prpl_got_user_status(gaim_connection_get_account(gc), name, status, "message",
378 yahoo_friend_get_status_message(f), NULL);
379 else
380 gaim_prpl_got_user_status(gaim_connection_get_account(gc), name, status, NULL);
381 }
382
328 } 383 }
329 384
330 static void yahoo_process_status(GaimConnection *gc, struct yahoo_packet *pkt) 385 static void yahoo_process_status(GaimConnection *gc, struct yahoo_packet *pkt)
331 { 386 {
387 GaimAccount *account = gaim_connection_get_account(gc);
332 struct yahoo_data *yd = gc->proto_data; 388 struct yahoo_data *yd = gc->proto_data;
333 GSList *l = pkt->hash; 389 GSList *l = pkt->hash;
334 YahooFriend *f = NULL; 390 YahooFriend *f = NULL;
335 char *name = NULL; 391 char *name = NULL;
336 392
436 break; 492 break;
437 case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */ 493 case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */
438 if (strtol(pair->value, NULL, 10) == 0) { 494 if (strtol(pair->value, NULL, 10) == 0) {
439 if (f) 495 if (f)
440 f->status = YAHOO_STATUS_OFFLINE; 496 f->status = YAHOO_STATUS_OFFLINE;
441 serv_got_update(gc, name, FALSE, 0, 0, 0, 0); 497 gaim_prpl_got_user_status(account, name, "offline", NULL);
442 break; 498 break;
443 } 499 }
444 500
445 if (f) 501 if (f)
446 yahoo_update_status(gc, name, f); 502 yahoo_update_status(gc, name, f);
946 g_free(msg2); 1002 g_free(msg2);
947 } 1003 }
948 gaim_notify_info(gc, NULL, _("Add buddy rejected"), buf->str); 1004 gaim_notify_info(gc, NULL, _("Add buddy rejected"), buf->str);
949 g_string_free(buf, TRUE); 1005 g_string_free(buf, TRUE);
950 g_hash_table_remove(yd->friends, who); 1006 g_hash_table_remove(yd->friends, who);
951 serv_got_update(gc, who, FALSE, 0, 0, 0, 0); 1007 gaim_prpl_got_user_status(gaim_connection_get_account(gc), who, "offline", NULL); /* FIXME: make this set not on list status instead */
952 } 1008 }
953 } 1009 }
954 1010
955 static void yahoo_process_contact(GaimConnection *gc, struct yahoo_packet *pkt) 1011 static void yahoo_process_contact(GaimConnection *gc, struct yahoo_packet *pkt)
956 { 1012 {