* fix _MuStore initialization; proliferate API change
This commit is contained in:
@ -50,10 +50,9 @@ struct _MuStore {
|
|||||||
public:
|
public:
|
||||||
/* create a read-write MuStore */
|
/* create a read-write MuStore */
|
||||||
_MuStore (const char *path, const char *contacts_path,
|
_MuStore (const char *path, const char *contacts_path,
|
||||||
const char **my_addresses,
|
bool rebuild) {
|
||||||
bool rebuild) :_my_addresses(NULL) {
|
|
||||||
|
|
||||||
init (path, contacts_path, my_addresses, rebuild, false);
|
init (path, contacts_path, rebuild, false);
|
||||||
|
|
||||||
if (rebuild)
|
if (rebuild)
|
||||||
_db = new Xapian::WritableDatabase
|
_db = new Xapian::WritableDatabase
|
||||||
@ -78,7 +77,7 @@ public:
|
|||||||
/* create a read-only MuStore */
|
/* create a read-only MuStore */
|
||||||
_MuStore (const char *path) {
|
_MuStore (const char *path) {
|
||||||
|
|
||||||
init (path, NULL, NULL, false, false);
|
init (path, NULL, false, false);
|
||||||
|
|
||||||
_db = new Xapian::Database (path);
|
_db = new Xapian::Database (path);
|
||||||
if (mu_store_needs_upgrade(this))
|
if (mu_store_needs_upgrade(this))
|
||||||
@ -89,9 +88,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void init (const char *path, const char *contacts_path,
|
void init (const char *path, const char *contacts_path,
|
||||||
const char **my_addresses,
|
|
||||||
bool rebuild, bool read_only) {
|
bool rebuild, bool read_only) {
|
||||||
|
|
||||||
|
_my_addresses = NULL;
|
||||||
_batch_size = DEFAULT_BATCH_SIZE;
|
_batch_size = DEFAULT_BATCH_SIZE;
|
||||||
_contacts = 0;
|
_contacts = 0;
|
||||||
_in_transaction = false;
|
_in_transaction = false;
|
||||||
@ -100,8 +99,6 @@ public:
|
|||||||
_read_only = read_only;
|
_read_only = read_only;
|
||||||
_ref_count = 1;
|
_ref_count = 1;
|
||||||
_version = NULL;
|
_version = NULL;
|
||||||
|
|
||||||
set_my_addresses (my_addresses);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_my_addresses (const char **my_addresses) {
|
void set_my_addresses (const char **my_addresses) {
|
||||||
@ -118,7 +115,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void check_set_version () {
|
void check_set_version () {
|
||||||
/* check version...*/
|
/* check version...*/
|
||||||
gchar *version;
|
gchar *version;
|
||||||
|
|||||||
@ -123,14 +123,14 @@ add_synonyms (MuStore *store)
|
|||||||
|
|
||||||
MuStore*
|
MuStore*
|
||||||
mu_store_new_writable (const char* xpath, const char *contacts_cache,
|
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);
|
g_return_val_if_fail (xpath, NULL);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
MuStore *store;
|
MuStore *store;
|
||||||
store = new _MuStore (xpath, contacts_cache, my_addresses,
|
store = new _MuStore (xpath, contacts_cache,
|
||||||
rebuild ? true : false);
|
rebuild ? true : false);
|
||||||
add_synonyms (store);
|
add_synonyms (store);
|
||||||
return store;
|
return store;
|
||||||
|
|||||||
@ -36,15 +36,13 @@ typedef struct _MuStore MuStore;
|
|||||||
*
|
*
|
||||||
* @param path the path to the database
|
* @param path the path to the database
|
||||||
* @param ccachepath path where to cache the contacts information, or NULL
|
* @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
|
* @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
|
* @return a new MuStore object with ref count == 1, or NULL in case
|
||||||
* of error; free with mu_store_unref
|
* of error; free with mu_store_unref
|
||||||
*/
|
*/
|
||||||
MuStore* mu_store_new_writable (const char *xpath,
|
MuStore* mu_store_new_writable (const char *xpath,
|
||||||
const char *ccachepath, const char **my_addresses,
|
const char *ccachepath,
|
||||||
gboolean rebuild, GError **err)
|
gboolean rebuild, GError **err)
|
||||||
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,7 @@ test_mu_store_new_destroy (void)
|
|||||||
g_assert (tmpdir);
|
g_assert (tmpdir);
|
||||||
|
|
||||||
err = NULL;
|
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 (store);
|
||||||
g_assert (err == NULL);
|
g_assert (err == NULL);
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ test_mu_store_version (void)
|
|||||||
g_assert (tmpdir);
|
g_assert (tmpdir);
|
||||||
|
|
||||||
err = NULL;
|
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 (store);
|
||||||
mu_store_unref (store);
|
mu_store_unref (store);
|
||||||
store = mu_store_new_read_only (tmpdir, &err);
|
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();
|
tmpdir = test_mu_common_get_random_tmpdir();
|
||||||
g_assert (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 (store);
|
||||||
|
|
||||||
g_assert_cmpuint (0,==,mu_store_count (store, NULL));
|
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();
|
tmpdir = test_mu_common_get_random_tmpdir();
|
||||||
g_assert (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 (store);
|
||||||
|
|
||||||
g_assert_cmpuint (0,==,mu_store_count (store, NULL));
|
g_assert_cmpuint (0,==,mu_store_count (store, NULL));
|
||||||
|
|||||||
@ -415,6 +415,7 @@ with_store (store_func func, MuConfig *opts, gboolean read_only,
|
|||||||
GError **err)
|
GError **err)
|
||||||
{
|
{
|
||||||
MuStore *store;
|
MuStore *store;
|
||||||
|
MuError merr;
|
||||||
|
|
||||||
if (read_only)
|
if (read_only)
|
||||||
store = mu_store_new_read_only
|
store = mu_store_new_read_only
|
||||||
@ -424,17 +425,15 @@ with_store (store_func func, MuConfig *opts, gboolean read_only,
|
|||||||
store = mu_store_new_writable
|
store = mu_store_new_writable
|
||||||
(mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB),
|
(mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB),
|
||||||
mu_runtime_path(MU_RUNTIME_PATH_CONTACTS),
|
mu_runtime_path(MU_RUNTIME_PATH_CONTACTS),
|
||||||
(const char**)opts->my_addresses,
|
|
||||||
opts->rebuild, err);
|
opts->rebuild, err);
|
||||||
if (!store)
|
if (!store)
|
||||||
return MU_G_ERROR_CODE(err);
|
return MU_G_ERROR_CODE(err);
|
||||||
else {
|
|
||||||
MuError merr;
|
mu_store_set_my_addresses (store, (const char**)opts->my_addresses);
|
||||||
merr = func (store, opts, err);
|
merr = func (store, opts, err);
|
||||||
mu_store_unref (store);
|
mu_store_unref (store);
|
||||||
return merr;
|
return merr;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
|||||||
Reference in New Issue
Block a user