2 * Copyright (c) 2012 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 SecurityCommunicationClient.h
18 * @author Zofia Abramowska (z.abramowska@samsung.com)
20 * @brief This is implementation of class used IPC client
24 #include "SecurityCommunicationClient.h"
26 #ifdef DBUS_CONNECTION
27 #include "security_daemon_dbus_config.h"
30 namespace WrtSecurity{
31 namespace Communication{
33 Client::Client(const std::string& interfaceName){
35 LogInfo("DBus create");
37 m_dbusClient.reset(new DPL::DBus::Client(WrtSecurity::SecurityDaemonConfig::OBJECT_PATH(),
38 WrtSecurity::SecurityDaemonConfig::SERVICE_NAME(),
40 } Catch (DPL::DBus::Client::Exception::DBusClientException) {
41 LogError("Error getting connection");
42 ReThrowMsg(Exception::SecurityCommunicationClientException,
43 "Error getting connection");
45 if(NULL == m_dbusClient.get()){
46 LogError("Couldn't get client");
47 ThrowMsg(Exception::SecurityCommunicationClientException,
48 "Error getting client");
50 #endif //DBUS_CONNECTION
52 #ifdef SOCKET_CONNECTION
53 m_socketClient.reset(new SecuritySocketClient(interfaceName));
54 if(NULL == m_socketClient.get()){
55 LogError("Couldn't get client");
56 ThrowMsg(Exception::SecurityCommunicationClientException,
57 "Error getting client");
59 #endif //SOCKET_CONNECTION
60 LogInfo("Created communication client");
63 void Client::connect(){
64 #ifdef SOCKET_CONNECTION
66 m_socketClient->connect();
67 } Catch(SecuritySocketClient::Exception::SecuritySocketClientException){
68 LogError("Couldn't connect");
69 ReThrowMsg(Exception::SecurityCommunicationClientException,
73 #endif //SOCKET_CONNECTION
77 void Client::disconnect(){
79 #ifdef SOCKET_CONNECTION
80 m_socketClient->disconnect();
81 #endif //SOCKET_CONNECTION
82 LogInfo("Disconnected");
86 } // namespace Communication
88 } // namespace WrtSecurity