about summary refs log tree commit diff stats
path: root/src/ui/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/core.c')
-rw-r--r--src/ui/core.c134
1 files changed, 134 insertions, 0 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index adebdadd..bc4a9587 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -767,6 +767,7 @@ _ui_gone_secure(const char * const recipient, gboolean trusted)
         title_bar_set_recipient(recipient_str->str);
         g_string_free(recipient_str, TRUE);
         win_update_virtual(window);
+        ui_current_page_off();
     } else {
         int num = wins_get_num(window);
         status_bar_new(num);
@@ -785,6 +786,98 @@ _ui_gone_secure(const char * const recipient, gboolean trusted)
 }
 
 static void
+_ui_smp_recipient_initiated(const char * const recipient)
+{
+    ProfWin *window = wins_get_by_recipient(recipient);
+    if (window == NULL) {
+        return;
+    } else {
+        win_vprint_line(window, '!', 0, "%s wants to authenticate your identity, use '/otr secret <secret>'.", recipient);
+        win_update_virtual(window);
+        if (wins_is_current(window)) {
+            ui_current_page_off();
+        }
+    }
+}
+
+static void
+_ui_smp_recipient_initiated_q(const char * const recipient, const char *question)
+{
+    ProfWin *window = wins_get_by_recipient(recipient);
+    if (window == NULL) {
+        return;
+    } else {
+        win_vprint_line(window, '!', 0, "%s wants to authenticate your identity with the following question:", recipient);
+        win_vprint_line(window, '!', 0, "  %s", question);
+        win_vprint_line(window, '!', 0, "use '/otr answer <answer>'.");
+        win_update_virtual(window);
+        if (wins_is_current(window)) {
+            ui_current_page_off();
+        }
+    }
+}
+
+static void
+_ui_smp_unsuccessful_sender(const char * const recipient)
+{
+    ProfWin *window = wins_get_by_recipient(recipient);
+    if (window == NULL) {
+        return;
+    } else {
+        win_vprint_line(window, '!', 0, "Authentication failed, the secret you entered does not match the secret entered by %s.", recipient);
+        win_update_virtual(window);
+        if (wins_is_current(window)) {
+            ui_current_page_off();
+        }
+    }
+}
+
+static void
+_ui_smp_unsuccessful_receiver(const char * const recipient)
+{
+    ProfWin *window = wins_get_by_recipient(recipient);
+    if (window == NULL) {
+        return;
+    } else {
+        win_vprint_line(window, '!', 0, "Authentication failed, the secret entered by %s does not match yours.", recipient);
+        win_update_virtual(window);
+        if (wins_is_current(window)) {
+            ui_current_page_off();
+        }
+    }
+}
+
+static void
+_ui_smp_aborted(const char * const recipient)
+{
+    ProfWin *window = wins_get_by_recipient(recipient);
+    if (window == NULL) {
+        return;
+    } else {
+        win_vprint_line(window, '!', 0, "SMP session aborted.");
+        win_update_virtual(window);
+        if (wins_is_current(window)) {
+            ui_current_page_off();
+        }
+    }
+}
+
+static void
+_ui_smp_successful(const char * const recipient)
+{
+    ProfWin *window = wins_get_by_recipient(recipient);
+    if (window == NULL) {
+        return;
+    } else {
+        win_vprint_line(window, '!', 0, "Authentication successful.");
+        win_update_virtual(window);
+        if (wins_is_current(window)) {
+            ui_current_page_off();
+        }
+    }
+}
+
+static void
 _ui_gone_insecure(const char * const recipient)
 {
     ProfWin *window = wins_get_by_recipient(recipient);
@@ -798,6 +891,7 @@ _ui_gone_insecure(const char * const recipient)
             title_bar_set_recipient(recipient_str->str);
             g_string_free(recipient_str, TRUE);
             win_update_virtual(window);
+            ui_current_page_off();
         }
     }
 }
@@ -816,6 +910,7 @@ _ui_trust(const char * const recipient)
             title_bar_set_recipient(recipient_str->str);
             g_string_free(recipient_str, TRUE);
             win_update_virtual(window);
+            ui_current_page_off();
         }
     }
 }
@@ -834,6 +929,7 @@ _ui_untrust(const char * const recipient)
             title_bar_set_recipient(recipient_str->str);
             g_string_free(recipient_str, TRUE);
             win_update_virtual(window);
+            ui_current_page_off();
         }
     }
 }
@@ -976,6 +1072,36 @@ _ui_current_set_otr(gboolean value)
     current->is_otr = value;
 }
 
+static void
+_ui_otr_authenticating(const char * const recipient)
+{
+    ProfWin *window = wins_get_by_recipient(recipient);
+    if (window == NULL) {
+        return;
+    } else {
+        win_vprint_line(window, '!', 0, "Authenticating %s...", recipient);
+        win_update_virtual(window);
+        if (wins_is_current(window)) {
+            ui_current_page_off();
+        }
+    }
+}
+
+static void
+_ui_otr_authetication_waiting(const char * const recipient)
+{
+    ProfWin *window = wins_get_by_recipient(recipient);
+    if (window == NULL) {
+        return;
+    } else {
+        win_vprint_line(window, '!', 0, "Awaiting authentication from %s...", recipient);
+        win_update_virtual(window);
+        if (wins_is_current(window)) {
+            ui_current_page_off();
+        }
+    }
+}
+
 static int
 _ui_current_win_index(void)
 {
@@ -1974,10 +2100,18 @@ ui_init_module(void)
     ui_ask_password = _ui_ask_password;
     ui_current_win_is_otr = _ui_current_win_is_otr;
     ui_current_set_otr = _ui_current_set_otr;
+    ui_otr_authenticating = _ui_otr_authenticating;
+    ui_otr_authetication_waiting = _ui_otr_authetication_waiting;
     ui_gone_secure = _ui_gone_secure;
     ui_gone_insecure = _ui_gone_insecure;
     ui_trust = _ui_trust;
     ui_untrust = _ui_untrust;
+    ui_smp_recipient_initiated = _ui_smp_recipient_initiated;
+    ui_smp_recipient_initiated_q = _ui_smp_recipient_initiated_q;
+    ui_smp_successful = _ui_smp_successful;
+    ui_smp_unsuccessful_sender = _ui_smp_unsuccessful_sender;
+    ui_smp_unsuccessful_receiver = _ui_smp_unsuccessful_receiver;
+    ui_smp_aborted = _ui_smp_aborted;
     ui_chat_win_contact_online = _ui_chat_win_contact_online;
     ui_chat_win_contact_offline = _ui_chat_win_contact_offline;
     ui_handle_recipient_not_found = _ui_handle_recipient_not_found;