From abc90b737074d93f73490a77e1eb1e1666dac375 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 6 Jul 2016 09:58:34 +0200 Subject: Test the resource status --- examples/dummyresource/resourcefactory.cpp | 13 +++++++++++++ examples/dummyresource/resourcefactory.h | 1 + 2 files changed, 14 insertions(+) (limited to 'examples/dummyresource') diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp index 2bd52cc..21a76ad 100644 --- a/examples/dummyresource/resourcefactory.cpp +++ b/examples/dummyresource/resourcefactory.cpp @@ -23,6 +23,7 @@ #include "entitybuffer.h" #include "pipeline.h" #include "dummycalendar_generated.h" +#include "notification_generated.h" #include "mail_generated.h" #include "createentity_generated.h" #include "domainadaptor.h" @@ -144,6 +145,18 @@ DummyResource::~DummyResource() } +KAsync::Job DummyResource::synchronizeWithSource() +{ + Trace() << "Synchronize with source and sending a notification about it"; + Sink::Notification n; + n.id = "connected"; + n.type = Sink::Notification::Status; + n.message = "We're connected"; + n.code = Sink::ApplicationDomain::ConnectedStatus; + emit notify(n); + return GenericResource::synchronizeWithSource(); +} + KAsync::Job DummyResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) { diff --git a/examples/dummyresource/resourcefactory.h b/examples/dummyresource/resourcefactory.h index 1c51b00..a7d0281 100644 --- a/examples/dummyresource/resourcefactory.h +++ b/examples/dummyresource/resourcefactory.h @@ -35,6 +35,7 @@ public: DummyResource(const QByteArray &instanceIdentifier, const QSharedPointer &pipeline = QSharedPointer()); virtual ~DummyResource(); + KAsync::Job synchronizeWithSource() Q_DECL_OVERRIDE; KAsync::Job inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) Q_DECL_OVERRIDE; }; -- 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/dummyresource/resourcefactory.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'examples/dummyresource') diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp index 21a76ad..0f7463f 100644 --- a/examples/dummyresource/resourcefactory.cpp +++ b/examples/dummyresource/resourcefactory.cpp @@ -48,6 +48,8 @@ #define ENTITY_TYPE_MAIL "mail" #define ENTITY_TYPE_FOLDER "folder" +SINK_DEBUG_AREA("dummyresource") + class DummySynchronizer : public Sink::Synchronizer { public: @@ -105,12 +107,12 @@ class DummySynchronizer : public Sink::Synchronizer { auto entity = createEntity(remoteId, it.value()); createOrModify(bufferType, remoteId, *entity); } - Trace() << "Sync of " << count << " entities of type " << bufferType << " done." << Sink::Log::TraceTime(time->elapsed()); + SinkTrace() << "Sync of " << count << " entities of type " << bufferType << " done." << Sink::Log::TraceTime(time->elapsed()); } KAsync::Job synchronizeWithSource() Q_DECL_OVERRIDE { - Log() << " Synchronizing with the source"; + SinkLog() << " Synchronizing with the source"; return KAsync::start([this]() { synchronize(ENTITY_TYPE_EVENT, DummyStore::instance().events(), [this](const QByteArray &ridBuffer, const QMap &data) { return createEvent(ridBuffer, data); @@ -121,7 +123,7 @@ class DummySynchronizer : public Sink::Synchronizer { synchronize(ENTITY_TYPE_FOLDER, DummyStore::instance().folders(), [this](const QByteArray &ridBuffer, const QMap &data) { return createFolder(ridBuffer, data); }); - Log() << "Done Synchronizing"; + SinkLog() << "Done Synchronizing"; }); } @@ -147,7 +149,7 @@ DummyResource::~DummyResource() KAsync::Job DummyResource::synchronizeWithSource() { - Trace() << "Synchronize with source and sending a notification about it"; + SinkTrace() << "Synchronize with source and sending a notification about it"; Sink::Notification n; n.id = "connected"; n.type = Sink::Notification::Status; @@ -160,7 +162,7 @@ KAsync::Job DummyResource::synchronizeWithSource() KAsync::Job DummyResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) { - Trace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue; + SinkTrace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue; if (property == "testInspection") { if (expectedValue.toBool()) { //Success -- 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/dummyresource/resourcefactory.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples/dummyresource') diff --git a/examples/dummyresource/resourcefactory.h b/examples/dummyresource/resourcefactory.h index a7d0281..9192c68 100644 --- a/examples/dummyresource/resourcefactory.h +++ b/examples/dummyresource/resourcefactory.h @@ -27,7 +27,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.dummy" +#define PLUGIN_NAME "sink.dummy" class DummyResource : public Sink::GenericResource { @@ -42,7 +42,7 @@ public: class DummyResourceFactory : public Sink::ResourceFactory { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.kde.dummy") + Q_PLUGIN_METADATA(IID "sink.dummy") Q_INTERFACES(Sink::ResourceFactory) public: -- cgit v1.2.3