Integrate changes from Tizen 2.4 (Version 0.5.3) 62/44362/1 accepted/tizen/mobile/20150722.000950 accepted/tizen/tv/20150722.001048 submit/tizen_mobile/20150721.115234 submit/tizen_tv/20150721.114308
authorMu-Woong <muwoong.lee@samsung.com>
Tue, 21 Jul 2015 06:33:05 +0000 (15:33 +0900)
committerMu-Woong <muwoong.lee@samsung.com>
Tue, 21 Jul 2015 06:33:05 +0000 (15:33 +0900)
- Remove Vasum zone control code
- Assign null to clips_h while initialization
- Removed unnecessary logs and modified invalid log tag
- Modified to construct clips handler instanece only when at least one enabled rule exists

Change-Id: I6bf048441161aee5ee50d5d55f43bf4db9fe666e
Signed-off-by: Mu-Woong <muwoong.lee@samsung.com>
30 files changed:
packaging/context-service.spec
packaging/context-service.xml
src/client_request.cpp
src/client_request.h
src/context_mgr_impl.cpp
src/context_mgr_impl.h
src/context_trigger/clips_handler.cpp
src/context_trigger/clips_handler.h
src/context_trigger/context_monitor.cpp
src/context_trigger/context_monitor.h
src/context_trigger/fact.cpp
src/context_trigger/fact.h
src/context_trigger/fact_reader.cpp
src/context_trigger/fact_reader.h
src/context_trigger/fact_request.cpp
src/context_trigger/fact_request.h
src/context_trigger/rule_manager.cpp
src/context_trigger/rule_manager.h
src/context_trigger/script_generator.cpp
src/context_trigger/script_generator.h
src/context_trigger/timer.cpp
src/context_trigger/timer.h
src/context_trigger/trigger.cpp
src/context_trigger/trigger.h
src/dbus_server_impl.cpp
src/request.cpp
src/request.h
src/server.cpp
src/zone_util_impl.cpp [deleted file]
src/zone_util_impl.h [deleted file]

index e054daad28e56972752cf8e7d568e540fbdf2636..ed4f119db154c3e010b1755651f3b679a6fa524d 100644 (file)
@@ -1,6 +1,6 @@
 Name:       context-service
 Summary:    Context-Service
-Version:    0.5.0
+Version:    0.5.3
 Release:    1
 Group:      System/Service
 License:    Apache-2.0
index 61c5d87daddee7b123bef91e38f97c6a11031cd5..dd71b93ca8e1d533056c046aa6a849c87b1a65bd 100644 (file)
@@ -2,6 +2,7 @@
 <manifest xmlns="http://tizen.org/ns/packages"
        package="context-service"
        version="0.0.0"
+       api-version="3.0"
        install-location="internal-only"
        type="rpm">
        <label>Context Service</label>
@@ -17,6 +18,5 @@
        </service-application>
        <privileges>
                <privilege>http://tizen.org/privilege/location</privilege>
-               <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
        </privileges>
 </manifest>
index b4c27535cd78cc7d0a84d27503038f821194dbda..f7205caa4cfce9e2fb436d2e7f106cd257303b20 100644 (file)
@@ -19,7 +19,6 @@
 #include <app_manager.h>
 #include <types_internal.h>
 #include <dbus_server.h>
-#include "zone_util_impl.h"
 #include "dbus_server_impl.h"
 #include "client_request.h"
 
@@ -35,11 +34,10 @@ ctx::client_request::~client_request()
                g_dbus_method_invocation_return_value(invocation, g_variant_new("(iss)", ERR_OPERATION_FAILED, EMPTY_JSON_OBJECT, EMPTY_JSON_OBJECT));
 }
 
-bool ctx::client_request::set_peer_creds(const char *smack_label, const char *zone)
+bool ctx::client_request::set_peer_creds(const char *smack_label)
 {
-       IF_FAIL_RETURN_TAG(smack_label && zone, false, _E, "Invalid parameter");
+       IF_FAIL_RETURN_TAG(smack_label, false, _E, "Invalid parameter");
        client_app_id = smack_label;
-       _zone_name = zone;
        return true;
 }
 
index bc7e8f364934f3366b52d4fb299da937f019093a..ae1628200e09e99d0d890e2ad3bad6f9079bf004 100644 (file)
@@ -27,7 +27,7 @@ namespace ctx {
                        client_request(int type, const char* client, int req_id, const char* subj, const char* desc, GDBusMethodInvocation *inv);
                        ~client_request();
 
-                       bool set_peer_creds(const char *smack_label, const char *zone);
+                       bool set_peer_creds(const char *smack_label);
                        const char* get_app_id();
 
                        bool reply(int error);
index 0837a82f001b97d6f7a4f132ece346868bd69563..18cec7b74417aaddfdc92b65fece456bf9188df0 100644 (file)
@@ -22,7 +22,6 @@
 #include <provider_iface.h>
 #include "server.h"
 #include "context_mgr_impl.h"
-#include "zone_util_impl.h"
 #include "access_control/privilege.h"
 
 /* Analyzer Headers */
@@ -139,17 +138,17 @@ void ctx::context_manager_impl::assign_request(ctx::request_info* request)
        }
 }
 
-bool ctx::context_manager_impl::is_supported(const char* subject, const char* zone)
+bool ctx::context_manager_impl::is_supported(const char* subject)
 {
        subject_provider_map_t::iterator it = subject_provider_map.find(subject);
        IF_FAIL_RETURN(it != subject_provider_map.end(), false);
 
-       return it->second->is_supported(subject, zone);
+       return it->second->is_supported(subject);
 }
 
 void ctx::context_manager_impl::is_supported(request_info *request)
 {
-       if (is_supported(request->get_subject(), request->get_zone_name()))
+       if (is_supported(request->get_subject()))
                request->reply(ERR_NONE);
        else
                request->reply(ERR_NOT_SUPPORTED);
@@ -158,9 +157,9 @@ void ctx::context_manager_impl::is_supported(request_info *request)
 }
 
 ctx::context_manager_impl::request_list_t::iterator
-ctx::context_manager_impl::find_request(request_list_t& r_list, std::string subject, json& option, const char* zone)
+ctx::context_manager_impl::find_request(request_list_t& r_list, std::string subject, json& option)
 {
-       return find_request(r_list.begin(), r_list.end(), subject, option, zone);
+       return find_request(r_list.begin(), r_list.end(), subject, option);
 }
 
 ctx::context_manager_impl::request_list_t::iterator
@@ -176,12 +175,12 @@ ctx::context_manager_impl::find_request(request_list_t& r_list, std::string clie
 }
 
 ctx::context_manager_impl::request_list_t::iterator
