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

remaining otr functions take ProfChatWin

This commit is contained in:
James Booth 2015-10-27 00:19:22 +00:00
parent 8bd74cefcf
commit 124aaa9809
7 changed files with 106 additions and 110 deletions

View File

@ -4956,7 +4956,7 @@ cmd_otr(ProfWin *window, const char *const command, gchar **args)
return TRUE;
}
ui_trust(chatwin->barejid);
ui_trust(chatwin);
otr_trust(chatwin->barejid);
return TRUE;
@ -4973,7 +4973,7 @@ cmd_otr(ProfWin *window, const char *const command, gchar **args)
return TRUE;
}
ui_untrust(chatwin->barejid);
ui_untrust(chatwin);
otr_untrust(chatwin->barejid);
return TRUE;

View File

@ -573,13 +573,18 @@ otr_smp_secret(const char *const recipient, const char *secret)
}
// if recipient initiated SMP, send response, else initialise
ProfChatWin *chatwin = wins_get_chat(recipient);
if (g_hash_table_contains(smp_initiators, recipient)) {
otrl_message_respond_smp(user_state, &ops, NULL, context, (const unsigned char*)secret, strlen(secret));
ui_otr_authenticating(recipient);
if (chatwin) {
ui_otr_authenticating(chatwin);
}
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_otr_authetication_waiting(recipient);
if (chatwin) {
ui_otr_authetication_waiting(chatwin);
}
}
}
@ -597,7 +602,10 @@ otr_smp_question(const char *const recipient, const char *question, const char *
}
otrl_message_initiate_smp_q(user_state, &ops, NULL, context, question, (const unsigned char*)answer, strlen(answer));
ui_otr_authetication_waiting(recipient);
ProfChatWin *chatwin = wins_get_chat(recipient);
if (chatwin) {
ui_otr_authetication_waiting(chatwin);
}
}
void

View File

