mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Remove scheme and filetype matching for url (save|open)
This commit is contained in:
parent
7f0165a912
commit
d7848e38bc
@ -2374,7 +2374,7 @@ static struct cmd_t command_defs[] = {
|
|||||||
"Settings for consistent color generation for nicks (XEP-0392). Including corrections for Color Vision Deficiencies. "
|
"Settings for consistent color generation for nicks (XEP-0392). Including corrections for Color Vision Deficiencies. "
|
||||||
"Your terminal needs to support 256 colors.")
|
"Your terminal needs to support 256 colors.")
|
||||||
CMD_ARGS(
|
CMD_ARGS(
|
||||||
{ "on|off|redgreen|blue", "Enable or disable nick colorization for MUC nicks. 'redgreen' is for people with red/green blindess and 'blue' for people with blue blindness." },
|
{ "on|off|redgreen|blue", "Enable or disable nick colorization for MUC nicks. 'redgreen' is for people with red/green blindness and 'blue' for people with blue blindness." },
|
||||||
{ "own on|off", "Enable color generation for own nick. If disabled the color from the color from the theme ('me') will get used." })
|
{ "own on|off", "Enable color generation for own nick. If disabled the color from the color from the theme ('me') will get used." })
|
||||||
CMD_EXAMPLES(
|
CMD_EXAMPLES(
|
||||||
"/color off",
|
"/color off",
|
||||||
@ -2493,26 +2493,35 @@ static struct cmd_t command_defs[] = {
|
|||||||
|
|
||||||
{ "/executable",
|
{ "/executable",
|
||||||
parse_args, 2, 4, &cons_executable_setting,
|
parse_args, 2, 4, &cons_executable_setting,
|
||||||
CMD_NOSUBFUNCS
|
CMD_SUBFUNCS(
|
||||||
CMD_MAINFUNC(cmd_executable)
|
{ "avatar", cmd_executable_avatar },
|
||||||
|
{ "urlopen", cmd_executable_urlopen },
|
||||||
|
{ "urlsave", cmd_executable_urlsave })
|
||||||
|
CMD_NOMAINFUNC
|
||||||
CMD_TAGS(
|
CMD_TAGS(
|
||||||
CMD_TAG_DISCOVERY)
|
CMD_TAG_DISCOVERY)
|
||||||
CMD_SYN(
|
CMD_SYN(
|
||||||
"/executable avatar <cmd>",
|
"/executable avatar <cmd>",
|
||||||
"/executable urlopen (<fileType>|DEF <require_save> <cmd>",
|
"/executable urlopen set <cmdtemplate>",
|
||||||
"/executable urlsave (<protocol>|DEF) <cmd>")
|
"/executable urlopen default",
|
||||||
|
"/executable urlsave set <cmdtemplate>",
|
||||||
|
"/executable urlsave default")
|
||||||
CMD_DESC(
|
CMD_DESC(
|
||||||
"Configure executable that should be called upon a certain command."
|
"Configure executable that should be called upon a certain command.")
|
||||||
"Default is xdg-open.")
|
|
||||||
CMD_ARGS(
|
CMD_ARGS(
|
||||||
{ "avatar", "Set executable that is run in /avatar open. Use your favourite image viewer." },
|
{ "avatar", "Set executable that is run by /avatar open. Use your favorite image viewer." },
|
||||||
{ "urlopen", "Set executable that is run in /url open for a given file type. It may be your favorite browser or a specific viewer. Use DEF to set default command for undefined file type." },
|
{ "urlopen set", "Set executable that is run by /url open. It may be your favorite browser or a specific viewer." },
|
||||||
{ "urlsave", "Set executable that is run in /url save for a given protocol. Use your favourite downloader. Use DEF to set default command for undefined protocol." })
|
{ "urlopen default", "Restore to default settings." },
|
||||||
|
{ "urlsave set", "Set executable that is run by /url save. It may be your favorite downloader.'" },
|
||||||
|
{ "urlsave default", "Use the built-in download method for saving." })
|
||||||
CMD_EXAMPLES(
|
CMD_EXAMPLES(
|
||||||
"/executable avatar xdg-open",
|
"/executable avatar xdg-open",
|
||||||
"/executable urlopen DEF false \"xdg-open %u\"",
|
"/executable urlopen set \"xdg-open %u\"",
|
||||||
"/executable urlopen html false \"firefox %u\"",
|
"/executable urlopen set \"firefox %u\"",
|
||||||
"/executable urlsave aesgcm \"omut -d -o %p %u\"")
|
"/executable urlopen default",
|
||||||
|
"/executable urlsave set \"wget %u -O %p\"",
|
||||||
|
"/executable urlsave set \"curl %u -o %p\"",
|
||||||
|
"/executable urlsave default")
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "/url",
|
{ "/url",
|
||||||
|
@ -9135,9 +9135,9 @@ cmd_url_open(ProfWin* window, const char* const command, gchar** args)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_template = prefs_get_string_with_option(PREF_URL_OPEN_CMD, scheme);
|
cmd_template = prefs_get_string(PREF_URL_OPEN_CMD);
|
||||||
if (cmd_template == NULL) {
|
if (cmd_template == NULL) {
|
||||||
cons_show("No default open command found in url open preferences");
|
cons_show("No default `url open` command found in executables preferences.");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9195,21 +9195,18 @@ cmd_url_save(ProfWin* window, const char* const command, gchar** args)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_template = prefs_get_string_with_option(PREF_URL_SAVE_CMD, scheme);
|
cmd_template = prefs_get_string(PREF_URL_SAVE_CMD);
|
||||||
if (cmd_template == NULL) {
|
if (cmd_template == NULL && (g_strcmp0(scheme, "http") == 0 || g_strcmp0(scheme, "https") == 0)) {
|
||||||
if (g_strcmp0(scheme, "http") == 0
|
|
||||||
|| g_strcmp0(scheme, "https") == 0) {
|
|
||||||
_url_http_method(window, cmd_template, url, filename);
|
_url_http_method(window, cmd_template, url, filename);
|
||||||
#ifdef HAVE_OMEMO
|
#ifdef HAVE_OMEMO
|
||||||
} else if (g_strcmp0(scheme, "aesgcm") == 0) {
|
} else if (g_strcmp0(scheme, "aesgcm") == 0) {
|
||||||
_url_aesgcm_method(window, cmd_template, url, filename);
|
_url_aesgcm_method(window, cmd_template, url, filename);
|
||||||
#endif
|
#endif
|
||||||
|
} else if (cmd_template != NULL) {
|
||||||
|
_url_external_method(cmd_template, url, filename);
|
||||||
} else {
|
} else {
|
||||||
cons_show_error("No download method defined for the scheme '%s'.", scheme);
|
cons_show_error("No download method defined for the scheme '%s'.", scheme);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
_url_external_method(cmd_template, url, filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
||||||
@ -9223,48 +9220,59 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cmd_executable(ProfWin* window, const char* const command, gchar** args)
|
cmd_executable_avatar(ProfWin* window, const char* const command, gchar** args)
|
||||||
|
{
|
||||||
|
prefs_set_string(PREF_AVATAR_CMD, args[1]);
|
||||||
|
cons_show("`avatar` command set to invoke '%s'", args[1]);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cmd_executable_urlopen(ProfWin* window, const char* const command, gchar** args)
|
||||||
{
|
{
|
||||||
guint num_args = g_strv_length(args);
|
guint num_args = g_strv_length(args);
|
||||||
|
if (num_args < 2) {
|
||||||
if (g_strcmp0(args[0], "avatar") == 0) {
|
|
||||||
prefs_set_string(PREF_AVATAR_CMD, args[1]);
|
|
||||||
cons_show("Avatar command set to: %s", args[1]);
|
|
||||||
|
|
||||||
} else if (g_strcmp0(args[0], "urlopen") == 0) {
|
|
||||||
if (num_args < 4) {
|
|
||||||
cons_bad_cmd_usage(command);
|
cons_bad_cmd_usage(command);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar* str = g_strjoinv(" ", &args[3]);
|
if (g_strcmp0(args[1], "set") == 0 && num_args >= 3) {
|
||||||
const gchar* const list[] = { args[2], str, NULL };
|
gchar* str = g_strjoinv(" ", &args[2]);
|
||||||
prefs_set_string_list_with_option(PREF_URL_OPEN_CMD, args[1], list);
|
prefs_set_string(PREF_URL_OPEN_CMD, str);
|
||||||
cons_show("`url open` command set to: %s for %s files", str, args[1]);
|
cons_show("`url open` command set to invoke '%s'", str);
|
||||||
g_free(str);
|
g_free(str);
|
||||||
|
|
||||||
} else if (g_strcmp0(args[0], "urlsave") == 0) {
|
} else if (g_strcmp0(args[1], "default") == 0) {
|
||||||
|
prefs_set_string(PREF_URL_SAVE_CMD, NULL);
|
||||||
if (num_args < 3) {
|
gchar* def = prefs_get_string(PREF_URL_SAVE_CMD);
|
||||||
cons_bad_cmd_usage(command);
|
cons_show("`url open` command set to invoke %s (default)", def);
|
||||||
return TRUE;
|
g_free(def);
|
||||||
}
|
} else {
|
||||||
|
cons_bad_cmd_usage(command);
|
||||||
if (g_strcmp0(args[1], "set") == 0 && num_args >= 4) {
|
}
|
||||||
gchar* str = g_strjoinv(" ", &args[3]);
|
|
||||||
prefs_set_string_with_option(PREF_URL_SAVE_CMD, args[2], str);
|
return TRUE;
|
||||||
cons_show("`url save` command set to: %s for scheme %s", str, args[2]);
|
}
|
||||||
g_free(str);
|
|
||||||
|
gboolean
|
||||||
} else if (g_strcmp0(args[1], "clear") == 0) {
|
cmd_executable_urlsave(ProfWin* window, const char* const command, gchar** args)
|
||||||
prefs_set_string_with_option(PREF_URL_SAVE_CMD, args[2], NULL);
|
{
|
||||||
cons_show("`url save` will use internal download method for scheme %s", args[2]);
|
|
||||||
|
guint num_args = g_strv_length(args);
|
||||||
} else {
|
if (num_args < 2) {
|
||||||
cons_bad_cmd_usage(command);
|
cons_bad_cmd_usage(command);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_strcmp0(args[1], "set") == 0 && num_args >= 3) {
|
||||||
|
gchar* str = g_strjoinv(" ", &args[2]);
|
||||||
|
prefs_set_string(PREF_URL_SAVE_CMD, str);
|
||||||
|
cons_show("`url save` command set to invoke '%s'", str);
|
||||||
|
g_free(str);
|
||||||
|
|
||||||
|
} else if (g_strcmp0(args[1], "default") == 0) {
|
||||||
|
prefs_set_string(PREF_URL_SAVE_CMD, NULL);
|
||||||
|
cons_show("`url save` will use built-in download method (default)");
|
||||||
} else {
|
} else {
|
||||||
cons_bad_cmd_usage(command);
|
cons_bad_cmd_usage(command);
|
||||||
}
|
}
|
||||||
|
@ -237,6 +237,8 @@ gboolean cmd_slashguard(ProfWin* window, const char* const command, gchar** args
|
|||||||
gboolean cmd_serversoftware(ProfWin* window, const char* const command, gchar** args);
|
gboolean cmd_serversoftware(ProfWin* window, const char* const command, gchar** args);
|
||||||
gboolean cmd_url_open(ProfWin* window, const char* const command, gchar** args);
|
gboolean cmd_url_open(ProfWin* window, const char* const command, gchar** args);
|
||||||
gboolean cmd_url_save(ProfWin* window, const char* const command, gchar** args);
|
gboolean cmd_url_save(ProfWin* window, const char* const command, gchar** args);
|
||||||
gboolean cmd_executable(ProfWin* window, const char* const command, gchar** args);
|
gboolean cmd_executable_avatar(ProfWin* window, const char* const command, gchar** args);
|
||||||
|
gboolean cmd_executable_urlopen(ProfWin* window, const char* const command, gchar** args);
|
||||||
|
gboolean cmd_executable_urlsave(ProfWin* window, const char* const command, gchar** args);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -170,7 +170,7 @@ _prefs_load(void)
|
|||||||
value = g_string_append(value, val);
|
value = g_string_append(value, val);
|
||||||
value = g_string_append(value, " %u;");
|
value = g_string_append(value, " %u;");
|
||||||
|
|
||||||
g_key_file_set_locale_string(prefs, PREF_GROUP_EXECUTABLES, "url.open.cmd", "DEF", value->str);
|
g_key_file_set_locale_string(prefs, PREF_GROUP_EXECUTABLES, "url.open.cmd", "*", value->str);
|
||||||
g_key_file_remove_key(prefs, PREF_GROUP_LOGGING, "urlopen.cmd", NULL);
|
g_key_file_remove_key(prefs, PREF_GROUP_LOGGING, "urlopen.cmd", NULL);
|
||||||
|
|
||||||
g_string_free(value, TRUE);
|
g_string_free(value, TRUE);
|
||||||
@ -529,7 +529,7 @@ prefs_get_string_with_option(preference_t pref, gchar* option)
|
|||||||
|
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
// check for user set default
|
// check for user set default
|
||||||
result = g_key_file_get_locale_string(prefs, group, key, "DEF", NULL);
|
result = g_key_file_get_locale_string(prefs, group, key, "*", NULL);
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
if (def) {
|
if (def) {
|
||||||
// use hardcoded profanity default
|
// use hardcoded profanity default
|
||||||
|
@ -2068,17 +2068,20 @@ cons_correction_setting(void)
|
|||||||
void
|
void
|
||||||
cons_executable_setting(void)
|
cons_executable_setting(void)
|
||||||
{
|
{
|
||||||
char* avatar = prefs_get_string(PREF_AVATAR_CMD);
|
gchar* avatar = prefs_get_string(PREF_AVATAR_CMD);
|
||||||
cons_show("Default '/avatar open' command (/executable avatar) : %s", avatar);
|
cons_show("Default '/avatar open' command (/executable avatar) : %s", avatar);
|
||||||
g_free(avatar);
|
g_free(avatar);
|
||||||
|
|
||||||
//TODO: there needs to be a way to get all the "locales"/schemes so we can
|
//TODO: there needs to be a way to get all the "locales"/schemes so we can
|
||||||
//display the default openers for all filetypes
|
//display the default openers for all filetypes
|
||||||
char* urlopen = prefs_get_string_with_option(PREF_URL_OPEN_CMD, "");
|
gchar* urlopen = prefs_get_string(PREF_URL_OPEN_CMD);
|
||||||
cons_show("Default '/url open' command (/executable urlopen) : %s", urlopen);
|
cons_show("Default '/url open' command (/executable urlopen) : %s", urlopen);
|
||||||
g_free(urlopen);
|
g_free(urlopen);
|
||||||
|
|
||||||
char* urlsave = prefs_get_string(PREF_URL_SAVE_CMD);
|
gchar* urlsave = prefs_get_string(PREF_URL_SAVE_CMD);
|
||||||
|
if (urlsave == NULL) {
|
||||||
|
urlsave = g_strdup("(built-in)");
|
||||||
|
}
|
||||||
cons_show("Default '/url save' command (/executable urlsave) : %s", urlsave);
|
cons_show("Default '/url save' command (/executable urlsave) : %s", urlsave);
|
||||||
g_free(urlsave);
|
g_free(urlsave);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user