mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Allow incoming private messages from chat rooms
This commit is contained in:
parent
df094a7d2c
commit
13689a1f84
25
src/jabber.c
25
src/jabber.c
@ -466,6 +466,15 @@ _chat_message_handler(xmpp_stanza_t * const stanza)
|
|||||||
char from_cpy[strlen(from) + 1];
|
char from_cpy[strlen(from) + 1];
|
||||||
strcpy(from_cpy, from);
|
strcpy(from_cpy, from);
|
||||||
char *short_from = strtok(from_cpy, "/");
|
char *short_from = strtok(from_cpy, "/");
|
||||||
|
char *jid = NULL;
|
||||||
|
|
||||||
|
// private message from chat room use full jid (room/nick)
|
||||||
|
if (room_is_active(short_from)) {
|
||||||
|
jid = strdup(from);
|
||||||
|
// standard chat message, use jid without resource
|
||||||
|
} else {
|
||||||
|
jid = strdup(short_from);
|
||||||
|
}
|
||||||
|
|
||||||
// determine chatstate support of recipient
|
// determine chatstate support of recipient
|
||||||
gboolean recipient_supports = FALSE;
|
gboolean recipient_supports = FALSE;
|
||||||
@ -474,10 +483,10 @@ _chat_message_handler(xmpp_stanza_t * const stanza)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create or update chat session
|
// create or update chat session
|
||||||
if (!chat_session_exists(short_from)) {
|
if (!chat_session_exists(jid)) {
|
||||||
chat_session_start(short_from, recipient_supports);
|
chat_session_start(jid, recipient_supports);
|
||||||
} else {
|
} else {
|
||||||
chat_session_set_recipient_supports(short_from, recipient_supports);
|
chat_session_set_recipient_supports(jid, recipient_supports);
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine if the notifications happened whilst offline
|
// determine if the notifications happened whilst offline
|
||||||
@ -487,10 +496,10 @@ _chat_message_handler(xmpp_stanza_t * const stanza)
|
|||||||
if (recipient_supports && (delay == NULL)) {
|
if (recipient_supports && (delay == NULL)) {
|
||||||
if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_COMPOSING) != NULL) {
|
if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_COMPOSING) != NULL) {
|
||||||
if (prefs_get_notify_typing() || prefs_get_intype()) {
|
if (prefs_get_notify_typing() || prefs_get_intype()) {
|
||||||
prof_handle_typing(short_from);
|
prof_handle_typing(jid);
|
||||||
}
|
}
|
||||||
} else if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_GONE) != NULL) {
|
} else if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_GONE) != NULL) {
|
||||||
prof_handle_gone(short_from);
|
prof_handle_gone(jid);
|
||||||
} else if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PAUSED) != NULL) {
|
} else if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PAUSED) != NULL) {
|
||||||
// do something
|
// do something
|
||||||
} else if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_INACTIVE) != NULL) {
|
} else if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_INACTIVE) != NULL) {
|
||||||
@ -510,16 +519,18 @@ _chat_message_handler(xmpp_stanza_t * const stanza)
|
|||||||
|
|
||||||
if (g_time_val_from_iso8601(utc_stamp, &tv_stamp)) {
|
if (g_time_val_from_iso8601(utc_stamp, &tv_stamp)) {
|
||||||
if (message != NULL) {
|
if (message != NULL) {
|
||||||
prof_handle_delayed_message(short_from, message, tv_stamp);
|
prof_handle_delayed_message(jid, message, tv_stamp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log_error("Couldn't parse datetime string of historic message: %s", utc_stamp);
|
log_error("Couldn't parse datetime string of historic message: %s", utc_stamp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
prof_handle_incoming_message(short_from, message);
|
prof_handle_incoming_message(jid, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free(jid);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,13 +303,9 @@ void
|
|||||||
win_show_incomming_msg(const char * const from, const char * const message,
|
win_show_incomming_msg(const char * const from, const char * const message,
|
||||||
GTimeVal *tv_stamp)
|
GTimeVal *tv_stamp)
|
||||||
{
|
{
|
||||||
char from_cpy[strlen(from) + 1];
|
int win_index = _find_prof_win_index(from);
|
||||||
strcpy(from_cpy, from);
|
|
||||||
char *short_from = strtok(from_cpy, "/");
|
|
||||||
|
|
||||||
int win_index = _find_prof_win_index(short_from);
|
|
||||||
if (win_index == NUM_WINS)
|
if (win_index == NUM_WINS)
|
||||||
win_index = _new_prof_win(short_from, WIN_CHAT);
|
win_index = _new_prof_win(from, WIN_CHAT);
|
||||||
|
|
||||||
WINDOW *win = _wins[win_index].win;
|
WINDOW *win = _wins[win_index].win;
|
||||||
|
|
||||||
@ -327,12 +323,12 @@ win_show_incomming_msg(const char * const from, const char * const message,
|
|||||||
|
|
||||||
if (strncmp(message, "/me ", 4) == 0) {
|
if (strncmp(message, "/me ", 4) == 0) {
|
||||||
wattron(win, COLOUR_ONLINE);
|
wattron(win, COLOUR_ONLINE);
|
||||||
wprintw(win, "*%s ", short_from);
|
wprintw(win, "*%s ", from);
|
||||||
wprintw(win, message + 4);
|
wprintw(win, message + 4);
|
||||||
wprintw(win, "\n");
|
wprintw(win, "\n");
|
||||||
wattroff(win, COLOUR_ONLINE);
|
wattroff(win, COLOUR_ONLINE);
|
||||||
} else {
|
} else {
|
||||||
_win_show_user(win, short_from, 1);
|
_win_show_user(win, from, 1);
|
||||||
_win_show_message(win, message);
|
_win_show_message(win, message);
|
||||||
}
|
}
|
||||||
title_bar_set_typing(FALSE);
|
title_bar_set_typing(FALSE);
|
||||||
@ -343,13 +339,13 @@ win_show_incomming_msg(const char * const from, const char * const message,
|
|||||||
// not currently viewing chat window with sender
|
// not currently viewing chat window with sender
|
||||||
} else {
|
} else {
|
||||||
status_bar_new(win_index);
|
status_bar_new(win_index);
|
||||||
_cons_show_incoming_message(short_from, win_index);
|
_cons_show_incoming_message(from, win_index);
|
||||||
if (prefs_get_flash())
|
if (prefs_get_flash())
|
||||||
flash();
|
flash();
|
||||||
|
|
||||||
_wins[win_index].unread++;
|
_wins[win_index].unread++;
|
||||||
if (prefs_get_chlog() && prefs_get_history()) {
|
if (prefs_get_chlog() && prefs_get_history()) {
|
||||||
_win_show_history(win, win_index, short_from);
|
_win_show_history(win, win_index, from);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tv_stamp == NULL) {
|
if (tv_stamp == NULL) {
|
||||||
@ -364,12 +360,12 @@ win_show_incomming_msg(const char * const from, const char * const message,
|
|||||||
|
|
||||||
if (strncmp(message, "/me ", 4) == 0) {
|
if (strncmp(message, "/me ", 4) == 0) {
|
||||||
wattron(win, COLOUR_ONLINE);
|
wattron(win, COLOUR_ONLINE);
|
||||||
wprintw(win, "*%s ", short_from);
|
wprintw(win, "*%s ", from);
|
||||||
wprintw(win, message + 4);
|
wprintw(win, message + 4);
|
||||||
wprintw(win, "\n");
|
wprintw(win, "\n");
|
||||||
wattroff(win, COLOUR_ONLINE);
|
wattroff(win, COLOUR_ONLINE);
|
||||||
} else {
|
} else {
|
||||||
_win_show_user(win, short_from, 1);
|
_win_show_user(win, from, 1);
|
||||||
_win_show_message(win, message);
|
_win_show_message(win, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -378,7 +374,7 @@ win_show_incomming_msg(const char * const from, const char * const message,
|
|||||||
beep();
|
beep();
|
||||||
#ifdef HAVE_LIBNOTIFY
|
#ifdef HAVE_LIBNOTIFY
|
||||||
if (prefs_get_notify_message())
|
if (prefs_get_notify_message())
|
||||||
_win_notify_message(short_from);
|
_win_notify_message(from);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user