comparison src/protocols/msn/msn.c @ 9967:2f153f8cdf81

[gaim-migrate @ 10877] (21:12:31) KingAnt: What's up with MSN status stuff? (21:12:33) KingAnt: I want to compile (21:12:35) LSchiere: hey mark :-) (21:12:39) LSchiere: lack of patches (21:12:48) nosnilmot: http://nosnilmot.com/patches/gaim-1.0.0cvs-msn-status.patch (21:12:54) KingAnt: Ha ha (21:12:57) LSchiere: there we go :-D (21:12:58) nosnilmot: might be good enough, might not (21:13:06) KingAnt: I need to ask these kinds of questions more often committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Wed, 08 Sep 2004 01:16:14 +0000
parents d908907d9441
children 86a6d78b070b
comparison
equal deleted inserted replaced
9966:b15c177895b9 9967:2f153f8cdf81
390 static void 390 static void
391 msn_list_emblems(GaimBuddy *b, const char **se, const char **sw, 391 msn_list_emblems(GaimBuddy *b, const char **se, const char **sw,
392 const char **nw, const char **ne) 392 const char **nw, const char **ne)
393 { 393 {
394 MsnUser *user; 394 MsnUser *user;
395 GaimPresence *presence;
395 const char *emblems[4] = { NULL, NULL, NULL, NULL }; 396 const char *emblems[4] = { NULL, NULL, NULL, NULL };
396 int away_type = MSN_AWAY_TYPE(b->uc);
397 int i = 0; 397 int i = 0;
398 398
399 user = b->proto_data; 399 user = b->proto_data;
400 400 presence = gaim_buddy_get_presence(b);
401 if (b->present == GAIM_BUDDY_OFFLINE) 401
402 if (!gaim_presence_is_online(presence))
402 emblems[i++] = "offline"; 403 emblems[i++] = "offline";
403 else if (away_type == MSN_BUSY || away_type == MSN_PHONE) 404 else if (gaim_presence_is_status_active(presence, "busy") ||
405 gaim_presence_is_status_active(presence, "phone"))
404 emblems[i++] = "occupied"; 406 emblems[i++] = "occupied";
405 else if (away_type != 0) 407 else if (gaim_presence_is_status_active(presence, "away"))
406 emblems[i++] = "away"; 408 emblems[i++] = "away";
407 409
408 if (user == NULL) 410 if (user == NULL)
409 { 411 {
410 emblems[0] = "offline"; 412 emblems[0] = "offline";
447 } 449 }
448 450
449 static GList * 451 static GList *
450 msn_status_types(GaimAccount *account) 452 msn_status_types(GaimAccount *account)
451 { 453 {
452 GaimStatusType *offline; 454 GaimStatusType *status;
453 GaimStatusType *online;
454 GaimStatusType *unavail;
455 GList *types = NULL; 455 GList *types = NULL;
456 456
457 offline = gaim_status_type_new(GAIM_STATUS_OFFLINE, 457 status = gaim_status_type_new(GAIM_STATUS_OFFLINE,
458 "offline", _("Offline"), FALSE); 458 "offline", _("Offline"), FALSE);
459 types = g_list_append(types, offline); 459 types = g_list_append(types, status);
460 460
461 online = gaim_status_type_new(GAIM_STATUS_ONLINE, 461 status = gaim_status_type_new(GAIM_STATUS_ONLINE,
462 "online", _("Online"), FALSE); 462 "online", _("Online"), FALSE);
463 types = g_list_append(types, online); 463 types = g_list_append(types, status);
464 464
465 gaim_status_type_new(online, GAIM_STATUS_AVAILABLE, "available", 465 status = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE,
466 _("Available"), FALSE, FALSE, FALSE); 466 "available", _("Available"), FALSE, FALSE, FALSE);
467 unavail = gaim_status_type_new(online, GAIM_STATUS_UNAVAILABLE, 467 types = g_list_append(types, status);
468
469 status = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE,
468 "unavailable", _("Unavailable"), 470 "unavailable", _("Unavailable"),
469 FALSE, FALSE, FALSE); 471 FALSE, FALSE, FALSE);
470 472 types = g_list_append(types, status);
471 gaim_status_type_new(unavail, GAIM_STATUS_AWAY, "away", 473
474 status = gaim_status_type_new_full(GAIM_STATUS_AWAY, "away",
472 _("Away"), FALSE, TRUE, FALSE); 475 _("Away"), FALSE, TRUE, FALSE);
473 gaim_status_type_new(unavail, GAIM_STATUS_AWAY, "brb", 476 types = g_list_append(types, status);
477
478 status = gaim_status_type_new_full(GAIM_STATUS_AWAY, "brb",
474 _("Be Right Back"), FALSE, TRUE, FALSE); 479 _("Be Right Back"), FALSE, TRUE, FALSE);
475 gaim_status_type_new(unavail, GAIM_STATUS_AWAY, "busy", 480 types = g_list_append(types, status);
481
482 status = gaim_status_type_new_full(GAIM_STATUS_AWAY, "busy",
476 _("Busy"), FALSE, TRUE, FALSE); 483 _("Busy"), FALSE, TRUE, FALSE);
477 gaim_status_type_new(unavail, GAIM_STATUS_AWAY, "phone", 484 types = g_list_append(types, status);
485
486 status = gaim_status_type_new_full(GAIM_STATUS_AWAY, "phone",
478 _("On The Phone"), FALSE, TRUE, FALSE); 487 _("On The Phone"), FALSE, TRUE, FALSE);
479 gaim_status_type_new(unavail, GAIM_STATUS_AWAY, "lunch", 488 types = g_list_append(types, status);
489
490 status = gaim_status_type_new_full(GAIM_STATUS_AWAY, "lunch",
480 _("Out To Lunch"), FALSE, TRUE, FALSE); 491 _("Out To Lunch"), FALSE, TRUE, FALSE);
481 gaim_status_type_new(unavail, GAIM_STATUS_HIDDEN, "hidden", 492 types = g_list_append(types, status);
493
494 status = gaim_status_type_new_full(GAIM_STATUS_HIDDEN, "hidden",
482 _("Hidden"), FALSE, TRUE, FALSE); 495 _("Hidden"), FALSE, TRUE, FALSE);
496 types = g_list_append(types, status);
483 497
484 return types; 498 return types;
485 } 499 }
486 500
487 static GList * 501 static GList *
738 752
739 return MSN_TYPING_SEND_TIMEOUT; 753 return MSN_TYPING_SEND_TIMEOUT;
740 } 754 }
741 755
742 static void 756 static void
743 msn_set_away(GaimConnection *gc, const char *state, const char *msg) 757 msn_set_status(GaimAccount *account, GaimStatus *status)
744 { 758 {
745 MsnSession *session; 759 GaimConnection *gc;
746 int status; 760 MsnSession *session;
747 761 const char *state;
748 session = gc->proto_data; 762 int msnstatus;
749 763
750 if (gc->away != NULL) 764 gc = gaim_account_get_connection(account);
751 { 765
752 g_free(gc->away); 766 if (gc == NULL)
753 gc->away = NULL; 767 return;
754 } 768
755 769 session = gc->proto_data;
756 if (msg != NULL) 770
757 { 771 state = gaim_status_get_id(status);
758 gc->away = g_strdup(""); 772
759 status = MSN_AWAY; 773 if (!strcmp(state, "away"))
760 } 774 msnstatus = MSN_AWAY;
761 else if (state) 775 else if (!strcmp(state, "brb"))
762 { 776 msnstatus = MSN_BRB;
763 gc->away = g_strdup(""); 777 else if (!strcmp(state, "busy"))
764 778 msnstatus = MSN_BUSY;
765 if (!strcmp(state, _("Away From Computer"))) 779 else if (!strcmp(state, "phone"))
766 status = MSN_AWAY; 780 msnstatus = MSN_PHONE;
767 else if (!strcmp(state, _("Be Right Back"))) 781 else if (!strcmp(state, "lunch"))
768 status = MSN_BRB; 782 msnstatus = MSN_LUNCH;
769 else if (!strcmp(state, _("Busy"))) 783 else if (!strcmp(state, "hidden"))
770 status = MSN_BUSY; 784 msnstatus = MSN_HIDDEN;
771 else if (!strcmp(state, _("On The Phone"))) 785 else if (0) /* how do we detect idle with new status? */
772 status = MSN_PHONE; 786 msnstatus = MSN_IDLE;
773 else if (!strcmp(state, _("Out To Lunch")))
774 status = MSN_LUNCH;
775 else if (!strcmp(state, _("Hidden")))
776 status = MSN_HIDDEN;
777 else
778 {
779 g_free(gc->away);
780 gc->away = NULL;
781 status = MSN_ONLINE;
782 }
783 }
784 else if (gc->is_idle)
785 status = MSN_IDLE;
786 else 787 else
787 status = MSN_ONLINE; 788 msnstatus = MSN_ONLINE;
788 789
789 msn_change_status(session, status); 790 msn_change_status(session, msnstatus);
790 } 791 }
791 792
792 static void 793 static void
793 msn_set_idle(GaimConnection *gc, int idle) 794 msn_set_idle(GaimConnection *gc, int idle)
794 { 795 {
795 MsnSession *session; 796 MsnSession *session;
796 797
797 session = gc->proto_data; 798 session = gc->proto_data;
798
799 if (gc->away != NULL)
800 return;
801 799
802 msn_change_status(session, (idle ? MSN_IDLE : MSN_ONLINE)); 800 msn_change_status(session, (idle ? MSN_IDLE : MSN_ONLINE));
803 } 801 }
804 802
805 static void 803 static void
1168 g_string_free(name, TRUE); 1166 g_string_free(name, TRUE);
1169 b = gaim_find_buddy(gaim_connection_get_account(info_data->gc), 1167 b = gaim_find_buddy(gaim_connection_get_account(info_data->gc),
1170 info_data->name); 1168 info_data->name);
1171 1169
1172 if (b) { 1170 if (b) {
1171 GaimPresence *presence;
1173 char *statustext = msn_tooltip_text(b); 1172 char *statustext = msn_tooltip_text(b);
1173 presence = gaim_buddy_get_presence(b);
1174 if(b->alias && b->alias[0]) { 1174 if(b->alias && b->alias[0]) {
1175 char *aliastext = g_markup_escape_text(b->alias, -1); 1175 char *aliastext = g_markup_escape_text(b->alias, -1);
1176 g_string_append_printf(s, _("<b>Alias:</b> %s<br>"), aliastext); 1176 g_string_append_printf(s, _("<b>Alias:</b> %s<br>"), aliastext);
1177 g_free(aliastext); 1177 g_free(aliastext);
1178 } 1178 }
1181 g_string_append_printf(s, _("<b>%s:</b> "), _("Nickname")); 1181 g_string_append_printf(s, _("<b>%s:</b> "), _("Nickname"));
1182 g_string_append_printf(s, "<font sml=\"msn\">%s</font><br>", 1182 g_string_append_printf(s, "<font sml=\"msn\">%s</font><br>",
1183 nicktext); 1183 nicktext);
1184 g_free(nicktext); 1184 g_free(nicktext);
1185 } 1185 }
1186 if (b->idle > 0) { 1186 if (gaim_presence_is_idle(presence)) {
1187 char *idletime = gaim_str_seconds_to_string(time(NULL) - b->idle); 1187 char *idletime = gaim_str_seconds_to_string(time(NULL) -
1188 gaim_presence_get_idle_time(presence));
1188 g_string_append_printf(s, _("<b>%s:</b> %s<br>"), _("Idle"), 1189 g_string_append_printf(s, _("<b>%s:</b> %s<br>"), _("Idle"),
1189 idletime); 1190 idletime);
1190 g_free(idletime); 1191 g_free(idletime);
1191 } 1192 }
1192 if (statustext) { 1193 if (statustext) {
1683 msn_close, /* close */ 1684 msn_close, /* close */
1684 msn_send_im, /* send_im */ 1685 msn_send_im, /* send_im */
1685 NULL, /* set_info */ 1686 NULL, /* set_info */
1686 msn_send_typing, /* send_typing */ 1687 msn_send_typing, /* send_typing */
1687 msn_get_info, /* get_info */ 1688 msn_get_info, /* get_info */
1688 msn_set_away, /* set_away */ 1689 msn_set_status, /* set_away */
1689 msn_set_idle, /* set_idle */ 1690 msn_set_idle, /* set_idle */
1690 NULL, /* change_passwd */ 1691 NULL, /* change_passwd */
1691 msn_add_buddy, /* add_buddy */ 1692 msn_add_buddy, /* add_buddy */
1692 NULL, /* add_buddies */ 1693 NULL, /* add_buddies */
1693 msn_rem_buddy, /* remove_buddy */ 1694 msn_rem_buddy, /* remove_buddy */