1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Added SMP ui events

This commit is contained in:
James Booth 2014-04-26 23:29:05 +01:00
parent aff9eee433
commit 84c7fc9ae0
3 changed files with 92 additions and 6 deletions

View File

@ -117,7 +117,7 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext
otrl_message_abort_smp(user_state, ops, NULL, context);
} else {
// [get secret from user and continue SMP];
cons_debug("%s initiated SMP with secret", context->username);
ui_smp_recipient_initiated(context->username);
g_hash_table_insert(smp_initiators, strdup(context->username), strdup(context->username));
}
}
@ -140,9 +140,9 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext
context->smstate->nextExpected = OTRL_SMP_EXPECT1;
// Report result to user
if ((context->active_fingerprint->trust != NULL) && (context->active_fingerprint->trust[0] != '\0')) {
cons_debug("SMP SUCCESSFUL");
ui_smp_successful_sender(context->username);
} else {
cons_debug("SMP UNSUCCESSFUL");
ui_smp_unsuccessful_sender(context->username);
}
}
}
@ -155,9 +155,9 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext
context->smstate->nextExpected = OTRL_SMP_EXPECT1;
// Report result to user
if ((context->active_fingerprint->trust != NULL) && (context->active_fingerprint->trust[0] != '\0')) {
cons_debug("SMP SUCCESSFUL");
ui_smp_successful_receiver(context->username);
} else {
cons_debug("SMP UNSUCCESSFUL");
ui_smp_unsuccessful_receiver(context->username);
}
}
}
@ -166,6 +166,6 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext
// The message we are waiting for will not arrive, so reset
// and prepare for the next SMP
context->smstate->nextExpected = OTRL_SMP_EXPECT1;
cons_debug("SMP ABORTED");
ui_smp_aborted(context->username);
}
}

View File

@ -784,6 +784,78 @@ _ui_gone_secure(const char * const recipient, gboolean trusted)
}
}
static void
_ui_smp_recipient_initiated(const char * const recipient)
{
ProfWin *window = wins_get_by_recipient(recipient);
if (window == NULL) {
return;
} else {
win_vprint_line(window, '!', 0, "%s initiated SMP with secret, use '/otr secret <secret>' to start a trusted session.", recipient);
win_update_virtual(window);
}
}
static void
_ui_smp_successful_sender(const char * const recipient)
{
ProfWin *window = wins_get_by_recipient(recipient);
if (window == NULL) {
return;
} else {
win_vprint_line(window, '!', 0, "SMP session started.");
win_update_virtual(window);
}
}
static void
_ui_smp_unsuccessful_sender(const char * const recipient)
{
ProfWin *window = wins_get_by_recipient(recipient);
if (window == NULL) {
return;
} else {
win_vprint_line(window, '!', 0, "SMP session failed, the secret you entered does not match the secret entered by %s.", recipient);
win_update_virtual(window);
}
}
static void
_ui_smp_successful_receiver(const char * const recipient)
{
ProfWin *window = wins_get_by_recipient(recipient);
if (window == NULL) {
return;
} else {
win_vprint_line(window, '!', 0, "SMP session started.");
win_update_virtual(window);
}
}
static void
_ui_smp_unsuccessful_receiver(const char * const recipient)
{
ProfWin *window = wins_get_by_recipient(recipient);
if (window == NULL) {
return;
} else {
win_vprint_line(window, '!', 0, "SMP session failed, the secret %s entered does not match the secret you entered.", recipient);
win_update_virtual(window);
}
}
static void
_ui_smp_aborted(const char * const recipient)
{
ProfWin *window = wins_get_by_recipient(recipient);
if (window == NULL) {
return;
} else {
win_vprint_line(window, '!', 0, "SMP session aborted.");
win_update_virtual(window);
}
}
static void
_ui_gone_insecure(const char * const recipient)
{
@ -1978,6 +2050,12 @@ ui_init_module(void)
ui_gone_insecure = _ui_gone_insecure;
ui_trust = _ui_trust;
ui_untrust = _ui_untrust;
ui_smp_recipient_initiated = _ui_smp_recipient_initiated;
ui_smp_successful_sender = _ui_smp_successful_sender;
ui_smp_unsuccessful_sender = _ui_smp_unsuccessful_sender;
ui_smp_successful_receiver = _ui_smp_successful_receiver;
ui_smp_unsuccessful_receiver = _ui_smp_unsuccessful_receiver;
ui_smp_aborted = _ui_smp_aborted;
ui_chat_win_contact_online = _ui_chat_win_contact_online;
ui_chat_win_contact_offline = _ui_chat_win_contact_offline;
ui_handle_recipient_not_found = _ui_handle_recipient_not_found;

View File

@ -58,10 +58,18 @@ void (*ui_handle_special_keys)(const wint_t * const ch, const char * const inp,
gboolean (*ui_switch_win)(const int i);
void (*ui_next_win)(void);
void (*ui_previous_win)(void);
void (*ui_gone_secure)(const char * const recipient, gboolean trusted);
void (*ui_gone_insecure)(const char * const recipient);
void (*ui_trust)(const char * const recipient);
void (*ui_untrust)(const char * const recipient);
void (*ui_smp_recipient_initiated)(const char * const recipient);
void (*ui_smp_successful_sender)(const char * const recipient);
void (*ui_smp_unsuccessful_sender)(const char * const recipient);
void (*ui_smp_successful_receiver)(const char * const recipient);
void (*ui_smp_unsuccessful_receiver)(const char * const recipient);
void (*ui_smp_aborted)(const char * const recipient);
unsigned long (*ui_get_idle_time)(void);
void (*ui_reset_idle_time)(void);
void (*ui_new_chat_win)(const char * const to);