1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

Check nick exists when private messaging

Show nick part of jid in private messaging
This commit is contained in:
James Booth 2013-01-11 01:35:25 +00:00
parent 1cc5353697
commit 5fbf966b9c
2 changed files with 43 additions and 13 deletions

View File

@ -1532,19 +1532,44 @@ _cmd_msg(gchar **args, struct cmd_help_t help)
return TRUE;
}
if (msg != NULL) {
jabber_send(msg, usr);
win_show_outgoing_msg("me", usr, msg);
if (win_current_is_groupchat()) {
char *room_name = win_current_get_recipient();
if (room_nick_in_roster(room_name, usr)) {
GString *full_jid = g_string_new(room_name);
g_string_append(full_jid, "/");
g_string_append(full_jid, usr);
if (prefs_get_chlog()) {
const char *jid = jabber_get_jid();
chat_log_chat(jid, usr, msg, PROF_OUT_LOG, NULL);
jabber_send(msg, full_jid->str);
win_show_outgoing_msg("me", full_jid->str, msg);
if (prefs_get_chlog()) {
const char *jid = jabber_get_jid();
chat_log_chat(jid, full_jid->str, msg, PROF_OUT_LOG, NULL);
}
g_string_free(full_jid, TRUE);
} else {
cons_show("No such nick \"%s\" in room %s.", usr, room_name);
}
return TRUE;
} else {
win_new_chat_win(usr);
return TRUE;
if (msg != NULL) {
jabber_send(msg, usr);
win_show_outgoing_msg("me", usr, msg);
if (prefs_get_chlog()) {
const char *jid = jabber_get_jid();
chat_log_chat(jid, usr, msg, PROF_OUT_LOG, NULL);
}
return TRUE;
} else {
win_new_chat_win(usr);
return TRUE;
}
}
}

View File

@ -326,11 +326,14 @@ void
ui_show_incoming_msg(const char * const from, const char * const message,
GTimeVal *tv_stamp, gboolean priv)
{
char *display_from;
win_type_t win_type;
if (priv) {
win_type = WIN_PRIVATE;
display_from = room_get_nick_from_full_jid(from);
} else {
win_type = WIN_CHAT;
display_from = strdup(from);
}
int win_index = _find_prof_win_index(from);
@ -390,12 +393,12 @@ ui_show_incoming_msg(const char * const from, const char * const message,
if (strncmp(message, "/me ", 4) == 0) {
wattron(win, COLOUR_THEM);
wprintw(win, "*%s ", from);
wprintw(win, "*%s ", display_from);
wprintw(win, message + 4);
wprintw(win, "\n");
wattroff(win, COLOUR_THEM);
} else {
_win_show_user(win, from, 1);
_win_show_user(win, display_from, 1);
_win_show_message(win, message);
}
title_bar_set_typing(FALSE);
@ -429,12 +432,12 @@ ui_show_incoming_msg(const char * const from, const char * const message,
if (strncmp(message, "/me ", 4) == 0) {
wattron(win, COLOUR_THEM);
wprintw(win, "*%s ", from);
wprintw(win, "*%s ", display_from);
wprintw(win, message + 4);
wprintw(win, "\n");
wattroff(win, COLOUR_THEM);
} else {
_win_show_user(win, from, 1);
_win_show_user(win, display_from, 1);
_win_show_message(win, message);
}
}
@ -443,7 +446,9 @@ ui_show_incoming_msg(const char * const from, const char * const message,
if (prefs_get_beep())
beep();
if (prefs_get_notify_message())
_notify_message(from);
_notify_message(display_from);
g_free(display_from);
}
void