mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Show "request pending" in /sub show, when request has been sent
This commit is contained in:
parent
4b460100ad
commit
2f2fa8de66
@ -1009,13 +1009,7 @@ _cmd_sub(gchar **args, struct cmd_help_t help)
|
||||
log_info("Sent subscription request to %s.", bare_jid);
|
||||
} else if (strcmp(subcmd, "show") == 0) {
|
||||
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 ((contact == NULL) || (p_contact_subscription(contact) == NULL)) {
|
||||
if (win_current_is_chat()) {
|
||||
win_current_show("No subscription information for %s.", bare_jid);
|
||||
} else {
|
||||
@ -1023,11 +1017,21 @@ _cmd_sub(gchar **args, struct cmd_help_t help)
|
||||
}
|
||||
} else {
|
||||
if (win_current_is_chat()) {
|
||||
win_current_show("%s subscription status: %s.", bare_jid,
|
||||
p_contact_subscription(contact));
|
||||
if (p_contact_pending_out(contact)) {
|
||||
win_current_show("%s subscription status: %s, request pending.",
|
||||
bare_jid, p_contact_subscription(contact));
|
||||
} else {
|
||||
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));
|
||||
if (p_contact_pending_out(contact)) {
|
||||
cons_show("%s subscription status: %s, request pending.",
|
||||
bare_jid, p_contact_subscription(contact));
|
||||
} else {
|
||||
cons_show("%s subscription status: %s.", bare_jid,
|
||||
p_contact_subscription(contact));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -33,12 +33,13 @@ struct p_contact_t {
|
||||
char *presence;
|
||||
char *status;
|
||||
char *subscription;
|
||||
gboolean pending_out;
|
||||
};
|
||||
|
||||
PContact
|
||||
p_contact_new(const char * const jid, const char * const name,
|
||||
const char * const presence, const char * const status,
|
||||
const char * const subscription)
|
||||
const char * const subscription, gboolean pending_out)
|
||||
{
|
||||
PContact contact = malloc(sizeof(struct p_contact_t));
|
||||
contact->jid = strdup(jid);
|
||||
@ -64,6 +65,8 @@ p_contact_new(const char * const jid, const char * const name,
|
||||
else
|
||||
contact->subscription = strdup("none");;
|
||||
|
||||
contact->pending_out = pending_out;
|
||||
|
||||
return contact;
|
||||
}
|
||||
|
||||
@ -156,6 +159,12 @@ p_contact_subscription(const PContact contact)
|
||||
return contact->subscription;
|
||||
}
|
||||
|
||||
gboolean
|
||||
p_contact_pending_out(const PContact contact)
|
||||
{
|
||||
return contact->pending_out;
|
||||
}
|
||||
|
||||
void
|
||||
p_contact_set_presence(const PContact contact, const char * const presence)
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ typedef struct p_contact_t *PContact;
|
||||
|
||||
PContact p_contact_new(const char * const jid, const char * const name,
|
||||
const char * const presence, const char * const status,
|
||||
const char * const subscription);
|
||||
const char * const subscription, gboolean pending_out);
|
||||
PContact p_contact_copy(PContact contact);
|
||||
void p_contact_free(PContact contact);
|
||||
const char * p_contact_jid(PContact contact);
|
||||
@ -35,6 +35,7 @@ const char * p_contact_name(PContact contact);
|
||||
const char * p_contact_presence(PContact contact);
|
||||
const char * p_contact_status(PContact contact);
|
||||
const char * p_contact_subscription(const PContact contact);
|
||||
gboolean p_contact_pending_out(const PContact contact);
|
||||
void p_contact_set_presence(const PContact contact, const char * const presence);
|
||||
void p_contact_set_status(const PContact contact, const char * const status);
|
||||
int p_contacts_equal_deep(const PContact c1, const PContact c2);
|
||||
|
@ -56,13 +56,14 @@ contact_list_reset_search_attempts(void)
|
||||
gboolean
|
||||
contact_list_add(const char * const jid, const char * const name,
|
||||
const char * const presence, const char * const status,
|
||||
const char * const subscription)
|
||||
const char * const subscription, gboolean pending_out)
|
||||
{
|
||||
gboolean added = FALSE;
|
||||
PContact contact = g_hash_table_lookup(contacts, jid);
|
||||
|
||||
if (contact == NULL) {
|
||||
contact = p_contact_new(jid, name, presence, status, subscription);
|
||||
contact = p_contact_new(jid, name, presence, status, subscription,
|
||||
pending_out);
|
||||
g_hash_table_insert(contacts, strdup(jid), contact);
|
||||
p_autocomplete_add(ac, strdup(jid));
|
||||
added = TRUE;
|
||||
|
@ -32,7 +32,7 @@ void contact_list_clear(void);
|
||||
void contact_list_reset_search_attempts(void);
|
||||
gboolean contact_list_add(const char * const jid, const char * const name,
|
||||
const char * const presence, const char * const status,
|
||||
const char * const subscription);
|
||||
const char * const subscription, gboolean pending_out);
|
||||
gboolean contact_list_update_contact(const char * const jid, const char * const presence,
|
||||
const char * const status);
|
||||
GSList * get_contact_list(void);
|
||||
|
10
src/jabber.c
10
src/jabber.c
@ -760,7 +760,15 @@ _roster_handler(xmpp_conn_t * const conn,
|
||||
const char *jid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
|
||||
const char *name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
|
||||
const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
|
||||
gboolean added = contact_list_add(jid, name, "offline", NULL, sub);
|
||||
|
||||
gboolean pending_out = FALSE;
|
||||
const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
|
||||
if ((ask != NULL) && (strcmp(ask, "subscribe") == 0)) {
|
||||
pending_out = TRUE;
|
||||
}
|
||||
|
||||
gboolean added = contact_list_add(jid, name, "offline", NULL, sub,
|
||||
pending_out);
|
||||
|
||||
if (!added) {
|
||||
log_warning("Attempt to add contact twice: %s", jid);
|
||||
|
@ -252,7 +252,7 @@ room_add_to_roster(const char * const room, const char * const nick,
|
||||
updated = TRUE;
|
||||
}
|
||||
|
||||
PContact contact = p_contact_new(nick, NULL, show, status, NULL);
|
||||
PContact contact = p_contact_new(nick, NULL, show, status, NULL, FALSE);
|
||||
g_hash_table_replace(chat_room->roster, strdup(nick), contact);
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@
|
||||
#define STANZA_ATTR_SUBSCRIPTION "subscription"
|
||||
#define STANZA_ATTR_XMLNS "xmlns"
|
||||
#define STANZA_ATTR_NICK "nick"
|
||||
#define STANZA_ATTR_ASK "ask"
|
||||
|
||||
#define STANZA_TEXT_AWAY "away"
|
||||
#define STANZA_TEXT_DND "dnd"
|
||||
|
Loading…
Reference in New Issue
Block a user