Add TRIGGER_SUPPORT build feature for turning on/off the trigger 28/71328/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 25 May 2016 05:24:39 +0000 (14:24 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 25 May 2016 05:24:39 +0000 (14:24 +0900)
Change-Id: If844a8c1f27cf8ec70d80be99457550ace3e8e1c
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
CMakeLists.txt
packaging/context-service.spec
src/ContextManager.cpp
src/Server.cpp

index 4530121..73cdd69 100644 (file)
@@ -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
index 132ffed..26e7760 100644 (file)
@@ -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
index f32ab7e..637b058 100644 (file)
@@ -23,7 +23,6 @@
 #include <ContextProvider.h>
 
 #include "access_control/Privilege.h"
-#include "trigger/TemplateManager.h"
 #include "Server.h"
 #include "Request.h"
 #include "ProviderHandler.h"
index 04a043c..9e56d6c 100644 (file)
 #include <Types.h>
 #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)