[AT-SPI] SetPreferredBusName in WidgetImplTizen
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / tizen-wayland / widget-controller-tizen.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/system/tizen-wayland/widget-controller-tizen.h>
20
21 // EXTERNAL INCLUDES
22 #include <bundle.h>
23 #include <widget_base.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
27
28 namespace Dali
29 {
30 namespace Internal
31 {
32 namespace Adaptor
33 {
34 WidgetImplTizen::WidgetImplTizen(widget_base_instance_h instanceHandle)
35 : Widget::Impl(),
36   mInstanceHandle(instanceHandle),
37   mWindow(),
38   mWidgetId(),
39   mUsingKeyEvent(false)
40 {
41 }
42
43 WidgetImplTizen::~WidgetImplTizen()
44 {
45 }
46
47 void WidgetImplTizen::SetContentInfo(const std::string& contentInfo)
48 {
49   bundle*     contentBundle;
50   bundle_raw* contentBundleRaw = reinterpret_cast<bundle_raw*>(const_cast<char*>(contentInfo.c_str()));
51   int         len              = contentInfo.length();
52   contentBundle                = bundle_decode(contentBundleRaw, len);
53
54   widget_base_context_set_content_info(mInstanceHandle, contentBundle);
55
56   bundle_free(contentBundle);
57 }
58
59 bool WidgetImplTizen::IsKeyEventUsing() const
60 {
61   return mUsingKeyEvent;
62 }
63
64 void WidgetImplTizen::SetUsingKeyEvent(bool flag)
65 {
66   mUsingKeyEvent = flag;
67 }
68
69 void WidgetImplTizen::SetInformation(Dali::Window window, const std::string& widgetId)
70 {
71   using Dali::Accessibility::Bridge;
72
73   mWindow = window;
74   mWidgetId = widgetId;
75
76   auto preferredBusName = Bridge::MakeBusNameForWidget(widgetId);
77   Bridge::GetCurrentBridge()->SetPreferredBusName(preferredBusName);
78 }
79
80 Dali::Window WidgetImplTizen::GetWindow() const
81 {
82   return mWindow;
83 }
84
85 std::string WidgetImplTizen::GetWidgetId() const
86 {
87   return mWidgetId;
88 }
89
90 } // namespace Adaptor
91
92 } // namespace Internal
93
94 } // namespace Dali