[evolution-data-server/email-factory] Add cancel operation support.



commit 07f922e0a9947e481236b5533637e4130c0728b8
Author: Srinivasa Ragavan <sragavan gnome org>
Date:   Mon May 9 14:50:53 2011 +0530

    Add cancel operation support.

 mail/daemon/e-mail-data-session.c     |   13 +++++
 mail/daemon/e-mail-data-session.xml   |    2 +
 mail/libegdbus/e-gdbus-emailsession.c |   90 +++++++++++++++++++++++++++++++++
 mail/libegdbus/e-gdbus-emailsession.h |   24 +++++++++
 4 files changed, 129 insertions(+), 0 deletions(-)
---
diff --git a/mail/daemon/e-mail-data-session.c b/mail/daemon/e-mail-data-session.c
index 5323268..b5f2f0b 100644
--- a/mail/daemon/e-mail-data-session.c
+++ b/mail/daemon/e-mail-data-session.c
@@ -358,6 +358,18 @@ impl_Mail_sendReceive (EGdbusSessionCS *object, GDBusMethodInvocation *invocatio
 	return TRUE;
 }
 
+static gboolean
+impl_Mail_cancelOperations (EGdbusSessionCS *object, GDBusMethodInvocation *invocation, EMailDataSession *msession)
+{
+	ipc(printf("Canceling all Mail Operations\n"));
+
+	/* This is the only known reliable way to cancel an issued operation. No harm in canceling this. */
+	mail_cancel_all ();
+
+	egdbus_session_cs_complete_cancel_operations (object, invocation);
+	return TRUE;
+}
+
 static void
 e_mail_data_session_get_property (GObject *object, guint property_id,
                               GValue *value, GParamSpec *pspec)
@@ -417,6 +429,7 @@ e_mail_data_session_init (EMailDataSession *self)
 	g_signal_connect (priv->gdbus_object, "handle-get-folder-from-uri", G_CALLBACK (impl_Mail_getFolderFromUri), self);
 	g_signal_connect (priv->gdbus_object, "handle-add-password", G_CALLBACK (impl_Mail_addPassword), self);
 	g_signal_connect (priv->gdbus_object, "handle-send-receive", G_CALLBACK (impl_Mail_sendReceive), self);
+	g_signal_connect (priv->gdbus_object, "handle-cancel-operations", G_CALLBACK (impl_Mail_cancelOperations), self);
 
 	priv->stores_lock = g_mutex_new ();
 	priv->stores = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
diff --git a/mail/daemon/e-mail-data-session.xml b/mail/daemon/e-mail-data-session.xml
index 42dc199..04f71ae 100644
--- a/mail/daemon/e-mail-data-session.xml
+++ b/mail/daemon/e-mail-data-session.xml
@@ -42,6 +42,8 @@
 
     <method name="sendReceive">
     </method>
+    <method name="cancelOperations">
+    </method>    
     <signal name="sendReceiveComplete">
     </signal>
 
diff --git a/mail/libegdbus/e-gdbus-emailsession.c b/mail/libegdbus/e-gdbus-emailsession.c
index d0552dc..5f8a0b2 100644
--- a/mail/libegdbus/e-gdbus-emailsession.c
+++ b/mail/libegdbus/e-gdbus-emailsession.c
@@ -562,6 +562,18 @@ static const _ExtendedGDBusMethodInfo _egdbus_session_cs_method_info_send_receiv
   "handle-send-receive"
 };
 
+static const _ExtendedGDBusMethodInfo _egdbus_session_cs_method_info_cancel_operations =
+{
+  {
+    -1,
+    "cancelOperations",
+    NULL,
+    NULL,
+    NULL
+  },
+  "handle-cancel-operations"
+};
+
 static const _ExtendedGDBusMethodInfo * const _egdbus_session_cs_method_info_pointers[] =
 {
   &_egdbus_session_cs_method_info_get_store,
@@ -570,6 +582,7 @@ static const _ExtendedGDBusMethodInfo * const _egdbus_session_cs_method_info_poi
   &_egdbus_session_cs_method_info_get_local_folder,
   &_egdbus_session_cs_method_info_get_folder_from_uri,
   &_egdbus_session_cs_method_info_send_receive,
+  &_egdbus_session_cs_method_info_cancel_operations,
   NULL
 };
 
@@ -746,6 +759,17 @@ egdbus_session_cs_default_init (EGdbusSessionCSIface *iface)
     1,
     G_TYPE_DBUS_METHOD_INVOCATION);
 
+  g_signal_new ("handle-cancel-operations",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusSessionCSIface, handle_cancel_operations),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
   /* GObject signals for received D-Bus signals: */
   g_signal_new ("send-receive-complete",
     G_TYPE_FROM_INTERFACE (iface),
@@ -1174,6 +1198,63 @@ _out:
 }
 
 void
+egdbus_session_cs_call_cancel_operations (
+    EGdbusSessionCS *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "cancelOperations",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_session_cs_call_cancel_operations_finish (
+    EGdbusSessionCS *proxy,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_session_cs_call_cancel_operations_sync (
+    EGdbusSessionCS *proxy,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "cancelOperations",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
 egdbus_session_cs_complete_get_store (
     EGdbusSessionCS *object,
     GDBusMethodInvocation *invocation,
@@ -1235,6 +1316,15 @@ egdbus_session_cs_complete_send_receive (
     g_variant_new ("()"));
 }
 
+void
+egdbus_session_cs_complete_cancel_operations (
+    EGdbusSessionCS *object,
+    GDBusMethodInvocation *invocation)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("()"));
+}
+
 /* ------------------------------------------------------------------------ */
 
 static void
diff --git a/mail/libegdbus/e-gdbus-emailsession.h b/mail/libegdbus/e-gdbus-emailsession.h
index 1238fff..1f102e0 100644
--- a/mail/libegdbus/e-gdbus-emailsession.h
+++ b/mail/libegdbus/e-gdbus-emailsession.h
@@ -63,6 +63,10 @@ struct _EGdbusSessionCSIface
     EGdbusSessionCS *object,
     GDBusMethodInvocation *invocation);
 
+  gboolean (*handle_cancel_operations) (
+    EGdbusSessionCS *object,
+    GDBusMethodInvocation *invocation);
+
 
   /* GObject signal class handlers for received D-Bus signals: */
   void (*send_receive_complete) (
@@ -110,6 +114,10 @@ void egdbus_session_cs_complete_send_receive (
     EGdbusSessionCS *object,
     GDBusMethodInvocation *invocation);
 
+void egdbus_session_cs_complete_cancel_operations (
+    EGdbusSessionCS *object,
+    GDBusMethodInvocation *invocation);
+
 
 
 /* D-Bus signal emissions functions: */
@@ -241,6 +249,22 @@ gboolean egdbus_session_cs_call_send_receive_sync (
     GCancellable *cancellable,
     GError **error);
 
+void egdbus_session_cs_call_cancel_operations (
+    EGdbusSessionCS *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_session_cs_call_cancel_operations_finish (
+    EGdbusSessionCS *proxy,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_session_cs_call_cancel_operations_sync (
+    EGdbusSessionCS *proxy,
+    GCancellable *cancellable,
+    GError **error);
+
 
 
 /* ---- */



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