/soc/2013/ankitkv/gobjectification: 7ad7681dcfd8: Use purple_pro...

Ankit Vani a at nevitus.org
Thu Aug 29 14:52:23 EDT 2013


Changeset: 7ad7681dcfd84404f7d139756d869dfd279e0b93
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-08-29 23:52 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/7ad7681dcfd8

Description:

Use purple_protocol_get_* API instead of protocol->member

diffstat:

 finch/gntaccount.c                    |  18 +++++++-------
 libpurple/account.c                   |  10 ++++----
 libpurple/connection.c                |   8 +++---
 libpurple/conversation.c              |   2 +-
 libpurple/conversationtypes.c         |  10 ++++----
 libpurple/plugins/one_time_password.c |  10 ++++----
 libpurple/protocols.c                 |  20 ++++++++--------
 libpurple/whiteboard.c                |   2 +-
 pidgin/gtkaccount.c                   |  40 +++++++++++++++++-----------------
 pidgin/gtkblist.c                     |   8 +++---
 pidgin/gtkconv.c                      |  12 +++++-----
 pidgin/gtkstatusbox.c                 |   6 ++--
 pidgin/gtkthemes.c                    |   2 +-
 pidgin/gtkutils.c                     |  12 +++++-----
 pidgin/smileyparser.c                 |   2 +-
 15 files changed, 81 insertions(+), 81 deletions(-)

diffs (truncated from 650 to 300 lines):