-ctx::context_manager_impl::find_request(request_list_t::iterator begin, request_list_t::iterator end, std::string subject, json& option, const char* zone)
+ctx::context_manager_impl::find_request(request_list_t::iterator begin, request_list_t::iterator end, std::string subject, json& option)
 {
        //TODO: Do we need to consider the case that the inparam option is a subset of the request description?
        request_list_t::iterator it;
        for (it = begin; it != end; ++it) {
-               if (subject == (*it)->get_subject() && option == (*it)->get_description() && STR_EQ(zone, (*it)->get_zone_name())) {
+               if (subject == (*it)->get_subject() && option == (*it)->get_description()) {
                        break;
                }
        }
@@ -214,8 +213,6 @@ bool ctx::context_manager_impl::check_permission(ctx::request_info* request)
 
        IF_FAIL_RETURN_TAG(!STR_EQ(app_id, TRIGGER_CLIENT_NAME), true, _D, "Skipping permission check for Trigger");
 
-       scope_zone_joiner sz(request->get_zone_name());
-
        bool allowed = ctx::privilege_manager::is_allowed(app_id, request->get_subject());
        if (!allowed) {
                _W("Permission denied");
@@ -229,14 +226,14 @@ bool ctx::context_manager_impl::check_permission(ctx::request_info* request)
 
 void ctx::context_manager_impl::subscribe(ctx::request_info *request)
 {
-       _I(CYAN("[%s] '%s' subscribes '%s' (RID-%d)"), request->get_zone_name(), request->get_client(), request->get_subject(), request->get_id());
+       _I(CYAN("'%s' subscribes '%s' (RID-%d)"), request->get_client(), request->get_subject(), request->get_id());
        IF_FAIL_VOID(check_permission(request));
 
        context_provider_iface *provider = get_provider(request);
        IF_FAIL_VOID(provider);
 
        ctx::json request_result;
-       int error = provider->subscribe(request->get_subject(), request->get_description().str(), &request_result, request->get_zone_name());
+       int error = provider->subscribe(request->get_subject(), request->get_description().str(), &request_result);
 
        _D("Analyzer returned %d", error);
 
@@ -250,7 +247,7 @@ void ctx::context_manager_impl::subscribe(ctx::request_info *request)
 
 void ctx::context_manager_impl::unsubscribe(ctx::request_info *request)
 {
-       _I(CYAN("[%s] '%s' unsubscribes RID-%d"), request->get_zone_name(), request->get_client(), request->get_id());
+       _I(CYAN("'%s' unsubscribes RID-%d"), request->get_client(), request->get_id());
 
        // Search the subscribe request to be removed
        request_list_t::iterator target = find_request(subscribe_request_list, request->get_client(), request->get_id());
@@ -267,7 +264,7 @@ void ctx::context_manager_impl::unsubscribe(ctx::request_info *request)
        subscribe_request_list.erase(target);
 
        // Check if there exist the same requests
-       if (find_request(subscribe_request_list, req_found->get_subject(), req_found->get_description(), req_found->get_zone_name()) != subscribe_request_list.end()) {
+       if (find_request(subscribe_request_list, req_found->get_subject(), req_found->get_description()) != subscribe_request_list.end()) {
                // Do not stop detecting the subject
                _D("A same request from '%s' exists", req_found->get_client());
                request->reply(ERR_NONE);
@@ -286,7 +283,7 @@ void ctx::context_manager_impl::unsubscribe(ctx::request_info *request)
        }
 
        // Stop detecting the subject
-       int error = ca->second->unsubscribe(req_found->get_subject(), req_found->get_description(), req_found->get_zone_name());
+       int error = ca->second->unsubscribe(req_found->get_subject(), req_found->get_description());
        request->reply(error);
        delete request;
        delete req_found;
@@ -294,14 +291,14 @@ void ctx::context_manager_impl::unsubscribe(ctx::request_info *request)
 
 void ctx::context_manager_impl::read(ctx::request_info *request)
 {
-       _I(CYAN("[%s] '%s' reads '%s' (RID-%d)"), request->get_zone_name(), request->get_client(), request->get_subject(), request->get_id());
+       _I(CYAN("'%s' reads '%s' (RID-%d)"), request->get_client(), request->get_subject(), request->get_id());
        IF_FAIL_VOID(check_permission(request));
 
        context_provider_iface *provider = get_provider(request);
        IF_FAIL_VOID(provider);
 
        ctx::json request_result;
-       int error = provider->read(request->get_subject(), request->get_description().str(), &request_result, request->get_zone_name());
+       int error = provider->read(request->get_subject(), request->get_description().str(), &request_result);
 
        _D("Analyzer returned %d", error);
 
@@ -315,14 +312,14 @@ void ctx::context_manager_impl::read(ctx::request_info *request)
 
 void ctx::context_manager_impl::write(ctx::request_info *request)
 {
-       _I(CYAN("[%s] '%s' writes '%s' (RID-%d)"), request->get_zone_name(), request->get_client(), request->get_subject(), request->get_id());
+       _I(CYAN("'%s' writes '%s' (RID-%d)"), request->get_client(), request->get_subject(), request->get_id());
        IF_FAIL_VOID(check_permission(request));
 
        context_provider_iface *provider = get_provider(request);
        IF_FAIL_VOID(provider);
 
        ctx::json request_result;
-       int error = provider->write(request->get_subject(), request->get_description(), &request_result, request->get_zone_name());
+       int error = provider->write(request->get_subject(), request->get_description(), &request_result);
 
        _D("Analyzer returned %d", error);
 
@@ -330,7 +327,7 @@ void ctx::context_manager_impl::write(ctx::request_info *request)
        delete request;
 }
 
-bool ctx::context_manager_impl::_publish(const char* subject, ctx::json option, int error, ctx::json data_updated, const char* zone)
+bool ctx::context_manager_impl::_publish(const char* subject, ctx::json option, int error, ctx::json data_updated)
 {
        IF_FAIL_RETURN_TAG(subject, false, _E, "Invalid parameter");
 
@@ -338,29 +335,28 @@ bool ctx::context_manager_impl::_publish(const char* subject, ctx::json option,
        _J("Option", option);
 
        request_list_t::iterator end = subscribe_request_list.end();
-       request_list_t::iterator target = find_request(subscribe_request_list.begin(), end, subject, option, zone);
+       request_list_t::iterator target = find_request(subscribe_request_list.begin(), end, subject, option);
 
        while (target != end) {
                if (!(*target)->publish(error, data_updated)) {
                        return false;
                }
-               target = find_request(++target, end, subject, option, zone);
+               target = find_request(++target, end, subject, option);
        }
 
        return true;
 }
 
-bool ctx::context_manager_impl::_reply_to_read(const char* subject, ctx::json option, int error, ctx::json data_read, const char* zone)
+bool ctx::context_manager_impl::_reply_to_read(const char* subject, ctx::json option, int error, ctx::json data_read)
 {
        IF_FAIL_RETURN_TAG(subject, false, _E, "Invalid parameter");
 
        _I("Sending data of '%s'", subject);
        _J("Option", option);
        _J("Data", data_read);
-       _SI("Zone: '%s'", zone);
 
        request_list_t::iterator end = read_request_list.end();
-       request_list_t::iterator target = find_request(read_request_list.begin(), end, subject, option, zone);
+       request_list_t::iterator target = find_request(read_request_list.begin(), end, subject, option);
        request_list_t::iterator prev;
 
        ctx::json dummy;
@@ -368,7 +364,7 @@ bool ctx::context_manager_impl::_reply_to_read(const char* subject, ctx::json op
        while (target != end) {
                (*target)->reply(error, dummy, data_read);
                prev = target;
-               target = find_request(++target, end, subject, option, zone);
+               target = find_request(++target, end, subject, option);
 
                delete *prev;
                read_request_list.erase(prev);
@@ -381,16 +377,14 @@ struct published_data_s {
        int type;
        ctx::context_manager_impl *mgr;
        std::string subject;
-       std::string zone;
        int error;
        ctx::json option;
        ctx::json data;
-       published_data_s(int t, ctx::context_manager_impl *m, const char* s, ctx::json& o, int e, ctx::json& d, const char* z)
+       published_data_s(int t, ctx::context_manager_impl *m, const char* s, ctx::json& o, int e, ctx::json& d)
                : type(t), mgr(m), subject(s), error(e)
        {
                option = o.str();
                data = d.str();
-               zone = z;
        }
 };
 
@@ -400,10 +394,10 @@ gboolean ctx::context_manager_impl::thread_switcher(gpointer data)
 
        switch (tuple->type) {
                case REQ_SUBSCRIBE:
-                       tuple->mgr->_publish(tuple->subject.c_str(), tuple->option, tuple->error, tuple->data, tuple->zone.c_str());
+                       tuple->mgr->_publish(tuple->subject.c_str(), tuple->option, tuple->error, tuple->data);
                        break;
                case REQ_READ:
-                       tuple->mgr->_reply_to_read(tuple->subject.c_str(), tuple->option, tuple->error, tuple->data, tuple->zone.c_str());
+                       tuple->mgr->_reply_to_read(tuple->subject.c_str(), tuple->option, tuple->error, tuple->data);
                        break;
                default:
                        _W("Invalid type");
@@ -413,11 +407,11 @@ gboolean ctx::context_manager_impl::thread_switcher(gpointer data)
        return FALSE;
 }
 
-bool ctx::context_manager_impl::publish(const char* subject, ctx::json& option, int error, ctx::json& data_updated, const char* zone)
+bool ctx::context_manager_impl::publish(const char* subject, ctx::json& option, int error, ctx::json& data_updated)
 {
-       IF_FAIL_RETURN_TAG(subject && zone, false, _E, "Invalid parameter");
+       IF_FAIL_RETURN_TAG(subject, false, _E, "Invalid parameter");
 
-       published_data_s *tuple = new(std::nothrow) published_data_s(REQ_SUBSCRIBE, this, subject, option, error, data_updated, zone);
+       published_data_s *tuple = new(std::nothrow) published_data_s(REQ_SUBSCRIBE, this, subject, option, error, data_updated);
        IF_FAIL_RETURN_TAG(tuple, false, _E, "Memory allocation failed");
 
        g_idle_add(thread_switcher, tuple);
@@ -425,11 +419,11 @@ bool ctx::context_manager_impl::publish(const char* subject, ctx::json& option,
        return true;
 }
 
-bool ctx::context_manager_impl::reply_to_read(const char* subject, ctx::json& option, int error, ctx::json& data_read, const char* zone)
+bool ctx::context_manager_impl::reply_to_read(const char* subject, ctx::json& option, int error, ctx::json& data_read)
 {
-       IF_FAIL_RETURN_TAG(subject && zone, false, _E, "Invalid parameter");
+       IF_FAIL_RETURN_TAG(subject, false, _E, "Invalid parameter");
 
-       published_data_s *tuple = new(std::nothrow) published_data_s(REQ_READ, this, subject, option, error, data_read, zone);
+       published_data_s *tuple = new(std::nothrow) published_data_s(REQ_READ, this, subject, option, error, data_read);
        IF_FAIL_RETURN_TAG(tuple, false, _E, "Memory allocation failed");
 
        g_idle_add(thread_switcher, tuple);
index 9aa8305ce24015eea20ad11f8eaf898a5749d700..c6026d39530bb6c39a12067007dcd7beb4e9472e 100644 (file)
@@ -38,12 +38,12 @@ namespace ctx {
                void release();
 
                void assign_request(ctx::request_info *request);
-               bool is_supported(const char *subject, const char *zone);
+               bool is_supported(const char *subject);
 
                /* From the interface class */
                bool register_provider(const char *subject, ctx::context_provider_iface *cp);
-               bool publish(const char *subject, ctx::json& option, int error, ctx::json& data_updated, const char *zone);
-               bool reply_to_read(const char *subject, ctx::json& option, int error, ctx::json& data_read, const char *zone);
+               bool publish(const char *subject, ctx::json& option, int error, ctx::json& data_updated);
+               bool reply_to_read(const char *subject, ctx::json& option, int error, ctx::json& data_read);
 
        private:
                typedef std::vector<context_provider_iface*> provider_list_t;
@@ -66,12 +66,12 @@ namespace ctx {
                bool check_permission(request_info *request);
 
                static gboolean thread_switcher(gpointer data);
-               bool _publish(const char *subject, ctx::json option, int error, ctx::json data_updated, const char *zone);
-               bool _reply_to_read(const char *subject, ctx::json option, int error, ctx::json data_read, const char *zone);
+               bool _publish(const char *subject, ctx::json option, int error, ctx::json data_updated);
+               bool _reply_to_read(const char *subject, ctx::json option, int error, ctx::json data_read);
 
-               request_list_t::iterator find_request(request_list_t& r_list, std::string subject, json& option, const char *zone);
+               request_list_t::iterator find_request(request_list_t& r_list, std::string subject, json& option);
                request_list_t::iterator find_request(request_list_t& r_list, std::string client, int req_id);
-               request_list_t::iterator find_request(request_list_t::iterator begin, request_list_t::iterator end, std::string subject, json& option, const char *zone);
+               request_list_t::iterator find_request(request_list_t::iterator begin, request_list_t::iterator end, std::string subject, json& option);
 
        };      /* class context_manager_impl */
 
index 0fb6c71fbbe00fca8298f14a34c41dd924228b9a..2f2b749847b17c7b662f386939be1178a5cb0bb7 100644 (file)
@@ -31,34 +31,32 @@ static void* env = NULL;
 static ctx::rule_manager* rule_mgr = NULL;
 static int string_to_int(std::string str);
 
-ctx::clips_handler::clips_handler()
+ctx::clips_handler::clips_handler(ctx::rule_manager* rm)
 {
+       rule_mgr = rm;
+       init_environment();
+       _D(YELLOW("Clips handler initialized"));
 }
 
 ctx::clips_handler::~clips_handler()
 {
        if (env) {
                DestroyEnvironment(env);
+               env = NULL;
        }
-}
-
-bool ctx::clips_handler::init(ctx::rule_manager* rm)
-{
-       rule_mgr = rm;
 
-       int error = init_environment(env);
-       IF_FAIL_RETURN(error == ERR_NONE, false);
-
-       bool ret = define_global_variable_string("zone", "");
-       IF_FAIL_RETURN(ret, false);
-
-       return true;
+       _D(YELLOW("Clips handler destroyed"));
 }
 
-int ctx::clips_handler::init_environment(void* &environment)
+int ctx::clips_handler::init_environment(void)
 {
-       environment = CreateEnvironment();
-       if (!environment) {
+       if (env) {
+               _D("Clips environment already created");
+               return ERR_NONE;
+       }
+
+       env = CreateEnvironment();
+       if (!env) {
                _E("Create environment failed");
                return ERR_OPERATION_FAILED;
        }
@@ -73,8 +71,7 @@ int ctx::clips_handler::init_environment(void* &environment)
                return ERR_OUT_OF_MEMORY;
        }
 
-       EnvDefineFunction2(environment, func_name, 'i', PTIEF execute_action, func_name, restrictions);
-
+       EnvDefineFunction2(env, func_name, 'i', PTIEF execute_action, func_name, restrictions);
        free(func_name);
        free(restrictions);
 
@@ -190,12 +187,9 @@ int ctx::clips_handler::unmake_instance(std::string& instance_name)
        return ERR_NONE;
 }
 
-int ctx::clips_handler::execute_action()
+int ctx::clips_handler::execute_action(void)
 {
-       if (!env) {
-               _E("Environment not created");
-               return ERR_OPERATION_FAILED;
-       }
+       ASSERT_NOT_NULL(env);
 
        const char* result = EnvRtnLexeme(env, 1);
        if (!result) {
@@ -214,6 +208,7 @@ int ctx::clips_handler::execute_action()
 bool ctx::clips_handler::find_instance(std::string& instance_name)
 {
        ASSERT_NOT_NULL(env);
+
        if (find_instance_internal(instance_name)) {
                _D("[%s] already exists", instance_name.c_str());
                return true;
index 8d3f6a626e1fc1ffbe81e6c9bdc5e32bfce35e36..0ebb74782915390ab5307677d1e9aea6a725c582 100644 (file)
@@ -24,9 +24,8 @@ namespace ctx {
 
        class clips_handler {
                public:
-                       clips_handler();
+                       clips_handler(ctx::rule_manager* rm);
                        ~clips_handler();
-                       bool init(ctx::rule_manager* rm);
 
                        int define_template(std::string& script);
                        int define_class(std::string& script);
@@ -36,13 +35,14 @@ namespace ctx {
                        int route_string_command(std::string& fact);
                        int make_instance(std::string& script);
                        int unmake_instance(std::string& instance_name);
-                       static int execute_action();
+                       static int execute_action(void);
                        bool find_instance(std::string& instance_name);
                        bool define_global_variable_string(std::string variable_name, std::string value);
                        bool set_global_variable_string(std::string variable_name, std::string value);
 
                private:
-                       int init_environment(void* &environment);
+                       clips_handler();
+                       int init_environment(void);
                        int env_build(std::string& script);
                        void* find_instance_internal(std::string& instance_name);
 
index cce3bab3e8b4ae377fa0c14dab55224f9489481f..ed9d6a7ab4cbf17beba4970165a88b431f6ae412 100644 (file)
@@ -22,8 +22,6 @@
 #include "timer_types.h"
 
 static ctx::fact_reader *reader = NULL;
-typedef std::map<std::string, ctx::trigger_timer> timer_map_t;
-static timer_map_t timer_map;  // <zone_name, timer>
 
 ctx::context_monitor::context_monitor()
 {
@@ -31,27 +29,30 @@ ctx::context_monitor::context_monitor()
 
 ctx::context_monitor::~context_monitor()
 {
+       delete timer;
 }
 
 bool ctx::context_monitor::init(ctx::fact_reader* fr, ctx::context_trigger* tr)
 {
        reader = fr;
        trigger = tr;
+       timer = new(std::nothrow) trigger_timer(trigger);
+       IF_FAIL_RETURN_TAG(timer, false, _E, "Memory allocation failed");
 
        return true;
 }
 
-int ctx::context_monitor::subscribe(int rule_id, std::string subject, ctx::json event, const char* zone)
+int ctx::context_monitor::subscribe(int rule_id, std::string subject, ctx::json event)
 {
        if (subject.compare(TIMER_EVENT_SUBJECT) == 0) {
                // option is event json in case of ON_TIME
-               return subscribe_timer(event, zone);
+               return subscribe_timer(event);
        }
 
        ctx::json eoption = NULL;
        event.get(NULL, CT_RULE_EVENT_OPTION, &eoption);
 
-       int req_id = reader->subscribe(subject.c_str(), &eoption, zone, true);
+       int req_id = reader->subscribe(subject.c_str(), &eoption, true);
        IF_FAIL_RETURN_TAG(req_id > 0, ERR_OPERATION_FAILED, _E, "Subscribe event failed");
        _D(YELLOW("Subscribe event(rule%d). req%d"), rule_id, req_id);
        request_map[rule_id] = req_id;
@@ -60,10 +61,10 @@ int ctx::context_monitor::subscribe(int rule_id, std::string subject, ctx::json
        return ERR_NONE;
 }
 
-int ctx::context_monitor::unsubscribe(int rule_id, std::string subject, ctx::json option, const char* zone)
+int ctx::context_monitor::unsubscribe(int rule_id, std::string subject, ctx::json option)
 {
        if (subject.compare(TIMER_EVENT_SUBJECT) == 0) {
-               return unsubscribe_timer(option, zone);
+               return unsubscribe_timer(option);
        }
 
        _D(YELLOW("Unsubscribe event(rule%d). req%d"), rule_id, request_map[rule_id]);
@@ -79,7 +80,7 @@ int ctx::context_monitor::unsubscribe(int rule_id, std::string subject, ctx::jso
        return ERR_NONE;
 }
 
-int ctx::context_monitor::read_time(ctx::json* result, const char* zone)
+int ctx::context_monitor::read_time(ctx::json* result)
 {
        int dom = ctx::trigger_timer::get_day_of_month();
        (*result).set(NULL, TIMER_RESPONSE_KEY_DAY_OF_MONTH, dom);
@@ -93,15 +94,15 @@ int ctx::context_monitor::read_time(ctx::json* result, const char* zone)
        return ERR_NONE;
 }
 
-int ctx::context_monitor::read(std::string subject, json option, const char* zone, ctx::json* result)
+int ctx::context_monitor::read(std::string subject, json option, ctx::json* result)
 {
        bool ret;
        if (subject.compare(TIMER_CONDITION_SUBJECT) == 0) {
-               return read_time(result, zone);
+               return read_time(result);
        }
 
        context_fact fact;
-       ret = reader->read(subject.c_str(), &option, zone, fact);
+       ret = reader->read(subject.c_str(), &option, fact);
        IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Read fact failed");
 
        *result = fact.get_data();
@@ -144,18 +145,7 @@ static int arrange_day_of_week(ctx::json day_info)
        return result;
 }
 
-timer_map_t::iterator ctx::context_monitor::get_zone_timer(std::string zone)
-{
-       timer_map_t::iterator it = timer_map.find(zone);
-
-       if (it == timer_map.end()) {
-               timer_map.insert(std::pair<std::string, ctx::trigger_timer>(zone, ctx::trigger_timer(trigger, zone)));
-       }
-
-       return timer_map.find(zone);
-}
-
-int ctx::context_monitor::subscribe_timer(ctx::json option, const char* zone)
+int ctx::context_monitor::subscribe_timer(ctx::json option)
 {
        ctx::json day_info;
        ctx::json time_info;
@@ -177,15 +167,14 @@ int ctx::context_monitor::subscribe_timer(ctx::json option, const char* zone)
 
        // Time option processing
        int time; // minute
-       timer_map_t::iterator timer = get_zone_timer(zone);
        for (int i = 0; time_info.get_array_elem(NULL, CT_RULE_DATA_VALUE_ARR, i, &time); i++) {
-               (timer->second).add(time, dow);
+               timer->add(time, dow);
        }
 
        return ERR_NONE;
 }
 
-int ctx::context_monitor::unsubscribe_timer(ctx::json option, const char* zone)
+int ctx::context_monitor::unsubscribe_timer(ctx::json option)
 {
        ctx::json day_info;
        ctx::json time_info;
@@ -207,24 +196,19 @@ int ctx::context_monitor::unsubscribe_timer(ctx::json option, const char* zone)
 
        // Time option processing
        int time; // minute
-       timer_map_t::iterator timer = get_zone_timer(zone);
        for (int i = 0; time_info.get_array_elem(NULL, CT_RULE_DATA_VALUE_ARR, i, &time); i++) {
-               (timer->second).remove(time, dow);
-       }
-
-       if ((timer->second).empty()) {
-               timer_map.erase(timer);
+               timer->remove(time, dow);
        }
 
        return ERR_NONE;
 }
 
-bool ctx::context_monitor::is_supported(std::string subject, const char* zone)
+bool ctx::context_monitor::is_supported(std::string subject)
 {
        if (subject.compare(TIMER_EVENT_SUBJECT) == 0
                        || subject.compare(TIMER_CONDITION_SUBJECT) == 0) {
                return true;
        }
 
-       return reader->is_supported(subject.c_str(), zone);
+       return reader->is_supported(subject.c_str());
 }
index 48d4f0fefb98a81ab3ec4dc85bfc12c31499445f..678107a9f48584f449dedb91582f6f675cfe2e3a 100644 (file)
@@ -27,28 +27,28 @@ namespace ctx {
        class context_fact;
 
        class context_monitor {
-          public:
-                       context_monitor();
-                       ~context_monitor();
-                       bool init(ctx::fact_reader* fr, ctx::context_trigger* tr);
-
-                       int subscribe(int rule_id, std::string subject, ctx::json event, const char* zone);
-                       int unsubscribe(int rule_id, std::string subject, ctx::json option, const char* zone);
-                       int read(std::string subject, json option, const char* zone, ctx::json* result);
-                       bool is_supported(std::string subject, const char* zone);
-
-               private:
-                       std::map<std::string, ctx::trigger_timer>::iterator get_zone_timer(std::string zone);
-                       int subscribe_timer(ctx::json option, const char* zone);
-                       int unsubscribe_timer(ctx::json option, const char* zone);
-                       int read_day_of_month(ctx::json* result, const char* zone);
-                       int read_day_of_week(ctx::json* result, const char* zone);
-                       int read_time(ctx::json* result, const char* zone);
-                       std::map<int, int> request_map; // <rule_id, fact_read_req_id>
-                       std::map<int, int> read_req_cnt_map;    // <fact_read_req_id, count>
-                       ctx::context_trigger* trigger;
-
-   };  /* class context_monitor */
+       public:
+               context_monitor();
+               ~context_monitor();
+               bool init(ctx::fact_reader* fr, ctx::context_trigger* tr);
+
+               int subscribe(int rule_id, std::string subject, ctx::json event);
+               int unsubscribe(int rule_id, std::string subject, ctx::json option);
+               int read(std::string subject, json option, ctx::json* result);
+               bool is_supported(std::string subject);
+
+       private:
+               int subscribe_timer(ctx::json option);
+               int unsubscribe_timer(ctx::json option);
+               int read_day_of_month(ctx::json* result);
+               int read_day_of_week(ctx::json* result);
+               int read_time(ctx::json* result);
+               std::map<int, int> request_map; // <rule_id, fact_read_req_id>
+               std::map<int, int> read_req_cnt_map;    // <fact_read_req_id, count>
+               ctx::context_trigger* trigger;
+               ctx::trigger_timer* timer;
+
+       };      /* class context_monitor */
 
 }      /* namespace ctx */
 
index 85ee3da6666c038ba251167b9c117a176f8d9a55..960f59d1032f40377ee6da36ed9c098f4609009a 100644 (file)
@@ -23,16 +23,13 @@ ctx::context_fact::context_fact()
 {
 }
 
-ctx::context_fact::context_fact(int id, int err, const char* s, ctx::json& o, ctx::json& d, const char* z)
+ctx::context_fact::context_fact(int id, int err, const char* s, ctx::json& o, ctx::json& d)
        : req_id(id)
        , error(err)
        , subject(s)
        , option(o)
        , data(d)
 {
-       if (z) {
-               zone_name = z;
-       }
 }
 
 ctx::context_fact::~context_fact()
@@ -64,11 +61,6 @@ void ctx::context_fact::set_data(ctx::json& d)
        data = d;
 }
 
-void ctx::context_fact::set_zone_name(const char* z)
-{
-       zone_name = z;
-}
-
 int ctx::context_fact::get_req_id()
 {
        return req_id;
@@ -84,11 +76,6 @@ const char* ctx::context_fact::get_subject()
        return subject.c_str();
 }
 
-const char* ctx::context_fact::get_zone_name()
-{
-       return zone_name.c_str();
-}
-
 ctx::json& ctx::context_fact::get_option()
 {
        return option;
index 14ff95e9e02df94cf5c523a183db7e2cf4350cc3..9411b68732e37c0afb85a3bf75057750083b32d0 100644 (file)
@@ -29,24 +29,21 @@ namespace ctx {
                        std::string subject;
                        ctx::json option;
                        ctx::json data;
-                       std::string zone_name;
 
                public:
                        context_fact();
-                       context_fact(int id, int err, const char* s, ctx::json& o, ctx::json& d, const char* z);
+                       context_fact(int id, int err, const char* s, ctx::json& o, ctx::json& d);
                        ~context_fact();
 
                        void set_req_id(int id);
                        void set_error(int err);
                        void set_subject(const char* s);
                        void set_option(ctx::json& o);
-                       void set_zone_name(const char* z);
                        void set_data(ctx::json& d);
 
                        int get_req_id();
                        int get_error();
                        const char* get_subject();
-                       const char* get_zone_name();
                        ctx::json& get_option();
                        ctx::json& get_data();
        };
index cbce51db150adfdbcb457bc0db15712842bd9403..f8935eae7c8c66e477ac8e7b964beb08f51a83ec 100644 (file)
@@ -59,7 +59,7 @@ ctx::fact_reader::~fact_reader()
        subscr_list.clear();
 }
 
-int ctx::fact_reader::find_sub(const char* subject, json* option, const char* zone)
+int ctx::fact_reader::find_sub(const char* subject, json* option)
 {
        json opt_j;
        if (option) {
@@ -67,7 +67,7 @@ int ctx::fact_reader::find_sub(const char* subject, json* option, const char* zo
        }
 
        for (subscr_list_t::iterator it = subscr_list.begin(); it != subscr_list.end(); ++it) {
-               if ((*it)->subject == subject && (*it)->option == opt_j && (*it)->zone_name == zone) {
+               if ((*it)->subject == subject && (*it)->option == opt_j) {
                        return (*it)->sid;
                }
        }
@@ -75,16 +75,16 @@ int ctx::fact_reader::find_sub(const char* subject, json* option, const char* zo
        return -1;
 }
 
-bool ctx::fact_reader::add_sub(int sid, const char* subject, json* option, const char* zone)
+bool ctx::fact_reader::add_sub(int sid, const char* subject, json* option)
 {
-       subscr_info_s *info = new(std::nothrow) subscr_info_s(sid, subject, option, zone);
+       subscr_info_s *info = new(std::nothrow) subscr_info_s(sid, subject, option);
        IF_FAIL_RETURN_TAG(info, false, _E, "Memory allocation failed");
 
        subscr_list.push_back(info);
        return true;
 }
 
-void ctx::fact_reader::remove_sub(const char* subject, json* option, const char* zone)
+void ctx::fact_reader::remove_sub(const char* subject, json* option)
 {
        json opt_j;
        if (option) {
@@ -92,7 +92,7 @@ void ctx::fact_reader::remove_sub(const char* subject, json* option, const char*
        }
 
        for (subscr_list_t::iterator it = subscr_list.begin(); it != subscr_list.end(); ++it) {
-               if ((*it)->subject == subject && (*it)->option == opt_j && (*it)->zone_name == zone) {
+               if ((*it)->subject == subject && (*it)->option == opt_j) {
                        delete *it;
                        subscr_list.erase(it);
                        return;
@@ -118,20 +118,18 @@ gboolean ctx::fact_reader::send_request(gpointer data)
        return FALSE;
 }
 
-bool ctx::fact_reader::is_supported(const char* subject, const char* zone)
+bool ctx::fact_reader::is_supported(const char* subject)
 {
-       IF_FAIL_RETURN_TAG(zone, false, _E, "'zone' cannot be NULL");
-       return _context_mgr->is_supported(subject, zone);
+       return _context_mgr->is_supported(subject);
 }
 
-int ctx::fact_reader::subscribe(const char* subject, json* option, const char* zone, bool wait_response)
+int ctx::fact_reader::subscribe(const char* subject, json* option, bool wait_response)
 {
-       IF_FAIL_RETURN_TAG(zone, ERR_INVALID_PARAMETER, _E, "'zone' cannot be NULL");
        IF_FAIL_RETURN(subject, ERR_INVALID_PARAMETER);
 
        ctx::scope_mutex sm(&request_mutex);
 
-       int rid = find_sub(subject, option, zone);
+       int rid = find_sub(subject, option);
        if (rid > 0) {
                _D("Duplicated request for %s", subject);
                return rid;
@@ -140,11 +138,11 @@ int ctx::fact_reader::subscribe(const char* subject, json* option, const char* z
        rid = generate_req_id();
 
        fact_request *req = new(std::nothrow) fact_request(REQ_SUBSCRIBE, CLIENT_NAME,
-                       rid, subject, option ? option->str().c_str() : NULL, zone, wait_response ? this : NULL);
+                       rid, subject, option ? option->str().c_str() : NULL, wait_response ? this : NULL);
        IF_FAIL_RETURN_TAG(req, -1, _E, "Memory allocation failed");
 
        g_idle_add(send_request, req);
-       add_sub(rid, subject, option, zone);
+       add_sub(rid, subject, option);
 
        IF_FAIL_RETURN_TAG(wait_response, rid, _D, "Ignoring response for %s", subject);
 
@@ -166,14 +164,13 @@ int ctx::fact_reader::subscribe(const char* subject, json* option, const char* z
        return rid;
 }
 
-void ctx::fact_reader::unsubscribe(const char* subject, json* option, const char* zone)
+void ctx::fact_reader::unsubscribe(const char* subject, json* option)
 {
-       IF_FAIL_VOID_TAG(zone, _E, "'zone' cannot be NULL");
        IF_FAIL_VOID(subject);
 
        ctx::scope_mutex sm(&request_mutex);
 
-       int rid = find_sub(subject, option, zone);
+       int rid = find_sub(subject, option);
        IF_FAIL_VOID_TAG(rid > 0, _W, "Unknown subscription for %s", subject);
 
        unsubscribe(rid);
@@ -181,16 +178,15 @@ void ctx::fact_reader::unsubscribe(const char* subject, json* option, const char
 
 void ctx::fact_reader::unsubscribe(int subscription_id)
 {
-       fact_request *req = new(std::nothrow) fact_request(REQ_UNSUBSCRIBE, CLIENT_NAME, subscription_id, "", NULL, NULL, NULL);
+       fact_request *req = new(std::nothrow) fact_request(REQ_UNSUBSCRIBE, CLIENT_NAME, subscription_id, "", NULL, NULL);
        IF_FAIL_VOID_TAG(req, _E, "Memory allocation failed");
 
        g_idle_add(send_request, req);
        remove_sub(subscription_id);
 }
 
-bool ctx::fact_reader::read(const char* subject, json* option, const char* zone, context_fact& fact)
+bool ctx::fact_reader::read(const char* subject, json* option, context_fact& fact)
 {
-       IF_FAIL_RETURN_TAG(zone, false, _E, "'zone' cannot be NULL");
        IF_FAIL_RETURN(subject, false);
 
        ctx::scope_mutex sm(&request_mutex);
@@ -198,7 +194,7 @@ bool ctx::fact_reader::read(const char* subject, json* option, const char* zone,
        int rid = generate_req_id();
 
        fact_request *req = new(std::nothrow) fact_request(REQ_READ_SYNC, CLIENT_NAME,
-                       rid, subject, option ? option->str().c_str() : NULL, zone, this);
+                       rid, subject, option ? option->str().c_str() : NULL, this);
        IF_FAIL_RETURN_TAG(req, false, _E, "Memory allocation failed");
 
        g_idle_add(send_request, req);
@@ -219,16 +215,12 @@ bool ctx::fact_reader::read(const char* subject, json* option, const char* zone,
        fact.set_req_id(rid);
        fact.set_subject(subject);
        fact.set_data(last_data_read);
-       if (zone) {
-               fact.set_zone_name(zone);
-       }
-
        last_data_read = EMPTY_JSON_OBJECT;
 
        return true;
 }
 
-void ctx::fact_reader::reply_result(int req_id, int error, const char* zone, json* request_result, json* fact)
+void ctx::fact_reader::reply_result(int req_id, int error, json* request_result, json* fact)
 {
        ctx::scope_mutex sm(&request_mutex);
 
@@ -239,7 +231,7 @@ void ctx::fact_reader::reply_result(int req_id, int error, const char* zone, jso
        g_cond_signal(&request_cond);
 }
 
-void ctx::fact_reader::publish_fact(int req_id, int error, const char* zone, const char* subject, json* option, json* fact)
+void ctx::fact_reader::publish_fact(int req_id, int error, const char* subject, json* option, json* fact)
 {
-       _trigger->push_fact(req_id, error, subject, *option, *fact, zone);
+       _trigger->push_fact(req_id, error, subject, *option, *fact);
 }
index 2a5192d075fd8bb3f5aeefb3b6c28198ba0d81bc..e52b86e963de8506ab2057166b6dfa1e4f580308 100644 (file)
@@ -31,15 +31,15 @@ namespace ctx {
                        fact_reader(context_manager_impl* mgr, context_trigger* trigger);
                        ~fact_reader();
 
-                       bool is_supported(const char* subject, const char* zone);
+                       bool is_supported(const char* subject);
 
-                       int subscribe(const char* subject, json* option, const char* zone, bool wait_response = false);
-                       void unsubscribe(const char* subject, json* option, const char* zone);
+                       int subscribe(const char* subject, json* option, bool wait_response = false);
+                       void unsubscribe(const char* subject, json* option);
                        void unsubscribe(int subscription_id);
-                       bool read(const char* subject, json* option, const char* zone, context_fact& fact);
+                       bool read(const char* subject, json* option, context_fact& fact);
 
-                       void reply_result(int req_id, int error, const char* zone, json* request_result = NULL, json* fact = NULL);
-                       void publish_fact(int req_id, int error, const char* zone, const char* subject, json* option, json* fact);
+                       void reply_result(int req_id, int error, json* request_result = NULL, json* fact = NULL);
+                       void publish_fact(int req_id, int error, const char* subject, json* option, json* fact);
 
                private:
                        static context_manager_impl* _context_mgr;
@@ -49,24 +49,20 @@ namespace ctx {
                                int sid;
                                std::string subject;
                                ctx::json option;
-                               std::string zone_name;
-                               subscr_info_s(int id, const char* subj, ctx::json* opt, const char* zone)
+                               subscr_info_s(int id, const char* subj, ctx::json* opt)
                                        : sid(id), subject(subj)
                                {
                                        if (opt)
                                                option = *opt;
-
-                                       if (zone)
-                                               zone_name = zone;
                                }
                        };
 
                        typedef std::list<subscr_info_s*> subscr_list_t;
                        subscr_list_t subscr_list;
 
-                       int find_sub(const char* subject, json* option, const char* zone);
-                       bool add_sub(int sid, const char* subject, json* option, const char* zone);
-                       void remove_sub(const char* subject, json* option, const char* zone);
+                       int find_sub(const char* subject, json* option);
+                       bool add_sub(int sid, const char* subject, json* option);
+                       void remove_sub(const char* subject, json* option);
                        void remove_sub(int sid);
 
                        static gboolean send_request(gpointer data);
index ec074b202005c4388f267acf824aaf49ea3223f6..b4017bd847980e587db1710ca96820db00bea0ae 100644 (file)
 #include <types_internal.h>
 #include "fact_request.h"
 
-ctx::fact_request::fact_request(int type, const char* client, int req_id, const char* subj, const char* desc, const char* zone, fact_reader* reader)
+ctx::fact_request::fact_request(int type, const char* client, int req_id, const char* subj, const char* desc, fact_reader* reader)
        : request_info(type, client, req_id, subj, desc)
        , _reader(reader)
        , replied(false)
 {
-       if (zone)
-               _zone_name = zone;
 }
 
 ctx::fact_request::~fact_request()
@@ -34,7 +32,7 @@ ctx::fact_request::~fact_request()
 bool ctx::fact_request::reply(int error)
 {
        IF_FAIL_RETURN(!replied && _reader, true);
-       _reader->reply_result(_req_id, error, _zone_name.c_str());
+       _reader->reply_result(_req_id, error);
        return (replied = true);
 }
 
@@ -42,26 +40,20 @@ bool ctx::fact_request::reply(int error, ctx::json& request_result)
 {
        IF_FAIL_RETURN(!replied && _reader, true);
        IF_FAIL_RETURN(_type != REQ_READ_SYNC, true);
-       _reader->reply_result(_req_id, error, _zone_name.c_str(), &request_result);
+       _reader->reply_result(_req_id, error, &request_result);
        return (replied = true);
 }
 
 bool ctx::fact_request::reply(int error, ctx::json& request_result, ctx::json& data_read)
 {
        IF_FAIL_RETURN(!replied && _reader, true);
-       _reader->reply_result(_req_id, error, _zone_name.c_str(), &request_result, &data_read);
+       _reader->reply_result(_req_id, error, &request_result, &data_read);
        return (replied = true);
 }
 
 bool ctx::fact_request::publish(int error, ctx::json& data)
 {
        IF_FAIL_RETURN(_reader, true);
-       _reader->publish_fact(_req_id, error, _zone_name.c_str(), _subject.c_str(), &get_description(), &data);
+       _reader->publish_fact(_req_id, error, _subject.c_str(), &get_description(), &data);
        return true;
 }
-
-void ctx::fact_request::set_zone_name(const char* zone_name)
-{
-       if (zone_name)
-               _zone_name = zone_name;
-}
index 7832072fe760052c91743a540eaaab22ff0cbd39..6ad52c536757c342d6253a5187872f2ddd32ff71 100644 (file)
@@ -24,10 +24,9 @@ namespace ctx {
 
        class fact_request : public request_info {
                public:
-                       fact_request(int type, const char* client, int req_id, const char* subj, const char* desc, const char* zone, fact_reader* reader);
+                       fact_request(int type, const char* client, int req_id, const char* subj, const char* desc, fact_reader* reader);
                        ~fact_request();
 
-                       void set_zone_name(const char* zone_name);
                        bool reply(int error);
                        bool reply(int error, ctx::json& request_result);
                        bool reply(int error, ctx::json& request_result, ctx::json& data_read);
index ceecc8507067c97abfd92d7138881772072364c5..4fd214fe1c5780a07bcbee60766dccea8e331aa0 100644 (file)
@@ -29,7 +29,6 @@
 #include <context_trigger_types_internal.h>
 #include <context_trigger.h>
 #include <db_mgr.h>
-#include <zone_util.h>
 #include "../access_control/privilege.h"
 #include "rule_manager.h"
 #include "script_generator.h"
@@ -40,9 +39,9 @@
 #define CONDITION_TABLE "context_trigger_condition"
 #define TEMPLATE_TABLE "context_trigger_template"
 
-#define RULE_TABLE_COLUMNS "enabled INTEGER DEFAULT 0 NOT NULL, creator TEXT DEFAULT '' NOT NULL, description TEXT DEFAULT '', details TEXT DEFAULT '' NOT NULL, zone TEXT DEFAULT '' NOT NULL"
-#define EVENT_TABLE_COLUMNS "rule_id INTEGER references context_trigger_rule(row_id) ON DELETE CASCADE NOT NULL, name TEXT DEFAULT '' NOT NULL, instance_name TEXT DEFAULT '', zone TEXT DEFAULT '' NOT NULL"
-#define CONDITION_TABLE_COLUMNS "rule_id INTEGER references context_trigger_rule(row_id) ON DELETE CASCADE NOT NULL, name TEXT DEFAULT '' NOT NULL, option TEXT DEFAULT '', instance_name TEXT DEFAULT '', zone TEXT DEFAULT '' NOT NULL"
+#define RULE_TABLE_COLUMNS "enabled INTEGER DEFAULT 0 NOT NULL, creator TEXT DEFAULT '' NOT NULL, description TEXT DEFAULT '', details TEXT DEFAULT '' NOT NULL"
+#define EVENT_TABLE_COLUMNS "rule_id INTEGER references context_trigger_rule(row_id) ON DELETE CASCADE NOT NULL, name TEXT DEFAULT '' NOT NULL, instance_name TEXT DEFAULT ''"
+#define CONDITION_TABLE_COLUMNS "rule_id INTEGER references context_trigger_rule(row_id) ON DELETE CASCADE NOT NULL, name TEXT DEFAULT '' NOT NULL, option TEXT DEFAULT '', instance_name TEXT DEFAULT ''"
 #define CREATE_TEMPLATE_TABLE "CREATE TABLE IF NOT EXISTS context_trigger_template (name TEXT DEFAULT '' NOT NULL PRIMARY KEY, j_template TEXT DEFAULT '' NOT NULL)"
 #define QUERY_TEMPLATE_TABLE "SELECT j_template FROM context_trigger_template"
 #define FOREIGN_KEYS_ON "PRAGMA foreign_keys = ON"
@@ -51,7 +50,7 @@
 #define UPDATE_RULE_DISABLED_STATEMENT "UPDATE context_trigger_rule SET enabled = 0 WHERE row_id = "
 #define QUERY_NAME_INSTANCE_NAME_AND_TEMPLATE_BY_RULE_ID_STATEMENT "SELECT context_trigger_condition.name, instance_name, j_template as templates FROM context_trigger_condition JOIN context_trigger_template ON (context_trigger_condition.name = context_trigger_template.name) WHERE rule_id = "
 #define QUERY_CONDITION_TEMPLATES_OF_INVOKED_EVENT_STATEMENT "SELECT DISTINCT context_trigger_condition.name, instance_name, option, j_template FROM context_trigger_condition JOIN context_trigger_template ON (context_trigger_condition.name = context_trigger_template.name) WHERE rule_id IN (SELECT row_id FROM context_trigger_rule WHERE enabled = 1 AND row_id IN (SELECT rule_id FROM context_trigger_event WHERE context_trigger_event.instance_name = '"
-#define QUERY_RULE_AND_ZONE_BY_RULE_ID "SELECT details, zone FROM context_trigger_rule WHERE row_id = "
+#define QUERY_RULE_BY_RULE_ID "SELECT details FROM context_trigger_rule WHERE row_id = "
 #define QUERY_EVENT_TEMPLATE_BY_RULE_ID "SELECT j_template FROM context_trigger_template WHERE name IN (SELECT name FROM context_trigger_event WHERE rule_id = "
 #define QUERY_CONDITION_BY_RULE_ID "SELECT name, option FROM context_trigger_condition WHERE rule_id = "
 
@@ -59,6 +58,7 @@
 #define EVENT_KEY_PREFIX "?"
 
 static ctx::context_trigger* trigger = NULL;
+static int enb_rule_cnt = 0;
 
 static int string_to_int(std::string str)
 {
@@ -85,19 +85,17 @@ ctx::rule_manager::rule_manager()
 
 ctx::rule_manager::~rule_manager()
 {
+       destroy_clips();
 }
 
 bool ctx::rule_manager::init(ctx::context_trigger* tr, ctx::fact_reader* fr)
 {
-       int error;
        bool ret;
 
+       clips_h = NULL;
        trigger = tr;
-
-       ret = clips_h.init(this);
-       IF_FAIL_RETURN_TAG(ret, false, _E, "CLIPS handler initialization failed");
-
        ret = c_monitor.init(fr, tr);
+       IF_FAIL_RETURN_TAG(ret, false, _E, "Context monitor initialization failed");
 
        // Create tables into db (rule, event, condition, action, template)
        ret = db_manager::create_table(1, RULE_TABLE, RULE_TABLE_COLUMNS, NULL, NULL);
@@ -112,9 +110,29 @@ bool ctx::rule_manager::init(ctx::context_trigger* tr, ctx::fact_reader* fr)
        ret = db_manager::execute(4, CREATE_TEMPLATE_TABLE, NULL);
        IF_FAIL_RETURN_TAG(ret, false, _E, "Create template table failed");
 
+       // Foreign keys on
+       std::vector<json> record;
+       ret = db_manager::execute_sync(FOREIGN_KEYS_ON, &record);
+       IF_FAIL_RETURN_TAG(ret, false, _E, "Foreign keys on failed");
+
+       ret = reenable_rule();
+
+       return ret;
+}
+
+bool ctx::rule_manager::initialize_clips(void)
+{
+       if (clips_h) {
+               _D("CLIPS handler already initialized");
+               return true;
+       }
+
+       clips_h = new(std::nothrow) clips_handler(this);
+       IF_FAIL_RETURN_TAG(clips_h, false, _E, "CLIPS handler initialization failed");
+
        // Load all templates from DB
        std::vector<json> record;
-       ret = db_manager::execute_sync(QUERY_TEMPLATE_TABLE, &record);
+       bool ret = db_manager::execute_sync(QUERY_TEMPLATE_TABLE, &record);
        IF_FAIL_RETURN_TAG(ret, false, _E, "Query template table failed");
 
        // Make scripts for deftemplate, defclass, make-instance and load them to clips
@@ -126,25 +144,26 @@ bool ctx::rule_manager::init(ctx::context_trigger* tr, ctx::fact_reader* fr)
                ctx::json tmpl = tmpl_str;
 
                std::string deftemplate_str = script_generator::generate_deftemplate(&tmpl);
-               error = clips_h.define_template(deftemplate_str);
+               int error = clips_h->define_template(deftemplate_str);
                IF_FAIL_RETURN_TAG(error == ERR_NONE, false, _E, "Deftemplate failed");
 
                std::string defclass_str = script_generator::generate_defclass(&tmpl);
-               error = clips_h.define_class(defclass_str);
+               error = clips_h->define_class(defclass_str);
                IF_FAIL_RETURN_TAG(error == ERR_NONE, false, _E, "Defclass failed");
 
                std::string makeinstance_str = script_generator::generate_makeinstance(&tmpl);
-               error = clips_h.make_instance(makeinstance_str);
+               error = clips_h->make_instance(makeinstance_str);
                IF_FAIL_RETURN_TAG(error == ERR_NONE, false, _E, "Makeinstance failed");
        }
 
-       // Foreign keys on
-       ret = db_manager::execute_sync(FOREIGN_KEYS_ON, &record);
-       IF_FAIL_RETURN_TAG(ret, false, _E, "Foreign keys on failed");
-
-       ret = reenable_rule();
+       _D(YELLOW("Deftemplate, Defclass, Make-instance completed"));
+       return true;
+}
 
-       return ret;
+void ctx::rule_manager::destroy_clips(void)
+{
+       delete clips_h;
+       clips_h = NULL;
 }
 
 bool ctx::rule_manager::reenable_rule(void)
@@ -166,7 +185,7 @@ bool ctx::rule_manager::reenable_rule(void)
                if (error != ERR_NONE) {
                        _E("Re-enable rule%d failed(%d)", row_id, error);
                } else {
-                       _E("Re-enable rule%d succeeded", row_id);
+                       _D("Re-enable rule%d succeeded", row_id);
                }
        }
 
@@ -327,12 +346,10 @@ bool ctx::rule_manager::rule_equals(ctx::json& lrule, ctx::json& rrule)
        return true;
 }
 
-int64_t ctx::rule_manager::get_duplicated_rule(std::string creator, std::string zone, ctx::json& rule)
+int64_t ctx::rule_manager::get_duplicated_rule(std::string creator, ctx::json& rule)
 {
        std::string q = "SELECT row_id, details FROM context_trigger_rule WHERE creator = '";
        q += creator;
-       q += "' AND zone ='";
-       q += zone;
        q += "'";
 
        std::vector<json> record;
@@ -361,7 +378,7 @@ int64_t ctx::rule_manager::get_duplicated_rule(std::string creator, std::string
        return -1;
 }
 
-int ctx::rule_manager::verify_rule(ctx::json& rule, const char* app_id, const char* zone)
+int ctx::rule_manager::verify_rule(ctx::json& rule, const char* app_id)
 {
        ctx::json details;
        rule.get(NULL, CT_RULE_DETAILS, &details);
@@ -369,7 +386,7 @@ int ctx::rule_manager::verify_rule(ctx::json& rule, const char* app_id, const ch
        std::string e_name;
        rule.get(CT_RULE_DETAILS "." CT_RULE_EVENT, CT_RULE_EVENT_ITEM, &e_name);
 
-       IF_FAIL_RETURN_TAG(c_monitor.is_supported(e_name, zone), ERR_NOT_SUPPORTED, _I, "Event(%s) is not supported", e_name.c_str());
+       IF_FAIL_RETURN_TAG(c_monitor.is_supported(e_name), ERR_NOT_SUPPORTED, _I, "Event(%s) is not supported", e_name.c_str());
 
        if (app_id) {
                if (!ctx::privilege_manager::is_allowed(app_id, e_name.c_str())) {
@@ -383,7 +400,7 @@ int ctx::rule_manager::verify_rule(ctx::json& rule, const char* app_id, const ch
                std::string c_name;
                it.get(NULL, CT_RULE_CONDITION_ITEM, &c_name);
 
-               IF_FAIL_RETURN_TAG(c_monitor.is_supported(c_name, zone), ERR_NOT_SUPPORTED, _I, "Condition(%s) is not supported", c_name.c_str());
+               IF_FAIL_RETURN_TAG(c_monitor.is_supported(c_name), ERR_NOT_SUPPORTED, _I, "Condition(%s) is not supported", c_name.c_str());
 
                if (!ctx::privilege_manager::is_allowed(app_id, c_name.c_str())) {
                        _W("Permission denied for '%s'", c_name.c_str());
@@ -394,18 +411,18 @@ int ctx::rule_manager::verify_rule(ctx::json& rule, const char* app_id, const ch
        return ERR_NONE;
 }
 
-int ctx::rule_manager::add_rule(std::string creator, ctx::json rule, std::string zone, ctx::json* rule_id)
+int ctx::rule_manager::add_rule(std::string creator, ctx::json rule, ctx::json* rule_id)
 {
        // * Insert rule to DB
        bool ret;
        int64_t rid;
 
        // Check if all items are supported && allowed to access
-       int err = verify_rule(rule, creator.c_str(), zone.c_str());
+       int err = verify_rule(rule, creator.c_str());
        IF_FAIL_RETURN(err==ERR_NONE, err);
 
        // Check if duplicated rule exits
-       if ((rid = get_duplicated_rule(creator, zone, rule)) > 0) {
+       if ((rid = get_duplicated_rule(creator, rule)) > 0) {
                // Save rule id
                rule_id->set(NULL, CT_RULE_ID, rid);
                return ERR_NONE;
@@ -420,7 +437,6 @@ int ctx::rule_manager::add_rule(std::string creator, ctx::json rule, std::string
        r_record.set(NULL, "creator", creator);
        r_record.set(NULL, "description", description);
        r_record.set(NULL, "details", details.str());
-       r_record.set(NULL, "zone", zone);
        ret = db_manager::insert_sync(RULE_TABLE, r_record, &rid);
        IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Insert rule to db failed");
 
@@ -440,7 +456,6 @@ int ctx::rule_manager::add_rule(std::string creator, ctx::json rule, std::string
        e_record.set(NULL, "rule_id", rid);
        e_record.set(NULL, "name", e_name);
        e_record.set(NULL, "instance_name", e_inst);
-       e_record.set(NULL, "zone", zone);
        ret = db_manager::insert(1, EVENT_TABLE, e_record, NULL);
        IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Insert event to db failed");
 
@@ -463,7 +478,6 @@ int ctx::rule_manager::add_rule(std::string creator, ctx::json rule, std::string
                c_record.set(NULL, "name", c_name);
                c_record.set(NULL, "option", (c_option_str)? c_option_str : "");
                c_record.set(NULL, "instance_name", c_inst);
-               c_record.set(NULL, "zone", zone);
 
                ret = db_manager::insert(2, CONDITION_TABLE, c_record, NULL);
                IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Insert conditions to db failed");
@@ -493,45 +507,57 @@ int ctx::rule_manager::remove_rule(int rule_id)
 
 int ctx::rule_manager::enable_rule(int rule_id)
 {
+       if (enb_rule_cnt == 0) {
+               initialize_clips();
+       }
+
        // Subscribe event
-       bool ret;
        int error;
+       std::string query;
+       std::string ename;
+       std::string script;
+       std::string r_details;
+       std::string etmpl_str;
+
+       ctx::json jrule;
+       ctx::json jetemplate;
+       ctx::json jevent;
+       ctx::json inst_names;
+
+       std::vector<json> rule_record;
+       std::vector<json> etemplate_record;
+       std::vector<json> cond_record;
+       std::vector<json> record;
+       std::vector<json>::iterator vec_end;
+
        std::string id_str = int_to_string(rule_id);
 
        // Get rule json by rule id;
-       std::string q1 = QUERY_RULE_AND_ZONE_BY_RULE_ID;
-       q1 += int_to_string(rule_id);
-       std::vector<json> rule_record;
-       ret = db_manager::execute_sync(q1.c_str(), &rule_record);
-       IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Query rule by rule id failed");
-       std::string r1;
-       std::string zone;
-       rule_record[0].get(NULL, "details", &r1);
-       rule_record[0].get(NULL, "zone", &zone);
-       ctx::json rule = r1;
-       ctx::json event;
-       rule.get(NULL, CT_RULE_EVENT, &event);
+       query = QUERY_RULE_BY_RULE_ID;
+       query += int_to_string(rule_id);
+       error = (db_manager::execute_sync(query.c_str(), &rule_record))? ERR_NONE : ERR_OPERATION_FAILED;
+       IF_FAIL_CATCH_TAG(error == ERR_NONE, _E, "Query rule by rule id failed");
+
+       rule_record[0].get(NULL, "details", &r_details);
+       jrule = r_details;
+       jrule.get(NULL, CT_RULE_EVENT, &jevent);
 
        // Get event template by rule id
-       std::string q2 = QUERY_EVENT_TEMPLATE_BY_RULE_ID;
-       q2 += int_to_string(rule_id);
-       q2 += ")";
-       std::vector<json> etemplate_record;
-       ret = db_manager::execute_sync(q2.c_str(), &etemplate_record);
-       IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Query event template by rule id failed");
-       std::string r2;
-       etemplate_record[0].get(NULL, "j_template", &r2);
-       ctx::json etemplate = r2;
+       query = QUERY_EVENT_TEMPLATE_BY_RULE_ID;
+       query += int_to_string(rule_id);
+       query += ")";
+       error = (db_manager::execute_sync(query.c_str(), &etemplate_record))? ERR_NONE : ERR_OPERATION_FAILED;
+       IF_FAIL_CATCH_TAG(error == ERR_NONE, _E, "Query event template by rule id failed");
+       etemplate_record[0].get(NULL, "j_template", &etmpl_str);
+       jetemplate = etmpl_str;
 
        // Query name, instance name & template for conditions of the rule
-       std::string q3 = QUERY_NAME_INSTANCE_NAME_AND_TEMPLATE_BY_RULE_ID_STATEMENT;
-       q3 += id_str;
-       std::vector<json> cond_record;
-       ret = db_manager::execute_sync(q3.c_str(), &cond_record);
-       IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Query condition's names, instance names, templates by rule id failed");
+       query = QUERY_NAME_INSTANCE_NAME_AND_TEMPLATE_BY_RULE_ID_STATEMENT;
+       query += id_str;
+       error = (db_manager::execute_sync(query.c_str(), &cond_record))? ERR_NONE : ERR_OPERATION_FAILED;
+       IF_FAIL_CATCH_TAG(error == ERR_NONE, _E, "Query condition's names, instance names, templates by rule id failed");
 
-       ctx::json inst_names;
-       std::vector<json>::iterator vec_end = cond_record.end();
+       vec_end = cond_record.end();
        for (std::vector<json>::iterator vec_pos = cond_record.begin(); vec_pos != vec_end; ++vec_pos) {
                ctx::json elem = *vec_pos;
 
@@ -543,16 +569,17 @@ int ctx::rule_manager::enable_rule(int rule_id)
                elem.get(NULL, "templates", &temp);
                ctx::json ctemplate = temp;
                ctemplate.set(NULL, "instance_name", ciname);
-               // TODO ctemplate (name, instance_name, attributes) now - it is based on form using when templates are inserted into db when rebooting
 
                // For defrule script generation
                inst_names.set(NULL, cname.c_str(), ciname);
 
                if (cname.compare(ciname) != 0) {
-                       if (!clips_h.find_instance(ciname)) {
+                       if (!clips_h->find_instance(ciname)) {
                                std::string makeinst_script = script_generator::generate_makeinstance(&ctemplate);
-                               error = clips_h.make_instance(makeinst_script);
-                               IF_FAIL_RETURN_TAG(error == ERR_NONE, ERR_OPERATION_FAILED, _E, "Add condition instance([%s]) failed", ciname.c_str());
+                               error = (makeinst_script.length() > 0)? ERR_NONE : ERR_OPERATION_FAILED;
+                               IF_FAIL_CATCH_TAG(error == ERR_NONE, _E, "Make instance script generation failed");
+                               error = clips_h->make_instance(makeinst_script);
+                               IF_FAIL_CATCH_TAG(error == ERR_NONE, _E, "Add condition instance([%s]) failed", ciname.c_str());
 
                                cond_cnt_map[ciname] = 1;
                        } else {
@@ -562,28 +589,33 @@ int ctx::rule_manager::enable_rule(int rule_id)
        }
 
        // Subscribe event
-       std::string ename;
-       etemplate.get(NULL, "name", &ename);
-
-       //TODO: set the proper zone
-       error = c_monitor.subscribe(rule_id, ename, event, zone.c_str());
-       IF_FAIL_RETURN(error == ERR_NONE, ERR_OPERATION_FAILED);
+       jetemplate.get(NULL, "name", &ename);
+       error = c_monitor.subscribe(rule_id, ename, jevent);
+       IF_FAIL_CATCH(error == ERR_NONE);
 
        // Generate defrule script and execute it
-       std::string script = script_generator::generate_defrule(id_str, etemplate, rule, &inst_names, zone);
-       error = clips_h.define_rule(script);
-       IF_FAIL_RETURN_TAG(error == ERR_NONE, ERR_OPERATION_FAILED, _E, "Defrule failed");
+       script = script_generator::generate_defrule(id_str, jetemplate, jrule, &inst_names);
+       error = clips_h->define_rule(script);
+       IF_FAIL_CATCH_TAG(error == ERR_NONE, _E, "Defrule failed");
 
        // Update db to set 'enabled'
-       std::string q4 = UPDATE_RULE_ENABLED_STATEMENT;
-       q4 += id_str;
-       std::vector<json> record;
-       ret = db_manager::execute_sync(q4.c_str(), &record);
-       IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Update db failed");
+       query = UPDATE_RULE_ENABLED_STATEMENT;
+       query += id_str;
+       error = (db_manager::execute_sync(query.c_str(), &record))? ERR_NONE : ERR_OPERATION_FAILED;
+       IF_FAIL_CATCH_TAG(error == ERR_NONE, _E, "Update db failed");
 
+       enb_rule_cnt++;
        _D(YELLOW("Enable Rule%d succeeded"), rule_id);
 
        return ERR_NONE;
+
+CATCH:
+       if (enb_rule_cnt <= 0) {
+               enb_rule_cnt = 0;
+               destroy_clips();
+       }
+
+       return error;
 }
 
 std::string ctx::rule_manager::get_instance_name(std::string name, ctx::json& option)
@@ -626,15 +658,13 @@ int ctx::rule_manager::disable_rule(int rule_id)
 
        // For event with options
        // Get rule json by rule id;
-       std::string q1 = QUERY_RULE_AND_ZONE_BY_RULE_ID;
+       std::string q1 = QUERY_RULE_BY_RULE_ID;
        q1 += int_to_string(rule_id);
        std::vector<json> rule_record;
        ret = db_manager::execute_sync(q1.c_str(), &rule_record);
        IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Query rule by rule id failed");
        std::string r1;
-       std::string zone;
        rule_record[0].get(NULL, "details", &r1);
-       rule_record[0].get(NULL, "zone", &zone);
        ctx::json rule = r1;
        ctx::json event;
        rule.get(NULL, CT_RULE_EVENT, &event);
@@ -642,13 +672,13 @@ int ctx::rule_manager::disable_rule(int rule_id)
        event.get(NULL, CT_RULE_EVENT_ITEM, &ename);
 
        // Unsubscribe event
-       error = c_monitor.unsubscribe(rule_id, ename, event, zone.c_str());
+       error = c_monitor.unsubscribe(rule_id, ename, event);
        IF_FAIL_RETURN(error == ERR_NONE, ERR_OPERATION_FAILED);
 
        // Undef rule in clips
        std::string id_str = int_to_string(rule_id);
        std::string script = script_generator::generate_undefrule(id_str);
-       error = clips_h.route_string_command(script);
+       error = clips_h->route_string_command(script);
        IF_FAIL_RETURN_TAG(error == ERR_NONE, ERR_OPERATION_FAILED, _E, "Undefrule failed");
 
        // Update db to set 'disabled'
@@ -658,7 +688,7 @@ int ctx::rule_manager::disable_rule(int rule_id)
        ret = db_manager::execute_sync(q2.c_str(), &record);
        IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Update db failed");
 
-       // Remove condition instances TODO
+       // Remove condition instances
        std::string q3 = "SELECT name, instance_name FROM context_trigger_condition WHERE rule_id = ";
        q3 += id_str;
        std::vector<json> name_record;
@@ -678,7 +708,7 @@ int ctx::rule_manager::disable_rule(int rule_id)
                        cond_cnt_map[ciname]--;
 
                        if (cond_cnt_map[ciname] == 0) {
-                               error = clips_h.unmake_instance(ciname);
+                               error = clips_h->unmake_instance(ciname);
                                IF_FAIL_RETURN(error == ERR_NONE, error);
 
                                cond_cnt_map.erase(ciname);
@@ -686,6 +716,10 @@ int ctx::rule_manager::disable_rule(int rule_id)
                }
        }
 
+       if (--enb_rule_cnt <= 0) {
+               enb_rule_cnt = 0;
+               destroy_clips();
+       }
        return ERR_NONE;
 }
 
@@ -710,19 +744,13 @@ void ctx::rule_manager::make_condition_option_based_on_event_data(ctx::json& cte
        }
 }
 
-void ctx::rule_manager::on_event_received(std::string item, ctx::json option, ctx::json data, std::string zone)
+void ctx::rule_manager::on_event_received(std::string item, ctx::json option, ctx::json data)
 {
        _D(YELLOW("Event(%s(%s) - %s) is invoked."), item.c_str(), option.str().c_str(), data.str().c_str());
        // TODO: Check permission of an event(item), if permission denied, return
 
        int err;
        bool ret;
-       // Set the zone
-       ret = clips_h.set_global_variable_string("zone", zone);
-       if (!ret) {
-               _E("Set clips zone to %s failed", zone.c_str());
-               return;
-       }
 
        // Generate event fact script
        std::string q1 = "SELECT j_template FROM context_trigger_template WHERE name = '";
@@ -740,8 +768,6 @@ void ctx::rule_manager::on_event_received(std::string item, ctx::json option, ct
        std::string e_inst = get_instance_name(item, option);
        std::string query = QUERY_CONDITION_TEMPLATES_OF_INVOKED_EVENT_STATEMENT;
        query += e_inst;
-       query += "' AND zone = '";
-       query += zone;
        query += "'))";
        std::vector<json> conds;
        ret = db_manager::execute_sync(query.c_str(), &conds);
@@ -774,9 +800,9 @@ void ctx::rule_manager::on_event_received(std::string item, ctx::json option, ct
 
                // TODO: Check permission of a condition(cname), if permission granted, read condition data. (or, condition data should be empty json)
 
-               //      Get Context Data and Set the proper zone.
+               //      Get Context Data
                ctx::json condition_data;
-               err = c_monitor.read(cname, coption, zone.c_str(), &condition_data);
+               err = c_monitor.read(cname, coption, &condition_data);
                if (err != ERR_NONE)
                        return;
                _D(YELLOW("Condition(%s(%s) - %s)."), cname.c_str(), coption.str().c_str(), condition_data.str().c_str());
@@ -784,24 +810,24 @@ void ctx::rule_manager::on_event_received(std::string item, ctx::json option, ct
                // Generate ModifyInstance script
                std::string modifyinst_script = script_generator::generate_modifyinstance(ciname, ctemplate, condition_data);
 
-               err = clips_h.route_string_command(modifyinst_script);
+               err = clips_h->route_string_command(modifyinst_script);
                IF_FAIL_VOID_TAG(err == ERR_NONE, _E, "Modify condition instance failed");
        }
 
        // Add fact and Run environment
-       err = clips_h.add_fact(eventfact_str);
+       err = clips_h->add_fact(eventfact_str);
        IF_FAIL_VOID_TAG(err == ERR_NONE, _E, "Assert event fact failed");
 
-       err = clips_h.run_environment();
+       err = clips_h->run_environment();
        IF_FAIL_VOID_TAG(err == ERR_NONE, _E, "Run environment failed");
 
        // Retract event fact
        std::string retract_command = "(retract *)";
-       err = clips_h.route_string_command(retract_command);
+       err = clips_h->route_string_command(retract_command);
        IF_FAIL_VOID_TAG(err == ERR_NONE, _E, "Retract event fact failed");
 }
 
-static void trigger_action_app_control(ctx::json& action, std::string zone)
+static void trigger_action_app_control(ctx::json& action)
 {
        int error;
        std::string appctl_str;
@@ -820,16 +846,6 @@ static void trigger_action_app_control(ctx::json& action, std::string zone)
        app_control_create(&app);
        app_control_import_from_bundle(app, appctl_bundle);
 
-#if _ZONE_ENABLED_
-       char* op;
-       app_control_get_operation(app, &op);
-       app_control_set_operation(app, APP_SVC_OPERATION_JUMP);
-       app_control_add_extra_data(app, APP_SVC_K_JUMP_ZONE_NAME, zone.c_str());
-       if (op != NULL) {
-               app_control_add_extra_data(app, APP_SVC_K_JUMP_ORIGIN_OPERATION, op);
-       }
-#endif
-
        error = app_control_send_launch_request(app, NULL, NULL);
        if (error != APP_CONTROL_ERROR_NONE) {
                _E("Launch request failed(%d)", error);
@@ -841,7 +857,7 @@ static void trigger_action_app_control(ctx::json& action, std::string zone)
        app_control_destroy(app);
 }
 
-static void trigger_action_notification(ctx::json& action, std::string creator, std::string zone)
+static void trigger_action_notification(ctx::json& action, std::string creator)
 {
        int error;
        notification_h notification = notification_create(NOTIFICATION_TYPE_NOTI);
@@ -899,8 +915,6 @@ static void trigger_action_notification(ctx::json& action, std::string creator,
                _E("Set pkgname(%s) failed(%d)", creator.c_str(), error);
        }
 
-       ctx::scope_zone_joiner sz(zone.c_str());
-
        error = notification_post(notification);
        if (error != NOTIFICATION_ERROR_NONE) {
                _E("Post notification failed(%d)", error);
@@ -920,7 +934,7 @@ void ctx::rule_manager::on_rule_triggered(int rule_id)
 {
        _D(YELLOW("Rule%d is triggered"), rule_id);
 
-       std::string q = "SELECT details, creator, zone FROM context_trigger_rule WHERE row_id =";
+       std::string q = "SELECT details, creator FROM context_trigger_rule WHERE row_id =";
        q += int_to_string(rule_id);
 
        std::vector<json> record;
@@ -931,17 +945,15 @@ void ctx::rule_manager::on_rule_triggered(int rule_id)
        ctx::json details = details_str;
        ctx::json action;
        details.get(NULL, CT_RULE_ACTION, &action);
-       std::string zone;
-       record[0].get(NULL, "zone", &zone);
 
        std::string type;
        if (action.get(NULL, CT_RULE_ACTION_TYPE, &type)) {
                if (type.compare(CT_RULE_ACTION_TYPE_APP_CONTROL) == 0) {
-                       trigger_action_app_control(action, zone);
+                       trigger_action_app_control(action);
                } else if (type.compare(CT_RULE_ACTION_TYPE_NOTIFICATION) == 0) {
                        std::string creator;
                        record[0].get(NULL, "creator", &creator);
-                       trigger_action_notification(action, creator, zone);
+                       trigger_action_notification(action, creator);
                }
        }
 }
@@ -990,7 +1002,6 @@ bool ctx::rule_manager::is_rule_enabled(int rule_id)
 
 int ctx::rule_manager::get_rule_by_id(std::string creator, int rule_id, ctx::json* request_result)
 {
-//     std::string q = "SELECT description, details FROM context_trigger_rule WHERE (creator = '";
        std::string q = "SELECT description FROM context_trigger_rule WHERE (creator = '";
        q += creator;
        q += "') and (row_id = ";
@@ -1008,13 +1019,10 @@ int ctx::rule_manager::get_rule_by_id(std::string creator, int rule_id, ctx::jso
        }
 
        std::string description;
-//     std::string details;
        record[0].get(NULL, "description", &description);
-//     record[0].get(NULL, "details", &details);
 
        (*request_result).set(NULL, CT_RULE_ID, rule_id);
        (*request_result).set(NULL, CT_RULE_DESCRIPTION, description);
-//     (*request_result).set(NULL, CT_RULE_DETAILS, details);
 
        return ERR_NONE;
 }
index 11da15735e7bdc9f721ad64390c5b154d5c14d33..b64a6587352d8ddcd020ac1baa8f7132cfed6f3e 100644 (file)
@@ -31,7 +31,7 @@ namespace ctx {
                        rule_manager();
                        ~rule_manager();
                        bool init(ctx::context_trigger* tr, ctx::fact_reader* fr);
-                       int add_rule(std::string creator, ctx::json rule, std::string zone, ctx::json* rule_id);
+                       int add_rule(std::string creator, ctx::json rule, ctx::json* rule_id);
                        int remove_rule(int rule_id);
                        int enable_rule(int rule_id);
                        int disable_rule(int rule_id);
@@ -40,24 +40,25 @@ namespace ctx {
                        int check_rule(std::string creator, int rule_id);
                        bool is_rule_enabled(int rule_id);
 
-                       void on_event_received(std::string item, ctx::json option, ctx::json data, std::string zone);
+                       void on_event_received(std::string item, ctx::json option, ctx::json data);
                        void on_rule_triggered(int rule_id);
 
                private:
-                       clips_handler clips_h;
+                       clips_handler* clips_h;
                        context_monitor c_monitor;
 
                        bool reenable_rule(void);
-                       int verify_rule(ctx::json& rule, const char* app_id, const char* zone);
-                       int64_t get_duplicated_rule(std::string creator, std::string zone, ctx::json& rule);
+                       int verify_rule(ctx::json& rule, const char* app_id);
+                       int64_t get_duplicated_rule(std::string creator, ctx::json& rule);
                        bool rule_data_arr_elem_equals(ctx::json& lelem, ctx::json& relem);
                        bool rule_item_equals(ctx::json& litem, ctx::json& ritem);
                        bool rule_equals(ctx::json& lrule, ctx::json& rrule);
                        std::string get_instance_name(std::string name, ctx::json& condition);
                        void make_condition_option_based_on_event_data(ctx::json& ctemplate, ctx::json& edata, ctx::json* coption);
+                       bool initialize_clips(void);
+                       void destroy_clips(void);
 
                        std::map<std::string, int> cond_cnt_map; // <condition instance name, count>
-
    };  /* class rule_manager */
 
 }      /* namespace ctx */
index d567988fe94bb262bcd85dc85b00fc308f41c213..3c8653bff1eef206bf26f545602cd9cf72439624 100644 (file)
@@ -46,7 +46,7 @@ static std::string convert_condition_weekday_weekend(std::string inst_name, std:
        std::string buf = (day.compare(TIMER_WEEKDAY) == 0)? CONDITION_WEEKDAY : CONDITION_WEEKEND;
 
        size_t pos = 0;
-       while((pos = buf.find("%s", pos)) != std::string::npos) {
+       while ((pos = buf.find("%s", pos)) != std::string::npos) {
                buf.replace(pos, 2, inst_name);
                pos += inst_name.length();
        }
@@ -83,10 +83,7 @@ std::string ctx::script_generator::generate_deftemplate(ctx::json* item)
                script += *it;
                script += " (default null))";
        }
-       script += ")";
-
-//     _D("Deftemplate script is generated: %s", script.c_str());
-       script += "\n";
+       script += ")\n";
 
        return script;
 }
@@ -109,10 +106,7 @@ std::string ctx::script_generator::generate_defclass(ctx::json* item)
                script += attr_name;
                script += " (create-accessor read-write))";
        }
-       script += ")";
-
-//     _D("Defclass script is generated: %s", script.c_str());
-       script += "\n";
+       script += ")\n";
 
        return script;
 }
@@ -141,10 +135,7 @@ std::string ctx::script_generator::generate_makeinstance(ctx::json* item)
                script += attr_name;
                script += " 0)";
        }
-       script += ")";
-
-//     _D("Makeinstance script is generated: %s", script.c_str());
-       script += "\n";
+       script += ")\n";
 
        return script;
 }
@@ -159,16 +150,13 @@ std::string ctx::script_generator::generate_undefrule(std::string rule_id)
        return script;
 }
 
-std::string ctx::script_generator::generate_defrule(std::string rule_id, ctx::json event_template, ctx::json rule, ctx::json* inst_names, std::string zone)
+std::string ctx::script_generator::generate_defrule(std::string rule_id, ctx::json event_template, ctx::json rule, ctx::json* inst_names)
 {
        std::string script;
        ctx::json option = NULL;
        rule.get(CT_RULE_EVENT, CT_RULE_EVENT_OPTION, &option);
 
-       script = "(defrule rule";
-       script += rule_id;
-       script += " ";
-
+       script = "(defrule rule" + rule_id + " ";
        script += generate_initial_fact(event_template, option);
        script += " => ";
 
@@ -177,13 +165,12 @@ std::string ctx::script_generator::generate_defrule(std::string rule_id, ctx::js
 
        if (condition_num > 0) {
                // case1: condition exists
-               script += "(if (and (eq ?*zone* \"";
-               script += zone;
-               script += "\") ";
+               script += "(if ";
 
                if (eventdata_num > 0) {
                        ctx::json event;
                        rule.get(NULL, CT_RULE_EVENT, &event);
+                       script += "(and ";
                        script += generate_event_data(event);
                }
 
@@ -194,31 +181,21 @@ std::string ctx::script_generator::generate_defrule(std::string rule_id, ctx::js
                rule.get(NULL, CT_RULE_OPERATOR, &rule_op);
                script += generate_condition_data(rule_id, conditions, rule_op, inst_names);
 
-               script += ")";
-               script += " then ";
-               script += " (execute_action rule";
-               script += rule_id;
-               script += "))";
+               if (eventdata_num > 0)
+                       script += ")";
+
+               script = script + " then (execute_action rule" + rule_id + "))";
        } else if (eventdata_num > 0) {
                // case2: no conditions, but event data
                ctx::json event;
                rule.get(NULL, CT_RULE_EVENT, &event);
 
-               script += "(if (and (eq ?*zone* \"";
-               script += zone;
-               script += "\") ";
+               script += "(if ";
                script += generate_event_data(event);
-               script += ") then ";
-               script += " (execute_action rule";
-               script += rule_id;
-               script += "))";
+               script = script + " then (execute_action rule" + rule_id + "))";
        } else {
                // case3: only action
-               script += "if (eq ?*zone* \"";
-               script += zone;
-               script += "\") then (execute_action rule";
-               script += rule_id;
-               script += ")";
+               script = script + " (execute_action rule" + rule_id + ")";
        }
 
        script += ")";
@@ -267,7 +244,6 @@ std::string generate_initial_fact(ctx::json event_template, ctx::json option)
        }
        script += ")";
 
-//     _D("Initial event fact is %s", script.c_str());
        return script;
 }
 
@@ -505,7 +481,6 @@ std::string ctx::script_generator::generate_modifyinstance(std::string instance_
                } else  if (data.get(NULL, key.c_str(), &value)) {      // integer type data
                        script += "(" + key + " " + int_to_string(value) + ")";
                }
-               // else continue;
        }
        script += ")";
 
index 4185ade8adb6734c834e76aad172554ad322a460..3b1a4c637743ada0f075231cf959885b985c20e3 100644 (file)
@@ -25,7 +25,7 @@ namespace ctx {
                std::string generate_defclass(ctx::json* item);
                std::string generate_makeinstance(ctx::json* item);
                std::string generate_undefrule(std::string rule_id);
-               std::string generate_defrule(std::string rule_id, ctx::json event_template, ctx::json rule, ctx::json* inst_names, std::string zone);
+               std::string generate_defrule(std::string rule_id, ctx::json event_template, ctx::json rule, ctx::json* inst_names);
                std::string generate_fact(std::string item_name, ctx::json event_template, ctx::json option, ctx::json data);
                std::string generate_modifyinstance(std::string instance_name, ctx::json condition_template, ctx::json data);
 
index de19e779b114bf178bc436d17c4182187b74ff38..152af580ac1fdd1999a9fff9045f09cc56b3ed86 100644 (file)
@@ -34,9 +34,8 @@ ctx::trigger_timer::ref_count_array_s::ref_count_array_s()
        memset(count, 0, sizeof(int) * MAX_DAY);
 }
 
-ctx::trigger_timer::trigger_timer(ctx::context_trigger* tr, std::string z)
+ctx::trigger_timer::trigger_timer(ctx::context_trigger* tr)
        : trigger(tr)
-       , zone(z)
 {
 }
 
@@ -167,14 +166,14 @@ bool ctx::trigger_timer::on_timer_expired(int timer_id, void* user_data)
 
 void ctx::trigger_timer::on_timer_expired(int hour, int min, int day_of_week)
 {
-       _I("[Timer-%s] Time: %02d:%02d, Day of Week: %#x", zone.c_str(), hour, min, day_of_week);
+       _I("Time: %02d:%02d, Day of Week: %#x", hour, min, day_of_week);
 
        ctx::json result;
        result.set(NULL, TIMER_RESPONSE_KEY_TIME_OF_DAY, hour * 60 + min);
        result.set(NULL, TIMER_RESPONSE_KEY_DAY_OF_WEEK, convert_day_of_week_to_string(day_of_week));
 
        ctx::json dummy = NULL;
-       trigger->push_fact(TIMER_EVENT_REQ_ID, ERR_NONE, TIMER_EVENT_SUBJECT, dummy, result, zone.c_str());
+       trigger->push_fact(TIMER_EVENT_REQ_ID, ERR_NONE, TIMER_EVENT_SUBJECT, dummy, result);
 }
 
 int ctx::trigger_timer::get_day_of_month()
index f1b9787cc3317b174e376bf46a0b1c9fdb264efc..8914bb7ba3f33e835880ccfd1a2b9f63d5cb4d74 100644 (file)
@@ -43,7 +43,6 @@ namespace ctx {
                typedef std::map<int, timer_state_s> timer_state_map_t;
 
                ctx::context_trigger *trigger;
-               std::string zone;
                ref_count_map_t ref_count_map;
                timer_state_map_t timer_state_map;
 
@@ -55,7 +54,7 @@ namespace ctx {
                bool on_timer_expired(int timer_id, void *user_data);
 
        public:
-               trigger_timer(ctx::context_trigger *tr, std::string z);
+               trigger_timer(ctx::context_trigger *tr);
                ~trigger_timer();
 
                bool add(int minute, int day_of_week);
index 568ca7cd09b8700f56d7de92dc4145db8b1bce5c..32eb2f4d85b0f1b26b8ad35158f7b693c8ed007e 100644 (file)
@@ -53,6 +53,9 @@ void ctx::context_trigger::release()
        // This function is called from the main thread during the service termination process.
        delete _reader;
        _reader = NULL;
+
+       delete rule_mgr;
+       rule_mgr = NULL;
 }
 
 void ctx::context_trigger::on_thread_event_popped(int type, void* data)
@@ -138,9 +141,9 @@ void ctx::context_trigger::process_request(ctx::request_info* request)
        }
 }
 
-void ctx::context_trigger::push_fact(int req_id, int error, const char* subject, ctx::json& option, ctx::json& data, const char* zone)
+void ctx::context_trigger::push_fact(int req_id, int error, const char* subject, ctx::json& option, ctx::json& data)
 {
-       context_fact *fact = new(std::nothrow) context_fact(req_id, error, subject, option, data, zone);
+       context_fact *fact = new(std::nothrow) context_fact(req_id, error, subject, option, data);
        IF_FAIL_VOID_TAG(fact, _E, "Memory allocation failed");
 
        push_thread_event(ETYPE_FACT, fact);
@@ -149,7 +152,7 @@ void ctx::context_trigger::push_fact(int req_id, int error, const char* subject,
 void ctx::context_trigger::process_fact(ctx::context_fact* fact)
 {
        // Process the context fact.
-       rule_mgr->on_event_received(fact->get_subject(), fact->get_option(), fact->get_data(), fact->get_zone_name());
+       rule_mgr->on_event_received(fact->get_subject(), fact->get_option(), fact->get_data());
 }
 
 void ctx::context_trigger::process_initialize(void)
@@ -174,13 +177,7 @@ void ctx::context_trigger::add_rule(ctx::request_info* request)
                return;
        }
 
-       const char* zone_name = request->get_zone_name();
-       if (zone_name == NULL) {
-               request->reply(ERR_OPERATION_FAILED);
-               return;
-       }
-
-       int error = rule_mgr->add_rule(app_id, request->get_description(), zone_name, &rule_id);
+       int error = rule_mgr->add_rule(app_id, request->get_description(), &rule_id);
        _I("'%s' adds a rule (Error: %#x)", request->get_client(), error);
 
        request->reply(error, rule_id);
index c1a7173e5423549cafa8b5cc8d02f26e6e813182..1d4ba2ad6b0f10bf73d11122912b0c035a6416b5 100644 (file)
@@ -36,10 +36,7 @@ namespace ctx {
                        void release();
 
                        bool assign_request(ctx::request_info* request);
-                       void push_fact(int req_id, int error, const char* subject, ctx::json& option, ctx::json& data, const char* zone);
-                       bool publish(int rule_id, int error, ctx::json data);
-                       bool _publish(int rule_id, int error, ctx::json data);
-
+                       void push_fact(int req_id, int error, const char* subject, ctx::json& option, ctx::json& data);
 
                private:
                        enum event_type_e {
index 167498689cf0a3b9579c76eabdc7ef7d0307c710..23f20e45e8f696fd855dafa18d9f37aec04ebf7f 100644 (file)
@@ -23,7 +23,6 @@
 #include "server.h"
 #include "client_request.h"
 #include "access_control/peer_creds.h"
-#include "zone_util_impl.h"
 #include "dbus_server_impl.h"
 
 static bool conn_acquired = false;
@@ -94,8 +93,7 @@ static void handle_request(const char *sender, GVariant *param, GDBusMethodInvoc
        std::string smack_label;
        pid_t pid;
 
-       if (ctx::peer_creds::get(dbus_connection, sender, smack_label, pid) &&
-                       request->set_peer_creds(smack_label.c_str(), ctx::zone_util::get_name_by_pid(pid))) {
+       if (ctx::peer_creds::get(dbus_connection, sender, smack_label, pid) && request->set_peer_creds(smack_label.c_str())) {
                ctx::server::send_request(request);
                return;
        }
index 92153027eca7a6978a5770d7c02800c7490b291e..6b9e51c66acf58d61cde7d490797e0d20d0c7365 100644 (file)
@@ -41,11 +41,6 @@ int ctx::request_info::get_id()
        return _req_id;
 }
 
-const char* ctx::request_info::get_zone_name()
-{
-       return _zone_name.c_str();
-}
-
 const char* ctx::request_info::get_client()
 {
        return _client.c_str();
index f0e65863f3335cd3aa4bbee3875777672f9a3f9d..a11487fdb94e7382e97f5fbe06a5544741eb59d3 100644 (file)
@@ -29,7 +29,6 @@ namespace ctx {
 
                        int get_type();
                        int get_id();
-                       const char* get_zone_name();
                        const char* get_client();
                        const char* get_subject();
                        ctx::json& get_description();
@@ -43,7 +42,6 @@ namespace ctx {
                protected:
                        int _type;
                        int _req_id;
-                       std::string _zone_name;
                        std::string _client;
                        std::string _subject;
                        ctx::json _description;
index 385e76a294dece7b2751197ebae2270d6e09c2d2..82432fec4748a6397ffdc59aa0612748a68a21a2 100644 (file)
@@ -24,7 +24,6 @@
 #include "db_mgr_impl.h"
 #include "timer_mgr_impl.h"
 #include "context_mgr_impl.h"
-#include "zone_util_impl.h"
 #include "access_control/privilege.h"
 #include "context_trigger/trigger.h"
 #include "server.h"
@@ -75,10 +74,6 @@ void ctx::server::activate()
 
        bool result = false;
 
-       _I("Init vasum context");
-       result = ctx::zone_util::init();
-       IF_FAIL_CATCH_TAG(result, _E, "Vasum context initialization failed");
-
        _I("Init access control configuration");
        result = ctx::privilege_manager::init();
        IF_FAIL_CATCH_TAG(result, _E, "Access controller initialization failed");
@@ -151,9 +146,6 @@ void ctx::server::release()
        _I("Release Access control configuration");
        ctx::privilege_manager::release();
 
-       _I("Release Vasum context");
-       ctx::zone_util::release();
-
 #ifdef _USE_ECORE_MAIN_LOOP_
        ecore_shutdown();
 #else
diff --git a/src/zone_util_impl.cpp b/src/zone_util_impl.cpp
deleted file mode 100644 (file)
index aa0636b..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <unistd.h>
-#ifdef _ZONE_ENABLED_
-#include <vasum.h>
-#endif
-#include <system_info.h>
-#include <types_internal.h>
-#include "zone_util_impl.h"
-
-#define HOST_NAME ""
-
-#if _ZONE_ENABLED_
-static bool container_enabled = false;
-static vsm_context_h _vsm_ctx = NULL;
-#endif
-static ctx::zone_util_impl* _instance = NULL;
-
-const char* ctx::zone_util_impl::default_zone()
-{
-#if _ZONE_ENABLED_
-       if (container_enabled)
-               return VSM_DEFAULT_ZONE;
-#endif
-
-       return HOST_NAME;
-}
-
-void* ctx::zone_util_impl::join_by_name(const char* name)
-{
-#if _ZONE_ENABLED_
-       IF_FAIL_RETURN(container_enabled, NULL);
-       IF_FAIL_RETURN_TAG(_vsm_ctx, NULL, _E, "Not initialized");
-
-       if (name == NULL) {
-               _D("NULL zone name. The default zone will be used.");
-               name = VSM_DEFAULT_ZONE;
-       }
-
-       vsm_zone_h target_zone = vsm_lookup_zone_by_name(_vsm_ctx, name);
-       IF_FAIL_RETURN_TAG(target_zone, NULL, _E, RED("Zone lookup failed"));
-
-       vsm_zone_h current_zone = vsm_lookup_zone_by_pid(_vsm_ctx, getpid());
-       IF_FAIL_RETURN_TAG(current_zone, NULL, _E, RED("Zone lookup failed"));
-       IF_FAIL_RETURN_TAG(target_zone != current_zone, NULL, _I, YELLOW("Already in the target zone %s"), name);
-
-       _I(YELLOW("Joining to '%s'"), name);
-       return vsm_join_zone(target_zone);
-#else
-       return NULL;
-#endif
-}
-
-void* ctx::zone_util_impl::join_to_zone(void* zone)
-{
-#if _ZONE_ENABLED_
-       IF_FAIL_RETURN(container_enabled, NULL);
-       IF_FAIL_RETURN_TAG(_vsm_ctx, NULL, _E, "Not initialized");
-       IF_FAIL_RETURN(zone, NULL);
-       vsm_zone_h target = static_cast<vsm_zone_h>(zone);
-       _I(YELLOW("Joining to '%s'"), vsm_get_zone_name(target));
-       return vsm_join_zone(target);
-#else
-       return NULL;
-#endif
-}
-
-bool ctx::zone_util::init()
-{
-#if _ZONE_ENABLED_
-       system_info_get_platform_bool("tizen.org/feature/container", &container_enabled);
-       IF_FAIL_RETURN_TAG(_instance == NULL, true, _W, "Re-initialization");
-#endif
-
-       _instance = new(std::nothrow) zone_util_impl();
-       IF_FAIL_RETURN_TAG(_instance, false, _E, "Memory allocation failed");
-
-#if _ZONE_ENABLED_
-       if (container_enabled) {
-               _vsm_ctx = vsm_create_context();
-               if (!_vsm_ctx) {
-                       delete _instance;
-                       _E("Memory allocation failed");
-                       return false;
-               }
-       }
-#endif
-
-       zone_util::set_instance(_instance);
-       return true;
-}
-
-void ctx::zone_util::release()
-{
-       zone_util::set_instance(NULL);
-
-       delete _instance;
-       _instance = NULL;
-
-#if _ZONE_ENABLED_
-       if (_vsm_ctx)
-               vsm_cleanup_context(_vsm_ctx);
-
-       _vsm_ctx = NULL;
-#endif
-}
-
-const char* ctx::zone_util::get_name_by_pid(pid_t pid)
-{
-#if _ZONE_ENABLED_
-       IF_FAIL_RETURN(container_enabled, HOST_NAME);
-       IF_FAIL_RETURN_TAG(_vsm_ctx, NULL, _E, "Not initialized");
-       vsm_zone_h zn = vsm_lookup_zone_by_pid(_vsm_ctx, pid);
-       return vsm_get_zone_name(zn);
-#else
-       return HOST_NAME;
-#endif
-}
diff --git a/src/zone_util_impl.h b/src/zone_util_impl.h
deleted file mode 100644 (file)
index 4ae9bcb..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __CONTEXT_VASUM_ZONE_UTIL_IMPL_H__
-#define __CONTEXT_VASUM_ZONE_UTIL_IMPL_H__
-
-#include <sys/types.h>
-#include <zone_util.h>
-#include <zone_util_iface.h>
-
-namespace ctx {
-
-       class zone_util_impl : public zone_util_iface {
-               public:
-                       zone_util_impl() {}
-                       ~zone_util_impl() {}
-                       void* join_by_name(const char* name);
-                       void* join_to_zone(void* zone);
-                       const char* default_zone();
-       };
-
-       namespace zone_util {
-               bool init();
-               void release();
-               const char* get_name_by_pid(pid_t pid);
-       }
-
-}      /* namespace ctx */
-
-#endif /* End of __CONTEXT_VASUM_ZONE_UTIL_IMPL_H__ */