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

Added ui functions for otr authentication

This commit is contained in:
James Booth 2014-04-30 22:41:53 +01:00
parent 8994b3769c
commit eaa19598c1
3 changed files with 37 additions and 4 deletions

View File

@ -442,13 +442,11 @@ _otr_smp_secret(const char * const recipient, const char *secret)
// if recipient initiated SMP, send response, else initialise
if (g_hash_table_contains(smp_initiators, recipient)) {
otrl_message_respond_smp(user_state, &ops, NULL, context, (const unsigned char*)secret, strlen(secret));
ui_current_print_formatted_line('!', 0, "Authenticating %s...", recipient);
ui_current_page_off();
ui_otr_authenticating(recipient);
g_hash_table_remove(smp_initiators, context->username);
} else {
otrl_message_initiate_smp(user_state, &ops, NULL, context, (const unsigned char*)secret, strlen(secret));
ui_current_print_formatted_line('!', 0, "Awaiting authentication from %s...", recipient);
ui_current_page_off();
ui_otr_authetication_waiting(recipient);
}
}

View File

@ -1055,6 +1055,36 @@ _ui_current_set_otr(gboolean value)
current->is_otr = value;
}
static void
_ui_otr_authenticating(const char * const recipient)
{
ProfWin *window = wins_get_by_recipient(recipient);
if (window == NULL) {
return;
} else {
win_vprint_line(window, '!', 0, "Authenticating %s...", recipient);
win_update_virtual(window);
if (wins_is_current(window)) {
ui_current_page_off();
}
}
}
static void
_ui_otr_authetication_waiting(const char * const recipient)
{
ProfWin *window = wins_get_by_recipient(recipient);
if (window == NULL) {
return;
} else {
win_vprint_line(window, '!', 0, "Awaiting authentication from %s...", recipient);
win_update_virtual(window);
if (wins_is_current(window)) {
ui_current_page_off();
}
}
}
static int
_ui_current_win_index(void)
{
@ -2053,6 +2083,8 @@ ui_init_module(void)
ui_ask_password = _ui_ask_password;
ui_current_win_is_otr = _ui_current_win_is_otr;
ui_current_set_otr = _ui_current_set_otr;
ui_otr_authenticating = _ui_otr_authenticating;
ui_otr_authetication_waiting = _ui_otr_authetication_waiting;
ui_gone_secure = _ui_gone_secure;
ui_gone_insecure = _ui_gone_insecure;
ui_trust = _ui_trust;

View File

@ -92,6 +92,9 @@ void (*ui_current_error_line)(const char * const msg);
void (*ui_current_page_off)(void);
void (*ui_current_update_virtual)(void);
void (*ui_otr_authenticating)(const char * const recipient);
void (*ui_otr_authetication_waiting)(const char * const recipient);
win_type_t (*ui_win_type)(int index);
char * (*ui_recipient)(int index);
void (*ui_close_win)(int index);