1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-10-27 20:30:13 -04:00

Added /otr char and /pgp char

This commit is contained in:
James Booth 2015-08-26 01:24:53 +01:00
parent 1bf584793f
commit 98ea744648
3 changed files with 46 additions and 10 deletions

View File

@ -1145,7 +1145,8 @@ static struct cmd_t command_defs[] =
{ "/pgp", { "/pgp",
cmd_pgp, parse_args, 1, 3, NULL, cmd_pgp, parse_args, 1, 3, NULL,
CMD_TAGS( CMD_TAGS(
CMD_TAG_CHAT) CMD_TAG_CHAT,
CMD_TAG_UI)
CMD_SYN( CMD_SYN(
"/pgp libver", "/pgp libver",
"/pgp keys", "/pgp keys",
@ -1153,7 +1154,8 @@ static struct cmd_t command_defs[] =
"/pgp setkey <contact> <keyid>", "/pgp setkey <contact> <keyid>",
"/pgp start [<contact>]", "/pgp start [<contact>]",
"/pgp end", "/pgp end",
"/pgp log on|off|redact") "/pgp log on|off|redact",
"/pgp char <char>")
CMD_DESC( CMD_DESC(
"Open PGP commands to manage keys, and perform PGP encryption during chat sessions. " "Open PGP commands to manage keys, and perform PGP encryption during chat sessions. "
"See the /account command to set your own PGP key.") "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." }, { "start [<contact>]", "Start PGP encrypted chat, current contact will be used if not specified." },
{ "end", "End PGP encrypted chat with the current recipient." }, { "end", "End PGP encrypted chat with the current recipient." },
{ "log on|off", "Enable or disable plaintext logging of PGP encrypted messages." }, { "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( CMD_EXAMPLES(
"/pgp log off", "/pgp log off",
"/pgp setkey buddy@buddychat.org BA19CACE5A9592C5", "/pgp setkey buddy@buddychat.org BA19CACE5A9592C5",
"/pgp start buddy@buddychat.org", "/pgp start buddy@buddychat.org",
"/pgp end") "/pgp end",
"/pgp char P")
}, },
{ "/otr", { "/otr",
cmd_otr, parse_args, 1, 3, NULL, cmd_otr, parse_args, 1, 3, NULL,
CMD_TAGS( CMD_TAGS(
CMD_TAG_CHAT) CMD_TAG_CHAT,
CMD_TAG_UI)
CMD_SYN( CMD_SYN(
"/otr libver", "/otr libver",
"/otr gen", "/otr gen",
@ -1188,7 +1193,8 @@ static struct cmd_t command_defs[] =
"/otr question <question> <answer>", "/otr question <question> <answer>",
"/otr answer <answer>", "/otr answer <answer>",
"/otr policy manual|opportunistic|always", "/otr policy manual|opportunistic|always",
"/otr log on|off|redact") "/otr log on|off|redact",
"/otr char <char>")
CMD_DESC( CMD_DESC(
"Off The Record (OTR) commands to manage keys, and perform OTR encryption during chat sessions.") "Off The Record (OTR) commands to manage keys, and perform OTR encryption during chat sessions.")
CMD_ARGS( 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 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." }, { "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 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( CMD_EXAMPLES(
"/otr log off", "/otr log off",
"/otr policy manual", "/otr policy manual",
@ -1215,7 +1222,8 @@ static struct cmd_t command_defs[] =
"/otr myfp", "/otr myfp",
"/otr theirfp", "/otr theirfp",
"/otr question \"What is the name of my rabbit?\" fiffi", "/otr question \"What is the name of my rabbit?\" fiffi",
"/otr end") "/otr end",
"/otr char *")
}, },
{ "/outtype", { "/outtype",
@ -1949,6 +1957,7 @@ cmd_init(void)
autocomplete_add(otr_ac, "policy"); autocomplete_add(otr_ac, "policy");
autocomplete_add(otr_ac, "question"); autocomplete_add(otr_ac, "question");
autocomplete_add(otr_ac, "answer"); autocomplete_add(otr_ac, "answer");
autocomplete_add(otr_ac, "char");
otr_log_ac = autocomplete_new(); otr_log_ac = autocomplete_new();
autocomplete_add(otr_log_ac, "on"); autocomplete_add(otr_log_ac, "on");
@ -2062,6 +2071,7 @@ cmd_init(void)
autocomplete_add(pgp_ac, "start"); autocomplete_add(pgp_ac, "start");
autocomplete_add(pgp_ac, "end"); autocomplete_add(pgp_ac, "end");
autocomplete_add(pgp_ac, "log"); autocomplete_add(pgp_ac, "log");
autocomplete_add(pgp_ac, "char");
pgp_log_ac = autocomplete_new(); pgp_log_ac = autocomplete_new();
autocomplete_add(pgp_log_ac, "on"); autocomplete_add(pgp_log_ac, "on");

View File

@ -4191,7 +4191,17 @@ cmd_pgp(ProfWin *window, const char * const command, gchar **args)
return TRUE; 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]; char *choice = args[1];
if (g_strcmp0(choice, "on") == 0) { if (g_strcmp0(choice, "on") == 0) {
prefs_set_string(PREF_PGP_LOG, "on"); prefs_set_string(PREF_PGP_LOG, "on");
@ -4414,7 +4424,17 @@ cmd_otr(ProfWin *window, const char * const command, gchar **args)
return TRUE; 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]; char *choice = args[1];
if (g_strcmp0(choice, "on") == 0) { if (g_strcmp0(choice, "on") == 0) {
prefs_set_string(PREF_OTR_LOG, "on"); prefs_set_string(PREF_OTR_LOG, "on");

View File

@ -1453,6 +1453,9 @@ cons_show_otr_prefs(void)
} }
prefs_free_string(log_value); prefs_free_string(log_value);
char ch = prefs_get_otr_char();
cons_show("OTR char (/otr char) : %c", ch);
cons_alert(); cons_alert();
} }
@ -1472,6 +1475,9 @@ cons_show_pgp_prefs(void)
} }
prefs_free_string(log_value); prefs_free_string(log_value);
char ch = prefs_get_pgp_char();
cons_show("PGP char (/pgp char) : %c", ch);
cons_alert(); cons_alert();
} }