diff --git a/finch/gntaccount.c b/finch/gntaccount.c
--- a/finch/gntaccount.c
+++ b/finch/gntaccount.c
@@ -134,7 +134,7 @@ save_account_cb(AccountEditDialog *dialo
 	if (protocol != NULL)
 	{
 		GList *iter, *entries;
-		for (iter = protocol->user_splits, entries = dialog->split_entries;
+		for (iter = purple_protocol_get_user_splits(protocol), entries = dialog->split_entries;
 				iter && entries; iter = iter->next, entries = entries->next)
 		{
 			PurpleAccountUserSplit *split = iter->data;
@@ -151,7 +151,7 @@ save_account_cb(AccountEditDialog *dialo
 
 	if (dialog->account == NULL)
 	{
-		account = purple_account_new(username->str, protocol->id);
+		account = purple_account_new(username->str, purple_protocol_get_id(protocol));
 		purple_accounts_add(account);
 	}
 	else
@@ -160,12 +160,12 @@ save_account_cb(AccountEditDialog *dialo
 
 		/* Protocol */
 		if (purple_account_is_disconnected(account)) {
-			purple_account_set_protocol_id(account, protocol->id);
+			purple_account_set_protocol_id(account, purple_protocol_get_id(protocol));
 			purple_account_set_username(account, username->str);
 		} else {
 			const char *old = purple_account_get_protocol_id(account);
 			char *oldprpl;
-			if (strcmp(old, protocol->id)) {
+			if (strcmp(old, purple_protocol_get_id(protocol))) {
 				purple_notify_error(NULL, _("Error"), _("Account was not modified"),
 						_("The account's protocol cannot be changed while it is connected to the server."));
 				return;
@@ -206,7 +206,7 @@ save_account_cb(AccountEditDialog *dialo
 	{
 		GList *iter, *entries;
 
-		for (iter = protocol->protocol_options, entries = dialog->protocol_entries;
+		for (iter = purple_protocol_get_protocol_options(protocol), entries = dialog->protocol_entries;
 				iter && entries; iter = iter->next, entries = entries->next)
 		{
 			PurpleAccountOption *option = iter->data;
@@ -307,7 +307,7 @@ update_user_splits(AccountEditDialog *di
 
 	username = dialog->account ? g_strdup(purple_account_get_username(dialog->account)) : NULL;
 
-	for (iter = protocol->user_splits; iter; iter = iter->next)
+	for (iter = purple_protocol_get_user_splits(protocol); iter; iter = iter->next)
 	{
 		PurpleAccountUserSplit *split = iter->data;
 		GntWidget *entry;
@@ -326,7 +326,7 @@ update_user_splits(AccountEditDialog *di
 		g_free(buf);
 	}
 
-	for (iter = g_list_last(protocol->user_splits), entries = g_list_last(dialog->split_entries);
+	for (iter = g_list_last(purple_protocol_get_user_splits(protocol)), entries = g_list_last(dialog->split_entries);
 			iter && entries; iter = iter->prev, entries = entries->prev)
 	{
 		GntWidget *entry = entries->data;
@@ -393,7 +393,7 @@ add_protocol_options(AccountEditDialog *
 
 	account = dialog->account;
 
-	for (iter = protocol->protocol_options; iter; iter = iter->next)
+	for (iter = purple_protocol_get_protocol_options(protocol); iter; iter = iter->next)
 	{
 		PurpleAccountOption *option = iter->data;
 		PurplePrefType type = purple_account_option_get_type(option);
@@ -501,7 +501,7 @@ update_user_options(AccountEditDialog *d
 	if (dialog->account)
 		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->newmail),
 				purple_account_get_check_mail(dialog->account));
-	if (!protocol || !(protocol->options & OPT_PROTO_MAIL_CHECK))
+	if (!protocol || !(purple_protocol_get_options(protocol) & OPT_PROTO_MAIL_CHECK))
 		gnt_widget_set_visible(dialog->newmail, FALSE);
 	else
 		gnt_widget_set_visible(dialog->newmail, TRUE);
diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -296,8 +296,8 @@ purple_account_connect_got_password_cb(P
 	PurpleProtocol *protocol = data;
 
 	if ((password == NULL || *password == '\0') &&
-		!(protocol->options & OPT_PROTO_NO_PASSWORD) &&
-		!(protocol->options & OPT_PROTO_PASSWORD_OPTIONAL))
+		!(purple_protocol_get_options(protocol) & OPT_PROTO_NO_PASSWORD) &&
+		!(purple_protocol_get_options(protocol) & OPT_PROTO_PASSWORD_OPTIONAL))
 		purple_account_request_password(account,
 			G_CALLBACK(request_password_ok_cb),
 			G_CALLBACK(request_password_cancel_cb), account);
@@ -632,7 +632,7 @@ purple_account_request_change_password(P
 	field = purple_request_field_string_new("password", _("Original password"),
 										  NULL, FALSE);
 	purple_request_field_string_set_masked(field, TRUE);
-	if (!protocol || !(protocol->options & OPT_PROTO_PASSWORD_OPTIONAL))
+	if (!protocol || !(purple_protocol_get_options(protocol) & OPT_PROTO_PASSWORD_OPTIONAL))
 		purple_request_field_set_required(field, TRUE);
 	purple_request_field_group_add_field(group, field);
 
@@ -640,7 +640,7 @@ purple_account_request_change_password(P
 										  _("New password"),
 										  NULL, FALSE);
 	purple_request_field_string_set_masked(field, TRUE);
-	if (!protocol || !(protocol->options & OPT_PROTO_PASSWORD_OPTIONAL))
+	if (!protocol || !(purple_protocol_get_options(protocol) & OPT_PROTO_PASSWORD_OPTIONAL))
 		purple_request_field_set_required(field, TRUE);
 	purple_request_field_group_add_field(group, field);
 
@@ -648,7 +648,7 @@ purple_account_request_change_password(P
 										  _("New password (again)"),
 										  NULL, FALSE);
 	purple_request_field_string_set_masked(field, TRUE);
-	if (!protocol || !(protocol->options & OPT_PROTO_PASSWORD_OPTIONAL))
+	if (!protocol || !(purple_protocol_get_options(protocol) & OPT_PROTO_PASSWORD_OPTIONAL))
 		purple_request_field_set_required(field, TRUE);
 	purple_request_field_group_add_field(group, field);
 
diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -915,8 +915,8 @@ void
 	else
 	{
 		if (((password == NULL) || (*password == '\0')) &&
-			!(protocol->options & OPT_PROTO_NO_PASSWORD) &&
-			!(protocol->options & OPT_PROTO_PASSWORD_OPTIONAL))
+			!(purple_protocol_get_options(protocol) & OPT_PROTO_NO_PASSWORD) &&
+			!(purple_protocol_get_options(protocol) & OPT_PROTO_PASSWORD_OPTIONAL))
 		{
 			purple_debug_error("connection", "Cannot connect to account %s without "
 							 "a password.\n", purple_account_get_username(account));
@@ -976,8 +976,8 @@ void
 	}
 
 	if (((password == NULL) || (*password == '\0')) &&
-		!(protocol->options & OPT_PROTO_NO_PASSWORD) &&
-		!(protocol->options & OPT_PROTO_PASSWORD_OPTIONAL))
+		!(purple_protocol_get_options(protocol) & OPT_PROTO_NO_PASSWORD) &&
+		!(purple_protocol_get_options(protocol) & OPT_PROTO_PASSWORD_OPTIONAL))
 	{
 		purple_debug_error("connection", "Cannot connect to account %s without "
 						   "a password.\n", purple_account_get_username(account));
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -531,7 +531,7 @@ purple_conversation_write(PurpleConversa
 		protocol = purple_find_protocol_info(purple_account_get_protocol_id(account));
 
 		if (PURPLE_IS_IM_CONVERSATION(conv) ||
-			!(protocol->options & OPT_PROTO_UNIQUE_CHATNAME)) {
+			!(purple_protocol_get_options(protocol) & OPT_PROTO_UNIQUE_CHATNAME)) {
 
 			if (flags & PURPLE_MESSAGE_SEND) {
 				b = purple_blist_find_buddy(account,
diff --git a/libpurple/conversationtypes.c b/libpurple/conversationtypes.c
--- a/libpurple/conversationtypes.c
+++ b/libpurple/conversationtypes.c
@@ -860,7 +860,7 @@ purple_chat_conversation_add_users(Purpl
 		PurpleChatUserFlags flag = GPOINTER_TO_INT(fl->data);
 		const char *extra_msg = (extra_msgs ? extra_msgs->data : NULL);
 
-		if(!(protocol->options & OPT_PROTO_UNIQUE_CHATNAME)) {
+		if(!(purple_protocol_get_options(protocol) & OPT_PROTO_UNIQUE_CHATNAME)) {
 			if (purple_strequal(priv->nick, purple_normalize(account, user))) {
 				const char *alias2 = purple_account_get_private_alias(account);
 				if (alias2 != NULL)
@@ -964,7 +964,7 @@ purple_chat_conversation_rename_user(Pur
 		/* Note this for later. */
 		is_me = TRUE;
 
-		if(!(protocol->options & OPT_PROTO_UNIQUE_CHATNAME)) {
+		if(!(purple_protocol_get_options(protocol) & OPT_PROTO_UNIQUE_CHATNAME)) {
 			alias = purple_account_get_private_alias(account);
 			if (alias != NULL)
 				new_alias = alias;
@@ -975,7 +975,7 @@ purple_chat_conversation_rename_user(Pur
 					new_alias = display_name;
 			}
 		}
-	} else if (!(protocol->options & OPT_PROTO_UNIQUE_CHATNAME)) {
+	} else if (!(purple_protocol_get_options(protocol) & OPT_PROTO_UNIQUE_CHATNAME)) {
 		PurpleBuddy *buddy;
 		if ((buddy = purple_blist_find_buddy(purple_connection_get_account(gc), new_user)) != NULL)
 			new_alias = purple_buddy_get_contact_alias(buddy);
@@ -1024,7 +1024,7 @@ purple_chat_conversation_rename_user(Pur
 			char *escaped;
 			char *escaped2;
 
-			if (!(protocol->options & OPT_PROTO_UNIQUE_CHATNAME)) {
+			if (!(purple_protocol_get_options(protocol) & OPT_PROTO_UNIQUE_CHATNAME)) {
 				PurpleBuddy *buddy;
 
 				if ((buddy = purple_blist_find_buddy(purple_connection_get_account(gc), old_user)) != NULL)
@@ -1104,7 +1104,7 @@ purple_chat_conversation_remove_users(Pu
 			char *alias_esc;
 			char *tmp;
 
-			if (!(protocol->options & OPT_PROTO_UNIQUE_CHATNAME)) {
+			if (!(purple_protocol_get_options(protocol) & OPT_PROTO_UNIQUE_CHATNAME)) {
 				PurpleBuddy *buddy;
 
 				if ((buddy = purple_blist_find_buddy(purple_connection_get_account(gc), user)) != NULL)
diff --git a/libpurple/plugins/one_time_password.c b/libpurple/plugins/one_time_password.c
--- a/libpurple/plugins/one_time_password.c
+++ b/libpurple/plugins/one_time_password.c
@@ -64,10 +64,10 @@ plugin_load(PurplePlugin *plugin)
 	for (l = purple_plugins_get_protocols(); l != NULL; l = l->next) {
 		prpl = (PurplePlugin *)l->data;
 		protocol = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-		if (protocol != NULL && !(protocol->options & OPT_PROTO_NO_PASSWORD)) {
+		if (protocol != NULL && !(purple_protocol_get_options(protocol) & OPT_PROTO_NO_PASSWORD)) {
 			option = purple_account_option_bool_new(_("One Time Password"),
 								PREF_NAME, FALSE);
-			protocol->protocol_options = g_list_append(protocol->protocol_options, option);
+			purple_protocol_get_protocol_options(protocol) = g_list_append(purple_protocol_get_protocol_options(protocol), option);
 		}
 	}
 
@@ -90,12 +90,12 @@ plugin_unload(PurplePlugin *plugin)
 	for (l = purple_plugins_get_protocols(); l != NULL; l = l->next) {
 		prpl = (PurplePlugin *)l->data;
 		protocol = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-		if (protocol != NULL && !(protocol->options & OPT_PROTO_NO_PASSWORD)) {
-			options = protocol->protocol_options;
+		if (protocol != NULL && !(purple_protocol_get_options(protocol) & OPT_PROTO_NO_PASSWORD)) {
+			options = purple_protocol_get_protocol_options(protocol);
 			while (options != NULL) {
 				option = (PurpleAccountOption *) options->data;
 				if (strcmp(PREF_NAME, purple_account_option_get_setting(option)) == 0) {
-					protocol->protocol_options = g_list_delete_link(protocol->protocol_options, options);
+					purple_protocol_get_protocol_options(protocol) = g_list_delete_link(purple_protocol_get_protocol_options(protocol), options);
 					purple_account_option_destroy(option);
 					break;
 				}
diff --git a/libpurple/protocols.c b/libpurple/protocols.c
--- a/libpurple/protocols.c
+++ b/libpurple/protocols.c
@@ -659,25 +659,25 @@ purple_protocol_destroy(PurpleProtocol *
 		if (purple_account_is_disconnected(account))
 			continue;
 
-		if (purple_strequal(protocol->id, purple_account_get_protocol_id(account)))
+		if (purple_strequal(purple_protocol_get_id(protocol), purple_account_get_protocol_id(account)))
 			purple_account_disconnect(account);
 	}
 
 	g_list_free(accounts);
 
-	while (protocol->user_splits) {
-		PurpleAccountUserSplit *split = protocol->user_splits->data;
+	while (purple_protocol_get_user_splits(protocol)) {
+		PurpleAccountUserSplit *split = purple_protocol_get_user_splits(protocol)->data;
 		purple_account_user_split_destroy(split);
-		protocol->user_splits = g_list_delete_link(protocol->user_splits,
-				protocol->user_splits);
+		purple_protocol_get_user_splits(protocol) = g_list_delete_link(purple_protocol_get_user_splits(protocol),
+				purple_protocol_get_user_splits(protocol));
 	}
 
-	while (protocol->protocol_options) {
-		PurpleAccountOption *option = protocol->protocol_options->data;
+	while (purple_protocol_get_protocol_options(protocol)) {
+		PurpleAccountOption *option = purple_protocol_get_protocol_options(protocol)->data;
 		purple_account_option_destroy(option);
-		protocol->protocol_options =
-				g_list_delete_link(protocol->protocol_options,
-				protocol->protocol_options);
+		purple_protocol_get_protocol_options(protocol) =
+				g_list_delete_link(purple_protocol_get_protocol_options(protocol),
+				purple_protocol_get_protocol_options(protocol));
 	}
 
 	purple_request_close_with_handle(protocol);
diff --git a/libpurple/whiteboard.c b/libpurple/whiteboard.c
--- a/libpurple/whiteboard.c
+++ b/libpurple/whiteboard.c
@@ -75,7 +75,7 @@ PurpleWhiteboard *purple_whiteboard_crea
 	wb->who     = g_strdup(who);
 
 	protocol = purple_connection_get_protocol_info(purple_account_get_connection(account));
-	purple_whiteboard_set_protocol_ops(wb, protocol->whiteboard_protocol_ops);
+	purple_whiteboard_set_protocol_ops(wb, purple_protocol_get_whiteboard_ops(protocol));
 
 	/* Start up protocol specifics */
 	if(wb->protocol_ops && wb->protocol_ops->start)
diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
--- a/pidgin/gtkaccount.c
+++ b/pidgin/gtkaccount.c
@@ -203,13 +203,13 @@ set_dialog_icon(AccountPrefsDialog *dial
 	}
 
 	if (pixbuf && dialog->protocol &&
-	    (dialog->protocol->icon_spec.scale_rules & PURPLE_ICON_SCALE_DISPLAY))
+	    (dialog->purple_protocol_get_icon_spec(protocol).scale_rules & PURPLE_ICON_SCALE_DISPLAY))
 	{



More information about the Commits mailing list