about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorPaul Fariello <paul@fariello.eu>2019-03-26 17:10:46 +0100
committerPaul Fariello <paul@fariello.eu>2019-04-10 17:12:31 +0200
commitba9679a706a1c3d4d37b45da707978d83a463b2a (patch)
tree5bd5545a94af1aa62ef050d0fbe0384dc38697ab
parentbc16ba1669b5a8fb0d2b449b2f2be8149025d70b (diff)
downloadprofani-tty-ba9679a706a1c3d4d37b45da707978d83a463b2a.tar.gz
Print fingerprint after trust and untrust command
-rw-r--r--src/command/cmd_funcs.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index fcbb10b8..eb550812 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -8176,6 +8176,23 @@ cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args)
 
     omemo_trust(barejid, fingerprint);
 
+    char *unformatted_fingerprint = malloc(strlen(fingerprint));
+    int i;
+    int j;
+    for (i = 0, j = 0; fingerprint[i] != '\0'; i++) {
+        if (!g_ascii_isxdigit(fingerprint[i])) {
+            continue;
+        }
+        unformatted_fingerprint[j++] = fingerprint[i];
+    }
+
+    unformatted_fingerprint[j] = '\0';
+    gboolean trusted = omemo_is_trusted_identity(barejid, unformatted_fingerprint);
+
+    win_println(window, THEME_DEFAULT, '-', "%s's OMEMO fingerprint: %s%s", barejid, fingerprint, trusted ? " (trusted)" : "");
+
+    free(unformatted_fingerprint);
+
     return TRUE;
 #else
     cons_show("This version of Profanity has not been built with OMEMO support enabled");
@@ -8228,6 +8245,23 @@ cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args)
 
     omemo_untrust(barejid, fingerprint);
 
+    char *unformatted_fingerprint = malloc(strlen(fingerprint));
+    int i;
+    int j;
+    for (i = 0, j = 0; fingerprint[i] != '\0'; i++) {
+        if (!g_ascii_isxdigit(fingerprint[i])) {
+            continue;
+        }
+        unformatted_fingerprint[j++] = fingerprint[i];
+    }
+
+    unformatted_fingerprint[j] = '\0';
+    gboolean trusted = omemo_is_trusted_identity(barejid, unformatted_fingerprint);
+
+    win_println(window, THEME_DEFAULT, '-', "%s's OMEMO fingerprint: %s%s", barejid, fingerprint, trusted ? " (trusted)" : "");
+
+    free(unformatted_fingerprint);
+
     return TRUE;
 #else
     cons_show("This version of Profanity has not been built with OMEMO support enabled");