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 #include <dpl/log/log.h>
32 namespace WrtSecurity{
33 namespace Communication{
35 Client::Client(const std::string& interfaceName){
37 LogInfo("DBus create");
39 m_dbusClient.reset(new DPL::DBus::Client(WrtSecurity::SecurityDaemonConfig::OBJECT_PATH(),
40 WrtSecurity::SecurityDaemonConfig::SERVICE_NAME(),
42 } Catch (DPL::DBus::Client::Exception::DBusClientException) {
43 LogError("Error getting connection");
44 ReThrowMsg(Exception::SecurityCommunicationClientException,
45 "Error getting connection");
47 if(NULL == m_dbusClient.get()){
48 LogError("Couldn't get client");
49 ThrowMsg(Exception::SecurityCommunicationClientException,
50 "Error getting client");
52 #endif //DBUS_CONNECTION
54 #ifdef SOCKET_CONNECTION
55 m_socketClient.reset(new SecuritySocketClient(interfaceName));
56 if(NULL == m_socketClient.get()){
57 LogError("Couldn't get client");
58 ThrowMsg(Exception::SecurityCommunicationClientException,
59 "Error getting client");
61 #endif //SOCKET_CONNECTION
62 LogDebug("Created wrt-security communication client");
65 void Client::connect(){
66 #ifdef SOCKET_CONNECTION
68 m_socketClient->connect();
69 } Catch(SecuritySocketClient::Exception::SecuritySocketClientException){
70 LogError("Couldn't connect");
71 ReThrowMsg(Exception::SecurityCommunicationClientException,
75 #endif //SOCKET_CONNECTION
76 LogDebug("Wrt-security client Connected");
79 void Client::disconnect(){
81 #ifdef SOCKET_CONNECTION
82 m_socketClient->disconnect();
83 #endif //SOCKET_CONNECTION
84 LogDebug("Wrt-security client Disconnected");
88 } // namespace Communication
90 } // namespace WrtSecurity