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:
parent
8bd74cefcf
commit
124aaa9809
@ -4956,7 +4956,7 @@ cmd_otr(ProfWin *window, const char *const command, gchar **args)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_trust(chatwin->barejid);
|
ui_trust(chatwin);
|
||||||
otr_trust(chatwin->barejid);
|
otr_trust(chatwin->barejid);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
@ -4973,7 +4973,7 @@ cmd_otr(ProfWin *window, const char *const command, gchar **args)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_untrust(chatwin->barejid);
|
ui_untrust(chatwin);
|
||||||
otr_untrust(chatwin->barejid);
|
otr_untrust(chatwin->barejid);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
@ -573,13 +573,18 @@ otr_smp_secret(const char *const recipient, const char *secret)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if recipient initiated SMP, send response, else initialise
|
// if recipient initiated SMP, send response, else initialise
|
||||||
|
ProfChatWin *chatwin = wins_get_chat(recipient);
|
||||||
if (g_hash_table_contains(smp_initiators, recipient)) {
|
if (g_hash_table_contains(smp_initiators, recipient)) {
|
||||||
otrl_message_respond_smp(user_state, &ops, NULL, context, (const unsigned char*)secret, strlen(secret));
|
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);
|
g_hash_table_remove(smp_initiators, context->username);
|
||||||
} else {
|
} else {
|
||||||
otrl_message_initiate_smp(user_state, &ops, NULL, context, (const unsigned char*)secret, strlen(secret));
|
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));
|
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
|
void
|
||||||
|
@ -176,24 +176,22 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext
|
|||||||
otrl_message_abort_smp(user_state, ops, NULL, context);
|
otrl_message_abort_smp(user_state, ops, NULL, context);
|
||||||
} else {
|
} else {
|
||||||
context->smstate->nextExpected = OTRL_SMP_EXPECT1;
|
context->smstate->nextExpected = OTRL_SMP_EXPECT1;
|
||||||
if (context->smstate->received_question == 0) {
|
ProfChatWin *chatwin = wins_get_chat(context->username);
|
||||||
ProfChatWin *chatwin = wins_get_chat(context->username);
|
if (chatwin) {
|
||||||
if (context->active_fingerprint->trust && (context->active_fingerprint->trust[0] != '\0')) {
|
if (context->smstate->received_question == 0) {
|
||||||
if (chatwin) {
|
if (context->active_fingerprint->trust && (context->active_fingerprint->trust[0] != '\0')) {
|
||||||
ui_smp_successful(chatwin);
|
ui_smp_successful(chatwin);
|
||||||
}
|
ui_trust(chatwin);
|
||||||
ui_trust(context->username);
|
} else {
|
||||||
} else {
|
|
||||||
if (chatwin) {
|
|
||||||
ui_smp_unsuccessful_sender(chatwin);
|
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 {
|
} 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 {
|
} else {
|
||||||
context->smstate->nextExpected = OTRL_SMP_EXPECT1;
|
context->smstate->nextExpected = OTRL_SMP_EXPECT1;
|
||||||
ProfChatWin *chatwin = wins_get_chat(context->username);
|
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_smp_successful(chatwin);
|
||||||
}
|
ui_trust(chatwin);
|
||||||
ui_trust(context->username);
|
} else {
|
||||||
} else {
|
|
||||||
if (chatwin) {
|
|
||||||
ui_smp_unsuccessful_receiver(chatwin);
|
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);
|
ProfChatWin *chatwin = wins_get_chat(context->username);
|
||||||
if (chatwin) {
|
if (chatwin) {
|
||||||
ui_smp_aborted(chatwin);
|
ui_smp_aborted(chatwin);
|
||||||
|
ui_untrust(chatwin);
|
||||||
}
|
}
|
||||||
ui_untrust(context->username);
|
|
||||||
otr_untrust(context->username);
|
otr_untrust(context->username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,30 +195,28 @@ cb_handle_smp_event(void *opdata, OtrlSMPEvent smp_event,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OTRL_SMPEVENT_SUCCESS:
|
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_smp_successful(chatwin);
|
||||||
|
ui_trust(chatwin);
|
||||||
|
} else {
|
||||||
|
ui_smp_answer_success(chatwin);
|
||||||
}
|
}
|
||||||
ui_trust(context->username);
|
|
||||||
} else {
|
|
||||||
ui_smp_answer_success(context->username);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OTRL_SMPEVENT_FAILURE:
|
case OTRL_SMPEVENT_FAILURE:
|
||||||
if (context->smstate->received_question == 0) {
|
if (chatwin) {
|
||||||
if (nextMsg == OTRL_SMP_EXPECT3) {
|
if (context->smstate->received_question == 0) {
|
||||||
if (chatwin) {
|
if (nextMsg == OTRL_SMP_EXPECT3) {
|
||||||
ui_smp_unsuccessful_sender(chatwin);
|
ui_smp_unsuccessful_sender(chatwin);
|
||||||
}
|
} else if (nextMsg == OTRL_SMP_EXPECT4) {
|
||||||
} else if (nextMsg == OTRL_SMP_EXPECT4) {
|
|
||||||
if (chatwin) {
|
|
||||||
ui_smp_unsuccessful_receiver(chatwin);
|
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;
|
break;
|
||||||
|
|
||||||
@ -233,8 +231,8 @@ cb_handle_smp_event(void *opdata, OtrlSMPEvent smp_event,
|
|||||||
case OTRL_SMPEVENT_ABORT:
|
case OTRL_SMPEVENT_ABORT:
|
||||||
if (chatwin) {
|
if (chatwin) {
|
||||||
ui_smp_aborted(chatwin);
|
ui_smp_aborted(chatwin);
|
||||||
|
ui_untrust(chatwin);
|
||||||
}
|
}
|
||||||
ui_untrust(context->username);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OTRL_SMPEVENT_IN_PROGRESS:
|
case OTRL_SMPEVENT_IN_PROGRESS:
|
||||||
|
106
src/ui/chatwin.c
106
src/ui/chatwin.c
@ -156,38 +156,64 @@ ui_smp_successful(ProfChatWin *chatwin)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ui_smp_answer_success(const char *const barejid)
|
ui_smp_answer_success(ProfChatWin *chatwin)
|
||||||
{
|
{
|
||||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
assert(chatwin != NULL);
|
||||||
if (chatwin) {
|
|
||||||
win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s successfully authenticated you.", barejid);
|
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
|
void
|
||||||
ui_smp_answer_failure(const char *const barejid)
|
ui_untrust(ProfChatWin *chatwin)
|
||||||
{
|
{
|
||||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
assert(chatwin != NULL);
|
||||||
if (chatwin) {
|
|
||||||
win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s failed to authenticate you.", barejid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
chatwin->is_otr = TRUE;
|
||||||
ui_otr_authenticating(const char *const barejid)
|
chatwin->otr_is_trusted = FALSE;
|
||||||
{
|
|
||||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
|
||||||
if (chatwin) {
|
|
||||||
win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Authenticating %s...", barejid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
ProfWin *window = (ProfWin*)chatwin;
|
||||||
ui_otr_authetication_waiting(const char *const barejid)
|
win_print(window, '!', 0, NULL, 0, THEME_OTR_UNTRUSTED, "", "OTR session untrusted.");
|
||||||
{
|
if (wins_is_current(window)) {
|
||||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
title_bar_switch();
|
||||||
if (chatwin) {
|
|
||||||
win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Awaiting authentication from %s...", barejid);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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
|
void
|
||||||
ui_recipient_gone(const char *const barejid, const char *const resource)
|
ui_recipient_gone(const char *const barejid, const char *const resource)
|
||||||
{
|
{
|
||||||
|
12
src/ui/ui.h
12
src/ui/ui.h
@ -64,8 +64,8 @@ void ui_sigwinch_handler(int sig);
|
|||||||
|
|
||||||
void ui_gone_secure(ProfChatWin *chatwin, gboolean trusted);
|
void ui_gone_secure(ProfChatWin *chatwin, gboolean trusted);
|
||||||
void ui_gone_insecure(ProfChatWin *chatwin);
|
void ui_gone_insecure(ProfChatWin *chatwin);
|
||||||
void ui_trust(const char *const barejid);
|
void ui_trust(ProfChatWin *chatwin);
|
||||||
void ui_untrust(const char *const barejid);
|
void ui_untrust(ProfChatWin *chatwin);
|
||||||
void ui_smp_recipient_initiated(ProfChatWin *chatwin);
|
void ui_smp_recipient_initiated(ProfChatWin *chatwin);
|
||||||
void ui_smp_recipient_initiated_q(ProfChatWin *chatwin, const char *question);
|
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_unsuccessful_receiver(ProfChatWin *chatwin);
|
||||||
void ui_smp_aborted(ProfChatWin *chatwin);
|
void ui_smp_aborted(ProfChatWin *chatwin);
|
||||||
|
|
||||||
void ui_smp_answer_success(const char *const barejid);
|
void ui_smp_answer_success(ProfChatWin *chatwin);
|
||||||
void ui_smp_answer_failure(const char *const barejid);
|
void ui_smp_answer_failure(ProfChatWin *chatwin);
|
||||||
|
|
||||||
void ui_otr_authenticating(const char *const barejid);
|
void ui_otr_authenticating(ProfChatWin *chatwin);
|
||||||
void ui_otr_authetication_waiting(const char *const recipient);
|
void ui_otr_authetication_waiting(ProfChatWin *chatwin);
|
||||||
|
|
||||||
void ui_handle_otr_error(const char *const barejid, const char *const message);
|
void ui_handle_otr_error(const char *const barejid, const char *const message);
|
||||||
|
|
||||||
|
@ -68,8 +68,8 @@ void ui_switch_win(ProfWin *win) {}
|
|||||||
|
|
||||||
void ui_gone_secure(ProfChatWin *chatwin, gboolean trusted) {}
|
void ui_gone_secure(ProfChatWin *chatwin, gboolean trusted) {}
|
||||||
void ui_gone_insecure(ProfChatWin *chatwin) {}
|
void ui_gone_insecure(ProfChatWin *chatwin) {}
|
||||||
void ui_trust(const char * const barejid) {}
|
void ui_trust(ProfChatWin *chatwin) {}
|
||||||
void ui_untrust(const char * const barejid) {}
|
void ui_untrust(ProfChatWin *chatwin) {}
|
||||||
void ui_smp_recipient_initiated(ProfChatWin *chatwin) {}
|
void ui_smp_recipient_initiated(ProfChatWin *chatwin) {}
|
||||||
void ui_smp_recipient_initiated_q(ProfChatWin *chatwin, const char *question) {}
|
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_unsuccessful_receiver(ProfChatWin *chatwin) {}
|
||||||
void ui_smp_aborted(ProfChatWin *chatwin) {}
|
void ui_smp_aborted(ProfChatWin *chatwin) {}
|
||||||
|
|
||||||
void ui_smp_answer_success(const char * const barejid) {}
|
void ui_smp_answer_success(ProfChatWin *chatwin) {}
|
||||||
void ui_smp_answer_failure(const char * const barejid) {}
|
void ui_smp_answer_failure(ProfChatWin *chatwin) {}
|
||||||
|
|
||||||
void ui_otr_authenticating(const char * const barejid) {}
|
void ui_otr_authenticating(ProfChatWin *chatwin) {}
|
||||||
void ui_otr_authetication_waiting(const char * const recipient) {}
|
void ui_otr_authetication_waiting(ProfChatWin *chatwin) {}
|
||||||
void ui_sigwinch_handler(int sig) {}
|
void ui_sigwinch_handler(int sig) {}
|
||||||
|
|
||||||
unsigned long ui_get_idle_time(void)
|
unsigned long ui_get_idle_time(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user