107 static void otr_message_disconnect(ConnContext *ctx); |
107 static void otr_message_disconnect(ConnContext *ctx); |
108 static ConnContext * otr_get_context(const char *buddy); |
108 static ConnContext * otr_get_context(const char *buddy); |
109 static void otr_startstop(const char * buddy, int start); |
109 static void otr_startstop(const char * buddy, int start); |
110 static void otr_handle_smp_tlvs(OtrlTLV * tlvs, ConnContext * ctx); |
110 static void otr_handle_smp_tlvs(OtrlTLV * tlvs, ConnContext * ctx); |
111 |
111 |
|
112 static char * otr_get_dir(void); |
112 |
113 |
113 void otr_init(const char *jid) |
114 void otr_init(const char *jid) |
114 { |
115 { |
115 char * root = expand_filename("~/.mcabber/otr/"); |
116 char * root = otr_get_dir(); |
116 account = jidtodisp(jid); |
117 account = jidtodisp(jid); |
117 keyfile = g_strdup_printf("%s%s.key", root, account); |
118 keyfile = g_strdup_printf("%s%s.key", root, account); |
118 fprfile = g_strdup_printf("%s%s.fpr", root, account); |
119 fprfile = g_strdup_printf("%s%s.fpr", root, account); |
119 g_free(root); |
120 g_free(root); |
120 |
121 |
546 * desired. */ |
557 * desired. */ |
547 static void cb_create_privkey(void *opdata, const char *accountname, |
558 static void cb_create_privkey(void *opdata, const char *accountname, |
548 const char *protocol) |
559 const char *protocol) |
549 { |
560 { |
550 gcry_error_t e; |
561 gcry_error_t e; |
|
562 char * root; |
551 |
563 |
552 scr_LogPrint(LPRINT_LOGNORM, |
564 scr_LogPrint(LPRINT_LOGNORM, |
553 "Generating new OTR key for %s. This may take a while...", |
565 "Generating new OTR key for %s. This may take a while...", |
554 accountname); |
566 accountname); |
555 scr_DoUpdate(); |
567 scr_DoUpdate(); |
556 |
568 |
557 e = otrl_privkey_generate(userstate, keyfile, accountname, protocol); |
569 e = otrl_privkey_generate(userstate, keyfile, accountname, protocol); |
558 |
570 |
559 if (e) |
571 if (e) { |
560 scr_LogPrint(LPRINT_LOGNORM, "OTR key generation failed!" |
572 root = otr_get_dir(); |
561 " Please mkdir ~/.mcabber/otr/ and restart mcabber."); |
573 scr_LogPrint(LPRINT_LOGNORM, "OTR key generation failed! Please mkdir " |
|
574 "%s if you want to use otr encryption.", root); |
|
575 g_free(root); |
|
576 } |
562 else |
577 else |
563 scr_LogPrint(LPRINT_LOGNORM, "OTR key generated."); |
578 scr_LogPrint(LPRINT_LOGNORM, "OTR key generated."); |
564 } |
579 } |
565 |
580 |
566 /* Report whether you think the given user is online. Return 1 if |
581 /* Report whether you think the given user is online. Return 1 if |