From b25fb5f694cfa1c22c98e152e6bd9852ef9cbab2 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 21 Apr 2016 17:07:04 +0900 Subject: [PATCH] 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