balsa r7948 - in trunk: . libbalsa
- From: PeterB svn gnome org
- To: svn-commits-list gnome org
- Subject: balsa r7948 - in trunk: . libbalsa
- Date: Tue, 17 Jun 2008 16:40:20 +0000 (UTC)
Author: PeterB
Date: Tue Jun 17 16:40:19 2008
New Revision: 7948
URL: http://svn.gnome.org/viewvc/balsa?rev=7948&view=rev
Log:
cache message info at get-message time
Modified:
trunk/ChangeLog
trunk/libbalsa/mailbox.c
trunk/libbalsa/mailbox_mbox.c
Modified: trunk/libbalsa/mailbox.c
==============================================================================
--- trunk/libbalsa/mailbox.c (original)
+++ trunk/libbalsa/mailbox.c Tue Jun 17 16:40:19 2008
@@ -1726,6 +1726,26 @@
return retval;
}
+static void
+lbm_cache_message(LibBalsaMailbox * mailbox, guint msgno,
+ LibBalsaMessage * message)
+{
+ LibBalsaMailboxIndexEntry *entry;
+
+ if (mailbox->mindex->len < msgno)
+ g_ptr_array_set_size(mailbox->mindex, msgno);
+
+ entry = g_ptr_array_index(mailbox->mindex, msgno - 1);
+
+ if (!entry)
+ g_ptr_array_index(mailbox->mindex, msgno - 1) =
+ libbalsa_mailbox_index_entry_new_from_msg(message);
+#if BALSA_USE_THREADS
+ else if (entry->idle_pending)
+ lbm_index_entry_populate_from_msg(entry, message);
+#endif /* BALSA_USE_THREADS */
+}
+
LibBalsaMessage *
libbalsa_mailbox_get_message(LibBalsaMailbox * mailbox, guint msgno)
{
@@ -1758,6 +1778,10 @@
msgno);
libbalsa_unlock_mailbox(mailbox);
+ if (message && mailbox->mindex)
+ /* Cache the message info, if we do not already have it. */
+ lbm_cache_message(mailbox, msgno, message);
+
return message;
}
@@ -2716,10 +2740,10 @@
break;
pthread_mutex_unlock(&get_index_entry_lock);
- if ( (message = libbalsa_mailbox_get_message(mailbox, msgno)) ) {
- libbalsa_mailbox_cache_message(mailbox, msgno, message);
+ if ((message = libbalsa_mailbox_get_message(mailbox, msgno)))
+ /* get-message has cached the message info, so we just unref
+ * message. */
g_object_unref(message);
- }
pthread_mutex_lock(&get_index_entry_lock);
}
@@ -2742,8 +2766,8 @@
if (!lmm->mindex)
return NULL;
- while (lmm->mindex->len < msgno )
- g_ptr_array_add(lmm->mindex, NULL);
+ if (lmm->mindex->len < msgno )
+ g_ptr_array_set_size(lmm->mindex, msgno);
entry = g_ptr_array_index(lmm->mindex, msgno - 1);
#ifdef BALSA_USE_THREADS
@@ -2777,7 +2801,8 @@
LibBalsaMessage *message =
libbalsa_mailbox_get_message(lmm, msgno);
if (message) {
- libbalsa_mailbox_cache_message(lmm, msgno, message);
+ /* get-message has cached the message info, so we just unref
+ * message. */
g_object_unref(message);
entry = g_ptr_array_index(lmm->mindex, msgno - 1);
}
@@ -4184,24 +4209,11 @@
libbalsa_mailbox_cache_message(LibBalsaMailbox * mailbox, guint msgno,
LibBalsaMessage * message)
{
- LibBalsaMailboxIndexEntry *entry;
-
g_return_if_fail(LIBBALSA_IS_MAILBOX(mailbox));
if (!mailbox->mindex)
return;
g_return_if_fail(msgno > 0);
g_return_if_fail(LIBBALSA_IS_MESSAGE(message));
- if (mailbox->mindex->len < msgno)
- g_ptr_array_set_size(mailbox->mindex, msgno);
-
- entry = g_ptr_array_index(mailbox->mindex, msgno - 1);
-
- if (!entry)
- g_ptr_array_index(mailbox->mindex, msgno - 1) =
- libbalsa_mailbox_index_entry_new_from_msg(message);
-#if BALSA_USE_THREADS
- else if (entry->idle_pending)
- lbm_index_entry_populate_from_msg(entry, message);
-#endif /* BALSA_USE_THREADS */
+ lbm_cache_message(mailbox, msgno, message);
}
Modified: trunk/libbalsa/mailbox_mbox.c
==============================================================================
--- trunk/libbalsa/mailbox_mbox.c (original)
+++ trunk/libbalsa/mailbox_mbox.c Tue Jun 17 16:40:19 2008
@@ -520,13 +520,13 @@
msg->mailbox = LIBBALSA_MAILBOX(mbox);
msg->msgno = ++msgno;
/* We must drop the mime-stream lock to call
+ * libbalsa_mailbox_local_cache_message, which calls
* libbalsa_mailbox_cache_message(), as it may grab the
* gdk lock to emit gtk signals; we save and restore the current
* stream position, in case someone changes it while we're not
* holding the lock. */
offset = g_mime_stream_tell(mbox->gmime_stream);
libbalsa_mime_stream_shared_unlock(mbox->gmime_stream);
- libbalsa_mailbox_cache_message(LIBBALSA_MAILBOX(mbox), msgno, msg);
libbalsa_mailbox_local_cache_message(local, msgno, msg);
libbalsa_mime_stream_shared_lock(mbox->gmime_stream);
g_mime_stream_seek(mbox->gmime_stream, offset, GMIME_STREAM_SEEK_SET);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]