1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added cons_show_incoming_room_message()

This commit is contained in:
James Booth 2015-12-20 00:54:17 +00:00
parent 8f6b37f650
commit 1f56c12377
5 changed files with 75 additions and 54 deletions

View File

@ -212,16 +212,69 @@ void
sv_ev_room_message(const char *const room_jid, const char *const nick, sv_ev_room_message(const char *const room_jid, const char *const nick,
const char *const message) const char *const message)
{ {
ProfMucWin *mucwin = wins_get_muc(room_jid);
if (mucwin) {
mucwin_message(mucwin, nick, message);
}
if (prefs_get_boolean(PREF_GRLOG)) { if (prefs_get_boolean(PREF_GRLOG)) {
Jid *jid = jid_create(jabber_get_fulljid()); Jid *jid = jid_create(jabber_get_fulljid());
groupchat_log_chat(jid->barejid, room_jid, nick, message); groupchat_log_chat(jid->barejid, room_jid, nick, message);
jid_destroy(jid); jid_destroy(jid);
} }
ProfMucWin *mucwin = wins_get_muc(room_jid);
if (!mucwin) {
return;
}
mucwin_message(mucwin, nick, message);
ProfWin *window = (ProfWin*)mucwin;
gboolean is_current = wins_is_current(window);
int num = wins_get_num(window);
char *my_nick = muc_nick(mucwin->roomjid);
gboolean notify = prefs_do_room_notify(is_current, mucwin->roomjid, my_nick, message);
// currently in groupchat window
if (wins_is_current(window)) {
status_bar_active(num);
// not currently on groupchat window
} else {
status_bar_new(num);
cons_show_incoming_room_message(nick, mucwin->roomjid, num);
if (prefs_get_boolean(PREF_FLASH) && (strcmp(nick, my_nick) != 0)) {
flash();
}
mucwin->unread++;
if (notify) {
mucwin->notify = TRUE;
}
}
// don't notify self messages
if (strcmp(nick, my_nick) == 0) {
return;
}
if (prefs_get_boolean(PREF_BEEP)) {
beep();
}
if (!notify) {
return;
}
Jid *jidp = jid_create(mucwin->roomjid);
int ui_index = num;
if (ui_index == 10) {
ui_index = 0;
}
if (prefs_get_boolean(PREF_NOTIFY_ROOM_TEXT)) {
notify_room_message(nick, jidp->localpart, ui_index, message);
} else {
notify_room_message(nick, jidp->localpart, ui_index, NULL);
}
jid_destroy(jidp);
} }
void void

View File

@ -301,6 +301,21 @@ cons_show_typing(const char *const barejid)
cons_alert(); cons_alert();
} }
void
cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index)
{
ProfWin *const console = wins_get_console();
int ui_index = win_index;
if (ui_index == 10) {
ui_index = 0;
}
win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< incoming from %s in %s (win %d)", nick, room, ui_index);
cons_alert();
}
void void
cons_show_incoming_message(const char *const short_from, const int win_index) cons_show_incoming_message(const char *const short_from, const int win_index)
{ {

View File

@ -361,7 +361,6 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
int num = wins_get_num(window);
char *my_nick = muc_nick(mucwin->roomjid); char *my_nick = muc_nick(mucwin->roomjid);
if (g_strcmp0(nick, my_nick) != 0) { if (g_strcmp0(nick, my_nick) != 0) {
@ -373,54 +372,6 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
} else { } else {
win_print(window, '-', 0, NULL, 0, THEME_TEXT_ME, nick, message); win_print(window, '-', 0, NULL, 0, THEME_TEXT_ME, nick, message);
} }
gboolean is_current = wins_is_current(window);
gboolean notify = prefs_do_room_notify(is_current, mucwin->roomjid, my_nick, message);
// currently in groupchat window
if (wins_is_current(window)) {
status_bar_active(num);
// not currently on groupchat window
} else {
status_bar_new(num);
cons_show_incoming_message(nick, num);
if (prefs_get_boolean(PREF_FLASH) && (strcmp(nick, my_nick) != 0)) {
flash();
}
mucwin->unread++;
if (notify) {
mucwin->notify = TRUE;
}
}
// don't notify self messages
if (strcmp(nick, my_nick) == 0) {
return;
}
if (prefs_get_boolean(PREF_BEEP)) {
beep();
}
if (!notify) {
return;
}
Jid *jidp = jid_create(mucwin->roomjid);
int ui_index = num;
if (ui_index == 10) {
ui_index = 0;
}
if (prefs_get_boolean(PREF_NOTIFY_ROOM_TEXT)) {
notify_room_message(nick, jidp->localpart, ui_index, message);
} else {
notify_room_message(nick, jidp->localpart, ui_index, NULL);
}
jid_destroy(jidp);
} }
void void

View File

@ -257,6 +257,7 @@ void cons_show_disco_info(const char *from, GSList *identities, GSList *features
void cons_show_room_invite(const char *const invitor, const char *const room, const char *const reason); void cons_show_room_invite(const char *const invitor, const char *const room, const char *const reason);
void cons_check_version(gboolean not_available_msg); void cons_check_version(gboolean not_available_msg);
void cons_show_typing(const char *const barejid); void cons_show_typing(const char *const barejid);
void cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index);
void cons_show_incoming_message(const char *const short_from, const int win_index); void cons_show_incoming_message(const char *const short_from, const int win_index);
void cons_show_room_invites(GSList *invites); void cons_show_room_invites(GSList *invites);
void cons_show_received_subs(void); void cons_show_received_subs(void);

View File

@ -394,6 +394,7 @@ void cons_show_room_invite(const char * const invitor, const char * const room,
const char * const reason) {} const char * const reason) {}
void cons_check_version(gboolean not_available_msg) {} void cons_check_version(gboolean not_available_msg) {}
void cons_show_typing(const char * const barejid) {} void cons_show_typing(const char * const barejid) {}
void cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index) {}
void cons_show_incoming_message(const char * const short_from, const int win_index) {} void cons_show_incoming_message(const char * const short_from, const int win_index) {}
void cons_show_room_invites(GSList *invites) {} void cons_show_room_invites(GSList *invites) {}
void cons_show_received_subs(void) {} void cons_show_received_subs(void) {}