comparison libpurple/protocols/oscar/oscar.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 069919a0896c
children
comparison
equal deleted inserted replaced
32818:01ff09d4a463 32819:2c6510167895
53 #include "oscar.h" 53 #include "oscar.h"
54 #include "peer.h" 54 #include "peer.h"
55 55
56 #define AIMHASHDATA "http://pidgin.im/aim_data.php3" 56 #define AIMHASHDATA "http://pidgin.im/aim_data.php3"
57 57
58 #define OSCAR_CONNECT_STEPS 6
59
60 static guint64 purple_caps = 58 static guint64 purple_caps =
61 OSCAR_CAPABILITY_CHAT 59 OSCAR_CAPABILITY_CHAT
62 | OSCAR_CAPABILITY_BUDDYICON 60 | OSCAR_CAPABILITY_BUDDYICON
63 | OSCAR_CAPABILITY_DIRECTIM 61 | OSCAR_CAPABILITY_DIRECTIM
64 | OSCAR_CAPABILITY_SENDFILE 62 | OSCAR_CAPABILITY_SENDFILE
87 85
88 /* All the libfaim->purple callback functions */ 86 /* All the libfaim->purple callback functions */
89 87
90 /* Only used when connecting with the old-style BUCP login */ 88 /* Only used when connecting with the old-style BUCP login */
91 static int purple_parse_auth_resp (OscarData *, FlapConnection *, FlapFrame *, ...); 89 static int purple_parse_auth_resp (OscarData *, FlapConnection *, FlapFrame *, ...);
92 static int purple_parse_login (OscarData *, FlapConnection *, FlapFrame *, ...);
93 static int purple_parse_auth_securid_request(OscarData *, FlapConnection *, FlapFrame *, ...); 90 static int purple_parse_auth_securid_request(OscarData *, FlapConnection *, FlapFrame *, ...);
94 91
95 static int purple_handle_redirect (OscarData *, FlapConnection *, FlapFrame *, ...); 92 static int purple_handle_redirect (OscarData *, FlapConnection *, FlapFrame *, ...);
96 static int purple_info_change (OscarData *, FlapConnection *, FlapFrame *, ...); 93 static int purple_info_change (OscarData *, FlapConnection *, FlapFrame *, ...);
97 static int purple_account_confirm (OscarData *, FlapConnection *, FlapFrame *, ...); 94 static int purple_account_confirm (OscarData *, FlapConnection *, FlapFrame *, ...);
306 { 303 {
307 /* This only happens when connecting with the old-style BUCP login */ 304 /* This only happens when connecting with the old-style BUCP login */
308 gchar *msg; 305 gchar *msg;
309 msg = g_strdup_printf(_("Unable to connect to authentication server: %s"), 306 msg = g_strdup_printf(_("Unable to connect to authentication server: %s"),
310 error_message); 307 error_message);
311 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); 308 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
312 g_free(msg); 309 g_free(msg);
313 } 310 }
314 else if (conn->type == SNAC_FAMILY_LOCATE) 311 else if (conn->type == SNAC_FAMILY_LOCATE)
315 { 312 {
316 gchar *msg; 313 gchar *msg;
317 msg = g_strdup_printf(_("Unable to connect to BOS server: %s"), 314 msg = g_strdup_printf(_("Unable to connect to BOS server: %s"),
318 error_message); 315 error_message);
319 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); 316 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
320 g_free(msg); 317 g_free(msg);
321 } 318 }
322 else 319 else
323 { 320 {
324 /* Maybe we should call this for BOS connections, too? */ 321 /* Maybe we should call this for BOS connections, too? */
576 guint32 presence; 573 guint32 presence;
577 574
578 gc = data; 575 gc = data;
579 od = purple_connection_get_protocol_data(gc); 576 od = purple_connection_get_protocol_data(gc);
580 report_idle = strcmp((const char *)value, "none") != 0; 577 report_idle = strcmp((const char *)value, "none") != 0;
581 presence = aim_ssi_getpresence(od->ssi.local); 578 presence = aim_ssi_getpresence(&od->ssi.local);
582 579
583 if (report_idle) 580 if (report_idle)
584 aim_ssi_setpresence(od, presence | AIM_SSI_PRESENCE_FLAG_SHOWIDLE); 581 aim_ssi_setpresence(od, presence | AIM_SSI_PRESENCE_FLAG_SHOWIDLE);
585 else 582 else
586 aim_ssi_setpresence(od, presence & ~AIM_SSI_PRESENCE_FLAG_SHOWIDLE); 583 aim_ssi_setpresence(od, presence & ~AIM_SSI_PRESENCE_FLAG_SHOWIDLE);
598 OscarData *od; 595 OscarData *od;
599 guint32 presence; 596 guint32 presence;
600 597
601 gc = data; 598 gc = data;
602 od = purple_connection_get_protocol_data(gc); 599 od = purple_connection_get_protocol_data(gc);
603 presence = aim_ssi_getpresence(od->ssi.local); 600 presence = aim_ssi_getpresence(&od->ssi.local);
604 601
605 if (value) 602 if (value)
606 aim_ssi_setpresence(od, presence & ~AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES); 603 aim_ssi_setpresence(od, presence & ~AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES);
607 else 604 else
608 aim_ssi_setpresence(od, presence | AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES); 605 aim_ssi_setpresence(od, presence | AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES);
653 const gchar *encryption_type; 650 const gchar *encryption_type;
654 GList *handlers; 651 GList *handlers;
655 GList *sorted_handlers; 652 GList *sorted_handlers;
656 GList *cur; 653 GList *cur;
657 GString *msg = g_string_new(""); 654 GString *msg = g_string_new("");
655 PurpleConnectionFlags flags;
658 656
659 gc = purple_account_get_connection(account); 657 gc = purple_account_get_connection(account);
660 od = oscar_data_new(); 658 od = oscar_data_new();
661 od->gc = gc; 659 od->gc = gc;
662 purple_connection_set_protocol_data(gc, od); 660 purple_connection_set_protocol_data(gc, od);
670 oscar_data_addhandler(od, SNAC_FAMILY_ALERT, 0x0001, purple_parse_genericerr, 0); 668 oscar_data_addhandler(od, SNAC_FAMILY_ALERT, 0x0001, purple_parse_genericerr, 0);
671 oscar_data_addhandler(od, SNAC_FAMILY_ALERT, SNAC_SUBTYPE_ALERT_MAILSTATUS, purple_email_parseupdate, 0); 669 oscar_data_addhandler(od, SNAC_FAMILY_ALERT, SNAC_SUBTYPE_ALERT_MAILSTATUS, purple_email_parseupdate, 0);
672 670
673 /* These are only needed when connecting with the old-style BUCP login */ 671 /* These are only needed when connecting with the old-style BUCP login */
674 oscar_data_addhandler(od, SNAC_FAMILY_AUTH, 0x0003, purple_parse_auth_resp, 0); 672 oscar_data_addhandler(od, SNAC_FAMILY_AUTH, 0x0003, purple_parse_auth_resp, 0);
675 oscar_data_addhandler(od, SNAC_FAMILY_AUTH, 0x0007, purple_parse_login, 0);
676 oscar_data_addhandler(od, SNAC_FAMILY_AUTH, SNAC_SUBTYPE_AUTH_SECURID_REQUEST, purple_parse_auth_securid_request, 0); 673 oscar_data_addhandler(od, SNAC_FAMILY_AUTH, SNAC_SUBTYPE_AUTH_SECURID_REQUEST, purple_parse_auth_securid_request, 0);
677 674
678 oscar_data_addhandler(od, SNAC_FAMILY_BART, SNAC_SUBTYPE_BART_RESPONSE, purple_icon_parseicon, 0); 675 oscar_data_addhandler(od, SNAC_FAMILY_BART, SNAC_SUBTYPE_BART_RESPONSE, purple_icon_parseicon, 0);
679 oscar_data_addhandler(od, SNAC_FAMILY_BOS, 0x0001, purple_parse_genericerr, 0); 676 oscar_data_addhandler(od, SNAC_FAMILY_BOS, 0x0001, purple_parse_genericerr, 0);
680 oscar_data_addhandler(od, SNAC_FAMILY_BOS, 0x0003, purple_bosrights, 0); 677 oscar_data_addhandler(od, SNAC_FAMILY_BOS, 0x0003, purple_bosrights, 0);
733 purple_debug_misc("oscar", "oscar_login: gc = %p\n", gc); 730 purple_debug_misc("oscar", "oscar_login: gc = %p\n", gc);
734 731
735 if (!oscar_util_valid_name(purple_account_get_username(account))) { 732 if (!oscar_util_valid_name(purple_account_get_username(account))) {
736 gchar *buf; 733 gchar *buf;
737 buf = g_strdup_printf(_("Unable to sign on as %s because the username is invalid. Usernames must be a valid email address, or start with a letter and contain only letters, numbers and spaces, or contain only numbers."), purple_account_get_username(account)); 734 buf = g_strdup_printf(_("Unable to sign on as %s because the username is invalid. Usernames must be a valid email address, or start with a letter and contain only letters, numbers and spaces, or contain only numbers."), purple_account_get_username(account));
738 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, buf); 735 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, buf);
739 g_free(buf); 736 g_free(buf);
740 return; 737 return;
741 } 738 }
742 739
743 gc->flags |= PURPLE_CONNECTION_HTML; 740 flags = PURPLE_CONNECTION_HTML;
744 if (g_str_equal(purple_account_get_protocol_id(account), "prpl-icq")) { 741 if (g_str_equal(purple_account_get_protocol_id(account), "prpl-icq")) {
745 od->icq = TRUE; 742 od->icq = TRUE;
746 } else { 743 } else {
747 gc->flags |= PURPLE_CONNECTION_AUTO_RESP; 744 flags |= PURPLE_CONNECTION_AUTO_RESP;
748 } 745 }
749 746
750 /* Set this flag based on the protocol_id rather than the username, 747 /* Set this flag based on the protocol_id rather than the username,
751 because that is what's tied to the get_moods prpl callback. */ 748 because that is what's tied to the get_moods prpl callback. */
752 if (g_str_equal(purple_account_get_protocol_id(account), "prpl-icq")) 749 if (g_str_equal(purple_account_get_protocol_id(account), "prpl-icq"))
753 gc->flags |= PURPLE_CONNECTION_SUPPORT_MOODS; 750 flags |= PURPLE_CONNECTION_SUPPORT_MOODS;
751
752 purple_connection_set_flags(gc, flags);
754 753
755 od->default_port = purple_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT); 754 od->default_port = purple_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT);
756 755
757 encryption_type = purple_account_get_string(account, "encryption", OSCAR_DEFAULT_ENCRYPTION); 756 encryption_type = purple_account_get_string(account, "encryption", OSCAR_DEFAULT_ENCRYPTION);
758 if (!purple_ssl_is_supported() && strcmp(encryption_type, OSCAR_REQUIRE_ENCRYPTION) == 0) { 757 if (!purple_ssl_is_supported() && strcmp(encryption_type, OSCAR_REQUIRE_ENCRYPTION) == 0) {
759 purple_connection_error_reason( 758 purple_connection_error(
760 gc, 759 gc,
761 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, 760 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
762 _("You required encryption in your account settings, but encryption is not supported by your system.")); 761 _("You required encryption in your account settings, but encryption is not supported by your system."));
763 return; 762 return;
764 } 763 }
823 purple_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT), 822 purple_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT),
824 connection_established_cb, newconn); 823 connection_established_cb, newconn);
825 } 824 }
826 825
827 if (newconn->gsc == NULL && newconn->connect_data == NULL) { 826 if (newconn->gsc == NULL && newconn->connect_data == NULL) {
828 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 827 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
829 _("Unable to connect")); 828 _("Unable to connect"));
830 return; 829 return;
831 } 830 }
832 } 831 }
833 832
998 997
999 pos->offset = offset; 998 pos->offset = offset;
1000 pos->len = len; 999 pos->len = len;
1001 pos->modname = g_strdup(modname); 1000 pos->modname = g_strdup(modname);
1002 1001
1003 if (purple_proxy_connect(pos->gc, pos->gc->account, "pidgin.im", 80, 1002 if (purple_proxy_connect(pos->gc, purple_connection_get_account(pos->gc), "pidgin.im", 80,
1004 straight_to_hell, pos) == NULL) 1003 straight_to_hell, pos) == NULL)
1005 { 1004 {
1006 char buf[256]; 1005 char buf[256];
1007 g_free(pos->modname); 1006 g_free(pos->modname);
1008 g_free(pos); 1007 g_free(pos);
1046 connection_established_cb, conn); 1045 connection_established_cb, conn);
1047 } 1046 }
1048 1047
1049 if (conn->gsc == NULL && conn->connect_data == NULL) 1048 if (conn->gsc == NULL && conn->connect_data == NULL)
1050 { 1049 {
1051 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Unable to connect")); 1050 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Unable to connect"));
1052 return 0; 1051 return 0;
1053 } 1052 }
1054 1053
1055 od->default_port = port; 1054 od->default_port = port;
1056 1055
1085 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { 1084 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) {
1086 char buf[256]; 1085 char buf[256];
1087 switch (info->errorcode) { 1086 switch (info->errorcode) {
1088 case 0x01: 1087 case 0x01:
1089 /* Unregistered username */ 1088 /* Unregistered username */
1090 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_INVALID_USERNAME, _("Username does not exist")); 1089 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_INVALID_USERNAME, _("Username does not exist"));
1091 break; 1090 break;
1092 case 0x05: 1091 case 0x05:
1093 /* Incorrect password */ 1092 /* Incorrect password */
1094 if (!purple_account_get_remember_password(account)) 1093 if (!purple_account_get_remember_password(account))
1095 purple_account_set_password(account, NULL); 1094 purple_account_set_password(account, NULL);
1096 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("Incorrect password")); 1095 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("Incorrect password"));
1097 break; 1096 break;
1098 case 0x11: 1097 case 0x11:
1099 /* Suspended account */ 1098 /* Suspended account */
1100 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("Your account is currently suspended")); 1099 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("Your account is currently suspended"));
1101 break; 1100 break;
1102 case 0x02: 1101 case 0x02:
1103 case 0x14: 1102 case 0x14:
1104 /* service temporarily unavailable */ 1103 /* service temporarily unavailable */
1105 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("The AOL Instant Messenger service is temporarily unavailable.")); 1104 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("The AOL Instant Messenger service is temporarily unavailable."));
1106 break; 1105 break;
1107 case 0x18: 1106 case 0x18:
1108 /* username connecting too frequently */ 1107 /* username connecting too frequently */
1109 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, _("Your username has been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.")); 1108 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, _("Your username has been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."));
1110 break; 1109 break;
1111 case 0x1c: 1110 case 0x1c:
1112 { 1111 {
1113 /* client too old */ 1112 /* client too old */
1114 g_snprintf(buf, sizeof(buf), _("The client version you are using is too old. Please upgrade at %s"), 1113 g_snprintf(buf, sizeof(buf), _("The client version you are using is too old. Please upgrade at %s"),
1115 oscar_get_ui_info_string("website", PURPLE_WEBSITE)); 1114 oscar_get_ui_info_string("website", PURPLE_WEBSITE));
1116 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, buf); 1115 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, buf);
1117 break; 1116 break;
1118 } 1117 }
1119 case 0x1d: 1118 case 0x1d:
1120 /* IP address connecting too frequently */ 1119 /* IP address connecting too frequently */
1121 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, _("Your IP address has been connecting and disconnecting too frequently. Wait a minute and try again. If you continue to try, you will need to wait even longer.")); 1120 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, _("Your IP address has been connecting and disconnecting too frequently. Wait a minute and try again. If you continue to try, you will need to wait even longer."));
1122 break; 1121 break;
1123 default: 1122 default:
1124 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("Unknown reason")); 1123 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("Unknown reason"));
1125 break; 1124 break;
1126 } 1125 }
1127 purple_debug_info("oscar", "Login Error Code 0x%04hx\n", info->errorcode); 1126 purple_debug_info("oscar", "Login Error Code 0x%04hx\n", info->errorcode);
1128 purple_debug_info("oscar", "Error URL: %s\n", info->errorurl ? info->errorurl : ""); 1127 purple_debug_info("oscar", "Error URL: %s\n", info->errorurl ? info->errorurl : "");
1129 return 1; 1128 return 1;
1167 } 1166 }
1168 1167
1169 g_free(host); 1168 g_free(host);
1170 if (newconn->gsc == NULL && newconn->connect_data == NULL) 1169 if (newconn->gsc == NULL && newconn->connect_data == NULL)
1171 { 1170 {
1172 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Unable to connect")); 1171 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Unable to connect"));
1173 return 0; 1172 return 0;
1174 } 1173 }
1175 1174
1176 purple_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); 1175 purple_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS);
1177 1176
1197 purple_parse_auth_securid_request_no_cb(gpointer user_data, const char *value) 1196 purple_parse_auth_securid_request_no_cb(gpointer user_data, const char *value)
1198 { 1197 {
1199 PurpleConnection *gc = user_data; 1198 PurpleConnection *gc = user_data;
1200 1199
1201 /* Disconnect */ 1200 /* Disconnect */
1202 purple_connection_error_reason(gc, 1201 purple_connection_error(gc,
1203 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, 1202 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED,
1204 _("The SecurID key entered is invalid")); 1203 _("The SecurID key entered is invalid"));
1205 } 1204 }
1206 1205
1207 /** 1206 /**
1227 g_free(primary); 1226 g_free(primary);
1228 1227
1229 return 1; 1228 return 1;
1230 } 1229 }
1231 1230
1232 /**
1233 * Only used when connecting with the old-style BUCP login.
1234 */
1235 static int
1236 purple_parse_login(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
1237 {
1238 PurpleConnection *gc;
1239 PurpleAccount *account;
1240 ClientInfo aiminfo = CLIENTINFO_PURPLE_AIM;
1241 ClientInfo icqinfo = CLIENTINFO_PURPLE_ICQ;
1242 va_list ap;
1243 char *key;
1244 gboolean truncate_pass;
1245
1246 gc = od->gc;
1247 account = purple_connection_get_account(gc);
1248
1249 va_start(ap, fr);
1250 key = va_arg(ap, char *);
1251 truncate_pass = va_arg(ap, int);
1252 va_end(ap);
1253
1254 aim_send_login(od, conn, purple_account_get_username(account),
1255 purple_connection_get_password(gc), truncate_pass,
1256 od->icq ? &icqinfo : &aiminfo, key,
1257 purple_account_get_bool(account, "allow_multiple_logins", OSCAR_DEFAULT_ALLOW_MULTIPLE_LOGINS));
1258
1259 purple_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS);
1260
1261 return 1;
1262 }
1263
1264 static int 1231 static int
1265 purple_handle_redirect(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) 1232 purple_handle_redirect(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
1266 { 1233 {
1267 PurpleConnection *gc = od->gc; 1234 PurpleConnection *gc = od->gc;
1268 PurpleAccount *account = purple_connection_get_account(gc); 1235 PurpleAccount *account = purple_connection_get_account(gc);
1290 const gchar *encryption_type = purple_account_get_string(account, "encryption", OSCAR_DEFAULT_ENCRYPTION); 1257 const gchar *encryption_type = purple_account_get_string(account, "encryption", OSCAR_DEFAULT_ENCRYPTION);
1291 if (strcmp(encryption_type, OSCAR_OPPORTUNISTIC_ENCRYPTION) == 0) { 1258 if (strcmp(encryption_type, OSCAR_OPPORTUNISTIC_ENCRYPTION) == 0) {
1292 purple_debug_warning("oscar", "We won't use SSL for FLAP type 0x%04hx.\n", redir->group); 1259 purple_debug_warning("oscar", "We won't use SSL for FLAP type 0x%04hx.\n", redir->group);
1293 } else if (strcmp(encryption_type, OSCAR_REQUIRE_ENCRYPTION) == 0) { 1260 } else if (strcmp(encryption_type, OSCAR_REQUIRE_ENCRYPTION) == 0) {
1294 purple_debug_error("oscar", "FLAP server %s:%d of type 0x%04hx doesn't support encryption.", host, port, redir->group); 1261 purple_debug_error("oscar", "FLAP server %s:%d of type 0x%04hx doesn't support encryption.", host, port, redir->group);
1295 purple_connection_error_reason( 1262 purple_connection_error(
1296 gc, 1263 gc,
1297 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, 1264 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
1298 _("You required encryption in your account settings, but one of the servers doesn't support it.")); 1265 _("You required encryption in your account settings, but one of the servers doesn't support it."));
1299 return 0; 1266 return 0;
1300 } 1267 }
1545 info = va_arg(ap, aim_userinfo_t *); 1512 info = va_arg(ap, aim_userinfo_t *);
1546 va_end(ap); 1513 va_end(ap);
1547 1514
1548 purple_prpl_got_user_status(account, info->bn, OSCAR_STATUS_ID_OFFLINE, NULL); 1515 purple_prpl_got_user_status(account, info->bn, OSCAR_STATUS_ID_OFFLINE, NULL);
1549 purple_prpl_got_user_status_deactive(account, info->bn, OSCAR_STATUS_ID_MOBILE); 1516 purple_prpl_got_user_status_deactive(account, info->bn, OSCAR_STATUS_ID_MOBILE);
1550 g_hash_table_remove(od->buddyinfo, purple_normalize(gc->account, info->bn)); 1517 g_hash_table_remove(od->buddyinfo, purple_normalize(purple_connection_get_account(gc), info->bn));
1551 1518
1552 return 1; 1519 return 1;
1553 } 1520 }
1554 1521
1555 static int incomingim_chan1(OscarData *od, FlapConnection *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { 1522 static int incomingim_chan1(OscarData *od, FlapConnection *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) {
2276 } 2243 }
2277 2244
2278 return 0; 2245 return 0;
2279 } 2246 }
2280 2247
2281 static int purple_parse_clientauto_ch4(OscarData *od, char *who, guint16 reason, guint32 state, char *msg) { 2248 static int purple_parse_clientauto_ch4(OscarData *od, const char *who, guint16 reason, guint32 state, char *msg) {
2282 PurpleConnection *gc = od->gc; 2249 PurpleConnection *gc = od->gc;
2283 2250
2284 switch(reason) { 2251 switch(reason) {
2285 case 0x0003: { /* Reply from an ICQ status message request */ 2252 case 0x0003: { /* Reply from an ICQ status message request */
2286 char *statusmsg, **splitmsg; 2253 char *statusmsg, **splitmsg;
2287 PurpleNotifyUserInfo *user_info; 2254 PurpleNotifyUserInfo *user_info;
2288 2255
2256 statusmsg = oscar_icqstatus(state);
2257
2289 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ 2258 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */
2290 statusmsg = oscar_icqstatus(state); 2259 /* TODO: Don't we need to escape each piece? */
2291 splitmsg = g_strsplit(msg, "\r\n", 0); 2260 splitmsg = g_strsplit(msg, "\r\n", 0);
2292 2261
2293 user_info = purple_notify_user_info_new(); 2262 user_info = purple_notify_user_info_new();
2294 2263
2295 purple_notify_user_info_add_pair(user_info, _("UIN"), who); 2264 purple_notify_user_info_add_pair_plaintext(user_info, _("UIN"), who);
2296 purple_notify_user_info_add_pair(user_info, _("Status"), statusmsg); 2265 /* TODO: Check whether it's correct to call add_pair_html,
2266 or if we should be using add_pair_plaintext */
2267 purple_notify_user_info_add_pair_html(user_info, _("Status"), statusmsg);
2297 purple_notify_user_info_add_section_break(user_info); 2268 purple_notify_user_info_add_section_break(user_info);
2298 purple_notify_user_info_add_pair(user_info, NULL, g_strjoinv("<BR>", splitmsg)); 2269 purple_notify_user_info_add_pair_html(user_info, NULL, g_strjoinv("<BR>", splitmsg));
2299 2270
2300 g_free(statusmsg); 2271 g_free(statusmsg);
2301 g_strfreev(splitmsg); 2272 g_strfreev(splitmsg);
2302 2273
2303 purple_notify_userinfo(gc, who, user_info, NULL, NULL); 2274 purple_notify_userinfo(gc, who, user_info, NULL, NULL);
2307 2278
2308 case 0x0006: { /* Reply from an ICQ status message request */ 2279 case 0x0006: { /* Reply from an ICQ status message request */
2309 char *statusmsg, **splitmsg; 2280 char *statusmsg, **splitmsg;
2310 PurpleNotifyUserInfo *user_info; 2281 PurpleNotifyUserInfo *user_info;
2311 2282
2283 statusmsg = oscar_icqstatus(state);
2284
2312 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ 2285 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */
2313 statusmsg = oscar_icqstatus(state); 2286 /* TODO: Don't we need to escape each piece? */
2314 splitmsg = g_strsplit(msg, "\r\n", 0); 2287 splitmsg = g_strsplit(msg, "\r\n", 0);
2315 2288
2316 user_info = purple_notify_user_info_new(); 2289 user_info = purple_notify_user_info_new();
2317 2290
2318 purple_notify_user_info_add_pair(user_info, _("UIN"), who); 2291 purple_notify_user_info_add_pair_plaintext(user_info, _("UIN"), who);
2319 purple_notify_user_info_add_pair(user_info, _("Status"), statusmsg); 2292 /* TODO: Check whether it's correct to call add_pair_html,
2293 or if we should be using add_pair_plaintext */
2294 purple_notify_user_info_add_pair_html(user_info, _("Status"), statusmsg);
2320 purple_notify_user_info_add_section_break(user_info); 2295 purple_notify_user_info_add_section_break(user_info);
2321 purple_notify_user_info_add_pair(user_info, NULL, g_strjoinv("<BR>", splitmsg)); 2296 purple_notify_user_info_add_pair_html(user_info, NULL, g_strjoinv("<BR>", splitmsg));
2322 2297
2323 g_free(statusmsg); 2298 g_free(statusmsg);
2324 g_strfreev(splitmsg); 2299 g_strfreev(splitmsg);
2325 2300
2326 purple_notify_userinfo(gc, who, user_info, NULL, NULL); 2301 purple_notify_userinfo(gc, who, user_info, NULL, NULL);
2806 "locate rights: max sig len = %d\n", maxsiglen); 2781 "locate rights: max sig len = %d\n", maxsiglen);
2807 2782
2808 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; 2783 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen;
2809 2784
2810 aim_locate_setcaps(od, purple_caps); 2785 aim_locate_setcaps(od, purple_caps);
2811 oscar_set_info_and_status(account, TRUE, account->user_info, TRUE, 2786 oscar_set_info_and_status(account, TRUE, purple_account_get_user_info(account), TRUE,
2812 purple_account_get_active_status(account)); 2787 purple_account_get_active_status(account));
2813 2788
2814 return 1; 2789 return 1;
2815 } 2790 }
2816 2791
3166 peer_odc_send_typing(conn, state); 3141 peer_odc_send_typing(conn, state);
3167 } 3142 }
3168 else { 3143 else {
3169 /* Don't send if this turkey is in our deny list */ 3144 /* Don't send if this turkey is in our deny list */
3170 GSList *list; 3145 GSList *list;
3171 for (list=gc->account->deny; (list && oscar_util_name_compare(name, list->data)); list=list->next); 3146 for (list=purple_connection_get_account(gc)->deny; (list && oscar_util_name_compare(name, list->data)); list=list->next);
3172 if (!list) { 3147 if (!list) {
3173 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(gc->account, name)); 3148 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(purple_connection_get_account(gc), name));
3174 if (bi && bi->typingnot) { 3149 if (bi && bi->typingnot) {
3175 if (state == PURPLE_TYPING) 3150 if (state == PURPLE_TYPING)
3176 aim_im_sendmtn(od, 0x0001, name, 0x0002); 3151 aim_im_sendmtn(od, 0x0001, name, 0x0002);
3177 else if (state == PURPLE_TYPED) 3152 else if (state == PURPLE_TYPED)
3178 aim_im_sendmtn(od, 0x0001, name, 0x0001); 3153 aim_im_sendmtn(od, 0x0001, name, 0x0001);
3468 } 3443 }
3469 3444
3470 static guint32 3445 static guint32
3471 oscar_get_extended_status(PurpleConnection *gc) 3446 oscar_get_extended_status(PurpleConnection *gc)
3472 { 3447 {
3473 OscarData *od;
3474 PurpleAccount *account; 3448 PurpleAccount *account;
3475 PurpleStatus *status; 3449 PurpleStatus *status;
3476 const gchar *status_id; 3450 const gchar *status_id;
3477 guint32 data = 0x00000000; 3451 guint32 data = 0x00000000;
3478 3452
3479 od = purple_connection_get_protocol_data(gc);
3480 account = purple_connection_get_account(gc); 3453 account = purple_connection_get_account(gc);
3481 status = purple_account_get_active_status(account); 3454 status = purple_account_get_active_status(account);
3482 status_id = purple_status_get_id(status); 3455 status_id = purple_status_get_id(status);
3483 3456
3484 data |= AIM_ICQ_STATE_HIDEIP; 3457 data |= AIM_ICQ_STATE_HIDEIP;
3714 3687
3715 return; 3688 return;
3716 } 3689 }
3717 3690
3718 if (od->ssi.received_data) { 3691 if (od->ssi.received_data) {
3719 if (!aim_ssi_itemlist_finditem(od->ssi.local, gname, bname, AIM_SSI_TYPE_BUDDY)) { 3692 if (!aim_ssi_itemlist_finditem(&od->ssi.local, gname, bname, AIM_SSI_TYPE_BUDDY)) {
3720 purple_debug_info("oscar", 3693 purple_debug_info("oscar",
3721 "ssi: adding buddy %s to group %s\n", bname, gname); 3694 "ssi: adding buddy %s to group %s\n", bname, gname);
3722 aim_ssi_addbuddy(od, bname, gname, NULL, purple_buddy_get_alias_only(buddy), NULL, NULL, 0); 3695 aim_ssi_addbuddy(od, bname, gname, NULL, purple_buddy_get_alias_only(buddy), NULL, NULL, 0);
3723 3696
3724 /* Mobile users should always be online */ 3697 /* Mobile users should always be online */
3726 purple_prpl_got_user_status(account, bname, 3699 purple_prpl_got_user_status(account, bname,
3727 OSCAR_STATUS_ID_AVAILABLE, NULL); 3700 OSCAR_STATUS_ID_AVAILABLE, NULL);
3728 purple_prpl_got_user_status(account, bname, 3701 purple_prpl_got_user_status(account, bname,
3729 OSCAR_STATUS_ID_MOBILE, NULL); 3702 OSCAR_STATUS_ID_MOBILE, NULL);
3730 } 3703 }
3731 } else if (aim_ssi_waitingforauth(od->ssi.local, 3704 } else if (aim_ssi_waitingforauth(&od->ssi.local,
3732 aim_ssi_itemlist_findparentname(od->ssi.local, bname), 3705 aim_ssi_itemlist_findparentname(&od->ssi.local, bname),
3733 bname)) { 3706 bname)) {
3734 /* Not authorized -- Re-request authorization */ 3707 /* Not authorized -- Re-request authorization */
3735 oscar_auth_sendrequest(gc, bname, msg); 3708 oscar_auth_sendrequest(gc, bname, msg);
3736 } 3709 }
3737 } 3710 }
3765 3738
3766 void oscar_alias_buddy(PurpleConnection *gc, const char *name, const char *alias) { 3739 void oscar_alias_buddy(PurpleConnection *gc, const char *name, const char *alias) {
3767 OscarData *od = purple_connection_get_protocol_data(gc); 3740 OscarData *od = purple_connection_get_protocol_data(gc);
3768 3741
3769 if (od->ssi.received_data) { 3742 if (od->ssi.received_data) {
3770 char *gname = aim_ssi_itemlist_findparentname(od->ssi.local, name); 3743 char *gname = aim_ssi_itemlist_findparentname(&od->ssi.local, name);
3771 if (gname) { 3744 if (gname) {
3772 purple_debug_info("oscar", 3745 purple_debug_info("oscar",
3773 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); 3746 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)");
3774 aim_ssi_aliasbuddy(od, gname, name, alias); 3747 aim_ssi_aliasbuddy(od, gname, name, alias);
3775 } 3748 }
3782 void oscar_rename_group(PurpleConnection *gc, const char *old_name, PurpleGroup *group, GList *moved_buddies) { 3755 void oscar_rename_group(PurpleConnection *gc, const char *old_name, PurpleGroup *group, GList *moved_buddies) {
3783 OscarData *od = purple_connection_get_protocol_data(gc); 3756 OscarData *od = purple_connection_get_protocol_data(gc);
3784 3757
3785 if (od->ssi.received_data) { 3758 if (od->ssi.received_data) {
3786 const char *gname = purple_group_get_name(group); 3759 const char *gname = purple_group_get_name(group);
3787 if (aim_ssi_itemlist_finditem(od->ssi.local, gname, NULL, AIM_SSI_TYPE_GROUP)) { 3760 if (aim_ssi_itemlist_finditem(&od->ssi.local, gname, NULL, AIM_SSI_TYPE_GROUP)) {
3788 GList *cur, *groups = NULL; 3761 GList *cur, *groups = NULL;
3789 PurpleAccount *account = purple_connection_get_account(gc); 3762 PurpleAccount *account = purple_connection_get_account(gc);
3790 3763
3791 /* Make a list of what the groups each buddy is in */ 3764 /* Make a list of what the groups each buddy is in */
3792 for (cur = moved_buddies; cur != NULL; cur = cur->next) { 3765 for (cur = moved_buddies; cur != NULL; cur = cur->next) {
3796 groups = g_list_append(groups, 3769 groups = g_list_append(groups,
3797 purple_buddy_get_group((PurpleBuddy*)node)); 3770 purple_buddy_get_group((PurpleBuddy*)node));
3798 } 3771 }
3799 3772
3800 purple_account_remove_buddies(account, moved_buddies, groups); 3773 purple_account_remove_buddies(account, moved_buddies, groups);
3801 purple_account_add_buddies(account, moved_buddies); 3774 purple_account_add_buddies(account, moved_buddies, NULL);
3802 g_list_free(groups); 3775 g_list_free(groups);
3803 purple_debug_info("oscar", 3776 purple_debug_info("oscar",
3804 "ssi: moved all buddies from group %s to %s\n", old_name, gname); 3777 "ssi: moved all buddies from group %s to %s\n", old_name, gname);
3805 } else { 3778 } else {
3806 aim_ssi_rename_group(od, old_name, gname); 3779 aim_ssi_rename_group(od, old_name, gname);
3913 od->getblisttimer = 0; 3886 od->getblisttimer = 0;
3914 } 3887 }
3915 3888
3916 purple_debug_info("oscar", "ssi: syncing local list and server list\n"); 3889 purple_debug_info("oscar", "ssi: syncing local list and server list\n");
3917 3890
3918 /* Clean the buddy list */
3919 aim_ssi_cleanlist(od);
3920
3921 /*** Begin code for pruning buddies from local list if they're not in server list ***/ 3891 /*** Begin code for pruning buddies from local list if they're not in server list ***/
3922 3892
3923 /* Buddies */ 3893 /* Buddies */
3924 cur = NULL; 3894 cur = NULL;
3925 for (buddies = purple_find_buddies(account, NULL); 3895 for (buddies = purple_find_buddies(account, NULL);
3933 b = buddies->data; 3903 b = buddies->data;
3934 g = purple_buddy_get_group(b); 3904 g = purple_buddy_get_group(b);
3935 gname = purple_group_get_name(g); 3905 gname = purple_group_get_name(g);
3936 bname = purple_buddy_get_name(b); 3906 bname = purple_buddy_get_name(b);
3937 3907
3938 if (aim_ssi_itemlist_exists(od->ssi.local, bname)) { 3908 if (aim_ssi_itemlist_exists(&od->ssi.local, bname)) {
3939 /* If the buddy is an ICQ user then load his nickname */ 3909 /* If the buddy is an ICQ user then load his nickname */
3940 const char *servernick = purple_blist_node_get_string((PurpleBlistNode*)b, "servernick"); 3910 const char *servernick = purple_blist_node_get_string((PurpleBlistNode*)b, "servernick");
3941 char *alias; 3911 char *alias;
3942 const char *balias; 3912 const char *balias;
3943 if (servernick) 3913 if (servernick)
3944 serv_got_alias(gc, bname, servernick); 3914 serv_got_alias(gc, bname, servernick);
3945 3915
3946 /* Store local alias on server */ 3916 /* Store local alias on server */
3947 alias = aim_ssi_getalias(od->ssi.local, gname, bname); 3917 alias = aim_ssi_getalias(&od->ssi.local, gname, bname);
3948 balias = purple_buddy_get_local_buddy_alias(b); 3918 balias = purple_buddy_get_local_buddy_alias(b);
3949 if (!alias && balias && *balias) 3919 if (!alias && balias && *balias)
3950 aim_ssi_aliasbuddy(od, gname, bname, balias); 3920 aim_ssi_aliasbuddy(od, gname, bname, balias);
3951 g_free(alias); 3921 g_free(alias);
3952 } else { 3922 } else {
3965 if (!od->icq) { 3935 if (!od->icq) {
3966 next = account->permit; 3936 next = account->permit;
3967 while (next != NULL) { 3937 while (next != NULL) {
3968 cur = next; 3938 cur = next;
3969 next = next->next; 3939 next = next->next;
3970 if (!aim_ssi_itemlist_finditem(od->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { 3940 if (!aim_ssi_itemlist_finditem(&od->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) {
3971 purple_debug_info("oscar", 3941 purple_debug_info("oscar",
3972 "ssi: removing permit %s from local list\n", (const char *)cur->data); 3942 "ssi: removing permit %s from local list\n", (const char *)cur->data);
3973 purple_privacy_permit_remove(account, cur->data, TRUE); 3943 purple_privacy_permit_remove(account, cur->data, TRUE);
3974 } 3944 }
3975 } 3945 }
3978 /* Deny list */ 3948 /* Deny list */
3979 next = account->deny; 3949 next = account->deny;
3980 while (next != NULL) { 3950 while (next != NULL) {
3981 cur = next; 3951 cur = next;
3982 next = next->next; 3952 next = next->next;
3983 if (!aim_ssi_itemlist_finditem(od->ssi.local, NULL, cur->data, deny_entry_type)) { 3953 if (!aim_ssi_itemlist_finditem(&od->ssi.local, NULL, cur->data, deny_entry_type)) {
3984 purple_debug_info("oscar", 3954 purple_debug_info("oscar",
3985 "ssi: removing deny %s from local list\n", (const char *)cur->data); 3955 "ssi: removing deny %s from local list\n", (const char *)cur->data);
3986 purple_privacy_deny_remove(account, cur->data, TRUE); 3956 purple_privacy_deny_remove(account, cur->data, TRUE);
3987 } 3957 }
3988 } 3958 }
3989 3959
3990 /* Presence settings (idle time visibility) */ 3960 /* Presence settings (idle time visibility) */
3991 tmp = aim_ssi_getpresence(od->ssi.local); 3961 tmp = aim_ssi_getpresence(&od->ssi.local);
3992 if (tmp != 0xFFFFFFFF) { 3962 if (tmp != 0xFFFFFFFF) {
3993 const char *idle_reporting_pref; 3963 const char *idle_reporting_pref;
3994 gboolean report_idle; 3964 gboolean report_idle;
3995 3965
3996 idle_reporting_pref = purple_prefs_get_string("/purple/away/idle_reporting"); 3966 idle_reporting_pref = purple_prefs_get_string("/purple/away/idle_reporting");
4004 3974
4005 /*** End code for pruning buddies from local list ***/ 3975 /*** End code for pruning buddies from local list ***/
4006 3976
4007 /*** Begin code for adding from server list to local list ***/ 3977 /*** Begin code for adding from server list to local list ***/
4008 3978
4009 for (curitem=od->ssi.local; curitem; curitem=curitem->next) { 3979 for (curitem=od->ssi.local.data; curitem; curitem=curitem->next) {
4010 if (curitem->name && !g_utf8_validate(curitem->name, -1, NULL)) { 3980 if (curitem->name && !g_utf8_validate(curitem->name, -1, NULL)) {
4011 /* Got node with invalid UTF-8 in the name. Skip it. */ 3981 /* Got node with invalid UTF-8 in the name. Skip it. */
4012 purple_debug_warning("oscar", "ssi: server list contains item of " 3982 purple_debug_warning("oscar", "ssi: server list contains item of "
4013 "type 0x%04hhx with a non-utf8 name\n", curitem->type); 3983 "type 0x%04hhx with a non-utf8 name\n", curitem->type);
4014 continue; 3984 continue;
4018 case AIM_SSI_TYPE_BUDDY: { /* Buddy */ 3988 case AIM_SSI_TYPE_BUDDY: { /* Buddy */
4019 if (curitem->name) { 3989 if (curitem->name) {
4020 struct aim_ssi_item *groupitem; 3990 struct aim_ssi_item *groupitem;
4021 char *gname, *gname_utf8, *alias, *alias_utf8; 3991 char *gname, *gname_utf8, *alias, *alias_utf8;
4022 3992
4023 groupitem = aim_ssi_itemlist_find(od->ssi.local, curitem->gid, 0x0000); 3993 groupitem = aim_ssi_itemlist_find(&od->ssi.local, curitem->gid, 0x0000);
4024 gname = groupitem ? groupitem->name : NULL; 3994 gname = groupitem ? groupitem->name : NULL;
4025 gname_utf8 = oscar_utf8_try_convert(account, od, gname); 3995 gname_utf8 = oscar_utf8_try_convert(account, od, gname);
4026 3996
4027 g = purple_find_group(gname_utf8 ? gname_utf8 : _("Orphans")); 3997 g = purple_find_group(gname_utf8 ? gname_utf8 : _("Buddies"));
4028 if (g == NULL) { 3998 if (g == NULL) {
4029 g = purple_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); 3999 g = purple_group_new(gname_utf8 ? gname_utf8 : _("Buddies"));
4030 purple_blist_add_group(g, NULL); 4000 purple_blist_add_group(g, NULL);
4031 } 4001 }
4032 4002
4033 alias = aim_ssi_getalias(od->ssi.local, gname, curitem->name); 4003 alias = aim_ssi_getalias_from_item(curitem);
4034 alias_utf8 = oscar_utf8_try_convert(account, od, alias); 4004 alias_utf8 = oscar_utf8_try_convert(account, od, alias);
4035 4005
4036 b = purple_find_buddy_in_group(account, curitem->name, g); 4006 b = purple_find_buddy_in_group(account, curitem->name, g);
4037 if (b) { 4007 if (b) {
4038 /* Get server stored alias */ 4008 /* Get server stored alias */
4097 * for ICQ because, for ICQ, this setting controls who can 4067 * for ICQ because, for ICQ, this setting controls who can
4098 * see your online status when you are invisible. Thus it is 4068 * see your online status when you are invisible. Thus it is
4099 * a part of your status and not really related to blocking. 4069 * a part of your status and not really related to blocking.
4100 */ 4070 */
4101 if (!od->icq && curitem->data) { 4071 if (!od->icq && curitem->data) {
4102 guint8 perm_deny = aim_ssi_getpermdeny(od->ssi.local); 4072 guint8 perm_deny = aim_ssi_getpermdeny(&od->ssi.local);
4103 if (perm_deny != 0 && perm_deny != account->perm_deny) 4073 if (perm_deny != 0 && perm_deny != purple_account_get_privacy_type(account))
4104 { 4074 {
4105 purple_debug_info("oscar", 4075 purple_debug_info("oscar",
4106 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, perm_deny); 4076 "ssi: changing permdeny from %d to %hhu\n", purple_account_get_privacy_type(account), perm_deny);
4107 account->perm_deny = perm_deny; 4077 purple_account_set_privacy_type(account, perm_deny);
4108 } 4078 }
4109 } 4079 }
4110 } break; 4080 } break;
4111 4081
4112 case AIM_SSI_TYPE_PRESENCEPREFS: { /* Presence setting */ 4082 case AIM_SSI_TYPE_PRESENCEPREFS: { /* Presence setting */
4226 va_end(ap); 4196 va_end(ap);
4227 4197
4228 if ((type != 0x0000) || (name == NULL)) 4198 if ((type != 0x0000) || (name == NULL))
4229 return 1; 4199 return 1;
4230 4200
4231 gname = aim_ssi_itemlist_findparentname(od->ssi.local, name); 4201 gname = aim_ssi_itemlist_findparentname(&od->ssi.local, name);
4232 gname_utf8 = gname ? oscar_utf8_try_convert(account, od, gname) : NULL; 4202 gname_utf8 = gname ? oscar_utf8_try_convert(account, od, gname) : NULL;
4233 4203
4234 alias = aim_ssi_getalias(od->ssi.local, gname, name); 4204 alias = aim_ssi_getalias(&od->ssi.local, gname, name);
4235 alias_utf8 = oscar_utf8_try_convert(account, od, alias); 4205 alias_utf8 = oscar_utf8_try_convert(account, od, alias);
4236 g_free(alias); 4206 g_free(alias);
4237 4207
4238 b = purple_find_buddy(account, name); 4208 b = purple_find_buddy(account, name);
4239 if (b) { 4209 if (b) {
4248 * You're logged in somewhere else and you added a buddy to 4218 * You're logged in somewhere else and you added a buddy to
4249 * your server list, so add them to your local buddy list. 4219 * your server list, so add them to your local buddy list.
4250 */ 4220 */
4251 b = purple_buddy_new(account, name, alias_utf8); 4221 b = purple_buddy_new(account, name, alias_utf8);
4252 4222
4253 if (!(g = purple_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { 4223 if (!(g = purple_find_group(gname_utf8 ? gname_utf8 : _("Buddies")))) {
4254 g = purple_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); 4224 g = purple_group_new(gname_utf8 ? gname_utf8 : _("Buddies"));
4255 purple_blist_add_group(g, NULL); 4225 purple_blist_add_group(g, NULL);
4256 } 4226 }
4257 4227
4258 purple_debug_info("oscar", 4228 purple_debug_info("oscar",
4259 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); 4229 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Buddies"));
4260 purple_blist_add_buddy(b, NULL, g, NULL); 4230 purple_blist_add_buddy(b, NULL, g, NULL);
4261 4231
4262 /* Mobile users should always be online */ 4232 /* Mobile users should always be online */
4263 if (name[0] == '+') { 4233 if (name[0] == '+') {
4264 purple_prpl_got_user_status(account, 4234 purple_prpl_got_user_status(account,
4267 name, OSCAR_STATUS_ID_MOBILE, NULL); 4237 name, OSCAR_STATUS_ID_MOBILE, NULL);
4268 } 4238 }
4269 4239
4270 } 4240 }
4271 4241
4272 ssi_item = aim_ssi_itemlist_finditem(od->ssi.local, 4242 ssi_item = aim_ssi_itemlist_finditem(&od->ssi.local,
4273 gname, name, AIM_SSI_TYPE_BUDDY); 4243 gname, name, AIM_SSI_TYPE_BUDDY);
4274 if (ssi_item == NULL) 4244 if (ssi_item == NULL)
4275 { 4245 {
4276 purple_debug_error("oscar", "purple_ssi_parseaddmod: " 4246 purple_debug_error("oscar", "purple_ssi_parseaddmod: "
4277 "Could not find ssi item for oncoming buddy %s, " 4247 "Could not find ssi item for oncoming buddy %s, "
4606 PurpleConnection *gc = NULL; 4576 PurpleConnection *gc = NULL;
4607 OscarData *od = NULL; 4577 OscarData *od = NULL;
4608 PurpleAccount *account = NULL; 4578 PurpleAccount *account = NULL;
4609 PurplePresence *presence; 4579 PurplePresence *presence;
4610 PurpleStatus *status; 4580 PurpleStatus *status;
4611 const char *status_id;
4612 aim_userinfo_t *userinfo = NULL; 4581 aim_userinfo_t *userinfo = NULL;
4613 const char *name; 4582 const char *name;
4614 4583
4615 account = purple_buddy_get_account(b); 4584 account = purple_buddy_get_account(b);
4616 name = purple_buddy_get_name(b); 4585 name = purple_buddy_get_name(b);
4621 if (od != NULL) 4590 if (od != NULL)
4622 userinfo = aim_locate_finduserinfo(od, name); 4591 userinfo = aim_locate_finduserinfo(od, name);
4623 4592
4624 presence = purple_buddy_get_presence(b); 4593 presence = purple_buddy_get_presence(b);
4625 status = purple_presence_get_active_status(presence); 4594 status = purple_presence_get_active_status(presence);
4626 status_id = purple_status_get_id(status);
4627 4595
4628 if (purple_presence_is_online(presence) == FALSE) { 4596 if (purple_presence_is_online(presence) == FALSE) {
4629 char *gname; 4597 char *gname;
4630 if ((name) && (od) && (od->ssi.received_data) && 4598 if ((name) && (od) && (od->ssi.received_data) &&
4631 (gname = aim_ssi_itemlist_findparentname(od->ssi.local, name)) && 4599 (gname = aim_ssi_itemlist_findparentname(&od->ssi.local, name)) &&
4632 (aim_ssi_waitingforauth(od->ssi.local, gname, name))) { 4600 (aim_ssi_waitingforauth(&od->ssi.local, gname, name))) {
4633 return "not-authorized"; 4601 return "not-authorized";
4634 } 4602 }
4635 } 4603 }
4636 4604
4637 if (userinfo != NULL ) { 4605 if (userinfo != NULL ) {
4680 PurpleConnection *gc; 4648 PurpleConnection *gc;
4681 PurpleAccount *account; 4649 PurpleAccount *account;
4682 OscarData *od; 4650 OscarData *od;
4683 const PurplePresence *presence; 4651 const PurplePresence *presence;
4684 const PurpleStatus *status; 4652 const PurpleStatus *status;
4685 const char *id;
4686 const char *message; 4653 const char *message;
4687 gchar *ret = NULL; 4654 gchar *ret = NULL;
4688 4655
4689 gc = purple_account_get_connection(purple_buddy_get_account(b)); 4656 gc = purple_account_get_connection(purple_buddy_get_account(b));
4690 account = purple_connection_get_account(gc); 4657 account = purple_connection_get_account(gc);
4691 od = purple_connection_get_protocol_data(gc); 4658 od = purple_connection_get_protocol_data(gc);
4692 presence = purple_buddy_get_presence(b); 4659 presence = purple_buddy_get_presence(b);
4693 status = purple_presence_get_active_status(presence); 4660 status = purple_presence_get_active_status(presence);
4694 id = purple_status_get_id(status);
4695 4661
4696 if ((od != NULL) && !purple_presence_is_online(presence)) 4662 if ((od != NULL) && !purple_presence_is_online(presence))
4697 { 4663 {
4698 const char *name = purple_buddy_get_name(b); 4664 const char *name = purple_buddy_get_name(b);
4699 char *gname = aim_ssi_itemlist_findparentname(od->ssi.local, name); 4665 char *gname = aim_ssi_itemlist_findparentname(&od->ssi.local, name);
4700 if (aim_ssi_waitingforauth(od->ssi.local, gname, name)) 4666 if (aim_ssi_waitingforauth(&od->ssi.local, gname, name))
4701 ret = g_strdup(_("Not Authorized")); 4667 ret = g_strdup(_("Not Authorized"));
4702 else 4668 else
4703 ret = g_strdup(_("Offline")); 4669 ret = g_strdup(_("Offline"));
4704 } 4670 }
4705 else 4671 else
4731 /* 4697 /*
4732 * Conveniently there is a one-to-one mapping between the 4698 * Conveniently there is a one-to-one mapping between the
4733 * values of libpurple's PurplePrivacyType and the values used 4699 * values of libpurple's PurplePrivacyType and the values used
4734 * by the oscar protocol. 4700 * by the oscar protocol.
4735 */ 4701 */
4736 aim_ssi_setpermdeny(od, account->perm_deny); 4702 aim_ssi_setpermdeny(od, purple_account_get_privacy_type(account));
4737 } 4703 }
4738 4704
4739 void oscar_add_permit(PurpleConnection *gc, const char *who) { 4705 void oscar_add_permit(PurpleConnection *gc, const char *who) {
4740 OscarData *od = purple_connection_get_protocol_data(gc); 4706 OscarData *od = purple_connection_get_protocol_data(gc);
4741 purple_debug_info("oscar", "ssi: About to add a permit\n"); 4707 purple_debug_info("oscar", "ssi: About to add a permit\n");
4938 if (!(g = purple_buddy_get_group(buddy))) 4904 if (!(g = purple_buddy_get_group(buddy)))
4939 return; 4905 return;
4940 4906
4941 data = g_new(struct name_data, 1); 4907 data = g_new(struct name_data, 1);
4942 4908
4943 comment = aim_ssi_getcomment(od->ssi.local, purple_group_get_name(g), name); 4909 comment = aim_ssi_getcomment(&od->ssi.local, purple_group_get_name(g), name);
4944 comment_utf8 = comment ? oscar_utf8_try_convert(account, od, comment) : NULL; 4910 comment_utf8 = comment ? oscar_utf8_try_convert(account, od, comment) : NULL;
4945 4911
4946 data->gc = gc; 4912 data->gc = gc;
4947 data->name = g_strdup(name); 4913 data->name = g_strdup(name);
4948 data->nick = g_strdup(purple_buddy_get_alias_only(buddy)); 4914 data->nick = g_strdup(purple_buddy_get_alias_only(buddy));
5030 4996
5031 buddy = (PurpleBuddy*)node; 4997 buddy = (PurpleBuddy*)node;
5032 name = purple_buddy_get_name(buddy); 4998 name = purple_buddy_get_name(buddy);
5033 account = purple_buddy_get_account(buddy); 4999 account = purple_buddy_get_account(buddy);
5034 gc = purple_account_get_connection(account); 5000 gc = purple_account_get_connection(account);
5035 od = gc->proto_data; 5001 od = purple_connection_get_protocol_data(gc);
5036 conn = peer_connection_find_by_type(od, name, OSCAR_CAPABILITY_DIRECTIM); 5002 conn = peer_connection_find_by_type(od, name, OSCAR_CAPABILITY_DIRECTIM);
5037 5003
5038 if (conn != NULL) 5004 if (conn != NULL)
5039 { 5005 {
5040 if (!conn->ready) 5006 if (!conn->ready)
5159 /* 5125 /*
5160 * We only do this if the user is in our buddy list and we're 5126 * We only do this if the user is in our buddy list and we're
5161 * waiting for authorization. 5127 * waiting for authorization.
5162 */ 5128 */
5163 char *gname; 5129 char *gname;
5164 gname = aim_ssi_itemlist_findparentname(od->ssi.local, bname); 5130 gname = aim_ssi_itemlist_findparentname(&od->ssi.local, bname);
5165 if (gname && aim_ssi_waitingforauth(od->ssi.local, gname, bname)) 5131 if (gname && aim_ssi_waitingforauth(&od->ssi.local, gname, bname))
5166 { 5132 {
5167 act = purple_menu_action_new(_("Re-request Authorization"), 5133 act = purple_menu_action_new(_("Re-request Authorization"),
5168 PURPLE_CALLBACK(oscar_auth_sendrequest_menu), 5134 PURPLE_CALLBACK(oscar_auth_sendrequest_menu),
5169 NULL, NULL); 5135 NULL, NULL);
5170 menu = g_list_prepend(menu, act); 5136 menu = g_list_prepend(menu, act);
5311 const gchar *bname, *gname; 5277 const gchar *bname, *gname;
5312 5278
5313 buddy = cur->data; 5279 buddy = cur->data;
5314 bname = purple_buddy_get_name(buddy); 5280 bname = purple_buddy_get_name(buddy);
5315 gname = purple_group_get_name(purple_buddy_get_group(buddy)); 5281 gname = purple_group_get_name(purple_buddy_get_group(buddy));
5316 if (aim_ssi_waitingforauth(od->ssi.local, gname, bname)) { 5282 if (aim_ssi_waitingforauth(&od->ssi.local, gname, bname)) {
5317 filtered_buddies = g_slist_prepend(filtered_buddies, buddy); 5283 filtered_buddies = g_slist_prepend(filtered_buddies, buddy);
5318 } 5284 }
5319 } 5285 }
5320 5286
5321 g_slist_free(buddies); 5287 g_slist_free(buddies);
5466 conn = peer_connection_new(od, OSCAR_CAPABILITY_SENDFILE, who); 5432 conn = peer_connection_new(od, OSCAR_CAPABILITY_SENDFILE, who);
5467 conn->flags |= PEER_CONNECTION_FLAG_INITIATED_BY_ME; 5433 conn->flags |= PEER_CONNECTION_FLAG_INITIATED_BY_ME;
5468 conn->flags |= PEER_CONNECTION_FLAG_APPROVED; 5434 conn->flags |= PEER_CONNECTION_FLAG_APPROVED;
5469 aim_icbm_makecookie(conn->cookie); 5435 aim_icbm_makecookie(conn->cookie);
5470 conn->xfer = xfer; 5436 conn->xfer = xfer;
5471 xfer->data = conn; 5437 purple_xfer_set_protocol_data(xfer, conn);
5472 } 5438 }
5473 5439
5474 return xfer; 5440 return xfer;
5475 } 5441 }
5476 5442