Mercurial > hg
annotate mcabber/src/otr.c @ 1496:b9f8c1fddb23
Add hint about setting ssl_capath for SSL certificate verification
(Suggested by js)
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Fri, 27 Jun 2008 21:56:19 +0200 |
parents | 6f5754f86fbb |
children | 24ff212a1c54 |
rev | line source |
---|---|
1299 | 1 /* |
1303
b6fdbfa6b219
Minor whitespace change
Mikael Berthe <mikael@lilotux.net>
parents:
1301
diff
changeset
|
2 * otr.c -- Off-The-Record Messaging for mcabber |
1299 | 3 * |
4 * Copyright (C) 2007 Frank Zschockelt <mcabber_otr@freakysoft.de> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or (at | |
9 * your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, but | |
12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
19 * USA | |
20 */ | |
21 | |
22 #include <config.h> | |
1470
a8b924b5474c
The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
1420
diff
changeset
|
23 #include <glib.h> |
1299 | 24 |
25 #ifdef HAVE_LIBOTR | |
26 | |
27 #include "otr.h" | |
28 #include "logprint.h" | |
29 #include "hbuf.h" | |
30 #include "jab_priv.h" | |
31 #include "roster.h" | |
32 #include "utils.h" | |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
33 #include "screen.h" |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
34 #include "settings.h" |
1470
a8b924b5474c
The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
1420
diff
changeset
|
35 #include "nohtml.h" |
1299 | 36 |
37 | |
38 static OtrlUserState userstate = NULL; | |
39 static char * account = NULL; | |
40 static char * keyfile = NULL; | |
41 static char * fprfile = NULL; | |
42 | |
1347
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
43 static int otr_is_enabled = FALSE; |
1299 | 44 |
45 static OtrlPolicy cb_policy (void *opdata, ConnContext *ctx); | |
46 static void cb_create_privkey (void *opdata, | |
47 const char *accountname, | |
48 const char *protocol); | |
49 static int cb_is_logged_in (void *opdata, | |
50 const char *accountname, | |
51 const char *protocol, | |
52 const char *recipient); | |
53 static void cb_inject_message (void *opdata, | |
54 const char *accountname, | |
55 const char *protocol, | |
56 const char *recipient, | |
57 const char *message); | |
58 static void cb_notify (void *opdata, | |
59 OtrlNotifyLevel level, | |
60 const char *accountname, | |
61 const char *protocol, | |
62 const char *username, | |
63 const char *title, | |
64 const char *primary, | |
65 const char *secondary); | |
66 static int cb_display_otr_message(void *opdata, | |
67 const char *accountname, | |
68 const char *protocol, | |
69 const char *username, | |
70 const char *msg); | |
71 static void cb_update_context_list(void *opdata); | |
72 static const char *cb_protocol_name (void *opdata, const char *protocol); | |
73 static void cb_protocol_name_free (void *opdata, | |
74 const char *protocol_name); | |
75 static void cb_new_fingerprint (void *opdata, OtrlUserState us, | |
76 const char *accountname, | |
77 const char *protocol, | |
78 const char *username, | |
79 unsigned char fingerprint[20]); | |
80 static void cb_write_fingerprints (void *opdata); | |
81 static void cb_gone_secure (void *opdata, ConnContext *context); | |
82 static void cb_gone_insecure (void *opdata, ConnContext *context); | |
83 static void cb_still_secure (void *opdata, ConnContext *context, | |
84 int is_reply); | |
85 static void cb_log_message (void *opdata, const char *message); | |
86 static int cb_max_message_size (void *opdata, ConnContext *context); | |
87 | |
88 static OtrlMessageAppOps ops = | |
89 { | |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
90 cb_policy, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
91 cb_create_privkey, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
92 cb_is_logged_in, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
93 cb_inject_message, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
94 cb_notify, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
95 cb_display_otr_message, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
96 cb_update_context_list, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
97 cb_protocol_name, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
98 cb_protocol_name_free, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
99 cb_new_fingerprint, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
100 cb_write_fingerprints, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
101 cb_gone_secure, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
102 cb_gone_insecure, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
103 cb_still_secure, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
104 cb_log_message, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
105 cb_max_message_size, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
106 NULL, /*account_name*/ |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
107 NULL /*account_name_free*/ |
1299 | 108 }; |
109 | |
110 static void otr_message_disconnect(ConnContext *ctx); | |
111 static ConnContext * otr_get_context(const char *buddy); | |
112 static void otr_startstop(const char * buddy, int start); | |
113 static void otr_handle_smp_tlvs(OtrlTLV * tlvs, ConnContext * ctx); | |
114 | |
1320 | 115 static char * otr_get_dir(void); |
1299 | 116 |
1420
08f641e91f94
Do not use "jid" as a variable name
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
117 void otr_init(const char *fjid) |
1299 | 118 { |
1347
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
119 char *root; |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
120 |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
121 otr_is_enabled = !!settings_opt_get_int("otr"); |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
122 |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
123 if (!otr_is_enabled) |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
124 return; |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
125 |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
126 OTRL_INIT; |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
127 |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
128 userstate = otrl_userstate_create (); |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
129 |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
130 root = otr_get_dir(); |
1420
08f641e91f94
Do not use "jid" as a variable name
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
131 account = jidtodisp(fjid); |
1299 | 132 keyfile = g_strdup_printf("%s%s.key", root, account); |
133 fprfile = g_strdup_printf("%s%s.fpr", root, account); | |
134 g_free(root); | |
135 | |
136 if (otrl_privkey_read(userstate, keyfile)){ | |
137 scr_LogPrint(LPRINT_LOGNORM, "Could not read OTR key from %s", keyfile); | |
138 cb_create_privkey(NULL, account, "jabber"); | |
139 } | |
140 if (otrl_privkey_read_fingerprints(userstate, fprfile, NULL, NULL)){ | |
141 scr_LogPrint(LPRINT_LOGNORM, "Could not read OTR fingerprints from %s", | |
142 fprfile); | |
143 } | |
144 } | |
145 | |
146 void otr_terminate(void) | |
147 { | |
148 ConnContext * ctx; | |
149 | |
1347
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
150 if (!otr_is_enabled) |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
151 return; |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
152 |
1320 | 153 for (ctx = userstate->context_root; ctx; ctx = ctx->next) |
1299 | 154 if (ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) |
155 otr_message_disconnect(ctx); | |
156 | |
157 g_free(account); | |
158 account = NULL; | |
1307
6c116207ab2e
Work around segfault in otrl_userstate_free()
Mikael Berthe <mikael@lilotux.net>
parents:
1306
diff
changeset
|
159 |
6c116207ab2e
Work around segfault in otrl_userstate_free()
Mikael Berthe <mikael@lilotux.net>
parents:
1306
diff
changeset
|
160 /* XXX This #ifdef is a quick workaround: when mcabber |
6c116207ab2e
Work around segfault in otrl_userstate_free()
Mikael Berthe <mikael@lilotux.net>
parents:
1306
diff
changeset
|
161 * is linked to both gnutls and libotr, libgcrypt will |
6c116207ab2e
Work around segfault in otrl_userstate_free()
Mikael Berthe <mikael@lilotux.net>
parents:
1306
diff
changeset
|
162 * segfault when we call otrl_userstate_free(). |
6c116207ab2e
Work around segfault in otrl_userstate_free()
Mikael Berthe <mikael@lilotux.net>
parents:
1306
diff
changeset
|
163 * This is reported to be a bug in libgcrypt :-/ |
6c116207ab2e
Work around segfault in otrl_userstate_free()
Mikael Berthe <mikael@lilotux.net>
parents:
1306
diff
changeset
|
164 * Mikael |
6c116207ab2e
Work around segfault in otrl_userstate_free()
Mikael Berthe <mikael@lilotux.net>
parents:
1306
diff
changeset
|
165 */ |
6c116207ab2e
Work around segfault in otrl_userstate_free()
Mikael Berthe <mikael@lilotux.net>
parents:
1306
diff
changeset
|
166 #if defined(HAVE_GNUTLS) && !defined(HAVE_OPENSSL) |
6c116207ab2e
Work around segfault in otrl_userstate_free()
Mikael Berthe <mikael@lilotux.net>
parents:
1306
diff
changeset
|
167 if (!settings_opt_get_int("ssl")) |
6c116207ab2e
Work around segfault in otrl_userstate_free()
Mikael Berthe <mikael@lilotux.net>
parents:
1306
diff
changeset
|
168 #endif |
1299 | 169 otrl_userstate_free(userstate); |
1307
6c116207ab2e
Work around segfault in otrl_userstate_free()
Mikael Berthe <mikael@lilotux.net>
parents:
1306
diff
changeset
|
170 |
1299 | 171 userstate = NULL; |
172 g_free(keyfile); | |
173 keyfile = NULL; | |
174 } | |
175 | |
1320 | 176 static char * otr_get_dir(void) |
177 { | |
1346 | 178 const char *configured_dir = settings_opt_get("otr_dir"); |
1320 | 179 |
1335
ab1b7f7a682e
Make sure the otr_dir is always slash-terminated
Mikael Berthe <mikael@lilotux.net>
parents:
1320
diff
changeset
|
180 if (configured_dir && *configured_dir) { |
ab1b7f7a682e
Make sure the otr_dir is always slash-terminated
Mikael Berthe <mikael@lilotux.net>
parents:
1320
diff
changeset
|
181 char *xp_conf_dir; |
ab1b7f7a682e
Make sure the otr_dir is always slash-terminated
Mikael Berthe <mikael@lilotux.net>
parents:
1320
diff
changeset
|
182 int l; |
ab1b7f7a682e
Make sure the otr_dir is always slash-terminated
Mikael Berthe <mikael@lilotux.net>
parents:
1320
diff
changeset
|
183 xp_conf_dir = expand_filename(configured_dir); |
ab1b7f7a682e
Make sure the otr_dir is always slash-terminated
Mikael Berthe <mikael@lilotux.net>
parents:
1320
diff
changeset
|
184 // The path must be slash-terminated |
ab1b7f7a682e
Make sure the otr_dir is always slash-terminated
Mikael Berthe <mikael@lilotux.net>
parents:
1320
diff
changeset
|
185 l = strlen(xp_conf_dir); |
ab1b7f7a682e
Make sure the otr_dir is always slash-terminated
Mikael Berthe <mikael@lilotux.net>
parents:
1320
diff
changeset
|
186 if (xp_conf_dir[l-1] != '/') { |
ab1b7f7a682e
Make sure the otr_dir is always slash-terminated
Mikael Berthe <mikael@lilotux.net>
parents:
1320
diff
changeset
|
187 char *xp_conf_dir_tmp = xp_conf_dir; |
ab1b7f7a682e
Make sure the otr_dir is always slash-terminated
Mikael Berthe <mikael@lilotux.net>
parents:
1320
diff
changeset
|
188 xp_conf_dir = g_strdup_printf("%s/", xp_conf_dir_tmp); |
ab1b7f7a682e
Make sure the otr_dir is always slash-terminated
Mikael Berthe <mikael@lilotux.net>
parents:
1320
diff
changeset
|
189 g_free(xp_conf_dir_tmp); |
ab1b7f7a682e
Make sure the otr_dir is always slash-terminated
Mikael Berthe <mikael@lilotux.net>
parents:
1320
diff
changeset
|
190 } |
ab1b7f7a682e
Make sure the otr_dir is always slash-terminated
Mikael Berthe <mikael@lilotux.net>
parents:
1320
diff
changeset
|
191 return xp_conf_dir; |
ab1b7f7a682e
Make sure the otr_dir is always slash-terminated
Mikael Berthe <mikael@lilotux.net>
parents:
1320
diff
changeset
|
192 } else { |
1320 | 193 return expand_filename("~/.mcabber/otr/"); |
1335
ab1b7f7a682e
Make sure the otr_dir is always slash-terminated
Mikael Berthe <mikael@lilotux.net>
parents:
1320
diff
changeset
|
194 } |
1320 | 195 } |
196 | |
1299 | 197 static ConnContext * otr_get_context(const char *buddy) |
198 { | |
199 int null = 0; | |
1495
6f5754f86fbb
Fix JID case issue with OTR, v2 (franky)
Mikael Berthe <mikael@lilotux.net>
parents:
1470
diff
changeset
|
200 ConnContext * ctx; |
6f5754f86fbb
Fix JID case issue with OTR, v2 (franky)
Mikael Berthe <mikael@lilotux.net>
parents:
1470
diff
changeset
|
201 char * lowcasebuddy = g_strdup(buddy); |
6f5754f86fbb
Fix JID case issue with OTR, v2 (franky)
Mikael Berthe <mikael@lilotux.net>
parents:
1470
diff
changeset
|
202 |
6f5754f86fbb
Fix JID case issue with OTR, v2 (franky)
Mikael Berthe <mikael@lilotux.net>
parents:
1470
diff
changeset
|
203 mc_strtolower(lowcasebuddy); |
6f5754f86fbb
Fix JID case issue with OTR, v2 (franky)
Mikael Berthe <mikael@lilotux.net>
parents:
1470
diff
changeset
|
204 ctx = otrl_context_find(userstate, lowcasebuddy, account, "jabber", 1, &null, |
6f5754f86fbb
Fix JID case issue with OTR, v2 (franky)
Mikael Berthe <mikael@lilotux.net>
parents:
1470
diff
changeset
|
205 NULL, NULL); |
6f5754f86fbb
Fix JID case issue with OTR, v2 (franky)
Mikael Berthe <mikael@lilotux.net>
parents:
1470
diff
changeset
|
206 g_free(lowcasebuddy); |
6f5754f86fbb
Fix JID case issue with OTR, v2 (franky)
Mikael Berthe <mikael@lilotux.net>
parents:
1470
diff
changeset
|
207 return ctx; |
1299 | 208 } |
209 | |
210 static void otr_message_disconnect(ConnContext *ctx) | |
211 { | |
212 if (ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) | |
213 cb_gone_insecure(NULL, ctx); | |
214 otrl_message_disconnect(userstate, &ops, NULL, ctx->accountname, | |
215 ctx->protocol, ctx->username); | |
216 } | |
217 | |
218 static void otr_startstop(const char * buddy, int start) | |
219 { | |
220 char * msg = NULL; | |
221 ConnContext *ctx = otr_get_context(buddy); | |
222 | |
223 if (!userstate || !ctx) | |
224 return; | |
225 | |
226 if (start && ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) | |
227 otr_message_disconnect(ctx); | |
228 | |
229 if (start) { | |
230 OtrlPolicy policy = cb_policy(NULL, ctx); | |
1308
b17754d9221b
Show a warning for /otr start|stop, if policy == plain
franky@veqlargh.fs
parents:
1307
diff
changeset
|
231 if (policy == plain) { |
b17754d9221b
Show a warning for /otr start|stop, if policy == plain
franky@veqlargh.fs
parents:
1307
diff
changeset
|
232 scr_LogPrint(LPRINT_LOGNORM, "The OTR policy for this user is set to" |
b17754d9221b
Show a warning for /otr start|stop, if policy == plain
franky@veqlargh.fs
parents:
1307
diff
changeset
|
233 " plain. You have to change it first."); |
b17754d9221b
Show a warning for /otr start|stop, if policy == plain
franky@veqlargh.fs
parents:
1307
diff
changeset
|
234 return; |
b17754d9221b
Show a warning for /otr start|stop, if policy == plain
franky@veqlargh.fs
parents:
1307
diff
changeset
|
235 } |
1299 | 236 msg = otrl_proto_default_query_msg(ctx->accountname, policy); |
237 cb_inject_message(NULL, ctx->accountname, ctx->protocol, ctx->username, | |
238 msg); | |
239 free (msg); | |
240 } | |
241 else | |
242 otr_message_disconnect(ctx); | |
243 } | |
244 | |
245 void otr_establish(const char *buddy) | |
246 { | |
247 otr_startstop(buddy, 1); | |
248 } | |
249 | |
250 void otr_disconnect(const char * buddy) | |
251 { | |
252 otr_startstop(buddy, 0); | |
253 } | |
254 | |
255 void otr_fingerprint(const char * buddy, const char * trust) | |
256 { | |
257 char fpr[45], *tr; | |
258 ConnContext *ctx = otr_get_context(buddy); | |
259 if (!userstate || !ctx) | |
260 return; | |
261 | |
262 if (!ctx->active_fingerprint || !ctx->active_fingerprint->fingerprint) { | |
263 scr_LogPrint(LPRINT_LOGNORM, | |
264 "No active fingerprint - start OTR for this buddy first."); | |
265 return; | |
266 } | |
267 | |
268 otrl_privkey_hash_to_human(fpr, ctx->active_fingerprint->fingerprint); | |
269 if (trust) { | |
270 if (strcmp(fpr, trust) == 0) | |
271 otrl_context_set_trust(ctx->active_fingerprint, "trust"); | |
272 else | |
273 otrl_context_set_trust(ctx->active_fingerprint, NULL); | |
274 } | |
275 | |
276 tr = ctx->active_fingerprint->trust; | |
277 scr_LogPrint(LPRINT_LOGNORM, "%s [%44s]: %s", ctx->username, fpr, | |
278 tr && *tr ? "trusted" : "untrusted"); | |
279 cb_write_fingerprints(NULL); | |
280 } | |
281 | |
282 static void otr_handle_smp_tlvs(OtrlTLV * tlvs, ConnContext * ctx) | |
283 { | |
284 OtrlTLV *tlv = NULL; | |
285 char *sbuf = NULL; | |
286 NextExpectedSMP nextMsg = ctx->smstate->nextExpected; | |
287 | |
288 tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1); | |
289 if (tlv) { | |
290 if (nextMsg != OTRL_SMP_EXPECT1) | |
291 otr_smp_abort(ctx->username); | |
292 else { | |
293 sbuf = g_strdup_printf("OTR: Received SMP Initiation. " | |
294 "Answer with /otr smpr %s $secret", | |
295 ctx->username); | |
296 } | |
297 } | |
298 tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP2); | |
299 if (tlv) { | |
300 if (nextMsg != OTRL_SMP_EXPECT2) | |
301 otr_smp_abort(ctx->username); | |
302 else { | |
303 sbuf = g_strdup("OTR: Received SMP Response."); | |
304 /* If we received TLV2, we will send TLV3 and expect TLV4 */ | |
305 ctx->smstate->nextExpected = OTRL_SMP_EXPECT4; | |
306 } | |
307 } | |
308 tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP3); | |
309 if (tlv) { | |
310 if (nextMsg != OTRL_SMP_EXPECT3) | |
311 otr_smp_abort(ctx->username); | |
312 else { | |
313 /* If we received TLV3, we will send TLV4 | |
314 * We will not expect more messages, so prepare for next SMP */ | |
315 ctx->smstate->nextExpected = OTRL_SMP_EXPECT1; | |
316 /* Report result to user */ | |
317 if (ctx->active_fingerprint && ctx->active_fingerprint->trust && | |
318 *ctx->active_fingerprint->trust != '\0') | |
319 sbuf = g_strdup("OTR: SMP succeeded"); | |
320 else | |
321 sbuf = g_strdup("OTR: SMP failed"); | |
322 } | |
323 } | |
324 tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP4); | |
325 if (tlv) { | |
326 if (nextMsg != OTRL_SMP_EXPECT4) | |
327 otr_smp_abort(ctx->username); | |
328 else { | |
329 /* We will not expect more messages, so prepare for next SMP */ | |
330 ctx->smstate->nextExpected = OTRL_SMP_EXPECT1; | |
331 /* Report result to user */ | |
332 if (ctx->active_fingerprint && ctx->active_fingerprint->trust && | |
333 *ctx->active_fingerprint->trust != '\0') | |
334 sbuf = g_strdup("OTR: SMP succeeded"); | |
335 else | |
336 sbuf = g_strdup("OTR: SMP failed"); | |
337 } | |
338 } | |
339 tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP_ABORT); | |
340 if (tlv) { | |
341 /* The message we are waiting for will not arrive, so reset | |
342 * and prepare for the next SMP */ | |
343 sbuf = g_strdup("OTR: SMP aborted by your buddy"); | |
344 ctx->smstate->nextExpected = OTRL_SMP_EXPECT1; | |
345 } | |
346 | |
347 if (sbuf) { | |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
348 scr_WriteIncomingMessage(ctx->username, sbuf, 0, HBB_PREFIX_INFO, 0); |
1299 | 349 g_free(sbuf); |
350 } | |
351 } | |
352 | |
353 /* | |
354 * returns whether a otr_message was received | |
355 * sets *otr_data to NULL, when it was an internal otr message | |
356 */ | |
357 int otr_receive(char **otr_data, const char * buddy, int * free_msg) | |
358 { | |
359 int ignore_message; | |
360 char *newmessage = NULL; | |
361 OtrlTLV *tlvs = NULL; | |
362 OtrlTLV *tlv = NULL; | |
363 ConnContext * ctx; | |
364 | |
365 *free_msg = 0; | |
366 ignore_message = otrl_message_receiving(userstate, &ops, NULL, account, | |
367 "jabber", buddy, *otr_data, &newmessage, &tlvs, NULL, NULL); | |
368 | |
369 ctx = otr_get_context(buddy); | |
370 | |
371 tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED); | |
372 if (tlv) { | |
373 /* Notify the user that the other side disconnected. */ | |
374 if (ctx) { | |
375 cb_gone_insecure(NULL, ctx); | |
376 otr_disconnect(buddy); | |
377 } | |
378 } | |
379 | |
380 otr_handle_smp_tlvs(tlvs, ctx); | |
381 | |
382 if (tlvs != NULL) | |
383 otrl_tlv_free(tlvs); | |
384 | |
385 if (ignore_message) | |
386 *otr_data = NULL; | |
387 | |
388 if (!ignore_message && newmessage) { | |
389 *free_msg = 1; | |
1470
a8b924b5474c
The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
1420
diff
changeset
|
390 *otr_data = html_strip(newmessage); |
1299 | 391 otrl_message_free(newmessage); |
392 if (ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) | |
393 return 1; | |
394 } | |
395 return 0; | |
396 } | |
397 | |
398 int otr_send(char **msg, const char *buddy) | |
399 { | |
400 gcry_error_t err; | |
401 char *newmessage = NULL; | |
1470
a8b924b5474c
The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
1420
diff
changeset
|
402 char *htmlmsg; |
1299 | 403 ConnContext * ctx = otr_get_context(buddy); |
404 | |
1470
a8b924b5474c
The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
1420
diff
changeset
|
405 htmlmsg = html_escape(*msg); |
a8b924b5474c
The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
1420
diff
changeset
|
406 |
1299 | 407 err = otrl_message_sending(userstate, &ops, NULL, account, "jabber", buddy, |
1470
a8b924b5474c
The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
1420
diff
changeset
|
408 htmlmsg, NULL, &newmessage, NULL, NULL); |
a8b924b5474c
The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
1420
diff
changeset
|
409 |
a8b924b5474c
The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
1420
diff
changeset
|
410 g_free(htmlmsg); |
1299 | 411 |
412 if (err) | |
413 *msg = NULL; /*something went wrong, don't send the plain-message! */ | |
414 | |
415 if (!err && newmessage) { | |
416 *msg = g_strdup(newmessage); | |
417 otrl_message_free(newmessage); | |
418 if (cb_policy(NULL, ctx) & OTRL_POLICY_REQUIRE_ENCRYPTION || | |
419 ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) | |
420 return 1; | |
421 } | |
422 return 0; | |
423 } | |
424 | |
425 /* Prints OTR connection state */ | |
426 void otr_print_info(const char * buddy) | |
427 { | |
428 const char *state, *auth, *policy; | |
429 ConnContext * ctx = otr_get_context(buddy); | |
430 OtrlPolicy p = cb_policy (ctx->app_data, ctx); | |
431 | |
432 if (!userstate || !ctx) | |
433 return; | |
434 | |
435 switch (ctx->msgstate) { | |
436 case OTRL_MSGSTATE_PLAINTEXT: state = "plaintext"; break; | |
437 case OTRL_MSGSTATE_ENCRYPTED: | |
438 switch (ctx->protocol_version) { | |
439 case 1: state = "encrypted V1"; break; | |
440 case 2: state = "encrypted V2"; break; | |
441 default:state = "encrypted"; | |
442 }; | |
443 break; | |
444 case OTRL_MSGSTATE_FINISHED: state = "finished"; break; | |
445 default: state = "unknown state"; | |
446 } | |
447 switch (ctx->auth.authstate) { | |
448 case OTRL_AUTHSTATE_NONE: | |
449 switch (ctx->otr_offer) { | |
450 case OFFER_NOT: auth = "no offer sent"; break; | |
451 case OFFER_SENT: auth = "offer sent"; break; | |
452 case OFFER_ACCEPTED: auth = "offer accepted"; break; | |
453 case OFFER_REJECTED: auth = "offer rejected"; break; | |
454 default: auth = "unknown auth"; | |
455 } | |
456 break; | |
457 case OTRL_AUTHSTATE_AWAITING_DHKEY: | |
458 auth = "awaiting D-H key"; break; | |
459 case OTRL_AUTHSTATE_AWAITING_REVEALSIG: | |
460 auth = "awaiting reveal signature"; break; | |
461 case OTRL_AUTHSTATE_AWAITING_SIG: | |
462 auth = "awaiting signature"; break; | |
463 case OTRL_AUTHSTATE_V1_SETUP: | |
464 auth = "v1 setup"; break; | |
465 default: | |
466 auth = "unknown auth"; | |
467 } | |
468 if (p == OTRL_POLICY_NEVER) | |
469 policy = "plain"; | |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
470 else if (p == (OTRL_POLICY_OPPORTUNISTIC & ~OTRL_POLICY_ALLOW_V1)) |
1299 | 471 policy = "opportunistic"; |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
472 else if (p == (OTRL_POLICY_MANUAL & ~OTRL_POLICY_ALLOW_V1)) |
1299 | 473 policy = "manual"; |
474 else if (p == (OTRL_POLICY_ALWAYS & ~OTRL_POLICY_ALLOW_V1)) | |
475 policy = "always"; | |
476 else | |
477 policy = "unknown"; | |
478 | |
479 scr_LogPrint(LPRINT_LOGNORM, "%s: %s (%s) [%s]", | |
480 ctx->username, state, auth, policy); | |
481 } | |
482 | |
483 static ConnContext * otr_context_encrypted(const char * buddy) | |
484 { | |
485 ConnContext * ctx = otr_get_context(buddy); | |
486 | |
487 if (!userstate || !ctx || ctx->msgstate != OTRL_MSGSTATE_ENCRYPTED){ | |
488 scr_LogPrint(LPRINT_LOGNORM, | |
489 "You have to start an OTR channel with %s before you can " | |
490 "use SMP.", buddy); | |
491 return NULL; | |
492 } | |
493 | |
494 return ctx; | |
495 } | |
496 | |
497 void otr_smp_query(const char * buddy, const char * secret) | |
498 { | |
499 ConnContext * ctx = otr_context_encrypted(buddy); | |
500 | |
501 if (!secret) { | |
502 scr_LogPrint(LPRINT_LOGNORM, | |
503 "Using SMP without a secret isn't a good idea."); | |
504 return; | |
505 } | |
506 | |
507 if (ctx) { | |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
508 otrl_message_initiate_smp(userstate, &ops, NULL, ctx, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
509 (const unsigned char *)secret, |
1299 | 510 strlen(secret)); |
511 scr_WriteIncomingMessage(ctx->username, | |
512 "OTR: Socialist Millionaires' Protocol " | |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
513 "initiated.", 0, HBB_PREFIX_INFO, 0); |
1299 | 514 } |
515 } | |
516 | |
517 void otr_smp_respond(const char * buddy, const char * secret) | |
518 { | |
519 ConnContext * ctx = otr_context_encrypted(buddy); | |
520 | |
521 if (!secret) { | |
522 scr_LogPrint(LPRINT_LOGNORM, | |
523 "Using SMP without a secret isn't a good idea."); | |
524 return; | |
525 } | |
526 | |
527 if (ctx) { | |
528 if (!ctx->smstate->secret) { | |
529 scr_LogPrint(LPRINT_LOGNORM, | |
530 "Don't call smpr before you haven't received an SMP " | |
531 "Initiation!"); | |
532 return; | |
533 } | |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
534 otrl_message_respond_smp(userstate, &ops, NULL, ctx, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
535 (const unsigned char *)secret, |
1299 | 536 strlen(secret)); |
537 scr_WriteIncomingMessage(ctx->username, | |
538 "OTR: Socialist Millionaires' Protocol: " | |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
539 "response sent", 0, HBB_PREFIX_INFO, 0); |
1299 | 540 } |
541 } | |
542 | |
543 void otr_smp_abort(const char * buddy) | |
544 { | |
545 ConnContext * ctx = otr_context_encrypted(buddy); | |
546 | |
547 if (ctx) { | |
548 otrl_message_abort_smp(userstate, &ops, NULL, ctx); | |
549 scr_WriteIncomingMessage(ctx->username, | |
550 "OTR: Socialist Millionaires' Protocol aborted.", | |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
551 0, HBB_PREFIX_INFO, 0); |
1299 | 552 } |
553 } | |
554 | |
555 void otr_key(void) | |
556 { | |
557 OtrlPrivKey * key; | |
558 char readable[45] = ""; | |
559 | |
560 if(!userstate) | |
561 return; | |
562 for (key = userstate->privkey_root; key; key = key->next) { | |
563 otrl_privkey_fingerprint(userstate, readable, key->accountname, | |
564 key->protocol); | |
565 scr_LogPrint(LPRINT_LOGNORM, "%s: %s", key->accountname, readable); | |
566 } | |
567 } | |
568 | |
569 /* Return the OTR policy for the given context. */ | |
570 static OtrlPolicy cb_policy(void *opdata, ConnContext *ctx) | |
571 { | |
572 enum otr_policy p = settings_otr_getpolicy(NULL); | |
573 | |
574 if(ctx) | |
575 if(settings_otr_getpolicy(ctx->username)) | |
576 p = settings_otr_getpolicy(ctx->username); | |
577 | |
578 switch (p) { | |
579 case plain: | |
580 return OTRL_POLICY_NEVER; | |
581 case opportunistic: | |
582 return OTRL_POLICY_OPPORTUNISTIC & ~OTRL_POLICY_ALLOW_V1; | |
583 case manual: | |
584 return OTRL_POLICY_MANUAL & ~OTRL_POLICY_ALLOW_V1; | |
585 case always: | |
586 return OTRL_POLICY_ALWAYS & ~OTRL_POLICY_ALLOW_V1; | |
587 } | |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
588 |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
589 return OTRL_POLICY_MANUAL & ~OTRL_POLICY_ALLOW_V1; |
1299 | 590 } |
591 | |
592 /* Create a private key for the given accountname/protocol if | |
593 * desired. */ | |
594 static void cb_create_privkey(void *opdata, const char *accountname, | |
595 const char *protocol) | |
596 { | |
597 gcry_error_t e; | |
1320 | 598 char * root; |
1299 | 599 |
600 scr_LogPrint(LPRINT_LOGNORM, | |
601 "Generating new OTR key for %s. This may take a while...", | |
602 accountname); | |
603 scr_DoUpdate(); | |
604 | |
605 e = otrl_privkey_generate(userstate, keyfile, accountname, protocol); | |
606 | |
1320 | 607 if (e) { |
608 root = otr_get_dir(); | |
609 scr_LogPrint(LPRINT_LOGNORM, "OTR key generation failed! Please mkdir " | |
610 "%s if you want to use otr encryption.", root); | |
611 g_free(root); | |
612 } | |
1299 | 613 else |
614 scr_LogPrint(LPRINT_LOGNORM, "OTR key generated."); | |
615 } | |
616 | |
617 /* Report whether you think the given user is online. Return 1 if | |
618 * you think he is, 0 if you think he isn't, -1 if you're not sure. | |
619 * If you return 1, messages such as heartbeats or other | |
620 * notifications may be sent to the user, which could result in "not | |
621 * logged in" errors if you're wrong. */ | |
622 static int cb_is_logged_in(void *opdata, const char *accountname, | |
623 const char *protocol, const char *recipient) | |
624 { | |
1346 | 625 int ret = (roster_getstatus(recipient, NULL) != offline); |
1299 | 626 return ret; |
627 } | |
628 | |
629 /* Send the given IM to the given recipient from the given | |
630 * accountname/protocol. */ | |
631 static void cb_inject_message(void *opdata, const char *accountname, | |
632 const char *protocol, const char *recipient, | |
633 const char *message) | |
634 { | |
635 char * id = g_strdup("otrinject"); | |
1343 | 636 if (roster_gettype(recipient) == ROSTER_TYPE_USER) |
637 jb_send_msg(recipient, message, ROSTER_TYPE_USER, "", id, NULL, NULL); | |
1299 | 638 g_free(id); |
639 } | |
640 | |
641 /* Display a notification message for a particular | |
642 * accountname / protocol / username conversation. */ | |
643 static void cb_notify(void *opdata, OtrlNotifyLevel level, | |
644 const char *accountname, const char *protocol, | |
645 const char *username, const char *title, | |
646 const char *primary, const char *secondary) | |
647 { | |
648 char * type; | |
649 char *sbuf = NULL; | |
650 switch (level) { | |
651 case OTRL_NOTIFY_ERROR: type = "error"; break; | |
652 case OTRL_NOTIFY_WARNING: type = "warning"; break; | |
653 case OTRL_NOTIFY_INFO: type = "info"; break; | |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
654 default: type = "unknown"; |
1299 | 655 } |
656 sbuf = g_strdup_printf("OTR %s:%s\n%s\n%s",type,title, primary, secondary); | |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
657 scr_WriteIncomingMessage(username, sbuf, 0, HBB_PREFIX_INFO, 0); |
1299 | 658 g_free(sbuf); |
659 } | |
660 | |
661 /* Display an OTR control message for a particular | |
662 * accountname / protocol / username conversation. Return 0 if you are able | |
663 * to successfully display it. If you return non-0 (or if this | |
664 * function is NULL), the control message will be displayed inline, | |
665 * as a received message, or else by using the above notify() | |
666 * callback. */ | |
667 static int cb_display_otr_message(void *opdata, const char *accountname, | |
668 const char *protocol, const char *username, | |
669 const char *msg) | |
670 { | |
1470
a8b924b5474c
The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
1420
diff
changeset
|
671 char *strippedmsg = html_strip(msg); |
a8b924b5474c
The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
1420
diff
changeset
|
672 scr_WriteIncomingMessage(username, strippedmsg, 0, HBB_PREFIX_INFO, 0); |
a8b924b5474c
The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
1420
diff
changeset
|
673 g_free(strippedmsg); |
1299 | 674 return 0; |
675 } | |
676 | |
677 /* When the list of ConnContexts changes (including a change in | |
678 * state), this is called so the UI can be updated. */ | |
679 static void cb_update_context_list(void *opdata) | |
680 { | |
681 /*maybe introduce new status characters for mcabber, | |
682 * then use this function (?!)*/ | |
683 } | |
684 | |
685 /* Return a newly allocated string containing a human-friendly name | |
686 * for the given protocol id */ | |
687 static const char *cb_protocol_name(void *opdata, const char *protocol) | |
688 { | |
689 return protocol; | |
690 } | |
691 | |
692 /* Deallocate a string allocated by protocol_name */ | |
693 static void cb_protocol_name_free (void *opdata, const char *protocol_name) | |
694 { | |
695 /* We didn't allocated memory, so we don't have to free anything :p */ | |
696 } | |
697 | |
698 /* A new fingerprint for the given user has been received. */ | |
699 static void cb_new_fingerprint(void *opdata, OtrlUserState us, | |
700 const char *accountname, const char *protocol, | |
701 const char *username, | |
702 unsigned char fingerprint[20]) | |
703 { | |
704 char *sbuf = NULL; | |
705 char readable[45]; | |
706 | |
707 otrl_privkey_hash_to_human(readable, fingerprint); | |
708 sbuf = g_strdup_printf("OTR: new fingerprint: %s", readable); | |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
709 scr_WriteIncomingMessage(username, sbuf, 0, HBB_PREFIX_INFO, 0); |
1299 | 710 g_free(sbuf); |
711 } | |
712 | |
713 /* The list of known fingerprints has changed. Write them to disk. */ | |
714 static void cb_write_fingerprints(void *opdata) | |
715 { | |
716 otrl_privkey_write_fingerprints(userstate, fprfile); | |
717 } | |
718 | |
719 /* A ConnContext has entered a secure state. */ | |
720 static void cb_gone_secure(void *opdata, ConnContext *context) | |
721 { | |
722 scr_WriteIncomingMessage(context->username, "OTR: channel established", 0, | |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
723 HBB_PREFIX_INFO, 0); |
1299 | 724 } |
725 | |
726 /* A ConnContext has left a secure state. */ | |
727 static void cb_gone_insecure(void *opdata, ConnContext *context) | |
728 { | |
729 scr_WriteIncomingMessage(context->username, "OTR: channel closed", 0, | |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
730 HBB_PREFIX_INFO, 0); |
1299 | 731 } |
732 | |
733 /* We have completed an authentication, using the D-H keys we | |
734 * already knew. is_reply indicates whether we initiated the AKE. */ | |
735 static void cb_still_secure(void *opdata, ConnContext *context, int is_reply) | |
736 { | |
737 scr_WriteIncomingMessage(context->username, "OTR: channel reestablished", 0, | |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
738 HBB_PREFIX_INFO, 0); |
1299 | 739 } |
740 | |
741 /* Log a message. The passed message will end in "\n". */ | |
742 static void cb_log_message(void *opdata, const char *message) | |
743 { | |
744 scr_LogPrint(LPRINT_DEBUG, "OTR: %s", message); | |
745 } | |
746 | |
747 /* Find the maximum message size supported by this protocol. */ | |
748 static int cb_max_message_size(void *opdata, ConnContext *context) | |
749 { | |
750 return 8192; | |
751 } | |
752 | |
1347
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
753 int otr_enabled(void) |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
754 { |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
755 return otr_is_enabled; |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
756 } |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
757 |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
758 #else /* !HAVE_LIBOTR */ |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
759 |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
760 int otr_enabled(void) |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
761 { |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
762 return FALSE; |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
763 } |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1346
diff
changeset
|
764 |
1299 | 765 #endif /* HAVE_LIBOTR */ |
766 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |