aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorTravis Reitter <treitter@gmail.com>2010-06-16 09:29:03 +0800
committerTravis Reitter <treitter@gmail.com>2010-07-21 07:12:35 +0800
commitc75319eb432d4d815bf07ee30396f958b021abed (patch)
treeccce09b121fa0924690606e2639e2b8b41f87820 /libempathy
parentcdd2409d9048d1ffc7794713de52810ef0d18ebb (diff)
downloadgsoc2013-empathy-c75319eb432d4d815bf07ee30396f958b021abed.tar
gsoc2013-empathy-c75319eb432d4d815bf07ee30396f958b021abed.tar.gz
gsoc2013-empathy-c75319eb432d4d815bf07ee30396f958b021abed.tar.bz2
gsoc2013-empathy-c75319eb432d4d815bf07ee30396f958b021abed.tar.lz
gsoc2013-empathy-c75319eb432d4d815bf07ee30396f958b021abed.tar.xz
gsoc2013-empathy-c75319eb432d4d815bf07ee30396f958b021abed.tar.zst
gsoc2013-empathy-c75319eb432d4d815bf07ee30396f958b021abed.zip
Re-implement the context menu for Individuals
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-individual-manager.c30
-rw-r--r--libempathy/empathy-individual-manager.h6
-rw-r--r--libempathy/empathy-utils.c24
-rw-r--r--libempathy/empathy-utils.h1
4 files changed, 61 insertions, 0 deletions
diff --git a/libempathy/empathy-individual-manager.c b/libempathy/empathy-individual-manager.c
index 4b27e74a0..0af191ad1 100644
--- a/libempathy/empathy-individual-manager.c
+++ b/libempathy/empathy-individual-manager.c
@@ -288,3 +288,33 @@ empathy_individual_manager_remove (EmpathyIndividualManager *self,
/* TODO: implement */
DEBUG (G_STRLOC ": individual removal not implemented");
}
+
+EmpathyIndividualManagerFlags
+empathy_individual_manager_get_flags_for_connection (
+ EmpathyIndividualManager *self,
+ TpConnection *connection)
+{
+ EmpathyIndividualManagerPriv *priv;
+ EmpathyContactListFlags list_flags;
+ EmpathyIndividualManagerFlags flags;
+
+ g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self),
+ EMPATHY_INDIVIDUAL_MANAGER_NO_FLAGS);
+
+ priv = GET_PRIV (self);
+
+ list_flags = empathy_contact_manager_get_flags_for_connection (
+ priv->contact_manager, connection);
+
+ flags = EMPATHY_INDIVIDUAL_MANAGER_NO_FLAGS;
+ if (list_flags & EMPATHY_CONTACT_LIST_CAN_ADD)
+ flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_ADD;
+ if (list_flags & EMPATHY_CONTACT_LIST_CAN_REMOVE)
+ flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_REMOVE;
+ if (list_flags & EMPATHY_CONTACT_LIST_CAN_ALIAS)
+ flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_ALIAS;
+ if (list_flags & EMPATHY_CONTACT_LIST_CAN_GROUP)
+ flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_GROUP;
+
+ return flags;
+}
diff --git a/libempathy/empathy-individual-manager.h b/libempathy/empathy-individual-manager.h
index 1823dec5a..be95ab357 100644
--- a/libempathy/empathy-individual-manager.h
+++ b/libempathy/empathy-individual-manager.h
@@ -37,6 +37,7 @@ G_BEGIN_DECLS
#define EMPATHY_INDIVIDUAL_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_INDIVIDUAL_MANAGER, EmpathyIndividualManagerClass))
typedef enum
{
+ EMPATHY_INDIVIDUAL_MANAGER_NO_FLAGS = 0,
EMPATHY_INDIVIDUAL_MANAGER_CAN_ADD = 1 << 0,
EMPATHY_INDIVIDUAL_MANAGER_CAN_REMOVE = 1 << 1,
EMPATHY_INDIVIDUAL_MANAGER_CAN_ALIAS = 1 << 2,
@@ -78,5 +79,10 @@ gboolean empathy_individual_manager_is_favourite (
EmpathyIndividualManager *manager,
FolksIndividual *individual);
+EmpathyIndividualManagerFlags
+empathy_individual_manager_get_flags_for_connection (
+ EmpathyIndividualManager *manager,
+ TpConnection *connection);
+
G_END_DECLS
#endif /* __EMPATHY_INDIVIDUAL_MANAGER_H__ */
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index 56da323b9..df2a41abd 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -569,6 +569,30 @@ empathy_folks_presence_type_to_tp (FolksPresenceType type)
return (TpConnectionPresenceType) type;
}
+gboolean
+empathy_folks_individual_contains_contact (FolksIndividual *individual)
+{
+ GList *personas, *l;
+
+ g_return_val_if_fail (FOLKS_IS_INDIVIDUAL (individual), FALSE);
+
+ personas = folks_individual_get_personas (individual);
+ for (l = personas; l != NULL; l = l->next)
+ {
+ TpfPersona *persona = l->data;
+
+ if (TPF_IS_PERSONA (persona))
+ {
+ TpContact *contact = tpf_persona_get_contact (persona);
+
+ if (TP_IS_CONTACT (contact))
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
EmpathyContact *
empathy_contact_from_folks_individual (FolksIndividual *individual)
{
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index 1ba7e53f8..c6de97a8f 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -91,6 +91,7 @@ void empathy_connect_new_account (TpAccount *account,
TpAccountManager *account_manager);
TpConnectionPresenceType empathy_folks_presence_type_to_tp (FolksPresenceType type);
+gboolean empathy_folks_individual_contains_contact (FolksIndividual *individual);
EmpathyContact * empathy_contact_from_folks_individual (FolksIndividual *individual);
G_END_DECLS