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);
#include <context_mgr.h>
#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),
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();
return _owner;
}
-ctx::json ctx::custom_base::get_template()
+ctx::Json ctx::custom_base::get_template()
{
return _tmpl;
}
#ifndef _CUSTOM_BASE_H_
#define _CUSTOM_BASE_H_
-#include <json.h>
+#include <Json.h>
#include <provider_iface.h>
#include <types_internal.h>
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;
};
}
std::map<std::string, ctx::custom_base*> 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)
{
+ "(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<json> record;
+ std::vector<Json> record;
bool ret = db_manager::execute_sync(q.c_str(), &record);
IF_FAIL_RETURN_TAG(ret, false, _E, "Create template table failed");
IF_FAIL_RETURN(record.size() > 0, true);
int error;
- std::vector<json>::iterator vec_end = record.end();
- for (std::vector<json>::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) {
- ctx::json elem = *vec_pos;
+ std::vector<Json>::iterator vec_end = record.end();
+ for (std::vector<Json>::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) {
+ ctx::Json elem = *vec_pos;
std::string subject;
std::string name;
std::string attributes;
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);
}
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<std::string, ctx::custom_base*>::iterator it;
it = custom_map.find(subject);
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<json> record;
+ std::vector<Json> record;
bool ret = db_manager::execute_sync(q.c_str(), &record);
IF_FAIL_RETURN_TAG(ret, false, _E, "Failed to query custom templates");
}
// Remove item from custom template db
std::string q = "DELETE FROM context_trigger_custom_template WHERE subject = '" + subject + "'";
- std::vector<json> record;
+ std::vector<Json> record;
bool ret = db_manager::execute_sync(q.c_str(), &record);
IF_FAIL_RETURN_TAG(ret, false, _E, "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<std::string, ctx::custom_base*>::iterator it;
it = custom_map.find(subject);
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<std::string> keys;
- fact.get_keys(&keys);
+ fact.getKeys(&keys);
for (std::list<std::string>::iterator it = keys.begin(); it != keys.end(); it++) {
std::string key = *it;
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;
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;
}
{
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;
{
}
-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);
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;
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();
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();
#define __CONTEXT_DEVICE_PROVIDER_BASE_H__
#include <types_internal.h>
-#include <json.h>
+#include <Json.h>
#include <provider_iface.h>
#define CREATE_INSTANCE(prvd) \
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;
*/
#include <stdlib.h>
-#include <json.h>
+#include <Json.h>
#include <context_mgr.h>
#include "social_types.h"
#include "call.h"
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()
{
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;
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;
}
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++) {
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);
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);
}
* limitations under the License.
*/
-#include <json.h>
+#include <Json.h>
#include <context_mgr.h>
#include "social_types.h"
#include "message.h"
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");
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 {
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);
}
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);
{
_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;
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;
}
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))
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();
~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*/
typedef std::map<int, ref_count_array_s> ref_count_map_t;
typedef std::map<int, timer_state_s> timer_state_map_t;
- typedef std::set<ctx::json*> option_t;
+ typedef std::set<ctx::Json*> option_t;
ref_count_map_t ref_count_map;
timer_state_map_t timer_state_map;
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();
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;
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);
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);
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);
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;
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();
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");
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);
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);
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");
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);
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");
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);
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");
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);
_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:
{
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);
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);
}
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();
*/
#include <types_internal.h>
-#include <json.h>
+#include <Json.h>
#include <context_mgr.h>
#include "place_geofence_types.h"
#include "myplace_handle.h"
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));
#include <geofence_manager.h>
#include <types_internal.h>
-#include <json.h>
+#include <Json.h>
#include <context_mgr.h>
#include "place_geofence.h"
}
-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);
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);
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;
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();
};
_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<std::shared_ptr<ctx::Place>> 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.
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;
}
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;
#include "../place_recognition_types.h"
#include <db_mgr.h>
#include <sstream>
-#include <json.h>
+#include <Json.h>
#include "user_places_params.h"
#include "debug_utils.h"
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);
#include <sstream>
#include <types_internal.h>
#include <db_mgr.h>
-#include <json.h>
+#include <Json.h>
#include "similar.h"
#include "places_detector.h"
#include "place_categer.h"
return true;
}
-void ctx::PlacesDetector::on_query_result_received(unsigned int query_id, int error, std::vector<json>& records)
+void ctx::PlacesDetector::on_query_result_received(unsigned int query_id, int error, std::vector<Json>& records)
{
// TODO:
// The below "state machine" approach was choosen because it is not possible to use synchronized database queries in the main thread.
_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);
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);
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;
return visit;
}
-ctx::visits_t ctx::PlacesDetector::visits_from_jsons(std::vector<json>& records)
+ctx::visits_t ctx::PlacesDetector::visits_from_jsons(std::vector<Json>& 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);
}
return visits;
}
-std::shared_ptr<ctx::Place> ctx::PlacesDetector::place_from_json(json &row)
+std::shared_ptr<ctx::Place> ctx::PlacesDetector::place_from_json(Json &row)
{
std::shared_ptr<Place> place = std::make_shared<Place>();
{ // category
return place;
}
-std::vector<std::shared_ptr<ctx::Place>> ctx::PlacesDetector::places_from_jsons(std::vector<json>& records)
+std::vector<std::shared_ptr<ctx::Place>> ctx::PlacesDetector::places_from_jsons(std::vector<Json>& records)
{
std::vector<std::shared_ptr<Place>> places;
_D("db_result: number of all places: %d", records.size());
- for (json &row : records) {
+ for (Json &row : records) {
std::shared_ptr<Place> place = place_from_json(row);
places.push_back(place);
}
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);
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<json>& records);
- std::shared_ptr<ctx::Place> place_from_json(json &row);
- std::vector<std::shared_ptr<Place>> places_from_jsons(std::vector<json>& 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<Json>& records);
+ std::shared_ptr<ctx::Place> place_from_json(Json &row);
+ std::vector<std::shared_ptr<Place>> places_from_jsons(std::vector<Json>& records);
std::shared_ptr<graph_t> graph_from_visits(const std::vector<visit_s> &visits);
void db_create_table();
void db_delete_places();
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<json>& records);
+ void on_query_result_received(unsigned int query_id, int error, std::vector<Json>& records);
std::shared_ptr<components_t> merge_visits(const std::vector<visit_s> &visits);
std::vector<std::shared_ptr<Place>> get_places();
* ]
* }
*/
-ctx::json ctx::UserPlaces::compose_json(std::vector<std::shared_ptr<Place>> places)
+ctx::Json ctx::UserPlaces::compose_json(std::vector<std::shared_ptr<Place>> places)
{
- ctx::json data;
+ ctx::Json data;
for (std::shared_ptr<ctx::Place> 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);
}
place_j.set(NULL, PLACE_WIFI_APS, place->wifi_aps);
place_j.set(NULL, PLACE_CREATE_DATE, static_cast<int>(place->create_date));
- data.array_append(NULL, DATA_READ, place_j);
+ data.append(NULL, DATA_READ, place_j);
}
return data;
}
#include "places_detector.h"
#include <vector>
#include "user_places_types.h"
-#include <json.h>
+#include <Json.h>
namespace ctx {
void set_mode(place_recog_mode_e energy_mode);
std::vector<std::shared_ptr<Place>> get_places();
- static json compose_json(std::vector<std::shared_ptr<Place>> places);
+ static Json compose_json(std::vector<std::shared_ptr<Place>> places);
}; /* class UserPlaces */
#include <sstream>
#include <types_internal.h>
#include <db_mgr.h>
-#include <json.h>
+#include <Json.h>
#include "../place_recognition_types.h"
#include "visit_detector.h"
#include "user_places_params.h"
_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()) {
}
}
-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);
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);
#include <unordered_map>
#include <unordered_set>
#include "user_places_types.h"
-#include <json.h>
+#include <Json.h>
#include "visit_listener_iface.h"
#include "location_logger.h"
#include "location_listener_iface.h"
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);
#include <app_manager.h>
#include <db_mgr.h>
-#include <json.h>
+#include <Json.h>
#include <types_internal.h>
#include "../shared/system_info.h"
#include "app_stats_types.h"
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))
*/
#include <types_internal.h>
-#include <json.h>
+#include <Json.h>
#include <context_mgr.h>
#include "app_stats_provider.h"
#include "db_handle.h"
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");
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;
}
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;
{
}
-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;
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;
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;
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;
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;
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;
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;
#define __CONTEXT_APP_DB_HANDLE_H__
#include <string>
-#include <json.h>
+#include <Json.h>
#include "../shared/db_handle_base.h"
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);
};
}
*/
#include <sstream>
-#include <json.h>
+#include <Json.h>
#include <types_internal.h>
#include <db_mgr.h>
#include "app_stats_types.h"
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);
}
{
}
-void ctx::app_db_initializer::on_query_result_received(unsigned int query_id, int error, std::vector<json>& records)
+void ctx::app_db_initializer::on_query_result_received(unsigned int query_id, int error, std::vector<Json>& records)
{
if (query_id != EMPTY_CHECKER_QID) {
_E("Unknown Query ID: %d", query_id);
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<json>& records);
+ void on_query_result_received(unsigned int query_id, int error, std::vector<Json>& 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);
#include <sstream>
#include <glib.h>
-#include <json.h>
+#include <Json.h>
#include <types_internal.h>
#include <db_mgr.h>
#include "app_stats_types.h"
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) {
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<json>& records) {}
+ void on_query_result_received(unsigned int query_id, int error, std::vector<Json>& 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);
{
}
-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;
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;
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;
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);
#define __CONTEXT_MEDIA_DB_HANDLE_H__
#include <string>
-#include <json.h>
+#include <Json.h>
#include "../shared/db_handle_base.h"
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);
};
}
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<json>& records)
+void ctx::media_content_monitor::on_query_result_received(unsigned int query_id, int error, std::vector<Json>& records)
{
IF_FAIL_VOID(!records.empty());
{
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))
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<json>& records);
+ void on_query_result_received(unsigned int query_id, int error, std::vector<Json>& records);
static void on_media_content_db_updated(media_content_error_e error, int pid,
media_content_db_update_item_type_e update_item,
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");
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;
}
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;
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);
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;
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;
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;
delete this;
}
-void ctx::stats_db_handle_base::json_vector_to_array(std::vector<json> &vec_json, ctx::json &json_result)
+void ctx::stats_db_handle_base::json_vector_to_array(std::vector<Json> &vec_json, ctx::Json &json_result)
{
- std::vector<json>::iterator json_vec_end = vec_json.end();
+ std::vector<Json>::iterator json_vec_end = vec_json.end();
- for(std::vector<json>::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<Json>::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<json>& records)
+void ctx::stats_db_handle_base::on_query_result_received(unsigned int query_id, int error, std::vector<Json>& 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);
}
#define __CONTEXT_STATS_DB_HANDLE_BASE_H__
#include <string>
-#include <json.h>
+#include <Json.h>
#include <db_listener_iface.h>
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<json> &vec_json, ctx::json &json_result);
+ void json_vector_to_array(std::vector<Json> &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<json>& records);
+ void on_query_result_received(unsigned int query_id, int error, std::vector<Json>& records);
};
}
{
}
-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;
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;
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;
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;
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;
#define __CONTEXT_SOCIAL_DB_HANDLE_H__
#include <string>
-#include <json.h>
+#include <Json.h>
#include "../shared/db_handle_base.h"
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);
};
}
*/
#include <sstream>
-#include <json.h>
+#include <Json.h>
#include <db_mgr.h>
#include <timer_mgr.h>
#include <types_internal.h>
" FROM " SOCIAL_TABLE_CONTACT_LOG, this);
}
-void ctx::contact_log_aggregator::on_query_result_received(unsigned int query_id, int error, std::vector<json>& records)
+void ctx::contact_log_aggregator::on_query_result_received(unsigned int query_id, int error, std::vector<Json>& records)
{
IF_FAIL_VOID_TAG(!records.empty(), _E, "Invalid query result");
contacts_list_get_current_record_p(list, &record);
if (record == NULL) break;
- ctx::json data;
+ ctx::Json data;
char* address = NULL;
int log_type;
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<json>& records);
+ void on_query_result_received(unsigned int query_id, int error, std::vector<Json>& records);
bool on_timer_expired(int timer_id, void* user_data);
}; /* class phone_contact_log_aggregator */
*/
#include <types_internal.h>
-#include <json.h>
+#include <Json.h>
#include <context_mgr.h>
#include "social_stats_provider.h"
#include "db_handle.h"
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");
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;
}
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;