empathy r1885 - in trunk: libempathy src



Author: xclaesse
Date: Fri Nov 21 16:23:21 2008
New Revision: 1885
URL: http://svn.gnome.org/viewvc/empathy?rev=1885&view=rev

Log:
When the channel is invalidated, change state to CANCELLED.

Modified:
   trunk/libempathy/empathy-tp-file.c
   trunk/libempathy/empathy-tp-file.h
   trunk/src/empathy-ft-manager.c

Modified: trunk/libempathy/empathy-tp-file.c
==============================================================================
--- trunk/libempathy/empathy-tp-file.c	(original)
+++ trunk/libempathy/empathy-tp-file.c	Fri Nov 21 16:23:21 2008
@@ -327,13 +327,17 @@
 }
 
 static void
-tp_file_destroy_cb (TpChannel *file_channel,
-                    EmpathyTpFile *tp_file)
-{
-  DEBUG ("Channel Closed or CM crashed");
-
-  g_object_unref (tp_file->priv->channel);
-  tp_file->priv->channel = NULL;
+tp_file_invalidated_cb (TpProxy       *proxy,
+			guint          domain,
+			gint           code,
+			gchar         *message,
+			EmpathyTpFile *tp_file)
+{
+	DEBUG ("Channel invalidated: %s", message);
+	tp_file->priv->state = EMP_FILE_TRANSFER_STATE_CANCELLED;
+	tp_file->priv->state_change_reason =
+	    EMP_FILE_TRANSFER_STATE_CHANGE_REASON_LOCAL_ERROR;
+	g_object_notify (G_OBJECT (tp_file), "state");
 }
 
 static void
@@ -347,7 +351,7 @@
     {
       DEBUG ("Closing channel..");
       g_signal_handlers_disconnect_by_func (tp_file->priv->channel,
-          tp_file_destroy_cb, object);
+          tp_file_invalidated_cb, object);
       tp_cli_channel_call_close (tp_file->priv->channel, -1, NULL, NULL,
           NULL, NULL);
       g_object_unref (tp_file->priv->channel);
@@ -384,18 +388,6 @@
   G_OBJECT_CLASS (empathy_tp_file_parent_class)->finalize (object);
 }
 
-static void
-tp_file_closed_cb (TpChannel *file_channel,
-                   EmpathyTpFile *tp_file,
-                   GObject *weak_object)
-{
-  /* The channel is closed, do just like if the proxy was destroyed */
-  g_signal_handlers_disconnect_by_func (tp_file->priv->channel,
-      tp_file_destroy_cb,
-      tp_file);
-  tp_file_destroy_cb (file_channel, tp_file);
-}
-
 static gint
 _get_local_socket (EmpathyTpFile *tp_file)
 {
@@ -539,10 +531,8 @@
   tp_file->priv->factory = empathy_contact_factory_new ();
   tp_file->priv->mc = empathy_mission_control_new ();
 
-  tp_cli_channel_connect_to_closed (tp_file->priv->channel,
-      (tp_cli_channel_signal_callback_closed) tp_file_closed_cb,
-      tp_file,
-      NULL, NULL, NULL);
+  g_signal_connect (tp_file->priv->channel, "invalidated",
+    G_CALLBACK (tp_file_invalidated_cb), tp_file);
 
   emp_cli_channel_type_file_transfer_connect_to_file_transfer_state_changed (
       TP_PROXY (tp_file->priv->channel),
@@ -875,20 +865,16 @@
 }
 
 EmpFileTransferState
-empathy_tp_file_get_state (EmpathyTpFile *tp_file)
+empathy_tp_file_get_state (EmpathyTpFile *tp_file,
+                           EmpFileTransferStateChangeReason *reason)
 {
   g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file),
       EMP_FILE_TRANSFER_STATE_NONE);
-  return tp_file->priv->state;
-}
 
-EmpFileTransferStateChangeReason
-empathy_tp_file_get_state_change_reason (EmpathyTpFile *tp_file)
-{
-  g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file),
-      EMP_FILE_TRANSFER_STATE_CHANGE_REASON_NONE);
+  if (reason != NULL)
+    *reason = tp_file->priv->state_change_reason;
 
