about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command/command.c17
-rw-r--r--src/command/commands.c11
-rw-r--r--src/command/commands.h1
-rw-r--r--src/config/preferences.c26
-rw-r--r--src/config/preferences.h4
-rw-r--r--src/config/theme.c2
-rw-r--r--src/event/server_events.c2
-rw-r--r--src/ui/console.c17
-rw-r--r--src/ui/titlebar.c3
-rw-r--r--src/ui/ui.h1
10 files changed, 41 insertions, 43 deletions
diff --git a/src/command/command.c b/src/command/command.c
index af91bf16..05ca9737 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -668,6 +668,14 @@ static struct cmd_t command_defs[] =
           "If the terminal does not support sounds, it may attempt to flash the screen instead.",
           NULL } } },
 
+    { "/encwarn",
+        cmd_encwarn, parse_args, 1, 1, &cons_encwarn_setting,
+        { "/encwarn on|off", "Titlebar encryption warning.",
+        { "/encwarn on|off",
+          "---------------",
+          "Enabled or disable the unencrypted warning message in the titlebar.",
+          NULL } } },
+
     { "/presence",
         cmd_presence, parse_args, 1, 1, &cons_presence_setting,
         { "/presence on|off", "Show the contacts presence in the titlebar.",
@@ -1483,7 +1491,6 @@ cmd_init(void)
     autocomplete_add(otr_ac, "untrust");
     autocomplete_add(otr_ac, "secret");
     autocomplete_add(otr_ac, "log");
-    autocomplete_add(otr_ac, "warn");
     autocomplete_add(otr_ac, "libver");
     autocomplete_add(otr_ac, "policy");
     autocomplete_add(otr_ac, "question");
@@ -1957,7 +1964,7 @@ _cmd_complete_parameters(ProfWin *window, const char * const input)
     // autocomplete boolean settings
     gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype",
         "/flash", "/splash", "/chlog", "/grlog", "/mouse", "/history",
-        "/vercheck", "/privileges", "/presence", "/wrap", "/winstidy", "/carbons" };
+        "/vercheck", "/privileges", "/presence", "/wrap", "/winstidy", "/carbons", "/encwarn" };
 
     for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
         result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice);
@@ -2460,12 +2467,6 @@ _otr_autocomplete(ProfWin *window, const char * const input)
         return found;
     }
 
-    found = autocomplete_param_with_func(input, "/otr warn",
-        prefs_autocomplete_boolean_choice);
-    if (found) {
-        return found;
-    }
-
     found = autocomplete_param_with_ac(input, "/otr", otr_ac, TRUE);
     if (found) {
         return found;
diff --git a/src/command/commands.c b/src/command/commands.c
index 2fe4c2f6..03a3f9f6 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -4326,11 +4326,6 @@ cmd_otr(ProfWin *window, gchar **args, struct cmd_help_t help)
         }
         return TRUE;
 
-    } else if (strcmp(args[0], "warn") == 0) {
-        gboolean result =  _cmd_set_boolean_preference(args[1], help,
-            "OTR warning message", PREF_OTR_WARN);
-        return result;
-
     } else if (strcmp(args[0], "libver") == 0) {
         char *version = otr_libotr_version();
         cons_show("Using libotr version %s", version);
@@ -4608,6 +4603,12 @@ cmd_otr(ProfWin *window, gchar **args, struct cmd_help_t help)
 #endif
 }
 
