From 20850eb4db580ea9cb6193f420b9724a29ee63ea Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Fri, 3 Apr 2020 12:09:16 +0200 Subject: db: log encryption type --- src/database.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/database.c b/src/database.c index 6715356a..988bfeae 100644 --- a/src/database.c +++ b/src/database.c @@ -229,12 +229,28 @@ _add_to_db(ProfMessage *message, const char * const type, const Jid * const from return; } + char *enc; + switch (message->enc) { + case PROF_MSG_ENC_PGP: + enc = "pgp"; + break; + case PROF_MSG_ENC_OTR: + enc = "otr"; + break; + case PROF_MSG_ENC_OMEMO: + enc = "omemo"; + break; + case PROF_MSG_ENC_NONE: + default: + enc = "none"; + } + char *err_msg; char *query; //gchar *date_fmt = g_date_time_format_iso8601(message->timestamp); gchar *date_fmt = g_date_time_format(message->timestamp, "%Y/%m/%d %H:%M:%S"); - if (asprintf(&query, "INSERT INTO `ChatLogs` (`from_jid`, `from_resource`, `to_jid`, `to_resource`, `message`, `timestamp`, `stanza_id`, `replace_id`, `type`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", + if (asprintf(&query, "INSERT INTO `ChatLogs` (`from_jid`, `from_resource`, `to_jid`, `to_resource`, `message`, `timestamp`, `stanza_id`, `replace_id`, `type`, `encryption`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", from_jid->barejid, from_jid->resourcepart ? from_jid->resourcepart : "", to_jid->barejid, @@ -243,7 +259,8 @@ _add_to_db(ProfMessage *message, const char * const type, const Jid * const from date_fmt, message->id ? message->id : "", message->replace_id ? message->replace_id : "", - type) == -1) { + type, + enc) == -1) { log_error("log_database_add(): could not allocate memory"); return; } -- cgit 1.4.1-2-gfad0