[geary/mjog/search-update: 39/53] Geary.ImapDb.SearchQuery: Rename to Geary.FtsSearchQuery
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/search-update: 39/53] Geary.ImapDb.SearchQuery: Rename to Geary.FtsSearchQuery
- Date: Thu, 14 Jan 2021 10:29:37 +0000 (UTC)
commit 4fbc00f6a9c3858abba73cb8115d1259ba0873d3
Author: Michael Gratton <mike vee net>
Date: Thu Nov 5 00:21:39 2020 +1100
Geary.ImapDb.SearchQuery: Rename to Geary.FtsSearchQuery
There's nothing IMAP-specific about the class, so move it to common
and rename to reflect what it is actually used for.
po/POTFILES.in | 2 +-
.../common-fts-search-query.vala} | 10 +++++-----
src/engine/imap-db/imap-db-account.vala | 10 +++++-----
.../imap-engine/imap-engine-generic-account.vala | 2 +-
src/engine/meson.build | 2 +-
.../common-fts-search-query-test.vala} | 19 ++++++++++---------
test/meson.build | 2 +-
test/test-engine.vala | 4 +++-
8 files changed, 27 insertions(+), 24 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f66a91f25..109bfc924 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -211,6 +211,7 @@ src/engine/app/email-store/app-mark-operation.vala
src/engine/common/common-contact-harvester.vala
src/engine/common/common-contact-store-impl.vala
src/engine/common/common-message-data.vala
+src/engine/common/common-fts-search-query.vala
src/engine/db/db.vala
src/engine/db/db-connection.vala
src/engine/db/db-context.vala
@@ -269,7 +270,6 @@ src/engine/imap-db/imap-db-email-identifier.vala
src/engine/imap-db/imap-db-folder.vala
src/engine/imap-db/imap-db-gc.vala
src/engine/imap-db/imap-db-message-row.vala
-src/engine/imap-db/imap-db-search-query.vala
src/engine/imap-engine/gmail/imap-engine-gmail-account.vala
src/engine/imap-engine/gmail/imap-engine-gmail-all-mail-folder.vala
src/engine/imap-engine/gmail/imap-engine-gmail-drafts-folder.vala
diff --git a/src/engine/imap-db/imap-db-search-query.vala b/src/engine/common/common-fts-search-query.vala
similarity index 98%
rename from src/engine/imap-db/imap-db-search-query.vala
rename to src/engine/common/common-fts-search-query.vala
index 0ebbf21ed..a24c16dc2 100644
--- a/src/engine/imap-db/imap-db-search-query.vala
+++ b/src/engine/common/common-fts-search-query.vala
@@ -7,9 +7,9 @@
*/
/**
- * Internal implementation of {@link Geary.SearchQuery}.
+ * A search query implementation that provides full-text search.
*/
-private class Geary.ImapDB.SearchQuery : Geary.SearchQuery {
+internal class Geary.FtsSearchQuery : Geary.SearchQuery {
private const string EMAIL_TEXT_STEMMED_TERMS = "geary-stemmed-terms";
@@ -22,9 +22,9 @@ private class Geary.ImapDB.SearchQuery : Geary.SearchQuery {
private unowned SnowBall.Stemmer stemmer;
- public SearchQuery(Gee.List<Term> expression,
- string raw,
- SnowBall.Stemmer stemmer) {
+ public FtsSearchQuery(Gee.List<Term> expression,
+ string raw,
+ SnowBall.Stemmer stemmer) {
base(expression, raw);
this.stemmer = stemmer;
diff --git a/src/engine/imap-db/imap-db-account.vala b/src/engine/imap-db/imap-db-account.vala
index 081281e7b..fecb1867c 100644
--- a/src/engine/imap-db/imap-db-account.vala
+++ b/src/engine/imap-db/imap-db-account.vala
@@ -585,7 +585,7 @@ private class Geary.ImapDB.Account : BaseObject {
debug("Search query: %s", q.to_string());
check_open();
- ImapDB.SearchQuery query = check_search_query(q);
+ FtsSearchQuery query = check_search_query(q);
// Do this outside of transaction to catch invalid search ids up-front
string? search_ids_sql = get_search_ids_sql(search_ids);
@@ -696,7 +696,7 @@ private class Geary.ImapDB.Account : BaseObject {
public async Gee.Set<string>? get_search_matches_async(Geary.SearchQuery q,
Gee.Collection<ImapDB.EmailIdentifier> ids, Cancellable? cancellable = null) throws Error {
check_open();
- ImapDB.SearchQuery query = check_search_query(q);
+ FtsSearchQuery query = check_search_query(q);
Gee.Set<string>? search_matches = null;
yield db.exec_transaction_async(Db.TransactionType.RO, (cx) => {
@@ -1223,7 +1223,7 @@ private class Geary.ImapDB.Account : BaseObject {
// not per key-value
public Gee.Map<ImapDB.EmailIdentifier, Gee.Set<string>> do_get_search_matches(
Db.Connection cx,
- ImapDB.SearchQuery query,
+ FtsSearchQuery query,
Gee.Map<int64?, ImapDB.EmailIdentifier> id_map,
GLib.Cancellable? cancellable
) throws GLib.Error {
@@ -1327,8 +1327,8 @@ private class Geary.ImapDB.Account : BaseObject {
}
}
- private ImapDB.SearchQuery check_search_query(Geary.SearchQuery q) throws Error {
- ImapDB.SearchQuery? query = q as ImapDB.SearchQuery;
+ private FtsSearchQuery check_search_query(Geary.SearchQuery q) throws Error {
+ var query = q as FtsSearchQuery;
if (query == null) {
throw new EngineError.BAD_PARAMETERS("Geary.SearchQuery not associated with %s", name);
}
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala
b/src/engine/imap-engine/imap-engine-generic-account.vala
index fb5ab4d9b..68ed4efcf 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -580,7 +580,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
string text,
GLib.Cancellable? cancellable
) throws GLib.Error {
- return new ImapDB.SearchQuery(expression, text, this.stemmer);
+ return new FtsSearchQuery(expression, text, this.stemmer);
}
public override async Gee.MultiMap<Geary.Email, Geary.FolderPath?>? local_search_message_id_async(
diff --git a/src/engine/meson.build b/src/engine/meson.build
index 1e9eecf17..b3727861d 100644
--- a/src/engine/meson.build
+++ b/src/engine/meson.build
@@ -67,6 +67,7 @@ engine_vala_sources = files(
'common/common-contact-harvester.vala',
'common/common-contact-store-impl.vala',
+ 'common/common-fts-search-query.vala',
'common/common-message-data.vala',
'db/db.vala',
@@ -179,7 +180,6 @@ engine_vala_sources = files(
'imap-db/imap-db-fts5-matches.c',
'imap-db/imap-db-gc.vala',
'imap-db/imap-db-message-row.vala',
- 'imap-db/imap-db-search-query.vala',
'imap-db/imap-db-sqlite.c',
'imap-engine/imap-engine.vala',
diff --git a/test/engine/imap-db/imap-db-search-query-test.vala
b/test/engine/common/common-fts-search-query-test.vala
similarity index 92%
rename from test/engine/imap-db/imap-db-search-query-test.vala
rename to test/engine/common/common-fts-search-query-test.vala
index 4813fefaf..b575f5434 100644
--- a/test/engine/imap-db/imap-db-search-query-test.vala
+++ b/test/engine/common/common-fts-search-query-test.vala
@@ -5,17 +5,17 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-public class Geary.ImapDB.SearchQueryTest : TestCase {
+public class Geary.FtsSearchQueryTest : TestCase {
private GLib.File? tmp_dir = null;
private Geary.AccountInformation? config = null;
- private Account? account = null;
+ private ImapDB.Account? account = null;
private SnowBall.Stemmer? stemmer = null;
- public SearchQueryTest() {
- base("Geary.ImapDB.SearchQueryTest");
+ public FtsSearchQueryTest() {
+ base("Geary.FtsSearchQueryTest");
add_test("email_text_terms", email_text_terms);
add_test("email_text_terms_stemmed", email_text_terms_stemmed);
add_test("email_text_terms_specific", email_text_terms_specific);
@@ -25,7 +25,7 @@ public class Geary.ImapDB.SearchQueryTest : TestCase {
public override void set_up() throws GLib.Error {
this.tmp_dir = GLib.File.new_for_path(
- GLib.DirUtils.make_tmp("geary-imap-db-search-query-test-XXXXXX")
+ GLib.DirUtils.make_tmp("geary-common-fts-search-query-test-XXXXXX")
);
this.config = new Geary.AccountInformation(
@@ -35,7 +35,7 @@ public class Geary.ImapDB.SearchQueryTest : TestCase {
new Geary.RFC822.MailboxAddress(null, "test example com")
);
- this.account = new Account(
+ this.account = new ImapDB.Account(
config,
this.tmp_dir,
GLib.File.new_for_path(_SOURCE_ROOT_DIR).get_child("sql")
@@ -212,16 +212,17 @@ public class Geary.ImapDB.SearchQueryTest : TestCase {
search_with_both.exec(null);
}
- private SearchQuery new_search_query(Geary.SearchQuery.Term[] ops, string raw)
+ private FtsSearchQuery new_search_query(Geary.SearchQuery.Term[] ops,
+ string raw)
throws GLib.Error {
- return new SearchQuery(
+ return new FtsSearchQuery(
new Gee.ArrayList<Geary.SearchQuery.Term>.wrap(ops),
raw,
this.stemmer
);
}
- private void assert_queries(SearchQuery query) throws GLib.Error {
+ private void assert_queries(FtsSearchQuery query) throws GLib.Error {
var search = query.get_search_query(
this.account.db.get_primary_connection(),
null,
diff --git a/test/meson.build b/test/meson.build
index d4359f64b..a4fe2c292 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -36,6 +36,7 @@ test_engine_sources = [
'engine/app/app-conversation-set-test.vala',
'engine/common/common-contact-store-impl-test.vala',
'engine/common/common-contact-harvester-test.vala',
+ 'engine/common/common-fts-search-query-test.vala',
'engine/db/db-database-test.vala',
'engine/db/db-versioned-database-test.vala',
'engine/imap/command/imap-create-command-test.vala',
@@ -53,7 +54,6 @@ test_engine_sources = [
'engine/imap-db/imap-db-database-test.vala',
'engine/imap-db/imap-db-email-identifier-test.vala',
'engine/imap-db/imap-db-folder-test.vala',
- 'engine/imap-db/imap-db-search-query-test.vala',
'engine/imap-engine/account-processor-test.vala',
'engine/imap-engine/imap-engine-generic-account-test.vala',
'engine/mime/mime-content-type-test.vala',
diff --git a/test/test-engine.vala b/test/test-engine.vala
index a86ee94c1..e829b0bf5 100644
--- a/test/test-engine.vala
+++ b/test/test-engine.vala
@@ -72,7 +72,9 @@ int main(string[] args) {
engine.add_suite(new Geary.ImapDB.DatabaseTest().suite);
engine.add_suite(new Geary.ImapDB.EmailIdentifierTest().suite);
engine.add_suite(new Geary.ImapDB.FolderTest().suite);
- engine.add_suite(new Geary.ImapDB.SearchQueryTest().suite);
+
+ // Depends on ImapDB working
+ engine.add_suite(new Geary.FtsSearchQueryTest().suite);
engine.add_suite(new Geary.ImapEngine.AccountProcessorTest().suite);
engine.add_suite(new Geary.ImapEngine.GenericAccountTest().suite);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]