gobjectification: c9132cca: Convert PurpleAccount into GObject.

sadrul at pidgin.im sadrul at pidgin.im
Sun Jun 22 14:42:06 EDT 2008


-----------------------------------------------------------------
Revision: c9132cca3739ff1c47ef41beafb8521c3ed8b8bb
Ancestor: 79ecaafd47f4117c4c06abd0c58198889d2dac5a
Author: sadrul at pidgin.im
Date: 2008-06-22T05:58:54
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/c9132cca3739ff1c47ef41beafb8521c3ed8b8bb

Modified files:
        libpurple/account.c libpurple/account.h
        libpurple/connection.c libpurple/example/nullclient.c
        libpurple/protocols/msnp9/msn.c
        libpurple/protocols/msnp9/user.c libpurple/status.c
        libpurple/util.c

ChangeLog: 

Convert PurpleAccount into GObject.

-------------- next part --------------
============================================================
--- libpurple/account.c	7ed035f030c6dd9798efae88a2d5cba4265d6952
+++ libpurple/account.c	8a88522e9db92bdb685808eca6613d0d8f97d03d
@@ -46,6 +46,8 @@ struct _PurpleAccountPrivate
 struct _PurpleAccountPrivate
 {
 	PurpleConnectionErrorInfo *current_error;
+	gboolean enabled;
+	PurplePlugin *prpl;
 };
 
 #define PURPLE_ACCOUNT_GET_PRIVATE(account) \
@@ -490,22 +492,236 @@ delete_setting(void *data)
 }
 
 /****************
- * Purple Account
+ * GObject Code *
  ****************/
-static void purple_account_class_init(PurpleAccountClass *klass)
+static GObjectClass *parent_class = NULL;
+
+/* GObject Property enums */
+enum
 {
-#warning TODO: create signals and properties
+	PROP_0,
+	PROP_USERNAME,
+	PROP_PASSWORD,
+	PROP_PRIVATE_ALIAS,
+	PROP_PUBLIC_ALIAS,
+	PROP_ENABLED,
+	PROP_CONNECTION,
+	PROP_PRPL,
+	PROP_LAST
+};
+
+/* GObject Property names */
+#define PROP_USERNAME_S        "username"
+#define PROP_PASSWORD_S        "password"
+#define PROP_PRIVATE_ALIAS_S   "private-alias"
+#define PROP_PUBLIC_ALIAS_S    "public-alias"
+#define PROP_ENABLED_S         "enabled"
+#define PROP_CONNECTION_S      "connection"
+#define PROP_PRPL_S            "prpl"
+
+/* GObject Signal enums */
+enum
+{
+	SIG_SETTING_INFO,
+	SIG_LAST
+};
+static guint signals[SIG_LAST] = { 0, };
+
+/* Set method for GObject properties */
+static void
+purple_account_set_property(GObject *obj, guint param_id, const GValue *value,
+		GParamSpec *pspec)
+{
+	PurpleAccount *account = PURPLE_ACCOUNT(obj);
+	switch (param_id) {
+		case PROP_USERNAME:
+			purple_account_set_username(account, g_value_get_string(value));
+			break;
+		case PROP_PASSWORD:
+			purple_account_set_password(account, g_value_get_string(value));
+			break;
+		case PROP_PRIVATE_ALIAS:
+			purple_account_set_alias(account, g_value_get_string(value));
+			break;
+		case PROP_PUBLIC_ALIAS:
+#warning TODO: _public_alias and _private_alias foo
+			break;
+		case PROP_ENABLED:
+			purple_account_set_enabled(account, g_value_get_boolean(value));
+			break;
+		case PROP_CONNECTION:
+			purple_account_set_connection(account,
+				PURPLE_CONNECTION(g_value_get_object(value)));
+			break;
+		case PROP_PRPL:
+#warning use _object when the prpls are GObjects
+			account->priv->prpl = g_value_get_pointer(value);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+			break;
+	}
 }
 
+/* Get method for GObject properties */
+static void
+purple_account_get_property(GObject *obj, guint param_id, GValue *value,
+		GParamSpec *pspec)
+{
+	PurpleAccount *account = PURPLE_ACCOUNT(obj);
+	switch (param_id) {
+		case PROP_USERNAME:
+			g_value_set_string(value, purple_account_get_username(account));
+			break;
+		case PROP_PASSWORD:
+			g_value_set_string(value, purple_account_get_password(account));
+			break;
+		case PROP_PRIVATE_ALIAS:
+			g_value_set_string(value, purple_account_get_alias(account));
+			break;
+		case PROP_PUBLIC_ALIAS:
+#warning TODO: _public_alias and _private_alias foo
+			break;
+		case PROP_ENABLED:
+			g_value_set_boolean(value,
+					purple_account_get_enabled(account));
+			break;
+		case PROP_CONNECTION:
+			g_value_set_object(value,
+					purple_account_get_connection(account));
+			break;
+		case PROP_PRPL:
+#warning Use _object when prpls are GObjects
+			g_value_set_pointer(value, account->priv->prpl);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+			break;
+	}
+}
+
+/* Gobject initialization function */
 static void purple_account_init(GTypeInstance *instance, gpointer klass)
 {
-#warning TODO: Move the initializations from _account_new to here
-
 	PurpleAccount *account = PURPLE_ACCOUNT(instance);
 
 	account->priv = g_new0(PurpleAccountPrivate, 1);
+
+	account->settings = g_hash_table_new_full(g_str_hash, g_str_equal,
+			g_free, delete_setting);
+	account->ui_settings = g_hash_table_new_full(g_str_hash, g_str_equal,
+			g_free, (GDestroyNotify)g_hash_table_destroy);
+	account->system_log = NULL;
+
+	account->perm_deny = PURPLE_PRIVACY_ALLOW_ALL;
 }
 
