diff options
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/twitter/twitter.c | 2 | ||||
-rw-r--r-- | protocols/twitter/twitter_lib.c | 18 | ||||
-rw-r--r-- | protocols/twitter/twitter_lib.h | 1 |
3 files changed, 16 insertions, 5 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index 10b09da4..a5fc68ab 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -285,10 +285,12 @@ static void twitter_get_info(struct im_connection *ic, char *who) static void twitter_add_buddy( struct im_connection *ic, char *who, char *group ) { + twitter_friendships_create_destroy(ic, who, 1); } static void twitter_remove_buddy( struct im_connection *ic, char *who, char *group ) { + twitter_friendships_create_destroy(ic, who, 0); } static void twitter_chat_msg( struct groupchat *c, char *message, int flags ) diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c index e4dfc595..585bdd43 100644 --- a/protocols/twitter/twitter_lib.c +++ b/protocols/twitter/twitter_lib.c @@ -655,9 +655,9 @@ void twitter_get_statuses_friends(struct im_connection *ic, int next_cursor) } /** - * Callback after sending a new update to twitter. + * Callback to use after sending a post request to twitter. */ -static void twitter_http_post_status(struct http_request *req) +static void twitter_http_post(struct http_request *req) { struct im_connection *ic = req->data; @@ -668,7 +668,7 @@ static void twitter_http_post_status(struct http_request *req) // Check if the HTTP request went well. if (req->status_code != 200) { // It didn't go well, output the error and return. - imcb_error(ic, "Could not post message: %s", twitter_parse_error(req)); + imcb_error(ic, "HTTP error: %s", twitter_parse_error(req)); return; } } @@ -681,7 +681,7 @@ void twitter_post_status(struct im_connection *ic, char* msg) char* args[2]; args[0] = "status"; args[1] = msg; - twitter_http(ic, TWITTER_STATUS_UPDATE_URL, twitter_http_post_status, ic, 1, args, 2); + twitter_http(ic, TWITTER_STATUS_UPDATE_URL, twitter_http_post, ic, 1, args, 2); // g_free(args[1]); } @@ -697,7 +697,15 @@ void twitter_direct_messages_new(struct im_connection *ic, char *who, char *msg) args[2] = "text"; args[3] = msg; // Use the same callback as for twitter_post_status, since it does basically the same. - twitter_http(ic, TWITTER_DIRECT_MESSAGES_NEW_URL, twitter_http_post_status, ic, 1, args, 4); + twitter_http(ic, TWITTER_DIRECT_MESSAGES_NEW_URL, twitter_http_post, ic, 1, args, 4); // g_free(args[1]); // g_free(args[3]); } + +void twitter_friendships_create_destroy(struct im_connection *ic, char *who, int create) +{ + char* args[2]; + args[0] = "screen_name"; + args[1] = who; + twitter_http(ic, create ? TWITTER_FRIENDSHIPS_CREATE_URL : TWITTER_FRIENDSHIPS_DESTROY_URL, twitter_http_post, ic, 1, args, 2); +}
\ No newline at end of file diff --git a/protocols/twitter/twitter_lib.h b/protocols/twitter/twitter_lib.h index a4abac6f..65a596cc 100644 --- a/protocols/twitter/twitter_lib.h +++ b/protocols/twitter/twitter_lib.h @@ -81,6 +81,7 @@ void twitter_get_statuses_friends(struct im_connection *ic, int next_cursor); void twitter_post_status(struct im_connection *ic, char *msg); void twitter_direct_messages_new(struct im_connection *ic, char *who, char *message); +void twitter_friendships_create_destroy(struct im_connection *ic, char *who, int create); #endif //_TWITTER_LIB_H |