diff options
author | James Booth <boothj5@gmail.com> | 2015-08-26 01:06:10 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-08-26 01:06:10 +0100 |
commit | 1bf584793f54db23100e5c5815666a528230d745 (patch) | |
tree | a866d00ad423489c6b34fac662b139031c19e131 | |
parent | 48630d45a44ddc22284893e81b15b3880107cbd1 (diff) | |
download | profani-tty-1bf584793f54db23100e5c5815666a528230d745.tar.gz |
Added preference for encryption char
-rw-r--r-- | src/config/preferences.c | 54 | ||||
-rw-r--r-- | src/config/preferences.h | 5 | ||||
-rw-r--r-- | src/ui/core.c | 4 | ||||
-rw-r--r-- | src/ui/window.c | 4 |
4 files changed, 63 insertions, 4 deletions
diff --git a/src/config/preferences.c b/src/config/preferences.c index 7ae9695e..6d63d3e9 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -376,6 +376,60 @@ prefs_get_roster_size(void) } } +char +prefs_get_otr_char(void) +{ + char result = '~'; + + char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_OTR, "otr.char", NULL); + if (!resultstr) { + result = '~'; + } else { + result = resultstr[0]; + } + free(resultstr); + + return result; +} + +void +prefs_set_otr_char(char ch) +{ + char str[2]; + str[0] = ch; + str[1] = '\0'; + + g_key_file_set_string(prefs, PREF_GROUP_OTR, "otr.char", str); + _save_prefs(); +} + +char +prefs_get_pgp_char(void) +{ + char result = '~'; + + char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_PGP, "pgp.char", NULL); + if (!resultstr) { + result = '~'; + } else { + result = resultstr[0]; + } + free(resultstr); + + return result; +} + +void +prefs_set_pgp_char(char ch) +{ + char str[2]; + str[0] = ch; + str[1] = '\0'; + + g_key_file_set_string(prefs, PREF_GROUP_PGP, "pgp.char", str); + _save_prefs(); +} + gboolean prefs_add_alias(const char * const name, const char * const value) { diff --git a/src/config/preferences.h b/src/config/preferences.h index f479f7a6..2a7ab5bf 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -143,6 +143,11 @@ gint prefs_get_roster_size(void); gint prefs_get_autoaway_time(void); void prefs_set_autoaway_time(gint value); +char prefs_get_otr_char(void); +void prefs_set_otr_char(char ch); +char prefs_get_pgp_char(void); +void prefs_set_pgp_char(char ch); + void prefs_add_login(const char *jid); gboolean prefs_add_alias(const char * const name, const char * const value); diff --git a/src/ui/core.c b/src/ui/core.c index f416a448..d66806d4 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -1291,9 +1291,9 @@ ui_outgoing_chat_msg(ProfChatWin *chatwin, const char * const message, char *id, { char enc_char = '-'; if (enc_mode == PROF_ENC_OTR) { - enc_char = 'O'; + enc_char = prefs_get_otr_char(); } else if (enc_mode == PROF_ENC_PGP) { - enc_char = 'P'; + enc_char = prefs_get_pgp_char(); } if (prefs_get_boolean(PREF_RECEIPTS_REQUEST) && id) { diff --git a/src/ui/window.c b/src/ui/window.c index 808ad825..f6ad7cee 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -885,9 +885,9 @@ win_print_incoming_message(ProfWin *window, GDateTime *timestamp, { case WIN_CHAT: if (enc_mode == PROF_ENC_OTR) { - enc_char = 'O'; + enc_char = prefs_get_otr_char(); } else if (enc_mode == PROF_ENC_PGP) { - enc_char = 'P'; + enc_char = prefs_get_pgp_char(); } win_print(window, enc_char, 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message); break; |