Run make format on rebase

This commit is contained in:
William Wennerström
2020-07-20 13:01:05 +02:00
parent a0cf0844ab
commit 4711fc62a3
19 changed files with 782 additions and 827 deletions

View File

@@ -4807,16 +4807,18 @@ cmd_disco(ProfWin* window, const char* const command, gchar** args)
return TRUE; return TRUE;
} }
#ifdef HAVE_OMEMO
char *_add_omemo_stream(int *fd, FILE **fh, char **err) { char*
_add_omemo_stream(int* fd, FILE** fh, char** err)
{
// Create temporary file for writing ciphertext. // Create temporary file for writing ciphertext.
int tmpfd; int tmpfd;
char *tmpname = NULL; char* tmpname = NULL;
if ((tmpfd = g_file_open_tmp("profanity.XXXXXX", &tmpname, NULL)) == -1) { if ((tmpfd = g_file_open_tmp("profanity.XXXXXX", &tmpname, NULL)) == -1) {
*err = "Unable to create temporary file for encrypted transfer."; *err = "Unable to create temporary file for encrypted transfer.";
return NULL; return NULL;
} }
FILE *tmpfh = fdopen(tmpfd, "wb"); FILE* tmpfh = fdopen(tmpfd, "wb");
// The temporary ciphertext file should be removed after it has // The temporary ciphertext file should be removed after it has
// been closed. // been closed.
@@ -4824,7 +4826,7 @@ char *_add_omemo_stream(int *fd, FILE **fh, char **err) {
free(tmpname); free(tmpname);
int crypt_res; int crypt_res;
char *fragment; char* fragment;
fragment = omemo_encrypt_file(*fh, tmpfh, file_size(*fd), &crypt_res); fragment = omemo_encrypt_file(*fh, tmpfh, file_size(*fd), &crypt_res);
if (crypt_res != 0) { if (crypt_res != 0) {
fclose(tmpfh); fclose(tmpfh);
@@ -4843,14 +4845,15 @@ char *_add_omemo_stream(int *fd, FILE **fh, char **err) {
return fragment; return fragment;
} }
#endif
gboolean gboolean
cmd_sendfile(ProfWin* window, const char* const command, gchar** args) cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
{ {
jabber_conn_status_t conn_status = connection_get_status(); jabber_conn_status_t conn_status = connection_get_status();
char *filename = args[0]; char* filename = args[0];
char *alt_scheme = NULL; char* alt_scheme = NULL;
char *alt_fragment = NULL; char* alt_fragment = NULL;
// expand ~ to $HOME // expand ~ to $HOME
if (filename[0] == '~' && filename[1] == '/') { if (filename[0] == '~' && filename[1] == '/') {
@@ -4887,58 +4890,46 @@ cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
goto out; goto out;
} }
FILE *fh = fdopen(fd, "rb"); FILE* fh = fdopen(fd, "rb");
switch (window->type) { switch (window->type) {
case WIN_MUC: case WIN_MUC:
case WIN_CHAT: case WIN_CHAT:
{ {
ProfChatWin *chatwin = (ProfChatWin*)window; ProfChatWin* chatwin = (ProfChatWin*)window;
#ifdef HAVE_OMEMO #ifdef HAVE_OMEMO
if (chatwin->is_omemo) { if (chatwin->is_omemo) {
char *err = NULL; char* err = NULL;
alt_scheme = OMEMO_AESGCM_URL_SCHEME; alt_scheme = OMEMO_AESGCM_URL_SCHEME;
alt_fragment = _add_omemo_stream(&fd, &fh, &err); alt_fragment = _add_omemo_stream(&fd, &fh, &err);
if (err != NULL) { if (err != NULL) {
cons_show_error(err); cons_show_error(err);
win_println(window, THEME_ERROR, "-", err); win_println(window, THEME_ERROR, "-", err);
goto out; goto out;
}
break;
}
#endif
if (window->type == WIN_CHAT) {
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
if ((chatwin->pgp_send && !prefs_get_boolean(PREF_PGP_SENDFILE))
|| (chatwin->is_otr && !prefs_get_boolean(PREF_OTR_SENDFILE))) {
cons_show_error("Uploading unencrypted files disabled. See /otr sendfile or /pgp sendfile.");
win_println(window, THEME_ERROR, "-", "Sending encrypted files via http_upload is not possible yet.");
goto out;
}
} }
break; break;
} }
case WIN_PRIVATE: // We don't support encryption in private MUC windows. #endif
default:
cons_show_error("Unsupported window for file transmission."); if (window->type == WIN_CHAT) {
goto out; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
if ((chatwin->pgp_send && !prefs_get_boolean(PREF_PGP_SENDFILE))
|| (chatwin->is_otr && !prefs_get_boolean(PREF_OTR_SENDFILE))) {
cons_show_error("Uploading unencrypted files disabled. See /otr sendfile or /pgp sendfile.");
win_println(window, THEME_ERROR, "-", "Sending encrypted files via http_upload is not possible yet.");
goto out;
}
} }
break; break;
} }
case WIN_PRIVATE: case WIN_PRIVATE: // We don't support encryption in private MUC windows.
{
//we don't support encryption in private muc windows
break;
}
default: default:
cons_show_error("Unsupported window for file transmission."); cons_show_error("Unsupported window for file transmission.");
free(filename); goto out;
return TRUE;
} }
HTTPUpload *upload = malloc(sizeof(HTTPUpload)); HTTPUpload* upload = malloc(sizeof(HTTPUpload));
upload->window = window; upload->window = window;
upload->filename = strdup(filename); upload->filename = strdup(filename);
@@ -8847,7 +8838,7 @@ cmd_omemo_policy(ProfWin* window, const char* const command, gchar** args)
} }
gboolean gboolean
cmd_save(ProfWin *window, const char *const command, gchar **args) cmd_save(ProfWin* window, const char* const command, gchar** args)
{ {
log_info("Saving preferences to configuration file"); log_info("Saving preferences to configuration file");
cons_show("Saving preferences."); cons_show("Saving preferences.");
@@ -9123,8 +9114,8 @@ cmd_url_open(ProfWin* window, const char* const command, gchar** args)
gchar* suffix_cmd = g_strdup(suffix_cmd_pref[1]); gchar* suffix_cmd = g_strdup(suffix_cmd_pref[1]);
g_strfreev(suffix_cmd_pref); g_strfreev(suffix_cmd_pref);
gchar *scheme = g_uri_parse_scheme(args[1]); gchar* scheme = g_uri_parse_scheme(args[1]);
if( 0 == g_strcmp0(scheme, OMEMO_AESGCM_URL_SCHEME)) { if (0 == g_strcmp0(scheme, "aesgcm")) {
require_save = true; require_save = true;
} }
g_free(scheme); g_free(scheme);
@@ -9163,15 +9154,16 @@ cmd_url_open(ProfWin* window, const char* const command, gchar** args)
return TRUE; return TRUE;
} }
void
void _url_save_fallback_method(ProfWin *window, const char *url, const char *filename) { _url_save_fallback_method(ProfWin* window, const char* url, const char* filename)
FILE *fh = fopen(filename, "wb"); {
FILE* fh = fopen(filename, "wb");
if (!fh) { if (!fh) {
cons_show_error("Cannot open file '%s' for writing.", filename); cons_show_error("Cannot open file '%s' for writing.", filename);
return; return;
} }
HTTPDownload *download = malloc(sizeof(HTTPDownload)); HTTPDownload* download = malloc(sizeof(HTTPDownload));
download->window = window; download->window = window;
download->url = strdup(url); download->url = strdup(url);
download->filehandle = fh; download->filehandle = fh;
@@ -9180,8 +9172,10 @@ void _url_save_fallback_method(ProfWin *window, const char *url, const char *fil
http_download_add_download(download); http_download_add_download(download);
} }
void _url_save_external_method(const char *scheme_cmd, const char *url, const char *filename) { void
gchar **argv = g_strsplit(scheme_cmd, " ", 0); _url_save_external_method(const char* scheme_cmd, const char* url, const char* filename)
{
gchar** argv = g_strsplit(scheme_cmd, " ", 0);
guint num_args = 0; guint num_args = 0;
while (argv[num_args]) { while (argv[num_args]) {
@@ -9202,11 +9196,13 @@ void _url_save_external_method(const char *scheme_cmd, const char *url, const ch
} }
} }
char *_make_unique_filename(const char *filename) { char*
char *unique = strdup(filename); _make_unique_filename(const char* filename)
{
char* unique = strdup(filename);
unsigned int i = 0; unsigned int i = 0;
while(g_file_test(unique, G_FILE_TEST_EXISTS)) { while (g_file_test(unique, G_FILE_TEST_EXISTS)) {
free(unique); free(unique);
if (i > 1000) { // Give up after 1000 attempts. if (i > 1000) { // Give up after 1000 attempts.
@@ -9222,11 +9218,9 @@ char *_make_unique_filename(const char *filename) {
} }
gboolean gboolean
cmd_url_save(ProfWin *window, const char *const command, gchar **args) cmd_url_save(ProfWin* window, const char* const command, gchar** args)
{ {
if (window->type != WIN_CHAT && if (window->type != WIN_CHAT && window->type != WIN_MUC && window->type != WIN_PRIVATE) {
window->type != WIN_MUC &&
window->type != WIN_PRIVATE) {
cons_show_error("`/url save` is not supported in this window."); cons_show_error("`/url save` is not supported in this window.");
return TRUE; return TRUE;
} }
@@ -9236,18 +9230,18 @@ cmd_url_save(ProfWin *window, const char *const command, gchar **args)
return TRUE; return TRUE;
} }
gchar *url = args[1]; gchar* url = args[1];
gchar *path = g_strdup(args[2]); gchar* path = g_strdup(args[2]);
gchar *scheme = g_uri_parse_scheme(url); gchar* scheme = g_uri_parse_scheme(url);
if (scheme == NULL) { if (scheme == NULL) {
cons_show("URL '%s' is not valid.", url); cons_show("URL '%s' is not valid.", url);
g_free(url); g_free(url);
return TRUE; return TRUE;
} }
gchar *directory = NULL; gchar* directory = NULL;
gchar *basename = NULL; gchar* basename = NULL;
if (path != NULL) { if (path != NULL) {
directory = g_path_get_dirname(path); directory = g_path_get_dirname(path);
basename = g_path_get_basename(path); basename = g_path_get_basename(path);
@@ -9267,10 +9261,10 @@ cmd_url_save(ProfWin *window, const char *const command, gchar **args)
basename = http_basename_from_url(url); basename = http_basename_from_url(url);
} }
char *filename = NULL; char* filename = NULL;
filename = g_build_filename(directory, basename, NULL); filename = g_build_filename(directory, basename, NULL);
char *unique_filename = _make_unique_filename(filename); char* unique_filename = _make_unique_filename(filename);
if (!unique_filename) { if (!unique_filename) {
cons_show_error("Failed to generate an unique filename from '%s'.", filename); cons_show_error("Failed to generate an unique filename from '%s'.", filename);
free(filename); free(filename);
@@ -9280,11 +9274,11 @@ cmd_url_save(ProfWin *window, const char *const command, gchar **args)
free(filename); free(filename);
filename = unique_filename; filename = unique_filename;
gchar *scheme_cmd = prefs_get_string_with_option(PREF_URL_SAVE_CMD, scheme); gchar* scheme_cmd = prefs_get_string_with_option(PREF_URL_SAVE_CMD, scheme);
if (scheme_cmd == NULL) { if (scheme_cmd == NULL) {
if (g_strcmp0(scheme, "http") == 0 if (g_strcmp0(scheme, "http") == 0
|| g_strcmp0(scheme, "https") == 0 || g_strcmp0(scheme, "https") == 0
|| g_strcmp0(scheme, OMEMO_AESGCM_URL_SCHEME) == 0) { || g_strcmp0(scheme, "aesgcm") == 0) {
_url_save_fallback_method(window, url, filename); _url_save_fallback_method(window, 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);

View File

@@ -111,133 +111,133 @@ gboolean cmd_pgp(ProfWin* window, const char* const command, gchar** args);
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
gboolean cmd_ox(ProfWin* window, const char* const command, gchar** args); gboolean cmd_ox(ProfWin* window, const char* const command, gchar** args);
#endif // HAVE_LIBGPGME #endif // HAVE_LIBGPGME
gboolean cmd_outtype(ProfWin *window, const char *const command, gchar **args); gboolean cmd_outtype(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_prefs(ProfWin *window, const char *const command, gchar **args); gboolean cmd_prefs(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_priority(ProfWin *window, const char *const command, gchar **args); gboolean cmd_priority(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_quit(ProfWin *window, const char *const command, gchar **args); gboolean cmd_quit(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_reconnect(ProfWin *window, const char *const command, gchar **args); gboolean cmd_reconnect(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_room(ProfWin *window, const char *const command, gchar **args); gboolean cmd_room(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_rooms(ProfWin *window, const char *const command, gchar **args); gboolean cmd_rooms(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_bookmark(ProfWin *window, const char *const command, gchar **args); gboolean cmd_bookmark(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_bookmark_ignore(ProfWin *window, const char *const command, gchar **args); gboolean cmd_bookmark_ignore(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_roster(ProfWin *window, const char *const command, gchar **args); gboolean cmd_roster(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_software(ProfWin *window, const char *const command, gchar **args); gboolean cmd_software(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_splash(ProfWin *window, const char *const command, gchar **args); gboolean cmd_splash(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_states(ProfWin *window, const char *const command, gchar **args); gboolean cmd_states(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_status_get(ProfWin *window, const char *const command, gchar **args); gboolean cmd_status_get(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_status_set(ProfWin *window, const char *const command, gchar **args); gboolean cmd_status_set(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_sub(ProfWin *window, const char *const command, gchar **args); gboolean cmd_sub(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_theme(ProfWin *window, const char *const command, gchar **args); gboolean cmd_theme(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_tiny(ProfWin *window, const char *const command, gchar **args); gboolean cmd_tiny(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_wintitle(ProfWin *window, const char *const command, gchar **args); gboolean cmd_wintitle(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_vercheck(ProfWin *window, const char *const command, gchar **args); gboolean cmd_vercheck(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_who(ProfWin *window, const char *const command, gchar **args); gboolean cmd_who(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_win(ProfWin *window, const char *const command, gchar **args); gboolean cmd_win(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_alias(ProfWin *window, const char *const command, gchar **args); gboolean cmd_alias(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_xmlconsole(ProfWin *window, const char *const command, gchar **args); gboolean cmd_xmlconsole(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_ping(ProfWin *window, const char *const command, gchar **args); gboolean cmd_ping(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_form(ProfWin *window, const char *const command, gchar **args); gboolean cmd_form(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_occupants(ProfWin *window, const char *const command, gchar **args); gboolean cmd_occupants(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_kick(ProfWin *window, const char *const command, gchar **args); gboolean cmd_kick(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_ban(ProfWin *window, const char *const command, gchar **args); gboolean cmd_ban(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_subject(ProfWin *window, const char *const command, gchar **args); gboolean cmd_subject(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_affiliation(ProfWin *window, const char *const command, gchar **args); gboolean cmd_affiliation(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_role(ProfWin *window, const char *const command, gchar **args); gboolean cmd_role(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_privileges(ProfWin *window, const char *const command, gchar **args); gboolean cmd_privileges(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_presence(ProfWin *window, const char *const command, gchar **args); gboolean cmd_presence(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_wrap(ProfWin *window, const char *const command, gchar **args); gboolean cmd_wrap(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_time(ProfWin *window, const char *const command, gchar **args); gboolean cmd_time(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_resource(ProfWin *window, const char *const command, gchar **args); gboolean cmd_resource(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_inpblock(ProfWin *window, const char *const command, gchar **args); gboolean cmd_inpblock(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_titlebar(ProfWin *window, const char *const command, gchar **args); gboolean cmd_titlebar(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args); gboolean cmd_titlebar_show_hide(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_mainwin(ProfWin *window, const char *const command, gchar **args); gboolean cmd_mainwin(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_statusbar(ProfWin *window, const char *const command, gchar **args); gboolean cmd_statusbar(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_inputwin(ProfWin *window, const char *const command, gchar **args); gboolean cmd_inputwin(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_script(ProfWin *window, const char *const command, gchar **args); gboolean cmd_script(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_export(ProfWin *window, const char *const command, gchar **args); gboolean cmd_export(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_charset(ProfWin *window, const char *const command, gchar **args); gboolean cmd_charset(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_console(ProfWin *window, const char *const command, gchar **args); gboolean cmd_console(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_command_list(ProfWin *window, const char *const command, gchar **args); gboolean cmd_command_list(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_command_exec(ProfWin *window, const char *const command, gchar **args); gboolean cmd_command_exec(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_plugins(ProfWin *window, const char *const command, gchar **args); gboolean cmd_plugins(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_plugins_sourcepath(ProfWin *window, const char *const command, gchar **args); gboolean cmd_plugins_sourcepath(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_plugins_install(ProfWin *window, const char *const command, gchar **args); gboolean cmd_plugins_install(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_plugins_update(ProfWin *window, const char *const command, gchar **args); gboolean cmd_plugins_update(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_plugins_uninstall(ProfWin *window, const char *const command, gchar **args); gboolean cmd_plugins_uninstall(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_plugins_load(ProfWin *window, const char *const command, gchar **args); gboolean cmd_plugins_load(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_plugins_unload(ProfWin *window, const char *const command, gchar **args); gboolean cmd_plugins_unload(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_plugins_reload(ProfWin *window, const char *const command, gchar **args); gboolean cmd_plugins_reload(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_plugins_python_version(ProfWin *window, const char *const command, gchar **args); gboolean cmd_plugins_python_version(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_blocked(ProfWin *window, const char *const command, gchar **args); gboolean cmd_blocked(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_account(ProfWin *window, const char *const command, gchar **args); gboolean cmd_account(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_account_list(ProfWin *window, const char *const command, gchar **args); gboolean cmd_account_list(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_account_show(ProfWin *window, const char *const command, gchar **args); gboolean cmd_account_show(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_account_add(ProfWin *window, const char *const command, gchar **args); gboolean cmd_account_add(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_account_remove(ProfWin *window, const char *const command, gchar **args); gboolean cmd_account_remove(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_account_enable(ProfWin *window, const char *const command, gchar **args); gboolean cmd_account_enable(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_account_disable(ProfWin *window, const char *const command, gchar **args); gboolean cmd_account_disable(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_account_rename(ProfWin *window, const char *const command, gchar **args); gboolean cmd_account_rename(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_account_default(ProfWin *window, const char *const command, gchar **args); gboolean cmd_account_default(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_account_set(ProfWin *window, const char *const command, gchar **args); gboolean cmd_account_set(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_account_clear(ProfWin *window, const char *const command, gchar **args); gboolean cmd_account_clear(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_tls_certpath(ProfWin *window, const char *const command, gchar **args); gboolean cmd_tls_certpath(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_tls_trust(ProfWin *window, const char *const command, gchar **args); gboolean cmd_tls_trust(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_tls_trusted(ProfWin *window, const char *const command, gchar **args); gboolean cmd_tls_trusted(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_tls_revoke(ProfWin *window, const char *const command, gchar **args); gboolean cmd_tls_revoke(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_tls_cert(ProfWin *window, const char *const command, gchar **args); gboolean cmd_tls_cert(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_otr_char(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_char(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_otr_log(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_log(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_otr_libver(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_libver(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_otr_policy(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_policy(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_otr_gen(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_gen(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_otr_myfp(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_myfp(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_otr_theirfp(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_theirfp(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_otr_start(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_start(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_otr_end(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_end(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_otr_trust(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_trust(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_otr_untrust(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_untrust(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_otr_secret(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_secret(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_otr_question(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_question(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_otr_answer(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_answer(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_otr_sendfile(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_sendfile(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_wins(ProfWin *window, const char *const command, gchar **args); gboolean cmd_wins(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_wins_unread(ProfWin *window, const char *const command, gchar **args); gboolean cmd_wins_unread(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_wins_prune(ProfWin *window, const char *const command, gchar **args); gboolean cmd_wins_prune(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_wins_swap(ProfWin *window, const char *const command, gchar **args); gboolean cmd_wins_swap(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_form_field(ProfWin *window, char *tag, gchar **args); gboolean cmd_form_field(ProfWin* window, char* tag, gchar** args);
gboolean cmd_omemo_gen(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_gen(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_omemo_char(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_char(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_omemo_log(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_log(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_omemo_start(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_start(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_omemo_end(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_end(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_fingerprint(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_trust(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_untrust(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_omemo_policy(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_policy(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_omemo_clear_device_list(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_clear_device_list(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_save(ProfWin *window, const char *const command, gchar **args); gboolean cmd_save(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_reload(ProfWin *window, const char *const command, gchar **args); gboolean cmd_reload(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_paste(ProfWin *window, const char *const command, gchar **args); gboolean cmd_paste(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_color(ProfWin *window, const char *const command, gchar **args); gboolean cmd_color(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_avatar(ProfWin *window, const char *const command, gchar **args); gboolean cmd_avatar(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_os(ProfWin *window, const char *const command, gchar **args); gboolean cmd_os(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_correction(ProfWin *window, const char *const command, gchar **args); gboolean cmd_correction(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_correct(ProfWin *window, const char *const command, gchar **args); gboolean cmd_correct(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_slashguard(ProfWin *window, const char *const command, gchar **args); 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(ProfWin* window, const char* const command, gchar** args);
#endif #endif

View File

@@ -1790,145 +1790,144 @@ _save_prefs(void)
static const char* static const char*
_get_group(preference_t pref) _get_group(preference_t pref)
{ {
switch (pref) switch (pref) {
{ case PREF_CLEAR_PERSIST_HISTORY:
case PREF_CLEAR_PERSIST_HISTORY: case PREF_SPLASH:
case PREF_SPLASH: case PREF_BEEP:
case PREF_BEEP: case PREF_THEME:
case PREF_THEME: case PREF_VERCHECK:
case PREF_VERCHECK: case PREF_WINTITLE_SHOW:
case PREF_WINTITLE_SHOW: case PREF_WINTITLE_GOODBYE:
case PREF_WINTITLE_GOODBYE: case PREF_FLASH:
case PREF_FLASH: case PREF_INTYPE:
case PREF_INTYPE: case PREF_HISTORY:
case PREF_HISTORY: case PREF_OCCUPANTS:
case PREF_OCCUPANTS: case PREF_OCCUPANTS_JID:
case PREF_OCCUPANTS_JID: case PREF_OCCUPANTS_WRAP:
case PREF_OCCUPANTS_WRAP: case PREF_STATUSES:
case PREF_STATUSES: case PREF_STATUSES_CONSOLE:
case PREF_STATUSES_CONSOLE: case PREF_STATUSES_CHAT:
case PREF_STATUSES_CHAT: case PREF_STATUSES_MUC:
case PREF_STATUSES_MUC: case PREF_MUC_PRIVILEGES:
case PREF_MUC_PRIVILEGES: case PREF_PRESENCE:
case PREF_PRESENCE: case PREF_WRAP:
case PREF_WRAP: case PREF_TIME_CONSOLE:
case PREF_TIME_CONSOLE: case PREF_TIME_CHAT:
case PREF_TIME_CHAT: case PREF_TIME_MUC:
case PREF_TIME_MUC: case PREF_TIME_CONFIG:
case PREF_TIME_CONFIG: case PREF_TIME_PRIVATE:
case PREF_TIME_PRIVATE: case PREF_TIME_XMLCONSOLE:
case PREF_TIME_XMLCONSOLE: case PREF_TIME_STATUSBAR:
case PREF_TIME_STATUSBAR: case PREF_TIME_LASTACTIVITY:
case PREF_TIME_LASTACTIVITY: case PREF_ROSTER:
case PREF_ROSTER: case PREF_ROSTER_OFFLINE:
case PREF_ROSTER_OFFLINE: case PREF_ROSTER_RESOURCE:
case PREF_ROSTER_RESOURCE: case PREF_ROSTER_PRESENCE:
case PREF_ROSTER_PRESENCE: case PREF_ROSTER_STATUS:
case PREF_ROSTER_STATUS: case PREF_ROSTER_EMPTY:
case PREF_ROSTER_EMPTY: case PREF_ROSTER_BY:
case PREF_ROSTER_BY: case PREF_ROSTER_ORDER:
case PREF_ROSTER_ORDER: case PREF_ROSTER_UNREAD:
case PREF_ROSTER_UNREAD: case PREF_ROSTER_COUNT:
case PREF_ROSTER_COUNT: case PREF_ROSTER_COUNT_ZERO:
case PREF_ROSTER_COUNT_ZERO: case PREF_ROSTER_PRIORITY:
case PREF_ROSTER_PRIORITY: case PREF_ROSTER_WRAP:
case PREF_ROSTER_WRAP: case PREF_ROSTER_RESOURCE_JOIN:
case PREF_ROSTER_RESOURCE_JOIN: case PREF_ROSTER_CONTACTS:
case PREF_ROSTER_CONTACTS: case PREF_ROSTER_UNSUBSCRIBED:
case PREF_ROSTER_UNSUBSCRIBED: case PREF_ROSTER_ROOMS:
case PREF_ROSTER_ROOMS: case PREF_ROSTER_ROOMS_POS:
case PREF_ROSTER_ROOMS_POS: case PREF_ROSTER_ROOMS_BY:
case PREF_ROSTER_ROOMS_BY: case PREF_ROSTER_ROOMS_ORDER:
case PREF_ROSTER_ROOMS_ORDER: case PREF_ROSTER_ROOMS_UNREAD:
case PREF_ROSTER_ROOMS_UNREAD: case PREF_ROSTER_ROOMS_SERVER:
case PREF_ROSTER_ROOMS_SERVER: case PREF_ROSTER_ROOMS_USE_AS_NAME:
case PREF_ROSTER_ROOMS_USE_AS_NAME: case PREF_ROSTER_PRIVATE:
case PREF_ROSTER_PRIVATE: case PREF_RESOURCE_TITLE:
case PREF_RESOURCE_TITLE: case PREF_RESOURCE_MESSAGE:
case PREF_RESOURCE_MESSAGE: case PREF_ENC_WARN:
case PREF_ENC_WARN: case PREF_INPBLOCK_DYNAMIC:
case PREF_INPBLOCK_DYNAMIC: case PREF_TLS_SHOW:
case PREF_TLS_SHOW: case PREF_CONSOLE_MUC:
case PREF_CONSOLE_MUC: case PREF_CONSOLE_PRIVATE:
case PREF_CONSOLE_PRIVATE: case PREF_CONSOLE_CHAT:
case PREF_CONSOLE_CHAT: case PREF_COLOR_NICK:
case PREF_COLOR_NICK: case PREF_COLOR_NICK_OWN:
case PREF_COLOR_NICK_OWN: case PREF_ROSTER_COLOR_NICK:
case PREF_ROSTER_COLOR_NICK: case PREF_OCCUPANTS_COLOR_NICK:
case PREF_OCCUPANTS_COLOR_NICK: case PREF_STATUSBAR_SHOW_NAME:
case PREF_STATUSBAR_SHOW_NAME: case PREF_STATUSBAR_SHOW_NUMBER:
case PREF_STATUSBAR_SHOW_NUMBER: case PREF_STATUSBAR_SHOW_READ:
case PREF_STATUSBAR_SHOW_READ: case PREF_STATUSBAR_SELF:
case PREF_STATUSBAR_SELF: case PREF_STATUSBAR_CHAT:
case PREF_STATUSBAR_CHAT: case PREF_STATUSBAR_ROOM:
case PREF_STATUSBAR_ROOM: case PREF_TITLEBAR_MUC_TITLE_JID:
case PREF_TITLEBAR_MUC_TITLE_JID: case PREF_TITLEBAR_MUC_TITLE_NAME:
case PREF_TITLEBAR_MUC_TITLE_NAME: case PREF_SLASH_GUARD:
case PREF_SLASH_GUARD: return PREF_GROUP_UI;
return PREF_GROUP_UI; case PREF_STATES:
case PREF_STATES: case PREF_OUTTYPE:
case PREF_OUTTYPE: return PREF_GROUP_CHATSTATES;
return PREF_GROUP_CHATSTATES; case PREF_NOTIFY_TYPING:
case PREF_NOTIFY_TYPING: case PREF_NOTIFY_TYPING_CURRENT:
case PREF_NOTIFY_TYPING_CURRENT: case PREF_NOTIFY_CHAT:
case PREF_NOTIFY_CHAT: case PREF_NOTIFY_CHAT_CURRENT:
case PREF_NOTIFY_CHAT_CURRENT: case PREF_NOTIFY_CHAT_TEXT:
case PREF_NOTIFY_CHAT_TEXT: case PREF_NOTIFY_ROOM:
case PREF_NOTIFY_ROOM: case PREF_NOTIFY_ROOM_MENTION:
case PREF_NOTIFY_ROOM_MENTION: case PREF_NOTIFY_ROOM_TRIGGER:
case PREF_NOTIFY_ROOM_TRIGGER: case PREF_NOTIFY_ROOM_CURRENT:
case PREF_NOTIFY_ROOM_CURRENT: case PREF_NOTIFY_ROOM_TEXT:
case PREF_NOTIFY_ROOM_TEXT: case PREF_NOTIFY_INVITE:
case PREF_NOTIFY_INVITE: case PREF_NOTIFY_SUB:
case PREF_NOTIFY_SUB: case PREF_NOTIFY_MENTION_CASE_SENSITIVE:
case PREF_NOTIFY_MENTION_CASE_SENSITIVE: case PREF_NOTIFY_MENTION_WHOLE_WORD:
case PREF_NOTIFY_MENTION_WHOLE_WORD: case PREF_TRAY:
case PREF_TRAY: case PREF_TRAY_READ:
case PREF_TRAY_READ: case PREF_ADV_NOTIFY_DISCO_OR_VERSION:
case PREF_ADV_NOTIFY_DISCO_OR_VERSION: return PREF_GROUP_NOTIFICATIONS;
return PREF_GROUP_NOTIFICATIONS; case PREF_CHLOG:
case PREF_CHLOG: case PREF_GRLOG:
case PREF_GRLOG: case PREF_LOG_ROTATE:
case PREF_LOG_ROTATE: case PREF_LOG_SHARED:
case PREF_LOG_SHARED: return PREF_GROUP_LOGGING;
return PREF_GROUP_LOGGING; case PREF_AVATAR_CMD:
case PREF_AVATAR_CMD: case PREF_URL_OPEN_CMD:
case PREF_URL_OPEN_CMD: case PREF_URL_SAVE_CMD:
case PREF_URL_SAVE_CMD: return PREF_GROUP_EXECUTABLES;
return PREF_GROUP_EXECUTABLES; case PREF_AUTOAWAY_CHECK:
case PREF_AUTOAWAY_CHECK: case PREF_AUTOAWAY_MODE:
case PREF_AUTOAWAY_MODE: case PREF_AUTOAWAY_MESSAGE:
case PREF_AUTOAWAY_MESSAGE: case PREF_AUTOXA_MESSAGE:
case PREF_AUTOXA_MESSAGE: case PREF_LASTACTIVITY:
case PREF_LASTACTIVITY: return PREF_GROUP_PRESENCE;
return PREF_GROUP_PRESENCE; case PREF_CONNECT_ACCOUNT:
case PREF_CONNECT_ACCOUNT: case PREF_DEFAULT_ACCOUNT:
case PREF_DEFAULT_ACCOUNT: case PREF_CARBONS:
case PREF_CARBONS: case PREF_RECEIPTS_SEND:
case PREF_RECEIPTS_SEND: case PREF_RECEIPTS_REQUEST:
case PREF_RECEIPTS_REQUEST: case PREF_REVEAL_OS:
case PREF_REVEAL_OS: case PREF_TLS_CERTPATH:
case PREF_TLS_CERTPATH: case PREF_CORRECTION_ALLOW:
case PREF_CORRECTION_ALLOW: case PREF_MAM:
case PREF_MAM: return PREF_GROUP_CONNECTION;
return PREF_GROUP_CONNECTION; case PREF_OTR_LOG:
case PREF_OTR_LOG: case PREF_OTR_POLICY:
case PREF_OTR_POLICY: case PREF_OTR_SENDFILE:
case PREF_OTR_SENDFILE: return PREF_GROUP_OTR;
return PREF_GROUP_OTR; case PREF_PGP_LOG:
case PREF_PGP_LOG: case PREF_PGP_SENDFILE:
case PREF_PGP_SENDFILE: return PREF_GROUP_PGP;
return PREF_GROUP_PGP; case PREF_BOOKMARK_INVITE:
case PREF_BOOKMARK_INVITE: case PREF_ROOM_LIST_CACHE:
case PREF_ROOM_LIST_CACHE: return PREF_GROUP_MUC;
return PREF_GROUP_MUC; case PREF_PLUGINS_SOURCEPATH:
case PREF_PLUGINS_SOURCEPATH: return PREF_GROUP_PLUGINS;
return PREF_GROUP_PLUGINS; case PREF_OMEMO_LOG:
case PREF_OMEMO_LOG: case PREF_OMEMO_POLICY:
case PREF_OMEMO_POLICY: return PREF_GROUP_OMEMO;
return PREF_GROUP_OMEMO; default:
default: return NULL;
return NULL;
} }
} }
@@ -1937,256 +1936,255 @@ _get_group(preference_t pref)
static const char* static const char*
_get_key(preference_t pref) _get_key(preference_t pref)
{ {
switch (pref) switch (pref) {
{ case PREF_CLEAR_PERSIST_HISTORY:
case PREF_CLEAR_PERSIST_HISTORY: return "clear.persist_history";
return "clear.persist_history"; case PREF_SPLASH:
case PREF_SPLASH: return "splash";
return "splash"; case PREF_BEEP:
case PREF_BEEP: return "beep";
return "beep"; case PREF_THEME:
case PREF_THEME: return "theme";
return "theme"; case PREF_VERCHECK:
case PREF_VERCHECK: return "vercheck";
return "vercheck"; case PREF_WINTITLE_SHOW:
case PREF_WINTITLE_SHOW: return "wintitle.show";
return "wintitle.show"; case PREF_WINTITLE_GOODBYE:
case PREF_WINTITLE_GOODBYE: return "wintitle.goodbye";
return "wintitle.goodbye"; case PREF_FLASH:
case PREF_FLASH: return "flash";
return "flash"; case PREF_TRAY:
case PREF_TRAY: return "tray";
return "tray"; case PREF_TRAY_READ:
case PREF_TRAY_READ: return "tray.read";
return "tray.read"; case PREF_ADV_NOTIFY_DISCO_OR_VERSION:
case PREF_ADV_NOTIFY_DISCO_OR_VERSION: return "adv.notify.discoversion";
return "adv.notify.discoversion"; case PREF_INTYPE:
case PREF_INTYPE: return "intype";
return "intype"; case PREF_HISTORY:
case PREF_HISTORY: return "history";
return "history"; case PREF_CARBONS:
case PREF_CARBONS: return "carbons";
return "carbons"; case PREF_RECEIPTS_SEND:
case PREF_RECEIPTS_SEND: return "receipts.send";
return "receipts.send"; case PREF_RECEIPTS_REQUEST:
case PREF_RECEIPTS_REQUEST: return "receipts.request";
return "receipts.request"; case PREF_REVEAL_OS:
case PREF_REVEAL_OS: return "reveal.os";
return "reveal.os"; case PREF_OCCUPANTS:
case PREF_OCCUPANTS: return "occupants";
return "occupants"; case PREF_OCCUPANTS_JID:
case PREF_OCCUPANTS_JID: return "occupants.jid";
return "occupants.jid"; case PREF_OCCUPANTS_WRAP:
case PREF_OCCUPANTS_WRAP: return "occupants.wrap";
return "occupants.wrap"; case PREF_MUC_PRIVILEGES:
case PREF_MUC_PRIVILEGES: return "privileges";
return "privileges"; case PREF_STATUSES:
case PREF_STATUSES: return "statuses";
return "statuses"; case PREF_STATUSES_CONSOLE:
case PREF_STATUSES_CONSOLE: return "statuses.console";
return "statuses.console"; case PREF_STATUSES_CHAT:
case PREF_STATUSES_CHAT: return "statuses.chat";
return "statuses.chat"; case PREF_STATUSES_MUC:
case PREF_STATUSES_MUC: return "statuses.muc";
return "statuses.muc"; case PREF_STATES:
case PREF_STATES: return "enabled";
return "enabled"; case PREF_OUTTYPE:
case PREF_OUTTYPE: return "outtype";
return "outtype"; case PREF_NOTIFY_TYPING:
case PREF_NOTIFY_TYPING: return "typing";
return "typing"; case PREF_NOTIFY_TYPING_CURRENT:
case PREF_NOTIFY_TYPING_CURRENT: return "typing.current";
return "typing.current"; case PREF_NOTIFY_CHAT:
case PREF_NOTIFY_CHAT: return "message";
return "message"; case PREF_NOTIFY_CHAT_CURRENT:
case PREF_NOTIFY_CHAT_CURRENT: return "message.current";
return "message.current"; case PREF_NOTIFY_CHAT_TEXT:
case PREF_NOTIFY_CHAT_TEXT: return "message.text";
return "message.text"; case PREF_NOTIFY_ROOM:
case PREF_NOTIFY_ROOM: return "room";
return "room"; case PREF_NOTIFY_ROOM_TRIGGER:
case PREF_NOTIFY_ROOM_TRIGGER: return "room.trigger";
return "room.trigger"; case PREF_NOTIFY_ROOM_MENTION:
case PREF_NOTIFY_ROOM_MENTION: return "room.mention";
return "room.mention"; case PREF_NOTIFY_ROOM_CURRENT:
case PREF_NOTIFY_ROOM_CURRENT: return "room.current";
return "room.current"; case PREF_NOTIFY_ROOM_TEXT:
case PREF_NOTIFY_ROOM_TEXT: return "room.text";
return "room.text"; case PREF_NOTIFY_INVITE:
case PREF_NOTIFY_INVITE: return "invite";
return "invite"; case PREF_NOTIFY_SUB:
case PREF_NOTIFY_SUB: return "sub";
return "sub"; case PREF_NOTIFY_MENTION_CASE_SENSITIVE:
case PREF_NOTIFY_MENTION_CASE_SENSITIVE: return "room.mention.casesensitive";
return "room.mention.casesensitive"; case PREF_NOTIFY_MENTION_WHOLE_WORD:
case PREF_NOTIFY_MENTION_WHOLE_WORD: return "room.mention.wholeword";
return "room.mention.wholeword"; case PREF_CHLOG:
case PREF_CHLOG: return "chlog";
return "chlog"; case PREF_GRLOG:
case PREF_GRLOG: return "grlog";
return "grlog"; case PREF_AUTOAWAY_CHECK:
case PREF_AUTOAWAY_CHECK: return "autoaway.check";
return "autoaway.check"; case PREF_AUTOAWAY_MODE:
case PREF_AUTOAWAY_MODE: return "autoaway.mode";
return "autoaway.mode"; case PREF_AUTOAWAY_MESSAGE:
case PREF_AUTOAWAY_MESSAGE: return "autoaway.awaymessage";
return "autoaway.awaymessage"; case PREF_AUTOXA_MESSAGE:
case PREF_AUTOXA_MESSAGE: return "autoaway.xamessage";
return "autoaway.xamessage"; case PREF_CONNECT_ACCOUNT:
case PREF_CONNECT_ACCOUNT: return "account";
return "account"; case PREF_DEFAULT_ACCOUNT:
case PREF_DEFAULT_ACCOUNT: return "defaccount";
return "defaccount"; case PREF_OTR_LOG:
case PREF_OTR_LOG: return "log";
return "log"; case PREF_OTR_POLICY:
case PREF_OTR_POLICY: return "policy";
return "policy"; case PREF_OTR_SENDFILE:
case PREF_OTR_SENDFILE: return "sendfile";
return "sendfile"; case PREF_LOG_ROTATE:
case PREF_LOG_ROTATE: return "rotate";
return "rotate"; case PREF_LOG_SHARED:
case PREF_LOG_SHARED: return "shared";
return "shared"; case PREF_PRESENCE:
case PREF_PRESENCE: return "presence";
return "presence"; case PREF_WRAP:
case PREF_WRAP: return "wrap";
return "wrap"; case PREF_TIME_CONSOLE:
case PREF_TIME_CONSOLE: return "time.console";
return "time.console"; case PREF_TIME_CHAT:
case PREF_TIME_CHAT: return "time.chat";
return "time.chat"; case PREF_TIME_MUC:
case PREF_TIME_MUC: return "time.muc";
return "time.muc"; case PREF_TIME_CONFIG:
case PREF_TIME_CONFIG: return "time.config";
return "time.config"; case PREF_TIME_PRIVATE:
case PREF_TIME_PRIVATE: return "time.private";
return "time.private"; case PREF_TIME_XMLCONSOLE:
case PREF_TIME_XMLCONSOLE: return "time.xmlconsole";
return "time.xmlconsole"; case PREF_TIME_STATUSBAR:
case PREF_TIME_STATUSBAR: return "time.statusbar";
return "time.statusbar"; case PREF_TIME_LASTACTIVITY:
case PREF_TIME_LASTACTIVITY: return "time.lastactivity";
return "time.lastactivity"; case PREF_ROSTER:
case PREF_ROSTER: return "roster";
return "roster"; case PREF_ROSTER_OFFLINE:
case PREF_ROSTER_OFFLINE: return "roster.offline";
return "roster.offline"; case PREF_ROSTER_RESOURCE:
case PREF_ROSTER_RESOURCE: return "roster.resource";
return "roster.resource"; case PREF_ROSTER_PRESENCE:
case PREF_ROSTER_PRESENCE: return "roster.presence";
return "roster.presence"; case PREF_ROSTER_STATUS:
case PREF_ROSTER_STATUS: return "roster.status";
return "roster.status"; case PREF_ROSTER_EMPTY:
case PREF_ROSTER_EMPTY: return "roster.empty";
return "roster.empty"; case PREF_ROSTER_BY:
case PREF_ROSTER_BY: return "roster.by";
return "roster.by"; case PREF_ROSTER_ORDER:
case PREF_ROSTER_ORDER: return "roster.order";
return "roster.order"; case PREF_ROSTER_UNREAD:
case PREF_ROSTER_UNREAD: return "roster.unread";
return "roster.unread"; case PREF_ROSTER_COUNT:
case PREF_ROSTER_COUNT: return "roster.count";
return "roster.count"; case PREF_ROSTER_COUNT_ZERO:
case PREF_ROSTER_COUNT_ZERO: return "roster.count.zero";
return "roster.count.zero"; case PREF_ROSTER_PRIORITY:
case PREF_ROSTER_PRIORITY: return "roster.priority";
return "roster.priority"; case PREF_ROSTER_WRAP:
case PREF_ROSTER_WRAP: return "roster.wrap";
return "roster.wrap"; case PREF_ROSTER_RESOURCE_JOIN:
case PREF_ROSTER_RESOURCE_JOIN: return "roster.resource.join";
return "roster.resource.join"; case PREF_ROSTER_CONTACTS:
case PREF_ROSTER_CONTACTS: return "roster.contacts";
return "roster.contacts"; case PREF_ROSTER_UNSUBSCRIBED:
case PREF_ROSTER_UNSUBSCRIBED: return "roster.unsubscribed";
return "roster.unsubscribed"; case PREF_ROSTER_ROOMS:
case PREF_ROSTER_ROOMS: return "roster.rooms";
return "roster.rooms"; case PREF_ROSTER_ROOMS_POS:
case PREF_ROSTER_ROOMS_POS: return "roster.rooms.pos";
return "roster.rooms.pos"; case PREF_ROSTER_ROOMS_BY:
case PREF_ROSTER_ROOMS_BY: return "roster.rooms.by";
return "roster.rooms.by"; case PREF_ROSTER_ROOMS_ORDER:
case PREF_ROSTER_ROOMS_ORDER: return "roster.rooms.order";
return "roster.rooms.order"; case PREF_ROSTER_ROOMS_UNREAD:
case PREF_ROSTER_ROOMS_UNREAD: return "roster.rooms.unread";
return "roster.rooms.unread"; case PREF_ROSTER_ROOMS_SERVER:
case PREF_ROSTER_ROOMS_SERVER: return "roster.rooms.server";
return "roster.rooms.server"; case PREF_ROSTER_ROOMS_USE_AS_NAME:
case PREF_ROSTER_ROOMS_USE_AS_NAME: return "roster.rooms.use.name";
return "roster.rooms.use.name"; case PREF_ROSTER_PRIVATE:
case PREF_ROSTER_PRIVATE: return "roster.private";
return "roster.private"; case PREF_RESOURCE_TITLE:
case PREF_RESOURCE_TITLE: return "resource.title";
return "resource.title"; case PREF_RESOURCE_MESSAGE:
case PREF_RESOURCE_MESSAGE: return "resource.message";
return "resource.message"; case PREF_INPBLOCK_DYNAMIC:
case PREF_INPBLOCK_DYNAMIC: return "inpblock.dynamic";
return "inpblock.dynamic"; case PREF_ENC_WARN:
case PREF_ENC_WARN: return "enc.warn";
return "enc.warn"; case PREF_TITLEBAR_MUC_TITLE_JID:
case PREF_TITLEBAR_MUC_TITLE_JID: return "titlebar.muc.title.jid";
return "titlebar.muc.title.jid"; case PREF_TITLEBAR_MUC_TITLE_NAME:
case PREF_TITLEBAR_MUC_TITLE_NAME: return "titlebar.muc.title.name";
return "titlebar.muc.title.name"; case PREF_PGP_LOG:
case PREF_PGP_LOG: return "log";
return "log"; case PREF_PGP_SENDFILE:
case PREF_PGP_SENDFILE: return "sendfile";
return "sendfile"; case PREF_TLS_CERTPATH:
case PREF_TLS_CERTPATH: return "tls.certpath";
return "tls.certpath"; case PREF_TLS_SHOW:
case PREF_TLS_SHOW: return "tls.show";
return "tls.show"; case PREF_LASTACTIVITY:
case PREF_LASTACTIVITY: return "lastactivity";
return "lastactivity"; case PREF_CONSOLE_MUC:
case PREF_CONSOLE_MUC: return "console.muc";
return "console.muc"; case PREF_CONSOLE_PRIVATE:
case PREF_CONSOLE_PRIVATE: return "console.private";
return "console.private"; case PREF_CONSOLE_CHAT:
case PREF_CONSOLE_CHAT: return "console.chat";
return "console.chat"; case PREF_COLOR_NICK:
case PREF_COLOR_NICK: return "color.nick";
return "color.nick"; case PREF_COLOR_NICK_OWN:
case PREF_COLOR_NICK_OWN: return "color.nick.own";
return "color.nick.own"; case PREF_ROSTER_COLOR_NICK:
case PREF_ROSTER_COLOR_NICK: return "color.roster.nick";
return "color.roster.nick"; case PREF_OCCUPANTS_COLOR_NICK:
case PREF_OCCUPANTS_COLOR_NICK: return "color.occupants.nick";
return "color.occupants.nick"; case PREF_BOOKMARK_INVITE:
case PREF_BOOKMARK_INVITE: return "bookmark.invite";
return "bookmark.invite"; case PREF_PLUGINS_SOURCEPATH:
case PREF_PLUGINS_SOURCEPATH: return "sourcepath";
return "sourcepath"; case PREF_ROOM_LIST_CACHE:
case PREF_ROOM_LIST_CACHE: return "rooms.cache";
return "rooms.cache"; case PREF_STATUSBAR_SHOW_NAME:
case PREF_STATUSBAR_SHOW_NAME: return "statusbar.show.name";
return "statusbar.show.name"; case PREF_STATUSBAR_SHOW_NUMBER:
case PREF_STATUSBAR_SHOW_NUMBER: return "statusbar.show.number";
return "statusbar.show.number"; case PREF_STATUSBAR_SHOW_READ:
case PREF_STATUSBAR_SHOW_READ: return "statusbar.show.read";
return "statusbar.show.read"; case PREF_STATUSBAR_SELF:
case PREF_STATUSBAR_SELF: return "statusbar.self";
return "statusbar.self"; case PREF_STATUSBAR_CHAT:
case PREF_STATUSBAR_CHAT: return "statusbar.chat";
return "statusbar.chat"; case PREF_STATUSBAR_ROOM:
case PREF_STATUSBAR_ROOM: return "statusbar.room";
return "statusbar.room"; case PREF_OMEMO_LOG:
case PREF_OMEMO_LOG: return "log";
return "log"; case PREF_OMEMO_POLICY:
case PREF_OMEMO_POLICY: return "policy";
return "policy"; case PREF_CORRECTION_ALLOW:
case PREF_CORRECTION_ALLOW: return "correction.allow";
return "correction.allow"; case PREF_AVATAR_CMD:
case PREF_AVATAR_CMD: return "avatar.cmd";
return "avatar.cmd"; case PREF_SLASH_GUARD:
case PREF_SLASH_GUARD: return "slashguard";
return "slashguard"; case PREF_MAM:
case PREF_MAM: return "mam";
return "mam"; case PREF_URL_OPEN_CMD:
case PREF_URL_OPEN_CMD: return "url.open.cmd";
return "url.open.cmd"; case PREF_URL_SAVE_CMD:
case PREF_URL_SAVE_CMD: return "url.save.cmd";
return "url.save.cmd"; default:
default: return NULL;
return NULL;
} }
} }

View File

@@ -41,7 +41,7 @@
#include "omemo/omemo.h" #include "omemo/omemo.h"
#include "omemo/crypto.h" #include "omemo/crypto.h"
#define AES256_GCM_TAG_LENGTH 16 #define AES256_GCM_TAG_LENGTH 16
#define AES256_GCM_BUFFER_SIZE 1024 #define AES256_GCM_BUFFER_SIZE 1024
int int
@@ -377,8 +377,10 @@ out:
return res; return res;
} }
int aes256gcm_crypt_file(FILE *in, FILE *out, off_t file_size, int
unsigned char key[], unsigned char nonce[], bool encrypt) { aes256gcm_crypt_file(FILE* in, FILE* out, off_t file_size,
unsigned char key[], unsigned char nonce[], bool encrypt)
{
if (!gcry_control(GCRYCTL_INITIALIZATION_FINISHED_P)) { if (!gcry_control(GCRYCTL_INITIALIZATION_FINISHED_P)) {
fputs("libgcrypt has not been initialized\n", stderr); fputs("libgcrypt has not been initialized\n", stderr);
@@ -393,7 +395,7 @@ int aes256gcm_crypt_file(FILE *in, FILE *out, off_t file_size,
gcry_cipher_hd_t hd; gcry_cipher_hd_t hd;
res = gcry_cipher_open(&hd, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_GCM, res = gcry_cipher_open(&hd, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_GCM,
GCRY_CIPHER_SECURE); GCRY_CIPHER_SECURE);
if (res != GPG_ERR_NO_ERROR) { if (res != GPG_ERR_NO_ERROR) {
goto out; goto out;
} }
@@ -463,18 +465,20 @@ out:
return res; return res;
} }
char *aes256gcm_create_secure_fragment(unsigned char *key, unsigned char *nonce) { char*
aes256gcm_create_secure_fragment(unsigned char* key, unsigned char* nonce)
{
int key_size = AES256_GCM_KEY_LENGTH; int key_size = AES256_GCM_KEY_LENGTH;
int nonce_size = AES256_GCM_NONCE_LENGTH; int nonce_size = AES256_GCM_NONCE_LENGTH;
char *fragment = gcry_malloc_secure((nonce_size+key_size)*2+1); char* fragment = gcry_malloc_secure((nonce_size + key_size) * 2 + 1);
for (int i = 0; i < nonce_size; i++) { for (int i = 0; i < nonce_size; i++) {
sprintf(&(fragment[i*2]), "%02x", nonce[i]); sprintf(&(fragment[i * 2]), "%02x", nonce[i]);
} }
for (int i = 0; i < key_size; i++) { for (int i = 0; i < key_size; i++) {
sprintf(&(fragment[(i+nonce_size)*2]), "%02x", key[i]); sprintf(&(fragment[(i + nonce_size) * 2]), "%02x", key[i]);
} }
return fragment; return fragment;

View File

@@ -40,7 +40,7 @@
#define AES128_GCM_IV_LENGTH 12 #define AES128_GCM_IV_LENGTH 12
#define AES128_GCM_TAG_LENGTH 16 #define AES128_GCM_TAG_LENGTH 16
#define AES256_GCM_KEY_LENGTH 32 #define AES256_GCM_KEY_LENGTH 32
#define AES256_GCM_NONCE_LENGTH 12 #define AES256_GCM_NONCE_LENGTH 12
int omemo_crypto_init(void); int omemo_crypto_init(void);
@@ -181,13 +181,13 @@ int aes128gcm_encrypt(unsigned char* ciphertext, size_t* ciphertext_len,
const unsigned char* const plaintext, size_t plaintext_len, const unsigned char* const plaintext, size_t plaintext_len,
const unsigned char* const iv, const unsigned char* const key); const unsigned char* const iv, const unsigned char* const key);
int aes128gcm_decrypt(unsigned char *plaintext, int aes128gcm_decrypt(unsigned char* plaintext,
size_t *plaintext_len, const unsigned char *const ciphertext, size_t* plaintext_len, const unsigned char* const ciphertext,
size_t ciphertext_len, const unsigned char *const iv, size_t iv_len, size_t ciphertext_len, const unsigned char* const iv, size_t iv_len,
const unsigned char *const key, const unsigned char *const tag); const unsigned char* const key, const unsigned char* const tag);
int aes256gcm_crypt_file(FILE *in, FILE *out, off_t file_size, int aes256gcm_crypt_file(FILE* in, FILE* out, off_t file_size,
unsigned char key[], unsigned char nonce[], bool encrypt); unsigned char key[], unsigned char nonce[], bool encrypt);
char *aes256gcm_create_secure_fragment(unsigned char *key, char* aes256gcm_create_secure_fragment(unsigned char* key,
unsigned char *nonce); unsigned char* nonce);

View File

@@ -1654,13 +1654,16 @@ _generate_signed_pre_key(void)
SIGNAL_UNREF(signed_pre_key); SIGNAL_UNREF(signed_pre_key);
} }
void
void omemo_free(void *a) { omemo_free(void* a)
{
gcry_free(a); gcry_free(a);
} }
char *omemo_encrypt_file(FILE *in, FILE *out, off_t file_size, int *gcry_res) { char*
unsigned char *key = gcry_random_bytes_secure( omemo_encrypt_file(FILE* in, FILE* out, off_t file_size, int* gcry_res)
{
unsigned char* key = gcry_random_bytes_secure(
AES256_GCM_KEY_LENGTH, AES256_GCM_KEY_LENGTH,
GCRY_VERY_STRONG_RANDOM); GCRY_VERY_STRONG_RANDOM);
@@ -1668,7 +1671,7 @@ char *omemo_encrypt_file(FILE *in, FILE *out, off_t file_size, int *gcry_res) {
unsigned char nonce[AES256_GCM_NONCE_LENGTH]; unsigned char nonce[AES256_GCM_NONCE_LENGTH];
gcry_create_nonce(nonce, AES256_GCM_NONCE_LENGTH); gcry_create_nonce(nonce, AES256_GCM_NONCE_LENGTH);
char *fragment = aes256gcm_create_secure_fragment(key, nonce); char* fragment = aes256gcm_create_secure_fragment(key, nonce);
*gcry_res = aes256gcm_crypt_file(in, out, file_size, key, nonce, true); *gcry_res = aes256gcm_crypt_file(in, out, file_size, key, nonce, true);
if (*gcry_res != GPG_ERR_NO_ERROR) { if (*gcry_res != GPG_ERR_NO_ERROR) {

View File

@@ -95,8 +95,8 @@ void omemo_start_muc_sessions(const char* const roomjid);
void omemo_start_device_session(const char* const jid, uint32_t device_id, GList* prekeys, uint32_t signed_prekey_id, const unsigned char* const signed_prekey, size_t signed_prekey_len, const unsigned char* const signature, size_t signature_len, const unsigned char* const identity_key, size_t identity_key_len); void omemo_start_device_session(const char* const jid, uint32_t device_id, GList* prekeys, uint32_t signed_prekey_id, const unsigned char* const signed_prekey, size_t signed_prekey_len, const unsigned char* const signature, size_t signature_len, const unsigned char* const identity_key, size_t identity_key_len);
gboolean omemo_loaded(void); gboolean omemo_loaded(void);
char * omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_receipt, gboolean muc, const char *const replace_id); char* omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_receipt, gboolean muc, const char* const replace_id);
char * omemo_on_message_recv(const char *const from, uint32_t sid, const unsigned char *const iv, size_t iv_len, GList *keys, const unsigned char *const payload, size_t payload_len, gboolean muc, gboolean *trusted); char* omemo_on_message_recv(const char* const from, uint32_t sid, const unsigned char* const iv, size_t iv_len, GList* keys, const unsigned char* const payload, size_t payload_len, gboolean muc, gboolean* trusted);
char *omemo_encrypt_file(FILE *in, FILE *out, off_t file_size, int *gcry_res); char* omemo_encrypt_file(FILE* in, FILE* out, off_t file_size, int* gcry_res);
void omemo_free(void *a); void omemo_free(void* a);

View File

@@ -58,12 +58,12 @@
#define FALLBACK_MSG "" #define FALLBACK_MSG ""
GSList *download_processes = NULL; GSList* download_processes = NULL;
static int static int
_xferinfo(void *userdata, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) _xferinfo(void* userdata, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
{ {
HTTPDownload *download = (HTTPDownload *)userdata; HTTPDownload* download = (HTTPDownload*)userdata;
pthread_mutex_lock(&lock); pthread_mutex_lock(&lock);
@@ -84,7 +84,7 @@ _xferinfo(void *userdata, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultot
dlperc = (100 * dlnow) / dltotal; dlperc = (100 * dlnow) / dltotal;
} }
char *msg; char* msg;
if (asprintf(&msg, "Downloading '%s': %d%%", download->url, dlperc) == -1) { if (asprintf(&msg, "Downloading '%s': %d%%", download->url, dlperc) == -1) {
msg = strdup(FALLBACK_MSG); msg = strdup(FALLBACK_MSG);
} }
@@ -98,20 +98,20 @@ _xferinfo(void *userdata, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultot
#if LIBCURL_VERSION_NUM < 0x072000 #if LIBCURL_VERSION_NUM < 0x072000
static int static int
_older_progress(void *p, double dltotal, double dlnow, double ultotal, double ulnow) _older_progress(void* p, double dltotal, double dlnow, double ultotal, double ulnow)
{ {
return _xferinfo(p, (curl_off_t)dltotal, (curl_off_t)dlnow, (curl_off_t)ultotal, (curl_off_t)ulnow); return _xferinfo(p, (curl_off_t)dltotal, (curl_off_t)dlnow, (curl_off_t)ultotal, (curl_off_t)ulnow);
} }
#endif #endif
void * void*
http_file_get(void *userdata) http_file_get(void* userdata)
{ {
HTTPDownload *download = (HTTPDownload *)userdata; HTTPDownload* download = (HTTPDownload*)userdata;
char *err = NULL; char* err = NULL;
CURL *curl; CURL* curl;
CURLcode res; CURLcode res;
download->cancel = 0; download->cancel = 0;
@@ -125,7 +125,7 @@ http_file_get(void *userdata)
win_print_http_transfer(download->window, msg, download->url); win_print_http_transfer(download->window, msg, download->url);
free(msg); free(msg);
char *cert_path = prefs_get_string(PREF_TLS_CERTPATH); char* cert_path = prefs_get_string(PREF_TLS_CERTPATH);
pthread_mutex_unlock(&lock); pthread_mutex_unlock(&lock);
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
@@ -133,16 +133,16 @@ http_file_get(void *userdata)
curl_easy_setopt(curl, CURLOPT_URL, download->url); curl_easy_setopt(curl, CURLOPT_URL, download->url);
#if LIBCURL_VERSION_NUM >= 0x072000 #if LIBCURL_VERSION_NUM >= 0x072000
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, _xferinfo); curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, _xferinfo);
curl_easy_setopt(curl, CURLOPT_XFERINFODATA, download); curl_easy_setopt(curl, CURLOPT_XFERINFODATA, download);
#else #else
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, _older_progress); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, _older_progress);
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, download); curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, download);
#endif #endif
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)download->filehandle); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)download->filehandle);
curl_easy_setopt(curl, CURLOPT_USERAGENT, "profanity"); curl_easy_setopt(curl, CURLOPT_USERAGENT, "profanity");
@@ -165,7 +165,7 @@ http_file_get(void *userdata)
g_free(cert_path); g_free(cert_path);
if (err) { if (err) {
char *msg; char* msg;
if (download->cancel) { if (download->cancel) {
if (asprintf(&msg, "Downloading '%s' failed: Download was canceled", download->url) == -1) { if (asprintf(&msg, "Downloading '%s' failed: Download was canceled", download->url) == -1) {
msg = strdup(FALLBACK_MSG); msg = strdup(FALLBACK_MSG);
@@ -200,11 +200,11 @@ http_file_get(void *userdata)
} }
void void
http_download_cancel_processes(ProfWin *window) http_download_cancel_processes(ProfWin* window)
{ {
GSList *download_process = download_processes; GSList* download_process = download_processes;
while (download_process) { while (download_process) {
HTTPDownload *download = download_process->data; HTTPDownload* download = download_process->data;
if (download->window == window) { if (download->window == window) {
download->cancel = 1; download->cancel = 1;
break; break;
@@ -214,21 +214,23 @@ http_download_cancel_processes(ProfWin *window)
} }
void void
http_download_add_download(HTTPDownload *download) http_download_add_download(HTTPDownload* download)
{ {
download_processes = g_slist_append(download_processes, download); download_processes = g_slist_append(download_processes, download);
} }
char *http_basename_from_url(const char *url) { char*
const char *default_name = "index.html"; http_basename_from_url(const char* url)
{
const char* default_name = "index.html";
GFile *file = g_file_new_for_uri(url); GFile* file = g_file_new_for_uri(url);
char *filename = g_file_get_basename(file); char* filename = g_file_get_basename(file);
g_object_unref(file); g_object_unref(file);
if (g_strcmp0(filename, ".") == 0 if (g_strcmp0(filename, ".") == 0
|| g_strcmp0(filename, "..") == 0 || g_strcmp0(filename, "..") == 0
|| g_strcmp0(filename, G_DIR_SEPARATOR_S) == 0) { || g_strcmp0(filename, G_DIR_SEPARATOR_S) == 0) {
g_free(filename); g_free(filename);
return strdup(default_name); return strdup(default_name);
} }

View File

@@ -46,20 +46,21 @@
#include "ui/win_types.h" #include "ui/win_types.h"
typedef struct http_download_t { typedef struct http_download_t
char *url; {
FILE *filehandle; char* url;
FILE* filehandle;
curl_off_t bytes_received; curl_off_t bytes_received;
ProfWin *window; ProfWin* window;
pthread_t worker; pthread_t worker;
int cancel; int cancel;
} HTTPDownload; } HTTPDownload;
void* http_file_get(void *userdata); void* http_file_get(void* userdata);
void http_download_cancel_processes(ProfWin *window); void http_download_cancel_processes(ProfWin* window);
void http_download_add_download(HTTPDownload *download); void http_download_add_download(HTTPDownload* download);
char *http_basename_from_url(const char *url); char* http_basename_from_url(const char* url);
#endif #endif

View File

@@ -128,9 +128,11 @@ _data_callback(void* ptr, size_t size, size_t nmemb, void* data)
return realsize; return realsize;
} }
int format_alt_url(char *original_url, char *new_scheme, char *new_fragment, char **new_url) { int
format_alt_url(char* original_url, char* new_scheme, char* new_fragment, char** new_url)
{
int ret = 0; int ret = 0;
CURLU *h = curl_url(); CURLU* h = curl_url();
if ((ret = curl_url_set(h, CURLUPART_URL, original_url, 0)) != 0) { if ((ret = curl_url_set(h, CURLUPART_URL, original_url, 0)) != 0) {
goto out; goto out;
@@ -155,12 +157,12 @@ out:
return ret; return ret;
} }
void * void*
http_file_put(void *userdata) http_file_put(void* userdata)
{ {
HTTPUpload* upload = (HTTPUpload*)userdata; HTTPUpload* upload = (HTTPUpload*)userdata;
FILE *fh = NULL; FILE* fh = NULL;
char* err = NULL; char* err = NULL;
char* content_type_header; char* content_type_header;
@@ -283,10 +285,10 @@ http_file_put(void *userdata)
win_mark_received(upload->window, upload->put_url); win_mark_received(upload->window, upload->put_url);
free(msg); free(msg);
char *url = NULL; char* url = NULL;
if (format_alt_url(upload->get_url, upload->alt_scheme, upload->alt_fragment, &url) != 0) { if (format_alt_url(upload->get_url, upload->alt_scheme, upload->alt_fragment, &url) != 0) {
char *msg; char* msg;
if (asprintf(&msg, "Uploading '%s' failed: Bad URL ('%s')", upload->filename, upload->get_url)== -1) { if (asprintf(&msg, "Uploading '%s' failed: Bad URL ('%s')", upload->filename, upload->get_url) == -1) {
msg = strdup(FALLBACK_MSG); msg = strdup(FALLBACK_MSG);
} }
cons_show_error(msg); cons_show_error(msg);
@@ -295,21 +297,21 @@ http_file_put(void *userdata)
switch (upload->window->type) { switch (upload->window->type) {
case WIN_CHAT: case WIN_CHAT:
{ {
ProfChatWin *chatwin = (ProfChatWin*)(upload->window); ProfChatWin* chatwin = (ProfChatWin*)(upload->window);
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
cl_ev_send_msg(chatwin, url, url); cl_ev_send_msg(chatwin, url, url);
break; break;
} }
case WIN_PRIVATE: case WIN_PRIVATE:
{ {
ProfPrivateWin *privatewin = (ProfPrivateWin*)(upload->window); ProfPrivateWin* privatewin = (ProfPrivateWin*)(upload->window);
assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK);
cl_ev_send_priv_msg(privatewin, url, url); cl_ev_send_priv_msg(privatewin, url, url);
break; break;
} }
case WIN_MUC: case WIN_MUC:
{ {
ProfMucWin *mucwin = (ProfMucWin*)(upload->window); ProfMucWin* mucwin = (ProfMucWin*)(upload->window);
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
cl_ev_send_muc_msg(mucwin, url, url); cl_ev_send_muc_msg(mucwin, url, url);
break; break;
@@ -342,14 +344,14 @@ file_mime_type(const char* const filename)
{ {
char* out_mime_type; char* out_mime_type;
char file_header[FILE_HEADER_BYTES]; char file_header[FILE_HEADER_BYTES];
FILE *fh; FILE* fh;
if (!(fh = fopen(filename, "rb"))) { if (!(fh = fopen(filename, "rb"))) {
return strdup(FALLBACK_MIMETYPE); return strdup(FALLBACK_MIMETYPE);
} }
size_t file_header_size = fread(file_header, 1, FILE_HEADER_BYTES, fh); size_t file_header_size = fread(file_header, 1, FILE_HEADER_BYTES, fh);
fclose(fh); fclose(fh);
char *content_type = g_content_type_guess(filename, (unsigned char*)file_header, file_header_size, NULL); char* content_type = g_content_type_guess(filename, (unsigned char*)file_header, file_header_size, NULL);
if (content_type != NULL) { if (content_type != NULL) {
char* mime_type = g_content_type_get_mime_type(content_type); char* mime_type = g_content_type_get_mime_type(content_type);
out_mime_type = strdup(mime_type); out_mime_type = strdup(mime_type);
@@ -361,7 +363,8 @@ file_mime_type(const char* const filename)
return out_mime_type; return out_mime_type;
} }
off_t file_size(int filedes) off_t
file_size(int filedes)
{ {
struct stat st; struct stat st;
fstat(filedes, &st); fstat(filedes, &st);

View File

@@ -45,17 +45,18 @@
#include "ui/win_types.h" #include "ui/win_types.h"
typedef struct http_upload_t { typedef struct http_upload_t
char *filename; {
FILE *filehandle; char* filename;
FILE* filehandle;
off_t filesize; off_t filesize;
curl_off_t bytes_sent; curl_off_t bytes_sent;
char *mime_type; char* mime_type;
char *get_url; char* get_url;
char *put_url; char* put_url;
char *alt_scheme; char* alt_scheme;
char *alt_fragment; char* alt_fragment;
ProfWin *window; ProfWin* window;
pthread_t worker; pthread_t worker;
int cancel; int cancel;
} HTTPUpload; } HTTPUpload;

View File

@@ -2192,7 +2192,7 @@ cons_show_omemo_prefs(void)
cons_show("OMEMO char (/omemo char) : %s", ch); cons_show("OMEMO char (/omemo char) : %s", ch);
free(ch); free(ch);
cons_alert(); cons_alert(NULL);
} }
void void

View File

@@ -1390,7 +1390,7 @@ win_appendln_highlight(ProfWin* window, theme_item_t theme_item, const char* con
} }
void void
win_print_http_transfer(ProfWin *window, const char *const message, char *url) win_print_http_transfer(ProfWin* window, const char* const message, char* url)
{ {
win_print_outgoing_with_receipt(window, "!", NULL, message, url, NULL); win_print_outgoing_with_receipt(window, "!", NULL, message, url, NULL);
} }

View File

@@ -72,7 +72,7 @@ void win_println_incoming_muc_msg(ProfWin* window, char* show_char, int flags, c
void win_print_outgoing_muc_msg(ProfWin* window, char* show_char, const char* const me, const char* const id, const char* const replace_id, const char* const message); void win_print_outgoing_muc_msg(ProfWin* window, char* show_char, const char* const me, const char* const id, const char* const replace_id, const char* const message);
void win_print_history(ProfWin* window, const ProfMessage* const message); void win_print_history(ProfWin* window, const ProfMessage* const message);
void win_print_http_transfer(ProfWin *window, const char *const message, char *url); void win_print_http_transfer(ProfWin* window, const char* const message, char* url);
void win_newline(ProfWin* window); void win_newline(ProfWin* window);
void win_redraw(ProfWin* window); void win_redraw(ProfWin* window);

View File

@@ -79,15 +79,38 @@ omemo_own_fingerprint(gboolean formatted)
return NULL; return NULL;
} }
void omemo_start_muc_sessions(const char *const roomjid) {} void
void omemo_start_session(const char *const barejid) {} omemo_start_muc_sessions(const char* const roomjid)
void omemo_trust(const char *const jid, const char *const fingerprint_formatted) {} {
void omemo_untrust(const char *const jid, const char *const fingerprint_formatted) {} }
void omemo_devicelist_publish(GList *device_list) {} void
void omemo_publish_crypto_materials(void) {} omemo_start_session(const char* const barejid)
void omemo_start_sessions(void) {} {
}
void
omemo_trust(const char* const jid, const char* const fingerprint_formatted)
{
}
void
omemo_untrust(const char* const jid, const char* const fingerprint_formatted)
{
}
void
omemo_devicelist_publish(GList* device_list)
{
}
void
omemo_publish_crypto_materials(void)
{
}
void
omemo_start_sessions(void)
{
}
char *omemo_encrypt_file(FILE *in, FILE *out, off_t file_size, int *gcry_res) { char*
omemo_encrypt_file(FILE* in, FILE* out, off_t file_size, int* gcry_res)
{
return NULL; return NULL;
}; };
void omemo_free(void *a) {}; void omemo_free(void* a){};

View File

@@ -10,62 +10,65 @@
#include "tools/http_download.h" #include "tools/http_download.h"
typedef struct { typedef struct
char *url; {
char *basename; char* url;
char* basename;
} url_test_t; } url_test_t;
void http_basename_from_url_td(void **state) { void
http_basename_from_url_td(void** state)
{
int num_tests = 11; int num_tests = 11;
url_test_t tests[] = { url_test_t tests[] = {
(url_test_t){ (url_test_t){
.url = "https://host.test/image.jpeg", .url = "https://host.test/image.jpeg",
.basename = "image.jpeg", .basename = "image.jpeg",
}, },
(url_test_t){ (url_test_t){
.url = "https://host.test/image.jpeg#somefragment", .url = "https://host.test/image.jpeg#somefragment",
.basename = "image.jpeg", .basename = "image.jpeg",
}, },
(url_test_t){ (url_test_t){
.url = "https://host.test/image.jpeg?query=param", .url = "https://host.test/image.jpeg?query=param",
.basename = "image.jpeg", .basename = "image.jpeg",
}, },
(url_test_t){ (url_test_t){
.url = "https://host.test/image.jpeg?query=param&another=one", .url = "https://host.test/image.jpeg?query=param&another=one",
.basename = "image.jpeg", .basename = "image.jpeg",
}, },
(url_test_t){ (url_test_t){
.url = "https://host.test/images/", .url = "https://host.test/images/",
.basename = "images", .basename = "images",
}, },
(url_test_t){ (url_test_t){
.url = "https://host.test/images/../../file", .url = "https://host.test/images/../../file",
.basename = "file", .basename = "file",
}, },
(url_test_t){ (url_test_t){
.url = "https://host.test/images/../../file/..", .url = "https://host.test/images/../../file/..",
.basename = "index.html", .basename = "index.html",
}, },
(url_test_t){ (url_test_t){
.url = "https://host.test/images/..//", .url = "https://host.test/images/..//",
.basename = "index.html", .basename = "index.html",
}, },
(url_test_t){ (url_test_t){
.url = "https://host.test/", .url = "https://host.test/",
.basename = "index.html", .basename = "index.html",
}, },
(url_test_t){ (url_test_t){
.url = "https://host.test", .url = "https://host.test",
.basename = "index.html", .basename = "index.html",
}, },
(url_test_t){ (url_test_t){
.url = "aesgcm://host.test", .url = "aesgcm://host.test",
.basename = "index.html", .basename = "index.html",
}, },
}; };
char *basename; char* basename;
for(int i = 0; i < num_tests; i++) { for (int i = 0; i < num_tests; i++) {
basename = http_basename_from_url(tests[i].url); basename = http_basename_from_url(tests[i].url);
assert_string_equal(basename, tests[i].basename); assert_string_equal(basename, tests[i].basename);
} }

View File

@@ -1 +1 @@
void http_basename_from_url_td(void **state); void http_basename_from_url_td(void** state);

View File

@@ -6,23 +6,23 @@
typedef struct prof_win_t ProfWin; typedef struct prof_win_t ProfWin;
typedef struct http_download_t { typedef struct http_download_t
char *url; {
char *filename; char* url;
char *directory; char* filename;
FILE *filehandle; char* directory;
FILE* filehandle;
curl_off_t bytes_received; curl_off_t bytes_received;
ProfWin *window; ProfWin* window;
pthread_t worker; pthread_t worker;
int cancel; int cancel;
} HTTPDownload; } HTTPDownload;
void* http_file_get(void* userdata);
void* http_file_get(void *userdata); void http_download_cancel_processes(ProfWin* window);
void http_download_add_download(HTTPDownload* download);
void http_download_cancel_processes(ProfWin *window); char* http_filename_from_url(const char* url);
void http_download_add_download(HTTPDownload *download);
char *http_filename_from_url(const char *url);
#endif #endif

View File

@@ -236,97 +236,16 @@ ui_contact_online(char* barejid, Resource* resource, GDateTime* last_activity)
check_expected(last_activity); check_expected(last_activity);
} }
void ui_contact_typing(const char * const barejid, const char * const resource) {} void
void chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_created) {} ui_contact_typing(const char* const barejid, const char* const resource)
void chatwin_receipt_received(ProfChatWin *chatwin, const char * const id) {} {
}
void privwin_incoming_msg(ProfPrivateWin *privatewin, ProfMessage *message) {} void
chatwin_incoming_msg(ProfChatWin* chatwin, ProfMessage* message, gboolean win_created)
void ui_disconnected(void) {} {
void chatwin_recipient_gone(ProfChatWin *chatwin) {} }
void
void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode, gboolean request_receipt, const char *const replace_id) {} chatwin_receipt_received(ProfChatWin* chatwin, const char* const id)
void chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message) {}
void privwin_outgoing_msg(ProfPrivateWin *privwin, const char * const message) {}
void privwin_occupant_offline(ProfPrivateWin *privwin) {}
void privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason) {}
void privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason) {}
void privwin_occupant_online(ProfPrivateWin *privwin) {}
void privwin_message_occupant_offline(ProfPrivateWin *privwin) {}
void privwin_message_left_room(ProfPrivateWin *privwin) {}
void ui_room_join(const char * const roomjid, gboolean focus) {}
void ui_switch_to_room(const char * const roomjid) {}
void mucwin_role_change(ProfMucWin *mucwin, const char * const role, const char * const actor,
const char * const reason) {}
void mucwin_affiliation_change(ProfMucWin *mucwin, const char * const affiliation, const char * const actor,
const char * const reason) {}
void mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char * const role,
const char * const affiliation, const char * const actor, const char * const reason) {}
void mucwin_occupant_role_change(ProfMucWin *mucwin, const char * const nick, const char * const role,
const char * const actor, const char * const reason) {}
void mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char * const nick, const char * const affiliation,
const char * const actor, const char * const reason) {}
void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char * const nick, const char * const role,
const char * const affiliation, const char * const actor, const char * const reason) {}
void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char * const presence) {}
void mucwin_history(ProfMucWin *mucwin, const ProfMessage *const message) {}
void mucwin_incoming_msg(ProfMucWin *mucwin, const ProfMessage *const message, GSList *mentions, GList *triggers, gboolean filter_reflection) {}
void mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode, const char *const replace_id) {}
void mucwin_subject(ProfMucWin *mucwin, const char * const nick, const char * const subject) {}
void mucwin_requires_config(ProfMucWin *mucwin) {}
void ui_room_destroy(const char * const roomjid) {}
void mucwin_info(ProfMucWin *mucwin) {}
void mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) {}
void mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) {}
void mucwin_room_info_error(ProfMucWin *mucwin, const char * const error) {}
void mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) {}
void ui_room_destroyed(const char * const roomjid, const char * const reason, const char * const new_jid,
const char * const password) {}
void ui_room_kicked(const char * const roomjid, const char * const actor, const char * const reason) {}
void mucwin_occupant_kicked(ProfMucWin *mucwin, const char * const nick, const char * const actor,
const char * const reason) {}
void ui_room_banned(const char * const roomjid, const char * const actor, const char * const reason) {}
void mucwin_occupant_banned(ProfMucWin *mucwin, const char * const nick, const char * const actor,
const char * const reason) {}
void ui_leave_room(const char * const roomjid) {}
void mucwin_broadcast(ProfMucWin *mucwin, const char * const message) {}
void mucwin_occupant_offline(ProfMucWin *mucwin, const char * const nick) {}
void mucwin_occupant_online(ProfMucWin *mucwin, const char * const nick, const char * const roles,
const char * const affiliation, const char * const show, const char * const status) {}
void mucwin_occupant_nick_change(ProfMucWin *mucwin, const char * const old_nick, const char * const nick) {}
void mucwin_nick_change(ProfMucWin *mucwin, const char * const nick) {}
void mucwin_occupant_presence(ProfMucWin *mucwin, const char * const nick, const char * const show,
const char * const status) {}
void mucwin_update_occupants(ProfMucWin *mucwin) {}
void mucwin_show_occupants(ProfMucWin *mucwin) {}
void mucwin_hide_occupants(ProfMucWin *mucwin) {}
void mucwin_set_enctext(ProfMucWin *mucwin, const char *const enctext) {}
void mucwin_unset_enctext(ProfMucWin *mucwin) {}
void mucwin_set_message_char(ProfMucWin *mucwin, const char *const ch) {}
void mucwin_unset_message_char(ProfMucWin *mucwin) {}
void win_update_entry_message(ProfWin *window, const char *const id, const char *const message) {};
void win_mark_received(ProfWin *window, const char *const id) {};
void win_print_http_transfer(ProfWin *window, const char *const message, char *url) {};
void ui_show_roster(void) {}
void ui_hide_roster(void) {}
void ui_roster_add(const char * const barejid, const char * const name) {}
void ui_roster_remove(const char * const barejid) {}
void ui_contact_already_in_group(const char * const contact, const char * const group) {}
void ui_contact_not_in_group(const char * const contact, const char * const group) {}
void ui_group_added(const char * const contact, const char * const group) {}
void ui_group_removed(const char * const contact, const char * const group) {}
void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity) {}
void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status) {}
void ui_contact_offline(char *barejid, char *resource, char *status) {}
void ui_handle_recipient_error(const char * const recipient, const char * const err_msg)
{ {
} }
@@ -552,6 +471,10 @@ mucwin_unset_message_char(ProfMucWin* mucwin)
{ {
} }
void win_update_entry_message(ProfWin* window, const char* const id, const char* const message){};
void win_mark_received(ProfWin* window, const char* const id){};
void win_print_http_transfer(ProfWin* window, const char* const message, char* url){};
void void
ui_show_roster(void) ui_show_roster(void)
{ {