1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Set correct window type on private messages

This commit is contained in:
James Booth 2012-11-14 00:04:08 +00:00
parent faa5f8871f
commit a574f7ff40
5 changed files with 24 additions and 12 deletions

View File

@ -516,6 +516,7 @@ _error_handler(xmpp_stanza_t * const stanza)
static int
_chat_message_handler(xmpp_stanza_t * const stanza)
{
gboolean priv = FALSE;
gchar *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
char from_cpy[strlen(from) + 1];
@ -526,9 +527,11 @@ _chat_message_handler(xmpp_stanza_t * const stanza)
// private message from chat room use full jid (room/nick)
if (room_is_active(short_from)) {
jid = strdup(from);
priv = TRUE;
// standard chat message, use jid without resource
} else {
jid = strdup(short_from);
priv = FALSE;
}
// determine chatstate support of recipient
@ -574,13 +577,13 @@ _chat_message_handler(xmpp_stanza_t * const stanza)
if (g_time_val_from_iso8601(utc_stamp, &tv_stamp)) {
if (message != NULL) {
prof_handle_delayed_message(jid, message, tv_stamp);
prof_handle_delayed_message(jid, message, tv_stamp, priv);
}
} else {
log_error("Couldn't parse datetime string of historic message: %s", utc_stamp);
}
} else {
prof_handle_incoming_message(jid, message);
prof_handle_incoming_message(jid, message, priv);
}
}
@ -660,7 +663,7 @@ _roster_handler(xmpp_conn_t * const conn,
}
/* TODO: Save somehow last presence show and use it for initial
* presence rather than PRESENCE_ONLINE. It will be helpful
* presence rather than PRESENCE_ONLINE. It will be helpful
* when I set dnd status and reconnect for some reason */
// send initial presence
jabber_update_presence(PRESENCE_ONLINE, NULL);

View File

@ -102,9 +102,9 @@ prof_handle_typing(char *from)
}
void
prof_handle_incoming_message(char *from, char *message)
prof_handle_incoming_message(char *from, char *message, gboolean priv)
{
win_show_incomming_msg(from, message, NULL);
win_show_incomming_msg(from, message, NULL, priv);
win_page_off();
if (prefs_get_chlog()) {
@ -118,9 +118,10 @@ prof_handle_incoming_message(char *from, char *message)
}
void
prof_handle_delayed_message(char *from, char *message, GTimeVal tv_stamp)
prof_handle_delayed_message(char *from, char *message, GTimeVal tv_stamp,
gboolean priv)
{
win_show_incomming_msg(from, message, &tv_stamp);
win_show_incomming_msg(from, message, &tv_stamp, priv);
win_page_off();
if (prefs_get_chlog()) {

View File

@ -33,8 +33,9 @@ void prof_handle_failed_login(void);
void prof_handle_typing(char *from);
void prof_handle_contact_online(char *contact, char *show, char *status);
void prof_handle_contact_offline(char *contact, char *show, char *status);
void prof_handle_incoming_message(char *from, char *message);
void prof_handle_delayed_message(char *from, char *message, GTimeVal tv_stamp);
void prof_handle_incoming_message(char *from, char *message, gboolean priv);
void prof_handle_delayed_message(char *from, char *message, GTimeVal tv_stamp,
gboolean priv);
void prof_handle_error_message(const char *from, const char *err_msg);
void prof_handle_subscription(const char *from, jabber_subscr_t type);
void prof_handle_roster(GSList *roster);

View File

@ -98,7 +98,7 @@ char *win_get_recipient(void);
void win_show_typing(const char * const from);
void win_show_gone(const char * const from);
void win_show_incomming_msg(const char * const from, const char * const message,
GTimeVal *tv_stamp);
GTimeVal *tv_stamp, gboolean priv);
void win_show_error_msg(const char * const from, const char *err_msg);
void win_show_system_msg(const char * const from, const char *message);
void win_show_outgoing_msg(const char * const from, const char * const to,

View File

@ -298,11 +298,18 @@ win_no_activity(void)
void
win_show_incomming_msg(const char * const from, const char * const message,
GTimeVal *tv_stamp)
GTimeVal *tv_stamp, gboolean priv)
{
win_type_t win_type;
if (priv) {
win_type = WIN_PRIVATE;
} else {
win_type = WIN_CHAT;
}
int win_index = _find_prof_win_index(from);
if (win_index == NUM_WINS)
win_index = _new_prof_win(from, WIN_CHAT);
win_index = _new_prof_win(from, win_type);
WINDOW *win = _wins[win_index].win;