summaryrefslogtreecommitdiffstats
path: root/common/mailpreprocessor.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-07 22:23:49 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-07 22:23:49 +0200
commitda2b049e248c1ad7efeb53685158a205335e4e36 (patch)
tree1e7e5e940e9b760b2108081b1d2f3879cebdb0ff /common/mailpreprocessor.cpp
parent9bcb822963fc96c94dbe7dcc4134dcd2dac454ff (diff)
downloadsink-da2b049e248c1ad7efeb53685158a205335e4e36.tar.gz
sink-da2b049e248c1ad7efeb53685158a205335e4e36.zip
A new debug system.
Instead of a single #define as debug area the new system allows for an identifier for each debug message with the structure component.area. The component is a dot separated identifier of the runtime component, such as the process or the plugin. The area is the code component, and can be as such defined at compiletime. The idea of this system is that it becomes possible to i.e. look at the output of all messages in the query subsystem of a specific resource (something that happens in the client process, but in the resource-specific subcomponent). The new macros are supposed to be less likely to clash with other names, hence the new names.
Diffstat (limited to 'common/mailpreprocessor.cpp')
-rw-r--r--common/mailpreprocessor.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/common/mailpreprocessor.cpp b/common/mailpreprocessor.cpp
index c38035e..2863ad4 100644
--- a/common/mailpreprocessor.cpp
+++ b/common/mailpreprocessor.cpp
@@ -29,6 +29,8 @@
29 29
30using namespace Sink; 30using namespace Sink;
31 31
32SINK_DEBUG_AREA("mailpreprocessor")
33
32QString MailPropertyExtractor::getFilePathFromMimeMessagePath(const QString &s) const 34QString MailPropertyExtractor::getFilePathFromMimeMessagePath(const QString &s) const
33{ 35{
34 return s; 36 return s;
@@ -38,23 +40,23 @@ void MailPropertyExtractor::updatedIndexedProperties(Sink::ApplicationDomain::Ma
38{ 40{
39 const auto mimeMessagePath = getFilePathFromMimeMessagePath(mail.getMimeMessagePath()); 41 const auto mimeMessagePath = getFilePathFromMimeMessagePath(mail.getMimeMessagePath());
40 if (mimeMessagePath.isNull()) { 42 if (mimeMessagePath.isNull()) {
41 Trace() << "No mime message"; 43 SinkTrace() << "No mime message";
42 return; 44 return;
43 } 45 }
44 Trace() << "Updating indexed properties " << mimeMessagePath; 46 SinkTrace() << "Updating indexed properties " << mimeMessagePath;
45 QFile f(mimeMessagePath); 47 QFile f(mimeMessagePath);
46 if (!f.open(QIODevice::ReadOnly)) { 48 if (!f.open(QIODevice::ReadOnly)) {
47 Warning() << "Failed to open the file: " << mimeMessagePath; 49 SinkWarning() << "Failed to open the file: " << mimeMessagePath;
48 return; 50 return;
49 } 51 }
50 if (!f.size()) { 52 if (!f.size()) {
51 Warning() << "The file is empty."; 53 SinkWarning() << "The file is empty.";
52 return; 54 return;
53 } 55 }
54 const auto mappedSize = qMin((qint64)8000, f.size()); 56 const auto mappedSize = qMin((qint64)8000, f.size());
55 auto mapped = f.map(0, mappedSize); 57 auto mapped = f.map(0, mappedSize);
56 if (!mapped) { 58 if (!mapped) {
57 Warning() << "Failed to map the file: " << f.errorString(); 59 SinkWarning() << "Failed to map the file: " << f.errorString();
58 return; 60 return;
59 } 61 }
60 62
@@ -89,15 +91,15 @@ QString MimeMessageMover::moveMessage(const QString &oldPath, const Sink::Applic
89 const auto filePath = directory + "/" + mail.identifier(); 91 const auto filePath = directory + "/" + mail.identifier();
90 if (oldPath != filePath) { 92 if (oldPath != filePath) {
91 if (!QDir().mkpath(directory)) { 93 if (!QDir().mkpath(directory)) {
92 Warning() << "Failed to create the directory: " << directory; 94 SinkWarning() << "Failed to create the directory: " << directory;
93 } 95 }
94 QFile::remove(filePath); 96 QFile::remove(filePath);
95 QFile origFile(oldPath); 97 QFile origFile(oldPath);
96 if (!origFile.open(QIODevice::ReadWrite)) { 98 if (!origFile.open(QIODevice::ReadWrite)) {
97 Warning() << "Failed to open the original file with write rights: " << origFile.errorString(); 99 SinkWarning() << "Failed to open the original file with write rights: " << origFile.errorString();
98 } 100 }
99 if (!origFile.rename(filePath)) { 101 if (!origFile.rename(filePath)) {
100 Warning() << "Failed to move the file from: " << oldPath << " to " << filePath << ". " << origFile.errorString(); 102 SinkWarning() << "Failed to move the file from: " << oldPath << " to " << filePath << ". " << origFile.errorString();
101 } 103 }
102 origFile.close(); 104 origFile.close();
103 return filePath; 105 return filePath;