mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Handle sending messages in groupchat
This commit is contained in:
parent
8f317f9dbf
commit
517bc30360
@ -611,7 +611,11 @@ cmd_execute(const char * const command, const char * const inp)
|
||||
gboolean
|
||||
cmd_execute_default(const char * const inp)
|
||||
{
|
||||
if (win_in_chat()) {
|
||||
if (win_in_groupchat()) {
|
||||
char *recipient = win_get_recipient();
|
||||
jabber_send_groupchat(inp, recipient);
|
||||
free(recipient);
|
||||
} else if (win_in_chat()) {
|
||||
char *recipient = win_get_recipient();
|
||||
jabber_send(inp, recipient);
|
||||
|
||||
|
30
src/jabber.c
30
src/jabber.c
@ -186,6 +186,36 @@ jabber_send(const char * const msg, const char * const recipient)
|
||||
free(coded_msg3);
|
||||
}
|
||||
|
||||
void
|
||||
jabber_send_groupchat(const char * const msg, const char * const recipient)
|
||||
{
|
||||
char *coded_msg = str_replace(msg, "&", "&");
|
||||
char *coded_msg2 = str_replace(coded_msg, "<", "<");
|
||||
char *coded_msg3 = str_replace(coded_msg2, ">", ">");
|
||||
|
||||
xmpp_stanza_t *reply, *body, *text;
|
||||
|
||||
reply = xmpp_stanza_new(jabber_conn.ctx);
|
||||
xmpp_stanza_set_name(reply, "message");
|
||||
xmpp_stanza_set_type(reply, "groupchat");
|
||||
xmpp_stanza_set_attribute(reply, "to", recipient);
|
||||
|
||||
body = xmpp_stanza_new(jabber_conn.ctx);
|
||||
xmpp_stanza_set_name(body, "body");
|
||||
|
||||
text = xmpp_stanza_new(jabber_conn.ctx);
|
||||
xmpp_stanza_set_text(text, coded_msg3);
|
||||
|
||||
xmpp_stanza_add_child(body, text);
|
||||
xmpp_stanza_add_child(reply, body);
|
||||
|
||||
xmpp_send(jabber_conn.conn, reply);
|
||||
xmpp_stanza_release(reply);
|
||||
free(coded_msg);
|
||||
free(coded_msg2);
|
||||
free(coded_msg3);
|
||||
}
|
||||
|
||||
void
|
||||
jabber_send_inactive(const char * const recipient)
|
||||
{
|
||||
|
@ -48,6 +48,7 @@ void jabber_process_events(void);
|
||||
void jabber_subscribe(const char * const recipient);
|
||||
void jabber_join(const char * const room_jid, const char * const nick);
|
||||
void jabber_send(const char * const msg, const char * const recipient);
|
||||
void jabber_send_groupchat(const char * const msg, const char * const recipient);
|
||||
void jabber_send_inactive(const char * const recipient);
|
||||
void jabber_send_composing(const char * const recipient);
|
||||
void jabber_send_paused(const char * const recipient);
|
||||
|
@ -536,7 +536,11 @@ win_show_room_message(const char * const room_jid, const char * const nick,
|
||||
WINDOW *win = _wins[win_index].win;
|
||||
|
||||
_win_show_time(win);
|
||||
_win_show_user(win, nick, 1);
|
||||
if (strcmp(nick, room_get_nick_for_room(room_jid)) != 0) {
|
||||
_win_show_user(win, nick, 1);
|
||||
} else {
|
||||
_win_show_user(win, nick, 0);
|
||||
}
|
||||
_win_show_message(win, message);
|
||||
|
||||
// currently in groupchat window
|
||||
@ -552,18 +556,25 @@ win_show_room_message(const char * const room_jid, const char * const nick,
|
||||
dirty = TRUE;
|
||||
}
|
||||
|
||||
if (prefs_get_flash())
|
||||
flash();
|
||||
if (strcmp(nick, room_get_nick_for_room(room_jid)) != 0) {
|
||||
if (prefs_get_flash()) {
|
||||
flash();
|
||||
}
|
||||
}
|
||||
|
||||
_wins[win_index].unread++;
|
||||
}
|
||||
|
||||
if (prefs_get_beep())
|
||||
beep();
|
||||
if (strcmp(nick, room_get_nick_for_room(room_jid)) != 0) {
|
||||
if (prefs_get_beep()) {
|
||||
beep();
|
||||
}
|
||||
#ifdef HAVE_LIBNOTIFY
|
||||
if (prefs_get_notify_message())
|
||||
_win_notify_message(nick);
|
||||
if (prefs_get_notify_message()) {
|
||||
_win_notify_message(nick);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user