From 26e4596f59cca57e48f3671dd98b6dbc190717ce Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Wed, 25 May 2016 14:24:39 +0900 Subject: [PATCH] Add TRIGGER_SUPPORT build feature for turning on/off the trigger Change-Id: If844a8c1f27cf8ec70d80be99457550ace3e8e1c Signed-off-by: Mu-Woong Lee --- CMakeLists.txt | 6 +++++- packaging/context-service.spec | 4 +++- src/ContextManager.cpp | 1 - src/Server.cpp | 24 ++++++++++++++++++++---- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4530121..73cdd69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,11 @@ INCLUDE(GNUInstallDirs) SET(target "contextd") # Source Lists -FILE(GLOB_RECURSE SRCS src/*.cpp) +FILE(GLOB SRCS src/*.cpp src/access_control/*.cpp src/policy/*.cpp) +IF(${TRIGGER_SUPPORT}) + FILE(GLOB SRCS ${SRCS} src/trigger/*.cpp) + ADD_DEFINITIONS(-DTRIGGER_SUPPORT) +ENDIF(${TRIGGER_SUPPORT}) MESSAGE("Sources: ${SRCS}") # Dependencies diff --git a/packaging/context-service.spec b/packaging/context-service.spec index 132ffed..26e7760 100644 --- a/packaging/context-service.spec +++ b/packaging/context-service.spec @@ -11,6 +11,7 @@ Source1: context-service.service %define SYSTEM_SERVICE 0 %define LEGACY_SECURITY 0 +%define TRIGGER_SUPPORT 1 %if "%{?BUILD_PROFILE}" == "tv" ExcludeArch: %{arm} aarch64 %ix86 x86_64 @@ -80,7 +81,8 @@ export CXXFLAGS+=" -std=c++0x" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} \ -DSYSTEM_SERVICE=%{SYSTEM_SERVICE} \ - -DLEGACY_SECURITY=%{LEGACY_SECURITY} + -DLEGACY_SECURITY=%{LEGACY_SECURITY} \ + -DTRIGGER_SUPPORT=%{TRIGGER_SUPPORT} make %{?jobs:-j%jobs} %install diff --git a/src/ContextManager.cpp b/src/ContextManager.cpp index f32ab7e..637b058 100644 --- a/src/ContextManager.cpp +++ b/src/ContextManager.cpp @@ -23,7 +23,6 @@ #include #include "access_control/Privilege.h" -#include "trigger/TemplateManager.h" #include "Server.h" #include "Request.h" #include "ProviderHandler.h" diff --git a/src/Server.cpp b/src/Server.cpp index 04a043c..9e56d6c 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -22,17 +22,23 @@ #include #include "DBusServer.h" #include "ContextManager.h" -#include "trigger/Trigger.h" #include "policy/PolicyManager.h" #include "Server.h" +#ifdef TRIGGER_SUPPORT +#include "trigger/Trigger.h" +#endif + static GMainLoop *mainloop = NULL; static bool started = false; static ctx::ContextManager *__contextMgr = NULL; static ctx::DBusServer *__dbusHandle = NULL; static ctx::PolicyManager *__policyMgr = NULL; + +#ifdef TRIGGER_SUPPORT static ctx::trigger::Trigger *__contextTrigger = NULL; +#endif /* TODO: re-organize activation & deactivation processes */ void ctx::Server::initialize() @@ -66,11 +72,13 @@ void ctx::Server::activate() __policyMgr = new(std::nothrow) ctx::PolicyManager(__contextMgr); IF_FAIL_CATCH_TAG(__policyMgr, _E, "Memory allocation failed"); +#ifdef TRIGGER_SUPPORT _I("Init Context Trigger"); __contextTrigger = new(std::nothrow) ctx::trigger::Trigger(); IF_FAIL_CATCH_TAG(__contextTrigger, _E, "Memory allocation failed"); result = __contextTrigger->init(__contextMgr); IF_FAIL_CATCH_TAG(result, _E, "Initialization Failed"); +#endif started = true; _I(CYAN("Context-Service Launched")); @@ -86,9 +94,12 @@ CATCH: void ctx::Server::release() { _I(CYAN("Terminating Context-Service")); + +#ifdef TRIGGER_SUPPORT _I("Release Context Trigger"); if (__contextTrigger) __contextTrigger->release(); +#endif _I("Release Policy Manager"); delete __policyMgr; @@ -103,7 +114,9 @@ void ctx::Server::release() g_main_loop_unref(mainloop); +#ifdef TRIGGER_SUPPORT delete __contextTrigger; +#endif delete __contextMgr; delete __dbusHandle; } @@ -122,9 +135,12 @@ void ctx::Server::sendRequest(ctx::RequestInfo* request) return; } - if (!__contextTrigger->assignRequest(request)) { - __contextMgr->assignRequest(request); - } +#ifdef TRIGGER_SUPPORT + if (__contextTrigger->assignRequest(request)) + return; +#endif + + __contextMgr->assignRequest(request); } static void __signalHandler(int signo) -- 2.34.1