Mercurial > pidgin
comparison libpurple/protocols/msn/msn.c @ 29276:a0668fbf2483
Manual merge
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Mon, 02 Mar 2009 21:53:53 +0000 |
parents | 4561aa5b368c |
children | 68f6de7d1408 |
comparison
equal
deleted
inserted
replaced
29275:23f07a817807 | 29276:a0668fbf2483 |
---|---|
160 const gchar *username; | 160 const gchar *username; |
161 | 161 |
162 username = purple_conversation_get_name(conv); | 162 username = purple_conversation_get_name(conv); |
163 | 163 |
164 purple_prpl_send_attention(gc, username, MSN_NUDGE); | 164 purple_prpl_send_attention(gc, username, MSN_NUDGE); |
165 purple_conversation_attention(conv, username, 0, PURPLE_MESSAGE_SEND, | 165 |
166 time(NULL)); | |
167 | |
168 return PURPLE_CMD_RET_OK; | 166 return PURPLE_CMD_RET_OK; |
169 } | 167 } |
170 | 168 |
171 void | 169 void |
172 msn_act_id(PurpleConnection *gc, const char *entry) | 170 msn_act_id(PurpleConnection *gc, const char *entry) |
457 { | 455 { |
458 PurpleBuddy *buddy; | 456 PurpleBuddy *buddy; |
459 PurpleConnection *gc; | 457 PurpleConnection *gc; |
460 MsnSession *session; | 458 MsnSession *session; |
461 MsnMobileData *data; | 459 MsnMobileData *data; |
460 PurpleAccount *account; | |
461 const char *name; | |
462 | 462 |
463 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); | 463 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
464 | 464 |
465 buddy = (PurpleBuddy *) node; | 465 buddy = (PurpleBuddy *) node; |
466 gc = purple_account_get_connection(buddy->account); | 466 account = purple_buddy_get_account(buddy); |
467 gc = purple_account_get_connection(account); | |
468 name = purple_buddy_get_name(buddy); | |
467 | 469 |
468 session = gc->proto_data; | 470 session = gc->proto_data; |
469 | 471 |
470 data = g_new0(MsnMobileData, 1); | 472 data = g_new0(MsnMobileData, 1); |
471 data->gc = gc; | 473 data->gc = gc; |
472 data->passport = buddy->name; | 474 data->passport = name; |
473 | 475 |
474 purple_request_input(gc, NULL, _("Send a mobile message."), NULL, | 476 purple_request_input(gc, NULL, _("Send a mobile message."), NULL, |
475 NULL, TRUE, FALSE, NULL, | 477 NULL, TRUE, FALSE, NULL, |
476 _("Page"), G_CALLBACK(send_to_mobile_cb), | 478 _("Page"), G_CALLBACK(send_to_mobile_cb), |
477 _("Close"), G_CALLBACK(close_mobile_page_cb), | 479 _("Close"), G_CALLBACK(close_mobile_page_cb), |
478 purple_connection_get_account(gc), purple_buddy_get_name(buddy), NULL, | 480 account, name, NULL, |
479 data); | 481 data); |
480 } | 482 } |
481 | 483 |
482 static gboolean | 484 static gboolean |
483 msn_offline_message(const PurpleBuddy *buddy) { | 485 msn_offline_message(const PurpleBuddy *buddy) { |
505 static void | 507 static void |
506 initiate_chat_cb(PurpleBlistNode *node, gpointer data) | 508 initiate_chat_cb(PurpleBlistNode *node, gpointer data) |
507 { | 509 { |
508 PurpleBuddy *buddy; | 510 PurpleBuddy *buddy; |
509 PurpleConnection *gc; | 511 PurpleConnection *gc; |
512 PurpleAccount *account; | |
510 | 513 |
511 MsnSession *session; | 514 MsnSession *session; |
512 MsnSwitchBoard *swboard; | 515 MsnSwitchBoard *swboard; |
513 | 516 |
514 const char *alias; | 517 const char *alias; |
515 | 518 |
516 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); | 519 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
517 | 520 |
518 buddy = (PurpleBuddy *) node; | 521 buddy = (PurpleBuddy *) node; |
519 gc = purple_account_get_connection(buddy->account); | 522 account = purple_buddy_get_account(buddy); |
523 gc = purple_account_get_connection(account); | |
520 | 524 |
521 session = gc->proto_data; | 525 session = gc->proto_data; |
522 | 526 |
523 swboard = msn_switchboard_new(session); | 527 swboard = msn_switchboard_new(session); |
524 msn_switchboard_request(swboard); | 528 msn_switchboard_request(swboard); |
525 msn_switchboard_request_add_user(swboard, buddy->name); | 529 msn_switchboard_request_add_user(swboard, purple_buddy_get_name(buddy)); |
526 | 530 |
527 /* TODO: This might move somewhere else, after USR might be */ | 531 /* TODO: This might move somewhere else, after USR might be */ |
528 swboard->chat_id = msn_switchboard_get_chat_id(); | 532 swboard->chat_id = msn_switchboard_get_chat_id(); |
529 swboard->conv = serv_got_joined_chat(gc, swboard->chat_id, "MSN Chat"); | 533 swboard->conv = serv_got_joined_chat(gc, swboard->chat_id, "MSN Chat"); |
530 swboard->flag = MSN_SB_FLAG_IM; | 534 swboard->flag = MSN_SB_FLAG_IM; |
531 | 535 |
532 /* Local alias > Display name > Username */ | 536 /* Local alias > Display name > Username */ |
533 if ((alias = purple_account_get_alias(buddy->account)) == NULL) | 537 if ((alias = purple_account_get_alias(account)) == NULL) |
534 if ((alias = purple_connection_get_display_name(gc)) == NULL) | 538 if ((alias = purple_connection_get_display_name(gc)) == NULL) |
535 alias = purple_account_get_username(buddy->account); | 539 alias = purple_account_get_username(account); |
536 | 540 |
537 purple_conv_chat_add_user(PURPLE_CONV_CHAT(swboard->conv), | 541 purple_conv_chat_add_user(PURPLE_CONV_CHAT(swboard->conv), |
538 alias, NULL, PURPLE_CBFLAGS_NONE, TRUE); | 542 alias, NULL, PURPLE_CBFLAGS_NONE, TRUE); |
539 } | 543 } |
540 | 544 |
613 } | 617 } |
614 | 618 |
615 static const char * | 619 static const char * |
616 msn_list_emblems(PurpleBuddy *b) | 620 msn_list_emblems(PurpleBuddy *b) |
617 { | 621 { |
618 MsnUser *user = b->proto_data; | 622 MsnUser *user = purple_buddy_get_protocol_data(b); |
619 | 623 |
620 if (user != NULL) { | 624 if (user != NULL) { |
621 if (user->clientid & MSN_CLIENT_CAP_BOT) | 625 if (user->clientid & MSN_CLIENT_CAP_BOT) |
622 return "bot"; | 626 return "bot"; |
623 if (user->clientid & MSN_CLIENT_CAP_WIN_MOBILE) | 627 if (user->clientid & MSN_CLIENT_CAP_WIN_MOBILE) |
694 { | 698 { |
695 MsnUser *user; | 699 MsnUser *user; |
696 PurplePresence *presence = purple_buddy_get_presence(buddy); | 700 PurplePresence *presence = purple_buddy_get_presence(buddy); |
697 PurpleStatus *status = purple_presence_get_active_status(presence); | 701 PurpleStatus *status = purple_presence_get_active_status(presence); |
698 | 702 |
699 user = buddy->proto_data; | 703 user = purple_buddy_get_protocol_data(buddy); |
700 | 704 |
701 if (purple_presence_is_online(presence)) | 705 if (purple_presence_is_online(presence)) |
702 { | 706 { |
703 const char *psm, *name; | 707 const char *psm, *name; |
704 const char *mediatype = NULL; | 708 const char *mediatype = NULL; |
937 GList *m = NULL; | 941 GList *m = NULL; |
938 PurpleMenuAction *act; | 942 PurpleMenuAction *act; |
939 | 943 |
940 g_return_val_if_fail(buddy != NULL, NULL); | 944 g_return_val_if_fail(buddy != NULL, NULL); |
941 | 945 |
942 user = buddy->proto_data; | 946 user = purple_buddy_get_protocol_data(buddy); |
943 | 947 |
944 if (user != NULL) | 948 if (user != NULL) |
945 { | 949 { |
946 if (user->mobile) | 950 if (user->mobile) |
947 { | 951 { |
950 NULL, NULL); | 954 NULL, NULL); |
951 m = g_list_append(m, act); | 955 m = g_list_append(m, act); |
952 } | 956 } |
953 } | 957 } |
954 | 958 |
955 if (g_ascii_strcasecmp(buddy->name, | 959 if (g_ascii_strcasecmp(purple_buddy_get_name(buddy), |
956 purple_account_get_username(buddy->account))) | 960 purple_account_get_username(purple_buddy_get_account(buddy)))) |
957 { | 961 { |
958 act = purple_menu_action_new(_("Initiate _Chat"), | 962 act = purple_menu_action_new(_("Initiate _Chat"), |
959 PURPLE_CALLBACK(initiate_chat_cb), | 963 PURPLE_CALLBACK(initiate_chat_cb), |
960 NULL, NULL); | 964 NULL, NULL); |
961 m = g_list_append(m, act); | 965 m = g_list_append(m, act); |
1430 static void | 1434 static void |
1431 msn_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) | 1435 msn_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
1432 { | 1436 { |
1433 MsnSession *session; | 1437 MsnSession *session; |
1434 MsnUserList *userlist; | 1438 MsnUserList *userlist; |
1435 const char *who; | 1439 const char *who, *gname; |
1436 MsnUser *user; | 1440 MsnUser *user; |
1437 | 1441 |
1438 session = gc->proto_data; | 1442 session = gc->proto_data; |
1439 userlist = session->userlist; | 1443 userlist = session->userlist; |
1440 who = msn_normalize(gc->account, buddy->name); | 1444 who = msn_normalize(purple_connection_get_account(gc), purple_buddy_get_name(buddy)); |
1441 | 1445 |
1442 purple_debug_info("msn", "Add user:%s to group:%s\n", who, (group && group->name) ? group->name : "(null)"); | 1446 gname = group ? purple_group_get_name(group) : NULL; |
1447 purple_debug_info("msn", "Add user:%s to group:%s\n", who, gname ? gname : "(null)"); | |
1443 if (!session->logged_in) | 1448 if (!session->logged_in) |
1444 { | 1449 { |
1445 #if 0 | 1450 #if 0 |
1446 fake_userlist_add_buddy(session->sync_userlist, who, MSN_LIST_FL, | 1451 fake_userlist_add_buddy(session->sync_userlist, who, MSN_LIST_FL, |
1447 group ? group->name : NULL); | 1452 group ? group->name : NULL); |
1464 * internal. */ | 1469 * internal. */ |
1465 user = msn_userlist_find_user(userlist, who); | 1470 user = msn_userlist_find_user(userlist, who); |
1466 if ((user != NULL) && (user->networkid != MSN_NETWORK_UNKNOWN)) { | 1471 if ((user != NULL) && (user->networkid != MSN_NETWORK_UNKNOWN)) { |
1467 /* We already know this buddy and their network. This function knows | 1472 /* We already know this buddy and their network. This function knows |
1468 what to do with users already in the list and stuff... */ | 1473 what to do with users already in the list and stuff... */ |
1469 msn_userlist_add_buddy(userlist, who, group ? group->name : NULL); | 1474 msn_userlist_add_buddy(userlist, who, gname); |
1470 } else { | 1475 } else { |
1476 char **tokens; | |
1477 char *fqy; | |
1471 /* We need to check the network for this buddy first */ | 1478 /* We need to check the network for this buddy first */ |
1472 msn_userlist_save_pending_buddy(userlist, who, group ? group->name : NULL); | 1479 msn_userlist_save_pending_buddy(userlist, who, gname); |
1473 msn_notification_send_fqy(session, who); | 1480 tokens = g_strsplit(who, "@", 2); |
1481 fqy = g_strdup_printf("<ml><d n=\"%s\"><c n=\"%s\"/></d></ml>", | |
1482 tokens[1], | |
1483 tokens[0]); | |
1484 msn_notification_send_fqy(session, fqy, strlen(fqy), | |
1485 (MsnFqyCb)msn_userlist_add_pending_buddy); | |
1486 g_free(fqy); | |
1487 g_strfreev(tokens); | |
1474 } | 1488 } |
1475 } | 1489 } |
1476 | 1490 |
1477 static void | 1491 static void |
1478 msn_rem_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) | 1492 msn_rem_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
1485 | 1499 |
1486 if (!session->logged_in) | 1500 if (!session->logged_in) |
1487 return; | 1501 return; |
1488 | 1502 |
1489 /* XXX - Does buddy->name need to be msn_normalize'd here? --KingAnt */ | 1503 /* XXX - Does buddy->name need to be msn_normalize'd here? --KingAnt */ |
1490 msn_userlist_rem_buddy(userlist, buddy->name); | 1504 msn_userlist_rem_buddy(userlist, purple_buddy_get_name(buddy)); |
1491 } | 1505 } |
1492 | 1506 |
1493 static void | 1507 static void |
1494 msn_add_permit(PurpleConnection *gc, const char *who) | 1508 msn_add_permit(PurpleConnection *gc, const char *who) |
1495 { | 1509 { |
1738 static void | 1752 static void |
1739 msn_rename_group(PurpleConnection *gc, const char *old_name, | 1753 msn_rename_group(PurpleConnection *gc, const char *old_name, |
1740 PurpleGroup *group, GList *moved_buddies) | 1754 PurpleGroup *group, GList *moved_buddies) |
1741 { | 1755 { |
1742 MsnSession *session; | 1756 MsnSession *session; |
1757 const char *gname; | |
1743 | 1758 |
1744 session = gc->proto_data; | 1759 session = gc->proto_data; |
1745 | 1760 |
1746 g_return_if_fail(session != NULL); | 1761 g_return_if_fail(session != NULL); |
1747 g_return_if_fail(session->userlist != NULL); | 1762 g_return_if_fail(session->userlist != NULL); |
1748 | 1763 |
1764 gname = purple_group_get_name(group); | |
1749 if (msn_userlist_find_group_with_name(session->userlist, old_name) != NULL) | 1765 if (msn_userlist_find_group_with_name(session->userlist, old_name) != NULL) |
1750 { | 1766 { |
1751 msn_contact_rename_group(session, old_name, group->name); | 1767 msn_contact_rename_group(session, old_name, gname); |
1752 } | 1768 } |
1753 else | 1769 else |
1754 { | 1770 { |
1755 /* not found */ | 1771 /* not found */ |
1756 msn_add_group(session, NULL, group->name); | 1772 msn_add_group(session, NULL, gname); |
1757 } | 1773 } |
1758 } | 1774 } |
1759 | 1775 |
1760 static void | 1776 static void |
1761 msn_convo_closed(PurpleConnection *gc, const char *who) | 1777 msn_convo_closed(PurpleConnection *gc, const char *who) |
1811 static void | 1827 static void |
1812 msn_remove_group(PurpleConnection *gc, PurpleGroup *group) | 1828 msn_remove_group(PurpleConnection *gc, PurpleGroup *group) |
1813 { | 1829 { |
1814 MsnSession *session; | 1830 MsnSession *session; |
1815 MsnCmdProc *cmdproc; | 1831 MsnCmdProc *cmdproc; |
1832 const char *gname; | |
1816 | 1833 |
1817 session = gc->proto_data; | 1834 session = gc->proto_data; |
1818 cmdproc = session->notification->cmdproc; | 1835 cmdproc = session->notification->cmdproc; |
1819 | 1836 gname = purple_group_get_name(group); |
1820 purple_debug_info("msn", "Remove group %s\n", group->name); | 1837 |
1838 purple_debug_info("msn", "Remove group %s\n", gname); | |
1821 /*we can't delete the default group*/ | 1839 /*we can't delete the default group*/ |
1822 if(!strcmp(group->name, MSN_INDIVIDUALS_GROUP_NAME)|| | 1840 if(!strcmp(gname, MSN_INDIVIDUALS_GROUP_NAME)|| |
1823 !strcmp(group->name, MSN_NON_IM_GROUP_NAME)) | 1841 !strcmp(gname, MSN_NON_IM_GROUP_NAME)) |
1824 { | 1842 { |
1825 purple_debug_info("msn", "This group can't be removed, returning.\n"); | 1843 purple_debug_info("msn", "This group can't be removed, returning.\n"); |
1826 return ; | 1844 return ; |
1827 } | 1845 } |
1828 | 1846 |
1829 msn_del_group(session, group->name); | 1847 msn_del_group(session, gname); |
1830 } | 1848 } |
1831 | 1849 |
1832 /** | 1850 /** |
1833 * Extract info text from info_data and add it to user_info | 1851 * Extract info text from info_data and add it to user_info |
1834 */ | 1852 */ |
1841 info_data->name); | 1859 info_data->name); |
1842 | 1860 |
1843 if (b) | 1861 if (b) |
1844 { | 1862 { |
1845 char *tmp; | 1863 char *tmp; |
1846 | 1864 const char *alias; |
1847 if (b->alias && b->alias[0]) | 1865 |
1866 alias = purple_buddy_get_local_buddy_alias(b); | |
1867 if (alias && alias[0]) | |
1848 { | 1868 { |
1849 char *aliastext = g_markup_escape_text(b->alias, -1); | 1869 char *aliastext = g_markup_escape_text(alias, -1); |
1850 purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext); | 1870 purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext); |
1851 g_free(aliastext); | 1871 g_free(aliastext); |
1852 } | 1872 } |
1853 | 1873 |
1854 if (b->server_alias) | 1874 if ((alias = purple_buddy_get_server_alias(b)) != NULL) |
1855 { | 1875 { |
1856 char *nicktext = g_markup_escape_text(b->server_alias, -1); | 1876 char *nicktext = g_markup_escape_text(alias, -1); |
1857 tmp = g_strdup_printf("<font sml=\"msn\">%s</font>", nicktext); | 1877 tmp = g_strdup_printf("<font sml=\"msn\">%s</font>", nicktext); |
1858 purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp); | 1878 purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp); |
1859 g_free(tmp); | 1879 g_free(tmp); |
1860 g_free(nicktext); | 1880 g_free(nicktext); |
1861 } | 1881 } |