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: