diff options
author | James Booth <boothj5@gmail.com> | 2014-02-09 02:24:47 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-02-09 02:24:47 +0000 |
commit | 26e1fd545c81c9f93464ca0a6308fd40a37a4804 (patch) | |
tree | 5729741fa104c3f14dfec359d2758990185d73bb /src | |
parent | 4bd5cf35ffe49f8ed78775997d45b667538d2935 (diff) | |
download | profani-tty-26e1fd545c81c9f93464ca0a6308fd40a37a4804.tar.gz |
Added libotr4 message handlers
Diffstat (limited to 'src')
-rw-r--r-- | src/otr4.c | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/otr4.c b/src/otr4.c index 9cc4af63..69360d0f 100644 --- a/src/otr4.c +++ b/src/otr4.c @@ -62,12 +62,37 @@ cb_inject_message(void *opdata, const char *accountname, message_send(message, recipient); } -static int -cb_display_otr_message(void *opdata, const char *accountname, - const char *protocol, const char *username, const char *msg) +static const char* +cb_otr_error_message(void *opdata, ConnContext *context, + OtrlErrorCode err_code) +{ + switch(err_code) + { + case OTRL_ERRCODE_ENCRYPTION_ERROR: + return strdup("OTR Error: occured while encrypting a message"); + case OTRL_ERRCODE_MSG_NOT_IN_PRIVATE: + return strdup("OTR Error: Sent encrypted message to somebody who is not in a mutual OTR session"); + case OTRL_ERRCODE_MSG_UNREADABLE: + return strdup("OTR Error: sent an unreadable encrypted message"); + case OTRL_ERRCODE_MSG_MALFORMED: + return strdup("OTR Error: message sent is malformed"); + default: + return strdup("OTR Error: unknown"); + } +} + +static void +cb_otr_error_message_free(void *opdata, const char *err_msg) +{ + free(err_msg); +} + +static void +cb_handle_msg_event(void *opdata, OtrlMessageEvent msg_event, + ConnContext *context, const char *message, + gcry_error_t err) { - cons_show_error("%s", msg); - return 0; + cons_show_error("%s", message); } static void @@ -109,6 +134,9 @@ otr_init(void) ops.policy = cb_policy; ops.is_logged_in = cb_is_logged_in; ops.inject_message = cb_inject_message; + ops.otr_error_message = cb_otr_error_message; + ops.otr_error_message_free = cb_otr_error_message_free; + ops.handle_msg_event = cb_handle_msg_event; ops.display_otr_message = cb_display_otr_message; ops.write_fingerprints = cb_write_fingerprints; ops.gone_secure = cb_gone_secure; |