diff options
author | nandesu-utils <70854931+nandesu-utils@users.noreply.github.com> | 2022-08-25 00:10:22 +0300 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2022-09-06 12:51:27 +0200 |
commit | e1ed012f72495e2d2bdd10520eb943fbba932ed4 (patch) | |
tree | b79cc956bf779f7cb965431efb1f5e528ceb3ef2 | |
parent | 056b19eb91c03c8a8d5f261fa38450b5238986dc (diff) | |
download | profani-tty-e1ed012f72495e2d2bdd10520eb943fbba932ed4.tar.gz |
support for formatting in avatar executable
in before it just used the input command line as it was but this fixes this by adding formatting using `format_call_external_argv` which is already used in `url open` executable.
-rw-r--r-- | src/common.c | 24 | ||||
-rw-r--r-- | src/xmpp/avatar.c | 16 |
2 files changed, 25 insertions, 15 deletions
diff --git a/src/common.c b/src/common.c index f5b59612..de35ea2d 100644 --- a/src/common.c +++ b/src/common.c @@ -445,8 +445,8 @@ get_mentions(gboolean whole_word, gboolean case_sensitive, const char* const mes gboolean call_external(gchar** argv, gchar** std_out, gchar** std_err) { - GError *spawn_error = NULL; - GError *exit_error = NULL; + GError* spawn_error = NULL; + GError* exit_error = NULL; gboolean is_successful; gint wait_status; @@ -457,22 +457,22 @@ call_external(gchar** argv, gchar** std_out, gchar** std_err) flags |= G_SPAWN_STDERR_TO_DEV_NULL; is_successful = g_spawn_sync(NULL, // Inherit the parent PWD. - argv, - NULL, // Inherit the parent environment. - flags, - NULL, NULL, // No func. before exec() in child. - std_out, std_err, - &wait_status, &spawn_error); + argv, + NULL, // Inherit the parent environment. + flags, + NULL, NULL, // No func. before exec() in child. + std_out, std_err, + &wait_status, &spawn_error); if (!is_successful) { gchar* cmd = g_strjoinv(" ", argv); - log_error("could not spawn '%s' with error '%s'", cmd, spawn_error->message); + log_error("Spawning '%s' failed with with error '%s'", cmd, spawn_error ? spawn_error->message : "Unknown, spawn_error is NULL"); + ; g_error_free(spawn_error); g_free(cmd); - } - else { - is_successful = g_spawn_check_wait_status(wait_status, &exit_error); + } else { + is_successful = g_spawn_check_exit_status(wait_status, &exit_error); if (!is_successful) { gchar* cmd = g_strjoinv(" ", argv); diff --git a/src/xmpp/avatar.c b/src/xmpp/avatar.c index 9345ba3a..fb3b01ea 100644 --- a/src/xmpp/avatar.c +++ b/src/xmpp/avatar.c @@ -339,10 +339,20 @@ _avatar_request_item_result_handler(xmpp_stanza_t* const stanza, void* const use // if we shall open it if (g_hash_table_contains(shall_open, from_attr)) { - gchar* argv[] = { prefs_get_string(PREF_AVATAR_CMD), filename->str, NULL }; - if (!call_external(argv, NULL, NULL)) { - cons_show_error("Unable to display avatar: check the logs for more information."); + gchar* cmdtemplate = prefs_get_string(PREF_AVATAR_CMD); + + if (cmdtemplate == NULL) { + cons_show_error("No default `avatar open` command found in executables preferences."); + } else { + gchar** argv = format_call_external_argv(cmdtemplate, NULL, filename->str); + + if (!call_external(argv, NULL, NULL)) { + cons_show_error("Unable to display avatar: check the logs for more information."); + } + + g_strfreev(argv); } + g_hash_table_remove(shall_open, from_attr); } |