aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2009-01-07 00:47:31 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-01-07 00:47:31 +0800
commit7aa18c1cd5858b1bf3ef353c78400ad2bc6da307 (patch)
treefc42afaec8db0fdd495b7c4ad9d3a028c305a24c
parentd8496968bd3b210b8b76daaf2feb2ddcd04e9822 (diff)
downloadgsoc2013-empathy-7aa18c1cd5858b1bf3ef353c78400ad2bc6da307.tar
gsoc2013-empathy-7aa18c1cd5858b1bf3ef353c78400ad2bc6da307.tar.gz
gsoc2013-empathy-7aa18c1cd5858b1bf3ef353c78400ad2bc6da307.tar.bz2
gsoc2013-empathy-7aa18c1cd5858b1bf3ef353c78400ad2bc6da307.tar.lz
gsoc2013-empathy-7aa18c1cd5858b1bf3ef353c78400ad2bc6da307.tar.xz
gsoc2013-empathy-7aa18c1cd5858b1bf3ef353c78400ad2bc6da307.tar.zst
gsoc2013-empathy-7aa18c1cd5858b1bf3ef353c78400ad2bc6da307.zip
Add an API to EmpathyAccountManager to find out if an account has just
connected. svn path=/trunk/; revision=2054
-rw-r--r--libempathy/empathy-account-manager.c45
-rw-r--r--libempathy/empathy-account-manager.h6
2 files changed, 49 insertions, 2 deletions
diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c
index e3b628146..050144aad 100644
--- a/libempathy/empathy-account-manager.c
+++ b/libempathy/empathy-account-manager.c
@@ -41,7 +41,9 @@ typedef struct {
typedef struct {
McPresence presence;
TpConnectionStatus connection;
- gboolean is_enabled;
+ gboolean is_enabled;
+
+ guint source_id;
} AccountData;
enum {
@@ -70,6 +72,7 @@ account_data_new (McPresence presence, TpConnectionStatus connection,
retval->presence = presence;
retval->connection = connection;
retval->is_enabled = is_enabled;
+ retval->source_id = 0;
return retval;
}
@@ -100,6 +103,11 @@ account_data_new_default (MissionControl *mc,
static void
account_data_free (AccountData *data)
{
+ if (data->source_id > 0) {
+ g_source_remove (data->source_id);
+ data->source_id = 0;
+ }
+
g_slice_free (AccountData, data);
}
@@ -229,6 +237,16 @@ update_connection_numbers (EmpathyAccountManager *manager,
}
}
+static gboolean
+remove_data_timeout (gpointer _data)
+{
+ AccountData *data = _data;
+
+ data->source_id = 0;
+
+ return FALSE;
+}
+
static void
account_status_changed_cb (MissionControl *mc,
TpConnectionStatus connection,
@@ -264,8 +282,15 @@ account_status_changed_cb (MissionControl *mc,
g_signal_emit (manager, signals[ACCOUNT_CONNECTION_CHANGED], 0,
account, reason, connection, old_c);
+
+ if (old_c == TP_CONNECTION_STATUS_CONNECTING &&
+ connection == TP_CONNECTION_STATUS_CONNECTED) {
+ data->source_id = g_timeout_add_seconds (10,
+ remove_data_timeout,
+ data);
+ }
}
-
+
g_object_unref (account);
}
}
@@ -458,3 +483,19 @@ empathy_account_manager_get_connecting_accounts (EmpathyAccountManager *manager)
return priv->connecting;
}
+gboolean
+empathy_account_manager_is_account_just_connected (EmpathyAccountManager *manager,
+ McAccount *account)
+{
+ EmpathyAccountManagerPriv *priv;
+ AccountData *data;
+
+ g_assert (EMPATHY_IS_ACCOUNT_MANAGER (manager));
+
+ priv = GET_PRIV (manager);
+ data = g_hash_table_lookup (priv->accounts, account);
+
+ g_assert (data);
+
+ return (data->source_id > 0);
+}
diff --git a/libempathy/empathy-account-manager.h b/libempathy/empathy-account-manager.h
index 1687c0032..9e1cfce69 100644
--- a/libempathy/empathy-account-manager.h
+++ b/libempathy/empathy-account-manager.h
@@ -24,6 +24,8 @@
#include <glib-object.h>
+#include <libmissioncontrol/mc-account.h>
+
G_BEGIN_DECLS
#define EMPATHY_TYPE_ACCOUNT_MANAGER (empathy_account_manager_get_type ())
@@ -54,6 +56,10 @@ int empathy_account_manager_get_connected_accounts
(EmpathyAccountManager *manager);
int empathy_account_manager_get_connecting_accounts
(EmpathyAccountManager *manager);
+gboolean empathy_account_manager_is_account_just_connected
+ (EmpathyAccountManager *manager,
+ McAccount *account);
+
G_END_DECLS
#endif /* __EMPATHY_ACCOUNT_MANAGER_H__ */