connection_info_unref (cinfo);
}
+CamelIMAPXMailbox *
+camel_imapx_conn_manager_ref_mailbox (CamelIMAPXConnManager *con_man,
+ const gchar *mailbox_name)
+{
+ CamelIMAPXMailbox *mailbox = NULL;
+ GList *iter;
+
+ g_return_val_if_fail (CAMEL_IS_IMAPX_CONN_MANAGER (con_man), NULL);
+ g_return_val_if_fail (mailbox_name != NULL, NULL);
+
+ CON_READ_LOCK (con_man);
+
+ for (iter = con_man->priv->connections; iter != NULL; iter = g_list_next (iter)) {
+ ConnectionInfo *candidate = iter->data;
+
+ if (candidate->is) {
+ mailbox = camel_imapx_server_ref_mailbox (candidate->is, mailbox_name);
+ if (mailbox)
+ break;
+ }
+ }
+
+ CON_READ_UNLOCK (con_man);
+
+ return mailbox;
+}
+
void
camel_imapx_conn_manager_close_connections (CamelIMAPXConnManager *con_man)
{
(CamelIMAPXConnManager *con_man,
CamelIMAPXServer *server,
const gchar *folder_name);
+CamelIMAPXMailbox *
+ camel_imapx_conn_manager_ref_mailbox
+ (CamelIMAPXConnManager *con_man,
+ const gchar *mailbox_name);
G_END_DECLS
camel_imapx_folder_set_mailbox (CamelIMAPXFolder *folder,
CamelIMAPXMailbox *mailbox)
{
+ CamelIMAPXSummary *imapx_summary;
+ guint32 uidvalidity;
+
g_return_if_fail (CAMEL_IS_IMAPX_FOLDER (folder));
g_return_if_fail (CAMEL_IS_IMAPX_MAILBOX (mailbox));
g_weak_ref_set (&folder->priv->mailbox, mailbox);
+ imapx_summary = CAMEL_IMAPX_SUMMARY (CAMEL_FOLDER (folder)->summary);
+ uidvalidity = camel_imapx_mailbox_get_uidvalidity (mailbox);
+
+ if (uidvalidity > 0 && uidvalidity != imapx_summary->validity)
+ camel_imapx_folder_invalidate_local_cache (folder, uidvalidity);
+
g_object_notify (G_OBJECT (folder), "mailbox");
}
camel_store_summary_info_unref (imapx_store->summary, store_info);
- /* See if the CamelIMAPXServer already has the mailbox. */
+ /* See if the CamelIMAPXStore already has the mailbox. */
- server = camel_imapx_store_ref_server (imapx_store, NULL, FALSE, cancellable, error);
+ mailbox = camel_imapx_store_ref_mailbox (imapx_store, mailbox_name);
+ if (mailbox != NULL) {
+ camel_imapx_folder_set_mailbox (folder, mailbox);
+ goto exit;
+ }
+ server = camel_imapx_store_ref_server (imapx_store, NULL, FALSE, cancellable, error);
if (server == NULL)
goto exit;
}
static void
-imapx_store_process_mailbox_status (CamelIMAPXStore *store,
+imapx_store_process_mailbox_status (CamelIMAPXStore *imapx_store,
CamelIMAPXMailbox *mailbox)
{
- CamelFolder *folder = NULL;
+ CamelStore *store;
+ CamelFolder *folder;
gchar *folder_path;
- GError *local_error = NULL;
folder_path = camel_imapx_mailbox_dup_folder_path (mailbox);
+ store = CAMEL_STORE (imapx_store);
- folder = camel_store_get_folder_sync (
- CAMEL_STORE (store), folder_path, 0, NULL, &local_error);
-
- /* Sanity check. */
- g_return_if_fail (
- ((folder != NULL) && (local_error == NULL)) ||
- ((folder == NULL) && (local_error != NULL)));
-
+ /* Update only already opened folders */
+ folder = camel_object_bag_reserve (store->folders, folder_path);
if (folder != NULL) {
CamelIMAPXFolder *imapx_folder;
CamelIMAPXSummary *imapx_summary;
g_object_unref (folder);
} else {
- g_warning (
- "%s: Failed to get folder '%s': %s",
- G_STRFUNC, folder_path, local_error->message);
- g_error_free (local_error);
+ camel_object_bag_abort (store->folders, folder_path);
}
g_free (folder_path);
store->priv->con_man, server, folder_name);
}
+CamelIMAPXMailbox *
+camel_imapx_store_ref_mailbox (CamelIMAPXStore *imapx_store,
+ const gchar *mailbox_name)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAPX_STORE (imapx_store), NULL);
+ g_return_val_if_fail (mailbox_name != NULL, NULL);
+
+ return camel_imapx_conn_manager_ref_mailbox (imapx_store->priv->con_man, mailbox_name);
+}
+
CamelFolderQuotaInfo *
camel_imapx_store_dup_quota_info (CamelIMAPXStore *store,
const gchar *quota_root_name)
(CamelIMAPXStore *store,
CamelIMAPXServer *server,
const gchar *folder_name);
+CamelIMAPXMailbox *
+ camel_imapx_store_ref_mailbox (CamelIMAPXStore *imapx_store,
+ const gchar *mailbox_name);
+
CamelFolderQuotaInfo *
camel_imapx_store_dup_quota_info
(CamelIMAPXStore *store,