diff options
author | Michael Vetter <jubalh@iodoru.org> | 2020-04-06 22:25:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-06 22:25:40 +0200 |
commit | 6c158a9af86c0211a2e32aaabcb9a374214d53dd (patch) | |
tree | 65a57e346b56424b57ebd3e22a0ec102d3939e21 /src/log.c | |
parent | 49057077b9396a16c600ddd61357a1816a94e791 (diff) | |
parent | 6218a537276ca9c5e6ca3f6956759421c9425c23 (diff) | |
download | profani-tty-6c158a9af86c0211a2e32aaabcb9a374214d53dd.tar.gz |
Merge pull request #1282 from profanity-im/feature/sqlite-log
SQLite backend
Diffstat (limited to 'src/log.c')
-rw-r--r-- | src/log.c | 64 |
1 files changed, 8 insertions, 56 deletions
diff --git a/src/log.c b/src/log.c index 7304ed03..ae8f1542 100644 --- a/src/log.c +++ b/src/log.c @@ -355,14 +355,14 @@ chat_log_otr_msg_in(ProfMessage *message) const char *jid = connection_get_fulljid(); Jid *jidp = jid_create(jid); char *pref_otr_log = prefs_get_string(PREF_OTR_LOG); - if (message->enc == PROF_MSG_ENC_PLAIN || (strcmp(pref_otr_log, "on") == 0)) { - if (message->mucuser) { + if (message->enc == PROF_MSG_ENC_NONE || (strcmp(pref_otr_log, "on") == 0)) { + if (message->type == PROF_MSG_TYPE_MUCPM) { _chat_log_chat(jidp->barejid, message->jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->jid->resourcepart); } else { _chat_log_chat(jidp->barejid, message->jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, NULL); } } else if (strcmp(pref_otr_log, "redact") == 0) { - if (message->mucuser) { + if (message->type == PROF_MSG_TYPE_MUCPM) { _chat_log_chat(jidp->barejid, message->jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, message->jid->resourcepart); } else { _chat_log_chat(jidp->barejid, message->jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, NULL); @@ -381,13 +381,13 @@ chat_log_pgp_msg_in(ProfMessage *message) Jid *jidp = jid_create(jid); char *pref_pgp_log = prefs_get_string(PREF_PGP_LOG); if (strcmp(pref_pgp_log, "on") == 0) { - if (message->mucuser) { + if (message->type == PROF_MSG_TYPE_MUCPM) { _chat_log_chat(jidp->barejid, message->jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->jid->resourcepart); } else { _chat_log_chat(jidp->barejid, message->jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, NULL); } } else if (strcmp(pref_pgp_log, "redact") == 0) { - if (message->mucuser) { + if (message->type == PROF_MSG_TYPE_MUCPM) { _chat_log_chat(jidp->barejid, message->jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, message->jid->resourcepart); } else { _chat_log_chat(jidp->barejid, message->jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, NULL); @@ -406,13 +406,13 @@ chat_log_omemo_msg_in(ProfMessage *message) Jid *jidp = jid_create(jid); char *pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG); if (strcmp(pref_omemo_log, "on") == 0) { - if (message->mucuser) { + if (message->type == PROF_MSG_TYPE_MUCPM) { _chat_log_chat(jidp->barejid, message->jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->jid->resourcepart); } else { _chat_log_chat(jidp->barejid, message->jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, NULL); } } else if (strcmp(pref_omemo_log, "redact") == 0) { - if (message->mucuser) { + if (message->type == PROF_MSG_TYPE_MUCPM) { _chat_log_chat(jidp->barejid, message->jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, message->jid->resourcepart); } else { _chat_log_chat(jidp->barejid, message->jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, message->jid->resourcepart); @@ -430,7 +430,7 @@ chat_log_msg_in(ProfMessage *message) const char *jid = connection_get_fulljid(); Jid *jidp = jid_create(jid); - if (message->mucuser) { + if (message->type == PROF_MSG_TYPE_MUCPM) { _chat_log_chat(jidp->barejid, message->jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->jid->resourcepart); } else { _chat_log_chat(jidp->barejid, message->jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, NULL); @@ -619,54 +619,6 @@ _groupchat_log_chat(const gchar *const login, const gchar *const room, const gch g_date_time_unref(dt); } -GSList* -chat_log_get_previous(const gchar *const login, const gchar *const recipient) -{ - GSList *history = NULL; - GDateTime *now = g_date_time_new_now_local(); - GDateTime *log_date = g_date_time_new(tz, - g_date_time_get_year(session_started), - g_date_time_get_month(session_started), - g_date_time_get_day_of_month(session_started), - g_date_time_get_hour(session_started), - g_date_time_get_minute(session_started), - g_date_time_get_second(session_started)); - - // get data from all logs from the day the session was started to today - while (g_date_time_compare(log_date, now) != 1) { - char *filename = _get_log_filename(recipient, login, log_date, FALSE); - - FILE *logp = fopen(filename, "r"); - if (logp) { - GString *header = g_string_new(""); - g_string_append_printf(header, "%d/%d/%d:", - g_date_time_get_day_of_month(log_date), - g_date_time_get_month(log_date), - g_date_time_get_year(log_date)); - history = g_slist_append(history, header->str); - g_string_free(header, FALSE); - - char *line; - while ((line = file_getline(logp)) != NULL) { - history = g_slist_append(history, line); - } - - fclose(logp); - } - - free(filename); - - GDateTime *next = g_date_time_add_days(log_date, 1); - g_date_time_unref(log_date); - log_date = next; - } - - g_date_time_unref(log_date); - g_date_time_unref(now); - - return history; -} - void chat_log_close(void) { |