[evolution-kolab] KolabMailImapClient: make SQLite DB updates optional on foldernames query
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab] KolabMailImapClient: make SQLite DB updates optional on foldernames query
- Date: Tue, 24 Jul 2012 14:41:37 +0000 (UTC)
commit 90bae7d1c6391210b775a013cf2866e96c4debe6
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Tue Jul 24 16:32:59 2012 +0200
KolabMailImapClient: make SQLite DB updates optional on foldernames query
* when querying the list of folders (i.e., foldernames) from the
server, it is not always desirable to instantly update
the persistent DBs
* the automatic updates is switched off when doing the "online"
foldernames query (to be used in the collection backend for
folder (type) autodiscovery)
src/libekolab/kolab-mail-imap-client.c | 86 +++++++++++++++++++++----------
1 files changed, 58 insertions(+), 28 deletions(-)
---
diff --git a/src/libekolab/kolab-mail-imap-client.c b/src/libekolab/kolab-mail-imap-client.c
index 1472187..0eb270a 100644
--- a/src/libekolab/kolab-mail-imap-client.c
+++ b/src/libekolab/kolab-mail-imap-client.c
@@ -628,6 +628,56 @@ kolab_mail_imap_client_update_folder (KolabMailImapClient *self,
return TRUE;
}
+static GList*
+mail_imap_client_query_foldernames (KolabMailImapClient *self,
+ GCancellable *cancellable,
+ gboolean do_updatedb,
+ GError **err)
+{
+ KolabMailImapClientPrivate *priv = NULL;
+ CamelFolderInfo *fi = NULL;
+ GList *folder_list = NULL;
+ CamelStoreGetFolderInfoFlags flags = 0;
+ GError *tmp_err = NULL;
+
+ g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
+ /* cancellable may be NULL */
+ g_return_val_if_fail (err == NULL || *err == NULL, NULL);
+
+ priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
+
+ g_assert (priv->is_up == TRUE);
+
+ flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE | CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL;
+ if (do_updatedb) {
+ /* persistently stores folder info */
+ fi = camel_store_get_folder_info_sync (CAMEL_STORE (priv->store),
+ NULL,
+ flags,
+ cancellable,
+ &tmp_err);
+ } else {
+ /* does not store folder info persistently */
+ fi = camel_kolab_imapx_store_get_folder_info_online (priv->store,
+ NULL,
+ flags,
+ cancellable,
+ &tmp_err);
+ }
+ if (tmp_err != NULL) {
+ g_propagate_error (err, tmp_err);
+ return NULL;
+ }
+
+ if (fi == NULL)
+ return NULL;
+
+ camel_store_free_folder_info (CAMEL_STORE (priv->store), fi);
+
+ folder_list = camel_kolab_imapx_store_resect_folder_list (priv->store);
+ return folder_list;
+}
+
/*----------------------------------------------------------------------------*/
/* object config/status */
@@ -1017,37 +1067,16 @@ kolab_mail_imap_client_query_foldernames (KolabMailImapClient *self,
GCancellable *cancellable,
GError **err)
{
- KolabMailImapClientPrivate *priv = NULL;
- CamelFolderInfo *fi = NULL;
GList *folder_list = NULL;
- CamelStoreGetFolderInfoFlags flags = 0;
- GError *tmp_err = NULL;
g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
/* cancellable may be NULL */
g_return_val_if_fail (err == NULL || *err == NULL, NULL);
- priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
-
- g_assert (priv->is_up == TRUE);
-
- flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE | CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL;
- fi = camel_store_get_folder_info_sync (CAMEL_STORE (priv->store),
- NULL,
- flags,
- cancellable,
- &tmp_err);
- if (tmp_err != NULL) {
- g_propagate_error (err, tmp_err);
- return NULL;
- }
-
- if (fi == NULL)
- return NULL;
-
- camel_store_free_folder_info (CAMEL_STORE (priv->store), fi);
-
- folder_list = camel_kolab_imapx_store_resect_folder_list (priv->store);
+ folder_list = mail_imap_client_query_foldernames (self,
+ cancellable,
+ TRUE, /* update SQlite DBs */
+ err);
return folder_list;
}
@@ -1115,9 +1144,10 @@ kolab_mail_imap_client_query_folder_info_online (KolabMailImapClient *self,
return NULL;
}
- folder_names = kolab_mail_imap_client_query_foldernames (self,
- cancellable,
- &tmp_err);
+ folder_names = mail_imap_client_query_foldernames (self,
+ cancellable,
+ FALSE, /* do not update DBs */
+ &tmp_err);
if (tmp_err != NULL) {
g_propagate_error (err, tmp_err);
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]