+gboolean
+cmd_encwarn(ProfWin *window, gchar **args, struct cmd_help_t help)
+{
+    return _cmd_set_boolean_preference(args[0], help, "Encryption warning message", PREF_ENC_WARN);
+}
+
 // helper function for status change commands
 static void
 _update_presence(const resource_presence_t resource_presence,
diff --git a/src/command/commands.h b/src/command/commands.h
index d7044ea1..6f2bada2 100644
--- a/src/command/commands.h
+++ b/src/command/commands.h
@@ -146,6 +146,7 @@ gboolean cmd_wrap(ProfWin *window, gchar **args, struct cmd_help_t help);
 gboolean cmd_time(ProfWin *window, gchar **args, struct cmd_help_t help);
 gboolean cmd_resource(ProfWin *window, gchar **args, struct cmd_help_t help);
 gboolean cmd_inpblock(ProfWin *window, gchar **args, struct cmd_help_t help);
+gboolean cmd_encwarn(ProfWin *window, gchar **args, struct cmd_help_t help);
 
 gboolean cmd_form_field(ProfWin *window, char *tag, gchar **args);
 
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 62e2522b..64fb13bd 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -94,22 +94,12 @@ prefs_load(void)
         g_error_free(err);
     }
 
-    // move pre 0.4.6 OTR warn preferences to [ui] group
+    // move pre 0.4.7 enc.warn to enc.warn
     err = NULL;
-    gboolean otr_warn = g_key_file_get_boolean(prefs, PREF_GROUP_OTR, "warn", &err);
+    gboolean otr_warn = g_key_file_get_boolean(prefs, PREF_GROUP_UI, "otr.warn", &err);
     if (err == NULL) {
-        g_key_file_set_boolean(prefs, PREF_GROUP_UI, _get_key(PREF_OTR_WARN), otr_warn);
-        g_key_file_remove_key(prefs, PREF_GROUP_OTR, "warn", NULL);
-    } else {
-        g_error_free(err);
-    }
-
-    // move pre 0.4.6 titlebar preference
-    err = NULL;
-    gchar *old_titlebar = g_key_file_get_string(prefs, PREF_GROUP_UI, "titlebar", &err);
-    if (err == NULL) {
-        g_key_file_set_string(prefs, PREF_GROUP_UI, _get_key(PREF_TITLEBAR_SHOW), old_titlebar);
-        g_key_file_remove_key(prefs, PREF_GROUP_UI, "titlebar", NULL);
+        g_key_file_set_boolean(prefs, PREF_GROUP_UI, _get_key(PREF_ENC_WARN), otr_warn);
+        g_key_file_remove_key(prefs, PREF_GROUP_UI, "otr.warn", NULL);
     } else {
         g_error_free(err);
     }
@@ -510,7 +500,7 @@ _get_group(preference_t pref)
         case PREF_ROSTER_BY:
         case PREF_RESOURCE_TITLE:
         case PREF_RESOURCE_MESSAGE:
-        case PREF_OTR_WARN:
+        case PREF_ENC_WARN:
         case PREF_INPBLOCK_DYNAMIC:
             return PREF_GROUP_UI;
         case PREF_STATES:
@@ -637,8 +627,6 @@ _get_key(preference_t pref)
             return "defaccount";
         case PREF_OTR_LOG:
             return "log";
-        case PREF_OTR_WARN:
-            return "otr.warn";
         case PREF_OTR_POLICY:
             return "policy";
         case PREF_LOG_ROTATE:
@@ -669,6 +657,8 @@ _get_key(preference_t pref)
             return "resource.message";
         case PREF_INPBLOCK_DYNAMIC:
             return "inpblock.dynamic";
+        case PREF_ENC_WARN:
+            return "enc.warn";
         default:
             return NULL;
     }
