diff options
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/Makefile.am | 1 | ||||
-rw-r--r-- | libempathy/empathy-account-manager.c | 185 | ||||
-rw-r--r-- | libempathy/empathy-account-priv.h | 44 | ||||
-rw-r--r-- | libempathy/empathy-account.c | 368 | ||||
-rw-r--r-- | libempathy/empathy-account.h | 6 |
5 files changed, 449 insertions, 155 deletions
diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am index 27671543a..545074aed 100644 --- a/libempathy/Makefile.am +++ b/libempathy/Makefile.am @@ -25,7 +25,6 @@ lib_LTLIBRARIES = libempathy.la libempathy_la_SOURCES = \ empathy-account.c \ - empathy-account-priv.h \ empathy-account-manager.c \ empathy-chatroom.c \ empathy-chatroom-manager.c \ diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c index 0d09ec5f0..c31ac0159 100644 --- a/libempathy/empathy-account-manager.c +++ b/libempathy/empathy-account-manager.c @@ -23,6 +23,9 @@ #include <libmissioncontrol/mc-account-monitor.h> #include <telepathy-glib/util.h> +#include <telepathy-glib/account-manager.h> +#include <telepathy-glib/enums.h> +#include <telepathy-glib/defs.h> #include "empathy-account-manager.h" #include "empathy-account-priv.h" @@ -34,15 +37,18 @@ #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountManager) +#define MC5_BUS_NAME "org.freedesktop.Telepathy.MissionControl5" + typedef struct { - McAccountMonitor *monitor; - MissionControl *mc; /* (owned) unique name -> (reffed) EmpathyAccount */ GHashTable *accounts; int connected; int connecting; gboolean dispose_run; + TpProxySignalConnection *proxy_signal; + TpAccountManager *tp_manager; + TpDBusDaemon *dbus; } EmpathyAccountManagerPriv; enum { @@ -62,6 +68,7 @@ static EmpathyAccountManager *manager_singleton = NULL; G_DEFINE_TYPE (EmpathyAccountManager, empathy_account_manager, G_TYPE_OBJECT); +#if 0 static TpConnectionPresenceType mc_presence_to_tp_presence (McPresence presence) { @@ -83,6 +90,7 @@ mc_presence_to_tp_presence (McPresence presence) return TP_CONNECTION_PRESENCE_TYPE_UNSET; } } +#endif static void emp_account_connection_cb (EmpathyAccount *account, @@ -99,6 +107,17 @@ emp_account_connection_cb (EmpathyAccount *account, } 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, @@ -147,11 +166,39 @@ emp_account_presence_changed_cb (EmpathyAccount *account, account, new, old); } +static void +emp_account_ready_cb (GObject *obj, GParamSpec *spec, gpointer user_data) +{ + EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data); + EmpathyAccount *account = EMPATHY_ACCOUNT (obj); + gboolean ready; + + g_object_get (account, "ready", &ready, NULL); + + if (!ready) + return; + + 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); +} + static EmpathyAccount * create_account (EmpathyAccountManager *manager, const gchar *account_name, McAccount *mc_account) { +#if 0 EmpathyAccountManagerPriv *priv = GET_PRIV (manager); EmpathyAccount *account; TpConnectionStatus status; @@ -210,8 +257,11 @@ create_account (EmpathyAccountManager *manager, presence); return account; +#endif + return NULL; } +#if 0 static void account_created_cb (McAccountMonitor *mon, gchar *account_name, @@ -254,39 +304,6 @@ account_changed_cb (McAccountMonitor *mon, g_signal_emit (manager, signals[ACCOUNT_CHANGED], 0, account); } -static void -account_disabled_cb (McAccountMonitor *mon, - gchar *account_name, - EmpathyAccountManager *manager) -{ - EmpathyAccountManagerPriv *priv = GET_PRIV (manager); - EmpathyAccount *account; - - account = g_hash_table_lookup (priv->accounts, account_name); - - if (account) - { - _empathy_account_set_enabled (account, FALSE); - g_signal_emit (manager, signals[ACCOUNT_DISABLED], 0, account); - } -} - -static void -account_enabled_cb (McAccountMonitor *mon, - gchar *account_name, - EmpathyAccountManager *manager) -{ - EmpathyAccountManagerPriv *priv = GET_PRIV (manager); - EmpathyAccount *account; - - account = g_hash_table_lookup (priv->accounts, account_name); - - if (account) - { - _empathy_account_set_enabled (account, TRUE); - g_signal_emit (manager, signals[ACCOUNT_ENABLED], 0, account); - } -} typedef struct { TpConnectionStatus status; @@ -335,7 +352,9 @@ account_status_changed_idle_cb (ChangedSignalData *signal_data) return FALSE; } +#endif +#if 0 static void account_status_changed_cb (MissionControl *mc, TpConnectionStatus status, @@ -360,27 +379,104 @@ account_status_changed_cb (MissionControl *mc, g_idle_add ((GSourceFunc) account_status_changed_idle_cb, data); } +#endif + +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); + EmpathyAccountManagerPriv *priv = GET_PRIV (manager); + GPtrArray *accounts; + int i; + + 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); + + + for (i = 0; i < accounts->len; i++) + { + EmpathyAccount *account; + gchar *name = g_ptr_array_index (accounts, i); + + account = empathy_account_new (priv->dbus, name); + g_hash_table_insert (priv->accounts, g_strdup (name), account); + + g_signal_connect (account, "notify::ready", + G_CALLBACK (emp_account_ready_cb), manager); + } +} + +static void +account_manager_name_owner_changed_cb (TpDBusDaemon *proxy, + const gchar *arg0, + const gchar *arg1, + const gchar *arg2, + gpointer user_data, + GObject *weak_object) +{ + EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (weak_object); + EmpathyAccountManagerPriv *priv = GET_PRIV (manager); + + tp_proxy_signal_connection_disconnect (priv->proxy_signal); + priv->proxy_signal = NULL; + + priv->tp_manager = tp_account_manager_new (priv->dbus); + 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; - GList *mc_accounts, *l; + TpProxy *mc5_proxy; priv = G_TYPE_INSTANCE_GET_PRIVATE (manager, EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManagerPriv); manager->priv = priv; - priv->monitor = mc_account_monitor_new (); - priv->mc = empathy_mission_control_dup_singleton (); priv->connected = priv->connecting = 0; - priv->dispose_run = FALSE; priv->accounts = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_object_unref); - mc_accounts = mc_accounts_list (); + priv->dbus = tp_dbus_daemon_dup (NULL); + priv->proxy_signal = tp_cli_dbus_daemon_connect_to_name_owner_changed ( + priv->dbus, + account_manager_name_owner_changed_cb, + TP_ACCOUNT_MANAGER_BUS_NAME, + NULL, + G_OBJECT (manager), + NULL); + + /* trigger MC5 starting */ + mc5_proxy = g_object_new (TP_TYPE_PROXY, + "dbus-daemon", priv->dbus, + "dbus-connection", tp_proxy_get_dbus_connection (TP_PROXY (priv->dbus)), + "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); + +#if 0 for (l = mc_accounts; l; l = l->next) account_created_cb (priv->monitor, (char *) mc_account_get_unique_name (l->data), manager); @@ -401,6 +497,7 @@ empathy_account_manager_init (EmpathyAccountManager *manager) manager, NULL); mc_accounts_list_free (mc_accounts); +#endif } static void @@ -425,6 +522,11 @@ do_dispose (GObject *obj) priv->dispose_run = TRUE; + if (priv->dbus == NULL) + g_object_unref (priv->dbus); + priv->dbus = NULL; + +#if 0 dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->mc), "AccountStatusChanged", G_CALLBACK (account_status_changed_cb), @@ -450,6 +552,7 @@ do_dispose (GObject *obj) g_object_unref (priv->mc); g_hash_table_remove_all (priv->accounts); +#endif G_OBJECT_CLASS (empathy_account_manager_parent_class)->dispose (obj); } @@ -769,5 +872,5 @@ void empathy_account_manager_remove (EmpathyAccountManager *manager, EmpathyAccount *account) { - mc_account_delete (_empathy_account_get_mc_account (account)); + /* FIXME */ } diff --git a/libempathy/empathy-account-priv.h b/libempathy/empathy-account-priv.h deleted file mode 100644 index 8b656b4d8..000000000 --- a/libempathy/empathy-account-priv.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * empathy-account-priv.h - Private 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_PRIV_H__ -#define __EMPATHY_ACCOUNT_PRIV_H__ - -#include <glib.h> - -#include <libmissioncontrol/mc-account.h> -#include "empathy-account.h" - -G_BEGIN_DECLS - -EmpathyAccount *_empathy_account_new (McAccount *account); -void _empathy_account_set_status (EmpathyAccount *account, - TpConnectionStatus status, - TpConnectionStatusReason reason, - TpConnectionPresenceType presence); -void _empathy_account_set_connection (EmpathyAccount *account, - TpConnection *connection); -void _empathy_account_set_enabled (EmpathyAccount *account, - gboolean enabled); -McAccount *_empathy_account_get_mc_account (EmpathyAccount *account); - -G_END_DECLS - -#endif /* #ifndef __EMPATHY_ACCOUNT_PRIV_H__*/ diff --git a/libempathy/empathy-account.c b/libempathy/empathy-account.c index c6a2184f9..010990d7a 100644 --- a/libempathy/empathy-account.c +++ b/libempathy/empathy-account.c @@ -18,20 +18,25 @@ * 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> #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT #include <libempathy/empathy-debug.h> #include "empathy-account.h" -#include "empathy-account-priv.h" #include "empathy-utils.h" #include "empathy-marshal.h" +#define UNIQUE_NAME_PREFIX "/org/freedesktop/Telepathy/Account/" + /* signals */ enum { STATUS_CHANGED, @@ -45,10 +50,12 @@ static guint signals[LAST_SIGNAL]; enum { PROP_ENABLED = 1, PROP_PRESENCE, + PROP_READY, PROP_CONNECTION_STATUS, PROP_CONNECTION_STATUS_REASON, PROP_CONNECTION, PROP_UNIQUE_NAME, + PROP_DBUS_DAEMON, PROP_DISPLAY_NAME }; @@ -69,19 +76,28 @@ struct _EmpathyAccountPriv TpConnectionPresenceType presence; gboolean enabled; + gboolean valid; + gboolean ready; /* Timestamp when the connection got connected in seconds since the epoch */ glong connect_time; - McAccount *mc_account; - McProfile *mc_profile; - 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, + TpConnection *connection); + static void empathy_account_init (EmpathyAccount *obj) { @@ -96,6 +112,32 @@ empathy_account_init (EmpathyAccount *obj) } 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 (account, g_value_get_boolean (value)); + 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, @@ -109,6 +151,9 @@ empathy_account_get_property (GObject *object, case PROP_ENABLED: g_value_set_boolean (value, priv->enabled); break; + case PROP_READY: + g_value_set_boolean (value, priv->enabled); + break; case PROP_PRESENCE: g_value_set_uint (value, priv->presence); break; @@ -130,12 +175,208 @@ empathy_account_get_property (GObject *object, g_value_set_string (value, empathy_account_get_display_name (account)); break; + case PROP_DBUS_DAEMON: + g_value_set_string (value, + empathy_account_get_display_name (account)); + 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); + const gchar *conn_path; + GValueArray *arr; + TpConnectionStatus old_s = priv->status; + TpConnectionPresenceType old_p = priv->presence; + + if (g_hash_table_lookup (properties, "ConnectionStatus") != NULL) + priv->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) + { + 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)); + } + + if (g_hash_table_lookup (properties, "DisplayName") != NULL) + priv->display_name = + g_strdup (tp_asv_get_string (properties, "DisplayName")); + + if (g_hash_table_lookup (properties, "Enabled") != NULL) + empathy_account_set_enabled (account, + tp_asv_get_boolean (properties, "Enabled", NULL)); + + 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); + + 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->status != old_s) + { + if (priv->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->status, priv->reason); + + g_object_notify (G_OBJECT (account), "status"); + } + + if (priv->presence != old_p) + { + g_signal_emit (account, signals[PRESENCE_CHANGED], 0, + old_p, priv->presence); + g_object_notify (G_OBJECT (account), "presence"); + } + + if (g_hash_table_lookup (properties, "Connection") != NULL) + { + conn_path = tp_asv_get_object_path (properties, "Connection"); + + if (tp_strdiff (conn_path, "/") && priv->connection == NULL) + { + TpConnection *conn; + GError *error = NULL; + conn = tp_connection_new (priv->dbus, NULL, conn_path, &error); + + if (conn == NULL) + { + DEBUG ("Failed to create a new TpConnection: %s", + error->message); + g_error_free (error); + } + + _empathy_account_set_connection (account, conn); + } + } +} + +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_got_all_cb (TpProxy *proxy, + GHashTable *properties, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + EmpathyAccount *account = EMPATHY_ACCOUNT (weak_object); + + if (error != NULL) + { + printf ("Unhappy\n"); + return; + } + + empathy_account_update (account, properties); +} + +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, UNIQUE_NAME_PREFIX), FALSE); + + cm = bus_name + strlen (UNIQUE_NAME_PREFIX); + + 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 = g_strndup (proto, proto_end - proto); + + if (manager != NULL) + *manager = g_strndup (cm, cm_end - cm); + + return TRUE; +} + +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); + + empathy_account_parse_unique_name (priv->unique_name, + &(priv->proto_name), &(priv->cm_name)); + + priv->icon_name = g_strdup_printf ("im-%s", priv->proto_name); + + tp_cli_account_connect_to_account_property_changed (priv->account, + empathy_account_properties_changed, + NULL, NULL, object, NULL); + + tp_cli_dbus_properties_call_get_all (priv->account, -1, + TP_IFACE_ACCOUNT, + empathy_account_got_all_cb, + NULL, + NULL, + G_OBJECT (account)); +} + static void empathy_account_dispose (GObject *object); static void empathy_account_finalize (GObject *object); @@ -147,15 +388,24 @@ empathy_account_class_init (EmpathyAccountClass *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, @@ -197,7 +447,14 @@ empathy_account_class_init (EmpathyAccountClass *empathy_account_class) "UniqueName", "The accounts unique name", NULL, - G_PARAM_STATIC_STRINGS | G_PARAM_READABLE)); + 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", @@ -241,10 +498,6 @@ empathy_account_dispose (GObject *object) g_object_unref (priv->connection); priv->connection = NULL; - if (priv->mc_profile != NULL) - g_object_unref (priv->mc_profile); - priv->mc_profile = NULL; - /* 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); @@ -258,6 +511,7 @@ empathy_account_finalize (GObject *object) 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) @@ -310,7 +564,7 @@ empathy_account_get_unique_name (EmpathyAccount *account) { EmpathyAccountPriv *priv = GET_PRIV (account); - return mc_account_get_unique_name (priv->mc_account); + return priv->unique_name; } /** @@ -324,15 +578,16 @@ empathy_account_get_display_name (EmpathyAccount *account) { EmpathyAccountPriv *priv = GET_PRIV (account); - return mc_account_get_display_name (priv->mc_account); + return priv->display_name; } gboolean empathy_account_is_valid (EmpathyAccount *account) { - EmpathyAccountPriv *priv = GET_PRIV (account); + //EmpathyAccountPriv *priv = GET_PRIV (account); - return mc_account_is_complete (priv->mc_account); + /* FIXME */ + return FALSE; } const gchar * @@ -359,14 +614,6 @@ empathy_account_get_icon_name (EmpathyAccount *account) return priv->icon_name; } -void -empathy_account_set_enabled (EmpathyAccount *account, gboolean enabled) -{ - EmpathyAccountPriv *priv = GET_PRIV (account); - - mc_account_set_enabled (priv->mc_account, enabled); -} - gboolean empathy_account_is_enabled (EmpathyAccount *account) { @@ -378,39 +625,33 @@ empathy_account_is_enabled (EmpathyAccount *account) void empathy_account_unset_param (EmpathyAccount *account, const gchar *param) { - EmpathyAccountPriv *priv = GET_PRIV (account); + //EmpathyAccountPriv *priv = GET_PRIV (account); - mc_account_unset_param (priv->mc_account, param); + //mc_account_unset_param (priv->mc_account, param); } -gchar * +const gchar * empathy_account_get_param_string (EmpathyAccount *account, const gchar *param) { EmpathyAccountPriv *priv = GET_PRIV (account); - gchar *value = NULL; - mc_account_get_param_string (priv->mc_account, param, &value); - return value; + return tp_asv_get_string (priv->parameters, param); } gint empathy_account_get_param_int (EmpathyAccount *account, const gchar *param) { EmpathyAccountPriv *priv = GET_PRIV (account); - int value; - mc_account_get_param_int (priv->mc_account, param, &value); - return value; + return tp_asv_get_int32 (priv->parameters, param, NULL); } gboolean empathy_account_get_param_boolean (EmpathyAccount *account, const gchar *param) { EmpathyAccountPriv *priv = GET_PRIV (account); - gboolean value; - mc_account_get_param_boolean (priv->mc_account, param, &value); - return value; + return tp_asv_get_boolean (priv->parameters, param, NULL); } void @@ -418,8 +659,8 @@ empathy_account_set_param_string (EmpathyAccount *account, const gchar *param, const gchar *value) { - EmpathyAccountPriv *priv = GET_PRIV (account); - mc_account_set_param_string (priv->mc_account, param, value); + //EmpathyAccountPriv *priv = GET_PRIV (account); + //mc_account_set_param_string (priv->mc_account, param, value); } void @@ -427,8 +668,8 @@ empathy_account_set_param_int (EmpathyAccount *account, const gchar *param, gint value) { - EmpathyAccountPriv *priv = GET_PRIV (account); - mc_account_set_param_int (priv->mc_account, param, value); + //EmpathyAccountPriv *priv = GET_PRIV (account); + //mc_account_set_param_int (priv->mc_account, param, value); } void @@ -436,18 +677,29 @@ empathy_account_set_param_boolean (EmpathyAccount *account, const gchar *param, gboolean value) { - EmpathyAccountPriv *priv = GET_PRIV (account); - mc_account_set_param_boolean (priv->mc_account, param, value); + //EmpathyAccountPriv *priv = GET_PRIV (account); + //mc_account_set_param_boolean (priv->mc_account, param, value); } void empathy_account_set_display_name (EmpathyAccount *account, const gchar *display_name) { - EmpathyAccountPriv *priv = GET_PRIV (account); - mc_account_set_display_name (priv->mc_account, display_name); + //EmpathyAccountPriv *priv = GET_PRIV (account); + //mc_account_set_display_name (priv->mc_account, display_name); } + +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)); +} + +#if 0 EmpathyAccount * _empathy_account_new (McAccount *mc_account) { @@ -470,7 +722,6 @@ _empathy_account_new (McAccount *mc_account) priv->proto_name = g_strdup (mc_protocol_get_name (protocol)); priv->cm_name = g_strdup (mc_manager_get_unique_name (manager)); - priv->icon_name = g_strdup_printf ("im-%s", priv->proto_name); g_object_unref (protocol); g_object_unref (manager); @@ -493,30 +744,8 @@ _empathy_account_set_status (EmpathyAccount *account, priv->status = status; priv->presence = presence; - if (priv->status != old_s) - { - if (priv->status == TP_CONNECTION_STATUS_CONNECTED) - { - GTimeVal val; - g_get_current_time (&val); - - priv->connect_time = val.tv_sec; - } - - priv->reason = reason; - g_signal_emit (account, signals[STATUS_CHANGED], 0, - old_s, priv->status, reason); - - g_object_notify (G_OBJECT (account), "status"); - } - - if (priv->presence != old_p) - { - g_signal_emit (account, signals[PRESENCE_CHANGED], 0, - old_p, priv->presence); - g_object_notify (G_OBJECT (account), "presence"); - } } +#endif static void empathy_account_connection_ready_cb (TpConnection *connection, @@ -568,7 +797,7 @@ _empathy_account_connection_invalidated_cb (TpProxy *self, g_object_notify (G_OBJECT (account), "connection"); } -void +static void _empathy_account_set_connection (EmpathyAccount *account, TpConnection *connection) { @@ -599,6 +828,7 @@ _empathy_account_set_connection (EmpathyAccount *account, 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); @@ -606,7 +836,7 @@ _empathy_account_set_connection (EmpathyAccount *account, } void -_empathy_account_set_enabled (EmpathyAccount *account, +empathy_account_set_enabled (EmpathyAccount *account, gboolean enabled) { EmpathyAccountPriv *priv = GET_PRIV (account); @@ -618,6 +848,7 @@ _empathy_account_set_enabled (EmpathyAccount *account, g_object_notify (G_OBJECT (account), "enabled"); } +#if 0 McAccount * _empathy_account_get_mc_account (EmpathyAccount *account) { @@ -625,3 +856,4 @@ _empathy_account_get_mc_account (EmpathyAccount *account) return priv->mc_account; } +#endif diff --git a/libempathy/empathy-account.h b/libempathy/empathy-account.h index 95879215c..ab09e52f2 100644 --- a/libempathy/empathy-account.h +++ b/libempathy/empathy-account.h @@ -70,7 +70,7 @@ void empathy_account_set_enabled (EmpathyAccount *account, gboolean empathy_account_is_enabled (EmpathyAccount *account); void empathy_account_unset_param (EmpathyAccount *account, const gchar *param); -gchar *empathy_account_get_param_string (EmpathyAccount *account, +const gchar *empathy_account_get_param_string (EmpathyAccount *account, const gchar *param); gint empathy_account_get_param_int (EmpathyAccount *account, const gchar *param); @@ -85,10 +85,14 @@ void empathy_account_set_param_boolean (EmpathyAccount *account, const gchar *param, gboolean value); gboolean empathy_account_is_valid (EmpathyAccount *account); +gboolean empathy_account_is_ready (EmpathyAccount *account); void empathy_account_set_display_name (EmpathyAccount *account, const gchar *display_name); +EmpathyAccount *empathy_account_new (TpDBusDaemon *bus_daemon, + const gchar *unique_name); + G_END_DECLS #endif /* #ifndef __EMPATHY_ACCOUNT_H__*/ |