mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Handle room presence notifications
This commit is contained in:
parent
0deba9e13e
commit
2f6361a578
@ -1014,8 +1014,8 @@ _cmd_join(const char * const inp, struct cmd_help_t help)
|
|||||||
strcpy(jid_cpy, jid);
|
strcpy(jid_cpy, jid);
|
||||||
nick = strdup(strtok(jid_cpy, "@"));
|
nick = strdup(strtok(jid_cpy, "@"));
|
||||||
}
|
}
|
||||||
|
|
||||||
jabber_join(room_jid, nick);
|
jabber_join(room_jid, nick);
|
||||||
|
win_join_chat(room_jid, nick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,7 +605,12 @@ _presence_handler(xmpp_conn_t * const conn,
|
|||||||
char *from = xmpp_stanza_get_attribute(stanza, "from");
|
char *from = xmpp_stanza_get_attribute(stanza, "from");
|
||||||
|
|
||||||
if (room_jid_is_room_chat(from)) {
|
if (room_jid_is_room_chat(from)) {
|
||||||
cons_show("CHAT ROOM PRESENCE RECIEVED");
|
char **tokens = g_strsplit(from, "/", 0);
|
||||||
|
char *room_jid = tokens[0];
|
||||||
|
char *nick = tokens[1];
|
||||||
|
if (strcmp(room_get_nick_for_room(room_jid), nick) != 0) {
|
||||||
|
win_show_chat_room_member(room_jid, nick);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
char *short_from = strtok(from, "/");
|
char *short_from = strtok(from, "/");
|
||||||
char *type = xmpp_stanza_get_attribute(stanza, "type");
|
char *type = xmpp_stanza_get_attribute(stanza, "type");
|
||||||
|
@ -58,3 +58,17 @@ room_jid_is_room_chat(const char * const jid)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
room_get_nick_for_room(const char * const jid)
|
||||||
|
{
|
||||||
|
GSList *current = rooms;
|
||||||
|
while (current != NULL) {
|
||||||
|
muc_room *room = current->data;
|
||||||
|
if (strcmp(jid, room->jid) == 0) {
|
||||||
|
return room->nick;
|
||||||
|
}
|
||||||
|
current = g_slist_next(current);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
@ -24,3 +24,4 @@
|
|||||||
|
|
||||||
void room_join(const char * const jid, const char * const nick);
|
void room_join(const char * const jid, const char * const nick);
|
||||||
gboolean room_jid_is_room_chat(const char * const jid);
|
gboolean room_jid_is_room_chat(const char * const jid);
|
||||||
|
char * room_get_nick_for_room(const char * const jid);
|
||||||
|
4
src/ui.h
4
src/ui.h
@ -103,6 +103,10 @@ void win_show(const char * const msg);
|
|||||||
void win_bad_show(const char * const msg);
|
void win_bad_show(const char * const msg);
|
||||||
void win_remind(void);
|
void win_remind(void);
|
||||||
|
|
||||||
|
void win_join_chat(const char * const room_jid, const char * const nick);
|
||||||
|
void win_show_chat_room_member(const char * const room_jid,
|
||||||
|
const char * const nick);
|
||||||
|
|
||||||
// console window actions
|
// console window actions
|
||||||
void cons_about(void);
|
void cons_about(void);
|
||||||
void cons_help(void);
|
void cons_help(void);
|
||||||
|
@ -470,6 +470,33 @@ win_show_outgoing_msg(const char * const from, const char * const to,
|
|||||||
_win_switch_if_active(win_index);
|
_win_switch_if_active(win_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
win_join_chat(const char * const room_jid, const char * const nick)
|
||||||
|
{
|
||||||
|
int win_index = _find_prof_win_index(room_jid);
|
||||||
|
|
||||||
|
// create new window
|
||||||
|
if (win_index == NUM_WINS) {
|
||||||
|
win_index = _new_prof_win(room_jid);
|
||||||
|
}
|
||||||
|
|
||||||
|
_win_switch_if_active(win_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
win_show_chat_room_member(const char * const room_jid, const char * const nick)
|
||||||
|
{
|
||||||
|
int win_index = _find_prof_win_index(room_jid);
|
||||||
|
WINDOW *win = _wins[win_index].win;
|
||||||
|
|
||||||
|
wattron(win, COLOUR_ONLINE);
|
||||||
|
wprintw(win, "%s\n", nick);
|
||||||
|
wattroff(win, COLOUR_ONLINE);
|
||||||
|
|
||||||
|
if (win_index == _curr_prof_win)
|
||||||
|
dirty = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
win_show(const char * const msg)
|
win_show(const char * const msg)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user