aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorJonny Lamb <jonnylamb@gnome.org>2009-10-23 20:46:56 +0800
committerJonny Lamb <jonnylamb@gnome.org>2009-10-23 20:46:56 +0800
commit9750a6735d088fa5c1930f2ac581619ff31c8491 (patch)
treef2a093c4bb314a75cc40ec642ad992b4655923a3 /libempathy
parentf4e6cbe11974883a3883536461c0be08f75cdd39 (diff)
downloadgsoc2013-empathy-9750a6735d088fa5c1930f2ac581619ff31c8491.tar
gsoc2013-empathy-9750a6735d088fa5c1930f2ac581619ff31c8491.tar.gz
gsoc2013-empathy-9750a6735d088fa5c1930f2ac581619ff31c8491.tar.bz2
gsoc2013-empathy-9750a6735d088fa5c1930f2ac581619ff31c8491.tar.lz
gsoc2013-empathy-9750a6735d088fa5c1930f2ac581619ff31c8491.tar.xz
gsoc2013-empathy-9750a6735d088fa5c1930f2ac581619ff31c8491.tar.zst
gsoc2013-empathy-9750a6735d088fa5c1930f2ac581619ff31c8491.zip
Removed EmpathyAccount{,Manager}.
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/Makefile.am4
-rw-r--r--libempathy/empathy-account-manager.c1060
-rw-r--r--libempathy/empathy-account-manager.h111
-rw-r--r--libempathy/empathy-account.c1305
-rw-r--r--libempathy/empathy-account.h124
5 files changed, 0 insertions, 2604 deletions
diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am
index 1e7d01ca3..91fdf7ba1 100644
--- a/libempathy/Makefile.am
+++ b/libempathy/Makefile.am
@@ -27,8 +27,6 @@ noinst_LTLIBRARIES = libempathy.la
libempathy_headers = \
empathy-account-settings.h \
- empathy-account.h \
- empathy-account-manager.h \
empathy-chatroom.h \
empathy-chatroom-manager.h \
empathy-call-factory.h \
@@ -70,9 +68,7 @@ libempathy_headers = \
libempathy_la_SOURCES = \
$(libempathy_headers) \
- empathy-account.c \
empathy-account-settings.c \
- empathy-account-manager.c \
empathy-chatroom.c \
empathy-chatroom-manager.c \
empathy-call-factory.c \
diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c
deleted file mode 100644
index c71439bd4..000000000
--- a/libempathy/empathy-account-manager.c
+++ /dev/null
@@ -1,1060 +0,0 @@
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
- * Sjoerd Simons <sjoerd.simons@collabora.co.uk>
- */
-
-#include "config.h"
-
-#include <telepathy-glib/util.h>
-#include <telepathy-glib/account-manager.h>
-#include <telepathy-glib/enums.h>
-#include <telepathy-glib/defs.h>
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/interfaces.h>
-
-#include "empathy-account-manager.h"
-#include "empathy-marshal.h"
-#include "empathy-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
-#include <libempathy/empathy-debug.h>
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountManager)
-
-#define MC5_BUS_NAME "org.freedesktop.Telepathy.MissionControl5"
-
-typedef struct {
- /* (owned) unique name -> (reffed) EmpathyAccount */
- GHashTable *accounts;
- int connected;
- int connecting;
- gboolean dispose_run;
- gboolean ready;
- TpAccountManager *tp_manager;
- TpDBusDaemon *dbus;
-
- /* global presence */
- EmpathyAccount *global_account;
-
- TpConnectionPresenceType global_presence;
- gchar *global_status;
- gchar *global_status_message;
-
- /* requested global presence, could be different
- * from the actual global one.
- */
- TpConnectionPresenceType requested_presence;
- gchar *requested_status;
- gchar *requested_status_message;
-
- GHashTable *create_results;
-} EmpathyAccountManagerPriv;
-
-enum {
- ACCOUNT_CREATED,
- ACCOUNT_DELETED,
- ACCOUNT_ENABLED,
- ACCOUNT_DISABLED,
- ACCOUNT_CHANGED,
- ACCOUNT_CONNECTION_CHANGED,
- GLOBAL_PRESENCE_CHANGED,
- NEW_CONNECTION,
- LAST_SIGNAL
-};
-
-enum {
- PROP_READY = 1,
-};
-
-static guint signals[LAST_SIGNAL];
-static EmpathyAccountManager *manager_singleton = NULL;
-
-G_DEFINE_TYPE (EmpathyAccountManager, empathy_account_manager, G_TYPE_OBJECT);
-
-static void
-emp_account_connection_cb (EmpathyAccount *account,
- GParamSpec *spec,
- gpointer manager)
-{
- TpConnection *connection = empathy_account_get_connection (account);
-
- DEBUG ("Signalling connection %p of account %s",
- connection, empathy_account_get_unique_name (account));
-
- if (connection != NULL)
- g_signal_emit (manager, signals[NEW_CONNECTION], 0, connection);
-}
-
-static void
-emp_account_enabled_cb (EmpathyAccount *account,
- GParamSpec *spec,
- gpointer manager)
-{
- if (empathy_account_is_enabled (account))
- g_signal_emit (manager, signals[ACCOUNT_ENABLED], 0, account);
- else
- g_signal_emit (manager, signals[ACCOUNT_DISABLED], 0, account);
-}
-
-static void
-emp_account_status_changed_cb (EmpathyAccount *account,
- TpConnectionStatus old,
- TpConnectionStatus new,
- TpConnectionStatusReason reason,
- gpointer user_data)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- switch (old)
- {
- case TP_CONNECTION_STATUS_CONNECTING:
- priv->connecting--;
- break;
- case TP_CONNECTION_STATUS_CONNECTED:
- priv->connected--;
- break;
- default:
- break;
- }
-
- switch (new)
- {
- case TP_CONNECTION_STATUS_CONNECTING:
- priv->connecting++;
- break;
- case TP_CONNECTION_STATUS_CONNECTED:
- priv->connected++;
- break;
- default:
- break;
- }
-
- g_signal_emit (manager, signals[ACCOUNT_CONNECTION_CHANGED], 0,
- account, reason, new, old);
-}
-
-static void
-emp_account_manager_update_global_presence (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- TpConnectionPresenceType presence = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
- EmpathyAccount *account = NULL;
- GHashTableIter iter;
- gpointer value;
-
- /* Make the global presence is equal to the presence of the account with the
- * highest availability */
-
- g_hash_table_iter_init (&iter, priv->accounts);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- {
- EmpathyAccount *a = EMPATHY_ACCOUNT (value);
- TpConnectionPresenceType p;
-
- g_object_get (a, "presence", &p, NULL);
-
- if (tp_connection_presence_type_cmp_availability (p, presence) > 0)
- {
- account = a;
- presence = p;
- }
- }
-
- priv->global_account = account;
- g_free (priv->global_status);
- g_free (priv->global_status_message);
-
- if (account == NULL)
- {
- priv->global_presence = presence;
- priv->global_status = NULL;
- priv->global_status_message = NULL;
- return;
- }
-
- g_object_get (account,
- "presence", &priv->global_presence,
- "status", &priv->global_status,
- "status-message", &priv->global_status_message,
- NULL);
-
- DEBUG ("Updated global presence to: %s (%d) \"%s\"",
- priv->global_status, priv->global_presence, priv->global_status_message);
-}
-
-static void
-emp_account_presence_changed_cb (EmpathyAccount *account,
- TpConnectionPresenceType presence,
- const gchar *status,
- const gchar *status_message,
- gpointer user_data)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- if (tp_connection_presence_type_cmp_availability (presence,
- priv->global_presence) > 0)
- {
- priv->global_account = account;
-
- priv->global_presence = presence;
-
- g_free (priv->global_status);
- priv->global_status = g_strdup (status);
-
- g_free (priv->global_status_message);
- priv->global_status_message = g_strdup (status_message);
-
- goto signal;
- }
- else if (priv->global_account == account)
- {
- emp_account_manager_update_global_presence (manager);
- goto signal;
- }
-
- return;
-signal:
- g_signal_emit (manager, signals[GLOBAL_PRESENCE_CHANGED], 0,
- priv->global_presence, priv->global_status, priv->global_status_message);
-}
-
-static void
-emp_account_removed_cb (EmpathyAccount *account, gpointer user_data)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- g_object_ref (account);
- g_hash_table_remove (priv->accounts,
- empathy_account_get_unique_name (account));
-
- g_signal_emit (manager, signals[ACCOUNT_DELETED], 0, account);
- g_object_unref (account);
-}
-
-static void
-empathy_account_manager_check_ready (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- GHashTableIter iter;
- gpointer value;
-
- if (priv->ready)
- return;
-
- g_hash_table_iter_init (&iter, priv->accounts);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- {
- EmpathyAccount *account = EMPATHY_ACCOUNT (value);
- gboolean ready;
-
- g_object_get (account, "ready", &ready, NULL);
-
- if (!ready)
- return;
- }
-
- /* Rerequest global presence on the initial set of accounts for cases where a
- * global presence was requested before the manager was ready */
- if (priv->requested_presence != TP_CONNECTION_PRESENCE_TYPE_UNSET)
- empathy_account_manager_request_global_presence (manager,
- priv->requested_presence,
- priv->requested_status,
- priv->requested_status_message);
-
- priv->ready = TRUE;
- g_object_notify (G_OBJECT (manager), "ready");
-}
-
-static void
-account_manager_account_ready_cb (GObject *obj,
- GParamSpec *spec,
- gpointer user_data)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- EmpathyAccount *account = EMPATHY_ACCOUNT (obj);
- GSimpleAsyncResult *result;
- gboolean ready;
-
- g_object_get (account, "ready", &ready, NULL);
-
- if (!ready)
- return;
-
- /* see if there's any pending callbacks for this account */
- result = g_hash_table_lookup (priv->create_results, account);
- if (result != NULL)
- {
- g_simple_async_result_set_op_res_gpointer (
- G_SIMPLE_ASYNC_RESULT (result), account, NULL);
-
- g_simple_async_result_complete (result);
-
- g_hash_table_remove (priv->create_results, account);
- g_object_unref (result);
- }
-
- g_signal_emit (manager, signals[ACCOUNT_CREATED], 0, account);
-
- g_signal_connect (account, "notify::connection",
- G_CALLBACK (emp_account_connection_cb), manager);
-
- g_signal_connect (account, "notify::enabled",
- G_CALLBACK (emp_account_enabled_cb), manager);
-
- g_signal_connect (account, "status-changed",
- G_CALLBACK (emp_account_status_changed_cb), manager);
-
- g_signal_connect (account, "presence-changed",
- G_CALLBACK (emp_account_presence_changed_cb), manager);
-
- g_signal_connect (account, "removed",
- G_CALLBACK (emp_account_removed_cb), manager);
-
- empathy_account_manager_check_ready (manager);
-}
-
-EmpathyAccount *
-empathy_account_manager_get_account (EmpathyAccountManager *manager,
- const gchar *path)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- return g_hash_table_lookup (priv->accounts, path);
-}
-
-EmpathyAccount *
-empathy_account_manager_ensure_account (EmpathyAccountManager *manager,
- const gchar *path)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- EmpathyAccount *account;
-
- account = g_hash_table_lookup (priv->accounts, path);
- if (account != NULL)
- return account;
-
- account = empathy_account_new (priv->dbus, path);
- g_hash_table_insert (priv->accounts, g_strdup (path), account);
-
- g_signal_connect (account, "notify::ready",
- G_CALLBACK (account_manager_account_ready_cb), manager);
-
- return account;
-}
-
-
-static void
-account_manager_ensure_all_accounts (EmpathyAccountManager *manager,
- GPtrArray *accounts)
-{
- guint i, missing_accounts;
- GHashTableIter iter;
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- gpointer value;
- EmpathyAccount *account;
- gboolean found = FALSE;
- const gchar *name;
-
- /* ensure all accounts coming from MC5 first */
- for (i = 0; i < accounts->len; i++)
- {
- name = g_ptr_array_index (accounts, i);
-
- account = empathy_account_manager_ensure_account (manager, name);
- empathy_account_refresh_properties (account);
- }
-
- missing_accounts = empathy_account_manager_get_count (manager) -
- accounts->len;
-
- if (missing_accounts > 0)
- {
- /* look for accounts we have and the Tp AccountManager doesn't,
- * and remove them from our cache.
- */
-
- DEBUG ("%d missing accounts", missing_accounts);
-
- g_hash_table_iter_init (&iter, priv->accounts);
-
- while (g_hash_table_iter_next (&iter, NULL, &value) &&
- missing_accounts > 0)
- {
- account = value;
-
- /* look for this account in the AccountManager provided array */
- for (i = 0; i < accounts->len; i++)
- {
- name = g_ptr_array_index (accounts, i);
-
- if (!tp_strdiff
- (name, empathy_account_get_unique_name (account)))
- {
- found = TRUE;
- break;
- }
- }
-
- if (!found)
- {
- DEBUG ("Account %s was not found, remove it from the cache",
- empathy_account_get_unique_name (account));
-
- g_object_ref (account);
- g_hash_table_iter_remove (&iter);
- g_signal_emit (manager, signals[ACCOUNT_DELETED], 0, account);
- g_object_unref (account);
-
- missing_accounts--;
- }
-
- found = FALSE;
- }
- }
-}
-
-static void
-account_manager_got_all_cb (TpProxy *proxy,
- GHashTable *properties,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (weak_object);
- GPtrArray *accounts;
-
- if (error != NULL)
- {
- DEBUG ("Failed to get account manager properties: %s", error->message);
- return;
- }
-
- accounts = tp_asv_get_boxed (properties, "ValidAccounts",
- EMPATHY_ARRAY_TYPE_OBJECT);
-
- if (accounts != NULL)
- account_manager_ensure_all_accounts (manager, accounts);
-
- empathy_account_manager_check_ready (manager);
-}
-
-static void
-account_validity_changed_cb (TpAccountManager *proxy,
- const gchar *path,
- gboolean valid,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (weak_object);
-
- if (!valid)
- return;
-
- empathy_account_manager_ensure_account (manager, path);
-}
-
-static void
-account_manager_start_mc5 (TpDBusDaemon *bus)
-{
- TpProxy *mc5_proxy;
-
- /* trigger MC5 starting */
- mc5_proxy = g_object_new (TP_TYPE_PROXY,
- "dbus-daemon", bus,
- "dbus-connection", tp_proxy_get_dbus_connection (TP_PROXY (bus)),
- "bus-name", MC5_BUS_NAME,
- "object-path", "/",
- NULL);
-
- tp_cli_dbus_peer_call_ping (mc5_proxy, -1, NULL, NULL, NULL, NULL);
-
- g_object_unref (mc5_proxy);
-}
-
-static void
-account_manager_name_owner_cb (TpDBusDaemon *proxy,
- const gchar *name,
- const gchar *new_owner,
- gpointer user_data)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- DEBUG ("Name owner changed for %s, new name: %s", name, new_owner);
-
- if (EMP_STR_EMPTY (new_owner))
- {
- /* MC5 quit or crashed for some reason, let's start it again */
- account_manager_start_mc5 (priv->dbus);
-
- if (priv->tp_manager != NULL)
- g_object_unref (priv->tp_manager);
-
- priv->tp_manager = NULL;
- return;
- }
-
- if (priv->tp_manager == NULL)
- {
- priv->tp_manager = tp_account_manager_new (priv->dbus);
-
- tp_cli_account_manager_connect_to_account_validity_changed (
- priv->tp_manager,
- account_validity_changed_cb,
- NULL,
- NULL,
- G_OBJECT (manager),
- NULL);
-
- tp_cli_dbus_properties_call_get_all (priv->tp_manager, -1,
- TP_IFACE_ACCOUNT_MANAGER,
- account_manager_got_all_cb,
- NULL,
- NULL,
- G_OBJECT (manager));
- }
-}
-
-static void
-empathy_account_manager_init (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv;
-
- priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
- EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManagerPriv);
-
- manager->priv = priv;
- priv->connected = priv->connecting = 0;
- priv->global_presence = TP_CONNECTION_PRESENCE_TYPE_UNSET;
-
- priv->accounts = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, (GDestroyNotify) g_object_unref);
-
- priv->create_results = g_hash_table_new (g_direct_hash, g_direct_equal);
-
- priv->dbus = tp_dbus_daemon_dup (NULL);
-
- tp_dbus_daemon_watch_name_owner (priv->dbus,
- TP_ACCOUNT_MANAGER_BUS_NAME,
- account_manager_name_owner_cb,
- manager,
- NULL);
-
- account_manager_start_mc5 (priv->dbus);
-}
-
-static void
-do_finalize (GObject *obj)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (obj);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- g_hash_table_destroy (priv->create_results);
- g_hash_table_destroy (priv->accounts);
-
- g_free (priv->global_status);
- g_free (priv->global_status_message);
-
- g_free (priv->requested_status);
- g_free (priv->requested_status_message);
-
- G_OBJECT_CLASS (empathy_account_manager_parent_class)->finalize (obj);
-}
-
-static void
-do_dispose (GObject *obj)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (obj);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- GHashTableIter iter;
- GSimpleAsyncResult *result;
-
- if (priv->dispose_run)
- return;
-
- priv->dispose_run = TRUE;
-
- /* the manager is being destroyed while there are account creation
- * processes pending; this should not happen, but emit the callbacks
- * with an error anyway.
- */
- g_hash_table_iter_init (&iter, priv->create_results);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &result))
- {
- g_simple_async_result_set_error (result, G_IO_ERROR,
- G_IO_ERROR_CANCELLED, "The account manager was disposed while "
- "creating the account");
- g_simple_async_result_complete (result);
- g_object_unref (result);
- }
- g_hash_table_remove_all (priv->create_results);
-
- if (priv->dbus != NULL)
- {
- tp_dbus_daemon_cancel_name_owner_watch (priv->dbus,
- TP_ACCOUNT_MANAGER_BUS_NAME, account_manager_name_owner_cb, manager);
-
- g_object_unref (priv->dbus);
- priv->dbus = NULL;
- }
-
- G_OBJECT_CLASS (empathy_account_manager_parent_class)->dispose (obj);
-}
-
-static GObject *
-do_constructor (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
-{
- GObject *retval;
-
- if (!manager_singleton)
- {
- retval = G_OBJECT_CLASS
- (empathy_account_manager_parent_class)->constructor (type,
- n_construct_params, construct_params);
- manager_singleton = EMPATHY_ACCOUNT_MANAGER (retval);
- g_object_add_weak_pointer (retval, (gpointer) &manager_singleton);
- }
- else
- {
- retval = g_object_ref (manager_singleton);
- }
-
- return retval;
-}
-
-static void
-do_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (object);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- switch (prop_id)
- {
- case PROP_READY:
- g_value_set_boolean (value, priv->ready);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-empathy_account_manager_class_init (EmpathyAccountManagerClass *klass)
-{
- GObjectClass *oclass = G_OBJECT_CLASS (klass);
-
- oclass->finalize = do_finalize;
- oclass->dispose = do_dispose;
- oclass->constructor = do_constructor;
- oclass->get_property = do_get_property;
-
- g_object_class_install_property (oclass, PROP_READY,
- g_param_spec_boolean ("ready",
- "Ready",
- "Whether the initial state dump from the account manager is finished",
- FALSE,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- signals[ACCOUNT_CREATED] =
- g_signal_new ("account-created",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_ACCOUNT);
-
- signals[ACCOUNT_DELETED] =
- g_signal_new ("account-deleted",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_ACCOUNT);
-
- signals[ACCOUNT_ENABLED] =
- g_signal_new ("account-enabled",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_ACCOUNT);
-
- signals[ACCOUNT_DISABLED] =
- g_signal_new ("account-disabled",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_ACCOUNT);
-
- signals[ACCOUNT_CHANGED] =
- g_signal_new ("account-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_ACCOUNT);
-
- signals[ACCOUNT_CONNECTION_CHANGED] =
- g_signal_new ("account-connection-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_INT_UINT_UINT,
- G_TYPE_NONE,
- 4, EMPATHY_TYPE_ACCOUNT,
- G_TYPE_INT, /* reason */
- G_TYPE_UINT, /* actual connection */
- G_TYPE_UINT); /* previous connection */
-
- signals[GLOBAL_PRESENCE_CHANGED] =
- g_signal_new ("global-presence-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__UINT_STRING_STRING,
- G_TYPE_NONE,
- 3, G_TYPE_UINT, /* Presence type */
- G_TYPE_STRING, /* status */
- G_TYPE_STRING); /* stauts message*/
-
- signals[NEW_CONNECTION] =
- g_signal_new ("new-connection",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, TP_TYPE_CONNECTION);
-
- g_type_class_add_private (oclass, sizeof (EmpathyAccountManagerPriv));
-}
-
-/* public methods */
-
-EmpathyAccountManager *
-empathy_account_manager_dup_singleton (void)
-{
- return g_object_new (EMPATHY_TYPE_ACCOUNT_MANAGER, NULL);
-}
-
-gboolean
-empathy_account_manager_is_ready (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- return priv->ready;
-}
-
-int
-empathy_account_manager_get_connected_accounts (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), 0);
-
- priv = GET_PRIV (manager);
-
- return priv->connected;
-}
-
-int
-empathy_account_manager_get_connecting_accounts (
- EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), 0);
-
- priv = GET_PRIV (manager);
-
- return priv->connecting;
-}
-
-/**
- * empathy_account_manager_get_count:
- * @manager: a #EmpathyAccountManager
- *
- * Get the number of accounts.
- *
- * Returns: the number of accounts.
- **/
-int
-empathy_account_manager_get_count (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), 0);
-
- priv = GET_PRIV (manager);
-
- return g_hash_table_size (priv->accounts);
-}
-
-EmpathyAccount *
-empathy_account_manager_get_account_for_connection (
- EmpathyAccountManager *manager,
- TpConnection *connection)
-{
- EmpathyAccountManagerPriv *priv;
- GHashTableIter iter;
- gpointer value;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), 0);
-
- priv = GET_PRIV (manager);
-
- g_hash_table_iter_init (&iter, priv->accounts);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- {
- EmpathyAccount *account = EMPATHY_ACCOUNT (value);
-
- if (connection == empathy_account_get_connection (account))
- return account;
- }
-
- return NULL;
-}
-
-GList *
-empathy_account_manager_dup_accounts (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv;
- GList *ret;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), NULL);
-
- priv = GET_PRIV (manager);
-
- ret = g_hash_table_get_values (priv->accounts);
- g_list_foreach (ret, (GFunc) g_object_ref, NULL);
-
- return ret;
-}
-
-/**
- * empathy_account_manager_dup_connections:
- * @manager: a #EmpathyAccountManager
- *
- * Get a #GList of all ready #TpConnection. The list must be freed with
- * g_list_free, and its elements must be unreffed.
- *
- * Returns: the list of connections
- **/
-GList *
-empathy_account_manager_dup_connections (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv;
- GHashTableIter iter;
- gpointer value;
- GList *ret = NULL;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), NULL);
-
- priv = GET_PRIV (manager);
-
- g_hash_table_iter_init (&iter, priv->accounts);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- {
- EmpathyAccount *account = EMPATHY_ACCOUNT (value);
- TpConnection *connection;
-
- connection = empathy_account_get_connection (account);
- if (connection != NULL)
- ret = g_list_prepend (ret, g_object_ref (connection));
- }
-
- return ret;
-}
-
-void
-empathy_account_manager_request_global_presence (
- EmpathyAccountManager *manager,
- TpConnectionPresenceType type,
- const gchar *status,
- const gchar *message)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- GHashTableIter iter;
- gpointer value;
-
- DEBUG ("request global presence, type: %d, status: %s, message: %s",
- type, status, message);
-
- g_hash_table_iter_init (&iter, priv->accounts);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- {
- EmpathyAccount *account = EMPATHY_ACCOUNT (value);
- gboolean ready;
-
- g_object_get (account, "ready", &ready, NULL);
-
- if (ready)
- empathy_account_request_presence (account, type, status, message);
- }
-
- /* save the requested global presence, to use it in case we create
- * new accounts or some accounts become ready.
- */
- priv->requested_presence = type;
-
- if (tp_strdiff (priv->requested_status, status))
- {
- g_free (priv->requested_status);
- priv->requested_status = g_strdup (status);
- }
-
- if (tp_strdiff (priv->requested_status_message, message))
- {
- g_free (priv->requested_status_message);
- priv->requested_status_message = g_strdup (message);
- }
-}
-
-TpConnectionPresenceType
-empathy_account_manager_get_requested_global_presence (
- EmpathyAccountManager *manager,
- gchar **status,
- gchar **message)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- if (status != NULL)
- *status = g_strdup (priv->requested_status);
- if (message != NULL)
- *message = g_strdup (priv->requested_status_message);
-
- return priv->requested_presence;
-}
-
-TpConnectionPresenceType
-empathy_account_manager_get_global_presence (
- EmpathyAccountManager *manager,
- gchar **status,
- gchar **message)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- if (status != NULL)
- *status = g_strdup (priv->global_status);
- if (message != NULL)
- *message = g_strdup (priv->global_status_message);
-
- return priv->global_presence;
-}
-
-static void
-empathy_account_manager_created_cb (TpAccountManager *proxy,
- const gchar *account_path,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (weak_object);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- GSimpleAsyncResult *my_res = user_data;
- EmpathyAccount *account;
-
- if (error != NULL)
- {
- g_simple_async_result_set_from_error (my_res,
- (GError *) error);
- g_simple_async_result_complete (my_res);
- g_object_unref (my_res);
-
- return;
- }
-
- account = empathy_account_manager_ensure_account (manager, account_path);
-
- g_hash_table_insert (priv->create_results, account, my_res);
-}
-
-void
-empathy_account_manager_create_account_async (EmpathyAccountManager *manager,
- const gchar *connection_manager,
- const gchar *protocol,
- const gchar *display_name,
- GHashTable *parameters,
- GHashTable *properties,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- GSimpleAsyncResult *res;
-
- res = g_simple_async_result_new
- (G_OBJECT (manager), callback, user_data,
- empathy_account_manager_create_account_finish);
-
- tp_cli_account_manager_call_create_account (priv->tp_manager,
- -1,
- connection_manager,
- protocol,
- display_name,
- parameters,
- properties,
- empathy_account_manager_created_cb,
- res,
- NULL,
- G_OBJECT (manager));
-}
-
-EmpathyAccount *
-empathy_account_manager_create_account_finish (
- EmpathyAccountManager *manager, GAsyncResult *result, GError **error)
-{
- EmpathyAccount *retval;
-
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
- error))
- return NULL;
-
- g_return_val_if_fail (g_simple_async_result_is_valid (result,
- G_OBJECT (manager), empathy_account_manager_create_account_finish), NULL);
-
- retval = EMPATHY_ACCOUNT (g_simple_async_result_get_op_res_gpointer (
- G_SIMPLE_ASYNC_RESULT (result)));
-
- return retval;
-}
-
diff --git a/libempathy/empathy-account-manager.h b/libempathy/empathy-account-manager.h
deleted file mode 100644
index 7b4ebd9bb..000000000
--- a/libempathy/empathy-account-manager.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
- */
-
-#ifndef __EMPATHY_ACCOUNT_MANAGER_H__
-#define __EMPATHY_ACCOUNT_MANAGER_H__
-
-#include <glib-object.h>
-
-#include "empathy-account.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_ACCOUNT_MANAGER (empathy_account_manager_get_type ())
-#define EMPATHY_ACCOUNT_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
- EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManager))
-#define EMPATHY_ACCOUNT_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), \
- EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManagerClass))
-#define EMPATHY_IS_ACCOUNT_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
- EMPATHY_TYPE_ACCOUNT_MANAGER))
-#define EMPATHY_IS_ACCOUNT_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), \
- EMPATHY_TYPE_ACCOUNT_MANAGER))
-#define EMPATHY_ACCOUNT_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
- EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManagerClass))
-
-typedef struct _EmpathyAccountManager EmpathyAccountManager;
-typedef struct _EmpathyAccountManagerClass EmpathyAccountManagerClass;
-
-struct _EmpathyAccountManager {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyAccountManagerClass {
- GObjectClass parent_class;
-};
-
-GType empathy_account_manager_get_type (void);
-
-/* public methods */
-
-EmpathyAccountManager * empathy_account_manager_dup_singleton (void);
-
-gboolean empathy_account_manager_is_ready (EmpathyAccountManager *manager);
-
-int empathy_account_manager_get_connected_accounts
- (EmpathyAccountManager *manager);
-int empathy_account_manager_get_connecting_accounts
- (EmpathyAccountManager *manager);
-int empathy_account_manager_get_count
- (EmpathyAccountManager *manager);
-EmpathyAccount * empathy_account_manager_get_account_for_connection
- (EmpathyAccountManager *manager,
- TpConnection *connection);
-EmpathyAccount * empathy_account_manager_ensure_account
- (EmpathyAccountManager *manager,
- const gchar *unique_name);
-EmpathyAccount * empathy_account_manager_get_account
- (EmpathyAccountManager *manager,
- const gchar *unique_name);
-GList * empathy_account_manager_dup_accounts
- (EmpathyAccountManager *manager);
-GList * empathy_account_manager_dup_connections
- (EmpathyAccountManager *manager);
-
-void empathy_account_manager_request_global_presence (
- EmpathyAccountManager *manager,
- TpConnectionPresenceType type,
- const gchar *status,
- const gchar *message);
-
-TpConnectionPresenceType empathy_account_manager_get_requested_global_presence (
- EmpathyAccountManager *manager,
- gchar **status,
- gchar **message);
-
-TpConnectionPresenceType empathy_account_manager_get_global_presence (
- EmpathyAccountManager *manager,
- gchar **status,
- gchar **message);
-
-void empathy_account_manager_create_account_async (
- EmpathyAccountManager *manager, const gchar *connection_manager,
- const gchar *protocol, const gchar *display_name,
- GHashTable *parameters, GHashTable *properties,
- GAsyncReadyCallback callback, gpointer user_data);
-
-EmpathyAccount * empathy_account_manager_create_account_finish (
- EmpathyAccountManager *settings, GAsyncResult *result, GError **error);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_ACCOUNT_MANAGER_H__ */
-
diff --git a/libempathy/empathy-account.c b/libempathy/empathy-account.c
deleted file mode 100644
index fb1b2756d..000000000
--- a/libempathy/empathy-account.c
+++ /dev/null
@@ -1,1305 +0,0 @@
-/*
- * empathy-account.c - Source for EmpathyAccount
- * Copyright (C) 2009 Collabora Ltd.
- * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <telepathy-glib/enums.h>
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/account.h>
-#include <telepathy-glib/gtypes.h>
-#include <telepathy-glib/util.h>
-#include <telepathy-glib/interfaces.h>
-#include <telepathy-glib/defs.h>
-
-#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
-#include <libempathy/empathy-debug.h>
-
-#include <glib/gi18n-lib.h>
-
-#include "empathy-account.h"
-#include "empathy-account-manager.h"
-#include "empathy-utils.h"
-#include "empathy-marshal.h"
-
-/* signals */
-enum {
- STATUS_CHANGED,
- PRESENCE_CHANGED,
- REMOVED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-/* properties */
-enum {
- PROP_ENABLED = 1,
- PROP_PRESENCE,
- PROP_STATUS,
- PROP_STATUS_MESSAGE,
- PROP_READY,
- PROP_CONNECTION_STATUS,
- PROP_CONNECTION_STATUS_REASON,
- PROP_CONNECTION,
- PROP_UNIQUE_NAME,
- PROP_DBUS_DAEMON,
- PROP_DISPLAY_NAME
-};
-
-G_DEFINE_TYPE(EmpathyAccount, empathy_account, G_TYPE_OBJECT)
-
-/* private structure */
-typedef struct _EmpathyAccountPriv EmpathyAccountPriv;
-
-struct _EmpathyAccountPriv
-{
- gboolean dispose_has_run;
-
- TpConnection *connection;
- guint connection_invalidated_id;
-
- TpConnectionStatus connection_status;
- TpConnectionStatusReason reason;
-
- TpConnectionPresenceType presence;
- gchar *status;
- gchar *message;
-
- gboolean enabled;
- gboolean valid;
- gboolean ready;
- gboolean removed;
- /* Timestamp when the connection got connected in seconds since the epoch */
- glong connect_time;
-
- gchar *cm_name;
- gchar *proto_name;
- gchar *icon_name;
-
- gchar *unique_name;
- gchar *display_name;
- TpDBusDaemon *dbus;
-
- TpAccount *account;
- GHashTable *parameters;
-};
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccount)
-
-static void _empathy_account_set_connection (EmpathyAccount *account,
- const gchar *path);
-
-static void
-empathy_account_init (EmpathyAccount *obj)
-{
- EmpathyAccountPriv *priv;
-
- priv = G_TYPE_INSTANCE_GET_PRIVATE (obj,
- EMPATHY_TYPE_ACCOUNT, EmpathyAccountPriv);
-
- obj->priv = priv;
-
- priv->connection_status = TP_CONNECTION_STATUS_DISCONNECTED;
-}
-
-static void
-empathy_account_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (object);
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- switch (prop_id)
- {
- case PROP_ENABLED:
- empathy_account_set_enabled_async (account,
- g_value_get_boolean (value), NULL, NULL);
- break;
- case PROP_UNIQUE_NAME:
- priv->unique_name = g_value_dup_string (value);
- break;
- case PROP_DBUS_DAEMON:
- priv->dbus = g_value_get_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-empathy_account_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (object);
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- switch (prop_id)
- {
- case PROP_ENABLED:
- g_value_set_boolean (value, priv->enabled);
- break;
- case PROP_READY:
- g_value_set_boolean (value, priv->ready);
- break;
- case PROP_PRESENCE:
- g_value_set_uint (value, priv->presence);
- break;
- case PROP_STATUS:
- g_value_set_string (value, priv->status);
- break;
- case PROP_STATUS_MESSAGE:
- g_value_set_string (value, priv->message);
- break;
- case PROP_CONNECTION_STATUS:
- g_value_set_uint (value, priv->connection_status);
- break;
- case PROP_CONNECTION_STATUS_REASON:
- g_value_set_uint (value, priv->reason);
- break;
- case PROP_CONNECTION:
- g_value_set_object (value,
- empathy_account_get_connection (account));
- break;
- case PROP_UNIQUE_NAME:
- g_value_set_string (value,
- empathy_account_get_unique_name (account));
- break;
- case PROP_DISPLAY_NAME:
- g_value_set_string (value,
- empathy_account_get_display_name (account));
- break;
- case PROP_DBUS_DAEMON:
- g_value_set_object (value, priv->dbus);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-empathy_account_update (EmpathyAccount *account,
- GHashTable *properties)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
- GValueArray *arr;
- TpConnectionStatus old_s = priv->connection_status;
- gboolean presence_changed = FALSE;
-
- if (g_hash_table_lookup (properties, "ConnectionStatus") != NULL)
- priv->connection_status =
- tp_asv_get_int32 (properties, "ConnectionStatus", NULL);
-
- if (g_hash_table_lookup (properties, "ConnectionStatusReason") != NULL)
- priv->reason = tp_asv_get_int32 (properties,
- "ConnectionStatusReason", NULL);
-
- if (g_hash_table_lookup (properties, "CurrentPresence") != NULL)
- {
- presence_changed = TRUE;
- arr = tp_asv_get_boxed (properties, "CurrentPresence",
- TP_STRUCT_TYPE_SIMPLE_PRESENCE);
- priv->presence = g_value_get_uint (g_value_array_get_nth (arr, 0));
-
- g_free (priv->status);
- priv->status = g_value_dup_string (g_value_array_get_nth (arr, 1));
-
- g_free (priv->message);
- priv->message = g_value_dup_string (g_value_array_get_nth (arr, 2));
- }
-
- if (g_hash_table_lookup (properties, "DisplayName") != NULL)
- {
- g_free (priv->display_name);
- priv->display_name =
- g_strdup (tp_asv_get_string (properties, "DisplayName"));
- g_object_notify (G_OBJECT (account), "display-name");
- }
-
- if (g_hash_table_lookup (properties, "Icon") != NULL)
- {
- const gchar *icon_name;
-
- icon_name = tp_asv_get_string (properties, "Icon");
-
- g_free (priv->icon_name);
-
- if (EMP_STR_EMPTY (icon_name))
- priv->icon_name = empathy_protocol_icon_name (priv->proto_name);
- else
- priv->icon_name = g_strdup (icon_name);
- }
-
- if (g_hash_table_lookup (properties, "Enabled") != NULL)
- {
- gboolean enabled = tp_asv_get_boolean (properties, "Enabled", NULL);
- if (priv->enabled != enabled)
- {
- priv->enabled = enabled;
- g_object_notify (G_OBJECT (account), "enabled");
- }
- }
-
- if (g_hash_table_lookup (properties, "Valid") != NULL)
- priv->valid = tp_asv_get_boolean (properties, "Valid", NULL);
-
- if (g_hash_table_lookup (properties, "Parameters") != NULL)
- {
- GHashTable *parameters;
-
- parameters = tp_asv_get_boxed (properties, "Parameters",
- TP_HASH_TYPE_STRING_VARIANT_MAP);
-
- if (priv->parameters != NULL)
- g_hash_table_unref (priv->parameters);
-
- priv->parameters = g_boxed_copy (TP_HASH_TYPE_STRING_VARIANT_MAP,
- parameters);
- }
-
- if (!priv->ready)
- {
- priv->ready = TRUE;
- g_object_notify (G_OBJECT (account), "ready");
- }
-
- if (priv->connection_status != old_s)
- {
- if (priv->connection_status == TP_CONNECTION_STATUS_CONNECTED)
- {
- GTimeVal val;
- g_get_current_time (&val);
-
- priv->connect_time = val.tv_sec;
- }
-
- g_signal_emit (account, signals[STATUS_CHANGED], 0,
- old_s, priv->connection_status, priv->reason);
-
- g_object_notify (G_OBJECT (account), "connection-status");
- g_object_notify (G_OBJECT (account), "connection-status-reason");
- }
-
- if (presence_changed)
- {
- g_signal_emit (account, signals[PRESENCE_CHANGED], 0,
- priv->presence, priv->status, priv->message);
- g_object_notify (G_OBJECT (account), "presence");
- g_object_notify (G_OBJECT (account), "status");
- g_object_notify (G_OBJECT (account), "status-message");
- }
-
- if (g_hash_table_lookup (properties, "Connection") != NULL)
- {
- const gchar *conn_path =
- tp_asv_get_object_path (properties, "Connection");
-
- _empathy_account_set_connection (account, conn_path);
- }
-}
-
-static void
-empathy_account_properties_changed (TpAccount *proxy,
- GHashTable *properties,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (weak_object);
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- if (!priv->ready)
- return;
-
- empathy_account_update (account, properties);
-}
-
-static void
-empathy_account_removed_cb (TpAccount *proxy,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (weak_object);
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- if (priv->removed)
- return;
-
- priv->removed = TRUE;
-
- g_signal_emit (account, signals[REMOVED], 0);
-}
-
-static void
-empathy_account_got_all_cb (TpProxy *proxy,
- GHashTable *properties,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (weak_object);
-
- DEBUG ("Got whole set of properties for %s",
- empathy_account_get_unique_name (account));
-
- if (error != NULL)
- {
- DEBUG ("Failed to get the initial set of account properties: %s",
- error->message);
- return;
- }
-
- empathy_account_update (account, properties);
-}
-
-static gchar *
-empathy_account_unescape_protocol (const gchar *protocol, gssize len)
-{
- gchar *result, *escape;
- /* Bad implementation might accidentally use tp_escape_as_identifier,
- * which escapes - in the wrong way... */
- if ((escape = g_strstr_len (protocol, len, "_2d")) != NULL)
- {
- GString *str;
- const gchar *input;
-
- str = g_string_new ("");
- input = protocol;
- do {
- g_string_append_len (str, input, escape - input);
- g_string_append_c (str, '-');
-
- len -= escape - input + 3;
- input = escape + 3;
- } while ((escape = g_strstr_len (input, len, "_2d")) != NULL);
-
- g_string_append_len (str, input, len);
-
- result = g_string_free (str, FALSE);
- }
- else
- {
- result = g_strndup (protocol, len);
- }
-
- g_strdelimit (result, "_", '-');
-
- return result;
-}
-
-static gboolean
-empathy_account_parse_unique_name (const gchar *bus_name,
- gchar **protocol, gchar **manager)
-{
- const gchar *proto, *proto_end;
- const gchar *cm, *cm_end;
-
- g_return_val_if_fail (
- g_str_has_prefix (bus_name, TP_ACCOUNT_OBJECT_PATH_BASE), FALSE);
-
- cm = bus_name + strlen (TP_ACCOUNT_OBJECT_PATH_BASE);
-
- for (cm_end = cm; *cm_end != '/' && *cm_end != '\0'; cm_end++)
- /* pass */;
-
- if (*cm_end == '\0')
- return FALSE;
-
- if (cm_end == '\0')
- return FALSE;
-
- proto = cm_end + 1;
-
- for (proto_end = proto; *proto_end != '/' && *proto_end != '\0'; proto_end++)
- /* pass */;
-
- if (*proto_end == '\0')
- return FALSE;
-
- if (protocol != NULL)
- {
- *protocol = empathy_account_unescape_protocol (proto, proto_end - proto);
- }
-
- if (manager != NULL)
- *manager = g_strndup (cm, cm_end - cm);
-
- return TRUE;
-}
-
-static void
-account_invalidated_cb (TpProxy *proxy, guint domain, gint code,
- gchar *message, gpointer user_data)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (user_data);
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- if (priv->removed)
- return;
-
- priv->removed = TRUE;
-
- g_signal_emit (account, signals[REMOVED], 0);
-}
-
-static void
-empathy_account_constructed (GObject *object)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (object);
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- priv->account = tp_account_new (priv->dbus, priv->unique_name, NULL);
-
- g_signal_connect (priv->account, "invalidated",
- G_CALLBACK (account_invalidated_cb), object);
-
- empathy_account_parse_unique_name (priv->unique_name,
- &(priv->proto_name), &(priv->cm_name));
-
- priv->icon_name = empathy_protocol_icon_name (priv->proto_name);
-
- tp_cli_account_connect_to_account_property_changed (priv->account,
- empathy_account_properties_changed,
- NULL, NULL, object, NULL);
-
- tp_cli_account_connect_to_removed (priv->account,
- empathy_account_removed_cb,
- NULL, NULL, object, NULL);
-
- empathy_account_refresh_properties (account);
-}
-
-static void empathy_account_dispose (GObject *object);
-static void empathy_account_finalize (GObject *object);
-
-static void
-empathy_account_class_init (EmpathyAccountClass *empathy_account_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (empathy_account_class);
-
- g_type_class_add_private (empathy_account_class,
- sizeof (EmpathyAccountPriv));
-
- object_class->set_property = empathy_account_set_property;
- object_class->get_property = empathy_account_get_property;
- object_class->dispose = empathy_account_dispose;
- object_class->finalize = empathy_account_finalize;
- object_class->constructed = empathy_account_constructed;
-
- g_object_class_install_property (object_class, PROP_ENABLED,
- g_param_spec_boolean ("enabled",
- "Enabled",
- "Whether this account is enabled or not",
- FALSE,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class, PROP_READY,
- g_param_spec_boolean ("ready",
- "Ready",
- "Whether this account is ready to be used",
- FALSE,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- g_object_class_install_property (object_class, PROP_PRESENCE,
- g_param_spec_uint ("presence",
- "Presence",
- "The account connections presence type",
- 0,
- NUM_TP_CONNECTION_PRESENCE_TYPES,
- TP_CONNECTION_PRESENCE_TYPE_UNSET,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- g_object_class_install_property (object_class, PROP_STATUS,
- g_param_spec_string ("status",
- "Status",
- "The Status string of the account",
- NULL,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- g_object_class_install_property (object_class, PROP_STATUS_MESSAGE,
- g_param_spec_string ("status-message",
- "status-message",
- "The Status message string of the account",
- NULL,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- g_object_class_install_property (object_class, PROP_CONNECTION_STATUS,
- g_param_spec_uint ("connection-status",
- "ConnectionStatus",
- "The accounts connections status type",
- 0,
- NUM_TP_CONNECTION_STATUSES,
- TP_CONNECTION_STATUS_DISCONNECTED,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- g_object_class_install_property (object_class, PROP_CONNECTION_STATUS_REASON,
- g_param_spec_uint ("connection-status-reason",
- "ConnectionStatusReason",
- "The account connections status reason",
- 0,
- NUM_TP_CONNECTION_STATUS_REASONS,
- TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- g_object_class_install_property (object_class, PROP_CONNECTION,
- g_param_spec_object ("connection",
- "Connection",
- "The accounts connection",
- TP_TYPE_CONNECTION,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- g_object_class_install_property (object_class, PROP_UNIQUE_NAME,
- g_param_spec_string ("unique-name",
- "UniqueName",
- "The accounts unique name",
- NULL,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (object_class, PROP_DBUS_DAEMON,
- g_param_spec_object ("dbus-daemon",
- "dbus-daemon",
- "The Tp Dbus daemon on which this account exists",
- TP_TYPE_DBUS_DAEMON,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (object_class, PROP_DISPLAY_NAME,
- g_param_spec_string ("display-name",
- "DisplayName",
- "The accounts display name",
- NULL,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- signals[STATUS_CHANGED] = g_signal_new ("status-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- _empathy_marshal_VOID__UINT_UINT_UINT,
- G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
-
- signals[PRESENCE_CHANGED] = g_signal_new ("presence-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- _empathy_marshal_VOID__UINT_STRING_STRING,
- G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
-
- signals[REMOVED] = g_signal_new ("removed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-empathy_account_free_connection (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
- TpConnection *conn;
-
- if (priv->connection == NULL)
- return;
-
- conn = priv->connection;
- priv->connection = NULL;
-
- if (priv->connection_invalidated_id != 0)
- g_signal_handler_disconnect (conn, priv->connection_invalidated_id);
- priv->connection_invalidated_id = 0;
-
- g_object_unref (conn);
-}
-
-void
-empathy_account_dispose (GObject *object)
-{
- EmpathyAccount *self = EMPATHY_ACCOUNT (object);
- EmpathyAccountPriv *priv = GET_PRIV (self);
-
- if (priv->dispose_has_run)
- return;
-
- priv->dispose_has_run = TRUE;
-
- empathy_account_free_connection (self);
-
- /* release any references held by the object here */
- if (G_OBJECT_CLASS (empathy_account_parent_class)->dispose != NULL)
- G_OBJECT_CLASS (empathy_account_parent_class)->dispose (object);
-}
-
-void
-empathy_account_finalize (GObject *object)
-{
- EmpathyAccountPriv *priv = GET_PRIV (object);
-
- g_free (priv->status);
- g_free (priv->message);
-
- g_free (priv->cm_name);
- g_free (priv->proto_name);
- g_free (priv->icon_name);
- g_free (priv->display_name);
-
- /* free any data held directly by the object here */
- if (G_OBJECT_CLASS (empathy_account_parent_class)->finalize != NULL)
- G_OBJECT_CLASS (empathy_account_parent_class)->finalize (object);
-}
-
-gboolean
-empathy_account_is_just_connected (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
- GTimeVal val;
-
- if (priv->connection_status != TP_CONNECTION_STATUS_CONNECTED)
- return FALSE;
-
- g_get_current_time (&val);
-
- return (val.tv_sec - priv->connect_time) < 10;
-}
-
-/**
- * empathy_account_get_connection:
- * @account: a #EmpathyAccount
- *
- * Get the connection of the account, or NULL if account is offline or the
- * connection is not yet ready. This function does not return a new ref.
- *
- * Returns: the connection of the account.
- **/
-TpConnection *
-empathy_account_get_connection (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- if (priv->connection != NULL &&
- tp_connection_is_ready (priv->connection))
- return priv->connection;
-
- return NULL;
-}
-
-/**
- * empathy_account_get_connection_for_path:
- * @account: a #EmpathyAccount
- * @patch: the path to connection object for #EmpathyAccount
- *
- * Get the connection of the account on path. This function does not return a
- * new ref. It is not guaranteed that the returned connection object is ready
- *
- * Returns: the connection of the account.
- **/
-TpConnection *
-empathy_account_get_connection_for_path (EmpathyAccount *account,
- const gchar *path)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- /* double-check that the object path is valid */
- if (!tp_dbus_check_valid_object_path (path, NULL))
- return NULL;
-
- /* Should be a full object path, not the special "/" value */
- if (strlen (path) == 1)
- return NULL;
-
- _empathy_account_set_connection (account, path);
-
- return priv->connection;
-}
-
-/**
- * empathy_account_get_unique_name:
- * @account: a #EmpathyAccount
- *
- * Returns: the unique name of the account.
- **/
-const gchar *
-empathy_account_get_unique_name (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->unique_name;
-}
-
-/**
- * empathy_account_get_display_name:
- * @account: a #EmpathyAccount
- *
- * Returns: the display name of the account.
- **/
-const gchar *
-empathy_account_get_display_name (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->display_name;
-}
-
-gboolean
-empathy_account_is_valid (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->valid;
-}
-
-const gchar *
-empathy_account_get_connection_manager (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->cm_name;
-}
-
-const gchar *
-empathy_account_get_protocol (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->proto_name;
-}
-
-const gchar *
-empathy_account_get_icon_name (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->icon_name;
-}
-
-const GHashTable *
-empathy_account_get_parameters (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->parameters;
-}
-
-gboolean
-empathy_account_is_enabled (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->enabled;
-}
-
-gboolean
-empathy_account_is_ready (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->ready;
-}
-
-
-EmpathyAccount *
-empathy_account_new (TpDBusDaemon *dbus,
- const gchar *unique_name)
-{
- return EMPATHY_ACCOUNT (g_object_new (EMPATHY_TYPE_ACCOUNT,
- "dbus-daemon", dbus,
- "unique-name", unique_name,
- NULL));
-}
-
-static void
-empathy_account_connection_ready_cb (TpConnection *connection,
- const GError *error,
- gpointer user_data)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (user_data);
-
- if (error != NULL)
- {
- DEBUG ("(%s) Connection failed to become ready: %s",
- empathy_account_get_unique_name (account), error->message);
- empathy_account_free_connection (account);
- }
- else
- {
- DEBUG ("(%s) Connection ready",
- empathy_account_get_unique_name (account));
- g_object_notify (G_OBJECT (account), "connection");
- }
-}
-
-static void
-_empathy_account_connection_invalidated_cb (TpProxy *self,
- guint domain,
- gint code,
- gchar *message,
- gpointer user_data)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (user_data);
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- if (priv->connection == NULL)
- return;
-
- DEBUG ("(%s) Connection invalidated",
- empathy_account_get_unique_name (account));
-
- g_assert (priv->connection == TP_CONNECTION (self));
-
- empathy_account_free_connection (account);
-
- g_object_notify (G_OBJECT (account), "connection");
-}
-
-static void
-_empathy_account_set_connection (EmpathyAccount *account,
- const gchar *path)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- if (priv->connection != NULL)
- {
- const gchar *current;
-
- current = tp_proxy_get_object_path (priv->connection);
- if (!tp_strdiff (current, path))
- return;
- }
-
- empathy_account_free_connection (account);
-
- if (tp_strdiff ("/", path))
- {
- GError *error = NULL;
- priv->connection = tp_connection_new (priv->dbus, NULL, path, &error);
-
- if (priv->connection == NULL)
- {
- DEBUG ("Failed to create a new TpConnection: %s",
- error->message);
- g_error_free (error);
- }
- else
- {
- priv->connection_invalidated_id = g_signal_connect (priv->connection,
- "invalidated",
- G_CALLBACK (_empathy_account_connection_invalidated_cb), account);
-
- DEBUG ("Readying connection for %s", priv->unique_name);
- /* notify a change in the connection property when it's ready */
- tp_connection_call_when_ready (priv->connection,
- empathy_account_connection_ready_cb, account);
- }
- }
-
- g_object_notify (G_OBJECT (account), "connection");
-}
-
-static void
-account_enabled_set_cb (TpProxy *proxy,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- GSimpleAsyncResult *result = user_data;
-
- if (error != NULL)
- g_simple_async_result_set_from_error (result, (GError *) error);
-
- g_simple_async_result_complete (result);
- g_object_unref (result);
-}
-
-gboolean
-empathy_account_set_enabled_finish (EmpathyAccount *account,
- GAsyncResult *result,
- GError **error)
-{
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
- error) ||
- !g_simple_async_result_is_valid (result, G_OBJECT (account),
- empathy_account_set_enabled_finish))
- return FALSE;
-
- return TRUE;
-}
-
-void
-empathy_account_set_enabled_async (EmpathyAccount *account,
- gboolean enabled,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
- EmpathyAccountManager *acc_manager;
- GValue value = {0, };
- GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (account),
- callback, user_data, empathy_account_set_enabled_finish);
- char *status = NULL;
- char *status_message = NULL;
- TpConnectionPresenceType presence;
-
- if (priv->enabled == enabled)
- {
- g_simple_async_result_complete_in_idle (result);
- return;
- }
-
- if (enabled)
- {
- acc_manager = empathy_account_manager_dup_singleton ();
- presence = empathy_account_manager_get_requested_global_presence
- (acc_manager, &status, &status_message);
-
- if (presence != TP_CONNECTION_PRESENCE_TYPE_UNSET)
- empathy_account_request_presence (account, presence, status,
- status_message);
-
- g_object_unref (acc_manager);
- g_free (status);
- g_free (status_message);
- }
-
- g_value_init (&value, G_TYPE_BOOLEAN);
- g_value_set_boolean (&value, enabled);
-
- tp_cli_dbus_properties_call_set (TP_PROXY (priv->account),
- -1, TP_IFACE_ACCOUNT, "Enabled", &value,
- account_enabled_set_cb, result, NULL, G_OBJECT (account));
-}
-
-static void
-account_reconnected_cb (TpAccount *proxy,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- GSimpleAsyncResult *result = user_data;
-
- if (error != NULL)
- g_simple_async_result_set_from_error (result, (GError *) error);
-
- g_simple_async_result_complete (result);
- g_object_unref (result);
-}
-
-gboolean
-empathy_account_reconnect_finish (EmpathyAccount *account,
- GAsyncResult *result,
- GError **error)
-{
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
- error) ||
- !g_simple_async_result_is_valid (result, G_OBJECT (account),
- empathy_account_reconnect_finish))
- return FALSE;
-
- return TRUE;
-}
-
-void
-empathy_account_reconnect_async (EmpathyAccount *account,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (account),
- callback, user_data, empathy_account_reconnect_finish);
-
- tp_cli_account_call_reconnect (priv->account,
- -1, account_reconnected_cb, result, NULL, G_OBJECT (account));
-}
-
-static void
-empathy_account_requested_presence_cb (TpProxy *proxy,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- if (error)
- DEBUG ("Failed to set the requested presence: %s", error->message);
-}
-
-
-void
-empathy_account_request_presence (EmpathyAccount *account,
- TpConnectionPresenceType type,
- const gchar *status,
- const gchar *message)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
- GValue value = {0, };
- GValueArray *arr;
-
- g_value_init (&value, TP_STRUCT_TYPE_SIMPLE_PRESENCE);
- g_value_take_boxed (&value, dbus_g_type_specialized_construct
- (TP_STRUCT_TYPE_SIMPLE_PRESENCE));
- arr = (GValueArray *) g_value_get_boxed (&value);
-
- g_value_set_uint (arr->values, type);
- g_value_set_static_string (arr->values + 1, status);
- g_value_set_static_string (arr->values + 2, message);
-
- tp_cli_dbus_properties_call_set (TP_PROXY (priv->account),
- -1,
- TP_IFACE_ACCOUNT,
- "RequestedPresence",
- &value,
- empathy_account_requested_presence_cb,
- NULL,
- NULL,
- G_OBJECT (account));
-
- g_value_unset (&value);
-}
-
-static void
-empathy_account_updated_cb (TpAccount *proxy,
- const gchar **reconnect_required,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
-
- if (error != NULL)
- {
- g_simple_async_result_set_from_error (result, (GError *) error);
- }
-
- g_simple_async_result_complete (result);
- g_object_unref (G_OBJECT (result));
-}
-
-void
-empathy_account_update_settings_async (EmpathyAccount *account,
- GHashTable *parameters, const gchar **unset_parameters,
- GAsyncReadyCallback callback, gpointer user_data)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
- GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (account),
- callback, user_data, empathy_account_update_settings_finish);
-
- tp_cli_account_call_update_parameters (priv->account,
- -1,
- parameters,
- unset_parameters,
- empathy_account_updated_cb,
- result,
- NULL,
- G_OBJECT (account));
-}
-
-gboolean
-empathy_account_update_settings_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error)
-{
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
- error))
- return FALSE;
-
- g_return_val_if_fail (g_simple_async_result_is_valid (result,
- G_OBJECT (account), empathy_account_update_settings_finish), FALSE);
-
- return TRUE;
-}
-
-static void
-account_display_name_set_cb (TpProxy *proxy,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- GSimpleAsyncResult *result = user_data;
-
- if (error != NULL)
- g_simple_async_result_set_from_error (result, (GError *) error);
-
- g_simple_async_result_complete (result);
- g_object_unref (result);
-}
-
-void
-empathy_account_set_display_name_async (EmpathyAccount *account,
- const char *display_name,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *result;
- GValue value = {0, };
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- if (display_name == NULL)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (account),
- callback, user_data, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("Can't set an empty display name"));
- return;
- }
-
- result = g_simple_async_result_new (G_OBJECT (account), callback,
- user_data, empathy_account_set_display_name_finish);
-
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, display_name);
-
- tp_cli_dbus_properties_call_set (priv->account, -1, TP_IFACE_ACCOUNT,
- "DisplayName", &value, account_display_name_set_cb, result, NULL,
- G_OBJECT (account));
-}
-
-gboolean
-empathy_account_set_display_name_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error)
-{
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
- error) ||
- !g_simple_async_result_is_valid (result, G_OBJECT (account),
- empathy_account_set_display_name_finish))
- return FALSE;
-
- return TRUE;
-}
-
-static void
-account_icon_name_set_cb (TpProxy *proxy,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- GSimpleAsyncResult *result = user_data;
-
- if (error != NULL)
- g_simple_async_result_set_from_error (result, (GError *) error);
-
- g_simple_async_result_complete (result);
- g_object_unref (result);
-}
-
-void
-empathy_account_set_icon_name_async (EmpathyAccount *account,
- const char *icon_name,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *result;
- GValue value = {0, };
- EmpathyAccountPriv *priv = GET_PRIV (account);
- const char *icon_name_set;
-
- if (icon_name == NULL)
- /* settings an empty icon name is allowed */
- icon_name_set = "";
- else
- icon_name_set = icon_name;
-
- result = g_simple_async_result_new (G_OBJECT (account), callback,
- user_data, empathy_account_set_icon_name_finish);
-
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, icon_name_set);
-
- tp_cli_dbus_properties_call_set (priv->account, -1, TP_IFACE_ACCOUNT,
- "Icon", &value, account_icon_name_set_cb, result, NULL,
- G_OBJECT (account));
-}
-
-gboolean
-empathy_account_set_icon_name_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error)
-{
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
- error) ||
- !g_simple_async_result_is_valid (result, G_OBJECT (account),
- empathy_account_set_icon_name_finish))
- return FALSE;
-
- return TRUE;
-}
-
-static void
-empathy_account_remove_cb (TpAccount *proxy,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
-
- if (error != NULL)
- {
- g_simple_async_result_set_from_error (result, (GError *) error);
- }
-
- g_simple_async_result_complete (result);
- g_object_unref (G_OBJECT (result));
-}
-
-void
-empathy_account_remove_async (EmpathyAccount *account,
- GAsyncReadyCallback callback, gpointer user_data)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
- GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (account),
- callback, user_data, empathy_account_remove_finish);
-
- tp_cli_account_call_remove (priv->account,
- -1,
- empathy_account_remove_cb,
- result,
- NULL,
- G_OBJECT (account));
-}
-
-gboolean
-empathy_account_remove_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error)
-{
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
- error))
- return FALSE;
-
- g_return_val_if_fail (g_simple_async_result_is_valid (result,
- G_OBJECT (account), empathy_account_update_settings_finish), FALSE);
-
- return TRUE;
-}
-
-void
-empathy_account_refresh_properties (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_ACCOUNT (account));
-
- priv = GET_PRIV (account);
-
- tp_cli_dbus_properties_call_get_all (priv->account, -1,
- TP_IFACE_ACCOUNT,
- empathy_account_got_all_cb,
- NULL,
- NULL,
- G_OBJECT (account));
-}
-
diff --git a/libempathy/empathy-account.h b/libempathy/empathy-account.h
deleted file mode 100644
index 66f899448..000000000
--- a/libempathy/empathy-account.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * empathy-account.h - Header for EmpathyAccount
- * Copyright (C) 2009 Collabora Ltd.
- * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef __EMPATHY_ACCOUNT_H__
-#define __EMPATHY_ACCOUNT_H__
-
-#include <glib-object.h>
-#include <gio/gio.h>
-
-#include <telepathy-glib/connection.h>
-
-G_BEGIN_DECLS
-
-typedef struct _EmpathyAccount EmpathyAccount;
-typedef struct _EmpathyAccountClass EmpathyAccountClass;
-
-struct _EmpathyAccountClass {
- GObjectClass parent_class;
-};
-
-struct _EmpathyAccount {
- GObject parent;
- gpointer priv;
-};
-
-GType empathy_account_get_type (void);
-
-/* TYPE MACROS */
-#define EMPATHY_TYPE_ACCOUNT (empathy_account_get_type ())
-#define EMPATHY_ACCOUNT(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_ACCOUNT, EmpathyAccount))
-#define EMPATHY_ACCOUNT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_ACCOUNT, EmpathyAccountClass))
-#define EMPATHY_IS_ACCOUNT(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_ACCOUNT))
-#define EMPATHY_IS_ACCOUNT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_ACCOUNT))
-#define EMPATHY_ACCOUNT_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_ACCOUNT, \
- EmpathyAccountClass))
-
-gboolean empathy_account_is_just_connected (EmpathyAccount *account);
-TpConnection *empathy_account_get_connection (EmpathyAccount *account);
-TpConnection *empathy_account_get_connection_for_path (EmpathyAccount *account,
- const gchar *path);
-const gchar *empathy_account_get_unique_name (EmpathyAccount *account);
-const gchar *empathy_account_get_display_name (EmpathyAccount *account);
-
-const gchar *empathy_account_get_connection_manager (EmpathyAccount *account);
-const gchar *empathy_account_get_protocol (EmpathyAccount *account);
-const gchar *empathy_account_get_icon_name (EmpathyAccount *account);
-
-void empathy_account_set_enabled_async (EmpathyAccount *account,
- gboolean enabled, GAsyncReadyCallback callback, gpointer user_data);
-gboolean empathy_account_set_enabled_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error);
-
-void empathy_account_reconnect_async (EmpathyAccount *account,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean empathy_account_reconnect_finish (EmpathyAccount *account,
- GAsyncResult *result,
- GError **error);
-
-gboolean empathy_account_is_enabled (EmpathyAccount *account);
-
-gboolean empathy_account_is_valid (EmpathyAccount *account);
-gboolean empathy_account_is_ready (EmpathyAccount *account);
-
-void empathy_account_update_settings_async (EmpathyAccount *account,
- GHashTable *parameters, const gchar **unset_parameters,
- GAsyncReadyCallback callback, gpointer user_data);
-
-gboolean empathy_account_update_settings_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error);
-
-void empathy_account_remove_async (EmpathyAccount *account,
- GAsyncReadyCallback callback, gpointer user_data);
-gboolean empathy_account_remove_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error);
-
-void empathy_account_set_display_name_async (EmpathyAccount *account,
- const gchar *display_name, GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean empathy_account_set_display_name_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error);
-
-void empathy_account_set_icon_name_async (EmpathyAccount *account,
- const gchar *icon_name, GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean empathy_account_set_icon_name_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error);
-
-EmpathyAccount *empathy_account_new (TpDBusDaemon *bus_daemon,
- const gchar *unique_name);
-
-void empathy_account_request_presence (EmpathyAccount *account,
- TpConnectionPresenceType type, const gchar *status, const gchar *message);
-
-const GHashTable *empathy_account_get_parameters (EmpathyAccount *account);
-
-void empathy_account_refresh_properties (EmpathyAccount *account);
-
-
-G_END_DECLS
-
-#endif /* #ifndef __EMPATHY_ACCOUNT_H__*/