Пример #1
0
gboolean
roster_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;
}
Пример #2
0
void
cons_show_sent_subs(void)
{
   if (roster_has_pending_subscriptions()) {
        GSList *contacts = roster_get_contacts();
        PContact contact = NULL;
        cons_show("Awaiting subscription responses from:");
        while (contacts != NULL) {
            contact = (PContact) contacts->data;
            if (p_contact_pending_out(contact)) {
                cons_show("  %s", p_contact_barejid(contact));
            }
            contacts = g_slist_next(contacts);
        }
    } else {
        cons_show("No pending requests sent.");
    }
}
Пример #3
0
void
_show_roster_contacts(GSList *list, gboolean show_groups)
{
    GSList *curr = list;
    while(curr) {

        PContact contact = curr->data;
        GString *title = g_string_new("  ");
        title = g_string_append(title, p_contact_barejid(contact));
        if (p_contact_name(contact) != NULL) {
            title = g_string_append(title, " (");
            title = g_string_append(title, p_contact_name(contact));
            title = g_string_append(title, ")");
        }

        const char *presence = p_contact_presence(contact);
        win_print_time(console, '-');
        if (p_contact_subscribed(contact)) {
            win_presence_colour_on(console, presence);
            wprintw(console->win, "%s\n", title->str);
            win_presence_colour_off(console, presence);
        } else {
            win_presence_colour_on(console, "offline");
            wprintw(console->win, "%s\n", title->str);
            win_presence_colour_off(console, "offline");
        }

        g_string_free(title, TRUE);

        win_print_time(console, '-');
        wprintw(console->win, "    Subscription : ");
        GString *sub = g_string_new("");
        sub = g_string_append(sub, p_contact_subscription(contact));
        if (p_contact_pending_out(contact)) {
            sub = g_string_append(sub, ", request sent");
        }
        if (presence_sub_request_exists(p_contact_barejid(contact))) {
            sub = g_string_append(sub, ", request received");
        }
        if (p_contact_subscribed(contact)) {
            wattron(console->win, COLOUR_SUBSCRIBED);
        } else {
            wattron(console->win, COLOUR_UNSUBSCRIBED);
        }
        wprintw(console->win, "%s\n", sub->str);
        if (p_contact_subscribed(contact)) {
            wattroff(console->win, COLOUR_SUBSCRIBED);
        } else {
            wattroff(console->win, COLOUR_UNSUBSCRIBED);
        }

        g_string_free(sub, TRUE);

        if (show_groups) {
            GSList *groups = p_contact_groups(contact);
            if (groups != NULL) {
                GString *groups_str = g_string_new("    Groups : ");
                while (groups != NULL) {
                    g_string_append(groups_str, groups->data);
                    if (g_slist_next(groups) != NULL) {
                        g_string_append(groups_str, ", ");
                    }
                    groups = g_slist_next(groups);
                }

                cons_show(groups_str->str);
                g_string_free(groups_str, TRUE);
            }
        }

        curr = g_slist_next(curr);
    }

}