From dfcbc81b191998f95346ea197c7e88701d4fdc34 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Tue, 26 Apr 2016 14:33:43 +0900 Subject: [PATCH] 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.34.1