From: Somin Kim Date: Mon, 4 Apr 2016 04:21:59 +0000 (+0900) Subject: Apply Tizen C++ coding style based on context-common changes X-Git-Tag: submit/tizen/20160408.073002^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bb52ea000bf973bd227090af3f7f216d0bd4883a;p=platform%2Fcore%2Fcontext%2Fcontext-provider.git Apply Tizen C++ coding style based on context-common changes - ContextManager, IContextManager, ContextProviderBase(context_provider_iface) Change-Id: Icfbdfaaf570a98aba2115cb3c169722a3f01b7ab Signed-off-by: Somin Kim --- diff --git a/include/custom_context_provider.h b/include/custom_context_provider.h index 17c8cc4..918dfa6 100644 --- a/include/custom_context_provider.h +++ b/include/custom_context_provider.h @@ -21,11 +21,11 @@ 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 remove_item(std::string subject); - int publish_data(std::string subject, ctx::Json fact); + int addItem(std::string subject, std::string name, ctx::Json tmpl, const char* owner, bool is_init = false); + int removeItem(std::string subject); + int publishData(std::string subject, ctx::Json fact); - context_provider_iface* create(void* data); + ContextProviderBase* create(void* data); void destroy(void* data); } } diff --git a/src/custom/custom_base.cpp b/src/custom/custom_base.cpp index c5ac58d..4371202 100644 --- a/src/custom/custom_base.cpp +++ b/src/custom/custom_base.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include "custom_base.h" ctx::custom_base::custom_base(std::string subject, std::string name, ctx::Json tmpl, std::string owner) : @@ -36,16 +36,16 @@ bool ctx::custom_base::is_supported() void ctx::custom_base::submit_trigger_item() { - context_manager::register_trigger_item(_subject.c_str(), OPS_SUBSCRIBE | OPS_READ, + context_manager::registerTriggerItem(_subject.c_str(), OPS_SUBSCRIBE | OPS_READ, _tmpl.str(), NULL, _owner.c_str()); } void ctx::custom_base::unsubmit_trigger_item() { - context_manager::unregister_trigger_item(_subject.c_str()); + context_manager::unregisterTriggerItem(_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 *requestResult) { return ERR_NONE; @@ -56,14 +56,14 @@ 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 *requestResult) { ctx::Json data = latest.str(); - ctx::context_manager::reply_to_read(_subject.c_str(), NULL, ERR_NONE, data); + ctx::context_manager::replyToRead(_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 *requestResult) { return ERR_NONE; } diff --git a/src/custom/custom_base.h b/src/custom/custom_base.h index 0278e0f..68e45cc 100644 --- a/src/custom/custom_base.h +++ b/src/custom/custom_base.h @@ -18,20 +18,20 @@ #define _CUSTOM_BASE_H_ #include -#include +#include #include namespace ctx { - class custom_base : public context_provider_iface { + class custom_base : public ContextProviderBase { public: 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 subscribe(const char *subject, ctx::Json option, ctx::Json *requestResult); 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 read(const char *subject, ctx::Json option, ctx::Json *requestResult); + int write(const char *subject, ctx::Json data, ctx::Json *requestResult); static bool is_supported(); void submit_trigger_item(); diff --git a/src/custom/custom_context_provider.cpp b/src/custom/custom_context_provider.cpp index 29c9100..88aca00 100644 --- a/src/custom/custom_context_provider.cpp +++ b/src/custom/custom_context_provider.cpp @@ -17,8 +17,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include "custom_base.h" @@ -29,24 +29,24 @@ 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) +void registerProvider(const char *subject, const char *privilege) { - ctx::context_provider_info provider_info(ctx::custom_context_provider::create, + ctx::ContextProviderInfo providerInfo(ctx::custom_context_provider::create, ctx::custom_context_provider::destroy, const_cast(subject), privilege); - ctx::context_manager::register_provider(subject, provider_info); + ctx::context_manager::registerProvider(subject, providerInfo); custom_map[subject]->submit_trigger_item(); } -void unregister_provider(const char* subject) +void unregisterProvider(const char* subject) { custom_map[subject]->unsubmit_trigger_item(); - ctx::context_manager::unregister_provider(subject); + ctx::context_manager::unregisterProvider(subject); } -EXTAPI ctx::context_provider_iface* ctx::custom_context_provider::create(void *data) +EXTAPI ctx::ContextProviderBase* ctx::custom_context_provider::create(void *data) { - // Already created in add_item() function. Return corresponding custom provider + // Already created in addItem() function. Return corresponding custom provider return custom_map[static_cast(data)]; } @@ -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::addItem(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::addItem(std::string subject, std::string name, ctx::Json tmpl, const char* owner, bool is_init) { std::map::iterator it; it = custom_map.find(subject); @@ -116,7 +116,7 @@ EXTAPI int ctx::custom_context_provider::add_item(std::string subject, std::stri IF_FAIL_RETURN_TAG(custom, ERR_OUT_OF_MEMORY, _E, "Memory allocation failed"); custom_map[subject] = custom; - register_provider(custom->get_subject(), NULL); + registerProvider(custom->get_subject(), NULL); // Add item to custom template db if (!is_init) { @@ -130,13 +130,13 @@ EXTAPI int ctx::custom_context_provider::add_item(std::string subject, std::stri return ERR_NONE; } -EXTAPI int ctx::custom_context_provider::remove_item(std::string subject) +EXTAPI int ctx::custom_context_provider::removeItem(std::string subject) { std::map::iterator it; it = custom_map.find(subject); IF_FAIL_RETURN_TAG(it != custom_map.end(), ERR_NOT_SUPPORTED, _E, "%s not supported", subject.c_str()); - unregister_provider(subject.c_str()); + unregisterProvider(subject.c_str()); // Remove item from custom template db std::string q = "DELETE FROM context_trigger_custom_template WHERE subject = '" + subject + "'"; @@ -147,7 +147,7 @@ EXTAPI int ctx::custom_context_provider::remove_item(std::string subject) return ERR_NONE; } -EXTAPI int ctx::custom_context_provider::publish_data(std::string subject, ctx::Json fact) +EXTAPI int ctx::custom_context_provider::publishData(std::string subject, ctx::Json fact) { std::map::iterator it; it = custom_map.find(subject); diff --git a/src/device/activity/activity.h b/src/device/activity/activity.h index d0e0951..2f44267 100644 --- a/src/device/activity/activity.h +++ b/src/device/activity/activity.h @@ -23,7 +23,7 @@ #define GENERATE_ACTIVITY_PROVIDER(act_prvd, act_subj, act_type) \ class act_prvd : public user_activity_base { \ public: \ - static context_provider_iface *create(void *data) \ + static ContextProviderBase *create(void *data) \ { \ CREATE_INSTANCE(ctx::act_prvd); \ } \ @@ -37,7 +37,7 @@ } \ static void submit_trigger_item() \ { \ - context_manager::register_trigger_item((act_subj), OPS_SUBSCRIBE, \ + context_manager::registerTriggerItem((act_subj), OPS_SUBSCRIBE, \ "{\"Event\":{\"type\":\"string\", \"values\":[\"Detected\"]}}", \ "{\"Accuracy\":{\"type\":\"string\", \"values\":[\"Low\", \"Normal\", \"High\"]}}" \ ); \ diff --git a/src/device/activity/activity_base.cpp b/src/device/activity/activity_base.cpp index e0a9027..30201ca 100644 --- a/src/device/activity/activity_base.cpp +++ b/src/device/activity/activity_base.cpp @@ -15,7 +15,7 @@ */ #include -#include +#include #include "activity_types.h" #include "activity_base.h" @@ -44,25 +44,25 @@ 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; - data_read.set(NULL, USER_ACT_EVENT, USER_ACT_DETECTED); + ctx::Json dataRead; + dataRead.set(NULL, USER_ACT_EVENT, USER_ACT_DETECTED); activity_accuracy_e accuracy = ACTIVITY_ACCURACY_LOW; activity_get_accuracy(data, &accuracy); switch (accuracy) { case ACTIVITY_ACCURACY_HIGH: - data_read.set(NULL, USER_ACT_ACCURACY, USER_ACT_HIGH); + dataRead.set(NULL, USER_ACT_ACCURACY, USER_ACT_HIGH); break; case ACTIVITY_ACCURACY_MID: - data_read.set(NULL, USER_ACT_ACCURACY, USER_ACT_NORMAL); + dataRead.set(NULL, USER_ACT_ACCURACY, USER_ACT_NORMAL); break; default: - data_read.set(NULL, USER_ACT_ACCURACY, USER_ACT_LOW); + dataRead.set(NULL, USER_ACT_ACCURACY, USER_ACT_LOW); break; } - context_manager::publish(subject.c_str(), NULL, ERR_NONE, data_read); + context_manager::publish(subject.c_str(), NULL, ERR_NONE, dataRead); } int ctx::user_activity_base::subscribe() diff --git a/src/device/activity/activity_base.h b/src/device/activity/activity_base.h index 45fcc8d..05fa503 100644 --- a/src/device/activity/activity_base.h +++ b/src/device/activity/activity_base.h @@ -19,7 +19,7 @@ #include #include -#include "../provider_base.h" +#include "../device_provider_base.h" namespace ctx { diff --git a/src/device/device_context_provider.cpp b/src/device/device_context_provider.cpp index be6d911..39fcf7d 100644 --- a/src/device/device_context_provider.cpp +++ b/src/device/device_context_provider.cpp @@ -15,8 +15,8 @@ */ #include -#include -#include +#include +#include #include #include "system/system_types.h" @@ -65,40 +65,40 @@ #define PRIV_CONTACT "contact.read" template -void register_provider(const char *subject, const char *privilege) +void registerProvider(const char *subject, const char *privilege) { if (!provider::is_supported()) return; - ctx::context_provider_info provider_info(provider::create, provider::destroy, NULL, privilege); - ctx::context_manager::register_provider(subject, provider_info); + ctx::ContextProviderInfo providerInfo(provider::create, provider::destroy, NULL, privilege); + ctx::context_manager::registerProvider(subject, providerInfo); provider::submit_trigger_item(); } EXTAPI bool ctx::init_device_context_provider() { - register_provider(DEVICE_ST_SUBJ_ALARM, NULL); - register_provider(DEVICE_ST_SUBJ_TIME, NULL); + registerProvider(DEVICE_ST_SUBJ_ALARM, NULL); + registerProvider(DEVICE_ST_SUBJ_TIME, NULL); #ifdef _MOBILE_ - register_provider(DEVICE_ST_SUBJ_WIFI, PRIV_NETWORK); - register_provider(DEVICE_ST_SUBJ_HEADPHONE, NULL); + registerProvider(DEVICE_ST_SUBJ_WIFI, PRIV_NETWORK); + registerProvider(DEVICE_ST_SUBJ_HEADPHONE, NULL); - register_provider(DEVICE_ST_SUBJ_CHARGER, NULL); - register_provider(DEVICE_ST_SUBJ_GPS, NULL); - register_provider(DEVICE_ST_SUBJ_USB, NULL); - register_provider(DEVICE_ST_SUBJ_BATTERY, NULL); - register_provider(DEVICE_ST_SUBJ_PSMODE, NULL); + registerProvider(DEVICE_ST_SUBJ_CHARGER, NULL); + registerProvider(DEVICE_ST_SUBJ_GPS, NULL); + registerProvider(DEVICE_ST_SUBJ_USB, NULL); + registerProvider(DEVICE_ST_SUBJ_BATTERY, NULL); + registerProvider(DEVICE_ST_SUBJ_PSMODE, NULL); - register_provider(SOCIAL_ST_SUBJ_CALL, PRIV_TELEPHONY); - register_provider(SOCIAL_ST_SUBJ_EMAIL, NULL); - register_provider(SOCIAL_ST_SUBJ_MESSAGE, PRIV_MESSAGE); - register_provider(SOCIAL_ST_SUBJ_CONTACTS, PRIV_CONTACT); + registerProvider(SOCIAL_ST_SUBJ_CALL, PRIV_TELEPHONY); + registerProvider(SOCIAL_ST_SUBJ_EMAIL, NULL); + registerProvider(SOCIAL_ST_SUBJ_MESSAGE, PRIV_MESSAGE); + registerProvider(SOCIAL_ST_SUBJ_CONTACTS, PRIV_CONTACT); - register_provider(USER_ACT_SUBJ_STATIONARY, NULL); - register_provider(USER_ACT_SUBJ_WALKING, NULL); - register_provider(USER_ACT_SUBJ_RUNNING, NULL); - register_provider(USER_ACT_SUBJ_IN_VEHICLE, NULL); + registerProvider(USER_ACT_SUBJ_STATIONARY, NULL); + registerProvider(USER_ACT_SUBJ_WALKING, NULL); + registerProvider(USER_ACT_SUBJ_RUNNING, NULL); + registerProvider(USER_ACT_SUBJ_IN_VEHICLE, NULL); /* Create context providers, which need to be initiated before being subscribed */ if (device_status_wifi::is_supported()) @@ -106,22 +106,22 @@ EXTAPI bool ctx::init_device_context_provider() #endif #ifdef _WEARABLE_ - register_provider(DEVICE_ST_SUBJ_WIFI, PRIV_NETWORK); - register_provider(DEVICE_ST_SUBJ_HEADPHONE, NULL); + registerProvider(DEVICE_ST_SUBJ_WIFI, PRIV_NETWORK); + registerProvider(DEVICE_ST_SUBJ_HEADPHONE, NULL); - register_provider(DEVICE_ST_SUBJ_CHARGER, NULL); - register_provider(DEVICE_ST_SUBJ_GPS, NULL); - register_provider(DEVICE_ST_SUBJ_USB, NULL); - register_provider(DEVICE_ST_SUBJ_BATTERY, NULL); - register_provider(DEVICE_ST_SUBJ_PSMODE, NULL); + registerProvider(DEVICE_ST_SUBJ_CHARGER, NULL); + registerProvider(DEVICE_ST_SUBJ_GPS, NULL); + registerProvider(DEVICE_ST_SUBJ_USB, NULL); + registerProvider(DEVICE_ST_SUBJ_BATTERY, NULL); + registerProvider(DEVICE_ST_SUBJ_PSMODE, NULL); - register_provider(SOCIAL_ST_SUBJ_CALL, PRIV_TELEPHONY); - register_provider(SOCIAL_ST_SUBJ_MESSAGE, PRIV_MESSAGE); + registerProvider(SOCIAL_ST_SUBJ_CALL, PRIV_TELEPHONY); + registerProvider(SOCIAL_ST_SUBJ_MESSAGE, PRIV_MESSAGE); - register_provider(USER_ACT_SUBJ_STATIONARY, NULL); - register_provider(USER_ACT_SUBJ_WALKING, NULL); - register_provider(USER_ACT_SUBJ_RUNNING, NULL); - register_provider(USER_ACT_SUBJ_IN_VEHICLE, NULL); + registerProvider(USER_ACT_SUBJ_STATIONARY, NULL); + registerProvider(USER_ACT_SUBJ_WALKING, NULL); + registerProvider(USER_ACT_SUBJ_RUNNING, NULL); + registerProvider(USER_ACT_SUBJ_IN_VEHICLE, NULL); /* Create context providers, which need to be initiated before being subscribed */ if (device_status_wifi::is_supported()) @@ -129,8 +129,8 @@ EXTAPI bool ctx::init_device_context_provider() #endif #ifdef _TV_ - register_provider(DEVICE_ST_SUBJ_WIFI, PRIV_NETWORK); - register_provider(DEVICE_ST_SUBJ_HEADPHONE, NULL); + registerProvider(DEVICE_ST_SUBJ_WIFI, PRIV_NETWORK); + registerProvider(DEVICE_ST_SUBJ_HEADPHONE, NULL); /* Create context providers, which need to be initiated before being subscribed */ if (device_status_wifi::is_supported()) diff --git a/src/device/device_provider_base.cpp b/src/device/device_provider_base.cpp new file mode 100644 index 0000000..95f3988 --- /dev/null +++ b/src/device/device_provider_base.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "device_provider_base.h" + +ctx::device_provider_base::device_provider_base() + : being_subscribed(false) +{ +} + +int ctx::device_provider_base::subscribe(const char *subject, ctx::Json option, ctx::Json *requestResult) +{ + IF_FAIL_RETURN(!being_subscribed, ERR_NONE); + + int ret = subscribe(); + + if (ret == ERR_NONE) + being_subscribed = true; + else + destroy_self(); + + return ret; +} + +int ctx::device_provider_base::unsubscribe(const char *subject, ctx::Json option) +{ + int ret = ERR_NONE; + + if (being_subscribed) + ret = unsubscribe(); + + destroy_self(); + return ret; +} + +int ctx::device_provider_base::read(const char *subject, ctx::Json option, ctx::Json *requestResult) +{ + int ret = read(); + + if (!being_subscribed) + destroy_self(); + + return ret; +} + +int ctx::device_provider_base::write(const char *subject, ctx::Json data, ctx::Json *requestResult) +{ + int ret = write(); + + if (!being_subscribed) + destroy_self(); + + return ret; +} + +int ctx::device_provider_base::subscribe() +{ + return ERR_NOT_SUPPORTED; +} + +int ctx::device_provider_base::unsubscribe() +{ + return ERR_NOT_SUPPORTED; +} + +int ctx::device_provider_base::read() +{ + return ERR_NOT_SUPPORTED; +} + +int ctx::device_provider_base::write() +{ + return ERR_NOT_SUPPORTED; +} + +bool ctx::device_provider_base::get_system_info_bool(const char *key) +{ + bool supported = false; + int ret = system_info_get_platform_bool(key, &supported); + IF_FAIL_RETURN_TAG(ret == SYSTEM_INFO_ERROR_NONE, false, _E, "system_info_get_platform_bool() failed"); + return supported; +} diff --git a/src/device/device_provider_base.h b/src/device/device_provider_base.h new file mode 100644 index 0000000..6b2c1a9 --- /dev/null +++ b/src/device/device_provider_base.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CONTEXT_DEVICE_PROVIDER_BASE_H__ +#define __CONTEXT_DEVICE_PROVIDER_BASE_H__ + +#include +#include +#include + +#define CREATE_INSTANCE(prvd) \ + do { \ + IF_FAIL_RETURN(!__instance, __instance); \ + __instance = new(std::nothrow) prvd(); \ + IF_FAIL_RETURN_TAG(__instance, NULL, _E, "Memory allocation failed"); \ + _I(BLUE("Created")); \ + return __instance; \ + } while (0) \ + +#define DESTROY_INSTANCE() \ + do { \ + IF_FAIL_VOID(__instance); \ + delete __instance; \ + __instance = NULL; \ + _I(BLUE("Destroyed")); \ + } while (0) \ + +#define GENERATE_PROVIDER_COMMON_DECL(prvd) \ + public: \ + static ContextProviderBase *create(void *data); \ + static void destroy(void *data); \ + protected: \ + void destroy_self(); \ + private: \ + static prvd *__instance; \ + +#define GENERATE_PROVIDER_COMMON_IMPL(prvd) \ + ctx::prvd *ctx::prvd::__instance = NULL; \ + ctx::ContextProviderBase *ctx::prvd::create(void *data) \ + { \ + CREATE_INSTANCE(prvd); \ + } \ + void ctx::prvd::destroy(void *data) \ + { \ + DESTROY_INSTANCE(); \ + } \ + void ctx::prvd::destroy_self() \ + { \ + destroy(NULL); \ + } \ + +namespace ctx { + + class device_provider_base : public ContextProviderBase { + public: + int subscribe(const char *subject, ctx::Json option, ctx::Json *requestResult); + int unsubscribe(const char *subject, ctx::Json option); + int read(const char *subject, ctx::Json option, ctx::Json *requestResult); + int write(const char *subject, ctx::Json data, ctx::Json *requestResult); + + protected: + bool being_subscribed; + + device_provider_base(); + virtual ~device_provider_base() {} + + virtual int subscribe(); + virtual int unsubscribe(); + virtual int read(); + virtual int write(); + virtual void destroy_self() = 0; + + static bool get_system_info_bool(const char *key); + }; +} + +#endif diff --git a/src/device/provider_base.cpp b/src/device/provider_base.cpp deleted file mode 100644 index fefe212..0000000 --- a/src/device/provider_base.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "provider_base.h" - -ctx::device_provider_base::device_provider_base() - : being_subscribed(false) -{ -} - -int ctx::device_provider_base::subscribe(const char *subject, ctx::Json option, ctx::Json *request_result) -{ - IF_FAIL_RETURN(!being_subscribed, ERR_NONE); - - int ret = subscribe(); - - if (ret == ERR_NONE) - being_subscribed = true; - else - destroy_self(); - - return ret; -} - -int ctx::device_provider_base::unsubscribe(const char *subject, ctx::Json option) -{ - int ret = ERR_NONE; - - if (being_subscribed) - ret = unsubscribe(); - - destroy_self(); - return ret; -} - -int ctx::device_provider_base::read(const char *subject, ctx::Json option, ctx::Json *request_result) -{ - int ret = read(); - - if (!being_subscribed) - destroy_self(); - - return ret; -} - -int ctx::device_provider_base::write(const char *subject, ctx::Json data, ctx::Json *request_result) -{ - int ret = write(); - - if (!being_subscribed) - destroy_self(); - - return ret; -} - -int ctx::device_provider_base::subscribe() -{ - return ERR_NOT_SUPPORTED; -} - -int ctx::device_provider_base::unsubscribe() -{ - return ERR_NOT_SUPPORTED; -} - -int ctx::device_provider_base::read() -{ - return ERR_NOT_SUPPORTED; -} - -int ctx::device_provider_base::write() -{ - return ERR_NOT_SUPPORTED; -} - -bool ctx::device_provider_base::get_system_info_bool(const char *key) -{ - bool supported = false; - int ret = system_info_get_platform_bool(key, &supported); - IF_FAIL_RETURN_TAG(ret == SYSTEM_INFO_ERROR_NONE, false, _E, "system_info_get_platform_bool() failed"); - return supported; -} diff --git a/src/device/provider_base.h b/src/device/provider_base.h deleted file mode 100644 index 39983b1..0000000 --- a/src/device/provider_base.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __CONTEXT_DEVICE_PROVIDER_BASE_H__ -#define __CONTEXT_DEVICE_PROVIDER_BASE_H__ - -#include -#include -#include - -#define CREATE_INSTANCE(prvd) \ - do { \ - IF_FAIL_RETURN(!__instance, __instance); \ - __instance = new(std::nothrow) prvd(); \ - IF_FAIL_RETURN_TAG(__instance, NULL, _E, "Memory allocation failed"); \ - _I(BLUE("Created")); \ - return __instance; \ - } while (0) \ - -#define DESTROY_INSTANCE() \ - do { \ - IF_FAIL_VOID(__instance); \ - delete __instance; \ - __instance = NULL; \ - _I(BLUE("Destroyed")); \ - } while (0) \ - -#define GENERATE_PROVIDER_COMMON_DECL(prvd) \ - public: \ - static context_provider_iface *create(void *data); \ - static void destroy(void *data); \ - protected: \ - void destroy_self(); \ - private: \ - static prvd *__instance; \ - -#define GENERATE_PROVIDER_COMMON_IMPL(prvd) \ - ctx::prvd *ctx::prvd::__instance = NULL; \ - ctx::context_provider_iface *ctx::prvd::create(void *data) \ - { \ - CREATE_INSTANCE(prvd); \ - } \ - void ctx::prvd::destroy(void *data) \ - { \ - DESTROY_INSTANCE(); \ - } \ - void ctx::prvd::destroy_self() \ - { \ - destroy(NULL); \ - } \ - -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); - - protected: - bool being_subscribed; - - device_provider_base(); - virtual ~device_provider_base() {} - - virtual int subscribe(); - virtual int unsubscribe(); - virtual int read(); - virtual int write(); - virtual void destroy_self() = 0; - - static bool get_system_info_bool(const char *key); - }; -} - -#endif diff --git a/src/device/social/call.cpp b/src/device/social/call.cpp index 745442c..71e3ea8 100644 --- a/src/device/social/call.cpp +++ b/src/device/social/call.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include "social_types.h" #include "call.h" @@ -57,7 +57,7 @@ bool ctx::social_status_call::is_supported() void ctx::social_status_call::submit_trigger_item() { - context_manager::register_trigger_item(SOCIAL_ST_SUBJ_CALL, OPS_SUBSCRIBE | OPS_READ, + context_manager::registerTriggerItem(SOCIAL_ST_SUBJ_CALL, OPS_SUBSCRIBE | OPS_READ, "{" "\"Medium\":{\"type\":\"string\",\"values\":[\"Voice\",\"Video\"]}," "\"State\":{\"type\":\"string\",\"values\":[\"Idle\",\"Connecting\",\"Connected\"]}," @@ -381,7 +381,7 @@ int ctx::social_status_call::read() release_telephony(); if (ret) { - ctx::context_manager::reply_to_read(SOCIAL_ST_SUBJ_CALL, NULL, ERR_NONE, data); + ctx::context_manager::replyToRead(SOCIAL_ST_SUBJ_CALL, NULL, ERR_NONE, data); return ERR_NONE; } diff --git a/src/device/social/call.h b/src/device/social/call.h index cdd906c..f320f5c 100644 --- a/src/device/social/call.h +++ b/src/device/social/call.h @@ -18,7 +18,7 @@ #define _CONTEXT_SOCIAL_STATUS_CALL_H_ #include -#include "../provider_base.h" +#include "../device_provider_base.h" namespace ctx { diff --git a/src/device/social/contacts.cpp b/src/device/social/contacts.cpp index c7ee6e3..f071e78 100644 --- a/src/device/social/contacts.cpp +++ b/src/device/social/contacts.cpp @@ -15,7 +15,7 @@ */ #include -#include +#include #include "social_types.h" #include "contacts.h" @@ -42,7 +42,7 @@ bool ctx::social_status_contacts::is_supported() void ctx::social_status_contacts::submit_trigger_item() { - context_manager::register_trigger_item(SOCIAL_ST_SUBJ_CONTACTS, OPS_SUBSCRIBE, + context_manager::registerTriggerItem(SOCIAL_ST_SUBJ_CONTACTS, OPS_SUBSCRIBE, "{" "\"Event\":{\"type\":\"string\",\"values\":[\"Changed\"]}," "\"Type\":{\"type\":\"string\",\"values\":[\"MyProfile\",\"Person\"]}" diff --git a/src/device/social/contacts.h b/src/device/social/contacts.h index 52adb14..1169412 100644 --- a/src/device/social/contacts.h +++ b/src/device/social/contacts.h @@ -18,7 +18,7 @@ #define _CONTEXT_SOCIAL_STATUS_CONTACTS_H_ #include -#include "../provider_base.h" +#include "../device_provider_base.h" namespace ctx { diff --git a/src/device/social/email.cpp b/src/device/social/email.cpp index 831a963..898cf03 100644 --- a/src/device/social/email.cpp +++ b/src/device/social/email.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include "social_types.h" #include "email.h" @@ -40,7 +40,7 @@ bool ctx::social_status_email::is_supported() void ctx::social_status_email::submit_trigger_item() { - context_manager::register_trigger_item(SOCIAL_ST_SUBJ_EMAIL, OPS_SUBSCRIBE, + context_manager::registerTriggerItem(SOCIAL_ST_SUBJ_EMAIL, OPS_SUBSCRIBE, "{" "\"Event\":{\"type\":\"string\",\"values\":[\"Received\",\"Sent\"]}" "}", @@ -60,15 +60,15 @@ 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; - data_updated.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_RECEIVED); - context_manager::publish(SOCIAL_ST_SUBJ_EMAIL, NULL, ERR_NONE, data_updated); + ctx::Json dataUpdated; + dataUpdated.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_RECEIVED); + context_manager::publish(SOCIAL_ST_SUBJ_EMAIL, NULL, ERR_NONE, dataUpdated); } 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; - data_updated.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_SENT); - context_manager::publish(SOCIAL_ST_SUBJ_EMAIL, NULL, ERR_NONE, data_updated); + ctx::Json dataUpdated; + dataUpdated.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_SENT); + context_manager::publish(SOCIAL_ST_SUBJ_EMAIL, NULL, ERR_NONE, dataUpdated); } } diff --git a/src/device/social/email.h b/src/device/social/email.h index 930da24..9cc7508 100644 --- a/src/device/social/email.h +++ b/src/device/social/email.h @@ -18,7 +18,7 @@ #define _CONTEXT_SOCIAL_STATUS_EMAIL_H_ #include -#include "../provider_base.h" +#include "../device_provider_base.h" namespace ctx { diff --git a/src/device/social/message.cpp b/src/device/social/message.cpp index 4d46fe9..cf75e4f 100644 --- a/src/device/social/message.cpp +++ b/src/device/social/message.cpp @@ -15,7 +15,7 @@ */ #include -#include +#include #include "social_types.h" #include "message.h" @@ -39,7 +39,7 @@ bool ctx::social_status_message::is_supported() void ctx::social_status_message::submit_trigger_item() { - context_manager::register_trigger_item(SOCIAL_ST_SUBJ_MESSAGE, OPS_SUBSCRIBE, + context_manager::registerTriggerItem(SOCIAL_ST_SUBJ_MESSAGE, OPS_SUBSCRIBE, "{" "\"Event\":{\"type\":\"string\",\"values\":[\"Received\"]}," "\"Type\":{\"type\":\"string\",\"values\":[\"SMS\",\"MMS\"]}," diff --git a/src/device/social/message.h b/src/device/social/message.h index 1c1d15b..5239f21 100644 --- a/src/device/social/message.h +++ b/src/device/social/message.h @@ -19,7 +19,7 @@ #include #include -#include "../provider_base.h" +#include "../device_provider_base.h" namespace ctx { diff --git a/src/device/system/alarm.cpp b/src/device/system/alarm.cpp index d1c6f26..d4434a9 100644 --- a/src/device/system/alarm.cpp +++ b/src/device/system/alarm.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include "system_types.h" #include "alarm.h" @@ -41,7 +41,7 @@ bool ctx::device_status_alarm::is_supported() void ctx::device_status_alarm::submit_trigger_item() { - context_manager::register_trigger_item(DEVICE_ST_SUBJ_ALARM, OPS_SUBSCRIBE, + context_manager::registerTriggerItem(DEVICE_ST_SUBJ_ALARM, OPS_SUBSCRIBE, "{" "\"TimeOfDay\":{\"type\":\"integer\",\"min\":0,\"max\":1439}," "\"DayOfWeek\":{\"type\":\"string\",\"values\":[\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\",\"Sun\",\"Weekday\",\"Weekend\"]}" @@ -49,7 +49,7 @@ 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 *requestResult) { int ret = subscribe(option); destroy_if_unused(); @@ -63,13 +63,13 @@ int ctx::device_status_alarm::unsubscribe(const char *subject, ctx::Json option) 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 *requestResult) { 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 *requestResult) { destroy_if_unused(); return ERR_NOT_SUPPORTED; @@ -250,16 +250,16 @@ 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 dataRead; int result_time = hour * 60 + min; std::string result_day = ctx::TimerManager::dowToStr(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); + dataRead.set(NULL, DEVICE_ST_TIME_OF_DAY, result_time); + dataRead.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); if (is_matched(option, result_time, result_day)) { - context_manager::publish(DEVICE_ST_SUBJ_ALARM, option, ERR_NONE, data_read); + context_manager::publish(DEVICE_ST_SUBJ_ALARM, option, ERR_NONE, dataRead); } } } diff --git a/src/device/system/alarm.h b/src/device/system/alarm.h index 8d640e3..ff5271b 100644 --- a/src/device/system/alarm.h +++ b/src/device/system/alarm.h @@ -19,21 +19,21 @@ #include #include -#include +#include #include -#include "../provider_base.h" +#include "../device_provider_base.h" namespace ctx { - class device_status_alarm : public context_provider_iface, ITimerListener { + class device_status_alarm : public ContextProviderBase, ITimerListener { GENERATE_PROVIDER_COMMON_DECL(device_status_alarm); public: - int subscribe(const char *subject, ctx::Json option, ctx::Json *request_result); + int subscribe(const char *subject, ctx::Json option, ctx::Json *requestResult); 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 read(const char *subject, ctx::Json option, ctx::Json *requestResult); + int write(const char *subject, ctx::Json data, ctx::Json *requestResult); int subscribe(ctx::Json option); int unsubscribe(ctx::Json option); diff --git a/src/device/system/battery.cpp b/src/device/system/battery.cpp index 5be24b6..6207db9 100644 --- a/src/device/system/battery.cpp +++ b/src/device/system/battery.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include "system_types.h" #include "battery.h" @@ -35,7 +35,7 @@ bool ctx::device_status_battery::is_supported() void ctx::device_status_battery::submit_trigger_item() { - context_manager::register_trigger_item(DEVICE_ST_SUBJ_BATTERY, OPS_SUBSCRIBE | OPS_READ, + context_manager::registerTriggerItem(DEVICE_ST_SUBJ_BATTERY, OPS_SUBSCRIBE | OPS_READ, "{" "\"Level\":{\"type\":\"string\",\"values\":[\"Empty\",\"Critical\",\"Low\",\"Normal\",\"High\",\"Full\"]}," TRIG_BOOL_ITEM_DEF("IsCharging") @@ -58,15 +58,15 @@ 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; - data_read.set(NULL, DEVICE_ST_LEVEL, level_string); + ctx::Json dataRead; + dataRead.set(NULL, DEVICE_ST_LEVEL, level_string); bool charging_state = false; int ret = device_battery_is_charging(&charging_state); IF_FAIL_VOID_TAG(ret == DEVICE_ERROR_NONE, _E, "Getting state failed"); - data_read.set(NULL, DEVICE_ST_IS_CHARGING, charging_state ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); - ctx::context_manager::publish(DEVICE_ST_SUBJ_BATTERY, NULL, ERR_NONE, data_read); + dataRead.set(NULL, DEVICE_ST_IS_CHARGING, charging_state ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); + ctx::context_manager::publish(DEVICE_ST_SUBJ_BATTERY, NULL, ERR_NONE, dataRead); } const char* ctx::device_status_battery::trans_to_string(intptr_t level) @@ -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 dataRead; int ret = device_battery_get_level_status(&level); IF_FAIL_RETURN(ret == DEVICE_ERROR_NONE, ERR_OPERATION_FAILED); @@ -128,14 +128,14 @@ int ctx::device_status_battery::read() const char* level_string = trans_to_string(level); IF_FAIL_RETURN(level_string, ERR_OPERATION_FAILED); - data_read.set(NULL, DEVICE_ST_LEVEL, level_string); + dataRead.set(NULL, DEVICE_ST_LEVEL, level_string); bool charging_state = false; ret = device_battery_is_charging(&charging_state); IF_FAIL_RETURN(ret == DEVICE_ERROR_NONE, ERR_OPERATION_FAILED); - data_read.set(NULL, DEVICE_ST_IS_CHARGING, charging_state ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); + dataRead.set(NULL, DEVICE_ST_IS_CHARGING, charging_state ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); - ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_BATTERY, NULL, ERR_NONE, data_read); + ctx::context_manager::replyToRead(DEVICE_ST_SUBJ_BATTERY, NULL, ERR_NONE, dataRead); return ERR_NONE; } diff --git a/src/device/system/battery.h b/src/device/system/battery.h index 6fc3fdf..8f8a723 100644 --- a/src/device/system/battery.h +++ b/src/device/system/battery.h @@ -19,7 +19,7 @@ #include #include -#include "../provider_base.h" +#include "../device_provider_base.h" namespace ctx { diff --git a/src/device/system/headphone.cpp b/src/device/system/headphone.cpp index ac3d5db..91e1708 100644 --- a/src/device/system/headphone.cpp +++ b/src/device/system/headphone.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include "system_types.h" #include "headphone.h" @@ -44,7 +44,7 @@ bool ctx::device_status_headphone::is_supported() void ctx::device_status_headphone::submit_trigger_item() { - context_manager::register_trigger_item(DEVICE_ST_SUBJ_HEADPHONE, OPS_SUBSCRIBE | OPS_READ, + context_manager::registerTriggerItem(DEVICE_ST_SUBJ_HEADPHONE, OPS_SUBSCRIBE | OPS_READ, "{" TRIG_BOOL_ITEM_DEF("IsConnected") "," "\"Type\":{\"type\":\"string\",\"values\":[\"Normal\",\"Headset\",\"Bluetooth\"]}" @@ -81,7 +81,7 @@ int ctx::device_status_headphone::read() Json data; generate_data_packet(data); - ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_HEADPHONE, NULL, ERR_NONE, data); + ctx::context_manager::replyToRead(DEVICE_ST_SUBJ_HEADPHONE, NULL, ERR_NONE, data); return ERR_NONE; } diff --git a/src/device/system/headphone.h b/src/device/system/headphone.h index f451d52..8922a61 100644 --- a/src/device/system/headphone.h +++ b/src/device/system/headphone.h @@ -20,7 +20,7 @@ #include #include #include -#include "../provider_base.h" +#include "../device_provider_base.h" namespace ctx { diff --git a/src/device/system/psmode.cpp b/src/device/system/psmode.cpp index dcfc359..dc39f98 100644 --- a/src/device/system/psmode.cpp +++ b/src/device/system/psmode.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include "system_types.h" #include "psmode.h" @@ -35,7 +35,7 @@ bool ctx::device_status_psmode::is_supported() void ctx::device_status_psmode::submit_trigger_item() { - context_manager::register_trigger_item(DEVICE_ST_SUBJ_PSMODE, OPS_SUBSCRIBE | OPS_READ, + context_manager::registerTriggerItem(DEVICE_ST_SUBJ_PSMODE, OPS_SUBSCRIBE | OPS_READ, "{" TRIG_BOOL_ITEM_DEF("IsEnabled") "}", NULL); } @@ -48,14 +48,14 @@ 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 dataRead; status = vconf_keynode_get_int(node); IF_FAIL_VOID_TAG(status >= 0, _E, "Getting state failed"); - data_read.set(NULL, DEVICE_ST_IS_ENABLED, status == 0 ? DEVICE_ST_FALSE : DEVICE_ST_TRUE); + dataRead.set(NULL, DEVICE_ST_IS_ENABLED, status == 0 ? DEVICE_ST_FALSE : DEVICE_ST_TRUE); - context_manager::publish(DEVICE_ST_SUBJ_PSMODE, NULL, ERR_NONE, data_read); + context_manager::publish(DEVICE_ST_SUBJ_PSMODE, NULL, ERR_NONE, dataRead); } int ctx::device_status_psmode::subscribe() @@ -78,9 +78,9 @@ 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; - data_read.set(NULL, DEVICE_ST_IS_ENABLED, mode == 0 ? DEVICE_ST_FALSE : DEVICE_ST_TRUE); + ctx::Json dataRead; + dataRead.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); + ctx::context_manager::replyToRead(DEVICE_ST_SUBJ_PSMODE, NULL, ERR_NONE, dataRead); return ERR_NONE; } diff --git a/src/device/system/psmode.h b/src/device/system/psmode.h index 2cc1660..1d4e4f3 100644 --- a/src/device/system/psmode.h +++ b/src/device/system/psmode.h @@ -18,7 +18,7 @@ #define _DEVICE_STATUS_POWER_SAVING_MODE_H_ #include -#include "../provider_base.h" +#include "../device_provider_base.h" namespace ctx { diff --git a/src/device/system/runtime-info/base_rtinfo.h b/src/device/system/runtime-info/base_rtinfo.h index 29480c5..faaaa6a 100644 --- a/src/device/system/runtime-info/base_rtinfo.h +++ b/src/device/system/runtime-info/base_rtinfo.h @@ -18,7 +18,7 @@ #define __CONTEXT_DEVICE_STATUS_RUNTIME_INFO_H__ #include -#include "../../provider_base.h" +#include "../../device_provider_base.h" namespace ctx { diff --git a/src/device/system/runtime-info/charger.cpp b/src/device/system/runtime-info/charger.cpp index ae16d8c..d4cec25 100644 --- a/src/device/system/runtime-info/charger.cpp +++ b/src/device/system/runtime-info/charger.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include "../system_types.h" #include "charger.h" @@ -36,7 +36,7 @@ bool ctx::device_status_charger::is_supported() void ctx::device_status_charger::submit_trigger_item() { - context_manager::register_trigger_item(DEVICE_ST_SUBJ_CHARGER, OPS_SUBSCRIBE | OPS_READ, + context_manager::registerTriggerItem(DEVICE_ST_SUBJ_CHARGER, OPS_SUBSCRIBE | OPS_READ, "{" TRIG_BOOL_ITEM_DEF("IsConnected") "}", NULL); } @@ -47,22 +47,22 @@ 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; - data_read.set(NULL, DEVICE_ST_IS_CONNECTED, charger_status ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); + ctx::Json dataRead; + dataRead.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); + context_manager::publish(DEVICE_ST_SUBJ_CHARGER, NULL, ERR_NONE, dataRead); } int ctx::device_status_charger::read() { bool charger_status = false; - ctx::Json data_read; + ctx::Json dataRead; 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"); - data_read.set(NULL, DEVICE_ST_IS_CONNECTED, charger_status ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); + dataRead.set(NULL, DEVICE_ST_IS_CONNECTED, charger_status ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); - ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_CHARGER, NULL, ERR_NONE, data_read); + ctx::context_manager::replyToRead(DEVICE_ST_SUBJ_CHARGER, NULL, ERR_NONE, dataRead); return ERR_NONE; } diff --git a/src/device/system/runtime-info/gps.cpp b/src/device/system/runtime-info/gps.cpp index 80aa16c..9624d38 100644 --- a/src/device/system/runtime-info/gps.cpp +++ b/src/device/system/runtime-info/gps.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include "../system_types.h" #include "gps.h" @@ -54,7 +54,7 @@ bool ctx::device_status_gps::is_supported() void ctx::device_status_gps::submit_trigger_item() { - context_manager::register_trigger_item(DEVICE_ST_SUBJ_GPS, OPS_SUBSCRIBE | OPS_READ, + context_manager::registerTriggerItem(DEVICE_ST_SUBJ_GPS, OPS_SUBSCRIBE | OPS_READ, "{" "\"State\":{\"type\":\"string\",\"values\":[\"Disabled\",\"Searching\",\"Connected\"]}" "}", @@ -67,20 +67,20 @@ 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 dataRead; const char* state_str = get_state_string(gps_status); IF_FAIL_VOID(state_str); - data_read.set(NULL, DEVICE_ST_STATE, state_str); + dataRead.set(NULL, DEVICE_ST_STATE, state_str); - context_manager::publish(DEVICE_ST_SUBJ_GPS, NULL, ERR_NONE, data_read); + context_manager::publish(DEVICE_ST_SUBJ_GPS, NULL, ERR_NONE, dataRead); } int ctx::device_status_gps::read() { int gps_status; - ctx::Json data_read; + ctx::Json dataRead; 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"); @@ -88,8 +88,8 @@ int ctx::device_status_gps::read() const char* state_str = get_state_string(gps_status); IF_FAIL_RETURN(state_str, ERR_OPERATION_FAILED); - data_read.set(NULL, DEVICE_ST_STATE, state_str); + dataRead.set(NULL, DEVICE_ST_STATE, state_str); - ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_GPS, NULL, ERR_NONE, data_read); + ctx::context_manager::replyToRead(DEVICE_ST_SUBJ_GPS, NULL, ERR_NONE, dataRead); return ERR_NONE; } diff --git a/src/device/system/runtime-info/usb.cpp b/src/device/system/runtime-info/usb.cpp index 0ab4d0d..2b7ddbc 100644 --- a/src/device/system/runtime-info/usb.cpp +++ b/src/device/system/runtime-info/usb.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include "../system_types.h" #include "usb.h" @@ -36,7 +36,7 @@ bool ctx::device_status_usb::is_supported() void ctx::device_status_usb::submit_trigger_item() { - context_manager::register_trigger_item(DEVICE_ST_SUBJ_USB, OPS_SUBSCRIBE | OPS_READ, + context_manager::registerTriggerItem(DEVICE_ST_SUBJ_USB, OPS_SUBSCRIBE | OPS_READ, "{" TRIG_BOOL_ITEM_DEF("IsConnected") "}", NULL); } @@ -47,22 +47,22 @@ 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; - data_read.set(NULL, DEVICE_ST_IS_CONNECTED, status ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); + ctx::Json dataRead; + dataRead.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); + context_manager::publish(DEVICE_ST_SUBJ_USB, NULL, ERR_NONE, dataRead); } int ctx::device_status_usb::read() { bool status = false; - ctx::Json data_read; + ctx::Json dataRead; 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"); - data_read.set(NULL, DEVICE_ST_IS_CONNECTED, status ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); + dataRead.set(NULL, DEVICE_ST_IS_CONNECTED, status ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); - ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_USB, NULL, ERR_NONE, data_read); + ctx::context_manager::replyToRead(DEVICE_ST_SUBJ_USB, NULL, ERR_NONE, dataRead); return ERR_NONE; } diff --git a/src/device/system/time.cpp b/src/device/system/time.cpp index 7f5515a..6cd5ea0 100644 --- a/src/device/system/time.cpp +++ b/src/device/system/time.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include #include "system_types.h" #include "time.h" @@ -36,7 +36,7 @@ bool ctx::device_status_time::is_supported() void ctx::device_status_time::submit_trigger_item() { - context_manager::register_trigger_item(DEVICE_ST_SUBJ_TIME, OPS_READ, + context_manager::registerTriggerItem(DEVICE_ST_SUBJ_TIME, OPS_READ, "{" "\"TimeOfDay\":{\"type\":\"integer\",\"min\":0,\"max\":1439}," "\"DayOfWeek\":{\"type\":\"string\",\"values\":[\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\",\"Sun\",\"Weekday\",\"Weekend\"]}," @@ -68,14 +68,14 @@ int ctx::device_status_time::read() int minute_of_day = timeinfo.tm_hour * 60 + timeinfo.tm_min; std::string day_of_week = ctx::TimerManager::dowToStr(0x01 << timeinfo.tm_wday); - 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); + ctx::Json dataRead; + dataRead.set(NULL, DEVICE_ST_DAY_OF_MONTH, day_of_month); + dataRead.set(NULL, DEVICE_ST_DAY_OF_WEEK, day_of_week); + dataRead.set(NULL, DEVICE_ST_TIME_OF_DAY, minute_of_day); _I("Time: %02d:%02d, Day of Week: %s, Day of Month: %d", timeinfo.tm_hour, timeinfo.tm_min, day_of_week.c_str(), day_of_month); - ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_TIME, NULL, ERR_NONE, data_read); + ctx::context_manager::replyToRead(DEVICE_ST_SUBJ_TIME, NULL, ERR_NONE, dataRead); return ERR_NONE; } diff --git a/src/device/system/time.h b/src/device/system/time.h index 6775d7a..7d44bec 100644 --- a/src/device/system/time.h +++ b/src/device/system/time.h @@ -17,7 +17,7 @@ #ifndef _DEVICE_STATUS_TIME_H_ #define _DEVICE_STATUS_TIME_H_ -#include "../provider_base.h" +#include "../device_provider_base.h" namespace ctx { diff --git a/src/device/system/wifi.cpp b/src/device/system/wifi.cpp index a40c179..4d237df 100644 --- a/src/device/system/wifi.cpp +++ b/src/device/system/wifi.cpp @@ -15,7 +15,7 @@ */ #include -#include +#include #include "system_types.h" #include "wifi.h" @@ -39,7 +39,7 @@ ctx::device_status_wifi::~device_status_wifi() { } -ctx::context_provider_iface *ctx::device_status_wifi::create(void *data) +ctx::ContextProviderBase *ctx::device_status_wifi::create(void *data) { CREATE_INSTANCE(device_status_wifi); } @@ -62,7 +62,7 @@ bool ctx::device_status_wifi::is_supported() void ctx::device_status_wifi::submit_trigger_item() { - context_manager::register_trigger_item(DEVICE_ST_SUBJ_WIFI, OPS_SUBSCRIBE | OPS_READ, + context_manager::registerTriggerItem(DEVICE_ST_SUBJ_WIFI, OPS_SUBSCRIBE | OPS_READ, "{" "\"State\":{\"type\":\"string\",\"values\":[\"Disabled\",\"Unconnected\",\"Connected\"]}," "\"BSSID\":{\"type\":\"string\"}" @@ -162,10 +162,10 @@ int ctx::device_status_wifi::read() { IF_FAIL_RETURN(get_current_state(), ERR_OPERATION_FAILED); - ctx::Json data_read; + ctx::Json dataRead; - if (get_response_packet(data_read)) { - ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_WIFI, NULL, ERR_NONE, data_read); + if (get_response_packet(dataRead)) { + ctx::context_manager::replyToRead(DEVICE_ST_SUBJ_WIFI, NULL, ERR_NONE, dataRead); return ERR_NONE; } diff --git a/src/device/system/wifi.h b/src/device/system/wifi.h index 6bd81c1..3ed52d5 100644 --- a/src/device/system/wifi.h +++ b/src/device/system/wifi.h @@ -19,7 +19,7 @@ #include #include -#include "../provider_base.h" +#include "../device_provider_base.h" namespace ctx { diff --git a/src/place/geofence/myplace_handle.cpp b/src/place/geofence/myplace_handle.cpp index 8ea7684..d7b8fcc 100644 --- a/src/place/geofence/myplace_handle.cpp +++ b/src/place/geofence/myplace_handle.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include "place_geofence_types.h" #include "myplace_handle.h" diff --git a/src/place/geofence/place_geofence.cpp b/src/place/geofence/place_geofence.cpp index c1525a1..5bcfb7f 100644 --- a/src/place/geofence/place_geofence.cpp +++ b/src/place/geofence/place_geofence.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include "place_geofence.h" ctx::place_geofence_provider *ctx::place_geofence_provider::__instance = NULL; @@ -36,7 +36,7 @@ ctx::place_geofence_provider::~place_geofence_provider() __handle_map.clear(); } -ctx::context_provider_iface *ctx::place_geofence_provider::create(void *data) +ctx::ContextProviderBase *ctx::place_geofence_provider::create(void *data) { IF_FAIL_RETURN(!__instance, __instance); __instance = new(std::nothrow) place_geofence_provider(); @@ -63,7 +63,7 @@ bool ctx::place_geofence_provider::is_supported() void ctx::place_geofence_provider::submit_trigger_item() { - context_manager::register_trigger_item(PLACE_SUBJ_GEOFENCE, OPS_SUBSCRIBE, + context_manager::registerTriggerItem(PLACE_SUBJ_GEOFENCE, OPS_SUBSCRIBE, "{" "\"Event\":{\"type\":\"string\",\"values\":[\"In\",\"Out\"]}" "}", @@ -79,7 +79,7 @@ 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 *requestResult) { int ret = __subscribe(option); __destroy_if_unused(); @@ -93,13 +93,13 @@ int ctx::place_geofence_provider::unsubscribe(const char *subject, ctx::Json opt 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 *requestResult) { __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 *requestResult) { __destroy_if_unused(); return ERR_NOT_SUPPORTED; diff --git a/src/place/geofence/place_geofence.h b/src/place/geofence/place_geofence.h index 05de007..739610f 100644 --- a/src/place/geofence/place_geofence.h +++ b/src/place/geofence/place_geofence.h @@ -18,25 +18,25 @@ #define __CONTEXT_PLACE_GEOFENCE_H__ #include -#include +#include #include "myplace_handle.h" #include "place_geofence_types.h" namespace ctx { - class place_geofence_provider : public context_provider_iface { + class place_geofence_provider : public ContextProviderBase { typedef std::map handle_map_t; public: - static context_provider_iface *create(void *data); + static ContextProviderBase *create(void *data); static void destroy(void *data); static bool is_supported(); static void submit_trigger_item(); - int subscribe(const char *subject, ctx::Json option, ctx::Json *request_result); + int subscribe(const char *subject, ctx::Json option, ctx::Json *requestResult); 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 read(const char *subject, ctx::Json option, ctx::Json *requestResult); + int write(const char *subject, ctx::Json data, ctx::Json *requestResult); private: static place_geofence_provider *__instance; diff --git a/src/place/place_context_provider.cpp b/src/place/place_context_provider.cpp index 934f780..6bcf1c3 100644 --- a/src/place/place_context_provider.cpp +++ b/src/place/place_context_provider.cpp @@ -15,8 +15,8 @@ */ #include -#include -#include +#include +#include #include #ifdef _MOBILE_ @@ -27,24 +27,24 @@ #endif /* _MOBILE_ */ template -void register_provider(const char *subject, const char *privilege) +void registerProvider(const char *subject, const char *privilege) { if (!provider::is_supported()) return; - ctx::context_provider_info provider_info(provider::create, provider::destroy, NULL, privilege); - ctx::context_manager::register_provider(subject, provider_info); + ctx::ContextProviderInfo providerInfo(provider::create, provider::destroy, NULL, privilege); + ctx::context_manager::registerProvider(subject, providerInfo); } EXTAPI bool ctx::init_place_context_provider() { #ifdef _MOBILE_ - register_provider(PLACE_SUBJ_GEOFENCE, PLACE_PRIV_GEOFENCE); + registerProvider(PLACE_SUBJ_GEOFENCE, PLACE_PRIV_GEOFENCE); place_geofence_provider::submit_trigger_item(); #ifndef _DISABLE_RECOG_ENGINE_ place_recognition_provider::create(NULL); - register_provider(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION); + registerProvider(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION); #endif /* _DISABLE_RECOG_ENGINE_ */ #endif /* _MOBILE_ */ diff --git a/src/place/recognition/place_recognition.cpp b/src/place/recognition/place_recognition.cpp index 9cdd6f6..0b1b790 100644 --- a/src/place/recognition/place_recognition.cpp +++ b/src/place/recognition/place_recognition.cpp @@ -15,13 +15,13 @@ */ #include -#include +#include #include "place_recognition.h" #include "user_places/user_places.h" ctx::place_recognition_provider *ctx::place_recognition_provider::__instance = NULL; -ctx::context_provider_iface *ctx::place_recognition_provider::create(void *data) +ctx::ContextProviderBase *ctx::place_recognition_provider::create(void *data) { IF_FAIL_RETURN(!__instance, __instance); __instance = new(std::nothrow) place_recognition_provider(); @@ -38,7 +38,7 @@ 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* requestResult) { return ERR_NOT_SUPPORTED; } @@ -48,25 +48,25 @@ int ctx::place_recognition_provider::unsubscribe(const char *subject, ctx::Json 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* requestResult) { _I(BLUE("Read")); _J("Option", option); std::vector> places = engine.get_places(); - Json data_read = UserPlaces::compose_json(places); + Json dataRead = UserPlaces::compose_json(places); // The below function needs to be called once. // It does not need to be called within this read() function. // In can be called later, in another scope. // Please just be sure that, the 2nd input parameter "option" should be the same to the // "option" parameter received via ctx::place_recognition_provider::read(). - ctx::context_manager::reply_to_read(PLACE_SUBJ_RECOGNITION, option, ERR_NONE, data_read); + ctx::context_manager::replyToRead(PLACE_SUBJ_RECOGNITION, option, ERR_NONE, dataRead); 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* requestResult) { return ERR_NOT_SUPPORTED; } diff --git a/src/place/recognition/place_recognition.h b/src/place/recognition/place_recognition.h index 8f25424..40a93ec 100644 --- a/src/place/recognition/place_recognition.h +++ b/src/place/recognition/place_recognition.h @@ -17,23 +17,23 @@ #ifndef __CONTEXT_PLACE_RECOGNITION_H__ #define __CONTEXT_PLACE_RECOGNITION_H__ -#include +#include #include "place_recognition_types.h" #include "user_places/user_places.h" namespace ctx { - class place_recognition_provider : public context_provider_iface { + class place_recognition_provider : public ContextProviderBase { public: - static context_provider_iface *create(void *data); + static ContextProviderBase *create(void *data); static void destroy(void *data); static bool is_supported(); - int subscribe(const char *subject, ctx::Json option, ctx::Json *request_result); + int subscribe(const char *subject, ctx::Json option, ctx::Json *requestResult); 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 read(const char *subject, ctx::Json option, ctx::Json *requestResult); + int write(const char *subject, ctx::Json data, ctx::Json *requestResult); private: static place_recognition_provider *__instance; diff --git a/src/statistics/app/app_stats_provider.cpp b/src/statistics/app/app_stats_provider.cpp index cdb53f4..d924034 100644 --- a/src/statistics/app/app_stats_provider.cpp +++ b/src/statistics/app/app_stats_provider.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include "app_stats_provider.h" #include "db_handle.h" @@ -41,7 +41,7 @@ ctx::app_statistics_provider::~app_statistics_provider() launch_mon = NULL; } -ctx::context_provider_iface *ctx::app_statistics_provider::create(void *data) +ctx::ContextProviderBase *ctx::app_statistics_provider::create(void *data) { IF_FAIL_RETURN(!__instance, __instance); @@ -72,7 +72,7 @@ bool ctx::app_statistics_provider::is_supported(const char* subject) void ctx::app_statistics_provider::submit_trigger_item() { - context_manager::register_trigger_item(APP_SUBJ_FREQUENCY, OPS_READ, + context_manager::registerTriggerItem(APP_SUBJ_FREQUENCY, OPS_READ, "{" TRIG_DEF_RANK "," TRIG_DEF_TOTAL_COUNT "}", "{" "\"AppId\":{\"type\":\"string\"}," @@ -98,7 +98,7 @@ 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* requestResult) { return ERR_NOT_SUPPORTED; } @@ -108,7 +108,7 @@ int ctx::app_statistics_provider::unsubscribe(const char* subject, ctx::Json opt 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* requestResult) { 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* requestResult) { return ERR_NOT_SUPPORTED; } diff --git a/src/statistics/app/app_stats_provider.h b/src/statistics/app/app_stats_provider.h index 7735fd2..b224d77 100644 --- a/src/statistics/app/app_stats_provider.h +++ b/src/statistics/app/app_stats_provider.h @@ -17,22 +17,22 @@ #ifndef __CONTEXT_APP_STATS_PROVIDER_H__ #define __CONTEXT_APP_STATS_PROVIDER_H__ -#include +#include #include "app_stats_types.h" namespace ctx { - class app_statistics_provider : public context_provider_iface { + class app_statistics_provider : public ContextProviderBase { public: - static context_provider_iface *create(void *data); + static ContextProviderBase *create(void *data); static void destroy(void *data); 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 subscribe(const char *subject, ctx::Json option, ctx::Json *requestResult); 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 read(const char *subject, ctx::Json option, ctx::Json *requestResult); + int write(const char *subject, ctx::Json data, ctx::Json *requestResult); private: static app_statistics_provider *__instance; diff --git a/src/statistics/app/db_handle.cpp b/src/statistics/app/db_handle.cpp index d293ed4..fdabb05 100644 --- a/src/statistics/app/db_handle.cpp +++ b/src/statistics/app/db_handle.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include "app_stats_types.h" #include "db_handle.h" @@ -214,5 +214,5 @@ void ctx::app_db_handle::reply_trigger_item(int error, ctx::Json &json_result) json_result.get(NULL, STATS_RANK, &val); results.set(NULL, STATS_RANK, val); - context_manager::reply_to_read(req_subject.c_str(), req_filter, error, results); + context_manager::replyToRead(req_subject.c_str(), req_filter, error, results); } diff --git a/src/statistics/media/db_handle.cpp b/src/statistics/media/db_handle.cpp index bc74429..81a1d80 100644 --- a/src/statistics/media/db_handle.cpp +++ b/src/statistics/media/db_handle.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include "../shared/system_info.h" #include "media_stats_types.h" @@ -120,5 +120,5 @@ void ctx::media_db_handle::reply_trigger_item(int error, ctx::Json &json_result) json_result.get(NULL, STATS_TOTAL_COUNT, &val); results.set(NULL, STATS_TOTAL_COUNT, val); - context_manager::reply_to_read(req_subject.c_str(), req_filter, error, results); + context_manager::replyToRead(req_subject.c_str(), req_filter, error, results); } diff --git a/src/statistics/media/media_stats_provider.cpp b/src/statistics/media/media_stats_provider.cpp index e68fe6b..feac914 100644 --- a/src/statistics/media/media_stats_provider.cpp +++ b/src/statistics/media/media_stats_provider.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include "media_stats_provider.h" #include "db_handle.h" #include "media_content_monitor.h" @@ -35,7 +35,7 @@ ctx::media_statistics_provider::~media_statistics_provider() content_mon = NULL; } -ctx::context_provider_iface *ctx::media_statistics_provider::create(void *data) +ctx::ContextProviderBase *ctx::media_statistics_provider::create(void *data) { IF_FAIL_RETURN(!__instance, __instance); @@ -67,11 +67,11 @@ bool ctx::media_statistics_provider::is_supported(const char* subject) void ctx::media_statistics_provider::submit_trigger_item() { - context_manager::register_trigger_item(MEDIA_SUBJ_MUSIC_FREQUENCY, OPS_READ, + context_manager::registerTriggerItem(MEDIA_SUBJ_MUSIC_FREQUENCY, OPS_READ, "{" TRIG_DEF_TOTAL_COUNT "}", "{" TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK "}"); - context_manager::register_trigger_item(MEDIA_SUBJ_VIDEO_FREQUENCY, OPS_READ, + context_manager::registerTriggerItem(MEDIA_SUBJ_VIDEO_FREQUENCY, OPS_READ, "{" TRIG_DEF_TOTAL_COUNT "}", "{" TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK "}"); } @@ -83,7 +83,7 @@ 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* requestResult) { return ERR_NOT_SUPPORTED; } @@ -93,7 +93,7 @@ int ctx::media_statistics_provider::unsubscribe(const char* subject, ctx::Json o 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* requestResult) { 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* requestResult) { return ERR_NOT_SUPPORTED; } diff --git a/src/statistics/media/media_stats_provider.h b/src/statistics/media/media_stats_provider.h index 72bb198..ff695c6 100644 --- a/src/statistics/media/media_stats_provider.h +++ b/src/statistics/media/media_stats_provider.h @@ -17,22 +17,22 @@ #ifndef __CONTEXT_MEDIA_STATS_PROVIDER_H__ #define __CONTEXT_MEDIA_STATS_PROVIDER_H__ -#include +#include #include "media_stats_types.h" namespace ctx { - class media_statistics_provider : public context_provider_iface { + class media_statistics_provider : public ContextProviderBase { public: - static context_provider_iface *create(void *data); + static ContextProviderBase *create(void *data); static void destroy(void *data); 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 subscribe(const char* subject, ctx::Json option, ctx::Json* requestResult); 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 read(const char* subject, ctx::Json option, ctx::Json* requestResult); + int write(const char* subject, ctx::Json data, ctx::Json* requestResult); 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 f525b3d..159c5ca 100644 --- a/src/statistics/shared/db_handle_base.cpp +++ b/src/statistics/shared/db_handle_base.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include "common_types.h" #include "db_handle_base.h" @@ -215,12 +215,12 @@ void ctx::stats_db_handle_base::on_query_result_received(unsigned int query_id, } else { _E("Invalid query result"); Json dummy; - context_manager::reply_to_read(req_subject.c_str(), req_filter, ERR_OPERATION_FAILED, dummy); + context_manager::replyToRead(req_subject.c_str(), req_filter, ERR_OPERATION_FAILED, dummy); } } else { Json results = "{\"" STATS_QUERY_RESULT "\":[]}"; json_vector_to_array(records, results); - context_manager::reply_to_read(req_subject.c_str(), req_filter, error, results); + context_manager::replyToRead(req_subject.c_str(), req_filter, error, results); } delete this; diff --git a/src/statistics/social/db_handle.cpp b/src/statistics/social/db_handle.cpp index a42e625..1199a32 100644 --- a/src/statistics/social/db_handle.cpp +++ b/src/statistics/social/db_handle.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include "social_stats_types.h" #include "db_handle.h" @@ -158,5 +158,5 @@ void ctx::social_db_handle::reply_trigger_item(int error, ctx::Json &json_result json_result.get(NULL, STATS_RANK, &val); results.set(NULL, STATS_RANK, val); - context_manager::reply_to_read(req_subject.c_str(), req_filter, error, results); + context_manager::replyToRead(req_subject.c_str(), req_filter, error, results); } diff --git a/src/statistics/social/social_stats_provider.cpp b/src/statistics/social/social_stats_provider.cpp index 90aa35b..196b11e 100644 --- a/src/statistics/social/social_stats_provider.cpp +++ b/src/statistics/social/social_stats_provider.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include "social_stats_provider.h" #include "db_handle.h" #include "log_aggregator.h" @@ -34,7 +34,7 @@ ctx::social_statistics_provider::~social_statistics_provider() delete aggregator; } -ctx::context_provider_iface *ctx::social_statistics_provider::create(void *data) +ctx::ContextProviderBase *ctx::social_statistics_provider::create(void *data) { IF_FAIL_RETURN(!__instance, __instance); @@ -66,7 +66,7 @@ bool ctx::social_statistics_provider::is_supported(const char* subject) void ctx::social_statistics_provider::submit_trigger_item() { - context_manager::register_trigger_item(SOCIAL_SUBJ_FREQUENCY, OPS_READ, + context_manager::registerTriggerItem(SOCIAL_SUBJ_FREQUENCY, OPS_READ, "{" TRIG_DEF_RANK "," TRIG_DEF_TOTAL_COUNT "}", "{" "\"Address\":{\"type\":\"string\"}," @@ -81,7 +81,7 @@ 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* requestResult) { return ERR_NOT_SUPPORTED; } @@ -91,7 +91,7 @@ int ctx::social_statistics_provider::unsubscribe(const char* subject, ctx::Json 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* requestResult) { 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* requestResult) { return ERR_NOT_SUPPORTED; } diff --git a/src/statistics/social/social_stats_provider.h b/src/statistics/social/social_stats_provider.h index 7ba803d..1666b78 100644 --- a/src/statistics/social/social_stats_provider.h +++ b/src/statistics/social/social_stats_provider.h @@ -17,22 +17,22 @@ #ifndef __CONTEXT_SOCIAL_STATS_PROVIDER_H__ #define __CONTEXT_SOCIAL_STATS_PROVIDER_H__ -#include +#include #include "social_stats_types.h" namespace ctx { - class social_statistics_provider : public context_provider_iface { + class social_statistics_provider : public ContextProviderBase { public: - static context_provider_iface *create(void *data); + static ContextProviderBase *create(void *data); static void destroy(void *data); 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 subscribe(const char* subject, ctx::Json option, ctx::Json* requestResult); 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 read(const char* subject, ctx::Json option, ctx::Json* requestResult); + int write(const char* subject, ctx::Json data, ctx::Json* requestResult); private: static social_statistics_provider *__instance; diff --git a/src/statistics/statistics_context_provider.cpp b/src/statistics/statistics_context_provider.cpp index 13e9c40..2d305eb 100644 --- a/src/statistics/statistics_context_provider.cpp +++ b/src/statistics/statistics_context_provider.cpp @@ -14,8 +14,8 @@ */ #include -#include -#include +#include +#include #include #include "app/app_stats_provider.h" @@ -34,24 +34,24 @@ #endif template -void register_provider(const char *subject, const char *privilege) +void registerProvider(const char *subject, const char *privilege) { if (!provider::is_supported(subject)) return; - ctx::context_provider_info provider_info(provider::create, provider::destroy, NULL, privilege); - ctx::context_manager::register_provider(subject, provider_info); + ctx::ContextProviderInfo providerInfo(provider::create, provider::destroy, NULL, privilege); + ctx::context_manager::registerProvider(subject, providerInfo); } EXTAPI bool ctx::init_statistics_context_provider() { app_statistics_provider::create(NULL); - register_provider(APP_SUBJ_RECENTLY_USED, APP_HISTORY_PRIV); - register_provider(APP_SUBJ_FREQUENTLY_USED, APP_HISTORY_PRIV); - register_provider(APP_SUBJ_RARELY_USED, APP_HISTORY_PRIV); - register_provider(APP_SUBJ_PEAK_TIME, APP_HISTORY_PRIV); - register_provider(APP_SUBJ_COMMON_SETTING, APP_HISTORY_PRIV); - register_provider(APP_SUBJ_FREQUENCY, APP_HISTORY_PRIV); + registerProvider(APP_SUBJ_RECENTLY_USED, APP_HISTORY_PRIV); + registerProvider(APP_SUBJ_FREQUENTLY_USED, APP_HISTORY_PRIV); + registerProvider(APP_SUBJ_RARELY_USED, APP_HISTORY_PRIV); + registerProvider(APP_SUBJ_PEAK_TIME, APP_HISTORY_PRIV); + registerProvider(APP_SUBJ_COMMON_SETTING, APP_HISTORY_PRIV); + registerProvider(APP_SUBJ_FREQUENCY, APP_HISTORY_PRIV); app_statistics_provider::submit_trigger_item(); #ifndef _DISABLE_PREDICTION_ENGINE_ @@ -60,28 +60,28 @@ EXTAPI bool ctx::init_statistics_context_provider() #ifdef _MOBILE_ media_statistics_provider::create(NULL); - register_provider(MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC, MEDIA_HISTORY_PRIV); - register_provider(MEDIA_SUBJ_PEAK_TIME_FOR_VIDEO, MEDIA_HISTORY_PRIV); - register_provider(MEDIA_SUBJ_COMMON_SETTING_FOR_MUSIC, MEDIA_HISTORY_PRIV); - register_provider(MEDIA_SUBJ_COMMON_SETTING_FOR_VIDEO, MEDIA_HISTORY_PRIV); - register_provider(MEDIA_SUBJ_MUSIC_FREQUENCY, MEDIA_HISTORY_PRIV); - register_provider(MEDIA_SUBJ_VIDEO_FREQUENCY, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_PEAK_TIME_FOR_VIDEO, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_COMMON_SETTING_FOR_MUSIC, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_COMMON_SETTING_FOR_VIDEO, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_MUSIC_FREQUENCY, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_VIDEO_FREQUENCY, MEDIA_HISTORY_PRIV); media_statistics_provider::submit_trigger_item(); social_statistics_provider::create(NULL); - register_provider(SOCIAL_SUBJ_FREQ_ADDRESS, SOCIAL_HISTORY_PRIV); - register_provider(SOCIAL_SUBJ_FREQUENCY, SOCIAL_HISTORY_PRIV); + registerProvider(SOCIAL_SUBJ_FREQ_ADDRESS, SOCIAL_HISTORY_PRIV); + registerProvider(SOCIAL_SUBJ_FREQUENCY, SOCIAL_HISTORY_PRIV); social_statistics_provider::submit_trigger_item(); #endif #ifdef _TV_ media_statistics_provider::create(NULL); - register_provider(MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC, MEDIA_HISTORY_PRIV); - register_provider(MEDIA_SUBJ_PEAK_TIME_FOR_VIDEO, MEDIA_HISTORY_PRIV); - register_provider(MEDIA_SUBJ_COMMON_SETTING_FOR_MUSIC, MEDIA_HISTORY_PRIV); - register_provider(MEDIA_SUBJ_COMMON_SETTING_FOR_VIDEO, MEDIA_HISTORY_PRIV); - register_provider(MEDIA_SUBJ_MUSIC_FREQUENCY, MEDIA_HISTORY_PRIV); - register_provider(MEDIA_SUBJ_VIDEO_FREQUENCY, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_PEAK_TIME_FOR_VIDEO, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_COMMON_SETTING_FOR_MUSIC, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_COMMON_SETTING_FOR_VIDEO, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_MUSIC_FREQUENCY, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_VIDEO_FREQUENCY, MEDIA_HISTORY_PRIV); media_statistics_provider::submit_trigger_item(); #endif