5 #include "dbusLocators.hpp"
6 #include <dali/devel-api/adaptor-framework/accessibility.h>
7 #include <dali/integration-api/debug.h>
12 #define A11Y_DBUS_NAME "org.a11y.Bus"
13 #define A11Y_DBUS_PATH "/org/a11y/bus"
14 #define A11Y_DBUS_STATUS_INTERFACE "org.a11y.Status"
15 #define ATSPI_DBUS_NAME_REGISTRY "org.a11y.atspi.Registry"
16 #define ATSPI_DBUS_PATH_ROOT "/org/a11y/atspi/accessible/root"
17 #define ATSPI_DBUS_INTERFACE_SOCKET "org.a11y.atspi.Socket"
18 #define ATSPI_PATH "/org/a11y/atspi/accessible"
19 #define ATSPI_DBUS_INTERFACE_ACCESSIBLE "org.a11y.atspi.Accessible"
20 #define ATSPI_DBUS_INTERFACE_ACTION "org.a11y.atspi.Action"
21 #define ATSPI_DBUS_INTERFACE_APPLICATION "org.a11y.atspi.Application"
22 #define ATSPI_DBUS_INTERFACE_COLLECTION "org.a11y.atspi.Collection"
23 #define ATSPI_DBUS_INTERFACE_COMPONENT "org.a11y.atspi.Component"
24 #define ATSPI_DBUS_INTERFACE_DOCUMENT "org.a11y.atspi.Document"
25 #define ATSPI_DBUS_INTERFACE_EDITABLE_TEXT "org.a11y.atspi.EditableText"
26 #define ATSPI_DBUS_INTERFACE_EVENT_KEYBOARD "org.a11y.atspi.Event.Keyboard"
27 #define ATSPI_DBUS_INTERFACE_EVENT_MOUSE "org.a11y.atspi.Event.Mouse"
28 #define ATSPI_DBUS_INTERFACE_EVENT_OBJECT "org.a11y.atspi.Event.Object"
29 #define ATSPI_DBUS_INTERFACE_HYPERLINK "org.a11y.atspi.Hyperlink"
30 #define ATSPI_DBUS_INTERFACE_HYPERTEXT "org.a11y.atspi.Hypertext"
31 #define ATSPI_DBUS_INTERFACE_IMAGE "org.a11y.atspi.Image"
32 #define ATSPI_DBUS_INTERFACE_SELECTION "org.a11y.atspi.Selection"
33 #define ATSPI_DBUS_INTERFACE_TABLE "org.a11y.atspi.Table"
34 #define ATSPI_DBUS_INTERFACE_TABLE_CELL "org.a11y.atspi.TableCell"
35 #define ATSPI_DBUS_INTERFACE_TEXT "org.a11y.atspi.Text"
36 #define ATSPI_DBUS_INTERFACE_VALUE "org.a11y.atspi.Value"
37 #define ATSPI_DBUS_INTERFACE_SOCKET "org.a11y.atspi.Socket"
38 #define ATSPI_DBUS_INTERFACE_EVENT_WINDOW "org.a11y.atspi.Event.Window"
40 #define ATSPI_DBUS_PATH_DEC "/org/a11y/atspi/registry/deviceeventcontroller"
41 #define ATSPI_DBUS_INTERFACE_DEC "org.a11y.atspi.DeviceEventController"
42 #define ATSPI_DBUS_INTERFACE_DEVICE_EVENT_LISTENER "org.a11y.atspi.DeviceEventListener"
46 class CurrentBridgePtr
48 static Dali::Accessibility::Bridge*& get()
50 static thread_local Dali::Accessibility::Bridge* b = nullptr;
53 Dali::Accessibility::Bridge* prev;
54 CurrentBridgePtr( const CurrentBridgePtr& ) = delete;
55 CurrentBridgePtr( CurrentBridgePtr&& ) = delete;
56 CurrentBridgePtr& operator=( const CurrentBridgePtr& ) = delete;
57 CurrentBridgePtr& operator=( CurrentBridgePtr&& ) = delete;
60 CurrentBridgePtr( Dali::Accessibility::Bridge* b ) : prev( get() ) { get() = b; }
61 ~CurrentBridgePtr() { get() = prev; }
63 static Dali::Accessibility::Bridge* current() { return get(); }
67 template < typename T >
68 struct signature_accessible_impl
70 using subtype = std::pair< std::string, DBus::ObjectPath >;
73 * @brief Returns name of type marshalled, for informative purposes
75 static std::string name()
77 return "AtspiAccessiblePtr";
80 * @brief Returns DBUS' signature of type marshalled
82 static std::string sig()
87 * @brief Marshals value v as marshalled type into message
89 static void set( Eldbus_Message_Iter* iter, T* t )
91 const auto prefixPath = "/org/a11y/atspi/accessible/";
92 const auto nullPath = "/org/a11y/atspi/null";
96 auto v = t->GetAddress();
97 signature< subtype >::set( iter, {v.GetBus(), DBus::ObjectPath{std::string{prefixPath} + v.GetPath()}} );
101 signature< subtype >::set( iter, {"", DBus::ObjectPath{nullPath}} );
105 * @brief Marshals value from marshalled type into variable v
107 static bool get( Eldbus_Message_Iter* iter, T*& v )
109 const auto prefixPath = "/org/a11y/atspi/accessible/";
110 const auto nullPath = "/org/a11y/atspi/null";
112 if( !signature< subtype >::get( iter, tmp ) )
114 if( tmp.second.value == nullPath )
119 if( tmp.second.value.substr( 0, strlen( prefixPath ) ) != prefixPath )
121 auto b = CurrentBridgePtr::current();
122 if( b->GetBusName() != tmp.first )
124 v = b->FindByPath( tmp.second.value.substr( strlen( prefixPath ) ) );
129 struct signature< Dali::Accessibility::Accessible* > : public signature_accessible_impl< Dali::Accessibility::Accessible >
134 struct signature< Dali::Accessibility::Address >
136 using subtype = std::pair< std::string, DBus::ObjectPath >;
139 * @brief Returns name of type marshalled, for informative purposes
141 static std::string name()
143 return "AtspiAccessiblePtr";
146 * @brief Returns DBUS' signature of type marshalled
148 static std::string sig()
153 * @brief Marshals value v as marshalled type into message
155 static void set( Eldbus_Message_Iter* iter, const Dali::Accessibility::Address& v )
157 const auto prefixPath = "/org/a11y/atspi/accessible/";
158 const auto nullPath = "/org/a11y/atspi/null";
162 signature< subtype >::set( iter, {v.GetBus(), DBus::ObjectPath{std::string{prefixPath} + v.GetPath()}} );
166 signature< subtype >::set( iter, {v.GetBus(), DBus::ObjectPath{nullPath}} );
170 * @brief Marshals value from marshalled type into variable v
172 static bool get( Eldbus_Message_Iter* iter, Dali::Accessibility::Address& v )
174 const auto prefixPath = "/org/a11y/atspi/accessible/";
175 const auto nullPath = "/org/a11y/atspi/null";
177 if( !signature< subtype >::get( iter, tmp ) )
179 if( tmp.second.value == nullPath )
184 if( tmp.second.value.substr( 0, strlen( prefixPath ) ) != prefixPath )
186 v = {std::move( tmp.first ), tmp.second.value.substr( strlen( prefixPath ) )};
191 struct signature< Dali::Accessibility::States >
193 using subtype = std::array< uint32_t, 2 >;
196 * @brief Returns name of type marshalled, for informative purposes
198 static std::string name()
200 return signature< subtype >::name();
203 * @brief Returns DBUS' signature of type marshalled
205 static std::string sig()
207 return signature< subtype >::sig();
210 * @brief Marshals value v as marshalled type into message
212 static void set( Eldbus_Message_Iter* iter, const Dali::Accessibility::States& v )
214 signature< subtype >::set( iter, v.GetRawData() );
217 * @brief Marshals value from marshalled type into variable v
219 static bool get( Eldbus_Message_Iter* iter, Dali::Accessibility::States& v )
222 if( !signature< subtype >::get( iter, tmp ) )
224 v = Dali::Accessibility::States{tmp};
235 std::ostringstream tmp;
237 _Logger( const char* f, int l ) : file( f ), line( l ) {}
240 Dali::Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo, "%s:%d: %s", file, line, tmp.str().c_str() );
242 template < typename T >
243 _Logger& operator<<( T&& t )
245 tmp << std::forward< T >( t );
255 _LoggerScope( const char* f, int l ) : file( f ), line( l )
257 Dali::Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo, "%s:%d: +", file, line );
261 Dali::Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo, "%s:%d: -", file, line );
264 #define LOG() _Logger( __FILE__, __LINE__ )
265 #define SCOPE() _LoggerScope _l##__LINE__( __FILE__, __LINE__ )