/pidgin/main: 4b57eced35d5: oscar: Code cleaning by moving AIM/I...

Youness Alaoui <[email protected]>
Newsgroups gmane.comp.gnome.gaim.cvs
Message-ID <[email protected]>
Changeset: 4b57eced35d5bef2919308436b618ad42cc42ae7
Author:	 Youness Alaoui <[email protected]>
Date:	 2016-05-03 15:00 -0400
Branch:	 oscar_auth
URL: https://hg.pidgin.im/pidgin/main/rev/4b57eced35d5

Description:

oscar: Code cleaning by moving AIM/ICQ specific options to oscar.c

protocol options were in 3 different places, which caused code duplication
and made it harder to set protocol-specific options in a single function.
The fnuction that adds option now knows if it's for ICQ or AIM and acts
accordingly.

diffstat:

 libpurple/protocols/oscar/aim.c   |   9 +--------
 libpurple/protocols/oscar/icq.c   |   7 +------
 libpurple/protocols/oscar/oscar.c |  14 +++++++++++++-
 libpurple/protocols/oscar/oscar.h |   2 +-
 4 files changed, 16 insertions(+), 16 deletions(-)

diffs (87 lines):

diff --git a/libpurple/protocols/oscar/aim.c b/libpurple/protocols/oscar/aim.c
--- a/libpurple/protocols/oscar/aim.c
+++ b/libpurple/protocols/oscar/aim.c
@@ -36,14 +36,7 @@ aim_protocol_init(PurpleProtocol *protoc
 	protocol->id   = "prpl-aim";
 	protocol->name = "AIM";
 
-	oscar_init_account_options(protocol);
-
-	option = purple_account_option_bool_new(_("Allow multiple simultaneous logins"), "allow_multiple_logins",
-											OSCAR_DEFAULT_ALLOW_MULTIPLE_LOGINS);
-	protocol->account_options = g_list_append(protocol->account_options, option);
-
-	option = purple_account_option_string_new(_("Server"), "server", oscar_get_login_server(FALSE, TRUE));
-	protocol->account_options = g_list_prepend(protocol->account_options, option);
+	oscar_init_account_options(protocol, FALSE);
 }
 
 static void
diff --git a/libpurple/protocols/oscar/icq.c b/libpurple/protocols/oscar/icq.c
--- a/libpurple/protocols/oscar/icq.c
+++ b/libpurple/protocols/oscar/icq.c
@@ -52,13 +52,8 @@ icq_protocol_init(PurpleProtocol *protoc
 	protocol->id   = "prpl-icq";
 	protocol->name = "ICQ";
 
-	oscar_init_account_options(protocol);
+	oscar_init_account_options(protocol, TRUE);
 
-	option = purple_account_option_string_new(_("Server"), "server", oscar_get_login_server(TRUE, TRUE));
-	protocol->account_options = g_list_prepend(protocol->account_options, option);
-
-	option = purple_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
-	protocol->account_options = g_list_append(protocol->account_options, option);
 }
 
 static void
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
@@ -5559,7 +5559,7 @@ gboolean oscar_uri_handler(const char *p
 	return FALSE;
 }
 
-void oscar_init_account_options(PurpleProtocol *protocol)
+void oscar_init_account_options(PurpleProtocol *protocol, gboolean is_icq)
 {
 	PurpleAccountOption *option;
 	static const gchar *encryption_keys[] = {
@@ -5588,6 +5588,9 @@ void oscar_init_account_options(PurplePr
 	GList *login_options = NULL;
 	int i;
 
+	option = purple_account_option_string_new(_("Server"), "server", oscar_get_login_server(is_icq, TRUE));
+	protocol->account_options = g_list_append(protocol->account_options, option);
+
 	option = purple_account_option_int_new(_("Port"), "port", OSCAR_DEFAULT_LOGIN_PORT);
 	protocol->account_options = g_list_append(protocol->account_options, option);
 
@@ -5613,6 +5616,15 @@ void oscar_init_account_options(PurplePr
 		_("Always use AIM/ICQ proxy server for\nfile transfers and direct IM (slower,\nbut does not reveal your IP address)"), "always_use_rv_proxy",
 		OSCAR_DEFAULT_ALWAYS_USE_RV_PROXY);
 	protocol->account_options = g_list_append(protocol->account_options, option);
+
+	if (is_icq) {
+		option = purple_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
+		protocol->account_options = g_list_append(protocol->account_options, option);
+	} else {
+		option = purple_account_option_bool_new(_("Allow multiple simultaneous logins"), "allow_multiple_logins",
+												OSCAR_DEFAULT_ALLOW_MULTIPLE_LOGINS);
+		protocol->account_options = g_list_append(protocol->account_options, option);
+	}
 }
 
 static void
diff --git a/libpurple/protocols/oscar/oscar.h b/libpurple/protocols/oscar/oscar.h
--- a/libpurple/protocols/oscar/oscar.h
+++ b/libpurple/protocols/oscar/oscar.h
@@ -1367,7 +1367,7 @@ struct name_data
 
 void oscar_free_name_data(struct name_data *data);
 
-void oscar_init_account_options(PurpleProtocol *protocol);
+void oscar_init_account_options(PurpleProtocol *protocol, gboolean is_icq);
 
 #ifdef __cplusplus
 }

_______________________________________________
Commits mailing list
[email protected]
https://pidgin.im/cgi-bin/mailman/listinfo/commits
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.