Buddy Status

Giuseppe Santoro giuseppesantoro87 at gmail.com
Mon Mar 15 16:46:51 EDT 2010


Hi,

I tried with the example "nullclient".
I created the function:

static void
show_buddy_list_from_active_accounts()
{
    GList *accounts = purple_accounts_get_all_active();
    for (; accounts; accounts = g_list_delete_link(accounts, accounts)) {
        GSList *buddies = purple_find_buddies(accounts->data, NULL);
        for (; buddies; buddies = g_slist_delete_link(buddies,buddies)) {
            PurpleBuddy *b = buddies->data;
            PurplePresence *p = purple_buddy_get_presence(b);
            PurpleStatus *s = purple_presence_get_active_status(p);
            printf("status = %s  buddy = %s\n",
                    purple_status_get_name(s),
                    purple_buddy_get_name(b));
        }
    }
}

and I modified the function "signed_on":

static void
signed_on(PurpleConnection *gc, gpointer null)
{
    PurpleAccount *account = purple_connection_get_account(gc);
    printf("Account connected: %s %s\n", account->username,
account->protocol_id);
    purple_accounts_add(account);
    show_buddy_list_from_active_accounts();
}

Output is:
status = Offline  buddy = xxxxxxxxxx at hotmail.xxx
......
status = Offline  buddy = xxxxxxxxxx at hotmail.xxx

for all buddies.
I do not understand where is the problem.

Thanks,
Santoro Giuseppe


2010/3/15 Sadrul Habib Chowdhury <imadil at gmail.com>

> * Giuseppe Santoro had this to say on [15 Mar 2010, 15:08:20 +0100]:
> > Hi,
> >
> > yes, I'm sure the buddy is online. I tried this code:
> >
> > for(buddies = purple_blist_get_buddies(); buddies; buddies =
> buddies->next)
> > {
> >         buddy = buddies->data;
> >         PurplePresence *presence = purple_buddy_get_presence(buddy);
> >         PurpleStatus *status =
> purple_presence_get_active_status(presence);
> >
> >         printf("%s - ", purple_status_get_name(status));
> >         *printf("%s - ",
> >
> purple_primitive_get_id_from_type(purple_status_type_get_primitive(purple_status_get_type(status))));
> > *        printf("%s (%s)\n", purple_buddy_get_name(buddy),
> > purple_buddy_get_alias(buddy));
> > }
>
>
> When is this code executed? i.e. are you sure this code is executed
> *after* your account has connected? Try printing the status of
> buddy->account in the same loop.
>
> For connected accounts, the following code works for me:
>
>    GList *accounts = purple_accounts_get_all_active();
>    for (; accounts; accounts = g_list_delete_link(accounts, accounts)) {
>        GSList *buddies = purple_find_buddies(accounts->data, NULL);
>        for (; buddies; buddies = g_slist_delete_link(buddies,buddies)) {
>            PurpleBuddy *b = buddies->data;
>            PurplePresence *p = purple_buddy_get_presence(b);
>            PurpleStatus *s = purple_presence_get_active_status(p);
>            printf("status = %s  buddy = %s\n",
>                    purple_status_get_name(s),
>                    purple_buddy_get_name(b));
>        }
>    }
>
>
> Cheers,
> Sadrul
>
> > OUTPUT is:
> >
> > Offline - offline - xxxxxx at xxxx.com (xxxxxx at xxxx.com)
> > Offline - offline - xxxxxx at xxxx.com (xxxxxx at xxxx.com)
> > ......
> > Offline - offline - xxxxxx at xxxx.com (xxxxxx at xxxx.com)
> >
> > I can see who are online by the name.
> > I use MSN protocol.
> >
> > Other suggestions?
> >
> > Thanks,
> > Giuseppe Santoro
> >
> >
> > 2010/3/15 Mark Doliner <mark at kingant.net>
> >
> > > On Sun, Mar 14, 2010 at 11:43 AM, Giuseppe Santoro
> > > <giuseppesantoro87 at gmail.com> wrote:
> > > > Hi Pidgin Developers,
> > > >
> > > > I'm studying libpurple and pidgin to give my contribution in this
> > > project.
> > > >
> > > > I have a question:
> > > >
> > > > if I have a PurpleBuddy, how do I get his state?
> > > > I tried this code but state is ever "OFFLINE":
> > > >
> > > >             presence = purple_buddy_get_presence(buddy);
> > > >             status = purple_presence_get_active_status(presence);
> > > >             printf("%s\n", purple_status_get_name(status));
> > > >
> > > > where am I wrong?
> > >
> > > That looks correct to me.  Are you sure you're using the right buddy
> > > object?  Are you sure the buddy is online?  Are you sure you're
> > > printing the status while the buddy is online?
> > >
> > > The PurpleStatus name is actually the PurpleStatusType name.  And the
> > > PurpleStatusType name comes from the prpl.  It's possible the prpl
> > > mistakenly sets the name of the status type to "OFFLINE."  You could
> > > try printing
> > >
> purple_primitive_get_id_from_type(purple_status_type_get_primitive(purple_status_get_type(status)))
> > > to verify that the status type really is offline.
> > >
> > > --Mark
> > >
>
> > _______________________________________________
> > Devel mailing list
> > Devel at pidgin.im
> > http://pidgin.im/cgi-bin/mailman/listinfo/devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://pidgin.im/pipermail/devel/attachments/20100315/54508eb7/attachment.html>


More information about the Devel mailing list