Changeset b4dd253


Ignore:
Timestamp:
2009-12-02T18:08:40Z (15 years ago)
Author:
Geert Mulders <g.c.w.m.mulders@…>
Branches:
master
Children:
62d2cfb
Parents:
1b221e0
Message:

home/timeline is now displayed in a groupchat instead of private window.

Location:
protocols/twitter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter.h

    r1b221e0 rb4dd253  
    3838        char* pass;
    3939        guint64 home_timeline_id;
     40        struct groupchat *home_timeline_gc;
    4041};
    4142
  • protocols/twitter/twitter_lib.c

    r1b221e0 rb4dd253  
    272272        struct twitter_xml_list *txl;
    273273        struct twitter_data *td = ic->proto_data;
     274        struct groupchat *gc;
    274275
    275276        // Check if the HTTP request went well.
     
    293294        struct twitter_xml_status *status;
    294295
    295         imcb_add_buddy( ic, "home_timeline", NULL );
    296         imcb_buddy_status( ic, "home_timeline", OPT_LOGGED_IN, NULL, NULL );
     296        // Create a new groupchat if it does not exsist.
     297        if (!td->home_timeline_gc)
     298        {
     299                td->home_timeline_gc = gc = imcb_chat_new( ic, "home/timeline" );
     300                // Add the current user to the chat...
     301                imcb_chat_add_buddy( gc, ic->acc->user );
     302        }
     303        else
     304        {
     305                gc = td->home_timeline_gc;
     306        }
    297307
    298308        for ( l = txl->list; l ; l = g_slist_next(l) )
    299309        {
    300310                status = l->data;
    301                 imcb_buddy_msg( ic, "home_timeline", status->text, 0, 0 );
     311                // TODO Put the next part in a new function....
     312
     313                // Ugly hack, to show current user in chat...
     314                if ( g_strcasecmp(status->user->screen_name, ic->acc->user) == 0)
     315                {
     316                        char *tmp = g_strdup_printf ("_%s_", status->user->screen_name);
     317                        g_free(status->user->screen_name);
     318                        status->user->screen_name = tmp;
     319                }
     320
     321                // Check if the buddy is allready in the buddy list.
     322                if (!user_findhandle( ic, status->user->screen_name ))
     323                {
     324                        // The buddy is not in the list, add the buddy...
     325                        imcb_add_buddy( ic, status->user->screen_name, NULL );
     326                        imcb_buddy_status( ic, status->user->screen_name, OPT_LOGGED_IN, NULL, NULL );
     327                }
     328
     329                // Say it!
     330                imcb_chat_msg (gc, status->user->screen_name, status->text, 0, 0 );
     331                // Update the home_timeline_id to hold the highest id, so that by the next request
     332                // we won't pick up the updates allready in the list.
    302333                td->home_timeline_id = td->home_timeline_id < status->id ? status->id : td->home_timeline_id;
    303334        }
Note: See TracChangeset for help on using the changeset viewer.