/pidgin/main: d402d758daf0: oscar: Change clientLogin option int...

Youness Alaoui kakaroto at kakaroto.homelinux.net
Fri Jun 17 19:11:41 EDT 2016


Changeset: d402d758daf09fd8ade0bc6e0fe6ea6403c361b4
Author:	 Youness Alaoui <kakaroto at kakaroto.homelinux.net>
Date:	 2016-05-03 14:48 -0400
Branch:	 oscar_auth
URL: https://hg.pidgin.im/pidgin/main/rev/d402d758daf0

Description:

oscar: Change clientLogin option into a list

This allows the user to know that "Use clientLogin" is an authentication
method, and also what happens if the option is disabled. This also allows
us to add more authentication methods in the future.

diffstat:

 libpurple/protocols/oscar/oscar.c       |  28 ++++++++++++++++++++++++----
 libpurple/protocols/oscar/oscarcommon.h |   5 ++++-
 2 files changed, 28 insertions(+), 5 deletions(-)

diffs (96 lines):

diff --git a/libpurple/protocols/oscar/oscar.c b/libpurple/protocols/oscar/oscar.c
--- a/libpurple/protocols/oscar/oscar.c
+++ b/libpurple/protocols/oscar/oscar.c
@@ -348,7 +348,9 @@ connection_common_established_cb(FlapCon
 		flap_connection_send_version(od, conn);
 	else
 	{
-		if (purple_account_get_bool(account, "use_clientlogin", OSCAR_DEFAULT_USE_CLIENTLOGIN))
+		const gchar *login_type = purple_account_get_string(account, "login_type", OSCAR_DEFAULT_LOGIN);
+
+		if (strcmp(login_type, OSCAR_CLIENT_LOGIN) == 0)
 		{
 			ClientInfo aiminfo = CLIENTINFO_PURPLE_AIM;
 			ClientInfo icqinfo = CLIENTINFO_PURPLE_ICQ;
@@ -641,6 +643,7 @@ oscar_login(PurpleAccount *account)
 	PurpleConnection *gc;
 	OscarData *od;
 	const gchar *encryption_type;
+	const gchar *login_type;
 	GList *handlers;
 	GList *sorted_handlers;
 	GList *cur;
@@ -740,6 +743,7 @@ oscar_login(PurpleAccount *account)
 
 	od->default_port = purple_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT);
 
+	login_type = purple_account_get_string(account, "login_type", OSCAR_DEFAULT_LOGIN);
 	encryption_type = purple_account_get_string(account, "encryption", OSCAR_DEFAULT_ENCRYPTION);
 	od->use_ssl = strcmp(encryption_type, OSCAR_NO_ENCRYPTION) != 0;
 
@@ -757,7 +761,7 @@ oscar_login(PurpleAccount *account)
 	 * This authentication method is used for both ICQ and AIM when
 	 * clientLogin is not enabled.
 	 */
-	if (purple_account_get_bool(account, "use_clientlogin", OSCAR_DEFAULT_USE_CLIENTLOGIN)) {
+	if (strcmp(login_type, OSCAR_CLIENT_LOGIN) == 0) {
 		send_client_login(od, purple_account_get_username(account));
 	} else {
 		FlapConnection *newconn;
@@ -5570,7 +5574,18 @@ void oscar_init_account_options(PurplePr
 		OSCAR_NO_ENCRYPTION,
 		NULL
 	};
+	static const gchar *login_keys[] = {
+		N_("Use clientLogin authentication"),
+		N_("Use MD5 based authentication"),
+		NULL
+	};
+	static const gchar *login_values[] = {
+		OSCAR_CLIENT_LOGIN,
+		OSCAR_MD5_LOGIN,
+		NULL
+	};
 	GList *encryption_options = NULL;
+	GList *login_options = NULL;
 	int i;
 
 	option = purple_account_option_int_new(_("Port"), "port", OSCAR_DEFAULT_LOGIN_PORT);
@@ -5585,8 +5600,13 @@ void oscar_init_account_options(PurplePr
 	option = purple_account_option_list_new(_("Connection security"), "encryption", encryption_options);
 	protocol->account_options = g_list_append(protocol->account_options, option);
 
-	option = purple_account_option_bool_new(_("Use clientLogin"), "use_clientlogin",
-			OSCAR_DEFAULT_USE_CLIENTLOGIN);
+	for (i = 0; login_keys[i]; i++) {
+		PurpleKeyValuePair *kvp = g_new0(PurpleKeyValuePair, 1);
+		kvp->key = g_strdup(_(login_keys[i]));
+		kvp->value = g_strdup(login_values[i]);
+		login_options = g_list_append(login_options, kvp);
+	}
+	option = purple_account_option_list_new(_("Authentication method"), "login_type", login_options);
 	protocol->account_options = g_list_append(protocol->account_options, option);
 
 	option = purple_account_option_bool_new(
diff --git a/libpurple/protocols/oscar/oscarcommon.h b/libpurple/protocols/oscar/oscarcommon.h
--- a/libpurple/protocols/oscar/oscarcommon.h
+++ b/libpurple/protocols/oscar/oscarcommon.h
@@ -44,6 +44,9 @@
 #define OSCAR_REQUIRE_ENCRYPTION "require_encryption"
 #define OSCAR_NO_ENCRYPTION "no_encryption"
 
+#define OSCAR_MD5_LOGIN "md5_login"
+#define OSCAR_CLIENT_LOGIN "client_login"
+
 #ifndef _WIN32
 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1"
 #else
@@ -54,7 +57,7 @@
 #define OSCAR_DEFAULT_WEB_AWARE FALSE
 #define OSCAR_DEFAULT_ALWAYS_USE_RV_PROXY FALSE
 #define OSCAR_DEFAULT_ALLOW_MULTIPLE_LOGINS TRUE
-#define OSCAR_DEFAULT_USE_CLIENTLOGIN TRUE
+#define OSCAR_DEFAULT_LOGIN OSCAR_CLIENT_LOGIN
 #define OSCAR_DEFAULT_ENCRYPTION OSCAR_OPPORTUNISTIC_ENCRYPTION
 
 #ifdef _WIN32



More information about the Commits mailing list