diff options
Diffstat (limited to 'common/specialpurposepreprocessor.cpp')
-rw-r--r-- | common/specialpurposepreprocessor.cpp | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/common/specialpurposepreprocessor.cpp b/common/specialpurposepreprocessor.cpp index b9ad94a..a6ee373 100644 --- a/common/specialpurposepreprocessor.cpp +++ b/common/specialpurposepreprocessor.cpp | |||
@@ -11,6 +11,8 @@ static QHash<QByteArray, QString> specialPurposeFolders() | |||
11 | { | 11 | { |
12 | QHash<QByteArray, QString> hash; | 12 | QHash<QByteArray, QString> hash; |
13 | //FIXME localize | 13 | //FIXME localize |
14 | //TODO inbox | ||
15 | //TODO use standardized values | ||
14 | hash.insert("drafts", "Drafts"); | 16 | hash.insert("drafts", "Drafts"); |
15 | hash.insert("trash", "Trash"); | 17 | hash.insert("trash", "Trash"); |
16 | hash.insert("inbox", "Inbox"); | 18 | hash.insert("inbox", "Inbox"); |
@@ -45,31 +47,31 @@ QByteArray getSpecialPurposeType(const QString &name) | |||
45 | 47 | ||
46 | SpecialPurposeProcessor::SpecialPurposeProcessor(const QByteArray &resourceType, const QByteArray &resourceInstanceIdentifier) : mResourceType(resourceType), mResourceInstanceIdentifier(resourceInstanceIdentifier) {} | 48 | SpecialPurposeProcessor::SpecialPurposeProcessor(const QByteArray &resourceType, const QByteArray &resourceInstanceIdentifier) : mResourceType(resourceType), mResourceInstanceIdentifier(resourceInstanceIdentifier) {} |
47 | 49 | ||
48 | QByteArray SpecialPurposeProcessor::ensureFolder(Sink::Storage::Transaction &transaction, const QByteArray &specialPurpose) | 50 | QByteArray SpecialPurposeProcessor::ensureFolder(Sink::Storage::DataStore::Transaction &transaction, const QByteArray &specialPurpose) |
49 | { | 51 | { |
50 | if (!mSpecialPurposeFolders.contains(specialPurpose)) { | 52 | /* if (!mSpecialPurposeFolders.contains(specialPurpose)) { */ |
51 | //Try to find an existing drafts folder | 53 | /* //Try to find an existing drafts folder */ |
52 | Sink::EntityReader<ApplicationDomain::Folder> reader(mResourceType, mResourceInstanceIdentifier, transaction); | 54 | /* Sink::EntityReader<ApplicationDomain::Folder> reader(mResourceType, mResourceInstanceIdentifier, transaction); */ |
53 | reader.query(Sink::Query().filter<ApplicationDomain::Folder::SpecialPurpose>(Query::Comparator(specialPurpose, Query::Comparator::Contains)), | 55 | /* reader.query(Sink::Query().filter<ApplicationDomain::Folder::SpecialPurpose>(Query::Comparator(specialPurpose, Query::Comparator::Contains)), */ |
54 | [this, specialPurpose](const ApplicationDomain::Folder &f) -> bool{ | 56 | /* [this, specialPurpose](const ApplicationDomain::Folder &f) -> bool{ */ |
55 | mSpecialPurposeFolders.insert(specialPurpose, f.identifier()); | 57 | /* mSpecialPurposeFolders.insert(specialPurpose, f.identifier()); */ |
56 | return false; | 58 | /* return false; */ |
57 | }); | 59 | /* }); */ |
58 | if (!mSpecialPurposeFolders.contains(specialPurpose)) { | 60 | /* if (!mSpecialPurposeFolders.contains(specialPurpose)) { */ |
59 | SinkTrace() << "Failed to find a drafts folder, creating a new one"; | 61 | /* SinkTrace() << "Failed to find a drafts folder, creating a new one"; */ |
60 | auto folder = ApplicationDomain::Folder::create(mResourceInstanceIdentifier); | 62 | /* auto folder = ApplicationDomain::Folder::create(mResourceInstanceIdentifier); */ |
61 | folder.setSpecialPurpose(QByteArrayList() << specialPurpose); | 63 | /* folder.setSpecialPurpose(QByteArrayList() << specialPurpose); */ |
62 | folder.setName(sSpecialPurposeFolders.value(specialPurpose)); | 64 | /* folder.setName(sSpecialPurposeFolders.value(specialPurpose)); */ |
63 | folder.setIcon("folder"); | 65 | /* folder.setIcon("folder"); */ |
64 | //This processes the pipeline synchronously | 66 | /* //This processes the pipeline synchronously */ |
65 | createEntity(folder); | 67 | /* createEntity(folder); */ |
66 | mSpecialPurposeFolders.insert(specialPurpose, folder.identifier()); | 68 | /* mSpecialPurposeFolders.insert(specialPurpose, folder.identifier()); */ |
67 | } | 69 | /* } */ |
68 | } | 70 | /* } */ |
69 | return mSpecialPurposeFolders.value(specialPurpose); | 71 | return mSpecialPurposeFolders.value(specialPurpose); |
70 | } | 72 | } |
71 | 73 | ||
72 | void SpecialPurposeProcessor::moveToFolder(Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) | 74 | void SpecialPurposeProcessor::moveToFolder(Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::DataStore::Transaction &transaction) |
73 | { | 75 | { |
74 | if (newEntity.getProperty("trash").toBool()) { | 76 | if (newEntity.getProperty("trash").toBool()) { |
75 | newEntity.setProperty("folder", ensureFolder(transaction, "trash")); | 77 | newEntity.setProperty("folder", ensureFolder(transaction, "trash")); |
@@ -80,12 +82,12 @@ void SpecialPurposeProcessor::moveToFolder(Sink::ApplicationDomain::BufferAdapto | |||
80 | } | 82 | } |
81 | } | 83 | } |
82 | 84 | ||
83 | void SpecialPurposeProcessor::newEntity(const QByteArray &uid, qint64 revision, Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) | 85 | void SpecialPurposeProcessor::newEntity(const QByteArray &uid, qint64 revision, Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::DataStore::Transaction &transaction) |
84 | { | 86 | { |
85 | moveToFolder(newEntity, transaction); | 87 | moveToFolder(newEntity, transaction); |
86 | } | 88 | } |
87 | 89 | ||
88 | void SpecialPurposeProcessor::modifiedEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) | 90 | void SpecialPurposeProcessor::modifiedEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::DataStore::Transaction &transaction) |
89 | { | 91 | { |
90 | moveToFolder(newEntity, transaction); | 92 | moveToFolder(newEntity, transaction); |
91 | } | 93 | } |