From 0b3ffb13172c211eed561288d0fd04d76506bb02 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 19 May 2010 20:46:43 +0100 Subject: Setting the HTML flag on a connection has a nasty side effect of escaping a lot of "special" characters, and these HTML entities are not counted as one character. :-( So just strip HTML of incoming stuff and don't do anything with what goes out. It's not required. The story may actually be more complicated this, let's find out. --- protocols/twitter/twitter.c | 1 - 1 file changed, 1 deletion(-) (limited to 'protocols/twitter/twitter.c') diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index 98e85641..a9b38a2f 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -179,7 +179,6 @@ static void twitter_login( account_t *acc ) twitter_connections = g_slist_append( twitter_connections, ic ); ic->proto_data = td; - ic->flags |= OPT_DOES_HTML; td->user = acc->user; if( !set_getbool( &acc->set, "oauth" ) ) -- cgit v1.2.3 From c01bbd100fb460e34e10635ad43dc0f8f05b535d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 22 May 2010 16:00:36 +0100 Subject: Use HTTPS for the browser part of Twitter OAuth login. --- protocols/twitter/twitter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols/twitter/twitter.c') diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index a9b38a2f..f934f791 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -69,7 +69,7 @@ static const struct oauth_service twitter_oauth = { "http://api.twitter.com/oauth/request_token", "http://api.twitter.com/oauth/access_token", - "http://api.twitter.com/oauth/authorize", + "https://api.twitter.com/oauth/authorize", .consumer_key = "xsDNKJuNZYkZyMcu914uEA", .consumer_secret = "FCxqcr0pXKzsF9ajmP57S3VQ8V6Drk4o2QYtqMcOszo", }; -- cgit v1.2.3 From bb5ce4d1ad2aa6cbcf1042ccf87cf280d9645d4c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 23 May 2010 13:50:51 +0100 Subject: Added base_url settting to Twitter module so other services using the Twitter API can be used. Only with Basic authentication though. --- protocols/twitter/twitter.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'protocols/twitter/twitter.c') diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index f934f791..10b09da4 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -26,6 +26,7 @@ #include "twitter.h" #include "twitter_http.h" #include "twitter_lib.h" +#include "url.h" /** * Main loop function @@ -159,6 +160,9 @@ static void twitter_init( account_t *acc ) { set_t *s; + s = set_add( &acc->set, "base_url", TWITTER_API_URL, NULL, acc ); + s->flags |= ACC_SET_OFFLINE_ONLY; + s = set_add( &acc->set, "message_length", "140", set_eval_int, acc ); s = set_add( &acc->set, "mode", "one", set_eval_mode, acc ); @@ -174,24 +178,39 @@ static void twitter_init( account_t *acc ) static void twitter_login( account_t *acc ) { struct im_connection *ic = imcb_new( acc ); - struct twitter_data *td = g_new0( struct twitter_data, 1 ); + struct twitter_data *td; char name[strlen(acc->user)+9]; + url_t url; + if( !url_set( &url, set_getstr( &ic->acc->set, "base_url" ) ) || + ( url.proto != PROTO_HTTP && url.proto != PROTO_HTTPS ) ) + { + imcb_error( ic, "Incorrect API base URL: %s", set_getstr( &ic->acc->set, "base_url" ) ); + imc_logout( ic, FALSE ); + return; + } + twitter_connections = g_slist_append( twitter_connections, ic ); + td = g_new0( struct twitter_data, 1 ); ic->proto_data = td; + td->url_ssl = url.proto == PROTO_HTTPS; + td->url_port = url.port; + td->url_host = g_strdup( url.host ); + if( strcmp( url.file, "/" ) != 0 ) + td->url_path = g_strdup( url.file ); + else + td->url_path = g_strdup( "" ); + td->user = acc->user; - if( !set_getbool( &acc->set, "oauth" ) ) - td->pass = g_strdup( acc->pass ); - else if( strstr( acc->pass, "oauth_token=" ) ) + if( strstr( acc->pass, "oauth_token=" ) ) td->oauth_info = oauth_from_string( acc->pass, &twitter_oauth ); - td->home_timeline_id = 0; sprintf( name, "twitter_%s", acc->user ); imcb_add_buddy( ic, name, NULL ); imcb_buddy_status( ic, name, OPT_LOGGED_IN, NULL, NULL ); - if( td->pass || td->oauth_info ) + if( td->oauth_info || !set_getbool( &acc->set, "oauth" ) ) twitter_main_loop_start( ic ); else twitter_oauth_start( ic ); -- cgit v1.2.3 From 7d53efb7ec5310b2710757cef03d7f53c94a7797 Mon Sep 17 00:00:00 2001 From: Geert Mulders Date: Sat, 29 May 2010 14:40:17 +0200 Subject: Added functionality to add and remove friendships. --- protocols/twitter/twitter.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'protocols/twitter/twitter.c') diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index 98e85641..2f07adbb 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -267,10 +267,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 ) -- cgit v1.2.3