diff --git a/src/command.c b/src/command.c index 7ca54b71..705be6de 100644 --- a/src/command.c +++ b/src/command.c @@ -982,6 +982,11 @@ _cmd_sub(gchar **args, struct cmd_help_t help) return TRUE; } + if (!win_current_is_chat() && (jid == NULL)) { + cons_show("You must specify a contact."); + return TRUE; + } + if (jid != NULL) { jid = strdup(jid); } else { @@ -1003,7 +1008,28 @@ _cmd_sub(gchar **args, struct cmd_help_t help) cons_show("Sent subscription request to %s.", bare_jid); log_info("Sent subscription request to %s.", bare_jid); } else if (strcmp(subcmd, "show") == 0) { - /* TODO: not implemented yet */ + PContact contact = contact_list_get_contact(bare_jid); + if (contact == NULL) { + if (win_current_is_chat()) { + win_current_show("No subscription information for %s.", bare_jid); + } else { + cons_show("No subscription information for %s.", bare_jid); + } + } else if (p_contact_subscription(contact) == NULL) { + if (win_current_is_chat()) { + win_current_show("No subscription information for %s.", bare_jid); + } else { + cons_show("No subscription information for %s.", bare_jid); + } + } else { + if (win_current_is_chat()) { + win_current_show("%s subscription status: %s.", bare_jid, + p_contact_subscription(contact)); + } else { + cons_show("%s subscription status: %s.", bare_jid, + p_contact_subscription(contact)); + } + } } else { cons_show("Usage: %s", help.usage); } diff --git a/src/ui.h b/src/ui.h index 02128714..981407b5 100644 --- a/src/ui.h +++ b/src/ui.h @@ -98,7 +98,7 @@ int win_current_is_chat(void); int win_current_is_groupchat(void); int win_current_is_private(void); char* win_current_get_recipient(void); -void win_current_show(const char * const msg); +void win_current_show(const char * const msg, ...); void win_current_bad_show(const char * const msg); void win_current_page_off(void); diff --git a/src/windows.c b/src/windows.c index f75c0bb9..6efc9e19 100644 --- a/src/windows.c +++ b/src/windows.c @@ -488,11 +488,16 @@ win_current_get_recipient(void) } void -win_current_show(const char * const msg) +win_current_show(const char * const msg, ...) { - WINDOW *win = current->win; - _win_show_time(win); - wprintw(win, "%s\n", msg); + va_list arg; + va_start(arg, msg); + GString *fmt_msg = g_string_new(NULL); + g_string_vprintf(fmt_msg, msg, arg); + _win_show_time(current->win); + wprintw(current->win, "%s\n", fmt_msg->str); + g_string_free(fmt_msg, TRUE); + va_end(arg); dirty = TRUE; }