Append a link to the plugin to the notifications

This commit is contained in:
Robbert van der Helm
2021-06-28 13:05:32 +02:00
parent 388d9739a9
commit c5afb7f215
5 changed files with 32 additions and 5 deletions
+2 -1
View File
@@ -321,7 +321,8 @@ class PluginBridge {
"Check yabridge's output for more information on what "
"went wrong. You may need to rerun your DAW from a "
"terminal and restart the plugin scanning process to "
"see the error.");
"see the error.",
true);
std::terminate();
}
+21 -1
View File
@@ -398,7 +398,9 @@ Configuration load_config_for(const fs::path& yabridge_path) {
return Configuration(*config_file, yabridge_path);
}
bool send_notification(const std::string& title, const std::string body) {
bool send_notification(const std::string& title,
const std::string body,
bool append_origin) {
const fs::path notify_send_path = bp::search_path("notify-send");
if (notify_send_path.empty()) {
return false;
@@ -410,6 +412,24 @@ bool send_notification(const std::string& title, const std::string body) {
std::ostringstream formatted_body;
formatted_body << xml_escape(body);
// If possible, append the path to this library file to the message.
if (append_origin) {
try {
const fs::path this_library = get_this_file_location();
formatted_body
<< "\n"
<< "Source: <a href=\"file://"
// TODO: This should be URL encoded, but let's just pray that
// noone uses double quotes in their plugin names
<< this_library.parent_path().string() << "\">"
<< xml_escape(this_library.filename().string()) << "</a>";
} catch (const boost::system::system_error&) {
// I don't think this can fail in the way we're using it, but the
// last thing we want is our notification informing the user of an
// exception to trigger another exception
}
}
try {
return bp::system(notify_send_path, "--urgency=normal",
"--expire-time=30000", "--app-name=yabridge", title,
+5 -1
View File
@@ -274,11 +274,15 @@ Configuration load_config_for(const boost::filesystem::path& yabridge_path);
* @param body The message to display. This can contain line feeds, and it any
* HTML tags and XML escape sequences will be automatically escaped. The
* message can also be empty.
* @param Whether to append 'Source: <XXX.so>' to the body, where `<XXX.so>` is
* a hyperlink to the directory this library is placed in.
*
* @return Whether the notification was sent. This will be false if
* `notify-send` is not available.
*/
bool send_notification(const std::string& title, const std::string body);
bool send_notification(const std::string& title,
const std::string body,
bool append_origin);
/**
* Starting from the starting file or directory, go up in the directory
+2 -1
View File
@@ -54,7 +54,8 @@ extern "C" VST_EXPORT AEffect* VSTPluginMain(
// Also show a desktop notification most people likely won't see the
// above message
send_notification("Failed to initialize VST2 plugin", error.what());
send_notification("Failed to initialize VST2 plugin", error.what(),
true);
return nullptr;
}
+2 -1
View File
@@ -57,7 +57,8 @@ bool InitModule() {
// Also show a desktop notification most people likely won't see the
// above message
send_notification("Failed to initialize VST3 plugin", error.what());
send_notification("Failed to initialize VST3 plugin", error.what(),
true);
return false;
}