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

Always show output in console for /info command

This commit is contained in:
James Booth 2013-01-21 23:48:57 +00:00
parent dd6dfd9408
commit 134da4d001
3 changed files with 37 additions and 53 deletions

View File

@ -1727,25 +1727,49 @@ _cmd_info(gchar **args, struct cmd_help_t help)
} else { } else {
if (win_current_is_groupchat()) { if (win_current_is_groupchat()) {
if (usr != NULL) { if (usr != NULL) {
win_room_show_info(usr); PContact pcontact = muc_get_participant(win_current_get_recipient(), usr);
if (pcontact != NULL) {
cons_show_info(pcontact);
} else {
cons_show("No such participant \"%s\" in room.", usr);
}
} else { } else {
win_current_show("You must specify a nickname."); cons_show("No nickname supplied to /info in chat room.");
} }
} else if (win_current_is_chat()) { } else if (win_current_is_chat()) {
if (usr != NULL) { if (usr != NULL) {
win_current_show("No parameter required when in chat."); cons_show("No parameter required for /info in chat.");
} else { } else {
win_show_info(); PContact pcontact = contact_list_get_contact(win_current_get_recipient());
if (pcontact != NULL) {
cons_show_info(pcontact);
} else {
cons_show("No such contact \"%s\" in roster.", win_current_get_recipient());
}
} }
} else if (win_current_is_private()) { } else if (win_current_is_private()) {
if (usr != NULL) { if (usr != NULL) {
win_current_show("No parameter required when in chat."); win_current_show("No parameter required when in chat.");
} else { } else {
win_private_show_info(); Jid *jid = jid_create(win_current_get_recipient());
PContact pcontact = muc_get_participant(jid->barejid, jid->resourcepart);
if (pcontact != NULL) {
cons_show_info(pcontact);
} else {
cons_show("No such participant \"%s\" in room.", jid->resourcepart);
}
jid_destroy(jid);
} }
} else { } else {
if (usr != NULL) { if (usr != NULL) {
cons_show_info(usr); PContact pcontact = contact_list_get_contact(usr);
if (pcontact != NULL) {
cons_show_info(pcontact);
} else {
cons_show("No such contact \"%s\" in roster.", usr);
}
} else { } else {
cons_show("Usage: %s", help.usage); cons_show("Usage: %s", help.usage);
} }

View File

@ -35,6 +35,7 @@
#include <ncurses.h> #include <ncurses.h>
#endif #endif
#include "contact.h"
#include "jabber.h" #include "jabber.h"
#include "jid.h" #include "jid.h"
@ -136,8 +137,6 @@ void win_room_show_status(const char * const contact);
void win_room_show_info(const char * const contact); void win_room_show_info(const char * const contact);
void win_show_status(void); void win_show_status(void);
void win_private_show_status(void); void win_private_show_status(void);
void win_show_info(void);
void win_private_show_info(void);
// console window actions // console window actions
void cons_about(void); void cons_about(void);
@ -164,7 +163,7 @@ void cons_show_contacts(GSList * list);
void cons_check_version(gboolean not_available_msg); void cons_check_version(gboolean not_available_msg);
void cons_show_wins(void); void cons_show_wins(void);
void cons_show_status(const char * const contact); void cons_show_status(const char * const contact);
void cons_show_info(const char * const contact); void cons_show_info(PContact pcontact);
void cons_show_themes(GSList *themes); void cons_show_themes(GSList *themes);
// status bar actions // status bar actions

View File

@ -1159,53 +1159,14 @@ cons_show_wins(void)
} }
void void
win_room_show_info(const char * const contact) cons_show_info(PContact pcontact)
{ {
PContact pcontact = muc_get_participant(win_current_get_recipient(), contact); _win_show_info(console->win, pcontact);
if (pcontact != NULL) { if (current_index == 0) {
_win_show_info(current->win, pcontact); dirty = TRUE;
} else { } else {
win_current_show("No such participant \"%s\" in room.", contact); status_bar_new(0);
}
}
void
cons_show_info(const char * const contact)
{
PContact pcontact = contact_list_get_contact(contact);
if (pcontact != NULL) {
_win_show_info(console->win, pcontact);
} else {
cons_show("No such contact \"%s\" in roster.", contact);
}
}
void
win_show_info(void)
{
PContact pcontact = contact_list_get_contact(win_current_get_recipient());
if (pcontact != NULL) {
_win_show_info(current->win, pcontact);
} else {
win_current_show("No such contact \"%s\" in roster.", win_current_get_recipient());
}
}
void
win_private_show_info(void)
{
Jid *jid = jid_create(win_current_get_recipient());
PContact pcontact = muc_get_participant(jid->barejid, jid->resourcepart);
if (pcontact != NULL) {
_win_show_info(current->win, pcontact);
} else {
win_current_show("No such participant \"%s\" in room.", jid->resourcepart);
} }
} }