From dea26471d0da17addba2d906d65ac3b1cbfe7fbd Mon Sep 17 00:00:00 2001 From: djcb Date: Wed, 20 Jun 2012 20:33:58 +0300 Subject: [PATCH] * fix _MuStore initialization; proliferate API change --- lib/mu-store-priv.hh | 12 ++++-------- lib/mu-store-write.cc | 4 ++-- lib/mu-store.h | 4 +--- lib/tests/test-mu-store.c | 8 ++++---- mu/mu-cmd.c | 13 ++++++------- 5 files changed, 17 insertions(+), 24 deletions(-) diff --git a/lib/mu-store-priv.hh b/lib/mu-store-priv.hh index fc03eb71..947b9599 100644 --- a/lib/mu-store-priv.hh +++ b/lib/mu-store-priv.hh @@ -50,10 +50,9 @@ struct _MuStore { public: /* create a read-write MuStore */ _MuStore (const char *path, const char *contacts_path, - const char **my_addresses, - bool rebuild) :_my_addresses(NULL) { + bool rebuild) { - init (path, contacts_path, my_addresses, rebuild, false); + init (path, contacts_path, rebuild, false); if (rebuild) _db = new Xapian::WritableDatabase @@ -78,7 +77,7 @@ public: /* create a read-only MuStore */ _MuStore (const char *path) { - init (path, NULL, NULL, false, false); + init (path, NULL, false, false); _db = new Xapian::Database (path); if (mu_store_needs_upgrade(this)) @@ -89,9 +88,9 @@ public: } void init (const char *path, const char *contacts_path, - const char **my_addresses, bool rebuild, bool read_only) { + _my_addresses = NULL; _batch_size = DEFAULT_BATCH_SIZE; _contacts = 0; _in_transaction = false; @@ -100,8 +99,6 @@ public: _read_only = read_only; _ref_count = 1; _version = NULL; - - set_my_addresses (my_addresses); } void set_my_addresses (const char **my_addresses) { @@ -118,7 +115,6 @@ public: } } - void check_set_version () { /* check version...*/ gchar *version; diff --git a/lib/mu-store-write.cc b/lib/mu-store-write.cc index 38068d25..216d88e4 100644 --- a/lib/mu-store-write.cc +++ b/lib/mu-store-write.cc @@ -123,14 +123,14 @@ add_synonyms (MuStore *store) MuStore* mu_store_new_writable (const char* xpath, const char *contacts_cache, - const char **my_addresses, gboolean rebuild, GError **err) + gboolean rebuild, GError **err) { g_return_val_if_fail (xpath, NULL); try { try { MuStore *store; - store = new _MuStore (xpath, contacts_cache, my_addresses, + store = new _MuStore (xpath, contacts_cache, rebuild ? true : false); add_synonyms (store); return store; diff --git a/lib/mu-store.h b/lib/mu-store.h index c975363a..a28e6a7f 100644 --- a/lib/mu-store.h +++ b/lib/mu-store.h @@ -36,15 +36,13 @@ typedef struct _MuStore MuStore; * * @param path the path to the database * @param ccachepath path where to cache the contacts information, or NULL - * @param my_addresses, array of strings with regexps for my e-mail addresses (or NULL) - * (used for the contactac information) * @param err to receive error info or NULL. err->code is MuError value * * @return a new MuStore object with ref count == 1, or NULL in case * of error; free with mu_store_unref */ MuStore* mu_store_new_writable (const char *xpath, - const char *ccachepath, const char **my_addresses, + const char *ccachepath, gboolean rebuild, GError **err) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; diff --git a/lib/tests/test-mu-store.c b/lib/tests/test-mu-store.c index 510608a9..6b15bf0a 100644 --- a/lib/tests/test-mu-store.c +++ b/lib/tests/test-mu-store.c @@ -44,7 +44,7 @@ test_mu_store_new_destroy (void) g_assert (tmpdir); err = NULL; - store = mu_store_new_writable (tmpdir, NULL, NULL, FALSE, &err); + store = mu_store_new_writable (tmpdir, NULL, FALSE, &err); g_assert (store); g_assert (err == NULL); @@ -68,7 +68,7 @@ test_mu_store_version (void) g_assert (tmpdir); err = NULL; - store = mu_store_new_writable (tmpdir, NULL, NULL, FALSE, &err); + store = mu_store_new_writable (tmpdir, NULL, FALSE, &err); g_assert (store); mu_store_unref (store); store = mu_store_new_read_only (tmpdir, &err); @@ -95,7 +95,7 @@ test_mu_store_store_msg_and_count (void) tmpdir = test_mu_common_get_random_tmpdir(); g_assert (tmpdir); - store = mu_store_new_writable (tmpdir, NULL, NULL, FALSE, NULL); + store = mu_store_new_writable (tmpdir, NULL, FALSE, NULL); g_assert (store); g_assert_cmpuint (0,==,mu_store_count (store, NULL)); @@ -151,7 +151,7 @@ test_mu_store_store_msg_remove_and_count (void) tmpdir = test_mu_common_get_random_tmpdir(); g_assert (tmpdir); - store = mu_store_new_writable (tmpdir, NULL, NULL, FALSE, NULL); + store = mu_store_new_writable (tmpdir, NULL, FALSE, NULL); g_assert (store); g_assert_cmpuint (0,==,mu_store_count (store, NULL)); diff --git a/mu/mu-cmd.c b/mu/mu-cmd.c index a2c6715e..f1169db2 100644 --- a/mu/mu-cmd.c +++ b/mu/mu-cmd.c @@ -415,6 +415,7 @@ with_store (store_func func, MuConfig *opts, gboolean read_only, GError **err) { MuStore *store; + MuError merr; if (read_only) store = mu_store_new_read_only @@ -424,16 +425,14 @@ with_store (store_func func, MuConfig *opts, gboolean read_only, store = mu_store_new_writable (mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB), mu_runtime_path(MU_RUNTIME_PATH_CONTACTS), - (const char**)opts->my_addresses, opts->rebuild, err); if (!store) return MU_G_ERROR_CODE(err); - else { - MuError merr; - merr = func (store, opts, err); - mu_store_unref (store); - return merr; - } + + mu_store_set_my_addresses (store, (const char**)opts->my_addresses); + merr = func (store, opts, err); + mu_store_unref (store); + return merr; }