diff options
Diffstat (limited to 'common/mail')
-rw-r--r-- | common/mail/fulltextindexer.cpp | 64 | ||||
-rw-r--r-- | common/mail/fulltextindexer.h | 39 | ||||
-rw-r--r-- | common/mail/threadindexer.cpp | 5 | ||||
-rw-r--r-- | common/mail/threadindexer.h | 1 |
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 | |||
26 | using namespace Sink; | ||
27 | using namespace Sink::ApplicationDomain; | ||
28 | |||
29 | |||
30 | void 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 | |||
38 | void 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 | |||
46 | void FulltextIndexer::commitTransaction() | ||
47 | { | ||
48 | if (index) { | ||
49 | index->commitTransaction(); | ||
50 | } | ||
51 | } | ||
52 | |||
53 | void FulltextIndexer::abortTransaction() | ||
54 | { | ||
55 | if (index) { | ||
56 | index->abortTransaction(); | ||
57 | } | ||
58 | } | ||
59 | |||
60 | QMap<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 | |||
23 | class FulltextIndex; | ||
24 | namespace Sink { | ||
25 | |||
26 | class FulltextIndexer : public Indexer | ||
27 | { | ||
28 | public: | ||
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(); | ||
35 | private: | ||
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 | ||
101 | void ThreadIndexer::modify(const ApplicationDomain::ApplicationDomainType &old, const ApplicationDomain::ApplicationDomainType &entity) | ||
102 | { | ||
103 | |||
104 | } | ||
105 | |||
106 | void ThreadIndexer::remove(const ApplicationDomain::ApplicationDomainType &entity) | 101 | void 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 | |||
27 | public: | 27 | public: |
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(); |
33 | private: | 32 | private: |