comparison libpurple/protocols/oscar/oscar.c @ 31085:4297feb30ad1

Merged everything related to ICQ server changes. applied changes from b6d7712e90b68610df3bd2d8cbaf46d94c8b3794 through d849dc2a852a4ffdd345a150f0b88ab37de36e36 applied changes from 7aedaac3ed815cab16d758474a829d5ec5a59e4b through d849dc2a852a4ffdd345a150f0b88ab37de36e36
author ivan.komarov@soc.pidgin.im
date Sat, 30 Oct 2010 21:36:34 +0000
parents 001897406060
children 1558900f47e5
comparison
equal deleted inserted replaced
31084:a61147460879 31085:4297feb30ad1
608 608
609 if (value) 609 if (value)
610 aim_ssi_setpresence(od, presence & ~AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES); 610 aim_ssi_setpresence(od, presence & ~AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES);
611 else 611 else
612 aim_ssi_setpresence(od, presence | AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES); 612 aim_ssi_setpresence(od, presence | AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES);
613 }
614
615 static const gchar *login_servers[] = {
616 AIM_DEFAULT_LOGIN_SERVER,
617 AIM_DEFAULT_SSL_LOGIN_SERVER,
618 ICQ_DEFAULT_LOGIN_SERVER,
619 ICQ_DEFAULT_SSL_LOGIN_SERVER,
620 };
621
622 static const gchar *get_login_server(gboolean is_icq, gboolean use_ssl)
623 {
624 return login_servers[is_icq*2 + use_ssl];
613 } 625 }
614 626
615 void 627 void
616 oscar_login(PurpleAccount *account) 628 oscar_login(PurpleAccount *account)
617 { 629 {
723 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, 735 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
724 _("SSL support unavailable")); 736 _("SSL support unavailable"));
725 return; 737 return;
726 } 738 }
727 739
728 server = purple_account_get_string(account, "server", OSCAR_DEFAULT_SSL_LOGIN_SERVER); 740 server = purple_account_get_string(account, "server", get_login_server(od->icq, TRUE));
729 741
730 /* 742 /*
731 * If the account's server is what the oscar prpl has offered as 743 * If the account's server is what the oscar prpl has offered as
732 * the default login server through the vast eons (all two of 744 * the default login server through the vast eons (all two of
733 * said default options, AFAIK) and the user wants SSL, we'll 745 * said default options, AFAIK) and the user wants SSL, we'll
734 * do what we know is best for them and change the setting out 746 * do what we know is best for them and change the setting out
735 * from under them to the SSL login server. 747 * from under them to the SSL login server.
736 */ 748 */
737 if (!strcmp(server, OSCAR_DEFAULT_LOGIN_SERVER) || !strcmp(server, OSCAR_OLD_LOGIN_SERVER)) { 749 if (!strcmp(server, get_login_server(od->icq, FALSE))) {
738 purple_debug_info("oscar", "Account uses SSL, so changing server to default SSL server\n"); 750 purple_debug_info("oscar", "Account uses SSL, so changing server to default SSL server\n");
739 purple_account_set_string(account, "server", OSCAR_DEFAULT_SSL_LOGIN_SERVER); 751 purple_account_set_string(account, "server", get_login_server(od->icq, TRUE));
740 server = OSCAR_DEFAULT_SSL_LOGIN_SERVER; 752 server = get_login_server(od->icq, TRUE);
741 } 753 }
742 754
743 newconn->gsc = purple_ssl_connect(account, server, 755 newconn->gsc = purple_ssl_connect(account, server,
744 purple_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT), 756 purple_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT),
745 ssl_connection_established_cb, ssl_connection_error_cb, newconn); 757 ssl_connection_established_cb, ssl_connection_error_cb, newconn);
746 } else { 758 } else {
747 server = purple_account_get_string(account, "server", OSCAR_DEFAULT_LOGIN_SERVER); 759 server = purple_account_get_string(account, "server", get_login_server(od->icq, FALSE));
748 760
749 /* 761 /*
750 * See the comment above. We do the reverse here. If they don't want 762 * See the comment above. We do the reverse here. If they don't want
751 * SSL but their server is set to OSCAR_DEFAULT_SSL_LOGIN_SERVER, 763 * SSL but their server is set to OSCAR_DEFAULT_SSL_LOGIN_SERVER,
752 * set it back to the default. 764 * set it back to the default.
753 */ 765 */
754 if (!strcmp(server, OSCAR_DEFAULT_SSL_LOGIN_SERVER)) { 766 if (!strcmp(server, get_login_server(od->icq, TRUE))) {
755 purple_debug_info("oscar", "Account does not use SSL, so changing server back to non-SSL\n"); 767 purple_debug_info("oscar", "Account does not use SSL, so changing server back to non-SSL\n");
756 purple_account_set_string(account, "server", OSCAR_DEFAULT_LOGIN_SERVER); 768 purple_account_set_string(account, "server", get_login_server(od->icq, FALSE));
757 server = OSCAR_DEFAULT_LOGIN_SERVER; 769 server = get_login_server(od->icq, FALSE);
758 } 770 }
759 771
760 newconn->connect_data = purple_proxy_connect(NULL, account, server, 772 newconn->connect_data = purple_proxy_connect(NULL, account, server,
761 purple_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT), 773 purple_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT),
762 connection_established_cb, newconn); 774 connection_established_cb, newconn);
967 conn = flap_connection_new(od, SNAC_FAMILY_LOCATE); 979 conn = flap_connection_new(od, SNAC_FAMILY_LOCATE);
968 conn->cookielen = cookielen; 980 conn->cookielen = cookielen;
969 conn->cookie = g_memdup(cookie, cookielen); 981 conn->cookie = g_memdup(cookie, cookielen);
970 982
971 /* 983 /*
972 * tls_certname is only set (and must be set if we get this far) if 984 * Use SSL only if the server provided us with a tls_certname. The server might not specify a tls_certname even if we requested to use TLS,
973 * SSL is enabled. 985 * and that is something we should be prepared to.
974 */ 986 */
975 if (tls_certname) 987 if (tls_certname)
976 { 988 {
977 conn->gsc = purple_ssl_connect_with_ssl_cn(account, host, port, 989 conn->gsc = purple_ssl_connect_with_ssl_cn(account, host, port,
978 ssl_connection_established_cb, ssl_connection_error_cb, 990 ssl_connection_established_cb, ssl_connection_error_cb,
5664 } 5676 }
5665 5677
5666 return FALSE; 5678 return FALSE;
5667 } 5679 }
5668 5680
5669 void oscar_init(PurplePlugin *plugin) 5681 void oscar_init(PurplePlugin *plugin, gboolean is_icq)
5670 { 5682 {
5671 PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); 5683 PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
5672 PurpleAccountOption *option; 5684 PurpleAccountOption *option;
5673 static gboolean init = FALSE; 5685 static gboolean init = FALSE;
5674 5686
5675 option = purple_account_option_string_new(_("Server"), "server", OSCAR_DEFAULT_LOGIN_SERVER); 5687 option = purple_account_option_string_new(_("Server"), "server", get_login_server(is_icq, FALSE));
5676 prpl_info->protocol_options = g_list_append(prpl_info->protocol_options, option); 5688 prpl_info->protocol_options = g_list_append(prpl_info->protocol_options, option);
5677 5689
5678 option = purple_account_option_int_new(_("Port"), "port", OSCAR_DEFAULT_LOGIN_PORT); 5690 option = purple_account_option_int_new(_("Port"), "port", OSCAR_DEFAULT_LOGIN_PORT);
5679 prpl_info->protocol_options = g_list_append(prpl_info->protocol_options, option); 5691 prpl_info->protocol_options = g_list_append(prpl_info->protocol_options, option);
5680 5692