2 * Copyright (c) 2013-2014 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 service_manager.h
18 * @author Zbigniew Jasinski <z.jasinski@samsung.com>
19 * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
20 * @author Marcin Niesluchowski <m.niesluchow@samsungcom>
22 * @brief Declaration of service control class using dbus interface to communicate with systemd
25 #ifndef COMMON_SERVICE_MANAGER_H
26 #define COMMON_SERVICE_MANAGER_H
28 #include <dbus/dbus.h>
30 #include <dbus_connection.h>
31 #include <dbus_message_in.h>
32 #include <dbus_message_out.h>
38 class ServiceManager {
40 ServiceManager() = delete;
41 ServiceManager(const std::string &serviceName);
42 ~ServiceManager() = default;
46 void restartService();
47 pid_t getServicePid();
52 void addBusMatch(const std::string &member);
53 void subscribeSignals();
54 void reloadDbusManager();
56 DBus::MessageOut newMethodCall(const std::string &method);
57 std::string handleObjectPathMsgReply(DBus::MessageIn &messageIn);
58 uint32_t handleVariantUIntMsgReply(DBus::MessageIn &messageIn);
60 void sendToService(const std::string &method);
61 void sendMaskToService();
62 void sendUnmaskToService();
63 uint32_t getUIntProperty(const std::string &interface, const std::string &property);
64 void sendResetFailedToService();
66 static DBusHandlerResult messageHandler(DBusConnection *conn, DBusMessage *msg, void *t);
67 void signalJobRemovedHandler(DBus::MessageIn &messageIn);
68 void signalJobNewHandler(DBus::MessageIn &messageIn);
69 void signalReloadingHandler(DBus::MessageIn &messageIn);
70 void waitForRunningJobsFinish();
72 DBus::Connection m_connection;
74 const std::string m_serviceName;
75 std::string m_unitPath;
77 std::set<std::string> m_runningJobs;
80 #endif // COMMON_SERVICE_MANAGER_H