diff options
| -rw-r--r-- | irc.c | 1 | ||||
| -rw-r--r-- | otr.c | 62 | ||||
| -rw-r--r-- | otr.h | 28 | ||||
| -rw-r--r-- | set.c | 14 | ||||
| -rw-r--r-- | set.h | 1 | 
5 files changed, 98 insertions, 8 deletions
| @@ -118,6 +118,7 @@ irc_t *irc_new( int fd )  	set_add( &irc->set, "op_buddies", "trusted", set_eval_op_buddies, irc );  	set_add( &irc->set, "op_root", "true", set_eval_op_root, irc );  	set_add( &irc->set, "op_user", "true", set_eval_op_user, irc ); +	set_add( &irc->set, "otr_policy", "opportunistic", set_eval_otr_policy, irc );  	set_add( &irc->set, "password", NULL, passchange, irc );  	set_add( &irc->set, "private", "true", set_eval_bool, irc );  	set_add( &irc->set, "query_order", "lifo", NULL, irc ); @@ -1,3 +1,40 @@ +  /********************************************************************\ +  * BitlBee -- An IRC to other IM-networks gateway                     * +  *                                                                    * +  * Copyright 2002-2008 Wilmer van der Gaast and others                * +  \********************************************************************/ + +/* +  OTR support (cf. http://www.cypherpunks.ca/otr/) +  2008, Sven Moritz Hallberg <pesco@khjk.org> +     +  files used to store OTR data: +    <configdir>/<nick>.otr_keys +    <configdir>/<nick>.otr_fprints +     +  top-level todos: (search for TODO for more ;-)) +    integrate otr_load/otr_save with existing storage backends +    per-account policy settings +    per-user policy settings +*/ + +/* +  This program is free software; you can redistribute it and/or modify +  it under the terms of the GNU General Public License as published by +  the Free Software Foundation; either version 2 of the License, or +  (at your option) any later version. + +  This program is distributed in the hope that it will be useful, +  but WITHOUT ANY WARRANTY; without even the implied warranty of +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +  GNU General Public License for more details. + +  You should have received a copy of the GNU General Public License with +  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; +  if not, write to the Free Software Foundation, Inc., 59 Temple Place, +  Suite 330, Boston, MA  02111-1307  USA +*/ +  #include "bitlbee.h"  #ifdef WITH_OTR  #include "irc.h" @@ -5,12 +42,6 @@  #include <sys/types.h>  #include <unistd.h> -/** -files used to store OTR data: -  $configdir/$nick.otr_keys -  $configdir/$nick.otr_fprints - **/ -  /** OTR interface routines for the OtrlMessageAppOps struct: **/ @@ -344,7 +375,8 @@ int otr_send_message(struct im_connection *ic, const char *handle, const char *m  			otrmsg, OTRL_FRAGMENT_SEND_ALL, NULL);  		otrl_message_free(otrmsg);  	} else { -		/* yeah, well, some const casts as usual... ;-) */ +		/* note: otrl_message_sending handles policy, so that if REQUIRE_ENCRYPTION is set, +		   this case does not occur */  		st = ic->acc->prpl->buddy_msg( ic, (char *)handle, (char *)msg, flags );  	} @@ -387,7 +419,19 @@ void cmd_otr(irc_t *irc, char **args)  OtrlPolicy op_policy(void *opdata, ConnContext *context)  { -	/* TODO: OTR policy configurable */ +	struct im_connection *ic = check_imc(opdata, context->accountname, context->protocol); +	const char *p; + +	p = set_getstr(&ic->irc->set, "otr_policy"); +	if(!strcmp(p, "never")) +		return OTRL_POLICY_NEVER; +	if(!strcmp(p, "opportunistic")) +		return OTRL_POLICY_OPPORTUNISTIC; +	if(!strcmp(p, "manual")) +		return OTRL_POLICY_MANUAL; +	if(!strcmp(p, "always")) +		return OTRL_POLICY_ALWAYS; +	  	return OTRL_POLICY_OPPORTUNISTIC;  } @@ -857,6 +901,7 @@ void cmd_otr_forget(irc_t *irc, char **args)  			return;  		} +		/* TODO: allow context specs ("user/proto/account") in 'otr forget fingerprint'? */  		u = user_find(irc, args[2]);  		if(!u || !u->ic) {  			irc_usermsg(irc, "%s: unknown user", args[2]); @@ -892,6 +937,7 @@ void cmd_otr_forget(irc_t *irc, char **args)  		ConnContext *ctx;  		char *s; +		/* TODO: allow context specs ("user/proto/account") in 'otr forget contex'? */  		u = user_find(irc, args[2]);  		if(!u || !u->ic) {  			irc_usermsg(irc, "%s: unknown user", args[2]); @@ -1,3 +1,31 @@ +  /********************************************************************\ +  * BitlBee -- An IRC to other IM-networks gateway                     * +  *                                                                    * +  * Copyright 2002-2008 Wilmer van der Gaast and others                * +  \********************************************************************/ + +/* +  OTR support (cf. http://www.cypherpunks.ca/otr/) +  2008, Sven Moritz Hallberg <pesco@khjk.org> +*/ + +/* +  This program is free software; you can redistribute it and/or modify +  it under the terms of the GNU General Public License as published by +  the Free Software Foundation; either version 2 of the License, or +  (at your option) any later version. + +  This program is distributed in the hope that it will be useful, +  but WITHOUT ANY WARRANTY; without even the implied warranty of +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +  GNU General Public License for more details. + +  You should have received a copy of the GNU General Public License with +  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; +  if not, write to the Free Software Foundation, Inc., 59 Temple Place, +  Suite 330, Boston, MA  02111-1307  USA +*/ +  #ifndef BITLBEE_PROTOCOLS_OTR_H  #define BITLBEE_PROTOCOLS_OTR_H @@ -368,3 +368,17 @@ char *set_eval_charset( set_t *set, char *value )  	g_iconv_close( cd );  	return value;  } + +/* possible values: never, opportunistic, manual, always */ +char *set_eval_otr_policy( set_t *set, char *value ) +{ +	if ( !strcmp(value, "never") ) +		return value; +	if ( !strcmp(value, "opportunistic") ) +		return value; +	if ( !strcmp(value, "manual") ) +		return value; +	if ( !strcmp(value, "always") ) +		return value; +	return NULL; +} @@ -101,5 +101,6 @@ char *set_eval_op_buddies( set_t *set, char *value );  char *set_eval_halfop_buddies( set_t *set, char *value );  char *set_eval_voice_buddies( set_t *set, char *value );  char *set_eval_charset( set_t *set, char *value ); +char *set_eval_otr_policy( set_t *set, char *value );  #endif /* __SET_H__ */ | 
