X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Faccessibility%2Fbridge%2Fbridge-impl.cpp;h=2fd6c49614bb9ed2b9a482c006d8423a9db3d9e7;hb=HEAD;hp=b4df08e7d8a3e31d1cf60d3508d3273da8c8a600;hpb=53ba2fd4c2ef96b9fca03746588765d28abf947e;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/accessibility/bridge/bridge-impl.cpp b/dali/internal/accessibility/bridge/bridge-impl.cpp index b4df08e..2fd6c49 100644 --- a/dali/internal/accessibility/bridge/bridge-impl.cpp +++ b/dali/internal/accessibility/bridge/bridge-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -30,17 +30,19 @@ #include #include #include +#include #include #include #include -#include #include +#include #include #include #include +#include +#include #include #include -#include #include #include #include @@ -49,7 +51,6 @@ using namespace Dali::Accessibility; namespace // unnamed namespace { - const int RETRY_INTERVAL = 1000; } // unnamed namespace @@ -70,17 +71,19 @@ class BridgeImpl : public virtual BridgeBase, public BridgeApplication, public BridgeHypertext, public BridgeHyperlink, - public BridgeSocket + public BridgeSocket, + public BridgeTable, + public BridgeTableCell { - DBus::DBusClient mAccessibilityStatusClient; - DBus::DBusClient mRegistryClient; - DBus::DBusClient mDirectReadingClient; - bool mIsScreenReaderEnabled = false; - bool mIsEnabled = false; - std::unordered_map> mDirectReadingCallbacks; + DBus::DBusClient mAccessibilityStatusClient{}; + DBus::DBusClient mRegistryClient{}; + DBus::DBusClient mDirectReadingClient{}; + bool mIsScreenReaderEnabled{false}; + bool mIsEnabled{false}; + std::unordered_map> mDirectReadingCallbacks{}; Dali::Actor mHighlightedActor; - std::function mHighlightClearAction; - Dali::CallbackBase* mIdleCallback = NULL; + std::function mHighlightClearAction{nullptr}; + Dali::CallbackBase* mIdleCallback{}; Dali::Timer mInitializeTimer; Dali::Timer mReadIsEnabledTimer; Dali::Timer mReadScreenReaderEnabledTimer; @@ -88,48 +91,46 @@ class BridgeImpl : public virtual BridgeBase, std::string mPreferredBusName; public: - BridgeImpl() - { - } + BridgeImpl() = default; /** - * @copydoc Dali::Accessibility::Bridge::Emit() + * @copydoc Dali::Accessibility::Bridge::EmitKeyEvent() */ - Consumed Emit(KeyEventType type, unsigned int keyCode, const std::string& keyName, unsigned int timeStamp, bool isText) override + bool EmitKeyEvent(Dali::KeyEvent keyEvent, std::function callback) override { + using ArgumentTypes = std::tuple; + + static const char* methodName = "NotifyListenersSync"; + if(!IsUp()) { - return Consumed::NO; + return false; } - unsigned int keyType = 0; + uint32_t keyType = (keyEvent.GetState() == Dali::KeyEvent::DOWN ? 0U : 1U); + auto timeStamp = static_cast(keyEvent.GetTime()); + bool isText = !keyEvent.GetKeyString().empty(); - switch(type) - { - case KeyEventType::KEY_PRESSED: - { - keyType = 0; - break; - } - case KeyEventType::KEY_RELEASED: + ArgumentTypes arguments(keyType, 0, keyEvent.GetKeyCode(), 0, timeStamp, keyEvent.GetKeyName(), isText); + + auto functor = [keyEvent = std::move(keyEvent), callback = std::move(callback)](DBus::ValueOrError reply) { + bool consumed = false; + + if(!reply) { - keyType = 1; - break; + DALI_LOG_ERROR("%s call failed: %s", methodName, reply.getError().message.c_str()); } - default: + else { - return Consumed::NO; + consumed = std::get<0>(reply.getValues()); } - } - auto methodObject = mRegistryClient.method)>("NotifyListenersSync"); - auto result = methodObject.call(std::tuple{keyType, 0, static_cast(keyCode), 0, static_cast(timeStamp), keyName, isText ? 1 : 0}); - if(!result) - { - LOG() << result.getError().message; - return Consumed::NO; - } - return std::get<0>(result) ? Consumed::YES : Consumed::NO; + callback(std::move(keyEvent), consumed); + }; + + mRegistryClient.method(methodName).asyncCall(std::move(functor), arguments); + + return true; } /** @@ -148,7 +149,7 @@ public: LOG() << "Direct reading command failed (" << msg.getError().message << ")\n"; } }, - true); + true); } /** @@ -167,7 +168,7 @@ public: LOG() << "Direct reading command failed (" << msg.getError().message << ")\n"; } }, - false); + false); } /** @@ -186,7 +187,7 @@ public: LOG() << "Direct reading command failed (" << msg.getError().message << ")\n"; } }, - alsoNonDiscardable); + alsoNonDiscardable); } /** @@ -209,8 +210,8 @@ public: mDirectReadingCallbacks.emplace(std::get<2>(msg), callback); } }, - text, - discardable); + text, + discardable); } /** @@ -235,8 +236,8 @@ public: mHighlightedActor = {}; mHighlightClearAction = {}; BridgeAccessible::ForceDown(); - mRegistryClient = {}; - mDirectReadingClient = {}; + mRegistryClient = {}; + mDirectReadingClient = {}; mDirectReadingCallbacks.clear(); mApplication.mChildren.clear(); ClearTimer(); @@ -289,9 +290,9 @@ public: { Dali::Adaptor::Get().RemoveIdle(mIdleCallback); } - mAccessibilityStatusClient = {}; - mDbusServer = {}; - mConnectionPtr = {}; + mAccessibilityStatusClient = {}; + mDbusServer = {}; + mConnectionPtr = {}; } bool ForceUpTimerCallback() @@ -337,6 +338,8 @@ public: BridgeHypertext::RegisterInterfaces(); BridgeHyperlink::RegisterInterfaces(); BridgeSocket::RegisterInterfaces(); + BridgeTable::RegisterInterfaces(); + BridgeTableCell::RegisterInterfaces(); RegisterOnBridge(&mApplication); @@ -365,6 +368,21 @@ public: } /** + * @brief Sends a signal to dbus that the window is created. + * + * @param[in] window The window to be created + * @see BridgeObject::Emit() + */ + void EmitCreated(Dali::Window window) + { + auto windowAccessible = mApplication.GetWindowAccessible(window); + if(windowAccessible) + { + windowAccessible->Emit(WindowEvent::CREATE, 0); + } + } + + /** * @brief Sends a signal to dbus that the window is shown. * * @param[in] window The window to be shown @@ -471,6 +489,17 @@ public: } /** + * @copydoc Dali::Accessibility::Bridge::WindowCreated() + */ + void WindowCreated(Dali::Window window) override + { + if(IsUp()) + { + EmitCreated(window); + } + } + + /** * @copydoc Dali::Accessibility::Bridge::WindowShown() */ void WindowShown(Dali::Window window) override @@ -624,7 +653,7 @@ public: void ReadScreenReaderEnabledProperty() { // can be true because of SuppressScreenReader before init - if (!mAccessibilityStatusClient) + if(!mAccessibilityStatusClient) { return; } @@ -658,7 +687,7 @@ public: void EmitScreenReaderEnabledSignal() { - if (mIsScreenReaderEnabled) + if(mIsScreenReaderEnabled) { mScreenReaderEnabledSignal.Emit(); } @@ -690,7 +719,7 @@ public: { mAccessibilityStatusClient = DBus::DBusClient{A11yDbusName, A11yDbusPath, A11yDbusStatusInterface, DBus::ConnectionType::SESSION}; - if (!mAccessibilityStatusClient) + if(!mAccessibilityStatusClient) { DALI_LOG_ERROR("Accessibility Status DbusClient is not ready\n"); return false; @@ -701,7 +730,7 @@ public: bool InitializeTimerCallback() { - if ( InitializeAccessibilityStatusClient() ) + if(InitializeAccessibilityStatusClient()) { ReadAndListenProperties(); return false; @@ -711,7 +740,7 @@ public: bool OnIdleSignal() { - if ( InitializeAccessibilityStatusClient() ) + if(InitializeAccessibilityStatusClient()) { ReadAndListenProperties(); mIdleCallback = NULL; @@ -734,20 +763,24 @@ public: */ void Initialize() override { - if ( InitializeAccessibilityStatusClient() ) + if(InitializeAccessibilityStatusClient()) { ReadAndListenProperties(); return; } // Initialize failed. Try it again on Idle - if( Dali::Adaptor::IsAvailable() ) + if(Dali::Adaptor::IsAvailable()) { Dali::Adaptor& adaptor = Dali::Adaptor::Get(); - if( NULL == mIdleCallback ) + if(NULL == mIdleCallback) { - mIdleCallback = MakeCallback( this, &BridgeImpl::OnIdleSignal ); - adaptor.AddIdle( mIdleCallback, true ); + mIdleCallback = MakeCallback(this, &BridgeImpl::OnIdleSignal); + if(DALI_UNLIKELY(!adaptor.AddIdle(mIdleCallback, true))) + { + DALI_LOG_ERROR("Fail to add idle callback for bridge initialize. Call it synchronously.\n"); + OnIdleSignal(); + } } } } @@ -860,7 +893,6 @@ private: namespace // unnamed namespace { - bool INITIALIZED_BRIDGE = false; /**