+/* GObject destructor function */
+static void
+purple_account_finalize(GObject *object)
+{
+	PurpleAccountPrivate *priv = NULL;
+	GList *l;
+	PurpleAccount *account = PURPLE_ACCOUNT(object);
+
+	purple_debug_info("account", "Destroying account %p\n", account);
+
+	/* Make sure we disconnect first */
+	purple_account_set_connection(account, NULL);
+
+	for (l = purple_get_conversations(); l != NULL; l = l->next) {
+		PurpleConversation *conv = (PurpleConversation *)l->data;
+
+		if (purple_conversation_get_account(conv) == account)
+			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);
+
+	g_hash_table_destroy(account->settings);
+	g_hash_table_destroy(account->ui_settings);
+
+	purple_account_set_status_types(account, NULL);
+
+	purple_presence_destroy(account->presence);
+
+	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);
+
+	PURPLE_DBUS_UNREGISTER_POINTER(account);
+	parent_class->finalize(object);
+}
+
+/* Class initializer function */
+static void purple_account_class_init(PurpleAccountClass *klass)
+{
+	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+
+	parent_class = g_type_class_peek_parent(klass);
+
+	obj_class->finalize = purple_account_finalize;
+
+	/* Setup properties */
+	obj_class->get_property = purple_account_get_property;
+	obj_class->set_property = purple_account_set_property;
+
+	g_object_class_install_property(obj_class, PROP_USERNAME,
+			g_param_spec_string(PROP_USERNAME_S, _("Username"),
+				_("The username for the account."), NULL,
+				G_PARAM_READWRITE | G_PARAM_CONSTRUCT)
+			);
+
+	g_object_class_install_property(obj_class, PROP_PASSWORD,
+			g_param_spec_string(PROP_PASSWORD_S, _("Password"),
+				_("The password for the account."), NULL,
+				G_PARAM_READWRITE)
+			);
+
+	g_object_class_install_property(obj_class, PROP_PRIVATE_ALIAS,
+			g_param_spec_string(PROP_PRIVATE_ALIAS_S, _("Private Alias"),
+				_("The private alias for the account."), NULL,
+				G_PARAM_READWRITE)
+			);
+
+	g_object_class_install_property(obj_class, PROP_PUBLIC_ALIAS,
+			g_param_spec_string(PROP_PUBLIC_ALIAS_S, _("Public Alias"),
+				_("The public alias for the account."), NULL,
+				G_PARAM_READWRITE)
+			);
+
+	g_object_class_install_property(obj_class, PROP_ENABLED,
+			g_param_spec_boolean(PROP_ENABLED_S, _("Enabled"),
+				_("Whether the account is enabled or not."), FALSE,
+				G_PARAM_READWRITE | G_PARAM_CONSTRUCT)
+			);
+
+	g_object_class_install_property(obj_class, PROP_CONNECTION,
+			g_param_spec_object(PROP_CONNECTION_S, _("Connection"),
+				_("The PurpleConnection object for the account."),
+				PURPLE_TYPE_CONNECTION,
+				G_PARAM_READWRITE)
+			);
+#warning Use _object when protocol plugins are objects
+	g_object_class_install_property(obj_class, PROP_PRPL,
+			g_param_spec_pointer(PROP_PRPL_S, _("Protocol Plugin"),
+				_("The protocol plugin that is responsible for the account."),
+				G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)
+			);
+
+	/* Setup signals */
+#warning TODO: Setup signals
+}
+
 GType purple_account_get_gtype(void)
 {
 	static GType type = 0;
@@ -532,12 +748,10 @@ GType purple_account_get_gtype(void)
 	return type;
 }
 
-
 PurpleAccount *
 purple_account_new(const char *username, const char *protocol_id)
 {
 	PurpleAccount *account = NULL;
-	PurpleAccountPrivate *priv = NULL;
 	PurplePlugin *prpl = NULL;
 	PurplePluginProtocolInfo *prpl_info = NULL;
 	PurpleStatusType *status_type;
@@ -550,28 +764,18 @@ purple_account_new(const char *username,
 	if (account != NULL)
 		return account;
 
-	account = g_new0(PurpleAccount, 1);
-	PURPLE_DBUS_REGISTER_POINTER(account, PurpleAccount);
-	priv = g_new0(PurpleAccountPrivate, 1);
-	account->priv = priv;
+	prpl = purple_find_prpl(protocol_id);
+	g_return_val_if_fail(prpl != NULL, NULL);
 
-	purple_account_set_username(account, username);
+	account = g_object_new(PURPLE_TYPE_ACCOUNT,
+			PROP_USERNAME_S, username,
+			PROP_PRPL_S, prpl,
+			NULL);
 
-	purple_account_set_protocol_id(account, protocol_id);
+	PURPLE_DBUS_REGISTER_POINTER(account, PurpleAccount);
 
-	account->settings = g_hash_table_new_full(g_str_hash, g_str_equal,
-											  g_free, delete_setting);
-	account->ui_settings = g_hash_table_new_full(g_str_hash, g_str_equal,
-				g_free, (GDestroyNotify)g_hash_table_destroy);
-	account->system_log = NULL;
-	/* 0 is not a valid privacy setting */
-	account->perm_deny = PURPLE_PRIVACY_ALLOW_ALL;
+	purple_account_set_protocol_id(account, protocol_id);
 
-	prpl = purple_find_prpl(protocol_id);
-
-	if (prpl == NULL)
-		return account;
-
 	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
 	if (prpl_info != NULL && prpl_info->status_types != NULL)
 		purple_account_set_status_types(account, prpl_info->status_types(account));
@@ -579,14 +783,15 @@ purple_account_new(const char *username,
 	account->presence = purple_presence_new_for_account(account);
 
 	status_type = purple_account_get_status_type_with_primitive(account, PURPLE_STATUS_AVAILABLE);
-	if (status_type != NULL)
+	if (status_type != NULL) {
 		purple_presence_set_status_active(account->presence,
-										purple_status_type_get_id(status_type),
-										TRUE);
-	else
+				purple_status_type_get_id(status_type),
+				TRUE);
+	} else {
 		purple_presence_set_status_active(account->presence,
-										"offline",
-										TRUE);
+				"offline",
+				TRUE);
+	}
 
 	return account;
 }