@ -176,24 +176,22 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext
otrl_message_abort_smp(user_state, ops, NULL, context);
} else {
context->smstate->nextExpected = OTRL_SMP_EXPECT1;
if (context->smstate->received_question == 0) {
ProfChatWin *chatwin = wins_get_chat(context->username);
if (context->active_fingerprint->trust && (context->active_fingerprint->trust[0] != '\0')) {
if (chatwin) {
ProfChatWin *chatwin = wins_get_chat(context->username);
if (chatwin) {
if (context->smstate->received_question == 0) {
if (context->active_fingerprint->trust && (context->active_fingerprint->trust[0] != '\0')) {
ui_smp_successful(chatwin);
}
ui_trust(context->username);
} else {
if (chatwin) {
ui_trust(chatwin);
} else {
ui_smp_unsuccessful_sender(chatwin);
ui_untrust(chatwin);
}
ui_untrust(context->username);
}
} else {
if (context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) {
ui_smp_answer_success(context->username);
} else {
ui_smp_answer_failure(context->username);
if (context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) {
ui_smp_answer_success(chatwin);
} else {
ui_smp_answer_failure(chatwin);
}
}
}
}
@ -205,16 +203,14 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext
} else {
context->smstate->nextExpected = OTRL_SMP_EXPECT1;
ProfChatWin *chatwin = wins_get_chat(context->username);
if (context->active_fingerprint->trust && (context->active_fingerprint->trust[0] != '\0')) {
if (chatwin) {
if (chatwin) {
if (context->active_fingerprint->trust && (context->active_fingerprint->trust[0] != '\0')) {
ui_smp_successful(chatwin);
}
ui_trust(context->username);
} else {
if (chatwin) {
ui_trust(chatwin);
} else {
ui_smp_unsuccessful_receiver(chatwin);
ui_untrust(chatwin);
}
ui_untrust(context->username);
}
}
}
@ -224,8 +220,8 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext
ProfChatWin *chatwin = wins_get_chat(context->username);
if (chatwin) {
ui_smp_aborted(chatwin);
ui_untrust(chatwin);
}
ui_untrust(context->username);
otr_untrust(context->username);
}
}

View File

@ -195,30 +195,28 @@ cb_handle_smp_event(void *opdata, OtrlSMPEvent smp_event,
break;
case OTRL_SMPEVENT_SUCCESS:
if (context->smstate->received_question == 0) {
if (chatwin) {
if (chatwin) {
if (context->smstate->received_question == 0) {
ui_smp_successful(chatwin);
ui_trust(chatwin);
} else {
ui_smp_answer_success(chatwin);
}
ui_trust(context->username);
} else {
ui_smp_answer_success(context->username);
}
break;
case OTRL_SMPEVENT_FAILURE:
if (context->smstate->received_question == 0) {
if (nextMsg == OTRL_SMP_EXPECT3) {
if (chatwin) {
if (chatwin) {
if (context->smstate->received_question == 0) {
if (nextMsg == OTRL_SMP_EXPECT3) {
ui_smp_unsuccessful_sender(chatwin);
}
} else if (nextMsg == OTRL_SMP_EXPECT4) {
if (chatwin) {
} else if (nextMsg == OTRL_SMP_EXPECT4) {
ui_smp_unsuccessful_receiver(chatwin);
}
ui_untrust(chatwin);
} else {
ui_smp_answer_failure(chatwin);
}
ui_untrust(context->username);
} else {
ui_smp_answer_failure(context->username);
}
break;
@ -233,8 +231,8 @@ cb_handle_smp_event(void *opdata, OtrlSMPEvent smp_event,
case OTRL_SMPEVENT_ABORT:
if (chatwin) {
ui_smp_aborted(chatwin);
ui_untrust(chatwin);
}
ui_untrust(context->username);
break;
case OTRL_SMPEVENT_IN_PROGRESS:

View File

@ -156,38 +156,64 @@ ui_smp_successful(ProfChatWin *chatwin)
}
void
ui_smp_answer_success(const char *const barejid)
ui_smp_answer_success(ProfChatWin *chatwin)
{
ProfChatWin *chatwin = wins_get_chat(barejid);
if (chatwin) {
win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s successfully authenticated you.", barejid);
assert(chatwin != NULL);
win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s successfully authenticated you.", chatwin->barejid);
}
void
ui_smp_answer_failure(ProfChatWin *chatwin)
{
assert(chatwin != NULL);
win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s failed to authenticate you.", chatwin->barejid);
}
void
ui_otr_authenticating(ProfChatWin *chatwin)
{
assert(chatwin != NULL);
win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Authenticating %s...", chatwin->barejid);
}
void
ui_otr_authetication_waiting(ProfChatWin *chatwin)
{
assert(chatwin != NULL);
win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Awaiting authentication from %s...", chatwin->barejid);
}
void
ui_trust(ProfChatWin *chatwin)
{
assert(chatwin != NULL);
chatwin->is_otr = TRUE;
chatwin->otr_is_trusted = TRUE;
ProfWin *window = (ProfWin*)chatwin;
win_print(window, '!', 0, NULL, 0, THEME_OTR_TRUSTED, "", "OTR session trusted.");
if (wins_is_current(window)) {
title_bar_switch();
}
}
void
ui_smp_answer_failure(const char *const barejid)
ui_untrust(ProfChatWin *chatwin)
{
ProfChatWin *chatwin = wins_get_chat(barejid);
if (chatwin) {
win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s failed to authenticate you.", barejid);
}
}
assert(chatwin != NULL);
void
ui_otr_authenticating(const char *const barejid)
{
ProfChatWin *chatwin = wins_get_chat(barejid);
if (chatwin) {
win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Authenticating %s...", barejid);
}
}
chatwin->is_otr = TRUE;
chatwin->otr_is_trusted = FALSE;
void
ui_otr_authetication_waiting(const char *const barejid)
{
ProfChatWin *chatwin = wins_get_chat(barejid);
if (chatwin) {
win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Awaiting authentication from %s...", barejid);
ProfWin *window = (ProfWin*)chatwin;
win_print(window, '!', 0, NULL, 0, THEME_OTR_UNTRUSTED, "", "OTR session untrusted.");
if (wins_is_current(window)) {
title_bar_switch();
}
}
@ -202,38 +228,6 @@ ui_handle_otr_error(const char *const barejid, const char *const message)
}
}
void
ui_trust(const char *const barejid)
{
ProfChatWin *chatwin = wins_get_chat(barejid);
if (chatwin) {
chatwin->is_otr = TRUE;
chatwin->otr_is_trusted = TRUE;
ProfWin *window = (ProfWin*)chatwin;
win_print(window, '!', 0, NULL, 0, THEME_OTR_TRUSTED, "", "OTR session trusted.");
if (wins_is_current(window)) {
title_bar_switch();
}
}
}
void
ui_untrust(const char *const barejid)
{
ProfChatWin *chatwin = wins_get_chat(barejid);
if (chatwin) {
chatwin->is_otr = TRUE;
chatwin->otr_is_trusted = FALSE;
ProfWin *window = (ProfWin*)chatwin;
win_print(window, '!', 0, NULL, 0, THEME_OTR_UNTRUSTED, "", "OTR session untrusted.");
if (wins_is_current(window)) {
title_bar_switch();
}
}
}
void
ui_recipient_gone(const char *const barejid, const char *const resource)
{

View File

@ -64,8 +64,8 @@ void ui_sigwinch_handler(int sig);
void ui_gone_secure(ProfChatWin *chatwin, gboolean trusted);
void ui_gone_insecure(ProfChatWin *chatwin);
void ui_trust(const char *const barejid);
void ui_untrust(const char *const barejid);
void ui_trust(ProfChatWin *chatwin);
void ui_untrust(ProfChatWin *chatwin);
void ui_smp_recipient_initiated(ProfChatWin *chatwin);
void ui_smp_recipient_initiated_q(ProfChatWin *chatwin, const char *question);
@ -74,11 +74,11 @@ void ui_smp_unsuccessful_sender(ProfChatWin *chatwin);
void ui_smp_unsuccessful_receiver(ProfChatWin *chatwin);
void ui_smp_aborted(ProfChatWin *chatwin);
void ui_smp_answer_success(const char *const barejid);
void ui_smp_answer_failure(const char *const barejid);
void ui_smp_answer_success(ProfChatWin *chatwin);
void ui_smp_answer_failure(ProfChatWin *chatwin);
void ui_otr_authenticating(const char *const barejid);
void ui_otr_authetication_waiting(const char *const recipient);
void ui_otr_authenticating(ProfChatWin *chatwin);
void ui_otr_authetication_waiting(ProfChatWin *chatwin);
void ui_handle_otr_error(const char *const barejid, const char *const message);

View File

@ -68,8 +68,8 @@ void ui_switch_win(ProfWin *win) {}
void ui_gone_secure(ProfChatWin *chatwin, gboolean trusted) {}
void ui_gone_insecure(ProfChatWin *chatwin) {}
void ui_trust(const char * const barejid) {}
void ui_untrust(const char * const barejid) {}
void ui_trust(ProfChatWin *chatwin) {}
void ui_untrust(ProfChatWin *chatwin) {}
void ui_smp_recipient_initiated(ProfChatWin *chatwin) {}
void ui_smp_recipient_initiated_q(ProfChatWin *chatwin, const char *question) {}
@ -78,11 +78,11 @@ void ui_smp_unsuccessful_sender(ProfChatWin *chatwin) {}
void ui_smp_unsuccessful_receiver(ProfChatWin *chatwin) {}
void ui_smp_aborted(ProfChatWin *chatwin) {}
void ui_smp_answer_success(const char * const barejid) {}
void ui_smp_answer_failure(const char * const barejid) {}
void ui_smp_answer_success(ProfChatWin *chatwin) {}
void ui_smp_answer_failure(ProfChatWin *chatwin) {}
void ui_otr_authenticating(const char * const barejid) {}
void ui_otr_authetication_waiting(const char * const recipient) {}
void ui_otr_authenticating(ProfChatWin *chatwin) {}
void ui_otr_authetication_waiting(ProfChatWin *chatwin) {}
void ui_sigwinch_handler(int sig) {}
unsigned long ui_get_idle_time(void)