Replace ctx::json with ctx:Json 79/60079/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Tue, 23 Feb 2016 07:41:00 +0000 (16:41 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Tue, 23 Feb 2016 07:41:00 +0000 (16:41 +0900)
Change-Id: I78ac7a0ca09bd33eaa15bba0a2eb901a7654c45c
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
30 files changed:
src/client_request.cpp
src/client_request.h
src/context_mgr_impl.cpp
src/context_mgr_impl.h
src/context_trigger/action_manager.cpp
src/context_trigger/action_manager.h
src/context_trigger/context_listener_iface.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_request.cpp
src/context_trigger/fact_request.h
src/context_trigger/rule.cpp
src/context_trigger/rule.h
src/context_trigger/rule_evaluator.cpp
src/context_trigger/rule_evaluator.h
src/context_trigger/rule_manager.cpp
src/context_trigger/rule_manager.h
src/context_trigger/template_manager.cpp
src/context_trigger/template_manager.h
src/context_trigger/timer.cpp
src/context_trigger/timer.h
src/context_trigger/trigger.cpp
src/db_mgr_impl.cpp
src/db_mgr_impl.h
src/provider.cpp
src/provider.h
src/request.cpp
src/request.h

index 4b218be..e9e2391 100644 (file)
@@ -71,57 +71,44 @@ bool ctx::client_request::reply(int error)
        return true;
 }
 
-bool ctx::client_request::reply(int error, ctx::json& request_result)
+bool ctx::client_request::reply(int error, ctx::Json& request_result)
 {
        IF_FAIL_RETURN(__invocation, true);
        IF_FAIL_RETURN(_type != REQ_READ_SYNC, true);
 
-       char *result = request_result.dup_cstr();
-       IF_FAIL_RETURN_TAG(result, false, _E, "Memory allocation failed");
+       std::string result = request_result.str();
+       IF_FAIL_RETURN(!result.empty(), false);
 
        _I("Reply %#x", error);
-       _SD("Result: %s", result);
+       _SD("Result: %s", result.c_str());
 
-       g_dbus_method_invocation_return_value(__invocation, g_variant_new("(iss)", error, result, EMPTY_JSON_OBJECT));
+       g_dbus_method_invocation_return_value(__invocation, g_variant_new("(iss)", error, result.c_str(), EMPTY_JSON_OBJECT));
        __invocation = NULL;
 
-       g_free(result);
        return true;
 }
 
-bool ctx::client_request::reply(int error, ctx::json& request_result, ctx::json& data_read)
+bool ctx::client_request::reply(int error, ctx::Json& request_result, ctx::Json& data_read)
 {
        if (__invocation == NULL) {
                return publish(error, data_read);
        }
 
-       char *result = NULL;
-       char *data = NULL;
-
-       result = request_result.dup_cstr();
-       IF_FAIL_CATCH_TAG(result, _E, "Memory allocation failed");
-
-       data = data_read.dup_cstr();
-       IF_FAIL_CATCH_TAG(data, _E, "Memory allocation failed");
+       std::string result = request_result.str();
+       std::string data = data_read.str();
+       IF_FAIL_RETURN(!result.empty() && !data.empty(), false);
 
        _I("Reply %#x", error);
-       _SD("Result: %s", result);
-       _SD("Data: %s", data);
+       _SD("Result: %s", result.c_str());
+       _SD("Data: %s", data.c_str());
 
-       g_dbus_method_invocation_return_value(__invocation, g_variant_new("(iss)", error, result, data));
+       g_dbus_method_invocation_return_value(__invocation, g_variant_new("(iss)", error, result.c_str(), data.c_str()));
        __invocation = NULL;
 
-       g_free(result);
-       g_free(data);
        return true;
-
-CATCH:
-       g_free(result);
-       g_free(data);
-       return false;
 }
 
-bool ctx::client_request::publish(int error, ctx::json& data)
+bool ctx::client_request::publish(int error, ctx::Json& data)
 {
        DBusServer::publish(__dbus_sender, _req_id, _subject, error, data.str());
        return true;
index 9c13783..2b652d4 100644 (file)
@@ -32,9 +32,9 @@ namespace ctx {
                const char* get_package_id();
                const char* get_client();
                bool reply(int error);
-               bool reply(int error, ctx::json &request_result);
-               bool reply(int error, ctx::json &request_result, ctx::json &data_read);
-               bool publish(int error, ctx::json &data);
+               bool reply(int error, ctx::Json &request_result);
+               bool reply(int error, ctx::Json &request_result, ctx::Json &data_read);
+               bool publish(int error, ctx::Json &data);
 
        private:
                credentials *__credentials;
index d6ef171..00aabfe 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <types_internal.h>
 #include <context_trigger_types_internal.h>
-#include <json.h>
+#include <Json.h>
 #include <provider_iface.h>
 #include "server.h"
 #include "access_control/privilege.h"
 struct trigger_item_format_s {
        std::string subject;
        int operation;
-       ctx::json attributes;
-       ctx::json options;
+       ctx::Json attributes;
+       ctx::Json options;
        std::string owner;
        bool unregister;
-       trigger_item_format_s(std::string subj, int ops, ctx::json attr, ctx::json opt, std::string own)
+       trigger_item_format_s(std::string subj, int ops, ctx::Json attr, ctx::Json opt, std::string own)
                : subject(subj), operation(ops), attributes(attr), options(opt), owner(own)
        {
                unregister = false;
@@ -127,7 +127,7 @@ bool ctx::context_manager_impl::unregister_provider(const char *subject)
        return true;
 }
 
-bool ctx::context_manager_impl::register_trigger_item(const char *subject, int operation, ctx::json attributes, ctx::json options, const char* owner)
+bool ctx::context_manager_impl::register_trigger_item(const char *subject, int operation, ctx::Json attributes, ctx::Json options, const char* owner)
 {
        IF_FAIL_RETURN_TAG(subject, false, _E, "Invalid parameter");
        __trigger_item_list.push_back(trigger_item_format_s(subject, operation, attributes, options, (owner)? owner : ""));
@@ -143,7 +143,7 @@ bool ctx::context_manager_impl::unregister_trigger_item(const char *subject)
        return true;
 }
 
-bool ctx::context_manager_impl::pop_trigger_item(std::string &subject, int &operation, ctx::json &attributes, ctx::json &options, std::string& owner, bool& unregister)
+bool ctx::context_manager_impl::pop_trigger_item(std::string &subject, int &operation, ctx::Json &attributes, ctx::Json &options, std::string& owner, bool& unregister)
 {
        IF_FAIL_RETURN(!__trigger_item_list.empty(), false);
 
@@ -220,7 +220,7 @@ bool ctx::context_manager_impl::is_allowed(const ctx::credentials *creds, const
        return it->second->is_allowed(creds);
 }
 
-void ctx::context_manager_impl::_publish(const char* subject, ctx::json &option, int error, ctx::json &data_updated)
+void ctx::context_manager_impl::_publish(const char* subject, ctx::Json &option, int error, ctx::Json &data_updated)
 {
        _I("Publishing '%s'", subject);
        _J("Option", option);
@@ -231,7 +231,7 @@ void ctx::context_manager_impl::_publish(const char* subject, ctx::json &option,
        it->second->publish(option, error, data_updated);
 }
 
-void ctx::context_manager_impl::_reply_to_read(const char* subject, ctx::json &option, int error, ctx::json &data_read)
+void ctx::context_manager_impl::_reply_to_read(const char* subject, ctx::Json &option, int error, ctx::Json &data_read)
 {
        _I("Sending data of '%s'", subject);
        _J("Option", option);
@@ -248,9 +248,9 @@ struct published_data_s {
        ctx::context_manager_impl *mgr;
        std::string subject;
        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)
+       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)
                : type(t), mgr(m), subject(s), error(e)
        {
                option = o.str();
@@ -277,7 +277,7 @@ 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)
+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");
 
@@ -289,7 +289,7 @@ 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)
+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");
 
@@ -314,26 +314,26 @@ bool ctx::context_manager_impl::handle_custom_request(ctx::request_info* request
                return true;
        }
 
-       ctx::json desc = request->get_description();
+       ctx::Json desc = request->get_description();
        std::string name;
        desc.get(NULL, CT_CUSTOM_NAME, &name);
        std::string subj = pkg_id + std::string("::") + name;
 
        int error = ERR_NONE;
        if (subject == CONTEXT_TRIGGER_SUBJECT_CUSTOM_ADD) {
-               ctx::json tmpl;
+               ctx::Json tmpl;
                desc.get(NULL, CT_CUSTOM_ATTRIBUTES, &tmpl);
 
                error = ctx::custom_context_provider::add_item(subj, name, tmpl, pkg_id);
        } else if (subject == CONTEXT_TRIGGER_SUBJECT_CUSTOM_REMOVE) {
                error = ctx::custom_context_provider::remove_item(subj);
                if (error == ERR_NONE) {
-                       ctx::json data;
+                       ctx::Json data;
                        data.set(NULL, CT_CUSTOM_SUBJECT, subj);
                        request->reply(error, data);
                }
        } else if (subject == CONTEXT_TRIGGER_SUBJECT_CUSTOM_PUBLISH) {
-               ctx::json fact;
+               ctx::Json fact;
                desc.get(NULL, CT_CUSTOM_FACT, &fact);
 
                error = ctx::custom_context_provider::publish_data(subj, fact);
index a9fbb54..3eb2d36 100644 (file)
@@ -41,22 +41,22 @@ namespace ctx {
                void assign_request(ctx::request_info *request);
                bool is_supported(const char *subject);
                bool is_allowed(const credentials *creds, const char *subject);
-               bool pop_trigger_item(std::string &subject, int &operation, ctx::json &attributes, ctx::json &options, std::string &owner, bool& unregister);
+               bool pop_trigger_item(std::string &subject, int &operation, ctx::Json &attributes, ctx::Json &options, std::string &owner, bool& unregister);
 
                /* From the interface class */
                bool register_provider(const char *subject, context_provider_info &provider_info);
                bool unregister_provider(const char *subject);
-               bool register_trigger_item(const char *subject, int operation, ctx::json attributes, ctx::json options, const char *owner = NULL);
+               bool register_trigger_item(const char *subject, int operation, ctx::Json attributes, ctx::Json options, const char *owner = NULL);
                bool unregister_trigger_item(const char *subject);
-               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);
+               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:
                std::map<std::string, context_provider_handler*> provider_handle_map;
 
                static gboolean thread_switcher(gpointer data);
-               void _publish(const char *subject, ctx::json &option, int error, ctx::json &data_updated);
-               void _reply_to_read(const char *subject, ctx::json &option, int error, ctx::json &data_read);
+               void _publish(const char *subject, ctx::Json &option, int error, ctx::Json &data_updated);
+               void _reply_to_read(const char *subject, ctx::Json &option, int error, ctx::Json &data_read);
 
                /* For custom request */
                bool handle_custom_request(ctx::request_info* request);
index b839711..49e6023 100644 (file)
 #include <runtime_info.h>
 #include <system_settings.h>
 #include <context_trigger_types_internal.h>
-#include <json.h>
+#include <Json.h>
 #include "../DBusServer.h"
 #include "action_manager.h"
 
-static void trigger_action_app_control(ctx::json& action);
-static void trigger_action_notification(ctx::json& action, std::string pkg_id);
-static void trigger_action_dbus_call(ctx::json& action);
+static void trigger_action_app_control(ctx::Json& action);
+static void trigger_action_notification(ctx::Json& action, std::string pkg_id);
+static void trigger_action_dbus_call(ctx::Json& action);
 
-void ctx::action_manager::trigger_action(ctx::json& action, std::string pkg_id)
+void ctx::action_manager::trigger_action(ctx::Json& action, std::string pkg_id)
 {
        std::string type;
        action.get(NULL, CT_RULE_ACTION_TYPE, &type);
@@ -45,7 +45,7 @@ void ctx::action_manager::trigger_action(ctx::json& action, std::string pkg_id)
        }
 }
 
-void trigger_action_app_control(ctx::json& action)
+void trigger_action_app_control(ctx::Json& action)
 {
        int error;
        std::string appctl_str;
@@ -80,7 +80,7 @@ void trigger_action_app_control(ctx::json& action)
        }
 }
 
-void trigger_action_notification(ctx::json& action, std::string pkg_id)
+void trigger_action_notification(ctx::Json& action, std::string pkg_id)
 {
        int error;
        notification_h notification = notification_create(NOTIFICATION_TYPE_NOTI);
@@ -186,7 +186,7 @@ void trigger_action_notification(ctx::json& action, std::string pkg_id)
        }
 }
 
-void trigger_action_dbus_call(ctx::json& action)
+void trigger_action_dbus_call(ctx::Json& action)
 {
        std::string bus_name, object, iface, method;
        GVariant *param = NULL;
index e8bf6df..1a157ce 100644 (file)
 
 namespace ctx {
 
-       class json;
+       class Json;
 
        namespace action_manager {
 
-               void trigger_action(ctx::json& action, std::string pkg_id);
+               void trigger_action(ctx::Json& action, std::string pkg_id);
 
        }
 
index 657f07f..88bbaa2 100644 (file)
 
 namespace ctx {
        /* Forward Declaration */
-       class json;
+       class Json;
 
        class context_listener_iface {
                public:
                        virtual ~context_listener_iface() {}
 
-                       virtual void on_event_received(std::string name, ctx::json option, ctx::json data) = 0;
+                       virtual void on_event_received(std::string name, ctx::Json option, ctx::Json data) = 0;
 
-                       virtual void on_condition_received(std::string name, ctx::json option, ctx::json data) = 0;
+                       virtual void on_condition_received(std::string name, ctx::Json option, ctx::Json data) = 0;
        };
 
 }      /* namespace ctx */
index 576ee8c..236784d 100644 (file)
@@ -72,7 +72,7 @@ void ctx::context_monitor::destroy()
        }
 }
 
-int ctx::context_monitor::subscribe(int rule_id, std::string subject, ctx::json option, context_listener_iface* listener)
+int ctx::context_monitor::subscribe(int rule_id, std::string subject, ctx::Json option, context_listener_iface* listener)
 {
        int req_id = _subscribe(subject.c_str(), &option, listener);
        IF_FAIL_RETURN_TAG(req_id > 0, req_id, _E, "Subscribe event failed");
@@ -81,7 +81,7 @@ int ctx::context_monitor::subscribe(int rule_id, std::string subject, ctx::json
        return ERR_NONE;
 }
 
-int ctx::context_monitor::_subscribe(const char* subject, json* option, context_listener_iface* listener)
+int ctx::context_monitor::_subscribe(const char* subject, Json* option, context_listener_iface* listener)
 {
        IF_FAIL_RETURN(subject, ERR_INVALID_PARAMETER);
 
@@ -110,7 +110,7 @@ int ctx::context_monitor::_subscribe(const char* subject, json* option, context_
        return rid;
 }
 
-int ctx::context_monitor::unsubscribe(int rule_id, std::string subject, ctx::json option, context_listener_iface* listener)
+int ctx::context_monitor::unsubscribe(int rule_id, std::string subject, ctx::Json option, context_listener_iface* listener)
 {
        int rid = find_sub(REQ_SUBSCRIBE, subject.c_str(), &option);
        if (rid < 0) {
@@ -135,7 +135,7 @@ void ctx::context_monitor::_unsubscribe(const char *subject, int subscription_id
        remove_sub(REQ_SUBSCRIBE, subscription_id);
 }
 
-int ctx::context_monitor::read(std::string subject, json option, context_listener_iface* listener)
+int ctx::context_monitor::read(std::string subject, Json option, context_listener_iface* listener)
 {
        int req_id = _read(subject.c_str(), &option, listener);
        IF_FAIL_RETURN_TAG(req_id > 0, ERR_OPERATION_FAILED, _E, "Read condition failed");
@@ -144,7 +144,7 @@ int ctx::context_monitor::read(std::string subject, json option, context_listene
        return ERR_NONE;
 }
 
-int ctx::context_monitor::_read(const char* subject, json* option, context_listener_iface* listener)
+int ctx::context_monitor::_read(const char* subject, Json* option, context_listener_iface* listener)
 {
        IF_FAIL_RETURN(subject, ERR_INVALID_PARAMETER);
 
@@ -184,12 +184,12 @@ bool ctx::context_monitor::is_allowed(const char *client, const char *subject)
        return true;
 }
 
-int ctx::context_monitor::find_sub(request_type type, const char* subject, json* option)
+int ctx::context_monitor::find_sub(request_type type, const char* subject, Json* option)
 {
        // @return      request id
        subscr_map_t* map = (type == REQ_SUBSCRIBE)? &subscr_map : &read_map;
 
-       json opt_j;
+       Json opt_j;
        if (option) {
                opt_j = *option;
        }
@@ -203,7 +203,7 @@ int ctx::context_monitor::find_sub(request_type type, const char* subject, json*
        return -1;
 }
 
-bool ctx::context_monitor::add_sub(request_type type, int sid, const char* subject, json* option, context_listener_iface* listener)
+bool ctx::context_monitor::add_sub(request_type type, int sid, const char* subject, Json* option, context_listener_iface* listener)
 {
        subscr_map_t* map = (type == REQ_SUBSCRIBE)? &subscr_map : &read_map;
 
@@ -215,11 +215,11 @@ bool ctx::context_monitor::add_sub(request_type type, int sid, const char* subje
        return true;
 }
 
-void ctx::context_monitor::remove_sub(request_type type, const char* subject, json* option)
+void ctx::context_monitor::remove_sub(request_type type, const char* subject, Json* option)
 {
        subscr_map_t* map = (type == REQ_SUBSCRIBE)? &subscr_map : &read_map;
 
-       json opt_j;
+       Json opt_j;
        if (option) {
                opt_j = *option;
        }
@@ -278,7 +278,7 @@ int ctx::context_monitor::remove_listener(request_type type, int sid, context_li
        return info->listener_list.size();
 }
 
-void ctx::context_monitor::reply_result(int req_id, int error, json* request_result)
+void ctx::context_monitor::reply_result(int req_id, int error, Json* request_result)
 {
        _D("Request result received: %d", req_id);
 
@@ -286,7 +286,7 @@ void ctx::context_monitor::reply_result(int req_id, int error, json* request_res
        last_err = error;
 }
 
-void ctx::context_monitor::reply_result(int req_id, int error, const char* subject, json* option, json* fact)
+void ctx::context_monitor::reply_result(int req_id, int error, const char* subject, Json* option, Json* fact)
 {
        _D(YELLOW("Condition received: subject(%s), option(%s), fact(%s)"), subject, option->str().c_str(), fact->str().c_str());
 
@@ -301,7 +301,7 @@ void ctx::context_monitor::reply_result(int req_id, int error, const char* subje
        remove_sub(REQ_READ, req_id);
 }
 
-void ctx::context_monitor::publish_fact(int req_id, int error, const char* subject, json* option, json* fact)
+void ctx::context_monitor::publish_fact(int req_id, int error, const char* subject, Json* option, Json* fact)
 {
        _D(YELLOW("Event received: subject(%s), option(%s), fact(%s)"), subject, option->str().c_str(), fact->str().c_str());
 
index 53b2884..8162ce5 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <list>
 #include <map>
-#include <json.h>
+#include <Json.h>
 
 namespace ctx {
 
@@ -33,15 +33,15 @@ namespace ctx {
                static void set_context_manager(ctx::context_manager_impl* ctx_mgr);
                static void destroy();
 
-               int subscribe(int rule_id, std::string subject, ctx::json option, context_listener_iface* listener);
-               int unsubscribe(int rule_id, std::string subject, ctx::json option, context_listener_iface* listener);
-               int read(std::string subject, json option, context_listener_iface* listener);
+               int subscribe(int rule_id, std::string subject, ctx::Json option, context_listener_iface* listener);
+               int unsubscribe(int rule_id, std::string subject, ctx::Json option, context_listener_iface* listener);
+               int read(std::string subject, Json option, context_listener_iface* listener);
                bool is_supported(std::string subject);
                bool is_allowed(const char *client, const char *subject);
 
-               void reply_result(int req_id, int error, json *request_result = NULL);
-               void reply_result(int req_id, int error, const char *subject, ctx::json *option, ctx::json *fact);
-               void publish_fact(int req_id, int error, const char *subject, ctx::json *option, ctx::json *fact);
+               void reply_result(int req_id, int error, Json *request_result = NULL);
+               void reply_result(int req_id, int error, const char *subject, ctx::Json *option, ctx::Json *fact);
+               void publish_fact(int req_id, int error, const char *subject, ctx::Json *option, ctx::Json *fact);
 
        private:
                context_monitor();
@@ -51,19 +51,19 @@ namespace ctx {
                static context_monitor *_instance;
                static context_manager_impl *_context_mgr;
 
-               int _subscribe(const char* subject, ctx::json* option, context_listener_iface* listener);
+               int _subscribe(const char* subject, ctx::Json* option, context_listener_iface* listener);
                void _unsubscribe(const char *subject, int subscription_id);
-               int _read(const char *subject, ctx::json *option, context_listener_iface* listener);
+               int _read(const char *subject, ctx::Json *option, context_listener_iface* listener);
 
                typedef std::list<context_listener_iface*> listener_list_t;
 
                struct subscr_info_s {
                        int sid;
                        std::string subject;
-                       ctx::json option;
+                       ctx::Json option;
                        listener_list_t listener_list;
 
-                       subscr_info_s(int id, const char *subj, ctx::json *opt)
+                       subscr_info_s(int id, const char *subj, ctx::Json *opt)
                                : sid(id), subject(subj)
                        {
                                if (opt)
@@ -75,9 +75,9 @@ namespace ctx {
                subscr_map_t subscr_map;
                subscr_map_t read_map;
 
-               int find_sub(request_type type, const char *subject, ctx::json *option);
-               bool add_sub(request_type type, int sid, const char *subject, ctx::json *option, context_listener_iface* listener);
-               void remove_sub(request_type type, const char *subject, ctx::json *option);
+               int find_sub(request_type type, const char *subject, ctx::Json *option);
+               bool add_sub(request_type type, int sid, const char *subject, ctx::Json *option, context_listener_iface* listener);
+               void remove_sub(request_type type, const char *subject, ctx::Json *option);
                void remove_sub(request_type type, int sid);
                int add_listener(request_type type, int sid, context_listener_iface* listener);
                int remove_listener(request_type type, int sid, context_listener_iface* listener);
index 960f59d..09fe4bf 100644 (file)
@@ -23,7 +23,7 @@ ctx::context_fact::context_fact()
 {
 }
 
-ctx::context_fact::context_fact(int id, int err, const char* s, ctx::json& o, ctx::json& d)
+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)
@@ -51,12 +51,12 @@ void ctx::context_fact::set_subject(const char* s)
        subject = s;
 }
 
-void ctx::context_fact::set_option(ctx::json& o)
+void ctx::context_fact::set_option(ctx::Json& o)
 {
        option = o;
 }
 
-void ctx::context_fact::set_data(ctx::json& d)
+void ctx::context_fact::set_data(ctx::Json& d)
 {
        data = d;
 }
@@ -76,12 +76,12 @@ const char* ctx::context_fact::get_subject()
        return subject.c_str();
 }
 
-ctx::json& ctx::context_fact::get_option()
+ctx::Json& ctx::context_fact::get_option()
 {
        return option;
 }
 
-ctx::json& ctx::context_fact::get_data()
+ctx::Json& ctx::context_fact::get_data()
 {
        return data;
 }
index 9411b68..1fafe45 100644 (file)
@@ -18,7 +18,7 @@
 #define __CONTEXT_CONTEXT_TRIGGER_FACT_H__
 
 #include <string>
-#include <json.h>
+#include <Json.h>
 
 namespace ctx {
 
@@ -27,25 +27,25 @@ namespace ctx {
                        int req_id;
                        int error;
                        std::string subject;
-                       ctx::json option;
-                       ctx::json data;
+                       ctx::Json option;
+                       ctx::Json data;
 
                public:
                        context_fact();
-                       context_fact(int id, int err, const char* s, ctx::json& o, ctx::json& d);
+                       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_data(ctx::json& d);
+                       void set_option(ctx::Json& o);
+                       void set_data(ctx::Json& d);
 
                        int get_req_id();
                        int get_error();
                        const char* get_subject();
-                       ctx::json& get_option();
-                       ctx::json& get_data();
+                       ctx::Json& get_option();
+                       ctx::Json& get_data();
        };
 
 }      /* namespace ctx */
index 751d15f..37a9793 100644 (file)
@@ -42,7 +42,7 @@ bool ctx::fact_request::reply(int error)
        return true;
 }
 
-bool ctx::fact_request::reply(int error, ctx::json& request_result)
+bool ctx::fact_request::reply(int error, ctx::Json& request_result)
 {
        IF_FAIL_RETURN(!replied && _ctx_monitor, true);
        _ctx_monitor->reply_result(_req_id, error, &request_result);
@@ -50,14 +50,14 @@ bool ctx::fact_request::reply(int error, ctx::json& request_result)
        return true;
 }
 
-bool ctx::fact_request::reply(int error, ctx::json& request_result, ctx::json& data_read)
+bool ctx::fact_request::reply(int error, ctx::Json& request_result, ctx::Json& data_read)
 {
        IF_FAIL_RETURN(!replied && _ctx_monitor, true);
        _ctx_monitor->reply_result(_req_id, error, _subject.c_str(), &get_description(), &data_read);
        return (replied = true);
 }
 
-bool ctx::fact_request::publish(int error, ctx::json& data)
+bool ctx::fact_request::publish(int error, ctx::Json& data)
 {
        IF_FAIL_RETURN(_ctx_monitor, true);
        _ctx_monitor->publish_fact(_req_id, error, _subject.c_str(), &get_description(), &data);
index abaad61..6dae143 100644 (file)
@@ -29,9 +29,9 @@ namespace ctx {
 
                const char* get_client();
                bool reply(int error);
-               bool reply(int error, ctx::json& request_result);
-               bool reply(int error, ctx::json& request_result, ctx::json& data_read);
-               bool publish(int error, ctx::json& data);
+               bool reply(int error, ctx::Json& request_result);
+               bool reply(int error, ctx::Json& request_result, ctx::Json& data_read);
+               bool publish(int error, ctx::Json& data);
 
        private:
                context_monitor *_ctx_monitor;
index 34270ab..d7450fe 100644 (file)
@@ -24,7 +24,7 @@
 
 ctx::rule_manager *ctx::trigger_rule::rule_mgr = NULL;
 
-ctx::trigger_rule::trigger_rule(int i, ctx::json& d, const char* p, rule_manager* rm)
+ctx::trigger_rule::trigger_rule(int i, ctx::Json& d, const char* p, rule_manager* rm)
        : result(EMPTY_JSON_OBJECT)
        , id(i)
        , pkg_id(p)
@@ -38,20 +38,20 @@ ctx::trigger_rule::trigger_rule(int i, ctx::json& d, const char* p, rule_manager
        statement = d.str();
 
        // Event
-       ctx::json e;
+       ctx::Json e;
        d.get(NULL, CT_RULE_EVENT, &e);
        event = new(std::nothrow) context_item_s(e);
 
        // Condition
-       int cond_num = d.array_get_size(NULL, CT_RULE_CONDITION);
+       int cond_num = d.getSize(NULL, CT_RULE_CONDITION);
        for (int j = 0; j < cond_num; j++) {
-               ctx::json c;
-               d.get_array_elem(NULL, CT_RULE_CONDITION, j, &c);
+               ctx::Json c;
+               d.getAt(NULL, CT_RULE_CONDITION, j, &c);
                condition.push_back(new(std::nothrow) context_item_s(c));
        }
 
        // Action
-       ctx::json a;
+       ctx::Json a;
        d.get(NULL, CT_RULE_ACTION, &a);
        action = a.str();
 }
@@ -87,11 +87,11 @@ int ctx::trigger_rule::stop(void)
        return error;
 }
 
-bool ctx::trigger_rule::set_condition_option_based_on_event(ctx::json& option)
+bool ctx::trigger_rule::set_condition_option_based_on_event(ctx::Json& option)
 {
        // Set condition option if it references event data
        std::list<std::string> option_keys;
-       option.get_keys(&option_keys);
+       option.getKeys(&option_keys);
 
        for (std::list<std::string>::iterator it = option_keys.begin(); it != option_keys.end(); ++it) {
                std::string opt_key = (*it);
@@ -120,7 +120,7 @@ bool ctx::trigger_rule::set_condition_option_based_on_event(ctx::json& option)
        return true;
 }
 
-void ctx::trigger_rule::on_event_received(std::string name, ctx::json option, ctx::json data)
+void ctx::trigger_rule::on_event_received(std::string name, ctx::Json option, ctx::Json data)
 {
        if (result != EMPTY_JSON_OBJECT) {
                clear_result();
@@ -149,7 +149,7 @@ void ctx::trigger_rule::on_event_received(std::string name, ctx::json option, ct
 
        // Request read conditions
        for (std::list<context_item_t>::iterator it = condition.begin(); it != condition.end(); ++it) {
-               ctx::json cond_option = (*it)->option.str();
+               ctx::Json cond_option = (*it)->option.str();
                if (!set_condition_option_based_on_event(cond_option)) { // cond_option should be copy of original option.
                        clear_result();
                        return;
@@ -162,18 +162,18 @@ void ctx::trigger_rule::on_event_received(std::string name, ctx::json option, ct
        // TODO timer set
 }
 
-void ctx::trigger_rule::on_condition_received(std::string name, ctx::json option, ctx::json data)
+void ctx::trigger_rule::on_condition_received(std::string name, ctx::Json option, ctx::Json data)
 {
        _D("Rule%d received condition data", id);
 
        // Set condition data
-       ctx::json item;
+       ctx::Json item;
        item.set(NULL, CONTEXT_FACT_NAME, name);
        item.set(NULL, CONTEXT_FACT_OPTION, option);
        item.set(NULL, CONTEXT_FACT_DATA, data);
-       result.array_append(NULL, CONTEXT_FACT_CONDITION, item);
+       result.append(NULL, CONTEXT_FACT_CONDITION, item);
 
-       if (result.array_get_size(NULL, CONTEXT_FACT_CONDITION) == (int) condition.size()) {
+       if (result.getSize(NULL, CONTEXT_FACT_CONDITION) == (int) condition.size()) {
                on_context_data_prepared();
        }
 }
index b5829e0..d48665f 100644 (file)
@@ -18,7 +18,7 @@
 #define __CONTEXT_TRIGGER_RULE_H__
 
 #include <string>
-#include <json.h>
+#include <Json.h>
 #include "context_listener_iface.h"
 
 namespace ctx {
@@ -29,29 +29,29 @@ namespace ctx {
                private:
                        struct context_item_s {
                                std::string name;
-                               ctx::json option;
-                               context_item_s(ctx::json item) {
+                               ctx::Json option;
+                               context_item_s(ctx::Json item) {
                                        std::string n;
                                        item.get(NULL, CT_RULE_EVENT_ITEM, &n);
                                        name = n;
 
-                                       ctx::json o;
+                                       ctx::Json o;
                                        if (item.get(NULL, CT_RULE_EVENT_OPTION, &o))
                                                option = o.str();
                                }
                        };
 
                        typedef struct context_item_s* context_item_t;
-                       ctx::json statement;
+                       ctx::Json statement;
                        context_item_t event;
                        std::list<context_item_t> condition;
-                       ctx::json action;
-                       ctx::json result;
+                       ctx::Json action;
+                       ctx::Json result;
 
                        static rule_manager* rule_mgr;
 
                        void clear_result(void);
-                       bool set_condition_option_based_on_event(ctx::json& option);
+                       bool set_condition_option_based_on_event(ctx::Json& option);
                        void on_context_data_prepared(void);
 
                        static gboolean handle_uninstalled_rule(gpointer data);
@@ -60,14 +60,14 @@ namespace ctx {
                        int id;
                        std::string pkg_id;
 
-                       trigger_rule(int i, ctx::json& d, const char* p, rule_manager* rm);
+                       trigger_rule(int i, ctx::Json& d, const char* p, rule_manager* rm);
                        ~trigger_rule();
 
                        int start(void);
                        int stop(void);
 
-                       void on_event_received(std::string name, ctx::json option, ctx::json data);
-                       void on_condition_received(std::string name, ctx::json option, ctx::json data);
+                       void on_event_received(std::string name, ctx::Json option, ctx::Json data);
+                       void on_condition_received(std::string name, ctx::Json option, ctx::Json data);
 
        };
 
index 1bb90ed..51d08f4 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include <json.h>
+#include <Json.h>
 #include <types_internal.h>
 #include <context_trigger_types_internal.h>
 #include "rule_evaluator.h"
@@ -66,14 +66,14 @@ bool ctx::rule_evaluator::compare_int(std::string operation, int rule_var, int f
        }
 }
 
-bool ctx::rule_evaluator::replace_data_references(ctx::json& rule_data_arr, ctx::json event_fact_data)
+bool ctx::rule_evaluator::replace_data_references(ctx::Json& rule_data_arr, ctx::Json event_fact_data)
 {
        std::string arr_string;
        std::string event_reference_string;
        int event_reference_int;
 
-       for (int i = 0; i < rule_data_arr.array_get_size(NULL, CT_RULE_DATA_VALUE_ARR); i++) {
-               if (!rule_data_arr.get_array_elem(NULL, CT_RULE_DATA_VALUE_ARR, i, &arr_string)) {
+       for (int i = 0; i < rule_data_arr.getSize(NULL, CT_RULE_DATA_VALUE_ARR); i++) {
+               if (!rule_data_arr.getAt(NULL, CT_RULE_DATA_VALUE_ARR, i, &arr_string)) {
                        continue;
                }
                if (arr_string.substr(0, 1) != EVENT_REFERENCE) {
@@ -82,9 +82,9 @@ bool ctx::rule_evaluator::replace_data_references(ctx::json& rule_data_arr, ctx:
 
                std::string event_key = arr_string.substr(1, arr_string.length() - 1);
                if (event_fact_data.get(NULL, event_key.c_str(), &event_reference_string)) {
-                       rule_data_arr.array_set_at(NULL, CT_RULE_DATA_VALUE_ARR, i, event_reference_string);
+                       rule_data_arr.setAt(NULL, CT_RULE_DATA_VALUE_ARR, i, event_reference_string);
                } else if (event_fact_data.get(NULL, event_key.c_str(), &event_reference_int)) {
-                       rule_data_arr.array_set_at(NULL, CT_RULE_DATA_VALUE_ARR, i, event_reference_int);
+                       rule_data_arr.setAt(NULL, CT_RULE_DATA_VALUE_ARR, i, event_reference_int);
                } else {
                        _W("Option %s not found in event_data", event_key.c_str());
                }
@@ -93,10 +93,10 @@ bool ctx::rule_evaluator::replace_data_references(ctx::json& rule_data_arr, ctx:
        return true;
 }
 
-bool ctx::rule_evaluator::replace_option_references(ctx::json& rule_option, ctx::json event_fact_data)
+bool ctx::rule_evaluator::replace_option_references(ctx::Json& rule_option, ctx::Json event_fact_data)
 {
        std::list<std::string> key_list;
-       rule_option.get_keys(&key_list);
+       rule_option.getKeys(&key_list);
 
        for (std::list<std::string>::iterator it = key_list.begin(); it != key_list.end(); ++it) {
                std::string option_key = *it;
@@ -125,22 +125,22 @@ bool ctx::rule_evaluator::replace_option_references(ctx::json& rule_option, ctx:
        return true;
 }
 
-bool ctx::rule_evaluator::replace_event_references(ctx::json& rule, ctx::json& fact)
+bool ctx::rule_evaluator::replace_event_references(ctx::Json& rule, ctx::Json& fact)
 {
-       ctx::json event_fact_data;
+       ctx::Json event_fact_data;
        if (!fact.get(CONTEXT_FACT_EVENT, CONTEXT_FACT_DATA, &event_fact_data)) {
                _E("No event data found, error");
                return false;
        }
 
-       ctx::json rule_condition;
-       for (int i = 0; rule.get_array_elem(NULL, CT_RULE_CONDITION, i, &rule_condition); i++) {
-               ctx::json rule_data_arr;
-               for (int j = 0; rule_condition.get_array_elem(NULL, CT_RULE_DATA_ARR, j, &rule_data_arr); j++) {
+       ctx::Json rule_condition;
+       for (int i = 0; rule.getAt(NULL, CT_RULE_CONDITION, i, &rule_condition); i++) {
+               ctx::Json rule_data_arr;
+               for (int j = 0; rule_condition.getAt(NULL, CT_RULE_DATA_ARR, j, &rule_data_arr); j++) {
                        replace_data_references(rule_data_arr, event_fact_data);
                }
 
-               ctx::json rule_option;
+               ctx::Json rule_option;
                if (rule_condition.get(NULL, CT_RULE_CONDITION_OPTION, &rule_option)) {
                        replace_option_references(rule_option, event_fact_data);
                }
@@ -149,7 +149,7 @@ bool ctx::rule_evaluator::replace_event_references(ctx::json& rule, ctx::json& f
        return true;
 }
 
-bool ctx::rule_evaluator::evaluate_data_string(ctx::json& rule_data_arr, std::string fact_value_str)
+bool ctx::rule_evaluator::evaluate_data_string(ctx::Json& rule_data_arr, std::string fact_value_str)
 {
        std::string operate_internal;
        rule_data_arr.get(NULL, CT_RULE_DATA_KEY_OPERATOR, &operate_internal);
@@ -159,10 +159,10 @@ bool ctx::rule_evaluator::evaluate_data_string(ctx::json& rule_data_arr, std::st
        }
 
        std::string operator_str;
-       for (int j = 0; rule_data_arr.get_array_elem(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, j, &operator_str); j++) {
+       for (int j = 0; rule_data_arr.getAt(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, j, &operator_str); j++) {
                bool data_arr_vale_match;
                std::string get_str_val;
-               rule_data_arr.get_array_elem(NULL, CT_RULE_DATA_VALUE_ARR, j, &get_str_val);
+               rule_data_arr.getAt(NULL, CT_RULE_DATA_VALUE_ARR, j, &get_str_val);
                data_arr_vale_match = compare_string(operator_str, fact_value_str, get_str_val);
 
                if (is_and && !data_arr_vale_match) {
@@ -174,7 +174,7 @@ bool ctx::rule_evaluator::evaluate_data_string(ctx::json& rule_data_arr, std::st
        return is_and;
 }
 
-bool ctx::rule_evaluator::evaluate_data_int(ctx::json& rule_data_arr, int fact_value_int)
+bool ctx::rule_evaluator::evaluate_data_int(ctx::Json& rule_data_arr, int fact_value_int)
 {
        std::string operate_internal;
        rule_data_arr.get(NULL, CT_RULE_DATA_KEY_OPERATOR, &operate_internal);
@@ -184,10 +184,10 @@ bool ctx::rule_evaluator::evaluate_data_int(ctx::json& rule_data_arr, int fact_v
        }
 
        std::string operator_str;
-       for (int j = 0; rule_data_arr.get_array_elem(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, j, &operator_str); j++) {
+       for (int j = 0; rule_data_arr.getAt(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, j, &operator_str); j++) {
                bool data_arr_vale_match;
                int get_int_val;
-               if (!rule_data_arr.get_array_elem(NULL, CT_RULE_DATA_VALUE_ARR, j, &get_int_val)) {
+               if (!rule_data_arr.getAt(NULL, CT_RULE_DATA_VALUE_ARR, j, &get_int_val)) {
                        data_arr_vale_match = false;
                }
                data_arr_vale_match = compare_int(operator_str, fact_value_int, get_int_val);
@@ -201,10 +201,10 @@ bool ctx::rule_evaluator::evaluate_data_int(ctx::json& rule_data_arr, int fact_v
        return is_and;
 }
 
-bool ctx::rule_evaluator::evaluate_item(ctx::json& rule_item, ctx::json& fact_item)
+bool ctx::rule_evaluator::evaluate_item(ctx::Json& rule_item, ctx::Json& fact_item)
 {
-       ctx::json rule_data_arr;
-       if (rule_item.array_get_size(NULL, CT_RULE_DATA_ARR) == 0) {
+       ctx::Json rule_data_arr;
+       if (rule_item.getSize(NULL, CT_RULE_DATA_ARR) == 0) {
                return true;
        }
 
@@ -215,7 +215,7 @@ bool ctx::rule_evaluator::evaluate_item(ctx::json& rule_item, ctx::json& fact_it
                is_and = true;
        }
 
-       for (int i = 0; rule_item.get_array_elem(NULL, CT_RULE_DATA_ARR, i, &rule_data_arr); i++) {
+       for (int i = 0; rule_item.getAt(NULL, CT_RULE_DATA_ARR, i, &rule_data_arr); i++) {
                std::string data_key;
                rule_data_arr.get(NULL, CT_RULE_DATA_KEY, &data_key);
                std::string fact_value_str;
@@ -240,30 +240,30 @@ bool ctx::rule_evaluator::evaluate_item(ctx::json& rule_item, ctx::json& fact_it
        return is_and;
 }
 
-bool ctx::rule_evaluator::check_rule_event(ctx::json& rule, ctx::json& fact)
+bool ctx::rule_evaluator::check_rule_event(ctx::Json& rule, ctx::Json& fact)
 {
-       ctx::json fact_item;
+       ctx::Json fact_item;
        fact.get(NULL, CONTEXT_FACT_EVENT, &fact_item);
-       ctx::json rule_item;
+       ctx::Json rule_item;
        rule.get(NULL, CT_RULE_EVENT, &rule_item);
        return evaluate_item(rule_item, fact_item);
 }
 
-ctx::json ctx::rule_evaluator::find_condition_fact(ctx::json& rule_condition, ctx::json& fact)
+ctx::Json ctx::rule_evaluator::find_condition_fact(ctx::Json& rule_condition, ctx::Json& fact)
 {
-       ctx::json fact_condition;
+       ctx::Json fact_condition;
        std::string item_name_rule_condition;
        rule_condition.get(NULL, CT_RULE_CONDITION_ITEM, &item_name_rule_condition);
 
        std::string item_name_fact_condition;
-       for (int i = 0; fact.get_array_elem(NULL, CONTEXT_FACT_CONDITION, i, &fact_condition); i++) {
+       for (int i = 0; fact.getAt(NULL, CONTEXT_FACT_CONDITION, i, &fact_condition); i++) {
                fact_condition.get(NULL, CONTEXT_FACT_NAME, &item_name_fact_condition);
                if (item_name_fact_condition != item_name_rule_condition) {
                        continue;
                }
 
-               ctx::json rule_condition_option;
-               ctx::json fact_condition_option;
+               ctx::Json rule_condition_option;
+               ctx::Json fact_condition_option;
                rule_condition.get(NULL, CT_RULE_CONDITION_OPTION, &rule_condition_option);
                fact_condition.get(NULL, CONTEXT_FACT_OPTION, &fact_condition_option);
                if (fact_condition_option == rule_condition_option) {
@@ -275,10 +275,10 @@ ctx::json ctx::rule_evaluator::find_condition_fact(ctx::json& rule_condition, ct
        return EMPTY_JSON_OBJECT;
 }
 
-bool ctx::rule_evaluator::check_rule_condition(ctx::json& rule, ctx::json& fact)
+bool ctx::rule_evaluator::check_rule_condition(ctx::Json& rule, ctx::Json& fact)
 {
-       ctx::json rule_condition;
-       ctx::json fact_condition;
+       ctx::Json rule_condition;
+       ctx::Json fact_condition;
 
        std::string operate;
        rule.get(NULL, CT_RULE_OPERATOR, &operate);
@@ -287,7 +287,7 @@ bool ctx::rule_evaluator::check_rule_condition(ctx::json& rule, ctx::json& fact)
                is_and = true;
        }
 
-       for (int i = 0; rule.get_array_elem(NULL, CT_RULE_CONDITION, i, &rule_condition); i++) {
+       for (int i = 0; rule.getAt(NULL, CT_RULE_CONDITION, i, &rule_condition); i++) {
                fact_condition = find_condition_fact(rule_condition, fact);
                bool condition_satisfied;
                if (fact_condition == EMPTY_JSON_OBJECT) {
@@ -306,15 +306,15 @@ bool ctx::rule_evaluator::check_rule_condition(ctx::json& rule, ctx::json& fact)
        return is_and;
 }
 
-bool ctx::rule_evaluator::evaluate_rule(ctx::json rule, ctx::json fact)
+bool ctx::rule_evaluator::evaluate_rule(ctx::Json rule, ctx::Json fact)
 {
        _D("Rule is %s ", rule.str().c_str());
        _D("fact is %s ", fact.str().c_str());
        rule_evaluator eval;
        bool ret;
-       ctx::json temp_json;
+       ctx::Json temp_json;
        if (fact.get(NULL, CT_RULE_CONDITION, &temp_json)) {
-               ctx::json rule_copy(rule.str());
+               ctx::Json rule_copy(rule.str());
                if (!eval.replace_event_references(rule_copy, fact)) {
                        _W("Replace failed");
                }
index 9147eae..b0b2d40 100644 (file)
 
 namespace ctx {
 
-       class json;
+       class Json;
 
        class rule_evaluator {
        private:
                rule_evaluator();
-               bool evaluate_item(ctx::json& rule_item, ctx::json& fact_item);
+               bool evaluate_item(ctx::Json& rule_item, ctx::Json& fact_item);
                bool compare_int(std::string operation, int rule_var, int fact_var);
                bool compare_string(std::string operation, std::string rule_var, std::string fact_var);
-               bool check_rule_event(ctx::json& rule, ctx::json& fact);
-               ctx::json find_condition_fact(ctx::json& rule_condition, ctx::json& fact);
-               bool check_rule_condition(ctx::json& rule, ctx::json& fact);
-               bool replace_data_references(ctx::json& rule_data_arr, ctx::json event_fact_data);
-               bool replace_option_references(ctx::json& rule_option, ctx::json event_fact_data);
-               bool replace_event_references(ctx::json& rule, ctx::json& fact);
-               bool evaluate_data_string(ctx::json& rule_data_arr, std::string fact_value_str);
-               bool evaluate_data_int(ctx::json& rule_data_arr, int fact_value_int);
+               bool check_rule_event(ctx::Json& rule, ctx::Json& fact);
+               ctx::Json find_condition_fact(ctx::Json& rule_condition, ctx::Json& fact);
+               bool check_rule_condition(ctx::Json& rule, ctx::Json& fact);
+               bool replace_data_references(ctx::Json& rule_data_arr, ctx::Json event_fact_data);
+               bool replace_option_references(ctx::Json& rule_option, ctx::Json event_fact_data);
+               bool replace_event_references(ctx::Json& rule, ctx::Json& fact);
+               bool evaluate_data_string(ctx::Json& rule_data_arr, std::string fact_value_str);
+               bool evaluate_data_int(ctx::Json& rule_data_arr, int fact_value_int);
        public:
-               static bool evaluate_rule(ctx::json rule, ctx::json data);
+               static bool evaluate_rule(ctx::Json rule, ctx::Json data);
        };
 
 }      /* namespace ctx */
index 815ed2e..c29a1d4 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 #include <sstream>
-#include <json.h>
+#include <Json.h>
 #include <context_trigger_types_internal.h>
 #include <db_mgr.h>
 #include <package_manager.h>
@@ -87,13 +87,13 @@ int ctx::rule_manager::get_uninstalled_app(void)
        // Return number of uninstalled apps
        std::string q1 = "SELECT DISTINCT package_id FROM context_trigger_rule";
 
-       std::vector<json> record;
+       std::vector<Json> record;
        bool ret = db_manager::execute_sync(q1.c_str(), &record);
        IF_FAIL_RETURN_TAG(ret, -1, _E, "Query package ids of registered rules failed");
 
-       std::vector<json>::iterator vec_end = record.end();
-       for (std::vector<json>::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) {
-               ctx::json elem = *vec_pos;
+       std::vector<Json>::iterator vec_end = record.end();
+       for (std::vector<Json>::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) {
+               ctx::Json elem = *vec_pos;
                std::string pkg_id;
                elem.get(NULL, "package_id", &pkg_id);
 
@@ -151,13 +151,13 @@ int ctx::rule_manager::clear_rule_of_uninstalled_package(bool is_init)
                q1 += pkg_list;
                q1 += ")";
 
-               std::vector<json> record;
+               std::vector<Json> record;
                ret = db_manager::execute_sync(q1.c_str(), &record);
                IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Failed to query enabled rules of uninstalled packages");
 
-               std::vector<json>::iterator vec_end = record.end();
-               for (std::vector<json>::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) {
-                       ctx::json elem = *vec_pos;
+               std::vector<Json>::iterator vec_end = record.end();
+               for (std::vector<Json>::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) {
+                       ctx::Json elem = *vec_pos;
                        int rule_id;
                        elem.get(NULL, "row_id", &rule_id);
                        error = disable_rule(rule_id);
@@ -168,7 +168,7 @@ int ctx::rule_manager::clear_rule_of_uninstalled_package(bool is_init)
 
        // Delete rules of uninstalled packages from DB
        std::string q2 = "DELETE FROM context_trigger_rule WHERE " + pkg_list;
-       std::vector<json> dummy;
+       std::vector<Json> dummy;
        ret = db_manager::execute_sync(q2.c_str(), &dummy);
        IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Failed to remove rules from db");
        _D("Uninstalled packages' rules are deleted from db");
@@ -181,15 +181,15 @@ int ctx::rule_manager::clear_rule_of_uninstalled_package(bool is_init)
 int ctx::rule_manager::pause_rule_with_item(std::string& subject)
 {
        std::string q = "SELECT row_id FROM context_trigger_rule WHERE (status=2) AND (details LIKE '%\"ITEM_NAME\":\"" + subject + "\"%');";
-       std::vector<json> record;
+       std::vector<Json> record;
        bool ret = db_manager::execute_sync(q.c_str(), &record);
        IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Failed to query row_ids to be paused");
        IF_FAIL_RETURN(record.size() > 0, ERR_NONE);
 
        _D("Pause rules related to %s", subject.c_str());
-       std::vector<json>::iterator vec_end = record.end();
-       for (std::vector<json>::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) {
-               ctx::json elem = *vec_pos;
+       std::vector<Json>::iterator vec_end = record.end();
+       for (std::vector<Json>::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) {
+               ctx::Json elem = *vec_pos;
                int row_id;
                elem.get(NULL, "row_id", &row_id);
 
@@ -203,16 +203,16 @@ int ctx::rule_manager::pause_rule_with_item(std::string& subject)
 int ctx::rule_manager::resume_rule_with_item(std::string& subject)
 {
        std::string q = "SELECT row_id FROM context_trigger_rule WHERE (status=1) AND (details LIKE '%\"ITEM_NAME\":\"" + subject + "\"%');";
-       std::vector<json> record;
+       std::vector<Json> record;
        bool ret = db_manager::execute_sync(q.c_str(), &record);
        IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Query paused rule ids failed");
        IF_FAIL_RETURN(record.size() > 0, ERR_NONE);
 
        _D("Resume rules related to %s", subject.c_str());
        std::string q_rowid;
-       std::vector<json>::iterator vec_end = record.end();
-       for (std::vector<json>::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) {
-               ctx::json elem = *vec_pos;
+       std::vector<Json>::iterator vec_end = record.end();
+       for (std::vector<Json>::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) {
+               ctx::Json elem = *vec_pos;
                int row_id;
                elem.get(NULL, "row_id", &row_id);
 
@@ -228,7 +228,7 @@ bool ctx::rule_manager::reenable_rule(void)
        int error;
        std::string q = "SELECT row_id FROM context_trigger_rule WHERE status = 2";
 
-       std::vector<json> record;
+       std::vector<Json> record;
        bool ret = db_manager::execute_sync(q.c_str(), &record);
        IF_FAIL_RETURN_TAG(ret, false, _E, "Query row_ids of enabled rules failed");
        IF_FAIL_RETURN_TAG(record.size() > 0, true, _D, "No rule to re-enable");
@@ -237,9 +237,9 @@ bool ctx::rule_manager::reenable_rule(void)
 
        std::string q_rowid;
        q_rowid.clear();
-       std::vector<json>::iterator vec_end = record.end();
-       for (std::vector<json>::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) {
-               ctx::json elem = *vec_pos;
+       std::vector<Json>::iterator vec_end = record.end();
+       for (std::vector<Json>::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) {
+               ctx::Json elem = *vec_pos;
                int row_id;
                elem.get(NULL, "row_id", &row_id);
 
@@ -255,14 +255,14 @@ bool ctx::rule_manager::reenable_rule(void)
 
        // For rules which is failed to re-enable
        std::string q_update = "UPDATE context_trigger_rule SET status = 1 WHERE " + q_rowid;
-       std::vector<json> record2;
+       std::vector<Json> record2;
        ret = db_manager::execute_sync(q_update.c_str(), &record2);
        IF_FAIL_RETURN_TAG(ret, false, _E, "Failed to update rules as paused");
 
        return true;
 }
 
-bool ctx::rule_manager::rule_data_arr_elem_equals(ctx::json& lelem, ctx::json& relem)
+bool ctx::rule_manager::rule_data_arr_elem_equals(ctx::Json& lelem, ctx::Json& relem)
 {
        std::string lkey, rkey;
        lelem.get(NULL, CT_RULE_DATA_KEY, &lkey);
@@ -271,10 +271,10 @@ bool ctx::rule_manager::rule_data_arr_elem_equals(ctx::json& lelem, ctx::json& r
                return false;
 
        int lvc, rvc, lvoc, rvoc;
-       lvc = lelem.array_get_size(NULL, CT_RULE_DATA_VALUE_ARR);
-       rvc = relem.array_get_size(NULL, CT_RULE_DATA_VALUE_ARR);
-       lvoc = lelem.array_get_size(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR);
-       rvoc = relem.array_get_size(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR);
+       lvc = lelem.getSize(NULL, CT_RULE_DATA_VALUE_ARR);
+       rvc = relem.getSize(NULL, CT_RULE_DATA_VALUE_ARR);
+       lvoc = lelem.getSize(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR);
+       rvoc = relem.getSize(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR);
        if (!((lvc == rvc) && (lvc == lvoc) && (lvc && rvoc)))
                return false;
 
@@ -289,13 +289,13 @@ bool ctx::rule_manager::rule_data_arr_elem_equals(ctx::json& lelem, ctx::json& r
        for (int i = 0; i < lvc; i++) {
                bool found = false;
                std::string lv, lvo;
-               lelem.get_array_elem(NULL, CT_RULE_DATA_VALUE_ARR, i, &lv);
-               lelem.get_array_elem(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, i, &lvo);
+               lelem.getAt(NULL, CT_RULE_DATA_VALUE_ARR, i, &lv);
+               lelem.getAt(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, i, &lvo);
 
                for (int j = 0; j < lvc; j++) {
                        std::string rv, rvo;
-                       relem.get_array_elem(NULL, CT_RULE_DATA_VALUE_ARR, j, &rv);
-                       relem.get_array_elem(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, j, &rvo);
+                       relem.getAt(NULL, CT_RULE_DATA_VALUE_ARR, j, &rv);
+                       relem.getAt(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, j, &rvo);
 
                        if (!lv.compare(rv) && !lvo.compare(rvo)) {
                                found = true;
@@ -309,7 +309,7 @@ bool ctx::rule_manager::rule_data_arr_elem_equals(ctx::json& lelem, ctx::json& r
        return true;
 }
 
-bool ctx::rule_manager::rule_item_equals(ctx::json& litem, ctx::json& ritem)
+bool ctx::rule_manager::rule_item_equals(ctx::Json& litem, ctx::Json& ritem)
 {
        // Compare item name
        std::string lei, rei;
@@ -319,15 +319,15 @@ bool ctx::rule_manager::rule_item_equals(ctx::json& litem, ctx::json& ritem)
                return false;
 
        // Compare option
-       ctx::json loption, roption;
+       ctx::Json loption, roption;
        litem.get(NULL, CT_RULE_EVENT_OPTION, &loption);
        ritem.get(NULL, CT_RULE_EVENT_OPTION, &roption);
        if (loption != roption)
                return false;
 
        int ledac, redac;
-       ledac = litem.array_get_size(NULL, CT_RULE_DATA_ARR);
-       redac = ritem.array_get_size(NULL, CT_RULE_DATA_ARR);
+       ledac = litem.getSize(NULL, CT_RULE_DATA_ARR);
+       redac = ritem.getSize(NULL, CT_RULE_DATA_ARR);
        if (ledac != redac)
                return false;
 
@@ -342,12 +342,12 @@ bool ctx::rule_manager::rule_item_equals(ctx::json& litem, ctx::json& ritem)
 
        for (int i = 0; i < ledac; i++) {
                bool found = false;
-               ctx::json lelem;
-               litem.get_array_elem(NULL, CT_RULE_DATA_ARR, i, &lelem);
+               ctx::Json lelem;
+               litem.getAt(NULL, CT_RULE_DATA_ARR, i, &lelem);
 
                for (int j = 0; j < ledac; j++) {
-                       ctx::json relem;
-                       ritem.get_array_elem(NULL, CT_RULE_DATA_ARR, j, &relem);
+                       ctx::Json relem;
+                       ritem.getAt(NULL, CT_RULE_DATA_ARR, j, &relem);
 
                        if (rule_data_arr_elem_equals(lelem, relem)) {
                                found = true;
@@ -361,10 +361,10 @@ bool ctx::rule_manager::rule_item_equals(ctx::json& litem, ctx::json& ritem)
        return true;
 }
 
-bool ctx::rule_manager::rule_equals(ctx::json& lrule, ctx::json& rrule)
+bool ctx::rule_manager::rule_equals(ctx::Json& lrule, ctx::Json& rrule)
 {
        // Compare event
-       ctx::json le, re;
+       ctx::Json le, re;
        lrule.get(NULL, CT_RULE_EVENT, &le);
        rrule.get(NULL, CT_RULE_EVENT, &re);
        if (!rule_item_equals(le, re))
@@ -372,8 +372,8 @@ bool ctx::rule_manager::rule_equals(ctx::json& lrule, ctx::json& rrule)
 
        // Compare conditions
        int lcc, rcc;
-       lcc = lrule.array_get_size(NULL, CT_RULE_CONDITION);
-       rcc = rrule.array_get_size(NULL, CT_RULE_CONDITION);
+       lcc = lrule.getSize(NULL, CT_RULE_CONDITION);
+       rcc = rrule.getSize(NULL, CT_RULE_CONDITION);
        if (lcc != rcc)
                return false;
 
@@ -387,12 +387,12 @@ bool ctx::rule_manager::rule_equals(ctx::json& lrule, ctx::json& rrule)
 
        for (int i = 0; i < lcc; i++) {
                bool found = false;
-               ctx::json lc;
-               lrule.get_array_elem(NULL, CT_RULE_CONDITION, i, &lc);
+               ctx::Json lc;
+               lrule.getAt(NULL, CT_RULE_CONDITION, i, &lc);
 
                for (int j = 0; j < lcc; j++) {
-                       ctx::json rc;
-                       rrule.get_array_elem(NULL, CT_RULE_CONDITION, j, &rc);
+                       ctx::Json rc;
+                       rrule.getAt(NULL, CT_RULE_CONDITION, j, &rc);
 
                        if (rule_item_equals(lc, rc)) {
                                found = true;
@@ -404,7 +404,7 @@ bool ctx::rule_manager::rule_equals(ctx::json& lrule, ctx::json& rrule)
        }
 
        // Compare action
-       ctx::json laction, raction;
+       ctx::Json laction, raction;
        lrule.get(NULL, CT_RULE_ACTION, &laction);
        rrule.get(NULL, CT_RULE_ACTION, &raction);
        if (laction != raction)
@@ -413,26 +413,26 @@ bool ctx::rule_manager::rule_equals(ctx::json& lrule, ctx::json& rrule)
        return true;
 }
 
-int64_t ctx::rule_manager::get_duplicated_rule_id(std::string pkg_id, ctx::json& rule)
+int64_t ctx::rule_manager::get_duplicated_rule_id(std::string pkg_id, ctx::Json& rule)
 {
        std::string q = "SELECT row_id, description, details FROM context_trigger_rule WHERE package_id = '";
        q += pkg_id;
        q += "'";
 
-       std::vector<json> d_record;
+       std::vector<Json> d_record;
        bool ret = db_manager::execute_sync(q.c_str(), &d_record);
        IF_FAIL_RETURN_TAG(ret, false, _E, "Query row_id, details by package id failed");
 
-       ctx::json r_details;
+       ctx::Json r_details;
        rule.get(NULL, CT_RULE_DETAILS, &r_details);
        std::string r_desc;
        rule.get(NULL, CT_RULE_DESCRIPTION, &r_desc);
-       std::vector<json>::iterator vec_end = d_record.end();
+       std::vector<Json>::iterator vec_end = d_record.end();
 
-       for (std::vector<json>::iterator vec_pos = d_record.begin(); vec_pos != vec_end; ++vec_pos) {
-               ctx::json elem = *vec_pos;
+       for (std::vector<Json>::iterator vec_pos = d_record.begin(); vec_pos != vec_end; ++vec_pos) {
+               ctx::Json elem = *vec_pos;
                std::string details;
-               ctx::json d_details;
+               ctx::Json d_details;
 
                elem.get(NULL, "details", &details);
                d_details = details;
@@ -448,7 +448,7 @@ int64_t ctx::rule_manager::get_duplicated_rule_id(std::string pkg_id, ctx::json&
                                // Only description is changed
                                std::string q_update = "UPDATE context_trigger_rule SET description='" + r_desc + "' WHERE row_id = " + int_to_string(row_id);
 
-                               std::vector<json> record;
+                               std::vector<Json> record;
                                ret = db_manager::execute_sync(q_update.c_str(), &record);
                                if (ret) {
                                        _D("Rule%lld description is updated", row_id);
@@ -464,9 +464,9 @@ int64_t ctx::rule_manager::get_duplicated_rule_id(std::string pkg_id, ctx::json&
        return -1;
 }
 
-int ctx::rule_manager::verify_rule(ctx::json& rule, const char* creator)
+int ctx::rule_manager::verify_rule(ctx::Json& rule, const char* creator)
 {
-       ctx::json details;
+       ctx::Json details;
        rule.get(NULL, CT_RULE_DETAILS, &details);
 
        std::string e_name;
@@ -484,8 +484,8 @@ int ctx::rule_manager::verify_rule(ctx::json& rule, const char* creator)
                }
        }
 
-       ctx::json it;
-       for (int i = 0; rule.get_array_elem(CT_RULE_DETAILS, CT_RULE_CONDITION, i, &it); i++){
+       ctx::Json it;
+       for (int i = 0; rule.getAt(CT_RULE_DETAILS, CT_RULE_CONDITION, i, &it); i++){
                std::string c_name;
                it.get(NULL, CT_RULE_CONDITION_ITEM, &c_name);
 
@@ -500,7 +500,7 @@ int ctx::rule_manager::verify_rule(ctx::json& rule, const char* creator)
        return ERR_NONE;
 }
 
-int ctx::rule_manager::add_rule(std::string creator, const char* pkg_id, ctx::json rule, ctx::json* rule_id)
+int ctx::rule_manager::add_rule(std::string creator, const char* pkg_id, ctx::Json rule, ctx::Json* rule_id)
 {
        apply_templates();
        bool ret;
@@ -519,9 +519,9 @@ int ctx::rule_manager::add_rule(std::string creator, const char* pkg_id, ctx::js
        }
 
        // Insert rule to rule table, get rule id
-       ctx::json r_record;
+       ctx::Json r_record;
        std::string description;
-       ctx::json details;
+       ctx::Json details;
        rule.get(NULL, CT_RULE_DESCRIPTION, &description);
        rule.get(NULL, CT_RULE_DETAILS, &details);
        r_record.set(NULL, "creator", creator);
@@ -554,7 +554,7 @@ int ctx::rule_manager::remove_rule(int rule_id)
        std::string query = "DELETE FROM 'context_trigger_rule' where row_id = ";
        query += int_to_string(rule_id);
 
-       std::vector<json> record;
+       std::vector<Json> record;
        ret = db_manager::execute_sync(query.c_str(), &record);
        IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Remove rule from db failed");
 
@@ -568,16 +568,16 @@ int ctx::rule_manager::enable_rule(int rule_id)
        apply_templates();
        int error;
        std::string query;
-       std::vector<json> rule_record;
-       std::vector<json> record;
+       std::vector<Json> rule_record;
+       std::vector<Json> record;
        std::string pkg_id;
-       ctx::json jrule;
+       ctx::Json jrule;
        std::string tmp;
        std::string id_str = int_to_string(rule_id);
 
        trigger_rule* rule;
 
-       // Get rule json by rule id;
+       // Get rule Json by rule id;
        query = "SELECT details, package_id FROM context_trigger_rule WHERE row_id = ";
        query += id_str;
        error = (db_manager::execute_sync(query.c_str(), &rule_record))? ERR_NONE : ERR_OPERATION_FAILED;
@@ -638,7 +638,7 @@ int ctx::rule_manager::disable_rule(int rule_id)
        // Update db to set 'disabled'  // TODO skip while clear uninstalled rule
        std::string query = "UPDATE context_trigger_rule SET status = 0 WHERE row_id = ";
        query += int_to_string(rule_id);
-       std::vector<json> record;
+       std::vector<Json> record;
        ret = db_manager::execute_sync(query.c_str(), &record);
        IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Update db failed");
 
@@ -663,7 +663,7 @@ int ctx::rule_manager::pause_rule(int rule_id)
        std::string query = "UPDATE context_trigger_rule SET status = 1 WHERE row_id = ";
 
        query += int_to_string(rule_id);
-       std::vector<json> record;
+       std::vector<Json> record;
        ret = db_manager::execute_sync(query.c_str(), &record);
        IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Update db failed");
 
@@ -681,7 +681,7 @@ int ctx::rule_manager::check_rule(std::string pkg_id, int rule_id)
        std::string q = "SELECT package_id FROM context_trigger_rule WHERE row_id =";
        q += int_to_string(rule_id);
 
-       std::vector<json> record;
+       std::vector<Json> record;
        bool ret = db_manager::execute_sync(q.c_str(), &record);
        IF_FAIL_RETURN_TAG(ret, false, _E, "Query package id by rule id failed");
 
@@ -704,7 +704,7 @@ bool ctx::rule_manager::is_rule_enabled(int rule_id)
        std::string q = "SELECT status FROM context_trigger_rule WHERE row_id =";
        q += int_to_string(rule_id);
 
-       std::vector<json> record;
+       std::vector<Json> record;
        bool ret = db_manager::execute_sync(q.c_str(), &record);
        IF_FAIL_RETURN_TAG(ret, false, _E, "Query enabled by rule id failed");
 
@@ -714,7 +714,7 @@ bool ctx::rule_manager::is_rule_enabled(int rule_id)
        return (status != 0);
 }
 
-int ctx::rule_manager::get_rule_by_id(std::string pkg_id, int rule_id, ctx::json* request_result)
+int ctx::rule_manager::get_rule_by_id(std::string pkg_id, int rule_id, ctx::Json* request_result)
 {
        apply_templates();
        std::string q = "SELECT description FROM context_trigger_rule WHERE (package_id = '";
@@ -723,7 +723,7 @@ int ctx::rule_manager::get_rule_by_id(std::string pkg_id, int rule_id, ctx::json
        q += int_to_string(rule_id);
        q += ")";
 
-       std::vector<json> record;
+       std::vector<Json> record;
        bool ret = db_manager::execute_sync(q.c_str(), &record);
        IF_FAIL_RETURN_TAG(ret, false, _E, "Query rule by rule id failed");
 
@@ -742,7 +742,7 @@ int ctx::rule_manager::get_rule_by_id(std::string pkg_id, int rule_id, ctx::json
        return ERR_NONE;
 }
 
-int ctx::rule_manager::get_rule_ids(std::string pkg_id, ctx::json* request_result)
+int ctx::rule_manager::get_rule_ids(std::string pkg_id, ctx::Json* request_result)
 {
        (*request_result) = "{ \"" CT_RULE_ARRAY_ENABLED "\" : [ ] , \"" CT_RULE_ARRAY_DISABLED "\" : [ ] }";
 
@@ -750,13 +750,13 @@ int ctx::rule_manager::get_rule_ids(std::string pkg_id, ctx::json* request_resul
        q += pkg_id;
        q += "')";
 
-       std::vector<json> record;
+       std::vector<Json> record;
        bool ret = db_manager::execute_sync(q.c_str(), &record);
        IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Query rules failed");
 
-       std::vector<json>::iterator vec_end = record.end();
-       for (std::vector<json>::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) {
-               ctx::json elem = *vec_pos;
+       std::vector<Json>::iterator vec_end = record.end();
+       for (std::vector<Json>::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) {
+               ctx::Json elem = *vec_pos;
                std::string id;
                int status;
 
@@ -764,9 +764,9 @@ int ctx::rule_manager::get_rule_ids(std::string pkg_id, ctx::json* request_resul
                elem.get(NULL, "status", &status);
 
                if (status >= 1) {
-                       (*request_result).array_append(NULL, CT_RULE_ARRAY_ENABLED, string_to_int(id));
+                       (*request_result).append(NULL, CT_RULE_ARRAY_ENABLED, string_to_int(id));
                } else if (status == 0) {
-                       (*request_result).array_append(NULL, CT_RULE_ARRAY_DISABLED, string_to_int(id));
+                       (*request_result).append(NULL, CT_RULE_ARRAY_DISABLED, string_to_int(id));
                }
        }
 
index 2b0b44e..1862fcd 100644 (file)
@@ -22,7 +22,7 @@
 
 namespace ctx {
 
-       class json;
+       class Json;
        class context_trigger;
        class trigger_rule;
 
@@ -32,12 +32,12 @@ namespace ctx {
                        ~rule_manager();
 
                        bool init();
-                       int add_rule(std::string creator, const char* pkg_id, ctx::json rule, ctx::json* rule_id);
+                       int add_rule(std::string creator, const char* pkg_id, 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);
-                       int get_rule_by_id(std::string pkg_id, int rule_id, ctx::json* request_result);
-                       int get_rule_ids(std::string pkg_id, ctx::json* request_result);
+                       int get_rule_by_id(std::string pkg_id, int rule_id, ctx::Json* request_result);
+                       int get_rule_ids(std::string pkg_id, ctx::Json* request_result);
                        int check_rule(std::string pkg_id, int rule_id);
                        bool is_rule_enabled(int rule_id);
                        int pause_rule_with_item(std::string& subject);
@@ -49,11 +49,11 @@ namespace ctx {
 
                private:
                        bool reenable_rule(void);
-                       int verify_rule(ctx::json& rule, const char* creator);
-                       int64_t get_duplicated_rule_id(std::string pkg_id, 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);
+                       int verify_rule(ctx::Json& rule, const char* creator);
+                       int64_t get_duplicated_rule_id(std::string pkg_id, 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);
                        int get_uninstalled_app(void);
                        int clear_rule_of_uninstalled_package(bool is_init = false);
                        void apply_templates(void);
index a1c2cf2..ae9606e 100644 (file)
@@ -77,7 +77,7 @@ bool ctx::template_manager::init()
                        + "(name TEXT DEFAULT '' NOT NULL PRIMARY KEY, operation INTEGER DEFAULT 3 NOT NULL, "
                        + "attributes TEXT DEFAULT '' NOT NULL, options TEXT DEFAULT '' NOT NULL, owner TEXT DEFAULT '' NOT NULL)";
 
-       std::vector<json> record;
+       std::vector<Json> record;
        bool ret = db_manager::execute_sync(q.c_str(), &record);
        IF_FAIL_RETURN_TAG(ret, false, _E, "Create template table failed");
 
@@ -91,8 +91,8 @@ void ctx::template_manager::apply_templates()
 {
        std::string subject;
        int operation;
-       ctx::json attributes;
-       ctx::json options;
+       ctx::Json attributes;
+       ctx::Json options;
        std::string owner;
        bool unregister;
        std::string query;
@@ -111,12 +111,12 @@ void ctx::template_manager::apply_templates()
        }
        IF_FAIL_VOID(!query.empty());
 
-       std::vector<json> record;
+       std::vector<Json> record;
        bool ret = db_manager::execute_sync(query.c_str(), &record);
        IF_FAIL_VOID_TAG(ret, _E, "Update template db failed");
 }
 
-std::string ctx::template_manager::add_template(std::string &subject, int &operation, ctx::json &attributes, ctx::json &options, std::string &owner)
+std::string ctx::template_manager::add_template(std::string &subject, int &operation, ctx::Json &attributes, ctx::Json &options, std::string &owner)
 {
        _D("[Add template] Subject: %s, Ops: %d, Owner: %s", subject.c_str(), operation, owner.c_str());
        _J("Attr", attributes);
@@ -141,14 +141,14 @@ std::string ctx::template_manager::remove_template(std::string &subject)
        return query;
 }
 
-int ctx::template_manager::get_template(std::string &subject, ctx::json* tmpl)
+int ctx::template_manager::get_template(std::string &subject, ctx::Json* tmpl)
 {
        // Update latest template information
        apply_templates();
 
        std::string q = "SELECT * FROM context_trigger_template WHERE name = '" + subject + "'";
 
-       std::vector<json> record;
+       std::vector<Json> record;
        bool ret = db_manager::execute_sync(q.c_str(), &record);
        IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Query template failed");
        IF_FAIL_RETURN_TAG(record.size() > 0, ERR_NOT_SUPPORTED, _E, "Template(%s) not found", subject.c_str());
@@ -161,8 +161,8 @@ int ctx::template_manager::get_template(std::string &subject, ctx::json* tmpl)
        tmpl->get(NULL, TYPE_OPTION_STR, &opt_str);
        tmpl->get(NULL, TYPE_ATTR_STR, &attr_str);
 
-       ctx::json opt = opt_str;
-       ctx::json attr = attr_str;
+       ctx::Json opt = opt_str;
+       ctx::Json attr = attr_str;
 
        tmpl->set(NULL, TYPE_OPTION_STR, opt);
        tmpl->set(NULL, TYPE_ATTR_STR, attr);
index dc578e6..3f84a24 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef __TEMPLATE_MANAGER_H__
 #define __TEMPLATE_MANAGER_H__
 
-#include <json.h>
+#include <Json.h>
 
 namespace ctx {
 
@@ -31,7 +31,7 @@ namespace ctx {
 
                bool init();
                void apply_templates();
-               int get_template(std::string &subject, ctx::json* tmpl);
+               int get_template(std::string &subject, ctx::Json* tmpl);
 
        private:
                template_manager();
@@ -42,7 +42,7 @@ namespace ctx {
                static context_manager_impl *_context_mgr;
                static rule_manager *_rule_mgr;
 
-               std::string add_template(std::string &subject, int &operation, ctx::json &attributes, ctx::json &options, std::string &owner);
+               std::string add_template(std::string &subject, int &operation, ctx::Json &attributes, ctx::Json &options, std::string &owner);
                std::string remove_template(std::string &subject);
 
        };      /* class template_manager */
index 33f09b4..0a14b58 100644 (file)
@@ -23,7 +23,7 @@
 #define TIMER_DAY_OF_WEEK "DayOfWeek"
 #define TIMER_TIME_OF_DAY "TimeOfDay"
 
-static int arrange_day_of_week(ctx::json day_info)
+static int arrange_day_of_week(ctx::Json day_info)
 {
        int result = 0;
 
@@ -38,10 +38,10 @@ static int arrange_day_of_week(ctx::json day_info)
        }
 
        std::string tmp_d;
-       for (int i = 0; day_info.get_array_elem(NULL, CT_RULE_DATA_VALUE_ARR, i, &tmp_d); i++) {
+       for (int i = 0; day_info.getAt(NULL, CT_RULE_DATA_VALUE_ARR, i, &tmp_d); i++) {
                int dow = ctx::timer_util::convert_day_of_week_string_to_int(tmp_d);
                std::string op;
-               day_info.get_array_elem(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, i, &op);
+               day_info.getAt(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, i, &op);
 
                if (op.compare(CONTEXT_TRIGGER_NOT_EQUAL_TO) == 0) {
                        dow = ctx::timer_util::convert_day_of_week_string_to_int(TIMER_TYPES_EVERYDAY) & ~dow;
@@ -58,9 +58,9 @@ static int arrange_day_of_week(ctx::json day_info)
        return result;
 }
 
-void ctx::trigger_timer::handle_timer_event(ctx::json& rule)
+void ctx::trigger_timer::handle_timer_event(ctx::Json& rule)
 {
-       ctx::json event;
+       ctx::Json event;
        rule.get(NULL, CT_RULE_EVENT, &event);
 
        std::string e_name;
@@ -69,10 +69,10 @@ void ctx::trigger_timer::handle_timer_event(ctx::json& rule)
                return;
        }
 
-       ctx::json day_info;
-       ctx::json it;
+       ctx::Json day_info;
+       ctx::Json it;
        int dow;
-       for (int i = 0; event.get_array_elem(NULL, CT_RULE_DATA_ARR, i, &it); i++) {
+       for (int i = 0; event.getAt(NULL, CT_RULE_DATA_ARR, i, &it); i++) {
                std::string key;
                it.get(NULL, CT_RULE_DATA_KEY, &key);
 
@@ -86,18 +86,18 @@ void ctx::trigger_timer::handle_timer_event(ctx::json& rule)
                                int d = 0x01 << j;
                                if (dow & d) {
                                        std::string day = ctx::timer_util::convert_day_of_week_int_to_string(d);
-                                       day_info.array_append(NULL, CT_RULE_DATA_VALUE_ARR, day);
-                                       day_info.array_append(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, CONTEXT_TRIGGER_EQUAL_TO);
+                                       day_info.append(NULL, CT_RULE_DATA_VALUE_ARR, day);
+                                       day_info.append(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, CONTEXT_TRIGGER_EQUAL_TO);
 
                                        // Set option
-                                       event.array_append(CT_RULE_EVENT_OPTION, TIMER_DAY_OF_WEEK, day);
+                                       event.append(CT_RULE_EVENT_OPTION, TIMER_DAY_OF_WEEK, day);
                                }
                        }
-                       event.array_set_at(NULL, CT_RULE_DATA_ARR, i, day_info);
+                       event.setAt(NULL, CT_RULE_DATA_ARR, i, day_info);
                } else if (key.compare(TIMER_TIME_OF_DAY) == 0) {
                        int time;
-                       for (int j = 0; it.get_array_elem(NULL, CT_RULE_DATA_VALUE_ARR, j, &time); j++) {
-                               event.array_append(CT_RULE_EVENT_OPTION, TIMER_TIME_OF_DAY, time);
+                       for (int j = 0; it.getAt(NULL, CT_RULE_DATA_VALUE_ARR, j, &time); j++) {
+                               event.append(CT_RULE_EVENT_OPTION, TIMER_TIME_OF_DAY, time);
                        }
                }
        }
index a40c9da..c72fd45 100644 (file)
 #ifndef __CONTEXT_CONTEXT_TRIGGER_TIMER_H__
 #define __CONTEXT_CONTEXT_TRIGGER_TIMER_H__
 
-#include <json.h>
+#include <Json.h>
 
 namespace ctx {
 
        namespace trigger_timer {
 
-               void handle_timer_event(ctx::json& rule);
+               void handle_timer_event(ctx::Json& rule);
 
        };
 
index d0b28e4..ab324b8 100644 (file)
@@ -124,7 +124,7 @@ void ctx::context_trigger::process_initialize(ctx::context_manager_impl* mgr)
 
 void ctx::context_trigger::add_rule(ctx::request_info* request)
 {
-       ctx::json rule_id;
+       ctx::Json rule_id;
 
        const char* client = request->get_client();
        if (client == NULL) {
@@ -147,7 +147,7 @@ void ctx::context_trigger::remove_rule(ctx::request_info* request)
 
        const char* pkg_id = request->get_package_id();
 
-       ctx::json rule_id = request->get_description();
+       ctx::Json rule_id = request->get_description();
        rule_id.get(NULL, CT_RULE_ID, &id);
 
        error = rule_mgr->check_rule((pkg_id)? pkg_id : "", id);
@@ -174,7 +174,7 @@ void ctx::context_trigger::enable_rule(ctx::request_info* request)
 
        const char* pkg_id = request->get_package_id();
 
-       ctx::json rule_id = request->get_description();
+       ctx::Json rule_id = request->get_description();
        rule_id.get(NULL, CT_RULE_ID, &id);
 
        error = rule_mgr->check_rule((pkg_id)? pkg_id : "", id);
@@ -201,7 +201,7 @@ void ctx::context_trigger::disable_rule(ctx::request_info* request)
 
        const char* pkg_id = request->get_package_id();
 
-       ctx::json rule_id = request->get_description();
+       ctx::Json rule_id = request->get_description();
        rule_id.get(NULL, CT_RULE_ID, &id);
 
        error = rule_mgr->check_rule((pkg_id)? pkg_id : "", id);
@@ -225,16 +225,16 @@ void ctx::context_trigger::get_rule_by_id(ctx::request_info* request)
 {
        int error;
 
-       ctx::json option = request->get_description();
+       ctx::Json option = request->get_description();
        int id;
        option.get(NULL, CT_RULE_ID, &id);
 
        const char* pkg_id = request->get_package_id();
 
-       ctx::json read_data;
+       ctx::Json read_data;
        error = rule_mgr->get_rule_by_id((pkg_id)? pkg_id : "", id, &read_data);
 
-       ctx::json dummy;
+       ctx::Json dummy;
        request->reply(error, dummy, read_data);
 }
 
@@ -244,10 +244,10 @@ void ctx::context_trigger::get_rule_ids(ctx::request_info* request)
 
        const char* pkg_id = request->get_package_id();
 
-       ctx::json read_data;
+       ctx::Json read_data;
        error = rule_mgr->get_rule_ids((pkg_id)? pkg_id : "", &read_data);
 
-       ctx::json dummy;
+       ctx::Json dummy;
        request->reply(error, dummy, read_data);
 }
 
@@ -255,7 +255,7 @@ void ctx::context_trigger::get_template(ctx::request_info* request)
 {
        int error;
 
-       ctx::json option = request->get_description();
+       ctx::Json option = request->get_description();
        std::string name;
        option.get(NULL, SUBJECT_STR, &name);
 
@@ -266,9 +266,9 @@ void ctx::context_trigger::get_template(ctx::request_info* request)
                return;
        }
 
-       ctx::json tmpl;
+       ctx::Json tmpl;
        error = tmpl_mgr->get_template(name, &tmpl);
 
-       ctx::json dummy;
+       ctx::Json dummy;
        request->reply(error, dummy, tmpl);
 }
index 7ff7920..40e30c0 100644 (file)
@@ -133,10 +133,10 @@ bool ctx::db_manager_impl::create_table(unsigned int query_id, const char* table
        return true;
 }
 
-std::string ctx::db_manager_impl::compose_insert_query(const char* table_name, json& record)
+std::string ctx::db_manager_impl::compose_insert_query(const char* table_name, Json& record)
 {
        std::list<std::string> keys;
-       IF_FAIL_RETURN_TAG(record.get_keys(&keys), "", _E, "Invalid record");
+       IF_FAIL_RETURN_TAG(record.getKeys(&keys), "", _E, "Invalid record");
 
        std::ostringstream colstream;
        std::ostringstream valstream;
@@ -172,7 +172,7 @@ std::string ctx::db_manager_impl::compose_insert_query(const char* table_name, j
        return query;
 }
 
-bool ctx::db_manager_impl::insert(unsigned int query_id, const char* table_name, json& record, db_listener_iface* listener)
+bool ctx::db_manager_impl::insert(unsigned int query_id, const char* table_name, Json& record, db_listener_iface* listener)
 {
        IF_FAIL_RETURN_TAG(initialized, false, _E, "Not initialized");
 
@@ -222,7 +222,7 @@ void ctx::db_manager_impl::_execute(int query_type, unsigned int query_id, const
        IF_FAIL_VOID_TAG(db_handle, _E, "DB not opened");
        _SD("SQL(%d): %s", query_id, query);
 
-       std::vector<json> *query_result = new(std::nothrow) std::vector<json>;
+       std::vector<Json> *query_result = new(std::nothrow) std::vector<Json>;
        IF_FAIL_VOID_TAG(query_result, _E, "Memory allocation failed");
 
        char *err = NULL;
@@ -246,8 +246,8 @@ void ctx::db_manager_impl::_execute(int query_type, unsigned int query_id, const
 
 int ctx::db_manager_impl::execution_result_cb(void *user_data, int dim, char **value, char **column)
 {
-       std::vector<json> *records = static_cast<std::vector<json>*>(user_data);
-       json row;
+       std::vector<Json> *records = static_cast<std::vector<Json>*>(user_data);
+       Json row;
        bool column_null = false;
 
        for (int i=0; i<dim; ++i) {
@@ -267,7 +267,7 @@ int ctx::db_manager_impl::execution_result_cb(void *user_data, int dim, char **v
        return 0;
 }
 
-void ctx::db_manager_impl::send_result(int query_type, unsigned int query_id, db_listener_iface* listener, int error, std::vector<json>* result)
+void ctx::db_manager_impl::send_result(int query_type, unsigned int query_id, db_listener_iface* listener, int error, std::vector<Json>* result)
 {
        query_result_s *qr = new(std::nothrow) query_result_s();
        IF_FAIL_VOID_TAG(qr, _E, "Memory allocation failed");
@@ -337,7 +337,7 @@ bool ctx::db_manager_impl::create_table_sync(const char* table_name, const char*
        return true;
 }
 
-bool ctx::db_manager_impl::insert_sync(const char* table_name, json& record, int64_t* row_id)
+bool ctx::db_manager_impl::insert_sync(const char* table_name, Json& record, int64_t* row_id)
 {
        IF_FAIL_RETURN_TAG(db_handle, false, _E, "DB not opened");
        IF_FAIL_RETURN_TAG(table_name && row_id, false, _E, "Invalid parameter");
@@ -346,7 +346,7 @@ bool ctx::db_manager_impl::insert_sync(const char* table_name, json& record, int
        IF_FAIL_RETURN(!query.empty(), false);
        _SD("SQL: %s", query.c_str());
 
-       std::vector<json> query_result;
+       std::vector<Json> query_result;
        char *err = NULL;
        int ret;
        {
@@ -369,7 +369,7 @@ bool ctx::db_manager_impl::insert_sync(const char* table_name, json& record, int
        return true;
 }
 
-bool ctx::db_manager_impl::execute_sync(const char* query, std::vector<json>* records)
+bool ctx::db_manager_impl::execute_sync(const char* query, std::vector<Json>* records)
 {
        IF_FAIL_RETURN_TAG(db_handle, false, _E, "DB not opened");
        IF_FAIL_RETURN_TAG(query && records, false, _E, "Invalid parameter");
index 4ca11c1..5d8020e 100644 (file)
@@ -18,7 +18,7 @@
 #define __CONTEXT_DB_MANAGER_IMPL_H__
 
 #include <vector>
-#include <json.h>
+#include <Json.h>
 #include <sqlite3.h>
 
 #include <EventDrivenThread.h>
@@ -46,7 +46,7 @@ namespace ctx {
                        unsigned int id;
                        int error;
                        db_listener_iface* listener;
-                       std::vector<json>* result;
+                       std::vector<Json>* result;
                };
 
                sqlite3 *db_handle;
@@ -58,10 +58,10 @@ namespace ctx {
                void close();
 
                std::string compose_create_query(const char* table_name, const char* columns, const char* option);
-               std::string compose_insert_query(const char* table_name, json& record);
+               std::string compose_insert_query(const char* table_name, Json& record);
 
                void _execute(int query_type, unsigned int query_id, const char* query, db_listener_iface* listener);
-               void send_result(int query_type, unsigned int query_id, db_listener_iface* listener, int error, std::vector<json>* result);
+               void send_result(int query_type, unsigned int query_id, db_listener_iface* listener, int error, std::vector<Json>* result);
 
                static int execution_result_cb(void *user_data, int dim, char **value, char **column);
                static gboolean _send_result(gpointer data);
@@ -74,12 +74,12 @@ namespace ctx {
                void release();
 
                bool create_table(unsigned int query_id, const char* table_name, const char* columns, const char* option = NULL, db_listener_iface* listener = NULL);
-               bool insert(unsigned int query_id, const char* table_name, json& record, db_listener_iface* listener = NULL);
+               bool insert(unsigned int query_id, const char* table_name, Json& record, db_listener_iface* listener = NULL);
                bool execute(unsigned int query_id, const char* query, db_listener_iface* listener);
 
                bool create_table_sync(const char* table_name, const char* columns, const char* option = NULL);
-               bool insert_sync(const char* table_name, json& record, int64_t* row_id);
-               bool execute_sync(const char* query, std::vector<json>* records);
+               bool insert_sync(const char* table_name, Json& record, int64_t* row_id);
+               bool execute_sync(const char* query, std::vector<Json>* records);
 
        };      /* class db_manager */
 }
index 582c823..1b945f8 100644 (file)
@@ -16,7 +16,7 @@
 
 #include <glib.h>
 #include <types_internal.h>
-#include <json.h>
+#include <Json.h>
 #include "access_control/privilege.h"
 #include "server.h"
 #include "request.h"
@@ -68,7 +68,7 @@ void ctx::context_provider_handler::subscribe(ctx::request_info *request)
        context_provider_iface *provider = get_provider(request);
        IF_FAIL_VOID(provider);
 
-       ctx::json request_result;
+       ctx::Json request_result;
        int error = provider->subscribe(subject, request->get_description().str(), &request_result);
 
        if (!request->reply(error, request_result) || error != ERR_NONE) {
@@ -125,7 +125,7 @@ void ctx::context_provider_handler::read(ctx::request_info *request)
        context_provider_iface *provider = get_provider(request);
        IF_FAIL_VOID(provider);
 
-       ctx::json request_result;
+       ctx::Json request_result;
        int error = provider->read(subject, request->get_description().str(), &request_result);
 
        if (!request->reply(error, request_result) || error != ERR_NONE) {
@@ -143,14 +143,14 @@ void ctx::context_provider_handler::write(ctx::request_info *request)
        context_provider_iface *provider = get_provider(request);
        IF_FAIL_VOID(provider);
 
-       ctx::json request_result;
+       ctx::Json request_result;
        int error = provider->write(subject, request->get_description(), &request_result);
 
        request->reply(error, request_result);
        delete request;
 }
 
-bool ctx::context_provider_handler::publish(ctx::json &option, int error, ctx::json &data_updated)
+bool ctx::context_provider_handler::publish(ctx::Json &option, int error, ctx::Json &data_updated)
 {
        auto end = subscribe_requests.end();
        auto target = find_request(subscribe_requests.begin(), end, option);
@@ -165,13 +165,13 @@ bool ctx::context_provider_handler::publish(ctx::json &option, int error, ctx::j
        return true;
 }
 
-bool ctx::context_provider_handler::reply_to_read(ctx::json &option, int error, ctx::json &data_read)
+bool ctx::context_provider_handler::reply_to_read(ctx::Json &option, int error, ctx::Json &data_read)
 {
        auto end = read_requests.end();
        auto target = find_request(read_requests.begin(), end, option);
        auto prev = target;
 
-       ctx::json dummy;
+       ctx::Json dummy;
 
        while (target != end) {
                (*target)->reply(error, dummy, data_read);
@@ -186,7 +186,7 @@ bool ctx::context_provider_handler::reply_to_read(ctx::json &option, int error,
 }
 
 ctx::context_provider_handler::request_list_t::iterator
-ctx::context_provider_handler::find_request(request_list_t &r_list, json &option)
+ctx::context_provider_handler::find_request(request_list_t &r_list, Json &option)
 {
        return find_request(r_list.begin(), r_list.end(), option);
 }
@@ -203,7 +203,7 @@ ctx::context_provider_handler::find_request(request_list_t &r_list, std::string
 }
 
 ctx::context_provider_handler::request_list_t::iterator
-ctx::context_provider_handler::find_request(request_list_t::iterator begin, request_list_t::iterator end, json &option)
+ctx::context_provider_handler::find_request(request_list_t::iterator begin, request_list_t::iterator end, Json &option)
 {
        for (auto it = begin; it != end; ++it) {
                if (option == (*it)->get_description()) {
index c7dbfd0..8772f36 100644 (file)
@@ -23,7 +23,7 @@
 
 namespace ctx {
 
-       class json;
+       class Json;
        class credentials;
        class request_info;
 
@@ -41,8 +41,8 @@ namespace ctx {
                void read(request_info *request);
                void write(request_info *request);
 
-               bool publish(ctx::json &option, int error, ctx::json &data_updated);
-               bool reply_to_read(ctx::json &option, int error, ctx::json &data_read);
+               bool publish(ctx::Json &option, int error, ctx::Json &data_updated);
+               bool reply_to_read(ctx::Json &option, int error, ctx::Json &data_read);
 
        private:
                const char *subject;
@@ -51,9 +51,9 @@ namespace ctx {
                request_list_t read_requests;
 
                context_provider_iface* get_provider(request_info *request);
-               request_list_t::iterator find_request(request_list_t &r_list, json &option);
+               request_list_t::iterator find_request(request_list_t &r_list, 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, json &option);
+               request_list_t::iterator find_request(request_list_t::iterator begin, request_list_t::iterator end, Json &option);
 
        };      /* class context_provider_handler */
 
index 61f158d..7661460 100644 (file)
@@ -60,7 +60,7 @@ const char* ctx::request_info::get_subject()
        return _subject.c_str();
 }
 
-ctx::json& ctx::request_info::get_description()
+ctx::Json& ctx::request_info::get_description()
 {
        return _description;
 }
index 00de3be..143af68 100644 (file)
@@ -18,7 +18,7 @@
 #define __CONTEXT_REQUEST_INFO_H__
 
 #include <string>
-#include <json.h>
+#include <Json.h>
 
 namespace ctx {
 
@@ -33,22 +33,22 @@ namespace ctx {
                int get_type();
                int get_id();
                const char* get_subject();
-               ctx::json& get_description();
+               ctx::Json& get_description();
 
                virtual const credentials* get_credentials();
                virtual const char* get_package_id();
                /* TODO: remove this get_client() */
                virtual const char* get_client();
                virtual bool reply(int error) = 0;
-               virtual bool reply(int error, ctx::json &request_result) = 0;
-               virtual bool reply(int error, ctx::json &request_result, ctx::json &data_read) = 0;
-               virtual bool publish(int error, ctx::json &data) = 0;
+               virtual bool reply(int error, ctx::Json &request_result) = 0;
+               virtual bool reply(int error, ctx::Json &request_result, ctx::Json &data_read) = 0;
+               virtual bool publish(int error, ctx::Json &data) = 0;
 
        protected:
                int _type;
                int _req_id;
                std::string _subject;
-               ctx::json _description;
+               ctx::Json _description;
        };
 
 }      /* namespace ctx */