From 71564ab2125d8bb2629b33480290ad36dca4e6de Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Fri, 9 Jun 2017 20:17:57 +0900 Subject: [PATCH] Dependency cleanup: apply the modified service & client interfaces Change-Id: I75efce7c6c54255e3beb088a873f56cc578e6395 Signed-off-by: Mu-Woong Lee --- include/private/JobSchedulerService.h | 24 ++++++++++++---- packaging/context-job-scheduler.spec | 2 +- src/server-dummy/JobSchedulerService.cpp | 31 +++++++++++++++++--- src/server/JobSchedulerService.cpp | 33 ++++++++++++++++++---- ...obSchedulerClient.cpp => MethodCallHandler.cpp} | 19 +++++++------ .../{JobSchedulerClient.h => MethodCallHandler.h} | 24 ++++++++++------ 6 files changed, 101 insertions(+), 32 deletions(-) rename src/server/{JobSchedulerClient.cpp => MethodCallHandler.cpp} (65%) rename src/server/{JobSchedulerClient.h => MethodCallHandler.h} (57%) diff --git a/include/private/JobSchedulerService.h b/include/private/JobSchedulerService.h index 9735ab2..def2c70 100644 --- a/include/private/JobSchedulerService.h +++ b/include/private/JobSchedulerService.h @@ -17,22 +17,36 @@ #ifndef __CONTEXT_JOB_SCHEDULER_SERVICE_H__ #define __CONTEXT_JOB_SCHEDULER_SERVICE_H__ -#include +#include +#include +#include namespace ctx { - class EXPORT_API JobSchedulerService : public ServiceBase { + class EXPORT_API JobSchedulerService : public IService { public: - JobSchedulerService(GDBusConnection* conn); + JobSchedulerService(); ~JobSchedulerService(); + void setServiceRunner(IServiceRunner* runner); + bool isUserService(); - protected: + const char* getServiceName(); + const char* getMethodSpecs(); + bool prepare(); void cleanup(); - ClientBase* createClient(const std::string& busName); + void onUserActivated(); + void onUserDeactivated(); + + IMethodCallHandler* createMethodCallHandler(); + + GDBusConnection* getConnection(); + + private: + IServiceRunner* __serviceRunner; }; } diff --git a/packaging/context-job-scheduler.spec b/packaging/context-job-scheduler.spec index 042b24e..b1a245f 100644 --- a/packaging/context-job-scheduler.spec +++ b/packaging/context-job-scheduler.spec @@ -1,6 +1,6 @@ Name: context-job-scheduler Summary: Unified job scheduler service server and client libraries -Version: 0.0.1 +Version: 0.0.2 Release: 1 Group: Service Framework/Context License: Apache-2.0 diff --git a/src/server-dummy/JobSchedulerService.cpp b/src/server-dummy/JobSchedulerService.cpp index afdad28..3c97c12 100644 --- a/src/server-dummy/JobSchedulerService.cpp +++ b/src/server-dummy/JobSchedulerService.cpp @@ -14,26 +14,41 @@ * limitations under the License. */ +#include #include #include using namespace ctx; -JobSchedulerService::JobSchedulerService(GDBusConnection* conn) : - ServiceBase(conn, CTX_JOB_SCHEDULER, CTX_JOB_SCHEDULER_SPEC) +JobSchedulerService::JobSchedulerService() : + __serviceRunner(NULL) { - throw std::runtime_error("Job Scheduler is not supported"); + throw std::runtime_error("Job-Scheduler is not supported"); } JobSchedulerService::~JobSchedulerService() { } +void JobSchedulerService::setServiceRunner(IServiceRunner* runner) +{ +} + bool JobSchedulerService::isUserService() { return false; } +const char* JobSchedulerService::getServiceName() +{ + return NULL; +} + +const char* JobSchedulerService::getMethodSpecs() +{ + return NULL; +} + bool JobSchedulerService::prepare() { return false; @@ -43,7 +58,15 @@ void JobSchedulerService::cleanup() { } -ClientBase* JobSchedulerService::createClient(const std::string& busName) +void JobSchedulerService::onUserActivated() +{ +} + +void JobSchedulerService::onUserDeactivated() +{ +} + +IMethodCallHandler* JobSchedulerService::createMethodCallHandler() { return NULL; } diff --git a/src/server/JobSchedulerService.cpp b/src/server/JobSchedulerService.cpp index 7f38bf2..4e6d1c2 100644 --- a/src/server/JobSchedulerService.cpp +++ b/src/server/JobSchedulerService.cpp @@ -16,12 +16,12 @@ #include #include -#include "JobSchedulerClient.h" +#include "MethodCallHandler.h" using namespace ctx; -JobSchedulerService::JobSchedulerService(GDBusConnection* conn) : - ServiceBase(conn, CTX_JOB_SCHEDULER, CTX_JOB_SCHEDULER_SPEC) +JobSchedulerService::JobSchedulerService() : + __serviceRunner(NULL) { } @@ -29,14 +29,27 @@ JobSchedulerService::~JobSchedulerService() { } +void JobSchedulerService::setServiceRunner(IServiceRunner* runner) +{ +} + bool JobSchedulerService::isUserService() { return false; } +const char* JobSchedulerService::getServiceName() +{ + return NULL; +} + +const char* JobSchedulerService::getMethodSpecs() +{ + return NULL; +} + bool JobSchedulerService::prepare() { - /* Service-specific initialization tasks */ return true; } @@ -44,7 +57,15 @@ void JobSchedulerService::cleanup() { } -ClientBase* JobSchedulerService::createClient(const std::string& busName) +void JobSchedulerService::onUserActivated() +{ +} + +void JobSchedulerService::onUserDeactivated() +{ +} + +IMethodCallHandler* JobSchedulerService::createMethodCallHandler() { - return new(std::nothrow) JobSchedulerClient(this, busName); + return new MethodCallHandler(); } diff --git a/src/server/JobSchedulerClient.cpp b/src/server/MethodCallHandler.cpp similarity index 65% rename from src/server/JobSchedulerClient.cpp rename to src/server/MethodCallHandler.cpp index ecd6736..6675063 100644 --- a/src/server/JobSchedulerClient.cpp +++ b/src/server/MethodCallHandler.cpp @@ -14,26 +14,29 @@ * limitations under the License. */ -#include -#include -#include "JobSchedulerClient.h" +#include "MethodCallHandler.h" using namespace ctx; -JobSchedulerClient::JobSchedulerClient(ServiceBase* hostService, const std::string& busName) : - ClientBase(hostService, busName) +MethodCallHandler::MethodCallHandler() : + __caller(NULL) { } -JobSchedulerClient::~JobSchedulerClient() +MethodCallHandler::~MethodCallHandler() { } -void JobSchedulerClient::onMethodCalled(MethodCall* methodCall) +void MethodCallHandler::setCaller(IClient* client) +{ + __caller = client; +} + +void MethodCallHandler::onMethodCalled(IMethodCall* methodCall) { delete methodCall; } -void JobSchedulerClient::onDisconnected() +void MethodCallHandler::onDisconnected() { } diff --git a/src/server/JobSchedulerClient.h b/src/server/MethodCallHandler.h similarity index 57% rename from src/server/JobSchedulerClient.h rename to src/server/MethodCallHandler.h index e24286e..c400825 100644 --- a/src/server/JobSchedulerClient.h +++ b/src/server/MethodCallHandler.h @@ -14,22 +14,30 @@ * limitations under the License. */ -#ifndef __CONTEXT_JOB_SCHEDULER_CLIENT_H__ -#define __CONTEXT_JOB_SCHEDULER_CLIENT_H__ +#ifndef __CONTEXT_JOB_SCHEDULER_METHOD_CALL_HANDLER_H__ +#define __CONTEXT_JOB_SCHEDULER_METHOD_CALL_HANDLER_H__ -#include +#include +#include +#include namespace ctx { - class JobSchedulerClient : public ClientBase { + class SensorProvider; + + class MethodCallHandler : public IMethodCallHandler { public: - JobSchedulerClient(ServiceBase* hostService, const std::string& busName); - ~JobSchedulerClient(); + MethodCallHandler(); + ~MethodCallHandler(); - void onMethodCalled(MethodCall* methodCall); + void setCaller(IClient* client); + void onMethodCalled(IMethodCall* methodCall); void onDisconnected(); + + private: + IClient* __caller; }; } -#endif /* __CONTEXT_JOB_SCHEDULER_CLIENT_H__ */ +#endif /* __CONTEXT_JOB_SCHEDULER_METHOD_CALL_HANDLER_H__ */ -- 2.7.4