From: Mu-Woong Lee Date: Thu, 21 Apr 2016 05:07:49 +0000 (+0900) Subject: Rename DeviceProviderBase as BasicProvider X-Git-Tag: submit/tizen/20160503.015801^2~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c9ecd4ec06f4ebfeb0ede1690de760e90aa36977;p=platform%2Fcore%2Fcontext%2Fcontext-provider.git Rename DeviceProviderBase as BasicProvider Change-Id: I0d7e97a0d988ce3d619585ad4cbfd81e08b9af85 Signed-off-by: Mu-Woong Lee --- 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/BasicProvider.cpp b/src/shared/BasicProvider.cpp new file mode 100644 index 0000000..95cba6b --- /dev/null +++ b/src/shared/BasicProvider.cpp @@ -0,0 +1,99 @@ +/* + * 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 "BasicProvider.h" + +using namespace ctx; + +BasicProvider::BasicProvider(const char *subject) : + ContextProvider(subject), + __beingSubscribed(false) +{ +} + +BasicProvider::~BasicProvider() +{ +} + +bool BasicProvider::isSupported() +{ + return true; +} + +void BasicProvider::submitTriggerItem() +{ +} + +int BasicProvider::subscribe(Json option, Json *requestResult) +{ + IF_FAIL_RETURN(!__beingSubscribed, ERR_NONE); + + int ret = subscribe(); + + if (ret == ERR_NONE) + __beingSubscribed = true; + + return ret; +} + +int BasicProvider::unsubscribe(Json option) +{ + int ret = ERR_NONE; + + if (__beingSubscribed) + ret = unsubscribe(); + + return ret; +} + +int BasicProvider::read(Json option, Json *requestResult) +{ + return read(); +} + +int BasicProvider::write(Json data, Json *requestResult) +{ + return write(data); +} + +int BasicProvider::subscribe() +{ + return ERR_NOT_SUPPORTED; +} + +int BasicProvider::unsubscribe() +{ + return ERR_NOT_SUPPORTED; +} + +int BasicProvider::read() +{ + return ERR_NOT_SUPPORTED; +} + +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 new file mode 100644 index 0000000..c7a7f5d --- /dev/null +++ b/src/shared/BasicProvider.h @@ -0,0 +1,55 @@ +/* + * 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_BASIC_PROVIDER_H_ +#define _CONTEXT_BASIC_PROVIDER_H_ + +#include + +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 { + public: + 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(); + + /* TODO: This function will be deprecated */ + virtual void submitTriggerItem(); + + protected: + bool __beingSubscribed; + + BasicProvider(const char *subject); + virtual ~BasicProvider(); + + virtual int subscribe(); + 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); + }; +} + +#endif /* _CONTEXT_BASIC_PROVIDER_H_ */ diff --git a/src/shared/DeviceProviderBase.cpp b/src/shared/DeviceProviderBase.cpp deleted file mode 100644 index 1c5f5ef..0000000 --- a/src/shared/DeviceProviderBase.cpp +++ /dev/null @@ -1,95 +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 "DeviceProviderBase.h" - -using namespace ctx; - -DeviceProviderBase::DeviceProviderBase(const char *subject) : - ContextProvider(subject), - __beingSubscribed(false) -{ -} - -bool DeviceProviderBase::isSupported() -{ - return true; -} - -void DeviceProviderBase::submitTriggerItem() -{ -} - -int DeviceProviderBase::subscribe(Json option, Json *requestResult) -{ - IF_FAIL_RETURN(!__beingSubscribed, ERR_NONE); - - int ret = subscribe(); - - if (ret == ERR_NONE) - __beingSubscribed = true; - - return ret; -} - -int DeviceProviderBase::unsubscribe(Json option) -{ - int ret = ERR_NONE; - - if (__beingSubscribed) - ret = unsubscribe(); - - return ret; -} - -int DeviceProviderBase::read(Json option, Json *requestResult) -{ - return read(); -} - -int DeviceProviderBase::write(Json data, Json *requestResult) -{ - return write(); -} - -int DeviceProviderBase::subscribe() -{ - return ERR_NOT_SUPPORTED; -} - -int DeviceProviderBase::unsubscribe() -{ - return ERR_NOT_SUPPORTED; -} - -int DeviceProviderBase::read() -{ - return ERR_NOT_SUPPORTED; -} - -int DeviceProviderBase::write() -{ - return ERR_NOT_SUPPORTED; -} - -bool DeviceProviderBase::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/DeviceProviderBase.h b/src/shared/DeviceProviderBase.h deleted file mode 100644 index f5a55da..0000000 --- a/src/shared/DeviceProviderBase.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _CONTEXT_DEVICE_PROVIDER_BASE_H_ -#define _CONTEXT_DEVICE_PROVIDER_BASE_H_ - -#include - -namespace ctx { - - class DeviceProviderBase : public ContextProvider { - public: - 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(const char *subject); - virtual ~DeviceProviderBase() {} - - virtual int subscribe(); - virtual int unsubscribe(); - virtual int read(); - virtual int write(); - - static bool getSystemInfoBool(const char *key); - }; -} - -#endif // _CONTEXT_DEVICE_PROVIDER_BASE_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();