summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevron Rees <kevron.m.rees@intel.com>2013-11-08 14:53:45 -0800
committerKevron Rees <kevron.m.rees@intel.com>2013-11-08 14:55:29 -0800
commit413cf8bd3d10aa3c4265af322a4cfc2f024d2a78 (patch)
tree105f04900fbe13209ec082ea4bed0bb4b9d4fb5c
parentc15ae7a6dd8fc8b8e104452d7521b5488d4c92bb (diff)
downloadautomotive-message-broker-413cf8bd3d10aa3c4265af322a4cfc2f024d2a78.tar.gz
added debug output for dbus property and method calls
-rw-r--r--lib/debugout.h5
-rw-r--r--plugins/dbus/abstractdbusinterface.cpp54
-rw-r--r--plugins/dbus/abstractdbusinterface.h1
3 files changed, 59 insertions, 1 deletions
diff --git a/lib/debugout.h b/lib/debugout.h
index aa57725a..1d32c18a 100644
--- a/lib/debugout.h
+++ b/lib/debugout.h
@@ -117,6 +117,11 @@ public:
throwErr = v;
}
+ static const int getDebugThreshhold()
+ {
+ return debugThreshhold;
+ }
+
private:
std::string bufferTime(double time)
diff --git a/plugins/dbus/abstractdbusinterface.cpp b/plugins/dbus/abstractdbusinterface.cpp
index bced578b..0da66286 100644
--- a/plugins/dbus/abstractdbusinterface.cpp
+++ b/plugins/dbus/abstractdbusinterface.cpp
@@ -30,6 +30,42 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
unordered_map<string, AbstractDBusInterface*> AbstractDBusInterface::objectMap;
list<string> AbstractDBusInterface::mimplementedProperties;
+const uint getPid(const char *owner)
+{
+ GError* error = nullptr;
+ GDBusProxy* dbus = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL,
+ "org.freedesktop.DBus",
+ "/",
+ "org.freedesktop.DBus",
+ NULL,
+ &error);
+
+ if(error)
+ {
+ throw std::runtime_error(error->message);
+ }
+
+ error = nullptr;
+
+ GVariant* pid = g_dbus_proxy_call_sync(dbus, "GetConnectionUnixProcessID", g_variant_new("(s)", owner), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+ if(error)
+ {
+ throw std::runtime_error(error->message);
+ }
+
+ const char* p = g_variant_get_type_string(pid);
+
+ DebugOut()<<"pid "<<p<<endl;
+
+ uint thePid=0;
+
+ g_variant_get(pid,"(u)",&thePid);
+
+ return thePid;
+}
+
+
static void handleMyMethodCall(GDBusConnection *connection,
const gchar *sender,
@@ -44,6 +80,12 @@ static void handleMyMethodCall(GDBusConnection *connection,
std::string method = method_name;
AbstractDBusInterface* iface = static_cast<AbstractDBusInterface*>(user_data);
+ if(DebugOut::getDebugThreshhold() >= 6)
+ {
+ DebugOut(6)<<"DBus method call from: "<<sender<< " pid: " <<getPid(sender)<< " interface: "<<interface_name<<" method: "<<method<<endl;
+ DebugOut(6)<<"DBus method call path: "<<object_path<<endl;
+ }
+
g_assert(iface);
if(method == "GetHistory")
@@ -377,7 +419,11 @@ void AbstractDBusInterface::startRegistration()
GVariant* AbstractDBusInterface::getProperty(GDBusConnection* connection, const gchar* sender, const gchar* objectPath, const gchar* interfaceName, const gchar* propertyName, GError** error, gpointer userData)
{
- DebugOut(6)<<"getProperty call from: "<<sender<<endl;
+ if(DebugOut::getDebugThreshhold() >= 6)
+ {
+ DebugOut(6)<<"DBus GetProperty call from: "<<sender<< " pid: " <<getPid(sender)<< " interface: "<<interfaceName<<" property: "<<propertyName<<endl;
+ DebugOut(6)<<"DBus GetProperty call path: "<<objectPath<<endl;
+ }
std::string pn = propertyName;
if(pn == "Time")
@@ -442,6 +488,12 @@ GVariant* AbstractDBusInterface::getProperty(GDBusConnection* connection, const
gboolean AbstractDBusInterface::setProperty(GDBusConnection* connection, const gchar* sender, const gchar* objectPath, const gchar* interfaceName, const gchar* propertyName, GVariant* value, GError** error, gpointer userData)
{
+ if(DebugOut::getDebugThreshhold() >= 6)
+ {
+ DebugOut(6)<<"DBus SetProperty call from: "<<sender<< " pid: " <<getPid(sender)<< " interface: "<<interfaceName<<" property: "<<propertyName<<endl;
+ DebugOut(6)<<"DBus SetProperty call path: "<<objectPath<<endl;
+ }
+
if(objectMap.count(objectPath))
{
objectMap[objectPath]->setProperty(propertyName, value);
diff --git a/plugins/dbus/abstractdbusinterface.h b/plugins/dbus/abstractdbusinterface.h
index 68d74d93..76e143d6 100644
--- a/plugins/dbus/abstractdbusinterface.h
+++ b/plugins/dbus/abstractdbusinterface.h
@@ -121,6 +121,7 @@ private:
static std::unordered_map<std::string, AbstractDBusInterface*> objectMap;
static std::list<std::string> mimplementedProperties;
guint regId;
+
};
#endif // ABSTRACTDBUSINTERFACE_H