# HG changeset patch
# Node ID 88f8c35a358e
# Parent  c5d992e0ee08
diff --git a/libpurple/meson.build b/libpurple/meson.build
--- a/libpurple/meson.build
+++ b/libpurple/meson.build
@@ -33,7 +33,6 @@
 	'purpleaccount.c',
 	'purpleaccountmanager.c',
 	'purpleaccountoption.c',
-	'purpleaccountpresence.c',
 	'purpleaccountusersplit.c',
 	'purpleaddcontactrequest.c',
 	'purpleattachment.c',
@@ -157,7 +156,6 @@
 	'purpleaccount.h',
 	'purpleaccountmanager.h',
 	'purpleaccountoption.h',
-	'purpleaccountpresence.h',
 	'purpleaccountusersplit.h',
 	'purpleaddcontactrequest.h',
 	'purpleauthorizationrequest.h',
diff --git a/libpurple/purpleaccount.c b/libpurple/purpleaccount.c
--- a/libpurple/purpleaccount.c
+++ b/libpurple/purpleaccount.c
@@ -30,7 +30,6 @@
 #include "network.h"
 #include "notify.h"
 #include "prefs.h"
-#include "purpleaccountpresence.h"
 #include "purpleaddcontactrequest.h"
 #include "purpleconversationmanager.h"
 #include "purplecredentialmanager.h"
@@ -757,11 +756,7 @@
 static void
 purple_account_constructed(GObject *object) {
 	PurpleAccount *account = PURPLE_ACCOUNT(object);
-	gchar *username, *protocol_id;
 	const char *id = NULL;
-	PurpleProtocol *protocol = NULL;
-	PurpleProtocolManager *manager = NULL;
-	PurpleStatusType *status_type;
 
 	G_OBJECT_CLASS(purple_account_parent_class)->constructed(object);
 
@@ -783,38 +778,7 @@
 		g_checksum_free(checksum);
 	}
 
