2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Jan Olszak <j.olszak@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
21 * @author Jan Olszak (j.olszak@samsung.com)
22 * @brief Declaration of a class for communication between zone and server
26 #ifndef ZONE_DAEMON_DAEMON_CONNECTION_HPP
27 #define ZONE_DAEMON_DAEMON_CONNECTION_HPP
29 #include "dbus/connection.hpp"
32 #include <condition_variable>
36 namespace zone_daemon {
39 class DaemonConnection {
42 typedef std::function<void()> NameLostCallback;
43 typedef std::function<void()> GainFocusCallback;
44 typedef std::function<void()> LoseFocusCallback;
46 DaemonConnection(const NameLostCallback& nameLostCallback,
47 const GainFocusCallback& gainFocusCallback,
48 const LoseFocusCallback& loseFocusCallback);
53 dbus::DbusConnection::Pointer mDbusConnection;
54 std::mutex mNameMutex;
55 std::condition_variable mNameCondition;
59 NameLostCallback mNameLostCallback;
60 GainFocusCallback mGainFocusCallback;
61 LoseFocusCallback mLoseFocusCallback;
63 void onNameAcquired();
65 bool waitForNameAndSetCallback(const unsigned int timeoutMs, const NameLostCallback& callback);
67 void onMessageCall(const std::string& objectPath,
68 const std::string& interface,
69 const std::string& methodName,
71 dbus::MethodResultBuilder::Pointer result);
75 } // namespace zone_daemon
79 #endif // ZONE_DAEMON_DAEMON_CONNECTION_HPP