diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-09-20 17:18:21 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-09-20 17:18:21 +0200 |
commit | ebc5c48c03b6145e604da7c313b35321d0a71142 (patch) | |
tree | 1cee00a9fa4faa4995c0a50f01703ac5672c8797 /examples/maildirresource | |
parent | 4a14a6fade947aa830d3f21598a4a6ba7316b933 (diff) | |
download | sink-ebc5c48c03b6145e604da7c313b35321d0a71142.tar.gz sink-ebc5c48c03b6145e604da7c313b35321d0a71142.zip |
A first draft of the threading algorithm.
Diffstat (limited to 'examples/maildirresource')
6 files changed, 286 insertions, 27 deletions
diff --git a/examples/maildirresource/tests/CMakeLists.txt b/examples/maildirresource/tests/CMakeLists.txt index d6f0fe7..b3e4050 100644 --- a/examples/maildirresource/tests/CMakeLists.txt +++ b/examples/maildirresource/tests/CMakeLists.txt | |||
@@ -8,6 +8,8 @@ include(SinkTest) | |||
8 | auto_tests ( | 8 | auto_tests ( |
9 | maildirmailtest | 9 | maildirmailtest |
10 | maildirmailsynctest | 10 | maildirmailsynctest |
11 | maildirthreadtest | ||
11 | ) | 12 | ) |
12 | target_link_libraries(maildirmailtest sink_resource_maildir) | 13 | target_link_libraries(maildirmailtest sink_resource_maildir) |
13 | target_link_libraries(maildirmailsynctest sink_resource_maildir) | 14 | target_link_libraries(maildirmailsynctest sink_resource_maildir) |
15 | target_link_libraries(maildirthreadtest sink_resource_maildir) | ||
diff --git a/examples/maildirresource/tests/data/maildir2/INBOX/cur/100000000.R28.localhost.localdomain:2,S b/examples/maildirresource/tests/data/maildir2/INBOX/cur/100000000.R28.localhost.localdomain:2,S new file mode 100644 index 0000000..e899eb7 --- /dev/null +++ b/examples/maildirresource/tests/data/maildir2/INBOX/cur/100000000.R28.localhost.localdomain:2,S | |||
@@ -0,0 +1,70 @@ | |||
1 | Return-Path: <nepomuk-bounces@kde.org> | ||
2 | Received: from compute4.internal (compute4.nyi.mail.srv.osa [10.202.2.44]) | ||
3 | by slots3a1p1 (Cyrus git2.5+0-git-fastmail-8998) with LMTPA; | ||
4 | Mon, 11 Mar 2013 14:28:42 -0400 | ||
5 | X-Sieve: CMU Sieve 2.4 | ||
6 | X-Spam-score: 0.0 | ||
7 | X-Spam-hits: BAYES_00 -1.9, RCVD_IN_DNSWL_MED -2.3, RP_MATCHES_RCVD -0.704, | ||
8 | LANGUAGES unknown, BAYES_USED global, SA_VERSION 3.3.1 | ||
9 | X-Spam-source: IP='46.4.96.248', Host='postbox.kde.org', Country='unk', FromHeader='org', | ||
10 | MailFrom='org' | ||
11 | X-Spam-charsets: plain='us-ascii' | ||
12 | X-Resolved-to: chrigi_1@fastmail.fm | ||
13 | X-Delivered-to: chrigi_1@fastmail.fm | ||
14 | X-Mail-from: nepomuk-bounces@kde.org | ||
15 | Received: from mx4.nyi.mail.srv.osa ([10.202.2.203]) | ||
16 | by compute4.internal (LMTPProxy); Mon, 11 Mar 2013 14:28:42 -0400 | ||
17 | Received: from postbox.kde.org (postbox.kde.org [46.4.96.248]) | ||
18 | by mx4.messagingengine.com (Postfix) with ESMTP id 1C9D2440F88 | ||
19 | for <chrigi_1@fastmail.fm>; Mon, 11 Mar 2013 14:28:42 -0400 (EDT) | ||
20 | Received: from postbox.kde.org (localhost [IPv6:::1]) | ||
21 | by postbox.kde.org (Postfix) with ESMTP id 00FFEB3732B; | ||
22 | Mon, 11 Mar 2013 18:28:40 +0000 (UTC) | ||
23 | DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=kde.org; s=default; | ||
24 | t=1363026520; bh=cOdvyBAJJ8ho64q0H7rxkl+cB2y6TiyVOX0fO3yZ64U=; | ||
25 | h=Date:From:To:Message-ID:In-Reply-To:References:MIME-Version: | ||
26 | Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: | ||
27 | List-Subscribe:Content-Type:Content-Transfer-Encoding:Sender; b=dv | ||
28 | dJAFu+6JCuNun5WIuP4ysfKpLh0DeuhEEfy2cQavUGMICJ27k7tI73x6gN37V5Q/evJ | ||
29 | NDFna3/IhNBsAQeLiXs28HKxzcVhbnq5jdFR6fbyo6k1fOKt5vTT1GTDZ+3zIGPD1CU | ||
30 | ioDBGxPb/Ds6gee90tjadOj6o+Oc+2ZSq94= | ||
31 | X-Original-To: nepomuk@kde.org | ||
32 | X-Remote-Delivered-To: nepomuk@localhost.kde.org | ||
33 | Received: from build.kde.org (build.kde.org [IPv6:2a01:4f8:160:9363::5]) | ||
34 | by postbox.kde.org (Postfix) with ESMTP id 4491CB3732B | ||
35 | for <nepomuk@kde.org>; Mon, 11 Mar 2013 18:28:27 +0000 (UTC) | ||
36 | Received: from localhost ([127.0.0.1]) by build.kde.org with esmtp (Exim 4.72) | ||
37 | (envelope-from <null@kde.org>) id 1UF7SV-0000gs-11 | ||
38 | for nepomuk@kde.org; Mon, 11 Mar 2013 18:28:27 +0000 | ||
39 | Date: Mon, 11 Mar 2013 18:28:27 +0000 (UTC) | ||
40 | From: KDE CI System <null@kde.org> | ||
41 | To: nepomuk@kde.org | ||
42 | Message-ID: <1977027405.27.1363026507008.JavaMail.jenkins@build> | ||
43 | MIME-Version: 1.0 | ||
44 | X-Jenkins-Job: nepomuk-core_stable | ||
45 | X-Jenkins-Result: UNSTABLE | ||
46 | X-Scanned-By: MIMEDefang 2.71 on 46.4.96.248 | ||
47 | Subject: First message | ||
48 | X-BeenThere: nepomuk@kde.org | ||
49 | X-Mailman-Version: 2.1.14 | ||
50 | Precedence: list | ||
51 | List-Id: The Semantic KDE <nepomuk.kde.org> | ||
52 | List-Unsubscribe: <https://mail.kde.org/mailman/options/nepomuk>, | ||
53 | <mailto:nepomuk-request@kde.org?subject=unsubscribe> | ||
54 | List-Archive: <http://mail.kde.org/pipermail/nepomuk> | ||
55 | List-Post: <mailto:nepomuk@kde.org> | ||
56 | List-Help: <mailto:nepomuk-request@kde.org?subject=help> | ||
57 | List-Subscribe: <https://mail.kde.org/mailman/listinfo/nepomuk>, | ||
58 | <mailto:nepomuk-request@kde.org?subject=subscribe> | ||
59 | Content-Type: text/plain; charset="us-ascii" | ||
60 | Content-Transfer-Encoding: 7bit | ||
61 | Errors-To: nepomuk-bounces@kde.org | ||
62 | Sender: nepomuk-bounces@kde.org | ||
63 | X-Truedomain: NotChecked | ||
64 | |||
65 | See <http://build.kde.org/job/nepomuk-core_stable/changes> | ||
66 | |||
67 | _______________________________________________ | ||
68 | Nepomuk mailing list | ||
69 | Nepomuk@kde.org | ||
70 | https://mail.kde.org/mailman/listinfo/nepomuk | ||
diff --git a/examples/maildirresource/tests/data/maildir2/INBOX/cur/100000001.R28.localhost.localdomain:2,S b/examples/maildirresource/tests/data/maildir2/INBOX/cur/100000001.R28.localhost.localdomain:2,S new file mode 100644 index 0000000..cfdd438 --- /dev/null +++ b/examples/maildirresource/tests/data/maildir2/INBOX/cur/100000001.R28.localhost.localdomain:2,S | |||
@@ -0,0 +1,72 @@ | |||
1 | Return-Path: <nepomuk-bounces@kde.org> | ||
2 | Received: from compute4.internal (compute4.nyi.mail.srv.osa [10.202.2.44]) | ||
3 | by slots3a1p1 (Cyrus git2.5+0-git-fastmail-8998) with LMTPA; | ||
4 | Mon, 11 Mar 2013 14:28:42 -0400 | ||
5 | X-Sieve: CMU Sieve 2.4 | ||
6 | X-Spam-score: 0.0 | ||
7 | X-Spam-hits: BAYES_00 -1.9, RCVD_IN_DNSWL_MED -2.3, RP_MATCHES_RCVD -0.704, | ||
8 | LANGUAGES unknown, BAYES_USED global, SA_VERSION 3.3.1 | ||
9 | X-Spam-source: IP='46.4.96.248', Host='postbox.kde.org', Country='unk', FromHeader='org', | ||
10 | MailFrom='org' | ||
11 | X-Spam-charsets: plain='us-ascii' | ||
12 | X-Resolved-to: chrigi_1@fastmail.fm | ||
13 | X-Delivered-to: chrigi_1@fastmail.fm | ||
14 | X-Mail-from: nepomuk-bounces@kde.org | ||
15 | Received: from mx4.nyi.mail.srv.osa ([10.202.2.203]) | ||
16 | by compute4.internal (LMTPProxy); Mon, 11 Mar 2013 14:28:42 -0400 | ||
17 | Received: from postbox.kde.org (postbox.kde.org [46.4.96.248]) | ||
18 | by mx4.messagingengine.com (Postfix) with ESMTP id 1C9D2440F88 | ||
19 | for <chrigi_1@fastmail.fm>; Mon, 11 Mar 2013 14:28:42 -0400 (EDT) | ||
20 | Received: from postbox.kde.org (localhost [IPv6:::1]) | ||
21 | by postbox.kde.org (Postfix) with ESMTP id 00FFEB3732B; | ||
22 | Mon, 11 Mar 2013 18:28:40 +0000 (UTC) | ||
23 | DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=kde.org; s=default; | ||
24 | t=1363026520; bh=cOdvyBAJJ8ho64q0H7rxkl+cB2y6TiyVOX0fO3yZ64U=; | ||
25 | h=Date:From:To:Message-ID:In-Reply-To:References:MIME-Version: | ||
26 | Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: | ||
27 | List-Subscribe:Content-Type:Content-Transfer-Encoding:Sender; b=dv | ||
28 | dJAFu+6JCuNun5WIuP4ysfKpLh0DeuhEEfy2cQavUGMICJ27k7tI73x6gN37V5Q/evJ | ||
29 | NDFna3/IhNBsAQeLiXs28HKxzcVhbnq5jdFR6fbyo6k1fOKt5vTT1GTDZ+3zIGPD1CU | ||
30 | ioDBGxPb/Ds6gee90tjadOj6o+Oc+2ZSq94= | ||
31 | X-Original-To: nepomuk@kde.org | ||
32 | X-Remote-Delivered-To: nepomuk@localhost.kde.org | ||
33 | Received: from build.kde.org (build.kde.org [IPv6:2a01:4f8:160:9363::5]) | ||
34 | by postbox.kde.org (Postfix) with ESMTP id 4491CB3732B | ||
35 | for <nepomuk@kde.org>; Mon, 11 Mar 2013 18:28:27 +0000 (UTC) | ||
36 | Received: from localhost ([127.0.0.1]) by build.kde.org with esmtp (Exim 4.72) | ||
37 | (envelope-from <null@kde.org>) id 1UF7SV-0000gs-11 | ||
38 | for nepomuk@kde.org; Mon, 11 Mar 2013 18:28:27 +0000 | ||
39 | Date: Mon, 11 Mar 2013 19:28:27 +0000 (UTC) | ||
40 | From: KDE CI System <null@kde.org> | ||
41 | To: nepomuk@kde.org | ||
42 | Message-ID: <1000000001.27.1363026507008.JavaMail.jenkins@build> | ||
43 | In-Reply-To: <1977027405.27.1363026507008.JavaMail.jenkins@build> | ||
44 | References: <1977027405.27.1363026507008.JavaMail.jenkins@build> | ||
45 | MIME-Version: 1.0 | ||
46 | X-Jenkins-Job: nepomuk-core_stable | ||
47 | X-Jenkins-Result: UNSTABLE | ||
48 | X-Scanned-By: MIMEDefang 2.71 on 46.4.96.248 | ||
49 | Subject: ThreadLeader | ||
50 | X-BeenThere: nepomuk@kde.org | ||
51 | X-Mailman-Version: 2.1.14 | ||
52 | Precedence: list | ||
53 | List-Id: The Semantic KDE <nepomuk.kde.org> | ||
54 | List-Unsubscribe: <https://mail.kde.org/mailman/options/nepomuk>, | ||
55 | <mailto:nepomuk-request@kde.org?subject=unsubscribe> | ||
56 | List-Archive: <http://mail.kde.org/pipermail/nepomuk> | ||
57 | List-Post: <mailto:nepomuk@kde.org> | ||
58 | List-Help: <mailto:nepomuk-request@kde.org?subject=help> | ||
59 | List-Subscribe: <https://mail.kde.org/mailman/listinfo/nepomuk>, | ||
60 | <mailto:nepomuk-request@kde.org?subject=subscribe> | ||
61 | Content-Type: text/plain; charset="us-ascii" | ||
62 | Content-Transfer-Encoding: 7bit | ||
63 | Errors-To: nepomuk-bounces@kde.org | ||
64 | Sender: nepomuk-bounces@kde.org | ||
65 | X-Truedomain: NotChecked | ||
66 | |||
67 | See <http://build.kde.org/job/nepomuk-core_stable/changes> | ||
68 | |||
69 | _______________________________________________ | ||
70 | Nepomuk mailing list | ||
71 | Nepomuk@kde.org | ||
72 | https://mail.kde.org/mailman/listinfo/nepomuk | ||
diff --git a/examples/maildirresource/tests/maildirmailsynctest.cpp b/examples/maildirresource/tests/maildirmailsynctest.cpp index f2cf3e0..bafd5a8 100644 --- a/examples/maildirresource/tests/maildirmailsynctest.cpp +++ b/examples/maildirresource/tests/maildirmailsynctest.cpp | |||
@@ -25,36 +25,11 @@ | |||
25 | #include "common/test.h" | 25 | #include "common/test.h" |
26 | #include "common/domain/applicationdomaintype.h" | 26 | #include "common/domain/applicationdomaintype.h" |
27 | 27 | ||
28 | #include "utils.h" | ||
29 | |||
28 | using namespace Sink; | 30 | using namespace Sink; |
29 | using namespace Sink::ApplicationDomain; | 31 | using namespace Sink::ApplicationDomain; |
30 | 32 | ||
31 | static bool copyRecursively(const QString &srcFilePath, const QString &tgtFilePath) | ||
32 | { | ||
33 | QFileInfo srcFileInfo(srcFilePath); | ||
34 | if (srcFileInfo.isDir()) { | ||
35 | QDir targetDir(tgtFilePath); | ||
36 | targetDir.cdUp(); | ||
37 | if (!targetDir.mkdir(QFileInfo(srcFilePath).fileName())) { | ||
38 | qWarning() << "Failed to create directory " << tgtFilePath; | ||
39 | return false; | ||
40 | } | ||
41 | QDir sourceDir(srcFilePath); | ||
42 | QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System); | ||
43 | foreach (const QString &fileName, fileNames) { | ||
44 | const QString newSrcFilePath = srcFilePath + QLatin1Char('/') + fileName; | ||
45 | const QString newTgtFilePath = tgtFilePath + QLatin1Char('/') + fileName; | ||
46 | if (!copyRecursively(newSrcFilePath, newTgtFilePath)) | ||
47 | return false; | ||
48 | } | ||
49 | } else { | ||
50 | if (!QFile::copy(srcFilePath, tgtFilePath)) { | ||
51 | qWarning() << "Failed to copy file " << tgtFilePath; | ||
52 | return false; | ||
53 | } | ||
54 | } | ||
55 | return true; | ||
56 | } | ||
57 | |||
58 | /** | 33 | /** |
59 | * Test of complete system using the maildir resource. | 34 | * Test of complete system using the maildir resource. |
60 | * | 35 | * |
diff --git a/examples/maildirresource/tests/maildirthreadtest.cpp b/examples/maildirresource/tests/maildirthreadtest.cpp new file mode 100644 index 0000000..a74869c --- /dev/null +++ b/examples/maildirresource/tests/maildirthreadtest.cpp | |||
@@ -0,0 +1,90 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 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 <QtTest> | ||
20 | |||
21 | #include <tests/mailthreadtest.h> | ||
22 | #include "../maildirresource.h" | ||
23 | #include "../libmaildir/maildir.h" | ||
24 | |||
25 | #include "common/test.h" | ||
26 | #include "common/domain/applicationdomaintype.h" | ||
27 | |||
28 | #include "utils.h"; | ||
29 | |||
30 | using namespace Sink; | ||
31 | using namespace Sink::ApplicationDomain; | ||
32 | |||
33 | /** | ||
34 | * Test of complete system using the maildir resource. | ||
35 | * | ||
36 | * This test requires the maildir resource installed. | ||
37 | */ | ||
38 | class MaildirThreadTest : public Sink::MailThreadTest | ||
39 | { | ||
40 | Q_OBJECT | ||
41 | |||
42 | QTemporaryDir tempDir; | ||
43 | QString targetPath; | ||
44 | |||
45 | protected: | ||
46 | void resetTestEnvironment() Q_DECL_OVERRIDE | ||
47 | { | ||
48 | targetPath = tempDir.path() + "/maildir2/"; | ||
49 | QDir dir(targetPath); | ||
50 | dir.removeRecursively(); | ||
51 | copyRecursively(TESTDATAPATH "/maildir2", targetPath); | ||
52 | } | ||
53 | |||
54 | Sink::ApplicationDomain::SinkResource createResource() Q_DECL_OVERRIDE | ||
55 | { | ||
56 | auto resource = ApplicationDomain::MaildirResource::create("account1"); | ||
57 | resource.setProperty("path", targetPath); | ||
58 | return resource; | ||
59 | } | ||
60 | |||
61 | Sink::ApplicationDomain::SinkResource createFaultyResource() Q_DECL_OVERRIDE | ||
62 | { | ||
63 | auto resource = ApplicationDomain::MaildirResource::create("account1"); | ||
64 | resource.setProperty("path", ""); | ||
65 | return resource; | ||
66 | } | ||
67 | |||
68 | void removeResourceFromDisk(const QByteArray &identifier) Q_DECL_OVERRIDE | ||
69 | { | ||
70 | ::MaildirResource::removeFromDisk(identifier); | ||
71 | } | ||
72 | |||
73 | QByteArray createMessage(const QStringList &folderPath, const QByteArray &message) Q_DECL_OVERRIDE | ||
74 | { | ||
75 | auto rootPath = tempDir.path() + "/maildir2/"; | ||
76 | KPIM::Maildir maildir(rootPath + folderPath.join('/')); | ||
77 | return maildir.addEntry(message).toUtf8(); | ||
78 | } | ||
79 | |||
80 | void removeMessage(const QStringList &folderPath, const QByteArray &messageIdentifier) Q_DECL_OVERRIDE | ||
81 | { | ||
82 | auto rootPath = tempDir.path() + "/maildir2/"; | ||
83 | KPIM::Maildir maildir(rootPath + folderPath.join('/')); | ||
84 | maildir.removeEntry(messageIdentifier); | ||
85 | } | ||
86 | }; | ||
87 | |||
88 | QTEST_MAIN(MaildirThreadTest) | ||
89 | |||
90 | #include "maildirthreadtest.moc" | ||
diff --git a/examples/maildirresource/tests/utils.h b/examples/maildirresource/tests/utils.h new file mode 100644 index 0000000..6e25353 --- /dev/null +++ b/examples/maildirresource/tests/utils.h | |||
@@ -0,0 +1,50 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 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 <QFileInfo> | ||
22 | #include <QDir> | ||
23 | #include <QDebug> | ||
24 | |||
25 | static bool copyRecursively(const QString &srcFilePath, const QString &tgtFilePath) | ||
26 | { | ||
27 | QFileInfo srcFileInfo(srcFilePath); | ||
28 | if (srcFileInfo.isDir()) { | ||
29 | QDir targetDir(tgtFilePath); | ||
30 | targetDir.cdUp(); | ||
31 | if (!targetDir.mkdir(QFileInfo(srcFilePath).fileName())) { | ||
32 | qWarning() << "Failed to create directory " << tgtFilePath; | ||
33 | return false; | ||
34 | } | ||
35 | QDir sourceDir(srcFilePath); | ||
36 | QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System); | ||
37 | foreach (const QString &fileName, fileNames) { | ||
38 | const QString newSrcFilePath = srcFilePath + QLatin1Char('/') + fileName; | ||
39 | const QString newTgtFilePath = tgtFilePath + QLatin1Char('/') + fileName; | ||
40 | if (!copyRecursively(newSrcFilePath, newTgtFilePath)) | ||
41 | return false; | ||
42 | } | ||
43 | } else { | ||
44 | if (!QFile::copy(srcFilePath, tgtFilePath)) { | ||
45 | qWarning() << "Failed to copy file " << tgtFilePath; | ||
46 | return false; | ||
47 | } | ||
48 | } | ||
49 | return true; | ||
50 | } | ||