aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Moritz Hallberg <sm@khjk.org>2008-02-12 01:01:35 +0100
committerSven Moritz Hallberg <sm@khjk.org>2008-02-12 01:01:35 +0100
commite2b15bb7ebd347dd044167575068ef87ffd9301c (patch)
tree5ff386cd06c3d282b39e0e8f8792f956222b31a6
parent5f4eedefd2a444c213f65283a3d942d6287e6ea2 (diff)
- add global policy setting
- add copyright and author notices to otr.h and otr.c
-rw-r--r--irc.c1
-rw-r--r--otr.c62
-rw-r--r--otr.h28
-rw-r--r--set.c14
-rw-r--r--set.h1
5 files changed, 98 insertions, 8 deletions
diff --git a/irc.c b/irc.c
index aea21934..b7046e59 100644
--- a/irc.c
+++ b/irc.c
@@ -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 );
diff --git a/otr.c b/otr.c
index adba7b68..757caca3 100644
--- a/otr.c
+++ b/otr.c
@@ -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]);
diff --git a/otr.h b/otr.h
index ef5453ef..ad6c6874 100644
--- a/otr.h
+++ b/otr.h
@@ -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
diff --git a/set.c b/set.c
index 0e9ae5dc..c65953f2 100644
--- a/set.c
+++ b/set.c
@@ -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;
+}
diff --git a/set.h b/set.h
index 3e1b4f66..d8d772a9 100644
--- a/set.h
+++ b/set.h
@@ -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__ */