| 4495 | } |
| 4496 | |
| 4497 | static void |
| 4498 | send_to_external_app(gint index, signal_user_data_t * ud) |
| 4499 | { |
| 4500 | gboolean send_file_to = ghb_dict_get_bool(ud->prefs, "SendFileTo"); |
| 4501 | const gchar * send_file_to_target = ghb_dict_get_string(ud->prefs, "SendFileToTarget"); |
| 4502 | if (send_file_to && send_file_to_target != NULL && send_file_to_target[0] != '\0') |
| 4503 | { |
| 4504 | if (is_flatpak && !flatpak_spawn_enable) |
| 4505 | { |
| 4506 | ghb_log("Could not run command outside Flatpak as fr.handbrake.ghb " |
| 4507 | "doesn't have the --talk-name=org.freedesktop.Flatpak override"); |
| 4508 | return; |
| 4509 | } |
| 4510 | GhbValue *queueDict, *jobDict, *destDict; |
| 4511 | queueDict = ghb_array_get(ud->queue, index); |
| 4512 | jobDict = ghb_dict_get(queueDict, "Job"); |
| 4513 | destDict = ghb_dict_get(jobDict, "Destination"); |
| 4514 | |
| 4515 | gchar * file = g_shell_quote(ghb_dict_get_string(destDict, "File")); |
| 4516 | gchar * command_str; |
| 4517 | if (is_flatpak) |
| 4518 | { |
| 4519 | command_str = g_strjoin(" ", "flatpak-spawn", "--host", "--", send_file_to_target, file, NULL); |
| 4520 | } |
| 4521 | else |
| 4522 | { |
| 4523 | command_str = g_strjoin(" ", send_file_to_target, file, NULL); |
| 4524 | } |
| 4525 | |
| 4526 | gchar ** command_array = NULL; |
| 4527 | GError * error = NULL; |
| 4528 | ghb_log("Running command `%s`", command_str); |
| 4529 | if (g_shell_parse_argv(command_str, NULL, &command_array, &error)) |
| 4530 | { |
| 4531 | g_spawn_async( |
| 4532 | NULL, |
| 4533 | command_array, |
| 4534 | NULL, |
| 4535 | G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL | G_SPAWN_STDOUT_TO_DEV_NULL, |
| 4536 | NULL, |
| 4537 | NULL, |
| 4538 | NULL, |
| 4539 | &error); |
| 4540 | g_strfreev(command_array); |
| 4541 | } |
| 4542 | |
| 4543 | if (error != NULL) |
| 4544 | { |
| 4545 | ghb_log("Failed to run command `%s`: %s", command_str, error->message); |
| 4546 | g_error_free(error); |
| 4547 | } |
| 4548 | |
| 4549 | g_free(command_str); |
| 4550 | g_free(file); |
| 4551 | } |
| 4552 | } |
| 4553 | |
| 4554 | static void |
no test coverage detected