Changeset 6d9f0ba for otr.c


Ignore:
Timestamp:
2013-08-02T11:15:21Z (11 years ago)
Author:
unknown <pesco@…>
Branches:
master
Children:
22ec21d
Parents:
b939cff
Message:

implement otr_error_message callback

File:
1 edited

Legend:

Unmodified
Added
Removed
  • otr.c

    rb939cff r6d9f0ba  
    8787        const char *message, gcry_error_t err);
    8888
     89const char *op_otr_error_message(void *opdata, ConnContext *ctx,
     90        OtrlErrorCode err_code);
     91
    8992/** otr sub-command handlers: **/
    9093
     
    229232        /* stuff added with libotr 4.0.0 */
    230233        otr_ops.received_symkey = NULL;         /* we don't use the extra key */
    231         otr_ops.otr_error_message = NULL;       // TODO?
     234        otr_ops.otr_error_message = &op_otr_error_message;
    232235        otr_ops.otr_error_message_free = NULL;
    233         otr_ops.resent_msg_prefix = NULL;       // don't need?
     236        otr_ops.resent_msg_prefix = NULL;       /* default: [resent] */
    234237        otr_ops.resent_msg_prefix_free = NULL;
    235238        otr_ops.handle_smp_event = &op_handle_smp_event;
     
    861864                /* ignore  XXX log? */
    862865                break;
     866        }
     867}
     868
     869const char *op_otr_error_message(void *opdata, ConnContext *ctx,
     870        OtrlErrorCode err_code)
     871{
     872        switch(err_code) {
     873        case OTRL_ERRCODE_ENCRYPTION_ERROR:
     874                return "i failed to encrypt a message";
     875        case OTRL_ERRCODE_MSG_NOT_IN_PRIVATE:
     876                return "you sent an encrypted message i didn't expect";
     877        case OTRL_ERRCODE_MSG_UNREADABLE:
     878                return "could not read encrypted message";
     879        case OTRL_ERRCODE_MSG_MALFORMED:
     880                return "you sent a malformed OTR message";
     881        default:
     882                return "i suffered an unexpected OTR error";
    863883        }
    864884}
Note: See TracChangeset for help on using the changeset viewer.