aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-07-01 00:56:46 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2010-07-01 00:56:46 +0100
commit3353b5e52e6d78b1d1a294cea6ef1f6d383e38ba (patch)
tree344df7a973c2438f52646ad414a95650775f5f53
parent52a252173062bbce66040ef2b79c15dc2e2c03e6 (diff)
parent8203da9d2f792252d2144e5e9063391a3ceebfe9 (diff)
A few Twitter fixes from mainline.
-rw-r--r--protocols/twitter/twitter.c9
-rw-r--r--protocols/twitter/twitter_lib.c22
-rw-r--r--protocols/twitter/twitter_lib.h6
3 files changed, 24 insertions, 13 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c
index ca57e51e..2e3ab634 100644
--- a/protocols/twitter/twitter.c
+++ b/protocols/twitter/twitter.c
@@ -268,7 +268,14 @@ static int twitter_buddy_msg( struct im_connection *ic, char *who, char *message
if( set_getbool( &ic->acc->set, "oauth" ) &&
td->oauth_info && td->oauth_info->token == NULL )
{
- if( !oauth_access_token( message, td->oauth_info ) )
+ char pin[strlen(message)+1], *s;
+
+ strcpy( pin, message );
+ for( s = pin + sizeof( pin ) - 2; s > pin && isspace( *s ); s -- )
+ *s = '\0';
+ for( s = pin; *s && isspace( *s ); s ++ ) {}
+
+ if( !oauth_access_token( s, td->oauth_info ) )
{
imcb_error( ic, "OAuth error: %s", "Failed to send access token request" );
imc_logout( ic, TRUE );
diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c
index 6ceeae29..92c6415f 100644
--- a/protocols/twitter/twitter_lib.c
+++ b/protocols/twitter/twitter_lib.c
@@ -41,7 +41,7 @@
struct twitter_xml_list {
int type;
- int next_cursor;
+ gint64 next_cursor;
GSList *list;
gpointer data;
};
@@ -154,12 +154,12 @@ static void twitter_http_get_friends_ids(struct http_request *req);
/**
* Get the friends ids.
*/
-void twitter_get_friends_ids(struct im_connection *ic, int next_cursor)
+void twitter_get_friends_ids(struct im_connection *ic, gint64 next_cursor)
{
// Primitive, but hey! It works...
char* args[2];
args[0] = "cursor";
- args[1] = g_strdup_printf ("%d", next_cursor);
+ args[1] = g_strdup_printf ("%lld", (long long) next_cursor);
twitter_http(ic, TWITTER_FRIENDS_IDS_URL, twitter_http_get_friends_ids, ic, 0, args, 2);
g_free(args[1]);
@@ -170,8 +170,12 @@ void twitter_get_friends_ids(struct im_connection *ic, int next_cursor)
*/
static xt_status twitter_xt_next_cursor( struct xt_node *node, struct twitter_xml_list *txl )
{
- // Do something with the cursor.
- txl->next_cursor = node->text != NULL ? atoi(node->text) : -1;
+ char *end = NULL;
+
+ if( node->text )
+ txl->next_cursor = g_ascii_strtoll( node->text, &end, 10 );
+ if( end == NULL )
+ txl->next_cursor = -1;
return XT_HANDLED;
}
@@ -414,13 +418,13 @@ static void twitter_http_get_home_timeline(struct http_request *req);
/**
* Get the timeline.
*/
-void twitter_get_home_timeline(struct im_connection *ic, int next_cursor)
+void twitter_get_home_timeline(struct im_connection *ic, gint64 next_cursor)
{
struct twitter_data *td = ic->proto_data;
char* args[4];
args[0] = "cursor";
- args[1] = g_strdup_printf ("%d", next_cursor);
+ args[1] = g_strdup_printf ("%lld", (long long) next_cursor);
if (td->home_timeline_id) {
args[2] = "since_id";
args[3] = g_strdup_printf ("%llu", (long long unsigned int) td->home_timeline_id);
@@ -666,11 +670,11 @@ static void twitter_http_get_statuses_friends(struct http_request *req)
/**
* Get the friends.
*/
-void twitter_get_statuses_friends(struct im_connection *ic, int next_cursor)
+void twitter_get_statuses_friends(struct im_connection *ic, gint64 next_cursor)
{
char* args[2];
args[0] = "cursor";
- args[1] = g_strdup_printf ("%d", next_cursor);
+ args[1] = g_strdup_printf ("%lld", (long long) next_cursor);
twitter_http(ic, TWITTER_SHOW_FRIENDS_URL, twitter_http_get_statuses_friends, ic, 0, args, 2);
diff --git a/protocols/twitter/twitter_lib.h b/protocols/twitter/twitter_lib.h
index 65a596cc..6b90f9bb 100644
--- a/protocols/twitter/twitter_lib.h
+++ b/protocols/twitter/twitter_lib.h
@@ -75,9 +75,9 @@
#define TWITTER_BLOCKS_CREATE_URL "/blocks/create/"
#define TWITTER_BLOCKS_DESTROY_URL "/blocks/destroy/"
-void twitter_get_friends_ids(struct im_connection *ic, int next_cursor);
-void twitter_get_home_timeline(struct im_connection *ic, int next_cursor);
-void twitter_get_statuses_friends(struct im_connection *ic, int next_cursor);
+void twitter_get_friends_ids(struct im_connection *ic, gint64 next_cursor);
+void twitter_get_home_timeline(struct im_connection *ic, gint64 next_cursor);
+void twitter_get_statuses_friends(struct im_connection *ic, gint64 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);