mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Allow /info and /msg in private room chat when nick has space in name
This commit is contained in:
parent
cbb3fd45e4
commit
62b89a4d8a
@ -1584,7 +1584,11 @@ _cmd_info(gchar **args, struct cmd_help_t help)
|
|||||||
if (conn_status != JABBER_CONNECTED) {
|
if (conn_status != JABBER_CONNECTED) {
|
||||||
cons_show("You are not currently connected.");
|
cons_show("You are not currently connected.");
|
||||||
} else {
|
} else {
|
||||||
cons_show_status(usr);
|
if (win_current_is_groupchat()) {
|
||||||
|
win_show_status(usr);
|
||||||
|
} else {
|
||||||
|
cons_show_status(usr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
13
src/muc.c
13
src/muc.c
@ -241,6 +241,19 @@ muc_remove_from_roster(const char * const room, const char * const nick)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PContact
|
||||||
|
muc_get_participant(const char * const room, const char * const nick)
|
||||||
|
{
|
||||||
|
ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
|
||||||
|
|
||||||
|
if (chat_room != NULL) {
|
||||||
|
PContact participant = g_hash_table_lookup(chat_room->roster, nick);
|
||||||
|
return participant;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return a list of PContacts representing the room members in the room's roster
|
* Return a list of PContacts representing the room members in the room's roster
|
||||||
* The list is owned by the room and must not be mofified or freed
|
* The list is owned by the room and must not be mofified or freed
|
||||||
|
@ -44,6 +44,7 @@ void muc_remove_from_roster(const char * const room, const char * const nick);
|
|||||||
GList * muc_get_roster(const char * const room);
|
GList * muc_get_roster(const char * const room);
|
||||||
PAutocomplete muc_get_roster_ac(const char * const room);
|
PAutocomplete muc_get_roster_ac(const char * const room);
|
||||||
gboolean muc_nick_in_roster(const char * const room, const char * const nick);
|
gboolean muc_nick_in_roster(const char * const room, const char * const nick);
|
||||||
|
PContact muc_get_participant(const char * const room, const char * const nick);
|
||||||
void muc_set_roster_received(const char * const room);
|
void muc_set_roster_received(const char * const room);
|
||||||
gboolean muc_get_roster_received(const char * const room);
|
gboolean muc_get_roster_received(const char * const room);
|
||||||
|
|
||||||
|
1
src/ui.h
1
src/ui.h
@ -132,6 +132,7 @@ void win_show_room_member_nick_change(const char * const room,
|
|||||||
void win_show_room_nick_change(const char * const room, const char * const nick);
|
void win_show_room_nick_change(const char * const room, const char * const nick);
|
||||||
void win_show_room_member_presence(const char * const room,
|
void win_show_room_member_presence(const char * const room,
|
||||||
const char * const nick, const char * const show, const char * const status);
|
const char * const nick, const char * const show, const char * const status);
|
||||||
|
void win_show_status(const char * const contact);
|
||||||
|
|
||||||
// console window actions
|
// console window actions
|
||||||
void cons_about(void);
|
void cons_about(void);
|
||||||
|
@ -88,7 +88,7 @@ static void _set_current(int index);
|
|||||||
static void _create_windows(void);
|
static void _create_windows(void);
|
||||||
static void _cons_splash_logo(void);
|
static void _cons_splash_logo(void);
|
||||||
static void _cons_show_basic_help(void);
|
static void _cons_show_basic_help(void);
|
||||||
static void _cons_show_contact(PContact contact);
|
static void _win_show_contact(ProfWin *window, PContact contact);
|
||||||
static int _find_prof_win_index(const char * const contact);
|
static int _find_prof_win_index(const char * const contact);
|
||||||
static int _new_prof_win(const char * const contact, win_type_t type);
|
static int _new_prof_win(const char * const contact, win_type_t type);
|
||||||
static void _current_window_refresh(void);
|
static void _current_window_refresh(void);
|
||||||
@ -1166,12 +1166,24 @@ cons_show_status(const char * const contact)
|
|||||||
PContact pcontact = contact_list_get_contact(contact);
|
PContact pcontact = contact_list_get_contact(contact);
|
||||||
|
|
||||||
if (pcontact != NULL) {
|
if (pcontact != NULL) {
|
||||||
_cons_show_contact(pcontact);
|
_win_show_contact(console, pcontact);
|
||||||
} else {
|
} else {
|
||||||
cons_show("No such contact \"%s\" in roster.", contact);
|
cons_show("No such contact \"%s\" in roster.", contact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
win_show_status(const char * const contact)
|
||||||
|
{
|
||||||
|
PContact pcontact = muc_get_participant(win_current_get_recipient(), contact);
|
||||||
|
|
||||||
|
if (pcontact != NULL) {
|
||||||
|
_win_show_contact(current, pcontact);
|
||||||
|
} else {
|
||||||
|
win_current_show("No such participant \"%s\" in room.", contact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cons_show_account(ProfAccount *account)
|
cons_show_account(ProfAccount *account)
|
||||||
{
|
{
|
||||||
@ -1522,7 +1534,7 @@ cons_show_contacts(GSList *list)
|
|||||||
while(curr) {
|
while(curr) {
|
||||||
PContact contact = curr->data;
|
PContact contact = curr->data;
|
||||||
if (strcmp(p_contact_subscription(contact), "none") != 0) {
|
if (strcmp(p_contact_subscription(contact), "none") != 0) {
|
||||||
_cons_show_contact(contact);
|
_win_show_contact(console, contact);
|
||||||
}
|
}
|
||||||
curr = g_slist_next(curr);
|
curr = g_slist_next(curr);
|
||||||
}
|
}
|
||||||
@ -2063,7 +2075,7 @@ _cons_show_incoming_message(const char * const short_from, const int win_index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cons_show_contact(PContact contact)
|
_win_show_contact(ProfWin *window, PContact contact)
|
||||||
{
|
{
|
||||||
const char *jid = p_contact_jid(contact);
|
const char *jid = p_contact_jid(contact);
|
||||||
const char *name = p_contact_name(contact);
|
const char *name = p_contact_name(contact);
|
||||||
@ -2071,68 +2083,68 @@ _cons_show_contact(PContact contact)
|
|||||||
const char *status = p_contact_status(contact);
|
const char *status = p_contact_status(contact);
|
||||||
GDateTime *last_activity = p_contact_last_activity(contact);
|
GDateTime *last_activity = p_contact_last_activity(contact);
|
||||||
|
|
||||||
_win_show_time(console->win);
|
_win_show_time(window->win);
|
||||||
|
|
||||||
if (strcmp(presence, "online") == 0) {
|
if (strcmp(presence, "online") == 0) {
|
||||||
wattron(console->win, COLOUR_ONLINE);
|
wattron(window->win, COLOUR_ONLINE);
|
||||||
} else if (strcmp(presence, "away") == 0) {
|
} else if (strcmp(presence, "away") == 0) {
|
||||||
wattron(console->win, COLOUR_AWAY);
|
wattron(window->win, COLOUR_AWAY);
|
||||||
} else if (strcmp(presence, "chat") == 0) {
|
} else if (strcmp(presence, "chat") == 0) {
|
||||||
wattron(console->win, COLOUR_CHAT);
|
wattron(window->win, COLOUR_CHAT);
|
||||||
} else if (strcmp(presence, "dnd") == 0) {
|
} else if (strcmp(presence, "dnd") == 0) {
|
||||||
wattron(console->win, COLOUR_DND);
|
wattron(window->win, COLOUR_DND);
|
||||||
} else if (strcmp(presence, "xa") == 0) {
|
} else if (strcmp(presence, "xa") == 0) {
|
||||||
wattron(console->win, COLOUR_XA);
|
wattron(window->win, COLOUR_XA);
|
||||||
} else {
|
} else {
|
||||||
wattron(console->win, COLOUR_OFFLINE);
|
wattron(window->win, COLOUR_OFFLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintw(console->win, "%s", jid);
|
wprintw(window->win, "%s", jid);
|
||||||
|
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
wprintw(console->win, " (%s)", name);
|
wprintw(window->win, " (%s)", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintw(console->win, " is %s", presence);
|
wprintw(window->win, " is %s", presence);
|
||||||
|
|
||||||
if (last_activity != NULL) {
|
if (last_activity != NULL) {
|
||||||
GDateTime *now = g_date_time_new_now_local();
|
GDateTime *now = g_date_time_new_now_local();
|
||||||
GTimeSpan span = g_date_time_difference(now, last_activity);
|
GTimeSpan span = g_date_time_difference(now, last_activity);
|
||||||
|
|
||||||
wprintw(console->win, ", idle ");
|
wprintw(window->win, ", idle ");
|
||||||
|
|
||||||
int hours = span / G_TIME_SPAN_HOUR;
|
int hours = span / G_TIME_SPAN_HOUR;
|
||||||
span = span - hours * G_TIME_SPAN_HOUR;
|
span = span - hours * G_TIME_SPAN_HOUR;
|
||||||
if (hours > 0) {
|
if (hours > 0) {
|
||||||
wprintw(console->win, "%dh", hours);
|
wprintw(window->win, "%dh", hours);
|
||||||
}
|
}
|
||||||
|
|
||||||
int minutes = span / G_TIME_SPAN_MINUTE;
|
int minutes = span / G_TIME_SPAN_MINUTE;
|
||||||
span = span - minutes * G_TIME_SPAN_MINUTE;
|
span = span - minutes * G_TIME_SPAN_MINUTE;
|
||||||
wprintw(console->win, "%dm", minutes);
|
wprintw(window->win, "%dm", minutes);
|
||||||
|
|
||||||
int seconds = span / G_TIME_SPAN_SECOND;
|
int seconds = span / G_TIME_SPAN_SECOND;
|
||||||
wprintw(console->win, "%ds", seconds);
|
wprintw(window->win, "%ds", seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status != NULL) {
|
if (status != NULL) {
|
||||||
wprintw(console->win, ", \"%s\"", p_contact_status(contact));
|
wprintw(window->win, ", \"%s\"", p_contact_status(contact));
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintw(console->win, "\n");
|
wprintw(window->win, "\n");
|
||||||
|
|
||||||
if (strcmp(presence, "online") == 0) {
|
if (strcmp(presence, "online") == 0) {
|
||||||
wattroff(console->win, COLOUR_ONLINE);
|
wattroff(window->win, COLOUR_ONLINE);
|
||||||
} else if (strcmp(presence, "away") == 0) {
|
} else if (strcmp(presence, "away") == 0) {
|
||||||
wattroff(console->win, COLOUR_AWAY);
|
wattroff(window->win, COLOUR_AWAY);
|
||||||
} else if (strcmp(presence, "chat") == 0) {
|
} else if (strcmp(presence, "chat") == 0) {
|
||||||
wattroff(console->win, COLOUR_CHAT);
|
wattroff(window->win, COLOUR_CHAT);
|
||||||
} else if (strcmp(presence, "dnd") == 0) {
|
} else if (strcmp(presence, "dnd") == 0) {
|
||||||
wattroff(console->win, COLOUR_DND);
|
wattroff(window->win, COLOUR_DND);
|
||||||
} else if (strcmp(presence, "xa") == 0) {
|
} else if (strcmp(presence, "xa") == 0) {
|
||||||
wattroff(console->win, COLOUR_XA);
|
wattroff(window->win, COLOUR_XA);
|
||||||
} else {
|
} else {
|
||||||
wattroff(console->win, COLOUR_OFFLINE);
|
wattroff(window->win, COLOUR_OFFLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user