diff options
| author | Michael Vetter <jubalh@iodoru.org> | 2022-03-21 10:08:13 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-21 10:08:13 +0100 |
| commit | 024694215dce1be21b09b8096eb499f107563f66 (patch) | |
| tree | e4136051c50a46e7c852c698cf5a7a52eef69f5c /src/command | |
| parent | 963065775b0f1008b149b80c19620636a35f8d49 (diff) | |
| parent | cdb8383260ce132e1b4784841727a4b210688b91 (diff) | |
| download | profani-tty-024694215dce1be21b09b8096eb499f107563f66.tar.gz | |
Merge pull request #1644 from profanity-im/ox-polish
Improve OX user experience
Diffstat (limited to 'src/command')
| -rw-r--r-- | src/command/cmd_ac.c | 23 | ||||
| -rw-r--r-- | src/command/cmd_funcs.c | 18 |
2 files changed, 19 insertions, 22 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 57484736..bb703cfb 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -2554,11 +2554,6 @@ _pgp_autocomplete(ProfWin* window, const char* const input, gboolean previous) return NULL; } -/*! - * \brief Auto completion for XEP-0373: OpenPGP for XMPP command. - * - * - */ static char* _ox_autocomplete(ProfWin* window, const char* const input, gboolean previous) { @@ -2590,23 +2585,9 @@ _ox_autocomplete(ProfWin* window, const char* const input, gboolean previous) return found; } - gboolean result; - gchar** args = parse_args(input, 2, 3, &result); - if ((strncmp(input, "/ox", 4) == 0) && (result == TRUE)) { - GString* beginning = g_string_new("/ox "); - g_string_append(beginning, args[0]); - if (args[1]) { - g_string_append(beginning, " "); - g_string_append(beginning, args[1]); - } - found = autocomplete_param_with_func(input, beginning->str, p_gpg_autocomplete_key, previous, NULL); - g_string_free(beginning, TRUE); - if (found) { - g_strfreev(args); - return found; - } + if (strncmp(input, "/ox announce ", 13) == 0) { + return cmd_ac_complete_filepath(input, "/ox announce", previous); } - g_strfreev(args); if (conn_status == JABBER_CONNECTED) { found = autocomplete_param_with_func(input, "/ox setkey", roster_barejid_autocomplete, previous, NULL); diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index eabfb4bf..b1aadbf0 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -1102,6 +1102,7 @@ cmd_export(ProfWin* window, const char* const command, gchar** args) char* path = get_expanded_path(args[0]); fd = open(path, O_WRONLY | O_CREAT, 00600); + free(path); if (-1 == fd) { cons_show("error: cannot open %s: %s", args[0], strerror(errno)); @@ -7630,7 +7631,22 @@ cmd_ox(ProfWin* window, const char* const command, gchar** args) return TRUE; } else if (g_strcmp0(args[0], "announce") == 0) { if (args[1]) { - ox_announce_public_key(args[1]); + gchar* filename = get_expanded_path(args[1]); + + if (access(filename, R_OK) != 0) { + cons_show_error("File not found: %s", filename); + g_free(filename); + return TRUE; + } + + if (!is_regular_file(filename)) { + cons_show_error("Not a file: %s", filename); + g_free(filename); + return TRUE; + } + + ox_announce_public_key(filename); + free(filename); } else { cons_show("Filename is required"); } |