2 * Copyright 2018 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.
17 #include "ScreenSwitchPage.hpp"
19 #include "AccessibilitySettingLog.hpp"
20 #include "Singleton.hpp"
21 #include "setting-accessibility.h"
23 ScreenSwitchPage::ScreenSwitchPage(NaviframeItem targetItem)
24 : context_(Singleton<AppContext>::instance())
26 actionPage_ = std::make_unique<ActionPage>(targetItem);
27 actionPage_->attachCallback(actionCb, this);
30 void ScreenSwitchPage::attachActionCallback(UniversalSwitchCb cb, void *cbData)
33 switch_added_cb_data = cbData;
36 void ScreenSwitchPage::actionCb(const std::string &action, void *user_data)
38 auto self = static_cast<ScreenSwitchPage *>(user_data);
40 if (self->switch_added_cb) {
41 auto switches = setting_accessibility_universal_switch_dbus_config_get_switches(
42 &self->context_.config, ACCESSIBILITY_UNIVERSAL_SWITCH_SCREEN_SWITCH_PROVIDER);
43 ASSERT(!switches.empty(), "Screen switch not found");
44 auto screen_switch = switches[0];
45 self->switch_added_cb(self->switch_added_cb_data, screen_switch->id, action, ACCESSIBILITY_UNIVERSAL_SWITCH_SCREEN);