-  return tp_file->priv->state_change_reason;
+  return tp_file->priv->state;
 }
 
 guint64

Modified: trunk/libempathy/empathy-tp-file.h
==============================================================================
--- trunk/libempathy/empathy-tp-file.h	(original)
+++ trunk/libempathy/empathy-tp-file.h	Fri Nov 21 16:23:21 2008
@@ -78,8 +78,8 @@
 EmpathyContact *empathy_tp_file_get_contact (EmpathyTpFile *tp_file);
 const gchar *empathy_tp_file_get_filename (EmpathyTpFile *tp_file);
 gboolean empathy_tp_file_is_incoming (EmpathyTpFile *tp_file);
-EmpFileTransferState empathy_tp_file_get_state (EmpathyTpFile *tp_file);
-EmpFileTransferStateChangeReason empathy_tp_file_get_state_change_reason (EmpathyTpFile *tp_file);
+EmpFileTransferState empathy_tp_file_get_state (EmpathyTpFile *tp_file,
+  EmpFileTransferStateChangeReason *reason);
 guint64 empathy_tp_file_get_size (EmpathyTpFile *tp_file);
 guint64 empathy_tp_file_get_transferred_bytes (EmpathyTpFile *tp_file);
 gint empathy_tp_file_get_remaining_time (EmpathyTpFile *tp_file);

Modified: trunk/src/empathy-ft-manager.c
==============================================================================
--- trunk/src/empathy-ft-manager.c	(original)
+++ trunk/src/empathy-ft-manager.c	Fri Nov 21 16:23:21 2008
@@ -177,7 +177,7 @@
     {
       gtk_tree_model_get (model, &iter, COL_FT_OBJECT, &tp_file, -1);
 
-      if (empathy_tp_file_get_state (tp_file)
+      if (empathy_tp_file_get_state (tp_file, NULL)
           == EMP_FILE_TRANSFER_STATE_COMPLETED)
         {
           if (empathy_tp_file_is_incoming (tp_file))
@@ -188,7 +188,7 @@
           abort_enabled = FALSE;
 
         }
-      else if (empathy_tp_file_get_state (tp_file) ==
+      else if (empathy_tp_file_get_state (tp_file, NULL) ==
         EMP_FILE_TRANSFER_STATE_CANCELLED)
         {
           open_enabled = FALSE;
@@ -254,8 +254,7 @@
   contact_name = empathy_contact_get_name (empathy_tp_file_get_contact (tp_file));
   transferred_bytes = empathy_tp_file_get_transferred_bytes (tp_file);
   total_size = empathy_tp_file_get_size (tp_file);
-  state = empathy_tp_file_get_state (tp_file);
-  reason = empathy_tp_file_get_state_change_reason (tp_file);
+  state = empathy_tp_file_get_state (tp_file, &reason);
   incoming = empathy_tp_file_is_incoming (tp_file);
 
   switch (state)
@@ -523,7 +522,7 @@
   EmpathyFTManager *self = EMPATHY_FT_MANAGER (user_data);
   EmpFileTransferState state;
 
-  state = empathy_tp_file_get_state (tp_file);
+  state = empathy_tp_file_get_state (tp_file, NULL);
   if (state == EMP_FILE_TRANSFER_STATE_COMPLETED ||
       state == EMP_FILE_TRANSFER_STATE_CANCELLED)
     {
@@ -551,7 +550,7 @@
 {
   gboolean remove;
 
-  switch (empathy_tp_file_get_state (tp_file))
+  switch (empathy_tp_file_get_state (tp_file, NULL))
     {
       case EMP_FILE_TRANSFER_STATE_COMPLETED:
         if (empathy_tp_file_is_incoming (tp_file))
@@ -944,7 +943,7 @@
       empathy_contact_get_name (empathy_tp_file_get_contact (tp_file)),
       empathy_tp_file_get_filename (tp_file));
 
-  state = empathy_tp_file_get_state (tp_file);
+  state = empathy_tp_file_get_state (tp_file, NULL);
 
   if (state == EMP_FILE_TRANSFER_STATE_PENDING &&
       empathy_tp_file_is_incoming (tp_file))



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