From: Changgyu Choi Date: Mon, 21 Aug 2023 04:29:25 +0000 (+0900) Subject: Add new app event X-Git-Tag: accepted/tizen/7.0/unified/20240125.054738~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=30ded08c10cbc59a31a37eafedec4871ab31c76b;p=platform%2Fcore%2Fappfw%2Fapp-core.git Add new app event tizen app can receive time zone changed event. Adds: - TIME_ZONE_CHANGED Change-Id: I1da9aeafd8e2afa1e878a1eaea5d8c68cfc1451d Signed-off-by: Changgyu Choi --- diff --git a/tizen-cpp/app-core-cpp/app_core_base.cc b/tizen-cpp/app-core-cpp/app_core_base.cc index 9d22bb1..72b3539 100644 --- a/tizen-cpp/app-core-cpp/app_core_base.cc +++ b/tizen-cpp/app-core-cpp/app_core_base.cc @@ -228,6 +228,7 @@ class AppCoreBase::Impl { static void ReceiveSuspendSignalCb(GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*, GVariant*, gpointer); static void OnLowBatteryCb(keynode_t* key, void* data); + static void OnTimeZoneChangedCb(keynode_t* key, void* data); static void LockCb(keynode_t* node, void* user_data); static void AutoRotationChangedCb(sensor_t sensor, unsigned int event_type, sensor_data_t* data, void* user_data); @@ -787,6 +788,21 @@ void AppCoreBase::Impl::OnLowBatteryCb(keynode_t* key, void* data) { } } +void AppCoreBase::Impl::OnTimeZoneChangedCb(keynode_t* key, void* data) { + char* time_zone_id = vconf_keynode_get_str(key); + if (time_zone_id == nullptr) { + return; + } + + char* time_zone = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_INT); + if (time_zone != nullptr) { + AppCoreBase* base = reinterpret_cast(data); + base->impl_->InvokeCallback(std::string(time_zone) + "|" + time_zone_id, + IEvent::Type::TIME_ZONE_CHANGED); + free(time_zone); + } +} + void AppCoreBase::Impl::UnregisterRotationChangedEvent() { if (!__rotation.ref) return; @@ -828,6 +844,10 @@ int AppCoreBase::OnSetEvent(IEvent::Type event) { break; case IEvent::Type::SUSPENDED_STATE_CHANGE: break; + case IEvent::Type::TIME_ZONE_CHANGED: + vconf_notify_key_changed(VCONFKEY_SETAPPL_TIMEZONE_ID, + impl_->OnTimeZoneChangedCb, this); + break; default: break; } diff --git a/tizen-cpp/app-core-cpp/interface_app_core.hh b/tizen-cpp/app-core-cpp/interface_app_core.hh index 504abbe..ed9ce8b 100644 --- a/tizen-cpp/app-core-cpp/interface_app_core.hh +++ b/tizen-cpp/app-core-cpp/interface_app_core.hh @@ -40,6 +40,7 @@ class EXPORT_API IAppCore { REGION_CHANGE, SUSPENDED_STATE_CHANGE, UPDATE_REQUESTED, + TIME_ZONE_CHANGED, END /* for iterate */ }; diff --git a/tizen-cpp/app-core-ui-cpp/app_core_task_base.cc b/tizen-cpp/app-core-ui-cpp/app_core_task_base.cc index f6e1906..1425b68 100644 --- a/tizen-cpp/app-core-ui-cpp/app_core_task_base.cc +++ b/tizen-cpp/app-core-ui-cpp/app_core_task_base.cc @@ -72,6 +72,7 @@ class AppCoreTaskBase::Impl : public SystemEvent::IEvent { std::shared_ptr lang_change_; std::shared_ptr device_orientation_changed_; std::shared_ptr region_change_; + std::shared_ptr time_zone_change_; GMainLoop* loop_ = nullptr; std::queue queue_; mutable std::recursive_mutex mutex_; @@ -100,6 +101,8 @@ AppCoreTaskBase::Impl::Impl(AppCoreTaskBase* parent) : parent_(parent) { IAppCore::IEvent::Type::DEVICE_ORIENTATION_CHANGED, this); region_change_ = std::make_shared( IAppCore::IEvent::Type::REGION_CHANGE, this); + time_zone_change_ = std::make_shared( + IAppCore::IEvent::Type::TIME_ZONE_CHANGED, this); } void AppCoreTaskBase::Impl::LoopInit(int argc, char** argv) { @@ -127,6 +130,7 @@ void AppCoreTaskBase::Impl::SetSystemEvents() { } void AppCoreTaskBase::Impl::UnsetSystemEvents() { + parent_->RemoveEvent(time_zone_change_); parent_->RemoveEvent(region_change_); parent_->RemoveEvent(device_orientation_changed_); parent_->RemoveEvent(lang_change_); @@ -146,6 +150,8 @@ void AppCoreTaskBase::Impl::OnSystemEvent(IAppCore::IEvent::Type type) { ConvertRotationState(device_orientation_changed_->GetVal(0))); } else if (type == IAppCore::IEvent::Type::REGION_CHANGE) { parent_->OnRegionChanged(region_change_->GetVal("")); + } else if (type == IAppCore::IEvent::Type::TIME_ZONE_CHANGED) { + parent_->OnTimeZoneChanged(time_zone_change_->GetVal("")); } } @@ -286,6 +292,8 @@ void AppCoreTaskBase::OnDeviceOrientationChanged(DeviceOrientationState state) { void AppCoreTaskBase::OnRegionChanged(const std::string& region) {} +void AppCoreTaskBase::OnTimeZoneChanged(const std::string& time_zone) {} + void AppCoreTaskBase::Run(int argc, char** argv) { impl_->SetSystemEvents(); AppCoreBase::Run(argc, argv); diff --git a/tizen-cpp/app-core-ui-cpp/app_core_task_base.hh b/tizen-cpp/app-core-ui-cpp/app_core_task_base.hh index 182e64b..da4355c 100644 --- a/tizen-cpp/app-core-ui-cpp/app_core_task_base.hh +++ b/tizen-cpp/app-core-ui-cpp/app_core_task_base.hh @@ -70,6 +70,7 @@ class EXPORT_API AppCoreTaskBase : public AppCoreBase, virtual void OnLangChanged(const std::string& lang); virtual void OnDeviceOrientationChanged(DeviceOrientationState state); virtual void OnRegionChanged(const std::string& region); + virtual void OnTimeZoneChanged(const std::string& time_zone); void Run(int argc, char** argv) override;