aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-07-05 17:28:04 +0800
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-07-05 17:28:04 +0800
commitadef4b7fed1d3555723b7e223781f6caa1a8e015 (patch)
treee6838e74c00bdc84edaaa23f14a0cf83fafb8cc4 /libempathy
parent0e9e2124eee55872b7e6209cbcfd626c9e366e40 (diff)
downloadgsoc2013-empathy-adef4b7fed1d3555723b7e223781f6caa1a8e015.tar
gsoc2013-empathy-adef4b7fed1d3555723b7e223781f6caa1a8e015.tar.gz
gsoc2013-empathy-adef4b7fed1d3555723b7e223781f6caa1a8e015.tar.bz2
gsoc2013-empathy-adef4b7fed1d3555723b7e223781f6caa1a8e015.tar.lz
gsoc2013-empathy-adef4b7fed1d3555723b7e223781f6caa1a8e015.tar.xz
gsoc2013-empathy-adef4b7fed1d3555723b7e223781f6caa1a8e015.tar.zst
gsoc2013-empathy-adef4b7fed1d3555723b7e223781f6caa1a8e015.zip
Add API to get the protocol and cm name from a account
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-account.c55
-rw-r--r--libempathy/empathy-account.h7
2 files changed, 51 insertions, 11 deletions
diff --git a/libempathy/empathy-account.c b/libempathy/empathy-account.c
index e0a8e756b..3bae8f5b5 100644
--- a/libempathy/empathy-account.c
+++ b/libempathy/empathy-account.c
@@ -73,6 +73,10 @@ struct _EmpathyAccountPriv
glong connect_time;
McAccount *mc_account;
+ McProfile *mc_profile;
+
+ gchar *cm_name;
+ gchar *proto_name;
};
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccount)
@@ -236,6 +240,10 @@ 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);
@@ -244,6 +252,11 @@ empathy_account_dispose (GObject *object)
void
empathy_account_finalize (GObject *object)
{
+ EmpathyAccountPriv *priv = GET_PRIV (object);
+
+ g_free (priv->cm_name);
+ g_free (priv->proto_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);
@@ -320,6 +333,22 @@ empathy_account_is_valid (EmpathyAccount *account)
return mc_account_is_complete (priv->mc_account);
}
+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;
+}
+
void
empathy_account_set_enabled (EmpathyAccount *account, gboolean enabled)
{
@@ -409,23 +438,34 @@ empathy_account_set_display_name (EmpathyAccount *account,
mc_account_set_display_name (priv->mc_account, display_name);
}
-McProfile *
-empathy_account_get_profile (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
- return mc_account_get_profile (priv->mc_account);
-}
-
EmpathyAccount *
_empathy_account_new (McAccount *mc_account)
{
EmpathyAccount *account;
EmpathyAccountPriv *priv;
+ McProfile *profile;
+ McProtocol *protocol;
+
account = g_object_new (EMPATHY_TYPE_ACCOUNT, NULL);
priv = GET_PRIV (account);
priv->mc_account = mc_account;
+ profile = mc_account_get_profile (mc_account);
+ protocol = mc_profile_get_protocol (profile);
+
+ if (protocol != NULL)
+ {
+ McManager *manager = mc_protocol_get_manager (protocol);
+
+ priv->proto_name = g_strdup (mc_protocol_get_name (protocol));
+ priv->cm_name = g_strdup (mc_manager_get_unique_name (manager));
+
+ g_object_unref (protocol);
+ g_object_unref (manager);
+ }
+ g_object_unref (profile);
+
return account;
}
@@ -571,5 +611,6 @@ McAccount *
_empathy_account_get_mc_account (EmpathyAccount *account)
{
EmpathyAccountPriv *priv = GET_PRIV (account);
+
return priv->mc_account;
}
diff --git a/libempathy/empathy-account.h b/libempathy/empathy-account.h
index 75babd826..66141ae9b 100644
--- a/libempathy/empathy-account.h
+++ b/libempathy/empathy-account.h
@@ -61,6 +61,9 @@ TpConnection *empathy_account_get_connection (EmpathyAccount *account);
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);
+
void empathy_account_set_enabled (EmpathyAccount *account,
gboolean enabled);
gboolean empathy_account_is_enabled (EmpathyAccount *account);
@@ -85,10 +88,6 @@ gboolean empathy_account_is_valid (EmpathyAccount *account);
void empathy_account_set_display_name (EmpathyAccount *account,
const gchar *display_name);
-
-/* TODO remove McProfile */
-McProfile *empathy_account_get_profile (EmpathyAccount *account);
-
G_END_DECLS
#endif /* #ifndef __EMPATHY_ACCOUNT_H__*/