Changeset a13855a for otr.c


Ignore:
Timestamp:
2008-02-06T16:42:23Z (12 years ago)
Author:
Sven Moritz Hallberg <sm@…>
Branches:
master
Children:
5a71d9c
Parents:
3c80a9d
Message:

use peernicks and try to guess max message size

File:
1 edited

Legend:

Unmodified
Added
Removed
  • otr.c

    r3c80a9d ra13855a  
    4343void op_log_message(void *opdata, const char *message);
    4444
    45 /* TODO: int op_max_message_size(void *opdata, ConnContext *context); */
    46 
    47 /* TODO: const char *op_account_name(void *opdata, const char *account,
    48         const char *protocol); */
     45int op_max_message_size(void *opdata, ConnContext *context);
     46
     47const char *op_account_name(void *opdata, const char *account, const char *protocol);
    4948
    5049
     
    132131        global.otr_ops.still_secure = &op_still_secure;
    133132        global.otr_ops.log_message = &op_log_message;
    134         global.otr_ops.max_message_size = NULL;
    135         global.otr_ops.account_name = NULL;
     133        global.otr_ops.max_message_size = &op_max_message_size;
     134        global.otr_ops.account_name = &op_account_name;
    136135        global.otr_ops.account_name_free = NULL;
    137136}
     
    221220{
    222221        irc_t *irc = a->irc;
    223         char buf[45];
    224         char *fp;
    225        
    226         fp = otrl_privkey_fingerprint(irc->otr_us, buf, a->user, a->prpl->name);
    227         if(fp) {
    228                 irc_usermsg(irc, "otr: %s/%s ready with f'print %s",
    229                         a->user, a->prpl->name, fp);
     222        OtrlPrivKey *k;
     223       
     224        k = otrl_privkey_find(irc->otr_us, a->user, a->prpl->name);
     225        if(k) {
     226                irc_usermsg(irc, "otr: %s/%s ready",
     227                        a->user, a->prpl->name);
    230228        } else {
    231229                otr_keygen(irc, a->user, a->prpl->name);
     
    242240    if(!g_mutex_trylock(ic->irc->otr_mutex)) {
    243241        /* TODO: queue msgs received during keygen for later */
    244                 irc_usermsg(ic->irc, "msg from %s/%s during keygen - dropped",
    245                         handle, ic->acc->prpl->name);
     242                irc_usermsg(ic->irc, "msg from %s during keygen - dropped",
     243                        peernick(ic->irc, handle, ic->acc->prpl->name));
    246244                return NULL;
    247245        }
     
    290288   
    291289    if(!g_mutex_trylock(ic->irc->otr_mutex)) {
    292         irc_usermsg(ic->irc, "msg to %s/%s during keygen - not sent",
    293                 handle, ic->acc->prpl->name);
     290        irc_usermsg(ic->irc, "msg to %s during keygen - not sent",
     291                peernick(ic->irc, handle, ic->acc->prpl->name));
    294292        return 1;
    295293    }
     
    487485{
    488486        log_message(LOGLVL_INFO, "%s", message);
     487}
     488
     489int op_max_message_size(void *opdata, ConnContext *context)
     490{
     491        /* TODO: make max_message_size a property of the prpl.
     492                 the values here are taken from the libotr UPGRADING file */
     493        if(!strcmp(context->protocol, "msn"))
     494                return 1409;
     495        if(!strcmp(context->protocol, "yahoo"))
     496                return 832;
     497        if(!strcmp(context->protocol, "oscar"))
     498                return 2343;
     499}
     500
     501const char *op_account_name(void *opdata, const char *account, const char *protocol)
     502{
     503        struct im_connection *ic = (struct im_connection *)opdata;
     504
     505        log_message(LOGLVL_DEBUG, "op_account_name '%s' '%s'", account, protocol);
     506       
     507        return peernick(ic->irc, account, protocol);
    489508}
    490509
     
    947966        account_t *acc = (account_t *)data;
    948967       
     968        /* TODO: remember that we didn't want a key? */
    949969        irc_usermsg(acc->irc, "proceeding without key, otr inoperable on %s/%s",
    950970                acc->user, acc->prpl->name);
Note: See TracChangeset for help on using the changeset viewer.