mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Allow pasing a jid to info command in chat window
If we pass a jid/nick to `/info` in a chat window we will still get the output. But on the console window. Regards https://github.com/profanity-im/profanity/issues/1194
This commit is contained in:
parent
0f732466f8
commit
b961ad29c7
@ -3300,6 +3300,21 @@ cmd_status(ProfWin *window, const char *const command, gchar **args)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cmd_info_show_conact(char *usr)
|
||||||
|
{
|
||||||
|
char *usr_jid = roster_barejid_from_name(usr);
|
||||||
|
if (usr_jid == NULL) {
|
||||||
|
usr_jid = usr;
|
||||||
|
}
|
||||||
|
PContact pcontact = roster_get_contact(usr_jid);
|
||||||
|
if (pcontact) {
|
||||||
|
cons_show_info(pcontact);
|
||||||
|
} else {
|
||||||
|
cons_show("No such contact \"%s\" in roster.", usr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cmd_info(ProfWin *window, const char *const command, gchar **args)
|
cmd_info(ProfWin *window, const char *const command, gchar **args)
|
||||||
{
|
{
|
||||||
@ -3334,7 +3349,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args)
|
|||||||
break;
|
break;
|
||||||
case WIN_CHAT:
|
case WIN_CHAT:
|
||||||
if (usr) {
|
if (usr) {
|
||||||
win_println(window, THEME_DEFAULT, '-', "No parameter required when in chat.");
|
_cmd_info_show_conact(usr);
|
||||||
} else {
|
} else {
|
||||||
ProfChatWin *chatwin = (ProfChatWin*)window;
|
ProfChatWin *chatwin = (ProfChatWin*)window;
|
||||||
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||||
@ -3348,7 +3363,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args)
|
|||||||
break;
|
break;
|
||||||
case WIN_PRIVATE:
|
case WIN_PRIVATE:
|
||||||
if (usr) {
|
if (usr) {
|
||||||
win_println(window, THEME_DEFAULT, '-', "No parameter required when in chat.");
|
_cmd_info_show_conact(usr);
|
||||||
} else {
|
} else {
|
||||||
ProfPrivateWin *privatewin = (ProfPrivateWin*)window;
|
ProfPrivateWin *privatewin = (ProfPrivateWin*)window;
|
||||||
assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK);
|
assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK);
|
||||||
@ -3364,16 +3379,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args)
|
|||||||
break;
|
break;
|
||||||
case WIN_CONSOLE:
|
case WIN_CONSOLE:
|
||||||
if (usr) {
|
if (usr) {
|
||||||
char *usr_jid = roster_barejid_from_name(usr);
|
_cmd_info_show_conact(usr);
|
||||||
if (usr_jid == NULL) {
|
|
||||||
usr_jid = usr;
|
|
||||||
}
|
|
||||||
PContact pcontact = roster_get_contact(usr_jid);
|
|
||||||
if (pcontact) {
|
|
||||||
cons_show_info(pcontact);
|
|
||||||
} else {
|
|
||||||
cons_show("No such contact \"%s\" in roster.", usr);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
cons_bad_cmd_usage(command);
|
cons_bad_cmd_usage(command);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user