-	g_object_get(object,
-	             "username", &username,
-	             "protocol-id", &protocol_id,
-	             NULL);
-
-	manager = purple_protocol_manager_get_default();
-	protocol = purple_protocol_manager_find(manager, protocol_id);
-	if(protocol == NULL) {
-		g_free(username);
-		g_free(protocol_id);
-		return;
-	}
-
-	purple_account_set_status_types(account,
-	                                purple_protocol_get_status_types(protocol, account));
-
-	account->presence = PURPLE_PRESENCE(purple_account_presence_new(account));
-
-	status_type = purple_account_get_status_type_with_primitive(account,
-	                                                            PURPLE_STATUS_AVAILABLE);
-	if(status_type != NULL) {
-		purple_presence_set_status_active(account->presence,
-		                                  purple_status_type_get_id(status_type),
-		                                  TRUE);
-	} else {
-		purple_presence_set_status_active(account->presence,
-		                                  "offline",
-		                                  TRUE);
-	}
-
-	g_free(username);
-	g_free(protocol_id);
+	account->presence = purple_presence_new();
 
 	/* Connect to our own notify signal so we can update accounts.xml. */
 	g_signal_connect(object, "notify",
diff --git a/libpurple/purpleaccountmanager.c b/libpurple/purpleaccountmanager.c
--- a/libpurple/purpleaccountmanager.c
+++ b/libpurple/purpleaccountmanager.c
@@ -743,7 +743,7 @@
 				presence = purple_account_get_presence(account);
 				online = purple_presence_is_online(presence);
 
-				if(online) {
+				if(!online) {
 					purple_account_connect(account);
 				}
 			}
diff --git a/libpurple/purpleaccountpresence.h b/libpurple/purpleaccountpresence.h
deleted file mode 100644
--- a/libpurple/purpleaccountpresence.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Purple - Internet Messaging Library
- * Copyright (C) Pidgin Developers <devel@pidgin.im>
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this library; if not, see <https://www.gnu.org/licenses/>.
- */
-
-#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
-# error "only <purple.h> may be included directly"
-#endif
-
-#ifndef PURPLE_ACCOUNT_PRESENCE_H
-#define PURPLE_ACCOUNT_PRESENCE_H
-
-#include "purpleaccount.h"
-#include "purplepresence.h"
-#include "purpleversion.h"
-
-G_BEGIN_DECLS
-
-/**
- * PurpleAccountPresence:
- *
- * A #PurpleAccountPresence represent the #PurplePresence for a specific
- * #PurpleAccount.
- *
- * Since: 3.0
- */
-
-#define PURPLE_TYPE_ACCOUNT_PRESENCE (purple_account_presence_get_type())
-
-PURPLE_AVAILABLE_IN_3_0
-G_DECLARE_FINAL_TYPE(PurpleAccountPresence, purple_account_presence, PURPLE,
-                     ACCOUNT_PRESENCE, PurplePresence)
-
-/**
- * purple_account_presence_new:
- * @account: The account to associate with the presence.
- *
- * Creates a presence for an account.
- *
- * Returns: The new presence.
- *
- * Since: 3.0
- */
-PURPLE_AVAILABLE_IN_3_0
-PurpleAccountPresence *purple_account_presence_new(PurpleAccount *account);
-
-/**
- * purple_account_presence_get_account:
- * @presence: The presence.
- *
- * Returns an account presence's account.
- *
- * Returns: (transfer none): The presence's account.
- *
- * Since: 3.0
- */
-PURPLE_AVAILABLE_IN_3_0
-PurpleAccount *purple_account_presence_get_account(PurpleAccountPresence *presence);
-
-G_END_DECLS
-
-#endif /* PURPLE_ACCOUNT_PRESENCE_H */
diff --git a/libpurple/purpleaccountpresence.c b/libpurple/purpleaccountpresence.c
deleted file mode 100644
--- a/libpurple/purpleaccountpresence.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Purple - Internet Messaging Library
- * Copyright (C) Pidgin Developers <devel@pidgin.im>
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this library; if not, see <https://www.gnu.org/licenses/>.
- */
-
-#include <glib/gi18n-lib.h>
-
-#include "purpleaccountpresence.h"
-
-#include "protocols.h"
-#include "purpleprotocolserver.h"
-
-struct _PurpleAccountPresence {
-	PurplePresence parent;
-
-	PurpleAccount *account;
-	GList *statuses;
-};
-
-enum {
-	PROP_0,
-	PROP_ACCOUNT,
-	N_PROPERTIES,
-};
-static GParamSpec *properties[N_PROPERTIES] = {NULL, };
-
-/******************************************************************************
- * Helpers
- *****************************************************************************/
-static void
-purple_account_presence_set_account(PurpleAccountPresence *presence,
-                                    PurpleAccount *account)
-{
-	if(g_set_object(&presence->account, account)) {
-		g_object_notify_by_pspec(G_OBJECT(presence), properties[PROP_ACCOUNT]);
-	}
-}
-
-/******************************************************************************
- * PurplePresence Implementation
- *****************************************************************************/
-static void
-purple_account_presence_update_idle(PurplePresence *presence,
-                                    G_GNUC_UNUSED gboolean old_idle)
-{
-	PurpleAccountPresence *account_presence = PURPLE_ACCOUNT_PRESENCE(presence);
-	PurpleConnection *gc = NULL;
-	PurpleProtocol *protocol = NULL;
-	gboolean idle = purple_presence_is_idle(presence);
-
-	gc = purple_account_get_connection(account_presence->account);
-
-	if(PURPLE_CONNECTION_IS_CONNECTED(gc)) {
-		protocol = purple_connection_get_protocol(gc);
-	}
-
-	if(PURPLE_IS_PROTOCOL_SERVER(protocol)) {
-		gint idle_time = 0;
-
-		if(idle) {
-			GDateTime *idle_since = purple_presence_get_idle_time(presence);
-
-			if(idle_since != NULL) {
-				GDateTime *now = g_date_time_new_now_local();
-
-				idle_time = g_date_time_difference(now, idle_since);
-				idle_time = idle_time / G_TIME_SPAN_SECOND;
-
-				g_date_time_unref(now);
-				g_date_time_unref(idle_since);
-			}
-		}
-
-		purple_protocol_server_set_idle(PURPLE_PROTOCOL_SERVER(protocol), gc,
-		                                idle_time);
-	}
-}
-
-static GList *
-purple_account_presence_get_statuses(PurplePresence *presence) {
-	PurpleAccountPresence *account_presence = PURPLE_ACCOUNT_PRESENCE(presence);
-
-	/* We cache purple_protocol_get_statuses because it creates all new
-	 * statuses which loses at least the active attribute, which breaks all
-	 * sorts of things.
-	 */
-	if(account_presence->statuses == NULL) {
-		account_presence->statuses =
-			purple_protocol_get_statuses(account_presence->account, presence);
-	}
-
-	return account_presence->statuses;
-}
-
-/******************************************************************************
- * GObject Implementation
- *****************************************************************************/
-G_DEFINE_FINAL_TYPE(PurpleAccountPresence, purple_account_presence,
-                    PURPLE_TYPE_PRESENCE)
-
-static void
-purple_account_presence_set_property(GObject *obj, guint param_id,
-                                     const GValue *value, GParamSpec *pspec)
-{
-	PurpleAccountPresence *presence = PURPLE_ACCOUNT_PRESENCE(obj);
-
-	switch (param_id) {
-		case PROP_ACCOUNT:
-			purple_account_presence_set_account(presence,
-			                                    g_value_get_object(value));
-			break;
-		default:
-			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-			break;
-	}
-}
-
-static void
-purple_account_presence_get_property(GObject *obj, guint param_id,
-                                     GValue *value, GParamSpec *pspec)
-{
-	PurpleAccountPresence *presence = PURPLE_ACCOUNT_PRESENCE(obj);
-
-	switch (param_id) {
-		case PROP_ACCOUNT:
-			g_value_set_object(value,
-			                   purple_account_presence_get_account(presence));
-			break;
-		default:
-			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-			break;
-	}
-}
-
-static void
-purple_account_presence_finalize(GObject *obj) {
-	PurpleAccountPresence *presence = PURPLE_ACCOUNT_PRESENCE(obj);
-
-	g_clear_object(&presence->account);
-	g_list_free_full(presence->statuses, g_object_unref);
-
-	G_OBJECT_CLASS(purple_account_presence_parent_class)->finalize(obj);
-}
-
-static void
-purple_account_presence_init(G_GNUC_UNUSED PurpleAccountPresence *presence) {
-}
-
-static void
-purple_account_presence_class_init(PurpleAccountPresenceClass *klass) {
-	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
-	PurplePresenceClass *presence_class = PURPLE_PRESENCE_CLASS(klass);
-
-	obj_class->get_property = purple_account_presence_get_property;
-	obj_class->set_property = purple_account_presence_set_property;
-	obj_class->finalize = purple_account_presence_finalize;
-
-	presence_class->update_idle = purple_account_presence_update_idle;
-	presence_class->get_statuses = purple_account_presence_get_statuses;
-
-	/**
-	 * PurpleAccountPresence:account:
-	 *
-	 * The account for this presence.
-	 *
-	 * Since: 3.0
-	 */
-	properties[PROP_ACCOUNT] = g_param_spec_object(
-		"account", "Account",
-		"The account for this presence.",
-		PURPLE_TYPE_ACCOUNT,
-		G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
-
-	g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
-}
-
-/******************************************************************************
- * Public API
- *****************************************************************************/
-PurpleAccountPresence *
-purple_account_presence_new(PurpleAccount *account) {
-	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
-
-	return g_object_new(
-		PURPLE_TYPE_ACCOUNT_PRESENCE,
-		"account", account,
-		NULL);
-}
-
-PurpleAccount *
-purple_account_presence_get_account(PurpleAccountPresence *presence)
-{
-	g_return_val_if_fail(PURPLE_IS_ACCOUNT_PRESENCE(presence), NULL);
-
-	return presence->account;
-}
diff --git a/libpurple/status.c b/libpurple/status.c
--- a/libpurple/status.c
+++ b/libpurple/status.c
@@ -30,7 +30,6 @@
 #include "notify.h"
 #include "prefs.h"
 #include "protocols.h"
-#include "purpleaccountpresence.h"
 #include "status.h"
 
 /*
@@ -524,20 +523,6 @@
 * PurpleStatus API
 **************************************************************************/
 static void
-notify_status_update(PurplePresence *presence, PurpleStatus *old_status,
-					 PurpleStatus *new_status)
-{
-	if (PURPLE_IS_ACCOUNT_PRESENCE(presence))
-	{
-		PurpleAccount *account = purple_account_presence_get_account(
-				PURPLE_ACCOUNT_PRESENCE(presence));
-
-		if (purple_account_get_enabled(account))
-			purple_protocol_change_account_status(account, old_status, new_status);
-	}
-}
-
-static void
 status_has_changed(PurpleStatus *status)
 {
 	PurplePresence *presence;
@@ -564,8 +549,6 @@
 
 	g_object_set(presence, "active-status", status, NULL);
 	g_object_notify_by_pspec(G_OBJECT(status), properties[PROP_ACTIVE]);
-
-	notify_status_update(presence, old_status, status);
 }
 
 static void
diff --git a/po/POTFILES.in b/po/POTFILES.in
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -42,7 +42,6 @@
 libpurple/purpleaccount.c
 libpurple/purpleaccountmanager.c
 libpurple/purpleaccountoption.c
-libpurple/purpleaccountpresence.c
 libpurple/purpleaccountusersplit.c
 libpurple/purpleaddcontactrequest.c
 libpurple/purpleattachment.c
