Pass delay timestamp to all incoming chat events

This commit is contained in:
James Booth
2015-09-08 20:18:31 +01:00
parent 3883e04d24
commit b266e4d035
6 changed files with 40 additions and 73 deletions

View File

@@ -188,22 +188,22 @@ sv_ev_incoming_carbon(char *barejid, char *resource, char *message)
}
ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_MSG_PLAIN);
chat_log_msg_in(barejid, message);
chat_log_msg_in(barejid, message, NULL);
}
#ifdef HAVE_LIBGPGME
static void
_sv_ev_incoming_pgp(ProfChatWin *chatwin, gboolean new_win, char *barejid, char *resource, char *message, char *pgp_message)
_sv_ev_incoming_pgp(ProfChatWin *chatwin, gboolean new_win, char *barejid, char *resource, char *message, char *pgp_message, GDateTime *timestamp)
{
char *decrypted = p_gpg_decrypt(pgp_message);
if (decrypted) {
ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win, PROF_MSG_PGP);
chat_log_pgp_msg_in(barejid, decrypted);
ui_incoming_msg(chatwin, resource, decrypted, timestamp, new_win, PROF_MSG_PGP);
chat_log_pgp_msg_in(barejid, decrypted, timestamp);
chatwin->pgp_recv = TRUE;
p_gpg_free_decrypted(decrypted);
} else {
ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_MSG_PLAIN);
chat_log_msg_in(barejid, message);
ui_incoming_msg(chatwin, resource, message, timestamp, new_win, PROF_MSG_PLAIN);
chat_log_msg_in(barejid, message, timestamp);
chatwin->pgp_recv = FALSE;
}
}
@@ -211,18 +211,18 @@ _sv_ev_incoming_pgp(ProfChatWin *chatwin, gboolean new_win, char *barejid, char
#ifdef HAVE_LIBOTR
static void
_sv_ev_incoming_otr(ProfChatWin *chatwin, gboolean new_win, char *barejid, char *resource, char *message)
_sv_ev_incoming_otr(ProfChatWin *chatwin, gboolean new_win, char *barejid, char *resource, char *message, GDateTime *timestamp)
{
gboolean decrypted = FALSE;
char *otr_res = otr_on_message_recv(barejid, resource, message, &decrypted);
if (otr_res) {
if (decrypted) {
ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win, PROF_MSG_OTR);
ui_incoming_msg(chatwin, resource, otr_res, timestamp, new_win, PROF_MSG_OTR);
chatwin->pgp_send = FALSE;
} else {
ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win, PROF_MSG_PLAIN);
ui_incoming_msg(chatwin, resource, otr_res, timestamp, new_win, PROF_MSG_PLAIN);
}
chat_log_otr_msg_in(barejid, otr_res, decrypted);
chat_log_otr_msg_in(barejid, otr_res, decrypted, timestamp);
otr_free_message(otr_res);
chatwin->pgp_recv = FALSE;
}
@@ -231,16 +231,16 @@ _sv_ev_incoming_otr(ProfChatWin *chatwin, gboolean new_win, char *barejid, char
#ifndef HAVE_LIBOTR
static void
_sv_ev_incoming_plain(ProfChatWin *chatwin, gboolean new_win, char *barejid, char *resource, char *message)
_sv_ev_incoming_plain(ProfChatWin *chatwin, gboolean new_win, char *barejid, char *resource, char *message, GDateTime *timestamp)
{
ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_MSG_PLAIN);
chat_log_msg_in(barejid, message);
ui_incoming_msg(chatwin, resource, message, timestamp, new_win, PROF_MSG_PLAIN);
chat_log_msg_in(barejid, message, timestamp);
chatwin->pgp_recv = FALSE;
}
#endif
void
sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_message)
sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_message, GDateTime *timestamp)
{
gboolean new_win = FALSE;
ProfChatWin *chatwin = wins_get_chat(barejid);
@@ -257,10 +257,10 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_m
if (chatwin->is_otr) {
win_println((ProfWin*)chatwin, 0, "PGP encrypted message received whilst in OTR session.");
} else { // PROF_ENC_NONE, PROF_ENC_PGP
_sv_ev_incoming_pgp(chatwin, new_win, barejid, resource, message, pgp_message);
_sv_ev_incoming_pgp(chatwin, new_win, barejid, resource, message, pgp_message, timestamp);
}
} else {
_sv_ev_incoming_otr(chatwin, new_win, barejid, resource, message);
_sv_ev_incoming_otr(chatwin, new_win, barejid, resource, message, timestamp);
}
return;
#endif
@@ -269,7 +269,7 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_m
// OTR supported, PGP unsupported
#ifdef HAVE_LIBOTR
#ifndef HAVE_LIBGPGME
_sv_ev_incoming_otr(chatwin, new_win, barejid, resource, message);
_sv_ev_incoming_otr(chatwin, new_win, barejid, resource, message, timestamp);
return;
#endif
#endif
@@ -278,9 +278,9 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_m
#ifndef HAVE_LIBOTR
#ifdef HAVE_LIBGPGME
if (pgp_message) {
_sv_ev_incoming_pgp(chatwin, new_win, barejid, resource, message, pgp_message);
_sv_ev_incoming_pgp(chatwin, new_win, barejid, resource, message, pgp_message, timestamp);
} else {
_sv_ev_incoming_plain(chatwin, new_win, barejid, resource, message);
_sv_ev_incoming_plain(chatwin, new_win, barejid, resource, message, timestamp);
}
return;
#endif
@@ -289,7 +289,7 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_m
// OTR unsupported, PGP unsupported
#ifndef HAVE_LIBOTR
#ifndef HAVE_LIBGPGME
_sv_ev_incoming_plain(chatwin, new_win, barejid, resource, message);
_sv_ev_incoming_plain(chatwin, new_win, barejid, resource, message, timestamp);
return;
#endif
#endif
@@ -301,21 +301,6 @@ sv_ev_delayed_private_message(const char * const fulljid, char *message, GDateTi
ui_incoming_private_msg(fulljid, message, timestamp);
}
void
sv_ev_delayed_message(char *barejid, char *message, GDateTime *timestamp)
{
gboolean new_win = FALSE;
ProfChatWin *chatwin = wins_get_chat(barejid);
if (!chatwin) {
ProfWin *window = wins_new_chat(barejid);
chatwin = (ProfChatWin*)window;
new_win = TRUE;
}
ui_incoming_msg(chatwin, NULL, message, timestamp, new_win, PROF_MSG_PLAIN);
chat_log_msg_in_delayed(barejid, message, timestamp);
}
void
sv_ev_message_receipt(char *barejid, char *id)
{

View File

@@ -50,9 +50,8 @@ void sv_ev_room_history(const char * const room_jid, const char * const nick,
GDateTime *timestamp, const char * const message);
void sv_ev_room_message(const char * const room_jid, const char * const nick,
const char * const message);
void sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_message);
void sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_message, GDateTime *timestamp);
void sv_ev_incoming_private_message(const char * const fulljid, char *message);
void sv_ev_delayed_message(char *fulljid, char *message, GDateTime *timestamp);
void sv_ev_delayed_private_message(const char * const fulljid, char *message, GDateTime *timestamp);
void sv_ev_typing(char *barejid, char *resource);
void sv_ev_paused(char *barejid, char *resource);