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/log.h>
29 #include <dpl/dbus/dispatcher.h>
34 class InterfaceDispatcher : public DBus::Dispatcher
37 explicit InterfaceDispatcher(const std::string& interfaceName):
38 m_interfaceName(interfaceName)
42 virtual ~InterfaceDispatcher()
45 // Implement it in specific interface with method handling
46 virtual void onMethodCall(const gchar* /*methodName*/,
47 GVariant* /*parameters*/,
48 GDBusMethodInvocation* /*invocation*/) = 0;
50 virtual std::string getName() const
52 return m_interfaceName;
55 virtual std::string getXmlSignature() const
59 virtual void setXmlSignature(const std::string& newSignature)
64 virtual void onMethodCall(GDBusConnection* /*connection*/,
65 const gchar* /*sender*/,
66 const gchar* /*objectPath*/,
67 const gchar* interfaceName,
68 const gchar* methodName,
70 GDBusMethodInvocation* invocation)
72 if (g_strcmp0(interfaceName, m_interfaceName.c_str()) == 0){
73 onMethodCall(methodName, parameters, invocation);
75 LogPedantic("Called invalid interface: " << interfaceName <<
76 " instead of: " << m_interfaceName);
80 virtual GVariant* onPropertyGet(GDBusConnection* /*connection*/,
81 const gchar* /*sender*/,
82 const gchar* /*objectPath*/,
83 const gchar* /*interfaceName*/,
84 const gchar* propertyName)
86 LogInfo("InterfaceDispatcher onPropertyGet: " << propertyName);
90 virtual gboolean onPropertySet(GDBusConnection* /*connection*/,
91 const gchar* /*sender*/,
92 const gchar* /*objectPath*/,
93 const gchar* /*interfaceName*/,
94 const gchar* propertyName,
97 LogInfo("InterfaceDispatcher onPropertySet: " << propertyName);
101 std::string m_interfaceName, m_xml;
107 #endif // DPL_DBUS_DBUS_INTERFACE_DISPATCHER_H_