mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Create call_external() helper function
This commit is contained in:
parent
aef74f90ec
commit
fc5fa62951
@ -8871,15 +8871,7 @@ cmd_urlopen(ProfWin *window, const char *const command, gchar **args)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: make function. see src/xmpp/avatar.c
|
call_external("xdg-open", args[0]);
|
||||||
GString *cmd = g_string_new("");
|
|
||||||
|
|
||||||
g_string_append_printf(cmd, "%s %s > /dev/null 2>&1", "xdg-open", args[0]);
|
|
||||||
cons_show("Calling: %s", cmd->str);
|
|
||||||
FILE *stream = popen(cmd->str, "r");
|
|
||||||
|
|
||||||
pclose(stream);
|
|
||||||
g_string_free(cmd, TRUE);
|
|
||||||
} else {
|
} else {
|
||||||
cons_show("urlopen not supported in this window");
|
cons_show("urlopen not supported in this window");
|
||||||
}
|
}
|
||||||
|
13
src/common.c
13
src/common.c
@ -483,3 +483,16 @@ get_mentions(gboolean whole_word, gboolean case_sensitive, const char *const mes
|
|||||||
|
|
||||||
return mentions;
|
return mentions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
call_external(const char *const exe, const char *const param)
|
||||||
|
{
|
||||||
|
GString *cmd = g_string_new("");
|
||||||
|
|
||||||
|
g_string_append_printf(cmd, "%s %s > /dev/null 2>&1", exe, param);
|
||||||
|
log_debug("Calling external: %s", cmd->str);
|
||||||
|
FILE *stream = popen(cmd->str, "r");
|
||||||
|
|
||||||
|
pclose(stream);
|
||||||
|
g_string_free(cmd, TRUE);
|
||||||
|
}
|
||||||
|
@ -106,4 +106,6 @@ void get_file_paths_recursive(const char *directory, GSList **contents);
|
|||||||
|
|
||||||
char* get_random_string(int length);
|
char* get_random_string(int length);
|
||||||
|
|
||||||
|
void call_external(const char *const exe, const char *const param);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -266,15 +266,7 @@ _avatar_request_item_result_handler(xmpp_stanza_t *const stanza, void *const use
|
|||||||
|
|
||||||
// if we shall open it
|
// if we shall open it
|
||||||
if (g_hash_table_contains(shall_open, from_attr)) {
|
if (g_hash_table_contains(shall_open, from_attr)) {
|
||||||
GString *cmd = g_string_new("");
|
call_external(prefs_get_string(PREF_AVATAR_CMD), filename->str);
|
||||||
|
|
||||||
g_string_append_printf(cmd, "%s %s > /dev/null 2>&1", prefs_get_string(PREF_AVATAR_CMD), filename->str);
|
|
||||||
cons_show("Calling: %s", cmd->str);
|
|
||||||
FILE *stream = popen(cmd->str, "r");
|
|
||||||
|
|
||||||
pclose(stream);
|
|
||||||
g_string_free(cmd, TRUE);
|
|
||||||
|
|
||||||
g_hash_table_remove(shall_open, from_attr);
|
g_hash_table_remove(shall_open, from_attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user