From e3da13d1fe9ad623e05aec1977c813e7da37cedd Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 7 Jul 2016 11:46:45 +0200 Subject: Fail quickly if the backend is not available --- examples/imapresource/tests/imapmailsynctest.cpp | 8 ++++++++ examples/imapresource/tests/imapmailtest.cpp | 8 ++++++++ examples/imapresource/tests/imapserverproxytest.cpp | 4 ++++ 3 files changed, 20 insertions(+) (limited to 'examples/imapresource') diff --git a/examples/imapresource/tests/imapmailsynctest.cpp b/examples/imapresource/tests/imapmailsynctest.cpp index 968cde5..fcc659d 100644 --- a/examples/imapresource/tests/imapmailsynctest.cpp +++ b/examples/imapresource/tests/imapmailsynctest.cpp @@ -17,6 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include +#include #include #include "../imapresource.h" @@ -38,6 +39,13 @@ class ImapMailSyncTest : public Sink::MailSyncTest Q_OBJECT protected: + bool isBackendAvailable() Q_DECL_OVERRIDE + { + QTcpSocket socket; + socket.connectToHost("localhost", 993); + return socket.waitForConnected(200); + } + void resetTestEnvironment() Q_DECL_OVERRIDE { system("resetmailbox.sh"); diff --git a/examples/imapresource/tests/imapmailtest.cpp b/examples/imapresource/tests/imapmailtest.cpp index c94a731..e6f41f4 100644 --- a/examples/imapresource/tests/imapmailtest.cpp +++ b/examples/imapresource/tests/imapmailtest.cpp @@ -1,4 +1,5 @@ #include +#include #include @@ -18,6 +19,13 @@ class ImapMailTest : public Sink::MailTest Q_OBJECT protected: + bool isBackendAvailable() Q_DECL_OVERRIDE + { + QTcpSocket socket; + socket.connectToHost("localhost", 993); + return socket.waitForConnected(200); + } + void resetTestEnvironment() Q_DECL_OVERRIDE { system("resetmailbox.sh"); diff --git a/examples/imapresource/tests/imapserverproxytest.cpp b/examples/imapresource/tests/imapserverproxytest.cpp index e32298c..6819685 100644 --- a/examples/imapresource/tests/imapserverproxytest.cpp +++ b/examples/imapresource/tests/imapserverproxytest.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "../imapserverproxy.h" @@ -22,6 +23,9 @@ class ImapServerProxyTest : public QObject private slots: void initTestCase() { + QTcpSocket socket; + socket.connectToHost("localhost", 993); + QVERIFY(socket.waitForConnected(200)); Sink::Log::setDebugOutputLevel(Sink::Log::Trace); system("resetmailbox.sh"); } -- cgit v1.2.3 From 7ac1e222090ecfaa27ea8de2950e8c98a5033137 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 7 Jul 2016 11:57:43 +0200 Subject: Fix imap tests after trash addition --- examples/imapresource/tests/resetmailbox.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'examples/imapresource') diff --git a/examples/imapresource/tests/resetmailbox.sh b/examples/imapresource/tests/resetmailbox.sh index 8834b51..6ed198e 100644 --- a/examples/imapresource/tests/resetmailbox.sh +++ b/examples/imapresource/tests/resetmailbox.sh @@ -4,6 +4,7 @@ sudo echo "sam user.doe.* cyrus c" | cyradm --auth PLAIN -u cyrus -w admin local sudo echo "dm user.doe.*" | cyradm --auth PLAIN -u cyrus -w admin localhost sudo echo "cm user.doe.test" | cyradm --auth PLAIN -u cyrus -w admin localhost sudo echo "cm user.doe.Drafts" | cyradm --auth PLAIN -u cyrus -w admin localhost +sudo echo "cm user.doe.Trash" | cyradm --auth PLAIN -u cyrus -w admin localhost sudo echo "sam user.doe cyrus c" | cyradm --auth PLAIN -u cyrus -w admin localhost sudo cp /work/source/Sink/examples/imapresource/tests/data/1365777830.R28.localhost.localdomain\:2\,S /var/spool/imap/d/user/doe/test/1. sudo chown cyrus:mail /var/spool/imap/d/user/doe/test/1. -- cgit v1.2.3 From da2b049e248c1ad7efeb53685158a205335e4e36 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 7 Jul 2016 22:23:49 +0200 Subject: 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. --- examples/imapresource/imapresource.cpp | 99 +++++++++++----------- examples/imapresource/imapserverproxy.cpp | 40 ++++----- .../imapresource/tests/imapserverproxytest.cpp | 10 ++- 3 files changed, 76 insertions(+), 73 deletions(-) (limited to 'examples/imapresource') diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index e23add8..92f64bf 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp @@ -54,8 +54,7 @@ #define ENTITY_TYPE_MAIL "mail" #define ENTITY_TYPE_FOLDER "folder" -#undef DEBUG_AREA -#define DEBUG_AREA "resource.imap" +SINK_DEBUG_AREA("imapresource") using namespace Imap; using namespace Sink; @@ -95,7 +94,7 @@ public: QByteArray createFolder(const QString &folderName, const QString &folderPath, const QString &parentFolderRid, const QByteArray &icon) { - Trace() << "Creating folder: " << folderName << parentFolderRid; + SinkTrace() << "Creating folder: " << folderName << parentFolderRid; const auto remoteId = folderPath.toUtf8(); const auto bufferType = ENTITY_TYPE_FOLDER; Sink::ApplicationDomain::Folder folder; @@ -118,7 +117,7 @@ public: void synchronizeFolders(const QVector &folderList) { const QByteArray bufferType = ENTITY_TYPE_FOLDER; - Trace() << "Found folders " << folderList.size(); + SinkTrace() << "Found folders " << folderList.size(); scanForRemovals(bufferType, [this, &bufferType](const std::function &callback) { @@ -154,7 +153,7 @@ public: time->start(); const QByteArray bufferType = ENTITY_TYPE_MAIL; - Trace() << "Importing new mail." << path; + SinkTrace() << "Importing new mail." << path; const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, path.toUtf8()); @@ -163,7 +162,7 @@ public: count++; const auto remoteId = assembleMailRid(folderLocalId, message.uid); - Trace() << "Found a mail " << remoteId << message.msg->subject(true)->asUnicodeString() << message.flags; + SinkTrace() << "Found a mail " << remoteId << message.msg->subject(true)->asUnicodeString() << message.flags; auto mail = Sink::ApplicationDomain::Mail::create(mResourceInstanceIdentifier); mail.setFolder(folderLocalId); @@ -174,7 +173,7 @@ public: createOrModify(bufferType, remoteId, mail); } const auto elapsed = time->elapsed(); - Log() << "Synchronized " << count << " mails in " << path << Sink::Log::TraceTime(elapsed) << " " << elapsed/qMax(count, 1) << " [ms/mail]"; + SinkLog() << "Synchronized " << count << " mails in " << path << Sink::Log::TraceTime(elapsed) << " " << elapsed/qMax(count, 1) << " [ms/mail]"; } void synchronizeRemovals(const QString &path, const QSet &messages) @@ -183,7 +182,7 @@ public: time->start(); const QByteArray bufferType = ENTITY_TYPE_MAIL; - Trace() << "Finding removed mail."; + SinkTrace() << "Finding removed mail."; const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, path.toUtf8()); @@ -196,7 +195,7 @@ public: callback(sinkId); }, [&](const Index::Error &error) { - Warning() << "Error in index: " << error.message << property; + SinkWarning() << "Error in index: " << error.message << property; }); }, [messages, path, &count](const QByteArray &remoteId) -> bool { @@ -209,24 +208,24 @@ public: ); const auto elapsed = time->elapsed(); - Log() << "Removed " << count << " mails in " << path << Sink::Log::TraceTime(elapsed) << " " << elapsed/qMax(count, 1) << " [ms/mail]"; + SinkLog() << "Removed " << count << " mails in " << path << Sink::Log::TraceTime(elapsed) << " " << elapsed/qMax(count, 1) << " [ms/mail]"; } KAsync::Job synchronizeWithSource() Q_DECL_OVERRIDE { - Log() << " Synchronizing"; + SinkLog() << " Synchronizing"; return KAsync::start([this](KAsync::Future future) { - Trace() << "Connecting to:" << mServer << mPort; - Trace() << "as:" << mUser; + SinkTrace() << "Connecting to:" << mServer << mPort; + SinkTrace() << "as:" << mUser; ImapServerProxy imap(mServer, mPort); auto loginFuture = imap.login(mUser, mPassword).exec(); loginFuture.waitForFinished(); if (loginFuture.errorCode()) { - Warning() << "Login failed."; + SinkWarning() << "Login failed."; future.setError(1, "Login failed"); return; } else { - Trace() << "Login was successful"; + SinkTrace() << "Login was successful"; } QVector folderList; @@ -238,11 +237,11 @@ public: }).exec(); folderFuture.waitForFinished(); if (folderFuture.errorCode()) { - Warning() << "Folder sync failed."; + SinkWarning() << "Folder sync failed."; future.setError(1, "Folder list sync failed"); return; } else { - Trace() << "Folder sync was successful"; + SinkTrace() << "Folder sync was successful"; } for (const auto &folder : folderList) { @@ -251,7 +250,7 @@ public: } QSet uids; auto messagesFuture = imap.fetchMessages(folder, [this, folder, &uids](const QVector &messages) { - Trace() << "Synchronizing mails" << folder.normalizedPath(); + SinkTrace() << "Synchronizing mails" << folder.normalizedPath(); for (const auto &msg : messages) { uids << msg.uid; } @@ -260,16 +259,16 @@ public: messagesFuture.waitForFinished(); commit(); if (messagesFuture.errorCode()) { - Warning() << "Folder sync failed: " << folder.normalizedPath(); + SinkWarning() << "Folder sync failed: " << folder.normalizedPath(); continue; } //Remove what there is to remove synchronizeRemovals(folder.normalizedPath(), uids); commit(); - Trace() << "Folder synchronized: " << folder.normalizedPath(); + SinkTrace() << "Folder synchronized: " << folder.normalizedPath(); } - Log() << "Done Synchronizing"; + SinkLog() << "Done Synchronizing"; future.setFinished(); }); } @@ -310,7 +309,7 @@ public: .then([imap, mailbox, rid, mail](qint64 uid) { const auto remoteId = assembleMailRid(mail, uid); //FIXME this get's called after the final error handler? WTF? - Trace() << "Finished creating a new mail: " << remoteId; + SinkTrace() << "Finished creating a new mail: " << remoteId; *rid = remoteId; }).then([rid, imap]() { //FIXME fix KJob so we don't need this extra clause return *rid; @@ -319,19 +318,19 @@ public: const auto folderId = folderIdFromMailRid(oldRemoteId); const QString mailbox = syncStore().resolveLocalId(ENTITY_TYPE_FOLDER, folderId); const auto uid = uidFromMailRid(oldRemoteId); - Trace() << "Removing a mail: " << oldRemoteId << "in the mailbox: " << mailbox; + SinkTrace() << "Removing a mail: " << oldRemoteId << "in the mailbox: " << mailbox; KIMAP::ImapSet set; set.add(uid); return login.then(imap->remove(mailbox, set)) .then([imap, oldRemoteId]() { - Trace() << "Finished removing a mail: " << oldRemoteId; + SinkTrace() << "Finished removing a mail: " << oldRemoteId; return QByteArray(); }); } else if (operation == Sink::Operation_Modification) { const QString mailbox = syncStore().resolveLocalId(ENTITY_TYPE_FOLDER, mail.getFolder()); const auto uid = uidFromMailRid(oldRemoteId); - Trace() << "Modifying a mail: " << oldRemoteId << " in the mailbox: " << mailbox << changedProperties; + SinkTrace() << "Modifying a mail: " << oldRemoteId << " in the mailbox: " << mailbox << changedProperties; QByteArrayList flags; if (!mail.getUnread()) { @@ -344,7 +343,7 @@ public: const bool messageMoved = changedProperties.contains(ApplicationDomain::Mail::Folder::name); const bool messageChanged = changedProperties.contains(ApplicationDomain::Mail::MimeMessage::name); if (messageChanged || messageMoved) { - Trace() << "Replacing message."; + SinkTrace() << "Replacing message."; const auto folderId = folderIdFromMailRid(oldRemoteId); const QString oldMailbox = syncStore().resolveLocalId(ENTITY_TYPE_FOLDER, folderId); QByteArray content = KMime::LFtoCRLF(mail.getMimeMessage()); @@ -355,7 +354,7 @@ public: return login.then(imap->append(mailbox, content, flags, internalDate)) .then([imap, mailbox, rid, mail](qint64 uid) { const auto remoteId = assembleMailRid(mail, uid); - Trace() << "Finished creating a modified mail: " << remoteId; + SinkTrace() << "Finished creating a modified mail: " << remoteId; *rid = remoteId; }) .then(imap->remove(oldMailbox, set)) @@ -363,13 +362,13 @@ public: return *rid; }); } else { - Trace() << "Updating flags only."; + SinkTrace() << "Updating flags only."; KIMAP::ImapSet set; set.add(uid); return login.then(imap->select(mailbox)) .then(imap->storeFlags(set, flags)) .then([imap, mailbox]() { - Trace() << "Finished modifying mail"; + SinkTrace() << "Finished modifying mail"; }) .then([oldRemoteId, imap]() { return oldRemoteId; @@ -388,11 +387,11 @@ public: if (!folder.getParent().isEmpty()) { parentFolder = syncStore().resolveLocalId(ENTITY_TYPE_FOLDER, folder.getParent()); } - Trace() << "Creating a new folder: " << parentFolder << folder.getName(); + SinkTrace() << "Creating a new folder: " << parentFolder << folder.getName(); auto rid = QSharedPointer::create(); auto createFolder = login.then(imap->createSubfolder(parentFolder, folder.getName())) .then([imap, rid](const QString &createdFolder) { - Trace() << "Finished creating a new folder: " << createdFolder; + SinkTrace() << "Finished creating a new folder: " << createdFolder; *rid = createdFolder.toUtf8(); }); if (folder.getSpecialPurpose().isEmpty()) { @@ -414,15 +413,15 @@ public: for (const auto &purpose : folder.getSpecialPurpose()) { if (specialPurposeFolders->contains(purpose)) { auto f = specialPurposeFolders->value(purpose); - Trace() << "Merging specialpurpose folder with: " << f << " with purpose: " << purpose; + SinkTrace() << "Merging specialpurpose folder with: " << f << " with purpose: " << purpose; *rid = f.toUtf8(); return KAsync::null(); } } - Trace() << "No match found for merging, creating a new folder"; + SinkTrace() << "No match found for merging, creating a new folder"; return imap->createSubfolder(parentFolder, folder.getName()) .then([imap, rid](const QString &createdFolder) { - Trace() << "Finished creating a new folder: " << createdFolder; + SinkTrace() << "Finished creating a new folder: " << createdFolder; *rid = createdFolder.toUtf8(); }); @@ -433,18 +432,18 @@ public: return mergeJob; } } else if (operation == Sink::Operation_Removal) { - Trace() << "Removing a folder: " << oldRemoteId; + SinkTrace() << "Removing a folder: " << oldRemoteId; return login.then(imap->remove(oldRemoteId)) .then([oldRemoteId, imap]() { - Trace() << "Finished removing a folder: " << oldRemoteId; + SinkTrace() << "Finished removing a folder: " << oldRemoteId; return QByteArray(); }); } else if (operation == Sink::Operation_Modification) { - Trace() << "Renaming a folder: " << oldRemoteId << folder.getName(); + SinkTrace() << "Renaming a folder: " << oldRemoteId << folder.getName(); auto rid = QSharedPointer::create(); return login.then(imap->renameSubfolder(oldRemoteId, folder.getName())) .then([imap, rid](const QString &createdFolder) { - Trace() << "Finished renaming a folder: " << createdFolder; + SinkTrace() << "Finished renaming a folder: " << createdFolder; *rid = createdFolder.toUtf8(); }) .then([rid](){ @@ -515,7 +514,7 @@ KAsync::Job ImapResource::inspect(int inspectionType, const QByteArray &in auto entityStore = QSharedPointer::create(mResourceType, mResourceInstanceIdentifier, transaction); auto syncStore = QSharedPointer::create(synchronizationTransaction); - Trace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue; + SinkTrace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue; if (domainType == ENTITY_TYPE_MAIL) { const auto mail = entityStore->read(entityId); @@ -523,11 +522,11 @@ KAsync::Job ImapResource::inspect(int inspectionType, const QByteArray &in const auto folderRemoteId = syncStore->resolveLocalId(ENTITY_TYPE_FOLDER, mail.getFolder()); const auto mailRemoteId = syncStore->resolveLocalId(ENTITY_TYPE_MAIL, mail.identifier()); if (mailRemoteId.isEmpty() || folderRemoteId.isEmpty()) { - Warning() << "Missing remote id for folder or mail. " << mailRemoteId << folderRemoteId; + SinkWarning() << "Missing remote id for folder or mail. " << mailRemoteId << folderRemoteId; return KAsync::error(); } const auto uid = uidFromMailRid(mailRemoteId); - Trace() << "Mail remote id: " << folderRemoteId << mailRemoteId << mail.identifier() << folder.identifier(); + SinkTrace() << "Mail remote id: " << folderRemoteId << mailRemoteId << mail.identifier() << folder.identifier(); KIMAP::ImapSet set; set.add(uid); @@ -538,8 +537,8 @@ KAsync::Job ImapResource::inspect(int inspectionType, const QByteArray &in scope.mode = KIMAP::FetchJob::FetchScope::Full; auto imap = QSharedPointer::create(mServer, mPort); auto messageByUid = QSharedPointer>::create(); - Trace() << "Connecting to:" << mServer << mPort; - Trace() << "as:" << mUser; + SinkTrace() << "Connecting to:" << mServer << mPort; + SinkTrace() << "as:" << mUser; auto inspectionJob = imap->login(mUser, mPassword) .then(imap->select(folderRemoteId)) .then(imap->fetch(set, scope, [imap, messageByUid](const QVector &messages) { @@ -574,8 +573,8 @@ KAsync::Job ImapResource::inspect(int inspectionType, const QByteArray &in if (inspectionType == Sink::ResourceControl::Inspection::ExistenceInspectionType) { return inspectionJob.then>([=]() { if (!messageByUid->contains(uid)) { - Warning() << "Existing messages are: " << messageByUid->keys(); - Warning() << "We're looking for: " << uid; + SinkWarning() << "Existing messages are: " << messageByUid->keys(); + SinkWarning() << "We're looking for: " << uid; return KAsync::error(1, "Couldn't find message: " + mailRemoteId); } return KAsync::null(); @@ -587,7 +586,7 @@ KAsync::Job ImapResource::inspect(int inspectionType, const QByteArray &in const auto folder = entityStore->read(entityId); if (inspectionType == Sink::ResourceControl::Inspection::CacheIntegrityInspectionType) { - Log() << "Inspecting cache integrity" << remoteId; + SinkLog() << "Inspecting cache integrity" << remoteId; int expectedCount = 0; Index index("mail.index.folder", transaction); @@ -595,7 +594,7 @@ KAsync::Job ImapResource::inspect(int inspectionType, const QByteArray &in expectedCount++; }, [&](const Index::Error &error) { - Warning() << "Error in index: " << error.message << property; + SinkWarning() << "Error in index: " << error.message << property; }); auto set = KIMAP::ImapSet::fromImapSequenceSet("1:*"); @@ -630,10 +629,10 @@ KAsync::Job ImapResource::inspect(int inspectionType, const QByteArray &in *folderByName << f.pathParts.last(); } })) - .then>([folderByName, folderByPath, folder, remoteId, imap]() { + .then>([this, folderByName, folderByPath, folder, remoteId, imap]() { if (!folderByName->contains(folder.getName())) { - Warning() << "Existing folders are: " << *folderByPath; - Warning() << "We're looking for: " << folder.getName(); + SinkWarning() << "Existing folders are: " << *folderByPath; + SinkWarning() << "We're looking for: " << folder.getName(); return KAsync::error(1, "Wrong folder name: " + remoteId); } return KAsync::null(); diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp index 1b0a2ec..73ec654 100644 --- a/examples/imapresource/imapserverproxy.cpp +++ b/examples/imapresource/imapserverproxy.cpp @@ -37,6 +37,8 @@ #include "log.h" +SINK_DEBUG_AREA("imapserverproxy") + using namespace Imap; const char* Imap::Flags::Seen = "\\Seen"; @@ -54,16 +56,16 @@ static KAsync::Job runJob(KJob *job, const std::function &f) { return KAsync::start([job, f](KAsync::Future &future) { QObject::connect(job, &KJob::result, [&future, f](KJob *job) { - Trace() << "Job done: " << job->metaObject()->className(); + SinkTrace() << "Job done: " << job->metaObject()->className(); if (job->error()) { - Warning() << "Job failed: " << job->errorString(); + SinkWarning() << "Job failed: " << job->errorString(); future.setError(job->error(), job->errorString()); } else { future.setValue(f(job)); future.setFinished(); } }); - Trace() << "Starting job: " << job->metaObject()->className(); + SinkTrace() << "Starting job: " << job->metaObject()->className(); job->start(); }); } @@ -72,15 +74,15 @@ static KAsync::Job runJob(KJob *job) { return KAsync::start([job](KAsync::Future &future) { QObject::connect(job, &KJob::result, [&future](KJob *job) { - Trace() << "Job done: " << job->metaObject()->className(); + SinkTrace() << "Job done: " << job->metaObject()->className(); if (job->error()) { - Warning() << "Job failed: " << job->errorString(); + SinkWarning() << "Job failed: " << job->errorString(); future.setError(job->error(), job->errorString()); } else { future.setFinished(); } }); - Trace() << "Starting job: " << job->metaObject()->className(); + SinkTrace() << "Starting job: " << job->metaObject()->className(); job->start(); }); } @@ -117,11 +119,11 @@ KAsync::Job ImapServerProxy::login(const QString &username, const QString auto namespaceJob = new KIMAP::NamespaceJob(mSession); return runJob(loginJob).then(runJob(capabilitiesJob)).then([this](){ - Trace() << "Supported capabilities: " << mCapabilities; + SinkTrace() << "Supported capabilities: " << mCapabilities; QStringList requiredExtensions = QStringList() << "UIDPLUS" << "NAMESPACE"; for (const auto &requiredExtension : requiredExtensions) { if (!mCapabilities.contains(requiredExtension)) { - Warning() << "Server doesn't support required capability: " << requiredExtension; + SinkWarning() << "Server doesn't support required capability: " << requiredExtension; //TODO fail the job } } @@ -138,9 +140,9 @@ KAsync::Job ImapServerProxy::login(const QString &username, const QString mUserNamespaces << ns.name; mUserNamespaceSeparator = ns.separator; } - Trace() << "Found personal namespaces: " << mPersonalNamespaces << mPersonalNamespaceSeparator; - Trace() << "Found shared namespaces: " << mSharedNamespaces << mSharedNamespaceSeparator; - Trace() << "Found user namespaces: " << mUserNamespaces << mUserNamespaceSeparator; + SinkTrace() << "Found personal namespaces: " << mPersonalNamespaces << mPersonalNamespaceSeparator; + SinkTrace() << "Found shared namespaces: " << mSharedNamespaces << mSharedNamespaceSeparator; + SinkTrace() << "Found user namespaces: " << mUserNamespaces << mUserNamespaceSeparator; }); } @@ -291,8 +293,8 @@ KAsync::Job> ImapServerProxy::fetchHeaders(const QString &mailbox) const QMap &attrs, const QMap &flags, const QMap &messages) { - Trace() << "Received " << uids.size() << " headers from " << mailbox; - Trace() << uids.size() << sizes.size() << attrs.size() << flags.size() << messages.size(); + SinkTrace() << "Received " << uids.size() << " headers from " << mailbox; + SinkTrace() << uids.size() << sizes.size() << attrs.size() << flags.size() << messages.size(); //TODO based on the data available here, figure out which messages to actually fetch //(we only fetched headers and structure so far) @@ -344,7 +346,7 @@ KAsync::Job ImapServerProxy::createSubfolder(const QString &parentMailb } else { *folder = parentMailbox + mPersonalNamespaceSeparator + folderName; } - Trace() << "Creating subfolder: " << *folder; + SinkTrace() << "Creating subfolder: " << *folder; return create(*folder); }) .then([=]() { @@ -360,7 +362,7 @@ KAsync::Job ImapServerProxy::renameSubfolder(const QString &oldMailbox, auto parts = oldMailbox.split(mPersonalNamespaceSeparator); parts.removeLast(); *folder = parts.join(mPersonalNamespaceSeparator) + mPersonalNamespaceSeparator + newName; - Trace() << "Renaming subfolder: " << oldMailbox << *folder; + SinkTrace() << "Renaming subfolder: " << oldMailbox << *folder; return rename(oldMailbox, *folder); }) .then([=]() { @@ -370,14 +372,14 @@ KAsync::Job ImapServerProxy::renameSubfolder(const QString &oldMailbox, KAsync::Job ImapServerProxy::fetchFolders(std::function &)> callback) { - Trace() << "Fetching folders"; + SinkTrace() << "Fetching folders"; return list(KIMAP::ListJob::IncludeUnsubscribed, [callback](const QList &mailboxes, const QList > &flags){ QVector list; for (int i = 0; i < mailboxes.size(); i++) { const auto mailbox = mailboxes[i]; const auto mailboxFlags = flags[i]; bool noselect = mailboxFlags.contains(QByteArray(FolderFlags::Noselect).toLower()) || mailboxFlags.contains(QByteArray(FolderFlags::Noselect)); - Log() << "Found mailbox: " << mailbox.name << mailboxFlags << FolderFlags::Noselect << noselect; + SinkLog() << "Found mailbox: " << mailbox.name << mailboxFlags << FolderFlags::Noselect << noselect; list << Folder{mailbox.name.split(mailbox.separator), mailbox.name, mailbox.separator, noselect}; } callback(list); @@ -395,9 +397,9 @@ KAsync::Job ImapServerProxy::fetchMessages(const Folder &folder, std::func Q_ASSERT(!mPersonalNamespaceSeparator.isNull()); return select(mailboxFromFolder(folder)).then>([this, callback, folder]() -> KAsync::Job { return fetchHeaders(mailboxFromFolder(folder)).then, QList>([this, callback](const QList &uidsToFetch){ - Trace() << "Uids to fetch: " << uidsToFetch; + SinkTrace() << "Uids to fetch: " << uidsToFetch; if (uidsToFetch.isEmpty()) { - Trace() << "Nothing to fetch"; + SinkTrace() << "Nothing to fetch"; callback(QVector()); return KAsync::null(); } diff --git a/examples/imapresource/tests/imapserverproxytest.cpp b/examples/imapresource/tests/imapserverproxytest.cpp index 6819685..d9af453 100644 --- a/examples/imapresource/tests/imapserverproxytest.cpp +++ b/examples/imapresource/tests/imapserverproxytest.cpp @@ -12,6 +12,8 @@ using namespace Imap; +SINK_DEBUG_AREA("imapserverproxytest") + /** */ class ImapServerProxyTest : public QObject @@ -81,8 +83,8 @@ private slots: const QMap &attrs, const QMap &flags, const QMap &messages) { - Trace() << "Received " << uids.size() << " messages from " << mailbox; - Trace() << uids.size() << sizes.size() << attrs.size() << flags.size() << messages.size(); + SinkTrace() << "Received " << uids.size() << " messages from " << mailbox; + SinkTrace() << uids.size() << sizes.size() << attrs.size() << flags.size() << messages.size(); count += uids.size(); })); @@ -106,8 +108,8 @@ private slots: const QMap &attrs, const QMap &flags, const QMap &messages) { - Trace() << "Received " << uids.size() << " messages from " << mailbox; - Trace() << uids.size() << sizes.size() << attrs.size() << flags.size() << messages.size(); + SinkTrace() << "Received " << uids.size() << " messages from " << mailbox; + SinkTrace() << uids.size() << sizes.size() << attrs.size() << flags.size() << messages.size(); count += uids.size(); })); -- cgit v1.2.3 From 9317fbffeab4a8c258acb1116eb12fbded7053d8 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 8 Jul 2016 11:01:48 +0200 Subject: Control debugoutput during tests with sinksh. --- examples/imapresource/tests/imapserverproxytest.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'examples/imapresource') diff --git a/examples/imapresource/tests/imapserverproxytest.cpp b/examples/imapresource/tests/imapserverproxytest.cpp index d9af453..ef695b3 100644 --- a/examples/imapresource/tests/imapserverproxytest.cpp +++ b/examples/imapresource/tests/imapserverproxytest.cpp @@ -28,7 +28,6 @@ private slots: QTcpSocket socket; socket.connectToHost("localhost", 993); QVERIFY(socket.waitForConnected(200)); - Sink::Log::setDebugOutputLevel(Sink::Log::Trace); system("resetmailbox.sh"); } -- cgit v1.2.3 From 81fa4c3635a029b1c8f9cc3cd670f0b04f1c3f21 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 8 Jul 2016 11:22:40 +0200 Subject: Shorten the types to be more distinctive. The org.kde prefix is useless and possibly misleading. Simply prefixing with sink is more unique and shorter. --- examples/imapresource/imapresource.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples/imapresource') diff --git a/examples/imapresource/imapresource.h b/examples/imapresource/imapresource.h index 0c3b541..534a04e 100644 --- a/examples/imapresource/imapresource.h +++ b/examples/imapresource/imapresource.h @@ -26,7 +26,7 @@ #include //TODO: a little ugly to have this in two places, once here and once in Q_PLUGIN_METADATA -#define PLUGIN_NAME "org.kde.imap" +#define PLUGIN_NAME "sink.imap" class ImapMailAdaptorFactory; class ImapFolderAdaptorFactory; @@ -56,7 +56,7 @@ private: class ImapResourceFactory : public Sink::ResourceFactory { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.kde.imap") + Q_PLUGIN_METADATA(IID "sink.imap") Q_INTERFACES(Sink::ResourceFactory) public: -- cgit v1.2.3