gobjectification: 855e08f7: Hide some of the struct members of Purpl...

sadrul at pidgin.im sadrul at pidgin.im
Sun Jun 22 17:50:40 EDT 2008


-----------------------------------------------------------------
Revision: 855e08f7caf0c5a56a9ecec94f0d59f3daaac32b
Ancestor: 31a07cc53ba9397f832e19caeba0b8e391c747ed
Author: sadrul at pidgin.im
Date: 2008-06-22T21:37:51
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/855e08f7caf0c5a56a9ecec94f0d59f3daaac32b

Modified files:
        libpurple/account.c libpurple/account.h
        libpurple/conversation.c libpurple/plugins/log_reader.c
        libpurple/protocols/jabber/auth.c
        libpurple/protocols/oscar/oscar.c
        libpurple/protocols/silc/silc.c
        libpurple/protocols/yahoo/yahoo_aliases.c

ChangeLog: 

Hide some of the struct members of PurpleAccount.

-------------- next part --------------
============================================================
--- libpurple/account.c	771c682a562430c929261ce0d4ec21804e7f3327
+++ libpurple/account.c	dc825787568d1bfebd2639a5f47e7e4e1244606d
@@ -45,6 +45,17 @@ struct _PurpleAccountPrivate
 
 struct _PurpleAccountPrivate
 {
+	char *username;             /**< The username.                          */
+	char *alias;                /**< How you appear to yourself.            */
+	char *password;             /**< The account password.                  */
+	char *user_info;            /**< User information.                      */
+
+	char *buddy_icon_path;      /**< The buddy icon's non-cached path.      */
+
+	gboolean remember_pass;     /**< Remember the password.                 */
+
+	char *protocol_id;          /**< The ID of the protocol.                */
+
 	PurpleConnectionErrorInfo *current_error;
 	gboolean check_mail;
 	gboolean enabled;
@@ -443,6 +454,7 @@ purple_account_set_property(GObject *obj
 		case PROP_PRPL:
 #warning use _object when the prpls are GObjects
 			account->priv->prpl = g_value_get_pointer(value);
+			account->priv->protocol_id = g_strdup(purple_plugin_get_id(account->priv->prpl));
 			break;
 		case PROP_USER_INFO:
 			purple_account_set_user_info(account, g_value_get_string(value));
@@ -555,13 +567,15 @@ purple_account_finalize(GObject *object)
 			purple_conversation_set_account(conv, NULL);
 	}
 
-	g_free(account->username);
-	g_free(account->alias);
-	g_free(account->password);
-	g_free(account->user_info);
-	g_free(account->buddy_icon_path);
-	g_free(account->protocol_id);
+	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
 
+	g_free(account->priv->username);
+	g_free(account->priv->alias);
+	g_free(account->priv->password);
+	g_free(account->priv->user_info);
+	g_free(account->priv->buddy_icon_path);
+	g_free(account->priv->protocol_id);
+
 	g_hash_table_destroy(account->settings);
 	g_hash_table_destroy(account->ui_settings);
 
@@ -572,7 +586,6 @@ purple_account_finalize(GObject *object)
 	if(account->system_log)
 		purple_log_free(account->system_log);
 
-	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
 	PURPLE_DBUS_UNREGISTER_POINTER(priv->current_error);
 	g_free(priv->current_error);
 	g_free(priv);
@@ -1207,14 +1220,17 @@ purple_account_set_username(PurpleAccoun
 void
 purple_account_set_username(PurpleAccount *account, const char *username)
 {
+	PurpleAccountPrivate *priv;
+
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 	g_return_if_fail(username != NULL);
 
-	if (purple_util_strings_equal(account->username, username))
+	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+	if (purple_util_strings_equal(priv->username, username))
 		return;
 
-	g_free(account->username);
-	account->username = g_strdup(username);
+	g_free(priv->username);
+	priv->username = g_strdup(username);
 	g_object_notify(G_OBJECT(account), PROP_USERNAME_S);
 
 	/* if the name changes, we should re-write the buddy list
@@ -1225,26 +1241,32 @@ purple_account_set_password(PurpleAccoun
 void
 purple_account_set_password(PurpleAccount *account, const char *password)
 {
+	PurpleAccountPrivate *priv;
+
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
-	if (purple_util_strings_equal(account->password, password))
+	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+	if (purple_util_strings_equal(priv->password, password))
 		return;
 
-	g_free(account->password);
-	account->password = g_strdup(password);
+	g_free(priv->password);
+	priv->password = g_strdup(password);
 	g_object_notify(G_OBJECT(account), PROP_PASSWORD_S);
 }
 
 void
 purple_account_set_alias(PurpleAccount *account, const char *alias)
 {
+	PurpleAccountPrivate *priv;
+
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
-	if (purple_util_strings_equal(account->alias, alias))
+	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+	if (purple_util_strings_equal(priv->alias, alias))
 		return;
 
-	g_free(account->alias);
-	account->alias = g_strdup(alias);
+	g_free(priv->alias);
+	priv->alias = g_strdup(alias);
 	g_object_notify(G_OBJECT(account), PROP_PRIVATE_ALIAS_S);
 #if 0
 	/* XXX: For now, we don't have a signale for this event, since the
@@ -1259,25 +1281,33 @@ purple_account_set_user_info(PurpleAccou
 void
 purple_account_set_user_info(PurpleAccount *account, const char *user_info)
 {
+	PurpleAccountPrivate *priv;
+
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
-	if (purple_util_strings_equal(account->user_info, user_info))
+	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+
+	if (purple_util_strings_equal(priv->user_info, user_info))
 		return;
 
-	g_free(account->user_info);
-	account->user_info = g_strdup(user_info);
+	g_free(priv->user_info);
+	priv->user_info = g_strdup(user_info);
 	g_object_notify(G_OBJECT(account), PROP_USER_INFO_S);
 }
 
 void purple_account_set_buddy_icon_path(PurpleAccount *account, const char *path)
 {
+	PurpleAccountPrivate *priv;
+
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
-	if (purple_util_strings_equal(account->buddy_icon_path, path))
+	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+
+	if (purple_util_strings_equal(priv->buddy_icon_path, path))
 		return;
 
-	g_free(account->buddy_icon_path);
-	account->buddy_icon_path = g_strdup(path);
+	g_free(priv->buddy_icon_path);
+	priv->buddy_icon_path = g_strdup(path);
 	g_object_notify(G_OBJECT(account), PROP_BUDDY_ICON_PATH_S);
 }
 
@@ -1303,21 +1333,25 @@ purple_account_set_remember_password(Pur
 void
 purple_account_set_remember_password(PurpleAccount *account, gboolean value)
 {
+	PurpleAccountPrivate *priv;
+
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
-	if (account->remember_pass == value)
+	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+	if (priv->remember_pass == value)
 		return;
-	account->remember_pass = value;
+	priv->remember_pass = value;
 	g_object_notify(G_OBJECT(account), PROP_REMEMBER_PASSWORD_S);
 }
 
 void
 purple_account_set_check_mail(PurpleAccount *account, gboolean value)
 {
-	PurpleAccountPrivate *priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+	PurpleAccountPrivate *priv;
 
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
+	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
 	if (priv->check_mail == value)
 		return;
 	priv->check_mail = value;
@@ -1742,7 +1776,7 @@ purple_account_get_username(const Purple
 {
 	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
-	return account->username;
+	return PURPLE_ACCOUNT_GET_PRIVATE(account)->username;
 }
 
 const char *
@@ -1750,7 +1784,7 @@ purple_account_get_password(const Purple
 {
 	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
-	return account->password;
+	return PURPLE_ACCOUNT_GET_PRIVATE(account)->password;
 }
 
 const char *
@@ -1758,7 +1792,7 @@ purple_account_get_alias(const PurpleAcc
 {
 	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
-	return account->alias;
+	return PURPLE_ACCOUNT_GET_PRIVATE(account)->alias;
 }
 
 const char *
@@ -1766,7 +1800,7 @@ purple_account_get_user_info(const Purpl
 {
 	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
-	return account->user_info;
+	return PURPLE_ACCOUNT_GET_PRIVATE(account)->user_info;
 }
 
 const char *
@@ -1774,14 +1808,15 @@ purple_account_get_buddy_icon_path(const
 {
 	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
-	return account->buddy_icon_path;
+	return PURPLE_ACCOUNT_GET_PRIVATE(account)->buddy_icon_path;
 }
 
 const char *
 purple_account_get_protocol_id(const PurpleAccount *account)
 {
 	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
-	return account->protocol_id;
+
+	return PURPLE_ACCOUNT_GET_PRIVATE(account)->protocol_id;
 }
 
 const char *
@@ -1809,7 +1844,7 @@ purple_account_get_remember_password(con
 {
 	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), FALSE);
 
-	return account->remember_pass;
+	return PURPLE_ACCOUNT_GET_PRIVATE(account)->remember_pass;
 }
 
 gboolean
============================================================
--- libpurple/account.h	5c47ec2d685f633bea28d0eb02d192637e9ef82c
+++ libpurple/account.h	750313c104c561763790d46cdfae899ab9e44540
@@ -126,17 +126,6 @@ struct _PurpleAccount
 
 	PurpleAccountPrivate *priv;
 
-	char *username;             /**< The username.                          */
-	char *alias;                /**< How you appear to yourself.            */
-	char *password;             /**< The account password.                  */
-	char *user_info;            /**< User information.                      */
-
-	char *buddy_icon_path;      /**< The buddy icon's non-cached path.      */
-
-	gboolean remember_pass;     /**< Remember the password.                 */
-
-	char *protocol_id;          /**< The ID of the protocol.                */
-
 	PurpleConnection *gc;         /**< The connection handle.                 */
 	gboolean disconnecting;     /**< The account is currently disconnecting */
 
============================================================
--- libpurple/conversation.c	09534f1e8cf582be64564d5989748c2aa54229bd
+++ libpurple/conversation.c	f246947ec7d829ca16328e601af8f1826a5413bb
@@ -903,7 +903,7 @@ purple_conversation_write(PurpleConversa
 							purple_account_get_username(account));
 
 				if (purple_account_get_alias(account) != NULL)
-					alias = account->alias;
+					alias = purple_account_get_alias(account);
 				else if (b != NULL && strcmp(b->name, purple_buddy_get_contact_alias(b)))
 					alias = purple_buddy_get_contact_alias(b);
 				else if (purple_connection_get_display_name(gc) != NULL)
============================================================
--- libpurple/plugins/log_reader.c	3f2017ee630d98a99a27aa4d8cc9e40e43727024
+++ libpurple/plugins/log_reader.c	f418e36b7a85b2063bf235ab1631150ae2e02ecc
@@ -984,9 +984,9 @@ static char * msn_logger_read (PurpleLog
 				if (buddy && buddy->alias)
 					their_name = buddy->alias;
 
-				if (log->account->alias)
+				if (purple_account_get_alias(log->account))
 				{
-					alias = log->account->alias;
+					alias = purple_account_get_alias(log->account);
 					alias_length = strlen(alias);
 				}
 				else
@@ -1111,8 +1111,8 @@ static char * msn_logger_read (PurpleLog
 			text = g_string_append(text, "<b>");
 
 			if (name_guessed == NAME_GUESS_ME) {
-				if (log->account->alias)
-					text = g_string_append(text, log->account->alias);
+				if (purple_account_get_alias(log->account))
+					text = g_string_append(text, purple_account_get_alias(log->account));
 				else
 					text = g_string_append(text, purple_account_get_username(log->account));
 			}
============================================================
--- libpurple/protocols/jabber/auth.c	b6999e84387ddf7e62035f1d38c5509ae2f873db
+++ libpurple/protocols/jabber/auth.c	cc572d37e6d6c04f14f3f3b169b26a302a7a7567
@@ -529,14 +529,15 @@ jabber_auth_start(JabberStream *js, xmln
 		js->auth_type = JABBER_AUTH_PLAIN;
 
 		if(js->gsc == NULL && !purple_account_get_bool(purple_connection_get_account(js->gc), "auth_plain_in_clear", FALSE)) {
+			PurpleAccount *account = purple_connection_get_account(js->gc);
 			char *msg = g_strdup_printf(_("%s requires plaintext authentication over an unencrypted connection.  Allow this and continue authentication?"),
-					purple_connection_get_account(js->gc)->username);
+					purple_account_get_username(account));
 			purple_request_yes_no(js->gc, _("Plaintext Authentication"),
 					_("Plaintext Authentication"),
 					msg,
 					1,
-					purple_connection_get_account(js->gc), NULL, NULL,
-					purple_connection_get_account(js->gc), allow_plaintext_auth,
+					account, NULL, NULL,
+					account, allow_plaintext_auth,
 					disallow_plaintext_auth);
 			g_free(msg);
 			return;
@@ -722,14 +723,15 @@ static void auth_old_cb(JabberStream *js
 		} else if(xmlnode_get_child(query, "password")) {
 			if(js->gsc == NULL && !purple_account_get_bool(purple_connection_get_account(js->gc),
 						"auth_plain_in_clear", FALSE)) {
+				PurpleAccount *account = purple_connection_get_account(js->gc);
 				char *msg = g_strdup_printf(_("%s requires plaintext authentication over an unencrypted connection.  Allow this and continue authentication?"),
-											purple_connection_get_account(js->gc)->username);
+						purple_account_get_username(account));
 				purple_request_yes_no(js->gc, _("Plaintext Authentication"),
 						_("Plaintext Authentication"),
 						msg,
 						1,
-						purple_connection_get_account(js->gc), NULL, NULL,
-						purple_connection_get_account(js->gc), allow_plaintext_auth,
+						account, NULL, NULL,
+						account, allow_plaintext_auth,
 						disallow_plaintext_auth);
 				g_free(msg);
 				return;
============================================================
--- libpurple/protocols/oscar/oscar.c	12d5d449a524fa9ac10fa13ba6144c099da2ab3b
+++ libpurple/protocols/oscar/oscar.c	e0e369a3e249a590e2c56022887b5a59d07c7d36
@@ -3571,7 +3571,7 @@ static int purple_parse_locaterights(Osc
 	od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen;
 
 	aim_locate_setcaps(od, purple_caps);
-	oscar_set_info_and_status(account, TRUE, account->user_info, TRUE,
+	oscar_set_info_and_status(account, TRUE, purple_account_get_user_info(account), TRUE,
 							  purple_account_get_active_status(account));
 
 	return 1;
@@ -3670,7 +3670,7 @@ static int purple_bosrights(OscarData *o
 	 * breaks mail notification for @mac.com accounts, but it gets rid
 	 * of an annoying error at signon for @anythingelse.com accounts.
 	 */
-	if ((od->authinfo->email != NULL) && ((strchr(purple_connection_get_account(gc)->username, '@') == NULL)))
+	if ((od->authinfo->email != NULL) && ((strchr(purple_account_get_username(account), '@') == NULL)))
 		aim_srv_requestnew(od, SNAC_FAMILY_ALERT);
 
 	return 1;
@@ -5961,6 +5961,7 @@ static void oscar_ssi_editcomment(struct
 	OscarData *od = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	PurpleBuddy *b;
 	PurpleGroup *g;
+	PurpleAccount *account = purple_connection_get_account(gc);
 
 	if (!(b = purple_find_buddy(purple_connection_get_account(data->gc), data->name))) {
 		oscar_free_name_data(data);
@@ -5974,7 +5975,7 @@ static void oscar_ssi_editcomment(struct
 
 	aim_ssi_editcomment(od, g->name, data->name, text);
 
-	if (!aim_sncmp(data->name, purple_connection_get_account(gc)->username))
+	if (!aim_sncmp(data->name, purple_account_get_username(account)))
 		purple_check_comment(od, text);
 
 	oscar_free_name_data(data);
============================================================
--- libpurple/protocols/silc/silc.c	ea18b8c607c0bc7dc28a8169a1e5f48ba62f5a71
+++ libpurple/protocols/silc/silc.c	54872be2e4548bef1a0cf8da11add2f8f401f98b
@@ -1551,6 +1551,7 @@ static PurpleCmdRet silcpurple_cmd_chat_
 		return PURPLE_CMD_RET_FAILED;
 
 	if (!args || !args[0]) {
+		PurpleAccount *account = purple_connection_get_account(gc);
 		topic = purple_conv_chat_get_topic (PURPLE_CONV_CHAT(conv));
 		if (topic) {
 			tmp = g_markup_escape_text(topic, -1);
@@ -1560,7 +1561,7 @@ static PurpleCmdRet silcpurple_cmd_chat_
 			g_free(tmp2);
 		} else
 			buf = g_strdup(_("No topic is set"));
-		purple_conv_chat_write(PURPLE_CONV_CHAT(conv), purple_connection_get_account(gc)->username, buf,
+		purple_conv_chat_write(PURPLE_CONV_CHAT(conv), purple_account_get_username(account), buf,
 							 PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
 		g_free(buf);
 
============================================================
--- libpurple/protocols/yahoo/yahoo_aliases.c	cc671eb532e7aadbc1e78988e55ef628302a661b
+++ libpurple/protocols/yahoo/yahoo_aliases.c	0cd4fe467825ac3726d74fe7b31fc4939e1f367d
@@ -240,9 +240,12 @@ yahoo_update_alias(PurpleConnection *gc,
 	PurpleBuddy *buddy;
 	PurpleUtilFetchUrlData *url_data;
 	gboolean use_whole_url = FALSE;
+	PurpleAccount *account;
 
+	account = purple_connection_get_account(gc);
+
 	/* use whole URL if using HTTP Proxy */
-	if ((purple_connection_get_account(gc)->proxy_info) && (purple_connection_get_account(gc)->proxy_info->type == PURPLE_PROXY_HTTP))
+	if ((account->proxy_info) && (account->proxy_info->type == PURPLE_PROXY_HTTP))
 	    use_whole_url = TRUE;
 
 	g_return_if_fail(alias != NULL);
@@ -251,7 +254,7 @@ yahoo_update_alias(PurpleConnection *gc,
 
 	purple_debug_info("yahoo", "Sending '%s' as new alias for user '%s'.\n",alias, who);
 
-	buddy = purple_find_buddy(purple_connection_get_account(gc), who);
+	buddy = purple_find_buddy(account, who);
 	if (buddy == NULL || buddy->proto_data == NULL) {
 		purple_debug_info("yahoo", "Missing proto_data (get_yahoo_aliases must have failed), bailing out\n");
 		return;
@@ -274,7 +277,7 @@ yahoo_update_alias(PurpleConnection *gc,
 		converted_alias_jp = yahoo_convert_to_numeric(alias_jp);
 		content = g_strdup_printf("<ab k=\"%s\" cc=\"1\">\n"
 		                          "<ct e=\"1\"  yi='%s' id='%s' nn='%s' pr='0' />\n</ab>\r\n",
-		                          purple_connection_get_account(gc)->username, who, yu->id, converted_alias_jp);
+		                          purple_account_get_username(account), who, yu->id, converted_alias_jp);
 		free(converted_alias_jp);
 		g_free(alias_jp);
 	}
@@ -282,7 +285,7 @@ yahoo_update_alias(PurpleConnection *gc,
 		escaped_alias = g_markup_escape_text(alias, strlen(alias));
 		content = g_strdup_printf("<?xml version=\"1.0\" encoding=\"utf-8\"?><ab k=\"%s\" cc=\"1\">\n"
 		                          "<ct e=\"1\"  yi='%s' id='%s' nn='%s' pr='0' />\n</ab>\r\n",
-		                          purple_connection_get_account(gc)->username, who, yu->id, escaped_alias);
+		                          purple_account_get_username(account), who, yu->id, escaped_alias);
 		g_free(escaped_alias);
 	}
 


More information about the Commits mailing list