1
0
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Refactor cmd_urlopen

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2020-06-07 22:18:43 +02:00 committed by Michael Vetter
parent 64eb11fbaf
commit 96c877de80

View File

@ -8939,27 +8939,27 @@ cmd_slashguard(ProfWin *window, const char *const command, gchar **args)
gboolean
cmd_urlopen(ProfWin *window, const char *const command, gchar **args)
{
if (window->type == WIN_CHAT ||
window->type == WIN_MUC ||
window->type == WIN_PRIVATE) {
if (args[0] == NULL) {
cons_bad_cmd_usage(command);
return TRUE;
}
gchar* cmd = prefs_get_string(PREF_URL_OPEN_CMD);
gchar *argv[] = {cmd, args[0], NULL};
if (!call_external(argv, NULL, NULL)) {
cons_show_error("Unable to open url: check the logs for more information.");
}
g_free(cmd);
} else {
if (window->type != WIN_CHAT &&
window->type != WIN_MUC &&
window->type != WIN_PRIVATE) {
cons_show("urlopen not supported in this window");
return TRUE;
}
if (args[0] == NULL) {
cons_bad_cmd_usage(command);
return TRUE;
}
gchar* cmd = prefs_get_string(PREF_URL_OPEN_CMD);
gchar *argv[] = {cmd, args[0], NULL};
if (!call_external(argv, NULL, NULL)) {
cons_show_error("Unable to open url: check the logs for more information.");
}
g_free(cmd);
return TRUE;
}