Changeset 7d53efb


Ignore:
Timestamp:
2010-05-29T12:40:17Z (9 years ago)
Author:
Geert Mulders <g.c.w.m.mulders@…>
Branches:
master
Children:
ba3233c
Parents:
9997691
Message:

Added functionality to add and remove friendships.

Location:
protocols/twitter
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter.c

    r9997691 r7d53efb  
    268268static void twitter_add_buddy( struct im_connection *ic, char *who, char *group )
    269269{
     270        twitter_friendships_create_destroy(ic, who, 1);
    270271}
    271272
    272273static void twitter_remove_buddy( struct im_connection *ic, char *who, char *group )
    273274{
     275        twitter_friendships_create_destroy(ic, who, 0);
    274276}
    275277
  • protocols/twitter/twitter_lib.c

    r9997691 r7d53efb  
    626626
    627627/**
    628  * Callback after sending a new update to twitter.
    629  */
    630 static void twitter_http_post_status(struct http_request *req)
     628 * Callback to use after sending a post request to twitter.
     629 */
     630static void twitter_http_post(struct http_request *req)
    631631{
    632632        struct im_connection *ic = req->data;
     
    639639        if (req->status_code != 200) {
    640640                // It didn't go well, output the error and return.
    641                 imcb_error(ic, "Could not post message... HTTP STATUS: %d", req->status_code);
     641                imcb_error(ic, "HTTP Error... STATUS: %d", req->status_code);
    642642                return;
    643643        }
     
    654654        args[0] = "status";
    655655        args[1] = msg;
    656         twitter_http(TWITTER_STATUS_UPDATE_URL, twitter_http_post_status, ic, 1, td->user, td->pass, td->oauth_info, args, 2);
     656        twitter_http(TWITTER_STATUS_UPDATE_URL, twitter_http_post, ic, 1, td->user, td->pass, td->oauth_info, args, 2);
    657657//      g_free(args[1]);
    658658}
     
    672672        args[3] = msg;
    673673        // Use the same callback as for twitter_post_status, since it does basically the same.
    674         twitter_http(TWITTER_DIRECT_MESSAGES_NEW_URL, twitter_http_post_status, ic, 1, td->user, td->pass, td->oauth_info, args, 4);
     674        twitter_http(TWITTER_DIRECT_MESSAGES_NEW_URL, twitter_http_post, ic, 1, td->user, td->pass, td->oauth_info, args, 4);
    675675//      g_free(args[1]);
    676676//      g_free(args[3]);
    677677}
     678
     679void twitter_friendships_create_destroy(struct im_connection *ic, char *who, int create)
     680{
     681        struct twitter_data *td = ic->proto_data;
     682
     683        char* args[2];
     684        args[0] = "screen_name";
     685        args[1] = who;
     686        twitter_http(create ? TWITTER_FRIENDSHIPS_CREATE_URL : TWITTER_FRIENDSHIPS_DESTROY_URL, twitter_http_post, ic, 1, td->user, td->pass, td->oauth_info, args, 2);
     687}
     688
     689
     690
  • protocols/twitter/twitter_lib.h

    r9997691 r7d53efb  
    8282void twitter_post_status(struct im_connection *ic, char *msg);
    8383void twitter_direct_messages_new(struct im_connection *ic, char *who, char *message);
     84void twitter_friendships_create_destroy(struct im_connection *ic, char *who, int create);
    8485
    8586#endif //_TWITTER_LIB_H
Note: See TracChangeset for help on using the changeset viewer.