mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Moved window creation to sv_ev_incoming_message
This commit is contained in:
parent
8d2d923603
commit
13a612cbc2
@ -43,6 +43,7 @@
|
||||
#include "config/preferences.h"
|
||||
#include "config/account.h"
|
||||
#include "roster_list.h"
|
||||
#include "window_list.h"
|
||||
|
||||
#ifdef HAVE_LIBOTR
|
||||
#include "otr/otr.h"
|
||||
@ -171,16 +172,24 @@ sv_ev_carbon(char *barejid, char *message)
|
||||
void
|
||||
sv_ev_incoming_message(char *barejid, char *resource, char *message)
|
||||
{
|
||||
gboolean new_win = FALSE;
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (!chatwin) {
|
||||
ProfWin *window = wins_new_chat(barejid);
|
||||
chatwin = (ProfChatWin*)window;
|
||||
new_win = TRUE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBOTR
|
||||
gboolean decrypted = FALSE;
|
||||
char *otr_res = otr_on_message_recv(barejid, resource, message, &decrypted);
|
||||
if (otr_res) {
|
||||
ui_incoming_msg(barejid, resource, otr_res, NULL);
|
||||
ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win);
|
||||
chat_log_otr_msg_in(barejid, otr_res, decrypted);
|
||||
otr_free_message(otr_res);
|
||||
}
|
||||
#else
|
||||
ui_incoming_msg(barejid, resource, message, NULL);
|
||||
ui_incoming_msg(chatwin, resource, message, NULL, new_win);
|
||||
chat_log_msg_in(barejid, message);
|
||||
#endif
|
||||
}
|
||||
@ -194,7 +203,15 @@ sv_ev_delayed_private_message(const char * const fulljid, char *message, GTimeVa
|
||||
void
|
||||
sv_ev_delayed_message(char *barejid, char *message, GTimeVal tv_stamp)
|
||||
{
|
||||
ui_incoming_msg(barejid, NULL, message, &tv_stamp);
|
||||
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, &tv_stamp, new_win);
|
||||
chat_log_msg_in_delayed(barejid, message, &tv_stamp);
|
||||
}
|
||||
|
||||
|
@ -416,21 +416,12 @@ ui_message_receipt(const char * const barejid, const char * const id)
|
||||
}
|
||||
|
||||
void
|
||||
ui_incoming_msg(const char * const barejid, const char * const resource, const char * const message, GTimeVal *tv_stamp)
|
||||
ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GTimeVal *tv_stamp, gboolean win_created)
|
||||
{
|
||||
gboolean win_created = FALSE;
|
||||
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (chatwin == NULL) {
|
||||
ProfWin *window = wins_new_chat(barejid);
|
||||
chatwin = (ProfChatWin*)window;
|
||||
win_created = TRUE;
|
||||
}
|
||||
|
||||
ProfWin *window = (ProfWin*)chatwin;
|
||||
int num = wins_get_num(window);
|
||||
|
||||
char *display_name = roster_get_msg_display_name(barejid, resource);
|
||||
char *display_name = roster_get_msg_display_name(chatwin->barejid, resource);
|
||||
|
||||
// currently viewing chat window with sender
|
||||
if (wins_is_current(window)) {
|
||||
@ -449,12 +440,12 @@ ui_incoming_msg(const char * const barejid, const char * const resource, const c
|
||||
|
||||
chatwin->unread++;
|
||||
if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
|
||||
_win_show_history(chatwin, barejid);
|
||||
_win_show_history(chatwin, chatwin->barejid);
|
||||
}
|
||||
|
||||
// show users status first, when receiving message via delayed delivery
|
||||
if (tv_stamp && (win_created)) {
|
||||
PContact pcontact = roster_get_contact(barejid);
|
||||
if (tv_stamp && win_created) {
|
||||
PContact pcontact = roster_get_contact(chatwin->barejid);
|
||||
if (pcontact) {
|
||||
win_show_contact(window, pcontact);
|
||||
}
|
||||
@ -1277,12 +1268,6 @@ ui_new_chat_win(const char * const barejid)
|
||||
ProfWin *window = wins_new_chat(barejid);
|
||||
ProfChatWin *chatwin = (ProfChatWin *)window;
|
||||
|
||||
#ifdef HAVE_LIBOTR
|
||||
if (otr_is_secure(barejid)) {
|
||||
chatwin->enc_mode = PROF_ENC_OTR;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
|
||||
_win_show_history(chatwin, barejid);
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ void ui_handle_stanza(const char * const msg);
|
||||
// ui events
|
||||
void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity);
|
||||
void ui_contact_typing(const char * const barejid, const char * const resource);
|
||||
void ui_incoming_msg(const char * const from, const char * const resource, const char * const message, GTimeVal *tv_stamp);
|
||||
void ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GTimeVal *tv_stamp, gboolean win_created);
|
||||
void ui_incoming_private_msg(const char * const fulljid, const char * const message, GTimeVal *tv_stamp);
|
||||
void ui_message_receipt(const char * const barejid, const char * const id);
|
||||
|
||||
|
@ -179,7 +179,7 @@ void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activi
|
||||
}
|
||||
|
||||
void ui_contact_typing(const char * const barejid, const char * const resource) {}
|
||||
void ui_incoming_msg(const char * const from, const char * const resource, const char * const message, GTimeVal *tv_stamp) {}
|
||||
void ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GTimeVal *tv_stamp, gboolean win_created) {}
|
||||
void ui_message_receipt(const char * const barejid, const char * const id) {}
|
||||
|
||||
void ui_incoming_private_msg(const char * const fulljid, const char * const message, GTimeVal *tv_stamp) {}
|
||||
|
Loading…
Reference in New Issue
Block a user