summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-09-08 22:28:38 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-09-08 22:28:38 +0200
commitd5526368825c5bbfe204d08d5de3d2069976596d (patch)
tree55d1b8306dab41d8a657f4daadd8735dcd38c3cd
parentbbbda3fe9444eba6795a5490da0425cdf8f26361 (diff)
downloadsink-d5526368825c5bbfe204d08d5de3d2069976596d.tar.gz
sink-d5526368825c5bbfe204d08d5de3d2069976596d.zip
A folder dummy folder facade and a folder property for mails.
Mails in inbox!
-rw-r--r--common/domain/mail.cpp3
-rw-r--r--common/domain/mail.fbs1
-rw-r--r--examples/dummyresource/facade.cpp23
-rw-r--r--examples/dummyresource/facade.h11
-rw-r--r--examples/dummyresource/resourcefactory.cpp16
5 files changed, 48 insertions, 6 deletions
diff --git a/common/domain/mail.cpp b/common/domain/mail.cpp
index c52bfe0..230ef31 100644
--- a/common/domain/mail.cpp
+++ b/common/domain/mail.cpp
@@ -83,6 +83,9 @@ QSharedPointer<ReadPropertyMapper<TypeImplementation<Mail>::Buffer> > TypeImplem
83 propertyMapper->addMapping("important", [](Buffer const *buffer) -> QVariant { 83 propertyMapper->addMapping("important", [](Buffer const *buffer) -> QVariant {
84 return propertyToVariant<bool>(buffer->important()); 84 return propertyToVariant<bool>(buffer->important());
85 }); 85 });
86 propertyMapper->addMapping("folder", [](Buffer const *buffer) -> QVariant {
87 return propertyToVariant<QString>(buffer->folder());
88 });
86 return propertyMapper; 89 return propertyMapper;
87} 90}
88 91
diff --git a/common/domain/mail.fbs b/common/domain/mail.fbs
index 654f49c..13aa36d 100644
--- a/common/domain/mail.fbs
+++ b/common/domain/mail.fbs
@@ -2,6 +2,7 @@ namespace Akonadi2.ApplicationDomain.Buffer;
2 2
3table Mail { 3table Mail {
4 uid:string; 4 uid:string;
5 folder:string;
5 sender:string; 6 sender:string;
6 senderName:string; 7 senderName:string;
7 subject:string; 8 subject:string;
diff --git a/examples/dummyresource/facade.cpp b/examples/dummyresource/facade.cpp
index 63f84f2..5a9d722 100644
--- a/examples/dummyresource/facade.cpp
+++ b/examples/dummyresource/facade.cpp
@@ -38,3 +38,26 @@ DummyResourceMailFacade::DummyResourceMailFacade(const QByteArray &instanceIdent
38DummyResourceMailFacade::~DummyResourceMailFacade() 38DummyResourceMailFacade::~DummyResourceMailFacade()
39{ 39{
40} 40}
41
42static void addFolder(const QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Folder::Ptr> > &resultProvider, QByteArray uid, QString name, QString icon)
43{
44 auto folder = Akonadi2::ApplicationDomain::Folder::Ptr::create();
45 folder->setProperty("name", name);
46 folder->setProperty("uid", uid);
47 resultProvider->add(folder);
48}
49
50KAsync::Job<void> load(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Folder::Ptr> > &resultProvider)
51{
52 //Dummy implementation for a fixed set of folders
53 addFolder(resultProvider, "inbox", "INBOX", "mail-folder-inbox");
54 addFolder(resultProvider, "sent", "Sent", "mail-folder-sent");
55 addFolder(resultProvider, "trash", "Trash", "user-trash");
56 addFolder(resultProvider, "drafts", "Drafts", "document-edit");
57 addFolder(resultProvider, "1", "dragons", "folder");
58 addFolder(resultProvider, "1", "super mega long tailed dragons", "folder");
59 resultProvider->initialResultSetComplete();
60 resultProvider->complete();
61 return KAsync::null<void>();
62}
63
diff --git a/examples/dummyresource/facade.h b/examples/dummyresource/facade.h
index 87f68c3..948116b 100644
--- a/examples/dummyresource/facade.h
+++ b/examples/dummyresource/facade.h
@@ -35,3 +35,14 @@ public:
35 DummyResourceMailFacade(const QByteArray &instanceIdentifier); 35 DummyResourceMailFacade(const QByteArray &instanceIdentifier);
36 virtual ~DummyResourceMailFacade(); 36 virtual ~DummyResourceMailFacade();
37}; 37};
38
39class DummyResourceFolderFacade : public Akonadi2::StoreFacade<Akonadi2::ApplicationDomain::Folder>
40{
41public:
42 DummyResourceFolderFacade(const QByteArray &instanceIdentifier);
43 virtual ~DummyResourceFolderFacade();
44 virtual KAsync::Job<void> create(const Akonadi2::ApplicationDomain::Folder &domainObject) { return KAsync::null<void>(); };
45 virtual KAsync::Job<void> modify(const Akonadi2::ApplicationDomain::Folder &domainObject) { return KAsync::null<void>(); };
46 virtual KAsync::Job<void> remove(const Akonadi2::ApplicationDomain::Folder &domainObject) { return KAsync::null<void>(); };
47 virtual KAsync::Job<void> load(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Folder::Ptr> > &resultProvider);
48};
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp
index 8d605b9..147cb22 100644
--- a/examples/dummyresource/resourcefactory.cpp
+++ b/examples/dummyresource/resourcefactory.cpp
@@ -109,15 +109,19 @@ void DummyResource::createMail(const QByteArray &ridBuffer, const QByteArray &da
109 //Map the source format to the buffer format (which happens to be an exact copy here) 109 //Map the source format to the buffer format (which happens to be an exact copy here)
110 auto subject = m_fbb.CreateString(mailBuffer->subject()->c_str()); 110 auto subject = m_fbb.CreateString(mailBuffer->subject()->c_str());
111 auto rid = m_fbb.CreateString(std::string(ridBuffer.constData(), ridBuffer.size())); 111 auto rid = m_fbb.CreateString(std::string(ridBuffer.constData(), ridBuffer.size()));
112 // auto description = m_fbb.CreateString(std::string(ridBuffer.constData(), ridBuffer.size())); 112 auto sender = m_fbb.CreateString(std::string("sender@example.org"));
113 // static uint8_t rawData[100]; 113 auto senderName = m_fbb.CreateString(std::string("Sender Name"));
114 // auto attachment = Akonadi2::EntityBuffer::appendAsVector(m_fbb, rawData, 100); 114 auto date = m_fbb.CreateString(std::string("2004"));
115 auto folder = m_fbb.CreateString(std::string("inbox"));
115 116
116 auto builder = Akonadi2::ApplicationDomain::Buffer::MailBuilder(m_fbb); 117 auto builder = Akonadi2::ApplicationDomain::Buffer::MailBuilder(m_fbb);
117 builder.add_subject(subject); 118 builder.add_subject(subject);
118 // builder.add(rid); 119 builder.add_sender(sender);
119 // builder.add_description(description); 120 builder.add_senderName(senderName);
120 // builder.add_attachment(attachment); 121 builder.add_unread(true);
122 builder.add_important(false);
123 builder.add_date(date);
124 builder.add_folder(folder);
121 auto buffer = builder.Finish(); 125 auto buffer = builder.Finish();
122 Akonadi2::ApplicationDomain::Buffer::FinishMailBuffer(m_fbb, buffer); 126 Akonadi2::ApplicationDomain::Buffer::FinishMailBuffer(m_fbb, buffer);
123 Akonadi2::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, 0, 0, m_fbb.GetBufferPointer(), m_fbb.GetSize()); 127 Akonadi2::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, 0, 0, m_fbb.GetBufferPointer(), m_fbb.GetSize());