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 ace_api_client.cpp
18 * @author Tomasz Swierczek (t.swierczek@samsung.com)
20 * @brief This file contains implementation of ACE client API
23 #include <dpl/log/log.h>
24 #include <ace_popup_handler.h>
25 #include "ace_api_client.h"
26 #include "ace-client/ace_client.h"
30 #include <dpl/dbus/dbus_client.h>
31 #include "popup_response_server_api.h"
32 #include "security_daemon_dbus_config.h"
33 //#include "PromptModel.h"
35 ace_return_t ace_client_initialize(ace_popup_handler_func_t handler)
37 if (!AceClient::AceThinClientSingleton::Instance().isInitialized()) {
38 return ACE_INTERNAL_ERROR;
41 // Changed order of checks to make API run with old popup implementation
42 // instead of always needing the popup handler to be implemented.
43 if (NULL == handler) {
44 LogError("NULL argument(s) passed");
45 return ACE_INVALID_ARGUMENTS;
50 ace_return_t ace_client_shutdown(void)
56 ace_return_t ace_check_access(const ace_request_t* request, ace_bool_t* access)
58 if (NULL == request || NULL == access) {
59 LogError("NULL argument(s) passed");
60 return ACE_INVALID_ARGUMENTS;
63 AceClient::AceRequest aceRequest;
64 aceRequest.sessionId = request->session_id;
65 aceRequest.widgetHandle = request->widget_handle;
67 aceRequest.apiFeatures.count = request->feature_list.count;
68 aceRequest.apiFeatures.apiFeature =
69 const_cast<const char**>(request->feature_list.items);
70 aceRequest.functionName = NULL; // TODO will be removed
71 aceRequest.deviceCapabilities.devcapsCount = request->dev_cap_list.count;
72 aceRequest.deviceCapabilities.paramsCount = request->dev_cap_list.count;
74 char** devCapNames = new char*[request->dev_cap_list.count];
75 AceClient::AceParamList* paramList =
76 new AceClient::AceParamList[request->dev_cap_list.count];
79 for (i = 0; i < request->dev_cap_list.count; ++i) {
80 devCapNames[i] = request->dev_cap_list.items[i].name;
81 paramList[i].count = request->dev_cap_list.items[i].param_list.count;
83 paramList[i].param = new AceClient::AceParam[
84 request->dev_cap_list.items[i].param_list.count];
87 for (j = 0; j < request->dev_cap_list.items[i].param_list.count; ++j) {
88 paramList[i].param[j].name =
89 request->dev_cap_list.items[i].param_list.items[j].name;
90 paramList[i].param[j].value =
91 request->dev_cap_list.items[i].param_list.items[j].value;
96 aceRequest.deviceCapabilities.devCapNames =
97 const_cast<const char**>(devCapNames);
98 aceRequest.deviceCapabilities.params = paramList;
103 ret = AceClient::AceThinClientSingleton::
104 Instance().checkFunctionCall(aceRequest);
105 *access = ret ? ACE_TRUE : ACE_FALSE;
106 } Catch (AceClient::AceThinClient::Exception::AceThinClientException) {
107 LogError("Ace client exception");
108 delete [] devCapNames;
109 for (i = 0; i < request->dev_cap_list.count; ++i) {
110 delete [] paramList[i].param;
113 return ACE_INTERNAL_ERROR;
116 delete [] devCapNames;
117 for (i = 0; i < request->dev_cap_list.count; ++i) {
118 delete [] paramList[i].param;