1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-08 19:34:14 -04:00

Added /otr command

This commit is contained in:
James Booth 2013-09-21 22:33:43 +01:00
parent 4aa05f65be
commit 1d32413b99
2 changed files with 32 additions and 3 deletions

View File

@ -126,6 +126,7 @@ static gboolean _cmd_nick(gchar **args, struct cmd_help_t help);
static gboolean _cmd_notify(gchar **args, struct cmd_help_t help);
static gboolean _cmd_online(gchar **args, struct cmd_help_t help);
static gboolean _cmd_outtype(gchar **args, struct cmd_help_t help);
static gboolean _cmd_otr(gchar **args, struct cmd_help_t help);
static gboolean _cmd_prefs(gchar **args, struct cmd_help_t help);
static gboolean _cmd_priority(gchar **args, struct cmd_help_t help);
static gboolean _cmd_quit(gchar **args, struct cmd_help_t help);
@ -638,6 +639,14 @@ static struct cmd_t command_defs[] =
"Such as whether you have become inactive, or have closed the chat window.",
NULL } } },
{ "/otr",
_cmd_otr, parse_args, 1, 2, NULL,
{ "/otr gen|start|end|trust|untrust [contact]", "Off The Record encryption commands.",
{ "/otr gen|start|end|trust|untrust [contact]",
"-----------------------------------------",
"gen - Load or create private key and fingerprints.",
NULL } } },
{ "/outtype",
_cmd_outtype, parse_args, 1, 1, cons_outtype_setting,
{ "/outtype on|off", "Send typing notification to recipient.",
@ -3181,6 +3190,29 @@ _cmd_outtype(gchar **args, struct cmd_help_t help)
return result;
}
static gboolean
_cmd_otr(gchar **args, struct cmd_help_t help)
{
#ifdef HAVE_LIBOTR
if (strcmp(args[0], "gen") == 0) {
if (jabber_get_connection_status() != JABBER_CONNECTED) {
cons_show("You must be connected with an account to load OTR information.");
return TRUE;
} else {
ProfAccount *account = accounts_get_account(jabber_get_account_name());
otr_account_load(account);
return TRUE;
}
} else {
cons_show("Usage: %s", help.usage);
return TRUE;
}
#else
cons_show("This version of Profanity has not been build with OTR support enabled");
return TRUE;
#endif
}
static gboolean
_cmd_gone(gchar **args, struct cmd_help_t help)
{

View File

@ -253,9 +253,6 @@ void
prof_handle_login_account_success(char *account_name)
{
ProfAccount *account = accounts_get_account(account_name);
#ifdef HAVE_LIBOTR
otr_account_load(account);
#endif
resource_presence_t resource_presence = accounts_get_login_presence(account->name);
contact_presence_t contact_presence = contact_presence_from_resource_presence(resource_presence);
cons_show_login_success(account);