From 0756a9cec61649a7294ebffe19c7f756d7dc5892 Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 28 Nov 2012 01:36:04 +0000 Subject: Implemented "/sub sent" to show outstanding sent subscription requests --- src/command.c | 17 +++++++++++++++-- src/contact_list.c | 18 ++++++++++++++++++ src/contact_list.h | 1 + src/profanity.c | 2 +- 4 files changed, 35 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/command.c b/src/command.c index 39f6beae..590abed0 100644 --- a/src/command.c +++ b/src/command.c @@ -991,7 +991,20 @@ _cmd_sub(gchar **args, struct cmd_help_t help) } if (strcmp(subcmd, "sent") == 0) { - cons_show("No pending requests sent."); + if (contact_list_has_pending_subscriptions()) { + cons_show("Awaiting subscription responses from:"); + GSList *contacts = get_contact_list(); + while (contacts != NULL) { + PContact contact = (PContact) contacts->data; + if (p_contact_pending_out(contact)) { + cons_show(p_contact_jid(contact)); + } + contacts = g_slist_next(contacts); + } + } else { + cons_show("No pending requests sent."); + } + return TRUE; } @@ -1001,7 +1014,7 @@ _cmd_sub(gchar **args, struct cmd_help_t help) if (received == NULL) { cons_show("No outstanding subscription requests."); } else { - cons_show("%d outstanding subscription requests from:", + cons_show("Outstanding subscription requests from:", g_list_length(received)); while (received != NULL) { cons_show(received->data); diff --git a/src/contact_list.c b/src/contact_list.c index 5eb43324..8caa8784 100644 --- a/src/contact_list.c +++ b/src/contact_list.c @@ -118,6 +118,24 @@ contact_list_update_subscription(const char * const jid, } } +gboolean +contact_list_has_pending_subscriptions(void) +{ + GHashTableIter iter; + gpointer key; + gpointer value; + + g_hash_table_iter_init(&iter, contacts); + while (g_hash_table_iter_next(&iter, &key, &value)) { + PContact contact = (PContact) value; + if (p_contact_pending_out(contact)) { + return TRUE; + } + } + + return FALSE; +} + GSList * get_contact_list(void) { diff --git a/src/contact_list.h b/src/contact_list.h index 062cfa65..863c27b7 100644 --- a/src/contact_list.h +++ b/src/contact_list.h @@ -38,6 +38,7 @@ gboolean contact_list_update_contact(const char * const jid, const char * const const char * const status); void contact_list_update_subscription(const char * const jid, const char * const subscription, gboolean pending_out); +gboolean contact_list_has_pending_subscriptions(void); GSList * get_contact_list(void); char * contact_list_find_contact(char *search_str); PContact contact_list_get_contact(const char const *jid); diff --git a/src/profanity.c b/src/profanity.c index c7575498..e36fdd96 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -156,7 +156,7 @@ prof_handle_subscription(const char *from, jabber_subscr_t type) /* TODO: auto-subscribe if needed */ cons_show("Received authorization request from %s", from); log_info("Received authorization request from %s", from); - win_show_system_msg(from, "Authorization request, type '/sub add' to accept or '/sub del' to reject"); + win_show_system_msg(from, "Authorization request, type '/sub allow' to accept or '/sub deny' to reject"); win_current_page_off(); break; case PRESENCE_SUBSCRIBED: -- cgit 1.4.1-2-gfad0