mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge pull request #1447 from profanity-im/omemomediasharing-impr
omemo media sharing related polishing
This commit is contained in:
commit
f10edd202f
@ -4854,18 +4854,12 @@ gboolean
|
||||
cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
jabber_conn_status_t conn_status = connection_get_status();
|
||||
char* filename = args[0];
|
||||
gchar* filename;
|
||||
char* alt_scheme = NULL;
|
||||
char* alt_fragment = NULL;
|
||||
|
||||
// expand ~ to $HOME
|
||||
if (filename[0] == '~' && filename[1] == '/') {
|
||||
if (asprintf(&filename, "%s/%s", getenv("HOME"), filename + 2) == -1) {
|
||||
return TRUE;
|
||||
}
|
||||
} else {
|
||||
filename = strdup(filename);
|
||||
}
|
||||
filename = get_expanded_path(args[0]);
|
||||
|
||||
if (access(filename, R_OK) != 0) {
|
||||
cons_show_error("Uploading '%s' failed: File not found!", filename);
|
||||
|
30
src/common.c
30
src/common.c
@ -628,19 +628,41 @@ _basename_from_url(const char* url)
|
||||
return basename;
|
||||
}
|
||||
|
||||
gchar*
|
||||
get_expanded_path(const char *path)
|
||||
{
|
||||
GString* exp_path = g_string_new("");
|
||||
gchar *result;
|
||||
|
||||
if (strlen(path) >= 2 && path[0] == '~' && path[1] == '/') {
|
||||
g_string_printf(exp_path, "%s/%s", getenv("HOME"), path+2);
|
||||
} else {
|
||||
g_string_printf(exp_path, "%s", path+2);
|
||||
}
|
||||
|
||||
result = exp_path->str;
|
||||
g_string_free(exp_path, FALSE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gchar*
|
||||
unique_filename_from_url(const char* url, const char* path)
|
||||
{
|
||||
gchar *realpath;
|
||||
|
||||
// Default to './' as path when none has been provided.
|
||||
if (path == NULL) {
|
||||
path = "./";
|
||||
realpath = "./";
|
||||
} else {
|
||||
realpath = get_expanded_path(path);
|
||||
}
|
||||
|
||||
// Resolves paths such as './../.' for path.
|
||||
GFile* target = g_file_new_for_commandline_arg(path);
|
||||
GFile* target = g_file_new_for_commandline_arg(realpath);
|
||||
gchar* filename = NULL;
|
||||
|
||||
if (_has_directory_suffix(path) || g_file_test(path, G_FILE_TEST_IS_DIR)) {
|
||||
if (_has_directory_suffix(realpath) || g_file_test(realpath, G_FILE_TEST_IS_DIR)) {
|
||||
// The target should be used as a directory. Assume that the basename
|
||||
// should be derived from the URL.
|
||||
char* basename = _basename_from_url(url);
|
||||
@ -654,11 +676,13 @@ unique_filename_from_url(const char* url, const char* path)
|
||||
gchar* unique_filename = _unique_filename(filename);
|
||||
if (unique_filename == NULL) {
|
||||
g_free(filename);
|
||||
g_free(realpath);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_object_unref(target);
|
||||
g_free(filename);
|
||||
g_free(realpath);
|
||||
|
||||
return unique_filename;
|
||||
}
|
||||
|
@ -108,5 +108,6 @@ gboolean call_external(gchar** argv, gchar*** const output_ptr, gchar*** const e
|
||||
gchar** format_call_external_argv(const char* template, const char* url, const char* filename);
|
||||
|
||||
gchar* unique_filename_from_url(const char* url, const char* path);
|
||||
gchar* get_expanded_path(const char *path);
|
||||
|
||||
#endif
|
||||
|
@ -183,6 +183,11 @@ _prefs_load(void)
|
||||
g_key_file_remove_key(prefs, PREF_GROUP_LOGGING, "avatar.cmd", NULL);
|
||||
}
|
||||
|
||||
// 0.10 will have omemo media sharing. so disabling of senfile introduced in 0.9 is not needed (#1270)
|
||||
if (g_key_file_has_key(prefs, PREF_GROUP_OMEMO, "sendfile", NULL)) {
|
||||
g_key_file_remove_key(prefs, PREF_GROUP_OMEMO, "sendfile", NULL);
|
||||
}
|
||||
|
||||
_save_prefs();
|
||||
|
||||
boolean_choice_ac = autocomplete_new();
|
||||
|
Loading…
Reference in New Issue
Block a user