2 * Copyright (c) 2013-2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Bumjin Im <bj.im@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
19 * @file dbus_access.cpp
20 * @author Zbigniew Jasinski (z.jasinski@samsung.com)
22 * @brief Functios used in security-tests package for restarting Security Server through
23 * SystemD DBuS interface.
26 #include <dbus_access.h>
27 #include <dbus_access_impl.h>
30 const char* const RESTART = "Restart";
31 const char* const STOP = "Stop";
32 const char* const START = "Start";
33 const char* const RESET_FAILED = "ResetFailed";
35 const char* const MODE_FAIL = "fail";
37 } // anonymous namespace
39 DBusAccess::DBusAccess(const char* const object)
41 m_impl.reset(new DBusAccess::Impl(object));
44 DBusAccess::~DBusAccess()
48 void DBusAccess::restart() {
51 * dbus-send --system --dest=org.freedesktop.systemd1 --print-reply
52 * /org/freedesktop/systemd1/unit/central_2dkey_2dmanager_2eservice
53 * org.freedesktop.systemd1.Unit.Restart string:fail
55 m_impl->newMethodCall(RESTART);
56 m_impl->setMode(MODE_FAIL);
57 m_impl->sendCommand();
59 m_impl->waitForJobEnd();
64 void DBusAccess::start() {
65 m_impl->newMethodCall(START);
66 m_impl->setMode(MODE_FAIL);
67 m_impl->sendCommand();
69 m_impl->waitForJobEnd();
74 void DBusAccess::stop() {
75 m_impl->newMethodCall(STOP);
76 m_impl->setMode(MODE_FAIL);
77 m_impl->sendCommand();
79 m_impl->waitForJobEnd();
84 void DBusAccess::sendResetFailed() {
85 m_impl->newMethodCall(RESET_FAILED);
86 m_impl->sendCommand(false);