summaryrefslogtreecommitdiffstats
path: root/common/mail
diff options
context:
space:
mode:
Diffstat (limited to 'common/mail')
-rw-r--r--common/mail/fulltextindexer.cpp64
-rw-r--r--common/mail/fulltextindexer.h39
-rw-r--r--common/mail/threadindexer.cpp5
-rw-r--r--common/mail/threadindexer.h1
4 files changed, 103 insertions, 6 deletions
diff --git a/common/mail/fulltextindexer.cpp b/common/mail/fulltextindexer.cpp
new file mode 100644
index 0000000..a980752
--- /dev/null
+++ b/common/mail/fulltextindexer.cpp
@@ -0,0 +1,64 @@
1/*
2 * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastmail.fm>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19#include "fulltextindexer.h"
20
21#include "typeindex.h"
22#include "fulltextindex.h"
23#include "log.h"
24#include "utils.h"
25
26using namespace Sink;
27using namespace Sink::ApplicationDomain;
28
29
30void FulltextIndexer::add(const ApplicationDomain::ApplicationDomainType &entity)
31{
32 if (!index) {
33 index.reset(new FulltextIndex{mResourceInstanceIdentifier, Storage::DataStore::ReadWrite});
34 }
35 index->add(entity.identifier(), entity.getProperty("index").value<QList<QPair<QString, QString>>>());
36}
37
38void FulltextIndexer::remove(const ApplicationDomain::ApplicationDomainType &entity)
39{
40 if (!index) {
41 index.reset(new FulltextIndex{mResourceInstanceIdentifier, Storage::DataStore::ReadWrite});
42 }
43 index->remove(entity.identifier());
44}
45
46void FulltextIndexer::commitTransaction()
47{
48 if (index) {
49 index->commitTransaction();
50 }
51}
52
53void FulltextIndexer::abortTransaction()
54{
55 if (index) {
56 index->abortTransaction();
57 }
58}
59
60QMap<QByteArray, int> FulltextIndexer::databases()
61{
62 return {};
63}
64
diff --git a/common/mail/fulltextindexer.h b/common/mail/fulltextindexer.h
new file mode 100644
index 0000000..ef41455
--- /dev/null
+++ b/common/mail/fulltextindexer.h
@@ -0,0 +1,39 @@
1/*
2 * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastmail.fm>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19#pragma once
20
21#include "indexer.h"
22
23class FulltextIndex;
24namespace Sink {
25
26class FulltextIndexer : public Indexer
27{
28public:
29 typedef QSharedPointer<FulltextIndexer> Ptr;
30 virtual void add(const ApplicationDomain::ApplicationDomainType &entity) Q_DECL_OVERRIDE;
31 virtual void remove(const ApplicationDomain::ApplicationDomainType &entity) Q_DECL_OVERRIDE;
32 virtual void commitTransaction() Q_DECL_OVERRIDE;
33 virtual void abortTransaction() Q_DECL_OVERRIDE;
34 static QMap<QByteArray, int> databases();
35private:
36 QSharedPointer<FulltextIndex> index;
37};
38
39}
diff --git a/common/mail/threadindexer.cpp b/common/mail/threadindexer.cpp
index 2e6a6e7..fb47118 100644
--- a/common/mail/threadindexer.cpp
+++ b/common/mail/threadindexer.cpp
@@ -98,11 +98,6 @@ void ThreadIndexer::add(const ApplicationDomain::ApplicationDomainType &entity)
98 updateThreadingIndex(entity.identifier(), entity, transaction()); 98 updateThreadingIndex(entity.identifier(), entity, transaction());
99} 99}
100 100
101void ThreadIndexer::modify(const ApplicationDomain::ApplicationDomainType &old, const ApplicationDomain::ApplicationDomainType &entity)
102{
103
104}
105
106void ThreadIndexer::remove(const ApplicationDomain::ApplicationDomainType &entity) 101void ThreadIndexer::remove(const ApplicationDomain::ApplicationDomainType &entity)
107{ 102{
108 auto messageId = entity.getProperty(Mail::MessageId::name); 103 auto messageId = entity.getProperty(Mail::MessageId::name);
diff --git a/common/mail/threadindexer.h b/common/mail/threadindexer.h
index 60d0863..b2e939a 100644
--- a/common/mail/threadindexer.h
+++ b/common/mail/threadindexer.h
@@ -27,7 +27,6 @@ class ThreadIndexer : public Indexer
27public: 27public:
28 typedef QSharedPointer<ThreadIndexer> Ptr; 28 typedef QSharedPointer<ThreadIndexer> Ptr;
29 virtual void add(const ApplicationDomain::ApplicationDomainType &entity) Q_DECL_OVERRIDE; 29 virtual void add(const ApplicationDomain::ApplicationDomainType &entity) Q_DECL_OVERRIDE;
30 virtual void modify(const ApplicationDomain::ApplicationDomainType &old, const ApplicationDomain::ApplicationDomainType &entity) Q_DECL_OVERRIDE;
31 virtual void remove(const ApplicationDomain::ApplicationDomainType &entity) Q_DECL_OVERRIDE; 30 virtual void remove(const ApplicationDomain::ApplicationDomainType &entity) Q_DECL_OVERRIDE;
32 static QMap<QByteArray, int> databases(); 31 static QMap<QByteArray, int> databases();
33private: 32private: