Fix WGT handlers includes
[platform/core/appfw/wgt-backend.git] / src / wgt / step / step_check_settings_level.cc
1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by a apache 2.0 license that can be
3 // found in the LICENSE file.
4
5 #include "wgt/step/step_check_settings_level.h"
6
7 #include <manifest_parser/utils/logging.h>
8 #include <wgt_manifest_handlers/setting_handler.h>
9
10 #include <map>
11
12 #include "wgt/wgt_backend_data.h"
13
14 namespace {
15
16 bool ValidateSettingsForLevel(common_installer::PrivilegeLevel level,
17                               const wgt::parse::SettingInfo& settings) {
18   if (settings.background_vibration()) {
19     common_installer::PrivilegeLevel required_level =
20         common_installer::PrivilegeLevel::PARTNER;
21     if (!common_installer::SatifiesPrivilegeLevel(required_level, level)) {
22       LOG(ERROR) << "background_vibration requires visibility level: "
23                  << common_installer::PrivilegeLevelToString(required_level);
24       return false;
25     }
26     LOG(INFO) << "Setting: 'background-vibration' allowed";
27   }
28   return true;
29 }
30
31 }  // namespace
32
33 namespace wgt {
34 namespace security {
35
36 common_installer::Step::Status StepCheckSettingsLevel::process() {
37   if (!ValidateSettingsForLevel(context_->privilege_level.get(),
38       static_cast<WgtBackendData*>(
39           context_->backend_data.get())->settings.get())) {
40     return Status::PRIVILEGE_ERROR;
41   }
42   LOG(INFO) << "Settings privilege level checked";
43   return Status::OK;
44 }
45
46 }  // namespace security
47 }  // namespace wgt