2 * Copyright (c) 2015 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 #ifndef WRT_COMMON_DBUS_SERVER_H_
18 #define WRT_COMMON_DBUS_SERVER_H_
30 typedef std::function<bool(GCredentials* creds)> PeerCredentialsCallback;
31 typedef std::function<void(GDBusConnection* connection,
32 const std::string& method_name,
34 GDBusMethodInvocation* invocation)> MethodCallback;
35 typedef std::function<GVariant*(GDBusConnection* connection,
36 const gchar* property)> PropertyGetter;
37 typedef std::function<bool(GDBusConnection* connection,
38 const gchar* property,
39 GVariant* value)> PropertySetter;
42 virtual ~DBusServer();
44 void Start(const std::string& name);
46 std::string GetClientAddress() const;
48 void SetIntrospectionXML(const std::string& xml);
49 GDBusNodeInfo* GetIntrospectionNodeInfo() const { return node_info_; }
51 void SendSignal(GDBusConnection* connection,
52 const std::string& iface, const std::string& signal_name,
53 GVariant* parameters);
55 void SetPeerCredentialsCallback(PeerCredentialsCallback func);
56 void SetMethodCallback(const std::string& iface, MethodCallback func);
57 void SetPropertyGetter(const std::string& iface, PropertyGetter func);
58 void SetPropertySetter(const std::string& iface, PropertySetter func);
59 PeerCredentialsCallback GetPeerCredentialsCallback() const;
60 MethodCallback GetMethodCallback(const std::string& iface);
61 PropertySetter GetPropertySetter(const std::string& iface);
62 PropertyGetter GetPropertyGetter(const std::string& iface);
65 std::string address_path_;
67 GDBusNodeInfo* node_info_;
69 PeerCredentialsCallback peer_credentials_callback_;
70 std::map<std::string, MethodCallback> method_callbacks_;
71 std::map<std::string, PropertyGetter> property_getters_;
72 std::map<std::string, PropertySetter> property_setters_;
77 #endif // WRT_COMMON_DBUS_SERVER_H_