2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/accessibility/tizen-wayland/atspi/bridge-action.h>
24 using namespace Dali::Accessibility;
26 void BridgeAction::RegisterInterfaces()
28 DBus::DBusInterfaceDescription desc{AtspiDbusInterfaceAction};
30 AddGetPropertyToInterface( desc, "NActions", &BridgeAction::GetActionCount );
32 AddFunctionToInterface( desc, "GetName", &BridgeAction::GetActionName );
33 AddFunctionToInterface( desc, "GetLocalizedName", &BridgeAction::GetLocalizedActionName );
34 AddFunctionToInterface( desc, "GetDescription", &BridgeAction::GetActionDescription );
35 AddFunctionToInterface( desc, "GetKeyBinding", &BridgeAction::GetActionKeyBinding );
36 AddFunctionToInterface( desc, "DoAction", &BridgeAction::DoAction );
37 AddFunctionToInterface( desc, "DoActionName", &BridgeAction::DoActionName );
38 dbusServer.addInterface( "/", desc, true );
41 Action* BridgeAction::FindSelf() const
43 auto s = BridgeBase::FindSelf();
45 auto s2 = dynamic_cast< Action* >( s );
47 throw std::domain_error{"object " + s->GetAddress().ToString() + " doesn't have Action interface"};
51 DBus::ValueOrError< std::string > BridgeAction::GetActionName( int32_t index )
53 return FindSelf()->GetActionName( index );
56 DBus::ValueOrError< std::string > BridgeAction::GetLocalizedActionName( int32_t index )
58 return FindSelf()->GetLocalizedActionName( index );
61 DBus::ValueOrError< std::string > BridgeAction::GetActionDescription( int32_t index )
63 return FindSelf()->GetActionDescription( index );
66 DBus::ValueOrError< std::string > BridgeAction::GetActionKeyBinding( int32_t index )
68 return FindSelf()->GetActionKeyBinding( index );
71 DBus::ValueOrError< int32_t > BridgeAction::GetActionCount()
73 return FindSelf()->GetActionCount();
77 DBus::ValueOrError< bool > BridgeAction::DoAction( int32_t index )
79 return FindSelf()->DoAction( index );
82 DBus::ValueOrError< bool > BridgeAction::DoActionName( std::string name )
84 auto self = FindSelf();
85 auto cnt = self->GetActionCount();
86 for( auto i = 0u; i < cnt; ++i )
88 if( self->GetActionName( i ) == name )
90 return self->DoAction( i );
93 throw std::domain_error{"object " + self->GetAddress().ToString() + " doesn't have action '" + name + "'"};