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
|
gboolean
|
||||||
cmd_execute_default(const char * const inp)
|
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();
|
char *recipient = win_get_recipient();
|
||||||
jabber_send(inp, 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);
|
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
|
void
|
||||||
jabber_send_inactive(const char * const recipient)
|
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_subscribe(const char * const recipient);
|
||||||
void jabber_join(const char * const room_jid, const char * const nick);
|
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(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_inactive(const char * const recipient);
|
||||||
void jabber_send_composing(const char * const recipient);
|
void jabber_send_composing(const char * const recipient);
|
||||||
void jabber_send_paused(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;
|
WINDOW *win = _wins[win_index].win;
|
||||||
|
|
||||||
_win_show_time(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);
|
_win_show_message(win, message);
|
||||||
|
|
||||||
// currently in groupchat window
|
// currently in groupchat window
|
||||||
@ -552,18 +556,25 @@ win_show_room_message(const char * const room_jid, const char * const nick,
|
|||||||
dirty = TRUE;
|
dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefs_get_flash())
|
if (strcmp(nick, room_get_nick_for_room(room_jid)) != 0) {
|
||||||
flash();
|
if (prefs_get_flash()) {
|
||||||
|
flash();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_wins[win_index].unread++;
|
_wins[win_index].unread++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefs_get_beep())
|
if (strcmp(nick, room_get_nick_for_room(room_jid)) != 0) {
|
||||||
beep();
|
if (prefs_get_beep()) {
|
||||||
|
beep();
|
||||||
|
}
|
||||||
#ifdef HAVE_LIBNOTIFY
|
#ifdef HAVE_LIBNOTIFY
|
||||||
if (prefs_get_notify_message())
|
if (prefs_get_notify_message()) {
|
||||||
_win_notify_message(nick);
|
_win_notify_message(nick);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user