--- a/mcabber/mcabberrc.example Tue Oct 02 23:06:33 2007 +0200
+++ b/mcabber/mcabberrc.example Wed Oct 03 21:27:46 2007 +0200
@@ -362,6 +362,11 @@
#pgp disable foo@bar.org
#pgp setkey bar@foo.net C9940A9BB0B92210
+# OTR directory
+# If mcabber is built with OTR (Off-The-Record) support, you can specify
+# the OTR directory with the otr_dir option (default = ~/.mcabber/otr/).
+#set otr_dir = "~/.mcabber/otr/"
+
# Aliases
alias me = say /me
alias online = status online
--- a/mcabber/src/otr.c Tue Oct 02 23:06:33 2007 +0200
+++ b/mcabber/src/otr.c Wed Oct 03 21:27:46 2007 +0200
@@ -109,10 +109,11 @@
static void otr_startstop(const char * buddy, int start);
static void otr_handle_smp_tlvs(OtrlTLV * tlvs, ConnContext * ctx);
+static char * otr_get_dir(void);
void otr_init(const char *jid)
{
- char * root = expand_filename("~/.mcabber/otr/");
+ char * root = otr_get_dir();
account = jidtodisp(jid);
keyfile = g_strdup_printf("%s%s.key", root, account);
fprfile = g_strdup_printf("%s%s.fpr", root, account);
@@ -135,7 +136,7 @@
{
ConnContext * ctx;
- for(ctx = userstate->context_root; ctx; ctx = ctx->next)
+ for (ctx = userstate->context_root; ctx; ctx = ctx->next)
if (ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED)
otr_message_disconnect(ctx);
@@ -158,6 +159,16 @@
keyfile = NULL;
}
+static char * otr_get_dir(void)
+{
+ char * configured_dir = (char *)settings_opt_get("otr_dir");
+
+ if (configured_dir)
+ return expand_filename(configured_dir);
+ else
+ return expand_filename("~/.mcabber/otr/");
+}
+
static ConnContext * otr_get_context(const char *buddy)
{
int null = 0;
@@ -548,6 +559,7 @@
const char *protocol)
{
gcry_error_t e;
+ char * root;
scr_LogPrint(LPRINT_LOGNORM,
"Generating new OTR key for %s. This may take a while...",
@@ -556,9 +568,12 @@
e = otrl_privkey_generate(userstate, keyfile, accountname, protocol);
- if (e)
- scr_LogPrint(LPRINT_LOGNORM, "OTR key generation failed!"
- " Please mkdir ~/.mcabber/otr/ and restart mcabber.");
+ if (e) {
+ root = otr_get_dir();
+ scr_LogPrint(LPRINT_LOGNORM, "OTR key generation failed! Please mkdir "
+ "%s if you want to use otr encryption.", root);
+ g_free(root);
+ }
else
scr_LogPrint(LPRINT_LOGNORM, "OTR key generated.");
}