[empathy: 23/35] Use Contact Manager flags instead of Individual Manager flags



commit 81ba0edc73b6a226a054b76539645b7b4e5e2a99
Author: Chandni Verma <chandniverma2112 gmail com>
Date:   Tue Mar 8 13:36:05 2011 +0530

    Use Contact Manager flags instead of Individual Manager flags

 libempathy-gtk/empathy-individual-dialogs.c |   17 +++++----
 libempathy/empathy-individual-manager.c     |   48 ++++++--------------------
 libempathy/empathy-individual-manager.h     |   11 ------
 3 files changed, 20 insertions(+), 56 deletions(-)
---
diff --git a/libempathy-gtk/empathy-individual-dialogs.c b/libempathy-gtk/empathy-individual-dialogs.c
index 75e6970..1d3fcb8 100644
--- a/libempathy-gtk/empathy-individual-dialogs.c
+++ b/libempathy-gtk/empathy-individual-dialogs.c
@@ -33,6 +33,7 @@
 
 #include <libempathy/empathy-individual-manager.h>
 #include <libempathy/empathy-utils.h>
+#include <libempathy/empathy-contact-manager.h>
 
 #include "empathy-individual-dialogs.h"
 #include "empathy-contact-widget.h"
@@ -168,8 +169,8 @@ empathy_block_individual_dialog_show (GtkWindow *parent,
     FolksIndividual *individual,
     gboolean *abusive)
 {
-  EmpathyIndividualManager *manager =
-    empathy_individual_manager_dup_singleton ();
+  EmpathyContactManager *contact_manager =
+    empathy_contact_manager_dup_singleton ();
   GtkWidget *dialog;
   GtkWidget *abusive_check = NULL;
   GList *personas, *l;
@@ -190,18 +191,18 @@ empathy_block_individual_dialog_show (GtkWindow *parent,
     {
       TpfPersona *persona = l->data;
       TpContact *contact;
-      EmpathyIndividualManagerFlags flags;
+      EmpathyContactListFlags flags;
 
       if (!TPF_IS_PERSONA (persona))
           continue;
 
       contact = tpf_persona_get_contact (persona);
-      flags = empathy_individual_manager_get_flags_for_connection (manager,
-          tp_contact_get_connection (contact));
+      flags = empathy_contact_manager_get_flags_for_connection (
+          contact_manager, tp_contact_get_connection (contact));
 
-      if (!(flags & EMPATHY_INDIVIDUAL_MANAGER_CAN_BLOCK))
+      if (!(flags & EMPATHY_CONTACT_LIST_CAN_BLOCK))
         continue;
-      else if (flags & EMPATHY_INDIVIDUAL_MANAGER_CAN_REPORT_ABUSIVE)
+      else if (flags & EMPATHY_CONTACT_LIST_CAN_REPORT_ABUSIVE)
         can_report_abuse = TRUE;
 
       g_string_append_printf (str, "\n " BULLET_POINT " %s",
@@ -235,7 +236,7 @@ empathy_block_individual_dialog_show (GtkWindow *parent,
       gtk_widget_show (abusive_check);
     }
 
-  g_object_unref (manager);
+  g_object_unref (contact_manager);
   g_string_free (str, TRUE);
 
   res = gtk_dialog_run (GTK_DIALOG (dialog));
diff --git a/libempathy/empathy-individual-manager.c b/libempathy/empathy-individual-manager.c
index fd74e4b..71d15bb 100644
--- a/libempathy/empathy-individual-manager.c
+++ b/libempathy/empathy-individual-manager.c
@@ -37,6 +37,7 @@
 #include "empathy-individual-manager.h"
 #include "empathy-marshal.h"
 #include "empathy-utils.h"
+#include "empathy-contact-manager.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
 #include "empathy-debug.h"
@@ -510,15 +511,19 @@ empathy_individual_manager_supports_blocking (EmpathyIndividualManager *self,
     {
       TpfPersona *persona = l->data;
       TpConnection *conn;
+      EmpathyContactManager *manager;
 
       if (!TPF_IS_PERSONA (persona))
         continue;
 
       conn = tp_contact_get_connection (tpf_persona_get_contact (persona));
+      manager = empathy_contact_manager_dup_singleton ();
 
-      if (empathy_individual_manager_get_flags_for_connection (self, conn) &
-          EMPATHY_INDIVIDUAL_MANAGER_CAN_BLOCK)
+      if (empathy_contact_manager_get_flags_for_connection (manager, conn) &
+          EMPATHY_CONTACT_LIST_CAN_BLOCK)
         return TRUE;
+
+      g_object_unref (manager);
     }
 
   return FALSE;
@@ -542,6 +547,7 @@ empathy_individual_manager_set_blocked (EmpathyIndividualManager *self,
     {
       TpfPersona *persona = l->data;
       EmpathyContact *contact;
+      EmpathyContactManager *manager;
 
       if (!TPF_IS_PERSONA (persona))
         continue;
@@ -549,10 +555,12 @@ empathy_individual_manager_set_blocked (EmpathyIndividualManager *self,
       contact = empathy_contact_dup_from_tp_contact (
           tpf_persona_get_contact (persona));
       empathy_contact_set_persona (contact, FOLKS_PERSONA (persona));
+      manager = empathy_contact_manager_dup_singleton ();
       empathy_contact_list_set_blocked (
-          EMPATHY_CONTACT_LIST (priv->contact_manager),
+          EMPATHY_CONTACT_LIST (manager),
           contact, blocked);
 
+      g_object_unref (manager);
       g_object_unref (contact);
     }
 }
@@ -600,40 +608,6 @@ empathy_individual_manager_remove_group (EmpathyIndividualManager *manager,
       (gpointer) group);
 }
 
-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;
-  if (list_flags & EMPATHY_CONTACT_LIST_CAN_BLOCK)
-    flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_BLOCK;
-  if (list_flags & EMPATHY_CONTACT_LIST_CAN_REPORT_ABUSIVE)
-    flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_REPORT_ABUSIVE;
-
-  return flags;
-}
-
 static void
 link_personas_cb (FolksIndividualAggregator *aggregator,
     GAsyncResult *async_result,
diff --git a/libempathy/empathy-individual-manager.h b/libempathy/empathy-individual-manager.h
index 12f8ccd..75411b4 100644
--- a/libempathy/empathy-individual-manager.h
+++ b/libempathy/empathy-individual-manager.h
@@ -36,17 +36,6 @@ G_BEGIN_DECLS
 #define EMPATHY_IS_INDIVIDUAL_MANAGER_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_INDIVIDUAL_MANAGER))
 #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,
-  EMPATHY_INDIVIDUAL_MANAGER_CAN_GROUP = 1 << 3,
-  EMPATHY_INDIVIDUAL_MANAGER_CAN_BLOCK = 1 << 4,
-  EMPATHY_INDIVIDUAL_MANAGER_CAN_REPORT_ABUSIVE = 1 << 5,
-} EmpathyIndividualManagerFlags;
-
 typedef struct _EmpathyIndividualManager EmpathyIndividualManager;
 typedef struct _EmpathyIndividualManagerClass EmpathyIndividualManagerClass;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]