From 5a5ad31edf137e62ee5678f9845c155811d9e2e1 Mon Sep 17 00:00:00 2001 From: lightb Date: Tue, 22 Apr 2014 18:07:53 -0400 Subject: Added new functionality to OTR always policy If policy is set to always, and unencrypted message is received it will try to start an otr session. Note: Fully tested with pidgin, is now working (opportunistic and always) --- src/server_events.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/server_events.c b/src/server_events.c index 3935bfbc..7797b4f4 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -221,7 +221,6 @@ handle_incoming_message(char *from, char *message, gboolean priv) int tag_length = 24; if (strstr(message, OTRL_MESSAGE_TAG_V2) && strstr(message, OTRL_MESSAGE_TAG_V1)) tag_length = 32; memmove(whitespace_base, whitespace_base+tag_length, tag_length); - log_debug("<%s>", message); char *otr_query_message = otr_start_query(); cons_show("OTR Whitespace pattern detected. Attempting to start OTR session..."); message_send(otr_query_message, from); @@ -237,6 +236,13 @@ handle_incoming_message(char *from, char *message, gboolean priv) } else { newmessage = message; } + char *policy = prefs_get_string(PREF_OTR_POLICY); + if (strcmp(policy, "always") == 0 && !was_decrypted) + { + char *otr_query_message = otr_start_query(); + cons_show("Attempting to start OTR session.."); + message_send(otr_query_message, from); + } ui_incoming_msg(from, newmessage, NULL, priv); -- cgit 1.4.1-2-gfad0 From e08ee67f5f5e1edbd533b61c6460bda6f40ec8dd Mon Sep 17 00:00:00 2001 From: lightb Date: Tue, 22 Apr 2014 18:53:48 -0400 Subject: Bugfix: Because whitespace was removed, last check OTR always, didn't work, now it works. --- src/server_events.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/server_events.c b/src/server_events.c index 7797b4f4..39aebedf 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -209,11 +209,13 @@ handle_incoming_message(char *from, char *message, gboolean priv) gboolean was_decrypted = FALSE; char *newmessage; + char *policy = prefs_get_string(PREF_OTR_POLICY); + char *whitespace_base = strstr(message,OTRL_MESSAGE_TAG_BASE); + + if (!priv) { //check for OTR whitespace (opportunistic or always) - char *policy = prefs_get_string(PREF_OTR_POLICY); if (strcmp(policy, "opportunistic") == 0 || strcmp(policy, "always") == 0) { - char *whitespace_base = strstr(message,OTRL_MESSAGE_TAG_BASE); if (whitespace_base) { if (strstr(message, OTRL_MESSAGE_TAG_V2) || strstr(message, OTRL_MESSAGE_TAG_V1)) { // Remove whitespace pattern for proper display in UI @@ -236,11 +238,10 @@ handle_incoming_message(char *from, char *message, gboolean priv) } else { newmessage = message; } - char *policy = prefs_get_string(PREF_OTR_POLICY); - if (strcmp(policy, "always") == 0 && !was_decrypted) + if (strcmp(policy, "always") == 0 && !was_decrypted && !whitespace_base) { char *otr_query_message = otr_start_query(); - cons_show("Attempting to start OTR session.."); + cons_show("Attempting to start OTR session..."); message_send(otr_query_message, from); } -- cgit 1.4.1-2-gfad0