aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorTravis Reitter <travis.reitter@collabora.co.uk>2010-10-13 00:45:03 +0800
committerTravis Reitter <travis.reitter@collabora.co.uk>2010-10-16 05:14:45 +0800
commit4f39984ad575e8ee643e3cf52ad519386c23009e (patch)
tree2ea89c34660e7a6d1e610641cd6ce6aec7c6f8fd /libempathy
parent31905d995ddb96e2e25a795fa197cb541bc7724d (diff)
downloadgsoc2013-empathy-4f39984ad575e8ee643e3cf52ad519386c23009e.tar
gsoc2013-empathy-4f39984ad575e8ee643e3cf52ad519386c23009e.tar.gz
gsoc2013-empathy-4f39984ad575e8ee643e3cf52ad519386c23009e.tar.bz2
gsoc2013-empathy-4f39984ad575e8ee643e3cf52ad519386c23009e.tar.lz
gsoc2013-empathy-4f39984ad575e8ee643e3cf52ad519386c23009e.tar.xz
gsoc2013-empathy-4f39984ad575e8ee643e3cf52ad519386c23009e.tar.zst
gsoc2013-empathy-4f39984ad575e8ee643e3cf52ad519386c23009e.zip
Use Folks to check if a TpConnection can add personas.
Helps bgo#625969.
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-utils.c52
-rw-r--r--libempathy/empathy-utils.h3
2 files changed, 55 insertions, 0 deletions
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index c479f99f3..e6dc34303 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -770,6 +770,58 @@ tp_channel_group_change_reason_from_folks_groups_change_reason (
return (TpChannelGroupChangeReason) reason;
}
+TpfPersonaStore *
+empathy_get_persona_store_for_connection (TpConnection *connection)
+{
+ FolksBackendStore *backend_store;
+ FolksBackend *backend;
+ TpfPersonaStore *result = NULL;
+
+ backend_store = folks_backend_store_dup ();
+ backend = folks_backend_store_get_backend_by_name (backend_store,
+ "telepathy");
+ if (backend != NULL)
+ {
+ GHashTable *stores_hash;
+ GList *stores, *l;
+
+ stores_hash = folks_backend_get_persona_stores (backend);
+ stores = g_hash_table_get_values (stores_hash);
+ for (l = stores; l != NULL && result == NULL; l = l->next)
+ {
+ TpfPersonaStore *persona_store = TPF_PERSONA_STORE (l->data);
+ TpAccount *account;
+ TpConnection *conn_cur;
+
+ account = tpf_persona_store_get_account (persona_store);
+ conn_cur = tp_account_get_connection (account);
+ if (conn_cur == connection)
+ result = persona_store;
+ }
+
+ g_list_free (stores);
+ }
+
+ g_object_unref (backend);
+ g_object_unref (backend_store);
+
+ return result;
+}
+
+gboolean
+empathy_connection_can_add_personas (TpConnection *connection)
+{
+ FolksPersonaStore *persona_store;
+
+ g_return_val_if_fail (TP_IS_CONNECTION (connection), FALSE);
+
+ persona_store = FOLKS_PERSONA_STORE (
+ empathy_get_persona_store_for_connection (connection));
+
+ return (folks_persona_store_get_can_add_personas (persona_store) ==
+ FOLKS_MAYBE_BOOL_TRUE);
+}
+
gchar *
empathy_get_x509_certificate_hostname (gnutls_x509_crt_t cert)
{
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index ca184f589..7b9f897fb 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -34,6 +34,7 @@
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <folks/folks.h>
+#include <folks/folks-telepathy.h>
#include <telepathy-glib/account-manager.h>
#include "empathy-contact.h"
@@ -99,6 +100,8 @@ TpConnectionPresenceType empathy_folks_presence_type_to_tp (FolksPresenceType ty
gboolean empathy_folks_individual_contains_contact (FolksIndividual *individual);
EmpathyContact * empathy_contact_dup_from_folks_individual (FolksIndividual *individual);
TpChannelGroupChangeReason tp_channel_group_change_reason_from_folks_groups_change_reason (FolksGroupableChangeReason reason);
+TpfPersonaStore * empathy_get_persona_store_for_connection (TpConnection *connection);
+gboolean empathy_connection_can_add_personas (TpConnection *connection);
gchar * empathy_get_x509_certificate_hostname (gnutls_x509_crt_t cert);