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);
}
}
* limitations under the License.
*/
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "custom_base.h"
ctx::custom_base::custom_base(std::string subject, std::string name, ctx::Json tmpl, std::string owner) :
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;
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;
}
#define _CUSTOM_BASE_H_
#include <Json.h>
-#include <provider_iface.h>
+#include <ContextProviderBase.h>
#include <types_internal.h>
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();
#include <map>
#include <vector>
#include <types_internal.h>
-#include <context_mgr.h>
-#include <provider_iface.h>
+#include <ContextManager.h>
+#include <ContextProviderBase.h>
#include <db_mgr.h>
#include <custom_context_provider.h>
#include "custom_base.h"
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<char*>(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<const char*>(data)];
}
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);
}
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<std::string, ctx::custom_base*>::iterator it;
it = custom_map.find(subject);
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) {
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<std::string, ctx::custom_base*>::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 + "'";
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<std::string, ctx::custom_base*>::iterator it;
it = custom_map.find(subject);
#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); \
} \
} \
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\"]}}" \
); \
*/
#include <types_internal.h>
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "activity_types.h"
#include "activity_base.h"
{
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()
#include <string>
#include <activity_recognition.h>
-#include "../provider_base.h"
+#include "../device_provider_base.h"
namespace ctx {
*/
#include <types_internal.h>
-#include <context_mgr.h>
-#include <provider_iface.h>
+#include <ContextManager.h>
+#include <ContextProviderBase.h>
#include <device_context_provider.h>
#include "system/system_types.h"
#define PRIV_CONTACT "contact.read"
template<typename provider>
-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_status_alarm>(DEVICE_ST_SUBJ_ALARM, NULL);
- register_provider<device_status_time>(DEVICE_ST_SUBJ_TIME, NULL);
+ registerProvider<device_status_alarm>(DEVICE_ST_SUBJ_ALARM, NULL);
+ registerProvider<device_status_time>(DEVICE_ST_SUBJ_TIME, NULL);
#ifdef _MOBILE_
- register_provider<device_status_wifi>(DEVICE_ST_SUBJ_WIFI, PRIV_NETWORK);
- register_provider<device_status_headphone>(DEVICE_ST_SUBJ_HEADPHONE, NULL);
+ registerProvider<device_status_wifi>(DEVICE_ST_SUBJ_WIFI, PRIV_NETWORK);
+ registerProvider<device_status_headphone>(DEVICE_ST_SUBJ_HEADPHONE, NULL);
- register_provider<device_status_charger>(DEVICE_ST_SUBJ_CHARGER, NULL);
- register_provider<device_status_gps>(DEVICE_ST_SUBJ_GPS, NULL);
- register_provider<device_status_usb>(DEVICE_ST_SUBJ_USB, NULL);
- register_provider<device_status_battery>(DEVICE_ST_SUBJ_BATTERY, NULL);
- register_provider<device_status_psmode>(DEVICE_ST_SUBJ_PSMODE, NULL);
+ registerProvider<device_status_charger>(DEVICE_ST_SUBJ_CHARGER, NULL);
+ registerProvider<device_status_gps>(DEVICE_ST_SUBJ_GPS, NULL);
+ registerProvider<device_status_usb>(DEVICE_ST_SUBJ_USB, NULL);
+ registerProvider<device_status_battery>(DEVICE_ST_SUBJ_BATTERY, NULL);
+ registerProvider<device_status_psmode>(DEVICE_ST_SUBJ_PSMODE, NULL);
- register_provider<social_status_call>(SOCIAL_ST_SUBJ_CALL, PRIV_TELEPHONY);
- register_provider<social_status_email>(SOCIAL_ST_SUBJ_EMAIL, NULL);
- register_provider<social_status_message>(SOCIAL_ST_SUBJ_MESSAGE, PRIV_MESSAGE);
- register_provider<social_status_contacts>(SOCIAL_ST_SUBJ_CONTACTS, PRIV_CONTACT);
+ registerProvider<social_status_call>(SOCIAL_ST_SUBJ_CALL, PRIV_TELEPHONY);
+ registerProvider<social_status_email>(SOCIAL_ST_SUBJ_EMAIL, NULL);
+ registerProvider<social_status_message>(SOCIAL_ST_SUBJ_MESSAGE, PRIV_MESSAGE);
+ registerProvider<social_status_contacts>(SOCIAL_ST_SUBJ_CONTACTS, PRIV_CONTACT);
- register_provider<user_activity_stationary>(USER_ACT_SUBJ_STATIONARY, NULL);
- register_provider<user_activity_walking>(USER_ACT_SUBJ_WALKING, NULL);
- register_provider<user_activity_running>(USER_ACT_SUBJ_RUNNING, NULL);
- register_provider<user_activity_in_vehicle>(USER_ACT_SUBJ_IN_VEHICLE, NULL);
+ registerProvider<user_activity_stationary>(USER_ACT_SUBJ_STATIONARY, NULL);
+ registerProvider<user_activity_walking>(USER_ACT_SUBJ_WALKING, NULL);
+ registerProvider<user_activity_running>(USER_ACT_SUBJ_RUNNING, NULL);
+ registerProvider<user_activity_in_vehicle>(USER_ACT_SUBJ_IN_VEHICLE, NULL);
/* Create context providers, which need to be initiated before being subscribed */
if (device_status_wifi::is_supported())
#endif
#ifdef _WEARABLE_
- register_provider<device_status_wifi>(DEVICE_ST_SUBJ_WIFI, PRIV_NETWORK);
- register_provider<device_status_headphone>(DEVICE_ST_SUBJ_HEADPHONE, NULL);
+ registerProvider<device_status_wifi>(DEVICE_ST_SUBJ_WIFI, PRIV_NETWORK);
+ registerProvider<device_status_headphone>(DEVICE_ST_SUBJ_HEADPHONE, NULL);
- register_provider<device_status_charger>(DEVICE_ST_SUBJ_CHARGER, NULL);
- register_provider<device_status_gps>(DEVICE_ST_SUBJ_GPS, NULL);
- register_provider<device_status_usb>(DEVICE_ST_SUBJ_USB, NULL);
- register_provider<device_status_battery>(DEVICE_ST_SUBJ_BATTERY, NULL);
- register_provider<device_status_psmode>(DEVICE_ST_SUBJ_PSMODE, NULL);
+ registerProvider<device_status_charger>(DEVICE_ST_SUBJ_CHARGER, NULL);
+ registerProvider<device_status_gps>(DEVICE_ST_SUBJ_GPS, NULL);
+ registerProvider<device_status_usb>(DEVICE_ST_SUBJ_USB, NULL);
+ registerProvider<device_status_battery>(DEVICE_ST_SUBJ_BATTERY, NULL);
+ registerProvider<device_status_psmode>(DEVICE_ST_SUBJ_PSMODE, NULL);
- register_provider<social_status_call>(SOCIAL_ST_SUBJ_CALL, PRIV_TELEPHONY);
- register_provider<social_status_message>(SOCIAL_ST_SUBJ_MESSAGE, PRIV_MESSAGE);
+ registerProvider<social_status_call>(SOCIAL_ST_SUBJ_CALL, PRIV_TELEPHONY);
+ registerProvider<social_status_message>(SOCIAL_ST_SUBJ_MESSAGE, PRIV_MESSAGE);
- register_provider<user_activity_stationary>(USER_ACT_SUBJ_STATIONARY, NULL);
- register_provider<user_activity_walking>(USER_ACT_SUBJ_WALKING, NULL);
- register_provider<user_activity_running>(USER_ACT_SUBJ_RUNNING, NULL);
- register_provider<user_activity_in_vehicle>(USER_ACT_SUBJ_IN_VEHICLE, NULL);
+ registerProvider<user_activity_stationary>(USER_ACT_SUBJ_STATIONARY, NULL);
+ registerProvider<user_activity_walking>(USER_ACT_SUBJ_WALKING, NULL);
+ registerProvider<user_activity_running>(USER_ACT_SUBJ_RUNNING, NULL);
+ registerProvider<user_activity_in_vehicle>(USER_ACT_SUBJ_IN_VEHICLE, NULL);
/* Create context providers, which need to be initiated before being subscribed */
if (device_status_wifi::is_supported())
#endif
#ifdef _TV_
- register_provider<device_status_wifi>(DEVICE_ST_SUBJ_WIFI, PRIV_NETWORK);
- register_provider<device_status_headphone>(DEVICE_ST_SUBJ_HEADPHONE, NULL);
+ registerProvider<device_status_wifi>(DEVICE_ST_SUBJ_WIFI, PRIV_NETWORK);
+ registerProvider<device_status_headphone>(DEVICE_ST_SUBJ_HEADPHONE, NULL);
/* Create context providers, which need to be initiated before being subscribed */
if (device_status_wifi::is_supported())
--- /dev/null
+/*
+ * 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 <system_info.h>
+#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;
+}
--- /dev/null
+/*
+ * 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 <types_internal.h>
+#include <Json.h>
+#include <ContextProviderBase.h>
+
+#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
+++ /dev/null
-/*
- * 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 <system_info.h>
-#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;
-}
+++ /dev/null
-/*
- * 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 <types_internal.h>
-#include <Json.h>
-#include <provider_iface.h>
-
-#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
#include <stdlib.h>
#include <Json.h>
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "social_types.h"
#include "call.h"
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\"]},"
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;
}
#define _CONTEXT_SOCIAL_STATUS_CALL_H_
#include <telephony.h>
-#include "../provider_base.h"
+#include "../device_provider_base.h"
namespace ctx {
*/
#include <Json.h>
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "social_types.h"
#include "contacts.h"
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\"]}"
#define _CONTEXT_SOCIAL_STATUS_CONTACTS_H_
#include <contacts.h>
-#include "../provider_base.h"
+#include "../device_provider_base.h"
namespace ctx {
#include <gio/gio.h>
#include <email-api-etc.h>
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "social_types.h"
#include "email.h"
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\"]}"
"}",
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);
}
}
#define _CONTEXT_SOCIAL_STATUS_EMAIL_H_
#include <DBusSignalWatcher.h>
-#include "../provider_base.h"
+#include "../device_provider_base.h"
namespace ctx {
*/
#include <Json.h>
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "social_types.h"
#include "message.h"
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\"]},"
#include <msg.h>
#include <msg_transport.h>
-#include "../provider_base.h"
+#include "../device_provider_base.h"
namespace ctx {
* limitations under the License.
*/
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "system_types.h"
#include "alarm.h"
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\"]}"
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();
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;
{
_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);
}
}
}
#include <map>
#include <set>
-#include <provider_iface.h>
+#include <ContextProviderBase.h>
#include <TimerManager.h>
-#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);
* limitations under the License.
*/
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "system_types.h"
#include "battery.h"
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")
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)
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);
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;
}
#include <device/callback.h>
#include <device/battery.h>
-#include "../provider_base.h"
+#include "../device_provider_base.h"
namespace ctx {
* limitations under the License.
*/
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "system_types.h"
#include "headphone.h"
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\"]}"
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;
}
#include <glib.h>
#include <runtime_info.h>
#include <bluetooth.h>
-#include "../provider_base.h"
+#include "../device_provider_base.h"
namespace ctx {
* limitations under the License.
*/
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "system_types.h"
#include "psmode.h"
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);
}
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()
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;
}
#define _DEVICE_STATUS_POWER_SAVING_MODE_H_
#include <vconf.h>
-#include "../provider_base.h"
+#include "../device_provider_base.h"
namespace ctx {
#define __CONTEXT_DEVICE_STATUS_RUNTIME_INFO_H__
#include <runtime_info.h>
-#include "../../provider_base.h"
+#include "../../device_provider_base.h"
namespace ctx {
* limitations under the License.
*/
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "../system_types.h"
#include "charger.h"
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);
}
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;
}
* limitations under the License.
*/
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "../system_types.h"
#include "gps.h"
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\"]}"
"}",
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");
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;
}
* limitations under the License.
*/
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "../system_types.h"
#include "usb.h"
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);
}
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;
}
* limitations under the License.
*/
-#include <context_mgr.h>
+#include <ContextManager.h>
#include <TimerManager.h>
#include "system_types.h"
#include "time.h"
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\"]},"
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;
}
#ifndef _DEVICE_STATUS_TIME_H_
#define _DEVICE_STATUS_TIME_H_
-#include "../provider_base.h"
+#include "../device_provider_base.h"
namespace ctx {
*/
#include <SharedVars.h>
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "system_types.h"
#include "wifi.h"
{
}
-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);
}
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\"}"
{
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;
}
#include <string>
#include <wifi.h>
-#include "../provider_base.h"
+#include "../device_provider_base.h"
namespace ctx {
#include <types_internal.h>
#include <Json.h>
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "place_geofence_types.h"
#include "myplace_handle.h"
#include <types_internal.h>
#include <Json.h>
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "place_geofence.h"
ctx::place_geofence_provider *ctx::place_geofence_provider::__instance = NULL;
__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();
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\"]}"
"}",
}
-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();
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;
#define __CONTEXT_PLACE_GEOFENCE_H__
#include <map>
-#include <provider_iface.h>
+#include <ContextProviderBase.h>
#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<int, ctx::myplace_handle*> 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;
*/
#include <types_internal.h>
-#include <context_mgr.h>
-#include <provider_iface.h>
+#include <ContextManager.h>
+#include <ContextProviderBase.h>
#include <place_context_provider.h>
#ifdef _MOBILE_
#endif /* _MOBILE_ */
template<typename provider>
-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_geofence_provider>(PLACE_SUBJ_GEOFENCE, PLACE_PRIV_GEOFENCE);
+ registerProvider<place_geofence_provider>(PLACE_SUBJ_GEOFENCE, PLACE_PRIV_GEOFENCE);
place_geofence_provider::submit_trigger_item();
#ifndef _DISABLE_RECOG_ENGINE_
place_recognition_provider::create(NULL);
- register_provider<place_recognition_provider>(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION);
+ registerProvider<place_recognition_provider>(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION);
#endif /* _DISABLE_RECOG_ENGINE_ */
#endif /* _MOBILE_ */
*/
#include <types_internal.h>
-#include <context_mgr.h>
+#include <ContextManager.h>
#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();
_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;
}
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<std::shared_ptr<ctx::Place>> 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;
}
#ifndef __CONTEXT_PLACE_RECOGNITION_H__
#define __CONTEXT_PLACE_RECOGNITION_H__
-#include <provider_iface.h>
+#include <ContextProviderBase.h>
#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;
#include <types_internal.h>
#include <Json.h>
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "app_stats_provider.h"
#include "db_handle.h"
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);
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\"},"
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;
}
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");
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;
}
#ifndef __CONTEXT_APP_STATS_PROVIDER_H__
#define __CONTEXT_APP_STATS_PROVIDER_H__
-#include <provider_iface.h>
+#include <ContextProviderBase.h>
#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;
#include <sstream>
#include <types_internal.h>
-#include <context_mgr.h>
+#include <ContextManager.h>
#include <db_mgr.h>
#include "app_stats_types.h"
#include "db_handle.h"
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);
}
#include <sstream>
#include <types_internal.h>
-#include <context_mgr.h>
+#include <ContextManager.h>
#include <db_mgr.h>
#include "../shared/system_info.h"
#include "media_stats_types.h"
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);
}
#include <glib.h>
#include <string>
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "media_stats_provider.h"
#include "db_handle.h"
#include "media_content_monitor.h"
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);
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 "}");
}
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;
}
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");
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;
}
#ifndef __CONTEXT_MEDIA_STATS_PROVIDER_H__
#define __CONTEXT_MEDIA_STATS_PROVIDER_H__
-#include <provider_iface.h>
+#include <ContextProviderBase.h>
#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;
#include <sstream>
#include <types_internal.h>
-#include <context_mgr.h>
+#include <ContextManager.h>
#include <db_mgr.h>
#include "common_types.h"
#include "db_handle_base.h"
} 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;
#include <sstream>
#include <contacts.h>
#include <types_internal.h>
-#include <context_mgr.h>
+#include <ContextManager.h>
#include <db_mgr.h>
#include "social_stats_types.h"
#include "db_handle.h"
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);
}
#include <types_internal.h>
#include <Json.h>
-#include <context_mgr.h>
+#include <ContextManager.h>
#include "social_stats_provider.h"
#include "db_handle.h"
#include "log_aggregator.h"
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);
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\"},"
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;
}
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");
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;
}
#ifndef __CONTEXT_SOCIAL_STATS_PROVIDER_H__
#define __CONTEXT_SOCIAL_STATS_PROVIDER_H__
-#include <provider_iface.h>
+#include <ContextProviderBase.h>
#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;
*/
#include <types_internal.h>
-#include <context_mgr.h>
-#include <provider_iface.h>
+#include <ContextManager.h>
+#include <ContextProviderBase.h>
#include <statistics_context_provider.h>
#include "app/app_stats_provider.h"
#endif
template<typename provider>
-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_statistics_provider>(APP_SUBJ_RECENTLY_USED, APP_HISTORY_PRIV);
- register_provider<app_statistics_provider>(APP_SUBJ_FREQUENTLY_USED, APP_HISTORY_PRIV);
- register_provider<app_statistics_provider>(APP_SUBJ_RARELY_USED, APP_HISTORY_PRIV);
- register_provider<app_statistics_provider>(APP_SUBJ_PEAK_TIME, APP_HISTORY_PRIV);
- register_provider<app_statistics_provider>(APP_SUBJ_COMMON_SETTING, APP_HISTORY_PRIV);
- register_provider<app_statistics_provider>(APP_SUBJ_FREQUENCY, APP_HISTORY_PRIV);
+ registerProvider<app_statistics_provider>(APP_SUBJ_RECENTLY_USED, APP_HISTORY_PRIV);
+ registerProvider<app_statistics_provider>(APP_SUBJ_FREQUENTLY_USED, APP_HISTORY_PRIV);
+ registerProvider<app_statistics_provider>(APP_SUBJ_RARELY_USED, APP_HISTORY_PRIV);
+ registerProvider<app_statistics_provider>(APP_SUBJ_PEAK_TIME, APP_HISTORY_PRIV);
+ registerProvider<app_statistics_provider>(APP_SUBJ_COMMON_SETTING, APP_HISTORY_PRIV);
+ registerProvider<app_statistics_provider>(APP_SUBJ_FREQUENCY, APP_HISTORY_PRIV);
app_statistics_provider::submit_trigger_item();
#ifndef _DISABLE_PREDICTION_ENGINE_
#ifdef _MOBILE_
media_statistics_provider::create(NULL);
- register_provider<media_statistics_provider>(MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC, MEDIA_HISTORY_PRIV);
- register_provider<media_statistics_provider>(MEDIA_SUBJ_PEAK_TIME_FOR_VIDEO, MEDIA_HISTORY_PRIV);
- register_provider<media_statistics_provider>(MEDIA_SUBJ_COMMON_SETTING_FOR_MUSIC, MEDIA_HISTORY_PRIV);
- register_provider<media_statistics_provider>(MEDIA_SUBJ_COMMON_SETTING_FOR_VIDEO, MEDIA_HISTORY_PRIV);
- register_provider<media_statistics_provider>(MEDIA_SUBJ_MUSIC_FREQUENCY, MEDIA_HISTORY_PRIV);
- register_provider<media_statistics_provider>(MEDIA_SUBJ_VIDEO_FREQUENCY, MEDIA_HISTORY_PRIV);
+ registerProvider<media_statistics_provider>(MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC, MEDIA_HISTORY_PRIV);
+ registerProvider<media_statistics_provider>(MEDIA_SUBJ_PEAK_TIME_FOR_VIDEO, MEDIA_HISTORY_PRIV);
+ registerProvider<media_statistics_provider>(MEDIA_SUBJ_COMMON_SETTING_FOR_MUSIC, MEDIA_HISTORY_PRIV);
+ registerProvider<media_statistics_provider>(MEDIA_SUBJ_COMMON_SETTING_FOR_VIDEO, MEDIA_HISTORY_PRIV);
+ registerProvider<media_statistics_provider>(MEDIA_SUBJ_MUSIC_FREQUENCY, MEDIA_HISTORY_PRIV);
+ registerProvider<media_statistics_provider>(MEDIA_SUBJ_VIDEO_FREQUENCY, MEDIA_HISTORY_PRIV);
media_statistics_provider::submit_trigger_item();
social_statistics_provider::create(NULL);
- register_provider<social_statistics_provider>(SOCIAL_SUBJ_FREQ_ADDRESS, SOCIAL_HISTORY_PRIV);
- register_provider<social_statistics_provider>(SOCIAL_SUBJ_FREQUENCY, SOCIAL_HISTORY_PRIV);
+ registerProvider<social_statistics_provider>(SOCIAL_SUBJ_FREQ_ADDRESS, SOCIAL_HISTORY_PRIV);
+ registerProvider<social_statistics_provider>(SOCIAL_SUBJ_FREQUENCY, SOCIAL_HISTORY_PRIV);
social_statistics_provider::submit_trigger_item();
#endif
#ifdef _TV_
media_statistics_provider::create(NULL);
- register_provider<media_statistics_provider>(MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC, MEDIA_HISTORY_PRIV);
- register_provider<media_statistics_provider>(MEDIA_SUBJ_PEAK_TIME_FOR_VIDEO, MEDIA_HISTORY_PRIV);
- register_provider<media_statistics_provider>(MEDIA_SUBJ_COMMON_SETTING_FOR_MUSIC, MEDIA_HISTORY_PRIV);
- register_provider<media_statistics_provider>(MEDIA_SUBJ_COMMON_SETTING_FOR_VIDEO, MEDIA_HISTORY_PRIV);
- register_provider<media_statistics_provider>(MEDIA_SUBJ_MUSIC_FREQUENCY, MEDIA_HISTORY_PRIV);
- register_provider<media_statistics_provider>(MEDIA_SUBJ_VIDEO_FREQUENCY, MEDIA_HISTORY_PRIV);
+ registerProvider<media_statistics_provider>(MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC, MEDIA_HISTORY_PRIV);
+ registerProvider<media_statistics_provider>(MEDIA_SUBJ_PEAK_TIME_FOR_VIDEO, MEDIA_HISTORY_PRIV);
+ registerProvider<media_statistics_provider>(MEDIA_SUBJ_COMMON_SETTING_FOR_MUSIC, MEDIA_HISTORY_PRIV);
+ registerProvider<media_statistics_provider>(MEDIA_SUBJ_COMMON_SETTING_FOR_VIDEO, MEDIA_HISTORY_PRIV);
+ registerProvider<media_statistics_provider>(MEDIA_SUBJ_MUSIC_FREQUENCY, MEDIA_HISTORY_PRIV);
+ registerProvider<media_statistics_provider>(MEDIA_SUBJ_VIDEO_FREQUENCY, MEDIA_HISTORY_PRIV);
media_statistics_provider::submit_trigger_item();
#endif