From: Mu-Woong Lee Date: Tue, 23 Feb 2016 07:41:24 +0000 (+0900) Subject: Replace ctx::json with ctx:Json X-Git-Tag: submit/tizen/20160314.020719~1^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=89fec8b7e1d19aae2525c09d673080b94a251395;p=platform%2Fcore%2Fcontext%2Fcontext-provider.git Replace ctx::json with ctx:Json Change-Id: I71196345c2b860cca85701bd8d949f2a43b73e2d Signed-off-by: Mu-Woong Lee --- diff --git a/include/custom_context_provider.h b/include/custom_context_provider.h index 10e4275..17c8cc4 100644 --- a/include/custom_context_provider.h +++ b/include/custom_context_provider.h @@ -21,9 +21,9 @@ namespace ctx { bool init_custom_context_provider(); namespace custom_context_provider { - int add_item(std::string subject, std::string name, ctx::json tmpl, const char* owner, bool is_init = false); + int add_item(std::string subject, std::string name, ctx::Json tmpl, const char* owner, bool is_init = false); int remove_item(std::string subject); - int publish_data(std::string subject, ctx::json fact); + int publish_data(std::string subject, ctx::Json fact); context_provider_iface* create(void* data); void destroy(void* data); diff --git a/src/custom/custom_base.cpp b/src/custom/custom_base.cpp index 59cbec9..c5ac58d 100644 --- a/src/custom/custom_base.cpp +++ b/src/custom/custom_base.cpp @@ -17,7 +17,7 @@ #include #include "custom_base.h" -ctx::custom_base::custom_base(std::string subject, std::string name, ctx::json tmpl, std::string owner) : +ctx::custom_base::custom_base(std::string subject, std::string name, ctx::Json tmpl, std::string owner) : _subject(subject), _name(name), _tmpl(tmpl), @@ -45,30 +45,30 @@ void ctx::custom_base::unsubmit_trigger_item() context_manager::unregister_trigger_item(_subject.c_str()); } -int ctx::custom_base::subscribe(const char *subject, ctx::json option, ctx::json *request_result) +int ctx::custom_base::subscribe(const char *subject, ctx::Json option, ctx::Json *request_result) { return ERR_NONE; } -int ctx::custom_base::unsubscribe(const char *subject, ctx::json option) +int ctx::custom_base::unsubscribe(const char *subject, ctx::Json option) { return ERR_NONE; } -int ctx::custom_base::read(const char *subject, ctx::json option, ctx::json *request_result) +int ctx::custom_base::read(const char *subject, ctx::Json option, ctx::Json *request_result) { - ctx::json data = latest.str(); + ctx::Json data = latest.str(); ctx::context_manager::reply_to_read(_subject.c_str(), NULL, ERR_NONE, data); return ERR_NONE; } -int ctx::custom_base::write(const char *subject, ctx::json data, ctx::json *request_result) +int ctx::custom_base::write(const char *subject, ctx::Json data, ctx::Json *request_result) { return ERR_NONE; } -void ctx::custom_base::handle_update(ctx::json data) +void ctx::custom_base::handle_update(ctx::Json data) { // Store latest state latest = data.str(); @@ -85,7 +85,7 @@ std::string ctx::custom_base::get_owner() return _owner; } -ctx::json ctx::custom_base::get_template() +ctx::Json ctx::custom_base::get_template() { return _tmpl; } diff --git a/src/custom/custom_base.h b/src/custom/custom_base.h index e2e8bce..0278e0f 100644 --- a/src/custom/custom_base.h +++ b/src/custom/custom_base.h @@ -17,7 +17,7 @@ #ifndef _CUSTOM_BASE_H_ #define _CUSTOM_BASE_H_ -#include +#include #include #include @@ -25,30 +25,30 @@ namespace ctx { class custom_base : public context_provider_iface { public: - custom_base(std::string subject, std::string name, ctx::json tmpl, std::string owner); + custom_base(std::string subject, std::string name, ctx::Json tmpl, std::string owner); ~custom_base(); - int subscribe(const char *subject, ctx::json option, ctx::json *request_result); - int unsubscribe(const char *subject, ctx::json option); - int read(const char *subject, ctx::json option, ctx::json *request_result); - int write(const char *subject, ctx::json data, ctx::json *request_result); + int subscribe(const char *subject, ctx::Json option, ctx::Json *request_result); + int unsubscribe(const char *subject, ctx::Json option); + int read(const char *subject, ctx::Json option, ctx::Json *request_result); + int write(const char *subject, ctx::Json data, ctx::Json *request_result); static bool is_supported(); void submit_trigger_item(); void unsubmit_trigger_item(); - void handle_update(ctx::json data); + void handle_update(ctx::Json data); const char* get_subject(); std::string get_owner(); - ctx::json get_template(); + ctx::Json get_template(); private: std::string _subject; std::string _name; - ctx::json _tmpl; + ctx::Json _tmpl; std::string _owner; - ctx::json latest; + ctx::Json latest; }; } diff --git a/src/custom/custom_context_provider.cpp b/src/custom/custom_context_provider.cpp index dd79fd5..29c9100 100644 --- a/src/custom/custom_context_provider.cpp +++ b/src/custom/custom_context_provider.cpp @@ -25,9 +25,9 @@ std::map custom_map; -static bool is_valid_fact(std::string subject, ctx::json& fact); -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 bool is_valid_fact(std::string subject, ctx::Json& fact); +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); void register_provider(const char *subject, const char *privilege) { @@ -66,7 +66,7 @@ EXTAPI bool ctx::init_custom_context_provider() + "(subject TEXT DEFAULT '' NOT NULL PRIMARY KEY, name TEXT DEFAULT '' NOT NULL, operation INTEGER DEFAULT 3 NOT NULL, " + "attributes TEXT DEFAULT '' NOT NULL, owner TEXT DEFAULT '' NOT NULL)"; - std::vector record; + std::vector record; bool ret = db_manager::execute_sync(q.c_str(), &record); IF_FAIL_RETURN_TAG(ret, false, _E, "Create template table failed"); @@ -77,9 +77,9 @@ EXTAPI bool ctx::init_custom_context_provider() IF_FAIL_RETURN(record.size() > 0, true); int error; - std::vector::iterator vec_end = record.end(); - for (std::vector::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) { - ctx::json elem = *vec_pos; + std::vector::iterator vec_end = record.end(); + for (std::vector::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) { + ctx::Json elem = *vec_pos; std::string subject; std::string name; std::string attributes; @@ -89,7 +89,7 @@ EXTAPI bool ctx::init_custom_context_provider() elem.get(NULL, "attributes", &attributes); elem.get(NULL, "owner", &owner); - error = ctx::custom_context_provider::add_item(subject, name, ctx::json(attributes), owner.c_str(), true); + error = ctx::custom_context_provider::add_item(subject, name, ctx::Json(attributes), owner.c_str(), true); if (error != ERR_NONE) { _E("Failed to add custom item(%s): %#x", subject.c_str(), error); } @@ -98,7 +98,7 @@ EXTAPI bool ctx::init_custom_context_provider() return true; } -EXTAPI int ctx::custom_context_provider::add_item(std::string subject, std::string name, ctx::json tmpl, const char* owner, bool is_init) +EXTAPI int ctx::custom_context_provider::add_item(std::string subject, std::string name, ctx::Json tmpl, const char* owner, bool is_init) { std::map::iterator it; it = custom_map.find(subject); @@ -122,7 +122,7 @@ EXTAPI int ctx::custom_context_provider::add_item(std::string subject, std::stri if (!is_init) { std::string q = "INSERT OR IGNORE INTO context_trigger_custom_template (subject, name, attributes, owner) VALUES ('" + subject + "', '" + name + "', '" + tmpl.str() + "', '" + owner + "'); "; - std::vector record; + std::vector record; bool ret = db_manager::execute_sync(q.c_str(), &record); IF_FAIL_RETURN_TAG(ret, false, _E, "Failed to query custom templates"); } @@ -140,14 +140,14 @@ EXTAPI int ctx::custom_context_provider::remove_item(std::string subject) // Remove item from custom template db std::string q = "DELETE FROM context_trigger_custom_template WHERE subject = '" + subject + "'"; - std::vector record; + std::vector record; bool ret = db_manager::execute_sync(q.c_str(), &record); IF_FAIL_RETURN_TAG(ret, false, _E, "Failed to query custom templates"); return ERR_NONE; } -EXTAPI int ctx::custom_context_provider::publish_data(std::string subject, ctx::json fact) +EXTAPI int ctx::custom_context_provider::publish_data(std::string subject, ctx::Json fact) { std::map::iterator it; it = custom_map.find(subject); @@ -160,14 +160,14 @@ EXTAPI int ctx::custom_context_provider::publish_data(std::string subject, ctx:: return ERR_NONE; } -bool is_valid_fact(std::string subject, ctx::json& fact) +bool is_valid_fact(std::string subject, ctx::Json& fact) { - ctx::json tmpl = custom_map[subject]->get_template(); + ctx::Json tmpl = custom_map[subject]->get_template(); IF_FAIL_RETURN_TAG(tmpl != EMPTY_JSON_OBJECT, false, _E, "Failed to get template"); bool ret; std::list keys; - fact.get_keys(&keys); + fact.getKeys(&keys); for (std::list::iterator it = keys.begin(); it != keys.end(); it++) { std::string key = *it; @@ -197,7 +197,7 @@ bool is_valid_fact(std::string subject, ctx::json& fact) 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; @@ -212,15 +212,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(), "values") <= 0) + if (tmpl.getSize(key.c_str(), "values") <= 0) return true; // case2: check acceptable value std::string t_val; - for (int i = 0; tmpl.get_array_elem(key.c_str(), "values", i, &t_val); i++) { + for (int i = 0; tmpl.getAt(key.c_str(), "values", i, &t_val); i++) { if (t_val == value) return true; } diff --git a/src/device/activity/activity_base.cpp b/src/device/activity/activity_base.cpp index 1b834fd..e0a9027 100644 --- a/src/device/activity/activity_base.cpp +++ b/src/device/activity/activity_base.cpp @@ -44,7 +44,7 @@ void ctx::user_activity_base::handle_event(activity_type_e activity, const activ { IF_FAIL_VOID_TAG(activity == activity_type, _E, "Invalid activity: %d", activity); - ctx::json data_read; + ctx::Json data_read; data_read.set(NULL, USER_ACT_EVENT, USER_ACT_DETECTED); activity_accuracy_e accuracy = ACTIVITY_ACCURACY_LOW; diff --git a/src/device/provider_base.cpp b/src/device/provider_base.cpp index acc61cd..fefe212 100644 --- a/src/device/provider_base.cpp +++ b/src/device/provider_base.cpp @@ -22,7 +22,7 @@ ctx::device_provider_base::device_provider_base() { } -int ctx::device_provider_base::subscribe(const char *subject, ctx::json option, ctx::json *request_result) +int ctx::device_provider_base::subscribe(const char *subject, ctx::Json option, ctx::Json *request_result) { IF_FAIL_RETURN(!being_subscribed, ERR_NONE); @@ -36,7 +36,7 @@ int ctx::device_provider_base::subscribe(const char *subject, ctx::json option, return ret; } -int ctx::device_provider_base::unsubscribe(const char *subject, ctx::json option) +int ctx::device_provider_base::unsubscribe(const char *subject, ctx::Json option) { int ret = ERR_NONE; @@ -47,7 +47,7 @@ int ctx::device_provider_base::unsubscribe(const char *subject, ctx::json option return ret; } -int ctx::device_provider_base::read(const char *subject, ctx::json option, ctx::json *request_result) +int ctx::device_provider_base::read(const char *subject, ctx::Json option, ctx::Json *request_result) { int ret = read(); @@ -57,7 +57,7 @@ int ctx::device_provider_base::read(const char *subject, ctx::json option, ctx:: return ret; } -int ctx::device_provider_base::write(const char *subject, ctx::json data, ctx::json *request_result) +int ctx::device_provider_base::write(const char *subject, ctx::Json data, ctx::Json *request_result) { int ret = write(); diff --git a/src/device/provider_base.h b/src/device/provider_base.h index c05f4c7..39983b1 100644 --- a/src/device/provider_base.h +++ b/src/device/provider_base.h @@ -18,7 +18,7 @@ #define __CONTEXT_DEVICE_PROVIDER_BASE_H__ #include -#include +#include #include #define CREATE_INSTANCE(prvd) \ @@ -66,10 +66,10 @@ namespace ctx { class device_provider_base : public context_provider_iface { public: - int subscribe(const char *subject, ctx::json option, ctx::json *request_result); - int unsubscribe(const char *subject, ctx::json option); - int read(const char *subject, ctx::json option, ctx::json *request_result); - int write(const char *subject, ctx::json data, ctx::json *request_result); + int subscribe(const char *subject, ctx::Json option, ctx::Json *request_result); + int unsubscribe(const char *subject, ctx::Json option); + int read(const char *subject, ctx::Json option, ctx::Json *request_result); + int write(const char *subject, ctx::Json data, ctx::Json *request_result); protected: bool being_subscribed; diff --git a/src/device/social/call.cpp b/src/device/social/call.cpp index 52e6aa3..745442c 100644 --- a/src/device/social/call.cpp +++ b/src/device/social/call.cpp @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include "social_types.h" #include "call.h" @@ -38,7 +38,7 @@ static telephony_noti_e call_noti_ids[] = TELEPHONY_NOTI_VIDEO_CALL_STATUS_ALERTING, TELEPHONY_NOTI_VIDEO_CALL_STATUS_INCOMING, }; -static ctx::json latest; +static ctx::Json latest; ctx::social_status_call::social_status_call() { @@ -76,7 +76,7 @@ void ctx::social_status_call::call_event_cb(telephony_h handle, telephony_noti_e void ctx::social_status_call::handle_call_event(telephony_h handle, telephony_noti_e noti_id, void* id) { - json data; + Json data; unsigned int count; telephony_call_h *call_list; @@ -311,7 +311,7 @@ int ctx::social_status_call::unsubscribe() return ERR_NONE; } -bool ctx::social_status_call::read_current_status(telephony_h& handle, ctx::json& data) +bool ctx::social_status_call::read_current_status(telephony_h& handle, ctx::Json& data) { unsigned int count = 0; telephony_call_h *call_list = NULL; @@ -362,7 +362,7 @@ int ctx::social_status_call::read() } bool ret = true; - json data; + Json data; data.set(NULL, SOCIAL_ST_STATE, SOCIAL_ST_IDLE); for (unsigned int i = 0; i < handle_list.count; i++) { diff --git a/src/device/social/call.h b/src/device/social/call.h index a67eaa1..cdd906c 100644 --- a/src/device/social/call.h +++ b/src/device/social/call.h @@ -43,7 +43,7 @@ namespace ctx { void release_telephony(); bool set_callback(); void unset_callback(); - bool read_current_status(telephony_h& handle, ctx::json& data); + bool read_current_status(telephony_h& handle, ctx::Json& data); bool get_call_state(telephony_call_h& handle, std::string& state); bool get_call_type(telephony_call_h& handle, std::string& type); diff --git a/src/device/social/email.cpp b/src/device/social/email.cpp index 90a4efb..831a963 100644 --- a/src/device/social/email.cpp +++ b/src/device/social/email.cpp @@ -60,13 +60,13 @@ void ctx::social_status_email::onSignal(const char* sender, const char* path, co if (sub_type == NOTI_DOWNLOAD_FINISH) { //TODO: Check if this signal actually means that there are new mails _D("sub type: %d, gi1: %d, gc: %s, gi2: %d, gi3: %d", sub_type, gi1, gc, gi2, gi3); - ctx::json data_updated; + ctx::Json data_updated; data_updated.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_RECEIVED); context_manager::publish(SOCIAL_ST_SUBJ_EMAIL, NULL, ERR_NONE, data_updated); } else if (sub_type == NOTI_SEND_FINISH) { _D("sub type: %d, gi1: %d, gc: %s, gi2: %d, gi3: %d", sub_type, gi1, gc, gi2, gi3); - ctx::json data_updated; + ctx::Json data_updated; data_updated.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_SENT); context_manager::publish(SOCIAL_ST_SUBJ_EMAIL, NULL, ERR_NONE, data_updated); } diff --git a/src/device/social/message.cpp b/src/device/social/message.cpp index 5d091fb..4d46fe9 100644 --- a/src/device/social/message.cpp +++ b/src/device/social/message.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include #include "social_types.h" #include "message.h" @@ -59,7 +59,7 @@ void ctx::social_status_message::handle_state_change(msg_struct_t msg) int err; int type; char address[MAX_ADDR_SIZE]; - ctx::json data; + ctx::Json data; err = msg_get_int_value(msg, MSG_MESSAGE_TYPE_INT, &type); IF_FAIL_VOID_TAG(err == MSG_SUCCESS, _W, "Getting message type failed"); diff --git a/src/device/system/alarm.cpp b/src/device/system/alarm.cpp index 0b75fb5..bd800ee 100644 --- a/src/device/system/alarm.cpp +++ b/src/device/system/alarm.cpp @@ -51,42 +51,42 @@ void ctx::device_status_alarm::submit_trigger_item() NULL); } -int ctx::device_status_alarm::subscribe(const char *subject, ctx::json option, ctx::json *request_result) +int ctx::device_status_alarm::subscribe(const char *subject, ctx::Json option, ctx::Json *request_result) { int ret = subscribe(option); destroy_if_unused(); return ret; } -int ctx::device_status_alarm::unsubscribe(const char *subject, ctx::json option) +int ctx::device_status_alarm::unsubscribe(const char *subject, ctx::Json option) { int ret = unsubscribe(option); destroy_if_unused(); return ret; } -int ctx::device_status_alarm::read(const char *subject, ctx::json option, ctx::json *request_result) +int ctx::device_status_alarm::read(const char *subject, ctx::Json option, ctx::Json *request_result) { destroy_if_unused(); return ERR_NOT_SUPPORTED; } -int ctx::device_status_alarm::write(const char *subject, ctx::json data, ctx::json *request_result) +int ctx::device_status_alarm::write(const char *subject, ctx::Json data, ctx::Json *request_result) { destroy_if_unused(); return ERR_NOT_SUPPORTED; } -int ctx::device_status_alarm::subscribe(ctx::json option) +int ctx::device_status_alarm::subscribe(ctx::Json option) { int dow = get_arranged_day_of_week(option); int time; - for (int i = 0; option.get_array_elem(NULL, DEVICE_ST_TIME_OF_DAY, i, &time); i++) { + for (int i = 0; option.getAt(NULL, DEVICE_ST_TIME_OF_DAY, i, &time); i++) { add(time, dow); } - ctx::json* elem = new(std::nothrow) ctx::json(option); + ctx::Json* elem = new(std::nothrow) ctx::Json(option); if (elem) { option_set.insert(elem); } else { @@ -98,12 +98,12 @@ int ctx::device_status_alarm::subscribe(ctx::json option) return ERR_NONE; } -int ctx::device_status_alarm::unsubscribe(ctx::json option) +int ctx::device_status_alarm::unsubscribe(ctx::Json option) { int dow = get_arranged_day_of_week(option); int time; - for (int i = 0; option.get_array_elem(NULL, DEVICE_ST_TIME_OF_DAY, i, &time); i++) { + for (int i = 0; option.getAt(NULL, DEVICE_ST_TIME_OF_DAY, i, &time); i++) { remove(time, dow); } @@ -116,12 +116,12 @@ int ctx::device_status_alarm::unsubscribe(ctx::json option) return ERR_NONE; } -int ctx::device_status_alarm::get_arranged_day_of_week(ctx::json& option) +int ctx::device_status_alarm::get_arranged_day_of_week(ctx::Json& option) { int dow = 0; std::string tmp_d; - for (int i = 0; option.get_array_elem(NULL, DEVICE_ST_DAY_OF_WEEK, i, &tmp_d); i++) { + for (int i = 0; option.getAt(NULL, DEVICE_ST_DAY_OF_WEEK, i, &tmp_d); i++) { dow |= ctx::timer_util::convert_day_of_week_string_to_int(tmp_d); } _D("Requested day of week (%#x)", dow); @@ -252,25 +252,25 @@ void ctx::device_status_alarm::on_timer_expired(int hour, int min, int day_of_we { _I("Time: %02d:%02d, Day of Week: %#x", hour, min, day_of_week); - ctx::json data_read; + ctx::Json data_read; int result_time = hour * 60 + min; std::string result_day = ctx::timer_util::convert_day_of_week_int_to_string(day_of_week); data_read.set(NULL, DEVICE_ST_TIME_OF_DAY, result_time); data_read.set(NULL, DEVICE_ST_DAY_OF_WEEK, result_day); for (option_t::iterator it = option_set.begin(); it != option_set.end(); ++it) { - ctx::json option = (**it); + ctx::Json option = (**it); if (is_matched(option, result_time, result_day)) { context_manager::publish(DEVICE_ST_SUBJ_ALARM, option, ERR_NONE, data_read); } } } -bool ctx::device_status_alarm::is_matched(ctx::json& option, int time, std::string day) +bool ctx::device_status_alarm::is_matched(ctx::Json& option, int time, std::string day) { bool ret = false; int opt_time; - for (int i = 0; option.get_array_elem(NULL, DEVICE_ST_TIME_OF_DAY, i, &opt_time); i++){ + for (int i = 0; option.getAt(NULL, DEVICE_ST_TIME_OF_DAY, i, &opt_time); i++){ if (time == opt_time) { ret = true; break; @@ -279,7 +279,7 @@ bool ctx::device_status_alarm::is_matched(ctx::json& option, int time, std::stri IF_FAIL_RETURN(ret, false); std::string opt_day; - for (int i = 0; option.get_array_elem(NULL, DEVICE_ST_DAY_OF_WEEK, i, &opt_day); i++){ + for (int i = 0; option.getAt(NULL, DEVICE_ST_DAY_OF_WEEK, i, &opt_day); i++){ if (day == opt_day) { return true; } @@ -288,7 +288,7 @@ bool ctx::device_status_alarm::is_matched(ctx::json& option, int time, std::stri return false; } -ctx::device_status_alarm::option_t::iterator ctx::device_status_alarm::find_option(ctx::json& option) +ctx::device_status_alarm::option_t::iterator ctx::device_status_alarm::find_option(ctx::Json& option) { for (ctx::device_status_alarm::option_t::iterator it = option_set.begin(); it != option_set.end(); ++it) { if (option == (**it)) diff --git a/src/device/system/alarm.h b/src/device/system/alarm.h index 7596f74..8f51836 100644 --- a/src/device/system/alarm.h +++ b/src/device/system/alarm.h @@ -30,13 +30,13 @@ namespace ctx { GENERATE_PROVIDER_COMMON_DECL(device_status_alarm); public: - int subscribe(const char *subject, ctx::json option, ctx::json *request_result); - int unsubscribe(const char *subject, ctx::json option); - int read(const char *subject, ctx::json option, ctx::json *request_result); - int write(const char *subject, ctx::json data, ctx::json *request_result); + int subscribe(const char *subject, ctx::Json option, ctx::Json *request_result); + int unsubscribe(const char *subject, ctx::Json option); + int read(const char *subject, ctx::Json option, ctx::Json *request_result); + int write(const char *subject, ctx::Json data, ctx::Json *request_result); - int subscribe(ctx::json option); - int unsubscribe(ctx::json option); + int subscribe(ctx::Json option); + int unsubscribe(ctx::Json option); static bool is_supported(); static void submit_trigger_item(); @@ -45,7 +45,7 @@ namespace ctx { ~device_status_alarm(); void handle_update(); static void update_cb(void* user_data); - int get_arranged_day_of_week(ctx::json& option); + int get_arranged_day_of_week(ctx::Json& option); struct ref_count_array_s { int count[7]; /* reference counts for days of week*/ @@ -60,7 +60,7 @@ namespace ctx { typedef std::map ref_count_map_t; typedef std::map timer_state_map_t; - typedef std::set option_t; + typedef std::set option_t; ref_count_map_t ref_count_map; timer_state_map_t timer_state_map; @@ -76,8 +76,8 @@ namespace ctx { void on_timer_expired(int hour, int min, int day_of_week); bool on_timer_expired(int timer_id, void *user_data); - bool is_matched(ctx::json& option, int time, std::string day); - option_t::iterator find_option(ctx::json& option); + bool is_matched(ctx::Json& option, int time, std::string day); + option_t::iterator find_option(ctx::Json& option); void destroy_if_unused(); diff --git a/src/device/system/battery.cpp b/src/device/system/battery.cpp index 0060955..5be24b6 100644 --- a/src/device/system/battery.cpp +++ b/src/device/system/battery.cpp @@ -58,7 +58,7 @@ void ctx::device_status_battery::handle_update(device_callback_e device_type, vo const char* level_string = trans_to_string(level); IF_FAIL_VOID(level_string); - ctx::json data_read; + ctx::Json data_read; data_read.set(NULL, DEVICE_ST_LEVEL, level_string); bool charging_state = false; @@ -120,7 +120,7 @@ int ctx::device_status_battery::unsubscribe() int ctx::device_status_battery::read() { device_battery_level_e level; - ctx::json data_read; + ctx::Json data_read; int ret = device_battery_get_level_status(&level); IF_FAIL_RETURN(ret == DEVICE_ERROR_NONE, ERR_OPERATION_FAILED); diff --git a/src/device/system/headphone.cpp b/src/device/system/headphone.cpp index 2160cdc..ac3d5db 100644 --- a/src/device/system/headphone.cpp +++ b/src/device/system/headphone.cpp @@ -79,7 +79,7 @@ int ctx::device_status_headphone::read() if (!being_subscribed) connected = get_current_status(); - json data; + Json data; generate_data_packet(data); ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_HEADPHONE, NULL, ERR_NONE, data); @@ -140,7 +140,7 @@ bool ctx::device_status_headphone::get_current_status() return ((audio_jack_state != RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED) || bt_audio_state); } -void ctx::device_status_headphone::generate_data_packet(ctx::json &data) +void ctx::device_status_headphone::generate_data_packet(ctx::Json &data) { data.set(NULL, DEVICE_ST_IS_CONNECTED, connected ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); @@ -165,7 +165,7 @@ bool ctx::device_status_headphone::handle_event() IF_FAIL_RETURN(prev_state != connected, false); - ctx::json data; + ctx::Json data; generate_data_packet(data); ctx::context_manager::publish(DEVICE_ST_SUBJ_HEADPHONE, NULL, ERR_NONE, data); return true; diff --git a/src/device/system/headphone.h b/src/device/system/headphone.h index 16c2f1e..f451d52 100644 --- a/src/device/system/headphone.h +++ b/src/device/system/headphone.h @@ -51,7 +51,7 @@ namespace ctx { void unset_bt_audio_callback(); void set_bt_audio_state(bool state); - void generate_data_packet(json &data); + void generate_data_packet(Json &data); bool handle_event(); void handle_audio_jack_event(); diff --git a/src/device/system/psmode.cpp b/src/device/system/psmode.cpp index 90980d0..dcfc359 100644 --- a/src/device/system/psmode.cpp +++ b/src/device/system/psmode.cpp @@ -48,7 +48,7 @@ void ctx::device_status_psmode::update_cb(keynode_t *node, void* user_data) void ctx::device_status_psmode::handle_update(keynode_t *node) { int status; - ctx::json data_read; + ctx::Json data_read; status = vconf_keynode_get_int(node); IF_FAIL_VOID_TAG(status >= 0, _E, "Getting state failed"); @@ -78,7 +78,7 @@ int ctx::device_status_psmode::read() int ret = vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &mode); IF_FAIL_RETURN(ret == VCONF_OK, ERR_OPERATION_FAILED); - ctx::json data_read; + ctx::Json data_read; data_read.set(NULL, DEVICE_ST_IS_ENABLED, mode == 0 ? DEVICE_ST_FALSE : DEVICE_ST_TRUE); ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_PSMODE, NULL, ERR_NONE, data_read); diff --git a/src/device/system/runtime-info/charger.cpp b/src/device/system/runtime-info/charger.cpp index 821a9b5..ae16d8c 100644 --- a/src/device/system/runtime-info/charger.cpp +++ b/src/device/system/runtime-info/charger.cpp @@ -47,7 +47,7 @@ void ctx::device_status_charger::handle_update() int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &charger_status); IF_FAIL_VOID_TAG(ret == RUNTIME_INFO_ERROR_NONE, _E, "Getting runtime info failed"); - ctx::json data_read; + ctx::Json data_read; data_read.set(NULL, DEVICE_ST_IS_CONNECTED, charger_status ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); context_manager::publish(DEVICE_ST_SUBJ_CHARGER, NULL, ERR_NONE, data_read); @@ -56,7 +56,7 @@ void ctx::device_status_charger::handle_update() int ctx::device_status_charger::read() { bool charger_status = false; - ctx::json data_read; + ctx::Json data_read; int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &charger_status); IF_FAIL_RETURN_TAG(ret == RUNTIME_INFO_ERROR_NONE, ERR_OPERATION_FAILED, _E, "Getting runtime info failed"); diff --git a/src/device/system/runtime-info/gps.cpp b/src/device/system/runtime-info/gps.cpp index 74ebb3c..80aa16c 100644 --- a/src/device/system/runtime-info/gps.cpp +++ b/src/device/system/runtime-info/gps.cpp @@ -67,7 +67,7 @@ void ctx::device_status_gps::handle_update() int ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_GPS_STATUS, &gps_status); IF_FAIL_VOID_TAG(ret == RUNTIME_INFO_ERROR_NONE, _E, "Getting runtime info failed"); - ctx::json data_read; + ctx::Json data_read; const char* state_str = get_state_string(gps_status); IF_FAIL_VOID(state_str); @@ -80,7 +80,7 @@ void ctx::device_status_gps::handle_update() int ctx::device_status_gps::read() { int gps_status; - ctx::json data_read; + ctx::Json data_read; int ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_GPS_STATUS, &gps_status); IF_FAIL_RETURN_TAG(ret == RUNTIME_INFO_ERROR_NONE, ERR_OPERATION_FAILED, _E, "Getting runtime info failed"); diff --git a/src/device/system/runtime-info/usb.cpp b/src/device/system/runtime-info/usb.cpp index 77d19ad..0ab4d0d 100644 --- a/src/device/system/runtime-info/usb.cpp +++ b/src/device/system/runtime-info/usb.cpp @@ -47,7 +47,7 @@ void ctx::device_status_usb::handle_update() int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_USB_CONNECTED, &status); IF_FAIL_VOID_TAG(ret == RUNTIME_INFO_ERROR_NONE, _E, "Getting runtime info failed"); - ctx::json data_read; + ctx::Json data_read; data_read.set(NULL, DEVICE_ST_IS_CONNECTED, status ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); context_manager::publish(DEVICE_ST_SUBJ_USB, NULL, ERR_NONE, data_read); @@ -56,7 +56,7 @@ void ctx::device_status_usb::handle_update() int ctx::device_status_usb::read() { bool status = false; - ctx::json data_read; + ctx::Json data_read; int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_USB_CONNECTED, &status); IF_FAIL_RETURN_TAG(ret == RUNTIME_INFO_ERROR_NONE, ERR_OPERATION_FAILED, _E, "Getting runtime info failed"); diff --git a/src/device/system/time.cpp b/src/device/system/time.cpp index c4166a9..65ba55a 100644 --- a/src/device/system/time.cpp +++ b/src/device/system/time.cpp @@ -68,7 +68,7 @@ int ctx::device_status_time::read() int minute_of_day = timeinfo.tm_hour * 60 + timeinfo.tm_min; std::string day_of_week = ctx::timer_util::convert_day_of_week_int_to_string(0x01 << timeinfo.tm_wday); - ctx::json data_read; + ctx::Json data_read; data_read.set(NULL, DEVICE_ST_DAY_OF_MONTH, day_of_month); data_read.set(NULL, DEVICE_ST_DAY_OF_WEEK, day_of_week); data_read.set(NULL, DEVICE_ST_TIME_OF_DAY, minute_of_day); diff --git a/src/device/system/wifi.cpp b/src/device/system/wifi.cpp index 3680768..a40c179 100644 --- a/src/device/system/wifi.cpp +++ b/src/device/system/wifi.cpp @@ -135,7 +135,7 @@ void ctx::device_status_wifi::clear_bssid() _D("No WiFi connection"); } -bool ctx::device_status_wifi::get_response_packet(ctx::json &data) +bool ctx::device_status_wifi::get_response_packet(ctx::Json &data) { switch (last_state) { case _DISABLED: @@ -162,7 +162,7 @@ int ctx::device_status_wifi::read() { IF_FAIL_RETURN(get_current_state(), ERR_OPERATION_FAILED); - ctx::json data_read; + ctx::Json data_read; if (get_response_packet(data_read)) { ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_WIFI, NULL, ERR_NONE, data_read); @@ -246,7 +246,7 @@ void ctx::device_status_wifi::aggregate_updated_data() clear_bssid(); } - ctx::json data; + ctx::Json data; if (being_subscribed && get_response_packet(data)) context_manager::publish(DEVICE_ST_SUBJ_WIFI, NULL, ERR_NONE, data); } diff --git a/src/device/system/wifi.h b/src/device/system/wifi.h index 6dc505d..6bd81c1 100644 --- a/src/device/system/wifi.h +++ b/src/device/system/wifi.h @@ -54,7 +54,7 @@ namespace ctx { bool get_current_state(); bool get_bssid(); void clear_bssid(); - bool get_response_packet(json &data); + bool get_response_packet(Json &data); void aggregate_updated_data(); bool start_monitor(); void stop_monitor(); diff --git a/src/place/geofence/myplace_handle.cpp b/src/place/geofence/myplace_handle.cpp index cb830ff..8ea7684 100644 --- a/src/place/geofence/myplace_handle.cpp +++ b/src/place/geofence/myplace_handle.cpp @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include "place_geofence_types.h" #include "myplace_handle.h" @@ -180,10 +180,10 @@ void ctx::myplace_handle::emit_state_change() prev_state = current_state; - json option; + Json option; option.set(NULL, PLACE_STATUS_DATA_MYPLACE_ID, _place_id); - json data; + Json data; data.set(NULL, PLACE_STATUS_DATA_MYPLACE_ID, _place_id); data.set(NULL, PLACE_STATUS_DATA_MYPLACE_EVENT, get_state_string(current_state)); diff --git a/src/place/geofence/place_geofence.cpp b/src/place/geofence/place_geofence.cpp index 53fb40b..c1525a1 100644 --- a/src/place/geofence/place_geofence.cpp +++ b/src/place/geofence/place_geofence.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include "place_geofence.h" @@ -79,33 +79,33 @@ void ctx::place_geofence_provider::__destroy_if_unused() } -int ctx::place_geofence_provider::subscribe(const char *subject, ctx::json option, ctx::json *request_result) +int ctx::place_geofence_provider::subscribe(const char *subject, ctx::Json option, ctx::Json *request_result) { int ret = __subscribe(option); __destroy_if_unused(); return ret; } -int ctx::place_geofence_provider::unsubscribe(const char *subject, ctx::json option) +int ctx::place_geofence_provider::unsubscribe(const char *subject, ctx::Json option) { int ret = __unsubscribe(option); __destroy_if_unused(); return ret; } -int ctx::place_geofence_provider::read(const char *subject, ctx::json option, ctx::json *request_result) +int ctx::place_geofence_provider::read(const char *subject, ctx::Json option, ctx::Json *request_result) { __destroy_if_unused(); return ERR_NOT_SUPPORTED; } -int ctx::place_geofence_provider::write(const char *subject, ctx::json data, ctx::json *request_result) +int ctx::place_geofence_provider::write(const char *subject, ctx::Json data, ctx::Json *request_result) { __destroy_if_unused(); return ERR_NOT_SUPPORTED; } -int ctx::place_geofence_provider::__subscribe(ctx::json option) +int ctx::place_geofence_provider::__subscribe(ctx::Json option) { int pid = -1; option.get(NULL, PLACE_STATUS_OPT_MYPLACE_ID, &pid); @@ -132,7 +132,7 @@ int ctx::place_geofence_provider::__subscribe(ctx::json option) return ERR_NONE; } -int ctx::place_geofence_provider::__unsubscribe(ctx::json option) +int ctx::place_geofence_provider::__unsubscribe(ctx::Json option) { int pid = -1; option.get(NULL, PLACE_STATUS_OPT_MYPLACE_ID, &pid); diff --git a/src/place/geofence/place_geofence.h b/src/place/geofence/place_geofence.h index 9fb8ae8..05de007 100644 --- a/src/place/geofence/place_geofence.h +++ b/src/place/geofence/place_geofence.h @@ -33,10 +33,10 @@ namespace ctx { static bool is_supported(); static void submit_trigger_item(); - int subscribe(const char *subject, ctx::json option, ctx::json *request_result); - int unsubscribe(const char *subject, ctx::json option); - int read(const char *subject, ctx::json option, ctx::json *request_result); - int write(const char *subject, ctx::json data, ctx::json *request_result); + int subscribe(const char *subject, ctx::Json option, ctx::Json *request_result); + int unsubscribe(const char *subject, ctx::Json option); + int read(const char *subject, ctx::Json option, ctx::Json *request_result); + int write(const char *subject, ctx::Json data, ctx::Json *request_result); private: static place_geofence_provider *__instance; @@ -45,8 +45,8 @@ namespace ctx { place_geofence_provider(); ~place_geofence_provider(); - int __subscribe(ctx::json option); - int __unsubscribe(ctx::json option); + int __subscribe(ctx::Json option); + int __unsubscribe(ctx::Json option); void __destroy_if_unused(); }; diff --git a/src/place/recognition/place_recognition.cpp b/src/place/recognition/place_recognition.cpp index 137d3b6..7fb092f 100644 --- a/src/place/recognition/place_recognition.cpp +++ b/src/place/recognition/place_recognition.cpp @@ -38,23 +38,23 @@ void ctx::place_recognition_provider::destroy(void *data) _I(BLUE("Destroyed")); } -int ctx::place_recognition_provider::subscribe(const char *subject, ctx::json option, ctx::json* request_result) +int ctx::place_recognition_provider::subscribe(const char *subject, ctx::Json option, ctx::Json* request_result) { return ERR_NOT_SUPPORTED; } -int ctx::place_recognition_provider::unsubscribe(const char *subject, ctx::json option) +int ctx::place_recognition_provider::unsubscribe(const char *subject, ctx::Json option) { return ERR_NOT_SUPPORTED; } -int ctx::place_recognition_provider::read(const char *subject, ctx::json option, ctx::json* request_result) +int ctx::place_recognition_provider::read(const char *subject, ctx::Json option, ctx::Json* request_result) { _I(BLUE("Read")); _J("Option", option); std::vector> places = engine.get_places(); - json data_read = engine.compose_json(places); + Json data_read = engine.compose_json(places); // The below function needs to be called once. // It does not need to be called within this read() function. @@ -66,7 +66,7 @@ int ctx::place_recognition_provider::read(const char *subject, ctx::json option, return ERR_NONE; } -int ctx::place_recognition_provider::write(const char *subject, ctx::json data, ctx::json* request_result) +int ctx::place_recognition_provider::write(const char *subject, ctx::Json data, ctx::Json* request_result) { return ERR_NOT_SUPPORTED; } diff --git a/src/place/recognition/place_recognition.h b/src/place/recognition/place_recognition.h index 1f870af..8f25424 100644 --- a/src/place/recognition/place_recognition.h +++ b/src/place/recognition/place_recognition.h @@ -30,10 +30,10 @@ namespace ctx { static void destroy(void *data); static bool is_supported(); - int subscribe(const char *subject, ctx::json option, ctx::json *request_result); - int unsubscribe(const char *subject, ctx::json option); - int read(const char *subject, ctx::json option, ctx::json *request_result); - int write(const char *subject, ctx::json data, ctx::json *request_result); + int subscribe(const char *subject, ctx::Json option, ctx::Json *request_result); + int unsubscribe(const char *subject, ctx::Json option); + int read(const char *subject, ctx::Json option, ctx::Json *request_result); + int write(const char *subject, ctx::Json data, ctx::Json *request_result); private: static place_recognition_provider *__instance; diff --git a/src/place/recognition/user_places/location_logger.cpp b/src/place/recognition/user_places/location_logger.cpp index 4adc07c..eddf0dc 100644 --- a/src/place/recognition/user_places/location_logger.cpp +++ b/src/place/recognition/user_places/location_logger.cpp @@ -19,7 +19,7 @@ #include "../place_recognition_types.h" #include #include -#include +#include #include "user_places_params.h" #include "debug_utils.h" @@ -182,7 +182,7 @@ int ctx::LocationLogger::create_table() int ctx::LocationLogger::db_insert_log(location_event_s location_event) { - json data; + Json data; data.set(NULL, LOCATION_COLUMN_LATITUDE, location_event.coordinates.latitude, GEO_LOCATION_PRECISION); data.set(NULL, LOCATION_COLUMN_LONGITUDE, location_event.coordinates.longitude, GEO_LOCATION_PRECISION); data.set(NULL, LOCATION_COLUMN_ACCURACY, location_event.coordinates.accuracy, GEO_LOCATION_PRECISION); diff --git a/src/place/recognition/user_places/places_detector.cpp b/src/place/recognition/user_places/places_detector.cpp index 974fd7b..1530ef9 100644 --- a/src/place/recognition/user_places/places_detector.cpp +++ b/src/place/recognition/user_places/places_detector.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include "similar.h" #include "places_detector.h" #include "place_categer.h" @@ -77,7 +77,7 @@ bool ctx::PlacesDetector::on_timer_expired(int timer_id, void* user_data) return true; } -void ctx::PlacesDetector::on_query_result_received(unsigned int query_id, int error, std::vector& records) +void ctx::PlacesDetector::on_query_result_received(unsigned int query_id, int error, std::vector& records) { // TODO: // The below "state machine" approach was choosen because it is not possible to use synchronized database queries in the main thread. @@ -123,7 +123,7 @@ void ctx::PlacesDetector::db_get_places() _D("load places execute query result: %s", ret ? "SUCCESS" : "FAIL"); } -double ctx::PlacesDetector::double_value_from_json(json &row, const char* key) +double ctx::PlacesDetector::double_value_from_json(Json &row, const char* key) { double value; row.get(NULL, key, &value); @@ -131,7 +131,7 @@ double ctx::PlacesDetector::double_value_from_json(json &row, const char* key) return value; } -ctx::categs_t ctx::PlacesDetector::visit_categs_from_json(json &row) +ctx::categs_t ctx::PlacesDetector::visit_categs_from_json(Json &row) { categs_t categs; categs[PLACE_CATEG_ID_HOME] = double_value_from_json(row, VISIT_COLUMN_CATEG_HOME); @@ -140,7 +140,7 @@ ctx::categs_t ctx::PlacesDetector::visit_categs_from_json(json &row) return categs; } -ctx::visit_s ctx::PlacesDetector::visit_from_json(json &row) +ctx::visit_s ctx::PlacesDetector::visit_from_json(Json &row) { int start_time; int end_time; @@ -170,12 +170,12 @@ ctx::visit_s ctx::PlacesDetector::visit_from_json(json &row) return visit; } -ctx::visits_t ctx::PlacesDetector::visits_from_jsons(std::vector& records) +ctx::visits_t ctx::PlacesDetector::visits_from_jsons(std::vector& records) { visits_t visits; _D("db_result: number of all visits: %d", records.size()); - for (json &row : records) { + for (Json &row : records) { visit_s visit = visit_from_json(row); visits.push_back(visit); } @@ -183,7 +183,7 @@ ctx::visits_t ctx::PlacesDetector::visits_from_jsons(std::vector& records) return visits; } -std::shared_ptr ctx::PlacesDetector::place_from_json(json &row) +std::shared_ptr ctx::PlacesDetector::place_from_json(Json &row) { std::shared_ptr place = std::make_shared(); { // category @@ -211,12 +211,12 @@ std::shared_ptr ctx::PlacesDetector::place_from_json(json &row) return place; } -std::vector> ctx::PlacesDetector::places_from_jsons(std::vector& records) +std::vector> ctx::PlacesDetector::places_from_jsons(std::vector& records) { std::vector> places; _D("db_result: number of all places: %d", records.size()); - for (json &row : records) { + for (Json &row : records) { std::shared_ptr place = place_from_json(row); places.push_back(place); } @@ -432,7 +432,7 @@ void ctx::PlacesDetector::db_create_table() void ctx::PlacesDetector::db_insert_place(const Place &place) { - json data; + Json data; data.set(NULL, PLACE_COLUMN_CATEG_ID, place.categ_id); data.set(NULL, PLACE_COLUMN_CATEG_CONFIDENCE, place.categ_confidence); data.set(NULL, PLACE_COLUMN_NAME, place.name); diff --git a/src/place/recognition/user_places/places_detector.h b/src/place/recognition/user_places/places_detector.h index 72767c4..9adeb92 100644 --- a/src/place/recognition/user_places/places_detector.h +++ b/src/place/recognition/user_places/places_detector.h @@ -40,12 +40,12 @@ namespace ctx { private: bool test_mode; - double double_value_from_json(json &row, const char* key); - categs_t visit_categs_from_json(json &row); - visit_s visit_from_json(json &row); - visits_t visits_from_jsons(std::vector& records); - std::shared_ptr place_from_json(json &row); - std::vector> places_from_jsons(std::vector& records); + double double_value_from_json(Json &row, const char* key); + categs_t visit_categs_from_json(Json &row); + visit_s visit_from_json(Json &row); + visits_t visits_from_jsons(std::vector& records); + std::shared_ptr place_from_json(Json &row); + std::vector> places_from_jsons(std::vector& records); std::shared_ptr graph_from_visits(const std::vector &visits); void db_create_table(); void db_delete_places(); @@ -68,7 +68,7 @@ namespace ctx { bool on_timer_expired(int timer_id, void* user_data); void on_creation_result_received(unsigned int query_id, int error) {} void on_insertion_result_received(unsigned int query_id, int error, int64_t row_id) {} - void on_query_result_received(unsigned int query_id, int error, std::vector& records); + void on_query_result_received(unsigned int query_id, int error, std::vector& records); std::shared_ptr merge_visits(const std::vector &visits); std::vector> get_places(); diff --git a/src/place/recognition/user_places/user_places.cpp b/src/place/recognition/user_places/user_places.cpp index 4747ed1..46c8d31 100644 --- a/src/place/recognition/user_places/user_places.cpp +++ b/src/place/recognition/user_places/user_places.cpp @@ -111,11 +111,11 @@ std::vector> ctx::UserPlaces::get_places() * ] * } */ -ctx::json ctx::UserPlaces::compose_json(std::vector> places) +ctx::Json ctx::UserPlaces::compose_json(std::vector> places) { - ctx::json data; + ctx::Json data; for (std::shared_ptr place : places) { - ctx::json place_j; + ctx::Json place_j; place_j.set(NULL, PLACE_CATEG_ID, place->categ_id); place_j.set(NULL, PLACE_CATEG_CONFIDENCE, place->categ_confidence); place_j.set(NULL, PLACE_NAME, place->name); @@ -125,7 +125,7 @@ ctx::json ctx::UserPlaces::compose_json(std::vector> plac } place_j.set(NULL, PLACE_WIFI_APS, place->wifi_aps); place_j.set(NULL, PLACE_CREATE_DATE, static_cast(place->create_date)); - data.array_append(NULL, DATA_READ, place_j); + data.append(NULL, DATA_READ, place_j); } return data; } diff --git a/src/place/recognition/user_places/user_places.h b/src/place/recognition/user_places/user_places.h index 2ad10ce..d2c66da 100644 --- a/src/place/recognition/user_places/user_places.h +++ b/src/place/recognition/user_places/user_places.h @@ -21,7 +21,7 @@ #include "places_detector.h" #include #include "user_places_types.h" -#include +#include namespace ctx { @@ -38,7 +38,7 @@ namespace ctx { void set_mode(place_recog_mode_e energy_mode); std::vector> get_places(); - static json compose_json(std::vector> places); + static Json compose_json(std::vector> places); }; /* class UserPlaces */ diff --git a/src/place/recognition/user_places/visit_detector.cpp b/src/place/recognition/user_places/visit_detector.cpp index 0123b93..ccd9cb7 100644 --- a/src/place/recognition/user_places/visit_detector.cpp +++ b/src/place/recognition/user_places/visit_detector.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include "../place_recognition_types.h" #include "visit_detector.h" #include "user_places_params.h" @@ -372,7 +372,7 @@ void ctx::VisitDetector::db_create_table() _D("db: visit Table Creation Result: %s", ret ? "SUCCESS" : "FAIL"); } -void ctx::VisitDetector::json_put_visit_categ(json &data, const char* key, const categs_t &categs, int categ_type) +void ctx::VisitDetector::json_put_visit_categ(Json &data, const char* key, const categs_t &categs, int categ_type) { auto categ_p = categs.find(categ_type); if (categ_p == categs.end()) { @@ -382,7 +382,7 @@ void ctx::VisitDetector::json_put_visit_categ(json &data, const char* key, const } } -void ctx::VisitDetector::json_put_visit_categs(json &data, const categs_t &categs) +void ctx::VisitDetector::json_put_visit_categs(Json &data, const categs_t &categs) { json_put_visit_categ(data, VISIT_COLUMN_CATEG_HOME, categs, PLACE_CATEG_ID_HOME); json_put_visit_categ(data, VISIT_COLUMN_CATEG_WORK, categs, PLACE_CATEG_ID_WORK); @@ -394,7 +394,7 @@ int ctx::VisitDetector::db_insert_visit(visit_s visit) std::stringstream macs_ss; macs_ss << *visit.mac_set; - json data; + Json data; data.set(NULL, VISIT_COLUMN_WIFI_APS, macs_ss.str().c_str()); data.set(NULL, VISIT_COLUMN_LOCATION_VALID, visit.location_valid); diff --git a/src/place/recognition/user_places/visit_detector.h b/src/place/recognition/user_places/visit_detector.h index ccde0b2..52d0b20 100644 --- a/src/place/recognition/user_places/visit_detector.h +++ b/src/place/recognition/user_places/visit_detector.h @@ -23,7 +23,7 @@ #include #include #include "user_places_types.h" -#include +#include #include "visit_listener_iface.h" #include "location_logger.h" #include "location_listener_iface.h" @@ -80,8 +80,8 @@ namespace ctx { bool protrudes_from(const mac_counts_t &mac_counts, const mac_set_t &mac_set); void db_create_table(); - void json_put_visit_categ(json &data, const char* key, const categs_t &categs, int categ_type); - void json_put_visit_categs(json &data, const categs_t &categs); + void json_put_visit_categ(Json &data, const char* key, const categs_t &categs, int categ_type); + void json_put_visit_categs(Json &data, const categs_t &categs); int db_insert_visit(visit_s visit); void set_period(place_recog_mode_e mode); diff --git a/src/statistics/app/active_window_monitor.cpp b/src/statistics/app/active_window_monitor.cpp index 701209b..f429a9c 100644 --- a/src/statistics/app/active_window_monitor.cpp +++ b/src/statistics/app/active_window_monitor.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include "../shared/system_info.h" #include "app_stats_types.h" @@ -85,7 +85,7 @@ void ctx::app_use_monitor::create_record(std::string app_id) int system_volume; int media_volume; std::string bssid; - json data; + Json data; data.set(NULL, STATS_APP_ID, app_id); if (ctx::system_info::get_audio_jack_state(&audiojack)) diff --git a/src/statistics/app/app_stats_provider.cpp b/src/statistics/app/app_stats_provider.cpp index 06aa468..cdb53f4 100644 --- a/src/statistics/app/app_stats_provider.cpp +++ b/src/statistics/app/app_stats_provider.cpp @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include "app_stats_provider.h" #include "db_handle.h" @@ -98,17 +98,17 @@ CATCH: return false; } -int ctx::app_statistics_provider::subscribe(const char* subject, ctx::json option, ctx::json* request_result) +int ctx::app_statistics_provider::subscribe(const char* subject, ctx::Json option, ctx::Json* request_result) { return ERR_NOT_SUPPORTED; } -int ctx::app_statistics_provider::unsubscribe(const char* subject, ctx::json option) +int ctx::app_statistics_provider::unsubscribe(const char* subject, ctx::Json option) { return ERR_NOT_SUPPORTED; } -int ctx::app_statistics_provider::read(const char* subject, ctx::json option, ctx::json* request_result) +int ctx::app_statistics_provider::read(const char* subject, ctx::Json option, ctx::Json* request_result) { ctx::app_db_handle *handle = new(std::nothrow) ctx::app_db_handle(); IF_FAIL_RETURN_TAG(handle, ERR_OPERATION_FAILED, _E, "Memory allocation failed"); @@ -122,7 +122,7 @@ int ctx::app_statistics_provider::read(const char* subject, ctx::json option, ct return ERR_NONE; } -int ctx::app_statistics_provider::write(const char* subject, ctx::json data, ctx::json* request_result) +int ctx::app_statistics_provider::write(const char* subject, ctx::Json data, ctx::Json* request_result) { return ERR_NOT_SUPPORTED; } diff --git a/src/statistics/app/app_stats_provider.h b/src/statistics/app/app_stats_provider.h index f5804bd..7735fd2 100644 --- a/src/statistics/app/app_stats_provider.h +++ b/src/statistics/app/app_stats_provider.h @@ -29,10 +29,10 @@ namespace ctx { static bool is_supported(const char *subject); static void submit_trigger_item(); - int subscribe(const char *subject, ctx::json option, ctx::json *request_result); - int unsubscribe(const char *subject, ctx::json option); - int read(const char *subject, ctx::json option, ctx::json *request_result); - int write(const char *subject, ctx::json data, ctx::json *request_result); + int subscribe(const char *subject, ctx::Json option, ctx::Json *request_result); + int unsubscribe(const char *subject, ctx::Json option); + int read(const char *subject, ctx::Json option, ctx::Json *request_result); + int write(const char *subject, ctx::Json data, ctx::Json *request_result); private: static app_statistics_provider *__instance; diff --git a/src/statistics/app/db_handle.cpp b/src/statistics/app/db_handle.cpp index 5491d24..d293ed4 100644 --- a/src/statistics/app/db_handle.cpp +++ b/src/statistics/app/db_handle.cpp @@ -29,7 +29,7 @@ ctx::app_db_handle::~app_db_handle() { } -int ctx::app_db_handle::read(const char* subject, ctx::json filter) +int ctx::app_db_handle::read(const char* subject, ctx::Json filter) { std::string query; @@ -61,7 +61,7 @@ int ctx::app_db_handle::read(const char* subject, ctx::json filter) return ERR_NONE; } -std::string ctx::app_db_handle::create_where_clause_with_device_status(ctx::json filter) +std::string ctx::app_db_handle::create_where_clause_with_device_status(ctx::Json filter) { std::stringstream where_clause; std::string bssid; @@ -78,19 +78,19 @@ std::string ctx::app_db_handle::create_where_clause_with_device_status(ctx::json return where_clause.str(); } -std::string ctx::app_db_handle::create_sql_peak_time(ctx::json filter) +std::string ctx::app_db_handle::create_sql_peak_time(ctx::Json filter) { return stats_db_handle_base::create_sql_peak_time(filter, APP_TABLE_USAGE_LOG, create_where_clause(filter)); } -std::string ctx::app_db_handle::create_sql_common_setting(ctx::json filter) +std::string ctx::app_db_handle::create_sql_common_setting(ctx::Json filter) { return stats_db_handle_base::create_sql_common_setting(filter, APP_TABLE_USAGE_LOG, create_where_clause(filter)); } -std::string ctx::app_db_handle::create_sql_frequency(ctx::json filter) +std::string ctx::app_db_handle::create_sql_frequency(ctx::Json filter) { - ctx::json filter_cleaned; + ctx::Json filter_cleaned; std::string week_str; std::string time_of_day; std::string app_id; @@ -134,7 +134,7 @@ std::string ctx::app_db_handle::create_sql_frequency(ctx::json filter) return query.str(); } -std::string ctx::app_db_handle::create_sql_recently_used(ctx::json filter) +std::string ctx::app_db_handle::create_sql_recently_used(ctx::Json filter) { std::stringstream query; int limit = DEFAULT_LIMIT; @@ -155,7 +155,7 @@ std::string ctx::app_db_handle::create_sql_recently_used(ctx::json filter) return query.str(); } -std::string ctx::app_db_handle::create_sql_frequently_used(ctx::json filter) +std::string ctx::app_db_handle::create_sql_frequently_used(ctx::Json filter) { std::stringstream query; int limit = DEFAULT_LIMIT; @@ -176,7 +176,7 @@ std::string ctx::app_db_handle::create_sql_frequently_used(ctx::json filter) return query.str(); } -std::string ctx::app_db_handle::create_sql_rarely_used(ctx::json filter) +std::string ctx::app_db_handle::create_sql_rarely_used(ctx::Json filter) { std::stringstream query; int limit = DEFAULT_LIMIT; @@ -199,11 +199,11 @@ std::string ctx::app_db_handle::create_sql_rarely_used(ctx::json filter) return query.str(); } -void ctx::app_db_handle::reply_trigger_item(int error, ctx::json &json_result) +void ctx::app_db_handle::reply_trigger_item(int error, ctx::Json &json_result) { IF_FAIL_VOID_TAG(STR_EQ(req_subject.c_str(), APP_SUBJ_FREQUENCY), _E, "Invalid subject"); - ctx::json results; + ctx::Json results; std::string val_str; int val; diff --git a/src/statistics/app/db_handle.h b/src/statistics/app/db_handle.h index f629f00..c4cc79e 100644 --- a/src/statistics/app/db_handle.h +++ b/src/statistics/app/db_handle.h @@ -18,7 +18,7 @@ #define __CONTEXT_APP_DB_HANDLE_H__ #include -#include +#include #include "../shared/db_handle_base.h" namespace ctx { @@ -27,17 +27,17 @@ namespace ctx { app_db_handle(); ~app_db_handle(); - int read(const char* subject, ctx::json filter); + int read(const char* subject, ctx::Json filter); private: - std::string create_where_clause_with_device_status(ctx::json filter); - std::string create_sql_recently_used(ctx::json filter); - std::string create_sql_frequently_used(ctx::json filter); - std::string create_sql_rarely_used(ctx::json filter); - std::string create_sql_peak_time(ctx::json filter); - std::string create_sql_common_setting(ctx::json filter); - std::string create_sql_frequency(ctx::json filter); - void reply_trigger_item(int error, ctx::json &json_result); + std::string create_where_clause_with_device_status(ctx::Json filter); + std::string create_sql_recently_used(ctx::Json filter); + std::string create_sql_frequently_used(ctx::Json filter); + std::string create_sql_rarely_used(ctx::Json filter); + std::string create_sql_peak_time(ctx::Json filter); + std::string create_sql_common_setting(ctx::Json filter); + std::string create_sql_frequency(ctx::Json filter); + void reply_trigger_item(int error, ctx::Json &json_result); }; } diff --git a/src/statistics/app/db_init.cpp b/src/statistics/app/db_init.cpp index a5a7af9..1701585 100644 --- a/src/statistics/app/db_init.cpp +++ b/src/statistics/app/db_init.cpp @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include #include "app_stats_types.h" @@ -78,7 +78,7 @@ bool ctx::app_db_initializer::package_info_cb(package_info_h package_info, void bool ctx::app_db_initializer::app_info_cb(package_info_app_component_type_e comp_type, const char *app_id, void *user_data) { - json data; + Json data; data.set(NULL, STATS_APP_ID, app_id); return db_manager::insert(0, APP_TABLE_REMOVABLE_APP, data, NULL); } @@ -91,7 +91,7 @@ void ctx::app_db_initializer::on_insertion_result_received(unsigned int query_id { } -void ctx::app_db_initializer::on_query_result_received(unsigned int query_id, int error, std::vector& records) +void ctx::app_db_initializer::on_query_result_received(unsigned int query_id, int error, std::vector& records) { if (query_id != EMPTY_CHECKER_QID) { _E("Unknown Query ID: %d", query_id); diff --git a/src/statistics/app/db_init.h b/src/statistics/app/db_init.h index b042675..2bd20ad 100644 --- a/src/statistics/app/db_init.h +++ b/src/statistics/app/db_init.h @@ -30,7 +30,7 @@ namespace ctx { void on_creation_result_received(unsigned int query_id, int error); void on_insertion_result_received(unsigned int query_id, int error, int64_t row_id); - void on_query_result_received(unsigned int query_id, int error, std::vector& records); + void on_query_result_received(unsigned int query_id, int error, std::vector& records); static bool package_info_cb(package_info_h package_info, void *user_data); static bool app_info_cb(package_info_app_component_type_e comp_type, const char *app_id, void *user_data); diff --git a/src/statistics/app/install_monitor.cpp b/src/statistics/app/install_monitor.cpp index 7cec212..d4b92ce 100644 --- a/src/statistics/app/install_monitor.cpp +++ b/src/statistics/app/install_monitor.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include #include "app_stats_types.h" @@ -81,7 +81,7 @@ void ctx::app_install_monitor::package_event_cb(const char *type, const char *pa bool ctx::app_install_monitor::app_info_cb(package_info_app_component_type_e comp_type, const char *app_id, void *user_data) { if (last_event_type == PACKAGE_MANAGER_EVENT_TYPE_INSTALL) { - json data; + Json data; data.set(NULL, STATS_APP_ID, app_id); db_manager::insert(0, APP_TABLE_REMOVABLE_APP, data, NULL); } else if (last_event_type == PACKAGE_MANAGER_EVENT_TYPE_UNINSTALL) { diff --git a/src/statistics/app/install_monitor.h b/src/statistics/app/install_monitor.h index 0bfee65..cba445d 100644 --- a/src/statistics/app/install_monitor.h +++ b/src/statistics/app/install_monitor.h @@ -31,7 +31,7 @@ namespace ctx { void on_creation_result_received(unsigned int query_id, int error) {} void on_insertion_result_received(unsigned int query_id, int error, int64_t row_id) {} - void on_query_result_received(unsigned int query_id, int error, std::vector& records) {} + void on_query_result_received(unsigned int query_id, int error, std::vector& records) {} static std::string create_deletion_query(const char* table_name, const char* app_id); static void package_event_cb(const char *type, const char *package, package_manager_event_type_e event_type, package_manager_event_state_e event_state, int progress, package_manager_error_e error, void *user_data); diff --git a/src/statistics/media/db_handle.cpp b/src/statistics/media/db_handle.cpp index 6515c9f..bc74429 100644 --- a/src/statistics/media/db_handle.cpp +++ b/src/statistics/media/db_handle.cpp @@ -30,7 +30,7 @@ ctx::media_db_handle::~media_db_handle() { } -int ctx::media_db_handle::read(const char* subject, ctx::json filter) +int ctx::media_db_handle::read(const char* subject, ctx::Json filter) { //TODO: filter validation (in the API side?) std::string query; @@ -64,7 +64,7 @@ int ctx::media_db_handle::read(const char* subject, ctx::json filter) return ERR_NONE; } -std::string ctx::media_db_handle::create_where_clause(int media_type, ctx::json filter) +std::string ctx::media_db_handle::create_where_clause(int media_type, ctx::Json filter) { std::stringstream where_clause; @@ -74,21 +74,21 @@ std::string ctx::media_db_handle::create_where_clause(int media_type, ctx::json return where_clause.str(); } -std::string ctx::media_db_handle::create_sql_peak_time(int media_type, ctx::json filter) +std::string ctx::media_db_handle::create_sql_peak_time(int media_type, ctx::Json filter) { std::string where = create_where_clause(media_type, filter); return stats_db_handle_base::create_sql_peak_time(filter, MEDIA_TABLE_NAME, where); } -std::string ctx::media_db_handle::create_sql_common_setting(int media_type, ctx::json filter) +std::string ctx::media_db_handle::create_sql_common_setting(int media_type, ctx::Json filter) { std::string where = create_where_clause(media_type, filter); return stats_db_handle_base::create_sql_common_setting(filter, MEDIA_TABLE_NAME, where); } -std::string ctx::media_db_handle::create_sql_frequency(int media_type, ctx::json filter) +std::string ctx::media_db_handle::create_sql_frequency(int media_type, ctx::Json filter) { - ctx::json filter_cleaned; + ctx::Json filter_cleaned; std::string week_str; std::string time_of_day; @@ -109,12 +109,12 @@ std::string ctx::media_db_handle::create_sql_frequency(int media_type, ctx::json return query.str(); } -void ctx::media_db_handle::reply_trigger_item(int error, ctx::json &json_result) +void ctx::media_db_handle::reply_trigger_item(int error, ctx::Json &json_result) { IF_FAIL_VOID_TAG(STR_EQ(req_subject.c_str(), MEDIA_SUBJ_MUSIC_FREQUENCY) || STR_EQ(req_subject.c_str(), MEDIA_SUBJ_VIDEO_FREQUENCY), _E, "Invalid subject"); - ctx::json results; + ctx::Json results; int val; json_result.get(NULL, STATS_TOTAL_COUNT, &val); diff --git a/src/statistics/media/db_handle.h b/src/statistics/media/db_handle.h index 8fbe72a..deb3ded 100644 --- a/src/statistics/media/db_handle.h +++ b/src/statistics/media/db_handle.h @@ -18,7 +18,7 @@ #define __CONTEXT_MEDIA_DB_HANDLE_H__ #include -#include +#include #include "../shared/db_handle_base.h" namespace ctx { @@ -27,14 +27,14 @@ namespace ctx { media_db_handle(); ~media_db_handle(); - int read(const char* subject, ctx::json filter); + int read(const char* subject, ctx::Json filter); private: - std::string create_where_clause(int media_type, ctx::json filter); - std::string create_sql_peak_time(int media_type, ctx::json filter); - std::string create_sql_common_setting(int media_type, ctx::json filter); - std::string create_sql_frequency(int media_type, ctx::json filter); - void reply_trigger_item(int error, ctx::json &json_result); + std::string create_where_clause(int media_type, ctx::Json filter); + std::string create_sql_peak_time(int media_type, ctx::Json filter); + std::string create_sql_common_setting(int media_type, ctx::Json filter); + std::string create_sql_frequency(int media_type, ctx::Json filter); + void reply_trigger_item(int error, ctx::Json &json_result); }; } diff --git a/src/statistics/media/media_content_monitor.cpp b/src/statistics/media/media_content_monitor.cpp index 9c945d7..156d9b5 100644 --- a/src/statistics/media/media_content_monitor.cpp +++ b/src/statistics/media/media_content_monitor.cpp @@ -121,7 +121,7 @@ void ctx::media_content_monitor::update_play_count(const char *uuid, int type, i db_manager::execute(0, query.str().c_str(), this); } -void ctx::media_content_monitor::on_query_result_received(unsigned int query_id, int error, std::vector& records) +void ctx::media_content_monitor::on_query_result_received(unsigned int query_id, int error, std::vector& records) { IF_FAIL_VOID(!records.empty()); @@ -135,7 +135,7 @@ void ctx::media_content_monitor::insert_log(int media_type) { int system_volume = -1, media_volume = -1, audiojack = -1; - json data; + Json data; data.set(NULL, CX_MEDIA_TYPE, media_type); if (ctx::system_info::get_audio_jack_state(&audiojack)) diff --git a/src/statistics/media/media_content_monitor.h b/src/statistics/media/media_content_monitor.h index d51d54c..4bd97db 100644 --- a/src/statistics/media/media_content_monitor.h +++ b/src/statistics/media/media_content_monitor.h @@ -37,7 +37,7 @@ namespace ctx { void on_creation_result_received(unsigned int query_id, int error) {} void on_insertion_result_received(unsigned int query_id, int error, int64_t row_id) {} - void on_query_result_received(unsigned int query_id, int error, std::vector& records); + void on_query_result_received(unsigned int query_id, int error, std::vector& records); static void on_media_content_db_updated(media_content_error_e error, int pid, media_content_db_update_item_type_e update_item, diff --git a/src/statistics/media/media_stats_provider.cpp b/src/statistics/media/media_stats_provider.cpp index d6ad2b7..e68fe6b 100644 --- a/src/statistics/media/media_stats_provider.cpp +++ b/src/statistics/media/media_stats_provider.cpp @@ -83,17 +83,17 @@ bool ctx::media_statistics_provider::init() return true; } -int ctx::media_statistics_provider::subscribe(const char* subject, ctx::json option, ctx::json* request_result) +int ctx::media_statistics_provider::subscribe(const char* subject, ctx::Json option, ctx::Json* request_result) { return ERR_NOT_SUPPORTED; } -int ctx::media_statistics_provider::unsubscribe(const char* subject, ctx::json option) +int ctx::media_statistics_provider::unsubscribe(const char* subject, ctx::Json option) { return ERR_NOT_SUPPORTED; } -int ctx::media_statistics_provider::read(const char* subject, ctx::json option, ctx::json* request_result) +int ctx::media_statistics_provider::read(const char* subject, ctx::Json option, ctx::Json* request_result) { media_db_handle *handle = new(std::nothrow) media_db_handle(); IF_FAIL_RETURN_TAG(handle, ERR_OPERATION_FAILED, _E, "Memory allocation failed"); @@ -107,7 +107,7 @@ int ctx::media_statistics_provider::read(const char* subject, ctx::json option, return ERR_NONE; } -int ctx::media_statistics_provider::write(const char* subject, ctx::json data, ctx::json* request_result) +int ctx::media_statistics_provider::write(const char* subject, ctx::Json data, ctx::Json* request_result) { return ERR_NOT_SUPPORTED; } diff --git a/src/statistics/media/media_stats_provider.h b/src/statistics/media/media_stats_provider.h index 49949c3..72bb198 100644 --- a/src/statistics/media/media_stats_provider.h +++ b/src/statistics/media/media_stats_provider.h @@ -29,10 +29,10 @@ namespace ctx { static bool is_supported(const char *subject); static void submit_trigger_item(); - int subscribe(const char* subject, ctx::json option, ctx::json* request_result); - int unsubscribe(const char* subject, ctx::json option); - int read(const char* subject, ctx::json option, ctx::json* request_result); - int write(const char* subject, ctx::json data, ctx::json* request_result); + int subscribe(const char* subject, ctx::Json option, ctx::Json* request_result); + int unsubscribe(const char* subject, ctx::Json option); + int read(const char* subject, ctx::Json option, ctx::Json* request_result); + int write(const char* subject, ctx::Json data, ctx::Json* request_result); private: static media_statistics_provider *__instance; diff --git a/src/statistics/shared/db_handle_base.cpp b/src/statistics/shared/db_handle_base.cpp index e3d0602..f525b3d 100644 --- a/src/statistics/shared/db_handle_base.cpp +++ b/src/statistics/shared/db_handle_base.cpp @@ -41,7 +41,7 @@ int ctx::stats_db_handle_base::generate_qid() return qid; } -bool ctx::stats_db_handle_base::execute_query(const char* subject, ctx::json filter, const char* query) +bool ctx::stats_db_handle_base::execute_query(const char* subject, ctx::Json filter, const char* query) { bool ret = db_manager::execute(generate_qid(), query, this); IF_FAIL_RETURN(ret, false); @@ -52,7 +52,7 @@ bool ctx::stats_db_handle_base::execute_query(const char* subject, ctx::json fil return true; } -std::string ctx::stats_db_handle_base::create_where_clause(ctx::json filter) +std::string ctx::stats_db_handle_base::create_where_clause(ctx::Json filter) { std::stringstream where_clause; int week = 0; @@ -142,7 +142,7 @@ std::string ctx::stats_db_handle_base::create_where_clause(ctx::json filter) return where_clause.str(); } -std::string ctx::stats_db_handle_base::create_sql_peak_time(ctx::json filter, const char* table_name, std::string where_clause) +std::string ctx::stats_db_handle_base::create_sql_peak_time(ctx::Json filter, const char* table_name, std::string where_clause) { std::stringstream query; int limit = DEFAULT_LIMIT; @@ -161,7 +161,7 @@ std::string ctx::stats_db_handle_base::create_sql_peak_time(ctx::json filter, co return query.str(); } -std::string ctx::stats_db_handle_base::create_sql_common_setting(ctx::json filter, const char* table_name, std::string where_clause) +std::string ctx::stats_db_handle_base::create_sql_common_setting(ctx::Json filter, const char* table_name, std::string where_clause) { std::stringstream query; @@ -197,28 +197,28 @@ void ctx::stats_db_handle_base::on_insertion_result_received(unsigned int query_ delete this; } -void ctx::stats_db_handle_base::json_vector_to_array(std::vector &vec_json, ctx::json &json_result) +void ctx::stats_db_handle_base::json_vector_to_array(std::vector &vec_json, ctx::Json &json_result) { - std::vector::iterator json_vec_end = vec_json.end(); + std::vector::iterator json_vec_end = vec_json.end(); - for(std::vector::iterator json_vec_pos = vec_json.begin(); json_vec_pos != json_vec_end; ++json_vec_pos) { - json origin_j = *json_vec_pos; - json_result.array_append(NULL, STATS_QUERY_RESULT, origin_j); + for(std::vector::iterator json_vec_pos = vec_json.begin(); json_vec_pos != json_vec_end; ++json_vec_pos) { + Json origin_j = *json_vec_pos; + json_result.append(NULL, STATS_QUERY_RESULT, origin_j); } } -void ctx::stats_db_handle_base::on_query_result_received(unsigned int query_id, int error, std::vector& records) +void ctx::stats_db_handle_base::on_query_result_received(unsigned int query_id, int error, std::vector& records) { if (is_trigger_item) { if (records.size() == 1) { reply_trigger_item(error, records[0]); } else { _E("Invalid query result"); - json dummy; + Json dummy; context_manager::reply_to_read(req_subject.c_str(), req_filter, ERR_OPERATION_FAILED, dummy); } } else { - json results = "{\"" STATS_QUERY_RESULT "\":[]}"; + Json results = "{\"" STATS_QUERY_RESULT "\":[]}"; json_vector_to_array(records, results); context_manager::reply_to_read(req_subject.c_str(), req_filter, error, results); } diff --git a/src/statistics/shared/db_handle_base.h b/src/statistics/shared/db_handle_base.h index 6e05696..7c88380 100644 --- a/src/statistics/shared/db_handle_base.h +++ b/src/statistics/shared/db_handle_base.h @@ -18,7 +18,7 @@ #define __CONTEXT_STATS_DB_HANDLE_BASE_H__ #include -#include +#include #include namespace ctx { @@ -26,25 +26,25 @@ namespace ctx { protected: bool is_trigger_item; std::string req_subject; - ctx::json req_filter; + ctx::Json req_filter; stats_db_handle_base(); ~stats_db_handle_base(); - std::string create_where_clause(ctx::json filter); - std::string create_sql_peak_time(ctx::json filter, const char* table_name, std::string where_clause); - std::string create_sql_common_setting(ctx::json filter, const char* table_name, std::string where_clause); + std::string create_where_clause(ctx::Json filter); + std::string create_sql_peak_time(ctx::Json filter, const char* table_name, std::string where_clause); + std::string create_sql_common_setting(ctx::Json filter, const char* table_name, std::string where_clause); - bool execute_query(const char* subject, ctx::json filter, const char* query); - virtual void reply_trigger_item(int error, ctx::json &json_result) = 0; + bool execute_query(const char* subject, ctx::Json filter, const char* query); + virtual void reply_trigger_item(int error, ctx::Json &json_result) = 0; static int generate_qid(); private: - void json_vector_to_array(std::vector &vec_json, ctx::json &json_result); + void json_vector_to_array(std::vector &vec_json, ctx::Json &json_result); void on_creation_result_received(unsigned int query_id, int error); void on_insertion_result_received(unsigned int query_id, int error, int64_t row_id); - void on_query_result_received(unsigned int query_id, int error, std::vector& records); + void on_query_result_received(unsigned int query_id, int error, std::vector& records); }; } diff --git a/src/statistics/social/db_handle.cpp b/src/statistics/social/db_handle.cpp index e6a1a01..a42e625 100644 --- a/src/statistics/social/db_handle.cpp +++ b/src/statistics/social/db_handle.cpp @@ -30,7 +30,7 @@ ctx::social_db_handle::~social_db_handle() { } -int ctx::social_db_handle::read(const char* subject, ctx::json filter) +int ctx::social_db_handle::read(const char* subject, ctx::Json filter) { std::string query; @@ -50,7 +50,7 @@ int ctx::social_db_handle::read(const char* subject, ctx::json filter) return ERR_NONE; } -std::string ctx::social_db_handle::create_where_clause(ctx::json filter) +std::string ctx::social_db_handle::create_where_clause(ctx::Json filter) { std::stringstream where_clause; int comm_type = -1; @@ -77,7 +77,7 @@ std::string ctx::social_db_handle::create_where_clause(ctx::json filter) return where_clause.str(); } -std::string ctx::social_db_handle::create_sql_freq_address(ctx::json filter) +std::string ctx::social_db_handle::create_sql_freq_address(ctx::Json filter) { std::stringstream query; int limit = DEFAULT_LIMIT; @@ -98,9 +98,9 @@ std::string ctx::social_db_handle::create_sql_freq_address(ctx::json filter) return query.str(); } -std::string ctx::social_db_handle::create_sql_frequency(ctx::json filter) +std::string ctx::social_db_handle::create_sql_frequency(ctx::Json filter) { - ctx::json filter_cleaned; + ctx::Json filter_cleaned; std::string week_str; std::string time_of_day; std::string address; @@ -143,11 +143,11 @@ std::string ctx::social_db_handle::create_sql_frequency(ctx::json filter) return query.str(); } -void ctx::social_db_handle::reply_trigger_item(int error, ctx::json &json_result) +void ctx::social_db_handle::reply_trigger_item(int error, ctx::Json &json_result) { IF_FAIL_VOID_TAG(STR_EQ(req_subject.c_str(), SOCIAL_SUBJ_FREQUENCY), _E, "Invalid subject"); - ctx::json results; + ctx::Json results; std::string val_str; int val; diff --git a/src/statistics/social/db_handle.h b/src/statistics/social/db_handle.h index a8eecb1..1bf88fd 100644 --- a/src/statistics/social/db_handle.h +++ b/src/statistics/social/db_handle.h @@ -18,7 +18,7 @@ #define __CONTEXT_SOCIAL_DB_HANDLE_H__ #include -#include +#include #include "../shared/db_handle_base.h" namespace ctx { @@ -27,13 +27,13 @@ namespace ctx { social_db_handle(); ~social_db_handle(); - int read(const char* subject, ctx::json filter); + int read(const char* subject, ctx::Json filter); private: - std::string create_where_clause(ctx::json filter); - std::string create_sql_freq_address(ctx::json filter); - std::string create_sql_frequency(ctx::json filter); - void reply_trigger_item(int error, ctx::json &json_result); + std::string create_where_clause(ctx::Json filter); + std::string create_sql_freq_address(ctx::Json filter); + std::string create_sql_frequency(ctx::Json filter); + void reply_trigger_item(int error, ctx::Json &json_result); }; } diff --git a/src/statistics/social/log_aggregator.cpp b/src/statistics/social/log_aggregator.cpp index 2c4af98..309316f 100644 --- a/src/statistics/social/log_aggregator.cpp +++ b/src/statistics/social/log_aggregator.cpp @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include #include @@ -60,7 +60,7 @@ void ctx::contact_log_aggregator::aggregate_contact_log() " FROM " SOCIAL_TABLE_CONTACT_LOG, this); } -void ctx::contact_log_aggregator::on_query_result_received(unsigned int query_id, int error, std::vector& records) +void ctx::contact_log_aggregator::on_query_result_received(unsigned int query_id, int error, std::vector& records) { IF_FAIL_VOID_TAG(!records.empty(), _E, "Invalid query result"); @@ -131,7 +131,7 @@ void ctx::contact_log_aggregator::insert_contact_log_list(contacts_list_h list) contacts_list_get_current_record_p(list, &record); if (record == NULL) break; - ctx::json data; + ctx::Json data; char* address = NULL; int log_type; diff --git a/src/statistics/social/log_aggregator.h b/src/statistics/social/log_aggregator.h index 57c154f..e7aefb7 100644 --- a/src/statistics/social/log_aggregator.h +++ b/src/statistics/social/log_aggregator.h @@ -41,7 +41,7 @@ namespace ctx { void on_creation_result_received(unsigned int query_id, int error) {} void on_insertion_result_received(unsigned int query_id, int error, int64_t row_id) {} - void on_query_result_received(unsigned int query_id, int error, std::vector& records); + void on_query_result_received(unsigned int query_id, int error, std::vector& records); bool on_timer_expired(int timer_id, void* user_data); }; /* class phone_contact_log_aggregator */ diff --git a/src/statistics/social/social_stats_provider.cpp b/src/statistics/social/social_stats_provider.cpp index 92bb856..90aa35b 100644 --- a/src/statistics/social/social_stats_provider.cpp +++ b/src/statistics/social/social_stats_provider.cpp @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include "social_stats_provider.h" #include "db_handle.h" @@ -81,17 +81,17 @@ bool ctx::social_statistics_provider::init() return true; } -int ctx::social_statistics_provider::subscribe(const char* subject, ctx::json option, ctx::json* request_result) +int ctx::social_statistics_provider::subscribe(const char* subject, ctx::Json option, ctx::Json* request_result) { return ERR_NOT_SUPPORTED; } -int ctx::social_statistics_provider::unsubscribe(const char* subject, ctx::json option) +int ctx::social_statistics_provider::unsubscribe(const char* subject, ctx::Json option) { return ERR_NOT_SUPPORTED; } -int ctx::social_statistics_provider::read(const char* subject, ctx::json option, ctx::json* request_result) +int ctx::social_statistics_provider::read(const char* subject, ctx::Json option, ctx::Json* request_result) { ctx::social_db_handle *handle = new(std::nothrow) ctx::social_db_handle(); IF_FAIL_RETURN_TAG(handle, ERR_OPERATION_FAILED, _E, "Memory allocation failed"); @@ -105,7 +105,7 @@ int ctx::social_statistics_provider::read(const char* subject, ctx::json option, return ERR_NONE; } -int ctx::social_statistics_provider::write(const char* subject, ctx::json data, ctx::json* request_result) +int ctx::social_statistics_provider::write(const char* subject, ctx::Json data, ctx::Json* request_result) { return ERR_NOT_SUPPORTED; } diff --git a/src/statistics/social/social_stats_provider.h b/src/statistics/social/social_stats_provider.h index 64ab059..7ba803d 100644 --- a/src/statistics/social/social_stats_provider.h +++ b/src/statistics/social/social_stats_provider.h @@ -29,10 +29,10 @@ namespace ctx { static bool is_supported(const char *subject); static void submit_trigger_item(); - int subscribe(const char* subject, ctx::json option, ctx::json* request_result); - int unsubscribe(const char* subject, ctx::json option); - int read(const char* subject, ctx::json option, ctx::json* request_result); - int write(const char* subject, ctx::json data, ctx::json* request_result); + int subscribe(const char* subject, ctx::Json option, ctx::Json* request_result); + int unsubscribe(const char* subject, ctx::Json option); + int read(const char* subject, ctx::Json option, ctx::Json* request_result); + int write(const char* subject, ctx::Json data, ctx::Json* request_result); private: static social_statistics_provider *__instance;