mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-06-16 00:13:55 +02:00
Remove some assertions from D-Bus notifications
This commit is contained in:
@@ -173,51 +173,46 @@ bool send_notification(const std::string& title,
|
|||||||
|
|
||||||
// Can't use `dbus_message_append_args` because that doesn't support
|
// Can't use `dbus_message_append_args` because that doesn't support
|
||||||
// dictionaries
|
// dictionaries
|
||||||
DBusMessageIter iter;
|
DBusMessageIter iter{};
|
||||||
libdbus_message_iter_init_append(message.get(), &iter);
|
libdbus_message_iter_init_append(message.get(), &iter);
|
||||||
|
|
||||||
const char* app_name = "yabridge";
|
const char* app_name = "yabridge";
|
||||||
assert(
|
libdbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &app_name);
|
||||||
libdbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &app_name));
|
|
||||||
|
|
||||||
// It would be nice to be able to replace old notifications so we don't
|
// It would be nice to be able to replace old notifications so we don't
|
||||||
// accidentally spam the user when every plugin outputs the same message,
|
// accidentally spam the user when every plugin outputs the same message,
|
||||||
// but we can't really do this since during plugin scanning every plugin
|
// but we can't really do this since during plugin scanning every plugin
|
||||||
// will likely be loaded in a fresh process
|
// will likely be loaded in a fresh process
|
||||||
const dbus_uint32_t replaces_id = 0;
|
const dbus_uint32_t replaces_id = 0;
|
||||||
assert(libdbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32,
|
libdbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &replaces_id);
|
||||||
&replaces_id));
|
|
||||||
|
|
||||||
const char* app_icon = "";
|
const char* app_icon = "";
|
||||||
assert(
|
libdbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &app_icon);
|
||||||
libdbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &app_icon));
|
|
||||||
|
|
||||||
const char* title_cstr = title.c_str();
|
const char* title_cstr = title.c_str();
|
||||||
assert(libdbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING,
|
libdbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &title_cstr);
|
||||||
&title_cstr));
|
|
||||||
|
|
||||||
const std::string formatted_body_str = formatted_body.str();
|
const std::string formatted_body_str = formatted_body.str();
|
||||||
const char* formatted_body_cstr = formatted_body_str.c_str();
|
const char* formatted_body_cstr = formatted_body_str.c_str();
|
||||||
assert(libdbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING,
|
libdbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING,
|
||||||
&formatted_body_cstr));
|
&formatted_body_cstr);
|
||||||
|
|
||||||
// Our actions array is empty
|
// Our actions array is empty
|
||||||
DBusMessageIter array_iter;
|
DBusMessageIter array_iter;
|
||||||
assert(libdbus_message_iter_open_container(
|
libdbus_message_iter_open_container(
|
||||||
&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &array_iter));
|
&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &array_iter);
|
||||||
assert(libdbus_message_iter_close_container(&iter, &array_iter));
|
libdbus_message_iter_close_container(&iter, &array_iter);
|
||||||
|
|
||||||
// We also don't have any hints, but we can't use the simple
|
// We also don't have any hints, but we can't use the simple
|
||||||
// `libdbus_message_append_args` API because we can't use it to add an empty
|
// `libdbus_message_append_args` API because we can't use it to add an empty
|
||||||
// hints dictionary
|
// hints dictionary
|
||||||
assert(libdbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}",
|
libdbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}",
|
||||||
&array_iter));
|
&array_iter);
|
||||||
assert(libdbus_message_iter_close_container(&iter, &array_iter));
|
libdbus_message_iter_close_container(&iter, &array_iter);
|
||||||
|
|
||||||
// -1 is an implementation specific default duration
|
// -1 is an implementation specific default duration
|
||||||
const dbus_int32_t expiry_timeout = -1;
|
const dbus_int32_t expiry_timeout = -1;
|
||||||
assert(libdbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32,
|
libdbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &expiry_timeout);
|
||||||
&expiry_timeout));
|
|
||||||
|
|
||||||
// And after all of that we can finally send the actual notification
|
// And after all of that we can finally send the actual notification
|
||||||
dbus_uint32_t message_serial = libdbus_message_get_serial(message.get());
|
dbus_uint32_t message_serial = libdbus_message_get_serial(message.get());
|
||||||
|
|||||||
Reference in New Issue
Block a user