about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-08-26 01:24:53 +0100
committerJames Booth <boothj5@gmail.com>2015-08-26 01:24:53 +0100
commit98ea744648497367aecf60436b17d7162733f104 (patch)
tree82cab73c3d7a3aa6e6ea87591f7ff615a3ce1830 /src
parent1bf584793f54db23100e5c5815666a528230d745 (diff)
downloadprofani-tty-98ea744648497367aecf60436b17d7162733f104.tar.gz
Added /otr char and /pgp char
Diffstat (limited to 'src')
-rw-r--r--src/command/command.c26
-rw-r--r--src/command/commands.c24
-rw-r--r--src/ui/console.c6
3 files changed, 46 insertions, 10 deletions
diff --git a/src/command/command.c b/src/command/command.c
index ae8257ce..cac4d488 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1145,7 +1145,8 @@ static struct cmd_t command_defs[] =
     { "/pgp",
         cmd_pgp, parse_args, 1, 3, NULL,
         CMD_TAGS(
-            CMD_TAG_CHAT)
+            CMD_TAG_CHAT,
+            CMD_TAG_UI)
         CMD_SYN(
             "/pgp libver",
             "/pgp keys",
@@ -1153,7 +1154,8 @@ static struct cmd_t command_defs[] =
             "/pgp setkey <contact> <keyid>",
             "/pgp start [<contact>]",
             "/pgp end",
-            "/pgp log on|off|redact")
+            "/pgp log on|off|redact",
+            "/pgp char <char>")
         CMD_DESC(
             "Open PGP commands to manage keys, and perform PGP encryption during chat sessions. "
             "See the /account command to set your own PGP key.")
@@ -1165,18 +1167,21 @@ static struct cmd_t command_defs[] =
             { "start [<contact>]",        "Start PGP encrypted chat, current contact will be used if not specified." },
             { "end",                      "End PGP encrypted chat with the current recipient." },
             { "log on|off",               "Enable or disable plaintext logging of PGP encrypted messages." },
-            { "log redact",               "Log PGP encrypted messages, but replace the contents with [redacted]. This is the default." })
+            { "log redact",               "Log PGP encrypted messages, but replace the contents with [redacted]. This is the default." },
+            { "char <char>",              "Set the character to be displayed next to PGP encrypted messages." })
         CMD_EXAMPLES(
             "/pgp log off",
             "/pgp setkey buddy@buddychat.org BA19CACE5A9592C5",
             "/pgp start buddy@buddychat.org",
-            "/pgp end")
+            "/pgp end",
+            "/pgp char P")
     },
 
     { "/otr",
         cmd_otr, parse_args, 1, 3, NULL,
         CMD_TAGS(
-            CMD_TAG_CHAT)
+            CMD_TAG_CHAT,
+            CMD_TAG_UI)
         CMD_SYN(
             "/otr libver",
             "/otr gen",
@@ -1188,7 +1193,8 @@ static struct cmd_t command_defs[] =
             "/otr question <question> <answer>",
             "/otr answer <answer>",
             "/otr policy manual|opportunistic|always",
-            "/otr log on|off|redact")
+            "/otr log on|off|redact",
+            "/otr char <char>")
         CMD_DESC(
             "Off The Record (OTR) commands to manage keys, and perform OTR encryption during chat sessions.")
         CMD_ARGS(
@@ -1206,7 +1212,8 @@ static struct cmd_t command_defs[] =
             { "policy opportunistic",         "Set the global OTR policy to opportunistic, and OTR sessions will be attempted upon starting a conversation." },
             { "policy always",                "Set the global OTR policy to always, an error will be displayed if an OTR session cannot be initiated upon starting a conversation." },
             { "log on|off",                   "Enable or disable plaintext logging of OTR encrypted messages." },
-            { "log redact",                   "Log OTR encrypted messages, but replace the contents with [redacted]. This is the default." })
+            { "log redact",                   "Log OTR encrypted messages, but replace the contents with [redacted]. This is the default." },
+            { "char <char>",                  "Set the character to be displayed next to OTR encrypted messages." })
         CMD_EXAMPLES(
             "/otr log off",
             "/otr policy manual",
@@ -1215,7 +1222,8 @@ static struct cmd_t command_defs[] =
             "/otr myfp",
             "/otr theirfp",
             "/otr question \"What is the name of my rabbit?\" fiffi",
-            "/otr end")
+            "/otr end",
+            "/otr char *")
     },
 
     { "/outtype",
@@ -1949,6 +1957,7 @@ cmd_init(void)
     autocomplete_add(otr_ac, "policy");
     autocomplete_add(otr_ac, "question");
     autocomplete_add(otr_ac, "answer");
+    autocomplete_add(otr_ac, "char");
 
     otr_log_ac = autocomplete_new();
     autocomplete_add(otr_log_ac, "on");
@@ -2062,6 +2071,7 @@ cmd_init(void)
     autocomplete_add(pgp_ac, "start");
     autocomplete_add(pgp_ac, "end");
     autocomplete_add(pgp_ac, "log");
+    autocomplete_add(pgp_ac, "char");
 
     pgp_log_ac = autocomplete_new();
     autocomplete_add(pgp_log_ac, "on");
diff --git a/src/command/commands.c b/src/command/commands.c
index 99770abd..7d829e2f 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -4191,7 +4191,17 @@ cmd_pgp(ProfWin *window, const char * const command, gchar **args)
         return TRUE;
     }
 
-    if (g_strcmp0(args[0], "log") == 0) {
+    if (strcmp(args[0], "char") == 0) {
+        if (args[1] == NULL) {
+            cons_bad_cmd_usage(command);
+        } else if (strlen(args[1]) != 1) {
+            cons_bad_cmd_usage(command);
+        } else {
+            prefs_set_pgp_char(args[1][0]);
+            cons_show("PGP char set to %c.", args[1][0]);
+        }
+        return TRUE;
+    } else if (g_strcmp0(args[0], "log") == 0) {
         char *choice = args[1];
         if (g_strcmp0(choice, "on") == 0) {
             prefs_set_string(PREF_PGP_LOG, "on");
@@ -4414,7 +4424,17 @@ cmd_otr(ProfWin *window, const char * const command, gchar **args)
         return TRUE;
     }
 
-    if (strcmp(args[0], "log") == 0) {
+    if (strcmp(args[0], "char") == 0) {
+        if (args[1] == NULL) {
+            cons_bad_cmd_usage(command);
+        } else if (strlen(args[1]) != 1) {
+            cons_bad_cmd_usage(command);
+        } else {
+            prefs_set_otr_char(args[1][0]);
+            cons_show("OTR char set to %c.", args[1][0]);
+        }
+        return TRUE;
+    } else if (strcmp(args[0], "log") == 0) {
         char *choice = args[1];
         if (g_strcmp0(choice, "on") == 0) {
             prefs_set_string(PREF_OTR_LOG, "on");
diff --git a/src/ui/console.c b/src/ui/console.c
index 6497e809..2b05448b 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1453,6 +1453,9 @@ cons_show_otr_prefs(void)
     }
     prefs_free_string(log_value);
 
+    char ch = prefs_get_otr_char();
+    cons_show("OTR char (/otr char)     : %c", ch);
+
     cons_alert();
 }
 
@@ -1472,6 +1475,9 @@ cons_show_pgp_prefs(void)
     }
     prefs_free_string(log_value);
 
+    char ch = prefs_get_pgp_char();
+    cons_show("PGP char (/pgp char)     : %c", ch);
+
     cons_alert();
 }