evolution-data-server r9354 - in trunk/calendar: . backends/groupwise libedata-cal



Author: tobiasmue
Date: Fri Aug 15 02:44:45 2008
New Revision: 9354
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9354&view=rev

Log:
Patch by Stanislav Slusny which adds variable to remember last notified
value and method to set this new variable to zero. Notification is sent
only if new value is greater that last sent value.
Fixes bug 531930


Modified:
   trunk/calendar/ChangeLog
   trunk/calendar/backends/groupwise/e-cal-backend-groupwise.c
   trunk/calendar/libedata-cal/e-cal-backend.c
   trunk/calendar/libedata-cal/e-cal-backend.h

Modified: trunk/calendar/backends/groupwise/e-cal-backend-groupwise.c
==============================================================================
--- trunk/calendar/backends/groupwise/e-cal-backend-groupwise.c	(original)
+++ trunk/calendar/backends/groupwise/e-cal-backend-groupwise.c	Fri Aug 15 02:44:45 2008
@@ -246,6 +246,8 @@
 			forward = FALSE;
 		}
 
+		e_cal_backend_view_progress_start (E_CAL_BACKEND (cbgw));
+
 		while (!done) {
 
 			status = e_gw_connection_read_cursor (priv->cnc, priv->container_id, cursor, forward, CURSOR_ITEM_LIMIT, position, &list);
@@ -273,7 +275,7 @@
 					percent = 99;
 
 				progress_string = g_strdup_printf (_("Loading %s items"), type);
-				e_cal_backend_notify_view_progress (E_CAL_BACKEND (cbgw), progress_string, percent);
+				e_cal_backend_notify_view_progress_start (E_CAL_BACKEND (cbgw));
 
 				if (E_IS_CAL_COMPONENT (comp)) {
 					char *comp_str;

Modified: trunk/calendar/libedata-cal/e-cal-backend.c
==============================================================================
--- trunk/calendar/libedata-cal/e-cal-backend.c	(original)
+++ trunk/calendar/libedata-cal/e-cal-backend.c	Fri Aug 15 02:44:45 2008
@@ -50,6 +50,11 @@
 
 	/* ECalBackend to pass notifications on to */
 	ECalBackend *notification_proxy;
+
+	/* used when notifying clients about progress of some operation,
+	 * we do not send multiple notifications with the same percent
+	 * value */
+	int last_percent_notified;
 };
 
 /* Property IDs */
@@ -276,6 +281,7 @@
 
 	priv->clients = NULL;
 	priv->clients_mutex = g_mutex_new ();
+	priv->last_percent_notified = 0;
 
 	/* FIXME bonobo_object_ref/unref? */
 	priv->queries = e_list_new ((EListCopyFunc) bonobo_object_ref, (EListFreeFunc) bonobo_object_unref, NULL);
@@ -1200,6 +1206,23 @@
 }
 
 /**
+ * e_cal_backend_view_progress_start
+ * @backend: A calendar backend.
+ *
+ * This methods has to be used before e_cal_backend_notify_view_progress.
+ * Sets last notified percent value to 0.
+ **/
+void
+e_cal_backend_notify_view_progress_start (ECalBackend *backend)
+{
+	ECalBackendPrivate *priv;
+
+	priv = backend->priv;
+
+	priv->last_percent_notified = 0;
+}
+
+/**
  * e_cal_backend_notify_view_progress:
  * @backend: A calendar backend.
  * @message: the UID of the removed object
@@ -1217,6 +1240,11 @@
 
 	priv = backend->priv;
 
+	if (percent <= priv->last_percent_notified)
+		return;
+
+	priv->last_percent_notified = percent;
+
 	if (priv->notification_proxy) {
 		e_cal_backend_notify_view_progress (priv->notification_proxy, message, percent);
 		return;

Modified: trunk/calendar/libedata-cal/e-cal-backend.h
==============================================================================
--- trunk/calendar/libedata-cal/e-cal-backend.h	(original)
+++ trunk/calendar/libedata-cal/e-cal-backend.h	Fri Aug 15 02:44:45 2008
@@ -180,6 +180,7 @@
 void e_cal_backend_notify_error     (ECalBackend *backend, const char *message);
 
 void e_cal_backend_notify_view_done (ECalBackend *backend, GNOME_Evolution_Calendar_CallStatus status);
+void e_cal_backend_notify_view_progress_start (ECalBackend *backend);
 void e_cal_backend_notify_view_progress (ECalBackend *backend, const char *message, int percent);
 void e_cal_backend_notify_readonly (ECalBackend *backend, gboolean read_only);
 void e_cal_backend_notify_cal_address (ECalBackend *backend, char *address);



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