From 09472e43c46d29db160c3016a27c0c2293799a2e Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 18 Feb 2014 22:31:27 +0000 Subject: [PATCH] Added OTR supported versions in initial start query message --- src/command/commands.c | 6 ++++-- src/otr/otr.c | 7 +++++++ src/otr/otr.h | 1 + src/otr/otrlib.h | 2 ++ src/otr/otrlibv3.c | 6 ++++++ src/otr/otrlibv4.c | 6 ++++++ 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/command/commands.c b/src/command/commands.c index 53a2b1a3..853fee39 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -2653,7 +2653,8 @@ cmd_otr(gchar **args, struct cmd_help_t help) if (!otr_key_loaded()) { ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'"); } else if (!otr_is_secure(barejid)) { - message_send("?OTR?", barejid); + char *otr_query_message = otr_start_query(); + message_send(otr_query_message, barejid); } else { ui_gone_secure(barejid, otr_is_trusted(barejid)); } @@ -2670,7 +2671,8 @@ cmd_otr(gchar **args, struct cmd_help_t help) ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'"); } else { char *recipient = ui_current_recipient(); - message_send("?OTR?", recipient); + char *otr_query_message = otr_start_query(); + message_send(otr_query_message, recipient); } } } diff --git a/src/otr/otr.c b/src/otr/otr.c index f28406f2..64194cfc 100644 --- a/src/otr/otr.c +++ b/src/otr/otr.c @@ -99,6 +99,12 @@ _otr_libotr_version(void) return OTRL_VERSION; } +static char * +_otr_start_query(void) +{ + return otrlib_start_query(); +} + static void _otr_init(void) { @@ -454,6 +460,7 @@ otr_init_module(void) { otr_init = _otr_init; otr_libotr_version = _otr_libotr_version; + otr_start_query = _otr_start_query; otr_on_connect = _otr_on_connect; otr_keygen = _otr_keygen; otr_key_loaded = _otr_key_loaded; diff --git a/src/otr/otr.h b/src/otr/otr.h index eaf975d3..6318f425 100644 --- a/src/otr/otr.h +++ b/src/otr/otr.h @@ -29,6 +29,7 @@ void otr_init_module(void); void (*otr_init)(void); char* (*otr_libotr_version)(void); +char* (*otr_start_query)(void); void (*otr_on_connect)(ProfAccount *account); void (*otr_keygen)(ProfAccount *account); diff --git a/src/otr/otrlib.h b/src/otr/otrlib.h index bf187363..160a9e73 100644 --- a/src/otr/otrlib.h +++ b/src/otr/otrlib.h @@ -25,6 +25,8 @@ OtrlPolicy otrlib_policy(void); +char* otrlib_start_query(void); + void otrlib_init_ops(OtrlMessageAppOps *ops); ConnContext * otrlib_context_find(OtrlUserState user_state, const char * const recipient, char *jid); diff --git a/src/otr/otrlibv3.c b/src/otr/otrlibv3.c index b12f0b8f..3336093d 100644 --- a/src/otr/otrlibv3.c +++ b/src/otr/otrlibv3.c @@ -31,6 +31,12 @@ otrlib_policy(void) return OTRL_POLICY_ALLOW_V1 | OTRL_POLICY_ALLOW_V2 ; } +char * +otrlib_start_query(void) +{ + return "?OTR?v2?"; +} + static int cb_display_otr_message(void *opdata, const char *accountname, const char *protocol, const char *username, const char *msg) diff --git a/src/otr/otrlibv4.c b/src/otr/otrlibv4.c index f0b58a46..5c670355 100644 --- a/src/otr/otrlibv4.c +++ b/src/otr/otrlibv4.c @@ -32,6 +32,12 @@ otrlib_policy(void) return OTRL_POLICY_ALLOW_V1 | OTRL_POLICY_ALLOW_V2 | OTRL_POLICY_ALLOW_V3; } +char * +otrlib_start_query(void) +{ + return "?OTR?v23?"; +} + static const char* cb_otr_error_message(void *opdata, ConnContext *context, OtrlErrorCode err_code)