mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Subscription management
This commit is contained in:
parent
d13794bf60
commit
4e0a631fee
@ -59,6 +59,11 @@ p_contact_new(const char * const jid, const char * const name,
|
|||||||
else
|
else
|
||||||
contact->status = NULL;
|
contact->status = NULL;
|
||||||
|
|
||||||
|
if (subscription != NULL)
|
||||||
|
contact->subscription = strdup(subscription);
|
||||||
|
else
|
||||||
|
contact->subscription = NULL;
|
||||||
|
|
||||||
return contact;
|
return contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +86,11 @@ p_contact_copy(PContact contact)
|
|||||||
else
|
else
|
||||||
copy->status = NULL;
|
copy->status = NULL;
|
||||||
|
|
||||||
|
if (contact->subscription != NULL)
|
||||||
|
copy->subscription = strdup(contact->subscription);
|
||||||
|
else
|
||||||
|
copy->subscription = NULL;
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,6 +117,11 @@ p_contact_free(PContact contact)
|
|||||||
contact->status = NULL;
|
contact->status = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (contact->subscription != NULL) {
|
||||||
|
free(contact->subscription);
|
||||||
|
contact->subscription = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
free(contact);
|
free(contact);
|
||||||
contact = NULL;
|
contact = NULL;
|
||||||
}
|
}
|
||||||
@ -135,6 +150,12 @@ p_contact_status(const PContact contact)
|
|||||||
return contact->status;
|
return contact->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
p_contact_subscription(const PContact contact)
|
||||||
|
{
|
||||||
|
return contact->subscription;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
p_contacts_equal_deep(const PContact c1, const PContact c2)
|
p_contacts_equal_deep(const PContact c1, const PContact c2)
|
||||||
{
|
{
|
||||||
@ -142,6 +163,7 @@ p_contacts_equal_deep(const PContact c1, const PContact c2)
|
|||||||
int name_eq = (g_strcmp0(c1->name, c2->name) == 0);
|
int name_eq = (g_strcmp0(c1->name, c2->name) == 0);
|
||||||
int presence_eq = (g_strcmp0(c1->presence, c2->presence) == 0);
|
int presence_eq = (g_strcmp0(c1->presence, c2->presence) == 0);
|
||||||
int status_eq = (g_strcmp0(c1->status, c2->status) == 0);
|
int status_eq = (g_strcmp0(c1->status, c2->status) == 0);
|
||||||
|
int subscription_eq = (g_strcmp0(c1->subscription, c2->subscription) == 0);
|
||||||
|
|
||||||
return (jid_eq && name_eq && presence_eq && status_eq);
|
return (jid_eq && name_eq && presence_eq && status_eq && subscription_eq);
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ const char * p_contact_jid(PContact contact);
|
|||||||
const char * p_contact_name(PContact contact);
|
const char * p_contact_name(PContact contact);
|
||||||
const char * p_contact_presence(PContact contact);
|
const char * p_contact_presence(PContact contact);
|
||||||
const char * p_contact_status(PContact contact);
|
const char * p_contact_status(PContact contact);
|
||||||
|
const char * p_contact_subscription(const PContact contact);
|
||||||
int p_contacts_equal_deep(const PContact c1, const PContact c2);
|
int p_contacts_equal_deep(const PContact c1, const PContact c2);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -386,14 +386,8 @@ _roster_handler(xmpp_conn_t * const conn,
|
|||||||
const char *jid = xmpp_stanza_get_attribute(item, "jid");
|
const char *jid = xmpp_stanza_get_attribute(item, "jid");
|
||||||
const char *name = xmpp_stanza_get_attribute(item, "name");
|
const char *name = xmpp_stanza_get_attribute(item, "name");
|
||||||
const char *sub = xmpp_stanza_get_attribute(item, "subscription");
|
const char *sub = xmpp_stanza_get_attribute(item, "subscription");
|
||||||
|
|
||||||
if (sub != NULL) {
|
|
||||||
if (strcmp(sub, "none") != 0) {
|
|
||||||
|
|
||||||
contact_list_add(jid, name, "offline", NULL, sub);
|
contact_list_add(jid, name, "offline", NULL, sub);
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
item = xmpp_stanza_get_next(item);
|
item = xmpp_stanza_get_next(item);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -703,8 +703,13 @@ cons_show_contacts(GSList *list)
|
|||||||
|
|
||||||
while(curr) {
|
while(curr) {
|
||||||
PContact contact = curr->data;
|
PContact contact = curr->data;
|
||||||
|
const char *jid = p_contact_jid(contact);
|
||||||
|
const char *name = p_contact_name(contact);
|
||||||
const char *presence = p_contact_presence(contact);
|
const char *presence = p_contact_presence(contact);
|
||||||
|
const char *status = p_contact_status(contact);
|
||||||
|
const char *sub = p_contact_subscription(contact);
|
||||||
|
|
||||||
|
if (strcmp(sub, "none") != 0) {
|
||||||
_win_show_time(_cons_win);
|
_win_show_time(_cons_win);
|
||||||
|
|
||||||
if (strcmp(presence, "online") == 0) {
|
if (strcmp(presence, "online") == 0) {
|
||||||
@ -721,11 +726,17 @@ cons_show_contacts(GSList *list)
|
|||||||
wattron(_cons_win, COLOUR_OFFLINE);
|
wattron(_cons_win, COLOUR_OFFLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintw(_cons_win, "%s", p_contact_jid(contact));
|
wprintw(_cons_win, "%s", jid);
|
||||||
|
|
||||||
|
if (name != NULL) {
|
||||||
|
wprintw(_cons_win, " (%s)", name);
|
||||||
|
}
|
||||||
|
|
||||||
wprintw(_cons_win, " is %s", presence);
|
wprintw(_cons_win, " is %s", presence);
|
||||||
|
|
||||||
if (p_contact_status(contact))
|
if (status != NULL) {
|
||||||
wprintw(_cons_win, ", \"%s\"", p_contact_status(contact));
|
wprintw(_cons_win, ", \"%s\"", p_contact_status(contact));
|
||||||
|
}
|
||||||
|
|
||||||
wprintw(_cons_win, "\n");
|
wprintw(_cons_win, "\n");
|
||||||
|
|
||||||
@ -742,6 +753,7 @@ cons_show_contacts(GSList *list)
|
|||||||
} else {
|
} else {
|
||||||
wattroff(_cons_win, COLOUR_OFFLINE);
|
wattroff(_cons_win, COLOUR_OFFLINE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
curr = g_slist_next(curr);
|
curr = g_slist_next(curr);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user