[evolution-data-server] CamelLocalStore: Add a "need-summary-check" property.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] CamelLocalStore: Add a "need-summary-check" property.
- Date: Mon, 15 Aug 2011 15:56:22 +0000 (UTC)
commit 6a8e6d58b54e8974ccd63b495f7cb4b1f25bdc93
Author: Matthew Barnes <mbarnes redhat com>
Date: Sat Jul 9 10:45:38 2011 -0400
CamelLocalStore: Add a "need-summary-check" property.
Use g_object_set() instead of camel_url_set_param() to change the
need-summary-check flag common to all local store types.
camel/providers/local/camel-local-folder.c | 22 +++---
camel/providers/local/camel-local-folder.h | 1 -
camel/providers/local/camel-local-provider.c | 9 +-
camel/providers/local/camel-local-store.c | 109 ++++++++++++++++++++++++++
camel/providers/local/camel-local-store.h | 5 +
5 files changed, 130 insertions(+), 16 deletions(-)
---
diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c
index 7a8dbbb..0df10bc 100644
--- a/camel/providers/local/camel-local-folder.c
+++ b/camel/providers/local/camel-local-folder.c
@@ -369,9 +369,16 @@ local_folder_refresh_info_sync (CamelFolder *folder,
GCancellable *cancellable,
GError **error)
{
+ CamelStore *parent_store;
CamelLocalFolder *lf = (CamelLocalFolder *) folder;
+ gboolean need_summary_check;
+
+ parent_store = camel_folder_get_parent_store (folder);
+
+ need_summary_check = camel_local_store_get_need_summary_check (
+ CAMEL_LOCAL_STORE (parent_store));
- if (lf->need_summary_check &&
+ if (need_summary_check &&
camel_local_summary_check ((CamelLocalSummary *) folder->summary, lf->changes, cancellable, error) == -1)
return FALSE;
@@ -512,15 +519,14 @@ camel_local_folder_construct (CamelLocalFolder *lf,
CamelLocalStore *ls;
CamelStore *parent_store;
const gchar *full_name;
- const gchar *summary_check;
- CamelURL *url;
+ gboolean need_summary_check;
folder = CAMEL_FOLDER (lf);
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
ls = CAMEL_LOCAL_STORE (parent_store);
- url = camel_service_get_camel_url (CAMEL_SERVICE (parent_store));
+ need_summary_check = camel_local_store_get_need_summary_check (ls);
root_dir_path = camel_local_store_get_toplevel_dir (ls);
/* strip the trailing '/' which is always present */
@@ -540,12 +546,6 @@ camel_local_folder_construct (CamelLocalFolder *lf,
camel_object_set_state_filename (CAMEL_OBJECT (lf), statepath);
g_free (statepath);
- summary_check = camel_url_get_param (url, "need-summary-check");
- if (summary_check && !strcmp (summary_check, "no"))
- lf->need_summary_check = FALSE;
- else
- lf->need_summary_check = TRUE;
-
lf->flags = flags;
if (camel_object_state_read (CAMEL_OBJECT (lf)) == -1) {
@@ -610,7 +610,7 @@ camel_local_folder_construct (CamelLocalFolder *lf,
folder->summary = (CamelFolderSummary *) CAMEL_LOCAL_FOLDER_GET_CLASS (lf)->create_summary (lf, lf->summary_path, lf->folder_path, lf->index);
if (!(flags & CAMEL_STORE_IS_MIGRATING) && camel_local_summary_load ((CamelLocalSummary *) folder->summary, forceindex, NULL) == -1) {
/* ? */
- if (lf->need_summary_check &&
+ if (need_summary_check &&
camel_local_summary_check ((CamelLocalSummary *) folder->summary, lf->changes, cancellable, error) == 0) {
/* we sync here so that any hard work setting up the folder isn't lost */
if (camel_local_summary_sync ((CamelLocalSummary *) folder->summary, FALSE, lf->changes, cancellable, error) == -1) {
diff --git a/camel/providers/local/camel-local-folder.h b/camel/providers/local/camel-local-folder.h
index f262b55..02415dd 100644
--- a/camel/providers/local/camel-local-folder.h
+++ b/camel/providers/local/camel-local-folder.h
@@ -56,7 +56,6 @@ struct _CamelLocalFolder {
CamelLocalFolderPrivate *priv;
guint32 flags; /* open mode flags */
- gboolean need_summary_check;
gint locked; /* lock counter */
CamelLockType locktype; /* what type of lock we have */
diff --git a/camel/providers/local/camel-local-provider.c b/camel/providers/local/camel-local-provider.c
index e452875..0615c83 100644
--- a/camel/providers/local/camel-local-provider.c
+++ b/camel/providers/local/camel-local-provider.c
@@ -40,7 +40,7 @@
static CamelProviderConfEntry mh_conf_entries[] = {
CAMEL_PROVIDER_CONF_DEFAULT_PATH,
{ CAMEL_PROVIDER_CONF_SECTION_START, "general", NULL, N_("Options") },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "dotfolders", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "use-dot-folders", NULL,
N_("_Use the '.folders' folder summary file (exmh)"), "0" },
{ CAMEL_PROVIDER_CONF_SECTION_END },
{ CAMEL_PROVIDER_CONF_END }
@@ -82,7 +82,7 @@ static CamelProvider mbox_provider = {
static CamelProviderConfEntry maildir_conf_entries[] = {
CAMEL_PROVIDER_CONF_DEFAULT_PATH,
{ CAMEL_PROVIDER_CONF_SECTION_START, "general", NULL, N_("Options") },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "filter", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "filter-inbox", NULL,
N_("_Apply filters to new messages in INBOX"), "0" },
{ CAMEL_PROVIDER_CONF_SECTION_END },
{ CAMEL_PROVIDER_CONF_END }
@@ -103,8 +103,9 @@ static CamelProvider maildir_provider = {
static CamelProviderConfEntry spool_conf_entries[] = {
CAMEL_PROVIDER_CONF_DEFAULT_PATH,
{ CAMEL_PROVIDER_CONF_SECTION_START, "general", NULL, N_("Options") },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "filter", NULL, N_("_Apply filters to new messages in INBOX"), "0" },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "xstatus", NULL, N_("_Store status headers in Elm/Pine/Mutt format"), "0" },
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "filter-inbox", NULL,
+ N_("_Apply filters to new messages in INBOX"), "0" },
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "use-xstatus-headers", NULL, N_("_Store status headers in Elm/Pine/Mutt format"), "0" },
{ CAMEL_PROVIDER_CONF_SECTION_END },
{ CAMEL_PROVIDER_CONF_END }
};
diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c
index dbe2bef..62236e0 100644
--- a/camel/providers/local/camel-local-store.c
+++ b/camel/providers/local/camel-local-store.c
@@ -39,6 +39,19 @@
#define d(x)
+#define CAMEL_LOCAL_STORE_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), CAMEL_TYPE_LOCAL_STORE, CamelLocalStorePrivate))
+
+struct _CamelLocalStorePrivate {
+ gboolean need_summary_check;
+};
+
+enum {
+ PROP_0,
+ PROP_NEED_SUMMARY_CHECK
+};
+
G_DEFINE_TYPE (CamelLocalStore, camel_local_store, CAMEL_TYPE_STORE)
static gint
@@ -86,6 +99,41 @@ xrename (const gchar *oldp,
}
static void
+local_store_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_NEED_SUMMARY_CHECK:
+ camel_local_store_set_need_summary_check (
+ CAMEL_LOCAL_STORE (object),
+ g_value_get_boolean (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+local_store_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_NEED_SUMMARY_CHECK:
+ g_value_set_boolean (
+ value,
+ camel_local_store_get_need_summary_check (
+ CAMEL_LOCAL_STORE (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
local_store_finalize (GObject *object)
{
CamelLocalStore *local_store = CAMEL_LOCAL_STORE (object);
@@ -532,7 +580,11 @@ camel_local_store_class_init (CamelLocalStoreClass *class)
CamelServiceClass *service_class;
CamelStoreClass *store_class;
+ g_type_class_add_private (class, sizeof (CamelLocalStorePrivate));
+
object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = local_store_set_property;
+ object_class->get_property = local_store_get_property;
object_class->finalize = local_store_finalize;
object_class->constructed = local_store_constructed;
@@ -553,11 +605,24 @@ camel_local_store_class_init (CamelLocalStoreClass *class)
class->get_full_path = local_store_get_full_path;
class->get_meta_path = local_store_get_meta_path;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_NEED_SUMMARY_CHECK,
+ g_param_spec_boolean (
+ "need-summary-check",
+ "Need Summary Check",
+ "Whether to check for unexpected file changes",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
}
static void
camel_local_store_init (CamelLocalStore *local_store)
{
+ local_store->priv = CAMEL_LOCAL_STORE_GET_PRIVATE (local_store);
}
const gchar *
@@ -626,3 +691,47 @@ camel_local_store_get_folder_type_by_full_name (CamelLocalStore *store,
return CAMEL_FOLDER_TYPE_NORMAL;
}
+
+/**
+ * camel_local_store_get_need_summary_check:
+ * @store: a #CamelLocalStore
+ *
+ * Returns whether local mail files for @store should be check for
+ * consistency and the summary database synchronized with them. This
+ * is necessary to handle another mail application altering the files,
+ * such as local mail delivery using fetchmail.
+ *
+ * Returns: whether to check for changes in local mail files
+ *
+ * Since: 3.2
+ **/
+gboolean
+camel_local_store_get_need_summary_check (CamelLocalStore *store)
+{
+ g_return_val_if_fail (CAMEL_IS_LOCAL_STORE (store), FALSE);
+
+ return store->priv->need_summary_check;
+}
+
+/**
+ * camel_local_store_set_need_summary_check:
+ * @store: a #CamelLocalStore
+ * @need_summary_check: whether to check for changes in local mail files
+ *
+ * Sets whether local mail files for @store should be checked for
+ * consistency and the summary database synchronized with them. This
+ * is necessary to handle another mail application altering the files,
+ * such as local mail delivery using fetchmail.
+ *
+ * Since: 3.2
+ **/
+void
+camel_local_store_set_need_summary_check (CamelLocalStore *store,
+ gboolean need_summary_check)
+{
+ g_return_if_fail (CAMEL_IS_LOCAL_STORE (store));
+
+ store->priv->need_summary_check = need_summary_check;
+
+ g_object_notify (G_OBJECT (store), "need-summary-check");
+}
diff --git a/camel/providers/local/camel-local-store.h b/camel/providers/local/camel-local-store.h
index c6effa0..000706d 100644
--- a/camel/providers/local/camel-local-store.h
+++ b/camel/providers/local/camel-local-store.h
@@ -80,6 +80,11 @@ gchar * camel_local_store_get_meta_path (CamelLocalStore *store,
guint32 camel_local_store_get_folder_type_by_full_name
(CamelLocalStore *store,
const gchar *full_name);
+gboolean camel_local_store_get_need_summary_check
+ (CamelLocalStore *store);
+void camel_local_store_set_need_summary_check
+ (CamelLocalStore *store,
+ gboolean need_summary_check);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]