1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Add clear_device_list command

This commit is contained in:
Paul Fariello 2019-04-01 13:14:46 +02:00
parent 5cd2b8dc9d
commit 898302243e
4 changed files with 28 additions and 4 deletions

View File

@ -589,6 +589,7 @@ cmd_ac_init(void)
autocomplete_add(omemo_ac, "trust"); autocomplete_add(omemo_ac, "trust");
autocomplete_add(omemo_ac, "untrust"); autocomplete_add(omemo_ac, "untrust");
autocomplete_add(omemo_ac, "fingerprint"); autocomplete_add(omemo_ac, "fingerprint");
autocomplete_add(omemo_ac, "clear_device_list");
omemo_log_ac = autocomplete_new(); omemo_log_ac = autocomplete_new();
autocomplete_add(omemo_log_ac, "on"); autocomplete_add(omemo_log_ac, "on");

View File

@ -2339,7 +2339,8 @@ static struct cmd_t command_defs[] =
{ "end", cmd_omemo_end }, { "end", cmd_omemo_end },
{ "trust", cmd_omemo_trust }, { "trust", cmd_omemo_trust },
{ "untrust", cmd_omemo_untrust }, { "untrust", cmd_omemo_untrust },
{ "fingerprint", cmd_omemo_fingerprint }) { "fingerprint", cmd_omemo_fingerprint },
{ "clear_device_list", cmd_omemo_clear_device_list })
CMD_NOMAINFUNC CMD_NOMAINFUNC
CMD_TAGS( CMD_TAGS(
CMD_TAG_CHAT, CMD_TAG_CHAT,
@ -2350,7 +2351,8 @@ static struct cmd_t command_defs[] =
"/omemo start [<contact>]", "/omemo start [<contact>]",
"/omemo trust [<contact>] <fingerprint>", "/omemo trust [<contact>] <fingerprint>",
"/omemo end", "/omemo end",
"/omemo fingerprint [<contact>]") "/omemo fingerprint [<contact>]",
"/omemo clear_device_list")
CMD_DESC( CMD_DESC(
"Omemo commands to manage keys, and perform encryption during chat sessions.") "Omemo commands to manage keys, and perform encryption during chat sessions.")
CMD_ARGS( CMD_ARGS(
@ -2359,12 +2361,13 @@ static struct cmd_t command_defs[] =
{ "end", "End the current OMEMO session," }, { "end", "End the current OMEMO session," },
{ "log on|off", "Enable or disable plaintext logging of OMEMO encrypted messages." }, { "log on|off", "Enable or disable plaintext logging of OMEMO encrypted messages." },
{ "log redact", "Log OMEMO encrypted messages, but replace the contents with [redacted]. This is the default." }, { "log redact", "Log OMEMO encrypted messages, but replace the contents with [redacted]. This is the default." },
{ "fingerprint", "Show contact fingerprints." }) { "fingerprint", "Show contact fingerprints." },
{ "clear_device_list", "Clear your own device list on server side. Each client will reannounce itself when connected back."})
CMD_EXAMPLES( CMD_EXAMPLES(
"/omemo gen", "/omemo gen",
"/omemo start buddy@buddychat.org", "/omemo start buddy@buddychat.org",
"/omemo trust c4f9c875-144d7a3b-0c4a05b6-ca3be51a-a037f329-0bd3ae62-07f99719-55559d2a", "/omemo trust c4f9c875-144d7a3b-0c4a05b6-ca3be51a-a037f329-0bd3ae62-07f99719-55559d2a",
"/omemo untrust c4f9c875-144d7a3b-0c4a05b6-ca3be51a-a037f329-0bd3ae62-07f99719-55559d2a") "/omemo untrust buddy@buddychat.org c4f9c875-144d7a3b-0c4a05b6-ca3be51a-a037f329-0bd3ae62-07f99719-55559d2a")
}, },
}; };

View File

@ -87,6 +87,7 @@
#ifdef HAVE_OMEMO #ifdef HAVE_OMEMO
#include "omemo/omemo.h" #include "omemo/omemo.h"
#include "xmpp/omemo.h"
#endif #endif
#ifdef HAVE_GTK #ifdef HAVE_GTK
@ -8268,3 +8269,21 @@ cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args)
return TRUE; return TRUE;
#endif #endif
} }
gboolean
cmd_omemo_clear_device_list(ProfWin *window, const char *const command, gchar **args)
{
#ifdef HAVE_OMEMO
if (connection_get_status() != JABBER_CONNECTED) {
cons_show("You must be connected with an account to initialize OMEMO.");
return TRUE;
}
omemo_devicelist_publish(NULL);
cons_show("Cleared OMEMO device list");
return TRUE;
#else
cons_show("This version of Profanity has not been built with OMEMO support enabled");
return TRUE;
#endif
}

View File

@ -221,5 +221,6 @@ gboolean cmd_omemo_end(ProfWin *window, const char *const command, gchar **args)
gboolean cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_omemo_clear_device_list(ProfWin *window, const char *const command, gchar **args);
#endif #endif