1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Fixed chat logging

fixes #147
This commit is contained in:
James Booth 2013-01-29 23:01:15 +00:00
parent 61b4ef9c83
commit 957bea19e4
3 changed files with 24 additions and 16 deletions

View File

@ -913,7 +913,9 @@ cmd_execute_default(const char * const inp)
if (win_current_is_chat() && prefs_get_chlog()) { if (win_current_is_chat() && prefs_get_chlog()) {
const char *jid = jabber_get_jid(); const char *jid = jabber_get_jid();
chat_log_chat(jid, recipient, inp, PROF_OUT_LOG, NULL); Jid *jidp = jid_create(jid);
chat_log_chat(jidp->barejid, recipient, inp, PROF_OUT_LOG, NULL);
jid_destroy(jidp);
} }
win_show_outgoing_msg("me", recipient, inp); win_show_outgoing_msg("me", recipient, inp);
@ -1690,7 +1692,9 @@ _cmd_msg(gchar **args, struct cmd_help_t help)
if (win_current_is_chat() && prefs_get_chlog()) { if (win_current_is_chat() && prefs_get_chlog()) {
const char *jid = jabber_get_jid(); const char *jid = jabber_get_jid();
chat_log_chat(jid, usr, msg, PROF_OUT_LOG, NULL); Jid *jidp = jid_create(jid);
chat_log_chat(jidp->barejid, usr, msg, PROF_OUT_LOG, NULL);
jid_destroy(jidp);
} }
return TRUE; return TRUE;
@ -1886,7 +1890,9 @@ _cmd_tiny(gchar **args, struct cmd_help_t help)
if (prefs_get_chlog()) { if (prefs_get_chlog()) {
const char *jid = jabber_get_jid(); const char *jid = jabber_get_jid();
chat_log_chat(jid, recipient, tiny, PROF_OUT_LOG, NULL); Jid *jidp = jid_create(jid);
chat_log_chat(jidp->barejid, recipient, tiny, PROF_OUT_LOG, NULL);
jid_destroy(jidp);
} }
win_show_outgoing_msg("me", recipient, tiny); win_show_outgoing_msg("me", recipient, tiny);

View File

@ -120,13 +120,13 @@ prof_handle_incoming_message(char *from, char *message, gboolean priv)
ui_show_incoming_msg(from, message, NULL, priv); ui_show_incoming_msg(from, message, NULL, priv);
win_current_page_off(); win_current_page_off();
if (win_current_is_chat() && prefs_get_chlog()) { if (prefs_get_chlog() && !priv) {
char from_cpy[strlen(from) + 1]; Jid *from_jid = jid_create(from);
strcpy(from_cpy, from);
char *short_from = strtok(from_cpy, "/");
const char *jid = jabber_get_jid(); const char *jid = jabber_get_jid();
Jid *jidp = jid_create(jid);
chat_log_chat(jid, short_from, message, PROF_IN_LOG, NULL); chat_log_chat(jidp->barejid, from_jid->barejid, message, PROF_IN_LOG, NULL);
jid_destroy(jidp);
jid_destroy(from_jid);
} }
} }
@ -137,13 +137,13 @@ prof_handle_delayed_message(char *from, char *message, GTimeVal tv_stamp,
ui_show_incoming_msg(from, message, &tv_stamp, priv); ui_show_incoming_msg(from, message, &tv_stamp, priv);
win_current_page_off(); win_current_page_off();
if (win_current_is_chat() && prefs_get_chlog()) { if (prefs_get_chlog() && !priv) {
char from_cpy[strlen(from) + 1]; Jid *from_jid = jid_create(from);
strcpy(from_cpy, from);
char *short_from = strtok(from_cpy, "/");
const char *jid = jabber_get_jid(); const char *jid = jabber_get_jid();
Jid *jidp = jid_create(jid);
chat_log_chat(jid, short_from, message, PROF_IN_LOG, &tv_stamp); chat_log_chat(jidp->barejid, from_jid->barejid, message, PROF_IN_LOG, &tv_stamp);
jid_destroy(jidp);
jid_destroy(from_jid);
} }
} }

View File

@ -2327,7 +2327,9 @@ _win_show_history(WINDOW *win, int win_index, const char * const contact)
{ {
if (!windows[win_index]->history_shown) { if (!windows[win_index]->history_shown) {
GSList *history = NULL; GSList *history = NULL;
history = chat_log_get_previous(jabber_get_jid(), contact, history); Jid *jid = jid_create(jabber_get_jid());
history = chat_log_get_previous(jid->barejid, contact, history);
jid_destroy(jid);
while (history != NULL) { while (history != NULL) {
wprintw(win, "%s\n", history->data); wprintw(win, "%s\n", history->data);
history = g_slist_next(history); history = g_slist_next(history);