mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Handle room broadcasts
This commit is contained in:
parent
db15494e22
commit
b3e1d473a2
34
src/jabber.c
34
src/jabber.c
@ -426,18 +426,34 @@ _groupchat_message_handler(xmpp_stanza_t * const stanza)
|
||||
char *room = NULL;
|
||||
char *nick = NULL;
|
||||
char *message = NULL;
|
||||
xmpp_stanza_t *subject = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SUBJECT);
|
||||
gchar *room_jid = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
|
||||
// handle subject
|
||||
if (subject != NULL) {
|
||||
message = xmpp_stanza_get_text(subject);
|
||||
if (message != NULL) {
|
||||
room = room_get_room_from_full_jid(room_jid);
|
||||
prof_handle_room_subject(room, message);
|
||||
}
|
||||
// handle room broadcasts
|
||||
if (room_from_jid_is_room(room_jid)) {
|
||||
xmpp_stanza_t *subject = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SUBJECT);
|
||||
|
||||
return 1;
|
||||
// handle subject
|
||||
if (subject != NULL) {
|
||||
message = xmpp_stanza_get_text(subject);
|
||||
if (message != NULL) {
|
||||
room = room_get_room_from_full_jid(room_jid);
|
||||
prof_handle_room_subject(room, message);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
// handle other room broadcasts
|
||||
} else {
|
||||
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);
|
||||
if (body != NULL) {
|
||||
message = xmpp_stanza_get_text(body);
|
||||
if (message != NULL) {
|
||||
prof_handle_room_broadcast(room_jid, message);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// room jid not of form room/nick
|
||||
|
@ -238,6 +238,14 @@ prof_handle_room_subject(const char * const room_jid, const char * const subject
|
||||
win_page_off();
|
||||
}
|
||||
|
||||
void
|
||||
prof_handle_room_broadcast(const char *const room_jid,
|
||||
const char * const message)
|
||||
{
|
||||
win_show_room_broadcast(room_jid, message);
|
||||
win_page_off();
|
||||
}
|
||||
|
||||
void
|
||||
prof_handle_room_roster_complete(const char * const room)
|
||||
{
|
||||
|
@ -59,5 +59,7 @@ void prof_handle_room_member_nick_change(const char * const room,
|
||||
const char * const old_nick, const char * const nick);
|
||||
void prof_handle_room_nick_change(const char * const room,
|
||||
const char * const nick);
|
||||
void prof_handle_room_broadcast(const char *const room_jid,
|
||||
const char * const message);
|
||||
|
||||
#endif
|
||||
|
@ -153,6 +153,13 @@ room_get_room_from_full_jid(const char * const full_room_jid)
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
room_from_jid_is_room(const char * const room_jid)
|
||||
{
|
||||
gchar *result = g_strrstr(room_jid, "/");
|
||||
return (result == NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
room_get_nick_from_full_jid(const char * const full_room_jid)
|
||||
{
|
||||
|
@ -41,6 +41,7 @@ void room_add_pending_nick_change(const char * const room,
|
||||
char* room_complete_pending_nick_change(const char * const room,
|
||||
const char * const nick);
|
||||
gboolean room_nick_in_roster(const char * const room, const char * const nick);
|
||||
gboolean room_from_jid_is_room(const char * const room_jid);
|
||||
|
||||
GList * room_get_roster(const char * const room);
|
||||
void room_set_roster_received(const char * const room);
|
||||
|
2
src/ui.h
2
src/ui.h
@ -125,6 +125,8 @@ void win_show_room_message(const char * const room_jid, const char * const nick,
|
||||
const char * const message);
|
||||
void win_show_room_subject(const char * const room_jid,
|
||||
const char * const subject);
|
||||
void win_show_room_broadcast(const char * const room_jid,
|
||||
const char * const message);
|
||||
void win_show_room_member_offline(const char * const room, const char * const nick);
|
||||
void win_show_room_member_online(const char * const room,
|
||||
const char * const nick, const char * const show, const char * const status);
|
||||
|
@ -881,6 +881,28 @@ win_show_room_subject(const char * const room_jid, const char * const subject)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
win_show_room_broadcast(const char * const room_jid, const char * const message)
|
||||
{
|
||||
int win_index = _find_prof_win_index(room_jid);
|
||||
WINDOW *win = _wins[win_index].win;
|
||||
|
||||
wattron(win, COLOUR_INC);
|
||||
wprintw(win, "Room message: ");
|
||||
wattroff(win, COLOUR_INC);
|
||||
wprintw(win, "%s\n", message);
|
||||
|
||||
// currently in groupchat window
|
||||
if (win_index == _curr_prof_win) {
|
||||
status_bar_active(win_index);
|
||||
dirty = TRUE;
|
||||
|
||||
// not currenlty on groupchat window
|
||||
} else {
|
||||
status_bar_new(win_index);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
win_show(const char * const msg)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user