@@ -594,51 +799,14 @@ purple_account_destroy(PurpleAccount *ac
 void
 purple_account_destroy(PurpleAccount *account)
 {
-	PurpleAccountPrivate *priv = NULL;
-	GList *l;
-
-	g_return_if_fail(account != NULL);
-
-	purple_debug_info("account", "Destroying account %p\n", account);
-
-	for (l = purple_get_conversations(); l != NULL; l = l->next)
-	{
-		PurpleConversation *conv = (PurpleConversation *)l->data;
-
-		if (purple_conversation_get_account(conv) == account)
-			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);
-
-	g_hash_table_destroy(account->settings);
-	g_hash_table_destroy(account->ui_settings);
-
-	purple_account_set_status_types(account, NULL);
-
-	purple_presence_destroy(account->presence);
-
-	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);
-
-	PURPLE_DBUS_UNREGISTER_POINTER(account);
-	g_free(account);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
+	g_object_unref(G_OBJECT(account));
 }
 
 void
 purple_account_set_register_callback(PurpleAccount *account, PurpleAccountRegistrationCb cb, void *user_data)
 {
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	account->registration_cb = cb;
 	account->registration_cb_user_data = user_data;
@@ -647,7 +815,7 @@ purple_account_register(PurpleAccount *a
 void
 purple_account_register(PurpleAccount *account)
 {
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	purple_debug_info("account", "Registering account %s\n",
 					purple_account_get_username(account));
@@ -658,7 +826,7 @@ purple_account_unregister(PurpleAccount 
 void
 purple_account_unregister(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data)
 {
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	purple_debug_info("account", "Unregistering account %s\n",
 					  purple_account_get_username(account));
@@ -693,7 +861,7 @@ request_password_cancel_cb(PurpleAccount
 request_password_cancel_cb(PurpleAccount *account, PurpleRequestFields *fields)
 {
 	/* Disable the account as the user has canceled connecting */
-	purple_account_set_enabled(account, purple_core_get_ui(), FALSE);
+	purple_account_set_enabled(account, FALSE);
 }
 
 
@@ -745,12 +913,12 @@ purple_account_connect(PurpleAccount *ac
 	PurplePluginProtocolInfo *prpl_info;
 	const char *password;
 
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	purple_debug_info("account", "Connecting to account %s\n",
 					purple_account_get_username(account));
 
-	if (!purple_account_get_enabled(account, purple_core_get_ui()))
+	if (!purple_account_get_enabled(account))
 		return;
 
 	prpl = purple_find_prpl(purple_account_get_protocol_id(account));
@@ -778,20 +946,16 @@ purple_account_disconnect(PurpleAccount 
 void
 purple_account_disconnect(PurpleAccount *account)
 {
-	PurpleConnection *gc;
-
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 	g_return_if_fail(!purple_account_is_disconnected(account));
 
 	purple_debug_info("account", "Disconnecting account %p\n", account);
 
 	account->disconnecting = TRUE;
 
-	gc = purple_account_get_connection(account);
-	purple_connection_destroy(gc);
+	purple_account_set_connection(account, NULL);
 	if (!purple_account_get_remember_password(account))
 		purple_account_set_password(account, NULL);
-	purple_account_set_connection(account, NULL);
 
 	account->disconnecting = FALSE;
 }
@@ -850,7 +1014,7 @@ purple_account_request_close_with_accoun
 {
 	GList *l, *l_next;
 
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	for (l = handles; l != NULL; l = l_next) {
 		PurpleAccountRequestInfo *info = l->data;
@@ -1002,7 +1166,7 @@ purple_account_request_change_password(P
 	PurplePluginProtocolInfo *prpl_info = NULL;
 	char primary[256];
 
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 	g_return_if_fail(purple_account_is_connected(account));
 
 	gc = purple_account_get_connection(account);
@@ -1073,7 +1237,7 @@ purple_account_request_change_user_info(
 	char primary[256];
 	PurpleConnectionFlags flags = 0;
 
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 	g_return_if_fail(purple_account_is_connected(account));
 
 	gc = purple_account_get_connection(account);
@@ -1096,10 +1260,15 @@ purple_account_set_username(PurpleAccoun
 void
 purple_account_set_username(PurpleAccount *account, const char *username)
 {
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
+	g_return_if_fail(username != NULL);
 
+	if (purple_util_strings_equal(account->username, username))
+		return;
+
 	g_free(account->username);
 	account->username = g_strdup(username);
+	g_object_notify(G_OBJECT(account), PROP_USERNAME_S);
 
 	schedule_accounts_save();
 
@@ -1111,10 +1280,14 @@ purple_account_set_password(PurpleAccoun
 void
 purple_account_set_password(PurpleAccount *account, const char *password)
 {
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
+	if (purple_util_strings_equal(account->password, password))
+		return;
+
 	g_free(account->password);
 	account->password = g_strdup(password);
+	g_object_notify(G_OBJECT(account), PROP_PASSWORD_S);
 
 	schedule_accounts_save();
 }
@@ -1122,33 +1295,29 @@ purple_account_set_alias(PurpleAccount *
 void
 purple_account_set_alias(PurpleAccount *account, const char *alias)
 {
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
-	/*
-	 * Do nothing if alias and account->alias are both NULL.  Or if
-	 * they're the exact same string.
-	 */
-	if (alias == account->alias)
+	if (purple_util_strings_equal(account->alias, alias))
 		return;
 
-	if ((!alias && account->alias) || (alias && !account->alias) ||
-			g_utf8_collate(account->alias, alias))
-	{
-		char *old = account->alias;
-
-		account->alias = g_strdup(alias);
-		purple_signal_emit(purple_accounts_get_handle(), "account-alias-changed",
-						 account, old);
-		g_free(old);
-
-		schedule_accounts_save();
-	}
+	g_free(account->alias);
+	account->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
+	 * 'notify::private-alias' signal is emitted due to g_object_notify anyway.
+	 * If we decide that the old alias is also useful, then we can bring back
+	 * the signal */
+	purple_signal_emit(purple_accounts_get_handle(), "account-alias-changed",
+					 account, old);
+#endif
+	schedule_accounts_save();
 }
 
 void
 purple_account_set_user_info(PurpleAccount *account, const char *user_info)
 {
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	g_free(account->user_info);
 	account->user_info = g_strdup(user_info);
@@ -1158,7 +1327,7 @@ void purple_account_set_buddy_icon_path(
 
 void purple_account_set_buddy_icon_path(PurpleAccount *account, const char *path)
 {
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	g_free(account->buddy_icon_path);
 	account->buddy_icon_path = g_strdup(path);
@@ -1181,18 +1350,26 @@ purple_account_set_connection(PurpleAcco
 void
 purple_account_set_connection(PurpleAccount *account, PurpleConnection *gc)
 {
-	g_return_if_fail(account != NULL);
+	PurpleConnection *old;
 
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
+	g_return_if_fail(gc == NULL || PURPLE_IS_CONNECTION(gc));
+
 #warning Connect and disconnect to 'signed-on' and 'connection-error' on gc and set/clear current_error.
-	if (account->gc)
-		g_object_unref(account->gc);
-	account->gc = gc ? g_object_ref(gc) : NULL;
+	if (account->gc == gc)
+		return;
+
+	old = account->gc;
+	account->gc = gc;
+	if (old)
+		g_object_unref(old);
+	g_object_notify(G_OBJECT(account), PROP_CONNECTION_S);
 }
 
 void
 purple_account_set_remember_password(PurpleAccount *account, gboolean value)
 {
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	account->remember_pass = value;
 
@@ -1202,24 +1379,26 @@ purple_account_set_check_mail(PurpleAcco
 void
 purple_account_set_check_mail(PurpleAccount *account, gboolean value)
 {
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	purple_account_set_bool(account, "check-mail", value);
 }
 
 void
-purple_account_set_enabled(PurpleAccount *account, const char *ui,
-			 gboolean value)
+purple_account_set_enabled(PurpleAccount *account, gboolean value)
 {
 	PurpleConnection *gc;
 	gboolean was_enabled = FALSE;
 
-	g_return_if_fail(account != NULL);
-	g_return_if_fail(ui      != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
-	was_enabled = purple_account_get_enabled(account, ui);
+	was_enabled = purple_account_get_enabled(account);
+	if (was_enabled == value)
+		return;
 
-	purple_account_set_ui_bool(account, ui, "auto-login", value);
+	PURPLE_ACCOUNT_GET_PRIVATE(account)->enabled = value;
+	g_object_notify(G_OBJECT(account), PROP_ENABLED_S);
+
 	gc = purple_account_get_connection(account);
 
 	if(was_enabled && !value)
@@ -1244,7 +1423,7 @@ purple_account_set_proxy_info(PurpleAcco
 void
 purple_account_set_proxy_info(PurpleAccount *account, PurpleProxyInfo *info)
 {
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	if (account->proxy_info != NULL)
 		purple_proxy_info_destroy(account->proxy_info);
@@ -1257,7 +1436,7 @@ purple_account_set_status_types(PurpleAc
 void
 purple_account_set_status_types(PurpleAccount *account, GList *status_types)
 {
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	/* Out with the old... */
 	if (account->status_types != NULL)
@@ -1323,7 +1502,7 @@ purple_account_clear_settings(PurpleAcco
 void
 purple_account_clear_settings(PurpleAccount *account)
 {
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	g_hash_table_destroy(account->settings);
 
@@ -1336,7 +1515,7 @@ purple_account_set_int(PurpleAccount *ac
 {
 	PurpleAccountSetting *setting;
 
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 	g_return_if_fail(name    != NULL);
 
 	setting = g_new0(PurpleAccountSetting, 1);
@@ -1355,7 +1534,7 @@ purple_account_set_string(PurpleAccount 
 {
 	PurpleAccountSetting *setting;
 
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 	g_return_if_fail(name    != NULL);
 
 	setting = g_new0(PurpleAccountSetting, 1);
@@ -1373,7 +1552,7 @@ purple_account_set_bool(PurpleAccount *a
 {
 	PurpleAccountSetting *setting;
 
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 	g_return_if_fail(name    != NULL);
 
 	setting = g_new0(PurpleAccountSetting, 1);
@@ -1409,7 +1588,7 @@ purple_account_set_ui_int(PurpleAccount 
 	PurpleAccountSetting *setting;
 	GHashTable *table;
 
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 	g_return_if_fail(ui      != NULL);
 	g_return_if_fail(name    != NULL);
 
@@ -1433,7 +1612,7 @@ purple_account_set_ui_string(PurpleAccou
 	PurpleAccountSetting *setting;
 	GHashTable *table;
 
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 	g_return_if_fail(ui      != NULL);
 	g_return_if_fail(name    != NULL);
 
@@ -1457,7 +1636,7 @@ purple_account_set_ui_bool(PurpleAccount
 	PurpleAccountSetting *setting;
 	GHashTable *table;
 
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 	g_return_if_fail(ui      != NULL);
 	g_return_if_fail(name    != NULL);
 
@@ -1479,7 +1658,7 @@ purple_account_get_state(const PurpleAcc
 {
 	PurpleConnection *gc;
 
-	g_return_val_if_fail(account != NULL, PURPLE_CONNECTION_STATE_DISCONNECTED);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), PURPLE_CONNECTION_STATE_DISCONNECTED);
 
 	gc = purple_account_get_connection(account);
 	if (!gc)
@@ -1509,7 +1688,7 @@ purple_account_get_username(const Purple
 const char *
 purple_account_get_username(const PurpleAccount *account)
 {
-	g_return_val_if_fail(account != NULL, NULL);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
 	return account->username;
 }
@@ -1517,7 +1696,7 @@ purple_account_get_password(const Purple
 const char *
 purple_account_get_password(const PurpleAccount *account)
 {
-	g_return_val_if_fail(account != NULL, NULL);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
 	return account->password;
 }
@@ -1525,7 +1704,7 @@ purple_account_get_alias(const PurpleAcc
 const char *
 purple_account_get_alias(const PurpleAccount *account)
 {
-	g_return_val_if_fail(account != NULL, NULL);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
 	return account->alias;
 }
@@ -1533,7 +1712,7 @@ purple_account_get_user_info(const Purpl
 const char *
 purple_account_get_user_info(const PurpleAccount *account)
 {
-	g_return_val_if_fail(account != NULL, NULL);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
 	return account->user_info;
 }
@@ -1541,7 +1720,7 @@ purple_account_get_buddy_icon_path(const
 const char *
 purple_account_get_buddy_icon_path(const PurpleAccount *account)
 {
-	g_return_val_if_fail(account != NULL, NULL);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
 	return account->buddy_icon_path;
 }
@@ -1549,7 +1728,7 @@ purple_account_get_protocol_id(const Pur
 const char *
 purple_account_get_protocol_id(const PurpleAccount *account)
 {
-	g_return_val_if_fail(account != NULL, NULL);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 	return account->protocol_id;
 }
 
@@ -1558,7 +1737,7 @@ purple_account_get_protocol_name(const P
 {
 	PurplePlugin *p;
 
-	g_return_val_if_fail(account != NULL, NULL);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
 	p = purple_find_prpl(purple_account_get_protocol_id(account));
 
@@ -1568,7 +1747,7 @@ purple_account_get_connection(const Purp
 PurpleConnection *
 purple_account_get_connection(const PurpleAccount *account)
 {
-	g_return_val_if_fail(account != NULL, NULL);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
 	return account->gc;
 }
@@ -1576,7 +1755,7 @@ purple_account_get_remember_password(con
 gboolean
 purple_account_get_remember_password(const PurpleAccount *account)
 {
-	g_return_val_if_fail(account != NULL, FALSE);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), FALSE);
 
 	return account->remember_pass;
 }
@@ -1584,24 +1763,23 @@ purple_account_get_check_mail(const Purp
 gboolean
 purple_account_get_check_mail(const PurpleAccount *account)
 {
-	g_return_val_if_fail(account != NULL, FALSE);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), FALSE);
 
 	return purple_account_get_bool(account, "check-mail", FALSE);
 }
 
 gboolean
-purple_account_get_enabled(const PurpleAccount *account, const char *ui)
+purple_account_get_enabled(const PurpleAccount *account)
 {
-	g_return_val_if_fail(account != NULL, FALSE);
-	g_return_val_if_fail(ui      != NULL, FALSE);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), FALSE);
 
-	return purple_account_get_ui_bool(account, ui, "auto-login", FALSE);
+	return PURPLE_ACCOUNT_GET_PRIVATE(account)->enabled;
 }
 
 PurpleProxyInfo *
 purple_account_get_proxy_info(const PurpleAccount *account)
 {
-	g_return_val_if_fail(account != NULL, NULL);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
 	return account->proxy_info;
 }
@@ -1628,7 +1806,7 @@ purple_account_get_status_type(const Pur
 {
 	GList *l;
 
-	g_return_val_if_fail(account != NULL, NULL);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 	g_return_val_if_fail(id      != NULL, NULL);
 
 	for (l = purple_account_get_status_types(account); l != NULL; l = l->next)
@@ -1647,7 +1825,7 @@ purple_account_get_status_type_with_prim
 {
 	GList *l;
 
-	g_return_val_if_fail(account != NULL, NULL);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
 	for (l = purple_account_get_status_types(account); l != NULL; l = l->next)
 	{
@@ -1663,7 +1841,7 @@ purple_account_get_presence(const Purple
 PurplePresence *
 purple_account_get_presence(const PurpleAccount *account)
 {
-	g_return_val_if_fail(account != NULL, NULL);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
 	return account->presence;
 }
@@ -1681,7 +1859,7 @@ purple_account_get_status_types(const Pu
 GList *
 purple_account_get_status_types(const PurpleAccount *account)
 {
-	g_return_val_if_fail(account != NULL, NULL);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
 	return account->status_types;
 }
@@ -1692,7 +1870,7 @@ purple_account_get_int(const PurpleAccou
 {
 	PurpleAccountSetting *setting;
 
-	g_return_val_if_fail(account != NULL, default_value);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), default_value);
 	g_return_val_if_fail(name    != NULL, default_value);
 
 	setting = g_hash_table_lookup(account->settings, name);
@@ -1711,7 +1889,7 @@ purple_account_get_string(const PurpleAc
 {
 	PurpleAccountSetting *setting;
 
-	g_return_val_if_fail(account != NULL, default_value);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), default_value);
 	g_return_val_if_fail(name    != NULL, default_value);
 
 	setting = g_hash_table_lookup(account->settings, name);
@@ -1730,7 +1908,7 @@ purple_account_get_bool(const PurpleAcco
 {
 	PurpleAccountSetting *setting;
 
-	g_return_val_if_fail(account != NULL, default_value);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), default_value);
 	g_return_val_if_fail(name    != NULL, default_value);
 
 	setting = g_hash_table_lookup(account->settings, name);
@@ -1750,7 +1928,7 @@ purple_account_get_ui_int(const PurpleAc
 	PurpleAccountSetting *setting;
 	GHashTable *table;
 
-	g_return_val_if_fail(account != NULL, default_value);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), default_value);
 	g_return_val_if_fail(ui      != NULL, default_value);
 	g_return_val_if_fail(name    != NULL, default_value);
 
@@ -1772,7 +1950,7 @@ purple_account_get_ui_string(const Purpl
 	PurpleAccountSetting *setting;
 	GHashTable *table;
 
-	g_return_val_if_fail(account != NULL, default_value);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), default_value);
 	g_return_val_if_fail(ui      != NULL, default_value);
 	g_return_val_if_fail(name    != NULL, default_value);
 
@@ -1794,7 +1972,7 @@ purple_account_get_ui_bool(const PurpleA
 	PurpleAccountSetting *setting;
 	GHashTable *table;
 
-	g_return_val_if_fail(account != NULL, default_value);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), default_value);
 	g_return_val_if_fail(ui      != NULL, default_value);
 	g_return_val_if_fail(name    != NULL, default_value);
 
@@ -1812,7 +1990,7 @@ purple_account_get_log(PurpleAccount *ac
 PurpleLog *
 purple_account_get_log(PurpleAccount *account, gboolean create)
 {
-	g_return_val_if_fail(account != NULL, NULL);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
 	if(!account->system_log && create){
 		PurplePresence *presence;
@@ -1832,7 +2010,7 @@ purple_account_destroy_log(PurpleAccount
 void
 purple_account_destroy_log(PurpleAccount *account)
 {
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	if(account->system_log){
 		purple_log_free(account->system_log);
@@ -2016,7 +2194,7 @@ set_current_error(PurpleAccount *account
 	PurpleAccountPrivate *priv;
 	PurpleConnectionErrorInfo *old_err;
 
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
 	old_err = priv->current_error;
@@ -2049,7 +2227,7 @@ connection_error_cb(PurpleConnection *gc
 
 	account = purple_connection_get_account(gc);
 
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	err = g_new0(PurpleConnectionErrorInfo, 1);
 	PURPLE_DBUS_REGISTER_POINTER(err, PurpleConnectionErrorInfo);
@@ -2076,7 +2254,7 @@ purple_accounts_add(PurpleAccount *accou
 void
 purple_accounts_add(PurpleAccount *account)
 {
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	purple_account_manager_add_account(purple_account_manager_get(), account);
 
@@ -2086,7 +2264,7 @@ purple_accounts_remove(PurpleAccount *ac
 void
 purple_accounts_remove(PurpleAccount *account)
 {
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	purple_account_manager_remove_account(purple_account_manager_get(), account);
 
@@ -2106,7 +2284,7 @@ purple_accounts_delete(PurpleAccount *ac
 	PurpleBlistNode *gnode, *cnode, *bnode;
 	GList *iter;
 
-	g_return_if_fail(account != NULL);
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	/*
 	 * Disable the account before blowing it out of the water.
@@ -2114,7 +2292,7 @@ purple_accounts_delete(PurpleAccount *ac
 	 * account for all UIs rather than the just the current UI,
 	 * but it doesn't really matter.
 	 */
-	purple_account_set_enabled(account, purple_core_get_ui(), FALSE);
+	purple_account_set_enabled(account, FALSE);
 
 	purple_notify_close_with_handle(account);
 	purple_request_close_with_handle(account);
@@ -2194,7 +2372,7 @@ purple_accounts_get_all_active(void)
 	while (all != NULL) {
 		PurpleAccount *account = all->data;
 
-		if (purple_account_get_enabled(account, purple_core_get_ui()))
+		if (purple_account_get_enabled(account))
 			list = g_list_append(list, account);
 
 		all = all->next;
@@ -2244,7 +2422,7 @@ purple_accounts_restore_current_statuses
 	for (l = purple_accounts_get_all(); l != NULL; l = l->next)
 	{
 		account = (PurpleAccount *)l->data;
-		if (purple_account_get_enabled(account, purple_core_get_ui()) &&
+		if (purple_account_get_enabled(account) &&
 			(purple_presence_is_online(account->presence)))
 		{
 			purple_account_connect(account);
============================================================
--- libpurple/account.h	19ef4224681f13420a14d52e7e1405aa0449cca5
+++ libpurple/account.h	bbbb68c958453100855fd9768340bda3daec27ec
@@ -123,7 +123,7 @@ struct _PurpleAccount
 {
 	PurpleObject parent;
 
-	PurpleAccountPrivate *priv;	
+	PurpleAccountPrivate *priv;
 
 	char *username;             /**< The username.                          */
 	char *alias;                /**< How you appear to yourself.            */
@@ -162,7 +162,7 @@ struct _PurpleAccountClass
 
 struct _PurpleAccountClass
 {
-	GObjectClass parent;
+	PurpleObjectClass parent;
 	void (*_purple_reserved[4])(void);
 };
 
@@ -409,11 +409,9 @@ void purple_account_set_check_mail(Purpl
  * UI.
  *
  * @param account The account.
- * @param ui      The UI.
  * @param value   @c TRUE if it is enabled.
  */
-void purple_account_set_enabled(PurpleAccount *account, const char *ui,
-			      gboolean value);
+void purple_account_set_enabled(PurpleAccount *account, gboolean value);
 
 /**
  * Sets the account's proxy information.
@@ -656,8 +654,7 @@ gboolean purple_account_get_check_mail(c
  *
  * @return @c TRUE if it enabled on this UI.
  */
-gboolean purple_account_get_enabled(const PurpleAccount *account,
-				  const char *ui);
+gboolean purple_account_get_enabled(const PurpleAccount *account);
 
 /**
  * Returns the account's proxy information.
============================================================
--- libpurple/connection.c	50102fd43192538110dcbd902d7bdd6886c07cf8
+++ libpurple/connection.c	7fba96f87072746b6e07ad5b253f5fc314a30188
@@ -164,12 +164,7 @@ purple_connection_new(PurpleAccount *acc
 	PurplePlugin *prpl;
 	PurplePluginProtocolInfo *prpl_info;
 
-#warning Bring back when PurpleAccount is GObject
-#if 0
-	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
-#else
-	g_return_if_fail(account != NULL);
-#endif
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	if (!purple_account_is_disconnected(account))
 		return;
@@ -293,76 +288,8 @@ purple_connection_destroy(PurpleConnecti
 void
 purple_connection_destroy(PurpleConnection *gc)
 {
-	PurpleAccount *account;
-	GSList *buddies;
-	PurplePluginProtocolInfo *prpl_info = NULL;
-	gboolean remove = FALSE;
-
 	g_return_if_fail(PURPLE_IS_CONNECTION(gc));
-
-	account = purple_connection_get_account(gc);
-
-	purple_debug_info("connection", "Disconnecting connection %p\n", gc);
-
-	if (purple_connection_get_state(gc) != PURPLE_CONNECTION_STATE_CONNECTING)
-		remove = TRUE;
-
-#if 0
-	purple_signal_emit(purple_connections_get_handle(), "signing-off", gc);
-#endif
-
-	while (gc->priv->buddy_chats)
-	{
-		PurpleConversation *b = gc->priv->buddy_chats->data;
-
-		gc->priv->buddy_chats = g_slist_remove(gc->priv->buddy_chats, b);
-		purple_conv_chat_left(PURPLE_CONV_CHAT(b));
-	}
-
-	update_keepalive(gc, FALSE);
-
-	purple_proxy_connect_cancel_with_handle(gc);
-
-	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->priv->prpl);
-	if (prpl_info->close)
-		(prpl_info->close)(gc);
-
-	/* Clear out the proto data that was freed in the prpl close method*/
-	buddies = purple_find_buddies(account, NULL);
-	while (buddies != NULL) {
-		PurpleBuddy *buddy = buddies->data;
-		purple_object_set_protocol_data(PURPLE_OBJECT(buddy),NULL);
-		buddies = g_slist_delete_link(buddies, buddies);
-	}
-
-	connections = g_list_remove(connections, gc);
-
-	purple_connection_set_state(gc, PURPLE_CONNECTION_STATE_DISCONNECTED);
-
-	if (remove)
-		purple_blist_remove_account(account);
-
-#if 0
-	purple_signal_emit(purple_connections_get_handle(), "signed-off", gc);
-#endif
-
-	purple_account_request_close_with_account(account);
-	purple_request_close_with_handle(gc);
-	purple_notify_close_with_handle(gc);
-
-	purple_debug_info("connection", "Destroying connection %p\n", gc);
-
-	purple_account_set_connection(account, NULL);
-
-	g_free(gc->priv->password);
-	g_free(gc->priv->display_name);
-
-	if (gc->priv->disconnect_timeout)
-		purple_timeout_remove(gc->priv->disconnect_timeout);
-
-	PURPLE_DBUS_UNREGISTER_POINTER(gc);
-#warning TODO: Much of the above should be moved to purple_connection_finalize
-	g_object_unref(G_OBJECT(gc));
+	purple_account_set_connection(gc->priv->account, NULL);
 }
 
 /*
@@ -475,18 +402,12 @@ purple_connection_set_account(PurpleConn
 {
 	g_return_if_fail(PURPLE_IS_CONNECTION(gc));
 	g_return_if_fail(account != NULL);
+	g_return_if_fail(gc->priv->account == NULL); /* We set the account for a connection exactly once */
 
 	if (gc->priv->account == account)
 		return;
 
-	purple_account_set_connection(gc->priv->account, NULL);
-
-#if 1
-#warning Remove this after PurpleAccount is GObject
 	gc->priv->account = account;
-#else
-	gc->priv->account = g_object_ref(account);
-#endif
 	gc->priv->prpl = account ? purple_find_prpl(purple_account_get_protocol_id(account)) : NULL;
 
 	purple_account_set_connection(account, gc);
@@ -739,8 +660,7 @@ purple_connection_get_property(GObject *
 			g_value_set_enum(value, purple_connection_get_state(pc));
 			break;
 		case PROP_ACCOUNT:
-			#warning fix me when account is an object
-			g_value_set_pointer(value, purple_connection_get_account(pc));
+			g_value_set_object(value, purple_connection_get_account(pc));
 			break;
 		case PROP_INPUT_WATCHER:
 			g_value_set_int(value, pc->priv->inpa);
@@ -780,8 +700,7 @@ purple_connection_set_property(GObject *
 			purple_connection_set_state(pc, g_value_get_enum(value));
 			break;
 		case PROP_ACCOUNT:
-			#warning fix me when account is an object
-			purple_connection_set_account(pc, g_value_get_pointer(value));
+			purple_connection_set_account(pc, g_value_get_object(value));
 			break;
 		case PROP_INPUT_WATCHER:
 			pc->priv->inpa = g_value_get_int(value);
@@ -808,16 +727,87 @@ static void
 }
 
 static void
+purple_connection_dispose(GObject *obj)
+{
+	PurpleConnection *pc = PURPLE_CONNECTION(obj);
+	PurpleAccount *account;
+	GSList *buddies;
+	PurplePluginProtocolInfo *prpl_info = NULL;
+
+	g_return_if_fail(PURPLE_IS_CONNECTION(pc));
+
+	account = purple_connection_get_account(pc);
+
+	purple_debug_info("connection", "Disconnecting connection %p\n", pc);
+
+
+#if 0
+	purple_signal_emit(purple_connections_get_handle(), "signing-off", pc);
+#endif
+
+	while (pc->priv->buddy_chats)
+	{
+		PurpleConversation *b = pc->priv->buddy_chats->data;
+
+		pc->priv->buddy_chats = g_slist_remove(pc->priv->buddy_chats, b);
+		purple_conv_chat_left(PURPLE_CONV_CHAT(b));
+	}
+
+	update_keepalive(pc, FALSE);
+
+	purple_proxy_connect_cancel_with_handle(pc);
+
+	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(pc->priv->prpl);
+	if (prpl_info->close)
+		(prpl_info->close)(pc);
+
+	/* Clear out the proto data that was freed in the prpl close method*/
+	buddies = purple_find_buddies(account, NULL);
+	while (buddies != NULL) {
+		PurpleBuddy *buddy = buddies->data;
+#warning Uncomment when PurpleBuddy is a GObject
+#if 0
+		purple_object_set_protocol_data(PURPLE_OBJECT(buddy),NULL);
+#endif
+		buddies = g_slist_delete_link(buddies, buddies);
+	}
+
+}
+
+static void
 purple_connection_finalize(GObject *obj)
 {
 	PurpleConnection *pc = PURPLE_CONNECTION(obj);
+	PurpleAccount *account = pc->priv->account;
+	gboolean remove = FALSE;
 
-#warning Enable this when PurpleAccount is a GObject.
+	connections = g_list_remove(connections, pc);
+
+	if (purple_connection_get_state(pc) != PURPLE_CONNECTION_STATE_CONNECTING)
+		remove = TRUE;
+	purple_connection_set_state(pc, PURPLE_CONNECTION_STATE_DISCONNECTED);
+	if (remove)
+		purple_blist_remove_account(account);
+
 #if 0
-	if (PURPLE_IS_ACCOUNT(pc->priv->account))
-		g_object_unref(G_OBJECT(pc->priv->account));
+	purple_signal_emit(purple_connections_get_handle(), "signed-off", pc);
 #endif
 
+	purple_account_request_close_with_account(account);
+	purple_request_close_with_handle(pc);
+	purple_notify_close_with_handle(pc);
+
+	purple_debug_info("connection", "Destroying connection %p\n", pc);
+
+	purple_account_set_connection(account, NULL);
+
+	g_free(pc->priv->password);
+	g_free(pc->priv->display_name);
+
+	if (pc->priv->disconnect_timeout)
+		purple_timeout_remove(pc->priv->disconnect_timeout);
+
+	PURPLE_DBUS_UNREGISTER_POINTER(pc);
 	g_free(pc->priv);
 
 	G_OBJECT_CLASS(parent_class)->finalize(obj);
@@ -843,6 +833,7 @@ purple_connection_class_init(PurpleConne
 	obj_class->get_property = purple_connection_get_property;
 	obj_class->set_property = purple_connection_set_property;
 	obj_class->finalize = purple_connection_finalize;
+	obj_class->dispose = purple_connection_dispose;
 
 	/* explicitly make these pure */
 	klass->signing_on = NULL;
@@ -865,9 +856,9 @@ purple_connection_class_init(PurpleConne
 							  G_PARAM_READWRITE);
 	g_object_class_install_property(obj_class, PROP_STATE, pspec);
 
-	#warning This needs to be moved to g_param_spec_object when account is objectified
-	pspec = g_param_spec_pointer("account", "account",
-								 "The account this connection belongs to.",
+	pspec = g_param_spec_object("account", "account",
+								 _("The account this connection belongs to."),
+								 PURPLE_TYPE_ACCOUNT,
 								 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
 	g_object_class_install_property(obj_class, PROP_ACCOUNT, pspec);
 
============================================================
--- libpurple/example/nullclient.c	fdbd7623b555ee4cdb674733575fbe4760323bee
+++ libpurple/example/nullclient.c	29bb6e52a8623a7c20ad0c4e78c35efa8aa72c43
@@ -180,7 +180,7 @@ init_libpurple(void)
 	purple_util_set_user_dir(CUSTOM_USER_DIRECTORY);
 
 	/* We do not want any debugging for now to keep the noise to a minimum. */
-	purple_debug_set_enabled(FALSE);
+	purple_debug_set_enabled(TRUE);
 
 	/* Set the core-uiops, which is used to
 	 * 	- initialize the ui specific preferences.
@@ -298,7 +298,7 @@ int main(int argc, char *argv[])
 	purple_account_set_password(account, password);
 
 	/* It's necessary to enable the account first. */
-	purple_account_set_enabled(account, UI_ID, TRUE);
+	purple_account_set_enabled(account, TRUE);
 
 	/* Now, to connect the account(s), create a status and activate it. */
 	status = purple_savedstatus_new(NULL, PURPLE_STATUS_AVAILABLE);
============================================================
--- libpurple/protocols/msnp9/msn.c	673f052fa5b8dd251af5f1b7071c601df6e8900c
+++ libpurple/protocols/msnp9/msn.c	ce31afd23c1b929bd71e8a71de26b1da9ce4496b
@@ -407,7 +407,8 @@ msn_offline_message(const PurpleBuddy *b
 	MsnUser *user;
 	if (buddy == NULL)
 		return FALSE;
-	user = purple_object_get_protocol_data(PURPLE_OBJECT(buddy));
+	/*user = purple_object_get_protocol_data(PURPLE_OBJECT(buddy));*/
+	user = buddy->proto_data;
 	return user && user->mobile;
 }
 
@@ -532,7 +533,8 @@ msn_tooltip_text(PurpleBuddy *buddy, Pur
 	PurplePresence *presence = purple_buddy_get_presence(buddy);
 	PurpleStatus *status = purple_presence_get_active_status(presence);
 
-	user = purple_object_get_protocol_data(PURPLE_OBJECT(buddy));
+	/*user = purple_object_get_protocol_data(PURPLE_OBJECT(buddy));*/
+	user = buddy->proto_data;
 
 
 	if (purple_presence_is_online(presence))
@@ -684,7 +686,8 @@ msn_buddy_menu(PurpleBuddy *buddy)
 
 	g_return_val_if_fail(buddy != NULL, NULL);
 
-	user = purple_object_get_protocol_data(PURPLE_OBJECT(buddy));
+	/*user = purple_object_get_protocol_data(PURPLE_OBJECT(buddy));*/
+	user = buddy->proto_data;
 
 	if (user != NULL)
 	{
============================================================
--- libpurple/protocols/msnp9/user.c	e33de1bcd9385b13c5ec438cd9e9b653f485559f
+++ libpurple/protocols/msnp9/user.c	8e63d7bd20709beaebb0707cf8e24823c9f1966c
@@ -257,7 +257,8 @@ msn_user_add_group_id(MsnUser *user, int
 		purple_blist_add_buddy(b, NULL, g, NULL);
 	}
 
-	purple_object_set_protocol_data(PURPLE_OBJECT(b),user);
+	/*purple_object_set_protocol_data(PURPLE_OBJECT(b),user);*/
+	b->proto_data = user;
 }
 
 void
============================================================
--- libpurple/status.c	d5fad32197a4b3d45edee4cc864f9912f43b0e1a
+++ libpurple/status.c	befaf6816e2715f2a7ae7055ec3908142100a1e9
@@ -654,7 +654,7 @@ notify_status_update(PurplePresence *pre
 		PurpleAccount *account = purple_presence_get_account(presence);
 		PurpleAccountUiOps *ops = purple_accounts_get_ui_ops();
 
-		if (purple_account_get_enabled(account, purple_core_get_ui()))
+		if (purple_account_get_enabled(account))
 			purple_prpl_change_account_status(account, old_status, new_status);
 
 		if (ops != NULL && ops->status_changed != NULL)
============================================================
--- libpurple/util.c	3003c319ba47f3d4f71e531496955d082b384062
+++ libpurple/util.c	8c6fa95fd15c673698a871faa86d7b7425bfccd1
@@ -4665,7 +4665,7 @@ void purple_util_set_current_song(const 
 		PurplePresence *presence;
 		PurpleStatus *tune;
 		PurpleAccount *account = list->data;
-		if (!purple_account_get_enabled(account, purple_core_get_ui()))
+		if (!purple_account_get_enabled(account))
 			continue;
 
 		presence = purple_account_get_presence(account);


More information about the Commits mailing list