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

Added OTR error messages

This commit is contained in:
James Booth 2015-03-15 01:26:09 +00:00
parent 385336c10b
commit 49022068ef
3 changed files with 64 additions and 6 deletions

View File

@ -113,12 +113,57 @@ cb_handle_msg_event(void *opdata, OtrlMessageEvent msg_event,
ConnContext *context, const char *message,
gcry_error_t err)
{
if (err != 0) {
if (message != NULL) {
cons_show_error("%s", message);
} else {
cons_show_error("OTR error event with no message.");
}
GString *err_msg;
switch (msg_event)
{
case OTRL_MSGEVENT_ENCRYPTION_REQUIRED:
ui_handle_otr_error(context->username, "OTR: Policy requires encryption, but attempting to send an unencrypted message.");
break;
case OTRL_MSGEVENT_ENCRYPTION_ERROR:
ui_handle_otr_error(context->username, "OTR: Error occured while encrypting a message, message not sent.");
break;
case OTRL_MSGEVENT_CONNECTION_ENDED:
ui_handle_otr_error(context->username, "OTR: Message not sent because contact has ended the private conversation.");
break;
case OTRL_MSGEVENT_SETUP_ERROR:
ui_handle_otr_error(context->username, "OTR: A private conversation could not be set up.");
break;
case OTRL_MSGEVENT_MSG_REFLECTED:
ui_handle_otr_error(context->username, "OTR: Received our own OTR message.");
break;
case OTRL_MSGEVENT_MSG_RESENT:
ui_handle_otr_error(context->username, "OTR: The previous message was resent.");
break;
case OTRL_MSGEVENT_RCVDMSG_NOT_IN_PRIVATE:
ui_handle_otr_error(context->username, "OTR: Received an encrypted message but no private connection established.");
break;
case OTRL_MSGEVENT_RCVDMSG_UNREADABLE:
ui_handle_otr_error(context->username, "OTR: Cannot read the received message.");
break;
case OTRL_MSGEVENT_RCVDMSG_MALFORMED:
ui_handle_otr_error(context->username, "OTR: The message received contains malformed data.");
break;
case OTRL_MSGEVENT_RCVDMSG_GENERAL_ERR:
err_msg = g_string_new("OTR: Received error: ");
g_string_append(err_msg, message);
g_string_append(err_msg, ".");
ui_handle_otr_error(context->username, err_msg->str);
g_string_free(err_msg, TRUE);
break;
case OTRL_MSGEVENT_RCVDMSG_UNENCRYPTED:
err_msg = g_string_new("OTR: Received an unencrypted message: ");
g_string_append(err_msg, message);
ui_handle_otr_error(context->username, err_msg->str);
g_string_free(err_msg, TRUE);
break;
case OTRL_MSGEVENT_RCVDMSG_UNRECOGNIZED:
ui_handle_otr_error(context->username, "OTR: Cannot recognize the type of message received.");
break;
case OTRL_MSGEVENT_RCVDMSG_FOR_OTHER_INSTANCE:
ui_handle_otr_error(context->username, "OTR: Received and discarded a message intended for another instance.");
break;
default:
break;
}
}

View File

@ -1107,6 +1107,17 @@ ui_otr_authetication_waiting(const char * const barejid)
}
}
void
ui_handle_otr_error(const char * const barejid, const char * const message)
{
ProfChatWin *chatwin = wins_get_chat(barejid);
if (chatwin) {
win_save_print((ProfWin*)chatwin, '!', NULL, 0, THEME_ERROR, "", message);
} else {
cons_show_error(message);
}
}
void
ui_trust(const char * const barejid)
{

View File

@ -82,6 +82,8 @@ void ui_smp_answer_failure(const char * const barejid);
void ui_otr_authenticating(const char * const barejid);
void ui_otr_authetication_waiting(const char * const recipient);
void ui_handle_otr_error(const char * const barejid, const char * const message);
unsigned long ui_get_idle_time(void);
void ui_reset_idle_time(void);
void ui_new_chat_win(const char * const barejid);