2 * Copyright (c) 2011 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 dbus_interface_dispatcher.h
18 * @author Tomasz Swierczek (t.swierczek@samsung.com)
20 * @brief This file contains definitions of DBus::InterfaceDispatcher
24 #ifndef DPL_DBUS_DBUS_INTERFACE_DISPATCHER_H_
25 #define DPL_DBUS_DBUS_INTERFACE_DISPATCHER_H_
28 #include <dpl/log/wrt_log.h>
29 #include <dpl/dbus/dispatcher.h>
33 class InterfaceDispatcher : public DBus::Dispatcher
36 explicit InterfaceDispatcher(const std::string& interfaceName) :
37 m_interfaceName(interfaceName)
40 virtual ~InterfaceDispatcher()
43 // Implement it in specific interface with method handling
44 virtual void onMethodCall(const gchar* /*methodName*/,
45 GVariant* /*parameters*/,
46 GDBusMethodInvocation* /*invocation*/) = 0;
48 virtual std::string getName() const
50 return m_interfaceName;
53 virtual std::string getXmlSignature() const
57 virtual void setXmlSignature(const std::string& newSignature)
62 virtual void onMethodCall(GDBusConnection* /*connection*/,
63 const gchar* /*sender*/,
64 const gchar* /*objectPath*/,
65 const gchar* interfaceName,
66 const gchar* methodName,
68 GDBusMethodInvocation* invocation)
70 if (g_strcmp0(interfaceName, m_interfaceName.c_str()) == 0) {
71 onMethodCall(methodName, parameters, invocation);
73 WrtLogD("Called invalid interface: %s instead of: %s",
74 interfaceName, m_interfaceName.c_str());
78 virtual GVariant* onPropertyGet(GDBusConnection* /*connection*/,
79 const gchar* /*sender*/,
80 const gchar* /*objectPath*/,
81 const gchar* /*interfaceName*/,
82 const gchar* propertyName)
84 WrtLogD("InterfaceDispatcher onPropertyGet: %s", propertyName);
88 virtual gboolean onPropertySet(GDBusConnection* /*connection*/,
89 const gchar* /*sender*/,
90 const gchar* /*objectPath*/,
91 const gchar* /*interfaceName*/,
92 const gchar* propertyName,
95 WrtLogD("InterfaceDispatcher onPropertySet: %s", propertyName);
100 std::string m_interfaceName, m_xml;
105 #endif // DPL_DBUS_DBUS_INTERFACE_DISPATCHER_H_