From a296925676f10385929fee162610d49f1caff373 Mon Sep 17 00:00:00 2001
From: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Date: Thu, 3 May 2012 11:02:39 +0200
Subject: [PATCH] empathy_tp_chat_is_invited: return a TpContact for the
 inviter

https://bugzilla.gnome.org/show_bug.cgi?id=675229
---
 libempathy/empathy-tp-chat.c |   14 ++++----------
 libempathy/empathy-tp-chat.h |    2 +-
 src/empathy-event-manager.c  |   35 +++++------------------------------
 3 files changed, 10 insertions(+), 41 deletions(-)

diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index c70b030..aa324ca 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -1358,11 +1358,10 @@ empathy_tp_chat_leave (EmpathyTpChat *self,
 
 gboolean
 empathy_tp_chat_is_invited (EmpathyTpChat *self,
-    TpHandle *inviter)
+    TpContact **inviter)
 {
-  TpContact *self_contact, *actor;
+  TpContact *self_contact;
   TpChannel *channel = TP_CHANNEL (self);
-  gboolean result;
 
   if (!tp_proxy_has_interface (self, TP_IFACE_CHANNEL_INTERFACE_GROUP))
     return FALSE;
@@ -1371,13 +1370,8 @@ empathy_tp_chat_is_invited (EmpathyTpChat *self,
   if (self_contact == NULL)
     return FALSE;
 
-  result = tp_channel_group_get_local_pending_contact_info (channel,
-      self_contact, &actor, NULL, NULL);
-
-  if (inviter != NULL)
-    *inviter = tp_contact_get_handle (actor);
-
-  return result;
+  return tp_channel_group_get_local_pending_contact_info (channel,
+      self_contact, inviter, NULL, NULL);
 }
 
 TpChannelChatState
diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h
index 44f6a24..d3ad334 100644
--- a/libempathy/empathy-tp-chat.h
+++ b/libempathy/empathy-tp-chat.h
@@ -96,7 +96,7 @@ void empathy_tp_chat_leave (EmpathyTpChat *chat,
     const gchar *message);
 
 gboolean empathy_tp_chat_is_invited (EmpathyTpChat *chat,
-    TpHandle *inviter);
+    TpContact **inviter);
 TpChannelChatState empathy_tp_chat_get_chat_state (EmpathyTpChat *chat,
     EmpathyContact *contact);
 
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index 8f26feb..b3465ce 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -847,27 +847,6 @@ display_invite_room_dialog (EventManagerApproval *approval)
 }
 
 static void
-event_manager_muc_invite_got_contact_cb (TpConnection *connection,
-                                         EmpathyContact *contact,
-                                         const GError *error,
-                                         gpointer user_data,
-                                         GObject *object)
-{
-  EventManagerApproval *approval = (EventManagerApproval *) user_data;
-
-  if (error != NULL)
-    {
-      DEBUG ("Error: %s", error->message);
-    }
-  else
-    {
-      approval->contact = g_object_ref (contact);
-    }
-
-  display_invite_room_dialog (approval);
-}
-
-static void
 event_manager_ft_got_contact_cb (TpConnection *connection,
                                  EmpathyContact *contact,
                                  const GError *error,
@@ -979,7 +958,7 @@ approve_channels (TpSimpleApprover *approver,
       if (tp_proxy_has_interface (channel, TP_IFACE_CHANNEL_INTERFACE_GROUP))
         {
           /* Are we in local-pending ? */
-          TpHandle inviter;
+          TpContact *inviter;
 
           if (empathy_tp_chat_is_invited (tp_chat, &inviter))
             {
@@ -987,17 +966,13 @@ approve_channels (TpSimpleApprover *approver,
               DEBUG ("Have been invited to %s. Ask user if he wants to accept",
                   tp_channel_get_identifier (channel));
 
-              if (inviter != 0)
-                {
-                  empathy_tp_contact_factory_get_from_handle (connection,
-                      inviter, event_manager_muc_invite_got_contact_cb,
-                      approval, NULL, G_OBJECT (self));
-                }
-              else
+              if (inviter != NULL)
                 {
-                  display_invite_room_dialog (approval);
+                  approval->contact = empathy_contact_dup_from_tp_contact (
+                      inviter);
                 }
 
+              display_invite_room_dialog (approval);
               goto out;
             }
 
-- 
1.7.7.6