Changeset e2b15bb


Ignore:
Timestamp:
2008-02-12T00:01:35Z (17 years ago)
Author:
Sven Moritz Hallberg <sm@…>
Branches:
master
Children:
0529a7f
Parents:
5f4eede
Message:
  • add global policy setting
  • add copyright and author notices to otr.h and otr.c
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • irc.c

    r5f4eede re2b15bb  
    119119        set_add( &irc->set, "op_root", "true", set_eval_op_root, irc );
    120120        set_add( &irc->set, "op_user", "true", set_eval_op_user, irc );
     121        set_add( &irc->set, "otr_policy", "opportunistic", set_eval_otr_policy, irc );
    121122        set_add( &irc->set, "password", NULL, passchange, irc );
    122123        set_add( &irc->set, "private", "true", set_eval_bool, irc );
  • otr.c

    r5f4eede re2b15bb  
     1  /********************************************************************\
     2  * BitlBee -- An IRC to other IM-networks gateway                     *
     3  *                                                                    *
     4  * Copyright 2002-2008 Wilmer van der Gaast and others                *
     5  \********************************************************************/
     6
     7/*
     8  OTR support (cf. http://www.cypherpunks.ca/otr/)
     9  2008, Sven Moritz Hallberg <pesco@khjk.org>
     10   
     11  files used to store OTR data:
     12    <configdir>/<nick>.otr_keys
     13    <configdir>/<nick>.otr_fprints
     14   
     15  top-level todos: (search for TODO for more ;-))
     16    integrate otr_load/otr_save with existing storage backends
     17    per-account policy settings
     18    per-user policy settings
     19*/
     20
     21/*
     22  This program is free software; you can redistribute it and/or modify
     23  it under the terms of the GNU General Public License as published by
     24  the Free Software Foundation; either version 2 of the License, or
     25  (at your option) any later version.
     26
     27  This program is distributed in the hope that it will be useful,
     28  but WITHOUT ANY WARRANTY; without even the implied warranty of
     29  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     30  GNU General Public License for more details.
     31
     32  You should have received a copy of the GNU General Public License with
     33  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
     34  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
     35  Suite 330, Boston, MA  02111-1307  USA
     36*/
     37
    138#include "bitlbee.h"
    239#ifdef WITH_OTR
     
    542#include <sys/types.h>
    643#include <unistd.h>
    7 
    8 /**
    9 files used to store OTR data:
    10   $configdir/$nick.otr_keys
    11   $configdir/$nick.otr_fprints
    12  **/
    1344
    1445
     
    345376                otrl_message_free(otrmsg);
    346377        } else {
    347                 /* yeah, well, some const casts as usual... ;-) */
     378                /* note: otrl_message_sending handles policy, so that if REQUIRE_ENCRYPTION is set,
     379                   this case does not occur */
    348380                st = ic->acc->prpl->buddy_msg( ic, (char *)handle, (char *)msg, flags );
    349381        }
     
    388420OtrlPolicy op_policy(void *opdata, ConnContext *context)
    389421{
    390         /* TODO: OTR policy configurable */
     422        struct im_connection *ic = check_imc(opdata, context->accountname, context->protocol);
     423        const char *p;
     424
     425        p = set_getstr(&ic->irc->set, "otr_policy");
     426        if(!strcmp(p, "never"))
     427                return OTRL_POLICY_NEVER;
     428        if(!strcmp(p, "opportunistic"))
     429                return OTRL_POLICY_OPPORTUNISTIC;
     430        if(!strcmp(p, "manual"))
     431                return OTRL_POLICY_MANUAL;
     432        if(!strcmp(p, "always"))
     433                return OTRL_POLICY_ALWAYS;
     434       
    391435        return OTRL_POLICY_OPPORTUNISTIC;
    392436}
     
    858902                }
    859903               
     904                /* TODO: allow context specs ("user/proto/account") in 'otr forget fingerprint'? */
    860905                u = user_find(irc, args[2]);
    861906                if(!u || !u->ic) {
     
    893938                char *s;
    894939               
     940                /* TODO: allow context specs ("user/proto/account") in 'otr forget contex'? */
    895941                u = user_find(irc, args[2]);
    896942                if(!u || !u->ic) {
  • otr.h

    r5f4eede re2b15bb  
     1  /********************************************************************\
     2  * BitlBee -- An IRC to other IM-networks gateway                     *
     3  *                                                                    *
     4  * Copyright 2002-2008 Wilmer van der Gaast and others                *
     5  \********************************************************************/
     6
     7/*
     8  OTR support (cf. http://www.cypherpunks.ca/otr/)
     9  2008, Sven Moritz Hallberg <pesco@khjk.org>
     10*/
     11
     12/*
     13  This program is free software; you can redistribute it and/or modify
     14  it under the terms of the GNU General Public License as published by
     15  the Free Software Foundation; either version 2 of the License, or
     16  (at your option) any later version.
     17
     18  This program is distributed in the hope that it will be useful,
     19  but WITHOUT ANY WARRANTY; without even the implied warranty of
     20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     21  GNU General Public License for more details.
     22
     23  You should have received a copy of the GNU General Public License with
     24  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
     25  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
     26  Suite 330, Boston, MA  02111-1307  USA
     27*/
     28
    129#ifndef BITLBEE_PROTOCOLS_OTR_H
    230#define BITLBEE_PROTOCOLS_OTR_H
  • set.c

    r5f4eede re2b15bb  
    369369        return value;
    370370}
     371
     372/* possible values: never, opportunistic, manual, always */
     373char *set_eval_otr_policy( set_t *set, char *value )
     374{
     375        if ( !strcmp(value, "never") )
     376                return value;
     377        if ( !strcmp(value, "opportunistic") )
     378                return value;
     379        if ( !strcmp(value, "manual") )
     380                return value;
     381        if ( !strcmp(value, "always") )
     382                return value;
     383        return NULL;
     384}
  • set.h

    r5f4eede re2b15bb  
    102102char *set_eval_voice_buddies( set_t *set, char *value );
    103103char *set_eval_charset( set_t *set, char *value );
     104char *set_eval_otr_policy( set_t *set, char *value );
    104105
    105106#endif /* __SET_H__ */
Note: See TracChangeset for help on using the changeset viewer.