[evolution-data-server/meego-eds] Implement e_cal_view_set_caching_enabled() to toggle view caching
- From: Christophe Dumez <cdumez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/meego-eds] Implement e_cal_view_set_caching_enabled() to toggle view caching
- Date: Tue, 5 Jul 2011 17:52:21 +0000 (UTC)
commit 242f8558aa5ea6b15afcb9e4741bbb2f59153238
Author: Christophe Dumez <christophe dumez intel com>
Date: Tue Jul 5 19:42:09 2011 +0300
Implement e_cal_view_set_caching_enabled() to toggle view caching
View caching can now be toggled using
e_cal_view_set_caching_enabled() function.
calendar/libecal/e-cal-view.c | 28 ++++
calendar/libecal/e-cal-view.h | 1 +
calendar/libedata-cal/e-data-cal-view.c | 43 ++++++-
calendar/libegdbus/e-gdbus-egdbuscalview.c | 196 +++++++++++++++++++++++++++
calendar/libegdbus/e-gdbus-egdbuscalview.h | 27 ++++
calendar/libegdbus/e-gdbus-marshallers.c | 41 ++++++
calendar/libegdbus/e-gdbus-marshallers.h | 8 +
calendar/libegdbus/e-gdbus-marshallers.list | 1 +
8 files changed, 342 insertions(+), 3 deletions(-)
---
diff --git a/calendar/libecal/e-cal-view.c b/calendar/libecal/e-cal-view.c
index 6319c58..30e92d5 100644
--- a/calendar/libecal/e-cal-view.c
+++ b/calendar/libecal/e-cal-view.c
@@ -457,3 +457,31 @@ e_cal_view_stop (ECalView *view)
g_error_free (error);
}
}
+
+/**
+ * e_cal_view_set_caching_enabled:
+ * @view: A #ECalView object.
+ * @enable: Caching status
+ *
+ * Toggles notifications caching in the view.
+ */
+void
+e_cal_view_set_caching_enabled (ECalView *view, gboolean enabled)
+{
+ GError *error = NULL;
+ ECalViewPrivate *priv;
+
+ g_return_if_fail (view != NULL);
+ g_return_if_fail (E_IS_CAL_VIEW (view));
+
+ priv = E_CAL_VIEW_GET_PRIVATE(view);
+
+ if (priv->gdbus_calview) {
+ e_gdbus_cal_view_call_set_caching_enabled_sync (priv->gdbus_calview, enabled, NULL, &error);
+ }
+
+ if (error) {
+ g_warning ("Failed to toggle view caching: %s", error->message);
+ g_error_free (error);
+ }
+}
diff --git a/calendar/libecal/e-cal-view.h b/calendar/libecal/e-cal-view.h
index 0a3a5a0..7a99390 100644
--- a/calendar/libecal/e-cal-view.h
+++ b/calendar/libecal/e-cal-view.h
@@ -63,6 +63,7 @@ GType e_cal_view_get_type (void);
struct _ECal *e_cal_view_get_client (ECalView *view);
void e_cal_view_start (ECalView *view);
void e_cal_view_stop (ECalView *view);
+void e_cal_view_set_caching_enabled (ECalView *view, gboolean enabled);
G_END_DECLS
diff --git a/calendar/libedata-cal/e-data-cal-view.c b/calendar/libedata-cal/e-data-cal-view.c
index 7fc4a4d..3985139 100644
--- a/calendar/libedata-cal/e-data-cal-view.c
+++ b/calendar/libedata-cal/e-data-cal-view.c
@@ -49,6 +49,9 @@ struct _EDataCalViewPrivate {
gboolean stopped;
gboolean done;
+ /* Caching enabled */
+ gboolean caching;
+
/* Sexp that defines the query */
ECalBackendSExp *sexp;
@@ -233,7 +236,7 @@ notify_add (EDataCalView *view, gchar *obj)
send_pending_changes (view);
send_pending_removes (view);
- if (priv->adds->len == THRESHOLD_ITEMS) {
+ if (!priv->caching || (priv->adds->len == THRESHOLD_ITEMS)) {
send_pending_adds (view);
}
g_array_append_val (priv->adds, obj);
@@ -255,7 +258,7 @@ notify_change (EDataCalView *view, gchar *obj)
send_pending_adds (view);
send_pending_removes (view);
- if (priv->changes->len == THRESHOLD_ITEMS) {
+ if (!priv->caching || (priv->changes->len == THRESHOLD_ITEMS)) {
send_pending_changes (view);
}
@@ -274,7 +277,7 @@ notify_remove (EDataCalView *view, ECalComponentId *id)
send_pending_adds (view);
send_pending_changes (view);
- if (priv->removes->len == THRESHOLD_ITEMS) {
+ if (!priv->caching || (priv->removes->len == THRESHOLD_ITEMS)) {
send_pending_removes (view);
}
@@ -338,6 +341,38 @@ impl_DataCalView_stop (EGdbusCalView *object, GDBusMethodInvocation *invocation,
}
static gboolean
+impl_DataCalView_setCachingEnabled (EGdbusCalView *object, GDBusMethodInvocation *invocation, gboolean enabled, EDataCalView *query)
+{
+ EDataCalViewPrivate *priv;
+
+ priv = query->priv;
+
+ if (priv->caching != enabled) {
+ priv->caching = enabled;
+
+ /* Flush if caching gets disabled */
+ if (priv->caching) {
+ g_mutex_lock (priv->pending_mutex);
+ if (priv->flush_id) {
+ /* Disable flush timer */
+ g_source_remove (priv->flush_id);
+ priv->flush_id = 0;
+
+ /* flush */
+ send_pending_adds (query);
+ send_pending_changes (query);
+ send_pending_removes (query);
+ }
+ g_mutex_unlock (priv->pending_mutex);
+ }
+ }
+
+ e_gdbus_cal_view_complete_set_caching_enabled (object, invocation);
+
+ return TRUE;
+}
+
+static gboolean
impl_DataCalView_dispose (EGdbusCalView *object, GDBusMethodInvocation *invocation, EDataCalView *query)
{
e_gdbus_cal_view_complete_dispose (object, invocation);
@@ -402,6 +437,7 @@ e_data_cal_view_init (EDataCalView *query)
priv->gdbus_object = e_gdbus_cal_view_stub_new ();
g_signal_connect (priv->gdbus_object, "handle-start", G_CALLBACK (impl_DataCalView_start), query);
g_signal_connect (priv->gdbus_object, "handle-stop", G_CALLBACK (impl_DataCalView_stop), query);
+ g_signal_connect (priv->gdbus_object, "handle-setCachingEnabled", G_CALLBACK (impl_DataCalView_setCachingEnabled), query);
g_signal_connect (priv->gdbus_object, "handle-dispose", G_CALLBACK (impl_DataCalView_dispose), query);
priv->backend = NULL;
@@ -409,6 +445,7 @@ e_data_cal_view_init (EDataCalView *query)
priv->stopped = FALSE;
priv->done = FALSE;
priv->sexp = NULL;
+ priv->caching = TRUE;
priv->adds = g_array_sized_new (TRUE, TRUE, sizeof (gchar *), THRESHOLD_ITEMS);
priv->changes = g_array_sized_new (TRUE, TRUE, sizeof (gchar *), THRESHOLD_ITEMS);
diff --git a/calendar/libegdbus/e-gdbus-egdbuscalview.c b/calendar/libegdbus/e-gdbus-egdbuscalview.c
index c917c90..7d7a7da 100644
--- a/calendar/libegdbus/e-gdbus-egdbuscalview.c
+++ b/calendar/libegdbus/e-gdbus-egdbuscalview.c
@@ -71,6 +71,7 @@ enum
__DONE_SIGNAL,
__START_METHOD,
__STOP_METHOD,
+ __SETCACHINGENABLED_METHOD,
__DISPOSE_METHOD,
__LAST_SIGNAL
};
@@ -346,6 +347,7 @@ e_gdbus_cal_view_default_init (EGdbusCalViewIface *iface)
_property_name_to_gname = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (_method_name_to_id, (gpointer) "start", GUINT_TO_POINTER (__START_METHOD));
g_hash_table_insert (_method_name_to_id, (gpointer) "stop", GUINT_TO_POINTER (__STOP_METHOD));
+ g_hash_table_insert (_method_name_to_id, (gpointer) "setCachingEnabled", GUINT_TO_POINTER (__SETCACHINGENABLED_METHOD));
g_hash_table_insert (_method_name_to_id, (gpointer) "dispose", GUINT_TO_POINTER (__DISPOSE_METHOD));
g_hash_table_insert (_signal_name_to_id, (gpointer) "ObjectsAdded", GUINT_TO_POINTER (__OBJECTS_ADDED_SIGNAL));
g_hash_table_insert (_signal_name_to_id, (gpointer) "ObjectsModified", GUINT_TO_POINTER (__OBJECTS_MODIFIED_SIGNAL));
@@ -559,6 +561,33 @@ e_gdbus_cal_view_default_init (EGdbusCalViewIface *iface)
G_TYPE_DBUS_METHOD_INVOCATION);
/**
+ * EGdbusCalView::handle-setCachingEnabled:
+ * @object: The exported object emitting the signal.
+ * @invocation: A #GDBusMethodInvocation object that can be used to return a value or error.
+ * @enabled: Parameter.
+ *
+ * On exported objects, this signal is emitted when a remote process (identified by @invocation) invokes the <literal>setCachingEnabled</literal> D-Bus method on @object. Use e_gdbus_cal_view_complete_set_caching_enabled() to return a value or g_dbus_method_invocation_return_error() to return an error.
+ *
+ * The signal is emitted in the thread-default main loop of the thread that e_gdbus_cal_view_register_object() was called from.
+ *
+ * On proxies, this signal is never emitted.
+ *
+ * Returns: %TRUE if you want to handle the method call (will stop further handlers from being called), %FALSE otherwise.
+ */
+ signals[__SETCACHINGENABLED_METHOD] =
+ g_signal_new ("handle-setCachingEnabled",
+ G_TYPE_FROM_INTERFACE (iface),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EGdbusCalViewIface, handle_setCachingEnabled),
+ g_signal_accumulator_true_handled,
+ NULL,
+ _e_gdbus_gdbus_cclosure_marshaller_BOOLEAN__OBJECT_BOOLEAN,
+ G_TYPE_BOOLEAN,
+ 2,
+ G_TYPE_DBUS_METHOD_INVOCATION,
+ G_TYPE_BOOLEAN);
+
+ /**
* EGdbusCalView::handle-dispose:
* @object: The exported object emitting the signal.
* @invocation: A #GDBusMethodInvocation object that can be used to return a value or error.
@@ -789,6 +818,113 @@ _out:
}
/**
+ * e_gdbus_cal_view_call_set_caching_enabled:
+ * @proxy: A #EGdbusCalView.
+ * @enabled: Method parameter.
+ * @cancellable: A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't care about the result of the method invocation.
+ * @user_data: Data to pass to @callback.
+ *
+ * Invokes the <literal>org.gnome.evolution.dataserver.calendar.CalView.setCachingEnabled</literal>
+ * D-Bus method on the remote object represented by @proxy.
+ *
+ * This is an asynchronous method. When the operation is finished,
+ * callback will be invoked in the thread-default main loop of the
+ * thread you are calling this method from. You can then call
+ * e_gdbus_cal_view_call_set_caching_enabled_finish() to get the result of the operation.
+ *
+ * See e_gdbus_cal_view_call_set_caching_enabled_sync() for the synchronous version of this method.
+ */
+void
+e_gdbus_cal_view_call_set_caching_enabled (
+ EGdbusCalView *proxy,
+ gboolean enabled,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GVariant *_params;
+ _params = g_variant_new ("(b)",
+ enabled);
+ g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+ "setCachingEnabled",
+ _params,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ cancellable,
+ callback,
+ user_data);
+}
+
+/**
+ * e_gdbus_cal_view_call_set_caching_enabled_finish:
+ * @proxy: A #EGdbusCalView.
+ * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to e_gdbus_cal_view_call_set_caching_enabled().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes invoking the <literal>org.gnome.evolution.dataserver.calendar.CalView.setCachingEnabled</literal>
+ * D-Bus method on the remote object represented by @proxy.
+ *
+ * Returns: %TRUE if the call succeeded, %FALSE if @error is set.
+ */
+gboolean
+e_gdbus_cal_view_call_set_caching_enabled_finish (
+ EGdbusCalView *proxy,
+ GAsyncResult *res,
+ GError **error)
+{
+ gboolean _ret = FALSE;
+ GVariant *_result;
+ _result = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+ if (_result == NULL)
+ goto _out;
+ g_variant_unref (_result);
+ _ret = TRUE;
+_out:
+ return _ret;
+}
+
+/**
+ * e_gdbus_cal_view_call_set_caching_enabled_sync:
+ * @proxy: A #EGdbusCalView.
+ * @enabled: Caching status.
+ * @cancellable: A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <literal>org.gnome.evolution.dataserver.calendar.CalView.setCachingEnabled</literal>
+ * D-Bus method on the remote object represented by @proxy.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * Returns: %TRUE if the call succeeded, %FALSE if @error is set.
+ */
+gboolean e_gdbus_cal_view_call_set_caching_enabled_sync (
+ EGdbusCalView *proxy,
+ gboolean enabled,
+ GCancellable *cancellable,
+ GError **error)
+{
+ gboolean _ret = FALSE;
+ GVariant *_result;
+ GVariant *_params;
+ _params = g_variant_new ("(b)",
+ enabled);
+ _result = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+ "setCachingEnabled",
+ _params,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ cancellable,
+ error);
+ if (_result == NULL)
+ goto _out;
+ g_variant_unref (_result);
+ _ret = TRUE;
+_out:
+ return _ret;
+}
+
+/**
* e_gdbus_cal_view_call_dispose:
* @proxy: A #EGdbusCalView.
* @cancellable: A #GCancellable or %NULL.
@@ -929,6 +1065,26 @@ void e_gdbus_cal_view_complete_stop (
}
/**
+ * e_gdbus_cal_view_complete_set_caching_enabled:
+ * @object: A #EGdbusCalView.
+ * @invocation: A #GDBusMethodInvocation.
+ *
+ * Completes handling the <literal>org.gnome.evolution.dataserver.calendar.CalView.setCachingEnabled</literal>
+ * D-Bus method invocation by returning a value.
+ *
+ * If you want to return an error, use g_dbus_method_invocation_return_error()
+ * or similar instead.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void e_gdbus_cal_view_complete_set_caching_enabled (
+ EGdbusCalView *object,
+ GDBusMethodInvocation *invocation)
+{
+ g_dbus_method_invocation_return_value (invocation, NULL);
+}
+
+/**
* e_gdbus_cal_view_complete_dispose:
* @object: A #EGdbusCalView.
* @invocation: A #GDBusMethodInvocation.
@@ -1176,6 +1332,29 @@ static const GDBusMethodInfo e_gdbus_cal_view_method_stop =
(GDBusAnnotationInfo **) NULL,
};
+static const GDBusArgInfo e_gdbus_cal_method_in_setCachingEnabled_enabled =
+{
+ -1,
+ (gchar *) "enabled",
+ (gchar *) "b",
+ (GDBusAnnotationInfo **) NULL,
+};
+
+static const GDBusArgInfo * const e_gdbus_cal_method_in_setCachingEnabled_arg_pointers[] =
+{
+ &e_gdbus_cal_method_in_setCachingEnabled_enabled,
+ NULL
+};
+
+static const GDBusMethodInfo e_gdbus_cal_view_method_setCachingEnabled =
+{
+ -1,
+ (gchar *) "setCachingEnabled",
+ (GDBusArgInfo **) &e_gdbus_cal_method_in_setCachingEnabled_arg_pointers,
+ (GDBusArgInfo **) NULL,
+ (GDBusAnnotationInfo **) NULL,
+};
+
static const GDBusMethodInfo e_gdbus_cal_view_method_dispose =
{
-1,
@@ -1189,6 +1368,7 @@ static const GDBusMethodInfo * const e_gdbus_cal_view_method_info_pointers[] =
{
&e_gdbus_cal_view_method_start,
&e_gdbus_cal_view_method_stop,
+ &e_gdbus_cal_view_method_setCachingEnabled,
&e_gdbus_cal_view_method_dispose,
NULL
};
@@ -1240,6 +1420,22 @@ handle_method_call (GDBusConnection *connection,
}
break;
+ case __SETCACHINGENABLED_METHOD:
+ {
+ EGdbusCalView *object = E_GDBUS_CAL_VIEW (user_data);
+ gboolean handled;
+ gboolean enabled;
+ g_variant_get (parameters,
+ "(b)",
+ &enabled);
+ g_signal_emit (object,
+ signals[method_id],
+ 0, invocation, enabled, &handled);
+ if (!handled)
+ goto not_implemented;
+ }
+ break;
+
case __DISPOSE_METHOD:
{
EGdbusCalView *object = E_GDBUS_CAL_VIEW (user_data);
diff --git a/calendar/libegdbus/e-gdbus-egdbuscalview.h b/calendar/libegdbus/e-gdbus-egdbuscalview.h
index b3361d0..e87d540 100644
--- a/calendar/libegdbus/e-gdbus-egdbuscalview.h
+++ b/calendar/libegdbus/e-gdbus-egdbuscalview.h
@@ -35,6 +35,7 @@ typedef struct _EGdbusCalView EGdbusCalView; /* Dummy typedef */
* @done: Handler for the #EGdbusCalView::done signal.
* @handle_start: Handler for the #EGdbusCalView::handle-start signal.
* @handle_stop: Handler for the #EGdbusCalView::handle-stop signal.
+ * @handle_setCachingEnabled: Handler for the #EGdbusCalView::handle-setCachingEnabled signal.
* @handle_dispose: Handler for the #EGdbusCalView::handle-dispose signal.
*
* Virtual table.
@@ -190,6 +191,10 @@ struct _EGdbusCalViewIface
gboolean (*handle_stop) (
EGdbusCalView *object,
GDBusMethodInvocation *invocation);
+ gboolean (*handle_setCachingEnabled) (
+ EGdbusCalView *object,
+ GDBusMethodInvocation *invocation,
+ gboolean enabled);
gboolean (*handle_dispose) (
EGdbusCalView *object,
GDBusMethodInvocation *invocation);
@@ -230,6 +235,24 @@ gboolean e_gdbus_cal_view_call_stop_sync (
GCancellable *cancellable,
GError **error);
+void e_gdbus_cal_view_call_set_caching_enabled (
+ EGdbusCalView *proxy,
+ gboolean enabled,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+gboolean e_gdbus_cal_view_call_set_caching_enabled_finish (
+ EGdbusCalView *proxy,
+ GAsyncResult *res,
+ GError **error);
+
+gboolean e_gdbus_cal_view_call_set_caching_enabled_sync (
+ EGdbusCalView *proxy,
+ gboolean enabled,
+ GCancellable *cancellable,
+ GError **error);
+
void e_gdbus_cal_view_call_dispose (
EGdbusCalView *proxy,
GCancellable *cancellable,
@@ -255,6 +278,10 @@ void e_gdbus_cal_view_complete_stop (
EGdbusCalView *object,
GDBusMethodInvocation *invocation);
+void e_gdbus_cal_view_complete_set_caching_enabled (
+ EGdbusCalView *object,
+ GDBusMethodInvocation *invocation);
+
void e_gdbus_cal_view_complete_dispose (
EGdbusCalView *object,
GDBusMethodInvocation *invocation);
diff --git a/calendar/libegdbus/e-gdbus-marshallers.c b/calendar/libegdbus/e-gdbus-marshallers.c
index 7e2adfd..a176ed5 100644
--- a/calendar/libegdbus/e-gdbus-marshallers.c
+++ b/calendar/libegdbus/e-gdbus-marshallers.c
@@ -472,3 +472,44 @@ _e_gdbus_gdbus_cclosure_marshaller_BOOLEAN__OBJECT_STRING_STRING_UINT (GClosure
g_value_set_boolean (return_value, v_return);
}
+/* BOOLEAN:OBJECT,BOOLEAN (e-gdbus-marshallers.list:15) */
+void
+_e_gdbus_gdbus_cclosure_marshaller_BOOLEAN__OBJECT_BOOLEAN (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__OBJECT_BOOLEAN) (gpointer data1,
+ gpointer arg_1,
+ gboolean arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__OBJECT_BOOLEAN callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__OBJECT_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_object (param_values + 1),
+ g_marshal_value_peek_boolean (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
diff --git a/calendar/libegdbus/e-gdbus-marshallers.h b/calendar/libegdbus/e-gdbus-marshallers.h
index 1c1bc52..09c6e51 100644
--- a/calendar/libegdbus/e-gdbus-marshallers.h
+++ b/calendar/libegdbus/e-gdbus-marshallers.h
@@ -98,6 +98,14 @@ extern void _e_gdbus_gdbus_cclosure_marshaller_BOOLEAN__OBJECT_STRING_STRING_UIN
gpointer invocation_hint,
gpointer marshal_data);
+/* BOOLEAN:OBJECT,BOOLEAN (e-gdbus-marshallers.list:15) */
+extern void _e_gdbus_gdbus_cclosure_marshaller_BOOLEAN__OBJECT_BOOLEAN (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
G_END_DECLS
#endif /* ___e_gdbus_gdbus_cclosure_marshaller_MARSHAL_H__ */
diff --git a/calendar/libegdbus/e-gdbus-marshallers.list b/calendar/libegdbus/e-gdbus-marshallers.list
index c133202..3166726 100644
--- a/calendar/libegdbus/e-gdbus-marshallers.list
+++ b/calendar/libegdbus/e-gdbus-marshallers.list
@@ -12,3 +12,4 @@ BOOLEAN:OBJECT,STRING,STRING
BOOLEAN:OBJECT,STRING
BOOLEAN:OBJECT,BOXED,UINT,UINT
BOOLEAN:OBJECT,STRING,STRING,UINT
+BOOLEAN:OBJECT,BOOLEAN
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]