From 8dd9349b0f9ebc733ab117c58fd239ed4d760b69 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Mon, 18 Apr 2016 19:14:50 +0900 Subject: [PATCH 01/16] Replace the macro EXTAPI with SO_EXPORT Change-Id: Id4418789b8e408cd1cd30f6c412574f105e503f5 Signed-off-by: Mu-Woong Lee --- src/custom/CustomContextProvider.cpp | 12 ++++++------ src/device/DeviceContextProvider.cpp | 2 +- src/place/PlaceContextProvider.cpp | 2 +- src/statistics/StatisticsContextProvider.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/custom/CustomContextProvider.cpp b/src/custom/CustomContextProvider.cpp index 13371b5..61990b0 100644 --- a/src/custom/CustomContextProvider.cpp +++ b/src/custom/CustomContextProvider.cpp @@ -45,13 +45,13 @@ void unregisterProvider(const char* subject) ctx::context_manager::unregisterProvider(subject); } -EXTAPI ctx::ContextProviderBase* ctx::custom_context_provider::create(void *data) +SO_EXPORT ctx::ContextProviderBase* ctx::custom_context_provider::create(void *data) { // Already created in addItem() function. Return corresponding custom provider return __customMap[static_cast(data)]; } -EXTAPI void ctx::custom_context_provider::destroy(void *data) +SO_EXPORT void ctx::custom_context_provider::destroy(void *data) { std::map::iterator it = __customMap.find(static_cast(data)); if (it != __customMap.end()) { @@ -60,7 +60,7 @@ EXTAPI void ctx::custom_context_provider::destroy(void *data) } } -EXTAPI bool ctx::initCustomContextProvider() +SO_EXPORT bool ctx::initCustomContextProvider() { // Create custom template db std::string q = std::string("CREATE TABLE IF NOT EXISTS context_trigger_custom_template ") @@ -99,7 +99,7 @@ EXTAPI bool ctx::initCustomContextProvider() return true; } -EXTAPI int ctx::custom_context_provider::addItem(std::string subject, std::string name, ctx::Json tmpl, const char* owner, bool isInit) +SO_EXPORT int ctx::custom_context_provider::addItem(std::string subject, std::string name, ctx::Json tmpl, const char* owner, bool isInit) { std::map::iterator it; it = __customMap.find(subject); @@ -131,7 +131,7 @@ EXTAPI int ctx::custom_context_provider::addItem(std::string subject, std::strin return ERR_NONE; } -EXTAPI int ctx::custom_context_provider::removeItem(std::string subject) +SO_EXPORT int ctx::custom_context_provider::removeItem(std::string subject) { std::map::iterator it; it = __customMap.find(subject); @@ -148,7 +148,7 @@ EXTAPI int ctx::custom_context_provider::removeItem(std::string subject) return ERR_NONE; } -EXTAPI int ctx::custom_context_provider::publishData(std::string subject, ctx::Json fact) +SO_EXPORT int ctx::custom_context_provider::publishData(std::string subject, ctx::Json fact) { std::map::iterator it; it = __customMap.find(subject); diff --git a/src/device/DeviceContextProvider.cpp b/src/device/DeviceContextProvider.cpp index 0f31ed6..a6c2b85 100644 --- a/src/device/DeviceContextProvider.cpp +++ b/src/device/DeviceContextProvider.cpp @@ -75,7 +75,7 @@ void registerProvider(const char *subject, const char *privilege) Provider::submitTriggerItem(); } -EXTAPI bool ctx::initDeviceContextProvider() +SO_EXPORT bool ctx::initDeviceContextProvider() { registerProvider(DEVICE_ST_SUBJ_ALARM, NULL); registerProvider(DEVICE_ST_SUBJ_TIME, NULL); diff --git a/src/place/PlaceContextProvider.cpp b/src/place/PlaceContextProvider.cpp index dabdac0..363ed86 100644 --- a/src/place/PlaceContextProvider.cpp +++ b/src/place/PlaceContextProvider.cpp @@ -36,7 +36,7 @@ void registerProvider(const char *subject, const char *privilege) ctx::context_manager::registerProvider(subject, providerInfo); } -EXTAPI bool ctx::initPlaceContextProvider() +SO_EXPORT bool ctx::initPlaceContextProvider() { #ifdef _MOBILE_ registerProvider(PLACE_SUBJ_GEOFENCE, PLACE_PRIV_GEOFENCE); diff --git a/src/statistics/StatisticsContextProvider.cpp b/src/statistics/StatisticsContextProvider.cpp index 63bc618..7c3123d 100644 --- a/src/statistics/StatisticsContextProvider.cpp +++ b/src/statistics/StatisticsContextProvider.cpp @@ -43,7 +43,7 @@ void registerProvider(const char *subject, const char *privilege) ctx::context_manager::registerProvider(subject, providerInfo); } -EXTAPI bool ctx::initStatisticsContextProvider() +SO_EXPORT bool ctx::initStatisticsContextProvider() { AppStatisticsProvider::create(NULL); registerProvider(APP_SUBJ_RECENTLY_USED, APP_HISTORY_PRIV); -- 2.7.4 From ffde390acc2e2ef89d44d1e037e87d284e59a457 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Mon, 18 Apr 2016 17:53:10 +0900 Subject: [PATCH 02/16] Refactor provider instance initialization routines Change-Id: I552e9278ebbfbc408ef76f6a5a5a913fa2d128f1 Signed-off-by: Mu-Woong Lee --- include/CustomContextProvider.h | 2 +- src/CMakeLists.txt | 2 +- src/custom/CustomBase.h | 4 +- src/custom/CustomContextProvider.cpp | 4 +- src/device/CMakeLists.txt | 2 +- src/device/DeviceContextProvider.cpp | 35 ++---- src/device/DeviceProviderBase.cpp | 49 ++++---- src/device/DeviceProviderBase.h | 61 ++-------- src/device/activity/Activity.h | 30 +---- src/device/activity/ActivityBase.cpp | 42 ++++--- src/device/activity/ActivityBase.h | 10 +- src/device/social/Call.cpp | 57 +++++---- src/device/social/Call.h | 16 ++- src/device/social/Contacts.cpp | 33 +++--- src/device/social/Contacts.h | 14 +-- src/device/social/Email.cpp | 30 +++-- src/device/social/Email.h | 15 ++- src/device/social/Message.cpp | 31 +++-- src/device/social/Message.h | 14 +-- src/device/system/Alarm.cpp | 84 +++++--------- src/device/system/Alarm.h | 37 +++--- src/device/system/Battery.cpp | 34 +++--- src/device/system/Battery.h | 13 +-- src/device/system/Headphone.cpp | 56 ++++----- src/device/system/Headphone.h | 14 +-- src/device/system/Psmode.cpp | 32 +++--- src/device/system/Psmode.h | 13 +-- src/device/system/Time.cpp | 26 ++--- src/device/system/Time.h | 13 +-- src/device/system/Wifi.cpp | 67 +++++------ src/device/system/Wifi.h | 14 +-- src/device/system/runtime_info/Charger.cpp | 27 +++-- src/device/system/runtime_info/Charger.h | 15 +-- src/device/system/runtime_info/Gps.cpp | 27 +++-- src/device/system/runtime_info/Gps.h | 15 +-- src/device/system/runtime_info/RuntimeInfoBase.cpp | 13 ++- src/device/system/runtime_info/RuntimeInfoBase.h | 2 +- src/device/system/runtime_info/Usb.cpp | 27 +++-- src/device/system/runtime_info/Usb.h | 15 +-- src/place/PlaceContextProvider.cpp | 15 +-- src/place/geofence/GeofenceMonitorHandle.cpp | 84 +++++++------- src/place/geofence/GeofenceMonitorHandle.h | 6 +- src/place/geofence/PlaceGeofenceProvider.cpp | 78 +++---------- src/place/geofence/PlaceGeofenceProvider.h | 31 ++--- src/place/recognition/place_recognition.cpp | 32 +----- src/place/recognition/place_recognition.h | 29 +++-- src/statistics/CMakeLists.txt | 6 - src/statistics/StatisticsContextProvider.cpp | 75 ++++++------ src/statistics/app/AppStatisticsProvider.cpp | 128 --------------------- src/statistics/app/AppStatisticsProvider.h | 48 -------- src/statistics/app/AppStatisticsTypes.h | 1 + src/statistics/app/AppStatsLogger.cpp | 57 +++++++++ src/statistics/app/AppStatsLogger.h | 45 ++++++++ src/statistics/app/AppStatsProvider.cpp | 57 +++++++++ src/statistics/app/AppStatsProvider.h | 81 +++++++++++++ src/statistics/app/DbHandle.cpp | 39 ++++--- src/statistics/app/DbHandle.h | 20 ++-- .../app_inactive_detector/AppInactiveDetector.cpp | 2 +- .../app_inactive_detector/AppInactiveDetector.h | 6 +- src/statistics/media/DbHandle.cpp | 37 +++--- src/statistics/media/DbHandle.h | 14 +-- src/statistics/media/MediaStatisticsProvider.cpp | 113 ------------------ src/statistics/media/MediaStatisticsProvider.h | 48 -------- src/statistics/media/MediaStatisticsTypes.h | 1 + src/statistics/media/MediaStatsLogger.cpp | 39 +++++++ src/statistics/media/MediaStatsLogger.h | 42 +++++++ src/statistics/media/MediaStatsProvider.cpp | 67 +++++++++++ src/statistics/media/MediaStatsProvider.h | 85 ++++++++++++++ src/statistics/shared/DbHandleBase.cpp | 39 ++++--- src/statistics/shared/DbHandleBase.h | 25 ++-- src/statistics/shared/SystemInfo.cpp | 10 +- src/statistics/social/DbHandle.cpp | 31 ++--- src/statistics/social/DbHandle.h | 12 +- src/statistics/social/SocialStatisticsProvider.cpp | 111 ------------------ src/statistics/social/SocialStatisticsProvider.h | 48 -------- src/statistics/social/SocialStatisticsTypes.h | 1 + src/statistics/social/SocialStatsLogger.cpp | 39 +++++++ src/statistics/social/SocialStatsLogger.h | 42 +++++++ src/statistics/social/SocialStatsProvider.cpp | 63 ++++++++++ src/statistics/social/SocialStatsProvider.h | 55 +++++++++ 80 files changed, 1348 insertions(+), 1409 deletions(-) delete mode 100644 src/statistics/app/AppStatisticsProvider.cpp delete mode 100644 src/statistics/app/AppStatisticsProvider.h create mode 100644 src/statistics/app/AppStatsLogger.cpp create mode 100644 src/statistics/app/AppStatsLogger.h create mode 100644 src/statistics/app/AppStatsProvider.cpp create mode 100644 src/statistics/app/AppStatsProvider.h delete mode 100644 src/statistics/media/MediaStatisticsProvider.cpp delete mode 100644 src/statistics/media/MediaStatisticsProvider.h create mode 100644 src/statistics/media/MediaStatsLogger.cpp create mode 100644 src/statistics/media/MediaStatsLogger.h create mode 100644 src/statistics/media/MediaStatsProvider.cpp create mode 100644 src/statistics/media/MediaStatsProvider.h delete mode 100644 src/statistics/social/SocialStatisticsProvider.cpp delete mode 100644 src/statistics/social/SocialStatisticsProvider.h create mode 100644 src/statistics/social/SocialStatsLogger.cpp create mode 100644 src/statistics/social/SocialStatsLogger.h create mode 100644 src/statistics/social/SocialStatsProvider.cpp create mode 100644 src/statistics/social/SocialStatsProvider.h diff --git a/include/CustomContextProvider.h b/include/CustomContextProvider.h index c75d63e..b000fa5 100644 --- a/include/CustomContextProvider.h +++ b/include/CustomContextProvider.h @@ -27,7 +27,7 @@ namespace ctx { int removeItem(std::string subject); int publishData(std::string subject, ctx::Json fact); - ContextProviderBase* create(void* data); + ContextProvider* create(void* data); void destroy(void* data); } /* namespace custom_context_provider */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ed647fd..5926ed8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,7 +14,7 @@ ENDFUNCTION(add_provider) add_provider(device) add_provider(statistics) add_provider(place) -add_provider(custom) +#add_provider(custom) LIST(REMOVE_DUPLICATES deps_collected) diff --git a/src/custom/CustomBase.h b/src/custom/CustomBase.h index 07504ec..13c9d99 100644 --- a/src/custom/CustomBase.h +++ b/src/custom/CustomBase.h @@ -18,12 +18,12 @@ #define _CONTEXT_CUSTOM_BASE_H_ #include -#include +#include #include namespace ctx { - class CustomBase : public ContextProviderBase { + class CustomBase : public ContextProvider { public: CustomBase(std::string subject, std::string name, ctx::Json tmpl, std::string owner); ~CustomBase(); diff --git a/src/custom/CustomContextProvider.cpp b/src/custom/CustomContextProvider.cpp index 61990b0..bcfb7bc 100644 --- a/src/custom/CustomContextProvider.cpp +++ b/src/custom/CustomContextProvider.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include "CustomBase.h" @@ -45,7 +45,7 @@ void unregisterProvider(const char* subject) ctx::context_manager::unregisterProvider(subject); } -SO_EXPORT ctx::ContextProviderBase* ctx::custom_context_provider::create(void *data) +SO_EXPORT ctx::ContextProvider* ctx::custom_context_provider::create(void *data) { // Already created in addItem() function. Return corresponding custom provider return __customMap[static_cast(data)]; diff --git a/src/device/CMakeLists.txt b/src/device/CMakeLists.txt index 20276e3..16f436f 100644 --- a/src/device/CMakeLists.txt +++ b/src/device/CMakeLists.txt @@ -7,7 +7,7 @@ SET(prvd_deps vconf capi-system-info capi-system-device capi-system-runtime-info # Mobile Profile IF("${PROFILE}" STREQUAL "mobile") - SET(prvd_deps ${prvd_deps} capi-network-bluetooth capi-network-wifi) + SET(prvd_deps ${prvd_deps} capi-network-bluetooth capi-network-wifi contacts-service2) SET(prvd_deps ${prvd_deps} capi-telephony tapi msg-service capi-messaging-email motion) FILE(GLOB_RECURSE prvd_srcs ${prvd_srcs} activity/*.cpp) FILE(GLOB_RECURSE prvd_srcs ${prvd_srcs} system/*.cpp) diff --git a/src/device/DeviceContextProvider.cpp b/src/device/DeviceContextProvider.cpp index a6c2b85..332efdc 100644 --- a/src/device/DeviceContextProvider.cpp +++ b/src/device/DeviceContextProvider.cpp @@ -15,8 +15,7 @@ */ #include -#include -#include +#include #include #include "system/SystemTypes.h" @@ -54,11 +53,6 @@ #include "activity/Activity.h" #endif -#ifdef _TV_ -#include "system/Wifi.h" -#include "system/Headphone.h" -#endif - #define PRIV_NETWORK "network.get" #define PRIV_TELEPHONY "telephony" #define PRIV_MESSAGE "message.read" @@ -67,12 +61,16 @@ template void registerProvider(const char *subject, const char *privilege) { - if (!Provider::isSupported()) + Provider *provider = new(std::nothrow) Provider(); + IF_FAIL_VOID_TAG(provider, _E, "Memory allocation failed"); + + if (!provider->isSupported()) { + delete provider; return; + } - ctx::ContextProviderInfo providerInfo(Provider::create, Provider::destroy, NULL, privilege); - ctx::context_manager::registerProvider(subject, providerInfo); - Provider::submitTriggerItem(); + provider->registerProvider(privilege, provider); + provider->submitTriggerItem(); } SO_EXPORT bool ctx::initDeviceContextProvider() @@ -101,8 +99,10 @@ SO_EXPORT bool ctx::initDeviceContextProvider() registerProvider(USER_ACT_SUBJ_IN_VEHICLE, NULL); /* Create context providers, which need to be initiated before being subscribed */ + /* if (DeviceStatusWifi::isSupported()) DeviceStatusWifi::create(NULL); + */ #endif #ifdef _WEARABLE_ @@ -122,19 +122,6 @@ SO_EXPORT bool ctx::initDeviceContextProvider() 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 (DeviceStatusWifi::isSupported()) - DeviceStatusWifi::create(NULL); -#endif - -#ifdef _TV_ - 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 (DeviceStatusWifi::isSupported()) - DeviceStatusWifi::create(NULL); #endif return true; diff --git a/src/device/DeviceProviderBase.cpp b/src/device/DeviceProviderBase.cpp index db8e069..1c5f5ef 100644 --- a/src/device/DeviceProviderBase.cpp +++ b/src/device/DeviceProviderBase.cpp @@ -17,12 +17,24 @@ #include #include "DeviceProviderBase.h" -ctx::DeviceProviderBase::DeviceProviderBase() : +using namespace ctx; + +DeviceProviderBase::DeviceProviderBase(const char *subject) : + ContextProvider(subject), __beingSubscribed(false) { } -int ctx::DeviceProviderBase::subscribe(const char *subject, ctx::Json option, ctx::Json *requestResult) +bool DeviceProviderBase::isSupported() +{ + return true; +} + +void DeviceProviderBase::submitTriggerItem() +{ +} + +int DeviceProviderBase::subscribe(Json option, Json *requestResult) { IF_FAIL_RETURN(!__beingSubscribed, ERR_NONE); @@ -30,64 +42,51 @@ int ctx::DeviceProviderBase::subscribe(const char *subject, ctx::Json option, ct if (ret == ERR_NONE) __beingSubscribed = true; - else - destroySelf(); return ret; } -int ctx::DeviceProviderBase::unsubscribe(const char *subject, ctx::Json option) +int DeviceProviderBase::unsubscribe(Json option) { int ret = ERR_NONE; if (__beingSubscribed) ret = unsubscribe(); - destroySelf(); return ret; } -int ctx::DeviceProviderBase::read(const char *subject, ctx::Json option, ctx::Json *requestResult) +int DeviceProviderBase::read(Json option, Json *requestResult) { - int ret = read(); - - if (!__beingSubscribed) - destroySelf(); - - return ret; + return read(); } -int ctx::DeviceProviderBase::write(const char *subject, ctx::Json data, ctx::Json *requestResult) +int DeviceProviderBase::write(Json data, Json *requestResult) { - int ret = write(); - - if (!__beingSubscribed) - destroySelf(); - - return ret; + return write(); } -int ctx::DeviceProviderBase::subscribe() +int DeviceProviderBase::subscribe() { return ERR_NOT_SUPPORTED; } -int ctx::DeviceProviderBase::unsubscribe() +int DeviceProviderBase::unsubscribe() { return ERR_NOT_SUPPORTED; } -int ctx::DeviceProviderBase::read() +int DeviceProviderBase::read() { return ERR_NOT_SUPPORTED; } -int ctx::DeviceProviderBase::write() +int DeviceProviderBase::write() { return ERR_NOT_SUPPORTED; } -bool ctx::DeviceProviderBase::getSystemInfoBool(const char *key) +bool DeviceProviderBase::getSystemInfoBool(const char *key) { bool supported = false; int ret = system_info_get_platform_bool(key, &supported); diff --git a/src/device/DeviceProviderBase.h b/src/device/DeviceProviderBase.h index 323abe7..f5a55da 100644 --- a/src/device/DeviceProviderBase.h +++ b/src/device/DeviceProviderBase.h @@ -17,71 +17,30 @@ #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 destroySelf(); \ - 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::destroySelf() \ - { \ - destroy(NULL); \ - } \ +#include namespace ctx { - class DeviceProviderBase : public ContextProviderBase { + class DeviceProviderBase : public ContextProvider { 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); + int subscribe(Json option, Json *requestResult); + int unsubscribe(Json option); + int read(Json option, Json *requestResult); + int write(Json data, Json *requestResult); + + virtual bool isSupported(); + virtual void submitTriggerItem(); protected: bool __beingSubscribed; - DeviceProviderBase(); + DeviceProviderBase(const char *subject); virtual ~DeviceProviderBase() {} virtual int subscribe(); virtual int unsubscribe(); virtual int read(); virtual int write(); - virtual void destroySelf() = 0; static bool getSystemInfoBool(const char *key); }; diff --git a/src/device/activity/Activity.h b/src/device/activity/Activity.h index b7bf49e..f50b283 100644 --- a/src/device/activity/Activity.h +++ b/src/device/activity/Activity.h @@ -17,41 +17,13 @@ #ifndef _DEVICE_ACTIVITY_STATUS_H_ #define _DEVICE_ACTIVITY_STATUS_H_ -#include #include "ActivityBase.h" #define GENERATE_ACTIVITY_PROVIDER(actPrvd, actSubj, actType) \ class actPrvd : public UserActivityBase { \ public: \ - static ContextProviderBase *create(void *data) \ - { \ - CREATE_INSTANCE(ctx::actPrvd); \ - } \ - static void destroy(void *data) \ - { \ - DESTROY_INSTANCE(); \ - } \ - static bool isSupported() \ - { \ - return getSystemInfoBool("tizen.org/feature/sensor.activity_recognition"); \ - } \ - static void submitTriggerItem() \ - { \ - context_manager::registerTriggerItem((actSubj), OPS_SUBSCRIBE, \ - "{\"Event\":{\"type\":\"string\", \"values\":[\"Detected\"]}}", \ - "{\"Accuracy\":{\"type\":\"string\", \"values\":[\"Low\", \"Normal\", \"High\"]}}" \ - ); \ - } \ - protected: \ - void destroySelf() \ - { \ - destroy(NULL); \ - } \ - private: \ - static actPrvd *__instance; \ - actPrvd() : UserActivityBase((actSubj), (actType)) {} \ + actPrvd() : UserActivityBase(actSubj, actType) {} \ }; \ - ctx::actPrvd *ctx::actPrvd::__instance = NULL; \ namespace ctx { GENERATE_ACTIVITY_PROVIDER(UserActivityStationary, USER_ACT_SUBJ_STATIONARY, ACTIVITY_STATIONARY); diff --git a/src/device/activity/ActivityBase.cpp b/src/device/activity/ActivityBase.cpp index 8b16c28..4abda04 100644 --- a/src/device/activity/ActivityBase.cpp +++ b/src/device/activity/ActivityBase.cpp @@ -14,25 +14,39 @@ * limitations under the License. */ -#include -#include +#include #include "ActivityTypes.h" #include "ActivityBase.h" -ctx::UserActivityBase::UserActivityBase(const char *subj, activity_type_e type) : +using namespace ctx; + +UserActivityBase::UserActivityBase(const char *subject, activity_type_e type) : + DeviceProviderBase(subject), __activityType(type), - __activityHandle(NULL), - __subject(subj) + __activityHandle(NULL) { } -ctx::UserActivityBase::~UserActivityBase() +UserActivityBase::~UserActivityBase() { if (__activityHandle) activity_release(__activityHandle); } -void ctx::UserActivityBase::__updateCb(activity_type_e activity, const activity_data_h data, double timestamp, activity_error_e error, void* userData) +bool UserActivityBase::isSupported() +{ + return getSystemInfoBool("tizen.org/feature/sensor.activity_recognition"); +} + +void UserActivityBase::submitTriggerItem() +{ + registerTriggerItem(OPS_SUBSCRIBE, + "{\"Event\":{\"type\":\"string\", \"values\":[\"Detected\"]}}", + "{\"Accuracy\":{\"type\":\"string\", \"values\":[\"Low\", \"Normal\", \"High\"]}}" + ); +} + +void UserActivityBase::__updateCb(activity_type_e activity, const activity_data_h data, double timestamp, activity_error_e error, void* userData) { IF_FAIL_VOID_TAG(error == ACTIVITY_ERROR_NONE, _E, "Error: %d", error); @@ -40,11 +54,11 @@ void ctx::UserActivityBase::__updateCb(activity_type_e activity, const activity_ instance->__handleUpdate(activity, data, timestamp); } -void ctx::UserActivityBase::__handleUpdate(activity_type_e activity, const activity_data_h data, double timestamp) +void UserActivityBase::__handleUpdate(activity_type_e activity, const activity_data_h data, double timestamp) { IF_FAIL_VOID_TAG(activity == __activityType, _E, "Invalid activity: %d", activity); - ctx::Json dataRead; + Json dataRead; dataRead.set(NULL, USER_ACT_EVENT, USER_ACT_DETECTED); activity_accuracy_e accuracy = ACTIVITY_ACCURACY_LOW; @@ -62,15 +76,13 @@ void ctx::UserActivityBase::__handleUpdate(activity_type_e activity, const activ break; } - context_manager::publish(__subject.c_str(), NULL, ERR_NONE, dataRead); + publish(NULL, ERR_NONE, dataRead); } -int ctx::UserActivityBase::subscribe() +int UserActivityBase::subscribe() { IF_FAIL_RETURN(__activityHandle == NULL, ERR_NONE); - _D("Starting to monitor %s", __subject.c_str()); - activity_create(&__activityHandle); IF_FAIL_RETURN_TAG(__activityHandle, ERR_OPERATION_FAILED, _E, "Memory allocation failed"); @@ -85,12 +97,10 @@ int ctx::UserActivityBase::subscribe() return ERR_NONE; } -int ctx::UserActivityBase::unsubscribe() +int UserActivityBase::unsubscribe() { IF_FAIL_RETURN(__activityHandle, ERR_NONE); - _D("Stop monitoring %s", __subject.c_str()); - activity_stop_recognition(__activityHandle); activity_release(__activityHandle); __activityHandle = NULL; diff --git a/src/device/activity/ActivityBase.h b/src/device/activity/ActivityBase.h index c7ce566..ef68d58 100644 --- a/src/device/activity/ActivityBase.h +++ b/src/device/activity/ActivityBase.h @@ -25,16 +25,18 @@ namespace ctx { class UserActivityBase : public DeviceProviderBase { public: + UserActivityBase(const char *subject, activity_type_e type); + virtual ~UserActivityBase(); + int subscribe(); int unsubscribe(); + bool isSupported(); + void submitTriggerItem(); + protected: activity_type_e __activityType; activity_h __activityHandle; - std::string __subject; - - UserActivityBase(const char *subj, activity_type_e type); - virtual ~UserActivityBase(); private: void __handleUpdate(activity_type_e activity, const activity_data_h data, double timestamp); diff --git a/src/device/social/Call.cpp b/src/device/social/Call.cpp index d8bbebe..460c281 100644 --- a/src/device/social/Call.cpp +++ b/src/device/social/Call.cpp @@ -14,14 +14,12 @@ * limitations under the License. */ -#include -#include -#include #include "SocialTypes.h" #include "Call.h" #define TELEPHONY_NOTI_ID_CNT 8 -GENERATE_PROVIDER_COMMON_IMPL(SocialStatusCall); + +using namespace ctx; static bool __telephonyInitialized = false; static telephony_noti_e __callNotiIds[] = @@ -38,42 +36,43 @@ static telephony_noti_e __callNotiIds[] = TELEPHONY_NOTI_VIDEO_CALL_STATUS_ALERTING, TELEPHONY_NOTI_VIDEO_CALL_STATUS_INCOMING, }; -static ctx::Json __latest; +static Json __latest; -ctx::SocialStatusCall::SocialStatusCall() +SocialStatusCall::SocialStatusCall() : + DeviceProviderBase(SOCIAL_ST_SUBJ_CALL) { __handleList.count = 0; __handleList.handle = NULL; } -ctx::SocialStatusCall::~SocialStatusCall() +SocialStatusCall::~SocialStatusCall() { } -bool ctx::SocialStatusCall::isSupported() +bool SocialStatusCall::isSupported() { return getSystemInfoBool("tizen.org/feature/network.telephony"); } -void ctx::SocialStatusCall::submitTriggerItem() +void SocialStatusCall::submitTriggerItem() { - context_manager::registerTriggerItem(SOCIAL_ST_SUBJ_CALL, OPS_SUBSCRIBE | OPS_READ, + registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, "{" "\"Medium\":{\"type\":\"string\",\"values\":[\"Voice\",\"Video\"]}," "\"State\":{\"type\":\"string\",\"values\":[\"Idle\",\"Connecting\",\"Connected\"]}," "\"Address\":{\"type\":\"string\"}" "}", NULL); - //TODO remove Connecting, Connected + /* TODO remove Connecting, Connected */ } -void ctx::SocialStatusCall::__updateCb(telephony_h handle, telephony_noti_e notiId, void *data, void *userData) +void SocialStatusCall::__updateCb(telephony_h handle, telephony_noti_e notiId, void *data, void *userData) { SocialStatusCall *instance = static_cast(userData); instance->__handleUpdate(handle, notiId, data); } -void ctx::SocialStatusCall::__handleUpdate(telephony_h handle, telephony_noti_e notiId, void* id) +void SocialStatusCall::__handleUpdate(telephony_h handle, telephony_noti_e notiId, void* id) { Json data; unsigned int count; @@ -153,13 +152,13 @@ void ctx::SocialStatusCall::__handleUpdate(telephony_h handle, telephony_noti_e } if (__latest != data) { - context_manager::publish(SOCIAL_ST_SUBJ_CALL, NULL, ERR_NONE, data); + publish(NULL, ERR_NONE, data); __latest = data.str(); } telephony_call_release_call_list(count, &callList); } -bool ctx::SocialStatusCall::__initTelephony() +bool SocialStatusCall::__initTelephony() { IF_FAIL_RETURN(!__telephonyInitialized, true); @@ -170,7 +169,7 @@ bool ctx::SocialStatusCall::__initTelephony() return true; } -void ctx::SocialStatusCall::__releaseTelephony() +void SocialStatusCall::__releaseTelephony() { IF_FAIL_VOID(__telephonyInitialized); @@ -179,9 +178,9 @@ void ctx::SocialStatusCall::__releaseTelephony() __telephonyInitialized = false; } -bool ctx::SocialStatusCall::__setCallback() +bool SocialStatusCall::__setCallback() { - //TODO: Consider dual-sim devices + /* TODO: Consider dual-sim devices */ IF_FAIL_RETURN_TAG(__initTelephony(), false, _E, "Initialization failed"); int err; @@ -201,7 +200,7 @@ CATCH: return false; } -void ctx::SocialStatusCall::__unsetCallback() +void SocialStatusCall::__unsetCallback() { for (unsigned int i = 0; i < __handleList.count; i++) { for (unsigned int j = 0; j < TELEPHONY_NOTI_ID_CNT; j++) { @@ -212,7 +211,7 @@ void ctx::SocialStatusCall::__unsetCallback() __releaseTelephony(); } -bool ctx::SocialStatusCall::__getCallState(telephony_call_h& handle, std::string& state) +bool SocialStatusCall::__getCallState(telephony_call_h& handle, std::string& state) { state.clear(); @@ -245,7 +244,7 @@ bool ctx::SocialStatusCall::__getCallState(telephony_call_h& handle, std::string return true; } -bool ctx::SocialStatusCall::__getCallType(telephony_call_h& handle, std::string& type) +bool SocialStatusCall::__getCallType(telephony_call_h& handle, std::string& type) { type.clear(); @@ -270,7 +269,7 @@ bool ctx::SocialStatusCall::__getCallType(telephony_call_h& handle, std::string& return true; } -bool ctx::SocialStatusCall::__getCallAddress(telephony_call_h& handle, std::string& address) +bool SocialStatusCall::__getCallAddress(telephony_call_h& handle, std::string& address) { address.clear(); @@ -280,7 +279,7 @@ bool ctx::SocialStatusCall::__getCallAddress(telephony_call_h& handle, std::stri if (number) { address = number; - free(number); + g_free(number); number = NULL; } @@ -289,7 +288,7 @@ bool ctx::SocialStatusCall::__getCallAddress(telephony_call_h& handle, std::stri return true; } -bool ctx::SocialStatusCall::__getCallHandleId(telephony_call_h& handle, unsigned int& id) +bool SocialStatusCall::__getCallHandleId(telephony_call_h& handle, unsigned int& id) { int err = telephony_call_get_handle_id(handle, &id); IF_FAIL_RETURN_TAG(err == TELEPHONY_ERROR_NONE, false, _E, "Getting handle id failed"); @@ -297,20 +296,20 @@ bool ctx::SocialStatusCall::__getCallHandleId(telephony_call_h& handle, unsigned return true; } -int ctx::SocialStatusCall::subscribe() +int SocialStatusCall::subscribe() { bool ret = __setCallback(); IF_FAIL_RETURN(ret, ERR_OPERATION_FAILED); return ERR_NONE; } -int ctx::SocialStatusCall::unsubscribe() +int SocialStatusCall::unsubscribe() { __unsetCallback(); return ERR_NONE; } -bool ctx::SocialStatusCall::__readCurrentStatus(telephony_h& handle, ctx::Json* data) +bool SocialStatusCall::__readCurrentStatus(telephony_h& handle, Json* data) { unsigned int count = 0; telephony_call_h *callList = NULL; @@ -352,7 +351,7 @@ bool ctx::SocialStatusCall::__readCurrentStatus(telephony_h& handle, ctx::Json* return true; } -int ctx::SocialStatusCall::read() +int SocialStatusCall::read() { bool temporaryHandle = false; if (!__telephonyInitialized) { @@ -380,7 +379,7 @@ int ctx::SocialStatusCall::read() __releaseTelephony(); if (ret) { - ctx::context_manager::replyToRead(SOCIAL_ST_SUBJ_CALL, NULL, ERR_NONE, data); + replyToRead(NULL, ERR_NONE, data); return ERR_NONE; } diff --git a/src/device/social/Call.h b/src/device/social/Call.h index 38fdab9..02a4eaa 100644 --- a/src/device/social/Call.h +++ b/src/device/social/Call.h @@ -23,27 +23,25 @@ namespace ctx { class SocialStatusCall : public DeviceProviderBase { - - GENERATE_PROVIDER_COMMON_DECL(SocialStatusCall); - public: + SocialStatusCall(); + ~SocialStatusCall(); + int subscribe(); int unsubscribe(); int read(); - static bool isSupported(); - static void submitTriggerItem(); + + bool isSupported(); + void submitTriggerItem(); private: telephony_handle_list_s __handleList; - SocialStatusCall(); - ~SocialStatusCall(); - bool __initTelephony(); void __releaseTelephony(); bool __setCallback(); void __unsetCallback(); - bool __readCurrentStatus(telephony_h& handle, ctx::Json* data); + bool __readCurrentStatus(telephony_h& handle, Json* data); bool __getCallState(telephony_call_h& handle, std::string& state); bool __getCallType(telephony_call_h& handle, std::string& type); diff --git a/src/device/social/Contacts.cpp b/src/device/social/Contacts.cpp index 4604c37..55ff19a 100644 --- a/src/device/social/Contacts.cpp +++ b/src/device/social/Contacts.cpp @@ -14,8 +14,6 @@ * limitations under the License. */ -#include -#include #include "SocialTypes.h" #include "Contacts.h" @@ -23,26 +21,27 @@ #define PERSON_VIEW _contacts_person._uri #define TIME_INTERVAL 1 -GENERATE_PROVIDER_COMMON_IMPL(SocialStatusContacts); +using namespace ctx; -ctx::SocialStatusContacts::SocialStatusContacts() : +SocialStatusContacts::SocialStatusContacts() : + DeviceProviderBase(SOCIAL_ST_SUBJ_CONTACTS), __latestMyProfile(0), __latestPerson(0) { } -ctx::SocialStatusContacts::~SocialStatusContacts() +SocialStatusContacts::~SocialStatusContacts() { } -bool ctx::SocialStatusContacts::isSupported() +bool SocialStatusContacts::isSupported() { return true; } -void ctx::SocialStatusContacts::submitTriggerItem() +void SocialStatusContacts::submitTriggerItem() { - context_manager::registerTriggerItem(SOCIAL_ST_SUBJ_CONTACTS, OPS_SUBSCRIBE, + registerTriggerItem(OPS_SUBSCRIBE, "{" "\"Event\":{\"type\":\"string\",\"values\":[\"Changed\"]}," "\"Type\":{\"type\":\"string\",\"values\":[\"MyProfile\",\"Person\"]}" @@ -50,13 +49,13 @@ void ctx::SocialStatusContacts::submitTriggerItem() NULL); } -void ctx::SocialStatusContacts::__updateCb(const char* viewUri, void* userData) +void SocialStatusContacts::__updateCb(const char* viewUri, void* userData) { SocialStatusContacts *instance = static_cast(userData); instance->__handleUpdate(viewUri); } -void ctx::SocialStatusContacts::__handleUpdate(const char* viewUri) +void SocialStatusContacts::__handleUpdate(const char* viewUri) { if (!STR_EQ(viewUri, _contacts_my_profile._uri) && !STR_EQ(viewUri, _contacts_person._uri)) { _W("Unknown view uri"); @@ -66,13 +65,13 @@ void ctx::SocialStatusContacts::__handleUpdate(const char* viewUri) std::string view = (STR_EQ(viewUri, _contacts_my_profile._uri)? SOCIAL_ST_MY_PROFILE : SOCIAL_ST_PERSON); IF_FAIL_VOID_TAG(!__isConsecutiveChange(viewUri), _D, "Ignore consecutive db change: %s", view.c_str()); - ctx::Json data; + Json data; data.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_CHANGED); data.set(NULL, SOCIAL_ST_TYPE, view); - context_manager::publish(SOCIAL_ST_SUBJ_CONTACTS, NULL, ERR_NONE, data); + publish(NULL, ERR_NONE, data); } -bool ctx::SocialStatusContacts::__isConsecutiveChange(const char* viewUri) +bool SocialStatusContacts::__isConsecutiveChange(const char* viewUri) { time_t now = time(NULL); double diff = 0; @@ -91,7 +90,7 @@ bool ctx::SocialStatusContacts::__isConsecutiveChange(const char* viewUri) return false; } -bool ctx::SocialStatusContacts::__setCallback() +bool SocialStatusContacts::__setCallback() { int err; @@ -111,7 +110,7 @@ CATCH: return false; } -void ctx::SocialStatusContacts::__unsetCallback() +void SocialStatusContacts::__unsetCallback() { contacts_db_remove_changed_cb(MY_PROFILE_VIEW, __updateCb, this); contacts_db_remove_changed_cb(PERSON_VIEW, __updateCb, this); @@ -122,14 +121,14 @@ void ctx::SocialStatusContacts::__unsetCallback() __latestPerson = 0; } -int ctx::SocialStatusContacts::subscribe() +int SocialStatusContacts::subscribe() { bool ret = __setCallback(); IF_FAIL_RETURN(ret, ERR_OPERATION_FAILED); return ERR_NONE; } -int ctx::SocialStatusContacts::unsubscribe() +int SocialStatusContacts::unsubscribe() { __unsetCallback(); return ERR_NONE; diff --git a/src/device/social/Contacts.h b/src/device/social/Contacts.h index b99929b..c5ced5a 100644 --- a/src/device/social/Contacts.h +++ b/src/device/social/Contacts.h @@ -23,22 +23,20 @@ namespace ctx { class SocialStatusContacts : public DeviceProviderBase { - - GENERATE_PROVIDER_COMMON_DECL(SocialStatusContacts); - public: + SocialStatusContacts(); + ~SocialStatusContacts(); + int subscribe(); int unsubscribe(); - static bool isSupported(); - static void submitTriggerItem(); + + bool isSupported(); + void submitTriggerItem(); private: time_t __latestMyProfile; time_t __latestPerson; - SocialStatusContacts(); - ~SocialStatusContacts(); - bool __setCallback(); void __unsetCallback(); void __handleUpdate(const char* viewUri); diff --git a/src/device/social/Email.cpp b/src/device/social/Email.cpp index c49f185..e67729e 100644 --- a/src/device/social/Email.cpp +++ b/src/device/social/Email.cpp @@ -14,40 +14,38 @@ * limitations under the License. */ -#include #include - -#include #include "SocialTypes.h" #include "Email.h" -GENERATE_PROVIDER_COMMON_IMPL(SocialStatusEmail); +using namespace ctx; -ctx::SocialStatusEmail::SocialStatusEmail() : +SocialStatusEmail::SocialStatusEmail() : + DeviceProviderBase(SOCIAL_ST_SUBJ_EMAIL), __dbusSignalId(-1), __dbusWatcher(DBusType::SESSION) { } -ctx::SocialStatusEmail::~SocialStatusEmail() +SocialStatusEmail::~SocialStatusEmail() { } -bool ctx::SocialStatusEmail::isSupported() +bool SocialStatusEmail::isSupported() { return getSystemInfoBool("tizen.org/feature/network.telephony"); } -void ctx::SocialStatusEmail::submitTriggerItem() +void SocialStatusEmail::submitTriggerItem() { - context_manager::registerTriggerItem(SOCIAL_ST_SUBJ_EMAIL, OPS_SUBSCRIBE, + registerTriggerItem(OPS_SUBSCRIBE, "{" "\"Event\":{\"type\":\"string\",\"values\":[\"Received\",\"Sent\"]}" "}", NULL); } -void ctx::SocialStatusEmail::onSignal(const char* sender, const char* path, const char* iface, const char* name, GVariant* param) +void SocialStatusEmail::onSignal(const char* sender, const char* path, const char* iface, const char* name, GVariant* param) { gint subType = 0; gint gi1 = 0; @@ -60,20 +58,20 @@ void ctx::SocialStatusEmail::onSignal(const char* sender, const char* path, cons if (subType == 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", subType, gi1, gc, gi2, gi3); - ctx::Json dataUpdated; + Json dataUpdated; dataUpdated.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_RECEIVED); - context_manager::publish(SOCIAL_ST_SUBJ_EMAIL, NULL, ERR_NONE, dataUpdated); + publish(NULL, ERR_NONE, dataUpdated); } else if (subType == NOTI_SEND_FINISH) { _D("sub type: %d, gi1: %d, gc: %s, gi2: %d, gi3: %d", subType, gi1, gc, gi2, gi3); - ctx::Json dataUpdated; + Json dataUpdated; dataUpdated.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_SENT); - context_manager::publish(SOCIAL_ST_SUBJ_EMAIL, NULL, ERR_NONE, dataUpdated); + publish(NULL, ERR_NONE, dataUpdated); } } -int ctx::SocialStatusEmail::subscribe() +int SocialStatusEmail::subscribe() { __dbusSignalId = __dbusWatcher.watch(NULL, NULL, "User.Email.NetworkStatus", "email", this); IF_FAIL_RETURN_TAG(__dbusSignalId >= 0, ERR_OPERATION_FAILED, _E, "Email dbus signal subscription failed"); @@ -81,7 +79,7 @@ int ctx::SocialStatusEmail::subscribe() } -int ctx::SocialStatusEmail::unsubscribe() +int SocialStatusEmail::unsubscribe() { __dbusWatcher.unwatch(__dbusSignalId); return ERR_NONE; diff --git a/src/device/social/Email.h b/src/device/social/Email.h index 4daaea0..cf44ae7 100644 --- a/src/device/social/Email.h +++ b/src/device/social/Email.h @@ -23,22 +23,21 @@ namespace ctx { class SocialStatusEmail : public DeviceProviderBase, public IDBusSignalListener { - - GENERATE_PROVIDER_COMMON_DECL(SocialStatusEmail); - public: + SocialStatusEmail(); + ~SocialStatusEmail(); + int subscribe(); int unsubscribe(); + + bool isSupported(); + void submitTriggerItem(); + void onSignal(const char *sender, const char *path, const char *iface, const char *name, GVariant *param); - static bool isSupported(); - static void submitTriggerItem(); private: int64_t __dbusSignalId; DBusSignalWatcher __dbusWatcher; - - SocialStatusEmail(); - ~SocialStatusEmail(); }; } diff --git a/src/device/social/Message.cpp b/src/device/social/Message.cpp index 7643175..f55b3e6 100644 --- a/src/device/social/Message.cpp +++ b/src/device/social/Message.cpp @@ -14,32 +14,31 @@ * limitations under the License. */ -#include -#include #include "SocialTypes.h" #include "Message.h" #define MAX_ADDR_SIZE 20 -GENERATE_PROVIDER_COMMON_IMPL(SocialStatusMessage); +using namespace ctx; -ctx::SocialStatusMessage::SocialStatusMessage() : +SocialStatusMessage::SocialStatusMessage() : + DeviceProviderBase(SOCIAL_ST_SUBJ_MESSAGE), __messageHandle(NULL) { } -ctx::SocialStatusMessage::~SocialStatusMessage() +SocialStatusMessage::~SocialStatusMessage() { } -bool ctx::SocialStatusMessage::isSupported() +bool SocialStatusMessage::isSupported() { return getSystemInfoBool("tizen.org/feature/network.telephony"); } -void ctx::SocialStatusMessage::submitTriggerItem() +void SocialStatusMessage::submitTriggerItem() { - context_manager::registerTriggerItem(SOCIAL_ST_SUBJ_MESSAGE, OPS_SUBSCRIBE, + registerTriggerItem(OPS_SUBSCRIBE, "{" "\"Event\":{\"type\":\"string\",\"values\":[\"Received\"]}," "\"Type\":{\"type\":\"string\",\"values\":[\"SMS\",\"MMS\"]}," @@ -48,18 +47,18 @@ void ctx::SocialStatusMessage::submitTriggerItem() NULL); } -void ctx::SocialStatusMessage::__updateCb(msg_handle_t handle, msg_struct_t msg, void* userData) +void SocialStatusMessage::__updateCb(msg_handle_t handle, msg_struct_t msg, void* userData) { SocialStatusMessage *instance = static_cast(userData); instance->__handleUpdate(msg); } -void ctx::SocialStatusMessage::__handleUpdate(msg_struct_t msg) +void SocialStatusMessage::__handleUpdate(msg_struct_t msg) { int err; int type; char address[MAX_ADDR_SIZE]; - ctx::Json data; + Json data; err = msg_get_int_value(msg, MSG_MESSAGE_TYPE_INT, &type); IF_FAIL_VOID_TAG(err == MSG_SUCCESS, _W, "Getting message type failed"); @@ -91,10 +90,10 @@ void ctx::SocialStatusMessage::__handleUpdate(msg_struct_t msg) data.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_RECEIVED); data.set(NULL, SOCIAL_ST_ADDRESS, address); - context_manager::publish(SOCIAL_ST_SUBJ_MESSAGE, NULL, ERR_NONE, data); + publish(NULL, ERR_NONE, data); } -bool ctx::SocialStatusMessage::__setCallback() +bool SocialStatusMessage::__setCallback() { int err; @@ -112,7 +111,7 @@ bool ctx::SocialStatusMessage::__setCallback() return true; } -void ctx::SocialStatusMessage::__unsetCallback() +void SocialStatusMessage::__unsetCallback() { if (__messageHandle) msg_close_msg_handle(&__messageHandle); @@ -120,14 +119,14 @@ void ctx::SocialStatusMessage::__unsetCallback() __messageHandle = NULL; } -int ctx::SocialStatusMessage::subscribe() +int SocialStatusMessage::subscribe() { bool ret = __setCallback(); IF_FAIL_RETURN(ret, ERR_OPERATION_FAILED); return ERR_NONE; } -int ctx::SocialStatusMessage::unsubscribe() +int SocialStatusMessage::unsubscribe() { __unsetCallback(); return ERR_NONE; diff --git a/src/device/social/Message.h b/src/device/social/Message.h index 91c33b3..78d006b 100644 --- a/src/device/social/Message.h +++ b/src/device/social/Message.h @@ -24,22 +24,20 @@ namespace ctx { class SocialStatusMessage : public DeviceProviderBase { - - GENERATE_PROVIDER_COMMON_DECL(SocialStatusMessage); - public: + SocialStatusMessage(); + ~SocialStatusMessage(); + int subscribe(); int unsubscribe(); - static bool isSupported(); - static void submitTriggerItem(); + + bool isSupported(); + void submitTriggerItem(); private: msg_handle_t __messageHandle; bool __beingSubscribed; - SocialStatusMessage(); - ~SocialStatusMessage(); - bool __setCallback(); void __unsetCallback(); void __handleUpdate(msg_struct_t msg); diff --git a/src/device/system/Alarm.cpp b/src/device/system/Alarm.cpp index fc7aa10..edc7bad 100644 --- a/src/device/system/Alarm.cpp +++ b/src/device/system/Alarm.cpp @@ -14,17 +14,17 @@ * limitations under the License. */ -#include #include "SystemTypes.h" #include "Alarm.h" -GENERATE_PROVIDER_COMMON_IMPL(DeviceStatusAlarm); +using namespace ctx; -ctx::DeviceStatusAlarm::DeviceStatusAlarm() +DeviceStatusAlarm::DeviceStatusAlarm() + : ContextProvider(DEVICE_ST_SUBJ_ALARM) { } -ctx::DeviceStatusAlarm::~DeviceStatusAlarm() +DeviceStatusAlarm::~DeviceStatusAlarm() { __clear(); @@ -34,14 +34,14 @@ ctx::DeviceStatusAlarm::~DeviceStatusAlarm() __optionSet.clear(); } -bool ctx::DeviceStatusAlarm::isSupported() +bool DeviceStatusAlarm::isSupported() { return true; } -void ctx::DeviceStatusAlarm::submitTriggerItem() +void DeviceStatusAlarm::submitTriggerItem() { - context_manager::registerTriggerItem(DEVICE_ST_SUBJ_ALARM, OPS_SUBSCRIBE, + registerTriggerItem(OPS_SUBSCRIBE, "{" "\"TimeOfDay\":{\"type\":\"integer\",\"min\":0,\"max\":1439}," "\"DayOfWeek\":{\"type\":\"string\",\"values\":[\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\",\"Sun\",\"Weekday\",\"Weekend\"]}" @@ -49,33 +49,7 @@ void ctx::DeviceStatusAlarm::submitTriggerItem() NULL); } -int ctx::DeviceStatusAlarm::subscribe(const char *subject, ctx::Json option, ctx::Json *requestResult) -{ - int ret = subscribe(option); - __destroyIfUnused(); - return ret; -} - -int ctx::DeviceStatusAlarm::unsubscribe(const char *subject, ctx::Json option) -{ - int ret = unsubscribe(option); - __destroyIfUnused(); - return ret; -} - -int ctx::DeviceStatusAlarm::read(const char *subject, ctx::Json option, ctx::Json *requestResult) -{ - __destroyIfUnused(); - return ERR_NOT_SUPPORTED; -} - -int ctx::DeviceStatusAlarm::write(const char *subject, ctx::Json data, ctx::Json *requestResult) -{ - __destroyIfUnused(); - return ERR_NOT_SUPPORTED; -} - -int ctx::DeviceStatusAlarm::subscribe(ctx::Json option) +int DeviceStatusAlarm::subscribe(Json option, Json *requestResult) { int dow = __getArrangedDayOfWeek(option); @@ -84,7 +58,7 @@ int ctx::DeviceStatusAlarm::subscribe(ctx::Json option) __add(time, dow); } - ctx::Json* elem = new(std::nothrow) ctx::Json(option); + Json* elem = new(std::nothrow) Json(option); if (elem) { __optionSet.insert(elem); } else { @@ -96,7 +70,7 @@ int ctx::DeviceStatusAlarm::subscribe(ctx::Json option) return ERR_NONE; } -int ctx::DeviceStatusAlarm::unsubscribe(ctx::Json option) +int DeviceStatusAlarm::unsubscribe(Json option) { int dow = __getArrangedDayOfWeek(option); @@ -114,25 +88,25 @@ int ctx::DeviceStatusAlarm::unsubscribe(ctx::Json option) return ERR_NONE; } -int ctx::DeviceStatusAlarm::__getArrangedDayOfWeek(ctx::Json& option) +int DeviceStatusAlarm::__getArrangedDayOfWeek(Json& option) { int dow = 0; std::string tempDay; for (int i = 0; option.getAt(NULL, DEVICE_ST_DAY_OF_WEEK, i, &tempDay); i++) { - dow |= ctx::TimerManager::dowToInt(tempDay); + dow |= TimerManager::dowToInt(tempDay); } _D("Requested day of week (%#x)", dow); return dow; } -ctx::DeviceStatusAlarm::RefCountArray::RefCountArray() +DeviceStatusAlarm::RefCountArray::RefCountArray() { memset(count, 0, sizeof(int) * DAYS_PER_WEEK); } -int ctx::DeviceStatusAlarm::__mergeDayOfWeek(int* refCnt) +int DeviceStatusAlarm::__mergeDayOfWeek(int* refCnt) { int dayOfWeek = 0; @@ -145,7 +119,7 @@ int ctx::DeviceStatusAlarm::__mergeDayOfWeek(int* refCnt) return dayOfWeek; } -bool ctx::DeviceStatusAlarm::__add(int minute, int dayOfWeek) +bool DeviceStatusAlarm::__add(int minute, int dayOfWeek) { IF_FAIL_RETURN_TAG(minute >=0 && minute < 1440 && dayOfWeek > 0 && dayOfWeek <= static_cast(DayOfWeek::EVERYDAY), @@ -162,7 +136,7 @@ bool ctx::DeviceStatusAlarm::__add(int minute, int dayOfWeek) return __resetTimer(minute); } -bool ctx::DeviceStatusAlarm::__remove(int minute, int dayOfWeek) +bool DeviceStatusAlarm::__remove(int minute, int dayOfWeek) { IF_FAIL_RETURN_TAG(minute >= 0 && minute < 1440 && dayOfWeek > 0 && dayOfWeek <= static_cast(DayOfWeek::EVERYDAY), @@ -179,7 +153,7 @@ bool ctx::DeviceStatusAlarm::__remove(int minute, int dayOfWeek) return __resetTimer(minute); } -bool ctx::DeviceStatusAlarm::__resetTimer(int minute) +bool DeviceStatusAlarm::__resetTimer(int minute) { int dayOfWeek = __mergeDayOfWeek(__refCountMap[minute].count); TimerState &timer = __timerStateMap[minute]; @@ -216,7 +190,7 @@ bool ctx::DeviceStatusAlarm::__resetTimer(int minute) return true; } -void ctx::DeviceStatusAlarm::__clear() +void DeviceStatusAlarm::__clear() { for (auto it = __timerStateMap.begin(); it != __timerStateMap.end(); ++it) { if (it->second.timerId > 0) { @@ -228,7 +202,7 @@ void ctx::DeviceStatusAlarm::__clear() __refCountMap.clear(); } -bool ctx::DeviceStatusAlarm::onTimerExpired(int timerId) +bool DeviceStatusAlarm::onTimerExpired(int timerId) { time_t rawTime; struct tm timeInfo; @@ -246,25 +220,25 @@ bool ctx::DeviceStatusAlarm::onTimerExpired(int timerId) return true; } -void ctx::DeviceStatusAlarm::__handleUpdate(int hour, int min, int dayOfWeek) +void DeviceStatusAlarm::__handleUpdate(int hour, int min, int dayOfWeek) { _I("Time: %02d:%02d, Day of Week: %#x", hour, min, dayOfWeek); - ctx::Json dataRead; + Json dataRead; int resultTime = hour * 60 + min; - std::string resultDay = ctx::TimerManager::dowToStr(dayOfWeek); + std::string resultDay = TimerManager::dowToStr(dayOfWeek); dataRead.set(NULL, DEVICE_ST_TIME_OF_DAY, resultTime); dataRead.set(NULL, DEVICE_ST_DAY_OF_WEEK, resultDay); for (auto it = __optionSet.begin(); it != __optionSet.end(); ++it) { - ctx::Json option = (**it); + Json option = (**it); if (__isMatched(option, resultTime, resultDay)) { - context_manager::publish(DEVICE_ST_SUBJ_ALARM, option, ERR_NONE, dataRead); + publish(option, ERR_NONE, dataRead); } } } -bool ctx::DeviceStatusAlarm::__isMatched(ctx::Json& option, int time, std::string day) +bool DeviceStatusAlarm::__isMatched(Json& option, int time, std::string day) { bool ret = false; int optionTime; @@ -286,7 +260,7 @@ bool ctx::DeviceStatusAlarm::__isMatched(ctx::Json& option, int time, std::strin return false; } -ctx::DeviceStatusAlarm::OptionSet::iterator ctx::DeviceStatusAlarm::__findOption(ctx::Json& option) +DeviceStatusAlarm::OptionSet::iterator DeviceStatusAlarm::__findOption(Json& option) { for (auto it = __optionSet.begin(); it != __optionSet.end(); ++it) { if (option == (**it)) @@ -294,9 +268,3 @@ ctx::DeviceStatusAlarm::OptionSet::iterator ctx::DeviceStatusAlarm::__findOption } return __optionSet.end(); } - -void ctx::DeviceStatusAlarm::__destroyIfUnused() -{ - IF_FAIL_VOID(__optionSet.empty()); - destroy(NULL); -} diff --git a/src/device/system/Alarm.h b/src/device/system/Alarm.h index 0ae4fce..5535e5c 100644 --- a/src/device/system/Alarm.h +++ b/src/device/system/Alarm.h @@ -19,34 +19,26 @@ #include #include -#include #include -#include "../DeviceProviderBase.h" +#include namespace ctx { - class DeviceStatusAlarm : public ContextProviderBase, ITimerListener { - - GENERATE_PROVIDER_COMMON_DECL(DeviceStatusAlarm); - + class DeviceStatusAlarm : public ContextProvider, ITimerListener { 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); + DeviceStatusAlarm(); + ~DeviceStatusAlarm(); + + int subscribe(Json option, Json *requestResult); + int unsubscribe(Json option); - int subscribe(ctx::Json option); - int unsubscribe(ctx::Json option); - static bool isSupported(); - static void submitTriggerItem(); + bool isSupported(); + void submitTriggerItem(); protected: bool onTimerExpired(int timerId); private: - DeviceStatusAlarm(); - ~DeviceStatusAlarm(); - struct RefCountArray { int count[7]; /* reference counts for days of week*/ RefCountArray(); @@ -60,7 +52,7 @@ namespace ctx { typedef std::map RefCountMap; typedef std::map TimerStateMap; - typedef std::set OptionSet; + typedef std::set OptionSet; RefCountMap __refCountMap; TimerStateMap __timerStateMap; @@ -73,14 +65,11 @@ namespace ctx { void __clear(); void __handleUpdate(int hour, int min, int dayOfWeek); - int __getArrangedDayOfWeek(ctx::Json& option); + int __getArrangedDayOfWeek(Json& option); int __mergeDayOfWeek(int *refCnt); - bool __isMatched(ctx::Json& option, int time, std::string day); - OptionSet::iterator __findOption(ctx::Json& option); - - void __destroyIfUnused(); - + bool __isMatched(Json& option, int time, std::string day); + OptionSet::iterator __findOption(Json& option); }; } diff --git a/src/device/system/Battery.cpp b/src/device/system/Battery.cpp index 8313333..94c3d58 100644 --- a/src/device/system/Battery.cpp +++ b/src/device/system/Battery.cpp @@ -14,28 +14,28 @@ * limitations under the License. */ -#include #include "SystemTypes.h" #include "Battery.h" -GENERATE_PROVIDER_COMMON_IMPL(DeviceStatusBattery); +using namespace ctx; -ctx::DeviceStatusBattery::DeviceStatusBattery() +DeviceStatusBattery::DeviceStatusBattery() + : DeviceProviderBase(DEVICE_ST_SUBJ_BATTERY) { } -ctx::DeviceStatusBattery::~DeviceStatusBattery() +DeviceStatusBattery::~DeviceStatusBattery() { } -bool ctx::DeviceStatusBattery::isSupported() +bool DeviceStatusBattery::isSupported() { return true; } -void ctx::DeviceStatusBattery::submitTriggerItem() +void DeviceStatusBattery::submitTriggerItem() { - context_manager::registerTriggerItem(DEVICE_ST_SUBJ_BATTERY, OPS_SUBSCRIBE | OPS_READ, + registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, "{" "\"Level\":{\"type\":\"string\",\"values\":[\"Empty\",\"Critical\",\"Low\",\"Normal\",\"High\",\"Full\"]}," TRIG_BOOL_ITEM_DEF("IsCharging") @@ -43,7 +43,7 @@ void ctx::DeviceStatusBattery::submitTriggerItem() NULL); } -void ctx::DeviceStatusBattery::__updateCb(device_callback_e deviceType, void* value, void* userData) +void DeviceStatusBattery::__updateCb(device_callback_e deviceType, void* value, void* userData) { IF_FAIL_VOID(deviceType == DEVICE_CALLBACK_BATTERY_LEVEL); @@ -51,14 +51,14 @@ void ctx::DeviceStatusBattery::__updateCb(device_callback_e deviceType, void* va instance->__handleUpdate(deviceType, value); } -void ctx::DeviceStatusBattery::__handleUpdate(device_callback_e deviceType, void* value) +void DeviceStatusBattery::__handleUpdate(device_callback_e deviceType, void* value) { intptr_t level = (intptr_t)value; const char* levelString = __transToString(level); IF_FAIL_VOID(levelString); - ctx::Json dataRead; + Json dataRead; dataRead.set(NULL, DEVICE_ST_LEVEL, levelString); bool chargingState = false; @@ -66,10 +66,10 @@ void ctx::DeviceStatusBattery::__handleUpdate(device_callback_e deviceType, void IF_FAIL_VOID_TAG(ret == DEVICE_ERROR_NONE, _E, "Getting state failed"); dataRead.set(NULL, DEVICE_ST_IS_CHARGING, chargingState ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); - ctx::context_manager::publish(DEVICE_ST_SUBJ_BATTERY, NULL, ERR_NONE, dataRead); + publish(NULL, ERR_NONE, dataRead); } -const char* ctx::DeviceStatusBattery::__transToString(intptr_t level) +const char* DeviceStatusBattery::__transToString(intptr_t level) { switch (level) { case DEVICE_BATTERY_LEVEL_EMPTY: @@ -103,24 +103,24 @@ const char* ctx::DeviceStatusBattery::__transToString(intptr_t level) } } -int ctx::DeviceStatusBattery::subscribe() +int DeviceStatusBattery::subscribe() { int ret = device_add_callback(DEVICE_CALLBACK_BATTERY_LEVEL, __updateCb, this); IF_FAIL_RETURN(ret == DEVICE_ERROR_NONE, ERR_OPERATION_FAILED); return ERR_NONE; } -int ctx::DeviceStatusBattery::unsubscribe() +int DeviceStatusBattery::unsubscribe() { int ret = device_remove_callback(DEVICE_CALLBACK_BATTERY_LEVEL, __updateCb); IF_FAIL_RETURN(ret == DEVICE_ERROR_NONE, ERR_OPERATION_FAILED); return ERR_NONE; } -int ctx::DeviceStatusBattery::read() +int DeviceStatusBattery::read() { device_battery_level_e level; - ctx::Json dataRead; + Json dataRead; int ret = device_battery_get_level_status(&level); IF_FAIL_RETURN(ret == DEVICE_ERROR_NONE, ERR_OPERATION_FAILED); @@ -136,6 +136,6 @@ int ctx::DeviceStatusBattery::read() dataRead.set(NULL, DEVICE_ST_IS_CHARGING, chargingState ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); - ctx::context_manager::replyToRead(DEVICE_ST_SUBJ_BATTERY, NULL, ERR_NONE, dataRead); + replyToRead(NULL, ERR_NONE, dataRead); return ERR_NONE; } diff --git a/src/device/system/Battery.h b/src/device/system/Battery.h index cbc11ba..d016798 100644 --- a/src/device/system/Battery.h +++ b/src/device/system/Battery.h @@ -24,19 +24,18 @@ namespace ctx { class DeviceStatusBattery : public DeviceProviderBase { - - GENERATE_PROVIDER_COMMON_DECL(DeviceStatusBattery); - public: + DeviceStatusBattery(); + ~DeviceStatusBattery(); + int subscribe(); int unsubscribe(); int read(); - static bool isSupported(); - static void submitTriggerItem(); + + bool isSupported(); + void submitTriggerItem(); private: - DeviceStatusBattery(); - ~DeviceStatusBattery(); const char* __transToString(intptr_t level); void __handleUpdate(device_callback_e deviceType, void* value); static void __updateCb(device_callback_e deviceType, void* value, void* userData); diff --git a/src/device/system/Headphone.cpp b/src/device/system/Headphone.cpp index 3ec1281..0093af9 100644 --- a/src/device/system/Headphone.cpp +++ b/src/device/system/Headphone.cpp @@ -14,16 +14,16 @@ * limitations under the License. */ -#include #include "SystemTypes.h" #include "Headphone.h" #define HANDLING_DELAY 2000 #define MAX_HANDLING_COUNT 3 -GENERATE_PROVIDER_COMMON_IMPL(DeviceStatusHeadphone); +using namespace ctx; -ctx::DeviceStatusHeadphone::DeviceStatusHeadphone() : +DeviceStatusHeadphone::DeviceStatusHeadphone() : + DeviceProviderBase(DEVICE_ST_SUBJ_HEADPHONE), __connected(false), __audioJackState(RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED), __btAudioState(false), @@ -33,18 +33,18 @@ ctx::DeviceStatusHeadphone::DeviceStatusHeadphone() : { } -ctx::DeviceStatusHeadphone::~DeviceStatusHeadphone() +DeviceStatusHeadphone::~DeviceStatusHeadphone() { } -bool ctx::DeviceStatusHeadphone::isSupported() +bool DeviceStatusHeadphone::isSupported() { return true; } -void ctx::DeviceStatusHeadphone::submitTriggerItem() +void DeviceStatusHeadphone::submitTriggerItem() { - context_manager::registerTriggerItem(DEVICE_ST_SUBJ_HEADPHONE, OPS_SUBSCRIBE | OPS_READ, + registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, "{" TRIG_BOOL_ITEM_DEF("IsConnected") "," "\"Type\":{\"type\":\"string\",\"values\":[\"Normal\",\"Headset\",\"Bluetooth\"]}" @@ -52,7 +52,7 @@ void ctx::DeviceStatusHeadphone::submitTriggerItem() NULL); } -int ctx::DeviceStatusHeadphone::subscribe() +int DeviceStatusHeadphone::subscribe() { __connected = __getCurrentStatus(); @@ -66,7 +66,7 @@ int ctx::DeviceStatusHeadphone::subscribe() return ERR_NONE; } -int ctx::DeviceStatusHeadphone::unsubscribe() +int DeviceStatusHeadphone::unsubscribe() { runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS); __unsetBtAudioCallback(); @@ -74,19 +74,19 @@ int ctx::DeviceStatusHeadphone::unsubscribe() return ERR_NONE; } -int ctx::DeviceStatusHeadphone::read() +int DeviceStatusHeadphone::read() { if (!__beingSubscribed) __connected = __getCurrentStatus(); Json data; __generateDataPacket(&data); - ctx::context_manager::replyToRead(DEVICE_ST_SUBJ_HEADPHONE, NULL, ERR_NONE, data); + replyToRead(NULL, ERR_NONE, data); return ERR_NONE; } -void ctx::DeviceStatusHeadphone::__setBtAudioCallback() +void DeviceStatusHeadphone::__setBtAudioCallback() { IF_FAIL_VOID(!__btAudioCallbackOn); int ret; @@ -106,7 +106,7 @@ void ctx::DeviceStatusHeadphone::__setBtAudioCallback() __btAudioCallbackOn = true; } -void ctx::DeviceStatusHeadphone::__unsetBtAudioCallback() +void DeviceStatusHeadphone::__unsetBtAudioCallback() { IF_FAIL_VOID(__btAudioCallbackOn); @@ -116,12 +116,12 @@ void ctx::DeviceStatusHeadphone::__unsetBtAudioCallback() __btAudioCallbackOn = false; } -void ctx::DeviceStatusHeadphone::__setBtAudioState(bool state) +void DeviceStatusHeadphone::__setBtAudioState(bool state) { __btAudioState = state; } -bool ctx::DeviceStatusHeadphone::__getCurrentStatus() +bool DeviceStatusHeadphone::__getCurrentStatus() { int ret; @@ -140,7 +140,7 @@ bool ctx::DeviceStatusHeadphone::__getCurrentStatus() return ((__audioJackState != RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED) || __btAudioState); } -void ctx::DeviceStatusHeadphone::__generateDataPacket(ctx::Json* data) +void DeviceStatusHeadphone::__generateDataPacket(Json* data) { data->set(NULL, DEVICE_ST_IS_CONNECTED, __connected ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); @@ -158,36 +158,36 @@ void ctx::DeviceStatusHeadphone::__generateDataPacket(ctx::Json* data) } } -bool ctx::DeviceStatusHeadphone::__handleUpdate() +bool DeviceStatusHeadphone::__handleUpdate() { bool prevState = __connected; __connected = ((__audioJackState != RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED) || __btAudioState); IF_FAIL_RETURN(prevState != __connected, false); - ctx::Json data; + Json data; __generateDataPacket(&data); - ctx::context_manager::publish(DEVICE_ST_SUBJ_HEADPHONE, NULL, ERR_NONE, data); + publish(NULL, ERR_NONE, data); return true; } -void ctx::DeviceStatusHeadphone::__handleAudioJackEvent() +void DeviceStatusHeadphone::__handleAudioJackEvent() { int ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &__audioJackState); IF_FAIL_VOID_TAG(ret == ERR_NONE, _E, "Getting runtime info failed"); __handleUpdate(); } -void ctx::DeviceStatusHeadphone::__onAudioJackStateChanged(runtime_info_key_e runtimeKey, void* userData) +void DeviceStatusHeadphone::__onAudioJackStateChanged(runtime_info_key_e runtimeKey, void* userData) { _D("EarJack"); - ctx::DeviceStatusHeadphone *instance = static_cast(userData); + DeviceStatusHeadphone *instance = static_cast(userData); instance->__handleAudioJackEvent(); } -void ctx::DeviceStatusHeadphone::__onBtConnectionChanged(bool connected, bt_device_connection_info_s *connInfo, void *userData) +void DeviceStatusHeadphone::__onBtConnectionChanged(bool connected, bt_device_connection_info_s *connInfo, void *userData) { - ctx::DeviceStatusHeadphone *instance = static_cast(userData); + DeviceStatusHeadphone *instance = static_cast(userData); IF_FAIL_VOID(connected != instance->__btAudioState); IF_FAIL_VOID(!instance->__btEventHandlerAdded); @@ -201,10 +201,10 @@ void ctx::DeviceStatusHeadphone::__onBtConnectionChanged(bool connected, bt_devi } } -gboolean ctx::DeviceStatusHeadphone::__handleBtEvent(gpointer data) +gboolean DeviceStatusHeadphone::__handleBtEvent(gpointer data) { _D("BT state checking started"); - ctx::DeviceStatusHeadphone *instance = static_cast(data); + DeviceStatusHeadphone *instance = static_cast(data); instance->__btEventHandlerAdded = false; instance->__setBtAudioState(false); @@ -219,7 +219,7 @@ gboolean ctx::DeviceStatusHeadphone::__handleBtEvent(gpointer data) return TRUE; } -bool ctx::DeviceStatusHeadphone::__onBtBond(bt_device_info_s *deviceInfo, void* userData) +bool DeviceStatusHeadphone::__onBtBond(bt_device_info_s *deviceInfo, void* userData) { if (deviceInfo->bt_class.major_device_class != BT_MAJOR_DEVICE_CLASS_AUDIO_VIDEO) return true; @@ -229,7 +229,7 @@ bool ctx::DeviceStatusHeadphone::__onBtBond(bt_device_info_s *deviceInfo, void* IF_FAIL_RETURN_TAG(err == BT_ERROR_NONE, false, _E, "bt_device_is_profile_connected() failed"); if (st) { - ctx::DeviceStatusHeadphone *instance = static_cast(userData); + DeviceStatusHeadphone *instance = static_cast(userData); instance->__setBtAudioState(true); return false; } diff --git a/src/device/system/Headphone.h b/src/device/system/Headphone.h index 394a6d9..00edcfd 100644 --- a/src/device/system/Headphone.h +++ b/src/device/system/Headphone.h @@ -25,15 +25,16 @@ namespace ctx { class DeviceStatusHeadphone : public DeviceProviderBase { - - GENERATE_PROVIDER_COMMON_DECL(DeviceStatusHeadphone); - public: + DeviceStatusHeadphone(); + ~DeviceStatusHeadphone(); + int subscribe(); int unsubscribe(); int read(); - static bool isSupported(); - static void submitTriggerItem(); + + bool isSupported(); + void submitTriggerItem(); private: bool __connected; @@ -43,9 +44,6 @@ namespace ctx { bool __btEventHandlerAdded; int __btEventHandlingCount; - DeviceStatusHeadphone(); - ~DeviceStatusHeadphone(); - bool __getCurrentStatus(); void __setBtAudioCallback(); void __unsetBtAudioCallback(); diff --git a/src/device/system/Psmode.cpp b/src/device/system/Psmode.cpp index 894faf0..c52b176 100644 --- a/src/device/system/Psmode.cpp +++ b/src/device/system/Psmode.cpp @@ -14,73 +14,73 @@ * limitations under the License. */ -#include #include "SystemTypes.h" #include "Psmode.h" -GENERATE_PROVIDER_COMMON_IMPL(DeviceStatusPsmode); +using namespace ctx; -ctx::DeviceStatusPsmode::DeviceStatusPsmode() +DeviceStatusPsmode::DeviceStatusPsmode() : + DeviceProviderBase(DEVICE_ST_SUBJ_PSMODE) { } -ctx::DeviceStatusPsmode::~DeviceStatusPsmode() +DeviceStatusPsmode::~DeviceStatusPsmode() { } -bool ctx::DeviceStatusPsmode::isSupported() +bool DeviceStatusPsmode::isSupported() { return true; } -void ctx::DeviceStatusPsmode::submitTriggerItem() +void DeviceStatusPsmode::submitTriggerItem() { - context_manager::registerTriggerItem(DEVICE_ST_SUBJ_PSMODE, OPS_SUBSCRIBE | OPS_READ, + registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, "{" TRIG_BOOL_ITEM_DEF("IsEnabled") "}", NULL); } -void ctx::DeviceStatusPsmode::__updateCb(keynode_t *node, void* userData) +void DeviceStatusPsmode::__updateCb(keynode_t *node, void* userData) { DeviceStatusPsmode *instance = static_cast(userData); instance->__handleUpdate(node); } -void ctx::DeviceStatusPsmode::__handleUpdate(keynode_t *node) +void DeviceStatusPsmode::__handleUpdate(keynode_t *node) { int status; - ctx::Json dataRead; + Json dataRead; status = vconf_keynode_get_int(node); IF_FAIL_VOID_TAG(status >= 0, _E, "Getting state failed"); 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, dataRead); + publish(NULL, ERR_NONE, dataRead); } -int ctx::DeviceStatusPsmode::subscribe() +int DeviceStatusPsmode::subscribe() { int ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE, __updateCb, this); IF_FAIL_RETURN(ret == VCONF_OK, ERR_OPERATION_FAILED); return ERR_NONE; } -int ctx::DeviceStatusPsmode::unsubscribe() +int DeviceStatusPsmode::unsubscribe() { int ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE, __updateCb); IF_FAIL_RETURN(ret == VCONF_OK, ERR_OPERATION_FAILED); return ERR_NONE; } -int ctx::DeviceStatusPsmode::read() +int DeviceStatusPsmode::read() { int mode; int ret = vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &mode); IF_FAIL_RETURN(ret == VCONF_OK, ERR_OPERATION_FAILED); - ctx::Json dataRead; + Json dataRead; dataRead.set(NULL, DEVICE_ST_IS_ENABLED, mode == 0 ? DEVICE_ST_FALSE : DEVICE_ST_TRUE); - ctx::context_manager::replyToRead(DEVICE_ST_SUBJ_PSMODE, NULL, ERR_NONE, dataRead); + replyToRead(NULL, ERR_NONE, dataRead); return ERR_NONE; } diff --git a/src/device/system/Psmode.h b/src/device/system/Psmode.h index d18201e..d324ac3 100644 --- a/src/device/system/Psmode.h +++ b/src/device/system/Psmode.h @@ -23,19 +23,18 @@ namespace ctx { class DeviceStatusPsmode : public DeviceProviderBase { - - GENERATE_PROVIDER_COMMON_DECL(DeviceStatusPsmode); - public: + DeviceStatusPsmode(); + ~DeviceStatusPsmode(); + int subscribe(); int unsubscribe(); int read(); - static bool isSupported(); - static void submitTriggerItem(); + + bool isSupported(); + void submitTriggerItem(); private: - DeviceStatusPsmode(); - ~DeviceStatusPsmode(); void __handleUpdate(keynode_t *node); static void __updateCb(keynode_t *node, void* userData); }; diff --git a/src/device/system/Time.cpp b/src/device/system/Time.cpp index af3ded1..6fa0c81 100644 --- a/src/device/system/Time.cpp +++ b/src/device/system/Time.cpp @@ -14,29 +14,29 @@ * limitations under the License. */ -#include #include #include "SystemTypes.h" #include "Time.h" -GENERATE_PROVIDER_COMMON_IMPL(DeviceStatusTime); +using namespace ctx; -ctx::DeviceStatusTime::DeviceStatusTime() +DeviceStatusTime::DeviceStatusTime() : + DeviceProviderBase(DEVICE_ST_SUBJ_TIME) { } -ctx::DeviceStatusTime::~DeviceStatusTime() +DeviceStatusTime::~DeviceStatusTime() { } -bool ctx::DeviceStatusTime::isSupported() +bool DeviceStatusTime::isSupported() { return true; } -void ctx::DeviceStatusTime::submitTriggerItem() +void DeviceStatusTime::submitTriggerItem() { - context_manager::registerTriggerItem(DEVICE_ST_SUBJ_TIME, OPS_READ, + registerTriggerItem(OPS_READ, "{" "\"TimeOfDay\":{\"type\":\"integer\",\"min\":0,\"max\":1439}," "\"DayOfWeek\":{\"type\":\"string\",\"values\":[\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\",\"Sun\",\"Weekday\",\"Weekend\"]}," @@ -45,17 +45,17 @@ void ctx::DeviceStatusTime::submitTriggerItem() NULL); } -int ctx::DeviceStatusTime::subscribe() +int DeviceStatusTime::subscribe() { return ERR_NOT_SUPPORTED; } -int ctx::DeviceStatusTime::unsubscribe() +int DeviceStatusTime::unsubscribe() { return ERR_NOT_SUPPORTED; } -int ctx::DeviceStatusTime::read() +int DeviceStatusTime::read() { time_t rawtime; struct tm timeInfo; @@ -66,16 +66,16 @@ int ctx::DeviceStatusTime::read() int dayOfMonth = timeInfo.tm_mday; int minuteOfDay = timeInfo.tm_hour * 60 + timeInfo.tm_min; - std::string dayOfWeek = ctx::TimerManager::dowToStr(0x01 << timeInfo.tm_wday); + std::string dayOfWeek = TimerManager::dowToStr(0x01 << timeInfo.tm_wday); - ctx::Json dataRead; + Json dataRead; dataRead.set(NULL, DEVICE_ST_DAY_OF_MONTH, dayOfMonth); dataRead.set(NULL, DEVICE_ST_DAY_OF_WEEK, dayOfWeek); dataRead.set(NULL, DEVICE_ST_TIME_OF_DAY, minuteOfDay); _I("Time: %02d:%02d, Day of Week: %s, Day of Month: %d", timeInfo.tm_hour, timeInfo.tm_min, dayOfWeek.c_str(), dayOfMonth); - ctx::context_manager::replyToRead(DEVICE_ST_SUBJ_TIME, NULL, ERR_NONE, dataRead); + replyToRead(NULL, ERR_NONE, dataRead); return ERR_NONE; } diff --git a/src/device/system/Time.h b/src/device/system/Time.h index 2a97993..e5e1112 100644 --- a/src/device/system/Time.h +++ b/src/device/system/Time.h @@ -22,19 +22,16 @@ namespace ctx { class DeviceStatusTime : public DeviceProviderBase { - - GENERATE_PROVIDER_COMMON_DECL(DeviceStatusTime); - public: + DeviceStatusTime(); + ~DeviceStatusTime(); + int subscribe(); int unsubscribe(); int read(); - static bool isSupported(); - static void submitTriggerItem(); - private: - DeviceStatusTime(); - ~DeviceStatusTime(); + bool isSupported(); + void submitTriggerItem(); }; } diff --git a/src/device/system/Wifi.cpp b/src/device/system/Wifi.cpp index e3a8a3a..5f6cca7 100644 --- a/src/device/system/Wifi.cpp +++ b/src/device/system/Wifi.cpp @@ -15,13 +15,13 @@ */ #include -#include #include "SystemTypes.h" #include "Wifi.h" -ctx::DeviceStatusWifi *ctx::DeviceStatusWifi::__instance = NULL; +using namespace ctx; -ctx::DeviceStatusWifi::DeviceStatusWifi() : +DeviceStatusWifi::DeviceStatusWifi() : + DeviceProviderBase(DEVICE_ST_SUBJ_WIFI), __lastState(UNKNOWN), __isInitialized(false), __isActivated(false), @@ -35,34 +35,19 @@ ctx::DeviceStatusWifi::DeviceStatusWifi() : } } -ctx::DeviceStatusWifi::~DeviceStatusWifi() +DeviceStatusWifi::~DeviceStatusWifi() { + __stopMonitor(); } -ctx::ContextProviderBase *ctx::DeviceStatusWifi::create(void *data) -{ - CREATE_INSTANCE(DeviceStatusWifi); -} - -void ctx::DeviceStatusWifi::destroy(void *data) -{ - __instance->__stopMonitor(); - DESTROY_INSTANCE(); -} - -void ctx::DeviceStatusWifi::destroySelf() -{ - /* WiFi status will be monitored continuously, even if no client is subscribing it */ -} - -bool ctx::DeviceStatusWifi::isSupported() +bool DeviceStatusWifi::isSupported() { return getSystemInfoBool("tizen.org/feature/network.wifi"); } -void ctx::DeviceStatusWifi::submitTriggerItem() +void DeviceStatusWifi::submitTriggerItem() { - context_manager::registerTriggerItem(DEVICE_ST_SUBJ_WIFI, OPS_SUBSCRIBE | OPS_READ, + registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, "{" "\"State\":{\"type\":\"string\",\"values\":[\"Disabled\",\"Unconnected\",\"Connected\"]}," "\"BSSID\":{\"type\":\"string\"}" @@ -70,7 +55,7 @@ void ctx::DeviceStatusWifi::submitTriggerItem() NULL); } -bool ctx::DeviceStatusWifi::__getCurrentState() +bool DeviceStatusWifi::__getCurrentState() { int err; @@ -104,7 +89,7 @@ bool ctx::DeviceStatusWifi::__getCurrentState() return true; } -bool ctx::DeviceStatusWifi::__getBssid() +bool DeviceStatusWifi::__getBssid() { int err; char *strBuf = NULL; @@ -122,20 +107,20 @@ bool ctx::DeviceStatusWifi::__getBssid() if (__bssid.empty()) _W("Failed to get BSSID"); - SharedVars().set(ctx::SharedVars::WIFI_BSSID, __bssid); + SharedVars().set(SharedVars::WIFI_BSSID, __bssid); _D("BSSID: %s", __bssid.c_str()); return !__bssid.empty(); } -void ctx::DeviceStatusWifi::__clearBssid() +void DeviceStatusWifi::__clearBssid() { __bssid.clear(); - SharedVars().clear(ctx::SharedVars::WIFI_BSSID); + SharedVars().clear(SharedVars::WIFI_BSSID); _D("No WiFi connection"); } -bool ctx::DeviceStatusWifi::__getResponsePacket(ctx::Json* data) +bool DeviceStatusWifi::__getResponsePacket(Json* data) { switch (__lastState) { case DISABLED: @@ -158,20 +143,20 @@ bool ctx::DeviceStatusWifi::__getResponsePacket(ctx::Json* data) return true; } -int ctx::DeviceStatusWifi::read() +int DeviceStatusWifi::read() { IF_FAIL_RETURN(__getCurrentState(), ERR_OPERATION_FAILED); - ctx::Json dataRead; + Json dataRead; if (__getResponsePacket(&dataRead)) { - ctx::context_manager::replyToRead(DEVICE_ST_SUBJ_WIFI, NULL, ERR_NONE, dataRead); + replyToRead(NULL, ERR_NONE, dataRead); return ERR_NONE; } return ERR_OPERATION_FAILED; } -bool ctx::DeviceStatusWifi::__startMonitor() +bool DeviceStatusWifi::__startMonitor() { IF_FAIL_RETURN(!__isInitialized, true); @@ -193,7 +178,7 @@ CATCH: return false; } -void ctx::DeviceStatusWifi::__stopMonitor() +void DeviceStatusWifi::__stopMonitor() { IF_FAIL_VOID(__isInitialized); @@ -203,7 +188,7 @@ void ctx::DeviceStatusWifi::__stopMonitor() __isInitialized = false; } -int ctx::DeviceStatusWifi::subscribe() +int DeviceStatusWifi::subscribe() { #if 0 IF_FAIL_RETURN(__startMonitor(), ERR_OPERATION_FAILED); @@ -216,7 +201,7 @@ int ctx::DeviceStatusWifi::subscribe() return ERR_NONE; } -int ctx::DeviceStatusWifi::unsubscribe() +int DeviceStatusWifi::unsubscribe() { #if 0 __stopMonitor(); @@ -224,7 +209,7 @@ int ctx::DeviceStatusWifi::unsubscribe() return ERR_NONE; } -void ctx::DeviceStatusWifi::__handleUpdate() +void DeviceStatusWifi::__handleUpdate() { int prevState = __lastState; @@ -245,20 +230,20 @@ void ctx::DeviceStatusWifi::__handleUpdate() __clearBssid(); } - ctx::Json data; + Json data; if (__beingSubscribed && __getResponsePacket(&data)) - context_manager::publish(DEVICE_ST_SUBJ_WIFI, NULL, ERR_NONE, data); + publish(NULL, ERR_NONE, data); } } -void ctx::DeviceStatusWifi::__deviceStateChangedCb(wifi_device_state_e state, void *userData) +void DeviceStatusWifi::__deviceStateChangedCb(wifi_device_state_e state, void *userData) { DeviceStatusWifi *instance = static_cast(userData); instance->__isActivated = (state == WIFI_DEVICE_STATE_ACTIVATED); instance->__handleUpdate(); } -void ctx::DeviceStatusWifi::__connectionStateChangedCb(wifi_connection_state_e state, wifi_ap_h ap, void *userData) +void DeviceStatusWifi::__connectionStateChangedCb(wifi_connection_state_e state, wifi_ap_h ap, void *userData) { DeviceStatusWifi *instance = static_cast(userData); instance->__connState = state; diff --git a/src/device/system/Wifi.h b/src/device/system/Wifi.h index 59b721d..82cebb2 100644 --- a/src/device/system/Wifi.h +++ b/src/device/system/Wifi.h @@ -24,15 +24,16 @@ namespace ctx { class DeviceStatusWifi : public DeviceProviderBase { - - GENERATE_PROVIDER_COMMON_DECL(DeviceStatusWifi); - public: + DeviceStatusWifi(); + ~DeviceStatusWifi(); + int subscribe(); int unsubscribe(); int read(); - static bool isSupported(); - static void submitTriggerItem(); + + bool isSupported(); + void submitTriggerItem(); private: enum InternalState { @@ -48,9 +49,6 @@ namespace ctx { wifi_connection_state_e __connState; std::string __bssid; - DeviceStatusWifi(); - ~DeviceStatusWifi(); - bool __getCurrentState(); bool __getBssid(); void __clearBssid(); diff --git a/src/device/system/runtime_info/Charger.cpp b/src/device/system/runtime_info/Charger.cpp index 30802d9..8cdf40a 100644 --- a/src/device/system/runtime_info/Charger.cpp +++ b/src/device/system/runtime_info/Charger.cpp @@ -14,55 +14,54 @@ * limitations under the License. */ -#include #include "../SystemTypes.h" #include "Charger.h" -GENERATE_PROVIDER_COMMON_IMPL(DeviceStatusCharger); +using namespace ctx; -ctx::DeviceStatusCharger::DeviceStatusCharger() : - DeviceStatusRuntimeInfo(RUNTIME_INFO_KEY_CHARGER_CONNECTED) +DeviceStatusCharger::DeviceStatusCharger() : + DeviceStatusRuntimeInfo(DEVICE_ST_SUBJ_CHARGER, RUNTIME_INFO_KEY_CHARGER_CONNECTED) { } -ctx::DeviceStatusCharger::~DeviceStatusCharger() +DeviceStatusCharger::~DeviceStatusCharger() { } -bool ctx::DeviceStatusCharger::isSupported() +bool DeviceStatusCharger::isSupported() { return true; } -void ctx::DeviceStatusCharger::submitTriggerItem() +void DeviceStatusCharger::submitTriggerItem() { - context_manager::registerTriggerItem(DEVICE_ST_SUBJ_CHARGER, OPS_SUBSCRIBE | OPS_READ, + registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, "{" TRIG_BOOL_ITEM_DEF("IsConnected") "}", NULL); } -void ctx::DeviceStatusCharger::handleUpdate() +void DeviceStatusCharger::handleUpdate() { bool chargerStatus = false; int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &chargerStatus); IF_FAIL_VOID_TAG(ret == RUNTIME_INFO_ERROR_NONE, _E, "Getting runtime info failed"); - ctx::Json dataRead; + Json dataRead; dataRead.set(NULL, DEVICE_ST_IS_CONNECTED, chargerStatus ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); - context_manager::publish(DEVICE_ST_SUBJ_CHARGER, NULL, ERR_NONE, dataRead); + publish(NULL, ERR_NONE, dataRead); } -int ctx::DeviceStatusCharger::read() +int DeviceStatusCharger::read() { bool chargerStatus = false; - ctx::Json dataRead; + Json dataRead; int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &chargerStatus); IF_FAIL_RETURN_TAG(ret == RUNTIME_INFO_ERROR_NONE, ERR_OPERATION_FAILED, _E, "Getting runtime info failed"); dataRead.set(NULL, DEVICE_ST_IS_CONNECTED, chargerStatus ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); - ctx::context_manager::replyToRead(DEVICE_ST_SUBJ_CHARGER, NULL, ERR_NONE, dataRead); + replyToRead(NULL, ERR_NONE, dataRead); return ERR_NONE; } diff --git a/src/device/system/runtime_info/Charger.h b/src/device/system/runtime_info/Charger.h index 38cbca8..a6746a3 100644 --- a/src/device/system/runtime_info/Charger.h +++ b/src/device/system/runtime_info/Charger.h @@ -22,20 +22,17 @@ namespace ctx { class DeviceStatusCharger : public DeviceStatusRuntimeInfo { - - GENERATE_PROVIDER_COMMON_DECL(DeviceStatusCharger); - public: + DeviceStatusCharger(); + ~DeviceStatusCharger(); + int read(); - static bool isSupported(); - static void submitTriggerItem(); + + bool isSupported(); + void submitTriggerItem(); protected: void handleUpdate(); - - private: - DeviceStatusCharger(); - ~DeviceStatusCharger(); }; } diff --git a/src/device/system/runtime_info/Gps.cpp b/src/device/system/runtime_info/Gps.cpp index 9ec1c02..d2bc301 100644 --- a/src/device/system/runtime_info/Gps.cpp +++ b/src/device/system/runtime_info/Gps.cpp @@ -14,11 +14,10 @@ * limitations under the License. */ -#include #include "../SystemTypes.h" #include "Gps.h" -GENERATE_PROVIDER_COMMON_IMPL(DeviceStatusGps); +using namespace ctx; static const char* __getStatusString(int gpsStatus) { @@ -38,49 +37,49 @@ static const char* __getStatusString(int gpsStatus) } } -ctx::DeviceStatusGps::DeviceStatusGps() : - DeviceStatusRuntimeInfo(RUNTIME_INFO_KEY_GPS_STATUS) +DeviceStatusGps::DeviceStatusGps() : + DeviceStatusRuntimeInfo(DEVICE_ST_SUBJ_GPS, RUNTIME_INFO_KEY_GPS_STATUS) { } -ctx::DeviceStatusGps::~DeviceStatusGps() +DeviceStatusGps::~DeviceStatusGps() { } -bool ctx::DeviceStatusGps::isSupported() +bool DeviceStatusGps::isSupported() { return getSystemInfoBool("tizen.org/feature/location.gps"); } -void ctx::DeviceStatusGps::submitTriggerItem() +void DeviceStatusGps::submitTriggerItem() { - context_manager::registerTriggerItem(DEVICE_ST_SUBJ_GPS, OPS_SUBSCRIBE | OPS_READ, + registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, "{" "\"State\":{\"type\":\"string\",\"values\":[\"Disabled\",\"Searching\",\"Connected\"]}" "}", NULL); } -void ctx::DeviceStatusGps::handleUpdate() +void DeviceStatusGps::handleUpdate() { int gpsStatus; int ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_GPS_STATUS, &gpsStatus); IF_FAIL_VOID_TAG(ret == RUNTIME_INFO_ERROR_NONE, _E, "Getting runtime info failed"); - ctx::Json dataRead; + Json dataRead; const char* stateStr = __getStatusString(gpsStatus); IF_FAIL_VOID(stateStr); dataRead.set(NULL, DEVICE_ST_STATE, stateStr); - context_manager::publish(DEVICE_ST_SUBJ_GPS, NULL, ERR_NONE, dataRead); + publish(NULL, ERR_NONE, dataRead); } -int ctx::DeviceStatusGps::read() +int DeviceStatusGps::read() { int gpsStatus; - ctx::Json dataRead; + Json dataRead; int ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_GPS_STATUS, &gpsStatus); IF_FAIL_RETURN_TAG(ret == RUNTIME_INFO_ERROR_NONE, ERR_OPERATION_FAILED, _E, "Getting runtime info failed"); @@ -90,6 +89,6 @@ int ctx::DeviceStatusGps::read() dataRead.set(NULL, DEVICE_ST_STATE, stateStr); - ctx::context_manager::replyToRead(DEVICE_ST_SUBJ_GPS, NULL, ERR_NONE, dataRead); + replyToRead(NULL, ERR_NONE, dataRead); return ERR_NONE; } diff --git a/src/device/system/runtime_info/Gps.h b/src/device/system/runtime_info/Gps.h index 38bc8e8..87acd1b 100644 --- a/src/device/system/runtime_info/Gps.h +++ b/src/device/system/runtime_info/Gps.h @@ -22,20 +22,17 @@ namespace ctx { class DeviceStatusGps : public DeviceStatusRuntimeInfo { - - GENERATE_PROVIDER_COMMON_DECL(DeviceStatusGps); - public: + DeviceStatusGps(); + ~DeviceStatusGps(); + int read(); - static bool isSupported(); - static void submitTriggerItem(); + + bool isSupported(); + void submitTriggerItem(); protected: void handleUpdate(); - - private: - DeviceStatusGps(); - ~DeviceStatusGps(); }; } diff --git a/src/device/system/runtime_info/RuntimeInfoBase.cpp b/src/device/system/runtime_info/RuntimeInfoBase.cpp index 61b117f..1f745ad 100644 --- a/src/device/system/runtime_info/RuntimeInfoBase.cpp +++ b/src/device/system/runtime_info/RuntimeInfoBase.cpp @@ -16,31 +16,34 @@ #include "RuntimeInfoBase.h" -ctx::DeviceStatusRuntimeInfo::DeviceStatusRuntimeInfo(runtime_info_key_e key) : +using namespace ctx; + +DeviceStatusRuntimeInfo::DeviceStatusRuntimeInfo(const char *subject, runtime_info_key_e key) : + DeviceProviderBase(subject), __infoKey(key) { } -runtime_info_key_e ctx::DeviceStatusRuntimeInfo::__getInfoKey() +runtime_info_key_e DeviceStatusRuntimeInfo::__getInfoKey() { return __infoKey; } -void ctx::DeviceStatusRuntimeInfo::updateCb(runtime_info_key_e runtimeKey, void* userData) +void DeviceStatusRuntimeInfo::updateCb(runtime_info_key_e runtimeKey, void* userData) { DeviceStatusRuntimeInfo *instance = static_cast(userData); IF_FAIL_VOID_TAG(runtimeKey == instance->__getInfoKey(), _W, "Runtime info key mismatch"); instance->handleUpdate(); } -int ctx::DeviceStatusRuntimeInfo::subscribe() +int DeviceStatusRuntimeInfo::subscribe() { int ret = runtime_info_set_changed_cb(__infoKey, updateCb, this); IF_FAIL_RETURN(ret == RUNTIME_INFO_ERROR_NONE, ERR_OPERATION_FAILED); return ERR_NONE; } -int ctx::DeviceStatusRuntimeInfo::unsubscribe() +int DeviceStatusRuntimeInfo::unsubscribe() { int ret = runtime_info_unset_changed_cb(__infoKey); IF_FAIL_RETURN(ret == RUNTIME_INFO_ERROR_NONE, ERR_OPERATION_FAILED); diff --git a/src/device/system/runtime_info/RuntimeInfoBase.h b/src/device/system/runtime_info/RuntimeInfoBase.h index a0e2c20..a2e4a88 100644 --- a/src/device/system/runtime_info/RuntimeInfoBase.h +++ b/src/device/system/runtime_info/RuntimeInfoBase.h @@ -24,7 +24,7 @@ namespace ctx { class DeviceStatusRuntimeInfo : public DeviceProviderBase { public: - DeviceStatusRuntimeInfo(runtime_info_key_e key); + DeviceStatusRuntimeInfo(const char *subject, runtime_info_key_e key); int subscribe(); int unsubscribe(); diff --git a/src/device/system/runtime_info/Usb.cpp b/src/device/system/runtime_info/Usb.cpp index 929a03f..e0aa6af 100644 --- a/src/device/system/runtime_info/Usb.cpp +++ b/src/device/system/runtime_info/Usb.cpp @@ -14,55 +14,54 @@ * limitations under the License. */ -#include #include "../SystemTypes.h" #include "Usb.h" -GENERATE_PROVIDER_COMMON_IMPL(DeviceStatusUsb); +using namespace ctx; -ctx::DeviceStatusUsb::DeviceStatusUsb() : - DeviceStatusRuntimeInfo(RUNTIME_INFO_KEY_USB_CONNECTED) +DeviceStatusUsb::DeviceStatusUsb() : + DeviceStatusRuntimeInfo(DEVICE_ST_SUBJ_USB, RUNTIME_INFO_KEY_USB_CONNECTED) { } -ctx::DeviceStatusUsb::~DeviceStatusUsb() +DeviceStatusUsb::~DeviceStatusUsb() { } -bool ctx::DeviceStatusUsb::isSupported() +bool DeviceStatusUsb::isSupported() { return getSystemInfoBool("tizen.org/feature/usb.host"); } -void ctx::DeviceStatusUsb::submitTriggerItem() +void DeviceStatusUsb::submitTriggerItem() { - context_manager::registerTriggerItem(DEVICE_ST_SUBJ_USB, OPS_SUBSCRIBE | OPS_READ, + registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, "{" TRIG_BOOL_ITEM_DEF("IsConnected") "}", NULL); } -void ctx::DeviceStatusUsb::handleUpdate() +void DeviceStatusUsb::handleUpdate() { bool status = false; 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 dataRead; + 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, dataRead); + publish(NULL, ERR_NONE, dataRead); } -int ctx::DeviceStatusUsb::read() +int DeviceStatusUsb::read() { bool status = false; - ctx::Json dataRead; + 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"); dataRead.set(NULL, DEVICE_ST_IS_CONNECTED, status ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); - ctx::context_manager::replyToRead(DEVICE_ST_SUBJ_USB, NULL, ERR_NONE, dataRead); + replyToRead(NULL, ERR_NONE, dataRead); return ERR_NONE; } diff --git a/src/device/system/runtime_info/Usb.h b/src/device/system/runtime_info/Usb.h index 4602752..fc8678c 100644 --- a/src/device/system/runtime_info/Usb.h +++ b/src/device/system/runtime_info/Usb.h @@ -22,20 +22,17 @@ namespace ctx { class DeviceStatusUsb : public DeviceStatusRuntimeInfo { - - GENERATE_PROVIDER_COMMON_DECL(DeviceStatusUsb); - public: + DeviceStatusUsb(); + ~DeviceStatusUsb(); + int read(); - static bool isSupported(); - static void submitTriggerItem(); + + bool isSupported(); + void submitTriggerItem(); protected: void handleUpdate(); - - private: - DeviceStatusUsb(); - ~DeviceStatusUsb(); }; } diff --git a/src/place/PlaceContextProvider.cpp b/src/place/PlaceContextProvider.cpp index 363ed86..349000a 100644 --- a/src/place/PlaceContextProvider.cpp +++ b/src/place/PlaceContextProvider.cpp @@ -15,8 +15,6 @@ */ #include -#include -#include #include #ifdef _MOBILE_ @@ -29,21 +27,24 @@ template void registerProvider(const char *subject, const char *privilege) { - if (!Provider::isSupported()) + Provider *provider = new(std::nothrow) Provider(); + IF_FAIL_VOID_TAG(provider, _E, "Memory allocation failed"); + + if (!provider->isSupported()) { + delete provider; return; + } - ctx::ContextProviderInfo providerInfo(Provider::create, Provider::destroy, NULL, privilege); - ctx::context_manager::registerProvider(subject, providerInfo); + provider->registerProvider(privilege, provider); + provider->submitTriggerItem(); } SO_EXPORT bool ctx::initPlaceContextProvider() { #ifdef _MOBILE_ registerProvider(PLACE_SUBJ_GEOFENCE, PLACE_PRIV_GEOFENCE); - PlaceGeofenceProvider::submitTriggerItem(); #ifndef _DISABLE_RECOG_ENGINE_ - PlaceRecognitionProvider::create(NULL); registerProvider(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION); #endif /* _DISABLE_RECOG_ENGINE_ */ diff --git a/src/place/geofence/GeofenceMonitorHandle.cpp b/src/place/geofence/GeofenceMonitorHandle.cpp index 0e031bf..868966a 100644 --- a/src/place/geofence/GeofenceMonitorHandle.cpp +++ b/src/place/geofence/GeofenceMonitorHandle.cpp @@ -16,23 +16,25 @@ #include #include -#include -#include "PlaceGeofenceTypes.h" +#include "PlaceGeofenceProvider.h" #include "GeofenceMonitorHandle.h" -ctx::GeofenceMonitorHandle::GeofenceMonitorHandle() : +using namespace ctx; + +GeofenceMonitorHandle::GeofenceMonitorHandle(PlaceGeofenceProvider *provider) : + __provider(provider), __placeId(-1), __prevState(GEOFENCE_STATE_UNCERTAIN), __geoHandle(NULL) { } -ctx::GeofenceMonitorHandle::~GeofenceMonitorHandle() +GeofenceMonitorHandle::~GeofenceMonitorHandle() { __stopMonitor(); } -bool ctx::GeofenceMonitorHandle::startMonitor(int placeId) +bool GeofenceMonitorHandle::startMonitor(int placeId) { _D("Starts to monitor Place-%d", placeId); @@ -61,12 +63,12 @@ CATCH: return false; } -int ctx::GeofenceMonitorHandle::getPlaceId() +int GeofenceMonitorHandle::getPlaceId() { return __placeId; } -void ctx::GeofenceMonitorHandle::__stopMonitor() +void GeofenceMonitorHandle::__stopMonitor() { _D("Stops monitoring Place-%d", __placeId); @@ -81,7 +83,7 @@ void ctx::GeofenceMonitorHandle::__stopMonitor() __prevState = GEOFENCE_STATE_UNCERTAIN; } -bool ctx::GeofenceMonitorHandle::__startFence(int fenceId) +bool GeofenceMonitorHandle::__startFence(int fenceId) { int ret; @@ -101,48 +103,48 @@ bool ctx::GeofenceMonitorHandle::__startFence(int fenceId) return true; } -void ctx::GeofenceMonitorHandle::__removeFence(int fenceId) +void GeofenceMonitorHandle::__removeFence(int fenceId) { geofence_manager_stop(__geoHandle, fenceId); __geoStateMap.erase(fenceId); } -void ctx::GeofenceMonitorHandle::__updateFence(int fenceId, geofence_manage_e manage) +void GeofenceMonitorHandle::__updateFence(int fenceId, geofence_manage_e manage) { switch (manage) { - case GEOFENCE_MANAGE_PLACE_REMOVED: - _W("[Place-%d] Removed", __placeId); - __stopMonitor(); - break; - case GEOFENCE_MANAGE_FENCE_ADDED: - _I("[Place %d] Fence-%d added", __placeId, fenceId); - __startFence(fenceId); - __emitStateChange(); - break; - case GEOFENCE_MANAGE_FENCE_REMOVED: - _I("[Place-%d] Fence-%d removed", __placeId, fenceId); - __removeFence(fenceId); - __emitStateChange(); - break; - case GEOFENCE_MANAGE_FENCE_STARTED: - _D("[Place-%d] Fence-%d started", __placeId, fenceId); - break; - case GEOFENCE_MANAGE_FENCE_STOPPED: - _D("[Place-%d] Fence-%d stopped", __placeId, fenceId); - //TODO: Do we need to restart this? - break; - default: - _D("[Place-%d] Ignoring the manage event %d", __placeId, manage); - break; + case GEOFENCE_MANAGE_PLACE_REMOVED: + _W("[Place-%d] Removed", __placeId); + __stopMonitor(); + break; + case GEOFENCE_MANAGE_FENCE_ADDED: + _I("[Place %d] Fence-%d added", __placeId, fenceId); + __startFence(fenceId); + __emitStateChange(); + break; + case GEOFENCE_MANAGE_FENCE_REMOVED: + _I("[Place-%d] Fence-%d removed", __placeId, fenceId); + __removeFence(fenceId); + __emitStateChange(); + break; + case GEOFENCE_MANAGE_FENCE_STARTED: + _D("[Place-%d] Fence-%d started", __placeId, fenceId); + break; + case GEOFENCE_MANAGE_FENCE_STOPPED: + _D("[Place-%d] Fence-%d stopped", __placeId, fenceId); + //TODO: Do we need to restart this? + break; + default: + _D("[Place-%d] Ignoring the manage event %d", __placeId, manage); + break; } } -void ctx::GeofenceMonitorHandle::__updateState(int fenceId, geofence_state_e state) +void GeofenceMonitorHandle::__updateState(int fenceId, geofence_state_e state) { __geoStateMap[fenceId] = state; } -void ctx::GeofenceMonitorHandle::__emitStateChange() +void GeofenceMonitorHandle::__emitStateChange() { geofence_state_e currentState = GEOFENCE_STATE_UNCERTAIN; int outCount = 0; @@ -173,10 +175,10 @@ void ctx::GeofenceMonitorHandle::__emitStateChange() data.set(NULL, PLACE_GEOFENCE_PLACE_ID, __placeId); data.set(NULL, PLACE_GEOFENCE_EVENT, __getStateString(currentState)); - context_manager::publish(PLACE_SUBJ_GEOFENCE, option, ERR_NONE, data); + __provider->publish(option, ERR_NONE, data); } -const char* ctx::GeofenceMonitorHandle::__getStateString(geofence_state_e state) +const char* GeofenceMonitorHandle::__getStateString(geofence_state_e state) { switch (state) { case GEOFENCE_STATE_IN: @@ -190,7 +192,7 @@ const char* ctx::GeofenceMonitorHandle::__getStateString(geofence_state_e state) } } -bool ctx::GeofenceMonitorHandle::__fenceListCb(int geofenceId, geofence_h fence, int fenceIndex, int fenceCount, void* userData) +bool GeofenceMonitorHandle::__fenceListCb(int geofenceId, geofence_h fence, int fenceIndex, int fenceCount, void* userData) { _D("FenceID: %d, Index: %d, Count: %d", geofenceId, fenceIndex, fenceCount); IF_FAIL_RETURN(fenceCount > 0, false); @@ -199,7 +201,7 @@ bool ctx::GeofenceMonitorHandle::__fenceListCb(int geofenceId, geofence_h fence, return handle->__startFence(geofenceId); } -void ctx::GeofenceMonitorHandle::__fenceEventCb(int placeId, int geofenceId, geofence_manager_error_e error, geofence_manage_e manage, void* userData) +void GeofenceMonitorHandle::__fenceEventCb(int placeId, int geofenceId, geofence_manager_error_e error, geofence_manage_e manage, void* userData) { IF_FAIL_VOID_TAG(error == GEOFENCE_MANAGER_ERROR_NONE, _W, "Geofence error: %d", error); @@ -210,7 +212,7 @@ void ctx::GeofenceMonitorHandle::__fenceEventCb(int placeId, int geofenceId, geo handle->__updateFence(geofenceId, manage); } -void ctx::GeofenceMonitorHandle::__fenceStateCb(int geofenceId, geofence_state_e state, void* userData) +void GeofenceMonitorHandle::__fenceStateCb(int geofenceId, geofence_state_e state, void* userData) { GeofenceMonitorHandle *handle = reinterpret_cast(userData); handle->__updateState(geofenceId, state); diff --git a/src/place/geofence/GeofenceMonitorHandle.h b/src/place/geofence/GeofenceMonitorHandle.h index 2dc17ff..6bdd301 100644 --- a/src/place/geofence/GeofenceMonitorHandle.h +++ b/src/place/geofence/GeofenceMonitorHandle.h @@ -23,16 +23,18 @@ namespace ctx { - class GeofenceMonitorHandle { + class PlaceGeofenceProvider; + class GeofenceMonitorHandle { public: - GeofenceMonitorHandle(); + GeofenceMonitorHandle(PlaceGeofenceProvider *provider); ~GeofenceMonitorHandle(); bool startMonitor(int placeId); int getPlaceId(); private: + PlaceGeofenceProvider *__provider; int __placeId; geofence_state_e __prevState; geofence_manager_h __geoHandle; diff --git a/src/place/geofence/PlaceGeofenceProvider.cpp b/src/place/geofence/PlaceGeofenceProvider.cpp index 91b0785..e7aff50 100644 --- a/src/place/geofence/PlaceGeofenceProvider.cpp +++ b/src/place/geofence/PlaceGeofenceProvider.cpp @@ -15,45 +15,26 @@ */ #include - -#include -#include -#include +#include "GeofenceMonitorHandle.h" #include "PlaceGeofenceProvider.h" -ctx::PlaceGeofenceProvider *ctx::PlaceGeofenceProvider::__instance = NULL; +using namespace ctx; -ctx::PlaceGeofenceProvider::PlaceGeofenceProvider() +PlaceGeofenceProvider::PlaceGeofenceProvider() : + ContextProvider(PLACE_SUBJ_GEOFENCE) { } -ctx::PlaceGeofenceProvider::~PlaceGeofenceProvider() +PlaceGeofenceProvider::~PlaceGeofenceProvider() { - for (auto it = __handleMap.begin(); it != __handleMap.end(); ++it) { - delete it->second; + for (auto& it : __handleMap) { + delete it.second; } __handleMap.clear(); } -ctx::ContextProviderBase *ctx::PlaceGeofenceProvider::create(void *data) -{ - IF_FAIL_RETURN(!__instance, __instance); - __instance = new(std::nothrow) PlaceGeofenceProvider(); - IF_FAIL_RETURN_TAG(__instance, NULL, _E, "Memory allocation failed"); - _I(BLUE("Created")); - return __instance; -} - -void ctx::PlaceGeofenceProvider::destroy(void *data) -{ - IF_FAIL_VOID(__instance); - delete __instance; - __instance = NULL; - _I(BLUE("Destroyed")); -} - -bool ctx::PlaceGeofenceProvider::isSupported() +bool PlaceGeofenceProvider::isSupported() { bool supported = false; int ret = geofence_manager_is_supported(&supported); @@ -61,9 +42,9 @@ bool ctx::PlaceGeofenceProvider::isSupported() return supported; } -void ctx::PlaceGeofenceProvider::submitTriggerItem() +void PlaceGeofenceProvider::submitTriggerItem() { - context_manager::registerTriggerItem(PLACE_SUBJ_GEOFENCE, OPS_SUBSCRIBE, + registerTriggerItem(OPS_SUBSCRIBE, "{" "\"Event\":{\"type\":\"string\",\"values\":[\"In\",\"Out\"]}" "}", @@ -72,40 +53,7 @@ void ctx::PlaceGeofenceProvider::submitTriggerItem() "}"); } -void ctx::PlaceGeofenceProvider::__destroyIfUnused() -{ - IF_FAIL_VOID(__handleMap.empty()); - destroy(NULL); -} - - -int ctx::PlaceGeofenceProvider::subscribe(const char *subject, ctx::Json option, ctx::Json *requestResult) -{ - int ret = __subscribe(option); - __destroyIfUnused(); - return ret; -} - -int ctx::PlaceGeofenceProvider::unsubscribe(const char *subject, ctx::Json option) -{ - int ret = __unsubscribe(option); - __destroyIfUnused(); - return ret; -} - -int ctx::PlaceGeofenceProvider::read(const char *subject, ctx::Json option, ctx::Json *requestResult) -{ - __destroyIfUnused(); - return ERR_NOT_SUPPORTED; -} - -int ctx::PlaceGeofenceProvider::write(const char *subject, ctx::Json data, ctx::Json *requestResult) -{ - __destroyIfUnused(); - return ERR_NOT_SUPPORTED; -} - -int ctx::PlaceGeofenceProvider::__subscribe(ctx::Json option) +int PlaceGeofenceProvider::subscribe(Json option, Json *requestResult) { int placeId = -1; option.get(NULL, PLACE_GEOFENCE_PLACE_ID, &placeId); @@ -117,7 +65,7 @@ int ctx::PlaceGeofenceProvider::__subscribe(ctx::Json option) return ERR_NONE; } - GeofenceMonitorHandle *handle = new(std::nothrow) GeofenceMonitorHandle(); + GeofenceMonitorHandle *handle = new(std::nothrow) GeofenceMonitorHandle(this); ASSERT_ALLOC(handle); bool ret = handle->startMonitor(placeId); @@ -132,7 +80,7 @@ int ctx::PlaceGeofenceProvider::__subscribe(ctx::Json option) return ERR_NONE; } -int ctx::PlaceGeofenceProvider::__unsubscribe(ctx::Json option) +int PlaceGeofenceProvider::unsubscribe(Json option) { int placeId = -1; option.get(NULL, PLACE_GEOFENCE_PLACE_ID, &placeId); diff --git a/src/place/geofence/PlaceGeofenceProvider.h b/src/place/geofence/PlaceGeofenceProvider.h index a95f4c6..e6ebf2f 100644 --- a/src/place/geofence/PlaceGeofenceProvider.h +++ b/src/place/geofence/PlaceGeofenceProvider.h @@ -18,35 +18,26 @@ #define _CONTEXT_PLACE_GEOFENCE_PROVIDER_H_ #include -#include -#include "GeofenceMonitorHandle.h" +#include #include "PlaceGeofenceTypes.h" namespace ctx { - class PlaceGeofenceProvider : public ContextProviderBase { + class GeofenceMonitorHandle; + class PlaceGeofenceProvider : public ContextProvider { public: - static ContextProviderBase *create(void *data); - static void destroy(void *data); - static bool isSupported(); - static void submitTriggerItem(); - - 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); - - private: - static PlaceGeofenceProvider *__instance; - std::map __handleMap; - PlaceGeofenceProvider(); ~PlaceGeofenceProvider(); - int __subscribe(ctx::Json option); - int __unsubscribe(ctx::Json option); - void __destroyIfUnused(); + int subscribe(Json option, Json *requestResult); + int unsubscribe(Json option); + + bool isSupported(); + void submitTriggerItem(); + + private: + std::map __handleMap; }; } /* namespace ctx */ diff --git a/src/place/recognition/place_recognition.cpp b/src/place/recognition/place_recognition.cpp index bca18be..b736f1a 100644 --- a/src/place/recognition/place_recognition.cpp +++ b/src/place/recognition/place_recognition.cpp @@ -14,41 +14,20 @@ * limitations under the License. */ -#include -#include #include "place_recognition.h" #include "user_places/user_places.h" -ctx::PlaceRecognitionProvider *ctx::PlaceRecognitionProvider::__instance = NULL; - -ctx::ContextProviderBase *ctx::PlaceRecognitionProvider::create(void *data) -{ - IF_FAIL_RETURN(!__instance, __instance); - __instance = new(std::nothrow) PlaceRecognitionProvider(); - IF_FAIL_RETURN_TAG(__instance, NULL, _E, "Memory allocation failed"); - _I(BLUE("Created")); - return __instance; -} - -void ctx::PlaceRecognitionProvider::destroy(void *data) -{ - IF_FAIL_VOID(__instance); - delete __instance; - __instance = NULL; - _I(BLUE("Destroyed")); -} - -int ctx::PlaceRecognitionProvider::subscribe(const char *subject, ctx::Json option, ctx::Json* requestResult) +int ctx::PlaceRecognitionProvider::subscribe(ctx::Json option, ctx::Json* requestResult) { return ERR_NOT_SUPPORTED; } -int ctx::PlaceRecognitionProvider::unsubscribe(const char *subject, ctx::Json option) +int ctx::PlaceRecognitionProvider::unsubscribe(ctx::Json option) { return ERR_NOT_SUPPORTED; } -int ctx::PlaceRecognitionProvider::read(const char *subject, ctx::Json option, ctx::Json* requestResult) +int ctx::PlaceRecognitionProvider::read(ctx::Json option, ctx::Json* requestResult) { _I(BLUE("Read")); _J("Option", option); @@ -63,17 +42,18 @@ int ctx::PlaceRecognitionProvider::read(const char *subject, ctx::Json option, c * Please just be sure that, the 2nd input parameter "option" should be the same to the * "option" parameter received via ctx::PlaceRecognitionProvider::read(). */ - ctx::context_manager::replyToRead(PLACE_SUBJ_RECOGNITION, option, ERR_NONE, dataRead); + replyToRead(option, ERR_NONE, dataRead); return ERR_NONE; } -int ctx::PlaceRecognitionProvider::write(const char *subject, ctx::Json data, ctx::Json* requestResult) +int ctx::PlaceRecognitionProvider::write(ctx::Json data, ctx::Json* requestResult) { return ERR_NOT_SUPPORTED; } bool ctx::PlaceRecognitionProvider::isSupported() { + /* TODO: This function should be implemented properly */ return true; } diff --git a/src/place/recognition/place_recognition.h b/src/place/recognition/place_recognition.h index 545c953..814bb00 100644 --- a/src/place/recognition/place_recognition.h +++ b/src/place/recognition/place_recognition.h @@ -17,31 +17,30 @@ #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 PlaceRecognitionProvider : public ContextProviderBase { - + class PlaceRecognitionProvider : public ContextProvider { public: - static ContextProviderBase *create(void *data); - static void destroy(void *data); - static bool isSupported(); + PlaceRecognitionProvider() : + ContextProvider(PLACE_SUBJ_RECOGNITION), + __engine(PLACE_RECOG_HIGH_ACCURACY_MODE) {} - 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); + ~PlaceRecognitionProvider() {} - private: - static PlaceRecognitionProvider *__instance; - UserPlaces __engine; + int subscribe(ctx::Json option, ctx::Json *requestResult); + int unsubscribe(ctx::Json option); + int read(ctx::Json option, ctx::Json *requestResult); + int write(ctx::Json data, ctx::Json *requestResult); - PlaceRecognitionProvider() : __engine(PLACE_RECOG_HIGH_ACCURACY_MODE) {} - ~PlaceRecognitionProvider() {} + bool isSupported(); + void submitTriggerItem() {} + private: + UserPlaces __engine; }; /* class PlaceRecognitionProvider */ } /* namespace ctx */ diff --git a/src/statistics/CMakeLists.txt b/src/statistics/CMakeLists.txt index 79ac9c5..6b35770 100644 --- a/src/statistics/CMakeLists.txt +++ b/src/statistics/CMakeLists.txt @@ -29,9 +29,3 @@ ENDIF("${PROFILE}" STREQUAL "mobile") # Wearable Profile #IF("${PROFILE}" STREQUAL "wearable") #ENDIF("${PROFILE}" STREQUAL "wearable") - -# TV Profile -IF("${PROFILE}" STREQUAL "tv") - FILE(GLOB prvd_srcs ${prvd_srcs} media/*.cpp) - SET(prvd_deps ${prvd_deps} capi-content-media-content) -ENDIF("${PROFILE}" STREQUAL "tv") diff --git a/src/statistics/StatisticsContextProvider.cpp b/src/statistics/StatisticsContextProvider.cpp index 7c3123d..0dba666 100644 --- a/src/statistics/StatisticsContextProvider.cpp +++ b/src/statistics/StatisticsContextProvider.cpp @@ -14,75 +14,64 @@ */ #include -#include -#include +#include #include -#include "app/AppStatisticsProvider.h" +#include "app/AppStatsProvider.h" +#include "app/AppStatsLogger.h" #ifndef _DISABLE_PREDICTION_ENGINE_ // include prediction engine header files here #endif #ifdef _MOBILE_ -#include "media/MediaStatisticsProvider.h" -#include "social/SocialStatisticsProvider.h" -#endif - -#ifdef _TV_ -#include "media/MediaStatisticsProvider.h" +#include "media/MediaStatsProvider.h" +#include "media/MediaStatsLogger.h" +#include "social/SocialStatsProvider.h" +#include "social/SocialStatsLogger.h" #endif template void registerProvider(const char *subject, const char *privilege) { - if (!Provider::isSupported(subject)) + Provider *provider = new(std::nothrow) Provider(); + IF_FAIL_VOID_TAG(provider, _E, "Memory allocation failed"); + + if (!provider->isSupported()) { + delete provider; return; + } - ctx::ContextProviderInfo providerInfo(Provider::create, Provider::destroy, NULL, privilege); - ctx::context_manager::registerProvider(subject, providerInfo); + provider->registerProvider(privilege, provider); + provider->submitTriggerItem(); } SO_EXPORT bool ctx::initStatisticsContextProvider() { - AppStatisticsProvider::create(NULL); - 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); - AppStatisticsProvider::submitTriggerItem(); + registerProvider(APP_SUBJ_LOGGER, 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); #ifndef _DISABLE_PREDICTION_ENGINE_ // initialize the prediction engine here #endif #ifdef _MOBILE_ - MediaStatisticsProvider::create(NULL); - 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); - MediaStatisticsProvider::submitTriggerItem(); - - SocialStatisticsProvider::create(NULL); - registerProvider(SOCIAL_SUBJ_FREQ_ADDRESS, SOCIAL_HISTORY_PRIV); - registerProvider(SOCIAL_SUBJ_FREQUENCY, SOCIAL_HISTORY_PRIV); - SocialStatisticsProvider::submitTriggerItem(); -#endif + registerProvider(MEDIA_SUBJ_LOGGER, 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); -#ifdef _TV_ - MediaStatisticsProvider::create(NULL); - 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); - MediaStatisticsProvider::submitTriggerItem(); + registerProvider(SOCIAL_SUBJ_LOGGER, SOCIAL_HISTORY_PRIV); + registerProvider(SOCIAL_SUBJ_FREQUENCY, SOCIAL_HISTORY_PRIV); + registerProvider(SOCIAL_SUBJ_FREQ_ADDRESS, SOCIAL_HISTORY_PRIV); #endif return true; diff --git a/src/statistics/app/AppStatisticsProvider.cpp b/src/statistics/app/AppStatisticsProvider.cpp deleted file mode 100644 index a7d4211..0000000 --- a/src/statistics/app/AppStatisticsProvider.cpp +++ /dev/null @@ -1,128 +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 -#include -#include "AppStatisticsProvider.h" -#include "DbHandle.h" - -#include "DbInit.h" -#include "InstallMonitor.h" -#include "ActiveWindowMonitor.h" - -static ctx::AppInstallMonitor *__installMon = NULL; -static ctx::AppUseMonitor *__launchMon = NULL; - -ctx::AppStatisticsProvider *ctx::AppStatisticsProvider::__instance = NULL; - -ctx::AppStatisticsProvider::AppStatisticsProvider() -{ -} - -ctx::AppStatisticsProvider::~AppStatisticsProvider() -{ - delete __installMon; - delete __launchMon; - __installMon = NULL; - __launchMon = NULL; -} - -ctx::ContextProviderBase *ctx::AppStatisticsProvider::create(void *data) -{ - IF_FAIL_RETURN(!__instance, __instance); - - __instance = new(std::nothrow) AppStatisticsProvider(); - IF_FAIL_RETURN_TAG(__instance, NULL, _E, "Memory allocation failed"); - - if (!__instance->__init()) { - destroy(data); - return NULL; - } - - _I(BLUE("Created")); - return __instance; -} - -void ctx::AppStatisticsProvider::destroy(void *data) -{ - IF_FAIL_VOID(__instance); - delete __instance; - __instance = NULL; - _I(BLUE("Destroyed")); -} - -bool ctx::AppStatisticsProvider::isSupported(const char* subject) -{ - return true; -} - -void ctx::AppStatisticsProvider::submitTriggerItem() -{ - context_manager::registerTriggerItem(APP_SUBJ_FREQUENCY, OPS_READ, - "{" TRIG_DEF_RANK "," TRIG_DEF_TOTAL_COUNT "}", - "{" - "\"AppId\":{\"type\":\"string\"}," - TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK - "}"); -} - -bool ctx::AppStatisticsProvider::__init() -{ - AppDbInitializer *initializer = new(std::nothrow) AppDbInitializer(); - IF_FAIL_RETURN_TAG(initializer, false, _E, "Memory allocation failed"); - - __installMon = new(std::nothrow) ctx::AppInstallMonitor(); - __launchMon = new(std::nothrow) ctx::AppUseMonitor(); - IF_FAIL_CATCH_TAG(__installMon && __launchMon, _E, "Memory allocation failed"); - return true; - -CATCH: - delete __installMon; - delete __launchMon; - __installMon = NULL; - __launchMon = NULL; - return false; -} - -int ctx::AppStatisticsProvider::subscribe(const char* subject, ctx::Json option, ctx::Json* requestResult) -{ - return ERR_NOT_SUPPORTED; -} - -int ctx::AppStatisticsProvider::unsubscribe(const char* subject, ctx::Json option) -{ - return ERR_NOT_SUPPORTED; -} - -int ctx::AppStatisticsProvider::read(const char* subject, ctx::Json option, ctx::Json* requestResult) -{ - ctx::AppDbHandle *handle = new(std::nothrow) ctx::AppDbHandle(); - IF_FAIL_RETURN_TAG(handle, ERR_OPERATION_FAILED, _E, "Memory allocation failed"); - - int err = handle->read(subject, option); - if (err != ERR_NONE) { - delete handle; - return err; - } - - return ERR_NONE; -} - -int ctx::AppStatisticsProvider::write(const char* subject, ctx::Json data, ctx::Json* requestResult) -{ - return ERR_NOT_SUPPORTED; -} diff --git a/src/statistics/app/AppStatisticsProvider.h b/src/statistics/app/AppStatisticsProvider.h deleted file mode 100644 index 1d5bb2d..0000000 --- a/src/statistics/app/AppStatisticsProvider.h +++ /dev/null @@ -1,48 +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_STATS_APP_STATS_PROVIDER_H_ -#define _CONTEXT_STATS_APP_STATS_PROVIDER_H_ - -#include -#include "AppStatisticsTypes.h" - -namespace ctx { - - class AppStatisticsProvider : public ContextProviderBase { - public: - static ContextProviderBase *create(void *data); - static void destroy(void *data); - static bool isSupported(const char *subject); - static void submitTriggerItem(); - - 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); - - private: - static AppStatisticsProvider *__instance; - - AppStatisticsProvider(); - ~AppStatisticsProvider(); - bool __init(); - - }; /* class AppStatisticsProvider */ - -} /* namespace ctx */ - -#endif /* End of _CONTEXT_STATS_APP_STATS_PROVIDER_H_ */ diff --git a/src/statistics/app/AppStatisticsTypes.h b/src/statistics/app/AppStatisticsTypes.h index aa8f2d2..42b049e 100644 --- a/src/statistics/app/AppStatisticsTypes.h +++ b/src/statistics/app/AppStatisticsTypes.h @@ -20,6 +20,7 @@ #include "../shared/CommonTypes.h" #define APP_HISTORY_PRIV "apphistory.read" +#define APP_SUBJ_LOGGER "stats/app/logger" #define APP_SUBJ_RECENTLY_USED "stats/app/recently" #define APP_SUBJ_FREQUENTLY_USED "stats/app/often" #define APP_SUBJ_RARELY_USED "stats/app/rarely" diff --git a/src/statistics/app/AppStatsLogger.cpp b/src/statistics/app/AppStatsLogger.cpp new file mode 100644 index 0000000..9bbb390 --- /dev/null +++ b/src/statistics/app/AppStatsLogger.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2016 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 "AppStatisticsTypes.h" +#include "AppStatsLogger.h" + +using namespace ctx; + +AppStatsLogger::AppStatsLogger() : + ContextProvider(APP_SUBJ_LOGGER), + __initializer(NULL), + __installMon(NULL), + __launchMon(NULL) +{ + __initializer = new(std::nothrow) AppDbInitializer(); + IF_FAIL_VOID_TAG(__initializer, _E, "Memory allocation failed"); + + __installMon = new(std::nothrow) AppInstallMonitor(); + __launchMon = new(std::nothrow) AppUseMonitor(); + IF_FAIL_CATCH_TAG(__installMon && __launchMon, _E, "Memory allocation failed"); + return; + +CATCH: + delete __installMon; + delete __launchMon; + __installMon = NULL; + __launchMon = NULL; +} + +AppStatsLogger::~AppStatsLogger() +{ + delete __installMon; + delete __launchMon; +} + +int AppStatsLogger::subscribe(Json option, Json* requestResult) +{ + return ERR_NONE; +} + +int AppStatsLogger::unsubscribe(Json option) +{ + return ERR_NONE; +} diff --git a/src/statistics/app/AppStatsLogger.h b/src/statistics/app/AppStatsLogger.h new file mode 100644 index 0000000..b2104dd --- /dev/null +++ b/src/statistics/app/AppStatsLogger.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016 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_APP_STATS_LOGGER_H_ +#define _CONTEXT_APP_STATS_LOGGER_H_ + +#include +#include "DbInit.h" +#include "InstallMonitor.h" +#include "ActiveWindowMonitor.h" + +namespace ctx { + + class AppStatsLogger : public ContextProvider { + public: + AppStatsLogger(); + ~AppStatsLogger(); + + int subscribe(Json option, Json *requestResult); + int unsubscribe(Json option); + + void submitTriggerItem() {} + + private: + AppDbInitializer *__initializer; + AppInstallMonitor *__installMon; + AppUseMonitor *__launchMon; + }; + +} /* namespace ctx */ + +#endif /* _CONTEXT_APP_STATS_LOGGER_H_ */ diff --git a/src/statistics/app/AppStatsProvider.cpp b/src/statistics/app/AppStatsProvider.cpp new file mode 100644 index 0000000..7e18049 --- /dev/null +++ b/src/statistics/app/AppStatsProvider.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2016 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 "AppStatsProvider.h" +#include "DbHandle.h" + +using namespace ctx; + +AppStatsProvider::AppStatsProvider(const char *subject) : + ContextProvider(subject) +{ +} + +AppStatsProvider::~AppStatsProvider() +{ +} + +void AppStatsProvider::submitTriggerItem() +{ +} + +int AppStatsProvider::read(Json option, Json *requestResult) +{ + AppDbHandle *handle = new(std::nothrow) AppDbHandle(this); + IF_FAIL_RETURN_TAG(handle, ERR_OPERATION_FAILED, _E, "Memory allocation failed"); + + int err = handle->read(option); + if (err != ERR_NONE) { + delete handle; + return err; + } + + return ERR_NONE; +} + +void AppFreqProvider::submitTriggerItem() +{ + registerTriggerItem(OPS_READ, + "{" TRIG_DEF_RANK "," TRIG_DEF_TOTAL_COUNT "}", + "{" + "\"AppId\":{\"type\":\"string\"}," + TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK + "}"); +} diff --git a/src/statistics/app/AppStatsProvider.h b/src/statistics/app/AppStatsProvider.h new file mode 100644 index 0000000..dccb66a --- /dev/null +++ b/src/statistics/app/AppStatsProvider.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2016 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_APP_STATS_PROVIDER_H_ +#define _CONTEXT_APP_STATS_PROVIDER_H_ + +#include +#include "AppStatisticsTypes.h" + +namespace ctx { + + class AppStatsProvider : public ContextProvider { + public: + int read(Json option, Json *requestResult); + virtual void submitTriggerItem(); + + protected: + AppStatsProvider(const char *subject); + virtual ~AppStatsProvider(); + }; + + + class RecentAppProvider : public AppStatsProvider { + public: + RecentAppProvider() : + AppStatsProvider(APP_SUBJ_RECENTLY_USED) {} + }; + + + class FrequentAppProvider : public AppStatsProvider { + public: + FrequentAppProvider() : + AppStatsProvider(APP_SUBJ_FREQUENTLY_USED) {} + }; + + + class RareAppProvider : public AppStatsProvider { + public: + RareAppProvider() : + AppStatsProvider(APP_SUBJ_RARELY_USED) {} + }; + + + class AppPeakTimeProvider : public AppStatsProvider { + public: + AppPeakTimeProvider() : + AppStatsProvider(APP_SUBJ_PEAK_TIME) {} + }; + + + class AppSettingProvider : public AppStatsProvider { + public: + AppSettingProvider() : + AppStatsProvider(APP_SUBJ_COMMON_SETTING) {} + }; + + + class AppFreqProvider : public AppStatsProvider { + public: + AppFreqProvider() : + AppStatsProvider(APP_SUBJ_FREQUENCY) {} + + void submitTriggerItem(); + }; + +} /* namespace ctx */ + +#endif /* _CONTEXT_APP_STATS_PROVIDER_H_ */ diff --git a/src/statistics/app/DbHandle.cpp b/src/statistics/app/DbHandle.cpp index b83c137..06021e3 100644 --- a/src/statistics/app/DbHandle.cpp +++ b/src/statistics/app/DbHandle.cpp @@ -16,21 +16,24 @@ #include #include -#include #include "AppStatisticsTypes.h" #include "DbHandle.h" -ctx::AppDbHandle::AppDbHandle() +using namespace ctx; + +AppDbHandle::AppDbHandle(ContextProvider *provider) : + StatsDbHandleBase(provider) { } -ctx::AppDbHandle::~AppDbHandle() +AppDbHandle::~AppDbHandle() { } -int ctx::AppDbHandle::read(const char* subject, ctx::Json filter) +int AppDbHandle::read(Json filter) { std::string query; + const char *subject = reqProvider->getSubject(); if (STR_EQ(subject, APP_SUBJ_RECENTLY_USED)) { query = createSqlRecentlyUsed(filter); @@ -48,19 +51,19 @@ int ctx::AppDbHandle::read(const char* subject, ctx::Json filter) query = createSqlCommonSetting(filter); } else if (STR_EQ(subject, APP_SUBJ_FREQUENCY)) { - __isTriggerItem = true; + isTriggerItem = true; query = createSqlFrequency(filter); } IF_FAIL_RETURN(!query.empty(), ERR_OPERATION_FAILED); - bool ret = executeQuery(subject, filter, query.c_str()); + bool ret = executeQuery(filter, query.c_str()); IF_FAIL_RETURN(ret, ERR_OPERATION_FAILED); return ERR_NONE; } -std::string ctx::AppDbHandle::createWhereClauseWithDeviceStatus(ctx::Json filter) +std::string AppDbHandle::createWhereClauseWithDeviceStatus(Json filter) { std::stringstream whereClause; std::string bssid; @@ -77,19 +80,19 @@ std::string ctx::AppDbHandle::createWhereClauseWithDeviceStatus(ctx::Json filter return whereClause.str(); } -std::string ctx::AppDbHandle::createSqlPeakTime(ctx::Json filter) +std::string AppDbHandle::createSqlPeakTime(Json filter) { return StatsDbHandleBase::createSqlPeakTime(filter, APP_TABLE_USAGE_LOG, createWhereClause(filter)); } -std::string ctx::AppDbHandle::createSqlCommonSetting(ctx::Json filter) +std::string AppDbHandle::createSqlCommonSetting(Json filter) { return StatsDbHandleBase::createSqlCommonSetting(filter, APP_TABLE_USAGE_LOG, createWhereClause(filter)); } -std::string ctx::AppDbHandle::createSqlFrequency(ctx::Json filter) +std::string AppDbHandle::createSqlFrequency(Json filter) { - ctx::Json filterCleaned; + Json filterCleaned; std::string weekStr; std::string timeOfDay; std::string appId; @@ -133,7 +136,7 @@ std::string ctx::AppDbHandle::createSqlFrequency(ctx::Json filter) return query.str(); } -std::string ctx::AppDbHandle::createSqlRecentlyUsed(ctx::Json filter) +std::string AppDbHandle::createSqlRecentlyUsed(Json filter) { std::stringstream query; int limit = DEFAULT_LIMIT; @@ -154,7 +157,7 @@ std::string ctx::AppDbHandle::createSqlRecentlyUsed(ctx::Json filter) return query.str(); } -std::string ctx::AppDbHandle::createSqlFrequentlyUsed(ctx::Json filter) +std::string AppDbHandle::createSqlFrequentlyUsed(Json filter) { std::stringstream query; int limit = DEFAULT_LIMIT; @@ -175,7 +178,7 @@ std::string ctx::AppDbHandle::createSqlFrequentlyUsed(ctx::Json filter) return query.str(); } -std::string ctx::AppDbHandle::createSqlRarelyUsed(ctx::Json filter) +std::string AppDbHandle::createSqlRarelyUsed(Json filter) { std::stringstream query; int limit = DEFAULT_LIMIT; @@ -198,11 +201,11 @@ std::string ctx::AppDbHandle::createSqlRarelyUsed(ctx::Json filter) return query.str(); } -void ctx::AppDbHandle::replyTriggerItem(int error, ctx::Json &jsonResult) +void AppDbHandle::replyTriggerItem(int error, Json &jsonResult) { - IF_FAIL_VOID_TAG(STR_EQ(__reqSubject.c_str(), APP_SUBJ_FREQUENCY), _E, "Invalid subject"); + IF_FAIL_VOID_TAG(STR_EQ(reqProvider->getSubject(), APP_SUBJ_FREQUENCY), _E, "Invalid subject"); - ctx::Json results; + Json results; std::string valStr; int val; @@ -213,5 +216,5 @@ void ctx::AppDbHandle::replyTriggerItem(int error, ctx::Json &jsonResult) jsonResult.get(NULL, STATS_RANK, &val); results.set(NULL, STATS_RANK, val); - context_manager::replyToRead(__reqSubject.c_str(), __reqFilter, error, results); + reqProvider->replyToRead(reqFilter, error, results); } diff --git a/src/statistics/app/DbHandle.h b/src/statistics/app/DbHandle.h index ac2e7d5..9084d87 100644 --- a/src/statistics/app/DbHandle.h +++ b/src/statistics/app/DbHandle.h @@ -24,20 +24,20 @@ namespace ctx { class AppDbHandle : public StatsDbHandleBase { public: - AppDbHandle(); + AppDbHandle(ContextProvider *provider); ~AppDbHandle(); - int read(const char* subject, ctx::Json filter); + int read(Json filter); protected: - std::string createWhereClauseWithDeviceStatus(ctx::Json filter); - std::string createSqlRecentlyUsed(ctx::Json filter); - std::string createSqlFrequentlyUsed(ctx::Json filter); - std::string createSqlRarelyUsed(ctx::Json filter); - std::string createSqlPeakTime(ctx::Json filter); - std::string createSqlCommonSetting(ctx::Json filter); - std::string createSqlFrequency(ctx::Json filter); - void replyTriggerItem(int error, ctx::Json &jsonResult); + std::string createWhereClauseWithDeviceStatus(Json filter); + std::string createSqlRecentlyUsed(Json filter); + std::string createSqlFrequentlyUsed(Json filter); + std::string createSqlRarelyUsed(Json filter); + std::string createSqlPeakTime(Json filter); + std::string createSqlCommonSetting(Json filter); + std::string createSqlFrequency(Json filter); + void replyTriggerItem(int error, Json &jsonResult); }; } diff --git a/src/statistics/app/app_inactive_detector/AppInactiveDetector.cpp b/src/statistics/app/app_inactive_detector/AppInactiveDetector.cpp index 48dc313..148d655 100644 --- a/src/statistics/app/app_inactive_detector/AppInactiveDetector.cpp +++ b/src/statistics/app/app_inactive_detector/AppInactiveDetector.cpp @@ -32,7 +32,7 @@ ctx::app_inactive_detector_provider::~app_inactive_detector_provider() { } -ctx::ContextProviderBase *ctx::app_inactive_detector_provider::create(void *data) +ctx::ContextProvider *ctx::app_inactive_detector_provider::create(void *data) { IF_FAIL_RETURN(!__instance, __instance); __instance = new(std::nothrow) app_inactive_detector_provider(); diff --git a/src/statistics/app/app_inactive_detector/AppInactiveDetector.h b/src/statistics/app/app_inactive_detector/AppInactiveDetector.h index 2dd427d..588130a 100644 --- a/src/statistics/app/app_inactive_detector/AppInactiveDetector.h +++ b/src/statistics/app/app_inactive_detector/AppInactiveDetector.h @@ -17,16 +17,16 @@ #ifndef __CONTEXT_APP_INACTIVE_DETECTOR_H__ #define __CONTEXT_APP_INACTIVE_DETECTOR_H__ -#include +#include #include "AppInactiveDetectorTypes.h" #include "InactiveDetector.h" namespace ctx { - class app_inactive_detector_provider : public ContextProviderBase { + class app_inactive_detector_provider : public ContextProvider { public: - static ContextProviderBase *create(void *data); + static ContextProvider *create(void *data); static void destroy(void *data); static bool is_supported(); diff --git a/src/statistics/media/DbHandle.cpp b/src/statistics/media/DbHandle.cpp index ec1e252..e8f0f03 100644 --- a/src/statistics/media/DbHandle.cpp +++ b/src/statistics/media/DbHandle.cpp @@ -16,23 +16,26 @@ #include #include -#include #include "../shared/SystemInfo.h" #include "MediaStatisticsTypes.h" #include "DbHandle.h" -ctx::MediaDbHandle::MediaDbHandle() +using namespace ctx; + +MediaDbHandle::MediaDbHandle(ContextProvider *provider) : + StatsDbHandleBase(provider) { } -ctx::MediaDbHandle::~MediaDbHandle() +MediaDbHandle::~MediaDbHandle() { } -int ctx::MediaDbHandle::read(const char* subject, ctx::Json filter) +int MediaDbHandle::read(Json filter) { //TODO: filter validation (in the API side?) std::string query; + const char *subject = reqProvider->getSubject(); if (STR_EQ(subject, MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC)) { query = createSqlPeakTime(MEDIA_TYPE_MUSIC, filter); @@ -47,23 +50,23 @@ int ctx::MediaDbHandle::read(const char* subject, ctx::Json filter) query = createSqlCommonSetting(MEDIA_TYPE_VIDEO, filter); } else if (STR_EQ(subject, MEDIA_SUBJ_MUSIC_FREQUENCY)) { - __isTriggerItem = true; + isTriggerItem = true; query = createSqlFrequency(MEDIA_TYPE_MUSIC, filter); } else if (STR_EQ(subject, MEDIA_SUBJ_VIDEO_FREQUENCY)) { - __isTriggerItem = true; + isTriggerItem = true; query = createSqlFrequency(MEDIA_TYPE_VIDEO, filter); } IF_FAIL_RETURN(!query.empty(), ERR_OPERATION_FAILED); - bool ret = executeQuery(subject, filter, query.c_str()); + bool ret = executeQuery(filter, query.c_str()); IF_FAIL_RETURN(ret, ERR_OPERATION_FAILED); return ERR_NONE; } -std::string ctx::MediaDbHandle::createWhereClause(int mediaType, ctx::Json filter) +std::string MediaDbHandle::createWhereClause(int mediaType, Json filter) { std::stringstream whereClause; @@ -73,21 +76,21 @@ std::string ctx::MediaDbHandle::createWhereClause(int mediaType, ctx::Json filte return whereClause.str(); } -std::string ctx::MediaDbHandle::createSqlPeakTime(int mediaType, ctx::Json filter) +std::string MediaDbHandle::createSqlPeakTime(int mediaType, Json filter) { std::string where = createWhereClause(mediaType, filter); return StatsDbHandleBase::createSqlPeakTime(filter, MEDIA_TABLE_NAME, where); } -std::string ctx::MediaDbHandle::createSqlCommonSetting(int mediaType, ctx::Json filter) +std::string MediaDbHandle::createSqlCommonSetting(int mediaType, Json filter) { std::string where = createWhereClause(mediaType, filter); return StatsDbHandleBase::createSqlCommonSetting(filter, MEDIA_TABLE_NAME, where); } -std::string ctx::MediaDbHandle::createSqlFrequency(int mediaType, ctx::Json filter) +std::string MediaDbHandle::createSqlFrequency(int mediaType, Json filter) { - ctx::Json filterCleaned; + Json filterCleaned; std::string weekStr; std::string timeOfDay; @@ -108,16 +111,16 @@ std::string ctx::MediaDbHandle::createSqlFrequency(int mediaType, ctx::Json filt return query.str(); } -void ctx::MediaDbHandle::replyTriggerItem(int error, ctx::Json &jsonResult) +void MediaDbHandle::replyTriggerItem(int error, Json &jsonResult) { - IF_FAIL_VOID_TAG(STR_EQ(__reqSubject.c_str(), MEDIA_SUBJ_MUSIC_FREQUENCY) || - STR_EQ(__reqSubject.c_str(), MEDIA_SUBJ_VIDEO_FREQUENCY), _E, "Invalid subject"); + IF_FAIL_VOID_TAG(STR_EQ(reqProvider->getSubject(), MEDIA_SUBJ_MUSIC_FREQUENCY) || + STR_EQ(reqProvider->getSubject(), MEDIA_SUBJ_VIDEO_FREQUENCY), _E, "Invalid subject"); - ctx::Json results; + Json results; int val; jsonResult.get(NULL, STATS_TOTAL_COUNT, &val); results.set(NULL, STATS_TOTAL_COUNT, val); - context_manager::replyToRead(__reqSubject.c_str(), __reqFilter, error, results); + reqProvider->replyToRead(reqFilter, error, results); } diff --git a/src/statistics/media/DbHandle.h b/src/statistics/media/DbHandle.h index 8a1f036..8b7f1c1 100644 --- a/src/statistics/media/DbHandle.h +++ b/src/statistics/media/DbHandle.h @@ -24,17 +24,17 @@ namespace ctx { class MediaDbHandle : public StatsDbHandleBase { public: - MediaDbHandle(); + MediaDbHandle(ContextProvider *provider); ~MediaDbHandle(); - int read(const char* subject, ctx::Json filter); + int read(Json filter); protected: - std::string createWhereClause(int mediaType, ctx::Json filter); - std::string createSqlPeakTime(int mediaType, ctx::Json filter); - std::string createSqlCommonSetting(int mediaType, ctx::Json filter); - std::string createSqlFrequency(int mediaType, ctx::Json filter); - void replyTriggerItem(int error, ctx::Json &jsonResult); + std::string createWhereClause(int mediaType, Json filter); + std::string createSqlPeakTime(int mediaType, Json filter); + std::string createSqlCommonSetting(int mediaType, Json filter); + std::string createSqlFrequency(int mediaType, Json filter); + void replyTriggerItem(int error, Json &jsonResult); }; } diff --git a/src/statistics/media/MediaStatisticsProvider.cpp b/src/statistics/media/MediaStatisticsProvider.cpp deleted file mode 100644 index 582d654..0000000 --- a/src/statistics/media/MediaStatisticsProvider.cpp +++ /dev/null @@ -1,113 +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 -#include -#include "MediaStatisticsProvider.h" -#include "DbHandle.h" -#include "MediaContentMonitor.h" - -static ctx::MediaContentMonitor *__contentMon = NULL; - -ctx::MediaStatisticsProvider *ctx::MediaStatisticsProvider::__instance = NULL; - -ctx::MediaStatisticsProvider::MediaStatisticsProvider() -{ -} - -ctx::MediaStatisticsProvider::~MediaStatisticsProvider() -{ - delete __contentMon; - __contentMon = NULL; -} - -ctx::ContextProviderBase *ctx::MediaStatisticsProvider::create(void *data) -{ - IF_FAIL_RETURN(!__instance, __instance); - - __instance = new(std::nothrow) MediaStatisticsProvider(); - IF_FAIL_RETURN_TAG(__instance, NULL, _E, "Memory allocation failed"); - - _I(BLUE("Created")); - - if (!__instance->__init()) { - destroy(data); - return NULL; - } - - return __instance; -} - -void ctx::MediaStatisticsProvider::destroy(void *data) -{ - IF_FAIL_VOID(__instance); - delete __instance; - __instance = NULL; - _I(BLUE("Destroyed")); -} - -bool ctx::MediaStatisticsProvider::isSupported(const char* subject) -{ - return true; -} - -void ctx::MediaStatisticsProvider::submitTriggerItem() -{ - 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::registerTriggerItem(MEDIA_SUBJ_VIDEO_FREQUENCY, OPS_READ, - "{" TRIG_DEF_TOTAL_COUNT "}", - "{" TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK "}"); -} - -bool ctx::MediaStatisticsProvider::__init() -{ - __contentMon = new(std::nothrow) ctx::MediaContentMonitor(); - IF_FAIL_RETURN_TAG(__contentMon, false, _E, "Memory allocation failed"); - return true; -} - -int ctx::MediaStatisticsProvider::subscribe(const char* subject, ctx::Json option, ctx::Json* requestResult) -{ - return ERR_NOT_SUPPORTED; -} - -int ctx::MediaStatisticsProvider::unsubscribe(const char* subject, ctx::Json option) -{ - return ERR_NOT_SUPPORTED; -} - -int ctx::MediaStatisticsProvider::read(const char* subject, ctx::Json option, ctx::Json* requestResult) -{ - MediaDbHandle *handle = new(std::nothrow) MediaDbHandle(); - IF_FAIL_RETURN_TAG(handle, ERR_OPERATION_FAILED, _E, "Memory allocation failed"); - - int err = handle->read(subject, option); - if (err != ERR_NONE) { - delete handle; - return err; - } - - return ERR_NONE; -} - -int ctx::MediaStatisticsProvider::write(const char* subject, ctx::Json data, ctx::Json* requestResult) -{ - return ERR_NOT_SUPPORTED; -} diff --git a/src/statistics/media/MediaStatisticsProvider.h b/src/statistics/media/MediaStatisticsProvider.h deleted file mode 100644 index edcbc5a..0000000 --- a/src/statistics/media/MediaStatisticsProvider.h +++ /dev/null @@ -1,48 +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_STATS_MEDIA_STATS_PROVIDER_H_ -#define _CONTEXT_STATS_MEDIA_STATS_PROVIDER_H_ - -#include -#include "MediaStatisticsTypes.h" - -namespace ctx { - - class MediaStatisticsProvider : public ContextProviderBase { - public: - static ContextProviderBase *create(void *data); - static void destroy(void *data); - static bool isSupported(const char *subject); - static void submitTriggerItem(); - - 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); - - private: - static MediaStatisticsProvider *__instance; - - MediaStatisticsProvider(); - ~MediaStatisticsProvider(); - bool __init(); - - }; /* class MediaStatisticsProvider */ - -} /* namespace ctx */ - -#endif /* End of _CONTEXT_STATS_MEDIA_STATS_PROVIDER_H_ */ diff --git a/src/statistics/media/MediaStatisticsTypes.h b/src/statistics/media/MediaStatisticsTypes.h index 71d1fa1..a71e553 100644 --- a/src/statistics/media/MediaStatisticsTypes.h +++ b/src/statistics/media/MediaStatisticsTypes.h @@ -20,6 +20,7 @@ #include "../shared/CommonTypes.h" #define MEDIA_HISTORY_PRIV "mediahistory.read" +#define MEDIA_SUBJ_LOGGER "stats/media/logger" #define MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC "stats/music/peak_time" #define MEDIA_SUBJ_PEAK_TIME_FOR_VIDEO "stats/video/peak_time" #define MEDIA_SUBJ_COMMON_SETTING_FOR_MUSIC "stats/music/setting" diff --git a/src/statistics/media/MediaStatsLogger.cpp b/src/statistics/media/MediaStatsLogger.cpp new file mode 100644 index 0000000..9b1db7d --- /dev/null +++ b/src/statistics/media/MediaStatsLogger.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2016 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 "MediaStatisticsTypes.h" +#include "MediaStatsLogger.h" + +using namespace ctx; + +MediaStatsLogger::MediaStatsLogger() : + ContextProvider(MEDIA_SUBJ_LOGGER) +{ +} + +MediaStatsLogger::~MediaStatsLogger() +{ +} + +int MediaStatsLogger::subscribe(Json option, Json* requestResult) +{ + return ERR_NONE; +} + +int MediaStatsLogger::unsubscribe(Json option) +{ + return ERR_NONE; +} diff --git a/src/statistics/media/MediaStatsLogger.h b/src/statistics/media/MediaStatsLogger.h new file mode 100644 index 0000000..28e8aca --- /dev/null +++ b/src/statistics/media/MediaStatsLogger.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2016 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_MEDIA_STATS_LOGGER_H_ +#define _CONTEXT_MEDIA_STATS_LOGGER_H_ + +#include +#include "MediaContentMonitor.h" + +namespace ctx { + + class MediaStatsLogger : public ContextProvider { + public: + MediaStatsLogger(); + ~MediaStatsLogger(); + + int subscribe(Json option, Json *requestResult); + int unsubscribe(Json option); + + void submitTriggerItem() {} + + private: + MediaContentMonitor __contentMon; + }; + +} /* namespace ctx */ + +#endif /* _CONTEXT_MEDIA_STATS_LOGGER_H_ */ + diff --git a/src/statistics/media/MediaStatsProvider.cpp b/src/statistics/media/MediaStatsProvider.cpp new file mode 100644 index 0000000..b8ce482 --- /dev/null +++ b/src/statistics/media/MediaStatsProvider.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2016 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 "MediaStatsProvider.h" +#include "DbHandle.h" + +using namespace ctx; + +MediaStatsProvider::MediaStatsProvider(const char *subject) : + ContextProvider(subject) +{ +} + +MediaStatsProvider::~MediaStatsProvider() +{ +} + +bool MediaStatsProvider::isSupported() +{ + /* TODO */ + return true; +} + +void MediaStatsProvider::submitTriggerItem() +{ +} + +int MediaStatsProvider::read(Json option, Json* requestResult) +{ + MediaDbHandle *handle = new(std::nothrow) MediaDbHandle(this); + IF_FAIL_RETURN_TAG(handle, ERR_OPERATION_FAILED, _E, "Memory allocation failed"); + + int err = handle->read(option); + if (err != ERR_NONE) { + delete handle; + return err; + } + + return ERR_NONE; +} + +void MusicFreqProvider::submitTriggerItem() +{ + registerTriggerItem(OPS_READ, + "{" TRIG_DEF_TOTAL_COUNT "}", + "{" TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK "}"); +} + +void VideoFreqProvider::submitTriggerItem() +{ + registerTriggerItem(OPS_READ, + "{" TRIG_DEF_TOTAL_COUNT "}", + "{" TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK "}"); +} diff --git a/src/statistics/media/MediaStatsProvider.h b/src/statistics/media/MediaStatsProvider.h new file mode 100644 index 0000000..5895c46 --- /dev/null +++ b/src/statistics/media/MediaStatsProvider.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2016 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_MEDIA_STATS_PROVIDER_H_ +#define _CONTEXT_MEDIA_STATS_PROVIDER_H_ + +#include +#include "MediaStatisticsTypes.h" + +namespace ctx { + + class MediaStatsProvider : public ContextProvider { + public: + int read(Json option, Json* requestResult); + + bool isSupported(); + virtual void submitTriggerItem(); + + protected: + MediaStatsProvider(const char *subject); + virtual ~MediaStatsProvider(); + }; /* class MediaStatsProvider */ + + + class MusicPeakTimeProvider : public MediaStatsProvider { + public: + MusicPeakTimeProvider() : + MediaStatsProvider(MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC) {} + }; + + + class VideoPeakTimeProvider : public MediaStatsProvider { + public: + VideoPeakTimeProvider() : + MediaStatsProvider(MEDIA_SUBJ_PEAK_TIME_FOR_VIDEO) {} + }; + + + class MusicSettingProvider: public MediaStatsProvider { + public: + MusicSettingProvider() : + MediaStatsProvider(MEDIA_SUBJ_COMMON_SETTING_FOR_MUSIC) {} + }; + + + class VideoSettingProvider: public MediaStatsProvider { + public: + VideoSettingProvider() : + MediaStatsProvider(MEDIA_SUBJ_COMMON_SETTING_FOR_VIDEO) {} + }; + + + class MusicFreqProvider: public MediaStatsProvider { + public: + MusicFreqProvider() : + MediaStatsProvider(MEDIA_SUBJ_MUSIC_FREQUENCY) {} + + void submitTriggerItem(); + }; + + + class VideoFreqProvider: public MediaStatsProvider { + public: + VideoFreqProvider() : + MediaStatsProvider(MEDIA_SUBJ_VIDEO_FREQUENCY) {} + + void submitTriggerItem(); + }; + +} /* namespace ctx */ + +#endif /* _CONTEXT_MEDIA_STATS_PROVIDER_H_ */ diff --git a/src/statistics/shared/DbHandleBase.cpp b/src/statistics/shared/DbHandleBase.cpp index 77982aa..979f75b 100644 --- a/src/statistics/shared/DbHandleBase.cpp +++ b/src/statistics/shared/DbHandleBase.cpp @@ -16,23 +16,25 @@ #include #include -#include #include "CommonTypes.h" #include "DbHandleBase.h" #define DAY_OF_WEEK(SECOND) "CAST(strftime('%w', " SECOND ", 'unixepoch') AS INTEGER)" #define HOUR_OF_DAY(SECOND) "CAST(strftime('%H', " SECOND ", 'unixepoch') AS INTEGER)" -ctx::StatsDbHandleBase::StatsDbHandleBase() : - __isTriggerItem(false) +using namespace ctx; + +StatsDbHandleBase::StatsDbHandleBase(ContextProvider *provider) : + isTriggerItem(false), + reqProvider(provider) { } -ctx::StatsDbHandleBase::~StatsDbHandleBase() +StatsDbHandleBase::~StatsDbHandleBase() { } -int ctx::StatsDbHandleBase::generateQid() +int StatsDbHandleBase::generateQid() { static int qid = 0; @@ -40,18 +42,17 @@ int ctx::StatsDbHandleBase::generateQid() return qid; } -bool ctx::StatsDbHandleBase::executeQuery(const char* subject, ctx::Json filter, const char* query) +bool StatsDbHandleBase::executeQuery(Json filter, const char* query) { bool ret = __dbManager.execute(generateQid(), query, this); IF_FAIL_RETURN(ret, false); - __reqSubject = subject; - __reqFilter = filter; + reqFilter = filter; return true; } -std::string ctx::StatsDbHandleBase::createWhereClause(ctx::Json filter) +std::string StatsDbHandleBase::createWhereClause(Json filter) { std::stringstream whereClause; int week = 0; @@ -141,7 +142,7 @@ std::string ctx::StatsDbHandleBase::createWhereClause(ctx::Json filter) return whereClause.str(); } -std::string ctx::StatsDbHandleBase::createSqlPeakTime(ctx::Json filter, const char* tableName, std::string whereClause) +std::string StatsDbHandleBase::createSqlPeakTime(Json filter, const char* tableName, std::string whereClause) { std::stringstream query; int limit = DEFAULT_LIMIT; @@ -160,7 +161,7 @@ std::string ctx::StatsDbHandleBase::createSqlPeakTime(ctx::Json filter, const ch return query.str(); } -std::string ctx::StatsDbHandleBase::createSqlCommonSetting(ctx::Json filter, const char* tableName, std::string whereClause) +std::string StatsDbHandleBase::createSqlCommonSetting(Json filter, const char* tableName, std::string whereClause) { std::stringstream query; @@ -187,16 +188,16 @@ std::string ctx::StatsDbHandleBase::createSqlCommonSetting(ctx::Json filter, con return query.str(); } -void ctx::StatsDbHandleBase::onTableCreated(unsigned int queryId, int error) +void StatsDbHandleBase::onTableCreated(unsigned int queryId, int error) { } -void ctx::StatsDbHandleBase::onInserted(unsigned int queryId, int error, int64_t rowId) +void StatsDbHandleBase::onInserted(unsigned int queryId, int error, int64_t rowId) { delete this; } -void ctx::StatsDbHandleBase::jsonVectorToArray(std::vector &vecJson, ctx::Json &jsonResult) +void StatsDbHandleBase::__jsonVectorToArray(std::vector &vecJson, Json &jsonResult) { std::vector::iterator vecJsonEnd = vecJson.end(); @@ -206,20 +207,20 @@ void ctx::StatsDbHandleBase::jsonVectorToArray(std::vector &vecJson, ctx:: } } -void ctx::StatsDbHandleBase::onExecuted(unsigned int queryId, int error, std::vector& records) +void StatsDbHandleBase::onExecuted(unsigned int queryId, int error, std::vector& records) { - if (__isTriggerItem) { + if (isTriggerItem) { if (records.size() == 1) { replyTriggerItem(error, records[0]); } else { _E("Invalid query result"); Json dummy; - context_manager::replyToRead(__reqSubject.c_str(), __reqFilter, ERR_OPERATION_FAILED, dummy); + reqProvider->replyToRead(reqFilter, ERR_OPERATION_FAILED, dummy); } } else { Json results = "{\"" STATS_QUERY_RESULT "\":[]}"; - jsonVectorToArray(records, results); - context_manager::replyToRead(__reqSubject.c_str(), __reqFilter, error, results); + __jsonVectorToArray(records, results); + reqProvider->replyToRead(reqFilter, error, results); } delete this; diff --git a/src/statistics/shared/DbHandleBase.h b/src/statistics/shared/DbHandleBase.h index 0a06cb9..8949550 100644 --- a/src/statistics/shared/DbHandleBase.h +++ b/src/statistics/shared/DbHandleBase.h @@ -18,34 +18,35 @@ #define _CONTEXT_STATS_DB_HANDLE_BASE_H_ #include -#include +#include #include namespace ctx { class StatsDbHandleBase : public IDatabaseListener { protected: - bool __isTriggerItem; - std::string __reqSubject; - ctx::Json __reqFilter; - DatabaseManager __dbManager; + bool isTriggerItem; + ContextProvider *reqProvider; + Json reqFilter; - StatsDbHandleBase(); + StatsDbHandleBase(ContextProvider *provider); ~StatsDbHandleBase(); - std::string createWhereClause(ctx::Json filter); - std::string createSqlPeakTime(ctx::Json filter, const char* tableName, std::string whereClause); - std::string createSqlCommonSetting(ctx::Json filter, const char* tableName, std::string whereClause); + std::string createWhereClause(Json filter); + std::string createSqlPeakTime(Json filter, const char* tableName, std::string whereClause); + std::string createSqlCommonSetting(Json filter, const char* tableName, std::string whereClause); - bool executeQuery(const char* subject, ctx::Json filter, const char* query); - virtual void replyTriggerItem(int error, ctx::Json &jsonResult) = 0; + bool executeQuery(Json filter, const char* query); + virtual void replyTriggerItem(int error, Json &jsonResult) = 0; static int generateQid(); private: - void jsonVectorToArray(std::vector &vecJson, ctx::Json &jsonResult); + void __jsonVectorToArray(std::vector &vecJson, Json &jsonResult); void onTableCreated(unsigned int queryId, int error); void onInserted(unsigned int queryId, int error, int64_t rowId); void onExecuted(unsigned int queryId, int error, std::vector& records); + + DatabaseManager __dbManager; }; } diff --git a/src/statistics/shared/SystemInfo.cpp b/src/statistics/shared/SystemInfo.cpp index 369d5c3..63731f7 100644 --- a/src/statistics/shared/SystemInfo.cpp +++ b/src/statistics/shared/SystemInfo.cpp @@ -24,7 +24,9 @@ #define CONNECTED 1 #define NOT_CONNECTED 0 -bool ctx::system_info::getAudioJackState(int* state) +using namespace ctx; + +bool system_info::getAudioJackState(int* state) { int value = NOT_CONNECTED; int err = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &value); @@ -35,7 +37,7 @@ bool ctx::system_info::getAudioJackState(int* state) return true; } -bool ctx::system_info::getVolume(int* systemVolume, int* mediaVolume) +bool system_info::getVolume(int* systemVolume, int* mediaVolume) { int err; @@ -48,7 +50,7 @@ bool ctx::system_info::getVolume(int* systemVolume, int* mediaVolume) return true; } -bool ctx::system_info::getWifiBssid(std::string& bssid) +bool system_info::getWifiBssid(std::string& bssid) { #if 0 /* NOTE: This routine does not work, because the wifi API does not support multi-sessions in one process */ @@ -75,6 +77,6 @@ bool ctx::system_info::getWifiBssid(std::string& bssid) return !bssid.empty(); #endif - bssid = ctx::SharedVars().get(ctx::SharedVars::WIFI_BSSID); + bssid = SharedVars().get(SharedVars::WIFI_BSSID); return true; } diff --git a/src/statistics/social/DbHandle.cpp b/src/statistics/social/DbHandle.cpp index 03c7dab..5c1c0a6 100644 --- a/src/statistics/social/DbHandle.cpp +++ b/src/statistics/social/DbHandle.cpp @@ -17,39 +17,42 @@ #include #include #include -#include #include "SocialStatisticsTypes.h" #include "DbHandle.h" -ctx::SocialDbHandle::SocialDbHandle() +using namespace ctx; + +SocialDbHandle::SocialDbHandle(ContextProvider *provider) : + StatsDbHandleBase(provider) { } -ctx::SocialDbHandle::~SocialDbHandle() +SocialDbHandle::~SocialDbHandle() { } -int ctx::SocialDbHandle::read(const char* subject, ctx::Json filter) +int SocialDbHandle::read(Json filter) { std::string query; + const char *subject = reqProvider->getSubject(); if (STR_EQ(subject, SOCIAL_SUBJ_FREQ_ADDRESS)) { query = createSqlFreqAddress(filter); } else if (STR_EQ(subject, SOCIAL_SUBJ_FREQUENCY)) { - __isTriggerItem = true; + isTriggerItem = true; query = createSqlFrequency(filter); } IF_FAIL_RETURN(!query.empty(), ERR_OPERATION_FAILED); - bool ret = executeQuery(subject, filter, query.c_str()); + bool ret = executeQuery(filter, query.c_str()); IF_FAIL_RETURN(ret, ERR_OPERATION_FAILED); return ERR_NONE; } -std::string ctx::SocialDbHandle::createWhereClause(ctx::Json filter) +std::string SocialDbHandle::createWhereClause(Json filter) { std::stringstream whereClause; int commType = -1; @@ -76,7 +79,7 @@ std::string ctx::SocialDbHandle::createWhereClause(ctx::Json filter) return whereClause.str(); } -std::string ctx::SocialDbHandle::createSqlFreqAddress(ctx::Json filter) +std::string SocialDbHandle::createSqlFreqAddress(Json filter) { std::stringstream query; int limit = DEFAULT_LIMIT; @@ -97,9 +100,9 @@ std::string ctx::SocialDbHandle::createSqlFreqAddress(ctx::Json filter) return query.str(); } -std::string ctx::SocialDbHandle::createSqlFrequency(ctx::Json filter) +std::string SocialDbHandle::createSqlFrequency(Json filter) { - ctx::Json filterCleaned; + Json filterCleaned; std::string weekStr; std::string timeOfDay; std::string address; @@ -142,11 +145,11 @@ std::string ctx::SocialDbHandle::createSqlFrequency(ctx::Json filter) return query.str(); } -void ctx::SocialDbHandle::replyTriggerItem(int error, ctx::Json &jsonResult) +void SocialDbHandle::replyTriggerItem(int error, Json &jsonResult) { - IF_FAIL_VOID_TAG(STR_EQ(__reqSubject.c_str(), SOCIAL_SUBJ_FREQUENCY), _E, "Invalid subject"); + IF_FAIL_VOID_TAG(STR_EQ(reqProvider->getSubject(), SOCIAL_SUBJ_FREQUENCY), _E, "Invalid subject"); - ctx::Json results; + Json results; std::string valStr; int val; @@ -157,5 +160,5 @@ void ctx::SocialDbHandle::replyTriggerItem(int error, ctx::Json &jsonResult) jsonResult.get(NULL, STATS_RANK, &val); results.set(NULL, STATS_RANK, val); - context_manager::replyToRead(__reqSubject.c_str(), __reqFilter, error, results); + reqProvider->replyToRead(reqFilter, error, results); } diff --git a/src/statistics/social/DbHandle.h b/src/statistics/social/DbHandle.h index 3ff4ecf..576c6a1 100644 --- a/src/statistics/social/DbHandle.h +++ b/src/statistics/social/DbHandle.h @@ -24,16 +24,16 @@ namespace ctx { class SocialDbHandle : public StatsDbHandleBase { public: - SocialDbHandle(); + SocialDbHandle(ContextProvider *provider); ~SocialDbHandle(); - int read(const char* subject, ctx::Json filter); + int read(Json filter); protected: - std::string createWhereClause(ctx::Json filter); - std::string createSqlFreqAddress(ctx::Json filter); - std::string createSqlFrequency(ctx::Json filter); - void replyTriggerItem(int error, ctx::Json &jsonResult); + std::string createWhereClause(Json filter); + std::string createSqlFreqAddress(Json filter); + std::string createSqlFrequency(Json filter); + void replyTriggerItem(int error, Json &jsonResult); }; } diff --git a/src/statistics/social/SocialStatisticsProvider.cpp b/src/statistics/social/SocialStatisticsProvider.cpp deleted file mode 100644 index f240296..0000000 --- a/src/statistics/social/SocialStatisticsProvider.cpp +++ /dev/null @@ -1,111 +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 -#include -#include "SocialStatisticsProvider.h" -#include "DbHandle.h" -#include "LogAggregator.h" - -static ctx::ContactLogAggregator *__aggregator = NULL; - -ctx::SocialStatisticsProvider *ctx::SocialStatisticsProvider::__instance = NULL; - -ctx::SocialStatisticsProvider::SocialStatisticsProvider() -{ -} - -ctx::SocialStatisticsProvider::~SocialStatisticsProvider() -{ - delete __aggregator; -} - -ctx::ContextProviderBase *ctx::SocialStatisticsProvider::create(void *data) -{ - IF_FAIL_RETURN(!__instance, __instance); - - __instance = new(std::nothrow) SocialStatisticsProvider(); - IF_FAIL_RETURN_TAG(__instance, NULL, _E, "Memory allocation failed"); - - _I(BLUE("Created")); - - if (!__instance->__init()) { - destroy(data); - return NULL; - } - - return __instance; -} - -void ctx::SocialStatisticsProvider::destroy(void *data) -{ - IF_FAIL_VOID(__instance); - delete __instance; - __instance = NULL; - _I(BLUE("Destroyed")); -} - -bool ctx::SocialStatisticsProvider::isSupported(const char* subject) -{ - return true; -} - -void ctx::SocialStatisticsProvider::submitTriggerItem() -{ - context_manager::registerTriggerItem(SOCIAL_SUBJ_FREQUENCY, OPS_READ, - "{" TRIG_DEF_RANK "," TRIG_DEF_TOTAL_COUNT "}", - "{" - "\"Address\":{\"type\":\"string\"}," - TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK - "}"); -} - -bool ctx::SocialStatisticsProvider::__init() -{ - __aggregator = new(std::nothrow) ContactLogAggregator(); - IF_FAIL_RETURN_TAG(__aggregator, false, _E, "Memory allocation failed"); - return true; -} - -int ctx::SocialStatisticsProvider::subscribe(const char* subject, ctx::Json option, ctx::Json* requestResult) -{ - return ERR_NOT_SUPPORTED; -} - -int ctx::SocialStatisticsProvider::unsubscribe(const char* subject, ctx::Json option) -{ - return ERR_NOT_SUPPORTED; -} - -int ctx::SocialStatisticsProvider::read(const char* subject, ctx::Json option, ctx::Json* requestResult) -{ - ctx::SocialDbHandle *handle = new(std::nothrow) ctx::SocialDbHandle(); - IF_FAIL_RETURN_TAG(handle, ERR_OPERATION_FAILED, _E, "Memory allocation failed"); - - int err = handle->read(subject, option); - if (err != ERR_NONE) { - delete handle; - return err; - } - - return ERR_NONE; -} - -int ctx::SocialStatisticsProvider::write(const char* subject, ctx::Json data, ctx::Json* requestResult) -{ - return ERR_NOT_SUPPORTED; -} diff --git a/src/statistics/social/SocialStatisticsProvider.h b/src/statistics/social/SocialStatisticsProvider.h deleted file mode 100644 index 3075915..0000000 --- a/src/statistics/social/SocialStatisticsProvider.h +++ /dev/null @@ -1,48 +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_STATS_SOCIAL_STATS_PROVIDER_H_ -#define _CONTEXT_STATS_SOCIAL_STATS_PROVIDER_H_ - -#include -#include "SocialStatisticsTypes.h" - -namespace ctx { - - class SocialStatisticsProvider : public ContextProviderBase { - public: - static ContextProviderBase *create(void *data); - static void destroy(void *data); - static bool isSupported(const char *subject); - static void submitTriggerItem(); - - 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); - - private: - static SocialStatisticsProvider *__instance; - - SocialStatisticsProvider(); - ~SocialStatisticsProvider(); - bool __init(); - - }; /* class SocialStatisticsProvider */ - -} /* namespace ctx */ - -#endif /* End of _CONTEXT_SOCIAL_STATS_PROVIDER_H_ */ diff --git a/src/statistics/social/SocialStatisticsTypes.h b/src/statistics/social/SocialStatisticsTypes.h index 2675302..7c68b93 100644 --- a/src/statistics/social/SocialStatisticsTypes.h +++ b/src/statistics/social/SocialStatisticsTypes.h @@ -20,6 +20,7 @@ #include "../shared/CommonTypes.h" #define SOCIAL_HISTORY_PRIV "callhistory.read" +#define SOCIAL_SUBJ_LOGGER "stats/contact/logger" #define SOCIAL_SUBJ_FREQ_ADDRESS "stats/contact/often" #define SOCIAL_SUBJ_FREQUENCY "stats/contact/frequency" diff --git a/src/statistics/social/SocialStatsLogger.cpp b/src/statistics/social/SocialStatsLogger.cpp new file mode 100644 index 0000000..a32fa80 --- /dev/null +++ b/src/statistics/social/SocialStatsLogger.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2016 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 "SocialStatisticsTypes.h" +#include "SocialStatsLogger.h" + +using namespace ctx; + +SocialStatsLogger::SocialStatsLogger() : + ContextProvider(SOCIAL_SUBJ_LOGGER) +{ +} + +SocialStatsLogger::~SocialStatsLogger() +{ +} + +int SocialStatsLogger::subscribe(Json option, Json* requestResult) +{ + return ERR_NONE; +} + +int SocialStatsLogger::unsubscribe(Json option) +{ + return ERR_NONE; +} diff --git a/src/statistics/social/SocialStatsLogger.h b/src/statistics/social/SocialStatsLogger.h new file mode 100644 index 0000000..17850e9 --- /dev/null +++ b/src/statistics/social/SocialStatsLogger.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2016 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_SOCIAL_STATS_LOGGER_H_ +#define _CONTEXT_SOCIAL_STATS_LOGGER_H_ + +#include +#include "LogAggregator.h" + +namespace ctx { + + class SocialStatsLogger : public ContextProvider { + public: + SocialStatsLogger(); + ~SocialStatsLogger(); + + int subscribe(Json option, Json* requestResult); + int unsubscribe(Json option); + + void submitTriggerItem() {} + + private: + ContactLogAggregator __aggregator; + }; + +} /* namespace ctx */ + +#endif /* _CONTEXT_SOCIAL_STATS_LOGGER_H_ */ + diff --git a/src/statistics/social/SocialStatsProvider.cpp b/src/statistics/social/SocialStatsProvider.cpp new file mode 100644 index 0000000..0c0dd6d --- /dev/null +++ b/src/statistics/social/SocialStatsProvider.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2016 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 "SocialStatsProvider.h" +#include "DbHandle.h" + +using namespace ctx; + +SocialStatsProvider::SocialStatsProvider(const char *subject) : + ContextProvider(subject) +{ +} + +SocialStatsProvider::~SocialStatsProvider() +{ +} + +bool SocialStatsProvider::isSupported() +{ + /* TODO */ + return true; +} + +void SocialStatsProvider::submitTriggerItem() +{ +} + +int SocialStatsProvider::read(Json option, Json* requestResult) +{ + SocialDbHandle *handle = new(std::nothrow) SocialDbHandle(this); + IF_FAIL_RETURN_TAG(handle, ERR_OPERATION_FAILED, _E, "Memory allocation failed"); + + int err = handle->read(option); + if (err != ERR_NONE) { + delete handle; + return err; + } + + return ERR_NONE; +} + +void ContactFreqProvider::submitTriggerItem() +{ + registerTriggerItem(OPS_READ, + "{" TRIG_DEF_RANK "," TRIG_DEF_TOTAL_COUNT "}", + "{" + "\"Address\":{\"type\":\"string\"}," + TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK + "}"); +} diff --git a/src/statistics/social/SocialStatsProvider.h b/src/statistics/social/SocialStatsProvider.h new file mode 100644 index 0000000..0ee94fd --- /dev/null +++ b/src/statistics/social/SocialStatsProvider.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016 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_SOCIAL_STATS_PROVIDER_H_ +#define _CONTEXT_SOCIAL_STATS_PROVIDER_H_ + +#include +#include "SocialStatisticsTypes.h" + +namespace ctx { + + class SocialStatsProvider : public ContextProvider { + public: + int read(Json option, Json* requestResult); + + bool isSupported(); + virtual void submitTriggerItem(); + + protected: + SocialStatsProvider(const char *subject); + virtual ~SocialStatsProvider(); + }; + + + class ContactFreqProvider: public SocialStatsProvider { + public: + ContactFreqProvider() : + SocialStatsProvider(SOCIAL_SUBJ_FREQUENCY) {} + + void submitTriggerItem(); + }; + + + class TopContactsProvider: public SocialStatsProvider { + public: + TopContactsProvider() : + SocialStatsProvider(SOCIAL_SUBJ_FREQ_ADDRESS) {} + }; + +} /* namespace ctx */ + +#endif /* _CONTEXT_SOCIAL_STATS_PROVIDER_H_ */ -- 2.7.4 From 7e509e3b40cd5176a7979d8311a650d99084834c Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Tue, 19 Apr 2016 20:02:53 +0900 Subject: [PATCH 03/16] Reorganize the directory structure of source files Source directories are roughly separated by their dependencies. Later, the build script will be updated to produce one shared object per one directory, and a dynamic loading routine will be applied. Change-Id: Iceaae6740cebc15a89ce0631f13b1254640b12c4 Signed-off-by: Mu-Woong Lee --- CMakeLists.txt | 70 +++++++++++++++---- packaging/context-provider.spec | 31 +++------ src/CMakeLists.txt | 24 ------- src/{device => }/activity/Activity.h | 1 + src/{device => }/activity/ActivityBase.cpp | 0 src/{device => }/activity/ActivityBase.h | 2 +- src/{device => }/activity/ActivityTypes.h | 0 .../app => app-stats}/ActiveWindowMonitor.cpp | 0 .../app => app-stats}/ActiveWindowMonitor.h | 0 .../app => app-stats}/AppStatisticsTypes.h | 0 .../app => app-stats}/AppStatsLogger.cpp | 0 src/{statistics/app => app-stats}/AppStatsLogger.h | 0 .../app => app-stats}/AppStatsProvider.cpp | 0 .../app => app-stats}/AppStatsProvider.h | 0 src/{statistics/app => app-stats}/DbHandle.cpp | 0 src/{statistics/app => app-stats}/DbHandle.h | 0 src/{statistics/app => app-stats}/DbInit.cpp | 0 src/{statistics/app => app-stats}/DbInit.h | 0 .../app => app-stats}/InstallMonitor.cpp | 0 src/{statistics/app => app-stats}/InstallMonitor.h | 0 .../app_inactive_detector/AppInactiveDetector.cpp | 0 .../app_inactive_detector/AppInactiveDetector.h | 0 .../AppInactiveDetectorTypes.h | 0 .../app_inactive_detector/InactiveDetector.cpp | 0 .../app_inactive_detector/InactiveDetector.h | 0 .../InactiveDetectorClassificator.cpp | 0 .../InactiveDetectorClassificator.h | 0 .../InactiveDetectorClassificatorKmeans.cpp | 0 .../InactiveDetectorClassificatorKmeans.h | 0 .../InactiveDetectorClassificatorKmeansTypes.h | 0 .../InactiveDetectorStorage.cpp | 0 .../InactiveDetectorStorage.h | 0 .../InactiveDetectorStorageQueries.h | 0 .../InactiveDetectorWeight.cpp | 0 .../app_inactive_detector/InactiveDetectorWeight.h | 0 src/{device/social => call}/Call.cpp | 1 - src/{device/social => call}/Call.h | 3 +- src/{device/social => contacts}/Contacts.cpp | 1 - src/{device/social => contacts}/Contacts.h | 3 +- src/device/CMakeLists.txt | 30 -------- src/{device/social => email}/Email.cpp | 1 - src/{device/social => email}/Email.h | 3 +- src/{place => }/geofence/GeofenceMonitorHandle.cpp | 0 src/{place => }/geofence/GeofenceMonitorHandle.h | 0 src/{place => }/geofence/PlaceGeofenceProvider.cpp | 0 src/{place => }/geofence/PlaceGeofenceProvider.h | 0 src/{place => }/geofence/PlaceGeofenceTypes.h | 0 src/{device/system => headphone}/Headphone.cpp | 1 - src/{device/system => headphone}/Headphone.h | 9 +-- src/{statistics/media => media-stats}/DbHandle.cpp | 0 src/{statistics/media => media-stats}/DbHandle.h | 0 .../media => media-stats}/MediaContentMonitor.cpp | 0 .../media => media-stats}/MediaContentMonitor.h | 0 .../media => media-stats}/MediaStatisticsTypes.h | 0 .../media => media-stats}/MediaStatsLogger.cpp | 0 .../media => media-stats}/MediaStatsLogger.h | 0 .../media => media-stats}/MediaStatsProvider.cpp | 0 .../media => media-stats}/MediaStatsProvider.h | 0 src/{device/social => message}/Message.cpp | 1 - src/{device/social => message}/Message.h | 3 +- .../recognition => my-place}/place_recognition.cpp | 0 .../recognition => my-place}/place_recognition.h | 0 .../place_recognition_types.h | 0 .../user_places/debug_utils.cpp | 0 .../user_places/debug_utils.h | 0 .../recognition => my-place}/user_places/gmap.cpp | 0 .../recognition => my-place}/user_places/gmap.h | 0 .../recognition => my-place}/user_places/graph.cpp | 0 .../recognition => my-place}/user_places/graph.h | 0 .../user_places/location_listener_iface.h | 0 .../user_places/location_logger.cpp | 0 .../user_places/location_logger.h | 0 .../recognition => my-place}/user_places/mahal.cpp | 0 .../recognition => my-place}/user_places/mahal.h | 0 .../user_places/median.cpp | 0 .../recognition => my-place}/user_places/median.h | 0 .../user_places/piecewise_lin.cpp | 0 .../user_places/piecewise_lin.h | 0 .../user_places/place_categer.cpp | 0 .../user_places/place_categer.h | 0 .../user_places/places_detector.cpp | 0 .../user_places/places_detector.h | 0 .../user_places/prob_features_model.h | 0 .../user_places/similarity.h | 0 .../user_places/user_places.cpp | 0 .../user_places/user_places.h | 0 .../user_places/user_places_params.h | 0 .../user_places/user_places_types.cpp | 0 .../user_places/user_places_types.h | 0 .../user_places/visit_categer.cpp | 0 .../user_places/visit_categer.h | 0 .../user_places/visit_detector.cpp | 0 .../user_places/visit_detector.h | 0 .../user_places/visit_listener_iface.h | 0 .../user_places/wifi_listener_iface.h | 0 .../user_places/wifi_logger.cpp | 0 .../user_places/wifi_logger.h | 0 src/place/CMakeLists.txt | 22 ------ src/{statistics => }/prediction/assoc_rule.cpp | 0 src/{statistics => }/prediction/assoc_rule.h | 0 .../prediction/assoc_rule_miner.cpp | 0 src/{statistics => }/prediction/assoc_rule_miner.h | 0 .../prediction/assoc_rule_of_ids.h | 0 .../prediction/assoc_rule_producer.cpp | 0 .../prediction/assoc_rule_producer.h | 0 src/{statistics => }/prediction/basket.cpp | 0 src/{statistics => }/prediction/basket.h | 0 .../prediction/basket_compressor.cpp | 0 .../prediction/basket_compressor.h | 0 src/{statistics => }/prediction/basket_filter.cpp | 0 src/{statistics => }/prediction/basket_filter.h | 0 .../prediction/basket_producer.cpp | 0 src/{statistics => }/prediction/basket_producer.h | 0 .../prediction/baskets_agregator.cpp | 0 .../prediction/baskets_agregator.h | 0 src/{statistics => }/prediction/event.cpp | 0 src/{statistics => }/prediction/event.h | 0 src/{statistics => }/prediction/event_set.h | 0 src/{statistics => }/prediction/i_item_id_filter.h | 0 src/{statistics => }/prediction/interval.cpp | 0 src/{statistics => }/prediction/interval.h | 0 src/{statistics => }/prediction/item.cpp | 0 src/{statistics => }/prediction/item.h | 0 src/{statistics => }/prediction/item_catalogue.cpp | 0 src/{statistics => }/prediction/item_catalogue.h | 0 src/{statistics => }/prediction/item_id_set.h | 0 src/{statistics => }/prediction/item_set.cpp | 0 src/{statistics => }/prediction/item_set.h | 0 .../prediction/item_string_converter.cpp | 0 .../prediction/item_string_converter.h | 0 .../prediction/single_category_item_id_filter.cpp | 0 .../prediction/single_category_item_id_filter.h | 0 src/{statistics => }/prediction/weight_apriori.cpp | 0 src/{statistics => }/prediction/weight_apriori.h | 0 src/{statistics => }/shared/CommonTypes.h | 0 src/{statistics => }/shared/DbHandleBase.cpp | 0 src/{statistics => }/shared/DbHandleBase.h | 0 src/{device => shared}/DeviceContextProvider.cpp | 79 ++++++---------------- src/{device => shared}/DeviceProviderBase.cpp | 0 src/{device => shared}/DeviceProviderBase.h | 0 src/{place => shared}/PlaceContextProvider.cpp | 11 ++- src/{device/social => shared}/SocialTypes.h | 0 .../StatisticsContextProvider.cpp | 23 ++----- src/{statistics => }/shared/SystemInfo.cpp | 0 src/{statistics => }/shared/SystemInfo.h | 0 src/{device/system => shared}/SystemTypes.h | 0 .../social => social-stats}/DbHandle.cpp | 0 src/{statistics/social => social-stats}/DbHandle.h | 0 .../social => social-stats}/LogAggregator.cpp | 0 .../social => social-stats}/LogAggregator.h | 0 .../SocialStatisticsTypes.h | 0 .../social => social-stats}/SocialStatsLogger.cpp | 0 .../social => social-stats}/SocialStatsLogger.h | 0 .../SocialStatsProvider.cpp | 0 .../social => social-stats}/SocialStatsProvider.h | 0 src/statistics/CMakeLists.txt | 31 --------- src/{device => }/system/Battery.cpp | 1 - src/{device => }/system/Battery.h | 3 +- .../system/runtime_info => system}/Charger.cpp | 1 - .../system/runtime_info => system}/Charger.h | 0 src/{device/system/runtime_info => system}/Gps.cpp | 1 - src/{device/system/runtime_info => system}/Gps.h | 0 src/{device => }/system/Psmode.cpp | 1 - src/{device => }/system/Psmode.h | 3 +- .../runtime_info => system}/RuntimeInfoBase.cpp | 0 .../runtime_info => system}/RuntimeInfoBase.h | 3 +- src/{device/system/runtime_info => system}/Usb.cpp | 1 - src/{device/system/runtime_info => system}/Usb.h | 0 src/{device/system => time}/Alarm.cpp | 1 - src/{device/system => time}/Alarm.h | 1 + src/{device/system => time}/Time.cpp | 1 - src/{device/system => time}/Time.h | 3 +- src/{device/system => wifi}/Wifi.cpp | 1 - src/{device/system => wifi}/Wifi.h | 3 +- 174 files changed, 126 insertions(+), 248 deletions(-) delete mode 100644 src/CMakeLists.txt rename src/{device => }/activity/Activity.h (98%) rename src/{device => }/activity/ActivityBase.cpp (100%) rename src/{device => }/activity/ActivityBase.h (97%) rename src/{device => }/activity/ActivityTypes.h (100%) rename src/{statistics/app => app-stats}/ActiveWindowMonitor.cpp (100%) rename src/{statistics/app => app-stats}/ActiveWindowMonitor.h (100%) rename src/{statistics/app => app-stats}/AppStatisticsTypes.h (100%) rename src/{statistics/app => app-stats}/AppStatsLogger.cpp (100%) rename src/{statistics/app => app-stats}/AppStatsLogger.h (100%) rename src/{statistics/app => app-stats}/AppStatsProvider.cpp (100%) rename src/{statistics/app => app-stats}/AppStatsProvider.h (100%) rename src/{statistics/app => app-stats}/DbHandle.cpp (100%) rename src/{statistics/app => app-stats}/DbHandle.h (100%) rename src/{statistics/app => app-stats}/DbInit.cpp (100%) rename src/{statistics/app => app-stats}/DbInit.h (100%) rename src/{statistics/app => app-stats}/InstallMonitor.cpp (100%) rename src/{statistics/app => app-stats}/InstallMonitor.h (100%) rename src/{statistics/app => app-stats}/app_inactive_detector/AppInactiveDetector.cpp (100%) rename src/{statistics/app => app-stats}/app_inactive_detector/AppInactiveDetector.h (100%) rename src/{statistics/app => app-stats}/app_inactive_detector/AppInactiveDetectorTypes.h (100%) rename src/{statistics/app => app-stats}/app_inactive_detector/InactiveDetector.cpp (100%) rename src/{statistics/app => app-stats}/app_inactive_detector/InactiveDetector.h (100%) rename src/{statistics/app => app-stats}/app_inactive_detector/InactiveDetectorClassificator.cpp (100%) rename src/{statistics/app => app-stats}/app_inactive_detector/InactiveDetectorClassificator.h (100%) rename src/{statistics/app => app-stats}/app_inactive_detector/InactiveDetectorClassificatorKmeans.cpp (100%) rename src/{statistics/app => app-stats}/app_inactive_detector/InactiveDetectorClassificatorKmeans.h (100%) rename src/{statistics/app => app-stats}/app_inactive_detector/InactiveDetectorClassificatorKmeansTypes.h (100%) rename src/{statistics/app => app-stats}/app_inactive_detector/InactiveDetectorStorage.cpp (100%) rename src/{statistics/app => app-stats}/app_inactive_detector/InactiveDetectorStorage.h (100%) rename src/{statistics/app => app-stats}/app_inactive_detector/InactiveDetectorStorageQueries.h (100%) rename src/{statistics/app => app-stats}/app_inactive_detector/InactiveDetectorWeight.cpp (100%) rename src/{statistics/app => app-stats}/app_inactive_detector/InactiveDetectorWeight.h (100%) rename src/{device/social => call}/Call.cpp (99%) rename src/{device/social => call}/Call.h (95%) rename src/{device/social => contacts}/Contacts.cpp (99%) rename src/{device/social => contacts}/Contacts.h (94%) delete mode 100644 src/device/CMakeLists.txt rename src/{device/social => email}/Email.cpp (98%) rename src/{device/social => email}/Email.h (93%) rename src/{place => }/geofence/GeofenceMonitorHandle.cpp (100%) rename src/{place => }/geofence/GeofenceMonitorHandle.h (100%) rename src/{place => }/geofence/PlaceGeofenceProvider.cpp (100%) rename src/{place => }/geofence/PlaceGeofenceProvider.h (100%) rename src/{place => }/geofence/PlaceGeofenceTypes.h (100%) rename src/{device/system => headphone}/Headphone.cpp (99%) rename src/{device/system => headphone}/Headphone.h (90%) rename src/{statistics/media => media-stats}/DbHandle.cpp (100%) rename src/{statistics/media => media-stats}/DbHandle.h (100%) rename src/{statistics/media => media-stats}/MediaContentMonitor.cpp (100%) rename src/{statistics/media => media-stats}/MediaContentMonitor.h (100%) rename src/{statistics/media => media-stats}/MediaStatisticsTypes.h (100%) rename src/{statistics/media => media-stats}/MediaStatsLogger.cpp (100%) rename src/{statistics/media => media-stats}/MediaStatsLogger.h (100%) rename src/{statistics/media => media-stats}/MediaStatsProvider.cpp (100%) rename src/{statistics/media => media-stats}/MediaStatsProvider.h (100%) rename src/{device/social => message}/Message.cpp (99%) rename src/{device/social => message}/Message.h (94%) rename src/{place/recognition => my-place}/place_recognition.cpp (100%) rename src/{place/recognition => my-place}/place_recognition.h (100%) rename src/{place/recognition => my-place}/place_recognition_types.h (100%) rename src/{place/recognition => my-place}/user_places/debug_utils.cpp (100%) rename src/{place/recognition => my-place}/user_places/debug_utils.h (100%) rename src/{place/recognition => my-place}/user_places/gmap.cpp (100%) rename src/{place/recognition => my-place}/user_places/gmap.h (100%) rename src/{place/recognition => my-place}/user_places/graph.cpp (100%) rename src/{place/recognition => my-place}/user_places/graph.h (100%) rename src/{place/recognition => my-place}/user_places/location_listener_iface.h (100%) rename src/{place/recognition => my-place}/user_places/location_logger.cpp (100%) rename src/{place/recognition => my-place}/user_places/location_logger.h (100%) rename src/{place/recognition => my-place}/user_places/mahal.cpp (100%) rename src/{place/recognition => my-place}/user_places/mahal.h (100%) rename src/{place/recognition => my-place}/user_places/median.cpp (100%) rename src/{place/recognition => my-place}/user_places/median.h (100%) rename src/{place/recognition => my-place}/user_places/piecewise_lin.cpp (100%) rename src/{place/recognition => my-place}/user_places/piecewise_lin.h (100%) rename src/{place/recognition => my-place}/user_places/place_categer.cpp (100%) rename src/{place/recognition => my-place}/user_places/place_categer.h (100%) rename src/{place/recognition => my-place}/user_places/places_detector.cpp (100%) rename src/{place/recognition => my-place}/user_places/places_detector.h (100%) rename src/{place/recognition => my-place}/user_places/prob_features_model.h (100%) rename src/{place/recognition => my-place}/user_places/similarity.h (100%) rename src/{place/recognition => my-place}/user_places/user_places.cpp (100%) rename src/{place/recognition => my-place}/user_places/user_places.h (100%) rename src/{place/recognition => my-place}/user_places/user_places_params.h (100%) rename src/{place/recognition => my-place}/user_places/user_places_types.cpp (100%) rename src/{place/recognition => my-place}/user_places/user_places_types.h (100%) rename src/{place/recognition => my-place}/user_places/visit_categer.cpp (100%) rename src/{place/recognition => my-place}/user_places/visit_categer.h (100%) rename src/{place/recognition => my-place}/user_places/visit_detector.cpp (100%) rename src/{place/recognition => my-place}/user_places/visit_detector.h (100%) rename src/{place/recognition => my-place}/user_places/visit_listener_iface.h (100%) rename src/{place/recognition => my-place}/user_places/wifi_listener_iface.h (100%) rename src/{place/recognition => my-place}/user_places/wifi_logger.cpp (100%) rename src/{place/recognition => my-place}/user_places/wifi_logger.h (100%) delete mode 100644 src/place/CMakeLists.txt rename src/{statistics => }/prediction/assoc_rule.cpp (100%) rename src/{statistics => }/prediction/assoc_rule.h (100%) rename src/{statistics => }/prediction/assoc_rule_miner.cpp (100%) rename src/{statistics => }/prediction/assoc_rule_miner.h (100%) rename src/{statistics => }/prediction/assoc_rule_of_ids.h (100%) rename src/{statistics => }/prediction/assoc_rule_producer.cpp (100%) rename src/{statistics => }/prediction/assoc_rule_producer.h (100%) rename src/{statistics => }/prediction/basket.cpp (100%) rename src/{statistics => }/prediction/basket.h (100%) rename src/{statistics => }/prediction/basket_compressor.cpp (100%) rename src/{statistics => }/prediction/basket_compressor.h (100%) rename src/{statistics => }/prediction/basket_filter.cpp (100%) rename src/{statistics => }/prediction/basket_filter.h (100%) rename src/{statistics => }/prediction/basket_producer.cpp (100%) rename src/{statistics => }/prediction/basket_producer.h (100%) rename src/{statistics => }/prediction/baskets_agregator.cpp (100%) rename src/{statistics => }/prediction/baskets_agregator.h (100%) rename src/{statistics => }/prediction/event.cpp (100%) rename src/{statistics => }/prediction/event.h (100%) rename src/{statistics => }/prediction/event_set.h (100%) rename src/{statistics => }/prediction/i_item_id_filter.h (100%) rename src/{statistics => }/prediction/interval.cpp (100%) rename src/{statistics => }/prediction/interval.h (100%) rename src/{statistics => }/prediction/item.cpp (100%) rename src/{statistics => }/prediction/item.h (100%) rename src/{statistics => }/prediction/item_catalogue.cpp (100%) rename src/{statistics => }/prediction/item_catalogue.h (100%) rename src/{statistics => }/prediction/item_id_set.h (100%) rename src/{statistics => }/prediction/item_set.cpp (100%) rename src/{statistics => }/prediction/item_set.h (100%) rename src/{statistics => }/prediction/item_string_converter.cpp (100%) rename src/{statistics => }/prediction/item_string_converter.h (100%) rename src/{statistics => }/prediction/single_category_item_id_filter.cpp (100%) rename src/{statistics => }/prediction/single_category_item_id_filter.h (100%) rename src/{statistics => }/prediction/weight_apriori.cpp (100%) rename src/{statistics => }/prediction/weight_apriori.h (100%) rename src/{statistics => }/shared/CommonTypes.h (100%) rename src/{statistics => }/shared/DbHandleBase.cpp (100%) rename src/{statistics => }/shared/DbHandleBase.h (100%) rename src/{device => shared}/DeviceContextProvider.cpp (58%) rename src/{device => shared}/DeviceProviderBase.cpp (100%) rename src/{device => shared}/DeviceProviderBase.h (100%) rename src/{place => shared}/PlaceContextProvider.cpp (85%) rename src/{device/social => shared}/SocialTypes.h (100%) rename src/{statistics => shared}/StatisticsContextProvider.cpp (85%) rename src/{statistics => }/shared/SystemInfo.cpp (100%) rename src/{statistics => }/shared/SystemInfo.h (100%) rename src/{device/system => shared}/SystemTypes.h (100%) rename src/{statistics/social => social-stats}/DbHandle.cpp (100%) rename src/{statistics/social => social-stats}/DbHandle.h (100%) rename src/{statistics/social => social-stats}/LogAggregator.cpp (100%) rename src/{statistics/social => social-stats}/LogAggregator.h (100%) rename src/{statistics/social => social-stats}/SocialStatisticsTypes.h (100%) rename src/{statistics/social => social-stats}/SocialStatsLogger.cpp (100%) rename src/{statistics/social => social-stats}/SocialStatsLogger.h (100%) rename src/{statistics/social => social-stats}/SocialStatsProvider.cpp (100%) rename src/{statistics/social => social-stats}/SocialStatsProvider.h (100%) delete mode 100644 src/statistics/CMakeLists.txt rename src/{device => }/system/Battery.cpp (99%) rename src/{device => }/system/Battery.h (94%) rename src/{device/system/runtime_info => system}/Charger.cpp (98%) rename src/{device/system/runtime_info => system}/Charger.h (100%) rename src/{device/system/runtime_info => system}/Gps.cpp (98%) rename src/{device/system/runtime_info => system}/Gps.h (100%) rename src/{device => }/system/Psmode.cpp (98%) rename src/{device => }/system/Psmode.h (93%) rename src/{device/system/runtime_info => system}/RuntimeInfoBase.cpp (100%) rename src/{device/system/runtime_info => system}/RuntimeInfoBase.h (94%) rename src/{device/system/runtime_info => system}/Usb.cpp (98%) rename src/{device/system/runtime_info => system}/Usb.h (100%) rename src/{device/system => time}/Alarm.cpp (99%) rename src/{device/system => time}/Alarm.h (98%) rename src/{device/system => time}/Time.cpp (98%) rename src/{device/system => time}/Time.h (92%) rename src/{device/system => wifi}/Wifi.cpp (99%) rename src/{device/system => wifi}/Wifi.h (95%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 913174a..2865cfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,9 +11,6 @@ INCLUDE_DIRECTORIES( ADD_DEFINITIONS(-O2 -Wall -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIC -Wl,--as-needed -Wl,--gc-section -Wl,--print-gc-section") -# Base Dependency -SET(dependencies libcontext-server) - # Profiles IF("${PROFILE}" STREQUAL "mobile") ADD_DEFINITIONS("-D_MOBILE_") @@ -23,23 +20,70 @@ IF("${PROFILE}" STREQUAL "wearable") ADD_DEFINITIONS("-D_WEARABLE_") ENDIF("${PROFILE}" STREQUAL "wearable") -IF("${PROFILE}" STREQUAL "tv") - ADD_DEFINITIONS("-D_TV_") -ENDIF("${PROFILE}" STREQUAL "tv") -# Include Sub-modules -ADD_SUBDIRECTORY(src) -MESSAGE("Compile definitions: ${compile_defs}") +# Dependency & Source +SET(DEPS + libcontext-server + vconf + capi-system-info + capi-system-device + capi-system-runtime-info + capi-appfw-package-manager + capi-appfw-application + capi-appfw-app-manager + pkgmgr + pkgmgr-info + capi-media-sound-manager + capi-network-bluetooth + capi-network-wifi + motion +) + +FILE(GLOB SRCS + src/shared/*.cpp + src/time/*.cpp + src/activity/*.cpp + src/app-stats/*.cpp + src/headphone/*.cpp + src/system/*.cpp + src/wifi/*.cpp +) + +IF("${PROFILE}" STREQUAL "mobile") +SET(DEPS ${DEPS} + msg-service + contacts-service2 + tapi + capi-telephony + capi-messaging-email + capi-content-media-content + capi-location-manager + capi-geofence-manager +) + +FILE(GLOB SRCS ${SRCS} + src/call/*.cpp + src/contacts/*.cpp + src/email/*.cpp + src/geofence/*.cpp + src/media-stats/*.cpp + src/message/*.cpp + src/my-place/*.cpp + src/my-place/user_places/*.cpp + src/social-stats/*.cpp +) +ENDIF("${PROFILE}" STREQUAL "mobile") + # Build INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(DEPS REQUIRED ${dependencies}) +PKG_CHECK_MODULES(DEPS REQUIRED ${DEPS}) FOREACH(flag ${DEPS_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -ADD_LIBRARY(${target} STATIC ${sources}) +ADD_LIBRARY(${target} STATIC ${SRCS}) TARGET_LINK_LIBRARIES(${target} ${DEPS_LDFLAGS}) SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS}) SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "${compile_defs}") @@ -47,7 +91,7 @@ SET_TARGET_PROPERTIES(${target} PROPERTIES SOVERSION ${MAJORVER}) SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${FULLVER}) # Package Config -FOREACH(item IN LISTS dependencies) +FOREACH(item IN LISTS DEPS) SET(deps_str "${deps_str} ${item}") ENDFOREACH(item) @@ -74,4 +118,4 @@ INSTALL( FILES_MATCHING PATTERN "*.h" ) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries) +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/packaging/context-provider.spec b/packaging/context-provider.spec index 7068f1e..598eb65 100644 --- a/packaging/context-provider.spec +++ b/packaging/context-provider.spec @@ -9,6 +9,10 @@ Source0: %{name}-%{version}.tar.gz %define BUILD_PROFILE %{?profile}%{!?profile:%{?tizen_profile_name}} %define keepstatic 1 +%if "%{?BUILD_PROFILE}" == "tv" +ExcludeArch: %{arm} aarch64 %ix86 x86_64 +%endif + BuildRequires: cmake BuildRequires: pkgconfig(libcontext-server) @@ -22,36 +26,21 @@ BuildRequires: pkgconfig(capi-appfw-app-manager) BuildRequires: pkgconfig(pkgmgr) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(capi-media-sound-manager) - -%if "%{?BUILD_PROFILE}" == "mobile" BuildRequires: pkgconfig(capi-network-bluetooth) BuildRequires: pkgconfig(capi-network-wifi) -BuildRequires: pkgconfig(capi-telephony) -BuildRequires: pkgconfig(tapi) -BuildRequires: pkgconfig(msg-service) -BuildRequires: pkgconfig(capi-messaging-email) BuildRequires: pkgconfig(motion) + +%if "%{?BUILD_PROFILE}" == "mobile" +BuildRequires: pkgconfig(msg-service) BuildRequires: pkgconfig(contacts-service2) +BuildRequires: pkgconfig(tapi) +BuildRequires: pkgconfig(capi-telephony) +BuildRequires: pkgconfig(capi-messaging-email) BuildRequires: pkgconfig(capi-content-media-content) BuildRequires: pkgconfig(capi-location-manager) BuildRequires: pkgconfig(capi-geofence-manager) %endif -%if "%{?BUILD_PROFILE}" == "wearable" -BuildRequires: pkgconfig(capi-network-bluetooth) -BuildRequires: pkgconfig(capi-network-wifi) -BuildRequires: pkgconfig(capi-telephony) -BuildRequires: pkgconfig(tapi) -BuildRequires: pkgconfig(msg-service) -BuildRequires: pkgconfig(motion) -%endif - -%if "%{?BUILD_PROFILE}" == "tv" -BuildRequires: pkgconfig(capi-network-bluetooth) -BuildRequires: pkgconfig(capi-network-wifi) -BuildRequires: pkgconfig(capi-content-media-content) -%endif - %description Context Provider diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 5926ed8..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) - -FUNCTION(add_provider prvd_name) - ADD_SUBDIRECTORY(${prvd_name}) - GET_DIRECTORY_PROPERTY(srcs_subdir DIRECTORY ${prvd_name} DEFINITION prvd_srcs) - GET_DIRECTORY_PROPERTY(deps_subdir DIRECTORY ${prvd_name} DEFINITION prvd_deps) - GET_DIRECTORY_PROPERTY(cdef_subdir DIRECTORY ${prvd_name} DEFINITION prvd_cdef) - SET(srcs_collected ${srcs_collected} ${srcs_subdir} PARENT_SCOPE) - SET(deps_collected ${deps_collected} ${deps_subdir} PARENT_SCOPE) - SET(cdef_collected ${cdef_collected} ${cdef_subdir} PARENT_SCOPE) -ENDFUNCTION(add_provider) - - -add_provider(device) -add_provider(statistics) -add_provider(place) -#add_provider(custom) - - -LIST(REMOVE_DUPLICATES deps_collected) - -SET(sources ${sources} ${srcs_collected} PARENT_SCOPE) -SET(dependencies ${dependencies} ${deps_collected} PARENT_SCOPE) -SET(compile_defs ${compile_defs} ${cdef_collected} PARENT_SCOPE) diff --git a/src/device/activity/Activity.h b/src/activity/Activity.h similarity index 98% rename from src/device/activity/Activity.h rename to src/activity/Activity.h index f50b283..ab5be2e 100644 --- a/src/device/activity/Activity.h +++ b/src/activity/Activity.h @@ -18,6 +18,7 @@ #define _DEVICE_ACTIVITY_STATUS_H_ #include "ActivityBase.h" +#include "ActivityTypes.h" #define GENERATE_ACTIVITY_PROVIDER(actPrvd, actSubj, actType) \ class actPrvd : public UserActivityBase { \ diff --git a/src/device/activity/ActivityBase.cpp b/src/activity/ActivityBase.cpp similarity index 100% rename from src/device/activity/ActivityBase.cpp rename to src/activity/ActivityBase.cpp diff --git a/src/device/activity/ActivityBase.h b/src/activity/ActivityBase.h similarity index 97% rename from src/device/activity/ActivityBase.h rename to src/activity/ActivityBase.h index ef68d58..56b709f 100644 --- a/src/device/activity/ActivityBase.h +++ b/src/activity/ActivityBase.h @@ -19,7 +19,7 @@ #include #include -#include "../DeviceProviderBase.h" +#include "../shared/DeviceProviderBase.h" namespace ctx { diff --git a/src/device/activity/ActivityTypes.h b/src/activity/ActivityTypes.h similarity index 100% rename from src/device/activity/ActivityTypes.h rename to src/activity/ActivityTypes.h diff --git a/src/statistics/app/ActiveWindowMonitor.cpp b/src/app-stats/ActiveWindowMonitor.cpp similarity index 100% rename from src/statistics/app/ActiveWindowMonitor.cpp rename to src/app-stats/ActiveWindowMonitor.cpp diff --git a/src/statistics/app/ActiveWindowMonitor.h b/src/app-stats/ActiveWindowMonitor.h similarity index 100% rename from src/statistics/app/ActiveWindowMonitor.h rename to src/app-stats/ActiveWindowMonitor.h diff --git a/src/statistics/app/AppStatisticsTypes.h b/src/app-stats/AppStatisticsTypes.h similarity index 100% rename from src/statistics/app/AppStatisticsTypes.h rename to src/app-stats/AppStatisticsTypes.h diff --git a/src/statistics/app/AppStatsLogger.cpp b/src/app-stats/AppStatsLogger.cpp similarity index 100% rename from src/statistics/app/AppStatsLogger.cpp rename to src/app-stats/AppStatsLogger.cpp diff --git a/src/statistics/app/AppStatsLogger.h b/src/app-stats/AppStatsLogger.h similarity index 100% rename from src/statistics/app/AppStatsLogger.h rename to src/app-stats/AppStatsLogger.h diff --git a/src/statistics/app/AppStatsProvider.cpp b/src/app-stats/AppStatsProvider.cpp similarity index 100% rename from src/statistics/app/AppStatsProvider.cpp rename to src/app-stats/AppStatsProvider.cpp diff --git a/src/statistics/app/AppStatsProvider.h b/src/app-stats/AppStatsProvider.h similarity index 100% rename from src/statistics/app/AppStatsProvider.h rename to src/app-stats/AppStatsProvider.h diff --git a/src/statistics/app/DbHandle.cpp b/src/app-stats/DbHandle.cpp similarity index 100% rename from src/statistics/app/DbHandle.cpp rename to src/app-stats/DbHandle.cpp diff --git a/src/statistics/app/DbHandle.h b/src/app-stats/DbHandle.h similarity index 100% rename from src/statistics/app/DbHandle.h rename to src/app-stats/DbHandle.h diff --git a/src/statistics/app/DbInit.cpp b/src/app-stats/DbInit.cpp similarity index 100% rename from src/statistics/app/DbInit.cpp rename to src/app-stats/DbInit.cpp diff --git a/src/statistics/app/DbInit.h b/src/app-stats/DbInit.h similarity index 100% rename from src/statistics/app/DbInit.h rename to src/app-stats/DbInit.h diff --git a/src/statistics/app/InstallMonitor.cpp b/src/app-stats/InstallMonitor.cpp similarity index 100% rename from src/statistics/app/InstallMonitor.cpp rename to src/app-stats/InstallMonitor.cpp diff --git a/src/statistics/app/InstallMonitor.h b/src/app-stats/InstallMonitor.h similarity index 100% rename from src/statistics/app/InstallMonitor.h rename to src/app-stats/InstallMonitor.h diff --git a/src/statistics/app/app_inactive_detector/AppInactiveDetector.cpp b/src/app-stats/app_inactive_detector/AppInactiveDetector.cpp similarity index 100% rename from src/statistics/app/app_inactive_detector/AppInactiveDetector.cpp rename to src/app-stats/app_inactive_detector/AppInactiveDetector.cpp diff --git a/src/statistics/app/app_inactive_detector/AppInactiveDetector.h b/src/app-stats/app_inactive_detector/AppInactiveDetector.h similarity index 100% rename from src/statistics/app/app_inactive_detector/AppInactiveDetector.h rename to src/app-stats/app_inactive_detector/AppInactiveDetector.h diff --git a/src/statistics/app/app_inactive_detector/AppInactiveDetectorTypes.h b/src/app-stats/app_inactive_detector/AppInactiveDetectorTypes.h similarity index 100% rename from src/statistics/app/app_inactive_detector/AppInactiveDetectorTypes.h rename to src/app-stats/app_inactive_detector/AppInactiveDetectorTypes.h diff --git a/src/statistics/app/app_inactive_detector/InactiveDetector.cpp b/src/app-stats/app_inactive_detector/InactiveDetector.cpp similarity index 100% rename from src/statistics/app/app_inactive_detector/InactiveDetector.cpp rename to src/app-stats/app_inactive_detector/InactiveDetector.cpp diff --git a/src/statistics/app/app_inactive_detector/InactiveDetector.h b/src/app-stats/app_inactive_detector/InactiveDetector.h similarity index 100% rename from src/statistics/app/app_inactive_detector/InactiveDetector.h rename to src/app-stats/app_inactive_detector/InactiveDetector.h diff --git a/src/statistics/app/app_inactive_detector/InactiveDetectorClassificator.cpp b/src/app-stats/app_inactive_detector/InactiveDetectorClassificator.cpp similarity index 100% rename from src/statistics/app/app_inactive_detector/InactiveDetectorClassificator.cpp rename to src/app-stats/app_inactive_detector/InactiveDetectorClassificator.cpp diff --git a/src/statistics/app/app_inactive_detector/InactiveDetectorClassificator.h b/src/app-stats/app_inactive_detector/InactiveDetectorClassificator.h similarity index 100% rename from src/statistics/app/app_inactive_detector/InactiveDetectorClassificator.h rename to src/app-stats/app_inactive_detector/InactiveDetectorClassificator.h diff --git a/src/statistics/app/app_inactive_detector/InactiveDetectorClassificatorKmeans.cpp b/src/app-stats/app_inactive_detector/InactiveDetectorClassificatorKmeans.cpp similarity index 100% rename from src/statistics/app/app_inactive_detector/InactiveDetectorClassificatorKmeans.cpp rename to src/app-stats/app_inactive_detector/InactiveDetectorClassificatorKmeans.cpp diff --git a/src/statistics/app/app_inactive_detector/InactiveDetectorClassificatorKmeans.h b/src/app-stats/app_inactive_detector/InactiveDetectorClassificatorKmeans.h similarity index 100% rename from src/statistics/app/app_inactive_detector/InactiveDetectorClassificatorKmeans.h rename to src/app-stats/app_inactive_detector/InactiveDetectorClassificatorKmeans.h diff --git a/src/statistics/app/app_inactive_detector/InactiveDetectorClassificatorKmeansTypes.h b/src/app-stats/app_inactive_detector/InactiveDetectorClassificatorKmeansTypes.h similarity index 100% rename from src/statistics/app/app_inactive_detector/InactiveDetectorClassificatorKmeansTypes.h rename to src/app-stats/app_inactive_detector/InactiveDetectorClassificatorKmeansTypes.h diff --git a/src/statistics/app/app_inactive_detector/InactiveDetectorStorage.cpp b/src/app-stats/app_inactive_detector/InactiveDetectorStorage.cpp similarity index 100% rename from src/statistics/app/app_inactive_detector/InactiveDetectorStorage.cpp rename to src/app-stats/app_inactive_detector/InactiveDetectorStorage.cpp diff --git a/src/statistics/app/app_inactive_detector/InactiveDetectorStorage.h b/src/app-stats/app_inactive_detector/InactiveDetectorStorage.h similarity index 100% rename from src/statistics/app/app_inactive_detector/InactiveDetectorStorage.h rename to src/app-stats/app_inactive_detector/InactiveDetectorStorage.h diff --git a/src/statistics/app/app_inactive_detector/InactiveDetectorStorageQueries.h b/src/app-stats/app_inactive_detector/InactiveDetectorStorageQueries.h similarity index 100% rename from src/statistics/app/app_inactive_detector/InactiveDetectorStorageQueries.h rename to src/app-stats/app_inactive_detector/InactiveDetectorStorageQueries.h diff --git a/src/statistics/app/app_inactive_detector/InactiveDetectorWeight.cpp b/src/app-stats/app_inactive_detector/InactiveDetectorWeight.cpp similarity index 100% rename from src/statistics/app/app_inactive_detector/InactiveDetectorWeight.cpp rename to src/app-stats/app_inactive_detector/InactiveDetectorWeight.cpp diff --git a/src/statistics/app/app_inactive_detector/InactiveDetectorWeight.h b/src/app-stats/app_inactive_detector/InactiveDetectorWeight.h similarity index 100% rename from src/statistics/app/app_inactive_detector/InactiveDetectorWeight.h rename to src/app-stats/app_inactive_detector/InactiveDetectorWeight.h diff --git a/src/device/social/Call.cpp b/src/call/Call.cpp similarity index 99% rename from src/device/social/Call.cpp rename to src/call/Call.cpp index 460c281..a19a2b9 100644 --- a/src/device/social/Call.cpp +++ b/src/call/Call.cpp @@ -14,7 +14,6 @@ * limitations under the License. */ -#include "SocialTypes.h" #include "Call.h" #define TELEPHONY_NOTI_ID_CNT 8 diff --git a/src/device/social/Call.h b/src/call/Call.h similarity index 95% rename from src/device/social/Call.h rename to src/call/Call.h index 02a4eaa..a53276f 100644 --- a/src/device/social/Call.h +++ b/src/call/Call.h @@ -18,7 +18,8 @@ #define _CONTEXT_SOCIAL_STATUS_CALL_H_ #include -#include "../DeviceProviderBase.h" +#include "../shared/SocialTypes.h" +#include "../shared/DeviceProviderBase.h" namespace ctx { diff --git a/src/device/social/Contacts.cpp b/src/contacts/Contacts.cpp similarity index 99% rename from src/device/social/Contacts.cpp rename to src/contacts/Contacts.cpp index 55ff19a..42789a3 100644 --- a/src/device/social/Contacts.cpp +++ b/src/contacts/Contacts.cpp @@ -14,7 +14,6 @@ * limitations under the License. */ -#include "SocialTypes.h" #include "Contacts.h" #define MY_PROFILE_VIEW _contacts_my_profile._uri diff --git a/src/device/social/Contacts.h b/src/contacts/Contacts.h similarity index 94% rename from src/device/social/Contacts.h rename to src/contacts/Contacts.h index c5ced5a..28b68ce 100644 --- a/src/device/social/Contacts.h +++ b/src/contacts/Contacts.h @@ -18,7 +18,8 @@ #define _CONTEXT_SOCIAL_STATUS_CONTACTS_H_ #include -#include "../DeviceProviderBase.h" +#include "../shared/SocialTypes.h" +#include "../shared/DeviceProviderBase.h" namespace ctx { diff --git a/src/device/CMakeLists.txt b/src/device/CMakeLists.txt deleted file mode 100644 index 16f436f..0000000 --- a/src/device/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -# prvd_cdef, prvd_deps, and prvd_srcs need to be set properly - -# Common Profile -FILE(GLOB prvd_srcs ./*.cpp system/Alarm.cpp system/Time.cpp) -SET(prvd_deps vconf capi-system-info capi-system-device capi-system-runtime-info) - -# Mobile Profile -IF("${PROFILE}" STREQUAL "mobile") - SET(prvd_deps ${prvd_deps} capi-network-bluetooth capi-network-wifi contacts-service2) - SET(prvd_deps ${prvd_deps} capi-telephony tapi msg-service capi-messaging-email motion) - FILE(GLOB_RECURSE prvd_srcs ${prvd_srcs} activity/*.cpp) - FILE(GLOB_RECURSE prvd_srcs ${prvd_srcs} system/*.cpp) - FILE(GLOB_RECURSE prvd_srcs ${prvd_srcs} social/*.cpp) -ENDIF("${PROFILE}" STREQUAL "mobile") - -# Wearable Profile -IF("${PROFILE}" STREQUAL "wearable") - SET(prvd_deps ${prvd_deps} capi-network-bluetooth capi-network-wifi) - SET(prvd_deps ${prvd_deps} capi-telephony tapi msg-service motion) - FILE(GLOB_RECURSE prvd_srcs ${prvd_srcs} activity/*.cpp) - FILE(GLOB_RECURSE prvd_srcs ${prvd_srcs} system/*.cpp) - FILE(GLOB prvd_srcs ${prvd_srcs} social/Call.cpp social/Message.cpp) -ENDIF("${PROFILE}" STREQUAL "wearable") - -# TV Profile -IF("${PROFILE}" STREQUAL "tv") - SET(prvd_deps ${prvd_deps} capi-network-bluetooth capi-network-wifi) - FILE(GLOB prvd_srcs ${prvd_srcs} system/Headphone.cpp system/Wifi.cpp) -ENDIF("${PROFILE}" STREQUAL "tv") diff --git a/src/device/social/Email.cpp b/src/email/Email.cpp similarity index 98% rename from src/device/social/Email.cpp rename to src/email/Email.cpp index e67729e..fbf5c8d 100644 --- a/src/device/social/Email.cpp +++ b/src/email/Email.cpp @@ -15,7 +15,6 @@ */ #include -#include "SocialTypes.h" #include "Email.h" using namespace ctx; diff --git a/src/device/social/Email.h b/src/email/Email.h similarity index 93% rename from src/device/social/Email.h rename to src/email/Email.h index cf44ae7..b78eb33 100644 --- a/src/device/social/Email.h +++ b/src/email/Email.h @@ -18,7 +18,8 @@ #define _CONTEXT_SOCIAL_STATUS_EMAIL_H_ #include -#include "../DeviceProviderBase.h" +#include "../shared/SocialTypes.h" +#include "../shared/DeviceProviderBase.h" namespace ctx { diff --git a/src/place/geofence/GeofenceMonitorHandle.cpp b/src/geofence/GeofenceMonitorHandle.cpp similarity index 100% rename from src/place/geofence/GeofenceMonitorHandle.cpp rename to src/geofence/GeofenceMonitorHandle.cpp diff --git a/src/place/geofence/GeofenceMonitorHandle.h b/src/geofence/GeofenceMonitorHandle.h similarity index 100% rename from src/place/geofence/GeofenceMonitorHandle.h rename to src/geofence/GeofenceMonitorHandle.h diff --git a/src/place/geofence/PlaceGeofenceProvider.cpp b/src/geofence/PlaceGeofenceProvider.cpp similarity index 100% rename from src/place/geofence/PlaceGeofenceProvider.cpp rename to src/geofence/PlaceGeofenceProvider.cpp diff --git a/src/place/geofence/PlaceGeofenceProvider.h b/src/geofence/PlaceGeofenceProvider.h similarity index 100% rename from src/place/geofence/PlaceGeofenceProvider.h rename to src/geofence/PlaceGeofenceProvider.h diff --git a/src/place/geofence/PlaceGeofenceTypes.h b/src/geofence/PlaceGeofenceTypes.h similarity index 100% rename from src/place/geofence/PlaceGeofenceTypes.h rename to src/geofence/PlaceGeofenceTypes.h diff --git a/src/device/system/Headphone.cpp b/src/headphone/Headphone.cpp similarity index 99% rename from src/device/system/Headphone.cpp rename to src/headphone/Headphone.cpp index 0093af9..3ee6dfa 100644 --- a/src/device/system/Headphone.cpp +++ b/src/headphone/Headphone.cpp @@ -14,7 +14,6 @@ * limitations under the License. */ -#include "SystemTypes.h" #include "Headphone.h" #define HANDLING_DELAY 2000 diff --git a/src/device/system/Headphone.h b/src/headphone/Headphone.h similarity index 90% rename from src/device/system/Headphone.h rename to src/headphone/Headphone.h index 00edcfd..2fdd780 100644 --- a/src/device/system/Headphone.h +++ b/src/headphone/Headphone.h @@ -14,13 +14,14 @@ * limitations under the License. */ -#ifndef _DEVICE_SYSTEM_STATUS_HEADPHONE_H_ -#define _DEVICE_STATUS_HEADPNOHE_H_ +#ifndef _CONTEXT_HEADPHONE_H_ +#define _CONTEXT_HEADPNOHE_H_ #include #include #include -#include "../DeviceProviderBase.h" +#include "../shared/SystemTypes.h" +#include "../shared/DeviceProviderBase.h" namespace ctx { @@ -60,4 +61,4 @@ namespace ctx { }; } -#endif // _DEVICE_SYSTEM_STATUS_HEADPHONE_H_ +#endif // _CONTEXT_HEADPHONE_H_ diff --git a/src/statistics/media/DbHandle.cpp b/src/media-stats/DbHandle.cpp similarity index 100% rename from src/statistics/media/DbHandle.cpp rename to src/media-stats/DbHandle.cpp diff --git a/src/statistics/media/DbHandle.h b/src/media-stats/DbHandle.h similarity index 100% rename from src/statistics/media/DbHandle.h rename to src/media-stats/DbHandle.h diff --git a/src/statistics/media/MediaContentMonitor.cpp b/src/media-stats/MediaContentMonitor.cpp similarity index 100% rename from src/statistics/media/MediaContentMonitor.cpp rename to src/media-stats/MediaContentMonitor.cpp diff --git a/src/statistics/media/MediaContentMonitor.h b/src/media-stats/MediaContentMonitor.h similarity index 100% rename from src/statistics/media/MediaContentMonitor.h rename to src/media-stats/MediaContentMonitor.h diff --git a/src/statistics/media/MediaStatisticsTypes.h b/src/media-stats/MediaStatisticsTypes.h similarity index 100% rename from src/statistics/media/MediaStatisticsTypes.h rename to src/media-stats/MediaStatisticsTypes.h diff --git a/src/statistics/media/MediaStatsLogger.cpp b/src/media-stats/MediaStatsLogger.cpp similarity index 100% rename from src/statistics/media/MediaStatsLogger.cpp rename to src/media-stats/MediaStatsLogger.cpp diff --git a/src/statistics/media/MediaStatsLogger.h b/src/media-stats/MediaStatsLogger.h similarity index 100% rename from src/statistics/media/MediaStatsLogger.h rename to src/media-stats/MediaStatsLogger.h diff --git a/src/statistics/media/MediaStatsProvider.cpp b/src/media-stats/MediaStatsProvider.cpp similarity index 100% rename from src/statistics/media/MediaStatsProvider.cpp rename to src/media-stats/MediaStatsProvider.cpp diff --git a/src/statistics/media/MediaStatsProvider.h b/src/media-stats/MediaStatsProvider.h similarity index 100% rename from src/statistics/media/MediaStatsProvider.h rename to src/media-stats/MediaStatsProvider.h diff --git a/src/device/social/Message.cpp b/src/message/Message.cpp similarity index 99% rename from src/device/social/Message.cpp rename to src/message/Message.cpp index f55b3e6..9316806 100644 --- a/src/device/social/Message.cpp +++ b/src/message/Message.cpp @@ -14,7 +14,6 @@ * limitations under the License. */ -#include "SocialTypes.h" #include "Message.h" #define MAX_ADDR_SIZE 20 diff --git a/src/device/social/Message.h b/src/message/Message.h similarity index 94% rename from src/device/social/Message.h rename to src/message/Message.h index 78d006b..79e489a 100644 --- a/src/device/social/Message.h +++ b/src/message/Message.h @@ -19,7 +19,8 @@ #include #include -#include "../DeviceProviderBase.h" +#include "../shared/SocialTypes.h" +#include "../shared/DeviceProviderBase.h" namespace ctx { diff --git a/src/place/recognition/place_recognition.cpp b/src/my-place/place_recognition.cpp similarity index 100% rename from src/place/recognition/place_recognition.cpp rename to src/my-place/place_recognition.cpp diff --git a/src/place/recognition/place_recognition.h b/src/my-place/place_recognition.h similarity index 100% rename from src/place/recognition/place_recognition.h rename to src/my-place/place_recognition.h diff --git a/src/place/recognition/place_recognition_types.h b/src/my-place/place_recognition_types.h similarity index 100% rename from src/place/recognition/place_recognition_types.h rename to src/my-place/place_recognition_types.h diff --git a/src/place/recognition/user_places/debug_utils.cpp b/src/my-place/user_places/debug_utils.cpp similarity index 100% rename from src/place/recognition/user_places/debug_utils.cpp rename to src/my-place/user_places/debug_utils.cpp diff --git a/src/place/recognition/user_places/debug_utils.h b/src/my-place/user_places/debug_utils.h similarity index 100% rename from src/place/recognition/user_places/debug_utils.h rename to src/my-place/user_places/debug_utils.h diff --git a/src/place/recognition/user_places/gmap.cpp b/src/my-place/user_places/gmap.cpp similarity index 100% rename from src/place/recognition/user_places/gmap.cpp rename to src/my-place/user_places/gmap.cpp diff --git a/src/place/recognition/user_places/gmap.h b/src/my-place/user_places/gmap.h similarity index 100% rename from src/place/recognition/user_places/gmap.h rename to src/my-place/user_places/gmap.h diff --git a/src/place/recognition/user_places/graph.cpp b/src/my-place/user_places/graph.cpp similarity index 100% rename from src/place/recognition/user_places/graph.cpp rename to src/my-place/user_places/graph.cpp diff --git a/src/place/recognition/user_places/graph.h b/src/my-place/user_places/graph.h similarity index 100% rename from src/place/recognition/user_places/graph.h rename to src/my-place/user_places/graph.h diff --git a/src/place/recognition/user_places/location_listener_iface.h b/src/my-place/user_places/location_listener_iface.h similarity index 100% rename from src/place/recognition/user_places/location_listener_iface.h rename to src/my-place/user_places/location_listener_iface.h diff --git a/src/place/recognition/user_places/location_logger.cpp b/src/my-place/user_places/location_logger.cpp similarity index 100% rename from src/place/recognition/user_places/location_logger.cpp rename to src/my-place/user_places/location_logger.cpp diff --git a/src/place/recognition/user_places/location_logger.h b/src/my-place/user_places/location_logger.h similarity index 100% rename from src/place/recognition/user_places/location_logger.h rename to src/my-place/user_places/location_logger.h diff --git a/src/place/recognition/user_places/mahal.cpp b/src/my-place/user_places/mahal.cpp similarity index 100% rename from src/place/recognition/user_places/mahal.cpp rename to src/my-place/user_places/mahal.cpp diff --git a/src/place/recognition/user_places/mahal.h b/src/my-place/user_places/mahal.h similarity index 100% rename from src/place/recognition/user_places/mahal.h rename to src/my-place/user_places/mahal.h diff --git a/src/place/recognition/user_places/median.cpp b/src/my-place/user_places/median.cpp similarity index 100% rename from src/place/recognition/user_places/median.cpp rename to src/my-place/user_places/median.cpp diff --git a/src/place/recognition/user_places/median.h b/src/my-place/user_places/median.h similarity index 100% rename from src/place/recognition/user_places/median.h rename to src/my-place/user_places/median.h diff --git a/src/place/recognition/user_places/piecewise_lin.cpp b/src/my-place/user_places/piecewise_lin.cpp similarity index 100% rename from src/place/recognition/user_places/piecewise_lin.cpp rename to src/my-place/user_places/piecewise_lin.cpp diff --git a/src/place/recognition/user_places/piecewise_lin.h b/src/my-place/user_places/piecewise_lin.h similarity index 100% rename from src/place/recognition/user_places/piecewise_lin.h rename to src/my-place/user_places/piecewise_lin.h diff --git a/src/place/recognition/user_places/place_categer.cpp b/src/my-place/user_places/place_categer.cpp similarity index 100% rename from src/place/recognition/user_places/place_categer.cpp rename to src/my-place/user_places/place_categer.cpp diff --git a/src/place/recognition/user_places/place_categer.h b/src/my-place/user_places/place_categer.h similarity index 100% rename from src/place/recognition/user_places/place_categer.h rename to src/my-place/user_places/place_categer.h diff --git a/src/place/recognition/user_places/places_detector.cpp b/src/my-place/user_places/places_detector.cpp similarity index 100% rename from src/place/recognition/user_places/places_detector.cpp rename to src/my-place/user_places/places_detector.cpp diff --git a/src/place/recognition/user_places/places_detector.h b/src/my-place/user_places/places_detector.h similarity index 100% rename from src/place/recognition/user_places/places_detector.h rename to src/my-place/user_places/places_detector.h diff --git a/src/place/recognition/user_places/prob_features_model.h b/src/my-place/user_places/prob_features_model.h similarity index 100% rename from src/place/recognition/user_places/prob_features_model.h rename to src/my-place/user_places/prob_features_model.h diff --git a/src/place/recognition/user_places/similarity.h b/src/my-place/user_places/similarity.h similarity index 100% rename from src/place/recognition/user_places/similarity.h rename to src/my-place/user_places/similarity.h diff --git a/src/place/recognition/user_places/user_places.cpp b/src/my-place/user_places/user_places.cpp similarity index 100% rename from src/place/recognition/user_places/user_places.cpp rename to src/my-place/user_places/user_places.cpp diff --git a/src/place/recognition/user_places/user_places.h b/src/my-place/user_places/user_places.h similarity index 100% rename from src/place/recognition/user_places/user_places.h rename to src/my-place/user_places/user_places.h diff --git a/src/place/recognition/user_places/user_places_params.h b/src/my-place/user_places/user_places_params.h similarity index 100% rename from src/place/recognition/user_places/user_places_params.h rename to src/my-place/user_places/user_places_params.h diff --git a/src/place/recognition/user_places/user_places_types.cpp b/src/my-place/user_places/user_places_types.cpp similarity index 100% rename from src/place/recognition/user_places/user_places_types.cpp rename to src/my-place/user_places/user_places_types.cpp diff --git a/src/place/recognition/user_places/user_places_types.h b/src/my-place/user_places/user_places_types.h similarity index 100% rename from src/place/recognition/user_places/user_places_types.h rename to src/my-place/user_places/user_places_types.h diff --git a/src/place/recognition/user_places/visit_categer.cpp b/src/my-place/user_places/visit_categer.cpp similarity index 100% rename from src/place/recognition/user_places/visit_categer.cpp rename to src/my-place/user_places/visit_categer.cpp diff --git a/src/place/recognition/user_places/visit_categer.h b/src/my-place/user_places/visit_categer.h similarity index 100% rename from src/place/recognition/user_places/visit_categer.h rename to src/my-place/user_places/visit_categer.h diff --git a/src/place/recognition/user_places/visit_detector.cpp b/src/my-place/user_places/visit_detector.cpp similarity index 100% rename from src/place/recognition/user_places/visit_detector.cpp rename to src/my-place/user_places/visit_detector.cpp diff --git a/src/place/recognition/user_places/visit_detector.h b/src/my-place/user_places/visit_detector.h similarity index 100% rename from src/place/recognition/user_places/visit_detector.h rename to src/my-place/user_places/visit_detector.h diff --git a/src/place/recognition/user_places/visit_listener_iface.h b/src/my-place/user_places/visit_listener_iface.h similarity index 100% rename from src/place/recognition/user_places/visit_listener_iface.h rename to src/my-place/user_places/visit_listener_iface.h diff --git a/src/place/recognition/user_places/wifi_listener_iface.h b/src/my-place/user_places/wifi_listener_iface.h similarity index 100% rename from src/place/recognition/user_places/wifi_listener_iface.h rename to src/my-place/user_places/wifi_listener_iface.h diff --git a/src/place/recognition/user_places/wifi_logger.cpp b/src/my-place/user_places/wifi_logger.cpp similarity index 100% rename from src/place/recognition/user_places/wifi_logger.cpp rename to src/my-place/user_places/wifi_logger.cpp diff --git a/src/place/recognition/user_places/wifi_logger.h b/src/my-place/user_places/wifi_logger.h similarity index 100% rename from src/place/recognition/user_places/wifi_logger.h rename to src/my-place/user_places/wifi_logger.h diff --git a/src/place/CMakeLists.txt b/src/place/CMakeLists.txt deleted file mode 100644 index 1db79f7..0000000 --- a/src/place/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -# prvd_cdef, prvd_deps, and prvd_srcs need to be set properly - -# Build flag for the place auto detection engine. -# Set this to "yes" to enable the engine. -SET(enable_recog_engine "no") - -# Common Profile -FILE(GLOB prvd_srcs *.cpp) - -# Mobile Profile -IF("${PROFILE}" STREQUAL "mobile") - FILE(GLOB_RECURSE prvd_srcs ${prvd_srcs} geofence/*.cpp) - SET(prvd_deps ${prvd_deps} capi-geofence-manager) - IF("${enable_recog_engine}" STREQUAL "yes") - FILE(GLOB_RECURSE prvd_srcs ${prvd_srcs} recognition/*.cpp) - SET(prvd_deps ${prvd_deps} capi-location-manager) - SET(prvd_deps ${prvd_deps} capi-network-wifi) - ELSE("${enable_recog_engine}" STREQUAL "yes") - SET(prvd_cdef ${prvd_cdef} _DISABLE_RECOG_ENGINE_) - ENDIF("${enable_recog_engine}" STREQUAL "yes") -ENDIF("${PROFILE}" STREQUAL "mobile") diff --git a/src/statistics/prediction/assoc_rule.cpp b/src/prediction/assoc_rule.cpp similarity index 100% rename from src/statistics/prediction/assoc_rule.cpp rename to src/prediction/assoc_rule.cpp diff --git a/src/statistics/prediction/assoc_rule.h b/src/prediction/assoc_rule.h similarity index 100% rename from src/statistics/prediction/assoc_rule.h rename to src/prediction/assoc_rule.h diff --git a/src/statistics/prediction/assoc_rule_miner.cpp b/src/prediction/assoc_rule_miner.cpp similarity index 100% rename from src/statistics/prediction/assoc_rule_miner.cpp rename to src/prediction/assoc_rule_miner.cpp diff --git a/src/statistics/prediction/assoc_rule_miner.h b/src/prediction/assoc_rule_miner.h similarity index 100% rename from src/statistics/prediction/assoc_rule_miner.h rename to src/prediction/assoc_rule_miner.h diff --git a/src/statistics/prediction/assoc_rule_of_ids.h b/src/prediction/assoc_rule_of_ids.h similarity index 100% rename from src/statistics/prediction/assoc_rule_of_ids.h rename to src/prediction/assoc_rule_of_ids.h diff --git a/src/statistics/prediction/assoc_rule_producer.cpp b/src/prediction/assoc_rule_producer.cpp similarity index 100% rename from src/statistics/prediction/assoc_rule_producer.cpp rename to src/prediction/assoc_rule_producer.cpp diff --git a/src/statistics/prediction/assoc_rule_producer.h b/src/prediction/assoc_rule_producer.h similarity index 100% rename from src/statistics/prediction/assoc_rule_producer.h rename to src/prediction/assoc_rule_producer.h diff --git a/src/statistics/prediction/basket.cpp b/src/prediction/basket.cpp similarity index 100% rename from src/statistics/prediction/basket.cpp rename to src/prediction/basket.cpp diff --git a/src/statistics/prediction/basket.h b/src/prediction/basket.h similarity index 100% rename from src/statistics/prediction/basket.h rename to src/prediction/basket.h diff --git a/src/statistics/prediction/basket_compressor.cpp b/src/prediction/basket_compressor.cpp similarity index 100% rename from src/statistics/prediction/basket_compressor.cpp rename to src/prediction/basket_compressor.cpp diff --git a/src/statistics/prediction/basket_compressor.h b/src/prediction/basket_compressor.h similarity index 100% rename from src/statistics/prediction/basket_compressor.h rename to src/prediction/basket_compressor.h diff --git a/src/statistics/prediction/basket_filter.cpp b/src/prediction/basket_filter.cpp similarity index 100% rename from src/statistics/prediction/basket_filter.cpp rename to src/prediction/basket_filter.cpp diff --git a/src/statistics/prediction/basket_filter.h b/src/prediction/basket_filter.h similarity index 100% rename from src/statistics/prediction/basket_filter.h rename to src/prediction/basket_filter.h diff --git a/src/statistics/prediction/basket_producer.cpp b/src/prediction/basket_producer.cpp similarity index 100% rename from src/statistics/prediction/basket_producer.cpp rename to src/prediction/basket_producer.cpp diff --git a/src/statistics/prediction/basket_producer.h b/src/prediction/basket_producer.h similarity index 100% rename from src/statistics/prediction/basket_producer.h rename to src/prediction/basket_producer.h diff --git a/src/statistics/prediction/baskets_agregator.cpp b/src/prediction/baskets_agregator.cpp similarity index 100% rename from src/statistics/prediction/baskets_agregator.cpp rename to src/prediction/baskets_agregator.cpp diff --git a/src/statistics/prediction/baskets_agregator.h b/src/prediction/baskets_agregator.h similarity index 100% rename from src/statistics/prediction/baskets_agregator.h rename to src/prediction/baskets_agregator.h diff --git a/src/statistics/prediction/event.cpp b/src/prediction/event.cpp similarity index 100% rename from src/statistics/prediction/event.cpp rename to src/prediction/event.cpp diff --git a/src/statistics/prediction/event.h b/src/prediction/event.h similarity index 100% rename from src/statistics/prediction/event.h rename to src/prediction/event.h diff --git a/src/statistics/prediction/event_set.h b/src/prediction/event_set.h similarity index 100% rename from src/statistics/prediction/event_set.h rename to src/prediction/event_set.h diff --git a/src/statistics/prediction/i_item_id_filter.h b/src/prediction/i_item_id_filter.h similarity index 100% rename from src/statistics/prediction/i_item_id_filter.h rename to src/prediction/i_item_id_filter.h diff --git a/src/statistics/prediction/interval.cpp b/src/prediction/interval.cpp similarity index 100% rename from src/statistics/prediction/interval.cpp rename to src/prediction/interval.cpp diff --git a/src/statistics/prediction/interval.h b/src/prediction/interval.h similarity index 100% rename from src/statistics/prediction/interval.h rename to src/prediction/interval.h diff --git a/src/statistics/prediction/item.cpp b/src/prediction/item.cpp similarity index 100% rename from src/statistics/prediction/item.cpp rename to src/prediction/item.cpp diff --git a/src/statistics/prediction/item.h b/src/prediction/item.h similarity index 100% rename from src/statistics/prediction/item.h rename to src/prediction/item.h diff --git a/src/statistics/prediction/item_catalogue.cpp b/src/prediction/item_catalogue.cpp similarity index 100% rename from src/statistics/prediction/item_catalogue.cpp rename to src/prediction/item_catalogue.cpp diff --git a/src/statistics/prediction/item_catalogue.h b/src/prediction/item_catalogue.h similarity index 100% rename from src/statistics/prediction/item_catalogue.h rename to src/prediction/item_catalogue.h diff --git a/src/statistics/prediction/item_id_set.h b/src/prediction/item_id_set.h similarity index 100% rename from src/statistics/prediction/item_id_set.h rename to src/prediction/item_id_set.h diff --git a/src/statistics/prediction/item_set.cpp b/src/prediction/item_set.cpp similarity index 100% rename from src/statistics/prediction/item_set.cpp rename to src/prediction/item_set.cpp diff --git a/src/statistics/prediction/item_set.h b/src/prediction/item_set.h similarity index 100% rename from src/statistics/prediction/item_set.h rename to src/prediction/item_set.h diff --git a/src/statistics/prediction/item_string_converter.cpp b/src/prediction/item_string_converter.cpp similarity index 100% rename from src/statistics/prediction/item_string_converter.cpp rename to src/prediction/item_string_converter.cpp diff --git a/src/statistics/prediction/item_string_converter.h b/src/prediction/item_string_converter.h similarity index 100% rename from src/statistics/prediction/item_string_converter.h rename to src/prediction/item_string_converter.h diff --git a/src/statistics/prediction/single_category_item_id_filter.cpp b/src/prediction/single_category_item_id_filter.cpp similarity index 100% rename from src/statistics/prediction/single_category_item_id_filter.cpp rename to src/prediction/single_category_item_id_filter.cpp diff --git a/src/statistics/prediction/single_category_item_id_filter.h b/src/prediction/single_category_item_id_filter.h similarity index 100% rename from src/statistics/prediction/single_category_item_id_filter.h rename to src/prediction/single_category_item_id_filter.h diff --git a/src/statistics/prediction/weight_apriori.cpp b/src/prediction/weight_apriori.cpp similarity index 100% rename from src/statistics/prediction/weight_apriori.cpp rename to src/prediction/weight_apriori.cpp diff --git a/src/statistics/prediction/weight_apriori.h b/src/prediction/weight_apriori.h similarity index 100% rename from src/statistics/prediction/weight_apriori.h rename to src/prediction/weight_apriori.h diff --git a/src/statistics/shared/CommonTypes.h b/src/shared/CommonTypes.h similarity index 100% rename from src/statistics/shared/CommonTypes.h rename to src/shared/CommonTypes.h diff --git a/src/statistics/shared/DbHandleBase.cpp b/src/shared/DbHandleBase.cpp similarity index 100% rename from src/statistics/shared/DbHandleBase.cpp rename to src/shared/DbHandleBase.cpp diff --git a/src/statistics/shared/DbHandleBase.h b/src/shared/DbHandleBase.h similarity index 100% rename from src/statistics/shared/DbHandleBase.h rename to src/shared/DbHandleBase.h diff --git a/src/device/DeviceContextProvider.cpp b/src/shared/DeviceContextProvider.cpp similarity index 58% rename from src/device/DeviceContextProvider.cpp rename to src/shared/DeviceContextProvider.cpp index 332efdc..5ff533d 100644 --- a/src/device/DeviceContextProvider.cpp +++ b/src/shared/DeviceContextProvider.cpp @@ -14,43 +14,25 @@ * limitations under the License. */ -#include -#include +#include #include -#include "system/SystemTypes.h" -#include "social/SocialTypes.h" -#include "activity/ActivityTypes.h" - -#include "system/Alarm.h" -#include "system/Time.h" +#include "../time/Alarm.h" +#include "../time/Time.h" +#include "../activity/Activity.h" +#include "../headphone/Headphone.h" +#include "../system/Battery.h" +#include "../system/Charger.h" +#include "../system/Gps.h" +#include "../system/Psmode.h" +#include "../system/Usb.h" +#include "../wifi/Wifi.h" #ifdef _MOBILE_ -#include "system/runtime_info/Charger.h" -#include "system/runtime_info/Gps.h" -#include "system/runtime_info/Usb.h" -#include "system/Wifi.h" -#include "system/Headphone.h" -#include "system/Battery.h" -#include "system/Psmode.h" -#include "social/Call.h" -#include "social/Email.h" -#include "social/Message.h" -#include "social/Contacts.h" -#include "activity/Activity.h" -#endif - -#ifdef _WEARABLE_ -#include "system/runtime_info/Charger.h" -#include "system/runtime_info/Gps.h" -#include "system/runtime_info/Usb.h" -#include "system/Wifi.h" -#include "system/Headphone.h" -#include "system/Battery.h" -#include "system/Psmode.h" -#include "social/Call.h" -#include "social/Message.h" -#include "activity/Activity.h" +#include "../call/Call.h" +#include "../contacts/Contacts.h" +#include "../email/Email.h" +#include "../message/Message.h" #endif #define PRIV_NETWORK "network.get" @@ -78,7 +60,6 @@ SO_EXPORT bool ctx::initDeviceContextProvider() registerProvider(DEVICE_ST_SUBJ_ALARM, NULL); registerProvider(DEVICE_ST_SUBJ_TIME, NULL); -#ifdef _MOBILE_ registerProvider(DEVICE_ST_SUBJ_WIFI, PRIV_NETWORK); registerProvider(DEVICE_ST_SUBJ_HEADPHONE, NULL); @@ -88,16 +69,17 @@ SO_EXPORT bool ctx::initDeviceContextProvider() registerProvider(DEVICE_ST_SUBJ_BATTERY, NULL); registerProvider(DEVICE_ST_SUBJ_PSMODE, NULL); - 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); - 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); +#ifdef _MOBILE_ + 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); + /* Create context providers, which need to be initiated before being subscribed */ /* if (DeviceStatusWifi::isSupported()) @@ -105,24 +87,5 @@ SO_EXPORT bool ctx::initDeviceContextProvider() */ #endif -#ifdef _WEARABLE_ - registerProvider(DEVICE_ST_SUBJ_WIFI, PRIV_NETWORK); - registerProvider(DEVICE_ST_SUBJ_HEADPHONE, 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); - - registerProvider(SOCIAL_ST_SUBJ_CALL, PRIV_TELEPHONY); - registerProvider(SOCIAL_ST_SUBJ_MESSAGE, PRIV_MESSAGE); - - 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); -#endif - return true; } diff --git a/src/device/DeviceProviderBase.cpp b/src/shared/DeviceProviderBase.cpp similarity index 100% rename from src/device/DeviceProviderBase.cpp rename to src/shared/DeviceProviderBase.cpp diff --git a/src/device/DeviceProviderBase.h b/src/shared/DeviceProviderBase.h similarity index 100% rename from src/device/DeviceProviderBase.h rename to src/shared/DeviceProviderBase.h diff --git a/src/place/PlaceContextProvider.cpp b/src/shared/PlaceContextProvider.cpp similarity index 85% rename from src/place/PlaceContextProvider.cpp rename to src/shared/PlaceContextProvider.cpp index 349000a..eba5ff0 100644 --- a/src/place/PlaceContextProvider.cpp +++ b/src/shared/PlaceContextProvider.cpp @@ -14,14 +14,13 @@ * limitations under the License. */ +#include #include #include #ifdef _MOBILE_ -#include "geofence/PlaceGeofenceProvider.h" -#ifndef _DISABLE_RECOG_ENGINE_ -#include "recognition/place_recognition.h" -#endif /* _DISABLE_RECOG_ENGINE_ */ +#include "../geofence/PlaceGeofenceProvider.h" +#include "../my-place/place_recognition.h" #endif /* _MOBILE_ */ template @@ -44,9 +43,9 @@ SO_EXPORT bool ctx::initPlaceContextProvider() #ifdef _MOBILE_ registerProvider(PLACE_SUBJ_GEOFENCE, PLACE_PRIV_GEOFENCE); -#ifndef _DISABLE_RECOG_ENGINE_ + /* registerProvider(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION); -#endif /* _DISABLE_RECOG_ENGINE_ */ + */ #endif /* _MOBILE_ */ return true; diff --git a/src/device/social/SocialTypes.h b/src/shared/SocialTypes.h similarity index 100% rename from src/device/social/SocialTypes.h rename to src/shared/SocialTypes.h diff --git a/src/statistics/StatisticsContextProvider.cpp b/src/shared/StatisticsContextProvider.cpp similarity index 85% rename from src/statistics/StatisticsContextProvider.cpp rename to src/shared/StatisticsContextProvider.cpp index 0dba666..cfaf008 100644 --- a/src/statistics/StatisticsContextProvider.cpp +++ b/src/shared/StatisticsContextProvider.cpp @@ -13,22 +13,17 @@ * limitations under the License. */ -#include -#include +#include #include -#include "app/AppStatsProvider.h" -#include "app/AppStatsLogger.h" - -#ifndef _DISABLE_PREDICTION_ENGINE_ -// include prediction engine header files here -#endif +#include "../app-stats/AppStatsProvider.h" +#include "../app-stats/AppStatsLogger.h" #ifdef _MOBILE_ -#include "media/MediaStatsProvider.h" -#include "media/MediaStatsLogger.h" -#include "social/SocialStatsProvider.h" -#include "social/SocialStatsLogger.h" +#include "../media-stats/MediaStatsProvider.h" +#include "../media-stats/MediaStatsLogger.h" +#include "../social-stats/SocialStatsProvider.h" +#include "../social-stats/SocialStatsLogger.h" #endif template @@ -56,10 +51,6 @@ SO_EXPORT bool ctx::initStatisticsContextProvider() registerProvider(APP_SUBJ_COMMON_SETTING, APP_HISTORY_PRIV); registerProvider(APP_SUBJ_FREQUENCY, APP_HISTORY_PRIV); -#ifndef _DISABLE_PREDICTION_ENGINE_ -// initialize the prediction engine here -#endif - #ifdef _MOBILE_ registerProvider(MEDIA_SUBJ_LOGGER, MEDIA_HISTORY_PRIV); registerProvider(MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC, MEDIA_HISTORY_PRIV); diff --git a/src/statistics/shared/SystemInfo.cpp b/src/shared/SystemInfo.cpp similarity index 100% rename from src/statistics/shared/SystemInfo.cpp rename to src/shared/SystemInfo.cpp diff --git a/src/statistics/shared/SystemInfo.h b/src/shared/SystemInfo.h similarity index 100% rename from src/statistics/shared/SystemInfo.h rename to src/shared/SystemInfo.h diff --git a/src/device/system/SystemTypes.h b/src/shared/SystemTypes.h similarity index 100% rename from src/device/system/SystemTypes.h rename to src/shared/SystemTypes.h diff --git a/src/statistics/social/DbHandle.cpp b/src/social-stats/DbHandle.cpp similarity index 100% rename from src/statistics/social/DbHandle.cpp rename to src/social-stats/DbHandle.cpp diff --git a/src/statistics/social/DbHandle.h b/src/social-stats/DbHandle.h similarity index 100% rename from src/statistics/social/DbHandle.h rename to src/social-stats/DbHandle.h diff --git a/src/statistics/social/LogAggregator.cpp b/src/social-stats/LogAggregator.cpp similarity index 100% rename from src/statistics/social/LogAggregator.cpp rename to src/social-stats/LogAggregator.cpp diff --git a/src/statistics/social/LogAggregator.h b/src/social-stats/LogAggregator.h similarity index 100% rename from src/statistics/social/LogAggregator.h rename to src/social-stats/LogAggregator.h diff --git a/src/statistics/social/SocialStatisticsTypes.h b/src/social-stats/SocialStatisticsTypes.h similarity index 100% rename from src/statistics/social/SocialStatisticsTypes.h rename to src/social-stats/SocialStatisticsTypes.h diff --git a/src/statistics/social/SocialStatsLogger.cpp b/src/social-stats/SocialStatsLogger.cpp similarity index 100% rename from src/statistics/social/SocialStatsLogger.cpp rename to src/social-stats/SocialStatsLogger.cpp diff --git a/src/statistics/social/SocialStatsLogger.h b/src/social-stats/SocialStatsLogger.h similarity index 100% rename from src/statistics/social/SocialStatsLogger.h rename to src/social-stats/SocialStatsLogger.h diff --git a/src/statistics/social/SocialStatsProvider.cpp b/src/social-stats/SocialStatsProvider.cpp similarity index 100% rename from src/statistics/social/SocialStatsProvider.cpp rename to src/social-stats/SocialStatsProvider.cpp diff --git a/src/statistics/social/SocialStatsProvider.h b/src/social-stats/SocialStatsProvider.h similarity index 100% rename from src/statistics/social/SocialStatsProvider.h rename to src/social-stats/SocialStatsProvider.h diff --git a/src/statistics/CMakeLists.txt b/src/statistics/CMakeLists.txt deleted file mode 100644 index 6b35770..0000000 --- a/src/statistics/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -# prvd_cdef, prvd_deps, and prvd_srcs need to be set properly - -# Build flag for the prediction engine. -# Set this to "yes" to enable the engine. -SET(enable_prediction_engine "no") - -# Common Profile -FILE(GLOB prvd_srcs ./*.cpp) -FILE(GLOB prvd_srcs ${prvd_srcs} shared/*.cpp) -FILE(GLOB prvd_srcs ${prvd_srcs} app/*.cpp) -IF("${enable_prediction_engine}" STREQUAL "yes") - FILE(GLOB prvd_srcs ${prvd_srcs} prediction/*.cpp) -ELSE("${enable_prediction_engine}" STREQUAL "yes") - SET(prvd_cdef ${prvd_cdef} _DISABLE_PREDICTION_ENGINE_) -ENDIF("${enable_prediction_engine}" STREQUAL "yes") - -SET(prvd_deps capi-system-runtime-info pkgmgr pkgmgr-info capi-appfw-package-manager) -SET(prvd_deps ${prvd_deps} capi-appfw-application capi-appfw-app-manager) -SET(prvd_deps ${prvd_deps} capi-media-sound-manager) - -# Mobile Profile -IF("${PROFILE}" STREQUAL "mobile") - FILE(GLOB prvd_srcs ${prvd_srcs} media/*.cpp) - FILE(GLOB prvd_srcs ${prvd_srcs} social/*.cpp) - SET(prvd_deps ${prvd_deps} contacts-service2 capi-content-media-content) -ENDIF("${PROFILE}" STREQUAL "mobile") - -# Wearable Profile -#IF("${PROFILE}" STREQUAL "wearable") -#ENDIF("${PROFILE}" STREQUAL "wearable") diff --git a/src/device/system/Battery.cpp b/src/system/Battery.cpp similarity index 99% rename from src/device/system/Battery.cpp rename to src/system/Battery.cpp index 94c3d58..69b1ecd 100644 --- a/src/device/system/Battery.cpp +++ b/src/system/Battery.cpp @@ -14,7 +14,6 @@ * limitations under the License. */ -#include "SystemTypes.h" #include "Battery.h" using namespace ctx; diff --git a/src/device/system/Battery.h b/src/system/Battery.h similarity index 94% rename from src/device/system/Battery.h rename to src/system/Battery.h index d016798..34482b4 100644 --- a/src/device/system/Battery.h +++ b/src/system/Battery.h @@ -19,7 +19,8 @@ #include #include -#include "../DeviceProviderBase.h" +#include "../shared/SystemTypes.h" +#include "../shared/DeviceProviderBase.h" namespace ctx { diff --git a/src/device/system/runtime_info/Charger.cpp b/src/system/Charger.cpp similarity index 98% rename from src/device/system/runtime_info/Charger.cpp rename to src/system/Charger.cpp index 8cdf40a..5703747 100644 --- a/src/device/system/runtime_info/Charger.cpp +++ b/src/system/Charger.cpp @@ -14,7 +14,6 @@ * limitations under the License. */ -#include "../SystemTypes.h" #include "Charger.h" using namespace ctx; diff --git a/src/device/system/runtime_info/Charger.h b/src/system/Charger.h similarity index 100% rename from src/device/system/runtime_info/Charger.h rename to src/system/Charger.h diff --git a/src/device/system/runtime_info/Gps.cpp b/src/system/Gps.cpp similarity index 98% rename from src/device/system/runtime_info/Gps.cpp rename to src/system/Gps.cpp index d2bc301..9b6d083 100644 --- a/src/device/system/runtime_info/Gps.cpp +++ b/src/system/Gps.cpp @@ -14,7 +14,6 @@ * limitations under the License. */ -#include "../SystemTypes.h" #include "Gps.h" using namespace ctx; diff --git a/src/device/system/runtime_info/Gps.h b/src/system/Gps.h similarity index 100% rename from src/device/system/runtime_info/Gps.h rename to src/system/Gps.h diff --git a/src/device/system/Psmode.cpp b/src/system/Psmode.cpp similarity index 98% rename from src/device/system/Psmode.cpp rename to src/system/Psmode.cpp index c52b176..c7d61d7 100644 --- a/src/device/system/Psmode.cpp +++ b/src/system/Psmode.cpp @@ -14,7 +14,6 @@ * limitations under the License. */ -#include "SystemTypes.h" #include "Psmode.h" using namespace ctx; diff --git a/src/device/system/Psmode.h b/src/system/Psmode.h similarity index 93% rename from src/device/system/Psmode.h rename to src/system/Psmode.h index d324ac3..0cbe3cb 100644 --- a/src/device/system/Psmode.h +++ b/src/system/Psmode.h @@ -18,7 +18,8 @@ #define _DEVICE_SYSTEM_STATUS_POWER_SAVING_MODE_H_ #include -#include "../DeviceProviderBase.h" +#include "../shared/SystemTypes.h" +#include "../shared/DeviceProviderBase.h" namespace ctx { diff --git a/src/device/system/runtime_info/RuntimeInfoBase.cpp b/src/system/RuntimeInfoBase.cpp similarity index 100% rename from src/device/system/runtime_info/RuntimeInfoBase.cpp rename to src/system/RuntimeInfoBase.cpp diff --git a/src/device/system/runtime_info/RuntimeInfoBase.h b/src/system/RuntimeInfoBase.h similarity index 94% rename from src/device/system/runtime_info/RuntimeInfoBase.h rename to src/system/RuntimeInfoBase.h index a2e4a88..7d8f6ee 100644 --- a/src/device/system/runtime_info/RuntimeInfoBase.h +++ b/src/system/RuntimeInfoBase.h @@ -18,7 +18,8 @@ #define _DEVICE_SYSTEM_STATUS_RUNTIME_INFO_BASE_H_ #include -#include "../../DeviceProviderBase.h" +#include "../shared/SystemTypes.h" +#include "../shared/DeviceProviderBase.h" namespace ctx { diff --git a/src/device/system/runtime_info/Usb.cpp b/src/system/Usb.cpp similarity index 98% rename from src/device/system/runtime_info/Usb.cpp rename to src/system/Usb.cpp index e0aa6af..c94edf7 100644 --- a/src/device/system/runtime_info/Usb.cpp +++ b/src/system/Usb.cpp @@ -14,7 +14,6 @@ * limitations under the License. */ -#include "../SystemTypes.h" #include "Usb.h" using namespace ctx; diff --git a/src/device/system/runtime_info/Usb.h b/src/system/Usb.h similarity index 100% rename from src/device/system/runtime_info/Usb.h rename to src/system/Usb.h diff --git a/src/device/system/Alarm.cpp b/src/time/Alarm.cpp similarity index 99% rename from src/device/system/Alarm.cpp rename to src/time/Alarm.cpp index edc7bad..26bac0b 100644 --- a/src/device/system/Alarm.cpp +++ b/src/time/Alarm.cpp @@ -14,7 +14,6 @@ * limitations under the License. */ -#include "SystemTypes.h" #include "Alarm.h" using namespace ctx; diff --git a/src/device/system/Alarm.h b/src/time/Alarm.h similarity index 98% rename from src/device/system/Alarm.h rename to src/time/Alarm.h index 5535e5c..797e62f 100644 --- a/src/device/system/Alarm.h +++ b/src/time/Alarm.h @@ -21,6 +21,7 @@ #include #include #include +#include "../shared/SystemTypes.h" namespace ctx { diff --git a/src/device/system/Time.cpp b/src/time/Time.cpp similarity index 98% rename from src/device/system/Time.cpp rename to src/time/Time.cpp index 6fa0c81..73f3f37 100644 --- a/src/device/system/Time.cpp +++ b/src/time/Time.cpp @@ -15,7 +15,6 @@ */ #include -#include "SystemTypes.h" #include "Time.h" using namespace ctx; diff --git a/src/device/system/Time.h b/src/time/Time.h similarity index 92% rename from src/device/system/Time.h rename to src/time/Time.h index e5e1112..48e2202 100644 --- a/src/device/system/Time.h +++ b/src/time/Time.h @@ -17,7 +17,8 @@ #ifndef _DEVICE_SYSTEM_STATUS_TIME_H_ #define _DEVICE_SYSTEM_STATUS_TIME_H_ -#include "../DeviceProviderBase.h" +#include "../shared/DeviceProviderBase.h" +#include "../shared/SystemTypes.h" namespace ctx { diff --git a/src/device/system/Wifi.cpp b/src/wifi/Wifi.cpp similarity index 99% rename from src/device/system/Wifi.cpp rename to src/wifi/Wifi.cpp index 5f6cca7..8de9fa4 100644 --- a/src/device/system/Wifi.cpp +++ b/src/wifi/Wifi.cpp @@ -15,7 +15,6 @@ */ #include -#include "SystemTypes.h" #include "Wifi.h" using namespace ctx; diff --git a/src/device/system/Wifi.h b/src/wifi/Wifi.h similarity index 95% rename from src/device/system/Wifi.h rename to src/wifi/Wifi.h index 82cebb2..2c5cee6 100644 --- a/src/device/system/Wifi.h +++ b/src/wifi/Wifi.h @@ -19,7 +19,8 @@ #include #include -#include "../DeviceProviderBase.h" +#include "../shared/DeviceProviderBase.h" +#include "../shared/SystemTypes.h" namespace ctx { -- 2.7.4 From 298f6fe38a60bce9d847450bf1d1c2d85081d72f Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Wed, 20 Apr 2016 20:21:01 +0900 Subject: [PATCH 04/16] Update License text & boilerplates Change-Id: I54d0f60dbdd56d31d873d4a63b49c84a7a03a4c4 Signed-off-by: Mu-Woong Lee --- LICENSE | 4 ++-- src/app-stats/AppStatsLogger.cpp | 2 +- src/app-stats/AppStatsLogger.h | 2 +- src/app-stats/AppStatsProvider.cpp | 2 +- src/app-stats/AppStatsProvider.h | 2 +- src/media-stats/MediaStatsLogger.cpp | 2 +- src/media-stats/MediaStatsLogger.h | 2 +- src/media-stats/MediaStatsProvider.cpp | 2 +- src/media-stats/MediaStatsProvider.h | 2 +- src/my-place/place_recognition.cpp | 2 +- src/my-place/place_recognition.h | 2 +- src/my-place/place_recognition_types.h | 2 +- src/my-place/user_places/debug_utils.cpp | 2 +- src/my-place/user_places/debug_utils.h | 2 +- src/my-place/user_places/gmap.cpp | 2 +- src/my-place/user_places/gmap.h | 2 +- src/my-place/user_places/graph.cpp | 2 +- src/my-place/user_places/graph.h | 2 +- src/my-place/user_places/location_listener_iface.h | 2 +- src/my-place/user_places/location_logger.cpp | 2 +- src/my-place/user_places/location_logger.h | 2 +- src/my-place/user_places/mahal.cpp | 2 +- src/my-place/user_places/mahal.h | 2 +- src/my-place/user_places/median.cpp | 2 +- src/my-place/user_places/median.h | 2 +- src/my-place/user_places/piecewise_lin.cpp | 2 +- src/my-place/user_places/piecewise_lin.h | 2 +- src/my-place/user_places/place_categer.cpp | 2 +- src/my-place/user_places/place_categer.h | 2 +- src/my-place/user_places/places_detector.cpp | 2 +- src/my-place/user_places/places_detector.h | 2 +- src/my-place/user_places/prob_features_model.h | 2 +- src/my-place/user_places/similarity.h | 2 +- src/my-place/user_places/user_places.cpp | 2 +- src/my-place/user_places/user_places.h | 2 +- src/my-place/user_places/user_places_params.h | 2 +- src/my-place/user_places/user_places_types.cpp | 2 +- src/my-place/user_places/user_places_types.h | 2 +- src/my-place/user_places/visit_categer.cpp | 2 +- src/my-place/user_places/visit_categer.h | 2 +- src/my-place/user_places/visit_detector.cpp | 2 +- src/my-place/user_places/visit_detector.h | 2 +- src/my-place/user_places/visit_listener_iface.h | 2 +- src/my-place/user_places/wifi_listener_iface.h | 2 +- src/my-place/user_places/wifi_logger.cpp | 2 +- src/my-place/user_places/wifi_logger.h | 2 +- src/shared/StatisticsContextProvider.cpp | 3 ++- src/social-stats/SocialStatsLogger.cpp | 2 +- src/social-stats/SocialStatsLogger.h | 2 +- src/social-stats/SocialStatsProvider.cpp | 2 +- src/social-stats/SocialStatsProvider.h | 2 +- 51 files changed, 53 insertions(+), 52 deletions(-) diff --git a/LICENSE b/LICENSE index 1b01074..d6bdc8d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved. +Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd. All rights reserved. Apache License Version 2.0, January 2004 @@ -188,7 +188,7 @@ Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved. same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/app-stats/AppStatsLogger.cpp b/src/app-stats/AppStatsLogger.cpp index 9bbb390..78261b5 100644 --- a/src/app-stats/AppStatsLogger.cpp +++ b/src/app-stats/AppStatsLogger.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * 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. diff --git a/src/app-stats/AppStatsLogger.h b/src/app-stats/AppStatsLogger.h index b2104dd..4a8dd02 100644 --- a/src/app-stats/AppStatsLogger.h +++ b/src/app-stats/AppStatsLogger.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * 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. diff --git a/src/app-stats/AppStatsProvider.cpp b/src/app-stats/AppStatsProvider.cpp index 7e18049..ebafae9 100644 --- a/src/app-stats/AppStatsProvider.cpp +++ b/src/app-stats/AppStatsProvider.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * 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. diff --git a/src/app-stats/AppStatsProvider.h b/src/app-stats/AppStatsProvider.h index dccb66a..7186955 100644 --- a/src/app-stats/AppStatsProvider.h +++ b/src/app-stats/AppStatsProvider.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * 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. diff --git a/src/media-stats/MediaStatsLogger.cpp b/src/media-stats/MediaStatsLogger.cpp index 9b1db7d..44021d8 100644 --- a/src/media-stats/MediaStatsLogger.cpp +++ b/src/media-stats/MediaStatsLogger.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * 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. diff --git a/src/media-stats/MediaStatsLogger.h b/src/media-stats/MediaStatsLogger.h index 28e8aca..32affe5 100644 --- a/src/media-stats/MediaStatsLogger.h +++ b/src/media-stats/MediaStatsLogger.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * 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. diff --git a/src/media-stats/MediaStatsProvider.cpp b/src/media-stats/MediaStatsProvider.cpp index b8ce482..263a54d 100644 --- a/src/media-stats/MediaStatsProvider.cpp +++ b/src/media-stats/MediaStatsProvider.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * 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. diff --git a/src/media-stats/MediaStatsProvider.h b/src/media-stats/MediaStatsProvider.h index 5895c46..4d2c702 100644 --- a/src/media-stats/MediaStatsProvider.h +++ b/src/media-stats/MediaStatsProvider.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * 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. diff --git a/src/my-place/place_recognition.cpp b/src/my-place/place_recognition.cpp index b736f1a..789c2da 100644 --- a/src/my-place/place_recognition.cpp +++ b/src/my-place/place_recognition.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/place_recognition.h b/src/my-place/place_recognition.h index 814bb00..773dd34 100644 --- a/src/my-place/place_recognition.h +++ b/src/my-place/place_recognition.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/place_recognition_types.h b/src/my-place/place_recognition_types.h index 9576331..5a645e4 100644 --- a/src/my-place/place_recognition_types.h +++ b/src/my-place/place_recognition_types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/debug_utils.cpp b/src/my-place/user_places/debug_utils.cpp index b5fccf2..d609f76 100644 --- a/src/my-place/user_places/debug_utils.cpp +++ b/src/my-place/user_places/debug_utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/debug_utils.h b/src/my-place/user_places/debug_utils.h index dde40bc..4651dfc 100644 --- a/src/my-place/user_places/debug_utils.h +++ b/src/my-place/user_places/debug_utils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/gmap.cpp b/src/my-place/user_places/gmap.cpp index 845b3cf..767ae8b 100644 --- a/src/my-place/user_places/gmap.cpp +++ b/src/my-place/user_places/gmap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/gmap.h b/src/my-place/user_places/gmap.h index 29eacd2..34e9782 100644 --- a/src/my-place/user_places/gmap.h +++ b/src/my-place/user_places/gmap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/graph.cpp b/src/my-place/user_places/graph.cpp index 53daeb3..2fdb6dc 100644 --- a/src/my-place/user_places/graph.cpp +++ b/src/my-place/user_places/graph.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/graph.h b/src/my-place/user_places/graph.h index 9fedb26..542b0cd 100644 --- a/src/my-place/user_places/graph.h +++ b/src/my-place/user_places/graph.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/location_listener_iface.h b/src/my-place/user_places/location_listener_iface.h index 914e022..4c3aca3 100644 --- a/src/my-place/user_places/location_listener_iface.h +++ b/src/my-place/user_places/location_listener_iface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/location_logger.cpp b/src/my-place/user_places/location_logger.cpp index 0994734..1331740 100644 --- a/src/my-place/user_places/location_logger.cpp +++ b/src/my-place/user_places/location_logger.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/location_logger.h b/src/my-place/user_places/location_logger.h index ae4c9bd..c5cb74a 100644 --- a/src/my-place/user_places/location_logger.h +++ b/src/my-place/user_places/location_logger.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/mahal.cpp b/src/my-place/user_places/mahal.cpp index ccc7f9f..b78d34c 100644 --- a/src/my-place/user_places/mahal.cpp +++ b/src/my-place/user_places/mahal.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/mahal.h b/src/my-place/user_places/mahal.h index 9e733c7..9fc57ff 100644 --- a/src/my-place/user_places/mahal.h +++ b/src/my-place/user_places/mahal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/median.cpp b/src/my-place/user_places/median.cpp index f0463b3..37c0793 100644 --- a/src/my-place/user_places/median.cpp +++ b/src/my-place/user_places/median.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/median.h b/src/my-place/user_places/median.h index 70461ae..84eaa34 100644 --- a/src/my-place/user_places/median.h +++ b/src/my-place/user_places/median.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/piecewise_lin.cpp b/src/my-place/user_places/piecewise_lin.cpp index 638af66..eee1e4d 100644 --- a/src/my-place/user_places/piecewise_lin.cpp +++ b/src/my-place/user_places/piecewise_lin.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/piecewise_lin.h b/src/my-place/user_places/piecewise_lin.h index 0ef4bff..6195da6 100644 --- a/src/my-place/user_places/piecewise_lin.h +++ b/src/my-place/user_places/piecewise_lin.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/place_categer.cpp b/src/my-place/user_places/place_categer.cpp index 1b4c975..09fc2e5 100644 --- a/src/my-place/user_places/place_categer.cpp +++ b/src/my-place/user_places/place_categer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/place_categer.h b/src/my-place/user_places/place_categer.h index 0d127b1..de2c657 100644 --- a/src/my-place/user_places/place_categer.h +++ b/src/my-place/user_places/place_categer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/places_detector.cpp b/src/my-place/user_places/places_detector.cpp index a48e395..0077769 100644 --- a/src/my-place/user_places/places_detector.cpp +++ b/src/my-place/user_places/places_detector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/places_detector.h b/src/my-place/user_places/places_detector.h index 6444539..734c89d 100644 --- a/src/my-place/user_places/places_detector.h +++ b/src/my-place/user_places/places_detector.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/prob_features_model.h b/src/my-place/user_places/prob_features_model.h index d30f548..141125c 100644 --- a/src/my-place/user_places/prob_features_model.h +++ b/src/my-place/user_places/prob_features_model.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/similarity.h b/src/my-place/user_places/similarity.h index 5938ef5..c38a23e 100644 --- a/src/my-place/user_places/similarity.h +++ b/src/my-place/user_places/similarity.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/user_places.cpp b/src/my-place/user_places/user_places.cpp index ca237ea..bdd1bc6 100644 --- a/src/my-place/user_places/user_places.cpp +++ b/src/my-place/user_places/user_places.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/user_places.h b/src/my-place/user_places/user_places.h index 1df6388..6eaa1d7 100644 --- a/src/my-place/user_places/user_places.h +++ b/src/my-place/user_places/user_places.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/user_places_params.h b/src/my-place/user_places/user_places_params.h index ec70a29..262e7ed 100644 --- a/src/my-place/user_places/user_places_params.h +++ b/src/my-place/user_places/user_places_params.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/user_places_types.cpp b/src/my-place/user_places/user_places_types.cpp index 14b1355..f3faa37 100644 --- a/src/my-place/user_places/user_places_types.cpp +++ b/src/my-place/user_places/user_places_types.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/user_places_types.h b/src/my-place/user_places/user_places_types.h index cdf7be4..a809d30 100644 --- a/src/my-place/user_places/user_places_types.h +++ b/src/my-place/user_places/user_places_types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/visit_categer.cpp b/src/my-place/user_places/visit_categer.cpp index 1d4c0c6..96000f6 100644 --- a/src/my-place/user_places/visit_categer.cpp +++ b/src/my-place/user_places/visit_categer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/visit_categer.h b/src/my-place/user_places/visit_categer.h index b9d4940..9f5a7fa 100644 --- a/src/my-place/user_places/visit_categer.h +++ b/src/my-place/user_places/visit_categer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/visit_detector.cpp b/src/my-place/user_places/visit_detector.cpp index e0ba642..5b6852c 100644 --- a/src/my-place/user_places/visit_detector.cpp +++ b/src/my-place/user_places/visit_detector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/visit_detector.h b/src/my-place/user_places/visit_detector.h index ee6e7c2..0078553 100644 --- a/src/my-place/user_places/visit_detector.h +++ b/src/my-place/user_places/visit_detector.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/visit_listener_iface.h b/src/my-place/user_places/visit_listener_iface.h index fefc926..03f5f20 100644 --- a/src/my-place/user_places/visit_listener_iface.h +++ b/src/my-place/user_places/visit_listener_iface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/wifi_listener_iface.h b/src/my-place/user_places/wifi_listener_iface.h index 3b883d3..281575f 100644 --- a/src/my-place/user_places/wifi_listener_iface.h +++ b/src/my-place/user_places/wifi_listener_iface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/wifi_logger.cpp b/src/my-place/user_places/wifi_logger.cpp index 3367276..a8dfbb5 100644 --- a/src/my-place/user_places/wifi_logger.cpp +++ b/src/my-place/user_places/wifi_logger.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/my-place/user_places/wifi_logger.h b/src/my-place/user_places/wifi_logger.h index 9938a2c..b9f9bed 100644 --- a/src/my-place/user_places/wifi_logger.h +++ b/src/my-place/user_places/wifi_logger.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/shared/StatisticsContextProvider.cpp b/src/shared/StatisticsContextProvider.cpp index cfaf008..d547b60 100644 --- a/src/shared/StatisticsContextProvider.cpp +++ b/src/shared/StatisticsContextProvider.cpp @@ -1,5 +1,6 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. * + * 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 diff --git a/src/social-stats/SocialStatsLogger.cpp b/src/social-stats/SocialStatsLogger.cpp index a32fa80..753588e 100644 --- a/src/social-stats/SocialStatsLogger.cpp +++ b/src/social-stats/SocialStatsLogger.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * 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. diff --git a/src/social-stats/SocialStatsLogger.h b/src/social-stats/SocialStatsLogger.h index 17850e9..f79cceb 100644 --- a/src/social-stats/SocialStatsLogger.h +++ b/src/social-stats/SocialStatsLogger.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * 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. diff --git a/src/social-stats/SocialStatsProvider.cpp b/src/social-stats/SocialStatsProvider.cpp index 0c0dd6d..ff850a2 100644 --- a/src/social-stats/SocialStatsProvider.cpp +++ b/src/social-stats/SocialStatsProvider.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * 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. diff --git a/src/social-stats/SocialStatsProvider.h b/src/social-stats/SocialStatsProvider.h index 0ee94fd..1ae1570 100644 --- a/src/social-stats/SocialStatsProvider.h +++ b/src/social-stats/SocialStatsProvider.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * 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. -- 2.7.4 From c9ecd4ec06f4ebfeb0ede1690de760e90aa36977 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 21 Apr 2016 14:07:49 +0900 Subject: [PATCH 05/16] Rename DeviceProviderBase as BasicProvider Change-Id: I0d7e97a0d988ce3d619585ad4cbfd81e08b9af85 Signed-off-by: Mu-Woong Lee --- src/activity/ActivityBase.cpp | 2 +- src/activity/ActivityBase.h | 4 +-- src/call/Call.cpp | 2 +- src/call/Call.h | 4 +-- src/contacts/Contacts.cpp | 2 +- src/contacts/Contacts.h | 4 +-- src/email/Email.cpp | 2 +- src/email/Email.h | 4 +-- src/headphone/Headphone.cpp | 2 +- src/headphone/Headphone.h | 4 +-- src/message/Message.cpp | 2 +- src/message/Message.h | 4 +-- .../{DeviceProviderBase.cpp => BasicProvider.cpp} | 32 ++++++++++++---------- .../{DeviceProviderBase.h => BasicProvider.h} | 20 +++++++++----- src/system/Battery.cpp | 2 +- src/system/Battery.h | 4 +-- src/system/Psmode.cpp | 2 +- src/system/Psmode.h | 4 +-- src/system/RuntimeInfoBase.cpp | 2 +- src/system/RuntimeInfoBase.h | 4 +-- src/time/Time.cpp | 2 +- src/time/Time.h | 4 +-- src/wifi/Wifi.cpp | 2 +- src/wifi/Wifi.h | 4 +-- 24 files changed, 64 insertions(+), 54 deletions(-) rename src/shared/{DeviceProviderBase.cpp => BasicProvider.cpp} (67%) rename src/shared/{DeviceProviderBase.h => BasicProvider.h} (65%) diff --git a/src/activity/ActivityBase.cpp b/src/activity/ActivityBase.cpp index 4abda04..2611aa2 100644 --- a/src/activity/ActivityBase.cpp +++ b/src/activity/ActivityBase.cpp @@ -21,7 +21,7 @@ using namespace ctx; UserActivityBase::UserActivityBase(const char *subject, activity_type_e type) : - DeviceProviderBase(subject), + BasicProvider(subject), __activityType(type), __activityHandle(NULL) { diff --git a/src/activity/ActivityBase.h b/src/activity/ActivityBase.h index 56b709f..16235c6 100644 --- a/src/activity/ActivityBase.h +++ b/src/activity/ActivityBase.h @@ -19,11 +19,11 @@ #include #include -#include "../shared/DeviceProviderBase.h" +#include "../shared/BasicProvider.h" namespace ctx { - class UserActivityBase : public DeviceProviderBase { + class UserActivityBase : public BasicProvider { public: UserActivityBase(const char *subject, activity_type_e type); virtual ~UserActivityBase(); diff --git a/src/call/Call.cpp b/src/call/Call.cpp index a19a2b9..3cc49d6 100644 --- a/src/call/Call.cpp +++ b/src/call/Call.cpp @@ -38,7 +38,7 @@ static telephony_noti_e __callNotiIds[] = static Json __latest; SocialStatusCall::SocialStatusCall() : - DeviceProviderBase(SOCIAL_ST_SUBJ_CALL) + BasicProvider(SOCIAL_ST_SUBJ_CALL) { __handleList.count = 0; __handleList.handle = NULL; diff --git a/src/call/Call.h b/src/call/Call.h index a53276f..23d589d 100644 --- a/src/call/Call.h +++ b/src/call/Call.h @@ -19,11 +19,11 @@ #include #include "../shared/SocialTypes.h" -#include "../shared/DeviceProviderBase.h" +#include "../shared/BasicProvider.h" namespace ctx { - class SocialStatusCall : public DeviceProviderBase { + class SocialStatusCall : public BasicProvider { public: SocialStatusCall(); ~SocialStatusCall(); diff --git a/src/contacts/Contacts.cpp b/src/contacts/Contacts.cpp index 42789a3..6b195f7 100644 --- a/src/contacts/Contacts.cpp +++ b/src/contacts/Contacts.cpp @@ -23,7 +23,7 @@ using namespace ctx; SocialStatusContacts::SocialStatusContacts() : - DeviceProviderBase(SOCIAL_ST_SUBJ_CONTACTS), + BasicProvider(SOCIAL_ST_SUBJ_CONTACTS), __latestMyProfile(0), __latestPerson(0) { diff --git a/src/contacts/Contacts.h b/src/contacts/Contacts.h index 28b68ce..4211a6c 100644 --- a/src/contacts/Contacts.h +++ b/src/contacts/Contacts.h @@ -19,11 +19,11 @@ #include #include "../shared/SocialTypes.h" -#include "../shared/DeviceProviderBase.h" +#include "../shared/BasicProvider.h" namespace ctx { - class SocialStatusContacts : public DeviceProviderBase { + class SocialStatusContacts : public BasicProvider { public: SocialStatusContacts(); ~SocialStatusContacts(); diff --git a/src/email/Email.cpp b/src/email/Email.cpp index fbf5c8d..e16b6d5 100644 --- a/src/email/Email.cpp +++ b/src/email/Email.cpp @@ -20,7 +20,7 @@ using namespace ctx; SocialStatusEmail::SocialStatusEmail() : - DeviceProviderBase(SOCIAL_ST_SUBJ_EMAIL), + BasicProvider(SOCIAL_ST_SUBJ_EMAIL), __dbusSignalId(-1), __dbusWatcher(DBusType::SESSION) { diff --git a/src/email/Email.h b/src/email/Email.h index b78eb33..bfd7702 100644 --- a/src/email/Email.h +++ b/src/email/Email.h @@ -19,11 +19,11 @@ #include #include "../shared/SocialTypes.h" -#include "../shared/DeviceProviderBase.h" +#include "../shared/BasicProvider.h" namespace ctx { - class SocialStatusEmail : public DeviceProviderBase, public IDBusSignalListener { + class SocialStatusEmail : public BasicProvider, public IDBusSignalListener { public: SocialStatusEmail(); ~SocialStatusEmail(); diff --git a/src/headphone/Headphone.cpp b/src/headphone/Headphone.cpp index 3ee6dfa..a8da0ae 100644 --- a/src/headphone/Headphone.cpp +++ b/src/headphone/Headphone.cpp @@ -22,7 +22,7 @@ using namespace ctx; DeviceStatusHeadphone::DeviceStatusHeadphone() : - DeviceProviderBase(DEVICE_ST_SUBJ_HEADPHONE), + BasicProvider(DEVICE_ST_SUBJ_HEADPHONE), __connected(false), __audioJackState(RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED), __btAudioState(false), diff --git a/src/headphone/Headphone.h b/src/headphone/Headphone.h index 2fdd780..5d88b36 100644 --- a/src/headphone/Headphone.h +++ b/src/headphone/Headphone.h @@ -21,11 +21,11 @@ #include #include #include "../shared/SystemTypes.h" -#include "../shared/DeviceProviderBase.h" +#include "../shared/BasicProvider.h" namespace ctx { - class DeviceStatusHeadphone : public DeviceProviderBase { + class DeviceStatusHeadphone : public BasicProvider { public: DeviceStatusHeadphone(); ~DeviceStatusHeadphone(); diff --git a/src/message/Message.cpp b/src/message/Message.cpp index 9316806..9e8c350 100644 --- a/src/message/Message.cpp +++ b/src/message/Message.cpp @@ -21,7 +21,7 @@ using namespace ctx; SocialStatusMessage::SocialStatusMessage() : - DeviceProviderBase(SOCIAL_ST_SUBJ_MESSAGE), + BasicProvider(SOCIAL_ST_SUBJ_MESSAGE), __messageHandle(NULL) { } diff --git a/src/message/Message.h b/src/message/Message.h index 79e489a..a272144 100644 --- a/src/message/Message.h +++ b/src/message/Message.h @@ -20,11 +20,11 @@ #include #include #include "../shared/SocialTypes.h" -#include "../shared/DeviceProviderBase.h" +#include "../shared/BasicProvider.h" namespace ctx { - class SocialStatusMessage : public DeviceProviderBase { + class SocialStatusMessage : public BasicProvider { public: SocialStatusMessage(); ~SocialStatusMessage(); diff --git a/src/shared/DeviceProviderBase.cpp b/src/shared/BasicProvider.cpp similarity index 67% rename from src/shared/DeviceProviderBase.cpp rename to src/shared/BasicProvider.cpp index 1c5f5ef..95cba6b 100644 --- a/src/shared/DeviceProviderBase.cpp +++ b/src/shared/BasicProvider.cpp @@ -15,26 +15,30 @@ */ #include -#include "DeviceProviderBase.h" +#include "BasicProvider.h" using namespace ctx; -DeviceProviderBase::DeviceProviderBase(const char *subject) : +BasicProvider::BasicProvider(const char *subject) : ContextProvider(subject), __beingSubscribed(false) { } -bool DeviceProviderBase::isSupported() +BasicProvider::~BasicProvider() +{ +} + +bool BasicProvider::isSupported() { return true; } -void DeviceProviderBase::submitTriggerItem() +void BasicProvider::submitTriggerItem() { } -int DeviceProviderBase::subscribe(Json option, Json *requestResult) +int BasicProvider::subscribe(Json option, Json *requestResult) { IF_FAIL_RETURN(!__beingSubscribed, ERR_NONE); @@ -46,7 +50,7 @@ int DeviceProviderBase::subscribe(Json option, Json *requestResult) return ret; } -int DeviceProviderBase::unsubscribe(Json option) +int BasicProvider::unsubscribe(Json option) { int ret = ERR_NONE; @@ -56,37 +60,37 @@ int DeviceProviderBase::unsubscribe(Json option) return ret; } -int DeviceProviderBase::read(Json option, Json *requestResult) +int BasicProvider::read(Json option, Json *requestResult) { return read(); } -int DeviceProviderBase::write(Json data, Json *requestResult) +int BasicProvider::write(Json data, Json *requestResult) { - return write(); + return write(data); } -int DeviceProviderBase::subscribe() +int BasicProvider::subscribe() { return ERR_NOT_SUPPORTED; } -int DeviceProviderBase::unsubscribe() +int BasicProvider::unsubscribe() { return ERR_NOT_SUPPORTED; } -int DeviceProviderBase::read() +int BasicProvider::read() { return ERR_NOT_SUPPORTED; } -int DeviceProviderBase::write() +int BasicProvider::write(Json &data) { return ERR_NOT_SUPPORTED; } -bool DeviceProviderBase::getSystemInfoBool(const char *key) +bool BasicProvider::getSystemInfoBool(const char *key) { bool supported = false; int ret = system_info_get_platform_bool(key, &supported); diff --git a/src/shared/DeviceProviderBase.h b/src/shared/BasicProvider.h similarity index 65% rename from src/shared/DeviceProviderBase.h rename to src/shared/BasicProvider.h index f5a55da..c7a7f5d 100644 --- a/src/shared/DeviceProviderBase.h +++ b/src/shared/BasicProvider.h @@ -14,14 +14,17 @@ * limitations under the License. */ -#ifndef _CONTEXT_DEVICE_PROVIDER_BASE_H_ -#define _CONTEXT_DEVICE_PROVIDER_BASE_H_ +#ifndef _CONTEXT_BASIC_PROVIDER_H_ +#define _CONTEXT_BASIC_PROVIDER_H_ #include namespace ctx { - class DeviceProviderBase : public ContextProvider { + /* BasicProvider implements the very basic form of context providers, + which has no controllable options, and does not set the requestResult + parameter to reply to clients' requests immediately. */ + class BasicProvider : public ContextProvider { public: int subscribe(Json option, Json *requestResult); int unsubscribe(Json option); @@ -29,21 +32,24 @@ namespace ctx { int write(Json data, Json *requestResult); virtual bool isSupported(); + + /* TODO: This function will be deprecated */ virtual void submitTriggerItem(); protected: bool __beingSubscribed; - DeviceProviderBase(const char *subject); - virtual ~DeviceProviderBase() {} + BasicProvider(const char *subject); + virtual ~BasicProvider(); virtual int subscribe(); virtual int unsubscribe(); virtual int read(); - virtual int write(); + virtual int write(Json &data); + /* TODO: This function needs to be removed from here */ static bool getSystemInfoBool(const char *key); }; } -#endif // _CONTEXT_DEVICE_PROVIDER_BASE_H_ +#endif /* _CONTEXT_BASIC_PROVIDER_H_ */ diff --git a/src/system/Battery.cpp b/src/system/Battery.cpp index 69b1ecd..e86a595 100644 --- a/src/system/Battery.cpp +++ b/src/system/Battery.cpp @@ -19,7 +19,7 @@ using namespace ctx; DeviceStatusBattery::DeviceStatusBattery() - : DeviceProviderBase(DEVICE_ST_SUBJ_BATTERY) + : BasicProvider(DEVICE_ST_SUBJ_BATTERY) { } diff --git a/src/system/Battery.h b/src/system/Battery.h index 34482b4..40e4ce0 100644 --- a/src/system/Battery.h +++ b/src/system/Battery.h @@ -20,11 +20,11 @@ #include #include #include "../shared/SystemTypes.h" -#include "../shared/DeviceProviderBase.h" +#include "../shared/BasicProvider.h" namespace ctx { - class DeviceStatusBattery : public DeviceProviderBase { + class DeviceStatusBattery : public BasicProvider { public: DeviceStatusBattery(); ~DeviceStatusBattery(); diff --git a/src/system/Psmode.cpp b/src/system/Psmode.cpp index c7d61d7..cc0cf30 100644 --- a/src/system/Psmode.cpp +++ b/src/system/Psmode.cpp @@ -19,7 +19,7 @@ using namespace ctx; DeviceStatusPsmode::DeviceStatusPsmode() : - DeviceProviderBase(DEVICE_ST_SUBJ_PSMODE) + BasicProvider(DEVICE_ST_SUBJ_PSMODE) { } diff --git a/src/system/Psmode.h b/src/system/Psmode.h index 0cbe3cb..78ec7ec 100644 --- a/src/system/Psmode.h +++ b/src/system/Psmode.h @@ -19,11 +19,11 @@ #include #include "../shared/SystemTypes.h" -#include "../shared/DeviceProviderBase.h" +#include "../shared/BasicProvider.h" namespace ctx { - class DeviceStatusPsmode : public DeviceProviderBase { + class DeviceStatusPsmode : public BasicProvider { public: DeviceStatusPsmode(); ~DeviceStatusPsmode(); diff --git a/src/system/RuntimeInfoBase.cpp b/src/system/RuntimeInfoBase.cpp index 1f745ad..67e3710 100644 --- a/src/system/RuntimeInfoBase.cpp +++ b/src/system/RuntimeInfoBase.cpp @@ -19,7 +19,7 @@ using namespace ctx; DeviceStatusRuntimeInfo::DeviceStatusRuntimeInfo(const char *subject, runtime_info_key_e key) : - DeviceProviderBase(subject), + BasicProvider(subject), __infoKey(key) { } diff --git a/src/system/RuntimeInfoBase.h b/src/system/RuntimeInfoBase.h index 7d8f6ee..c99f462 100644 --- a/src/system/RuntimeInfoBase.h +++ b/src/system/RuntimeInfoBase.h @@ -19,11 +19,11 @@ #include #include "../shared/SystemTypes.h" -#include "../shared/DeviceProviderBase.h" +#include "../shared/BasicProvider.h" namespace ctx { - class DeviceStatusRuntimeInfo : public DeviceProviderBase { + class DeviceStatusRuntimeInfo : public BasicProvider { public: DeviceStatusRuntimeInfo(const char *subject, runtime_info_key_e key); diff --git a/src/time/Time.cpp b/src/time/Time.cpp index 73f3f37..d4ba82f 100644 --- a/src/time/Time.cpp +++ b/src/time/Time.cpp @@ -20,7 +20,7 @@ using namespace ctx; DeviceStatusTime::DeviceStatusTime() : - DeviceProviderBase(DEVICE_ST_SUBJ_TIME) + BasicProvider(DEVICE_ST_SUBJ_TIME) { } diff --git a/src/time/Time.h b/src/time/Time.h index 48e2202..9562723 100644 --- a/src/time/Time.h +++ b/src/time/Time.h @@ -17,12 +17,12 @@ #ifndef _DEVICE_SYSTEM_STATUS_TIME_H_ #define _DEVICE_SYSTEM_STATUS_TIME_H_ -#include "../shared/DeviceProviderBase.h" +#include "../shared/BasicProvider.h" #include "../shared/SystemTypes.h" namespace ctx { - class DeviceStatusTime : public DeviceProviderBase { + class DeviceStatusTime : public BasicProvider { public: DeviceStatusTime(); ~DeviceStatusTime(); diff --git a/src/wifi/Wifi.cpp b/src/wifi/Wifi.cpp index 8de9fa4..c8a1d02 100644 --- a/src/wifi/Wifi.cpp +++ b/src/wifi/Wifi.cpp @@ -20,7 +20,7 @@ using namespace ctx; DeviceStatusWifi::DeviceStatusWifi() : - DeviceProviderBase(DEVICE_ST_SUBJ_WIFI), + BasicProvider(DEVICE_ST_SUBJ_WIFI), __lastState(UNKNOWN), __isInitialized(false), __isActivated(false), diff --git a/src/wifi/Wifi.h b/src/wifi/Wifi.h index 2c5cee6..7fbe2f2 100644 --- a/src/wifi/Wifi.h +++ b/src/wifi/Wifi.h @@ -19,12 +19,12 @@ #include #include -#include "../shared/DeviceProviderBase.h" +#include "../shared/BasicProvider.h" #include "../shared/SystemTypes.h" namespace ctx { - class DeviceStatusWifi : public DeviceProviderBase { + class DeviceStatusWifi : public BasicProvider { public: DeviceStatusWifi(); ~DeviceStatusWifi(); -- 2.7.4 From 0d653684eabd120898b9c8b4524c1d62a0b0c8d7 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 21 Apr 2016 14:31:05 +0900 Subject: [PATCH 06/16] Separate util functions in BasicProvider to the namespace ctx::util Change-Id: I42239d9277ae346dda1a3d4241d392d67c194587 Signed-off-by: Mu-Woong Lee --- CMakeLists.txt | 1 + src/activity/ActivityBase.cpp | 4 ++-- src/call/Call.cpp | 3 ++- src/email/Email.cpp | 3 ++- src/message/Message.cpp | 3 ++- src/shared/BasicProvider.cpp | 8 -------- src/shared/BasicProvider.h | 3 --- src/shared/Util.cpp | 27 +++++++++++++++++++++++++++ src/shared/Util.h | 28 ++++++++++++++++++++++++++++ src/system/Gps.cpp | 3 ++- src/system/Usb.cpp | 3 ++- src/wifi/Wifi.cpp | 3 ++- 12 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 src/shared/Util.cpp create mode 100644 src/shared/Util.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2865cfa..f776afe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ SET(compile_defs "LOG_TAG=\"CONTEXT\"") # Common Options INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/src/shared ) ADD_DEFINITIONS(-O2 -Wall -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIC -Wl,--as-needed -Wl,--gc-section -Wl,--print-gc-section") diff --git a/src/activity/ActivityBase.cpp b/src/activity/ActivityBase.cpp index 2611aa2..b677b6e 100644 --- a/src/activity/ActivityBase.cpp +++ b/src/activity/ActivityBase.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include "ActivityTypes.h" #include "ActivityBase.h" @@ -35,7 +35,7 @@ UserActivityBase::~UserActivityBase() bool UserActivityBase::isSupported() { - return getSystemInfoBool("tizen.org/feature/sensor.activity_recognition"); + return util::getSystemInfoBool("tizen.org/feature/sensor.activity_recognition"); } void UserActivityBase::submitTriggerItem() diff --git a/src/call/Call.cpp b/src/call/Call.cpp index 3cc49d6..616914a 100644 --- a/src/call/Call.cpp +++ b/src/call/Call.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include "Call.h" #define TELEPHONY_NOTI_ID_CNT 8 @@ -50,7 +51,7 @@ SocialStatusCall::~SocialStatusCall() bool SocialStatusCall::isSupported() { - return getSystemInfoBool("tizen.org/feature/network.telephony"); + return util::getSystemInfoBool("tizen.org/feature/network.telephony"); } void SocialStatusCall::submitTriggerItem() diff --git a/src/email/Email.cpp b/src/email/Email.cpp index e16b6d5..b6b9721 100644 --- a/src/email/Email.cpp +++ b/src/email/Email.cpp @@ -15,6 +15,7 @@ */ #include +#include #include "Email.h" using namespace ctx; @@ -32,7 +33,7 @@ SocialStatusEmail::~SocialStatusEmail() bool SocialStatusEmail::isSupported() { - return getSystemInfoBool("tizen.org/feature/network.telephony"); + return util::getSystemInfoBool("tizen.org/feature/network.telephony"); } void SocialStatusEmail::submitTriggerItem() diff --git a/src/message/Message.cpp b/src/message/Message.cpp index 9e8c350..d1873e3 100644 --- a/src/message/Message.cpp +++ b/src/message/Message.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include "Message.h" #define MAX_ADDR_SIZE 20 @@ -32,7 +33,7 @@ SocialStatusMessage::~SocialStatusMessage() bool SocialStatusMessage::isSupported() { - return getSystemInfoBool("tizen.org/feature/network.telephony"); + return util::getSystemInfoBool("tizen.org/feature/network.telephony"); } void SocialStatusMessage::submitTriggerItem() diff --git a/src/shared/BasicProvider.cpp b/src/shared/BasicProvider.cpp index 95cba6b..28202dd 100644 --- a/src/shared/BasicProvider.cpp +++ b/src/shared/BasicProvider.cpp @@ -89,11 +89,3 @@ int BasicProvider::write(Json &data) { return ERR_NOT_SUPPORTED; } - -bool BasicProvider::getSystemInfoBool(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/shared/BasicProvider.h b/src/shared/BasicProvider.h index c7a7f5d..84b0838 100644 --- a/src/shared/BasicProvider.h +++ b/src/shared/BasicProvider.h @@ -46,9 +46,6 @@ namespace ctx { virtual int unsubscribe(); virtual int read(); virtual int write(Json &data); - - /* TODO: This function needs to be removed from here */ - static bool getSystemInfoBool(const char *key); }; } diff --git a/src/shared/Util.cpp b/src/shared/Util.cpp new file mode 100644 index 0000000..e25d0db --- /dev/null +++ b/src/shared/Util.cpp @@ -0,0 +1,27 @@ +/* + * 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 +#include "Util.h" + +bool ctx::util::getSystemInfoBool(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/shared/Util.h b/src/shared/Util.h new file mode 100644 index 0000000..a7c9d74 --- /dev/null +++ b/src/shared/Util.h @@ -0,0 +1,28 @@ +/* + * 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_UTIL_H_ +#define _CONTEXT_UTIL_H_ + +namespace ctx { +namespace util { + + bool getSystemInfoBool(const char *key); + +} /* namespace util */ +} /* namespace ctx */ + +#endif /* _CONTEXT_UTIL_H_ */ diff --git a/src/system/Gps.cpp b/src/system/Gps.cpp index 9b6d083..fb01f9d 100644 --- a/src/system/Gps.cpp +++ b/src/system/Gps.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include "Gps.h" using namespace ctx; @@ -47,7 +48,7 @@ DeviceStatusGps::~DeviceStatusGps() bool DeviceStatusGps::isSupported() { - return getSystemInfoBool("tizen.org/feature/location.gps"); + return util::getSystemInfoBool("tizen.org/feature/location.gps"); } void DeviceStatusGps::submitTriggerItem() diff --git a/src/system/Usb.cpp b/src/system/Usb.cpp index c94edf7..935aaeb 100644 --- a/src/system/Usb.cpp +++ b/src/system/Usb.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include "Usb.h" using namespace ctx; @@ -29,7 +30,7 @@ DeviceStatusUsb::~DeviceStatusUsb() bool DeviceStatusUsb::isSupported() { - return getSystemInfoBool("tizen.org/feature/usb.host"); + return util::getSystemInfoBool("tizen.org/feature/usb.host"); } void DeviceStatusUsb::submitTriggerItem() diff --git a/src/wifi/Wifi.cpp b/src/wifi/Wifi.cpp index c8a1d02..f5f2b49 100644 --- a/src/wifi/Wifi.cpp +++ b/src/wifi/Wifi.cpp @@ -15,6 +15,7 @@ */ #include +#include #include "Wifi.h" using namespace ctx; @@ -41,7 +42,7 @@ DeviceStatusWifi::~DeviceStatusWifi() bool DeviceStatusWifi::isSupported() { - return getSystemInfoBool("tizen.org/feature/network.wifi"); + return util::getSystemInfoBool("tizen.org/feature/network.wifi"); } void DeviceStatusWifi::submitTriggerItem() -- 2.7.4 From 5c9d867b72e22db0723fa6c68557a6799129aea0 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 21 Apr 2016 14:50:29 +0900 Subject: [PATCH 07/16] Code cleanup: activity providers Change-Id: I652e9847753c61b53b78bcce436bb90923e9c0b4 Signed-off-by: Mu-Woong Lee --- src/activity/{ActivityBase.cpp => Activity.cpp} | 29 ++++++++------- src/activity/Activity.h | 44 +++++++++++++++++------ src/activity/ActivityBase.h | 48 ------------------------- src/activity/ActivityTypes.h | 32 ++++++++--------- src/shared/DeviceContextProvider.cpp | 8 ++--- 5 files changed, 68 insertions(+), 93 deletions(-) rename src/activity/{ActivityBase.cpp => Activity.cpp} (76%) delete mode 100644 src/activity/ActivityBase.h diff --git a/src/activity/ActivityBase.cpp b/src/activity/Activity.cpp similarity index 76% rename from src/activity/ActivityBase.cpp rename to src/activity/Activity.cpp index b677b6e..faf864d 100644 --- a/src/activity/ActivityBase.cpp +++ b/src/activity/Activity.cpp @@ -15,30 +15,29 @@ */ #include -#include "ActivityTypes.h" -#include "ActivityBase.h" +#include "Activity.h" using namespace ctx; -UserActivityBase::UserActivityBase(const char *subject, activity_type_e type) : +ActivityProvider::ActivityProvider(const char *subject, activity_type_e type) : BasicProvider(subject), __activityType(type), __activityHandle(NULL) { } -UserActivityBase::~UserActivityBase() +ActivityProvider::~ActivityProvider() { if (__activityHandle) activity_release(__activityHandle); } -bool UserActivityBase::isSupported() +bool ActivityProvider::isSupported() { return util::getSystemInfoBool("tizen.org/feature/sensor.activity_recognition"); } -void UserActivityBase::submitTriggerItem() +void ActivityProvider::submitTriggerItem() { registerTriggerItem(OPS_SUBSCRIBE, "{\"Event\":{\"type\":\"string\", \"values\":[\"Detected\"]}}", @@ -46,40 +45,40 @@ void UserActivityBase::submitTriggerItem() ); } -void UserActivityBase::__updateCb(activity_type_e activity, const activity_data_h data, double timestamp, activity_error_e error, void* userData) +void ActivityProvider::__updateCb(activity_type_e activity, const activity_data_h data, double timestamp, activity_error_e error, void* userData) { IF_FAIL_VOID_TAG(error == ACTIVITY_ERROR_NONE, _E, "Error: %d", error); - UserActivityBase *instance = static_cast(userData); + ActivityProvider *instance = static_cast(userData); instance->__handleUpdate(activity, data, timestamp); } -void UserActivityBase::__handleUpdate(activity_type_e activity, const activity_data_h data, double timestamp) +void ActivityProvider::__handleUpdate(activity_type_e activity, const activity_data_h data, double timestamp) { IF_FAIL_VOID_TAG(activity == __activityType, _E, "Invalid activity: %d", activity); Json dataRead; - dataRead.set(NULL, USER_ACT_EVENT, USER_ACT_DETECTED); + dataRead.set(NULL, CTX_ACTIVITY_EVENT, CTX_ACTIVITY_DETECTED); activity_accuracy_e accuracy = ACTIVITY_ACCURACY_LOW; activity_get_accuracy(data, &accuracy); switch (accuracy) { case ACTIVITY_ACCURACY_HIGH: - dataRead.set(NULL, USER_ACT_ACCURACY, USER_ACT_HIGH); + dataRead.set(NULL, CTX_ACTIVITY_ACCURACY, CTX_ACTIVITY_HIGH); break; case ACTIVITY_ACCURACY_MID: - dataRead.set(NULL, USER_ACT_ACCURACY, USER_ACT_NORMAL); + dataRead.set(NULL, CTX_ACTIVITY_ACCURACY, CTX_ACTIVITY_NORMAL); break; default: - dataRead.set(NULL, USER_ACT_ACCURACY, USER_ACT_LOW); + dataRead.set(NULL, CTX_ACTIVITY_ACCURACY, CTX_ACTIVITY_LOW); break; } publish(NULL, ERR_NONE, dataRead); } -int UserActivityBase::subscribe() +int ActivityProvider::subscribe() { IF_FAIL_RETURN(__activityHandle == NULL, ERR_NONE); @@ -97,7 +96,7 @@ int UserActivityBase::subscribe() return ERR_NONE; } -int UserActivityBase::unsubscribe() +int ActivityProvider::unsubscribe() { IF_FAIL_RETURN(__activityHandle, ERR_NONE); diff --git a/src/activity/Activity.h b/src/activity/Activity.h index ab5be2e..c3c3dfe 100644 --- a/src/activity/Activity.h +++ b/src/activity/Activity.h @@ -14,23 +14,47 @@ * limitations under the License. */ -#ifndef _DEVICE_ACTIVITY_STATUS_H_ -#define _DEVICE_ACTIVITY_STATUS_H_ +#ifndef _CONTEXT_ACTIVITY_PROVIDER_H_ +#define _CONTEXT_ACTIVITY_PROVIDER_H_ -#include "ActivityBase.h" +#include +#include +#include #include "ActivityTypes.h" #define GENERATE_ACTIVITY_PROVIDER(actPrvd, actSubj, actType) \ - class actPrvd : public UserActivityBase { \ + class actPrvd : public ActivityProvider { \ public: \ - actPrvd() : UserActivityBase(actSubj, actType) {} \ + actPrvd() : ActivityProvider(actSubj, actType) {} \ }; \ namespace ctx { - GENERATE_ACTIVITY_PROVIDER(UserActivityStationary, USER_ACT_SUBJ_STATIONARY, ACTIVITY_STATIONARY); - GENERATE_ACTIVITY_PROVIDER(UserActivityWalking, USER_ACT_SUBJ_WALKING, ACTIVITY_WALK); - GENERATE_ACTIVITY_PROVIDER(UserActivityRunning, USER_ACT_SUBJ_RUNNING, ACTIVITY_RUN); - GENERATE_ACTIVITY_PROVIDER(UserActivityInVehicle, USER_ACT_SUBJ_IN_VEHICLE, ACTIVITY_IN_VEHICLE); + + class ActivityProvider : public BasicProvider { + public: + ActivityProvider(const char *subject, activity_type_e type); + virtual ~ActivityProvider(); + + int subscribe(); + int unsubscribe(); + + bool isSupported(); + void submitTriggerItem(); + + protected: + activity_type_e __activityType; + activity_h __activityHandle; + + private: + void __handleUpdate(activity_type_e activity, const activity_data_h data, double timestamp); + static void __updateCb(activity_type_e activity, const activity_data_h data, double timestamp, activity_error_e error, void* userData); + }; + + + GENERATE_ACTIVITY_PROVIDER(StationaryActivityProvider, CTX_ACTIVITY_SUBJ_STATIONARY, ACTIVITY_STATIONARY); + GENERATE_ACTIVITY_PROVIDER(WalkingActivityProvider, CTX_ACTIVITY_SUBJ_WALKING, ACTIVITY_WALK); + GENERATE_ACTIVITY_PROVIDER(RunningActivityProvider, CTX_ACTIVITY_SUBJ_RUNNING, ACTIVITY_RUN); + GENERATE_ACTIVITY_PROVIDER(InVehicleActivityProvider, CTX_ACTIVITY_SUBJ_IN_VEHICLE, ACTIVITY_IN_VEHICLE); } -#endif // _DEVICE_ACTIVITY_STATUS_H_ +#endif // _CONTEXT_ACTIVITY_PROVIDER_H_ diff --git a/src/activity/ActivityBase.h b/src/activity/ActivityBase.h deleted file mode 100644 index 16235c6..0000000 --- a/src/activity/ActivityBase.h +++ /dev/null @@ -1,48 +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 _DEVICE_ACTIVITY_STATUS_BASE_H_ -#define _DEVICE_ACTIVITY_STATUS_BASE_H_ - -#include -#include -#include "../shared/BasicProvider.h" - -namespace ctx { - - class UserActivityBase : public BasicProvider { - public: - UserActivityBase(const char *subject, activity_type_e type); - virtual ~UserActivityBase(); - - int subscribe(); - int unsubscribe(); - - bool isSupported(); - void submitTriggerItem(); - - protected: - activity_type_e __activityType; - activity_h __activityHandle; - - private: - void __handleUpdate(activity_type_e activity, const activity_data_h data, double timestamp); - static void __updateCb(activity_type_e activity, const activity_data_h data, double timestamp, activity_error_e error, void* userData); - }; - -} - -#endif // _DEVICE_ACTIVITY_STATUS_BASE_H_ diff --git a/src/activity/ActivityTypes.h b/src/activity/ActivityTypes.h index 4562b7b..8a58776 100644 --- a/src/activity/ActivityTypes.h +++ b/src/activity/ActivityTypes.h @@ -14,23 +14,23 @@ * limitations under the License. */ -#ifndef _DEVICE_ACTIVITY_STATUS_TYPES_H_ -#define _DEVICE_ACTIVITY_STATUS_TYPES_H_ +#ifndef _CONTEXT_ACTIVITY_TYPES_H_ +#define _CONTEXT_ACTIVITY_TYPES_H_ -// Subject -#define USER_ACT_SUBJ_IN_VEHICLE "activity/in_vehicle" -#define USER_ACT_SUBJ_RUNNING "activity/running" -#define USER_ACT_SUBJ_STATIONARY "activity/stationary" -#define USER_ACT_SUBJ_WALKING "activity/walking" +/* Subject */ +#define CTX_ACTIVITY_SUBJ_IN_VEHICLE "activity/in_vehicle" +#define CTX_ACTIVITY_SUBJ_RUNNING "activity/running" +#define CTX_ACTIVITY_SUBJ_STATIONARY "activity/stationary" +#define CTX_ACTIVITY_SUBJ_WALKING "activity/walking" -// Data Key -#define USER_ACT_EVENT "Event" -#define USER_ACT_ACCURACY "Accuracy" +/* Data Key */ +#define CTX_ACTIVITY_EVENT "Event" +#define CTX_ACTIVITY_ACCURACY "Accuracy" -// Data Value -#define USER_ACT_DETECTED "Detected" -#define USER_ACT_LOW "Low" -#define USER_ACT_NORMAL "Normal" -#define USER_ACT_HIGH "High" +/* Data Value */ +#define CTX_ACTIVITY_DETECTED "Detected" +#define CTX_ACTIVITY_LOW "Low" +#define CTX_ACTIVITY_NORMAL "Normal" +#define CTX_ACTIVITY_HIGH "High" -#endif // _DEVICE_ACTIVITY_STATUS_TYPES_H_ +#endif /* _CONTEXT_ACTIVITY_TYPES_H_ */ diff --git a/src/shared/DeviceContextProvider.cpp b/src/shared/DeviceContextProvider.cpp index 5ff533d..f0a8d79 100644 --- a/src/shared/DeviceContextProvider.cpp +++ b/src/shared/DeviceContextProvider.cpp @@ -69,10 +69,10 @@ SO_EXPORT bool ctx::initDeviceContextProvider() registerProvider(DEVICE_ST_SUBJ_BATTERY, NULL); registerProvider(DEVICE_ST_SUBJ_PSMODE, 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); + registerProvider(CTX_ACTIVITY_SUBJ_STATIONARY, NULL); + registerProvider(CTX_ACTIVITY_SUBJ_WALKING, NULL); + registerProvider(CTX_ACTIVITY_SUBJ_RUNNING, NULL); + registerProvider(CTX_ACTIVITY_SUBJ_IN_VEHICLE, NULL); #ifdef _MOBILE_ registerProvider(SOCIAL_ST_SUBJ_CALL, PRIV_TELEPHONY); -- 2.7.4 From 433563eb3983c0393a3542048da0007276cbdba4 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 21 Apr 2016 16:08:43 +0900 Subject: [PATCH 08/16] Code cleanup: merge common, system, social types into one provider types header Change-Id: I96e74636b9d2e4ce62a959f170e1e168d6ac1b2f Signed-off-by: Mu-Woong Lee --- src/app-stats/ActiveWindowMonitor.cpp | 22 ++--- src/app-stats/AppStatisticsTypes.h | 2 +- src/app-stats/DbHandle.cpp | 84 +++++++++---------- src/app-stats/DbInit.cpp | 2 +- src/app-stats/InstallMonitor.cpp | 4 +- src/call/Call.cpp | 46 +++++------ src/call/Call.h | 2 +- src/contacts/Contacts.cpp | 8 +- src/contacts/Contacts.h | 2 +- src/email/Email.cpp | 6 +- src/email/Email.h | 2 +- src/headphone/Headphone.cpp | 10 +-- src/headphone/Headphone.h | 2 +- src/media-stats/DbHandle.cpp | 14 ++-- src/media-stats/MediaContentMonitor.cpp | 6 +- src/media-stats/MediaStatisticsTypes.h | 2 +- src/message/Message.cpp | 10 +-- src/message/Message.h | 2 +- src/shared/CommonTypes.h | 79 ------------------ src/shared/DbHandleBase.cpp | 95 ++++++++++++++-------- src/shared/DeviceContextProvider.cpp | 26 +++--- src/shared/ProviderTypes.h | 134 +++++++++++++++++++++++++++++++ src/shared/SocialTypes.h | 52 ------------ src/shared/SystemTypes.h | 65 --------------- src/social-stats/DbHandle.cpp | 30 +++---- src/social-stats/LogAggregator.cpp | 12 +-- src/social-stats/SocialStatisticsTypes.h | 2 +- src/system/Battery.cpp | 22 ++--- src/system/Battery.h | 2 +- src/system/Charger.cpp | 6 +- src/system/Gps.cpp | 12 +-- src/system/Psmode.cpp | 6 +- src/system/Psmode.h | 2 +- src/system/RuntimeInfoBase.h | 2 +- src/system/Usb.cpp | 6 +- src/time/Alarm.cpp | 16 ++-- src/time/Alarm.h | 2 +- src/time/Time.cpp | 8 +- src/time/Time.h | 2 +- src/wifi/Wifi.cpp | 10 +-- src/wifi/Wifi.h | 2 +- 41 files changed, 391 insertions(+), 428 deletions(-) delete mode 100644 src/shared/CommonTypes.h create mode 100644 src/shared/ProviderTypes.h delete mode 100644 src/shared/SocialTypes.h delete mode 100644 src/shared/SystemTypes.h diff --git a/src/app-stats/ActiveWindowMonitor.cpp b/src/app-stats/ActiveWindowMonitor.cpp index c8d3120..107d598 100644 --- a/src/app-stats/ActiveWindowMonitor.cpp +++ b/src/app-stats/ActiveWindowMonitor.cpp @@ -85,18 +85,18 @@ void ctx::AppUseMonitor::__createRecord(std::string appId) int mediaVolume; std::string bssid; Json data; - data.set(NULL, STATS_APP_ID, appId); + data.set(NULL, KEY_APP_ID, appId); if (ctx::system_info::getAudioJackState(&audioJack)) - data.set(NULL, STATS_AUDIO_JACK, audioJack); + data.set(NULL, KEY_AUDIO_JACK, audioJack); if (ctx::system_info::getVolume(&systemVolume, &mediaVolume)) { - data.set(NULL, STATS_SYSTEM_VOLUME, systemVolume); - data.set(NULL, STATS_MEDIA_VOLUME, mediaVolume); + data.set(NULL, KEY_SYSTEM_VOLUME, systemVolume); + data.set(NULL, KEY_MEDIA_VOLUME, mediaVolume); } if (ctx::system_info::getWifiBssid(bssid)) - data.set(NULL, STATS_BSSID, bssid); + data.set(NULL, KEY_BSSID, bssid); __dbManager.insert(0, APP_TABLE_USAGE_LOG, data, NULL); } @@ -107,11 +107,11 @@ void ctx::AppUseMonitor::__finishRecord(std::string appId) std::stringstream query; query << "UPDATE " APP_TABLE_USAGE_LOG \ - " SET " STATS_DURATION " = strftime('%s', 'now') - " STATS_UNIV_TIME \ - " WHERE " STATS_COL_ROW_ID " = (" \ - "SELECT MAX(" STATS_COL_ROW_ID ") FROM " APP_TABLE_USAGE_LOG \ - " WHERE " STATS_APP_ID " = '" << appId << "'" \ - " AND " STATS_DURATION " = 0)"; + " SET " KEY_DURATION " = strftime('%s', 'now') - " KEY_UNIV_TIME \ + " WHERE " KEY_COL_ROW_ID " = (" \ + "SELECT MAX(" KEY_COL_ROW_ID ") FROM " APP_TABLE_USAGE_LOG \ + " WHERE " KEY_APP_ID " = '" << appId << "'" \ + " AND " KEY_DURATION " = 0)"; __dbManager.execute(0, query.str().c_str(), NULL); } @@ -143,6 +143,6 @@ void ctx::AppUseMonitor::__removeExpired() std::stringstream query; query << "DELETE FROM " APP_TABLE_USAGE_LOG " WHERE " \ - STATS_UNIV_TIME " < strftime('%s', 'now') - " << LOG_RETENTION_PERIOD; + KEY_UNIV_TIME " < strftime('%s', 'now') - " << LOG_RETENTION_PERIOD; __dbManager.execute(0, query.str().c_str(), NULL); } diff --git a/src/app-stats/AppStatisticsTypes.h b/src/app-stats/AppStatisticsTypes.h index 42b049e..f2ed478 100644 --- a/src/app-stats/AppStatisticsTypes.h +++ b/src/app-stats/AppStatisticsTypes.h @@ -17,7 +17,7 @@ #ifndef _CONTEXT_STATS_APP_TYPES_H_ #define _CONTEXT_STATS_APP_TYPES_H_ -#include "../shared/CommonTypes.h" +#include "../shared/ProviderTypes.h" #define APP_HISTORY_PRIV "apphistory.read" #define APP_SUBJ_LOGGER "stats/app/logger" diff --git a/src/app-stats/DbHandle.cpp b/src/app-stats/DbHandle.cpp index 06021e3..414bac1 100644 --- a/src/app-stats/DbHandle.cpp +++ b/src/app-stats/DbHandle.cpp @@ -71,11 +71,11 @@ std::string AppDbHandle::createWhereClauseWithDeviceStatus(Json filter) whereClause << StatsDbHandleBase::createWhereClause(filter); - if (filter.get(NULL, STATS_BSSID, &bssid)) - whereClause << " AND " STATS_BSSID " = '" << bssid << "'"; + if (filter.get(NULL, KEY_BSSID, &bssid)) + whereClause << " AND " KEY_BSSID " = '" << bssid << "'"; - if (filter.get(NULL, STATS_AUDIO_JACK, &audioJack)) - whereClause << " AND " STATS_AUDIO_JACK " = " << audioJack; + if (filter.get(NULL, KEY_AUDIO_JACK, &audioJack)) + whereClause << " AND " KEY_AUDIO_JACK " = " << audioJack; return whereClause.str(); } @@ -97,16 +97,16 @@ std::string AppDbHandle::createSqlFrequency(Json filter) std::string timeOfDay; std::string appId; - if (!filter.get(NULL, STATS_APP_ID, &appId)) { + if (!filter.get(NULL, KEY_APP_ID, &appId)) { _E("Invalid parameter"); return ""; } - if (filter.get(NULL, STATS_DAY_OF_WEEK, &weekStr)) - filterCleaned.set(NULL, STATS_DAY_OF_WEEK, weekStr); + if (filter.get(NULL, KEY_DAY_OF_WEEK, &weekStr)) + filterCleaned.set(NULL, KEY_DAY_OF_WEEK, weekStr); - if (filter.get(NULL, STATS_TIME_OF_DAY, &timeOfDay)) - filterCleaned.set(NULL, STATS_TIME_OF_DAY, timeOfDay); + if (filter.get(NULL, KEY_TIME_OF_DAY, &timeOfDay)) + filterCleaned.set(NULL, KEY_TIME_OF_DAY, timeOfDay); std::string whereClause = createWhereClause(filterCleaned); @@ -117,21 +117,21 @@ std::string AppDbHandle::createSqlFrequency(Json filter) query << "INSERT INTO " APP_TEMP_USAGE_FREQ \ - " SELECT " STATS_APP_ID ", COUNT(*) AS " STATS_TOTAL_COUNT \ + " SELECT " KEY_APP_ID ", COUNT(*) AS " KEY_TOTAL_COUNT \ " FROM " APP_TABLE_USAGE_LOG \ " WHERE " << whereClause << - " GROUP BY " STATS_APP_ID ";"; + " GROUP BY " KEY_APP_ID ";"; query << - "INSERT OR IGNORE INTO " APP_TEMP_USAGE_FREQ " (" STATS_APP_ID ")" \ + "INSERT OR IGNORE INTO " APP_TEMP_USAGE_FREQ " (" KEY_APP_ID ")" \ " VALUES ('" << appId << "');"; query << - "SELECT S." STATS_APP_ID ", S." STATS_TOTAL_COUNT ", 1+COUNT(lesser." STATS_TOTAL_COUNT ") AS " STATS_RANK \ + "SELECT S." KEY_APP_ID ", S." KEY_TOTAL_COUNT ", 1+COUNT(lesser." KEY_TOTAL_COUNT ") AS " KEY_RANK \ " FROM " APP_TEMP_USAGE_FREQ " AS S" \ " LEFT JOIN " APP_TEMP_USAGE_FREQ " AS lesser" \ - " ON S." STATS_TOTAL_COUNT " < lesser." STATS_TOTAL_COUNT \ - " WHERE S." STATS_APP_ID " = '" << appId << "'"; + " ON S." KEY_TOTAL_COUNT " < lesser." KEY_TOTAL_COUNT \ + " WHERE S." KEY_APP_ID " = '" << appId << "'"; return query.str(); } @@ -141,17 +141,17 @@ std::string AppDbHandle::createSqlRecentlyUsed(Json filter) std::stringstream query; int limit = DEFAULT_LIMIT; - filter.get(NULL, STATS_RESULT_SIZE, &limit); + filter.get(NULL, KEY_RESULT_SIZE, &limit); query << - "SELECT " STATS_APP_ID ", " \ - "COUNT(*) AS " STATS_TOTAL_COUNT ", " \ - "SUM(" STATS_DURATION ") AS " STATS_TOTAL_DURATION ", " \ - "MAX(" STATS_UNIV_TIME ") AS " STATS_LAST_TIME \ + "SELECT " KEY_APP_ID ", " \ + "COUNT(*) AS " KEY_TOTAL_COUNT ", " \ + "SUM(" KEY_DURATION ") AS " KEY_TOTAL_DURATION ", " \ + "MAX(" KEY_UNIV_TIME ") AS " KEY_LAST_TIME \ " FROM " APP_TABLE_USAGE_LOG \ " WHERE " << createWhereClauseWithDeviceStatus(filter) << - " GROUP BY " STATS_APP_ID \ - " ORDER BY MAX(" STATS_UNIV_TIME ") DESC" \ + " GROUP BY " KEY_APP_ID \ + " ORDER BY MAX(" KEY_UNIV_TIME ") DESC" \ " LIMIT " << limit; return query.str(); @@ -162,16 +162,16 @@ std::string AppDbHandle::createSqlFrequentlyUsed(Json filter) std::stringstream query; int limit = DEFAULT_LIMIT; - filter.get(NULL, STATS_RESULT_SIZE, &limit); + filter.get(NULL, KEY_RESULT_SIZE, &limit); query << - "SELECT " STATS_APP_ID ", " \ - "COUNT(*) AS " STATS_TOTAL_COUNT ", " \ - "SUM(" STATS_DURATION ") AS " STATS_TOTAL_DURATION ", " \ - "MAX(" STATS_UNIV_TIME ") AS " STATS_LAST_TIME \ + "SELECT " KEY_APP_ID ", " \ + "COUNT(*) AS " KEY_TOTAL_COUNT ", " \ + "SUM(" KEY_DURATION ") AS " KEY_TOTAL_DURATION ", " \ + "MAX(" KEY_UNIV_TIME ") AS " KEY_LAST_TIME \ " FROM " APP_TABLE_USAGE_LOG \ " WHERE " << createWhereClauseWithDeviceStatus(filter) << - " GROUP BY " STATS_APP_ID \ + " GROUP BY " KEY_APP_ID \ " ORDER BY COUNT(*) DESC" \ " LIMIT " << limit; @@ -183,19 +183,19 @@ std::string AppDbHandle::createSqlRarelyUsed(Json filter) std::stringstream query; int limit = DEFAULT_LIMIT; - filter.get(NULL, STATS_RESULT_SIZE, &limit); + filter.get(NULL, KEY_RESULT_SIZE, &limit); query << - "SELECT i." STATS_APP_ID ", " \ - "COUNT(u." STATS_DURATION ") AS " STATS_TOTAL_COUNT ", " \ - "IFNULL(SUM(u." STATS_DURATION "),0) AS " STATS_TOTAL_DURATION ", " \ - "IFNULL(MAX(u." STATS_UNIV_TIME "),-1) AS " STATS_LAST_TIME \ + "SELECT i." KEY_APP_ID ", " \ + "COUNT(u." KEY_DURATION ") AS " KEY_TOTAL_COUNT ", " \ + "IFNULL(SUM(u." KEY_DURATION "),0) AS " KEY_TOTAL_DURATION ", " \ + "IFNULL(MAX(u." KEY_UNIV_TIME "),-1) AS " KEY_LAST_TIME \ " FROM " APP_TABLE_REMOVABLE_APP " i LEFT OUTER JOIN (" \ " SELECT * FROM " APP_TABLE_USAGE_LOG \ " WHERE " << createWhereClauseWithDeviceStatus(filter) << ") u" \ - " ON i." STATS_APP_ID " = u." STATS_APP_ID \ - " GROUP BY i." STATS_APP_ID \ - " ORDER BY " STATS_TOTAL_COUNT " ASC" \ + " ON i." KEY_APP_ID " = u." KEY_APP_ID \ + " GROUP BY i." KEY_APP_ID \ + " ORDER BY " KEY_TOTAL_COUNT " ASC" \ " LIMIT " << limit; return query.str(); @@ -209,12 +209,12 @@ void AppDbHandle::replyTriggerItem(int error, Json &jsonResult) std::string valStr; int val; - jsonResult.get(NULL, STATS_APP_ID, &valStr); - results.set(NULL, STATS_APP_ID, valStr); - jsonResult.get(NULL, STATS_TOTAL_COUNT, &val); - results.set(NULL, STATS_TOTAL_COUNT, val); - jsonResult.get(NULL, STATS_RANK, &val); - results.set(NULL, STATS_RANK, val); + jsonResult.get(NULL, KEY_APP_ID, &valStr); + results.set(NULL, KEY_APP_ID, valStr); + jsonResult.get(NULL, KEY_TOTAL_COUNT, &val); + results.set(NULL, KEY_TOTAL_COUNT, val); + jsonResult.get(NULL, KEY_RANK, &val); + results.set(NULL, KEY_RANK, val); reqProvider->replyToRead(reqFilter, error, results); } diff --git a/src/app-stats/DbInit.cpp b/src/app-stats/DbInit.cpp index 9c4ec24..652950b 100644 --- a/src/app-stats/DbInit.cpp +++ b/src/app-stats/DbInit.cpp @@ -80,7 +80,7 @@ bool ctx::AppDbInitializer::__appInfoCb(package_info_app_component_type_e compTy Json data; DatabaseManager dbManager; - data.set(NULL, STATS_APP_ID, appId); + data.set(NULL, KEY_APP_ID, appId); return dbManager.insert(0, APP_TABLE_REMOVABLE_APP, data, NULL); } diff --git a/src/app-stats/InstallMonitor.cpp b/src/app-stats/InstallMonitor.cpp index af5169f..a89ce95 100644 --- a/src/app-stats/InstallMonitor.cpp +++ b/src/app-stats/InstallMonitor.cpp @@ -84,7 +84,7 @@ bool ctx::AppInstallMonitor::__appInfoCb(package_info_app_component_type_e compT if (__lastEventType == PACKAGE_MANAGER_EVENT_TYPE_INSTALL) { Json data; - data.set(NULL, STATS_APP_ID, appId); + data.set(NULL, KEY_APP_ID, appId); dbManager.insert(0, APP_TABLE_REMOVABLE_APP, data, NULL); } else if (__lastEventType == PACKAGE_MANAGER_EVENT_TYPE_UNINSTALL) { dbManager.execute(0, __createDeletionQuery(APP_TABLE_REMOVABLE_APP, appId).c_str(), NULL); @@ -98,6 +98,6 @@ std::string ctx::AppInstallMonitor::__createDeletionQuery(const char* tableName, { std::stringstream query; query << "DELETE FROM " << tableName; - query << " WHERE " STATS_APP_ID " = '" << appId << "'"; + query << " WHERE " KEY_APP_ID " = '" << appId << "'"; return query.str(); } diff --git a/src/call/Call.cpp b/src/call/Call.cpp index 616914a..9700fcf 100644 --- a/src/call/Call.cpp +++ b/src/call/Call.cpp @@ -39,7 +39,7 @@ static telephony_noti_e __callNotiIds[] = static Json __latest; SocialStatusCall::SocialStatusCall() : - BasicProvider(SOCIAL_ST_SUBJ_CALL) + BasicProvider(SUBJ_STATE_CALL) { __handleList.count = 0; __handleList.handle = NULL; @@ -82,19 +82,19 @@ void SocialStatusCall::__handleUpdate(telephony_h handle, telephony_noti_e notiI switch (notiId) { case TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE: case TELEPHONY_NOTI_VIDEO_CALL_STATUS_IDLE: - data.set(NULL, SOCIAL_ST_STATE, SOCIAL_ST_IDLE); + data.set(NULL, KEY_STATE, VAL_IDLE); break; case TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE: case TELEPHONY_NOTI_VIDEO_CALL_STATUS_ACTIVE: - data.set(NULL, SOCIAL_ST_STATE, SOCIAL_ST_ACTIVE); + data.set(NULL, KEY_STATE, VAL_ACTIVE); break; case TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING: case TELEPHONY_NOTI_VIDEO_CALL_STATUS_ALERTING: - data.set(NULL, SOCIAL_ST_STATE, SOCIAL_ST_ALERTING); + data.set(NULL, KEY_STATE, VAL_ALERTING); break; case TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING: case TELEPHONY_NOTI_VIDEO_CALL_STATUS_INCOMING: - data.set(NULL, SOCIAL_ST_STATE, SOCIAL_ST_INCOMING); + data.set(NULL, KEY_STATE, VAL_INCOMING); break; /* // Ignore below cases case TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD: @@ -111,13 +111,13 @@ void SocialStatusCall::__handleUpdate(telephony_h handle, telephony_noti_e notiI case TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE: case TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING: case TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING: - data.set(NULL, SOCIAL_ST_TYPE, SOCIAL_ST_VOICE); + data.set(NULL, KEY_TYPE, VAL_VOICE); break; case TELEPHONY_NOTI_VIDEO_CALL_STATUS_IDLE: case TELEPHONY_NOTI_VIDEO_CALL_STATUS_ACTIVE: case TELEPHONY_NOTI_VIDEO_CALL_STATUS_ALERTING: case TELEPHONY_NOTI_VIDEO_CALL_STATUS_INCOMING: - data.set(NULL, SOCIAL_ST_TYPE, SOCIAL_ST_VIDEO); + data.set(NULL, KEY_TYPE, VAL_VIDEO); break; /* // Ignore below cases case TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD: @@ -146,7 +146,7 @@ void SocialStatusCall::__handleUpdate(telephony_h handle, telephony_noti_e notiI // Address std::string address; if (__getCallAddress(callList[i], address)) { - data.set(NULL, SOCIAL_ST_ADDRESS, address); + data.set(NULL, KEY_ADDRESS, address); break; } } @@ -221,22 +221,22 @@ bool SocialStatusCall::__getCallState(telephony_call_h& handle, std::string& sta switch (st) { case TELEPHONY_CALL_STATUS_ACTIVE: - state = SOCIAL_ST_ACTIVE; + state = VAL_ACTIVE; break; case TELEPHONY_CALL_STATUS_HELD: - state = SOCIAL_ST_HELD; + state = VAL_HELD; break; case TELEPHONY_CALL_STATUS_DIALING: - state = SOCIAL_ST_DIALING; + state = VAL_DIALING; break; case TELEPHONY_CALL_STATUS_ALERTING: - state = SOCIAL_ST_ALERTING; + state = VAL_ALERTING; break; case TELEPHONY_CALL_STATUS_INCOMING: - state = SOCIAL_ST_INCOMING; + state = VAL_INCOMING; break; default: - state = SOCIAL_ST_IDLE; + state = VAL_IDLE; } IF_FAIL_RETURN_TAG(!state.empty(), false, _W, "State is empty"); @@ -254,10 +254,10 @@ bool SocialStatusCall::__getCallType(telephony_call_h& handle, std::string& type switch (t) { case TELEPHONY_CALL_TYPE_VOICE: - type = SOCIAL_ST_VOICE; + type = VAL_VOICE; break; case TELEPHONY_CALL_TYPE_VIDEO: - type = SOCIAL_ST_VIDEO; + type = VAL_VIDEO; break; default: _E("Unknown type: %d", t); @@ -316,7 +316,7 @@ bool SocialStatusCall::__readCurrentStatus(telephony_h& handle, Json* data) telephony_call_get_call_list(handle, &count, &callList); // Default data - data->set(NULL, SOCIAL_ST_STATE, SOCIAL_ST_IDLE); + data->set(NULL, KEY_STATE, VAL_IDLE); // Held & Dialing are ignored for (unsigned int i = 0; i < count; i++) { @@ -324,25 +324,25 @@ bool SocialStatusCall::__readCurrentStatus(telephony_h& handle, Json* data) std::string state; if (__getCallState(callList[i], state)) { // Skip Held & Dialing - if (state.compare(SOCIAL_ST_HELD) == 0 || state.compare(SOCIAL_ST_DIALING) == 0) + if (state.compare(VAL_HELD) == 0 || state.compare(VAL_DIALING) == 0) continue; - data->set(NULL, SOCIAL_ST_STATE, state); + data->set(NULL, KEY_STATE, state); } // Call type std::string type; if (__getCallType(callList[i], type)) { - data->set(NULL, SOCIAL_ST_MEDIUM, type); + data->set(NULL, KEY_MEDIUM, type); } // Address std::string address; if (__getCallAddress(callList[i], address)) { - data->set(NULL, SOCIAL_ST_ADDRESS, address); + data->set(NULL, KEY_ADDRESS, address); } - if (state == SOCIAL_ST_ACTIVE) { + if (state == VAL_ACTIVE) { break; } } @@ -361,7 +361,7 @@ int SocialStatusCall::read() bool ret = true; Json data; - data.set(NULL, SOCIAL_ST_STATE, SOCIAL_ST_IDLE); + data.set(NULL, KEY_STATE, VAL_IDLE); for (unsigned int i = 0; i < __handleList.count; i++) { telephony_sim_state_e state; diff --git a/src/call/Call.h b/src/call/Call.h index 23d589d..f76faac 100644 --- a/src/call/Call.h +++ b/src/call/Call.h @@ -18,7 +18,7 @@ #define _CONTEXT_SOCIAL_STATUS_CALL_H_ #include -#include "../shared/SocialTypes.h" +#include "../shared/ProviderTypes.h" #include "../shared/BasicProvider.h" namespace ctx { diff --git a/src/contacts/Contacts.cpp b/src/contacts/Contacts.cpp index 6b195f7..2dc4657 100644 --- a/src/contacts/Contacts.cpp +++ b/src/contacts/Contacts.cpp @@ -23,7 +23,7 @@ using namespace ctx; SocialStatusContacts::SocialStatusContacts() : - BasicProvider(SOCIAL_ST_SUBJ_CONTACTS), + BasicProvider(SUBJ_STATE_CONTACTS), __latestMyProfile(0), __latestPerson(0) { @@ -61,12 +61,12 @@ void SocialStatusContacts::__handleUpdate(const char* viewUri) return; } - std::string view = (STR_EQ(viewUri, _contacts_my_profile._uri)? SOCIAL_ST_MY_PROFILE : SOCIAL_ST_PERSON); + std::string view = (STR_EQ(viewUri, _contacts_my_profile._uri)? VAL_MY_PROFILE : VAL_PERSON); IF_FAIL_VOID_TAG(!__isConsecutiveChange(viewUri), _D, "Ignore consecutive db change: %s", view.c_str()); Json data; - data.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_CHANGED); - data.set(NULL, SOCIAL_ST_TYPE, view); + data.set(NULL, KEY_EVENT, VAL_CHANGED); + data.set(NULL, KEY_TYPE, view); publish(NULL, ERR_NONE, data); } diff --git a/src/contacts/Contacts.h b/src/contacts/Contacts.h index 4211a6c..dcabc2b 100644 --- a/src/contacts/Contacts.h +++ b/src/contacts/Contacts.h @@ -18,7 +18,7 @@ #define _CONTEXT_SOCIAL_STATUS_CONTACTS_H_ #include -#include "../shared/SocialTypes.h" +#include "../shared/ProviderTypes.h" #include "../shared/BasicProvider.h" namespace ctx { diff --git a/src/email/Email.cpp b/src/email/Email.cpp index b6b9721..3dba025 100644 --- a/src/email/Email.cpp +++ b/src/email/Email.cpp @@ -21,7 +21,7 @@ using namespace ctx; SocialStatusEmail::SocialStatusEmail() : - BasicProvider(SOCIAL_ST_SUBJ_EMAIL), + BasicProvider(SUBJ_STATE_EMAIL), __dbusSignalId(-1), __dbusWatcher(DBusType::SESSION) { @@ -59,13 +59,13 @@ void SocialStatusEmail::onSignal(const char* sender, const char* path, const cha //TODO: Check if this signal actually means that there are new mails _D("sub type: %d, gi1: %d, gc: %s, gi2: %d, gi3: %d", subType, gi1, gc, gi2, gi3); Json dataUpdated; - dataUpdated.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_RECEIVED); + dataUpdated.set(NULL, KEY_EVENT, VAL_RECEIVED); publish(NULL, ERR_NONE, dataUpdated); } else if (subType == NOTI_SEND_FINISH) { _D("sub type: %d, gi1: %d, gc: %s, gi2: %d, gi3: %d", subType, gi1, gc, gi2, gi3); Json dataUpdated; - dataUpdated.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_SENT); + dataUpdated.set(NULL, KEY_EVENT, VAL_SENT); publish(NULL, ERR_NONE, dataUpdated); } } diff --git a/src/email/Email.h b/src/email/Email.h index bfd7702..4c52e99 100644 --- a/src/email/Email.h +++ b/src/email/Email.h @@ -18,7 +18,7 @@ #define _CONTEXT_SOCIAL_STATUS_EMAIL_H_ #include -#include "../shared/SocialTypes.h" +#include "../shared/ProviderTypes.h" #include "../shared/BasicProvider.h" namespace ctx { diff --git a/src/headphone/Headphone.cpp b/src/headphone/Headphone.cpp index a8da0ae..c9a9169 100644 --- a/src/headphone/Headphone.cpp +++ b/src/headphone/Headphone.cpp @@ -22,7 +22,7 @@ using namespace ctx; DeviceStatusHeadphone::DeviceStatusHeadphone() : - BasicProvider(DEVICE_ST_SUBJ_HEADPHONE), + BasicProvider(SUBJ_STATE_HEADPHONE), __connected(false), __audioJackState(RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED), __btAudioState(false), @@ -141,18 +141,18 @@ bool DeviceStatusHeadphone::__getCurrentStatus() void DeviceStatusHeadphone::__generateDataPacket(Json* data) { - data->set(NULL, DEVICE_ST_IS_CONNECTED, __connected ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); + data->set(NULL, KEY_IS_CONNECTED, __connected ? VAL_TRUE : VAL_FALSE); switch (__audioJackState) { case RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE: - data->set(NULL, DEVICE_ST_TYPE, DEVICE_ST_NORMAL); + data->set(NULL, KEY_TYPE, VAL_NORMAL); break; case RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_4WIRE: - data->set(NULL, DEVICE_ST_TYPE, DEVICE_ST_HEADSET); + data->set(NULL, KEY_TYPE, VAL_HEADSET); break; default: if (__btAudioState) - data->set(NULL, DEVICE_ST_TYPE, DEVICE_ST_BLUETOOTH); + data->set(NULL, KEY_TYPE, VAL_BLUETOOTH); break; } } diff --git a/src/headphone/Headphone.h b/src/headphone/Headphone.h index 5d88b36..a6c8805 100644 --- a/src/headphone/Headphone.h +++ b/src/headphone/Headphone.h @@ -20,7 +20,7 @@ #include #include #include -#include "../shared/SystemTypes.h" +#include "../shared/ProviderTypes.h" #include "../shared/BasicProvider.h" namespace ctx { diff --git a/src/media-stats/DbHandle.cpp b/src/media-stats/DbHandle.cpp index e8f0f03..fdfadfc 100644 --- a/src/media-stats/DbHandle.cpp +++ b/src/media-stats/DbHandle.cpp @@ -94,17 +94,17 @@ std::string MediaDbHandle::createSqlFrequency(int mediaType, Json filter) std::string weekStr; std::string timeOfDay; - if (filter.get(NULL, STATS_DAY_OF_WEEK, &weekStr)) - filterCleaned.set(NULL, STATS_DAY_OF_WEEK, weekStr); + if (filter.get(NULL, KEY_DAY_OF_WEEK, &weekStr)) + filterCleaned.set(NULL, KEY_DAY_OF_WEEK, weekStr); - if (filter.get(NULL, STATS_TIME_OF_DAY, &timeOfDay)) - filterCleaned.set(NULL, STATS_TIME_OF_DAY, timeOfDay); + if (filter.get(NULL, KEY_TIME_OF_DAY, &timeOfDay)) + filterCleaned.set(NULL, KEY_TIME_OF_DAY, timeOfDay); std::string whereClause = createWhereClause(mediaType, filterCleaned); std::stringstream query; query << - "SELECT IFNULL(COUNT(*),0) AS " STATS_TOTAL_COUNT \ + "SELECT IFNULL(COUNT(*),0) AS " KEY_TOTAL_COUNT \ " FROM " MEDIA_TABLE_NAME \ " WHERE " << whereClause; @@ -119,8 +119,8 @@ void MediaDbHandle::replyTriggerItem(int error, Json &jsonResult) Json results; int val; - jsonResult.get(NULL, STATS_TOTAL_COUNT, &val); - results.set(NULL, STATS_TOTAL_COUNT, val); + jsonResult.get(NULL, KEY_TOTAL_COUNT, &val); + results.set(NULL, KEY_TOTAL_COUNT, val); reqProvider->replyToRead(reqFilter, error, results); } diff --git a/src/media-stats/MediaContentMonitor.cpp b/src/media-stats/MediaContentMonitor.cpp index 78ff0ef..734b64b 100644 --- a/src/media-stats/MediaContentMonitor.cpp +++ b/src/media-stats/MediaContentMonitor.cpp @@ -138,11 +138,11 @@ void ctx::MediaContentMonitor::__insertLog(int mediaType) data.set(NULL, CX_MEDIA_TYPE, mediaType); if (ctx::system_info::getAudioJackState(&audioJack)) - data.set(NULL, STATS_AUDIO_JACK, audioJack); + data.set(NULL, KEY_AUDIO_JACK, audioJack); if (ctx::system_info::getVolume(&systemVolume, &mediaVolume)) { - data.set(NULL, STATS_SYSTEM_VOLUME, systemVolume); - data.set(NULL, STATS_MEDIA_VOLUME, mediaVolume); + data.set(NULL, KEY_SYSTEM_VOLUME, systemVolume); + data.set(NULL, KEY_MEDIA_VOLUME, mediaVolume); } __dbManager.insert(0, MEDIA_TABLE_NAME, data, NULL); diff --git a/src/media-stats/MediaStatisticsTypes.h b/src/media-stats/MediaStatisticsTypes.h index a71e553..e0e0700 100644 --- a/src/media-stats/MediaStatisticsTypes.h +++ b/src/media-stats/MediaStatisticsTypes.h @@ -17,7 +17,7 @@ #ifndef _CONTEXT_STATS_MEDIA_TYPES_H_ #define _CONTEXT_STATS_MEDIA_TYPES_H_ -#include "../shared/CommonTypes.h" +#include "../shared/ProviderTypes.h" #define MEDIA_HISTORY_PRIV "mediahistory.read" #define MEDIA_SUBJ_LOGGER "stats/media/logger" diff --git a/src/message/Message.cpp b/src/message/Message.cpp index d1873e3..7e589f0 100644 --- a/src/message/Message.cpp +++ b/src/message/Message.cpp @@ -22,7 +22,7 @@ using namespace ctx; SocialStatusMessage::SocialStatusMessage() : - BasicProvider(SOCIAL_ST_SUBJ_MESSAGE), + BasicProvider(SUBJ_STATE_MESSAGE), __messageHandle(NULL) { } @@ -75,20 +75,20 @@ void SocialStatusMessage::__handleUpdate(msg_struct_t msg) case MSG_TYPE_SMS_REJECT : case MSG_TYPE_SMS_ETWS_PRIMARY : case MSG_TYPE_SMS : - data.set(NULL, SOCIAL_ST_TYPE, SOCIAL_ST_SMS); + data.set(NULL, KEY_TYPE, VAL_SMS); break; case MSG_TYPE_MMS_NOTI : case MSG_TYPE_MMS_JAVA : case MSG_TYPE_MMS : - data.set(NULL, SOCIAL_ST_TYPE, SOCIAL_ST_MMS); + data.set(NULL, KEY_TYPE, VAL_MMS); break; default : _W("Unknown message type"); return; } - data.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_RECEIVED); - data.set(NULL, SOCIAL_ST_ADDRESS, address); + data.set(NULL, KEY_EVENT, VAL_RECEIVED); + data.set(NULL, KEY_ADDRESS, address); publish(NULL, ERR_NONE, data); } diff --git a/src/message/Message.h b/src/message/Message.h index a272144..4f2514f 100644 --- a/src/message/Message.h +++ b/src/message/Message.h @@ -19,7 +19,7 @@ #include #include -#include "../shared/SocialTypes.h" +#include "../shared/ProviderTypes.h" #include "../shared/BasicProvider.h" namespace ctx { diff --git a/src/shared/CommonTypes.h b/src/shared/CommonTypes.h deleted file mode 100644 index d6673e1..0000000 --- a/src/shared/CommonTypes.h +++ /dev/null @@ -1,79 +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_STATS_COMMON_TYPES_H_ -#define _CONTEXT_STATS_COMMON_TYPES_H_ - -#define LOG_RETENTION_PERIOD 7776000 /* 90 days in secs */ - -#define DEFAULT_TIMESPAN 30 -#define DEFAULT_LIMIT 10 - -#define STATS_QUERY_RESULT "QueryResult" -#define STATS_RESULT_SIZE "ResultSize" -#define STATS_COL_ROW_ID "rowId" - -#define STATS_TIMESPAN "TimeSpan" -#define STATS_START_TIME "StartTime" -#define STATS_END_TIME "EndTime" -#define STATS_LAST_TIME "LastTime" -#define STATS_TOTAL_COUNT "TotalCount" -#define STATS_AVERAGE_COUNT "AvgCount" -#define STATS_DURATION "Duration" -#define STATS_TOTAL_DURATION "TotalDuration" -#define STATS_DAY_OF_WEEK "DayOfWeek" -#define STATS_HOUR_OF_DAY "HourOfDay" -#define STATS_TIME_OF_DAY "TimeOfDay" -#define STATS_TOTAL_COUNT "TotalCount" -#define STATS_APP_ID "AppId" -#define STATS_PKG_ID "PkgId" -#define STATS_AUDIO_JACK "AudioJack" -#define STATS_SYSTEM_VOLUME "SystemVolume" -#define STATS_MEDIA_VOLUME "MediaVolume" -#define STATS_BSSID "BSSID" -#define STATS_UNIV_TIME "UTC" -#define STATS_LOCAL_TIME "LocalTime" -#define STATS_RANK "Rank" - -#define STATS_SUN "Sun" -#define STATS_MON "Mon" -#define STATS_TUE "Tue" -#define STATS_WED "Wed" -#define STATS_THU "Thu" -#define STATS_FRI "Fri" -#define STATS_SAT "Sat" -#define STATS_WEEKDAY "Weekday" -#define STATS_WEEKEND "Weekend" - -enum StatsDayOfWeek_e { - STATS_DAY_OF_WEEK_WEEKDAY = 1, - STATS_DAY_OF_WEEK_WEEKEND, - STATS_DAY_OF_WEEK_ALL, - STATS_DAY_OF_WEEK_SUN, - STATS_DAY_OF_WEEK_MON, - STATS_DAY_OF_WEEK_TUE, - STATS_DAY_OF_WEEK_WED, - STATS_DAY_OF_WEEK_THU, - STATS_DAY_OF_WEEK_FRI, - STATS_DAY_OF_WEEK_SAT, -}; - -#define TRIG_DEF_RANK "\"Rank\":{\"type\":\"integer\",\"min\":1}" -#define TRIG_DEF_TOTAL_COUNT "\"TotalCount\":{\"type\":\"integer\",\"min\":0}" -#define TRIG_DEF_TIME_OF_DAY "\"TimeOfDay\":{\"type\":\"string\"}" -#define TRIG_DEF_DAY_OF_WEEK "\"DayOfWeek\":{\"type\":\"string\",\"values\":[\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\",\"Sun\",\"Weekday\",\"Weekend\"]}" - -#endif /* End of _CONTEXT_STATS_COMMMON_TYPES_ */ diff --git a/src/shared/DbHandleBase.cpp b/src/shared/DbHandleBase.cpp index 979f75b..846265d 100644 --- a/src/shared/DbHandleBase.cpp +++ b/src/shared/DbHandleBase.cpp @@ -16,12 +16,37 @@ #include #include -#include "CommonTypes.h" +#include "ProviderTypes.h" #include "DbHandleBase.h" #define DAY_OF_WEEK(SECOND) "CAST(strftime('%w', " SECOND ", 'unixepoch') AS INTEGER)" #define HOUR_OF_DAY(SECOND) "CAST(strftime('%H', " SECOND ", 'unixepoch') AS INTEGER)" +/* TODO: replace these macros */ +#define STATS_SUN "Sun" +#define STATS_MON "Mon" +#define STATS_TUE "Tue" +#define STATS_WED "Wed" +#define STATS_THU "Thu" +#define STATS_FRI "Fri" +#define STATS_SAT "Sat" +#define STATS_WEEKDAY "Weekday" +#define STATS_WEEKEND "Weekend" + +enum StatsDayOfWeek_e { + STATS_DAY_OF_WEEK_WEEKDAY = 1, + STATS_DAY_OF_WEEK_WEEKEND, + STATS_DAY_OF_WEEK_ALL, + STATS_DAY_OF_WEEK_SUN, + STATS_DAY_OF_WEEK_MON, + STATS_DAY_OF_WEEK_TUE, + STATS_DAY_OF_WEEK_WED, + STATS_DAY_OF_WEEK_THU, + STATS_DAY_OF_WEEK_FRI, + STATS_DAY_OF_WEEK_SAT, +}; + + using namespace ctx; StatsDbHandleBase::StatsDbHandleBase(ContextProvider *provider) : @@ -63,7 +88,7 @@ std::string StatsDbHandleBase::createWhereClause(Json filter) std::string weekStr; std::string timeOfDay; - if (filter.get(NULL, STATS_DAY_OF_WEEK, &weekStr)) { + if (filter.get(NULL, KEY_DAY_OF_WEEK, &weekStr)) { // In case of string (from Trigger) if (weekStr == STATS_WEEKDAY) { week = STATS_DAY_OF_WEEK_WEEKDAY; @@ -94,15 +119,15 @@ std::string StatsDbHandleBase::createWhereClause(Json filter) } } else { // In case of integer (from History) - filter.get(NULL, STATS_DAY_OF_WEEK, &week); + filter.get(NULL, KEY_DAY_OF_WEEK, &week); } switch(week) { case STATS_DAY_OF_WEEK_WEEKDAY: - whereClause << "(" DAY_OF_WEEK(STATS_LOCAL_TIME) " > 0 AND " DAY_OF_WEEK(STATS_LOCAL_TIME) " < 6) AND "; + whereClause << "(" DAY_OF_WEEK(KEY_LOCAL_TIME) " > 0 AND " DAY_OF_WEEK(KEY_LOCAL_TIME) " < 6) AND "; break; case STATS_DAY_OF_WEEK_WEEKEND: - whereClause << "(" DAY_OF_WEEK(STATS_LOCAL_TIME) " = 0 OR " DAY_OF_WEEK(STATS_LOCAL_TIME) " = 6) AND "; + whereClause << "(" DAY_OF_WEEK(KEY_LOCAL_TIME) " = 0 OR " DAY_OF_WEEK(KEY_LOCAL_TIME) " = 6) AND "; break; case STATS_DAY_OF_WEEK_SUN: case STATS_DAY_OF_WEEK_MON: @@ -111,33 +136,33 @@ std::string StatsDbHandleBase::createWhereClause(Json filter) case STATS_DAY_OF_WEEK_THU: case STATS_DAY_OF_WEEK_FRI: case STATS_DAY_OF_WEEK_SAT: - whereClause << DAY_OF_WEEK(STATS_LOCAL_TIME) " = " << week - STATS_DAY_OF_WEEK_SUN << " AND "; + whereClause << DAY_OF_WEEK(KEY_LOCAL_TIME) " = " << week - STATS_DAY_OF_WEEK_SUN << " AND "; break; default: break; } - if (filter.get(NULL, STATS_APP_ID, &appId)) - whereClause << STATS_APP_ID " = '" << appId << "' AND "; + if (filter.get(NULL, KEY_APP_ID, &appId)) + whereClause << KEY_APP_ID " = '" << appId << "' AND "; - if (filter.get(NULL, STATS_START_TIME, &start)) - whereClause << STATS_UNIV_TIME " >= " << start << " AND "; + if (filter.get(NULL, KEY_START_TIME, &start)) + whereClause << KEY_UNIV_TIME " >= " << start << " AND "; - if (filter.get(NULL, STATS_END_TIME, &end)) - whereClause << STATS_UNIV_TIME " <= " << end << " AND "; + if (filter.get(NULL, KEY_END_TIME, &end)) + whereClause << KEY_UNIV_TIME " <= " << end << " AND "; - if (filter.get(NULL, STATS_TIME_OF_DAY, &timeOfDay)) { + if (filter.get(NULL, KEY_TIME_OF_DAY, &timeOfDay)) { size_t pivot = timeOfDay.find('-'); if (pivot != std::string::npos) { std::string from = timeOfDay.substr(0, pivot); std::string to = timeOfDay.substr(pivot + 1); - whereClause << "(" HOUR_OF_DAY(STATS_LOCAL_TIME) " >= " << from \ - << " AND " HOUR_OF_DAY(STATS_LOCAL_TIME) " < " << to << ") AND "; + whereClause << "(" HOUR_OF_DAY(KEY_LOCAL_TIME) " >= " << from \ + << " AND " HOUR_OF_DAY(KEY_LOCAL_TIME) " < " << to << ") AND "; } } - filter.get(NULL, STATS_TIMESPAN, ×pan); - whereClause << STATS_UNIV_TIME " > strftime('%s', 'now', '-" << timespan <<" day')"; + filter.get(NULL, KEY_TIMESPAN, ×pan); + whereClause << KEY_UNIV_TIME " > strftime('%s', 'now', '-" << timespan <<" day')"; return whereClause.str(); } @@ -147,15 +172,15 @@ std::string StatsDbHandleBase::createSqlPeakTime(Json filter, const char* tableN std::stringstream query; int limit = DEFAULT_LIMIT; - filter.get(NULL, STATS_RESULT_SIZE, &limit); + filter.get(NULL, KEY_RESULT_SIZE, &limit); query << "SELECT " \ - HOUR_OF_DAY(STATS_LOCAL_TIME) " AS " STATS_HOUR_OF_DAY ", COUNT(*) AS " STATS_TOTAL_COUNT \ + HOUR_OF_DAY(KEY_LOCAL_TIME) " AS " KEY_HOUR_OF_DAY ", COUNT(*) AS " KEY_TOTAL_COUNT \ " FROM " << tableName << \ " WHERE " << whereClause << \ - " GROUP BY " HOUR_OF_DAY(STATS_LOCAL_TIME) \ - " ORDER BY " STATS_TOTAL_COUNT " DESC" \ + " GROUP BY " HOUR_OF_DAY(KEY_LOCAL_TIME) \ + " ORDER BY " KEY_TOTAL_COUNT " DESC" \ " LIMIT " << limit; return query.str(); @@ -166,24 +191,24 @@ std::string StatsDbHandleBase::createSqlCommonSetting(Json filter, const char* t std::stringstream query; query << - "SELECT ( SELECT " STATS_AUDIO_JACK \ + "SELECT ( SELECT " KEY_AUDIO_JACK \ " FROM " << tableName << \ " WHERE " << whereClause << \ - " GROUP BY " STATS_AUDIO_JACK \ - " ORDER BY count(" STATS_AUDIO_JACK ") DESC" \ - " LIMIT 1 ) AS " STATS_AUDIO_JACK \ - ", ( SELECT " STATS_SYSTEM_VOLUME \ + " GROUP BY " KEY_AUDIO_JACK \ + " ORDER BY count(" KEY_AUDIO_JACK ") DESC" \ + " LIMIT 1 ) AS " KEY_AUDIO_JACK \ + ", ( SELECT " KEY_SYSTEM_VOLUME \ " FROM " << tableName << \ " WHERE " << whereClause << \ - " GROUP BY " STATS_SYSTEM_VOLUME \ - " ORDER BY count(" STATS_SYSTEM_VOLUME ") DESC" \ - " LIMIT 1 ) AS " STATS_SYSTEM_VOLUME \ - ", ( SELECT " STATS_MEDIA_VOLUME \ + " GROUP BY " KEY_SYSTEM_VOLUME \ + " ORDER BY count(" KEY_SYSTEM_VOLUME ") DESC" \ + " LIMIT 1 ) AS " KEY_SYSTEM_VOLUME \ + ", ( SELECT " KEY_MEDIA_VOLUME \ " FROM " << tableName << \ " WHERE " << whereClause << \ - " GROUP BY " STATS_MEDIA_VOLUME \ - " ORDER BY count(" STATS_MEDIA_VOLUME ") DESC" \ - " LIMIT 1 ) AS " STATS_MEDIA_VOLUME; + " GROUP BY " KEY_MEDIA_VOLUME \ + " ORDER BY count(" KEY_MEDIA_VOLUME ") DESC" \ + " LIMIT 1 ) AS " KEY_MEDIA_VOLUME; return query.str(); } @@ -203,7 +228,7 @@ void StatsDbHandleBase::__jsonVectorToArray(std::vector &vecJson, Json &js for(auto vecJsonPos = vecJson.begin(); vecJsonPos != vecJsonEnd; ++vecJsonPos) { Json originJson = *vecJsonPos; - jsonResult.append(NULL, STATS_QUERY_RESULT, originJson); + jsonResult.append(NULL, KEY_QUERY_RESULT, originJson); } } @@ -218,7 +243,7 @@ void StatsDbHandleBase::onExecuted(unsigned int queryId, int error, std::vector< reqProvider->replyToRead(reqFilter, ERR_OPERATION_FAILED, dummy); } } else { - Json results = "{\"" STATS_QUERY_RESULT "\":[]}"; + Json results = "{\"" KEY_QUERY_RESULT "\":[]}"; __jsonVectorToArray(records, results); reqProvider->replyToRead(reqFilter, error, results); } diff --git a/src/shared/DeviceContextProvider.cpp b/src/shared/DeviceContextProvider.cpp index f0a8d79..f1eb8d4 100644 --- a/src/shared/DeviceContextProvider.cpp +++ b/src/shared/DeviceContextProvider.cpp @@ -57,17 +57,17 @@ void registerProvider(const char *subject, const char *privilege) SO_EXPORT bool ctx::initDeviceContextProvider() { - registerProvider(DEVICE_ST_SUBJ_ALARM, NULL); - registerProvider(DEVICE_ST_SUBJ_TIME, NULL); + registerProvider(SUBJ_STATE_ALARM, NULL); + registerProvider(SUBJ_STATE_TIME, NULL); - registerProvider(DEVICE_ST_SUBJ_WIFI, PRIV_NETWORK); - registerProvider(DEVICE_ST_SUBJ_HEADPHONE, NULL); + registerProvider(SUBJ_STATE_WIFI, PRIV_NETWORK); + registerProvider(SUBJ_STATE_HEADPHONE, 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); + registerProvider(SUBJ_STATE_CHARGER, NULL); + registerProvider(SUBJ_STATE_GPS, NULL); + registerProvider(SUBJ_STATE_USB, NULL); + registerProvider(SUBJ_STATE_BATTERY, NULL); + registerProvider(SUBJ_STATE_PSMODE, NULL); registerProvider(CTX_ACTIVITY_SUBJ_STATIONARY, NULL); registerProvider(CTX_ACTIVITY_SUBJ_WALKING, NULL); @@ -75,10 +75,10 @@ SO_EXPORT bool ctx::initDeviceContextProvider() registerProvider(CTX_ACTIVITY_SUBJ_IN_VEHICLE, NULL); #ifdef _MOBILE_ - 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); + registerProvider(SUBJ_STATE_CALL, PRIV_TELEPHONY); + registerProvider(SUBJ_STATE_EMAIL, NULL); + registerProvider(SUBJ_STATE_MESSAGE, PRIV_MESSAGE); + registerProvider(SUBJ_STATE_CONTACTS, PRIV_CONTACT); /* Create context providers, which need to be initiated before being subscribed */ /* diff --git a/src/shared/ProviderTypes.h b/src/shared/ProviderTypes.h new file mode 100644 index 0000000..84f5c68 --- /dev/null +++ b/src/shared/ProviderTypes.h @@ -0,0 +1,134 @@ +/* + * 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_PROVIDER_TYPES_H_ +#define _CONTEXT_PROVIDER_TYPES_H_ + + +/* FW-wide Data Logger Parameters */ +#define LOG_RETENTION_PERIOD 7776000 /* 90 days in secs */ + + +/* FW-wide Default Values */ +#define DEFAULT_TIMESPAN 30 +#define DEFAULT_LIMIT 10 + + +/* Subjects */ +#define SUBJ_STATE_BATTERY "system/battery" +#define SUBJ_STATE_CHARGER "system/charger" +#define SUBJ_STATE_HEADPHONE "system/headphone" +#define SUBJ_STATE_WIFI "system/wifi" +#define SUBJ_STATE_USB "system/usb" +#define SUBJ_STATE_GPS "system/gps" +#define SUBJ_STATE_PSMODE "system/psmode" +#define SUBJ_STATE_ALARM "device/alarm" +#define SUBJ_STATE_TIME "device/time" + +#define SUBJ_STATE_CALL "social/call" +#define SUBJ_STATE_EMAIL "social/email" +#define SUBJ_STATE_MESSAGE "social/message" +#define SUBJ_STATE_CONTACTS "social/contacts" + + +/* Data & Option Keys */ +#define KEY_QUERY_RESULT "QueryResult" +#define KEY_RESULT_SIZE "ResultSize" +#define KEY_COL_ROW_ID "rowId" +#define KEY_TIMESPAN "TimeSpan" +#define KEY_START_TIME "StartTime" +#define KEY_END_TIME "EndTime" +#define KEY_LAST_TIME "LastTime" +#define KEY_TOTAL_COUNT "TotalCount" +#define KEY_AVERAGE_COUNT "AvgCount" +#define KEY_DURATION "Duration" +#define KEY_TOTAL_DURATION "TotalDuration" +#define KEY_DAY_OF_WEEK "DayOfWeek" +#define KEY_HOUR_OF_DAY "HourOfDay" +#define KEY_TIME_OF_DAY "TimeOfDay" +#define KEY_TOTAL_COUNT "TotalCount" +#define KEY_APP_ID "AppId" +#define KEY_PKG_ID "PkgId" +#define KEY_AUDIO_JACK "AudioJack" +#define KEY_SYSTEM_VOLUME "SystemVolume" +#define KEY_MEDIA_VOLUME "MediaVolume" +#define KEY_BSSID "BSSID" +#define KEY_UNIV_TIME "UTC" +#define KEY_LOCAL_TIME "LocalTime" +#define KEY_RANK "Rank" + +#define KEY_EVENT "Event" +#define KEY_STATE "State" +#define KEY_TYPE "Type" +#define KEY_LEVEL "Level" +#define KEY_BSSID "BSSID" +#define KEY_MEDIUM "Medium" +#define KEY_ADDRESS "Address" +#define KEY_IS_CONNECTED "IsConnected" +#define KEY_IS_ENABLED "IsEnabled" +#define KEY_IS_CHARGING "IsCharging" +#define KEY_DETECTED "Detected" +#define KEY_TIME_OF_DAY "TimeOfDay" +#define KEY_DAY_OF_WEEK "DayOfWeek" +#define KEY_DAY_OF_MONTH "DayOfMonth" + + +/* Data & Option Values */ +#define VAL_TRUE 1 +#define VAL_FALSE 0 +#define VAL_ENTER "Enter" +#define VAL_EXIT "Exit" +#define VAL_DISABLED "Disabled" +#define VAL_CONNECTED "Connected" +#define VAL_UNCONNECTED "Unconnected" +#define VAL_SEARCHING "Searching" +#define VAL_EMPTY "Empty" +#define VAL_CRITICAL "Critical" +#define VAL_LOW "Low" +#define VAL_NORMAL "Normal" +#define VAL_HIGH "High" +#define VAL_FULL "Full" +#define VAL_HEADSET "Headset" +#define VAL_BLUETOOTH "Bluetooth" +#define VAL_IDLE "Idle" +#define VAL_CONNECTING "Connecting" +#define VAL_CONNECTED "Connected" +#define VAL_HELD "Held" +#define VAL_DIALING "Dialing" +#define VAL_VOICE "Voice" +#define VAL_VIDEO "Video" +#define VAL_SENT "Sent" +#define VAL_RECEIVED "Received" +#define VAL_SMS "SMS" +#define VAL_MMS "MMS" +#define VAL_MY_PROFILE "MyProfile" +#define VAL_PERSON "Person" +#define VAL_CHANGED "Changed" + +#define VAL_ACTIVE VAL_CONNECTED +#define VAL_ALERTING VAL_CONNECTING +#define VAL_INCOMING VAL_CONNECTING + + +/* Json Formats */ +#define TRIG_DEF_RANK "\"Rank\":{\"type\":\"integer\",\"min\":1}" +#define TRIG_DEF_TOTAL_COUNT "\"TotalCount\":{\"type\":\"integer\",\"min\":0}" +#define TRIG_DEF_TIME_OF_DAY "\"TimeOfDay\":{\"type\":\"string\"}" +#define TRIG_DEF_DAY_OF_WEEK "\"DayOfWeek\":{\"type\":\"string\",\"values\":[\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\",\"Sun\",\"Weekday\",\"Weekend\"]}" +#define TRIG_BOOL_ITEM_DEF(sbj) "\"" sbj "\":{\"type\":\"integer\",\"min\":0,\"max\":1}" + + +#endif /* _CONTEXT_PROVIDER_TYPES_H_ */ diff --git a/src/shared/SocialTypes.h b/src/shared/SocialTypes.h deleted file mode 100644 index 82dccff..0000000 --- a/src/shared/SocialTypes.h +++ /dev/null @@ -1,52 +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_SOCIAL_STATUS_TYPES_H_ -#define _CONTEXT_SOCIAL_STATUS_TYPES_H_ - -// Subject -#define SOCIAL_ST_SUBJ_CALL "social/call" -#define SOCIAL_ST_SUBJ_EMAIL "social/email" -#define SOCIAL_ST_SUBJ_MESSAGE "social/message" -#define SOCIAL_ST_SUBJ_CONTACTS "social/contacts" - -// Data Key -#define SOCIAL_ST_STATE "State" -#define SOCIAL_ST_EVENT "Event" -#define SOCIAL_ST_TYPE "Type" -#define SOCIAL_ST_MEDIUM "Medium" -#define SOCIAL_ST_ADDRESS "Address" - -// Data Values -#define SOCIAL_ST_IDLE "Idle" -#define SOCIAL_ST_CONNECTING "Connecting" -#define SOCIAL_ST_CONNECTED "Connected" -#define SOCIAL_ST_ACTIVE SOCIAL_ST_CONNECTED -#define SOCIAL_ST_HELD "Held" -#define SOCIAL_ST_DIALING "Dialing" -#define SOCIAL_ST_ALERTING SOCIAL_ST_CONNECTING -#define SOCIAL_ST_INCOMING SOCIAL_ST_CONNECTING -#define SOCIAL_ST_VOICE "Voice" -#define SOCIAL_ST_VIDEO "Video" -#define SOCIAL_ST_SENT "Sent" -#define SOCIAL_ST_RECEIVED "Received" -#define SOCIAL_ST_SMS "SMS" -#define SOCIAL_ST_MMS "MMS" -#define SOCIAL_ST_MY_PROFILE "MyProfile" -#define SOCIAL_ST_PERSON "Person" -#define SOCIAL_ST_CHANGED "Changed" - -#endif //_CONTEXT_SOCIAL_STATUS_TYPES_H diff --git a/src/shared/SystemTypes.h b/src/shared/SystemTypes.h deleted file mode 100644 index 3129a36..0000000 --- a/src/shared/SystemTypes.h +++ /dev/null @@ -1,65 +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 _DEVICE_SYSTEM_STATUS_TYPES_H_ -#define _DEVICE_SYSTEM_STATUS_TYPES_H_ - -// Subject -#define DEVICE_ST_SUBJ_BATTERY "system/battery" -#define DEVICE_ST_SUBJ_CHARGER "system/charger" -#define DEVICE_ST_SUBJ_HEADPHONE "system/headphone" -#define DEVICE_ST_SUBJ_WIFI "system/wifi" -#define DEVICE_ST_SUBJ_USB "system/usb" -#define DEVICE_ST_SUBJ_GPS "system/gps" -#define DEVICE_ST_SUBJ_PSMODE "system/psmode" -#define DEVICE_ST_SUBJ_ALARM "device/alarm" -#define DEVICE_ST_SUBJ_TIME "device/time" - -// Data Key -#define DEVICE_ST_EVENT "Event" -#define DEVICE_ST_STATE "State" -#define DEVICE_ST_TYPE "Type" -#define DEVICE_ST_LEVEL "Level" -#define DEVICE_ST_BSSID "BSSID" -#define DEVICE_ST_IS_CONNECTED "IsConnected" -#define DEVICE_ST_IS_ENABLED "IsEnabled" -#define DEVICE_ST_IS_CHARGING "IsCharging" -#define DEVICE_ST_DETECTED "Detected" -#define DEVICE_ST_TIME_OF_DAY "TimeOfDay" -#define DEVICE_ST_DAY_OF_WEEK "DayOfWeek" -#define DEVICE_ST_DAY_OF_MONTH "DayOfMonth" - -// Data Value -#define DEVICE_ST_TRUE 1 -#define DEVICE_ST_FALSE 0 -#define DEVICE_ST_ENTER "Enter" -#define DEVICE_ST_EXIT "Exit" -#define DEVICE_ST_DISABLED "Disabled" -#define DEVICE_ST_CONNECTED "Connected" -#define DEVICE_ST_UNCONNECTED "Unconnected" -#define DEVICE_ST_SEARCHING "Searching" -#define DEVICE_ST_EMPTY "Empty" -#define DEVICE_ST_CRITICAL "Critical" -#define DEVICE_ST_LOW "Low" -#define DEVICE_ST_NORMAL "Normal" -#define DEVICE_ST_HIGH "High" -#define DEVICE_ST_FULL "Full" -#define DEVICE_ST_HEADSET "Headset" -#define DEVICE_ST_BLUETOOTH "Bluetooth" - -#define TRIG_BOOL_ITEM_DEF(sbj) "\"" sbj "\":{\"type\":\"integer\",\"min\":0,\"max\":1}" - -#endif //_DEVICE_SYSTEM_STATUS_TYPES_H_ diff --git a/src/social-stats/DbHandle.cpp b/src/social-stats/DbHandle.cpp index 5c1c0a6..7e1b6cc 100644 --- a/src/social-stats/DbHandle.cpp +++ b/src/social-stats/DbHandle.cpp @@ -84,13 +84,13 @@ std::string SocialDbHandle::createSqlFreqAddress(Json filter) std::stringstream query; int limit = DEFAULT_LIMIT; - filter.get(NULL, STATS_RESULT_SIZE, &limit); + filter.get(NULL, KEY_RESULT_SIZE, &limit); query << "SELECT " SOCIAL_ADDRESS ", " \ - "COUNT(*) AS " STATS_TOTAL_COUNT ", " \ - "SUM(" STATS_DURATION ") AS " STATS_TOTAL_DURATION ", " \ - "MAX(" STATS_UNIV_TIME ") AS " STATS_LAST_TIME \ + "COUNT(*) AS " KEY_TOTAL_COUNT ", " \ + "SUM(" KEY_DURATION ") AS " KEY_TOTAL_DURATION ", " \ + "MAX(" KEY_UNIV_TIME ") AS " KEY_LAST_TIME \ " FROM " SOCIAL_TABLE_CONTACT_LOG \ " WHERE " << createWhereClause(filter) << " GROUP BY " SOCIAL_ADDRESS \ @@ -112,11 +112,11 @@ std::string SocialDbHandle::createSqlFrequency(Json filter) return ""; } - if (filter.get(NULL, STATS_DAY_OF_WEEK, &weekStr)) - filterCleaned.set(NULL, STATS_DAY_OF_WEEK, weekStr); + if (filter.get(NULL, KEY_DAY_OF_WEEK, &weekStr)) + filterCleaned.set(NULL, KEY_DAY_OF_WEEK, weekStr); - if (filter.get(NULL, STATS_TIME_OF_DAY, &timeOfDay)) - filterCleaned.set(NULL, STATS_TIME_OF_DAY, timeOfDay); + if (filter.get(NULL, KEY_TIME_OF_DAY, &timeOfDay)) + filterCleaned.set(NULL, KEY_TIME_OF_DAY, timeOfDay); std::stringstream query; @@ -125,7 +125,7 @@ std::string SocialDbHandle::createSqlFrequency(Json filter) query << "INSERT INTO " SOCIAL_TEMP_CONTACT_FREQ \ - " SELECT " SOCIAL_ADDRESS ", COUNT(*) AS " STATS_TOTAL_COUNT \ + " SELECT " SOCIAL_ADDRESS ", COUNT(*) AS " KEY_TOTAL_COUNT \ " FROM " SOCIAL_TABLE_CONTACT_LOG \ " WHERE " << createWhereClause(filterCleaned) << " GROUP BY " SOCIAL_ADDRESS ";"; @@ -135,10 +135,10 @@ std::string SocialDbHandle::createSqlFrequency(Json filter) " VALUES ('" << address << "');"; query << - "SELECT S." SOCIAL_ADDRESS ", S." STATS_TOTAL_COUNT ", 1+COUNT(lesser." STATS_TOTAL_COUNT ") AS " STATS_RANK \ + "SELECT S." SOCIAL_ADDRESS ", S." KEY_TOTAL_COUNT ", 1+COUNT(lesser." KEY_TOTAL_COUNT ") AS " KEY_RANK \ " FROM " SOCIAL_TEMP_CONTACT_FREQ " AS S" \ " LEFT JOIN " SOCIAL_TEMP_CONTACT_FREQ " AS lesser" \ - " ON S." STATS_TOTAL_COUNT " < lesser." STATS_TOTAL_COUNT \ + " ON S." KEY_TOTAL_COUNT " < lesser." KEY_TOTAL_COUNT \ " WHERE S." SOCIAL_ADDRESS " = '" << address << "'"; @@ -155,10 +155,10 @@ void SocialDbHandle::replyTriggerItem(int error, Json &jsonResult) jsonResult.get(NULL, SOCIAL_ADDRESS, &valStr); results.set(NULL, SOCIAL_ADDRESS, valStr); - jsonResult.get(NULL, STATS_TOTAL_COUNT, &val); - results.set(NULL, STATS_TOTAL_COUNT, val); - jsonResult.get(NULL, STATS_RANK, &val); - results.set(NULL, STATS_RANK, val); + jsonResult.get(NULL, KEY_TOTAL_COUNT, &val); + results.set(NULL, KEY_TOTAL_COUNT, val); + jsonResult.get(NULL, KEY_RANK, &val); + results.set(NULL, KEY_RANK, val); reqProvider->replyToRead(reqFilter, error, results); } diff --git a/src/social-stats/LogAggregator.cpp b/src/social-stats/LogAggregator.cpp index dac092d..2fc9608 100644 --- a/src/social-stats/LogAggregator.cpp +++ b/src/social-stats/LogAggregator.cpp @@ -53,7 +53,7 @@ bool ctx::ContactLogAggregator::onTimerExpired(int timerId) void ctx::ContactLogAggregator::aggregateContactLog() { __dbManager.execute(0, - "SELECT IFNULL(MAX(" STATS_UNIV_TIME "),0) AS " STATS_LAST_TIME \ + "SELECT IFNULL(MAX(" KEY_UNIV_TIME "),0) AS " KEY_LAST_TIME \ ", (strftime('%s', 'now', 'localtime')) - (strftime('%s', 'now')) AS " TIME_DIFFERENCE \ " FROM " SOCIAL_TABLE_CONTACT_LOG, this); } @@ -63,7 +63,7 @@ void ctx::ContactLogAggregator::onExecuted(unsigned int queryId, int error, std: IF_FAIL_VOID_TAG(!records.empty(), _E, "Invalid query result"); int lastTime = 0; - records[0].get(NULL, STATS_LAST_TIME, &lastTime); + records[0].get(NULL, KEY_LAST_TIME, &lastTime); records[0].get(NULL, TIME_DIFFERENCE, &__timeDiff); _D("Last Time: %d / Local - UTC: %d", lastTime, __timeDiff); @@ -149,9 +149,9 @@ void ctx::ContactLogAggregator::__insertContactLogList(contacts_list_h list) data.set(NULL, SOCIAL_ADDRESS, address); data.set(NULL, SOCIAL_PHONE_LOG_TYPE, logType); - data.set(NULL, STATS_DURATION, duration); - data.set(NULL, STATS_UNIV_TIME, accessTime); - data.set(NULL, STATS_LOCAL_TIME, accessTime + __timeDiff); + data.set(NULL, KEY_DURATION, duration); + data.set(NULL, KEY_UNIV_TIME, accessTime); + data.set(NULL, KEY_LOCAL_TIME, accessTime + __timeDiff); __dbManager.insert(0, SOCIAL_TABLE_CONTACT_LOG, data, NULL); @@ -162,6 +162,6 @@ void ctx::ContactLogAggregator::__removeExpiredLog() { std::stringstream query; query << "DELETE FROM " SOCIAL_TABLE_CONTACT_LOG " WHERE " \ - STATS_UNIV_TIME " < strftime('%s', 'now') - " << LOG_RETENTION_PERIOD; + KEY_UNIV_TIME " < strftime('%s', 'now') - " << LOG_RETENTION_PERIOD; __dbManager.execute(0, query.str().c_str(), NULL); } diff --git a/src/social-stats/SocialStatisticsTypes.h b/src/social-stats/SocialStatisticsTypes.h index 7c68b93..845f577 100644 --- a/src/social-stats/SocialStatisticsTypes.h +++ b/src/social-stats/SocialStatisticsTypes.h @@ -17,7 +17,7 @@ #ifndef _CONTEXT_STATS_SOCIAL_TYPES_H_ #define _CONTEXT_STATS_SOCIAL_TYPES_H_ -#include "../shared/CommonTypes.h" +#include "../shared/ProviderTypes.h" #define SOCIAL_HISTORY_PRIV "callhistory.read" #define SOCIAL_SUBJ_LOGGER "stats/contact/logger" diff --git a/src/system/Battery.cpp b/src/system/Battery.cpp index e86a595..b2d36a4 100644 --- a/src/system/Battery.cpp +++ b/src/system/Battery.cpp @@ -19,7 +19,7 @@ using namespace ctx; DeviceStatusBattery::DeviceStatusBattery() - : BasicProvider(DEVICE_ST_SUBJ_BATTERY) + : BasicProvider(SUBJ_STATE_BATTERY) { } @@ -58,13 +58,13 @@ void DeviceStatusBattery::__handleUpdate(device_callback_e deviceType, void* val IF_FAIL_VOID(levelString); Json dataRead; - dataRead.set(NULL, DEVICE_ST_LEVEL, levelString); + dataRead.set(NULL, KEY_LEVEL, levelString); bool chargingState = false; int ret = device_battery_is_charging(&chargingState); IF_FAIL_VOID_TAG(ret == DEVICE_ERROR_NONE, _E, "Getting state failed"); - dataRead.set(NULL, DEVICE_ST_IS_CHARGING, chargingState ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); + dataRead.set(NULL, KEY_IS_CHARGING, chargingState ? VAL_TRUE : VAL_FALSE); publish(NULL, ERR_NONE, dataRead); } @@ -72,16 +72,16 @@ const char* DeviceStatusBattery::__transToString(intptr_t level) { switch (level) { case DEVICE_BATTERY_LEVEL_EMPTY: - return DEVICE_ST_EMPTY; + return VAL_EMPTY; case DEVICE_BATTERY_LEVEL_CRITICAL: - return DEVICE_ST_CRITICAL; + return VAL_CRITICAL; case DEVICE_BATTERY_LEVEL_LOW: - return DEVICE_ST_LOW; + return VAL_LOW; case DEVICE_BATTERY_LEVEL_HIGH: - return DEVICE_ST_NORMAL; + return VAL_NORMAL; case DEVICE_BATTERY_LEVEL_FULL: { @@ -89,9 +89,9 @@ const char* DeviceStatusBattery::__transToString(intptr_t level) device_battery_get_percent(&percent); if (percent == 100) { - return DEVICE_ST_FULL; + return VAL_FULL; } else { - return DEVICE_ST_HIGH; + return VAL_HIGH; } break; } @@ -127,13 +127,13 @@ int DeviceStatusBattery::read() const char* levelString = __transToString(level); IF_FAIL_RETURN(levelString, ERR_OPERATION_FAILED); - dataRead.set(NULL, DEVICE_ST_LEVEL, levelString); + dataRead.set(NULL, KEY_LEVEL, levelString); bool chargingState = false; ret = device_battery_is_charging(&chargingState); IF_FAIL_RETURN(ret == DEVICE_ERROR_NONE, ERR_OPERATION_FAILED); - dataRead.set(NULL, DEVICE_ST_IS_CHARGING, chargingState ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); + dataRead.set(NULL, KEY_IS_CHARGING, chargingState ? VAL_TRUE : VAL_FALSE); replyToRead(NULL, ERR_NONE, dataRead); return ERR_NONE; diff --git a/src/system/Battery.h b/src/system/Battery.h index 40e4ce0..fab5a3c 100644 --- a/src/system/Battery.h +++ b/src/system/Battery.h @@ -19,7 +19,7 @@ #include #include -#include "../shared/SystemTypes.h" +#include "../shared/ProviderTypes.h" #include "../shared/BasicProvider.h" namespace ctx { diff --git a/src/system/Charger.cpp b/src/system/Charger.cpp index 5703747..8142bb4 100644 --- a/src/system/Charger.cpp +++ b/src/system/Charger.cpp @@ -19,7 +19,7 @@ using namespace ctx; DeviceStatusCharger::DeviceStatusCharger() : - DeviceStatusRuntimeInfo(DEVICE_ST_SUBJ_CHARGER, RUNTIME_INFO_KEY_CHARGER_CONNECTED) + DeviceStatusRuntimeInfo(SUBJ_STATE_CHARGER, RUNTIME_INFO_KEY_CHARGER_CONNECTED) { } @@ -46,7 +46,7 @@ void DeviceStatusCharger::handleUpdate() IF_FAIL_VOID_TAG(ret == RUNTIME_INFO_ERROR_NONE, _E, "Getting runtime info failed"); Json dataRead; - dataRead.set(NULL, DEVICE_ST_IS_CONNECTED, chargerStatus ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); + dataRead.set(NULL, KEY_IS_CONNECTED, chargerStatus ? VAL_TRUE : VAL_FALSE); publish(NULL, ERR_NONE, dataRead); } @@ -59,7 +59,7 @@ int DeviceStatusCharger::read() int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &chargerStatus); IF_FAIL_RETURN_TAG(ret == RUNTIME_INFO_ERROR_NONE, ERR_OPERATION_FAILED, _E, "Getting runtime info failed"); - dataRead.set(NULL, DEVICE_ST_IS_CONNECTED, chargerStatus ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); + dataRead.set(NULL, KEY_IS_CONNECTED, chargerStatus ? VAL_TRUE : VAL_FALSE); replyToRead(NULL, ERR_NONE, dataRead); return ERR_NONE; diff --git a/src/system/Gps.cpp b/src/system/Gps.cpp index fb01f9d..47b08d0 100644 --- a/src/system/Gps.cpp +++ b/src/system/Gps.cpp @@ -23,13 +23,13 @@ static const char* __getStatusString(int gpsStatus) { switch (gpsStatus) { case RUNTIME_INFO_GPS_STATUS_DISABLED: - return DEVICE_ST_DISABLED; + return VAL_DISABLED; case RUNTIME_INFO_GPS_STATUS_SEARCHING: - return DEVICE_ST_SEARCHING; + return VAL_SEARCHING; case RUNTIME_INFO_GPS_STATUS_CONNECTED: - return DEVICE_ST_CONNECTED; + return VAL_CONNECTED; default: _E("Unknown GPS status: %d", gpsStatus); @@ -38,7 +38,7 @@ static const char* __getStatusString(int gpsStatus) } DeviceStatusGps::DeviceStatusGps() : - DeviceStatusRuntimeInfo(DEVICE_ST_SUBJ_GPS, RUNTIME_INFO_KEY_GPS_STATUS) + DeviceStatusRuntimeInfo(SUBJ_STATE_GPS, RUNTIME_INFO_KEY_GPS_STATUS) { } @@ -71,7 +71,7 @@ void DeviceStatusGps::handleUpdate() const char* stateStr = __getStatusString(gpsStatus); IF_FAIL_VOID(stateStr); - dataRead.set(NULL, DEVICE_ST_STATE, stateStr); + dataRead.set(NULL, KEY_STATE, stateStr); publish(NULL, ERR_NONE, dataRead); } @@ -87,7 +87,7 @@ int DeviceStatusGps::read() const char* stateStr = __getStatusString(gpsStatus); IF_FAIL_RETURN(stateStr, ERR_OPERATION_FAILED); - dataRead.set(NULL, DEVICE_ST_STATE, stateStr); + dataRead.set(NULL, KEY_STATE, stateStr); replyToRead(NULL, ERR_NONE, dataRead); return ERR_NONE; diff --git a/src/system/Psmode.cpp b/src/system/Psmode.cpp index cc0cf30..c6d80ea 100644 --- a/src/system/Psmode.cpp +++ b/src/system/Psmode.cpp @@ -19,7 +19,7 @@ using namespace ctx; DeviceStatusPsmode::DeviceStatusPsmode() : - BasicProvider(DEVICE_ST_SUBJ_PSMODE) + BasicProvider(SUBJ_STATE_PSMODE) { } @@ -52,7 +52,7 @@ void DeviceStatusPsmode::__handleUpdate(keynode_t *node) status = vconf_keynode_get_int(node); IF_FAIL_VOID_TAG(status >= 0, _E, "Getting state failed"); - dataRead.set(NULL, DEVICE_ST_IS_ENABLED, status == 0 ? DEVICE_ST_FALSE : DEVICE_ST_TRUE); + dataRead.set(NULL, KEY_IS_ENABLED, status == 0 ? VAL_FALSE : VAL_TRUE); publish(NULL, ERR_NONE, dataRead); } @@ -78,7 +78,7 @@ int DeviceStatusPsmode::read() IF_FAIL_RETURN(ret == VCONF_OK, ERR_OPERATION_FAILED); Json dataRead; - dataRead.set(NULL, DEVICE_ST_IS_ENABLED, mode == 0 ? DEVICE_ST_FALSE : DEVICE_ST_TRUE); + dataRead.set(NULL, KEY_IS_ENABLED, mode == 0 ? VAL_FALSE : VAL_TRUE); replyToRead(NULL, ERR_NONE, dataRead); return ERR_NONE; diff --git a/src/system/Psmode.h b/src/system/Psmode.h index 78ec7ec..f821bd3 100644 --- a/src/system/Psmode.h +++ b/src/system/Psmode.h @@ -18,7 +18,7 @@ #define _DEVICE_SYSTEM_STATUS_POWER_SAVING_MODE_H_ #include -#include "../shared/SystemTypes.h" +#include "../shared/ProviderTypes.h" #include "../shared/BasicProvider.h" namespace ctx { diff --git a/src/system/RuntimeInfoBase.h b/src/system/RuntimeInfoBase.h index c99f462..2ff12a7 100644 --- a/src/system/RuntimeInfoBase.h +++ b/src/system/RuntimeInfoBase.h @@ -18,7 +18,7 @@ #define _DEVICE_SYSTEM_STATUS_RUNTIME_INFO_BASE_H_ #include -#include "../shared/SystemTypes.h" +#include "../shared/ProviderTypes.h" #include "../shared/BasicProvider.h" namespace ctx { diff --git a/src/system/Usb.cpp b/src/system/Usb.cpp index 935aaeb..6c9b087 100644 --- a/src/system/Usb.cpp +++ b/src/system/Usb.cpp @@ -20,7 +20,7 @@ using namespace ctx; DeviceStatusUsb::DeviceStatusUsb() : - DeviceStatusRuntimeInfo(DEVICE_ST_SUBJ_USB, RUNTIME_INFO_KEY_USB_CONNECTED) + DeviceStatusRuntimeInfo(SUBJ_STATE_USB, RUNTIME_INFO_KEY_USB_CONNECTED) { } @@ -47,7 +47,7 @@ void DeviceStatusUsb::handleUpdate() IF_FAIL_VOID_TAG(ret == RUNTIME_INFO_ERROR_NONE, _E, "Getting runtime info failed"); Json dataRead; - dataRead.set(NULL, DEVICE_ST_IS_CONNECTED, status ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); + dataRead.set(NULL, KEY_IS_CONNECTED, status ? VAL_TRUE : VAL_FALSE); publish(NULL, ERR_NONE, dataRead); } @@ -60,7 +60,7 @@ int DeviceStatusUsb::read() int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_USB_CONNECTED, &status); IF_FAIL_RETURN_TAG(ret == RUNTIME_INFO_ERROR_NONE, ERR_OPERATION_FAILED, _E, "Getting runtime info failed"); - dataRead.set(NULL, DEVICE_ST_IS_CONNECTED, status ? DEVICE_ST_TRUE : DEVICE_ST_FALSE); + dataRead.set(NULL, KEY_IS_CONNECTED, status ? VAL_TRUE : VAL_FALSE); replyToRead(NULL, ERR_NONE, dataRead); return ERR_NONE; diff --git a/src/time/Alarm.cpp b/src/time/Alarm.cpp index 26bac0b..8c3740a 100644 --- a/src/time/Alarm.cpp +++ b/src/time/Alarm.cpp @@ -19,7 +19,7 @@ using namespace ctx; DeviceStatusAlarm::DeviceStatusAlarm() - : ContextProvider(DEVICE_ST_SUBJ_ALARM) + : ContextProvider(SUBJ_STATE_ALARM) { } @@ -53,7 +53,7 @@ int DeviceStatusAlarm::subscribe(Json option, Json *requestResult) int dow = __getArrangedDayOfWeek(option); int time; - for (int i = 0; option.getAt(NULL, DEVICE_ST_TIME_OF_DAY, i, &time); i++) { + for (int i = 0; option.getAt(NULL, KEY_TIME_OF_DAY, i, &time); i++) { __add(time, dow); } @@ -74,7 +74,7 @@ int DeviceStatusAlarm::unsubscribe(Json option) int dow = __getArrangedDayOfWeek(option); int time; - for (int i = 0; option.getAt(NULL, DEVICE_ST_TIME_OF_DAY, i, &time); i++) { + for (int i = 0; option.getAt(NULL, KEY_TIME_OF_DAY, i, &time); i++) { __remove(time, dow); } @@ -92,7 +92,7 @@ int DeviceStatusAlarm::__getArrangedDayOfWeek(Json& option) int dow = 0; std::string tempDay; - for (int i = 0; option.getAt(NULL, DEVICE_ST_DAY_OF_WEEK, i, &tempDay); i++) { + for (int i = 0; option.getAt(NULL, KEY_DAY_OF_WEEK, i, &tempDay); i++) { dow |= TimerManager::dowToInt(tempDay); } _D("Requested day of week (%#x)", dow); @@ -226,8 +226,8 @@ void DeviceStatusAlarm::__handleUpdate(int hour, int min, int dayOfWeek) Json dataRead; int resultTime = hour * 60 + min; std::string resultDay = TimerManager::dowToStr(dayOfWeek); - dataRead.set(NULL, DEVICE_ST_TIME_OF_DAY, resultTime); - dataRead.set(NULL, DEVICE_ST_DAY_OF_WEEK, resultDay); + dataRead.set(NULL, KEY_TIME_OF_DAY, resultTime); + dataRead.set(NULL, KEY_DAY_OF_WEEK, resultDay); for (auto it = __optionSet.begin(); it != __optionSet.end(); ++it) { Json option = (**it); @@ -241,7 +241,7 @@ bool DeviceStatusAlarm::__isMatched(Json& option, int time, std::string day) { bool ret = false; int optionTime; - for (int i = 0; option.getAt(NULL, DEVICE_ST_TIME_OF_DAY, i, &optionTime); i++){ + for (int i = 0; option.getAt(NULL, KEY_TIME_OF_DAY, i, &optionTime); i++){ if (time == optionTime) { ret = true; break; @@ -250,7 +250,7 @@ bool DeviceStatusAlarm::__isMatched(Json& option, int time, std::string day) IF_FAIL_RETURN(ret, false); std::string optionDay; - for (int i = 0; option.getAt(NULL, DEVICE_ST_DAY_OF_WEEK, i, &optionDay); i++){ + for (int i = 0; option.getAt(NULL, KEY_DAY_OF_WEEK, i, &optionDay); i++){ if (day == optionDay) { return true; } diff --git a/src/time/Alarm.h b/src/time/Alarm.h index 797e62f..85b6419 100644 --- a/src/time/Alarm.h +++ b/src/time/Alarm.h @@ -21,7 +21,7 @@ #include #include #include -#include "../shared/SystemTypes.h" +#include "../shared/ProviderTypes.h" namespace ctx { diff --git a/src/time/Time.cpp b/src/time/Time.cpp index d4ba82f..770c560 100644 --- a/src/time/Time.cpp +++ b/src/time/Time.cpp @@ -20,7 +20,7 @@ using namespace ctx; DeviceStatusTime::DeviceStatusTime() : - BasicProvider(DEVICE_ST_SUBJ_TIME) + BasicProvider(SUBJ_STATE_TIME) { } @@ -68,9 +68,9 @@ int DeviceStatusTime::read() std::string dayOfWeek = TimerManager::dowToStr(0x01 << timeInfo.tm_wday); Json dataRead; - dataRead.set(NULL, DEVICE_ST_DAY_OF_MONTH, dayOfMonth); - dataRead.set(NULL, DEVICE_ST_DAY_OF_WEEK, dayOfWeek); - dataRead.set(NULL, DEVICE_ST_TIME_OF_DAY, minuteOfDay); + dataRead.set(NULL, KEY_DAY_OF_MONTH, dayOfMonth); + dataRead.set(NULL, KEY_DAY_OF_WEEK, dayOfWeek); + dataRead.set(NULL, KEY_TIME_OF_DAY, minuteOfDay); _I("Time: %02d:%02d, Day of Week: %s, Day of Month: %d", timeInfo.tm_hour, timeInfo.tm_min, dayOfWeek.c_str(), dayOfMonth); diff --git a/src/time/Time.h b/src/time/Time.h index 9562723..ac1862f 100644 --- a/src/time/Time.h +++ b/src/time/Time.h @@ -18,7 +18,7 @@ #define _DEVICE_SYSTEM_STATUS_TIME_H_ #include "../shared/BasicProvider.h" -#include "../shared/SystemTypes.h" +#include "../shared/ProviderTypes.h" namespace ctx { diff --git a/src/wifi/Wifi.cpp b/src/wifi/Wifi.cpp index f5f2b49..f70d59c 100644 --- a/src/wifi/Wifi.cpp +++ b/src/wifi/Wifi.cpp @@ -21,7 +21,7 @@ using namespace ctx; DeviceStatusWifi::DeviceStatusWifi() : - BasicProvider(DEVICE_ST_SUBJ_WIFI), + BasicProvider(SUBJ_STATE_WIFI), __lastState(UNKNOWN), __isInitialized(false), __isActivated(false), @@ -124,16 +124,16 @@ bool DeviceStatusWifi::__getResponsePacket(Json* data) { switch (__lastState) { case DISABLED: - data->set(NULL, DEVICE_ST_STATE, DEVICE_ST_DISABLED); + data->set(NULL, KEY_STATE, VAL_DISABLED); break; case UNCONNECTED: - data->set(NULL, DEVICE_ST_STATE, DEVICE_ST_UNCONNECTED); + data->set(NULL, KEY_STATE, VAL_UNCONNECTED); break; case CONNECTED: - data->set(NULL, DEVICE_ST_STATE, DEVICE_ST_CONNECTED); - data->set(NULL, DEVICE_ST_BSSID, __bssid); + data->set(NULL, KEY_STATE, VAL_CONNECTED); + data->set(NULL, KEY_BSSID, __bssid); break; default: diff --git a/src/wifi/Wifi.h b/src/wifi/Wifi.h index 7fbe2f2..35574b0 100644 --- a/src/wifi/Wifi.h +++ b/src/wifi/Wifi.h @@ -20,7 +20,7 @@ #include #include #include "../shared/BasicProvider.h" -#include "../shared/SystemTypes.h" +#include "../shared/ProviderTypes.h" namespace ctx { -- 2.7.4 From 835507edd9ccb9573149ffd30e1dc04822e8d78b Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 21 Apr 2016 16:20:58 +0900 Subject: [PATCH 09/16] Code cleanup: merge activity-related macros into ProviderTypes.h Change-Id: I79350b4d5e3894a8b134357884dca6bc9c918033 Signed-off-by: Mu-Woong Lee --- src/activity/Activity.cpp | 8 ++++---- src/activity/Activity.h | 10 +++++----- src/activity/ActivityTypes.h | 36 ------------------------------------ src/shared/DeviceContextProvider.cpp | 8 ++++---- src/shared/ProviderTypes.h | 7 +++++++ 5 files changed, 20 insertions(+), 49 deletions(-) delete mode 100644 src/activity/ActivityTypes.h diff --git a/src/activity/Activity.cpp b/src/activity/Activity.cpp index faf864d..a71dbfb 100644 --- a/src/activity/Activity.cpp +++ b/src/activity/Activity.cpp @@ -58,20 +58,20 @@ void ActivityProvider::__handleUpdate(activity_type_e activity, const activity_d IF_FAIL_VOID_TAG(activity == __activityType, _E, "Invalid activity: %d", activity); Json dataRead; - dataRead.set(NULL, CTX_ACTIVITY_EVENT, CTX_ACTIVITY_DETECTED); + dataRead.set(NULL, KEY_EVENT, VAL_DETECTED); activity_accuracy_e accuracy = ACTIVITY_ACCURACY_LOW; activity_get_accuracy(data, &accuracy); switch (accuracy) { case ACTIVITY_ACCURACY_HIGH: - dataRead.set(NULL, CTX_ACTIVITY_ACCURACY, CTX_ACTIVITY_HIGH); + dataRead.set(NULL, KEY_ACCURACY, VAL_HIGH); break; case ACTIVITY_ACCURACY_MID: - dataRead.set(NULL, CTX_ACTIVITY_ACCURACY, CTX_ACTIVITY_NORMAL); + dataRead.set(NULL, KEY_ACCURACY, VAL_NORMAL); break; default: - dataRead.set(NULL, CTX_ACTIVITY_ACCURACY, CTX_ACTIVITY_LOW); + dataRead.set(NULL, KEY_ACCURACY, VAL_LOW); break; } diff --git a/src/activity/Activity.h b/src/activity/Activity.h index c3c3dfe..b1bfe77 100644 --- a/src/activity/Activity.h +++ b/src/activity/Activity.h @@ -19,8 +19,8 @@ #include #include +#include #include -#include "ActivityTypes.h" #define GENERATE_ACTIVITY_PROVIDER(actPrvd, actSubj, actType) \ class actPrvd : public ActivityProvider { \ @@ -51,10 +51,10 @@ namespace ctx { }; - GENERATE_ACTIVITY_PROVIDER(StationaryActivityProvider, CTX_ACTIVITY_SUBJ_STATIONARY, ACTIVITY_STATIONARY); - GENERATE_ACTIVITY_PROVIDER(WalkingActivityProvider, CTX_ACTIVITY_SUBJ_WALKING, ACTIVITY_WALK); - GENERATE_ACTIVITY_PROVIDER(RunningActivityProvider, CTX_ACTIVITY_SUBJ_RUNNING, ACTIVITY_RUN); - GENERATE_ACTIVITY_PROVIDER(InVehicleActivityProvider, CTX_ACTIVITY_SUBJ_IN_VEHICLE, ACTIVITY_IN_VEHICLE); + GENERATE_ACTIVITY_PROVIDER(StationaryActivityProvider, SUBJ_ACTIVITY_STATIONARY, ACTIVITY_STATIONARY); + GENERATE_ACTIVITY_PROVIDER(WalkingActivityProvider, SUBJ_ACTIVITY_WALKING, ACTIVITY_WALK); + GENERATE_ACTIVITY_PROVIDER(RunningActivityProvider, SUBJ_ACTIVITY_RUNNING, ACTIVITY_RUN); + GENERATE_ACTIVITY_PROVIDER(InVehicleActivityProvider, SUBJ_ACTIVITY_IN_VEHICLE, ACTIVITY_IN_VEHICLE); } #endif // _CONTEXT_ACTIVITY_PROVIDER_H_ diff --git a/src/activity/ActivityTypes.h b/src/activity/ActivityTypes.h deleted file mode 100644 index 8a58776..0000000 --- a/src/activity/ActivityTypes.h +++ /dev/null @@ -1,36 +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_ACTIVITY_TYPES_H_ -#define _CONTEXT_ACTIVITY_TYPES_H_ - -/* Subject */ -#define CTX_ACTIVITY_SUBJ_IN_VEHICLE "activity/in_vehicle" -#define CTX_ACTIVITY_SUBJ_RUNNING "activity/running" -#define CTX_ACTIVITY_SUBJ_STATIONARY "activity/stationary" -#define CTX_ACTIVITY_SUBJ_WALKING "activity/walking" - -/* Data Key */ -#define CTX_ACTIVITY_EVENT "Event" -#define CTX_ACTIVITY_ACCURACY "Accuracy" - -/* Data Value */ -#define CTX_ACTIVITY_DETECTED "Detected" -#define CTX_ACTIVITY_LOW "Low" -#define CTX_ACTIVITY_NORMAL "Normal" -#define CTX_ACTIVITY_HIGH "High" - -#endif /* _CONTEXT_ACTIVITY_TYPES_H_ */ diff --git a/src/shared/DeviceContextProvider.cpp b/src/shared/DeviceContextProvider.cpp index f1eb8d4..46a6ae9 100644 --- a/src/shared/DeviceContextProvider.cpp +++ b/src/shared/DeviceContextProvider.cpp @@ -69,10 +69,10 @@ SO_EXPORT bool ctx::initDeviceContextProvider() registerProvider(SUBJ_STATE_BATTERY, NULL); registerProvider(SUBJ_STATE_PSMODE, NULL); - registerProvider(CTX_ACTIVITY_SUBJ_STATIONARY, NULL); - registerProvider(CTX_ACTIVITY_SUBJ_WALKING, NULL); - registerProvider(CTX_ACTIVITY_SUBJ_RUNNING, NULL); - registerProvider(CTX_ACTIVITY_SUBJ_IN_VEHICLE, NULL); + registerProvider(SUBJ_ACTIVITY_STATIONARY, NULL); + registerProvider(SUBJ_ACTIVITY_WALKING, NULL); + registerProvider(SUBJ_ACTIVITY_RUNNING, NULL); + registerProvider(SUBJ_ACTIVITY_IN_VEHICLE, NULL); #ifdef _MOBILE_ registerProvider(SUBJ_STATE_CALL, PRIV_TELEPHONY); diff --git a/src/shared/ProviderTypes.h b/src/shared/ProviderTypes.h index 84f5c68..667da28 100644 --- a/src/shared/ProviderTypes.h +++ b/src/shared/ProviderTypes.h @@ -43,6 +43,11 @@ #define SUBJ_STATE_MESSAGE "social/message" #define SUBJ_STATE_CONTACTS "social/contacts" +#define SUBJ_ACTIVITY_IN_VEHICLE "activity/in_vehicle" +#define SUBJ_ACTIVITY_RUNNING "activity/running" +#define SUBJ_ACTIVITY_STATIONARY "activity/stationary" +#define SUBJ_ACTIVITY_WALKING "activity/walking" + /* Data & Option Keys */ #define KEY_QUERY_RESULT "QueryResult" @@ -74,6 +79,7 @@ #define KEY_STATE "State" #define KEY_TYPE "Type" #define KEY_LEVEL "Level" +#define KEY_ACCURACY "Accuracy" #define KEY_BSSID "BSSID" #define KEY_MEDIUM "Medium" #define KEY_ADDRESS "Address" @@ -117,6 +123,7 @@ #define VAL_MY_PROFILE "MyProfile" #define VAL_PERSON "Person" #define VAL_CHANGED "Changed" +#define VAL_DETECTED "Detected" #define VAL_ACTIVE VAL_CONNECTED #define VAL_ALERTING VAL_CONNECTING -- 2.7.4 From b25fb5f694cfa1c22c98e152e6bd9852ef9cbab2 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 21 Apr 2016 17:07:04 +0900 Subject: [PATCH 10/16] Code cleanup: update provider class names Change-Id: Icbfd404caae4cc3fedc13936fd3a9b18b850d63a Signed-off-by: Mu-Woong Lee --- src/call/Call.cpp | 38 +++++++++++++++---------------- src/call/Call.h | 16 ++++++------- src/contacts/Contacts.cpp | 24 ++++++++++---------- src/contacts/Contacts.h | 16 ++++++------- src/email/Email.cpp | 14 ++++++------ src/email/Email.h | 16 ++++++------- src/headphone/Headphone.cpp | 44 ++++++++++++++++++------------------ src/headphone/Headphone.h | 17 +++++++------- src/message/Message.cpp | 22 +++++++++--------- src/message/Message.h | 16 ++++++------- src/shared/DeviceContextProvider.cpp | 30 ++++++++++++------------ src/system/Battery.cpp | 22 +++++++++--------- src/system/Battery.h | 16 ++++++------- src/system/Charger.cpp | 14 ++++++------ src/system/Charger.h | 12 +++++----- src/system/Gps.cpp | 14 ++++++------ src/system/Gps.h | 12 +++++----- src/system/Psmode.cpp | 20 ++++++++-------- src/system/Psmode.h | 16 ++++++------- src/system/RuntimeInfoBase.cpp | 12 +++++----- src/system/RuntimeInfoBase.h | 16 ++++++------- src/system/Usb.cpp | 14 ++++++------ src/system/Usb.h | 12 +++++----- src/time/Alarm.cpp | 34 ++++++++++++++-------------- src/time/Alarm.h | 14 ++++++------ src/time/Time.cpp | 14 ++++++------ src/time/Time.h | 16 ++++++------- src/wifi/Wifi.cpp | 36 ++++++++++++++--------------- src/wifi/Wifi.h | 16 ++++++------- 29 files changed, 281 insertions(+), 282 deletions(-) diff --git a/src/call/Call.cpp b/src/call/Call.cpp index 9700fcf..786fcc3 100644 --- a/src/call/Call.cpp +++ b/src/call/Call.cpp @@ -38,23 +38,23 @@ static telephony_noti_e __callNotiIds[] = }; static Json __latest; -SocialStatusCall::SocialStatusCall() : +CallStateProvider::CallStateProvider() : BasicProvider(SUBJ_STATE_CALL) { __handleList.count = 0; __handleList.handle = NULL; } -SocialStatusCall::~SocialStatusCall() +CallStateProvider::~CallStateProvider() { } -bool SocialStatusCall::isSupported() +bool CallStateProvider::isSupported() { return util::getSystemInfoBool("tizen.org/feature/network.telephony"); } -void SocialStatusCall::submitTriggerItem() +void CallStateProvider::submitTriggerItem() { registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, "{" @@ -66,13 +66,13 @@ void SocialStatusCall::submitTriggerItem() /* TODO remove Connecting, Connected */ } -void SocialStatusCall::__updateCb(telephony_h handle, telephony_noti_e notiId, void *data, void *userData) +void CallStateProvider::__updateCb(telephony_h handle, telephony_noti_e notiId, void *data, void *userData) { - SocialStatusCall *instance = static_cast(userData); + CallStateProvider *instance = static_cast(userData); instance->__handleUpdate(handle, notiId, data); } -void SocialStatusCall::__handleUpdate(telephony_h handle, telephony_noti_e notiId, void* id) +void CallStateProvider::__handleUpdate(telephony_h handle, telephony_noti_e notiId, void* id) { Json data; unsigned int count; @@ -158,7 +158,7 @@ void SocialStatusCall::__handleUpdate(telephony_h handle, telephony_noti_e notiI telephony_call_release_call_list(count, &callList); } -bool SocialStatusCall::__initTelephony() +bool CallStateProvider::__initTelephony() { IF_FAIL_RETURN(!__telephonyInitialized, true); @@ -169,7 +169,7 @@ bool SocialStatusCall::__initTelephony() return true; } -void SocialStatusCall::__releaseTelephony() +void CallStateProvider::__releaseTelephony() { IF_FAIL_VOID(__telephonyInitialized); @@ -178,7 +178,7 @@ void SocialStatusCall::__releaseTelephony() __telephonyInitialized = false; } -bool SocialStatusCall::__setCallback() +bool CallStateProvider::__setCallback() { /* TODO: Consider dual-sim devices */ IF_FAIL_RETURN_TAG(__initTelephony(), false, _E, "Initialization failed"); @@ -200,7 +200,7 @@ CATCH: return false; } -void SocialStatusCall::__unsetCallback() +void CallStateProvider::__unsetCallback() { for (unsigned int i = 0; i < __handleList.count; i++) { for (unsigned int j = 0; j < TELEPHONY_NOTI_ID_CNT; j++) { @@ -211,7 +211,7 @@ void SocialStatusCall::__unsetCallback() __releaseTelephony(); } -bool SocialStatusCall::__getCallState(telephony_call_h& handle, std::string& state) +bool CallStateProvider::__getCallState(telephony_call_h& handle, std::string& state) { state.clear(); @@ -244,7 +244,7 @@ bool SocialStatusCall::__getCallState(telephony_call_h& handle, std::string& sta return true; } -bool SocialStatusCall::__getCallType(telephony_call_h& handle, std::string& type) +bool CallStateProvider::__getCallType(telephony_call_h& handle, std::string& type) { type.clear(); @@ -269,7 +269,7 @@ bool SocialStatusCall::__getCallType(telephony_call_h& handle, std::string& type return true; } -bool SocialStatusCall::__getCallAddress(telephony_call_h& handle, std::string& address) +bool CallStateProvider::__getCallAddress(telephony_call_h& handle, std::string& address) { address.clear(); @@ -288,7 +288,7 @@ bool SocialStatusCall::__getCallAddress(telephony_call_h& handle, std::string& a return true; } -bool SocialStatusCall::__getCallHandleId(telephony_call_h& handle, unsigned int& id) +bool CallStateProvider::__getCallHandleId(telephony_call_h& handle, unsigned int& id) { int err = telephony_call_get_handle_id(handle, &id); IF_FAIL_RETURN_TAG(err == TELEPHONY_ERROR_NONE, false, _E, "Getting handle id failed"); @@ -296,20 +296,20 @@ bool SocialStatusCall::__getCallHandleId(telephony_call_h& handle, unsigned int& return true; } -int SocialStatusCall::subscribe() +int CallStateProvider::subscribe() { bool ret = __setCallback(); IF_FAIL_RETURN(ret, ERR_OPERATION_FAILED); return ERR_NONE; } -int SocialStatusCall::unsubscribe() +int CallStateProvider::unsubscribe() { __unsetCallback(); return ERR_NONE; } -bool SocialStatusCall::__readCurrentStatus(telephony_h& handle, Json* data) +bool CallStateProvider::__readCurrentStatus(telephony_h& handle, Json* data) { unsigned int count = 0; telephony_call_h *callList = NULL; @@ -351,7 +351,7 @@ bool SocialStatusCall::__readCurrentStatus(telephony_h& handle, Json* data) return true; } -int SocialStatusCall::read() +int CallStateProvider::read() { bool temporaryHandle = false; if (!__telephonyInitialized) { diff --git a/src/call/Call.h b/src/call/Call.h index f76faac..c980a38 100644 --- a/src/call/Call.h +++ b/src/call/Call.h @@ -14,19 +14,19 @@ * limitations under the License. */ -#ifndef _CONTEXT_SOCIAL_STATUS_CALL_H_ -#define _CONTEXT_SOCIAL_STATUS_CALL_H_ +#ifndef _CONTEXT_CALL_STATE_PROVIDER_H_ +#define _CONTEXT_CALL_STATE_PROVIDER_H_ #include -#include "../shared/ProviderTypes.h" -#include "../shared/BasicProvider.h" +#include +#include namespace ctx { - class SocialStatusCall : public BasicProvider { + class CallStateProvider : public BasicProvider { public: - SocialStatusCall(); - ~SocialStatusCall(); + CallStateProvider(); + ~CallStateProvider(); int subscribe(); int unsubscribe(); @@ -54,4 +54,4 @@ namespace ctx { }; } -#endif // _CONTEXT_SOCIAL_STATUS_CALL_H_ +#endif /* _CONTEXT_CALL_STATE_PROVIDER_H_ */ diff --git a/src/contacts/Contacts.cpp b/src/contacts/Contacts.cpp index 2dc4657..8265fd6 100644 --- a/src/contacts/Contacts.cpp +++ b/src/contacts/Contacts.cpp @@ -22,23 +22,23 @@ using namespace ctx; -SocialStatusContacts::SocialStatusContacts() : +ContactsChangeProvider::ContactsChangeProvider() : BasicProvider(SUBJ_STATE_CONTACTS), __latestMyProfile(0), __latestPerson(0) { } -SocialStatusContacts::~SocialStatusContacts() +ContactsChangeProvider::~ContactsChangeProvider() { } -bool SocialStatusContacts::isSupported() +bool ContactsChangeProvider::isSupported() { return true; } -void SocialStatusContacts::submitTriggerItem() +void ContactsChangeProvider::submitTriggerItem() { registerTriggerItem(OPS_SUBSCRIBE, "{" @@ -48,13 +48,13 @@ void SocialStatusContacts::submitTriggerItem() NULL); } -void SocialStatusContacts::__updateCb(const char* viewUri, void* userData) +void ContactsChangeProvider::__updateCb(const char* viewUri, void* userData) { - SocialStatusContacts *instance = static_cast(userData); + ContactsChangeProvider *instance = static_cast(userData); instance->__handleUpdate(viewUri); } -void SocialStatusContacts::__handleUpdate(const char* viewUri) +void ContactsChangeProvider::__handleUpdate(const char* viewUri) { if (!STR_EQ(viewUri, _contacts_my_profile._uri) && !STR_EQ(viewUri, _contacts_person._uri)) { _W("Unknown view uri"); @@ -70,7 +70,7 @@ void SocialStatusContacts::__handleUpdate(const char* viewUri) publish(NULL, ERR_NONE, data); } -bool SocialStatusContacts::__isConsecutiveChange(const char* viewUri) +bool ContactsChangeProvider::__isConsecutiveChange(const char* viewUri) { time_t now = time(NULL); double diff = 0; @@ -89,7 +89,7 @@ bool SocialStatusContacts::__isConsecutiveChange(const char* viewUri) return false; } -bool SocialStatusContacts::__setCallback() +bool ContactsChangeProvider::__setCallback() { int err; @@ -109,7 +109,7 @@ CATCH: return false; } -void SocialStatusContacts::__unsetCallback() +void ContactsChangeProvider::__unsetCallback() { contacts_db_remove_changed_cb(MY_PROFILE_VIEW, __updateCb, this); contacts_db_remove_changed_cb(PERSON_VIEW, __updateCb, this); @@ -120,14 +120,14 @@ void SocialStatusContacts::__unsetCallback() __latestPerson = 0; } -int SocialStatusContacts::subscribe() +int ContactsChangeProvider::subscribe() { bool ret = __setCallback(); IF_FAIL_RETURN(ret, ERR_OPERATION_FAILED); return ERR_NONE; } -int SocialStatusContacts::unsubscribe() +int ContactsChangeProvider::unsubscribe() { __unsetCallback(); return ERR_NONE; diff --git a/src/contacts/Contacts.h b/src/contacts/Contacts.h index dcabc2b..0ebd273 100644 --- a/src/contacts/Contacts.h +++ b/src/contacts/Contacts.h @@ -14,19 +14,19 @@ * limitations under the License. */ -#ifndef _CONTEXT_SOCIAL_STATUS_CONTACTS_H_ -#define _CONTEXT_SOCIAL_STATUS_CONTACTS_H_ +#ifndef _CONTEXT_CONTACTS_CHANGE_PROVIDER_H_ +#define _CONTEXT_CONTACTS_CHANGE_PROVIDER_H_ #include -#include "../shared/ProviderTypes.h" -#include "../shared/BasicProvider.h" +#include +#include namespace ctx { - class SocialStatusContacts : public BasicProvider { + class ContactsChangeProvider : public BasicProvider { public: - SocialStatusContacts(); - ~SocialStatusContacts(); + ContactsChangeProvider(); + ~ContactsChangeProvider(); int subscribe(); int unsubscribe(); @@ -46,4 +46,4 @@ namespace ctx { }; } -#endif // _CONTEXT_SOCIAL_STATUS_CONTACTS_H_ +#endif /* _CONTEXT_CONTACTS_CHANGE_PROVIDER_H_ */ diff --git a/src/email/Email.cpp b/src/email/Email.cpp index 3dba025..f2a23cb 100644 --- a/src/email/Email.cpp +++ b/src/email/Email.cpp @@ -20,23 +20,23 @@ using namespace ctx; -SocialStatusEmail::SocialStatusEmail() : +EmailEventProvider::EmailEventProvider() : BasicProvider(SUBJ_STATE_EMAIL), __dbusSignalId(-1), __dbusWatcher(DBusType::SESSION) { } -SocialStatusEmail::~SocialStatusEmail() +EmailEventProvider::~EmailEventProvider() { } -bool SocialStatusEmail::isSupported() +bool EmailEventProvider::isSupported() { return util::getSystemInfoBool("tizen.org/feature/network.telephony"); } -void SocialStatusEmail::submitTriggerItem() +void EmailEventProvider::submitTriggerItem() { registerTriggerItem(OPS_SUBSCRIBE, "{" @@ -45,7 +45,7 @@ void SocialStatusEmail::submitTriggerItem() NULL); } -void SocialStatusEmail::onSignal(const char* sender, const char* path, const char* iface, const char* name, GVariant* param) +void EmailEventProvider::onSignal(const char* sender, const char* path, const char* iface, const char* name, GVariant* param) { gint subType = 0; gint gi1 = 0; @@ -71,7 +71,7 @@ void SocialStatusEmail::onSignal(const char* sender, const char* path, const cha } -int SocialStatusEmail::subscribe() +int EmailEventProvider::subscribe() { __dbusSignalId = __dbusWatcher.watch(NULL, NULL, "User.Email.NetworkStatus", "email", this); IF_FAIL_RETURN_TAG(__dbusSignalId >= 0, ERR_OPERATION_FAILED, _E, "Email dbus signal subscription failed"); @@ -79,7 +79,7 @@ int SocialStatusEmail::subscribe() } -int SocialStatusEmail::unsubscribe() +int EmailEventProvider::unsubscribe() { __dbusWatcher.unwatch(__dbusSignalId); return ERR_NONE; diff --git a/src/email/Email.h b/src/email/Email.h index 4c52e99..c1cc093 100644 --- a/src/email/Email.h +++ b/src/email/Email.h @@ -14,19 +14,19 @@ * limitations under the License. */ -#ifndef _CONTEXT_SOCIAL_STATUS_EMAIL_H_ -#define _CONTEXT_SOCIAL_STATUS_EMAIL_H_ +#ifndef _CONTEXT_EMAIL_EVENT_PROVIDER_H_ +#define _CONTEXT_EMAIL_EVENT_PROVIDER_H_ #include -#include "../shared/ProviderTypes.h" -#include "../shared/BasicProvider.h" +#include +#include namespace ctx { - class SocialStatusEmail : public BasicProvider, public IDBusSignalListener { + class EmailEventProvider : public BasicProvider, public IDBusSignalListener { public: - SocialStatusEmail(); - ~SocialStatusEmail(); + EmailEventProvider(); + ~EmailEventProvider(); int subscribe(); int unsubscribe(); @@ -42,4 +42,4 @@ namespace ctx { }; } -#endif // _CONTEXT_SOCIAL_STATUS_EMAIL_H_ +#endif /* _CONTEXT_EMAIL_EVENT_PROVIDER_H_ */ diff --git a/src/headphone/Headphone.cpp b/src/headphone/Headphone.cpp index c9a9169..7bf8d8e 100644 --- a/src/headphone/Headphone.cpp +++ b/src/headphone/Headphone.cpp @@ -21,7 +21,7 @@ using namespace ctx; -DeviceStatusHeadphone::DeviceStatusHeadphone() : +HeadphoneStateProvider::HeadphoneStateProvider() : BasicProvider(SUBJ_STATE_HEADPHONE), __connected(false), __audioJackState(RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED), @@ -32,16 +32,16 @@ DeviceStatusHeadphone::DeviceStatusHeadphone() : { } -DeviceStatusHeadphone::~DeviceStatusHeadphone() +HeadphoneStateProvider::~HeadphoneStateProvider() { } -bool DeviceStatusHeadphone::isSupported() +bool HeadphoneStateProvider::isSupported() { return true; } -void DeviceStatusHeadphone::submitTriggerItem() +void HeadphoneStateProvider::submitTriggerItem() { registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, "{" @@ -51,7 +51,7 @@ void DeviceStatusHeadphone::submitTriggerItem() NULL); } -int DeviceStatusHeadphone::subscribe() +int HeadphoneStateProvider::subscribe() { __connected = __getCurrentStatus(); @@ -65,7 +65,7 @@ int DeviceStatusHeadphone::subscribe() return ERR_NONE; } -int DeviceStatusHeadphone::unsubscribe() +int HeadphoneStateProvider::unsubscribe() { runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS); __unsetBtAudioCallback(); @@ -73,7 +73,7 @@ int DeviceStatusHeadphone::unsubscribe() return ERR_NONE; } -int DeviceStatusHeadphone::read() +int HeadphoneStateProvider::read() { if (!__beingSubscribed) __connected = __getCurrentStatus(); @@ -85,7 +85,7 @@ int DeviceStatusHeadphone::read() return ERR_NONE; } -void DeviceStatusHeadphone::__setBtAudioCallback() +void HeadphoneStateProvider::__setBtAudioCallback() { IF_FAIL_VOID(!__btAudioCallbackOn); int ret; @@ -105,7 +105,7 @@ void DeviceStatusHeadphone::__setBtAudioCallback() __btAudioCallbackOn = true; } -void DeviceStatusHeadphone::__unsetBtAudioCallback() +void HeadphoneStateProvider::__unsetBtAudioCallback() { IF_FAIL_VOID(__btAudioCallbackOn); @@ -115,12 +115,12 @@ void DeviceStatusHeadphone::__unsetBtAudioCallback() __btAudioCallbackOn = false; } -void DeviceStatusHeadphone::__setBtAudioState(bool state) +void HeadphoneStateProvider::__setBtAudioState(bool state) { __btAudioState = state; } -bool DeviceStatusHeadphone::__getCurrentStatus() +bool HeadphoneStateProvider::__getCurrentStatus() { int ret; @@ -139,7 +139,7 @@ bool DeviceStatusHeadphone::__getCurrentStatus() return ((__audioJackState != RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED) || __btAudioState); } -void DeviceStatusHeadphone::__generateDataPacket(Json* data) +void HeadphoneStateProvider::__generateDataPacket(Json* data) { data->set(NULL, KEY_IS_CONNECTED, __connected ? VAL_TRUE : VAL_FALSE); @@ -157,7 +157,7 @@ void DeviceStatusHeadphone::__generateDataPacket(Json* data) } } -bool DeviceStatusHeadphone::__handleUpdate() +bool HeadphoneStateProvider::__handleUpdate() { bool prevState = __connected; __connected = ((__audioJackState != RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED) || __btAudioState); @@ -170,23 +170,23 @@ bool DeviceStatusHeadphone::__handleUpdate() return true; } -void DeviceStatusHeadphone::__handleAudioJackEvent() +void HeadphoneStateProvider::__handleAudioJackEvent() { int ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &__audioJackState); IF_FAIL_VOID_TAG(ret == ERR_NONE, _E, "Getting runtime info failed"); __handleUpdate(); } -void DeviceStatusHeadphone::__onAudioJackStateChanged(runtime_info_key_e runtimeKey, void* userData) +void HeadphoneStateProvider::__onAudioJackStateChanged(runtime_info_key_e runtimeKey, void* userData) { _D("EarJack"); - DeviceStatusHeadphone *instance = static_cast(userData); + HeadphoneStateProvider *instance = static_cast(userData); instance->__handleAudioJackEvent(); } -void DeviceStatusHeadphone::__onBtConnectionChanged(bool connected, bt_device_connection_info_s *connInfo, void *userData) +void HeadphoneStateProvider::__onBtConnectionChanged(bool connected, bt_device_connection_info_s *connInfo, void *userData) { - DeviceStatusHeadphone *instance = static_cast(userData); + HeadphoneStateProvider *instance = static_cast(userData); IF_FAIL_VOID(connected != instance->__btAudioState); IF_FAIL_VOID(!instance->__btEventHandlerAdded); @@ -200,10 +200,10 @@ void DeviceStatusHeadphone::__onBtConnectionChanged(bool connected, bt_device_co } } -gboolean DeviceStatusHeadphone::__handleBtEvent(gpointer data) +gboolean HeadphoneStateProvider::__handleBtEvent(gpointer data) { _D("BT state checking started"); - DeviceStatusHeadphone *instance = static_cast(data); + HeadphoneStateProvider *instance = static_cast(data); instance->__btEventHandlerAdded = false; instance->__setBtAudioState(false); @@ -218,7 +218,7 @@ gboolean DeviceStatusHeadphone::__handleBtEvent(gpointer data) return TRUE; } -bool DeviceStatusHeadphone::__onBtBond(bt_device_info_s *deviceInfo, void* userData) +bool HeadphoneStateProvider::__onBtBond(bt_device_info_s *deviceInfo, void* userData) { if (deviceInfo->bt_class.major_device_class != BT_MAJOR_DEVICE_CLASS_AUDIO_VIDEO) return true; @@ -228,7 +228,7 @@ bool DeviceStatusHeadphone::__onBtBond(bt_device_info_s *deviceInfo, void* userD IF_FAIL_RETURN_TAG(err == BT_ERROR_NONE, false, _E, "bt_device_is_profile_connected() failed"); if (st) { - DeviceStatusHeadphone *instance = static_cast(userData); + HeadphoneStateProvider *instance = static_cast(userData); instance->__setBtAudioState(true); return false; } diff --git a/src/headphone/Headphone.h b/src/headphone/Headphone.h index a6c8805..e61f446 100644 --- a/src/headphone/Headphone.h +++ b/src/headphone/Headphone.h @@ -14,21 +14,20 @@ * limitations under the License. */ -#ifndef _CONTEXT_HEADPHONE_H_ -#define _CONTEXT_HEADPNOHE_H_ +#ifndef _CONTEXT_HEADPHONE_STATE_PROVIDER_H_ +#define _CONTEXT_HEADPHONE_STATE_PROVIDER_H_ -#include #include #include -#include "../shared/ProviderTypes.h" -#include "../shared/BasicProvider.h" +#include +#include namespace ctx { - class DeviceStatusHeadphone : public BasicProvider { + class HeadphoneStateProvider : public BasicProvider { public: - DeviceStatusHeadphone(); - ~DeviceStatusHeadphone(); + HeadphoneStateProvider(); + ~HeadphoneStateProvider(); int subscribe(); int unsubscribe(); @@ -61,4 +60,4 @@ namespace ctx { }; } -#endif // _CONTEXT_HEADPHONE_H_ +#endif /* _CONTEXT_HEADPHONE_STATE_PROVIDER_H_ */ diff --git a/src/message/Message.cpp b/src/message/Message.cpp index 7e589f0..30268ed 100644 --- a/src/message/Message.cpp +++ b/src/message/Message.cpp @@ -21,22 +21,22 @@ using namespace ctx; -SocialStatusMessage::SocialStatusMessage() : +MessageEventProvider::MessageEventProvider() : BasicProvider(SUBJ_STATE_MESSAGE), __messageHandle(NULL) { } -SocialStatusMessage::~SocialStatusMessage() +MessageEventProvider::~MessageEventProvider() { } -bool SocialStatusMessage::isSupported() +bool MessageEventProvider::isSupported() { return util::getSystemInfoBool("tizen.org/feature/network.telephony"); } -void SocialStatusMessage::submitTriggerItem() +void MessageEventProvider::submitTriggerItem() { registerTriggerItem(OPS_SUBSCRIBE, "{" @@ -47,13 +47,13 @@ void SocialStatusMessage::submitTriggerItem() NULL); } -void SocialStatusMessage::__updateCb(msg_handle_t handle, msg_struct_t msg, void* userData) +void MessageEventProvider::__updateCb(msg_handle_t handle, msg_struct_t msg, void* userData) { - SocialStatusMessage *instance = static_cast(userData); + MessageEventProvider *instance = static_cast(userData); instance->__handleUpdate(msg); } -void SocialStatusMessage::__handleUpdate(msg_struct_t msg) +void MessageEventProvider::__handleUpdate(msg_struct_t msg) { int err; int type; @@ -93,7 +93,7 @@ void SocialStatusMessage::__handleUpdate(msg_struct_t msg) publish(NULL, ERR_NONE, data); } -bool SocialStatusMessage::__setCallback() +bool MessageEventProvider::__setCallback() { int err; @@ -111,7 +111,7 @@ bool SocialStatusMessage::__setCallback() return true; } -void SocialStatusMessage::__unsetCallback() +void MessageEventProvider::__unsetCallback() { if (__messageHandle) msg_close_msg_handle(&__messageHandle); @@ -119,14 +119,14 @@ void SocialStatusMessage::__unsetCallback() __messageHandle = NULL; } -int SocialStatusMessage::subscribe() +int MessageEventProvider::subscribe() { bool ret = __setCallback(); IF_FAIL_RETURN(ret, ERR_OPERATION_FAILED); return ERR_NONE; } -int SocialStatusMessage::unsubscribe() +int MessageEventProvider::unsubscribe() { __unsetCallback(); return ERR_NONE; diff --git a/src/message/Message.h b/src/message/Message.h index 4f2514f..058d418 100644 --- a/src/message/Message.h +++ b/src/message/Message.h @@ -14,20 +14,20 @@ * limitations under the License. */ -#ifndef _CONTEXT_SOCIAL_STATUS_SMS_H_ -#define _CONTEXT_SOCIAL_STATUS_SMS_H_ +#ifndef _CONTEXT_MESSAGE_EVENT_PROVIDER_H_ +#define _CONTEXT_MESSAGE_EVENT_PROVIDER_H_ #include #include -#include "../shared/ProviderTypes.h" -#include "../shared/BasicProvider.h" +#include +#include namespace ctx { - class SocialStatusMessage : public BasicProvider { + class MessageEventProvider : public BasicProvider { public: - SocialStatusMessage(); - ~SocialStatusMessage(); + MessageEventProvider(); + ~MessageEventProvider(); int subscribe(); int unsubscribe(); @@ -46,4 +46,4 @@ namespace ctx { }; } -#endif // _CONTEXT_SOCIAL_STATUS_SMS_H_ +#endif /* _CONTEXT_MESSAGE_EVENT_PROVIDER_H_ */ diff --git a/src/shared/DeviceContextProvider.cpp b/src/shared/DeviceContextProvider.cpp index 46a6ae9..1726c98 100644 --- a/src/shared/DeviceContextProvider.cpp +++ b/src/shared/DeviceContextProvider.cpp @@ -57,17 +57,17 @@ void registerProvider(const char *subject, const char *privilege) SO_EXPORT bool ctx::initDeviceContextProvider() { - registerProvider(SUBJ_STATE_ALARM, NULL); - registerProvider(SUBJ_STATE_TIME, NULL); + registerProvider(SUBJ_STATE_ALARM, NULL); + registerProvider(SUBJ_STATE_TIME, NULL); - registerProvider(SUBJ_STATE_WIFI, PRIV_NETWORK); - registerProvider(SUBJ_STATE_HEADPHONE, NULL); + registerProvider(SUBJ_STATE_WIFI, PRIV_NETWORK); + registerProvider(SUBJ_STATE_HEADPHONE, NULL); - registerProvider(SUBJ_STATE_CHARGER, NULL); - registerProvider(SUBJ_STATE_GPS, NULL); - registerProvider(SUBJ_STATE_USB, NULL); - registerProvider(SUBJ_STATE_BATTERY, NULL); - registerProvider(SUBJ_STATE_PSMODE, NULL); + registerProvider(SUBJ_STATE_CHARGER, NULL); + registerProvider(SUBJ_STATE_GPS, NULL); + registerProvider(SUBJ_STATE_USB, NULL); + registerProvider(SUBJ_STATE_BATTERY, NULL); + registerProvider(SUBJ_STATE_PSMODE, NULL); registerProvider(SUBJ_ACTIVITY_STATIONARY, NULL); registerProvider(SUBJ_ACTIVITY_WALKING, NULL); @@ -75,15 +75,15 @@ SO_EXPORT bool ctx::initDeviceContextProvider() registerProvider(SUBJ_ACTIVITY_IN_VEHICLE, NULL); #ifdef _MOBILE_ - registerProvider(SUBJ_STATE_CALL, PRIV_TELEPHONY); - registerProvider(SUBJ_STATE_EMAIL, NULL); - registerProvider(SUBJ_STATE_MESSAGE, PRIV_MESSAGE); - registerProvider(SUBJ_STATE_CONTACTS, PRIV_CONTACT); + registerProvider(SUBJ_STATE_CALL, PRIV_TELEPHONY); + registerProvider(SUBJ_STATE_EMAIL, NULL); + registerProvider(SUBJ_STATE_MESSAGE, PRIV_MESSAGE); + registerProvider(SUBJ_STATE_CONTACTS, PRIV_CONTACT); /* Create context providers, which need to be initiated before being subscribed */ /* - if (DeviceStatusWifi::isSupported()) - DeviceStatusWifi::create(NULL); + if (WifiStateProvider::isSupported()) + WifiStateProvider::create(NULL); */ #endif diff --git a/src/system/Battery.cpp b/src/system/Battery.cpp index b2d36a4..13bc62d 100644 --- a/src/system/Battery.cpp +++ b/src/system/Battery.cpp @@ -18,21 +18,21 @@ using namespace ctx; -DeviceStatusBattery::DeviceStatusBattery() +BatteryStateProvider::BatteryStateProvider() : BasicProvider(SUBJ_STATE_BATTERY) { } -DeviceStatusBattery::~DeviceStatusBattery() +BatteryStateProvider::~BatteryStateProvider() { } -bool DeviceStatusBattery::isSupported() +bool BatteryStateProvider::isSupported() { return true; } -void DeviceStatusBattery::submitTriggerItem() +void BatteryStateProvider::submitTriggerItem() { registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, "{" @@ -42,15 +42,15 @@ void DeviceStatusBattery::submitTriggerItem() NULL); } -void DeviceStatusBattery::__updateCb(device_callback_e deviceType, void* value, void* userData) +void BatteryStateProvider::__updateCb(device_callback_e deviceType, void* value, void* userData) { IF_FAIL_VOID(deviceType == DEVICE_CALLBACK_BATTERY_LEVEL); - DeviceStatusBattery *instance = static_cast(userData); + BatteryStateProvider *instance = static_cast(userData); instance->__handleUpdate(deviceType, value); } -void DeviceStatusBattery::__handleUpdate(device_callback_e deviceType, void* value) +void BatteryStateProvider::__handleUpdate(device_callback_e deviceType, void* value) { intptr_t level = (intptr_t)value; @@ -68,7 +68,7 @@ void DeviceStatusBattery::__handleUpdate(device_callback_e deviceType, void* val publish(NULL, ERR_NONE, dataRead); } -const char* DeviceStatusBattery::__transToString(intptr_t level) +const char* BatteryStateProvider::__transToString(intptr_t level) { switch (level) { case DEVICE_BATTERY_LEVEL_EMPTY: @@ -102,21 +102,21 @@ const char* DeviceStatusBattery::__transToString(intptr_t level) } } -int DeviceStatusBattery::subscribe() +int BatteryStateProvider::subscribe() { int ret = device_add_callback(DEVICE_CALLBACK_BATTERY_LEVEL, __updateCb, this); IF_FAIL_RETURN(ret == DEVICE_ERROR_NONE, ERR_OPERATION_FAILED); return ERR_NONE; } -int DeviceStatusBattery::unsubscribe() +int BatteryStateProvider::unsubscribe() { int ret = device_remove_callback(DEVICE_CALLBACK_BATTERY_LEVEL, __updateCb); IF_FAIL_RETURN(ret == DEVICE_ERROR_NONE, ERR_OPERATION_FAILED); return ERR_NONE; } -int DeviceStatusBattery::read() +int BatteryStateProvider::read() { device_battery_level_e level; Json dataRead; diff --git a/src/system/Battery.h b/src/system/Battery.h index fab5a3c..ce695ac 100644 --- a/src/system/Battery.h +++ b/src/system/Battery.h @@ -14,20 +14,20 @@ * limitations under the License. */ -#ifndef _DEVICE_SYSTEM_STATUS_BATTERY_H_ -#define _DEVICE_SYSTEM_STATUS_BATTERY_H_ +#ifndef _CONTEXT_BATTERY_STATE_PROVIDER_H_ +#define _CONTEXT_BATTERY_STATE_PROVIDER_H_ #include #include -#include "../shared/ProviderTypes.h" -#include "../shared/BasicProvider.h" +#include +#include namespace ctx { - class DeviceStatusBattery : public BasicProvider { + class BatteryStateProvider : public BasicProvider { public: - DeviceStatusBattery(); - ~DeviceStatusBattery(); + BatteryStateProvider(); + ~BatteryStateProvider(); int subscribe(); int unsubscribe(); @@ -43,4 +43,4 @@ namespace ctx { }; } -#endif // _DEVICE_SYSTEM_STATUS_BATTERY_H_ +#endif /* _CONTEXT_BATTERY_STATE_PROVIDER_H_ */ diff --git a/src/system/Charger.cpp b/src/system/Charger.cpp index 8142bb4..f06f88d 100644 --- a/src/system/Charger.cpp +++ b/src/system/Charger.cpp @@ -18,27 +18,27 @@ using namespace ctx; -DeviceStatusCharger::DeviceStatusCharger() : - DeviceStatusRuntimeInfo(SUBJ_STATE_CHARGER, RUNTIME_INFO_KEY_CHARGER_CONNECTED) +ChargerStateProvider::ChargerStateProvider() : + RuntimeInfoProvider(SUBJ_STATE_CHARGER, RUNTIME_INFO_KEY_CHARGER_CONNECTED) { } -DeviceStatusCharger::~DeviceStatusCharger() +ChargerStateProvider::~ChargerStateProvider() { } -bool DeviceStatusCharger::isSupported() +bool ChargerStateProvider::isSupported() { return true; } -void DeviceStatusCharger::submitTriggerItem() +void ChargerStateProvider::submitTriggerItem() { registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, "{" TRIG_BOOL_ITEM_DEF("IsConnected") "}", NULL); } -void DeviceStatusCharger::handleUpdate() +void ChargerStateProvider::handleUpdate() { bool chargerStatus = false; @@ -51,7 +51,7 @@ void DeviceStatusCharger::handleUpdate() publish(NULL, ERR_NONE, dataRead); } -int DeviceStatusCharger::read() +int ChargerStateProvider::read() { bool chargerStatus = false; Json dataRead; diff --git a/src/system/Charger.h b/src/system/Charger.h index a6746a3..166440d 100644 --- a/src/system/Charger.h +++ b/src/system/Charger.h @@ -14,17 +14,17 @@ * limitations under the License. */ -#ifndef _DEVICE_SYSTEM_STATUS_CHARGER_ -#define _DEVICE_SYSTEM_STATUS_CHARGER_ +#ifndef _CONTEXT_CHARGER_STATE_PROVIDER_H_ +#define _CONTEXT_CHARGER_STATE_PROVIDER_H_ #include "RuntimeInfoBase.h" namespace ctx { - class DeviceStatusCharger : public DeviceStatusRuntimeInfo { + class ChargerStateProvider : public RuntimeInfoProvider { public: - DeviceStatusCharger(); - ~DeviceStatusCharger(); + ChargerStateProvider(); + ~ChargerStateProvider(); int read(); @@ -36,4 +36,4 @@ namespace ctx { }; } -#endif // _DEVICE_SYSTEM_STATUS_CHARGER_H_ +#endif /* _CONTEXT_CHARGER_STATE_PROVIDER_H_ */ diff --git a/src/system/Gps.cpp b/src/system/Gps.cpp index 47b08d0..0d72cf8 100644 --- a/src/system/Gps.cpp +++ b/src/system/Gps.cpp @@ -37,21 +37,21 @@ static const char* __getStatusString(int gpsStatus) } } -DeviceStatusGps::DeviceStatusGps() : - DeviceStatusRuntimeInfo(SUBJ_STATE_GPS, RUNTIME_INFO_KEY_GPS_STATUS) +GpsStateProvider::GpsStateProvider() : + RuntimeInfoProvider(SUBJ_STATE_GPS, RUNTIME_INFO_KEY_GPS_STATUS) { } -DeviceStatusGps::~DeviceStatusGps() +GpsStateProvider::~GpsStateProvider() { } -bool DeviceStatusGps::isSupported() +bool GpsStateProvider::isSupported() { return util::getSystemInfoBool("tizen.org/feature/location.gps"); } -void DeviceStatusGps::submitTriggerItem() +void GpsStateProvider::submitTriggerItem() { registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, "{" @@ -60,7 +60,7 @@ void DeviceStatusGps::submitTriggerItem() NULL); } -void DeviceStatusGps::handleUpdate() +void GpsStateProvider::handleUpdate() { int gpsStatus; int ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_GPS_STATUS, &gpsStatus); @@ -76,7 +76,7 @@ void DeviceStatusGps::handleUpdate() publish(NULL, ERR_NONE, dataRead); } -int DeviceStatusGps::read() +int GpsStateProvider::read() { int gpsStatus; Json dataRead; diff --git a/src/system/Gps.h b/src/system/Gps.h index 87acd1b..c6af9a4 100644 --- a/src/system/Gps.h +++ b/src/system/Gps.h @@ -14,17 +14,17 @@ * limitations under the License. */ -#ifndef _DEVICE_SYSTEM_STATUS_GPS_H_ -#define _DEVICE_SYSTEM_STATUS_GPS_H_ +#ifndef _CONTEXT_GPS_STATE_PROVIDER_H_ +#define _CONTEXT_GPS_STATE_PROVIDER_H_ #include "RuntimeInfoBase.h" namespace ctx { - class DeviceStatusGps : public DeviceStatusRuntimeInfo { + class GpsStateProvider : public RuntimeInfoProvider { public: - DeviceStatusGps(); - ~DeviceStatusGps(); + GpsStateProvider(); + ~GpsStateProvider(); int read(); @@ -36,4 +36,4 @@ namespace ctx { }; } -#endif // _DEVICE_SYSTEM_STATUS_GPS_H_ +#endif /* _CONTEXT_GPS_STATE_PROVIDER_H_ */ diff --git a/src/system/Psmode.cpp b/src/system/Psmode.cpp index c6d80ea..8654191 100644 --- a/src/system/Psmode.cpp +++ b/src/system/Psmode.cpp @@ -18,33 +18,33 @@ using namespace ctx; -DeviceStatusPsmode::DeviceStatusPsmode() : +PowerSaveModeProvider::PowerSaveModeProvider() : BasicProvider(SUBJ_STATE_PSMODE) { } -DeviceStatusPsmode::~DeviceStatusPsmode() +PowerSaveModeProvider::~PowerSaveModeProvider() { } -bool DeviceStatusPsmode::isSupported() +bool PowerSaveModeProvider::isSupported() { return true; } -void DeviceStatusPsmode::submitTriggerItem() +void PowerSaveModeProvider::submitTriggerItem() { registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, "{" TRIG_BOOL_ITEM_DEF("IsEnabled") "}", NULL); } -void DeviceStatusPsmode::__updateCb(keynode_t *node, void* userData) +void PowerSaveModeProvider::__updateCb(keynode_t *node, void* userData) { - DeviceStatusPsmode *instance = static_cast(userData); + PowerSaveModeProvider *instance = static_cast(userData); instance->__handleUpdate(node); } -void DeviceStatusPsmode::__handleUpdate(keynode_t *node) +void PowerSaveModeProvider::__handleUpdate(keynode_t *node) { int status; Json dataRead; @@ -57,21 +57,21 @@ void DeviceStatusPsmode::__handleUpdate(keynode_t *node) publish(NULL, ERR_NONE, dataRead); } -int DeviceStatusPsmode::subscribe() +int PowerSaveModeProvider::subscribe() { int ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE, __updateCb, this); IF_FAIL_RETURN(ret == VCONF_OK, ERR_OPERATION_FAILED); return ERR_NONE; } -int DeviceStatusPsmode::unsubscribe() +int PowerSaveModeProvider::unsubscribe() { int ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE, __updateCb); IF_FAIL_RETURN(ret == VCONF_OK, ERR_OPERATION_FAILED); return ERR_NONE; } -int DeviceStatusPsmode::read() +int PowerSaveModeProvider::read() { int mode; int ret = vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &mode); diff --git a/src/system/Psmode.h b/src/system/Psmode.h index f821bd3..315465c 100644 --- a/src/system/Psmode.h +++ b/src/system/Psmode.h @@ -14,19 +14,19 @@ * limitations under the License. */ -#ifndef _DEVICE_SYSTEM_STATUS_POWER_SAVING_MODE_H_ -#define _DEVICE_SYSTEM_STATUS_POWER_SAVING_MODE_H_ +#ifndef _CONTEXT_POWER_SAVE_MODE_PROVIDER_H_ +#define _CONTEXT_POWER_SAVE_MODE_PROVIDER_H_ #include -#include "../shared/ProviderTypes.h" -#include "../shared/BasicProvider.h" +#include +#include namespace ctx { - class DeviceStatusPsmode : public BasicProvider { + class PowerSaveModeProvider : public BasicProvider { public: - DeviceStatusPsmode(); - ~DeviceStatusPsmode(); + PowerSaveModeProvider(); + ~PowerSaveModeProvider(); int subscribe(); int unsubscribe(); @@ -41,4 +41,4 @@ namespace ctx { }; } -#endif // _DEVICE_SYSTEM_STATUS_POWER_SAVING_MODE_H_ +#endif /* _CONTEXT_POWER_SAVE_MODE_PROVIDER_H_ */ diff --git a/src/system/RuntimeInfoBase.cpp b/src/system/RuntimeInfoBase.cpp index 67e3710..c5d1298 100644 --- a/src/system/RuntimeInfoBase.cpp +++ b/src/system/RuntimeInfoBase.cpp @@ -18,32 +18,32 @@ using namespace ctx; -DeviceStatusRuntimeInfo::DeviceStatusRuntimeInfo(const char *subject, runtime_info_key_e key) : +RuntimeInfoProvider::RuntimeInfoProvider(const char *subject, runtime_info_key_e key) : BasicProvider(subject), __infoKey(key) { } -runtime_info_key_e DeviceStatusRuntimeInfo::__getInfoKey() +runtime_info_key_e RuntimeInfoProvider::__getInfoKey() { return __infoKey; } -void DeviceStatusRuntimeInfo::updateCb(runtime_info_key_e runtimeKey, void* userData) +void RuntimeInfoProvider::updateCb(runtime_info_key_e runtimeKey, void* userData) { - DeviceStatusRuntimeInfo *instance = static_cast(userData); + RuntimeInfoProvider *instance = static_cast(userData); IF_FAIL_VOID_TAG(runtimeKey == instance->__getInfoKey(), _W, "Runtime info key mismatch"); instance->handleUpdate(); } -int DeviceStatusRuntimeInfo::subscribe() +int RuntimeInfoProvider::subscribe() { int ret = runtime_info_set_changed_cb(__infoKey, updateCb, this); IF_FAIL_RETURN(ret == RUNTIME_INFO_ERROR_NONE, ERR_OPERATION_FAILED); return ERR_NONE; } -int DeviceStatusRuntimeInfo::unsubscribe() +int RuntimeInfoProvider::unsubscribe() { int ret = runtime_info_unset_changed_cb(__infoKey); IF_FAIL_RETURN(ret == RUNTIME_INFO_ERROR_NONE, ERR_OPERATION_FAILED); diff --git a/src/system/RuntimeInfoBase.h b/src/system/RuntimeInfoBase.h index 2ff12a7..4ea5a1d 100644 --- a/src/system/RuntimeInfoBase.h +++ b/src/system/RuntimeInfoBase.h @@ -14,18 +14,18 @@ * limitations under the License. */ -#ifndef _DEVICE_SYSTEM_STATUS_RUNTIME_INFO_BASE_H_ -#define _DEVICE_SYSTEM_STATUS_RUNTIME_INFO_BASE_H_ +#ifndef _CONTEXT_RUNTIME_INFO_PROVIDER_H_ +#define _CONTEXT_RUNTIME_INFO_PROVIDER_H_ #include -#include "../shared/ProviderTypes.h" -#include "../shared/BasicProvider.h" +#include +#include namespace ctx { - class DeviceStatusRuntimeInfo : public BasicProvider { + class RuntimeInfoProvider : public BasicProvider { public: - DeviceStatusRuntimeInfo(const char *subject, runtime_info_key_e key); + RuntimeInfoProvider(const char *subject, runtime_info_key_e key); int subscribe(); int unsubscribe(); @@ -34,7 +34,7 @@ namespace ctx { protected: runtime_info_key_e __infoKey; - virtual ~DeviceStatusRuntimeInfo(){} + virtual ~RuntimeInfoProvider(){} static void updateCb(runtime_info_key_e runtimeKey, void* userData); virtual void handleUpdate() = 0; @@ -43,4 +43,4 @@ namespace ctx { }; } -#endif // _DEVICE_SYSTEM_STATUS_RUNTIME_INFO_BASE_H_ +#endif /* _CONTEXT_RUNTIME_INFO_PROVIDER_H_ */ diff --git a/src/system/Usb.cpp b/src/system/Usb.cpp index 6c9b087..5ea7242 100644 --- a/src/system/Usb.cpp +++ b/src/system/Usb.cpp @@ -19,27 +19,27 @@ using namespace ctx; -DeviceStatusUsb::DeviceStatusUsb() : - DeviceStatusRuntimeInfo(SUBJ_STATE_USB, RUNTIME_INFO_KEY_USB_CONNECTED) +UsbStateProvider::UsbStateProvider() : + RuntimeInfoProvider(SUBJ_STATE_USB, RUNTIME_INFO_KEY_USB_CONNECTED) { } -DeviceStatusUsb::~DeviceStatusUsb() +UsbStateProvider::~UsbStateProvider() { } -bool DeviceStatusUsb::isSupported() +bool UsbStateProvider::isSupported() { return util::getSystemInfoBool("tizen.org/feature/usb.host"); } -void DeviceStatusUsb::submitTriggerItem() +void UsbStateProvider::submitTriggerItem() { registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, "{" TRIG_BOOL_ITEM_DEF("IsConnected") "}", NULL); } -void DeviceStatusUsb::handleUpdate() +void UsbStateProvider::handleUpdate() { bool status = false; @@ -52,7 +52,7 @@ void DeviceStatusUsb::handleUpdate() publish(NULL, ERR_NONE, dataRead); } -int DeviceStatusUsb::read() +int UsbStateProvider::read() { bool status = false; Json dataRead; diff --git a/src/system/Usb.h b/src/system/Usb.h index fc8678c..55b6381 100644 --- a/src/system/Usb.h +++ b/src/system/Usb.h @@ -14,17 +14,17 @@ * limitations under the License. */ -#ifndef _DEVICE_SYSTEM_STATUS_USB_H_ -#define _DEVICE_SYSTEM_STATUS_USB_H_ +#ifndef _CONTEXT_USB_STATE_PROVIDER_H_ +#define _CONTEXT_USB_STATE_PROVIDER_H_ #include "RuntimeInfoBase.h" namespace ctx { - class DeviceStatusUsb : public DeviceStatusRuntimeInfo { + class UsbStateProvider : public RuntimeInfoProvider { public: - DeviceStatusUsb(); - ~DeviceStatusUsb(); + UsbStateProvider(); + ~UsbStateProvider(); int read(); @@ -36,4 +36,4 @@ namespace ctx { }; } -#endif // _DEVICE_SYSTEM_STATUS_USB_H_ +#endif /* _CONTEXT_USB_STATE_PROVIDER_H_ */ diff --git a/src/time/Alarm.cpp b/src/time/Alarm.cpp index 8c3740a..cdcf459 100644 --- a/src/time/Alarm.cpp +++ b/src/time/Alarm.cpp @@ -18,12 +18,12 @@ using namespace ctx; -DeviceStatusAlarm::DeviceStatusAlarm() +AlarmProvider::AlarmProvider() : ContextProvider(SUBJ_STATE_ALARM) { } -DeviceStatusAlarm::~DeviceStatusAlarm() +AlarmProvider::~AlarmProvider() { __clear(); @@ -33,12 +33,12 @@ DeviceStatusAlarm::~DeviceStatusAlarm() __optionSet.clear(); } -bool DeviceStatusAlarm::isSupported() +bool AlarmProvider::isSupported() { return true; } -void DeviceStatusAlarm::submitTriggerItem() +void AlarmProvider::submitTriggerItem() { registerTriggerItem(OPS_SUBSCRIBE, "{" @@ -48,7 +48,7 @@ void DeviceStatusAlarm::submitTriggerItem() NULL); } -int DeviceStatusAlarm::subscribe(Json option, Json *requestResult) +int AlarmProvider::subscribe(Json option, Json *requestResult) { int dow = __getArrangedDayOfWeek(option); @@ -69,7 +69,7 @@ int DeviceStatusAlarm::subscribe(Json option, Json *requestResult) return ERR_NONE; } -int DeviceStatusAlarm::unsubscribe(Json option) +int AlarmProvider::unsubscribe(Json option) { int dow = __getArrangedDayOfWeek(option); @@ -87,7 +87,7 @@ int DeviceStatusAlarm::unsubscribe(Json option) return ERR_NONE; } -int DeviceStatusAlarm::__getArrangedDayOfWeek(Json& option) +int AlarmProvider::__getArrangedDayOfWeek(Json& option) { int dow = 0; @@ -100,12 +100,12 @@ int DeviceStatusAlarm::__getArrangedDayOfWeek(Json& option) return dow; } -DeviceStatusAlarm::RefCountArray::RefCountArray() +AlarmProvider::RefCountArray::RefCountArray() { memset(count, 0, sizeof(int) * DAYS_PER_WEEK); } -int DeviceStatusAlarm::__mergeDayOfWeek(int* refCnt) +int AlarmProvider::__mergeDayOfWeek(int* refCnt) { int dayOfWeek = 0; @@ -118,7 +118,7 @@ int DeviceStatusAlarm::__mergeDayOfWeek(int* refCnt) return dayOfWeek; } -bool DeviceStatusAlarm::__add(int minute, int dayOfWeek) +bool AlarmProvider::__add(int minute, int dayOfWeek) { IF_FAIL_RETURN_TAG(minute >=0 && minute < 1440 && dayOfWeek > 0 && dayOfWeek <= static_cast(DayOfWeek::EVERYDAY), @@ -135,7 +135,7 @@ bool DeviceStatusAlarm::__add(int minute, int dayOfWeek) return __resetTimer(minute); } -bool DeviceStatusAlarm::__remove(int minute, int dayOfWeek) +bool AlarmProvider::__remove(int minute, int dayOfWeek) { IF_FAIL_RETURN_TAG(minute >= 0 && minute < 1440 && dayOfWeek > 0 && dayOfWeek <= static_cast(DayOfWeek::EVERYDAY), @@ -152,7 +152,7 @@ bool DeviceStatusAlarm::__remove(int minute, int dayOfWeek) return __resetTimer(minute); } -bool DeviceStatusAlarm::__resetTimer(int minute) +bool AlarmProvider::__resetTimer(int minute) { int dayOfWeek = __mergeDayOfWeek(__refCountMap[minute].count); TimerState &timer = __timerStateMap[minute]; @@ -189,7 +189,7 @@ bool DeviceStatusAlarm::__resetTimer(int minute) return true; } -void DeviceStatusAlarm::__clear() +void AlarmProvider::__clear() { for (auto it = __timerStateMap.begin(); it != __timerStateMap.end(); ++it) { if (it->second.timerId > 0) { @@ -201,7 +201,7 @@ void DeviceStatusAlarm::__clear() __refCountMap.clear(); } -bool DeviceStatusAlarm::onTimerExpired(int timerId) +bool AlarmProvider::onTimerExpired(int timerId) { time_t rawTime; struct tm timeInfo; @@ -219,7 +219,7 @@ bool DeviceStatusAlarm::onTimerExpired(int timerId) return true; } -void DeviceStatusAlarm::__handleUpdate(int hour, int min, int dayOfWeek) +void AlarmProvider::__handleUpdate(int hour, int min, int dayOfWeek) { _I("Time: %02d:%02d, Day of Week: %#x", hour, min, dayOfWeek); @@ -237,7 +237,7 @@ void DeviceStatusAlarm::__handleUpdate(int hour, int min, int dayOfWeek) } } -bool DeviceStatusAlarm::__isMatched(Json& option, int time, std::string day) +bool AlarmProvider::__isMatched(Json& option, int time, std::string day) { bool ret = false; int optionTime; @@ -259,7 +259,7 @@ bool DeviceStatusAlarm::__isMatched(Json& option, int time, std::string day) return false; } -DeviceStatusAlarm::OptionSet::iterator DeviceStatusAlarm::__findOption(Json& option) +AlarmProvider::OptionSet::iterator AlarmProvider::__findOption(Json& option) { for (auto it = __optionSet.begin(); it != __optionSet.end(); ++it) { if (option == (**it)) diff --git a/src/time/Alarm.h b/src/time/Alarm.h index 85b6419..ea53978 100644 --- a/src/time/Alarm.h +++ b/src/time/Alarm.h @@ -14,21 +14,21 @@ * limitations under the License. */ -#ifndef _DEVICE_SYSTEM_STATUS_ALARM_H_ -#define _DEVICE_SYSTEM_STATUS_ALARM_H_ +#ifndef _CONTEXT_ALARM_PROVIDER_H_ +#define _CONTEXT_ALARM_PROVIDER_H_ #include #include #include #include -#include "../shared/ProviderTypes.h" +#include namespace ctx { - class DeviceStatusAlarm : public ContextProvider, ITimerListener { + class AlarmProvider : public ContextProvider, ITimerListener { public: - DeviceStatusAlarm(); - ~DeviceStatusAlarm(); + AlarmProvider(); + ~AlarmProvider(); int subscribe(Json option, Json *requestResult); int unsubscribe(Json option); @@ -74,4 +74,4 @@ namespace ctx { }; } -#endif // _DEVICE_SYSTEM_STATUS_ALARM_H_ +#endif /* _CONTEXT_ALARM_PROVIDER_H_ */ diff --git a/src/time/Time.cpp b/src/time/Time.cpp index 770c560..99d0afd 100644 --- a/src/time/Time.cpp +++ b/src/time/Time.cpp @@ -19,21 +19,21 @@ using namespace ctx; -DeviceStatusTime::DeviceStatusTime() : +TimeProvider::TimeProvider() : BasicProvider(SUBJ_STATE_TIME) { } -DeviceStatusTime::~DeviceStatusTime() +TimeProvider::~TimeProvider() { } -bool DeviceStatusTime::isSupported() +bool TimeProvider::isSupported() { return true; } -void DeviceStatusTime::submitTriggerItem() +void TimeProvider::submitTriggerItem() { registerTriggerItem(OPS_READ, "{" @@ -44,17 +44,17 @@ void DeviceStatusTime::submitTriggerItem() NULL); } -int DeviceStatusTime::subscribe() +int TimeProvider::subscribe() { return ERR_NOT_SUPPORTED; } -int DeviceStatusTime::unsubscribe() +int TimeProvider::unsubscribe() { return ERR_NOT_SUPPORTED; } -int DeviceStatusTime::read() +int TimeProvider::read() { time_t rawtime; struct tm timeInfo; diff --git a/src/time/Time.h b/src/time/Time.h index ac1862f..6aee48d 100644 --- a/src/time/Time.h +++ b/src/time/Time.h @@ -14,18 +14,18 @@ * limitations under the License. */ -#ifndef _DEVICE_SYSTEM_STATUS_TIME_H_ -#define _DEVICE_SYSTEM_STATUS_TIME_H_ +#ifndef _CONTEXT_TIME_PROVIDER_H_ +#define _CONTEXT_TIME_PROVIDER_H_ -#include "../shared/BasicProvider.h" -#include "../shared/ProviderTypes.h" +#include +#include namespace ctx { - class DeviceStatusTime : public BasicProvider { + class TimeProvider : public BasicProvider { public: - DeviceStatusTime(); - ~DeviceStatusTime(); + TimeProvider(); + ~TimeProvider(); int subscribe(); int unsubscribe(); @@ -36,4 +36,4 @@ namespace ctx { }; } -#endif // _DEVICE_SYSTEM_STATUS_TIME_H_ +#endif /* _CONTEXT_TIME_PROVIDER_H_ */ diff --git a/src/wifi/Wifi.cpp b/src/wifi/Wifi.cpp index f70d59c..b7e085e 100644 --- a/src/wifi/Wifi.cpp +++ b/src/wifi/Wifi.cpp @@ -20,7 +20,7 @@ using namespace ctx; -DeviceStatusWifi::DeviceStatusWifi() : +WifiStateProvider::WifiStateProvider() : BasicProvider(SUBJ_STATE_WIFI), __lastState(UNKNOWN), __isInitialized(false), @@ -35,17 +35,17 @@ DeviceStatusWifi::DeviceStatusWifi() : } } -DeviceStatusWifi::~DeviceStatusWifi() +WifiStateProvider::~WifiStateProvider() { __stopMonitor(); } -bool DeviceStatusWifi::isSupported() +bool WifiStateProvider::isSupported() { return util::getSystemInfoBool("tizen.org/feature/network.wifi"); } -void DeviceStatusWifi::submitTriggerItem() +void WifiStateProvider::submitTriggerItem() { registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, "{" @@ -55,7 +55,7 @@ void DeviceStatusWifi::submitTriggerItem() NULL); } -bool DeviceStatusWifi::__getCurrentState() +bool WifiStateProvider::__getCurrentState() { int err; @@ -89,7 +89,7 @@ bool DeviceStatusWifi::__getCurrentState() return true; } -bool DeviceStatusWifi::__getBssid() +bool WifiStateProvider::__getBssid() { int err; char *strBuf = NULL; @@ -113,14 +113,14 @@ bool DeviceStatusWifi::__getBssid() return !__bssid.empty(); } -void DeviceStatusWifi::__clearBssid() +void WifiStateProvider::__clearBssid() { __bssid.clear(); SharedVars().clear(SharedVars::WIFI_BSSID); _D("No WiFi connection"); } -bool DeviceStatusWifi::__getResponsePacket(Json* data) +bool WifiStateProvider::__getResponsePacket(Json* data) { switch (__lastState) { case DISABLED: @@ -143,7 +143,7 @@ bool DeviceStatusWifi::__getResponsePacket(Json* data) return true; } -int DeviceStatusWifi::read() +int WifiStateProvider::read() { IF_FAIL_RETURN(__getCurrentState(), ERR_OPERATION_FAILED); @@ -156,7 +156,7 @@ int DeviceStatusWifi::read() return ERR_OPERATION_FAILED; } -bool DeviceStatusWifi::__startMonitor() +bool WifiStateProvider::__startMonitor() { IF_FAIL_RETURN(!__isInitialized, true); @@ -178,7 +178,7 @@ CATCH: return false; } -void DeviceStatusWifi::__stopMonitor() +void WifiStateProvider::__stopMonitor() { IF_FAIL_VOID(__isInitialized); @@ -188,7 +188,7 @@ void DeviceStatusWifi::__stopMonitor() __isInitialized = false; } -int DeviceStatusWifi::subscribe() +int WifiStateProvider::subscribe() { #if 0 IF_FAIL_RETURN(__startMonitor(), ERR_OPERATION_FAILED); @@ -201,7 +201,7 @@ int DeviceStatusWifi::subscribe() return ERR_NONE; } -int DeviceStatusWifi::unsubscribe() +int WifiStateProvider::unsubscribe() { #if 0 __stopMonitor(); @@ -209,7 +209,7 @@ int DeviceStatusWifi::unsubscribe() return ERR_NONE; } -void DeviceStatusWifi::__handleUpdate() +void WifiStateProvider::__handleUpdate() { int prevState = __lastState; @@ -236,16 +236,16 @@ void DeviceStatusWifi::__handleUpdate() } } -void DeviceStatusWifi::__deviceStateChangedCb(wifi_device_state_e state, void *userData) +void WifiStateProvider::__deviceStateChangedCb(wifi_device_state_e state, void *userData) { - DeviceStatusWifi *instance = static_cast(userData); + WifiStateProvider *instance = static_cast(userData); instance->__isActivated = (state == WIFI_DEVICE_STATE_ACTIVATED); instance->__handleUpdate(); } -void DeviceStatusWifi::__connectionStateChangedCb(wifi_connection_state_e state, wifi_ap_h ap, void *userData) +void WifiStateProvider::__connectionStateChangedCb(wifi_connection_state_e state, wifi_ap_h ap, void *userData) { - DeviceStatusWifi *instance = static_cast(userData); + WifiStateProvider *instance = static_cast(userData); instance->__connState = state; instance->__handleUpdate(); } diff --git a/src/wifi/Wifi.h b/src/wifi/Wifi.h index 35574b0..083a270 100644 --- a/src/wifi/Wifi.h +++ b/src/wifi/Wifi.h @@ -14,20 +14,20 @@ * limitations under the License. */ -#ifndef _DEVICE_SYSTEM_STATUS_WIFI_H_ -#define _DEVICE_SYSTEM_STATUS_WIFI_H_ +#ifndef _CONTEXT_WIFI_STATE_PROVIDER_H_ +#define _CONTEXT_WIFI_STATE_PROVIDER_H_ #include #include -#include "../shared/BasicProvider.h" -#include "../shared/ProviderTypes.h" +#include +#include namespace ctx { - class DeviceStatusWifi : public BasicProvider { + class WifiStateProvider : public BasicProvider { public: - DeviceStatusWifi(); - ~DeviceStatusWifi(); + WifiStateProvider(); + ~WifiStateProvider(); int subscribe(); int unsubscribe(); @@ -62,4 +62,4 @@ namespace ctx { }; } -#endif // _CONTEXT_SYSTEM_STATUS_WIFI_H_ +#endif /* _CONTEXT_SYSTEM_STATUS_WIFI_H_ */ -- 2.7.4 From ac6c766aa8be5dda9b80f3631964c8df05c937c3 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Fri, 22 Apr 2016 11:31:32 +0900 Subject: [PATCH 11/16] Code cleanup: merge geofence-related macros into ProviderTypes.h Change-Id: Ibb731bfdc6c34c6ba999c0798bda9c48142afc7c Signed-off-by: Mu-Woong Lee --- src/geofence/GeofenceMonitorHandle.cpp | 14 ++++++-------- src/geofence/PlaceGeofenceProvider.cpp | 6 +++--- src/geofence/PlaceGeofenceProvider.h | 2 +- src/geofence/PlaceGeofenceTypes.h | 35 ---------------------------------- src/shared/PlaceContextProvider.cpp | 4 +++- src/shared/ProviderTypes.h | 5 +++++ 6 files changed, 18 insertions(+), 48 deletions(-) delete mode 100644 src/geofence/PlaceGeofenceTypes.h diff --git a/src/geofence/GeofenceMonitorHandle.cpp b/src/geofence/GeofenceMonitorHandle.cpp index 868966a..cf896b2 100644 --- a/src/geofence/GeofenceMonitorHandle.cpp +++ b/src/geofence/GeofenceMonitorHandle.cpp @@ -169,11 +169,11 @@ void GeofenceMonitorHandle::__emitStateChange() __prevState = currentState; Json option; - option.set(NULL, PLACE_GEOFENCE_PLACE_ID, __placeId); + option.set(NULL, KEY_PLACE_ID, __placeId); Json data; - data.set(NULL, PLACE_GEOFENCE_PLACE_ID, __placeId); - data.set(NULL, PLACE_GEOFENCE_EVENT, __getStateString(currentState)); + data.set(NULL, KEY_PLACE_ID, __placeId); + data.set(NULL, KEY_EVENT, __getStateString(currentState)); __provider->publish(option, ERR_NONE, data); } @@ -182,13 +182,11 @@ const char* GeofenceMonitorHandle::__getStateString(geofence_state_e state) { switch (state) { case GEOFENCE_STATE_IN: - return PLACE_GEOFENCE_IN; + return VAL_IN; case GEOFENCE_STATE_OUT: - return PLACE_GEOFENCE_OUT; - case GEOFENCE_STATE_UNCERTAIN: - return PLACE_GEOFENCE_UNCERTAIN; + return VAL_OUT; default: - return PLACE_GEOFENCE_UNCERTAIN; + return VAL_UNCERTAIN; } } diff --git a/src/geofence/PlaceGeofenceProvider.cpp b/src/geofence/PlaceGeofenceProvider.cpp index e7aff50..718271b 100644 --- a/src/geofence/PlaceGeofenceProvider.cpp +++ b/src/geofence/PlaceGeofenceProvider.cpp @@ -21,7 +21,7 @@ using namespace ctx; PlaceGeofenceProvider::PlaceGeofenceProvider() : - ContextProvider(PLACE_SUBJ_GEOFENCE) + ContextProvider(SUBJ_PLACE_GEOFENCE) { } @@ -56,7 +56,7 @@ void PlaceGeofenceProvider::submitTriggerItem() int PlaceGeofenceProvider::subscribe(Json option, Json *requestResult) { int placeId = -1; - option.get(NULL, PLACE_GEOFENCE_PLACE_ID, &placeId); + option.get(NULL, KEY_PLACE_ID, &placeId); IF_FAIL_RETURN_TAG(placeId != -1, ERR_INVALID_PARAMETER, _E, "Getting PlaceID failed"); auto it = __handleMap.find(placeId); @@ -83,7 +83,7 @@ int PlaceGeofenceProvider::subscribe(Json option, Json *requestResult) int PlaceGeofenceProvider::unsubscribe(Json option) { int placeId = -1; - option.get(NULL, PLACE_GEOFENCE_PLACE_ID, &placeId); + option.get(NULL, KEY_PLACE_ID, &placeId); IF_FAIL_RETURN_TAG(placeId != -1, ERR_INVALID_PARAMETER, _E, "Getting PlaceID failed"); auto it = __handleMap.find(placeId); diff --git a/src/geofence/PlaceGeofenceProvider.h b/src/geofence/PlaceGeofenceProvider.h index e6ebf2f..286b239 100644 --- a/src/geofence/PlaceGeofenceProvider.h +++ b/src/geofence/PlaceGeofenceProvider.h @@ -19,7 +19,7 @@ #include #include -#include "PlaceGeofenceTypes.h" +#include namespace ctx { diff --git a/src/geofence/PlaceGeofenceTypes.h b/src/geofence/PlaceGeofenceTypes.h deleted file mode 100644 index fa66a41..0000000 --- a/src/geofence/PlaceGeofenceTypes.h +++ /dev/null @@ -1,35 +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_PLACE_GEOFENCE_TYPES_H_ -#define _CONTEXT_PLACE_GEOFENCE_TYPES_H_ - -// Subject -#define PLACE_SUBJ_GEOFENCE "place/geofence" - -// Privilege -#define PLACE_PRIV_GEOFENCE "location" - -// Option & Data Key -#define PLACE_GEOFENCE_PLACE_ID "PlaceId" -#define PLACE_GEOFENCE_EVENT "Event" - -// Data Value -#define PLACE_GEOFENCE_UNCERTAIN "Uncertain" -#define PLACE_GEOFENCE_IN "In" -#define PLACE_GEOFENCE_OUT "Out" - -#endif /* End of _CONTEXT_PLACE_GEOFENCE_TYPES_H_ */ diff --git a/src/shared/PlaceContextProvider.cpp b/src/shared/PlaceContextProvider.cpp index eba5ff0..ec00515 100644 --- a/src/shared/PlaceContextProvider.cpp +++ b/src/shared/PlaceContextProvider.cpp @@ -23,6 +23,8 @@ #include "../my-place/place_recognition.h" #endif /* _MOBILE_ */ +#define PRIV_LOCATION "location" + template void registerProvider(const char *subject, const char *privilege) { @@ -41,7 +43,7 @@ void registerProvider(const char *subject, const char *privilege) SO_EXPORT bool ctx::initPlaceContextProvider() { #ifdef _MOBILE_ - registerProvider(PLACE_SUBJ_GEOFENCE, PLACE_PRIV_GEOFENCE); + registerProvider(SUBJ_PLACE_GEOFENCE, PRIV_LOCATION); /* registerProvider(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION); diff --git a/src/shared/ProviderTypes.h b/src/shared/ProviderTypes.h index 667da28..03ddd38 100644 --- a/src/shared/ProviderTypes.h +++ b/src/shared/ProviderTypes.h @@ -48,6 +48,7 @@ #define SUBJ_ACTIVITY_STATIONARY "activity/stationary" #define SUBJ_ACTIVITY_WALKING "activity/walking" +#define SUBJ_PLACE_GEOFENCE "place/geofence" /* Data & Option Keys */ #define KEY_QUERY_RESULT "QueryResult" @@ -90,6 +91,7 @@ #define KEY_TIME_OF_DAY "TimeOfDay" #define KEY_DAY_OF_WEEK "DayOfWeek" #define KEY_DAY_OF_MONTH "DayOfMonth" +#define KEY_PLACE_ID "PlaceId" /* Data & Option Values */ @@ -124,6 +126,9 @@ #define VAL_PERSON "Person" #define VAL_CHANGED "Changed" #define VAL_DETECTED "Detected" +#define VAL_UNCERTAIN "Uncertain" +#define VAL_IN "In" +#define VAL_OUT "Out" #define VAL_ACTIVE VAL_CONNECTED #define VAL_ALERTING VAL_CONNECTING -- 2.7.4 From 90cd9a1048f844b7df3baeb7b537c6fa7717e2f7 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Fri, 22 Apr 2016 18:04:14 +0900 Subject: [PATCH 12/16] Split the .a file into .so files Each .so provides create() function, and contextd will the function for each so. Later, the create() will be updated to support on-demand loading of providers. Change-Id: Icc9f204941500c5e9d95f39644d4001fba36c76b Signed-off-by: Mu-Woong Lee --- CMakeLists.txt | 107 +-------------------- context-provider.pc.in | 13 --- packaging/context-provider.spec | 17 +--- src/CMakeLists.txt | 24 +++++ src/activity/Activity.cpp | 2 +- src/activity/CMakeLists.txt | 19 ++++ .../activity/create.cpp | 31 +++--- src/app-stats/CMakeLists.txt | 23 +++++ src/app-stats/create.cpp | 38 ++++++++ src/call/CMakeLists.txt | 20 ++++ .../PlaceContextProvider.h => src/call/create.cpp | 19 ++-- src/contacts/CMakeLists.txt | 19 ++++ src/contacts/create.cpp | 31 ++++++ src/email/CMakeLists.txt | 19 ++++ .../email/create.cpp | 19 ++-- src/geofence/CMakeLists.txt | 19 ++++ src/geofence/create.cpp | 31 ++++++ src/headphone/CMakeLists.txt | 20 ++++ src/headphone/create.cpp | 31 ++++++ src/media-stats/CMakeLists.txt | 19 ++++ src/media-stats/create.cpp | 38 ++++++++ src/message/CMakeLists.txt | 19 ++++ src/message/create.cpp | 31 ++++++ src/my-place/CMakeLists.txt | 20 ++++ src/my-place/create.cpp | 33 +++++++ src/shared/BasicProvider.h | 2 +- src/shared/CMakeLists.txt | 19 ++++ src/shared/DbHandleBase.h | 2 +- src/shared/DeviceContextProvider.cpp | 91 ------------------ src/shared/ProviderTypes.h | 9 ++ src/shared/StatisticsContextProvider.cpp | 70 -------------- src/shared/SystemInfo.cpp | 6 +- src/shared/Util.cpp | 2 +- src/shared/{PlaceContextProvider.cpp => create.h} | 26 +---- src/social-stats/CMakeLists.txt | 19 ++++ src/social-stats/create.cpp | 34 +++++++ src/system/CMakeLists.txt | 22 +++++ src/system/create.cpp | 39 ++++++++ src/time/CMakeLists.txt | 18 ++++ src/time/create.cpp | 33 +++++++ src/wifi/CMakeLists.txt | 19 ++++ .../DeviceContextProvider.h => src/wifi/create.cpp | 19 ++-- 42 files changed, 734 insertions(+), 358 deletions(-) delete mode 100644 context-provider.pc.in create mode 100644 src/CMakeLists.txt create mode 100644 src/activity/CMakeLists.txt rename include/CustomContextProvider.h => src/activity/create.cpp (51%) create mode 100644 src/app-stats/CMakeLists.txt create mode 100644 src/app-stats/create.cpp create mode 100644 src/call/CMakeLists.txt rename include/PlaceContextProvider.h => src/call/create.cpp (60%) create mode 100644 src/contacts/CMakeLists.txt create mode 100644 src/contacts/create.cpp create mode 100644 src/email/CMakeLists.txt rename include/StatisticsContextProvider.h => src/email/create.cpp (61%) create mode 100644 src/geofence/CMakeLists.txt create mode 100644 src/geofence/create.cpp create mode 100644 src/headphone/CMakeLists.txt create mode 100644 src/headphone/create.cpp create mode 100644 src/media-stats/CMakeLists.txt create mode 100644 src/media-stats/create.cpp create mode 100644 src/message/CMakeLists.txt create mode 100644 src/message/create.cpp create mode 100644 src/my-place/CMakeLists.txt create mode 100644 src/my-place/create.cpp create mode 100644 src/shared/CMakeLists.txt delete mode 100644 src/shared/DeviceContextProvider.cpp delete mode 100644 src/shared/StatisticsContextProvider.cpp rename src/shared/{PlaceContextProvider.cpp => create.h} (64%) create mode 100644 src/social-stats/CMakeLists.txt create mode 100644 src/social-stats/create.cpp create mode 100644 src/system/CMakeLists.txt create mode 100644 src/system/create.cpp create mode 100644 src/time/CMakeLists.txt create mode 100644 src/time/create.cpp create mode 100644 src/wifi/CMakeLists.txt rename include/DeviceContextProvider.h => src/wifi/create.cpp (60%) diff --git a/CMakeLists.txt b/CMakeLists.txt index f776afe..2865cb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,16 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(context-provider) INCLUDE(GNUInstallDirs) -SET(target "context-provider") -SET(compile_defs "LOG_TAG=\"CONTEXT\"") +SET(target_prefix "ctx-prvd") # Common Options INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src/shared ) -ADD_DEFINITIONS(-O2 -Wall -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden) +ADD_DEFINITIONS(-O2 -Wall -fPIC -fdata-sections -ffunction-sections) +ADD_DEFINITIONS(-fvisibility=hidden) +ADD_DEFINITIONS(-DLOG_TAG="CONTEXT") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIC -Wl,--as-needed -Wl,--gc-section -Wl,--print-gc-section") # Profiles @@ -21,102 +22,4 @@ IF("${PROFILE}" STREQUAL "wearable") ADD_DEFINITIONS("-D_WEARABLE_") ENDIF("${PROFILE}" STREQUAL "wearable") - -# Dependency & Source -SET(DEPS - libcontext-server - vconf - capi-system-info - capi-system-device - capi-system-runtime-info - capi-appfw-package-manager - capi-appfw-application - capi-appfw-app-manager - pkgmgr - pkgmgr-info - capi-media-sound-manager - capi-network-bluetooth - capi-network-wifi - motion -) - -FILE(GLOB SRCS - src/shared/*.cpp - src/time/*.cpp - src/activity/*.cpp - src/app-stats/*.cpp - src/headphone/*.cpp - src/system/*.cpp - src/wifi/*.cpp -) - -IF("${PROFILE}" STREQUAL "mobile") -SET(DEPS ${DEPS} - msg-service - contacts-service2 - tapi - capi-telephony - capi-messaging-email - capi-content-media-content - capi-location-manager - capi-geofence-manager -) - -FILE(GLOB SRCS ${SRCS} - src/call/*.cpp - src/contacts/*.cpp - src/email/*.cpp - src/geofence/*.cpp - src/media-stats/*.cpp - src/message/*.cpp - src/my-place/*.cpp - src/my-place/user_places/*.cpp - src/social-stats/*.cpp -) -ENDIF("${PROFILE}" STREQUAL "mobile") - - -# Build -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(DEPS REQUIRED ${DEPS}) - -FOREACH(flag ${DEPS_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -ADD_LIBRARY(${target} STATIC ${SRCS}) -TARGET_LINK_LIBRARIES(${target} ${DEPS_LDFLAGS}) -SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS}) -SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "${compile_defs}") -SET_TARGET_PROPERTIES(${target} PROPERTIES SOVERSION ${MAJORVER}) -SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${FULLVER}) - -# Package Config -FOREACH(item IN LISTS DEPS) - SET(deps_str "${deps_str} ${item}") -ENDFOREACH(item) - -SET(VERSION ${FULLVER}) -SET(PREFIX ${CMAKE_INSTALL_PREFIX}) -SET(PC_NAME ${PROJECT_NAME}) -SET(PC_DESCRIPTION "Tizen Context Framework Context Provider") -SET(PC_INCLUDE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/context-service") -SET(PC_LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") -SET(PC_CFLAGS "-I\${includedir}/context-service") -SET(PC_LDFLAGS "-l${target}") -SET(PC_REQUIRED "${deps_str}") - -CONFIGURE_FILE( - ${PROJECT_NAME}.pc.in - ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc - @ONLY -) - -# Installing -INSTALL( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/context-service/internal - FILES_MATCHING PATTERN "*.h" -) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +ADD_SUBDIRECTORY(src) diff --git a/context-provider.pc.in b/context-provider.pc.in deleted file mode 100644 index 378b991..0000000 --- a/context-provider.pc.in +++ /dev/null @@ -1,13 +0,0 @@ -#Package Information for pkg-config - -prefix=@PREFIX@ -exec_prefix=@PREFIX@ -libdir=@PC_LIBDIR@ -includedir=@PC_INCLUDE@ - -Name: @PC_NAME@ -Description: @PC_DESCRIPTION@ -Version: @VERSION@ -Requires: @PC_REQUIRED@ -Libs: -L${libdir} @PC_LDFLAGS@ -Cflags: -I${includedir} diff --git a/packaging/context-provider.spec b/packaging/context-provider.spec index 598eb65..cd48f58 100644 --- a/packaging/context-provider.spec +++ b/packaging/context-provider.spec @@ -7,7 +7,6 @@ License: Apache-2.0 Source0: %{name}-%{version}.tar.gz %define BUILD_PROFILE %{?profile}%{!?profile:%{?tizen_profile_name}} -%define keepstatic 1 %if "%{?BUILD_PROFILE}" == "tv" ExcludeArch: %{arm} aarch64 %ix86 x86_64 @@ -90,17 +89,5 @@ cp LICENSE %{buildroot}/usr/share/license/%{name} %manifest packaging/%{name}.manifest %defattr(-,root,root,-) /usr/share/license/%{name} - -%package devel -Summary: Context Provider (Development) -Group: Service/Context -Requires: %{name} = %{version}-%{release} - -%description devel -Context Provider (Development) - -%files devel -%defattr(-,root,root,-) -%{_includedir}/context-service/internal/*.h -%{_libdir}/pkgconfig/%{name}.pc -%{_libdir}/*.a +%{_libdir}/*.so* +%{_libdir}/context/*.so* diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..2d1bb6a --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,24 @@ +SET(target_shared "${target_prefix}-shared") +SET(DEPS + libcontext-server +) + +ADD_SUBDIRECTORY(shared) +ADD_SUBDIRECTORY(activity) +ADD_SUBDIRECTORY(app-stats) +#ADD_SUBDIRECTORY(custom) +ADD_SUBDIRECTORY(headphone) +ADD_SUBDIRECTORY(system) +ADD_SUBDIRECTORY(time) +ADD_SUBDIRECTORY(wifi) + +IF("${PROFILE}" STREQUAL "mobile") +ADD_SUBDIRECTORY(call) +ADD_SUBDIRECTORY(contacts) +ADD_SUBDIRECTORY(email) +ADD_SUBDIRECTORY(geofence) +ADD_SUBDIRECTORY(media-stats) +ADD_SUBDIRECTORY(message) +ADD_SUBDIRECTORY(my-place) +ADD_SUBDIRECTORY(social-stats) +ENDIF("${PROFILE}" STREQUAL "mobile") diff --git a/src/activity/Activity.cpp b/src/activity/Activity.cpp index a71dbfb..017c061 100644 --- a/src/activity/Activity.cpp +++ b/src/activity/Activity.cpp @@ -19,7 +19,7 @@ using namespace ctx; -ActivityProvider::ActivityProvider(const char *subject, activity_type_e type) : +ActivityProvider::ActivityProvider(const char *subject, activity_type_e type) : BasicProvider(subject), __activityType(type), __activityHandle(NULL) diff --git a/src/activity/CMakeLists.txt b/src/activity/CMakeLists.txt new file mode 100644 index 0000000..29e8f5d --- /dev/null +++ b/src/activity/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(target "${target_prefix}-activity") + +SET(DEPS ${DEPS} + motion +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_ACTIVITY REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_ACTIVITY_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_ACTIVITY_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/include/CustomContextProvider.h b/src/activity/create.cpp similarity index 51% rename from include/CustomContextProvider.h rename to src/activity/create.cpp index b000fa5..5009ae3 100644 --- a/include/CustomContextProvider.h +++ b/src/activity/create.cpp @@ -14,24 +14,21 @@ * limitations under the License. */ -#ifndef _CONTEXT_CUSTOM_CONTEXT_PROVIDER_H_ -#define _CONTEXT_CUSTOM_CONTEXT_PROVIDER_H_ +#include +#include +#include "Activity.h" -namespace ctx { +using namespace ctx; - bool initCustomContextProvider(); +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ - namespace custom_context_provider { +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_ACTIVITY_STATIONARY, NULL); + registerProvider(SUBJ_ACTIVITY_WALKING, NULL); + registerProvider(SUBJ_ACTIVITY_RUNNING, NULL); + registerProvider(SUBJ_ACTIVITY_IN_VEHICLE, NULL); - int addItem(std::string subject, std::string name, ctx::Json tmpl, const char* owner, bool isInit = false); - int removeItem(std::string subject); - int publishData(std::string subject, ctx::Json fact); - - ContextProvider* create(void* data); - void destroy(void* data); - - } /* namespace custom_context_provider */ - -} /* namespace ctx */ - -#endif /* End of _CONTEXT_CUSTOM_CONTEXT_PROVIDER_H_ */ + return true; +} diff --git a/src/app-stats/CMakeLists.txt b/src/app-stats/CMakeLists.txt new file mode 100644 index 0000000..70b329e --- /dev/null +++ b/src/app-stats/CMakeLists.txt @@ -0,0 +1,23 @@ +SET(target "${target_prefix}-app-stats") + +SET(DEPS ${DEPS} + capi-appfw-package-manager + capi-appfw-application + capi-appfw-app-manager + pkgmgr + pkgmgr-info +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_APP_STATS REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_APP_STATS_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_APP_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/app-stats/create.cpp b/src/app-stats/create.cpp new file mode 100644 index 0000000..5002f9a --- /dev/null +++ b/src/app-stats/create.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016 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 +#include "AppStatsProvider.h" +#include "AppStatsLogger.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(APP_SUBJ_LOGGER, 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); + + return true; +} diff --git a/src/call/CMakeLists.txt b/src/call/CMakeLists.txt new file mode 100644 index 0000000..8a60b79 --- /dev/null +++ b/src/call/CMakeLists.txt @@ -0,0 +1,20 @@ +SET(target "${target_prefix}-call") + +SET(DEPS ${DEPS} + tapi + capi-telephony +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_CALL REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_CALL_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_CALL_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/include/PlaceContextProvider.h b/src/call/create.cpp similarity index 60% rename from include/PlaceContextProvider.h rename to src/call/create.cpp index e7585b0..235db22 100644 --- a/include/PlaceContextProvider.h +++ b/src/call/create.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -14,13 +14,18 @@ * limitations under the License. */ -#ifndef _CONTEXT_PLACE_CONTEXT_PROVIDER_H_ -#define _CONTEXT_PLACE_CONTEXT_PROVIDER_H_ +#include +#include +#include "Call.h" -namespace ctx { +using namespace ctx; - bool initPlaceContextProvider(); +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ -} /* namespace ctx */ +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_STATE_CALL, PRIV_TELEPHONY); -#endif /* End of _CONTEXT_PLACE_CONTEXT_PROVIDER_H_ */ + return true; +} diff --git a/src/contacts/CMakeLists.txt b/src/contacts/CMakeLists.txt new file mode 100644 index 0000000..6773a23 --- /dev/null +++ b/src/contacts/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(target "${target_prefix}-contacts") + +SET(DEPS ${DEPS} + contacts-service2 +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_CONTACTS REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_CONTACTS_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_CONTACTS_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/contacts/create.cpp b/src/contacts/create.cpp new file mode 100644 index 0000000..b4b34b6 --- /dev/null +++ b/src/contacts/create.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016 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 +#include "Contacts.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_STATE_CONTACTS, PRIV_CONTACT); + + return true; +} diff --git a/src/email/CMakeLists.txt b/src/email/CMakeLists.txt new file mode 100644 index 0000000..d6d6687 --- /dev/null +++ b/src/email/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(target "${target_prefix}-email") + +SET(DEPS ${DEPS} + capi-messaging-email +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_EMAIL REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_EMAIL_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_EMAIL_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/include/StatisticsContextProvider.h b/src/email/create.cpp similarity index 61% rename from include/StatisticsContextProvider.h rename to src/email/create.cpp index f356719..ac15430 100644 --- a/include/StatisticsContextProvider.h +++ b/src/email/create.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -14,13 +14,18 @@ * limitations under the License. */ -#ifndef _CONTEXT_STATISTICS_CONTEXT_PROVIDER_H_ -#define _CONTEXT_STATISTICS_CONTEXT_PROVIDER_H_ +#include +#include +#include "Email.h" -namespace ctx { +using namespace ctx; - bool initStatisticsContextProvider(); +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ -} /* namespace ctx */ +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_STATE_EMAIL, NULL); -#endif /* End of _CONTEXT_STATISTICS_CONTEXT_PROVIDER_H_ */ + return true; +} diff --git a/src/geofence/CMakeLists.txt b/src/geofence/CMakeLists.txt new file mode 100644 index 0000000..c52a0b0 --- /dev/null +++ b/src/geofence/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(target "${target_prefix}-geofence") + +SET(DEPS ${DEPS} + capi-geofence-manager +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_GEOFENCE REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_GEOFENCE_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_GEOFENCE_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/geofence/create.cpp b/src/geofence/create.cpp new file mode 100644 index 0000000..6f9ccbe --- /dev/null +++ b/src/geofence/create.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016 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 +#include "PlaceGeofenceProvider.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_PLACE_GEOFENCE, PRIV_LOCATION); + + return true; +} diff --git a/src/headphone/CMakeLists.txt b/src/headphone/CMakeLists.txt new file mode 100644 index 0000000..1730405 --- /dev/null +++ b/src/headphone/CMakeLists.txt @@ -0,0 +1,20 @@ +SET(target "${target_prefix}-headphone") + +SET(DEPS ${DEPS} + capi-system-runtime-info + capi-network-bluetooth +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_HEADPHONE REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_HEADPHONE_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_HEADPHONE_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/headphone/create.cpp b/src/headphone/create.cpp new file mode 100644 index 0000000..79fa6a7 --- /dev/null +++ b/src/headphone/create.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016 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 +#include "Headphone.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_STATE_HEADPHONE, NULL); + + return true; +} diff --git a/src/media-stats/CMakeLists.txt b/src/media-stats/CMakeLists.txt new file mode 100644 index 0000000..cb22916 --- /dev/null +++ b/src/media-stats/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(target "${target_prefix}-media-stats") + +SET(DEPS ${DEPS} + capi-content-media-content +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_MEDIA_STATS REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_MEDIA_STATS_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_MEDIA_STATS_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/media-stats/create.cpp b/src/media-stats/create.cpp new file mode 100644 index 0000000..48f4ee9 --- /dev/null +++ b/src/media-stats/create.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016 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 +#include "MediaStatsProvider.h" +#include "MediaStatsLogger.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(MEDIA_SUBJ_LOGGER, 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); + + return true; +} diff --git a/src/message/CMakeLists.txt b/src/message/CMakeLists.txt new file mode 100644 index 0000000..0de59a0 --- /dev/null +++ b/src/message/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(target "${target_prefix}-message") + +SET(DEPS ${DEPS} + msg-service +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_MESSAGE REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_MESSAGE_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_MESSAGE_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/message/create.cpp b/src/message/create.cpp new file mode 100644 index 0000000..7588850 --- /dev/null +++ b/src/message/create.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016 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 +#include "Message.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_STATE_MESSAGE, PRIV_MESSAGE); + + return true; +} diff --git a/src/my-place/CMakeLists.txt b/src/my-place/CMakeLists.txt new file mode 100644 index 0000000..5277817 --- /dev/null +++ b/src/my-place/CMakeLists.txt @@ -0,0 +1,20 @@ +SET(target "${target_prefix}-my-place") + +SET(DEPS ${DEPS} + capi-location-manager + capi-network-wifi +) + +FILE(GLOB_RECURSE SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_MYPLACE REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_MYPLACE_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_MYPLACE_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/my-place/create.cpp b/src/my-place/create.cpp new file mode 100644 index 0000000..91cdaf9 --- /dev/null +++ b/src/my-place/create.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016 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 +#include "place_recognition.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + /* + registerProvider(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION); + */ + + return true; +} diff --git a/src/shared/BasicProvider.h b/src/shared/BasicProvider.h index 84b0838..069cc3a 100644 --- a/src/shared/BasicProvider.h +++ b/src/shared/BasicProvider.h @@ -24,7 +24,7 @@ namespace ctx { /* BasicProvider implements the very basic form of context providers, which has no controllable options, and does not set the requestResult parameter to reply to clients' requests immediately. */ - class BasicProvider : public ContextProvider { + class SO_EXPORT BasicProvider : public ContextProvider { public: int subscribe(Json option, Json *requestResult); int unsubscribe(Json option); diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt new file mode 100644 index 0000000..fc20fe4 --- /dev/null +++ b/src/shared/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(DEPS ${DEPS} + capi-system-info + capi-system-runtime-info + capi-media-sound-manager +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_SHARED REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_SHARED_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target_shared} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target_shared} ${PKG_SHARED_LDFLAGS}) + +INSTALL(TARGETS ${target_shared} DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/src/shared/DbHandleBase.h b/src/shared/DbHandleBase.h index 8949550..3404821 100644 --- a/src/shared/DbHandleBase.h +++ b/src/shared/DbHandleBase.h @@ -22,7 +22,7 @@ #include namespace ctx { - class StatsDbHandleBase : public IDatabaseListener { + class SO_EXPORT StatsDbHandleBase : public IDatabaseListener { protected: bool isTriggerItem; ContextProvider *reqProvider; diff --git a/src/shared/DeviceContextProvider.cpp b/src/shared/DeviceContextProvider.cpp deleted file mode 100644 index 1726c98..0000000 --- a/src/shared/DeviceContextProvider.cpp +++ /dev/null @@ -1,91 +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 - -#include "../time/Alarm.h" -#include "../time/Time.h" -#include "../activity/Activity.h" -#include "../headphone/Headphone.h" -#include "../system/Battery.h" -#include "../system/Charger.h" -#include "../system/Gps.h" -#include "../system/Psmode.h" -#include "../system/Usb.h" -#include "../wifi/Wifi.h" - -#ifdef _MOBILE_ -#include "../call/Call.h" -#include "../contacts/Contacts.h" -#include "../email/Email.h" -#include "../message/Message.h" -#endif - -#define PRIV_NETWORK "network.get" -#define PRIV_TELEPHONY "telephony" -#define PRIV_MESSAGE "message.read" -#define PRIV_CONTACT "contact.read" - -template -void registerProvider(const char *subject, const char *privilege) -{ - Provider *provider = new(std::nothrow) Provider(); - IF_FAIL_VOID_TAG(provider, _E, "Memory allocation failed"); - - if (!provider->isSupported()) { - delete provider; - return; - } - - provider->registerProvider(privilege, provider); - provider->submitTriggerItem(); -} - -SO_EXPORT bool ctx::initDeviceContextProvider() -{ - registerProvider(SUBJ_STATE_ALARM, NULL); - registerProvider(SUBJ_STATE_TIME, NULL); - - registerProvider(SUBJ_STATE_WIFI, PRIV_NETWORK); - registerProvider(SUBJ_STATE_HEADPHONE, NULL); - - registerProvider(SUBJ_STATE_CHARGER, NULL); - registerProvider(SUBJ_STATE_GPS, NULL); - registerProvider(SUBJ_STATE_USB, NULL); - registerProvider(SUBJ_STATE_BATTERY, NULL); - registerProvider(SUBJ_STATE_PSMODE, NULL); - - registerProvider(SUBJ_ACTIVITY_STATIONARY, NULL); - registerProvider(SUBJ_ACTIVITY_WALKING, NULL); - registerProvider(SUBJ_ACTIVITY_RUNNING, NULL); - registerProvider(SUBJ_ACTIVITY_IN_VEHICLE, NULL); - -#ifdef _MOBILE_ - registerProvider(SUBJ_STATE_CALL, PRIV_TELEPHONY); - registerProvider(SUBJ_STATE_EMAIL, NULL); - registerProvider(SUBJ_STATE_MESSAGE, PRIV_MESSAGE); - registerProvider(SUBJ_STATE_CONTACTS, PRIV_CONTACT); - - /* Create context providers, which need to be initiated before being subscribed */ - /* - if (WifiStateProvider::isSupported()) - WifiStateProvider::create(NULL); - */ -#endif - - return true; -} diff --git a/src/shared/ProviderTypes.h b/src/shared/ProviderTypes.h index 03ddd38..f5d0bac 100644 --- a/src/shared/ProviderTypes.h +++ b/src/shared/ProviderTypes.h @@ -18,6 +18,15 @@ #define _CONTEXT_PROVIDER_TYPES_H_ +/* Privileges */ +#define PRIV_ALARM "alarm.set" +#define PRIV_NETWORK "network.get" +#define PRIV_TELEPHONY "telephony" +#define PRIV_MESSAGE "message.read" +#define PRIV_CONTACT "contact.read" +#define PRIV_LOCATION "location" + + /* FW-wide Data Logger Parameters */ #define LOG_RETENTION_PERIOD 7776000 /* 90 days in secs */ diff --git a/src/shared/StatisticsContextProvider.cpp b/src/shared/StatisticsContextProvider.cpp deleted file mode 100644 index d547b60..0000000 --- a/src/shared/StatisticsContextProvider.cpp +++ /dev/null @@ -1,70 +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 - -#include "../app-stats/AppStatsProvider.h" -#include "../app-stats/AppStatsLogger.h" - -#ifdef _MOBILE_ -#include "../media-stats/MediaStatsProvider.h" -#include "../media-stats/MediaStatsLogger.h" -#include "../social-stats/SocialStatsProvider.h" -#include "../social-stats/SocialStatsLogger.h" -#endif - -template -void registerProvider(const char *subject, const char *privilege) -{ - Provider *provider = new(std::nothrow) Provider(); - IF_FAIL_VOID_TAG(provider, _E, "Memory allocation failed"); - - if (!provider->isSupported()) { - delete provider; - return; - } - - provider->registerProvider(privilege, provider); - provider->submitTriggerItem(); -} - -SO_EXPORT bool ctx::initStatisticsContextProvider() -{ - registerProvider(APP_SUBJ_LOGGER, 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); - -#ifdef _MOBILE_ - registerProvider(MEDIA_SUBJ_LOGGER, 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); - - registerProvider(SOCIAL_SUBJ_LOGGER, SOCIAL_HISTORY_PRIV); - registerProvider(SOCIAL_SUBJ_FREQUENCY, SOCIAL_HISTORY_PRIV); - registerProvider(SOCIAL_SUBJ_FREQ_ADDRESS, SOCIAL_HISTORY_PRIV); -#endif - - return true; -} diff --git a/src/shared/SystemInfo.cpp b/src/shared/SystemInfo.cpp index 63731f7..72ef4fe 100644 --- a/src/shared/SystemInfo.cpp +++ b/src/shared/SystemInfo.cpp @@ -26,7 +26,7 @@ using namespace ctx; -bool system_info::getAudioJackState(int* state) +SO_EXPORT bool system_info::getAudioJackState(int* state) { int value = NOT_CONNECTED; int err = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &value); @@ -37,7 +37,7 @@ bool system_info::getAudioJackState(int* state) return true; } -bool system_info::getVolume(int* systemVolume, int* mediaVolume) +SO_EXPORT bool system_info::getVolume(int* systemVolume, int* mediaVolume) { int err; @@ -50,7 +50,7 @@ bool system_info::getVolume(int* systemVolume, int* mediaVolume) return true; } -bool system_info::getWifiBssid(std::string& bssid) +SO_EXPORT bool system_info::getWifiBssid(std::string& bssid) { #if 0 /* NOTE: This routine does not work, because the wifi API does not support multi-sessions in one process */ diff --git a/src/shared/Util.cpp b/src/shared/Util.cpp index e25d0db..bc32a57 100644 --- a/src/shared/Util.cpp +++ b/src/shared/Util.cpp @@ -18,7 +18,7 @@ #include #include "Util.h" -bool ctx::util::getSystemInfoBool(const char * key) +SO_EXPORT bool ctx::util::getSystemInfoBool(const char * key) { bool supported = false; int ret = system_info_get_platform_bool(key, &supported); diff --git a/src/shared/PlaceContextProvider.cpp b/src/shared/create.h similarity index 64% rename from src/shared/PlaceContextProvider.cpp rename to src/shared/create.h index ec00515..2c57b7a 100644 --- a/src/shared/PlaceContextProvider.cpp +++ b/src/shared/create.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -14,16 +14,11 @@ * limitations under the License. */ +/* TODO: This is a temporary template implementation. + This will be removed soon. */ + #include #include -#include - -#ifdef _MOBILE_ -#include "../geofence/PlaceGeofenceProvider.h" -#include "../my-place/place_recognition.h" -#endif /* _MOBILE_ */ - -#define PRIV_LOCATION "location" template void registerProvider(const char *subject, const char *privilege) @@ -39,16 +34,3 @@ void registerProvider(const char *subject, const char *privilege) provider->registerProvider(privilege, provider); provider->submitTriggerItem(); } - -SO_EXPORT bool ctx::initPlaceContextProvider() -{ -#ifdef _MOBILE_ - registerProvider(SUBJ_PLACE_GEOFENCE, PRIV_LOCATION); - - /* - registerProvider(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION); - */ - -#endif /* _MOBILE_ */ - return true; -} diff --git a/src/social-stats/CMakeLists.txt b/src/social-stats/CMakeLists.txt new file mode 100644 index 0000000..004286e --- /dev/null +++ b/src/social-stats/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(target "${target_prefix}-social-stats") + +SET(DEPS ${DEPS} + contacts-service2 +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_SOCIAL_STATS REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_SOCIAL_STATS_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_SOCIAL_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/social-stats/create.cpp b/src/social-stats/create.cpp new file mode 100644 index 0000000..a498c28 --- /dev/null +++ b/src/social-stats/create.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016 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 +#include "SocialStatsProvider.h" +#include "SocialStatsLogger.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(SOCIAL_SUBJ_LOGGER, SOCIAL_HISTORY_PRIV); + registerProvider(SOCIAL_SUBJ_FREQUENCY, SOCIAL_HISTORY_PRIV); + registerProvider(SOCIAL_SUBJ_FREQ_ADDRESS, SOCIAL_HISTORY_PRIV); + + return true; +} diff --git a/src/system/CMakeLists.txt b/src/system/CMakeLists.txt new file mode 100644 index 0000000..a349974 --- /dev/null +++ b/src/system/CMakeLists.txt @@ -0,0 +1,22 @@ +SET(target "${target_prefix}-system") + +SET(DEPS ${DEPS} + vconf + capi-system-info + capi-system-device + capi-system-runtime-info +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_SYSTEM REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_SYSTEM_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_SYSTEM_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/system/create.cpp b/src/system/create.cpp new file mode 100644 index 0000000..7add7b5 --- /dev/null +++ b/src/system/create.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2016 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 +#include "Battery.h" +#include "Charger.h" +#include "Gps.h" +#include "Psmode.h" +#include "Usb.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_STATE_BATTERY, NULL); + registerProvider(SUBJ_STATE_CHARGER, NULL); + registerProvider(SUBJ_STATE_GPS, NULL); + registerProvider(SUBJ_STATE_PSMODE, NULL); + registerProvider(SUBJ_STATE_USB, NULL); + + return true; +} diff --git a/src/time/CMakeLists.txt b/src/time/CMakeLists.txt new file mode 100644 index 0000000..1ea12af --- /dev/null +++ b/src/time/CMakeLists.txt @@ -0,0 +1,18 @@ +SET(target "${target_prefix}-time") + +#SET(DEPS ${DEPS} +#) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_TIME REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_TIME_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_TIME_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/time/create.cpp b/src/time/create.cpp new file mode 100644 index 0000000..e0da510 --- /dev/null +++ b/src/time/create.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016 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 +#include "Alarm.h" +#include "Time.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_STATE_ALARM, PRIV_ALARM); + registerProvider(SUBJ_STATE_TIME, NULL); + + return true; +} diff --git a/src/wifi/CMakeLists.txt b/src/wifi/CMakeLists.txt new file mode 100644 index 0000000..10ca397 --- /dev/null +++ b/src/wifi/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(target "${target_prefix}-wifi") + +SET(DEPS ${DEPS} + capi-network-wifi +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_WIFI REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_WIFI_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_WIFI_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/include/DeviceContextProvider.h b/src/wifi/create.cpp similarity index 60% rename from include/DeviceContextProvider.h rename to src/wifi/create.cpp index 1e47323..cb8a87e 100644 --- a/include/DeviceContextProvider.h +++ b/src/wifi/create.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -14,13 +14,18 @@ * limitations under the License. */ -#ifndef _CONTEXT_DEVICE_CONTEXT_PROVIDER_H_ -#define _CONTEXT_DEVICE_CONTEXT_PROVIDER_H_ +#include +#include +#include "Wifi.h" -namespace ctx { +using namespace ctx; - bool initDeviceContextProvider(); +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ -} /* namespace ctx */ +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_STATE_WIFI, PRIV_NETWORK); -#endif /* End of _CONTEXT_DEVICE_CONTEXT_PROVIDER_H_ */ + return true; +} -- 2.7.4 From d1dfb763b14d38b3657e301fb6f10d352d8e835b Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Tue, 26 Apr 2016 11:10:01 +0900 Subject: [PATCH 13/16] Add a header file for listing so file names & trigger templates Change-Id: Ia73e288620653fdbec1e060a23c7a5b286a70b73 Signed-off-by: Mu-Woong Lee --- CMakeLists.txt | 6 + include/ProviderList.h | 210 +++++++++++++++++++++++++++++++ {src/shared => include}/ProviderTypes.h | 38 +++++- packaging/context-provider.spec | 12 ++ src/app-stats/AppStatisticsTypes.h | 18 +-- src/media-stats/MediaStatisticsTypes.h | 20 +-- src/my-place/place_recognition_types.h | 4 +- src/shared/DbHandleBase.cpp | 2 +- src/social-stats/SocialStatisticsTypes.h | 10 +- 9 files changed, 290 insertions(+), 30 deletions(-) create mode 100644 include/ProviderList.h rename {src/shared => include}/ProviderTypes.h (74%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2865cb6..10eb09c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,4 +22,10 @@ IF("${PROFILE}" STREQUAL "wearable") ADD_DEFINITIONS("-D_WEARABLE_") ENDIF("${PROFILE}" STREQUAL "wearable") +INSTALL( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/context-service/internal + FILES_MATCHING PATTERN "*.h" +) + ADD_SUBDIRECTORY(src) diff --git a/include/ProviderList.h b/include/ProviderList.h new file mode 100644 index 0000000..e63feb7 --- /dev/null +++ b/include/ProviderList.h @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2016 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_PROVIDER_LIST_H_ +#define _CONTEXT_PROVIDER_LIST_H_ + +#include +#include + +#define LIB_DIRECTORY "/usr/lib/context/" +#define LIB_PREFIX "libctx-prvd-" +#define LIB_EXTENSION ".so" + +const struct { + const char *subject; + const char *library; +} subjectLibraryList[] = { + {SUBJ_ACTIVITY, "activity"}, + {SUBJ_APP_STATS, "app-stats"}, + {SUBJ_STATE_CALL, "call"}, + {SUBJ_STATE_CONTACTS, "contacts"}, + // {SUBJ_CUSTOM, ""}, + {SUBJ_STATE_EMAIL, "email"}, + {SUBJ_PLACE_GEOFENCE, "geofence"}, + {SUBJ_STATE_HEADPHONE, "headphone"}, + {SUBJ_MEDIA_LOGGER, "media-stats"}, + {SUBJ_MUSIC_STATS, "media-stats"}, + {SUBJ_VIDEO_STATS, "media-stats"}, + {SUBJ_STATE_MESSAGE, "message"}, + {SUBJ_PLACE_DETECTION, "my-place"}, + {SUBJ_SOCIAL_STATS, "social-stats"}, + {SUBJ_STATE_BATTERY, "system"}, + {SUBJ_STATE_CHARGER, "system"}, + {SUBJ_STATE_USB, "system"}, + {SUBJ_STATE_GPS, "system"}, + {SUBJ_STATE_PSMODE, "system"}, + {SUBJ_STATE_ALARM, "time"}, + {SUBJ_STATE_TIME, "time"}, + {SUBJ_STATE_WIFI, "wifi"} +}; + +const struct { + const char *subject; + int operation; + const char *attribute; + const char *option; +} triggerTemplateList[] = { + { + SUBJ_ACTIVITY, + OPS_SUBSCRIBE, + "{\"Event\":{\"type\":\"string\", \"values\":[\"Detected\"]}}", + "{\"Accuracy\":{\"type\":\"string\", \"values\":[\"Low\", \"Normal\", \"High\"]}}" + }, + { + SUBJ_APP_FREQUENCY, + OPS_READ, + "{" TRIG_DEF_RANK "," TRIG_DEF_TOTAL_COUNT "}", + "{" + "\"AppId\":{\"type\":\"string\"}," + TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK + "}" + }, + { + SUBJ_STATE_CALL, + OPS_SUBSCRIBE | OPS_READ, + /* TODO remove Connecting, Connected */ + "{" + "\"Medium\":{\"type\":\"string\",\"values\":[\"Voice\",\"Video\"]}," + "\"State\":{\"type\":\"string\",\"values\":[\"Idle\",\"Connecting\",\"Connected\"]}," + "\"Address\":{\"type\":\"string\"}" + "}", + NULL + }, + { + SUBJ_STATE_CONTACTS, + OPS_SUBSCRIBE, + "{" + "\"Event\":{\"type\":\"string\",\"values\":[\"Changed\"]}," + "\"Type\":{\"type\":\"string\",\"values\":[\"MyProfile\",\"Person\"]}" + "}", + NULL + }, + { + SUBJ_STATE_EMAIL, + OPS_SUBSCRIBE, + "{" + "\"Event\":{\"type\":\"string\",\"values\":[\"Received\",\"Sent\"]}" + "}", + NULL + }, + { + SUBJ_PLACE_GEOFENCE, + OPS_SUBSCRIBE, + "{" + "\"Event\":{\"type\":\"string\",\"values\":[\"In\",\"Out\"]}" + "}", + "{" + "\"PlaceId\":{\"type\":\"integer\",\"min\":1}" + "}" + }, + { + SUBJ_STATE_HEADPHONE, + OPS_SUBSCRIBE | OPS_READ, + "{" + TRIG_BOOL_ITEM_DEF("IsConnected") "," + "\"Type\":{\"type\":\"string\",\"values\":[\"Normal\",\"Headset\",\"Bluetooth\"]}" + "}", + NULL + }, + { + SUBJ_MUSIC_FREQUENCY, + OPS_READ, + "{" TRIG_DEF_TOTAL_COUNT "}", + "{" TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK "}" + }, + { + SUBJ_VIDEO_FREQUENCY, + OPS_READ, + "{" TRIG_DEF_TOTAL_COUNT "}", + "{" TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK "}" + }, + { + SUBJ_STATE_MESSAGE, + OPS_SUBSCRIBE, + "{" + "\"Event\":{\"type\":\"string\",\"values\":[\"Received\"]}," + "\"Type\":{\"type\":\"string\",\"values\":[\"SMS\",\"MMS\"]}," + "\"Address\":{\"type\":\"string\"}" + "}", + NULL + }, + { + SUBJ_SOCIAL_FREQUENCY, + OPS_READ, + "{" TRIG_DEF_RANK "," TRIG_DEF_TOTAL_COUNT "}", + "{" + "\"Address\":{\"type\":\"string\"}," + TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK + "}" + }, + { + SUBJ_STATE_BATTERY, + OPS_SUBSCRIBE | OPS_READ, + "{" + "\"Level\":{\"type\":\"string\",\"values\":[\"Empty\",\"Critical\",\"Low\",\"Normal\",\"High\",\"Full\"]}," + TRIG_BOOL_ITEM_DEF("IsCharging") + "}", + NULL + }, + { + SUBJ_STATE_CHARGER, + OPS_SUBSCRIBE | OPS_READ, + "{" TRIG_BOOL_ITEM_DEF("IsConnected") "}", + NULL + }, + { + SUBJ_STATE_GPS, + OPS_SUBSCRIBE | OPS_READ, + "{" + "\"State\":{\"type\":\"string\",\"values\":[\"Disabled\",\"Searching\",\"Connected\"]}" + "}", + NULL + }, + { + SUBJ_STATE_PSMODE, + OPS_SUBSCRIBE | OPS_READ, + "{" TRIG_BOOL_ITEM_DEF("IsEnabled") "}", + NULL + }, + { + SUBJ_STATE_USB, + OPS_SUBSCRIBE | OPS_READ, + "{" TRIG_BOOL_ITEM_DEF("IsConnected") "}", + NULL + }, + { + SUBJ_STATE_ALARM, + OPS_SUBSCRIBE, + "{" + "\"TimeOfDay\":{\"type\":\"integer\",\"min\":0,\"max\":1439}," + "\"DayOfWeek\":{\"type\":\"string\",\"values\":[\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\",\"Sun\",\"Weekday\",\"Weekend\"]}" + "}", + NULL + }, + { + SUBJ_STATE_TIME, + OPS_READ, + "{" + "\"TimeOfDay\":{\"type\":\"integer\",\"min\":0,\"max\":1439}," + "\"DayOfWeek\":{\"type\":\"string\",\"values\":[\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\",\"Sun\",\"Weekday\",\"Weekend\"]}," + "\"DayOfMonth\":{\"type\":\"integer\",\"min\":1,\"max\":31}" + "}", + NULL + } +}; + +#endif /* _CONTEXT_PROVIDER_TYPES_H_ */ diff --git a/src/shared/ProviderTypes.h b/include/ProviderTypes.h similarity index 74% rename from src/shared/ProviderTypes.h rename to include/ProviderTypes.h index f5d0bac..2ab4a96 100644 --- a/src/shared/ProviderTypes.h +++ b/include/ProviderTypes.h @@ -25,6 +25,9 @@ #define PRIV_MESSAGE "message.read" #define PRIV_CONTACT "contact.read" #define PRIV_LOCATION "location" +#define PRIV_APP_HISTORY "apphistory.read" +#define PRIV_MEDIA_HISTORY "mediahistory.read" +#define PRIV_CALL_HISTORY "callhistory.read" /* FW-wide Data Logger Parameters */ @@ -37,6 +40,7 @@ /* Subjects */ +/* TODO: Cleanup the below namings */ #define SUBJ_STATE_BATTERY "system/battery" #define SUBJ_STATE_CHARGER "system/charger" #define SUBJ_STATE_HEADPHONE "system/headphone" @@ -52,12 +56,38 @@ #define SUBJ_STATE_MESSAGE "social/message" #define SUBJ_STATE_CONTACTS "social/contacts" -#define SUBJ_ACTIVITY_IN_VEHICLE "activity/in_vehicle" -#define SUBJ_ACTIVITY_RUNNING "activity/running" -#define SUBJ_ACTIVITY_STATIONARY "activity/stationary" -#define SUBJ_ACTIVITY_WALKING "activity/walking" +#define SUBJ_ACTIVITY "activity/" +#define SUBJ_ACTIVITY_IN_VEHICLE SUBJ_ACTIVITY "in_vehicle" +#define SUBJ_ACTIVITY_RUNNING SUBJ_ACTIVITY "running" +#define SUBJ_ACTIVITY_STATIONARY SUBJ_ACTIVITY "stationary" +#define SUBJ_ACTIVITY_WALKING SUBJ_ACTIVITY "walking" + +#define SUBJ_APP_STATS "stats/app/" +#define SUBJ_APP_LOGGER SUBJ_APP_STATS "logger" +#define SUBJ_APP_RECENTLY_USED SUBJ_APP_STATS "recently" +#define SUBJ_APP_FREQUENTLY_USED SUBJ_APP_STATS "often" +#define SUBJ_APP_RARELY_USED SUBJ_APP_STATS "rarely" +#define SUBJ_APP_PEAK_TIME SUBJ_APP_STATS "peak_time" +#define SUBJ_APP_COMMON_SETTING SUBJ_APP_STATS "setting" +#define SUBJ_APP_FREQUENCY SUBJ_APP_STATS "frequency" + +#define SUBJ_MEDIA_LOGGER "stats/media/logger" +#define SUBJ_MUSIC_STATS "stats/music/" +#define SUBJ_MUSIC_PEAK_TIME SUBJ_MUSIC_STATS "peak_time" +#define SUBJ_MUSIC_COMMON_SETTING SUBJ_MUSIC_STATS "setting" +#define SUBJ_MUSIC_FREQUENCY SUBJ_MUSIC_STATS "frequency" +#define SUBJ_VIDEO_STATS "stats/video/" +#define SUBJ_VIDEO_PEAK_TIME SUBJ_VIDEO_STATS "peak_time" +#define SUBJ_VIDEO_COMMON_SETTING SUBJ_VIDEO_STATS "setting" +#define SUBJ_VIDEO_FREQUENCY SUBJ_VIDEO_STATS "frequency" + +#define SUBJ_SOCIAL_STATS "stats/contact/" +#define SUBJ_SOCIAL_LOGGER SUBJ_SOCIAL_STATS "logger" +#define SUBJ_SOCIAL_FREQ_ADDRESS SUBJ_SOCIAL_STATS "often" +#define SUBJ_SOCIAL_FREQUENCY SUBJ_SOCIAL_STATS "frequency" #define SUBJ_PLACE_GEOFENCE "place/geofence" +#define SUBJ_PLACE_DETECTION "place/pattern/personal_poi" /* Data & Option Keys */ #define KEY_QUERY_RESULT "QueryResult" diff --git a/packaging/context-provider.spec b/packaging/context-provider.spec index cd48f58..4f97ae2 100644 --- a/packaging/context-provider.spec +++ b/packaging/context-provider.spec @@ -91,3 +91,15 @@ cp LICENSE %{buildroot}/usr/share/license/%{name} /usr/share/license/%{name} %{_libdir}/*.so* %{_libdir}/context/*.so* + +%package devel +Summary: Context Provider Shared Header (Development) +Group: Service/Context +Requires: %{name} = %{version}-%{release} + +%description devel +Context Provider Shared Header (DEV) + +%files devel +%defattr(-,root,root,-) +%{_includedir}/context-service/internal/*.h diff --git a/src/app-stats/AppStatisticsTypes.h b/src/app-stats/AppStatisticsTypes.h index f2ed478..2169d04 100644 --- a/src/app-stats/AppStatisticsTypes.h +++ b/src/app-stats/AppStatisticsTypes.h @@ -17,16 +17,16 @@ #ifndef _CONTEXT_STATS_APP_TYPES_H_ #define _CONTEXT_STATS_APP_TYPES_H_ -#include "../shared/ProviderTypes.h" +#include -#define APP_HISTORY_PRIV "apphistory.read" -#define APP_SUBJ_LOGGER "stats/app/logger" -#define APP_SUBJ_RECENTLY_USED "stats/app/recently" -#define APP_SUBJ_FREQUENTLY_USED "stats/app/often" -#define APP_SUBJ_RARELY_USED "stats/app/rarely" -#define APP_SUBJ_PEAK_TIME "stats/app/peak_time" -#define APP_SUBJ_COMMON_SETTING "stats/app/setting" -#define APP_SUBJ_FREQUENCY "stats/app/frequency" +#define APP_HISTORY_PRIV PRIV_APP_HISTORY +#define APP_SUBJ_LOGGER SUBJ_APP_LOGGER +#define APP_SUBJ_RECENTLY_USED SUBJ_APP_RECENTLY_USED +#define APP_SUBJ_FREQUENTLY_USED SUBJ_APP_FREQUENTLY_USED +#define APP_SUBJ_RARELY_USED SUBJ_APP_RARELY_USED +#define APP_SUBJ_PEAK_TIME SUBJ_APP_PEAK_TIME +#define APP_SUBJ_COMMON_SETTING SUBJ_APP_COMMON_SETTING +#define APP_SUBJ_FREQUENCY SUBJ_APP_FREQUENCY #define APP_TABLE_REMOVABLE_APP "Log_RemovableApp" #define APP_TABLE_REMOVABLE_APP_COLUMNS \ diff --git a/src/media-stats/MediaStatisticsTypes.h b/src/media-stats/MediaStatisticsTypes.h index e0e0700..a2fac9b 100644 --- a/src/media-stats/MediaStatisticsTypes.h +++ b/src/media-stats/MediaStatisticsTypes.h @@ -17,16 +17,16 @@ #ifndef _CONTEXT_STATS_MEDIA_TYPES_H_ #define _CONTEXT_STATS_MEDIA_TYPES_H_ -#include "../shared/ProviderTypes.h" - -#define MEDIA_HISTORY_PRIV "mediahistory.read" -#define MEDIA_SUBJ_LOGGER "stats/media/logger" -#define MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC "stats/music/peak_time" -#define MEDIA_SUBJ_PEAK_TIME_FOR_VIDEO "stats/video/peak_time" -#define MEDIA_SUBJ_COMMON_SETTING_FOR_MUSIC "stats/music/setting" -#define MEDIA_SUBJ_COMMON_SETTING_FOR_VIDEO "stats/video/setting" -#define MEDIA_SUBJ_MUSIC_FREQUENCY "stats/music/frequency" -#define MEDIA_SUBJ_VIDEO_FREQUENCY "stats/video/frequency" +#include + +#define MEDIA_HISTORY_PRIV PRIV_MEDIA_HISTORY +#define MEDIA_SUBJ_LOGGER SUBJ_MEDIA_LOGGER +#define MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC SUBJ_MUSIC_PEAK_TIME +#define MEDIA_SUBJ_PEAK_TIME_FOR_VIDEO SUBJ_VIDEO_PEAK_TIME +#define MEDIA_SUBJ_COMMON_SETTING_FOR_MUSIC SUBJ_MUSIC_COMMON_SETTING +#define MEDIA_SUBJ_COMMON_SETTING_FOR_VIDEO SUBJ_VIDEO_COMMON_SETTING +#define MEDIA_SUBJ_MUSIC_FREQUENCY SUBJ_MUSIC_FREQUENCY +#define MEDIA_SUBJ_VIDEO_FREQUENCY SUBJ_VIDEO_FREQUENCY #define MEDIA_TABLE_NAME "Log_MediaPlayback" #define MEDIA_TABLE_COLUMNS \ diff --git a/src/my-place/place_recognition_types.h b/src/my-place/place_recognition_types.h index 5a645e4..fcde0a7 100644 --- a/src/my-place/place_recognition_types.h +++ b/src/my-place/place_recognition_types.h @@ -17,8 +17,10 @@ #ifndef _CONTEXT_PLACE_RECOGNITION_TYPES_ #define _CONTEXT_PLACE_RECOGNITION_TYPES_ +#include + // Context Items -#define PLACE_SUBJ_RECOGNITION "place/pattern/personal_poi" +#define PLACE_SUBJ_RECOGNITION SUBJ_PLACE_DETECTION #define PLACE_PRIV_RECOGNITION "location" diff --git a/src/shared/DbHandleBase.cpp b/src/shared/DbHandleBase.cpp index 846265d..074a7ac 100644 --- a/src/shared/DbHandleBase.cpp +++ b/src/shared/DbHandleBase.cpp @@ -16,7 +16,7 @@ #include #include -#include "ProviderTypes.h" +#include #include "DbHandleBase.h" #define DAY_OF_WEEK(SECOND) "CAST(strftime('%w', " SECOND ", 'unixepoch') AS INTEGER)" diff --git a/src/social-stats/SocialStatisticsTypes.h b/src/social-stats/SocialStatisticsTypes.h index 845f577..cbe852d 100644 --- a/src/social-stats/SocialStatisticsTypes.h +++ b/src/social-stats/SocialStatisticsTypes.h @@ -17,12 +17,12 @@ #ifndef _CONTEXT_STATS_SOCIAL_TYPES_H_ #define _CONTEXT_STATS_SOCIAL_TYPES_H_ -#include "../shared/ProviderTypes.h" +#include -#define SOCIAL_HISTORY_PRIV "callhistory.read" -#define SOCIAL_SUBJ_LOGGER "stats/contact/logger" -#define SOCIAL_SUBJ_FREQ_ADDRESS "stats/contact/often" -#define SOCIAL_SUBJ_FREQUENCY "stats/contact/frequency" +#define SOCIAL_HISTORY_PRIV PRIV_CALL_HISTORY +#define SOCIAL_SUBJ_LOGGER SUBJ_SOCIAL_LOGGER +#define SOCIAL_SUBJ_FREQ_ADDRESS SUBJ_SOCIAL_FREQ_ADDRESS +#define SOCIAL_SUBJ_FREQUENCY SUBJ_SOCIAL_FREQUENCY #define SOCIAL_TABLE_CONTACT_LOG "Log_Contact" #define SOCIAL_TABLE_CONTACT_LOG_COLUMNS \ -- 2.7.4 From 81e4514fd7e6079acfa8d321d09076ec043d2285 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Tue, 26 Apr 2016 13:41:35 +0900 Subject: [PATCH 14/16] Align the lib directory path with the header path Change-Id: I3b8142d82f83e954ce74d28c96e6f7c1d07e3ff5 Signed-off-by: Mu-Woong Lee --- CMakeLists.txt | 3 ++- include/ProviderList.h | 2 +- packaging/context-provider.spec | 2 +- src/activity/CMakeLists.txt | 2 +- src/app-stats/CMakeLists.txt | 2 +- src/call/CMakeLists.txt | 2 +- src/contacts/CMakeLists.txt | 2 +- src/email/CMakeLists.txt | 2 +- src/geofence/CMakeLists.txt | 2 +- src/headphone/CMakeLists.txt | 2 +- src/media-stats/CMakeLists.txt | 2 +- src/message/CMakeLists.txt | 2 +- src/my-place/CMakeLists.txt | 2 +- src/social-stats/CMakeLists.txt | 2 +- src/system/CMakeLists.txt | 2 +- src/time/CMakeLists.txt | 2 +- src/wifi/CMakeLists.txt | 2 +- 17 files changed, 18 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10eb09c..04316da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(context-provider) INCLUDE(GNUInstallDirs) SET(target_prefix "ctx-prvd") +SET(target_dir "context-service") # Common Options INCLUDE_DIRECTORIES( @@ -24,7 +25,7 @@ ENDIF("${PROFILE}" STREQUAL "wearable") INSTALL( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/context-service/internal + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${target_dir}/internal FILES_MATCHING PATTERN "*.h" ) diff --git a/include/ProviderList.h b/include/ProviderList.h index e63feb7..7ffcd9c 100644 --- a/include/ProviderList.h +++ b/include/ProviderList.h @@ -20,7 +20,7 @@ #include #include -#define LIB_DIRECTORY "/usr/lib/context/" +#define LIB_DIRECTORY "/usr/lib/context-service/" #define LIB_PREFIX "libctx-prvd-" #define LIB_EXTENSION ".so" diff --git a/packaging/context-provider.spec b/packaging/context-provider.spec index 4f97ae2..01b83db 100644 --- a/packaging/context-provider.spec +++ b/packaging/context-provider.spec @@ -90,7 +90,7 @@ cp LICENSE %{buildroot}/usr/share/license/%{name} %defattr(-,root,root,-) /usr/share/license/%{name} %{_libdir}/*.so* -%{_libdir}/context/*.so* +%{_libdir}/context-service/*.so* %package devel Summary: Context Provider Shared Header (Development) diff --git a/src/activity/CMakeLists.txt b/src/activity/CMakeLists.txt index 29e8f5d..7ce6d10 100644 --- a/src/activity/CMakeLists.txt +++ b/src/activity/CMakeLists.txt @@ -16,4 +16,4 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${target} ${PKG_ACTIVITY_LDFLAGS} ${target_shared}) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir}) diff --git a/src/app-stats/CMakeLists.txt b/src/app-stats/CMakeLists.txt index 70b329e..a11dec1 100644 --- a/src/app-stats/CMakeLists.txt +++ b/src/app-stats/CMakeLists.txt @@ -20,4 +20,4 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${target} ${PKG_APP_LDFLAGS} ${target_shared}) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir}) diff --git a/src/call/CMakeLists.txt b/src/call/CMakeLists.txt index 8a60b79..2dbc38a 100644 --- a/src/call/CMakeLists.txt +++ b/src/call/CMakeLists.txt @@ -17,4 +17,4 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${target} ${PKG_CALL_LDFLAGS} ${target_shared}) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir}) diff --git a/src/contacts/CMakeLists.txt b/src/contacts/CMakeLists.txt index 6773a23..0d48f20 100644 --- a/src/contacts/CMakeLists.txt +++ b/src/contacts/CMakeLists.txt @@ -16,4 +16,4 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${target} ${PKG_CONTACTS_LDFLAGS} ${target_shared}) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir}) diff --git a/src/email/CMakeLists.txt b/src/email/CMakeLists.txt index d6d6687..b6c357e 100644 --- a/src/email/CMakeLists.txt +++ b/src/email/CMakeLists.txt @@ -16,4 +16,4 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${target} ${PKG_EMAIL_LDFLAGS} ${target_shared}) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir}) diff --git a/src/geofence/CMakeLists.txt b/src/geofence/CMakeLists.txt index c52a0b0..f2776d1 100644 --- a/src/geofence/CMakeLists.txt +++ b/src/geofence/CMakeLists.txt @@ -16,4 +16,4 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${target} ${PKG_GEOFENCE_LDFLAGS} ${target_shared}) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir}) diff --git a/src/headphone/CMakeLists.txt b/src/headphone/CMakeLists.txt index 1730405..df61ff6 100644 --- a/src/headphone/CMakeLists.txt +++ b/src/headphone/CMakeLists.txt @@ -17,4 +17,4 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${target} ${PKG_HEADPHONE_LDFLAGS} ${target_shared}) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir}) diff --git a/src/media-stats/CMakeLists.txt b/src/media-stats/CMakeLists.txt index cb22916..cf5e6de 100644 --- a/src/media-stats/CMakeLists.txt +++ b/src/media-stats/CMakeLists.txt @@ -16,4 +16,4 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${target} ${PKG_MEDIA_STATS_LDFLAGS} ${target_shared}) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir}) diff --git a/src/message/CMakeLists.txt b/src/message/CMakeLists.txt index 0de59a0..70561e1 100644 --- a/src/message/CMakeLists.txt +++ b/src/message/CMakeLists.txt @@ -16,4 +16,4 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${target} ${PKG_MESSAGE_LDFLAGS} ${target_shared}) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir}) diff --git a/src/my-place/CMakeLists.txt b/src/my-place/CMakeLists.txt index 5277817..662895b 100644 --- a/src/my-place/CMakeLists.txt +++ b/src/my-place/CMakeLists.txt @@ -17,4 +17,4 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${target} ${PKG_MYPLACE_LDFLAGS} ${target_shared}) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir}) diff --git a/src/social-stats/CMakeLists.txt b/src/social-stats/CMakeLists.txt index 004286e..a25e0d8 100644 --- a/src/social-stats/CMakeLists.txt +++ b/src/social-stats/CMakeLists.txt @@ -16,4 +16,4 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${target} ${PKG_SOCIAL_LDFLAGS} ${target_shared}) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir}) diff --git a/src/system/CMakeLists.txt b/src/system/CMakeLists.txt index a349974..ee1c8c1 100644 --- a/src/system/CMakeLists.txt +++ b/src/system/CMakeLists.txt @@ -19,4 +19,4 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${target} ${PKG_SYSTEM_LDFLAGS} ${target_shared}) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir}) diff --git a/src/time/CMakeLists.txt b/src/time/CMakeLists.txt index 1ea12af..8642441 100644 --- a/src/time/CMakeLists.txt +++ b/src/time/CMakeLists.txt @@ -15,4 +15,4 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${target} ${PKG_TIME_LDFLAGS} ${target_shared}) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir}) diff --git a/src/wifi/CMakeLists.txt b/src/wifi/CMakeLists.txt index 10ca397..20edd33 100644 --- a/src/wifi/CMakeLists.txt +++ b/src/wifi/CMakeLists.txt @@ -16,4 +16,4 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${target} ${PKG_WIFI_LDFLAGS} ${target_shared}) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir}) -- 2.7.4 From dfcbc81b191998f95346ea197c7e88701d4fdc34 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Tue, 26 Apr 2016 14:33:43 +0900 Subject: [PATCH 15/16] Re-implement 'create' functions to support dynamic loading Obsoluted trigger registration functions are removed. Change-Id: I89b950d7b996653a8ae64e3c2f8e29df9619d164 Signed-off-by: Mu-Woong Lee --- src/activity/Activity.cpp | 8 -------- src/activity/Activity.h | 1 - src/activity/create.cpp | 16 ++++++---------- src/app-stats/AppStatsLogger.h | 2 -- src/app-stats/AppStatsProvider.cpp | 14 -------------- src/app-stats/AppStatsProvider.h | 3 --- src/app-stats/create.cpp | 22 +++++++++------------- src/call/Call.cpp | 12 ------------ src/call/Call.h | 1 - src/call/create.cpp | 10 +++------- src/contacts/Contacts.cpp | 10 ---------- src/contacts/Contacts.h | 1 - src/contacts/create.cpp | 10 +++------- src/email/Email.cpp | 9 --------- src/email/Email.h | 1 - src/email/create.cpp | 10 +++------- src/geofence/PlaceGeofenceProvider.cpp | 11 ----------- src/geofence/PlaceGeofenceProvider.h | 1 - src/geofence/create.cpp | 10 +++------- src/headphone/Headphone.cpp | 10 ---------- src/headphone/Headphone.h | 1 - src/headphone/create.cpp | 10 +++------- src/media-stats/MediaStatsLogger.h | 2 -- src/media-stats/MediaStatsProvider.cpp | 18 ------------------ src/media-stats/MediaStatsProvider.h | 6 ------ src/media-stats/create.cpp | 22 +++++++++------------- src/message/Message.cpp | 11 ----------- src/message/Message.h | 2 -- src/message/create.cpp | 10 +++------- src/my-place/create.cpp | 12 +++--------- src/my-place/place_recognition.h | 1 - src/shared/BasicProvider.cpp | 4 ---- src/shared/BasicProvider.h | 3 --- src/shared/create.h | 24 ++++++++---------------- src/social-stats/SocialStatsLogger.h | 2 -- src/social-stats/SocialStatsProvider.cpp | 14 -------------- src/social-stats/SocialStatsProvider.h | 4 ---- src/social-stats/create.cpp | 14 +++++--------- src/system/Battery.cpp | 10 ---------- src/system/Battery.h | 1 - src/system/Charger.cpp | 6 ------ src/system/Charger.h | 2 -- src/system/Gps.cpp | 9 --------- src/system/Gps.h | 2 -- src/system/Psmode.cpp | 6 ------ src/system/Psmode.h | 1 - src/system/Usb.cpp | 6 ------ src/system/Usb.h | 2 -- src/system/create.cpp | 18 +++++++----------- src/time/Alarm.cpp | 10 ---------- src/time/Alarm.h | 1 - src/time/Time.cpp | 11 ----------- src/time/Time.h | 1 - src/time/create.cpp | 12 ++++-------- src/wifi/Wifi.cpp | 10 ---------- src/wifi/Wifi.h | 1 - src/wifi/create.cpp | 10 +++------- 57 files changed, 72 insertions(+), 369 deletions(-) diff --git a/src/activity/Activity.cpp b/src/activity/Activity.cpp index 017c061..f1a5da1 100644 --- a/src/activity/Activity.cpp +++ b/src/activity/Activity.cpp @@ -37,14 +37,6 @@ bool ActivityProvider::isSupported() return util::getSystemInfoBool("tizen.org/feature/sensor.activity_recognition"); } -void ActivityProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_SUBSCRIBE, - "{\"Event\":{\"type\":\"string\", \"values\":[\"Detected\"]}}", - "{\"Accuracy\":{\"type\":\"string\", \"values\":[\"Low\", \"Normal\", \"High\"]}}" - ); -} - void ActivityProvider::__updateCb(activity_type_e activity, const activity_data_h data, double timestamp, activity_error_e error, void* userData) { IF_FAIL_VOID_TAG(error == ACTIVITY_ERROR_NONE, _E, "Error: %d", error); diff --git a/src/activity/Activity.h b/src/activity/Activity.h index b1bfe77..5fdc972 100644 --- a/src/activity/Activity.h +++ b/src/activity/Activity.h @@ -39,7 +39,6 @@ namespace ctx { int unsubscribe(); bool isSupported(); - void submitTriggerItem(); protected: activity_type_e __activityType; diff --git a/src/activity/create.cpp b/src/activity/create.cpp index 5009ae3..caa0875 100644 --- a/src/activity/create.cpp +++ b/src/activity/create.cpp @@ -14,21 +14,17 @@ * limitations under the License. */ -#include #include #include "Activity.h" using namespace ctx; -/* TODO: This function will be changed into the following form: - ContextProvider* create(const char *subject) */ - -extern "C" SO_EXPORT bool create() +extern "C" SO_EXPORT ContextProvider* create(const char *subject) { - registerProvider(SUBJ_ACTIVITY_STATIONARY, NULL); - registerProvider(SUBJ_ACTIVITY_WALKING, NULL); - registerProvider(SUBJ_ACTIVITY_RUNNING, NULL); - registerProvider(SUBJ_ACTIVITY_IN_VEHICLE, NULL); + ADD_PROVIDER(SUBJ_ACTIVITY_STATIONARY, StationaryActivityProvider); + ADD_PROVIDER(SUBJ_ACTIVITY_WALKING, WalkingActivityProvider); + ADD_PROVIDER(SUBJ_ACTIVITY_RUNNING, RunningActivityProvider); + ADD_PROVIDER(SUBJ_ACTIVITY_IN_VEHICLE, InVehicleActivityProvider); - return true; + return NULL; } diff --git a/src/app-stats/AppStatsLogger.h b/src/app-stats/AppStatsLogger.h index 4a8dd02..2c6c4bd 100644 --- a/src/app-stats/AppStatsLogger.h +++ b/src/app-stats/AppStatsLogger.h @@ -32,8 +32,6 @@ namespace ctx { int subscribe(Json option, Json *requestResult); int unsubscribe(Json option); - void submitTriggerItem() {} - private: AppDbInitializer *__initializer; AppInstallMonitor *__installMon; diff --git a/src/app-stats/AppStatsProvider.cpp b/src/app-stats/AppStatsProvider.cpp index ebafae9..3513854 100644 --- a/src/app-stats/AppStatsProvider.cpp +++ b/src/app-stats/AppStatsProvider.cpp @@ -28,10 +28,6 @@ AppStatsProvider::~AppStatsProvider() { } -void AppStatsProvider::submitTriggerItem() -{ -} - int AppStatsProvider::read(Json option, Json *requestResult) { AppDbHandle *handle = new(std::nothrow) AppDbHandle(this); @@ -45,13 +41,3 @@ int AppStatsProvider::read(Json option, Json *requestResult) return ERR_NONE; } - -void AppFreqProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_READ, - "{" TRIG_DEF_RANK "," TRIG_DEF_TOTAL_COUNT "}", - "{" - "\"AppId\":{\"type\":\"string\"}," - TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK - "}"); -} diff --git a/src/app-stats/AppStatsProvider.h b/src/app-stats/AppStatsProvider.h index 7186955..85759be 100644 --- a/src/app-stats/AppStatsProvider.h +++ b/src/app-stats/AppStatsProvider.h @@ -25,7 +25,6 @@ namespace ctx { class AppStatsProvider : public ContextProvider { public: int read(Json option, Json *requestResult); - virtual void submitTriggerItem(); protected: AppStatsProvider(const char *subject); @@ -72,8 +71,6 @@ namespace ctx { public: AppFreqProvider() : AppStatsProvider(APP_SUBJ_FREQUENCY) {} - - void submitTriggerItem(); }; } /* namespace ctx */ diff --git a/src/app-stats/create.cpp b/src/app-stats/create.cpp index 5002f9a..b5de0f6 100644 --- a/src/app-stats/create.cpp +++ b/src/app-stats/create.cpp @@ -14,25 +14,21 @@ * limitations under the License. */ -#include #include #include "AppStatsProvider.h" #include "AppStatsLogger.h" using namespace ctx; -/* TODO: This function will be changed into the following form: - ContextProvider* create(const char *subject) */ - -extern "C" SO_EXPORT bool create() +extern "C" SO_EXPORT ContextProvider* create(const char *subject) { - registerProvider(APP_SUBJ_LOGGER, 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); + ADD_PROVIDER(SUBJ_APP_LOGGER, AppStatsLogger); + ADD_PROVIDER(SUBJ_APP_RECENTLY_USED, RecentAppProvider); + ADD_PROVIDER(SUBJ_APP_FREQUENTLY_USED, FrequentAppProvider); + ADD_PROVIDER(SUBJ_APP_RARELY_USED, RareAppProvider); + ADD_PROVIDER(SUBJ_APP_PEAK_TIME, AppPeakTimeProvider); + ADD_PROVIDER(SUBJ_APP_COMMON_SETTING, AppSettingProvider); + ADD_PROVIDER(SUBJ_APP_FREQUENCY, AppFreqProvider); - return true; + return NULL; } diff --git a/src/call/Call.cpp b/src/call/Call.cpp index 786fcc3..dc3d616 100644 --- a/src/call/Call.cpp +++ b/src/call/Call.cpp @@ -54,18 +54,6 @@ bool CallStateProvider::isSupported() return util::getSystemInfoBool("tizen.org/feature/network.telephony"); } -void CallStateProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, - "{" - "\"Medium\":{\"type\":\"string\",\"values\":[\"Voice\",\"Video\"]}," - "\"State\":{\"type\":\"string\",\"values\":[\"Idle\",\"Connecting\",\"Connected\"]}," - "\"Address\":{\"type\":\"string\"}" - "}", - NULL); - /* TODO remove Connecting, Connected */ -} - void CallStateProvider::__updateCb(telephony_h handle, telephony_noti_e notiId, void *data, void *userData) { CallStateProvider *instance = static_cast(userData); diff --git a/src/call/Call.h b/src/call/Call.h index c980a38..79b5e6b 100644 --- a/src/call/Call.h +++ b/src/call/Call.h @@ -33,7 +33,6 @@ namespace ctx { int read(); bool isSupported(); - void submitTriggerItem(); private: telephony_handle_list_s __handleList; diff --git a/src/call/create.cpp b/src/call/create.cpp index 235db22..3fb4b08 100644 --- a/src/call/create.cpp +++ b/src/call/create.cpp @@ -14,18 +14,14 @@ * limitations under the License. */ -#include #include #include "Call.h" using namespace ctx; -/* TODO: This function will be changed into the following form: - ContextProvider* create(const char *subject) */ - -extern "C" SO_EXPORT bool create() +extern "C" SO_EXPORT ContextProvider* create(const char *subject) { - registerProvider(SUBJ_STATE_CALL, PRIV_TELEPHONY); + ADD_PROVIDER(SUBJ_STATE_CALL, CallStateProvider); - return true; + return NULL; } diff --git a/src/contacts/Contacts.cpp b/src/contacts/Contacts.cpp index 8265fd6..13cf5c7 100644 --- a/src/contacts/Contacts.cpp +++ b/src/contacts/Contacts.cpp @@ -38,16 +38,6 @@ bool ContactsChangeProvider::isSupported() return true; } -void ContactsChangeProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_SUBSCRIBE, - "{" - "\"Event\":{\"type\":\"string\",\"values\":[\"Changed\"]}," - "\"Type\":{\"type\":\"string\",\"values\":[\"MyProfile\",\"Person\"]}" - "}", - NULL); -} - void ContactsChangeProvider::__updateCb(const char* viewUri, void* userData) { ContactsChangeProvider *instance = static_cast(userData); diff --git a/src/contacts/Contacts.h b/src/contacts/Contacts.h index 0ebd273..da65fe5 100644 --- a/src/contacts/Contacts.h +++ b/src/contacts/Contacts.h @@ -32,7 +32,6 @@ namespace ctx { int unsubscribe(); bool isSupported(); - void submitTriggerItem(); private: time_t __latestMyProfile; diff --git a/src/contacts/create.cpp b/src/contacts/create.cpp index b4b34b6..f6e08e9 100644 --- a/src/contacts/create.cpp +++ b/src/contacts/create.cpp @@ -14,18 +14,14 @@ * limitations under the License. */ -#include #include #include "Contacts.h" using namespace ctx; -/* TODO: This function will be changed into the following form: - ContextProvider* create(const char *subject) */ - -extern "C" SO_EXPORT bool create() +extern "C" SO_EXPORT ContextProvider* create(const char *subject) { - registerProvider(SUBJ_STATE_CONTACTS, PRIV_CONTACT); + ADD_PROVIDER(SUBJ_STATE_CONTACTS, ContactsChangeProvider); - return true; + return NULL; } diff --git a/src/email/Email.cpp b/src/email/Email.cpp index f2a23cb..69f4250 100644 --- a/src/email/Email.cpp +++ b/src/email/Email.cpp @@ -36,15 +36,6 @@ bool EmailEventProvider::isSupported() return util::getSystemInfoBool("tizen.org/feature/network.telephony"); } -void EmailEventProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_SUBSCRIBE, - "{" - "\"Event\":{\"type\":\"string\",\"values\":[\"Received\",\"Sent\"]}" - "}", - NULL); -} - void EmailEventProvider::onSignal(const char* sender, const char* path, const char* iface, const char* name, GVariant* param) { gint subType = 0; diff --git a/src/email/Email.h b/src/email/Email.h index c1cc093..b3fc502 100644 --- a/src/email/Email.h +++ b/src/email/Email.h @@ -32,7 +32,6 @@ namespace ctx { int unsubscribe(); bool isSupported(); - void submitTriggerItem(); void onSignal(const char *sender, const char *path, const char *iface, const char *name, GVariant *param); diff --git a/src/email/create.cpp b/src/email/create.cpp index ac15430..f13a3b7 100644 --- a/src/email/create.cpp +++ b/src/email/create.cpp @@ -14,18 +14,14 @@ * limitations under the License. */ -#include #include #include "Email.h" using namespace ctx; -/* TODO: This function will be changed into the following form: - ContextProvider* create(const char *subject) */ - -extern "C" SO_EXPORT bool create() +extern "C" SO_EXPORT ContextProvider* create(const char *subject) { - registerProvider(SUBJ_STATE_EMAIL, NULL); + ADD_PROVIDER(SUBJ_STATE_EMAIL, EmailEventProvider); - return true; + return NULL; } diff --git a/src/geofence/PlaceGeofenceProvider.cpp b/src/geofence/PlaceGeofenceProvider.cpp index 718271b..2f09c53 100644 --- a/src/geofence/PlaceGeofenceProvider.cpp +++ b/src/geofence/PlaceGeofenceProvider.cpp @@ -42,17 +42,6 @@ bool PlaceGeofenceProvider::isSupported() return supported; } -void PlaceGeofenceProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_SUBSCRIBE, - "{" - "\"Event\":{\"type\":\"string\",\"values\":[\"In\",\"Out\"]}" - "}", - "{" - "\"PlaceId\":{\"type\":\"integer\",\"min\":1}" - "}"); -} - int PlaceGeofenceProvider::subscribe(Json option, Json *requestResult) { int placeId = -1; diff --git a/src/geofence/PlaceGeofenceProvider.h b/src/geofence/PlaceGeofenceProvider.h index 286b239..fe2a416 100644 --- a/src/geofence/PlaceGeofenceProvider.h +++ b/src/geofence/PlaceGeofenceProvider.h @@ -34,7 +34,6 @@ namespace ctx { int unsubscribe(Json option); bool isSupported(); - void submitTriggerItem(); private: std::map __handleMap; diff --git a/src/geofence/create.cpp b/src/geofence/create.cpp index 6f9ccbe..1c84abd 100644 --- a/src/geofence/create.cpp +++ b/src/geofence/create.cpp @@ -14,18 +14,14 @@ * limitations under the License. */ -#include #include #include "PlaceGeofenceProvider.h" using namespace ctx; -/* TODO: This function will be changed into the following form: - ContextProvider* create(const char *subject) */ - -extern "C" SO_EXPORT bool create() +extern "C" SO_EXPORT ContextProvider* create(const char *subject) { - registerProvider(SUBJ_PLACE_GEOFENCE, PRIV_LOCATION); + ADD_PROVIDER(SUBJ_PLACE_GEOFENCE, PlaceGeofenceProvider); - return true; + return NULL; } diff --git a/src/headphone/Headphone.cpp b/src/headphone/Headphone.cpp index 7bf8d8e..d87daa4 100644 --- a/src/headphone/Headphone.cpp +++ b/src/headphone/Headphone.cpp @@ -41,16 +41,6 @@ bool HeadphoneStateProvider::isSupported() return true; } -void HeadphoneStateProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, - "{" - TRIG_BOOL_ITEM_DEF("IsConnected") "," - "\"Type\":{\"type\":\"string\",\"values\":[\"Normal\",\"Headset\",\"Bluetooth\"]}" - "}", - NULL); -} - int HeadphoneStateProvider::subscribe() { __connected = __getCurrentStatus(); diff --git a/src/headphone/Headphone.h b/src/headphone/Headphone.h index e61f446..eaaf1b6 100644 --- a/src/headphone/Headphone.h +++ b/src/headphone/Headphone.h @@ -34,7 +34,6 @@ namespace ctx { int read(); bool isSupported(); - void submitTriggerItem(); private: bool __connected; diff --git a/src/headphone/create.cpp b/src/headphone/create.cpp index 79fa6a7..a64b208 100644 --- a/src/headphone/create.cpp +++ b/src/headphone/create.cpp @@ -14,18 +14,14 @@ * limitations under the License. */ -#include #include #include "Headphone.h" using namespace ctx; -/* TODO: This function will be changed into the following form: - ContextProvider* create(const char *subject) */ - -extern "C" SO_EXPORT bool create() +extern "C" SO_EXPORT ContextProvider* create(const char *subject) { - registerProvider(SUBJ_STATE_HEADPHONE, NULL); + ADD_PROVIDER(SUBJ_STATE_HEADPHONE, HeadphoneStateProvider); - return true; + return NULL; } diff --git a/src/media-stats/MediaStatsLogger.h b/src/media-stats/MediaStatsLogger.h index 32affe5..eb273f9 100644 --- a/src/media-stats/MediaStatsLogger.h +++ b/src/media-stats/MediaStatsLogger.h @@ -30,8 +30,6 @@ namespace ctx { int subscribe(Json option, Json *requestResult); int unsubscribe(Json option); - void submitTriggerItem() {} - private: MediaContentMonitor __contentMon; }; diff --git a/src/media-stats/MediaStatsProvider.cpp b/src/media-stats/MediaStatsProvider.cpp index 263a54d..daa1349 100644 --- a/src/media-stats/MediaStatsProvider.cpp +++ b/src/media-stats/MediaStatsProvider.cpp @@ -34,10 +34,6 @@ bool MediaStatsProvider::isSupported() return true; } -void MediaStatsProvider::submitTriggerItem() -{ -} - int MediaStatsProvider::read(Json option, Json* requestResult) { MediaDbHandle *handle = new(std::nothrow) MediaDbHandle(this); @@ -51,17 +47,3 @@ int MediaStatsProvider::read(Json option, Json* requestResult) return ERR_NONE; } - -void MusicFreqProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_READ, - "{" TRIG_DEF_TOTAL_COUNT "}", - "{" TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK "}"); -} - -void VideoFreqProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_READ, - "{" TRIG_DEF_TOTAL_COUNT "}", - "{" TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK "}"); -} diff --git a/src/media-stats/MediaStatsProvider.h b/src/media-stats/MediaStatsProvider.h index 4d2c702..bb27e47 100644 --- a/src/media-stats/MediaStatsProvider.h +++ b/src/media-stats/MediaStatsProvider.h @@ -25,9 +25,7 @@ namespace ctx { class MediaStatsProvider : public ContextProvider { public: int read(Json option, Json* requestResult); - bool isSupported(); - virtual void submitTriggerItem(); protected: MediaStatsProvider(const char *subject); @@ -67,8 +65,6 @@ namespace ctx { public: MusicFreqProvider() : MediaStatsProvider(MEDIA_SUBJ_MUSIC_FREQUENCY) {} - - void submitTriggerItem(); }; @@ -76,8 +72,6 @@ namespace ctx { public: VideoFreqProvider() : MediaStatsProvider(MEDIA_SUBJ_VIDEO_FREQUENCY) {} - - void submitTriggerItem(); }; } /* namespace ctx */ diff --git a/src/media-stats/create.cpp b/src/media-stats/create.cpp index 48f4ee9..1bb7e5e 100644 --- a/src/media-stats/create.cpp +++ b/src/media-stats/create.cpp @@ -14,25 +14,21 @@ * limitations under the License. */ -#include #include #include "MediaStatsProvider.h" #include "MediaStatsLogger.h" using namespace ctx; -/* TODO: This function will be changed into the following form: - ContextProvider* create(const char *subject) */ - -extern "C" SO_EXPORT bool create() +extern "C" SO_EXPORT ContextProvider* create(const char *subject) { - registerProvider(MEDIA_SUBJ_LOGGER, 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); + ADD_PROVIDER(SUBJ_MEDIA_LOGGER, MediaStatsLogger); + ADD_PROVIDER(SUBJ_MUSIC_PEAK_TIME, MusicPeakTimeProvider); + ADD_PROVIDER(SUBJ_MUSIC_COMMON_SETTING, MusicSettingProvider); + ADD_PROVIDER(SUBJ_MUSIC_FREQUENCY, MusicFreqProvider); + ADD_PROVIDER(SUBJ_VIDEO_PEAK_TIME, VideoPeakTimeProvider); + ADD_PROVIDER(SUBJ_VIDEO_COMMON_SETTING, VideoSettingProvider); + ADD_PROVIDER(SUBJ_VIDEO_FREQUENCY, VideoFreqProvider); - return true; + return NULL; } diff --git a/src/message/Message.cpp b/src/message/Message.cpp index 30268ed..32a484b 100644 --- a/src/message/Message.cpp +++ b/src/message/Message.cpp @@ -36,17 +36,6 @@ bool MessageEventProvider::isSupported() return util::getSystemInfoBool("tizen.org/feature/network.telephony"); } -void MessageEventProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_SUBSCRIBE, - "{" - "\"Event\":{\"type\":\"string\",\"values\":[\"Received\"]}," - "\"Type\":{\"type\":\"string\",\"values\":[\"SMS\",\"MMS\"]}," - "\"Address\":{\"type\":\"string\"}" - "}", - NULL); -} - void MessageEventProvider::__updateCb(msg_handle_t handle, msg_struct_t msg, void* userData) { MessageEventProvider *instance = static_cast(userData); diff --git a/src/message/Message.h b/src/message/Message.h index 058d418..576ce2f 100644 --- a/src/message/Message.h +++ b/src/message/Message.h @@ -31,9 +31,7 @@ namespace ctx { int subscribe(); int unsubscribe(); - bool isSupported(); - void submitTriggerItem(); private: msg_handle_t __messageHandle; diff --git a/src/message/create.cpp b/src/message/create.cpp index 7588850..751765b 100644 --- a/src/message/create.cpp +++ b/src/message/create.cpp @@ -14,18 +14,14 @@ * limitations under the License. */ -#include #include #include "Message.h" using namespace ctx; -/* TODO: This function will be changed into the following form: - ContextProvider* create(const char *subject) */ - -extern "C" SO_EXPORT bool create() +extern "C" SO_EXPORT ContextProvider* create(const char *subject) { - registerProvider(SUBJ_STATE_MESSAGE, PRIV_MESSAGE); + ADD_PROVIDER(SUBJ_STATE_MESSAGE, MessageEventProvider); - return true; + return NULL; } diff --git a/src/my-place/create.cpp b/src/my-place/create.cpp index 91cdaf9..d6947a7 100644 --- a/src/my-place/create.cpp +++ b/src/my-place/create.cpp @@ -14,20 +14,14 @@ * limitations under the License. */ -#include #include #include "place_recognition.h" using namespace ctx; -/* TODO: This function will be changed into the following form: - ContextProvider* create(const char *subject) */ - -extern "C" SO_EXPORT bool create() +extern "C" SO_EXPORT ContextProvider* create(const char *subject) { - /* - registerProvider(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION); - */ + ADD_PROVIDER(SUBJ_PLACE_DETECTION, PlaceRecognitionProvider); - return true; + return NULL; } diff --git a/src/my-place/place_recognition.h b/src/my-place/place_recognition.h index 773dd34..9eda4ac 100644 --- a/src/my-place/place_recognition.h +++ b/src/my-place/place_recognition.h @@ -37,7 +37,6 @@ namespace ctx { int write(ctx::Json data, ctx::Json *requestResult); bool isSupported(); - void submitTriggerItem() {} private: UserPlaces __engine; diff --git a/src/shared/BasicProvider.cpp b/src/shared/BasicProvider.cpp index 28202dd..cae85ab 100644 --- a/src/shared/BasicProvider.cpp +++ b/src/shared/BasicProvider.cpp @@ -34,10 +34,6 @@ bool BasicProvider::isSupported() return true; } -void BasicProvider::submitTriggerItem() -{ -} - int BasicProvider::subscribe(Json option, Json *requestResult) { IF_FAIL_RETURN(!__beingSubscribed, ERR_NONE); diff --git a/src/shared/BasicProvider.h b/src/shared/BasicProvider.h index 069cc3a..7ce9f02 100644 --- a/src/shared/BasicProvider.h +++ b/src/shared/BasicProvider.h @@ -33,9 +33,6 @@ namespace ctx { virtual bool isSupported(); - /* TODO: This function will be deprecated */ - virtual void submitTriggerItem(); - protected: bool __beingSubscribed; diff --git a/src/shared/create.h b/src/shared/create.h index 2c57b7a..dc02fa7 100644 --- a/src/shared/create.h +++ b/src/shared/create.h @@ -14,23 +14,15 @@ * limitations under the License. */ -/* TODO: This is a temporary template implementation. - This will be removed soon. */ - #include #include -template -void registerProvider(const char *subject, const char *privilege) -{ - Provider *provider = new(std::nothrow) Provider(); - IF_FAIL_VOID_TAG(provider, _E, "Memory allocation failed"); - - if (!provider->isSupported()) { - delete provider; - return; +#define ADD_PROVIDER(subj, prvd) \ + if (STR_EQ((subj), subject)) { \ + ctx::ContextProvider *instance = new(std::nothrow) prvd; \ + if (instance == NULL) { \ + _E("Memoroy allocation failed"); \ + return NULL; \ + } \ + return instance; \ } - - provider->registerProvider(privilege, provider); - provider->submitTriggerItem(); -} diff --git a/src/social-stats/SocialStatsLogger.h b/src/social-stats/SocialStatsLogger.h index f79cceb..5f5cc9b 100644 --- a/src/social-stats/SocialStatsLogger.h +++ b/src/social-stats/SocialStatsLogger.h @@ -30,8 +30,6 @@ namespace ctx { int subscribe(Json option, Json* requestResult); int unsubscribe(Json option); - void submitTriggerItem() {} - private: ContactLogAggregator __aggregator; }; diff --git a/src/social-stats/SocialStatsProvider.cpp b/src/social-stats/SocialStatsProvider.cpp index ff850a2..a93978a 100644 --- a/src/social-stats/SocialStatsProvider.cpp +++ b/src/social-stats/SocialStatsProvider.cpp @@ -34,10 +34,6 @@ bool SocialStatsProvider::isSupported() return true; } -void SocialStatsProvider::submitTriggerItem() -{ -} - int SocialStatsProvider::read(Json option, Json* requestResult) { SocialDbHandle *handle = new(std::nothrow) SocialDbHandle(this); @@ -51,13 +47,3 @@ int SocialStatsProvider::read(Json option, Json* requestResult) return ERR_NONE; } - -void ContactFreqProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_READ, - "{" TRIG_DEF_RANK "," TRIG_DEF_TOTAL_COUNT "}", - "{" - "\"Address\":{\"type\":\"string\"}," - TRIG_DEF_TIME_OF_DAY "," TRIG_DEF_DAY_OF_WEEK - "}"); -} diff --git a/src/social-stats/SocialStatsProvider.h b/src/social-stats/SocialStatsProvider.h index 1ae1570..19fbde2 100644 --- a/src/social-stats/SocialStatsProvider.h +++ b/src/social-stats/SocialStatsProvider.h @@ -25,9 +25,7 @@ namespace ctx { class SocialStatsProvider : public ContextProvider { public: int read(Json option, Json* requestResult); - bool isSupported(); - virtual void submitTriggerItem(); protected: SocialStatsProvider(const char *subject); @@ -39,8 +37,6 @@ namespace ctx { public: ContactFreqProvider() : SocialStatsProvider(SOCIAL_SUBJ_FREQUENCY) {} - - void submitTriggerItem(); }; diff --git a/src/social-stats/create.cpp b/src/social-stats/create.cpp index a498c28..6b318b9 100644 --- a/src/social-stats/create.cpp +++ b/src/social-stats/create.cpp @@ -14,21 +14,17 @@ * limitations under the License. */ -#include #include #include "SocialStatsProvider.h" #include "SocialStatsLogger.h" using namespace ctx; -/* TODO: This function will be changed into the following form: - ContextProvider* create(const char *subject) */ - -extern "C" SO_EXPORT bool create() +extern "C" SO_EXPORT ContextProvider* create(const char *subject) { - registerProvider(SOCIAL_SUBJ_LOGGER, SOCIAL_HISTORY_PRIV); - registerProvider(SOCIAL_SUBJ_FREQUENCY, SOCIAL_HISTORY_PRIV); - registerProvider(SOCIAL_SUBJ_FREQ_ADDRESS, SOCIAL_HISTORY_PRIV); + ADD_PROVIDER(SUBJ_SOCIAL_LOGGER, SocialStatsLogger); + ADD_PROVIDER(SUBJ_SOCIAL_FREQ_ADDRESS, TopContactsProvider); + ADD_PROVIDER(SUBJ_SOCIAL_FREQUENCY, ContactFreqProvider); - return true; + return NULL; } diff --git a/src/system/Battery.cpp b/src/system/Battery.cpp index 13bc62d..9ffbf9b 100644 --- a/src/system/Battery.cpp +++ b/src/system/Battery.cpp @@ -32,16 +32,6 @@ bool BatteryStateProvider::isSupported() return true; } -void BatteryStateProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, - "{" - "\"Level\":{\"type\":\"string\",\"values\":[\"Empty\",\"Critical\",\"Low\",\"Normal\",\"High\",\"Full\"]}," - TRIG_BOOL_ITEM_DEF("IsCharging") - "}", - NULL); -} - void BatteryStateProvider::__updateCb(device_callback_e deviceType, void* value, void* userData) { IF_FAIL_VOID(deviceType == DEVICE_CALLBACK_BATTERY_LEVEL); diff --git a/src/system/Battery.h b/src/system/Battery.h index ce695ac..6bd5496 100644 --- a/src/system/Battery.h +++ b/src/system/Battery.h @@ -34,7 +34,6 @@ namespace ctx { int read(); bool isSupported(); - void submitTriggerItem(); private: const char* __transToString(intptr_t level); diff --git a/src/system/Charger.cpp b/src/system/Charger.cpp index f06f88d..1d65275 100644 --- a/src/system/Charger.cpp +++ b/src/system/Charger.cpp @@ -32,12 +32,6 @@ bool ChargerStateProvider::isSupported() return true; } -void ChargerStateProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, - "{" TRIG_BOOL_ITEM_DEF("IsConnected") "}", NULL); -} - void ChargerStateProvider::handleUpdate() { bool chargerStatus = false; diff --git a/src/system/Charger.h b/src/system/Charger.h index 166440d..a62606c 100644 --- a/src/system/Charger.h +++ b/src/system/Charger.h @@ -27,9 +27,7 @@ namespace ctx { ~ChargerStateProvider(); int read(); - bool isSupported(); - void submitTriggerItem(); protected: void handleUpdate(); diff --git a/src/system/Gps.cpp b/src/system/Gps.cpp index 0d72cf8..284600e 100644 --- a/src/system/Gps.cpp +++ b/src/system/Gps.cpp @@ -51,15 +51,6 @@ bool GpsStateProvider::isSupported() return util::getSystemInfoBool("tizen.org/feature/location.gps"); } -void GpsStateProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, - "{" - "\"State\":{\"type\":\"string\",\"values\":[\"Disabled\",\"Searching\",\"Connected\"]}" - "}", - NULL); -} - void GpsStateProvider::handleUpdate() { int gpsStatus; diff --git a/src/system/Gps.h b/src/system/Gps.h index c6af9a4..9f051a5 100644 --- a/src/system/Gps.h +++ b/src/system/Gps.h @@ -27,9 +27,7 @@ namespace ctx { ~GpsStateProvider(); int read(); - bool isSupported(); - void submitTriggerItem(); protected: void handleUpdate(); diff --git a/src/system/Psmode.cpp b/src/system/Psmode.cpp index 8654191..2c74948 100644 --- a/src/system/Psmode.cpp +++ b/src/system/Psmode.cpp @@ -32,12 +32,6 @@ bool PowerSaveModeProvider::isSupported() return true; } -void PowerSaveModeProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, - "{" TRIG_BOOL_ITEM_DEF("IsEnabled") "}", NULL); -} - void PowerSaveModeProvider::__updateCb(keynode_t *node, void* userData) { PowerSaveModeProvider *instance = static_cast(userData); diff --git a/src/system/Psmode.h b/src/system/Psmode.h index 315465c..e86f355 100644 --- a/src/system/Psmode.h +++ b/src/system/Psmode.h @@ -33,7 +33,6 @@ namespace ctx { int read(); bool isSupported(); - void submitTriggerItem(); private: void __handleUpdate(keynode_t *node); diff --git a/src/system/Usb.cpp b/src/system/Usb.cpp index 5ea7242..c017036 100644 --- a/src/system/Usb.cpp +++ b/src/system/Usb.cpp @@ -33,12 +33,6 @@ bool UsbStateProvider::isSupported() return util::getSystemInfoBool("tizen.org/feature/usb.host"); } -void UsbStateProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, - "{" TRIG_BOOL_ITEM_DEF("IsConnected") "}", NULL); -} - void UsbStateProvider::handleUpdate() { bool status = false; diff --git a/src/system/Usb.h b/src/system/Usb.h index 55b6381..8897dc2 100644 --- a/src/system/Usb.h +++ b/src/system/Usb.h @@ -27,9 +27,7 @@ namespace ctx { ~UsbStateProvider(); int read(); - bool isSupported(); - void submitTriggerItem(); protected: void handleUpdate(); diff --git a/src/system/create.cpp b/src/system/create.cpp index 7add7b5..59aa3c3 100644 --- a/src/system/create.cpp +++ b/src/system/create.cpp @@ -14,7 +14,6 @@ * limitations under the License. */ -#include #include #include "Battery.h" #include "Charger.h" @@ -24,16 +23,13 @@ using namespace ctx; -/* TODO: This function will be changed into the following form: - ContextProvider* create(const char *subject) */ - -extern "C" SO_EXPORT bool create() +extern "C" SO_EXPORT ContextProvider* create(const char *subject) { - registerProvider(SUBJ_STATE_BATTERY, NULL); - registerProvider(SUBJ_STATE_CHARGER, NULL); - registerProvider(SUBJ_STATE_GPS, NULL); - registerProvider(SUBJ_STATE_PSMODE, NULL); - registerProvider(SUBJ_STATE_USB, NULL); + ADD_PROVIDER(SUBJ_STATE_BATTERY, BatteryStateProvider); + ADD_PROVIDER(SUBJ_STATE_CHARGER, ChargerStateProvider); + ADD_PROVIDER(SUBJ_STATE_GPS, GpsStateProvider); + ADD_PROVIDER(SUBJ_STATE_PSMODE, PowerSaveModeProvider); + ADD_PROVIDER(SUBJ_STATE_USB, UsbStateProvider); - return true; + return NULL; } diff --git a/src/time/Alarm.cpp b/src/time/Alarm.cpp index cdcf459..e3efec6 100644 --- a/src/time/Alarm.cpp +++ b/src/time/Alarm.cpp @@ -38,16 +38,6 @@ bool AlarmProvider::isSupported() return true; } -void AlarmProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_SUBSCRIBE, - "{" - "\"TimeOfDay\":{\"type\":\"integer\",\"min\":0,\"max\":1439}," - "\"DayOfWeek\":{\"type\":\"string\",\"values\":[\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\",\"Sun\",\"Weekday\",\"Weekend\"]}" - "}", - NULL); -} - int AlarmProvider::subscribe(Json option, Json *requestResult) { int dow = __getArrangedDayOfWeek(option); diff --git a/src/time/Alarm.h b/src/time/Alarm.h index ea53978..1a21de2 100644 --- a/src/time/Alarm.h +++ b/src/time/Alarm.h @@ -34,7 +34,6 @@ namespace ctx { int unsubscribe(Json option); bool isSupported(); - void submitTriggerItem(); protected: bool onTimerExpired(int timerId); diff --git a/src/time/Time.cpp b/src/time/Time.cpp index 99d0afd..3490be5 100644 --- a/src/time/Time.cpp +++ b/src/time/Time.cpp @@ -33,17 +33,6 @@ bool TimeProvider::isSupported() return true; } -void TimeProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_READ, - "{" - "\"TimeOfDay\":{\"type\":\"integer\",\"min\":0,\"max\":1439}," - "\"DayOfWeek\":{\"type\":\"string\",\"values\":[\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\",\"Sun\",\"Weekday\",\"Weekend\"]}," - "\"DayOfMonth\":{\"type\":\"integer\",\"min\":1,\"max\":31}" - "}", - NULL); -} - int TimeProvider::subscribe() { return ERR_NOT_SUPPORTED; diff --git a/src/time/Time.h b/src/time/Time.h index 6aee48d..1900c81 100644 --- a/src/time/Time.h +++ b/src/time/Time.h @@ -32,7 +32,6 @@ namespace ctx { int read(); bool isSupported(); - void submitTriggerItem(); }; } diff --git a/src/time/create.cpp b/src/time/create.cpp index e0da510..d906a63 100644 --- a/src/time/create.cpp +++ b/src/time/create.cpp @@ -14,20 +14,16 @@ * limitations under the License. */ -#include #include #include "Alarm.h" #include "Time.h" using namespace ctx; -/* TODO: This function will be changed into the following form: - ContextProvider* create(const char *subject) */ - -extern "C" SO_EXPORT bool create() +extern "C" SO_EXPORT ContextProvider* create(const char *subject) { - registerProvider(SUBJ_STATE_ALARM, PRIV_ALARM); - registerProvider(SUBJ_STATE_TIME, NULL); + ADD_PROVIDER(SUBJ_STATE_ALARM, AlarmProvider); + ADD_PROVIDER(SUBJ_STATE_TIME, TimeProvider); - return true; + return NULL; } diff --git a/src/wifi/Wifi.cpp b/src/wifi/Wifi.cpp index b7e085e..4a1db85 100644 --- a/src/wifi/Wifi.cpp +++ b/src/wifi/Wifi.cpp @@ -45,16 +45,6 @@ bool WifiStateProvider::isSupported() return util::getSystemInfoBool("tizen.org/feature/network.wifi"); } -void WifiStateProvider::submitTriggerItem() -{ - registerTriggerItem(OPS_SUBSCRIBE | OPS_READ, - "{" - "\"State\":{\"type\":\"string\",\"values\":[\"Disabled\",\"Unconnected\",\"Connected\"]}," - "\"BSSID\":{\"type\":\"string\"}" - "}", - NULL); -} - bool WifiStateProvider::__getCurrentState() { int err; diff --git a/src/wifi/Wifi.h b/src/wifi/Wifi.h index 083a270..0446af4 100644 --- a/src/wifi/Wifi.h +++ b/src/wifi/Wifi.h @@ -34,7 +34,6 @@ namespace ctx { int read(); bool isSupported(); - void submitTriggerItem(); private: enum InternalState { diff --git a/src/wifi/create.cpp b/src/wifi/create.cpp index cb8a87e..cdf1db3 100644 --- a/src/wifi/create.cpp +++ b/src/wifi/create.cpp @@ -14,18 +14,14 @@ * limitations under the License. */ -#include #include #include "Wifi.h" using namespace ctx; -/* TODO: This function will be changed into the following form: - ContextProvider* create(const char *subject) */ - -extern "C" SO_EXPORT bool create() +extern "C" SO_EXPORT ContextProvider* create(const char *subject) { - registerProvider(SUBJ_STATE_WIFI, PRIV_NETWORK); + ADD_PROVIDER(SUBJ_STATE_WIFI, WifiStateProvider); - return true; + return NULL; } -- 2.7.4 From 2d96d1a9c27111f733d6889dbffe5d7d297bf03f Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Wed, 27 Apr 2016 16:17:21 +0900 Subject: [PATCH 16/16] Implement getPrivilege() functions Change-Id: I7fc00fe8c1542d4943376f92b7d36c7c926533e7 Signed-off-by: Mu-Woong Lee --- src/app-stats/AppStatsLogger.cpp | 5 +++++ src/app-stats/AppStatsLogger.h | 2 ++ src/app-stats/AppStatsProvider.cpp | 5 +++++ src/app-stats/AppStatsProvider.h | 1 + src/call/Call.cpp | 5 +++++ src/call/Call.h | 1 + src/contacts/Contacts.cpp | 5 +++++ src/contacts/Contacts.h | 1 + src/geofence/PlaceGeofenceProvider.cpp | 5 +++++ src/geofence/PlaceGeofenceProvider.h | 1 + src/media-stats/MediaStatsLogger.cpp | 5 +++++ src/media-stats/MediaStatsLogger.h | 1 + src/media-stats/MediaStatsProvider.cpp | 5 +++++ src/media-stats/MediaStatsProvider.h | 1 + src/message/Message.cpp | 5 +++++ src/message/Message.h | 1 + src/my-place/place_recognition.cpp | 6 ++++++ src/my-place/place_recognition.h | 1 + src/social-stats/SocialStatsLogger.cpp | 5 +++++ src/social-stats/SocialStatsLogger.h | 1 + src/social-stats/SocialStatsProvider.cpp | 5 +++++ src/social-stats/SocialStatsProvider.h | 1 + src/time/Alarm.cpp | 5 +++++ src/time/Alarm.h | 1 + src/wifi/Wifi.cpp | 5 +++++ src/wifi/Wifi.h | 1 + 26 files changed, 80 insertions(+) diff --git a/src/app-stats/AppStatsLogger.cpp b/src/app-stats/AppStatsLogger.cpp index 78261b5..8b7e045 100644 --- a/src/app-stats/AppStatsLogger.cpp +++ b/src/app-stats/AppStatsLogger.cpp @@ -46,6 +46,11 @@ AppStatsLogger::~AppStatsLogger() delete __launchMon; } +void AppStatsLogger::getPrivilege(std::vector &privilege) +{ + privilege.push_back(PRIV_APP_HISTORY); +} + int AppStatsLogger::subscribe(Json option, Json* requestResult) { return ERR_NONE; diff --git a/src/app-stats/AppStatsLogger.h b/src/app-stats/AppStatsLogger.h index 2c6c4bd..3c9fbc1 100644 --- a/src/app-stats/AppStatsLogger.h +++ b/src/app-stats/AppStatsLogger.h @@ -32,6 +32,8 @@ namespace ctx { int subscribe(Json option, Json *requestResult); int unsubscribe(Json option); + void getPrivilege(std::vector &privilege); + private: AppDbInitializer *__initializer; AppInstallMonitor *__installMon; diff --git a/src/app-stats/AppStatsProvider.cpp b/src/app-stats/AppStatsProvider.cpp index 3513854..2b8bb3f 100644 --- a/src/app-stats/AppStatsProvider.cpp +++ b/src/app-stats/AppStatsProvider.cpp @@ -28,6 +28,11 @@ AppStatsProvider::~AppStatsProvider() { } +void AppStatsProvider::getPrivilege(std::vector &privilege) +{ + privilege.push_back(PRIV_APP_HISTORY); +} + int AppStatsProvider::read(Json option, Json *requestResult) { AppDbHandle *handle = new(std::nothrow) AppDbHandle(this); diff --git a/src/app-stats/AppStatsProvider.h b/src/app-stats/AppStatsProvider.h index 85759be..767a523 100644 --- a/src/app-stats/AppStatsProvider.h +++ b/src/app-stats/AppStatsProvider.h @@ -25,6 +25,7 @@ namespace ctx { class AppStatsProvider : public ContextProvider { public: int read(Json option, Json *requestResult); + void getPrivilege(std::vector &privilege); protected: AppStatsProvider(const char *subject); diff --git a/src/call/Call.cpp b/src/call/Call.cpp index dc3d616..24c1f0c 100644 --- a/src/call/Call.cpp +++ b/src/call/Call.cpp @@ -49,6 +49,11 @@ CallStateProvider::~CallStateProvider() { } +void CallStateProvider::getPrivilege(std::vector &privilege) +{ + privilege.push_back(PRIV_TELEPHONY); +} + bool CallStateProvider::isSupported() { return util::getSystemInfoBool("tizen.org/feature/network.telephony"); diff --git a/src/call/Call.h b/src/call/Call.h index 79b5e6b..7fc03dc 100644 --- a/src/call/Call.h +++ b/src/call/Call.h @@ -33,6 +33,7 @@ namespace ctx { int read(); bool isSupported(); + void getPrivilege(std::vector &privilege); private: telephony_handle_list_s __handleList; diff --git a/src/contacts/Contacts.cpp b/src/contacts/Contacts.cpp index 13cf5c7..3bfe074 100644 --- a/src/contacts/Contacts.cpp +++ b/src/contacts/Contacts.cpp @@ -33,6 +33,11 @@ ContactsChangeProvider::~ContactsChangeProvider() { } +void ContactsChangeProvider::getPrivilege(std::vector &privilege) +{ + privilege.push_back(PRIV_CONTACT); +} + bool ContactsChangeProvider::isSupported() { return true; diff --git a/src/contacts/Contacts.h b/src/contacts/Contacts.h index da65fe5..623f8c9 100644 --- a/src/contacts/Contacts.h +++ b/src/contacts/Contacts.h @@ -32,6 +32,7 @@ namespace ctx { int unsubscribe(); bool isSupported(); + void getPrivilege(std::vector &privilege); private: time_t __latestMyProfile; diff --git a/src/geofence/PlaceGeofenceProvider.cpp b/src/geofence/PlaceGeofenceProvider.cpp index 2f09c53..17a096e 100644 --- a/src/geofence/PlaceGeofenceProvider.cpp +++ b/src/geofence/PlaceGeofenceProvider.cpp @@ -34,6 +34,11 @@ PlaceGeofenceProvider::~PlaceGeofenceProvider() __handleMap.clear(); } +void PlaceGeofenceProvider::getPrivilege(std::vector &privilege) +{ + privilege.push_back(PRIV_LOCATION); +} + bool PlaceGeofenceProvider::isSupported() { bool supported = false; diff --git a/src/geofence/PlaceGeofenceProvider.h b/src/geofence/PlaceGeofenceProvider.h index fe2a416..c09ea1d 100644 --- a/src/geofence/PlaceGeofenceProvider.h +++ b/src/geofence/PlaceGeofenceProvider.h @@ -34,6 +34,7 @@ namespace ctx { int unsubscribe(Json option); bool isSupported(); + void getPrivilege(std::vector &privilege); private: std::map __handleMap; diff --git a/src/media-stats/MediaStatsLogger.cpp b/src/media-stats/MediaStatsLogger.cpp index 44021d8..75fc326 100644 --- a/src/media-stats/MediaStatsLogger.cpp +++ b/src/media-stats/MediaStatsLogger.cpp @@ -28,6 +28,11 @@ MediaStatsLogger::~MediaStatsLogger() { } +void MediaStatsLogger::getPrivilege(std::vector &privilege) +{ + privilege.push_back(PRIV_MEDIA_HISTORY); +} + int MediaStatsLogger::subscribe(Json option, Json* requestResult) { return ERR_NONE; diff --git a/src/media-stats/MediaStatsLogger.h b/src/media-stats/MediaStatsLogger.h index eb273f9..60b8f12 100644 --- a/src/media-stats/MediaStatsLogger.h +++ b/src/media-stats/MediaStatsLogger.h @@ -29,6 +29,7 @@ namespace ctx { int subscribe(Json option, Json *requestResult); int unsubscribe(Json option); + void getPrivilege(std::vector &privilege); private: MediaContentMonitor __contentMon; diff --git a/src/media-stats/MediaStatsProvider.cpp b/src/media-stats/MediaStatsProvider.cpp index daa1349..ed05640 100644 --- a/src/media-stats/MediaStatsProvider.cpp +++ b/src/media-stats/MediaStatsProvider.cpp @@ -28,6 +28,11 @@ MediaStatsProvider::~MediaStatsProvider() { } +void MediaStatsProvider::getPrivilege(std::vector &privilege) +{ + privilege.push_back(PRIV_MEDIA_HISTORY); +} + bool MediaStatsProvider::isSupported() { /* TODO */ diff --git a/src/media-stats/MediaStatsProvider.h b/src/media-stats/MediaStatsProvider.h index bb27e47..26a32cc 100644 --- a/src/media-stats/MediaStatsProvider.h +++ b/src/media-stats/MediaStatsProvider.h @@ -26,6 +26,7 @@ namespace ctx { public: int read(Json option, Json* requestResult); bool isSupported(); + void getPrivilege(std::vector &privilege); protected: MediaStatsProvider(const char *subject); diff --git a/src/message/Message.cpp b/src/message/Message.cpp index 32a484b..787c89f 100644 --- a/src/message/Message.cpp +++ b/src/message/Message.cpp @@ -31,6 +31,11 @@ MessageEventProvider::~MessageEventProvider() { } +void MessageEventProvider::getPrivilege(std::vector &privilege) +{ + privilege.push_back(PRIV_MESSAGE); +} + bool MessageEventProvider::isSupported() { return util::getSystemInfoBool("tizen.org/feature/network.telephony"); diff --git a/src/message/Message.h b/src/message/Message.h index 576ce2f..e46eff3 100644 --- a/src/message/Message.h +++ b/src/message/Message.h @@ -32,6 +32,7 @@ namespace ctx { int subscribe(); int unsubscribe(); bool isSupported(); + void getPrivilege(std::vector &privilege); private: msg_handle_t __messageHandle; diff --git a/src/my-place/place_recognition.cpp b/src/my-place/place_recognition.cpp index 789c2da..3d90c6a 100644 --- a/src/my-place/place_recognition.cpp +++ b/src/my-place/place_recognition.cpp @@ -17,6 +17,12 @@ #include "place_recognition.h" #include "user_places/user_places.h" +void ctx::PlaceRecognitionProvider::getPrivilege(std::vector &privilege) +{ + privilege.push_back(PRIV_LOCATION); + privilege.push_back(PRIV_NETWORK); +} + int ctx::PlaceRecognitionProvider::subscribe(ctx::Json option, ctx::Json* requestResult) { return ERR_NOT_SUPPORTED; diff --git a/src/my-place/place_recognition.h b/src/my-place/place_recognition.h index 9eda4ac..fe90094 100644 --- a/src/my-place/place_recognition.h +++ b/src/my-place/place_recognition.h @@ -37,6 +37,7 @@ namespace ctx { int write(ctx::Json data, ctx::Json *requestResult); bool isSupported(); + void getPrivilege(std::vector &privilege); private: UserPlaces __engine; diff --git a/src/social-stats/SocialStatsLogger.cpp b/src/social-stats/SocialStatsLogger.cpp index 753588e..6e1b869 100644 --- a/src/social-stats/SocialStatsLogger.cpp +++ b/src/social-stats/SocialStatsLogger.cpp @@ -28,6 +28,11 @@ SocialStatsLogger::~SocialStatsLogger() { } +void SocialStatsLogger::getPrivilege(std::vector &privilege) +{ + privilege.push_back(PRIV_CALL_HISTORY); +} + int SocialStatsLogger::subscribe(Json option, Json* requestResult) { return ERR_NONE; diff --git a/src/social-stats/SocialStatsLogger.h b/src/social-stats/SocialStatsLogger.h index 5f5cc9b..3d15128 100644 --- a/src/social-stats/SocialStatsLogger.h +++ b/src/social-stats/SocialStatsLogger.h @@ -29,6 +29,7 @@ namespace ctx { int subscribe(Json option, Json* requestResult); int unsubscribe(Json option); + void getPrivilege(std::vector &privilege); private: ContactLogAggregator __aggregator; diff --git a/src/social-stats/SocialStatsProvider.cpp b/src/social-stats/SocialStatsProvider.cpp index a93978a..22d46b5 100644 --- a/src/social-stats/SocialStatsProvider.cpp +++ b/src/social-stats/SocialStatsProvider.cpp @@ -28,6 +28,11 @@ SocialStatsProvider::~SocialStatsProvider() { } +void SocialStatsProvider::getPrivilege(std::vector &privilege) +{ + privilege.push_back(PRIV_CALL_HISTORY); +} + bool SocialStatsProvider::isSupported() { /* TODO */ diff --git a/src/social-stats/SocialStatsProvider.h b/src/social-stats/SocialStatsProvider.h index 19fbde2..79893f2 100644 --- a/src/social-stats/SocialStatsProvider.h +++ b/src/social-stats/SocialStatsProvider.h @@ -26,6 +26,7 @@ namespace ctx { public: int read(Json option, Json* requestResult); bool isSupported(); + void getPrivilege(std::vector &privilege); protected: SocialStatsProvider(const char *subject); diff --git a/src/time/Alarm.cpp b/src/time/Alarm.cpp index e3efec6..0d25628 100644 --- a/src/time/Alarm.cpp +++ b/src/time/Alarm.cpp @@ -33,6 +33,11 @@ AlarmProvider::~AlarmProvider() __optionSet.clear(); } +void AlarmProvider::getPrivilege(std::vector &privilege) +{ + privilege.push_back(PRIV_ALARM); +} + bool AlarmProvider::isSupported() { return true; diff --git a/src/time/Alarm.h b/src/time/Alarm.h index 1a21de2..c0eb946 100644 --- a/src/time/Alarm.h +++ b/src/time/Alarm.h @@ -34,6 +34,7 @@ namespace ctx { int unsubscribe(Json option); bool isSupported(); + void getPrivilege(std::vector &privilege); protected: bool onTimerExpired(int timerId); diff --git a/src/wifi/Wifi.cpp b/src/wifi/Wifi.cpp index 4a1db85..ff501bf 100644 --- a/src/wifi/Wifi.cpp +++ b/src/wifi/Wifi.cpp @@ -40,6 +40,11 @@ WifiStateProvider::~WifiStateProvider() __stopMonitor(); } +void WifiStateProvider::getPrivilege(std::vector &privilege) +{ + privilege.push_back(PRIV_NETWORK); +} + bool WifiStateProvider::isSupported() { return util::getSystemInfoBool("tizen.org/feature/network.wifi"); diff --git a/src/wifi/Wifi.h b/src/wifi/Wifi.h index 0446af4..22695ca 100644 --- a/src/wifi/Wifi.h +++ b/src/wifi/Wifi.h @@ -34,6 +34,7 @@ namespace ctx { int read(); bool isSupported(); + void getPrivilege(std::vector &privilege); private: enum InternalState { -- 2.7.4