Changeset 8c3637b for protocols/nogaim.c


Ignore:
Timestamp:
2015-05-24T19:43:09Z (9 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Children:
a852b2b
Parents:
93e0901
Message:

imcb_get_local_contacts() so an IM plugin can request the local contact list
before finishing login. Makes sense since processing the contact list can be
a major part of the login process.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    r93e0901 r8c3637b  
    312312        }
    313313
    314         if (ic->acc->flags & ACC_FLAG_LOCAL_CONTACTS) {
     314        if ((ic->acc->flags & ACC_FLAG_LOCAL_CONTACTS) &&
     315            !(ic->flags & OPT_LOCAL_CONTACTS_SENT)) {
    315316                GHashTableIter nicks;
    316                 gpointer k, v;
     317                gpointer handle;
    317318                g_hash_table_iter_init(&nicks, ic->acc->nicks);
    318                 while (g_hash_table_iter_next(&nicks, &k, &v)) {
    319                         ic->acc->prpl->add_buddy(ic, (char *) k, NULL);
     319                while (g_hash_table_iter_next(&nicks, &handle, NULL)) {
     320                        ic->acc->prpl->add_buddy(ic, (char *) handle, NULL);
    320321                }
    321322        }
     
    495496                bee->ui->user_nick_hint(bee, bu, nick);
    496497        }
     498}
     499
     500/* Returns the local contacts for an IM account (based on assigned nicks).
     501   Linked list should be freed, the strings themselves not! So look at it
     502   like a GSList<const char*> I guess? Empty list means NULL retval (as
     503   always with GSList). */
     504GSList *imcb_get_local_contacts(struct im_connection *ic)
     505{
     506        GHashTableIter nicks;
     507        GSList *ret = NULL;
     508       
     509        g_hash_table_iter_init(&nicks, ic->acc->nicks);
     510        gpointer handle;
     511        while (g_hash_table_iter_next(&nicks, &handle, NULL)) {
     512                ret = g_slist_prepend(ret, (char *) handle);
     513        }
     514       
     515        /* If the protocol asked for the list, assume we won't have to send it
     516           anymore in imcb_connected(). */
     517        ic->flags |= OPT_LOCAL_CONTACTS_SENT;
     518       
     519        return ret;
    497520}
    498521
Note: See TracChangeset for help on using the changeset viewer.