Patch: fix the progress information when refreshing an imap folder
- From: "Martin Bonnin" <martinbonnin gmail com>
- To: tinymail-devel-list <tinymail-devel-list gnome org>
- Subject: Patch: fix the progress information when refreshing an imap folder
- Date: Thu, 20 Nov 2008 14:32:09 +0100
Hello,
Attached a small patch that remove some unwanted progress event
while refreshing an imap folder.
Changelog:
adding camel_operation_mute/unmute() and use it to filter the progress
events. This prevents to send bad progress when refreshing an IMAP folder
Regards,
--
Martin
Index: libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c
===================================================================
--- libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c (révision 3819)
+++ libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c (copie de travail)
@@ -3284,6 +3284,7 @@
tcnt = 0;
camel_operation_start (NULL, _("Fetching summary information for new messages in folder"));
+ camel_operation_mute (NULL);
camel_folder_summary_prepare_hash (folder->summary);
@@ -3551,7 +3552,11 @@
ucnt++;
allhdrs++;
+
+ camel_operation_unmute (NULL);
camel_operation_progress (NULL, allhdrs , ineed);
+ camel_operation_mute (NULL);
+
sequence = GPOINTER_TO_INT (g_datalist_get_data (&data, "SEQUENCE"));
curlen = camel_folder_summary_count (folder->summary);
Index: libtinymail-camel/camel-lite/camel/camel-operation.c
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-operation.c (révision 3819)
+++ libtinymail-camel/camel-lite/camel/camel-operation.c (copie de travail)
@@ -43,6 +43,7 @@
#define CAMEL_OPERATION_CANCELLED (1<<0)
#endif
#define CAMEL_OPERATION_TRANSIENT (1<<1)
+#define CAMEL_OPERATION_MUTE (1<<2)
/* Delay before a transient operation has any effect on the status */
#define CAMEL_OPERATION_TRANSIENT_DELAY (5)
@@ -111,23 +112,63 @@
return cc;
}
+static void
+co_mute(CamelOperation *cc, gboolean mute)
+{
+ struct _status_stack *s;
+
+ if (cc == NULL)
+ cc = co_getcc();
+
+ if (cc == NULL)
+ return;
+
+ LOCK();
+
+ if (cc->status == NULL || cc->status_stack == NULL) {
+ UNLOCK();
+ return;
+ }
+
+ s = cc->status_stack->data;
+
+ if (mute){
+ s->flags |= CAMEL_OPERATION_MUTE;
+ } else {
+ s->flags &= ~CAMEL_OPERATION_MUTE;
+ }
+
+ UNLOCK();
+}
+
+
/**
* camel_operation_mute:
* @cc:
*
- * mutes a camel operation permanently. from this point on you will never
+ * mutes a camel operation. from this point on you will never
* receive operation updates, even if more are sent.
**/
void
camel_operation_mute(CamelOperation *cc)
{
- LOCK();
- cc->status = NULL;
- cc->status_data = NULL;
- UNLOCK();
+ co_mute(cc, TRUE);
}
/**
+ * camel_operation_unmute:
+ * @cc:
+ *
+ * unmutes a camel operation.
+ * Makes the operation send updates again
+ **/
+void
+camel_operation_unmute(CamelOperation *cc)
+{
+ co_mute(cc, FALSE);
+}
+
+/**
* camel_operation_registered:
*
* Returns the registered operation, or %NULL if none registered.
@@ -577,6 +618,12 @@
}
s = cc->status_stack->data;
+
+ if( s->flags & CAMEL_OPERATION_MUTE ){
+ UNLOCK();
+ return;
+ }
+
s->sofar = sofar;
s->oftotal = oftotal;
Index: libtinymail-camel/camel-lite/camel/camel-operation.h
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-operation.h (révision 3819)
+++ libtinymail-camel/camel-lite/camel/camel-operation.h (copie de travail)
@@ -81,6 +81,7 @@
/* main thread functions */
CamelOperation *camel_operation_new(CamelOperationStatusFunc status, void *status_data);
void camel_operation_mute(CamelOperation *cc);
+void camel_operation_unmute(CamelOperation *cc);
void camel_operation_ref(CamelOperation *cc);
void camel_operation_unref(CamelOperation *cc);
void camel_operation_cancel(CamelOperation *cc);
Index: ChangeLog
===================================================================
--- ChangeLog (révision 3819)
+++ ChangeLog (copie de travail)
@@ -1,5 +1,11 @@
2008-11-20 Martin Bonnin <martinbonnin gmail com>
+ * camel operation:
+ adding camel_operation_mute/unmute() and use it to filter the progress
+ events. This prevents to send bad progress when refreshing an IMAP folder
+
+2008-11-20 Martin Bonnin <martinbonnin gmail com>
+
* libtinymail-camel/camel-lite/camel/providers/imap:
For IMAP, we open 2 sessions: one for standard operations, the other
for fetching messages. This makes concurrent accesses to the folder summary
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]