[empathy: 5/8] re-implement empathy_dispatcher_chat_with_contact using empathy_dispatcher_chat_with_contact_id



commit fabcd2ec298f6773112c6fad57238c6f7bc2d77e
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Wed Aug 11 15:08:39 2010 +0200

    re-implement empathy_dispatcher_chat_with_contact using empathy_dispatcher_chat_with_contact_id
    
    We don't use the callback arg anyway.

 libempathy-gtk/empathy-contact-list-view.c |    2 +-
 libempathy-gtk/empathy-contact-menu.c      |    3 +-
 libempathy-gtk/empathy-individual-menu.c   |    3 +-
 libempathy-gtk/empathy-individual-view.c   |    2 +-
 libempathy/empathy-dispatcher.c            |   46 ++-------------------------
 libempathy/empathy-dispatcher.h            |    4 +--
 tests/interactive/empetit.c                |   22 +-------------
 7 files changed, 10 insertions(+), 72 deletions(-)
---
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index f36718c..ce58642 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -892,7 +892,7 @@ contact_list_view_row_activated (GtkTreeView       *view,
 	if (contact) {
 		DEBUG ("Starting a chat");
 		empathy_dispatcher_chat_with_contact (contact,
-			gtk_get_current_event_time (), NULL, NULL);
+			gtk_get_current_event_time ());
 		g_object_unref (contact);
 	}
 }
diff --git a/libempathy-gtk/empathy-contact-menu.c b/libempathy-gtk/empathy-contact-menu.c
index a75fe8f..6516225 100644
--- a/libempathy-gtk/empathy-contact-menu.c
+++ b/libempathy-gtk/empathy-contact-menu.c
@@ -216,8 +216,7 @@ static void
 empathy_contact_chat_menu_item_activated (GtkMenuItem *item,
 	EmpathyContact *contact)
 {
-  empathy_dispatcher_chat_with_contact (contact, gtk_get_current_event_time (),
-      NULL, NULL);
+  empathy_dispatcher_chat_with_contact (contact, gtk_get_current_event_time ());
 }
 
 GtkWidget *
diff --git a/libempathy-gtk/empathy-individual-menu.c b/libempathy-gtk/empathy-individual-menu.c
index c3edf06..092208b 100644
--- a/libempathy-gtk/empathy-individual-menu.c
+++ b/libempathy-gtk/empathy-individual-menu.c
@@ -245,8 +245,7 @@ empathy_individual_chat_menu_item_activated (GtkMenuItem *item,
 
   g_return_if_fail (contact != NULL);
 
-  empathy_dispatcher_chat_with_contact (contact, gtk_get_current_event_time (),
-      NULL, NULL);
+  empathy_dispatcher_chat_with_contact (contact, gtk_get_current_event_time ());
 
   g_object_unref (contact);
 }
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c
index 8381175..716886d 100644
--- a/libempathy-gtk/empathy-individual-view.c
+++ b/libempathy-gtk/empathy-individual-view.c
@@ -925,7 +925,7 @@ individual_view_row_activated (GtkTreeView *view,
       DEBUG ("Starting a chat");
 
       empathy_dispatcher_chat_with_contact (contact,
-          gtk_get_current_event_time (), NULL, NULL);
+          gtk_get_current_event_time ());
     }
 
   g_object_unref (individual);
diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c
index ae8cdb1..e5abfde 100644
--- a/libempathy/empathy-dispatcher.c
+++ b/libempathy/empathy-dispatcher.c
@@ -1225,49 +1225,11 @@ dispatcher_request_channel (DispatcherRequestData *request_data)
 
 void
 empathy_dispatcher_chat_with_contact (EmpathyContact *contact,
-                                      gint64 timestamp,
-                                      EmpathyDispatcherRequestCb *callback,
-                                      gpointer user_data)
+    gint64 timestamp)
 {
-  EmpathyDispatcher *self;
-  EmpathyDispatcherPriv *priv;
-  TpConnection *connection;
-  ConnectionData *connection_data;
-  DispatcherRequestData *request_data;
-
-  g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
-  self = empathy_dispatcher_dup_singleton ();
-  priv = GET_PRIV (self);
-
-  connection = empathy_contact_get_connection (contact);
-  connection_data = g_hash_table_lookup (priv->connections, connection);
-  if (connection_data == NULL)
-    {
-      /* Connection has been invalidated */
-      if (callback != NULL)
-        {
-          GError error = { TP_DBUS_ERRORS, TP_DBUS_ERROR_PROXY_UNREFERENCED,
-              "Connection has been invalidated" };
-          callback (NULL, &error, user_data);
-        }
-      goto out;
-    }
-
-  /* The contact handle might not be known yet */
-  request_data = new_dispatcher_request_data (self, connection,
-    TP_IFACE_CHANNEL_TYPE_TEXT, TP_HANDLE_TYPE_CONTACT,
-    empathy_contact_get_handle (contact), NULL, timestamp, contact,
-    callback, user_data);
-  request_data->should_ensure = TRUE;
-
-  connection_data->outstanding_requests = g_list_prepend
-    (connection_data->outstanding_requests, request_data);
-
-  dispatcher_request_channel (request_data);
-
-out:
-  g_object_unref (self);
+  empathy_dispatcher_chat_with_contact_id (
+      empathy_contact_get_account (contact), empathy_contact_get_id (contact),
+      timestamp);
 }
 
 static void
diff --git a/libempathy/empathy-dispatcher.h b/libempathy/empathy-dispatcher.h
index 1fa6387..918a428 100644
--- a/libempathy/empathy-dispatcher.h
+++ b/libempathy/empathy-dispatcher.h
@@ -80,9 +80,7 @@ void empathy_dispatcher_chat_with_contact_id (TpAccount *account,
   gint64 timestamp);
 
 void  empathy_dispatcher_chat_with_contact (EmpathyContact *contact,
-  gint64 timestamp,
-  EmpathyDispatcherRequestCb *callback,
-  gpointer user_data);
+  gint64 timestamp);
 
 /* Request a muc channel */
 void empathy_dispatcher_join_muc (TpConnection *connection,
diff --git a/tests/interactive/empetit.c b/tests/interactive/empetit.c
index 7bcaf03..3ed5998 100644
--- a/tests/interactive/empetit.c
+++ b/tests/interactive/empetit.c
@@ -12,25 +12,6 @@
 static GtkWidget *window = NULL;
 
 static void
-chat_cb (EmpathyDispatchOperation *dispatch,
-         const GError *error,
-         gpointer user_data)
-{
-  GtkWidget *dialog;
-
-  if (error != NULL)
-    {
-      dialog = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_MODAL,
-          GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s",
-          error->message ? error->message : "No error message");
-
-      gtk_dialog_run (GTK_DIALOG (dialog));
-    }
-
-  gtk_widget_destroy (window);
-}
-
-static void
 clicked_cb (GtkButton *button,
             gpointer data)
 {
@@ -42,8 +23,7 @@ clicked_cb (GtkButton *button,
   if (!contact)
     return;
 
-  empathy_dispatcher_chat_with_contact (contact, gtk_get_current_event_time (),
-      chat_cb, NULL);
+  empathy_dispatcher_chat_with_contact (contact, gtk_get_current_event_time ());
 
   g_object_unref (contact);
 }



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