2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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 * @file view_logic_keys_support.cpp
18 * @author Pawel Sikorski (p.sikorski@samsung.com)
19 * @brief Implementation file of SecuritySupport API used by ViewLogic
22 #include "view_logic_security_support.h"
24 #include <dpl/string.h>
25 #include <dpl/log/log.h>
26 #include <dpl/wrt-dao-ro/global_dao_read_only.h>
27 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
28 #include <ace_api_client.h>
29 #include <dpl/utils/warp_iri.h>
30 #include <widget_data_types.h>
32 namespace ViewModule {
33 namespace SecuritySupport {
35 const char *GEOLOCATION_DEV_CAP = "geolocation.position";
36 const char *GEOLOCATION_PARAM_NAME = "param:enableHighAccuracy";
37 const char *GEOLOCATION_PARAM_VALUE = "true";
40 const DPL::String& tizenId,
42 const char *paramName,
43 const char *paramValue)
45 WrtDB::WidgetDAOReadOnly dao(tizenId);
46 ace_request_t aceRequest;
47 aceRequest.widget_handle = dao.getHandle();
48 aceRequest.session_id = const_cast<const ace_string_t>("");
49 aceRequest.feature_list.count = 0;
50 aceRequest.dev_cap_list.count = 1;
51 aceRequest.dev_cap_list.items = new ace_dev_cap_t[1];
52 aceRequest.dev_cap_list.items[0].name =
53 const_cast<ace_string_t>(devCap);
55 aceRequest.dev_cap_list.items[0].param_list.count = paramName ? 1 : 0;
56 aceRequest.dev_cap_list.items[0].param_list.items = NULL;
59 aceRequest.dev_cap_list.items[0].param_list.items = new ace_param_t[1];
60 aceRequest.dev_cap_list.items[0].param_list.items[0].name =
61 const_cast<ace_string_t>(paramName);
62 aceRequest.dev_cap_list.items[0].param_list.items[0].value =
63 const_cast<ace_string_t>(paramValue);
66 LogDebug("Making ace check with new C-API");
67 ace_check_result_t result = ACE_PRIVILEGE_DENIED;
68 ace_return_t ret = ace_check_access_ex(&aceRequest, &result);
70 LogDebug("Result is: " << static_cast<int>(result));
72 delete[] aceRequest.dev_cap_list.items[0].param_list.items;
73 delete[] aceRequest.dev_cap_list.items;
75 return ACE_OK == ret && ACE_ACCESS_GRANTED == result;
77 } //TODO copied from view_logic.cpp
79 bool geolocationACECheck(const DPL::String& tizenId, bool highAccuracy)
81 const char *paramName = NULL;
82 const char *paramValue = NULL;
84 paramName = GEOLOCATION_PARAM_NAME;
85 paramValue = GEOLOCATION_PARAM_VALUE;
87 return simpleAceCheck(
93 } // namespace SecuritySupport
94 } //namespace ViewModule