comparison libpurple/protocols/msn/msn.c @ 32819:2c6510167895 default tip

propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24) to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 02 Jun 2012 02:30:49 +0000
parents e10e419e6067
children
comparison
equal deleted inserted replaced
32818:01ff09d4a463 32819:2c6510167895
117 MsnMessage *msg; 117 MsnMessage *msg;
118 MsnSession *session; 118 MsnSession *session;
119 MsnSwitchBoard *swboard; 119 MsnSwitchBoard *swboard;
120 120
121 msg = msn_message_new_nudge(); 121 msg = msn_message_new_nudge();
122 session = gc->proto_data; 122 session = purple_connection_get_protocol_data(gc);
123 swboard = msn_session_get_swboard(session, username, MSN_SB_FLAG_IM); 123 swboard = msn_session_get_swboard(session, username, MSN_SB_FLAG_IM);
124 124
125 msn_switchboard_send_msg(swboard, msg, TRUE); 125 msn_switchboard_send_msg(swboard, msg, TRUE);
126 msn_message_unref(msg); 126 msn_message_unref(msg);
127 127
324 { 324 {
325 MsnCmdProc *cmdproc; 325 MsnCmdProc *cmdproc;
326 MsnSession *session; 326 MsnSession *session;
327 MsnTransaction *trans; 327 MsnTransaction *trans;
328 328
329 session = gc->proto_data; 329 session = purple_connection_get_protocol_data(gc);
330 cmdproc = session->notification->cmdproc; 330 cmdproc = session->notification->cmdproc;
331 331
332 if (entry == NULL || *entry == '\0') 332 if (entry == NULL || *entry == '\0')
333 { 333 {
334 trans = msn_transaction_new(cmdproc, "PRP", "%s", type); 334 trans = msn_transaction_new(cmdproc, "PRP", "%s", type);
382 MsnUser *user; 382 MsnUser *user;
383 char *payload = NULL; 383 char *payload = NULL;
384 const char *mobile_number = NULL; 384 const char *mobile_number = NULL;
385 gsize payload_len; 385 gsize payload_len;
386 386
387 session = gc->proto_data; 387 session = purple_connection_get_protocol_data(gc);
388 cmdproc = session->notification->cmdproc; 388 cmdproc = session->notification->cmdproc;
389 389
390 page = msn_page_new(); 390 page = msn_page_new();
391 msn_page_set_body(page, entry); 391 msn_page_set_body(page, entry);
392 392
645 { 645 {
646 PurpleConnection *gc; 646 PurpleConnection *gc;
647 MsnSession *session; 647 MsnSession *session;
648 648
649 gc = (PurpleConnection *) action->context; 649 gc = (PurpleConnection *) action->context;
650 session = gc->proto_data; 650 session = purple_connection_get_protocol_data(gc);
651 651
652 purple_request_input(gc, NULL, _("Set your home phone number."), NULL, 652 purple_request_input(gc, NULL, _("Set your home phone number."), NULL,
653 msn_user_get_home_phone(session->user), FALSE, FALSE, NULL, 653 msn_user_get_home_phone(session->user), FALSE, FALSE, NULL,
654 _("OK"), G_CALLBACK(msn_set_home_phone_cb), 654 _("OK"), G_CALLBACK(msn_set_home_phone_cb),
655 _("Cancel"), NULL, 655 _("Cancel"), NULL,
662 { 662 {
663 PurpleConnection *gc; 663 PurpleConnection *gc;
664 MsnSession *session; 664 MsnSession *session;
665 665
666 gc = (PurpleConnection *) action->context; 666 gc = (PurpleConnection *) action->context;
667 session = gc->proto_data; 667 session = purple_connection_get_protocol_data(gc);
668 668
669 purple_request_input(gc, NULL, _("Set your work phone number."), NULL, 669 purple_request_input(gc, NULL, _("Set your work phone number."), NULL,
670 msn_user_get_work_phone(session->user), FALSE, FALSE, NULL, 670 msn_user_get_work_phone(session->user), FALSE, FALSE, NULL,
671 _("OK"), G_CALLBACK(msn_set_work_phone_cb), 671 _("OK"), G_CALLBACK(msn_set_work_phone_cb),
672 _("Cancel"), NULL, 672 _("Cancel"), NULL,
679 { 679 {
680 PurpleConnection *gc; 680 PurpleConnection *gc;
681 MsnSession *session; 681 MsnSession *session;
682 682
683 gc = (PurpleConnection *) action->context; 683 gc = (PurpleConnection *) action->context;
684 session = gc->proto_data; 684 session = purple_connection_get_protocol_data(gc);
685 685
686 purple_request_input(gc, NULL, _("Set your mobile phone number."), NULL, 686 purple_request_input(gc, NULL, _("Set your mobile phone number."), NULL,
687 msn_user_get_mobile_phone(session->user), FALSE, FALSE, NULL, 687 msn_user_get_mobile_phone(session->user), FALSE, FALSE, NULL,
688 _("OK"), G_CALLBACK(msn_set_mobile_phone_cb), 688 _("OK"), G_CALLBACK(msn_set_mobile_phone_cb),
689 _("Cancel"), NULL, 689 _("Cancel"), NULL,
717 { 717 {
718 PurpleConnection *pc = (PurpleConnection *) action->context; 718 PurpleConnection *pc = (PurpleConnection *) action->context;
719 MsnSession *session; 719 MsnSession *session;
720 char *title; 720 char *title;
721 721
722 session = pc->proto_data; 722 session = purple_connection_get_protocol_data(pc);
723 723
724 title = g_strdup_printf(_("Blocked Text for %s"), session->account->username); 724 title = g_strdup_printf(_("Blocked Text for %s"), session->account->username);
725 if (session->blocked_text == NULL) { 725 if (session->blocked_text == NULL) {
726 purple_notify_formatted(pc, title, title, NULL, _("No text is blocked for this account."), NULL, NULL); 726 purple_notify_formatted(pc, title, title, NULL, _("No text is blocked for this account."), NULL, NULL);
727 } else { 727 } else {
741 { 741 {
742 PurpleConnection *gc; 742 PurpleConnection *gc;
743 MsnSession *session; 743 MsnSession *session;
744 744
745 gc = (PurpleConnection *) action->context; 745 gc = (PurpleConnection *) action->context;
746 session = gc->proto_data; 746 session = purple_connection_get_protocol_data(gc);
747 747
748 if (!session->passport_info.email_enabled) { 748 if (!session->passport_info.email_enabled) {
749 purple_notify_error(gc, NULL, 749 purple_notify_error(gc, NULL,
750 _("This account does not have email enabled."), NULL); 750 _("This account does not have email enabled."), NULL);
751 return; 751 return;
808 MsnSession *session; 808 MsnSession *session;
809 MsnCmdProc *cmdproc; 809 MsnCmdProc *cmdproc;
810 MsnTransaction *trans; 810 MsnTransaction *trans;
811 811
812 account = purple_connection_get_account(gc); 812 account = purple_connection_get_account(gc);
813 session = gc->proto_data; 813 session = purple_connection_get_protocol_data(gc);
814 cmdproc = session->notification->cmdproc; 814 cmdproc = session->notification->cmdproc;
815 815
816 if (account->perm_deny == PURPLE_PRIVACY_ALLOW_ALL || 816 if (purple_account_get_privacy_type(account) == PURPLE_PRIVACY_ALLOW_ALL ||
817 account->perm_deny == PURPLE_PRIVACY_DENY_USERS) 817 purple_account_get_privacy_type(account) == PURPLE_PRIVACY_DENY_USERS)
818 trans = msn_transaction_new(cmdproc, "BLP", "%s", "AL"); 818 trans = msn_transaction_new(cmdproc, "BLP", "%s", "AL");
819 else 819 else
820 trans = msn_transaction_new(cmdproc, "BLP", "%s", "BL"); 820 trans = msn_transaction_new(cmdproc, "BLP", "%s", "BL");
821 821
822 msn_cmdproc_send_trans(cmdproc, trans); 822 msn_cmdproc_send_trans(cmdproc, trans);
838 838
839 buddy = (PurpleBuddy *) node; 839 buddy = (PurpleBuddy *) node;
840 account = purple_buddy_get_account(buddy); 840 account = purple_buddy_get_account(buddy);
841 gc = purple_account_get_connection(account); 841 gc = purple_account_get_connection(account);
842 842
843 session = gc->proto_data; 843 session = purple_connection_get_protocol_data(gc);
844 844
845 swboard = msn_switchboard_new(session); 845 swboard = msn_switchboard_new(session);
846 msn_switchboard_request(swboard); 846 msn_switchboard_request(swboard);
847 msn_switchboard_request_add_user(swboard, purple_buddy_get_name(buddy)); 847 msn_switchboard_request_add_user(swboard, purple_buddy_get_name(buddy));
848 848
867 } 867 }
868 868
869 static void 869 static void
870 t_msn_xfer_cancel_send(PurpleXfer *xfer) 870 t_msn_xfer_cancel_send(PurpleXfer *xfer)
871 { 871 {
872 MsnSlpLink *slplink = xfer->data; 872 MsnSlpLink *slplink = purple_xfer_get_protocol_data(xfer);
873 msn_slplink_unref(slplink); 873 msn_slplink_unref(slplink);
874 } 874 }
875 875
876 static PurpleXfer* 876 static PurpleXfer*
877 msn_new_xfer(PurpleConnection *gc, const char *who) 877 msn_new_xfer(PurpleConnection *gc, const char *who)
878 { 878 {
879 MsnSession *session; 879 MsnSession *session;
880 PurpleXfer *xfer; 880 PurpleXfer *xfer;
881 881
882 session = gc->proto_data; 882 session = purple_connection_get_protocol_data(gc);
883 883
884 xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who); 884 xfer = purple_xfer_new(purple_connection_get_account(gc), PURPLE_XFER_SEND, who);
885 885
886 g_return_val_if_fail(xfer != NULL, NULL); 886 g_return_val_if_fail(xfer != NULL, NULL);
887 887
888 xfer->data = msn_slplink_ref(msn_session_get_slplink(session, who)); 888 purple_xfer_set_protocol_data(xfer, msn_slplink_ref(msn_session_get_slplink(session, who)));
889 889
890 purple_xfer_set_init_fnc(xfer, t_msn_xfer_init); 890 purple_xfer_set_init_fnc(xfer, t_msn_xfer_init);
891 purple_xfer_set_cancel_send_fnc(xfer, t_msn_xfer_cancel_send); 891 purple_xfer_set_cancel_send_fnc(xfer, t_msn_xfer_cancel_send);
892 892
893 return xfer; 893 return xfer;
916 normal = g_strdup(msn_normalize(account, purple_account_get_username(account))); 916 normal = g_strdup(msn_normalize(account, purple_account_get_username(account)));
917 ret = strcmp(normal, msn_normalize(account, who)); 917 ret = strcmp(normal, msn_normalize(account, who));
918 g_free(normal); 918 g_free(normal);
919 919
920 if (ret) { 920 if (ret) {
921 MsnSession *session = gc->proto_data; 921 MsnSession *session = purple_connection_get_protocol_data(gc);
922 if (session) { 922 if (session) {
923 MsnUser *user = msn_userlist_find_user(session->userlist, who); 923 MsnUser *user = msn_userlist_find_user(session->userlist, who);
924 if (user) { 924 if (user) {
925 /* Include these too: MSN_CAP_MOBILE_ON|MSN_CAP_WEB_WATCH ? */ 925 /* Include these too: MSN_CAP_MOBILE_ON|MSN_CAP_WEB_WATCH ? */
926 if ((user->clientid & MSN_CAP_VIA_WEBIM) || 926 if ((user->clientid & MSN_CAP_VIA_WEBIM) ||
1076 } 1076 }
1077 1077
1078 if (psm != NULL && *psm) { 1078 if (psm != NULL && *psm) {
1079 purple_notify_user_info_add_pair_plaintext(user_info, tmp2, psm); 1079 purple_notify_user_info_add_pair_plaintext(user_info, tmp2, psm);
1080 } else { 1080 } else {
1081 purple_notify_user_info_add_pair(user_info, _("Status"), tmp2); 1081 purple_notify_user_info_add_pair_html(user_info, _("Status"), tmp2);
1082 } 1082 }
1083 1083
1084 g_free(tmp2); 1084 g_free(tmp2);
1085 } else { 1085 } else {
1086 if (psm != NULL && *psm) { 1086 if (psm != NULL && *psm) {
1089 } else { 1089 } else {
1090 purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), psm); 1090 purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), psm);
1091 } 1091 }
1092 } else { 1092 } else {
1093 if (purple_presence_is_idle(presence)) { 1093 if (purple_presence_is_idle(presence)) {
1094 purple_notify_user_info_add_pair(user_info, _("Status"), 1094 purple_notify_user_info_add_pair_plaintext(user_info,
1095 _("Idle")); 1095 _("Status"), _("Idle"));
1096 } else { 1096 } else {
1097 purple_notify_user_info_add_pair(user_info, _("Status"), 1097 purple_notify_user_info_add_pair_plaintext(user_info,
1098 purple_status_get_name(status)); 1098 _("Status"), purple_status_get_name(status));
1099 } 1099 }
1100 } 1100 }
1101 } 1101 }
1102 1102
1103 if (currentmedia) { 1103 if (currentmedia) {
1104 purple_notify_user_info_add_pair(user_info, mediatype, currentmedia); 1104 purple_notify_user_info_add_pair_html(user_info, mediatype, currentmedia);
1105 g_free(currentmedia); 1105 g_free(currentmedia);
1106 } 1106 }
1107 } 1107 }
1108 1108
1109 /* XXX: This is being shown in non-full tooltips because the 1109 /* XXX: This is being shown in non-full tooltips because the
1117 */ 1117 */
1118 if (full && user) 1118 if (full && user)
1119 { 1119 {
1120 const char *phone; 1120 const char *phone;
1121 1121
1122 purple_notify_user_info_add_pair(user_info, _("Has you"), 1122 purple_notify_user_info_add_pair_plaintext(user_info, _("Has you"),
1123 ((user->list_op & (1 << MSN_LIST_RL)) ? _("Yes") : _("No"))); 1123 ((user->list_op & (1 << MSN_LIST_RL)) ? _("Yes") : _("No")));
1124 1124
1125 purple_notify_user_info_add_pair(user_info, _("Blocked"), 1125 purple_notify_user_info_add_pair_plaintext(user_info, _("Blocked"),
1126 ((user->list_op & (1 << MSN_LIST_BL)) ? _("Yes") : _("No"))); 1126 ((user->list_op & (1 << MSN_LIST_BL)) ? _("Yes") : _("No")));
1127 1127
1128 phone = msn_user_get_home_phone(user); 1128 phone = msn_user_get_home_phone(user);
1129 if (phone != NULL) 1129 if (phone != NULL) {
1130 purple_notify_user_info_add_pair(user_info, _("Home Phone Number"), phone); 1130 purple_notify_user_info_add_pair_plaintext(user_info, _("Home Phone Number"), phone);
1131 }
1131 1132
1132 phone = msn_user_get_work_phone(user); 1133 phone = msn_user_get_work_phone(user);
1133 if (phone != NULL) 1134 if (phone != NULL) {
1134 purple_notify_user_info_add_pair(user_info, _("Work Phone Number"), phone); 1135 purple_notify_user_info_add_pair_plaintext(user_info, _("Work Phone Number"), phone);
1136 }
1135 1137
1136 phone = msn_user_get_mobile_phone(user); 1138 phone = msn_user_get_mobile_phone(user);
1137 if (phone != NULL) 1139 if (phone != NULL) {
1138 purple_notify_user_info_add_pair(user_info, _("Mobile Phone Number"), phone); 1140 purple_notify_user_info_add_pair_plaintext(user_info, _("Mobile Phone Number"), phone);
1141 }
1139 } 1142 }
1140 } 1143 }
1141 1144
1142 static GList * 1145 static GList *
1143 msn_status_types(PurpleAccount *account) 1146 msn_status_types(PurpleAccount *account)
1211 MsnSession *session; 1214 MsnSession *session;
1212 GList *m = NULL; 1215 GList *m = NULL;
1213 PurplePluginAction *act; 1216 PurplePluginAction *act;
1214 1217
1215 gc = (PurpleConnection *) context; 1218 gc = (PurpleConnection *) context;
1216 session = gc->proto_data; 1219 session = purple_connection_get_protocol_data(gc);
1217 1220
1218 act = purple_plugin_action_new(_("Set Friendly Name..."), 1221 act = purple_plugin_action_new(_("Set Friendly Name..."),
1219 msn_show_set_friendly_name); 1222 msn_show_set_friendly_name);
1220 m = g_list_append(m, act); 1223 m = g_list_append(m, act);
1221 m = g_list_append(m, NULL); 1224 m = g_list_append(m, NULL);
1331 1334
1332 gc = purple_account_get_connection(account); 1335 gc = purple_account_get_connection(account);
1333 1336
1334 if (!purple_ssl_is_supported()) 1337 if (!purple_ssl_is_supported())
1335 { 1338 {
1336 purple_connection_error_reason(gc, 1339 purple_connection_error(gc,
1337 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, 1340 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
1338 _("SSL support is needed for MSN. Please install a supported " 1341 _("SSL support is needed for MSN. Please install a supported "
1339 "SSL library.")); 1342 "SSL library."));
1340 return; 1343 return;
1341 } 1344 }
1348 host = purple_account_get_string(account, "server", MSN_SERVER); 1351 host = purple_account_get_string(account, "server", MSN_SERVER);
1349 port = purple_account_get_int(account, "port", MSN_PORT); 1352 port = purple_account_get_int(account, "port", MSN_PORT);
1350 1353
1351 session = msn_session_new(account); 1354 session = msn_session_new(account);
1352 1355
1353 gc->proto_data = session; 1356 purple_connection_set_protocol_data(gc, session);
1354 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_FORMATTING_WBFO | PURPLE_CONNECTION_NO_BGCOLOR | 1357 purple_connection_set_flags(gc,
1355 PURPLE_CONNECTION_NO_FONTSIZE | PURPLE_CONNECTION_NO_URLDESC | PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY; 1358 PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_FORMATTING_WBFO | PURPLE_CONNECTION_NO_BGCOLOR |
1359 PURPLE_CONNECTION_NO_FONTSIZE | PURPLE_CONNECTION_NO_URLDESC | PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY);
1356 1360
1357 msn_session_set_login_step(session, MSN_LOGIN_STEP_START); 1361 msn_session_set_login_step(session, MSN_LOGIN_STEP_START);
1358 1362
1359 /* Hmm, I don't like this. */ 1363 /* Hmm, I don't like this. */
1360 /* XXX shx: Me neither */ 1364 /* XXX shx: Me neither */
1372 purple_account_set_string(account, "endpoint-name", 1376 purple_account_set_string(account, "endpoint-name",
1373 ui_name && *ui_name ? ui_name : PACKAGE_NAME); 1377 ui_name && *ui_name ? ui_name : PACKAGE_NAME);
1374 } 1378 }
1375 1379
1376 if (!msn_session_connect(session, host, port, http_method)) 1380 if (!msn_session_connect(session, host, port, http_method))
1377 purple_connection_error_reason(gc, 1381 purple_connection_error(gc,
1378 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 1382 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
1379 _("Unable to connect")); 1383 _("Unable to connect"));
1380 } 1384 }
1381 1385
1382 static void 1386 static void
1383 msn_close(PurpleConnection *gc) 1387 msn_close(PurpleConnection *gc)
1384 { 1388 {
1385 MsnSession *session; 1389 MsnSession *session;
1386 1390
1387 session = gc->proto_data; 1391 session = purple_connection_get_protocol_data(gc);
1388 1392
1389 g_return_if_fail(session != NULL); 1393 g_return_if_fail(session != NULL);
1390 1394
1391 msn_session_destroy(session); 1395 msn_session_destroy(session);
1392 1396
1393 gc->proto_data = NULL; 1397 purple_connection_set_protocol_data(gc, NULL);
1394 } 1398 }
1395 1399
1396 static gboolean 1400 static gboolean
1397 msn_send_me_im(gpointer data) 1401 msn_send_me_im(gpointer data)
1398 { 1402 {
1448 } 1452 }
1449 1453
1450 static void msn_emoticon_destroy(MsnEmoticon *emoticon) 1454 static void msn_emoticon_destroy(MsnEmoticon *emoticon)
1451 { 1455 {
1452 if (emoticon->obj) 1456 if (emoticon->obj)
1453 msn_object_destroy(emoticon->obj); 1457 msn_object_destroy(emoticon->obj, FALSE);
1454 g_free(emoticon->smile); 1458 g_free(emoticon->smile);
1455 g_free(emoticon); 1459 g_free(emoticon);
1456 } 1460 }
1457 1461
1458 static GSList* msn_msg_grab_emoticons(const char *msg, const char *username) 1462 static GSList* msn_msg_grab_emoticons(const char *msg, const char *username)
1521 static int 1525 static int
1522 msn_send_im(PurpleConnection *gc, const char *who, const char *message, 1526 msn_send_im(PurpleConnection *gc, const char *who, const char *message,
1523 PurpleMessageFlags flags) 1527 PurpleMessageFlags flags)
1524 { 1528 {
1525 PurpleAccount *account; 1529 PurpleAccount *account;
1526 PurpleBuddy *buddy = purple_find_buddy(gc->account, who); 1530 PurpleBuddy *buddy = purple_find_buddy(purple_connection_get_account(gc), who);
1527 MsnSession *session; 1531 MsnSession *session;
1528 MsnSwitchBoard *swboard; 1532 MsnSwitchBoard *swboard;
1529 MsnMessage *msg; 1533 MsnMessage *msg;
1530 char *msgformat; 1534 char *msgformat;
1531 char *msgtext; 1535 char *msgtext;
1534 1538
1535 purple_debug_info("msn", "send IM {%s} to %s\n", message, who); 1539 purple_debug_info("msn", "send IM {%s} to %s\n", message, who);
1536 account = purple_connection_get_account(gc); 1540 account = purple_connection_get_account(gc);
1537 username = purple_account_get_username(account); 1541 username = purple_account_get_username(account);
1538 1542
1539 session = gc->proto_data; 1543 session = purple_connection_get_protocol_data(gc);
1540 swboard = msn_session_find_swboard(session, who); 1544 swboard = msn_session_find_swboard(session, who);
1541 1545
1542 if (!strncmp("tel:+", who, 5)) { 1546 if (!strncmp("tel:+", who, 5)) {
1543 char *text = purple_markup_strip_html(message); 1547 char *text = purple_markup_strip_html(message);
1544 send_to_mobile(gc, who, text); 1548 send_to_mobile(gc, who, text);
1640 MsnSession *session; 1644 MsnSession *session;
1641 MsnSwitchBoard *swboard; 1645 MsnSwitchBoard *swboard;
1642 MsnMessage *msg; 1646 MsnMessage *msg;
1643 1647
1644 account = purple_connection_get_account(gc); 1648 account = purple_connection_get_account(gc);
1645 session = gc->proto_data; 1649 session = purple_connection_get_protocol_data(gc);
1646 1650
1647 /* 1651 /*
1648 * TODO: I feel like this should be "if (state != PURPLE_TYPING)" 1652 * TODO: I feel like this should be "if (state != PURPLE_TYPING)"
1649 * but this is how it was before, and I don't want to break 1653 * but this is how it was before, and I don't want to break
1650 * anything. --KingAnt 1654 * anything. --KingAnt
1689 1693
1690 gc = purple_account_get_connection(account); 1694 gc = purple_account_get_connection(account);
1691 1695
1692 if (gc != NULL) 1696 if (gc != NULL)
1693 { 1697 {
1694 session = gc->proto_data; 1698 session = purple_connection_get_protocol_data(gc);
1695 msn_change_status(session); 1699 msn_change_status(session);
1696 } 1700 }
1697 } 1701 }
1698 1702
1699 static void 1703 static void
1700 msn_set_idle(PurpleConnection *gc, int idle) 1704 msn_set_idle(PurpleConnection *gc, int idle)
1701 { 1705 {
1702 MsnSession *session; 1706 MsnSession *session;
1703 1707
1704 session = gc->proto_data; 1708 session = purple_connection_get_protocol_data(gc);
1705 1709
1706 msn_change_status(session); 1710 msn_change_status(session);
1707 } 1711 }
1708 1712
1709 /* 1713 /*
1829 msn_rem_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) 1833 msn_rem_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
1830 { 1834 {
1831 MsnSession *session; 1835 MsnSession *session;
1832 MsnUserList *userlist; 1836 MsnUserList *userlist;
1833 1837
1834 session = gc->proto_data; 1838 session = purple_connection_get_protocol_data(gc);
1835 userlist = session->userlist; 1839 userlist = session->userlist;
1836 1840
1837 if (!session->logged_in) 1841 if (!session->logged_in)
1838 return; 1842 return;
1839 1843
1846 { 1850 {
1847 MsnSession *session; 1851 MsnSession *session;
1848 MsnUserList *userlist; 1852 MsnUserList *userlist;
1849 MsnUser *user; 1853 MsnUser *user;
1850 1854
1851 session = gc->proto_data; 1855 session = purple_connection_get_protocol_data(gc);
1852 userlist = session->userlist; 1856 userlist = session->userlist;
1853 user = msn_userlist_find_user(userlist, who); 1857 user = msn_userlist_find_user(userlist, who);
1854 1858
1855 if (!session->logged_in) 1859 if (!session->logged_in)
1856 return; 1860 return;
1874 { 1878 {
1875 MsnSession *session; 1879 MsnSession *session;
1876 MsnUserList *userlist; 1880 MsnUserList *userlist;
1877 MsnUser *user; 1881 MsnUser *user;
1878 1882
1879 session = gc->proto_data; 1883 session = purple_connection_get_protocol_data(gc);
1880 userlist = session->userlist; 1884 userlist = session->userlist;
1881 user = msn_userlist_find_user(userlist, who); 1885 user = msn_userlist_find_user(userlist, who);
1882 1886
1883 if (!session->logged_in) 1887 if (!session->logged_in)
1884 return; 1888 return;
1901 { 1905 {
1902 MsnSession *session; 1906 MsnSession *session;
1903 MsnUserList *userlist; 1907 MsnUserList *userlist;
1904 MsnUser *user; 1908 MsnUser *user;
1905 1909
1906 session = gc->proto_data; 1910 session = purple_connection_get_protocol_data(gc);
1907 userlist = session->userlist; 1911 userlist = session->userlist;
1908 1912
1909 if (!session->logged_in) 1913 if (!session->logged_in)
1910 return; 1914 return;
1911 1915
1924 { 1928 {
1925 MsnSession *session; 1929 MsnSession *session;
1926 MsnUserList *userlist; 1930 MsnUserList *userlist;
1927 MsnUser *user; 1931 MsnUser *user;
1928 1932
1929 session = gc->proto_data; 1933 session = purple_connection_get_protocol_data(gc);
1930 userlist = session->userlist; 1934 userlist = session->userlist;
1931 1935
1932 if (!session->logged_in) 1936 if (!session->logged_in)
1933 return; 1937 return;
1934 1938
1953 const char *who) 1957 const char *who)
1954 { 1958 {
1955 MsnSession *session; 1959 MsnSession *session;
1956 MsnSwitchBoard *swboard; 1960 MsnSwitchBoard *swboard;
1957 1961
1958 session = gc->proto_data; 1962 session = purple_connection_get_protocol_data(gc);
1959 1963
1960 swboard = msn_session_find_swboard_with_id(session, id); 1964 swboard = msn_session_find_swboard_with_id(session, id);
1961 1965
1962 if (swboard == NULL) 1966 if (swboard == NULL)
1963 { 1967 {
1978 { 1982 {
1979 MsnSession *session; 1983 MsnSession *session;
1980 MsnSwitchBoard *swboard; 1984 MsnSwitchBoard *swboard;
1981 PurpleConversation *conv; 1985 PurpleConversation *conv;
1982 1986
1983 session = gc->proto_data; 1987 session = purple_connection_get_protocol_data(gc);
1984 1988
1985 swboard = msn_session_find_swboard_with_id(session, id); 1989 swboard = msn_session_find_swboard_with_id(session, id);
1986 1990
1987 /* if swboard is NULL we were the only person left anyway */ 1991 /* if swboard is NULL we were the only person left anyway */
1988 if (swboard == NULL) 1992 if (swboard == NULL)
2015 MsnEmoticon *smile; 2019 MsnEmoticon *smile;
2016 GSList *smileys; 2020 GSList *smileys;
2017 GString *emoticons = NULL; 2021 GString *emoticons = NULL;
2018 2022
2019 account = purple_connection_get_account(gc); 2023 account = purple_connection_get_account(gc);
2020 session = gc->proto_data; 2024 session = purple_connection_get_protocol_data(gc);
2021 username = purple_account_get_username(account); 2025 username = purple_account_get_username(account);
2022 swboard = msn_session_find_swboard_with_id(session, id); 2026 swboard = msn_session_find_swboard_with_id(session, id);
2023 2027
2024 if (swboard == NULL) 2028 if (swboard == NULL)
2025 return -EINVAL; 2029 return -EINVAL;
2081 msn_keepalive(PurpleConnection *gc) 2085 msn_keepalive(PurpleConnection *gc)
2082 { 2086 {
2083 MsnSession *session; 2087 MsnSession *session;
2084 MsnTransaction *trans; 2088 MsnTransaction *trans;
2085 2089
2086 session = gc->proto_data; 2090 session = purple_connection_get_protocol_data(gc);
2087 2091
2088 if (!session->http_method) 2092 if (!session->http_method)
2089 { 2093 {
2090 MsnCmdProc *cmdproc; 2094 MsnCmdProc *cmdproc;
2091 2095
2099 2103
2100 static void msn_alias_buddy(PurpleConnection *pc, const char *name, const char *alias) 2104 static void msn_alias_buddy(PurpleConnection *pc, const char *name, const char *alias)
2101 { 2105 {
2102 MsnSession *session; 2106 MsnSession *session;
2103 2107
2104 session = pc->proto_data; 2108 session = purple_connection_get_protocol_data(pc);
2105 2109
2106 msn_update_contact(session, name, MSN_UPDATE_ALIAS, alias); 2110 msn_update_contact(session, name, MSN_UPDATE_ALIAS, alias);
2107 } 2111 }
2108 2112
2109 static void 2113 static void
2111 const char *old_group_name, const char *new_group_name) 2115 const char *old_group_name, const char *new_group_name)
2112 { 2116 {
2113 MsnSession *session; 2117 MsnSession *session;
2114 MsnUserList *userlist; 2118 MsnUserList *userlist;
2115 2119
2116 session = gc->proto_data; 2120 session = purple_connection_get_protocol_data(gc);
2117 userlist = session->userlist; 2121 userlist = session->userlist;
2118 2122
2119 msn_userlist_move_buddy(userlist, who, old_group_name, new_group_name); 2123 msn_userlist_move_buddy(userlist, who, old_group_name, new_group_name);
2120 } 2124 }
2121 2125
2124 PurpleGroup *group, GList *moved_buddies) 2128 PurpleGroup *group, GList *moved_buddies)
2125 { 2129 {
2126 MsnSession *session; 2130 MsnSession *session;
2127 const char *gname; 2131 const char *gname;
2128 2132
2129 session = gc->proto_data; 2133 session = purple_connection_get_protocol_data(gc);
2130 2134
2131 g_return_if_fail(session != NULL); 2135 g_return_if_fail(session != NULL);
2132 g_return_if_fail(session->userlist != NULL); 2136 g_return_if_fail(session->userlist != NULL);
2133 2137
2134 gname = purple_group_get_name(group); 2138 gname = purple_group_get_name(group);
2148 { 2152 {
2149 MsnSession *session; 2153 MsnSession *session;
2150 MsnSwitchBoard *swboard; 2154 MsnSwitchBoard *swboard;
2151 PurpleConversation *conv; 2155 PurpleConversation *conv;
2152 2156
2153 session = gc->proto_data; 2157 session = purple_connection_get_protocol_data(gc);
2154 2158
2155 swboard = msn_session_find_swboard(session, who); 2159 swboard = msn_session_find_swboard(session, who);
2156 2160
2157 /* 2161 /*
2158 * Don't perform an assertion here. If swboard is NULL, then the 2162 * Don't perform an assertion here. If swboard is NULL, then the
2184 msn_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img) 2188 msn_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img)
2185 { 2189 {
2186 MsnSession *session; 2190 MsnSession *session;
2187 MsnUser *user; 2191 MsnUser *user;
2188 2192
2189 session = gc->proto_data; 2193 session = purple_connection_get_protocol_data(gc);
2190 user = session->user; 2194 user = session->user;
2191 2195
2192 msn_user_set_buddy_icon(user, img); 2196 msn_user_set_buddy_icon(user, img);
2193 2197
2194 msn_change_status(session); 2198 msn_change_status(session);
2198 msn_remove_group(PurpleConnection *gc, PurpleGroup *group) 2202 msn_remove_group(PurpleConnection *gc, PurpleGroup *group)
2199 { 2203 {
2200 MsnSession *session; 2204 MsnSession *session;
2201 const char *gname; 2205 const char *gname;
2202 2206
2203 session = gc->proto_data; 2207 session = purple_connection_get_protocol_data(gc);
2204 gname = purple_group_get_name(group); 2208 gname = purple_group_get_name(group);
2205 2209
2206 purple_debug_info("msn", "Remove group %s\n", gname); 2210 purple_debug_info("msn", "Remove group %s\n", gname);
2207 /*we can't delete the default group*/ 2211 /*we can't delete the default group*/
2208 if(!strcmp(gname, MSN_INDIVIDUALS_GROUP_NAME)|| 2212 if(!strcmp(gname, MSN_INDIVIDUALS_GROUP_NAME)||
2239 2243
2240 if ((alias = purple_buddy_get_server_alias(b)) != NULL) 2244 if ((alias = purple_buddy_get_server_alias(b)) != NULL)
2241 { 2245 {
2242 char *nicktext = g_markup_escape_text(alias, -1); 2246 char *nicktext = g_markup_escape_text(alias, -1);
2243 tmp = g_strdup_printf("<font sml=\"msn\">%s</font>", nicktext); 2247 tmp = g_strdup_printf("<font sml=\"msn\">%s</font>", nicktext);
2244 purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp); 2248 purple_notify_user_info_add_pair_html(user_info, _("Nickname"), tmp);
2245 g_free(tmp); 2249 g_free(tmp);
2246 g_free(nicktext); 2250 g_free(nicktext);
2247 } 2251 }
2248 2252
2249 /* Add the tooltip information */ 2253 /* Add the tooltip information */
2338 user_info = purple_notify_user_info_new(); 2342 user_info = purple_notify_user_info_new();
2339 has_tooltip_text = msn_tooltip_extract_info_text(user_info, info_data); 2343 has_tooltip_text = msn_tooltip_extract_info_text(user_info, info_data);
2340 2344
2341 if (error_message != NULL || url_text == NULL || strcmp(url_text, "") == 0) 2345 if (error_message != NULL || url_text == NULL || strcmp(url_text, "") == 0)
2342 { 2346 {
2343 purple_notify_user_info_add_pair(user_info, 2347 purple_notify_user_info_add_pair_html(user_info,
2344 _("Error retrieving profile"), NULL); 2348 _("Error retrieving profile"), NULL);
2345 2349
2346 purple_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL); 2350 purple_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL);
2347 purple_notify_user_info_destroy(user_info); 2351 purple_notify_user_info_destroy(user_info);
2348 2352
2657 2661
2658 /* If we were able to fetch a homepage url earlier, stick it in there */ 2662 /* If we were able to fetch a homepage url earlier, stick it in there */
2659 if (user_url != NULL) 2663 if (user_url != NULL)
2660 { 2664 {
2661 tmp = g_strdup_printf("<a href=\"%s\">%s</a>", user_url, user_url); 2665 tmp = g_strdup_printf("<a href=\"%s\">%s</a>", user_url, user_url);
2662 purple_notify_user_info_add_pair(user_info, _("Homepage"), tmp); 2666 purple_notify_user_info_add_pair_html(user_info, _("Homepage"), tmp);
2663 g_free(tmp); 2667 g_free(tmp);
2664 g_free(user_url); 2668 g_free(user_url);
2665 2669
2666 has_info = TRUE; 2670 has_info = TRUE;
2667 } 2671 }
2680 char *p = strstr(url_buffer, "form id=\"SpacesSearch\" name=\"SpacesSearch\""); 2684 char *p = strstr(url_buffer, "form id=\"SpacesSearch\" name=\"SpacesSearch\"");
2681 * Let's see how long this one holds out for ... */ 2685 * Let's see how long this one holds out for ... */
2682 char *p = strstr(url_buffer, "<form id=\"profile_form\" name=\"profile_form\" action=\"http&#58;&#47;&#47;spaces.live.com&#47;profile.aspx&#63;cid&#61;0\""); 2686 char *p = strstr(url_buffer, "<form id=\"profile_form\" name=\"profile_form\" action=\"http&#58;&#47;&#47;spaces.live.com&#47;profile.aspx&#63;cid&#61;0\"");
2683 PurpleBuddy *b = purple_find_buddy 2687 PurpleBuddy *b = purple_find_buddy
2684 (purple_connection_get_account(info_data->gc), info_data->name); 2688 (purple_connection_get_account(info_data->gc), info_data->name);
2685 purple_notify_user_info_add_pair(user_info, 2689 purple_notify_user_info_add_pair_html(user_info,
2686 _("Error retrieving profile"), NULL); 2690 _("Error retrieving profile"), NULL);
2687 purple_notify_user_info_add_pair(user_info, NULL, 2691 purple_notify_user_info_add_pair_plaintext(user_info, NULL,
2688 ((p && b) ? _("The user has not created a public profile.") : 2692 ((p && b) ? _("The user has not created a public profile.") :
2689 (p ? _("MSN reported not being able to find the user's profile. " 2693 (p ? _("MSN reported not being able to find the user's profile. "
2690 "This either means that the user does not exist, " 2694 "This either means that the user does not exist, "
2691 "or that the user exists " 2695 "or that the user exists "
2692 "but has not created a public profile.") : 2696 "but has not created a public profile.") :
2697 2701
2698 /* put a link to the actual profile URL */ 2702 /* put a link to the actual profile URL */
2699 purple_notify_user_info_add_section_break(user_info); 2703 purple_notify_user_info_add_section_break(user_info);
2700 tmp = g_strdup_printf("<a href=\"%s%s\">%s</a>", 2704 tmp = g_strdup_printf("<a href=\"%s%s\">%s</a>",
2701 PROFILE_URL, info_data->name, _("View web profile")); 2705 PROFILE_URL, info_data->name, _("View web profile"));
2702 purple_notify_user_info_add_pair(user_info, NULL, tmp); 2706 purple_notify_user_info_add_pair_html(user_info, NULL, tmp);
2703 g_free(tmp); 2707 g_free(tmp);
2704 2708
2705 #if PHOTO_SUPPORT 2709 #if PHOTO_SUPPORT
2706 /* Find the URL to the photo; must be before the marshalling [Bug 994207] */ 2710 /* Find the URL to the photo; must be before the marshalling [Bug 994207] */
2707 photo_url_text = msn_get_photo_url(url_text); 2711 photo_url_text = msn_get_photo_url(url_text);
2716 info2_data->photo_url_text = photo_url_text; 2720 info2_data->photo_url_text = photo_url_text;
2717 2721
2718 /* Try to put the photo in there too, if there's one */ 2722 /* Try to put the photo in there too, if there's one */
2719 if (photo_url_text) 2723 if (photo_url_text)
2720 { 2724 {
2721 url_data = purple_util_fetch_url_len(photo_url_text, FALSE, NULL, FALSE, 2725 url_data = purple_util_fetch_url(photo_url_text, FALSE, NULL, FALSE,
2722 MAX_HTTP_BUDDYICON_BYTES, 2726 MAX_HTTP_BUDDYICON_BYTES,
2723 msn_got_photo, info2_data); 2727 msn_got_photo, info2_data);
2724 session->url_datas = g_slist_prepend(session->url_datas, url_data); 2728 session->url_datas = g_slist_prepend(session->url_datas, url_data);
2725 } 2729 }
2726 else 2730 else
2778 { 2782 {
2779 char buf[1024]; 2783 char buf[1024];
2780 purple_debug_info("msn", "%s is %" G_GSIZE_FORMAT " bytes\n", photo_url_text, len); 2784 purple_debug_info("msn", "%s is %" G_GSIZE_FORMAT " bytes\n", photo_url_text, len);
2781 id = purple_imgstore_add_with_id(g_memdup(url_text, len), len, NULL); 2785 id = purple_imgstore_add_with_id(g_memdup(url_text, len), len, NULL);
2782 g_snprintf(buf, sizeof(buf), "<img id=\"%d\"><br>", id); 2786 g_snprintf(buf, sizeof(buf), "<img id=\"%d\"><br>", id);
2783 purple_notify_user_info_prepend_pair(user_info, NULL, buf); 2787 purple_notify_user_info_prepend_pair_html(user_info, NULL, buf);
2784 } 2788 }
2785 } 2789 }
2786 2790
2787 /* We continue here from msn_got_info, as if nothing has happened */ 2791 /* We continue here from msn_got_info, as if nothing has happened */
2788 #endif 2792 #endif
2815 2819
2816 url = g_strdup_printf("%s%s", PROFILE_URL, name); 2820 url = g_strdup_printf("%s%s", PROFILE_URL, name);
2817 2821
2818 url_data = purple_util_fetch_url(url, FALSE, 2822 url_data = purple_util_fetch_url(url, FALSE,
2819 "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)", 2823 "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)",
2820 TRUE, msn_got_info, data); 2824 TRUE, -1, msn_got_info, data);
2821 session->url_datas = g_slist_prepend(session->url_datas, url_data); 2825 session->url_datas = g_slist_prepend(session->url_datas, url_data);
2822 2826
2823 g_free(url); 2827 g_free(url);
2824 } 2828 }
2825 2829
2904 } 2908 }
2905 2909
2906 2910
2907 static PurplePluginProtocolInfo prpl_info = 2911 static PurplePluginProtocolInfo prpl_info =
2908 { 2912 {
2913 sizeof(PurplePluginProtocolInfo), /* struct_size */
2909 OPT_PROTO_MAIL_CHECK|OPT_PROTO_INVITE_MESSAGE, 2914 OPT_PROTO_MAIL_CHECK|OPT_PROTO_INVITE_MESSAGE,
2910 NULL, /* user_splits */ 2915 NULL, /* user_splits */
2911 NULL, /* protocol_options */ 2916 NULL, /* protocol_options */
2912 {"png,gif", 0, 0, 96, 96, 0, PURPLE_ICON_SCALE_SEND}, /* icon_spec */ 2917 {"png,gif", 0, 0, 96, 96, 0, PURPLE_ICON_SCALE_SEND}, /* icon_spec */
2913 msn_list_icon, /* list_icon */ 2918 msn_list_icon, /* list_icon */
2925 msn_send_typing, /* send_typing */ 2930 msn_send_typing, /* send_typing */
2926 msn_get_info, /* get_info */ 2931 msn_get_info, /* get_info */
2927 msn_set_status, /* set_away */ 2932 msn_set_status, /* set_away */
2928 msn_set_idle, /* set_idle */ 2933 msn_set_idle, /* set_idle */
2929 NULL, /* change_passwd */ 2934 NULL, /* change_passwd */
2930 NULL, /* add_buddy */ 2935 msn_add_buddy, /* add_buddy */
2931 NULL, /* add_buddies */ 2936 NULL, /* add_buddies */
2932 msn_rem_buddy, /* remove_buddy */ 2937 msn_rem_buddy, /* remove_buddy */
2933 NULL, /* remove_buddies */ 2938 NULL, /* remove_buddies */
2934 msn_add_permit, /* add_permit */ 2939 msn_add_permit, /* add_permit */
2935 msn_add_deny, /* add_deny */ 2940 msn_add_deny, /* add_deny */
2944 NULL, /* chat_whisper */ 2949 NULL, /* chat_whisper */
2945 msn_chat_send, /* chat_send */ 2950 msn_chat_send, /* chat_send */
2946 msn_keepalive, /* keepalive */ 2951 msn_keepalive, /* keepalive */
2947 NULL, /* register_user */ 2952 NULL, /* register_user */
2948 NULL, /* get_cb_info */ 2953 NULL, /* get_cb_info */
2949 NULL, /* get_cb_away */
2950 msn_alias_buddy, /* alias_buddy */ 2954 msn_alias_buddy, /* alias_buddy */
2951 msn_group_buddy, /* group_buddy */ 2955 msn_group_buddy, /* group_buddy */
2952 msn_rename_group, /* rename_group */ 2956 msn_rename_group, /* rename_group */
2953 NULL, /* buddy_free */ 2957 NULL, /* buddy_free */
2954 msn_convo_closed, /* convo_closed */ 2958 msn_convo_closed, /* convo_closed */
2969 NULL, /* send_raw */ 2973 NULL, /* send_raw */
2970 NULL, /* roomlist_room_serialize */ 2974 NULL, /* roomlist_room_serialize */
2971 NULL, /* unregister_user */ 2975 NULL, /* unregister_user */
2972 msn_send_attention, /* send_attention */ 2976 msn_send_attention, /* send_attention */
2973 msn_attention_types, /* attention_types */ 2977 msn_attention_types, /* attention_types */
2974 sizeof(PurplePluginProtocolInfo), /* struct_size */
2975 msn_get_account_text_table, /* get_account_text_table */ 2978 msn_get_account_text_table, /* get_account_text_table */
2976 NULL, /* initiate_media */ 2979 NULL, /* initiate_media */
2977 NULL, /* get_media_caps */ 2980 NULL, /* get_media_caps */
2978 NULL, /* get_moods */ 2981 NULL, /* get_moods */
2979 msn_set_public_alias, /* set_public_alias */ 2982 msn_set_public_alias, /* set_public_alias */
2980 msn_get_public_alias, /* get_public_alias */ 2983 msn_get_public_alias /* get_public_alias */
2981 msn_add_buddy, /* add_buddy_with_invite */
2982 NULL /* add_buddies_with_invite */
2983 }; 2984 };
2984 2985
2985 static PurplePluginInfo info = 2986 static PurplePluginInfo info =
2986 { 2987 {
2987 PURPLE_PLUGIN_MAGIC, 2988 PURPLE_PLUGIN_MAGIC,