mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Implemented /sub show
This commit is contained in:
parent
4e78f8f149
commit
ebf8911ffc
@ -982,6 +982,11 @@ _cmd_sub(gchar **args, struct cmd_help_t help)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!win_current_is_chat() && (jid == NULL)) {
|
||||||
|
cons_show("You must specify a contact.");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (jid != NULL) {
|
if (jid != NULL) {
|
||||||
jid = strdup(jid);
|
jid = strdup(jid);
|
||||||
} else {
|
} else {
|
||||||
@ -1003,7 +1008,28 @@ _cmd_sub(gchar **args, struct cmd_help_t help)
|
|||||||
cons_show("Sent subscription request to %s.", bare_jid);
|
cons_show("Sent subscription request to %s.", bare_jid);
|
||||||
log_info("Sent subscription request to %s.", bare_jid);
|
log_info("Sent subscription request to %s.", bare_jid);
|
||||||
} else if (strcmp(subcmd, "show") == 0) {
|
} 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 {
|
} else {
|
||||||
cons_show("Usage: %s", help.usage);
|
cons_show("Usage: %s", help.usage);
|
||||||
}
|
}
|
||||||
|
2
src/ui.h
2
src/ui.h
@ -98,7 +98,7 @@ int win_current_is_chat(void);
|
|||||||
int win_current_is_groupchat(void);
|
int win_current_is_groupchat(void);
|
||||||
int win_current_is_private(void);
|
int win_current_is_private(void);
|
||||||
char* win_current_get_recipient(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_bad_show(const char * const msg);
|
||||||
void win_current_page_off(void);
|
void win_current_page_off(void);
|
||||||
|
|
||||||
|
@ -488,11 +488,16 @@ win_current_get_recipient(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
win_current_show(const char * const msg)
|
win_current_show(const char * const msg, ...)
|
||||||
{
|
{
|
||||||
WINDOW *win = current->win;
|
va_list arg;
|
||||||
_win_show_time(win);
|
va_start(arg, msg);
|
||||||
wprintw(win, "%s\n", 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;
|
dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user