@@ -681,7 +671,7 @@ _get_default_boolean(preference_t pref)
 {
     switch (pref)
     {
-        case PREF_OTR_WARN:
+        case PREF_ENC_WARN:
         case PREF_AUTOAWAY_CHECK:
         case PREF_LOG_ROTATE:
         case PREF_LOG_SHARED:
diff --git a/src/config/preferences.h b/src/config/preferences.h
index 273ce6bb..16a4d4e0 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -98,11 +98,11 @@ typedef enum {
     PREF_LOG_ROTATE,
     PREF_LOG_SHARED,
     PREF_OTR_LOG,
-    PREF_OTR_WARN,
     PREF_OTR_POLICY,
     PREF_RESOURCE_TITLE,
     PREF_RESOURCE_MESSAGE,
-    PREF_INPBLOCK_DYNAMIC
+    PREF_INPBLOCK_DYNAMIC,
+    PREF_ENC_WARN,
 } preference_t;
 
 typedef struct prof_alias_t {
diff --git a/src/config/theme.c b/src/config/theme.c
index 640b7298..d870b371 100644
--- a/src/config/theme.c
+++ b/src/config/theme.c
@@ -463,7 +463,7 @@ _load_preferences(void)
     _set_boolean_preference("presence", PREF_PRESENCE);
     _set_boolean_preference("intype", PREF_INTYPE);
 
-    _set_boolean_preference("otr.warn", PREF_OTR_WARN);
+    _set_boolean_preference("enc.warn", PREF_ENC_WARN);
 }
 
 static gchar *
diff --git a/src/event/server_events.c b/src/event/server_events.c
index 8d830d5e..824a12cb 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -201,7 +201,7 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_m
     prof_enc_t enc_mode = chatwin->enc_mode;
     if (enc_message) {
         if (enc_mode == PROF_ENC_OTR) {
-            // TODO show error
+            win_println((ProfWin*)chatwin, "PGP encrypted message received whilst in OTR session.");
         } else { // PROF_ENC_NONE, PROF_ENC_PGP
             char *decrypted = p_gpg_decrypt(barejid, enc_message);
             if (decrypted) {
diff --git a/src/ui/console.c b/src/ui/console.c
index 1e20c964..ac18c7da 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -885,6 +885,16 @@ cons_winstidy_setting(void)
 }
 
 void
+cons_encwarn_setting(void)
+{
+    if (prefs_get_boolean(PREF_ENC_WARN)) {
+        cons_show("Warn unencrypted (/encwarn)   : ON");
+    } else {
+        cons_show("Warn unencrypted (/encwarn)   : OFF");
+    }
+}
+
+void
 cons_presence_setting(void)
 {
     if (prefs_get_boolean(PREF_PRESENCE))
@@ -1058,6 +1068,7 @@ cons_show_ui_prefs(void)
     cons_roster_setting();
     cons_privileges_setting();
     cons_titlebar_setting();
+    cons_encwarn_setting();
     cons_presence_setting();
     cons_inpblock_setting();
 
@@ -1398,12 +1409,6 @@ cons_show_otr_prefs(void)
     cons_show("OTR policy (/otr policy) : %s", policy_value);
     prefs_free_string(policy_value);
 
-    if (prefs_get_boolean(PREF_OTR_WARN)) {
-        cons_show("Warn non-OTR (/otr warn) : ON");
-    } else {
-        cons_show("Warn non-OTR (/otr warn) : OFF");
-    }
-
     char *log_value = prefs_get_string(PREF_OTR_LOG);
     if (strcmp(log_value, "on") == 0) {
         cons_show("OTR logging (/otr log)   : ON");
diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c
index 3642417a..16a9eaff 100644
--- a/src/ui/titlebar.c
+++ b/src/ui/titlebar.c
@@ -252,8 +252,7 @@ _show_privacy(ProfChatWin *chatwin)
 
     switch (chatwin->enc_mode) {
         case PROF_ENC_NONE:
-            // TODO generalise to PROF_ENC_WARN
-            if (prefs_get_boolean(PREF_OTR_WARN)) {
+            if (prefs_get_boolean(PREF_ENC_WARN)) {
                 wprintw(win, " ");
                 wattron(win, bracket_attrs);
                 wprintw(win, "[");
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 7cfad86c..b5bfb482 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -288,6 +288,7 @@ void cons_privileges_setting(void);
 void cons_beep_setting(void);
 void cons_flash_setting(void);
 void cons_splash_setting(void);
+void cons_encwarn_setting(void);
 void cons_vercheck_setting(void);
 void cons_occupants_setting(void);
 void cons_roster_setting(void);