From 7cb0bdd4fcd7001dcc4036772542ce5445798cf9 Mon Sep 17 00:00:00 2001 From: Kevin Dewald Date: Thu, 26 Sep 2024 23:40:15 -0700 Subject: [PATCH] Added is_method function for SimpleDBus messages --- simpledbus/include/simpledbus/base/Message.h | 1 + simpledbus/src/base/Message.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/simpledbus/include/simpledbus/base/Message.h b/simpledbus/include/simpledbus/base/Message.h index e3ca6b44..faa38015 100644 --- a/simpledbus/include/simpledbus/base/Message.h +++ b/simpledbus/include/simpledbus/base/Message.h @@ -51,6 +51,7 @@ class Message { Type get_type() const; bool is_signal(std::string interface, std::string signal_name); + bool is_method_call(const std::string& interface, const std::string& method); static Message create_method_call(std::string bus_name, std::string path, std::string interface, std::string method); diff --git a/simpledbus/src/base/Message.cpp b/simpledbus/src/base/Message.cpp index 9383ed8a..42bd2fb7 100644 --- a/simpledbus/src/base/Message.cpp +++ b/simpledbus/src/base/Message.cpp @@ -346,6 +346,10 @@ bool Message::is_signal(std::string interface, std::string signal_name) { return is_valid() && dbus_message_is_signal(_msg, interface.c_str(), signal_name.c_str()); } +bool Message::is_method_call(const std::string& interface, const std::string& method) { + return get_type() == Type::METHOD_CALL && get_interface() == interface && get_member() == method; +} + static const char* type_to_name(int message_type) { switch (message_type) { case DBUS_MESSAGE_TYPE_SIGNAL: