diff options
| author | unknown <pesco@khjk.org> | 2013-08-02 13:15:21 +0200 | 
|---|---|---|
| committer | unknown <pesco@khjk.org> | 2013-08-02 13:15:21 +0200 | 
| commit | 6d9f0ba48e127bbc9050d674772248b915f9fe35 (patch) | |
| tree | 8d761ecd48532790b01df4a7108e7e4b9f2dc1fc | |
| parent | b939cff59bfd94243bcde994232c72e5b9e8e8c5 (diff) | |
implement otr_error_message callback
| -rw-r--r-- | otr.c | 24 | 
1 files changed, 22 insertions, 2 deletions
@@ -86,6 +86,9 @@ void op_handle_smp_event(void *opdata, OtrlSMPEvent ev, ConnContext *ctx,  void op_handle_msg_event(void *opdata, OtrlMessageEvent ev, ConnContext *ctx,  	const char *message, gcry_error_t err); +const char *op_otr_error_message(void *opdata, ConnContext *ctx, +	OtrlErrorCode err_code); +  /** otr sub-command handlers: **/  static void cmd_otr(irc_t *irc, char **args); @@ -228,9 +231,9 @@ void init_plugin(void)  	/* stuff added with libotr 4.0.0 */  	otr_ops.received_symkey = NULL;         /* we don't use the extra key */ -	otr_ops.otr_error_message = NULL;       // TODO? +	otr_ops.otr_error_message = &op_otr_error_message;  	otr_ops.otr_error_message_free = NULL; -	otr_ops.resent_msg_prefix = NULL;       // don't need? +	otr_ops.resent_msg_prefix = NULL;       /* default: [resent] */  	otr_ops.resent_msg_prefix_free = NULL;  	otr_ops.handle_smp_event = &op_handle_smp_event;  	otr_ops.handle_msg_event = &op_handle_msg_event; @@ -863,6 +866,23 @@ void op_handle_msg_event(void *opdata, OtrlMessageEvent ev, ConnContext *ctx,  	}  } +const char *op_otr_error_message(void *opdata, ConnContext *ctx, +	OtrlErrorCode err_code) +{ +	switch(err_code) { +	case OTRL_ERRCODE_ENCRYPTION_ERROR: +		return "i failed to encrypt a message"; +	case OTRL_ERRCODE_MSG_NOT_IN_PRIVATE: +		return "you sent an encrypted message i didn't expect"; +	case OTRL_ERRCODE_MSG_UNREADABLE: +		return "could not read encrypted message"; +	case OTRL_ERRCODE_MSG_MALFORMED: +		return "you sent a malformed OTR message"; +	default: +		return "i suffered an unexpected OTR error"; +	} +} +  /*** OTR sub-command handlers ***/  | 
