From: Artur Świgoń Date: Fri, 20 May 2022 11:58:49 +0000 (+0200) Subject: [AT-SPI] SetPreferredBusName in WidgetImplTizen X-Git-Tag: dali_2.1.31~10^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F18%2F261418%2F24;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git [AT-SPI] SetPreferredBusName in WidgetImplTizen Reserving a well-known bus name allows the widget to be discovered and embedded by the parent application without any prior information exchange (which would be impossible before establishing a connection anyway). Change-Id: I6dddcf2dda4651f3592a73bb293418512286e311 --- diff --git a/dali/devel-api/adaptor-framework/accessibility-bridge.h b/dali/devel-api/adaptor-framework/accessibility-bridge.h index 23af622..e35d9a5 100644 --- a/dali/devel-api/adaptor-framework/accessibility-bridge.h +++ b/dali/devel-api/adaptor-framework/accessibility-bridge.h @@ -447,6 +447,16 @@ struct DALI_ADAPTOR_API Bridge */ static void EnableAutoInit(); + /** + * @brief Encodes a widget ID as a usable bus name. + * + * @param widgetInstanceId The instance ID of a widget + * @return std::string Encoded bus name + * + * @see SetPreferredBusName + */ + static std::string MakeBusNameForWidget(std::string_view widgetInstanceId); + static Signal& EnabledSignal() { return mEnabledSignal; diff --git a/dali/internal/accessibility/bridge/bridge-impl.cpp b/dali/internal/accessibility/bridge/bridge-impl.cpp index f0f381b..f5fa4d1 100644 --- a/dali/internal/accessibility/bridge/bridge-impl.cpp +++ b/dali/internal/accessibility/bridge/bridge-impl.cpp @@ -859,3 +859,23 @@ void Bridge::EnableAutoInit() bridge->WindowShown(window); } } + +std::string Bridge::MakeBusNameForWidget(std::string_view widgetInstanceId) +{ + // The bus name should consist of dot-separated alphanumeric elements, e.g. "com.example.BusName123". + // Allowed characters in each element: "[A-Z][a-z][0-9]_", but no element may start with a digit. + + static const char prefix[] = "com.samsung.dali.widget_"; + static const char underscore = '_'; + + std::stringstream tmp; + + tmp << prefix; + + for(char ch : widgetInstanceId) + { + tmp << (std::isalnum(ch) ? ch : underscore); + } + + return tmp.str(); +} diff --git a/dali/internal/accessibility/bridge/dummy-atspi.cpp b/dali/internal/accessibility/bridge/dummy-atspi.cpp index 3e6b302..21876c2 100644 --- a/dali/internal/accessibility/bridge/dummy-atspi.cpp +++ b/dali/internal/accessibility/bridge/dummy-atspi.cpp @@ -84,6 +84,11 @@ void Accessibility::Bridge::EnableAutoInit() { } +std::string MakeBusNameForWidget(std::string_view widgetInstanceId) +{ + return std::string{widgetInstanceId}; +} + void Accessibility::Accessible::EmitStateChanged(Accessibility::State state, int newValue, int reserved) { } diff --git a/dali/internal/system/tizen-wayland/widget-controller-tizen.cpp b/dali/internal/system/tizen-wayland/widget-controller-tizen.cpp index efe9f16..0f762bb 100644 --- a/dali/internal/system/tizen-wayland/widget-controller-tizen.cpp +++ b/dali/internal/system/tizen-wayland/widget-controller-tizen.cpp @@ -22,6 +22,9 @@ #include #include +// INTERNAL INCLUDES +#include + namespace Dali { namespace Internal @@ -65,8 +68,13 @@ void WidgetImplTizen::SetUsingKeyEvent(bool flag) void WidgetImplTizen::SetInformation(Dali::Window window, const std::string& widgetId) { + using Dali::Accessibility::Bridge; + mWindow = window; mWidgetId = widgetId; + + auto preferredBusName = Bridge::MakeBusNameForWidget(widgetId); + Bridge::GetCurrentBridge()->SetPreferredBusName(preferredBusName); } Dali::Window WidgetImplTizen::GetWindow() const