The dbus method specs are located here I am using the dbus-c++ library, there is virtually no real documentation for it apart from generated docs with no examples included.
after some extensive googling i could assembly the following code:
#include <iostream>
#include <vector>
#include <string>
#include <dbus-c++-1/dbus-c++/dbus.h>
int main (int argc, const char **argv)
{
DBus::BusDispatcher DbDispatcher;
DBus::default_dispatcher = &DbDispatcher;
DBus::Connection DbConnection = DBus::Connection::SessionBus();
std::vector<std::string> actions = {"ACT_ONE", "Click me"};
std::string appName = "TestApp";
std::string body = "TestBody";
std::string appIcon = "document-open";
std::string summary = "Summary";
DBus::CallMessage msg("", "", "org.freedesktop.Notifications", "Notify");
DBus::MessageIter msgIter = msg.writer();
msgIter.append_string(appName.c_str());
msgIter.append_uint32(0);
msgIter.append_string(appIcon.c_str());
msgIter.append_string(summary.c_str());
msgIter.append_string(body.c_str());
DBus::MessageIter arrayIter = msgIter.new_array(DBUS_TYPE_STRING_AS_STRING);
for(auto& iAction: actions)
{
arrayIter.append_string(iAction.c_str());
}
msgIter.close_container(arrayIter);
DBus::MessageIter dictIter = msgIter.new_dict_entry();
msgIter.close_container(dictIter);
msgIter.append_int32(-1);
DbConnection.send_blocking(msg);
};
but the above gives me:
dbus[12421]: arguments to dbus_message_new_method_call() were incorrect, assertion "destination == NULL || _dbus_check_is_valid_bus_name (destination)" failed in file ../../../dbus/dbus-message.c line 1365. This is normally a bug in some application using the D-Bus library.
with no backtrace. So apparently some arguments were appended the wrong way.
I'd just like a solution for this specific library, i don't like the alternatives.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire