Replace ctx::json with ctx:Json 78/60078/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Tue, 23 Feb 2016 07:40:31 +0000 (16:40 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Tue, 23 Feb 2016 07:40:31 +0000 (16:40 +0900)
Change-Id: I63da446738ac26ce2673e97ce1131b8c59756f65
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
14 files changed:
include/context_history_types_internal.h
src/DBusClient.cpp
src/DBusClient.h
src/IDBusClientListener.h
src/context_history.cpp
src/context_trigger.cpp
src/request_handler.cpp
src/request_handler.h
src/rule_validator.cpp
src/rule_validator.h
testsuite/src/shared.cpp
testsuite/src/shared.h
testsuite/src/trigger/condition.cpp
testsuite/src/trigger/event.cpp

index 57a0a8b..ae548f7 100644 (file)
@@ -17,8 +17,6 @@
 #ifndef __TIZEN_CONTEXT_HISTORY_TYPES_INTERNAL_H__
 #define __TIZEN_CONTEXT_HISTORY_TYPES_INTERNAL_H__
 
-#include <json.h>
-
 #define CONTEXT_HISTORY_DATA           "QueryResult"
 
 #define SUBJ_RECENTLY_USED_APP         "stats/app/recently"
index e85944e..bef46f0 100644 (file)
@@ -223,7 +223,7 @@ int DBusClient::isSupported(std::string subject)
        return __request(REQ_SUPPORT, __generateReqId(), subject.c_str(), NULL, NULL, NULL);
 }
 
-int DBusClient::subscribe(std::string subject, json option, int *reqId, json *result)
+int DBusClient::subscribe(std::string subject, Json option, int *reqId, Json *result)
 {
        IF_FAIL_RETURN(__init(), ERR_OPERATION_FAILED);
        ASSERT_NOT_NULL(reqId);
@@ -253,7 +253,7 @@ int DBusClient::unsubscribe(std::string subject, int reqId)
        return __request(REQ_UNSUBSCRIBE, reqId, subject.c_str(), NULL, NULL, NULL);
 }
 
-int DBusClient::read(std::string subject, json option, int *reqId, json *result)
+int DBusClient::read(std::string subject, Json option, int *reqId, Json *result)
 {
        IF_FAIL_RETURN(__init(), ERR_OPERATION_FAILED);
        ASSERT_NOT_NULL(reqId);
@@ -274,7 +274,7 @@ int DBusClient::read(std::string subject, json option, int *reqId, json *result)
        return error;
 }
 
-int DBusClient::readSync(std::string subject, json option, int *reqId, json *outputData)
+int DBusClient::readSync(std::string subject, Json option, int *reqId, Json *outputData)
 {
        IF_FAIL_RETURN(__init(), ERR_OPERATION_FAILED);
        ASSERT_NOT_NULL(reqId);
@@ -295,7 +295,7 @@ int DBusClient::readSync(std::string subject, json option, int *reqId, json *out
        return error;
 }
 
-int DBusClient::write(std::string subject, json inputData)
+int DBusClient::write(std::string subject, Json inputData)
 {
        IF_FAIL_RETURN(__init(), ERR_OPERATION_FAILED);
 
@@ -310,7 +310,7 @@ int DBusClient::write(std::string subject, json inputData)
        return error;
 }
 
-int DBusClient::write(std::string subject, json inputData, json *result)
+int DBusClient::write(std::string subject, Json inputData, Json *result)
 {
        IF_FAIL_RETURN(__init(), ERR_OPERATION_FAILED);
 
index 4078dbc..e4d8d42 100644 (file)
@@ -35,12 +35,12 @@ namespace ctx {
 
                int isSupported(std::string subject);
 
-               int subscribe(std::string subject, json option, int *reqId, json *result);
+               int subscribe(std::string subject, Json option, int *reqId, Json *result);
                int unsubscribe(std::string subject, int reqId);
-               int read(std::string subject, json option, int *reqId, json *result);
-               int readSync(std::string subject, json option, int *reqId, json *outputData);
-               int write(std::string subject, json inputData);
-               int write(std::string subject, json inputData, json *result);
+               int read(std::string subject, Json option, int *reqId, Json *result);
+               int readSync(std::string subject, Json option, int *reqId, Json *outputData);
+               int write(std::string subject, Json inputData);
+               int write(std::string subject, Json inputData, Json *result);
 
        private:
                static void __onMethodCalled(GDBusConnection *conn, const gchar *sender,
index 69bd0d2..379b389 100644 (file)
 #define _CONTEXT_I_DBUS_CLIENT_LISTENER_H_
 
 #include <string>
-#include <json.h>
+#include <Json.h>
 
 namespace ctx {
 
        class IDBusClientListener {
        public:
                virtual ~IDBusClientListener() {}
-               virtual void onPublish(std::string subject, int reqId, int error, json event) = 0;
+               virtual void onPublish(std::string subject, int reqId, int error, Json event) = 0;
        };
 
 }      /* namespace ctx */
index d418690..e39e36b 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 #include <map>
-#include <json.h>
+#include <Json.h>
 #include <context_history.h>
 #include <context_history_types_internal.h>
 #include "request_handler.h"
@@ -40,11 +40,11 @@ typedef struct _context_history_handle_s {
 } _cx_history_handle;
 
 typedef struct _context_history_filter_handle_s {
-       ctx::json jfilter;
+       ctx::Json jfilter;
 } _cx_history_filter_handle;
 
 typedef struct _context_history_list_handle_s {
-       ctx::json jlist;
+       ctx::Json jlist;
        int current;
        _context_history_list_handle_s()
        {
@@ -53,7 +53,7 @@ typedef struct _context_history_list_handle_s {
 } _cx_history_list_handle;
 
 typedef struct _context_history_record_handle_s {
-       ctx::json jrecord;
+       ctx::Json jrecord;
 } _cx_history_record_handle;
 
 static std::string convert_filter_to_string(context_history_filter_e filter_type);
@@ -153,13 +153,13 @@ EXTAPI int context_history_get_list(context_history_h handle, context_history_da
                IF_FAIL_RETURN_TAG(check_invalid_filter(data_type, filter), CONTEXT_HISTORY_ERROR_INVALID_PARAMETER, _E, "Invalid filter key");
 
        int req_id;
-       ctx::json tmp_list;
+       ctx::Json tmp_list;
        int err = ctx::request_handler::read_sync(data_type_str.c_str(), (filter)? &filter->jfilter : NULL, &req_id, &tmp_list);
        IF_FAIL_RETURN_TAG(err==ERR_NONE, err, _E, "Getting list failed");
 
        _J("Read response", tmp_list);
 
-       IF_FAIL_RETURN_TAG(tmp_list.array_get_size(NULL, CONTEXT_HISTORY_DATA) > 0, CONTEXT_HISTORY_ERROR_NO_DATA, _D, "No data");
+       IF_FAIL_RETURN_TAG(tmp_list.getSize(NULL, CONTEXT_HISTORY_DATA) > 0, CONTEXT_HISTORY_ERROR_NO_DATA, _D, "No data");
 
        *list = new(std::nothrow) _cx_history_list_handle();
        ASSERT_ALLOC(*list);
@@ -176,7 +176,7 @@ EXTAPI int context_history_list_get_count(context_history_list_h list, int* coun
        ASSERT_NOT_NULL(count);
        *count = 0;
 
-       int result = list->jlist.array_get_size(NULL, CONTEXT_HISTORY_DATA);
+       int result = list->jlist.getSize(NULL, CONTEXT_HISTORY_DATA);
        IF_FAIL_RETURN(result > 0, CONTEXT_HISTORY_ERROR_OPERATION_FAILED);
 
        *count = result;
@@ -190,8 +190,8 @@ EXTAPI int context_history_list_get_current(context_history_list_h list, context
        ASSERT_NOT_NULL(record);
        *record = NULL;
 
-       ctx::json tmp_record;
-       int error = list->jlist.get_array_elem(NULL, CONTEXT_HISTORY_DATA, list->current, &tmp_record);
+       ctx::Json tmp_record;
+       int error = list->jlist.getAt(NULL, CONTEXT_HISTORY_DATA, list->current, &tmp_record);
        IF_FAIL_RETURN_TAG(error, CONTEXT_HISTORY_ERROR_OPERATION_FAILED, _E, "Record load failed");
 
        *record = new(std::nothrow) _cx_history_record_handle();
@@ -215,7 +215,7 @@ EXTAPI int context_history_list_move_next(context_history_list_h list)
 {
        ASSERT_NOT_NULL(list);
 
-       IF_FAIL_RETURN_TAG(list->current+1 < list->jlist.array_get_size(NULL, CONTEXT_HISTORY_DATA), CONTEXT_HISTORY_ERROR_NO_DATA, _D, "End of list");
+       IF_FAIL_RETURN_TAG(list->current+1 < list->jlist.getSize(NULL, CONTEXT_HISTORY_DATA), CONTEXT_HISTORY_ERROR_NO_DATA, _D, "End of list");
 
        list->current++;
 
@@ -239,7 +239,7 @@ EXTAPI int context_history_record_get_int(context_history_record_h record, const
        IF_FAIL_RETURN_TAG(check_record_key_data_type(TYPE_INT, key), CONTEXT_HISTORY_ERROR_INVALID_PARAMETER, _E, "Data type mismatched");
 
        std::list<std::string> key_list;
-       record->jrecord.get_keys(&key_list);
+       record->jrecord.getKeys(&key_list);
        IF_FAIL_RETURN_TAG(key_list.size() > 0, CONTEXT_HISTORY_ERROR_NO_DATA, _E, "No data");
 
        // Check invalid record key
@@ -256,7 +256,7 @@ EXTAPI int context_history_record_get_string(context_history_record_h record, co
        IF_FAIL_RETURN_TAG(check_record_key_data_type(TYPE_STRING, key), CONTEXT_HISTORY_ERROR_INVALID_PARAMETER, _E, "Data type mismatched");
 
        std::list<std::string> key_list;
-       record->jrecord.get_keys(&key_list);
+       record->jrecord.getKeys(&key_list);
        IF_FAIL_RETURN_TAG(key_list.size() > 0, CONTEXT_HISTORY_ERROR_NO_DATA, _E, "No data");
 
        // Check Invalid record key
@@ -484,7 +484,7 @@ bool check_invalid_filter(context_history_data_e data_type, context_history_filt
 
        bool found = true;
        std::list<std::string> keys;
-       filter->jfilter.get_keys(&keys);
+       filter->jfilter.getKeys(&keys);
 
        for (std::list<std::string>::iterator it = keys.begin(); it != keys.end(); ++it) {
                std::string key = (*it);
index 606e3fa..6e4b70e 100644 (file)
@@ -17,7 +17,7 @@
 //#include <sstream>
 //#include <iomanip>
 #include <types_internal.h>
-#include <json.h>
+#include <Json.h>
 #include <app_control_internal.h>
 #include <bundle.h>
 #include <bundle_internal.h>
@@ -44,8 +44,8 @@ static std::string convert_logical_type_to_string(context_trigger_logical_type_e
 //static std::string double_to_string(int value);
 
 typedef struct _context_trigger_rule_s {
-       ctx::json jrule;        // rule_id, description, details(event, condition[])
-       ctx::json jref;
+       ctx::Json jrule;        // rule_id, description, details(event, condition[])
+       ctx::Json jref;
 
        _context_trigger_rule_s()
        {
@@ -55,9 +55,9 @@ typedef struct _context_trigger_rule_s {
 } _context_trigger_rule_h;
 
 typedef struct _context_trigger_rule_entry_s {
-       ctx::json jentry;       // key, value, operator
+       ctx::Json jentry;       // key, value, operator
        int type;
-       ctx::json jref;
+       ctx::Json jref;
 
        _context_trigger_rule_entry_s(int t): type(t)
        {
@@ -87,7 +87,7 @@ EXTAPI int context_trigger_add_rule(context_trigger_rule_h rule, int* rule_id)
        if (!ret)
                return CONTEXT_TRIGGER_ERROR_INVALID_RULE;
 
-       ctx::json jrule_id;
+       ctx::Json jrule_id;
        int error = ctx::request_handler::write_with_reply(CONTEXT_TRIGGER_SUBJECT_ADD, &(rule->jrule), &jrule_id);
 
        if (error == ERR_NONE) {
@@ -105,7 +105,7 @@ EXTAPI int context_trigger_remove_rule(int rule_id)
        if (rule_id <= 0)
                return CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER;
 
-       ctx::json jrule_id;
+       ctx::Json jrule_id;
        jrule_id.set(NULL, CT_RULE_ID, rule_id);
        int error = ctx::request_handler::write_with_reply(CONTEXT_TRIGGER_SUBJECT_REMOVE, &jrule_id, NULL);
 
@@ -125,7 +125,7 @@ EXTAPI int context_trigger_enable_rule(int rule_id)
        if (rule_id <= 0)
                return CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER;
 
-       ctx::json jrule_id;
+       ctx::Json jrule_id;
        jrule_id.set(NULL, CT_RULE_ID, rule_id);
 
        int req_id;     // Useless in context_trigger
@@ -145,7 +145,7 @@ EXTAPI int context_trigger_disable_rule(int rule_id)
        if (rule_id <= 0)
                return CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER;
 
-       ctx::json jrule_id;
+       ctx::Json jrule_id;
        jrule_id.set(NULL, CT_RULE_ID, rule_id);
        int error = ctx::request_handler::write_with_reply(CONTEXT_TRIGGER_SUBJECT_DISABLE, &jrule_id, NULL);
 
@@ -162,7 +162,7 @@ EXTAPI int context_trigger_get_own_rule_ids(int** enabled_rule_ids, int* enabled
        ASSERT_NOT_NULL(enabled_rule_ids && enabled_rule_count && disabled_rule_ids && disabled_rule_count);
 
        int req_id;
-       ctx::json data_read;
+       ctx::Json data_read;
        int error = ctx::request_handler::read_sync(CONTEXT_TRIGGER_SUBJECT_GET_RULE_IDS, NULL, &req_id, &data_read);
 
        if (error != ERR_NONE) {
@@ -171,14 +171,14 @@ EXTAPI int context_trigger_get_own_rule_ids(int** enabled_rule_ids, int* enabled
 
        // Enabled rules
        int* e_arr = NULL;
-       *enabled_rule_count = data_read.array_get_size(NULL, CT_RULE_ARRAY_ENABLED);
+       *enabled_rule_count = data_read.getSize(NULL, CT_RULE_ARRAY_ENABLED);
 
        if (*enabled_rule_count > 0) {
                e_arr = static_cast<int*>(g_malloc((*enabled_rule_count) * sizeof(int)));
                IF_FAIL_RETURN_TAG(e_arr, CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY, _E, "Memory allocation failed");
 
                int id;
-               for (int i = 0; data_read.get_array_elem(NULL, CT_RULE_ARRAY_ENABLED, i, &id); i++) {
+               for (int i = 0; data_read.getAt(NULL, CT_RULE_ARRAY_ENABLED, i, &id); i++) {
                        *(e_arr + i) = id;
                }
        }
@@ -186,14 +186,14 @@ EXTAPI int context_trigger_get_own_rule_ids(int** enabled_rule_ids, int* enabled
 
        // Disabled rules
        int* d_arr = NULL;
-       *disabled_rule_count = data_read.array_get_size(NULL, CT_RULE_ARRAY_DISABLED);
+       *disabled_rule_count = data_read.getSize(NULL, CT_RULE_ARRAY_DISABLED);
 
        if (*disabled_rule_count > 0) {
                d_arr = static_cast<int*>(g_malloc((*disabled_rule_count) * sizeof(int)));
                IF_FAIL_RETURN_TAG(d_arr, CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY, _E, "Memory allocation failed");
 
                int id;
-               for (int i = 0; data_read.get_array_elem(NULL, CT_RULE_ARRAY_DISABLED, i, &id); i++) {
+               for (int i = 0; data_read.getAt(NULL, CT_RULE_ARRAY_DISABLED, i, &id); i++) {
                        *(d_arr + i) = id;
                }
        }
@@ -209,11 +209,11 @@ EXTAPI int context_trigger_get_rule_by_id(int rule_id, context_trigger_rule_h* r
        if (rule_id <= 0)
                return CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER;
 
-       ctx::json option;
+       ctx::Json option;
        option.set(NULL, CT_RULE_ID, rule_id);
 
        int req_id;
-       ctx::json data_read;
+       ctx::Json data_read;
        int error = ctx::request_handler::read_sync(CONTEXT_TRIGGER_SUBJECT_GET, &option, &req_id, &data_read);
 
        if (error == ERR_NO_DATA) {
@@ -267,7 +267,7 @@ EXTAPI int context_trigger_rule_add_entry(context_trigger_rule_h rule, context_t
 
        if (entry->type == TYPE_EVENT) {
                // Err: More than one event
-               ctx::json elem;
+               ctx::Json elem;
                if ((rule->jrule).get(CT_RULE_DETAILS, CT_RULE_EVENT, &elem)) {
                        return CONTEXT_TRIGGER_ERROR_INVALID_RULE;
                }
@@ -282,18 +282,18 @@ EXTAPI int context_trigger_rule_add_entry(context_trigger_rule_h rule, context_t
                ret = ctx::rule_validator::check_referential_data(ename, rule->jref);
                IF_FAIL_RETURN(ret, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
 
-               ctx::json temp = (entry->jentry).str();
+               ctx::Json temp = (entry->jentry).str();
                ret = (rule->jrule).set(CT_RULE_DETAILS, CT_RULE_EVENT, temp);
        } else if (entry->type == TYPE_CONDITION) {
                // Err: Condition without comparison data
-               if ((entry->jentry).array_get_size(NULL, CT_RULE_DATA_ARR) < 1) {
+               if ((entry->jentry).getSize(NULL, CT_RULE_DATA_ARR) < 1) {
                        return CONTEXT_TRIGGER_ERROR_INVALID_RULE;
                }
 
-               ctx::json elem;
-               for (int i = 0; (entry->jentry).get_array_elem(NULL, CT_RULE_DATA_ARR, i, &elem); i++) {
-                       int val_arr_size = elem.array_get_size(NULL, CT_RULE_DATA_VALUE_ARR);
-                       int op_arr_size = elem.array_get_size(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR);
+               ctx::Json elem;
+               for (int i = 0; (entry->jentry).getAt(NULL, CT_RULE_DATA_ARR, i, &elem); i++) {
+                       int val_arr_size = elem.getSize(NULL, CT_RULE_DATA_VALUE_ARR);
+                       int op_arr_size = elem.getSize(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR);
 
                        // Err: Condition without comparison data
                        if (val_arr_size != op_arr_size || val_arr_size < 1 || op_arr_size < 1) {
@@ -313,19 +313,19 @@ EXTAPI int context_trigger_rule_add_entry(context_trigger_rule_h rule, context_t
                                IF_FAIL_RETURN(ret, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
                        } else {
                                // If not, copy referential information to rule entry
-                               ctx::json info;
-                               for (int j = 0; (entry->jref).get_array_elem(NULL, TYPE_OPTION_STR, j, &info); j++) {
-                                       (rule->jref).array_append(NULL, TYPE_OPTION_STR, info);
+                               ctx::Json info;
+                               for (int j = 0; (entry->jref).getAt(NULL, TYPE_OPTION_STR, j, &info); j++) {
+                                       (rule->jref).append(NULL, TYPE_OPTION_STR, info);
                                }
 
-                               for (int j = 0; (entry->jref).get_array_elem(NULL, TYPE_ATTR_STR, j, &info); j++) {
-                                       (rule->jref).array_append(NULL, TYPE_ATTR_STR, info);
+                               for (int j = 0; (entry->jref).getAt(NULL, TYPE_ATTR_STR, j, &info); j++) {
+                                       (rule->jref).append(NULL, TYPE_ATTR_STR, info);
                                }
                        }
                }
 
-               ctx::json temp = (entry->jentry).str();
-               ret = (rule->jrule).array_append(CT_RULE_DETAILS, CT_RULE_CONDITION, temp);
+               ctx::Json temp = (entry->jentry).str();
+               ret = (rule->jrule).append(CT_RULE_DETAILS, CT_RULE_CONDITION, temp);
        } else {
                // Entry is not created
                return CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER;
@@ -758,8 +758,8 @@ EXTAPI int context_trigger_rule_entry_add_key(context_trigger_rule_entry_h entry
        bool ret = ctx::rule_validator::check_valid_key(TYPE_ATTR_STR, name, key);
        IF_FAIL_RETURN(ret, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
 
-       ctx::json elem;
-       for (int i = 0; (entry->jentry).get_array_elem(NULL, CT_RULE_DATA_ARR, i, &elem); i++) {
+       ctx::Json elem;
+       for (int i = 0; (entry->jentry).getAt(NULL, CT_RULE_DATA_ARR, i, &elem); i++) {
                std::string elem_item;
                elem.get(NULL, CT_RULE_DATA_KEY, &elem_item);
                // Err: Comparison key is already added
@@ -768,35 +768,35 @@ EXTAPI int context_trigger_rule_entry_add_key(context_trigger_rule_entry_h entry
                }
        }
 
-       ctx::json data;
+       ctx::Json data;
        data.set(NULL, CT_RULE_DATA_KEY, key);
        data.set(NULL, CT_RULE_DATA_KEY_OPERATOR, logical_str);
-       (entry->jentry).array_append(NULL, CT_RULE_DATA_ARR, data);
+       (entry->jentry).append(NULL, CT_RULE_DATA_ARR, data);
 
        return CONTEXT_TRIGGER_ERROR_NONE;
 }
 
 static int context_trigger_rule_entry_add_comparison_string_internal(context_trigger_rule_entry_h entry, const char* key, std::string op, std::string value)
 {
-       ctx::json elem;
-       for (int i = 0; (entry->jentry).get_array_elem(NULL, CT_RULE_DATA_ARR, i, &elem); i++) {
+       ctx::Json elem;
+       for (int i = 0; (entry->jentry).getAt(NULL, CT_RULE_DATA_ARR, i, &elem); i++) {
                std::string elem_item;
                elem.get(NULL, CT_RULE_DATA_KEY, &elem_item);
 
                if (elem_item.compare(key) == 0) {
                        std::string elem_val;
                        std::string elem_op;
-                       for (int j = 0; elem.get_array_elem(NULL, CT_RULE_DATA_VALUE_ARR, j, &elem_val); j++) {
-                               elem.get_array_elem(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, j, &elem_op);
+                       for (int j = 0; elem.getAt(NULL, CT_RULE_DATA_VALUE_ARR, j, &elem_val); j++) {
+                               elem.getAt(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, j, &elem_op);
 
                                // Err: Duplicated <operator, value>
                                if (elem_val.compare(value) == 0 && elem_op.compare(op) == 0) {
                                        return CONTEXT_TRIGGER_ERROR_INVALID_RULE;
                                }
                        }
-                       elem.array_append(NULL, CT_RULE_DATA_VALUE_ARR, value.c_str());
-                       elem.array_append(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, op);
-                       (entry->jentry).array_set_at(NULL, CT_RULE_DATA_ARR, i, elem);
+                       elem.append(NULL, CT_RULE_DATA_VALUE_ARR, value.c_str());
+                       elem.append(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, op);
+                       (entry->jentry).setAt(NULL, CT_RULE_DATA_ARR, i, elem);
 
                        return CONTEXT_TRIGGER_ERROR_NONE;
                }
@@ -808,25 +808,25 @@ static int context_trigger_rule_entry_add_comparison_string_internal(context_tri
 
 static int context_trigger_rule_entry_add_comparison_int_internal(context_trigger_rule_entry_h entry, const char* key, std::string op, int value)
 {
-       ctx::json elem;
-       for (int i = 0; (entry->jentry).get_array_elem(NULL, CT_RULE_DATA_ARR, i, &elem); i++) {
+       ctx::Json elem;
+       for (int i = 0; (entry->jentry).getAt(NULL, CT_RULE_DATA_ARR, i, &elem); i++) {
                std::string elem_item;
                elem.get(NULL, CT_RULE_DATA_KEY, &elem_item);
 
                if (elem_item.compare(key) == 0) {
                        int elem_val;
                        std::string elem_op;
-                       for (int j = 0; elem.get_array_elem(NULL, CT_RULE_DATA_VALUE_ARR, j, &elem_val); j++) {
-                               elem.get_array_elem(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, j, &elem_op);
+                       for (int j = 0; elem.getAt(NULL, CT_RULE_DATA_VALUE_ARR, j, &elem_val); j++) {
+                               elem.getAt(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, j, &elem_op);
 
                                // Err: Duplicated <operator, value>
                                if (elem_val == value && elem_op.compare(op) == 0) {
                                        return CONTEXT_TRIGGER_ERROR_INVALID_RULE;
                                }
                        }
-                       elem.array_append(NULL, CT_RULE_DATA_VALUE_ARR, value);
-                       elem.array_append(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, op);
-                       (entry->jentry).array_set_at(NULL, CT_RULE_DATA_ARR, i, elem);
+                       elem.append(NULL, CT_RULE_DATA_VALUE_ARR, value);
+                       elem.append(NULL, CT_RULE_DATA_VALUE_OPERATOR_ARR, op);
+                       (entry->jentry).setAt(NULL, CT_RULE_DATA_ARR, i, elem);
 
                        return CONTEXT_TRIGGER_ERROR_NONE;
                }
@@ -919,15 +919,15 @@ EXTAPI int context_trigger_add_custom_item(const char* name, const char* attr_te
        _D("BEGIN");
        ASSERT_NOT_NULL(name && attr_template);
 
-       // Err: Invalid json
-       ctx::json jattr_template = attr_template;
+       // Err: Invalid Json
+       ctx::Json jattr_template = attr_template;
        IF_FAIL_RETURN_TAG(jattr_template.valid(), CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER, _E, "Failed to parse template");
 
        // Err: Invalid template
        bool ret = ctx::rule_validator::is_valid_template(jattr_template);
        IF_FAIL_RETURN_TAG(ret, CONTEXT_TRIGGER_ERROR_INVALID_DATA, _E, "Invalid template");
 
-       ctx::json data;
+       ctx::Json data;
        data.set(NULL, CT_CUSTOM_NAME, name);
        data.set(NULL, CT_CUSTOM_ATTRIBUTES, jattr_template);
 
@@ -942,10 +942,10 @@ EXTAPI int context_trigger_remove_custom_item(const char* name)
        _D("BEGIN");
        ASSERT_NOT_NULL(name);
 
-       ctx::json data;
+       ctx::Json data;
        data.set(NULL, CT_CUSTOM_NAME, name);
 
-       ctx::json subj;
+       ctx::Json subj;
        int error = ctx::request_handler::write_with_reply(CONTEXT_TRIGGER_SUBJECT_CUSTOM_REMOVE, &data, &subj);
        IF_FAIL_RETURN_TAG(error == ERR_NONE, error, _E, "Failed to remove custom item: %#x", error);
 
@@ -961,11 +961,11 @@ EXTAPI int context_trigger_publish_custom_item(const char* name, const char* fac
        _D("BEGIN");
        ASSERT_NOT_NULL(name && fact);
 
-       // Err: Invalid json
-       ctx::json jfact = fact;
-       IF_FAIL_RETURN_TAG(jfact.valid(), CONTEXT_TRIGGER_ERROR_INVALID_RULE, _E, "Cannot parse fact json" );
+       // Err: Invalid Json
+       ctx::Json jfact = fact;
+       IF_FAIL_RETURN_TAG(jfact.valid(), CONTEXT_TRIGGER_ERROR_INVALID_RULE, _E, "Cannot parse fact Json" );
 
-       ctx::json data;
+       ctx::Json data;
        data.set(NULL, CT_CUSTOM_NAME, name);
        data.set(NULL, CT_CUSTOM_FACT, jfact);
 
index 920ee23..6dcf2cd 100644 (file)
@@ -31,7 +31,7 @@ public:
        DBusClientListenerImpl() {}
        ~DBusClientListenerImpl() {}
        void setCb(std::string subject, request_handler::subject_response_cb cb);
-       void onPublish(std::string subject, int reqId, int error, json event);
+       void onPublish(std::string subject, int reqId, int error, Json event);
 private:
        std::map<std::string, request_handler::subject_response_cb> __callbackMap;
 };
@@ -41,7 +41,7 @@ void DBusClientListenerImpl::setCb(std::string subject, request_handler::subject
        __callbackMap[subject] = cb;
 }
 
-void DBusClientListenerImpl::onPublish(std::string subject, int reqId, int error, json event)
+void DBusClientListenerImpl::onPublish(std::string subject, int reqId, int error, Json event)
 {
        auto it = __callbackMap.find(subject);
        IF_FAIL_VOID_TAG(it != __callbackMap.end(), _W, "Unregistered subject");
@@ -51,7 +51,7 @@ void DBusClientListenerImpl::onPublish(std::string subject, int reqId, int error
 static DBusClientListenerImpl __dbusListener;
 static DBusClient __dbusClient;
 
-EXTAPI int ctx::request_handler::subscribe(const char* subject, ctx::json* option, int* req_id, ctx::json* request_result)
+EXTAPI int ctx::request_handler::subscribe(const char* subject, ctx::Json* option, int* req_id, ctx::Json* request_result)
 {
        return __dbusClient.subscribe(subject, option ? *option : NULL, req_id, request_result);
 }
@@ -61,22 +61,22 @@ EXTAPI int ctx::request_handler::unsubscribe(const char* subject, int req_id)
        return __dbusClient.unsubscribe(subject, req_id);
 }
 
-EXTAPI int ctx::request_handler::read(const char* subject, ctx::json* option, int* req_id, ctx::json* request_result)
+EXTAPI int ctx::request_handler::read(const char* subject, ctx::Json* option, int* req_id, ctx::Json* request_result)
 {
        return __dbusClient.read(subject, option ? *option : NULL, req_id, request_result);
 }
 
-EXTAPI int ctx::request_handler::read_sync(const char* subject, ctx::json* option, int* req_id, ctx::json* data_read)
+EXTAPI int ctx::request_handler::read_sync(const char* subject, ctx::Json* option, int* req_id, ctx::Json* data_read)
 {
        return __dbusClient.readSync(subject, option ? *option : NULL, req_id, data_read);
 }
 
-EXTAPI int ctx::request_handler::write(const char* subject, ctx::json* data)
+EXTAPI int ctx::request_handler::write(const char* subject, ctx::Json* data)
 {
        return __dbusClient.write(subject, *data);
 }
 
-EXTAPI int ctx::request_handler::write_with_reply(const char* subject, ctx::json* data, ctx::json* request_result)
+EXTAPI int ctx::request_handler::write_with_reply(const char* subject, ctx::Json* data, ctx::Json* request_result)
 {
        return __dbusClient.write(subject, *data, request_result);
 }
index d90f6f1..cb4468a 100644 (file)
 #ifndef __CONTEXT_LIB_REQUEST_HANDLER_H__
 #define __CONTEXT_LIB_REQUEST_HANDLER_H__
 
-#include <json.h>
+#include <Json.h>
 
 namespace ctx { namespace request_handler {
 
        /*
         */
-       typedef void(* subject_response_cb)(const char* subject, int req_id, int error, ctx::json response);
+       typedef void(* subject_response_cb)(const char* subject, int req_id, int error, ctx::Json response);
 
        /*
         */
@@ -31,7 +31,7 @@ namespace ctx { namespace request_handler {
 
        /*
         */
-       int subscribe(const char* subject, ctx::json* option, int* req_id, ctx::json* request_result = NULL);
+       int subscribe(const char* subject, ctx::Json* option, int* req_id, ctx::Json* request_result = NULL);
 
        /*
         */
@@ -39,19 +39,19 @@ namespace ctx { namespace request_handler {
 
        /*
         */
-       int read(const char* subject, ctx::json* option, int* req_id, ctx::json* request_result = NULL);
+       int read(const char* subject, ctx::Json* option, int* req_id, ctx::Json* request_result = NULL);
 
        /*
         */
-       int read_sync(const char* subject, ctx::json* option, int* req_id, ctx::json* data_read);
+       int read_sync(const char* subject, ctx::Json* option, int* req_id, ctx::Json* data_read);
 
        /*
         */
-       int write(const char* subject, ctx::json* data);
+       int write(const char* subject, ctx::Json* data);
 
        /*
         */
-       int write_with_reply(const char* subject, ctx::json* data, ctx::json* request_result = NULL);
+       int write_with_reply(const char* subject, ctx::Json* data, ctx::Json* request_result = NULL);
 
        /*
         */
index f4bb504..fd6f948 100644 (file)
 #define KEY_VALUES "values"
 #define KEY_REF "ref"
 
-typedef std::map<std::string, ctx::json> template_map_t;
+typedef std::map<std::string, ctx::Json> template_map_t;
 template_map_t template_map;   // <name, template>
 
 static int string_to_int(std::string str);
-static bool check_value_int(ctx::json& tmpl, std::string key, int value);
-static bool check_value_string(ctx::json& tmpl, std::string key, std::string value);
-static ctx::json get_template(std::string name);
+static bool check_value_int(ctx::Json& tmpl, std::string key, int value);
+static bool check_value_string(ctx::Json& tmpl, std::string key, std::string value);
+static ctx::Json get_template(std::string name);
 
 int string_to_int(std::string str)
 {
@@ -53,7 +53,7 @@ int string_to_int(std::string str)
        return i;
 }
 
-ctx::json get_template(std::string name)
+ctx::Json get_template(std::string name)
 {
        ctx::rule_validator::request_template(name);
        return template_map[name];
@@ -67,11 +67,11 @@ int ctx::rule_validator::request_template(std::string name, bool mandatory)
        }
 
        // Request template
-       ctx::json request;
+       ctx::Json request;
        request.set(NULL, SUBJECT_STR, name);
 
        int req_id;
-       ctx::json tmpl;
+       ctx::Json tmpl;
        int error = ctx::request_handler::read_sync(CONTEXT_TRIGGER_SUBJECT_GET_TEMPLATE, &request, &req_id, &tmpl);
        if (error == ERR_NOT_SUPPORTED) {
                template_map.erase(name);
@@ -91,20 +91,20 @@ void ctx::rule_validator::remove_template(std::string name)
 }
 
 // called by context_trigger_rule_add_entry()
-bool ctx::rule_validator::check_option(ctx::json& item)
+bool ctx::rule_validator::check_option(ctx::Json& item)
 {
        std::string name;
        item.get(NULL, CT_RULE_EVENT_ITEM, &name);
 
-       ctx::json tmpl = get_template(name);
+       ctx::Json tmpl = get_template(name);
        IF_FAIL_RETURN(tmpl != EMPTY_JSON_OBJECT, false);
 
        // No option needed
-       ctx::json opt_tmpl;
+       ctx::Json opt_tmpl;
        tmpl.get(NULL, KEY_OPTION, &opt_tmpl);
 
        std::list<std::string> opt_keys;
-       IF_FAIL_RETURN(opt_tmpl.get_keys(&opt_keys), false);
+       IF_FAIL_RETURN(opt_tmpl.getKeys(&opt_keys), false);
        if (opt_keys.size() <= 0) {
                return true;
        }
@@ -129,15 +129,15 @@ bool ctx::rule_validator::check_option(ctx::json& item)
 // called by context_trigger_rule_entry_add_option_int()
 bool ctx::rule_validator::check_option_int(std::string name, std::string key, int value)
 {
-       ctx::json tmpl = get_template(name);
+       ctx::Json tmpl = get_template(name);
        IF_FAIL_RETURN(tmpl != EMPTY_JSON_OBJECT, false);
 
-       ctx::json opt_tmpl;
+       ctx::Json opt_tmpl;
        tmpl.get(NULL, KEY_OPTION, &opt_tmpl);
 
        // Err: Item with no option
        std::list<std::string> opt_keys;
-       IF_FAIL_RETURN(opt_tmpl.get_keys(&opt_keys), false);
+       IF_FAIL_RETURN(opt_tmpl.getKeys(&opt_keys), false);
        IF_FAIL_RETURN(opt_keys.size() > 0, false);
 
        // Err: Invalid option key or Invalid value type
@@ -156,10 +156,10 @@ bool ctx::rule_validator::check_option_int(std::string name, std::string key, in
 // called by context_trigger_rule_entry_add_option_string()
 bool ctx::rule_validator::check_option_string(std::string name, std::string key, std::string value)
 {
-       ctx::json tmpl = get_template(name);
+       ctx::Json tmpl = get_template(name);
        IF_FAIL_RETURN(tmpl != EMPTY_JSON_OBJECT, false);
 
-       ctx::json opt_tmpl;
+       ctx::Json opt_tmpl;
        tmpl.get(NULL, KEY_OPTION, &opt_tmpl);
 
        // Err: ';' for SQL injection
@@ -167,7 +167,7 @@ bool ctx::rule_validator::check_option_string(std::string name, std::string key,
 
        // Err: Item with no option
        std::list<std::string> opt_keys;
-       IF_FAIL_RETURN(opt_tmpl.get_keys(&opt_keys), false);
+       IF_FAIL_RETURN(opt_tmpl.getKeys(&opt_keys), false);
        IF_FAIL_RETURN(opt_keys.size() > 0, false);
 
        // Err: Invalid option key or Invalid value type
@@ -209,10 +209,10 @@ bool ctx::rule_validator::check_option_string(std::string name, std::string key,
 // called by context_trigger_rule_entry_add_comparison_int()
 bool ctx::rule_validator::check_comparison_int(std::string name, std::string key, std::string op, int value)
 {
-       ctx::json tmpl = get_template(name);
+       ctx::Json tmpl = get_template(name);
        IF_FAIL_RETURN(tmpl != EMPTY_JSON_OBJECT, false);
 
-       ctx::json attr_tmpl;
+       ctx::Json attr_tmpl;
        tmpl.get(NULL, KEY_ATTR, &attr_tmpl);
 
        // Err: Invalid attribute key or Invalid value type
@@ -240,10 +240,10 @@ bool ctx::rule_validator::check_comparison_int(std::string name, std::string key
 // called by context_trigger_rule_entry_add_comparison_string()
 bool ctx::rule_validator::check_comparison_string(std::string name, std::string key, std::string op, std::string value)
 {
-       ctx::json tmpl = get_template(name);
-       IF_FAIL_RETURN(tmpl != ctx::json(EMPTY_JSON_OBJECT), false);
+       ctx::Json tmpl = get_template(name);
+       IF_FAIL_RETURN(tmpl != ctx::Json(EMPTY_JSON_OBJECT), false);
 
-       ctx::json attr_tmpl;
+       ctx::Json attr_tmpl;
        tmpl.get(NULL, KEY_ATTR, &attr_tmpl);
 
        // Err: ';' for SQL injection
@@ -268,18 +268,18 @@ bool ctx::rule_validator::check_comparison_string(std::string name, std::string
 
 bool ctx::rule_validator::check_valid_key(std::string type, std::string name, std::string key)
 {
-       ctx::json tmpl = get_template(name);
+       ctx::Json tmpl = get_template(name);
        IF_FAIL_RETURN(tmpl != EMPTY_JSON_OBJECT, false);
 
        // Err: Invalid key
-       ctx::json tmp;
+       ctx::Json tmp;
        bool ret = tmpl.get(type.c_str(), key.c_str(), &tmp);
        IF_FAIL_RETURN(ret, false);
 
        return true;
 }
 
-bool check_value_int(ctx::json& tmpl, std::string key, int value)
+bool check_value_int(ctx::Json& tmpl, std::string key, int value)
 {
        int min, max;
 
@@ -294,15 +294,15 @@ bool check_value_int(ctx::json& tmpl, std::string key, int value)
        return true;
 }
 
-bool check_value_string(ctx::json& tmpl, std::string key, std::string value)
+bool check_value_string(ctx::Json& tmpl, std::string key, std::string value)
 {
        // case1: any value is accepted
-       if (tmpl.array_get_size(key.c_str(), KEY_VALUES) <= 0)
+       if (tmpl.getSize(key.c_str(), KEY_VALUES) <= 0)
                return true;
 
        // case2: check acceptable value
        std::string t_val;
-       for (int i = 0; tmpl.get_array_elem(key.c_str(), KEY_VALUES, i, &t_val); i++) {
+       for (int i = 0; tmpl.getAt(key.c_str(), KEY_VALUES, i, &t_val); i++) {
                if (t_val == value)
                        return true;
        }
@@ -312,28 +312,28 @@ bool check_value_string(ctx::json& tmpl, std::string key, std::string value)
 
 // called by context_trigger_rule_entry_add_comparison()
 // called by context_trigger_rule_entry_add_option()
-bool ctx::rule_validator::set_ref_info(std::string type, ctx::json* jref, std::string name, std::string key, std::string ref_data)
+bool ctx::rule_validator::set_ref_info(std::string type, ctx::Json* jref, std::string name, std::string key, std::string ref_data)
 {
-       ctx::json tmpl = get_template(name);
+       ctx::Json tmpl = get_template(name);
        IF_FAIL_RETURN(tmpl != EMPTY_JSON_OBJECT, false);
 
-       ctx::json detailed_tmpl;
+       ctx::Json detailed_tmpl;
        tmpl.get(NULL, type.c_str(), &detailed_tmpl);
 
        std::string dt;
        bool ret = detailed_tmpl.get(key.c_str(), KEY_TYPE, &dt);
        IF_FAIL_RETURN(ret, false);
 
-       ctx::json temp;
+       ctx::Json temp;
        temp.set(NULL, KEY_NAME, name);
        temp.set(NULL, KEY_KEY, key);
        temp.set(NULL, KEY_TYPE, dt);
        temp.set(NULL, KEY_REF, ref_data);
 
        if (type == TYPE_OPTION_STR) {
-               jref->array_append(NULL, KEY_OPTION, temp);
+               jref->append(NULL, KEY_OPTION, temp);
        } else if (type == TYPE_ATTR_STR) {
-               jref->array_append(NULL, KEY_ATTR, temp);
+               jref->append(NULL, KEY_ATTR, temp);
        } else {
                return false;
        }
@@ -344,10 +344,10 @@ bool ctx::rule_validator::set_ref_info(std::string type, ctx::json* jref, std::s
 // called by context_trigger_rule_entry_add_comparison()
 std::string ctx::rule_validator::get_data_type(std::string type, std::string name, std::string key)
 {
-       ctx::json tmpl = get_template(name);
+       ctx::Json tmpl = get_template(name);
        IF_FAIL_RETURN(tmpl != EMPTY_JSON_OBJECT, false);
 
-       ctx::json detailed_tmpl;
+       ctx::Json detailed_tmpl;
        tmpl.get(NULL, type.c_str(), &detailed_tmpl);
 
        std::string dt;
@@ -358,12 +358,12 @@ std::string ctx::rule_validator::get_data_type(std::string type, std::string nam
 }
 
 // called by context_trigger_rule_add_entry()
-bool ctx::rule_validator::check_referential_data(std::string name, ctx::json& ref_info)
+bool ctx::rule_validator::check_referential_data(std::string name, ctx::Json& ref_info)
 {
        std::map<std::string, std::string> type_map;
 
-       ctx::json ref_data;
-       for (int i = 0; ref_info.get_array_elem(NULL, KEY_OPTION, i, &ref_data); i++) {
+       ctx::Json ref_data;
+       for (int i = 0; ref_info.getAt(NULL, KEY_OPTION, i, &ref_data); i++) {
                std::string ref_key;
                ref_data.get(NULL, KEY_REF, &ref_key);
                std::string cond_type;
@@ -378,7 +378,7 @@ bool ctx::rule_validator::check_referential_data(std::string name, ctx::json& re
                        return false;
        }
 
-       for (int i = 0; ref_info.get_array_elem(NULL, KEY_ATTR, i, &ref_data); i++) {
+       for (int i = 0; ref_info.getAt(NULL, KEY_ATTR, i, &ref_data); i++) {
                std::string ref_key;
                ref_data.get(NULL, KEY_REF, &ref_key);
                std::string cond_type;
@@ -413,13 +413,13 @@ bool ctx::rule_validator::is_valid_operator(std::string type, std::string op)
 }
 
 // For custom item template
-bool ctx::rule_validator::is_valid_template(ctx::json& attr_template)
+bool ctx::rule_validator::is_valid_template(ctx::Json& attr_template)
 {
-       IF_FAIL_RETURN_TAG(attr_template != EMPTY_JSON_OBJECT, false, _E, "Custom template: empty json");
+       IF_FAIL_RETURN_TAG(attr_template != EMPTY_JSON_OBJECT, false, _E, "Custom template: empty Json");
 
        bool ret;
        std::list<std::string> keys;
-       attr_template.get_keys(&keys);
+       attr_template.getKeys(&keys);
 
        for (std::list<std::string>::iterator it = keys.begin(); it != keys.end(); it++) {
                std::string key = *it;
@@ -429,10 +429,10 @@ bool ctx::rule_validator::is_valid_template(ctx::json& attr_template)
                IF_FAIL_RETURN_TAG(ret, false, _E, "Custom template: type missing");
                IF_FAIL_RETURN_TAG(type == CT_CUSTOM_INT || type == CT_CUSTOM_STRING, false, _E, "Custom template: invalid data type");
 
-               ctx::json elem;
+               ctx::Json elem;
                attr_template.get(NULL, key.c_str(), &elem);
                std::list<std::string> elem_keys;
-               elem.get_keys(&elem_keys);
+               elem.getKeys(&elem_keys);
 
                for (std::list<std::string>::iterator it2 = elem_keys.begin(); it2 != elem_keys.end(); it2++) {
                        std::string elem_key = *it2;
@@ -445,11 +445,11 @@ bool ctx::rule_validator::is_valid_template(ctx::json& attr_template)
                        } else if (elem_key == CT_CUSTOM_VALUES) {
                                IF_FAIL_RETURN_TAG(type == CT_CUSTOM_STRING, false, _E, "Custom template: string type support values");
 
-                               int size = attr_template.array_get_size(key.c_str(), CT_CUSTOM_VALUES);
+                               int size = attr_template.getSize(key.c_str(), CT_CUSTOM_VALUES);
                                if (size > 0) {
                                        std::string val_str;
                                        for (int i = 0; i < size; i++) {
-                                               ret = attr_template.get_array_elem(key.c_str(), CT_CUSTOM_VALUES, i, &val_str);
+                                               ret = attr_template.getAt(key.c_str(), CT_CUSTOM_VALUES, i, &val_str);
                                                IF_FAIL_RETURN_TAG(ret, false, _E, "Custom template: failed to get string type value");
                                        }
                                }
index f6922a1..c7e727d 100644 (file)
 #ifndef __CONTEXT_RULE_VALIDATOR_H__
 #define __CONTEXT_RULE_VALIDATOR_H__
 
-#include <json.h>
+#include <Json.h>
 
 namespace ctx {
        namespace rule_validator {
 
                int request_template(std::string name, bool mandatory = false);
                void remove_template(std::string name);
-               bool check_option(ctx::json &item);
+               bool check_option(ctx::Json &item);
                bool check_option_int(std::string name, std::string key, int value);
                bool check_option_string(std::string name, std::string key, std::string value);
-               bool check_option_reference(std::string event, ctx::json &item);
+               bool check_option_reference(std::string event, ctx::Json &item);
                bool check_comparison_int(std::string name, std::string key, std::string op, int value);
                bool check_comparison_string(std::string name, std::string key, std::string op, std::string value);
                bool check_valid_key(std::string type, std::string name, std::string key);
 
-               bool set_ref_info(std::string type, ctx::json *jref, std::string name, std::string key, std::string ref_key);
+               bool set_ref_info(std::string type, ctx::Json *jref, std::string name, std::string key, std::string ref_key);
                std::string get_data_type(std::string type, std::string name, std::string key);
-               bool check_referential_data(std::string name, ctx::json &ref_info);
+               bool check_referential_data(std::string name, ctx::Json &ref_info);
                bool is_valid_operator(std::string type, std::string op);
 
-               bool is_valid_template(ctx::json& attr_template);
+               bool is_valid_template(ctx::Json& attr_template);
        }
 }      /* namespace ctx */
 
index a52e126..b301b1d 100644 (file)
@@ -28,7 +28,7 @@ namespace ctx {
                bool bool_val = false;
                bool skip_tc = false;
                bool newline_after_tcname = false;
-               ctx::json json_val = EMPTY_JSON_OBJECT;
+               ctx::Json json_val = EMPTY_JSON_OBJECT;
                std::string str_val = "";
        }
 }
index 4e0c4eb..7e61267 100644 (file)
@@ -22,7 +22,7 @@
 #include <string>
 #include <glib.h>
 #include <types_internal.h>
-#include <json.h>
+#include <Json.h>
 
 #define CALLBACK_COUNT 5
 
@@ -80,7 +80,7 @@ namespace ctx {
                extern bool bool_val;
                extern bool skip_tc;
                extern bool newline_after_tcname;
-               extern ctx::json json_val;
+               extern ctx::Json json_val;
                extern std::string str_val;
 
                void start_mainloop();
index 899d29f..5594980 100644 (file)
@@ -217,7 +217,7 @@ static std::string& __get_objective_app_id()
        return app_id;
 }
 
-static bool __trigger_cond_app_use_freq_base(ctx::json option)
+static bool __trigger_cond_app_use_freq_base(ctx::Json option)
 {
        if (!__support(CONTEXT_TRIGGER_CONDITION_APP_USE_FREQUENCY)) return false;
 
@@ -238,7 +238,7 @@ static bool __trigger_cond_app_use_freq_base(ctx::json option)
 bool _trigger_cond_app_use_freq1()
 {
        /* Case 1: App ID only */
-       ctx::json option;
+       ctx::Json option;
        option.set(NULL, CONTEXT_TRIGGER_APP_ID, __get_objective_app_id());
 
        return __trigger_cond_app_use_freq_base(option);
@@ -247,7 +247,7 @@ bool _trigger_cond_app_use_freq1()
 bool _trigger_cond_app_use_freq2()
 {
        /* Case 2: App ID, Day of Week */
-       ctx::json option;
+       ctx::Json option;
        option.set(NULL, CONTEXT_TRIGGER_APP_ID, __get_objective_app_id());
        option.set(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_WEEKDAY);
 
@@ -257,7 +257,7 @@ bool _trigger_cond_app_use_freq2()
 bool _trigger_cond_app_use_freq3()
 {
        /* Case 3: App ID, Time of Day */
-       ctx::json option;
+       ctx::Json option;
        option.set(NULL, CONTEXT_TRIGGER_APP_ID, __get_objective_app_id());
        option.set(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, "10-16");
 
@@ -267,7 +267,7 @@ bool _trigger_cond_app_use_freq3()
 bool _trigger_cond_app_use_freq4()
 {
        /* Case 3: App ID, Time of Day, Day of Week */
-       ctx::json option;
+       ctx::Json option;
        option.set(NULL, CONTEXT_TRIGGER_APP_ID, __get_objective_app_id());
        option.set(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_WEEKDAY);
        option.set(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, "10-16");
@@ -315,7 +315,7 @@ static std::string& __get_objective_address()
        return address;
 }
 
-static bool __trigger_cond_comm_freq_base(ctx::json option)
+static bool __trigger_cond_comm_freq_base(ctx::Json option)
 {
        if (!__support(CONTEXT_TRIGGER_CONDITION_COMMUNICATION_FREQUENCY)) return false;
 
@@ -336,7 +336,7 @@ static bool __trigger_cond_comm_freq_base(ctx::json option)
 bool _trigger_cond_comm_freq1()
 {
        /* Case 1: Address only */
-       ctx::json option;
+       ctx::Json option;
        option.set(NULL, CONTEXT_TRIGGER_ADDRESS, __get_objective_address());
 
        return __trigger_cond_comm_freq_base(option);
@@ -345,7 +345,7 @@ bool _trigger_cond_comm_freq1()
 bool _trigger_cond_comm_freq2()
 {
        /* Case 2: Address, Day of Week */
-       ctx::json option;
+       ctx::Json option;
        option.set(NULL, CONTEXT_TRIGGER_ADDRESS, __get_objective_address());
        option.set(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_WEEKDAY);
 
@@ -355,7 +355,7 @@ bool _trigger_cond_comm_freq2()
 bool _trigger_cond_comm_freq3()
 {
        /* Case 3: Address, Time of Day */
-       ctx::json option;
+       ctx::Json option;
        option.set(NULL, CONTEXT_TRIGGER_ADDRESS, __get_objective_address());
        option.set(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, "10-16");
 
@@ -365,7 +365,7 @@ bool _trigger_cond_comm_freq3()
 bool _trigger_cond_comm_freq4()
 {
        /* Case 4: Address, Day of Week, Time of Day */
-       ctx::json option;
+       ctx::Json option;
        option.set(NULL, CONTEXT_TRIGGER_ADDRESS, __get_objective_address());
        option.set(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_WEEKDAY);
        option.set(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, "10-16");
@@ -373,7 +373,7 @@ bool _trigger_cond_comm_freq4()
        return __trigger_cond_comm_freq_base(option);
 }
 
-static bool __trigger_cond_media_freq_base(context_trigger_condition_e item, const char *item_str, ctx::json option)
+static bool __trigger_cond_media_freq_base(context_trigger_condition_e item, const char *item_str, ctx::Json option)
 {
        if (!__support(item)) return false;
 
@@ -390,7 +390,7 @@ static bool __trigger_cond_media_freq_base(context_trigger_condition_e item, con
 
 bool _trigger_cond_music_freq1()
 {
-       ctx::json option;
+       ctx::Json option;
 
        return __trigger_cond_media_freq_base(
                        CONTEXT_TRIGGER_CONDITION_MUSIC_PLAYBACK_FREQUENCY,
@@ -399,7 +399,7 @@ bool _trigger_cond_music_freq1()
 
 bool _trigger_cond_music_freq2()
 {
-       ctx::json option;
+       ctx::Json option;
        option.set(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_WEEKDAY);
 
        return __trigger_cond_media_freq_base(
@@ -409,7 +409,7 @@ bool _trigger_cond_music_freq2()
 
 bool _trigger_cond_music_freq3()
 {
-       ctx::json option;
+       ctx::Json option;
        option.set(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, "10-16");
 
        return __trigger_cond_media_freq_base(
@@ -419,7 +419,7 @@ bool _trigger_cond_music_freq3()
 
 bool _trigger_cond_music_freq4()
 {
-       ctx::json option;
+       ctx::Json option;
        option.set(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_WEEKDAY);
        option.set(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, "10-16");
 
@@ -430,7 +430,7 @@ bool _trigger_cond_music_freq4()
 
 bool _trigger_cond_video_freq1()
 {
-       ctx::json option;
+       ctx::Json option;
 
        return __trigger_cond_media_freq_base(
                        CONTEXT_TRIGGER_CONDITION_VIDEO_PLAYBACK_FREQUENCY,
@@ -439,7 +439,7 @@ bool _trigger_cond_video_freq1()
 
 bool _trigger_cond_video_freq2()
 {
-       ctx::json option;
+       ctx::Json option;
        option.set(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_WEEKDAY);
 
        return __trigger_cond_media_freq_base(
@@ -449,7 +449,7 @@ bool _trigger_cond_video_freq2()
 
 bool _trigger_cond_video_freq3()
 {
-       ctx::json option;
+       ctx::Json option;
        option.set(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, "10-16");
 
        return __trigger_cond_media_freq_base(
@@ -459,7 +459,7 @@ bool _trigger_cond_video_freq3()
 
 bool _trigger_cond_video_freq4()
 {
-       ctx::json option;
+       ctx::Json option;
        option.set(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_WEEKDAY);
        option.set(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, "10-16");
 
index ade9d38..b5968f8 100644 (file)
@@ -23,7 +23,7 @@
 
 using namespace ctx::test;
 
-static void __domain_cb(const char *item, int rid, int error, ctx::json data)
+static void __domain_cb(const char *item, int rid, int error, ctx::Json data)
 {
        g_print("[%d] %s: Error=%#x, Data=%s\n", callback_count--, item, error, data.str().c_str());
 
@@ -303,7 +303,7 @@ bool _trigger_event_place()
 {
        if (!__support(CONTEXT_TRIGGER_EVENT_PLACE)) return false;
 
-       ctx::json option;
+       ctx::Json option;
        option.set(NULL, CONTEXT_TRIGGER_PLACE_ID, 2);  /* 2 => office */
 
        err = ctx::request_handler::subscribe(CT_EVENT_PLACE, &option, &req_id, NULL);