Index: Makefile
===================================================================
--- Makefile	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ Makefile	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -11,5 +11,5 @@
 # Program variables
 objects = bitlbee.o dcc.o help.o ipc.o irc.o irc_im.o irc_channel.o irc_commands.o irc_send.o irc_user.o irc_util.o nick.o $(OTR_BI) query.o root_commands.o set.o storage.o $(STORAGE_OBJS)
-headers = bitlbee.h commands.h conf.h config.h help.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h lib/events.h lib/ftutil.h lib/http_client.h lib/ini.h lib/json.h lib/json_util.h lib/md5.h lib/misc.h lib/proxy.h lib/sha1.h lib/ssl_client.h lib/url.h protocols/account.h protocols/bee.h protocols/ft.h protocols/nogaim.h
+headers = bitlbee.h commands.h conf.h config.h help.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h lib/events.h lib/ftutil.h lib/http_client.h lib/ini.h lib/md5.h lib/misc.h lib/proxy.h lib/sha1.h lib/ssl_client.h lib/url.h protocols/account.h protocols/bee.h protocols/ft.h protocols/nogaim.h
 subdirs = lib protocols
 
Index: configure
===================================================================
--- configure	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ configure	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -211,5 +211,5 @@
 echo CFLAGS+=-I${srcdir} -I${srcdir}/lib -I${srcdir}/protocols -I. >> Makefile.settings
 
-echo CFLAGS+=-DHAVE_CONFIG_H -D_GNU_SOURCE >> Makefile.settings
+echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings
 
 if [ -n "$CC" ]; then
Index: lib/http_client.c
===================================================================
--- lib/http_client.c	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ lib/http_client.c	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -2,5 +2,5 @@
   * BitlBee -- An IRC to other IM-networks gateway                     *
   *                                                                    *
-  * Copyright 2002-2013 Wilmer van der Gaast and others                *
+  * Copyright 2002-2012 Wilmer van der Gaast and others                *
   \********************************************************************/
 
@@ -69,5 +69,4 @@
 	req->request_length = strlen( request );
 	req->redir_ttl = 3;
-	req->content_length = -1;
 	
 	if( getenv( "BITLBEE_DEBUG" ) )
@@ -97,4 +96,5 @@
 	request = g_strdup_printf( "GET %s HTTP/1.0\r\n"
 	                           "Host: %s\r\n"
+	                           "Connection: close\r\n"
 	                           "User-Agent: BitlBee " BITLBEE_VERSION " " ARCH "/" CPU "\r\n"
 	                           "\r\n", url->file, url->host );
@@ -193,14 +193,5 @@
 }
 
-typedef enum {
-	CR_OK,
-	CR_EOF,
-	CR_ERROR,
-	CR_ABORT,
-} http_ret_t;
-
 static gboolean http_handle_headers( struct http_request *req );
-static http_ret_t http_process_chunked_data( struct http_request *req, const char *buffer, int len );
-static http_ret_t http_process_data( struct http_request *req, const char *buffer, int len );
 
 static gboolean http_incoming_data( gpointer data, int source, b_input_condition cond )
@@ -208,4 +199,6 @@
 	struct http_request *req = data;
 	char buffer[4096];
+	char *s;
+	size_t content_length;
 	int st;
 	
@@ -251,22 +244,50 @@
 	}
 	
-	if( st > 0 )
-	{
-		http_ret_t c;
-		
-		if( req->flags & HTTPC_CHUNKED )
-			c = http_process_chunked_data( req, buffer, st );
-		else
-			c = http_process_data( req, buffer, st );
-		
-		if( c == CR_EOF )
-			goto eof;
-		else if( c == CR_ERROR || c == CR_ABORT )
-			return FALSE;
-	}
-	
-	if( req->content_length != -1 &&
-	    req->body_size >= req->content_length )
-		goto eof;
+	if( st > 0 && !req->sbuf )
+	{
+		req->reply_headers = g_realloc( req->reply_headers, req->bytes_read + st + 1 );
+		memcpy( req->reply_headers + req->bytes_read, buffer, st );
+		req->bytes_read += st;
+		
+		st = 0;
+	}
+	
+	if( st >= 0 && ( req->flags & HTTPC_STREAMING ) )
+	{
+		if( !req->reply_body &&
+		    ( strstr( req->reply_headers, "\r\n\r\n" ) ||
+		      strstr( req->reply_headers, "\n\n" ) ) )
+		{
+			size_t hlen;
+			
+			/* We've now received all headers, so process them once
+			   before we start feeding back data. */
+			if( !http_handle_headers( req ) )
+				return FALSE;
+			
+			hlen = req->reply_body - req->reply_headers;
+			
+			req->sblen = req->bytes_read - hlen;
+			req->sbuf = g_memdup( req->reply_body, req->sblen + 1 );
+			req->reply_headers = g_realloc( req->reply_headers, hlen + 1 );
+			
+			req->reply_body = req->sbuf;
+		}
+		
+		if( st > 0 )
+		{
+			int pos = req->reply_body - req->sbuf;
+			req->sbuf = g_realloc( req->sbuf, req->sblen + st + 1 );
+			memcpy( req->sbuf + req->sblen, buffer, st );
+			req->bytes_read += st;
+			req->sblen += st;
+			req->sbuf[req->sblen] = '\0';
+			req->reply_body = req->sbuf + pos;
+			req->body_size = req->sblen - pos;
+		}
+		
+		if( req->reply_body )
+			req->func( req );
+	}
 	
 	if( ssl_pending( req->ssl ) )
@@ -290,4 +311,12 @@
 		goto cleanup;
 	}
+	
+	if( !( req->flags & HTTPC_STREAMING ) )
+	{
+		/* Returns FALSE if we were redirected, in which case we should abort
+		   and not run any callback yet. */
+		if( !http_handle_headers( req ) )
+			return FALSE;
+	}
 
 cleanup:
@@ -297,10 +326,15 @@
 		closesocket( req->fd );
 	
-	if( req->body_size < req->content_length )
-	{
-		req->status_code = -1;
-		g_free( req->status_string );
-		req->status_string = g_strdup( "Response truncated" );
-	}
+	if( ( s = get_rfc822_header( req->reply_headers, "Content-Length", 0 ) ) &&
+	    sscanf( s, "%zd", &content_length ) == 1 )
+	{
+		if( content_length < req->body_size )
+		{
+			req->status_code = -1;
+			g_free( req->status_string );
+			req->status_string = g_strdup( "Response truncated" );
+		}
+	}
+	g_free( s );
 	
 	if( getenv( "BITLBEE_DEBUG" ) && req )
@@ -313,118 +347,9 @@
 }
 
-static http_ret_t http_process_chunked_data( struct http_request *req, const char *buffer, int len )
-{
-	char *chunk, *eos, *s;
-	
-	if( len < 0 )
-		return TRUE;
-	
-	if( len > 0 )
-	{
-		req->cbuf = g_realloc( req->cbuf, req->cblen + len + 1 );
-		memcpy( req->cbuf + req->cblen, buffer, len );
-		req->cblen += len;
-		req->cbuf[req->cblen] = '\0';
-	}
-	
-	/* Turns out writing a proper chunked-encoding state machine is not
-	   that simple. :-( I've tested this one feeding it byte by byte so
-	   I hope it's solid now. */
-	chunk = req->cbuf;
-	eos = req->cbuf + req->cblen;
-	while( TRUE )
-	{
-		int clen = 0;
-		
-		/* Might be a \r\n from the last chunk. */
-		s = chunk;
-		while( isspace( *s ) )
-			s ++;
-		/* Chunk length. Might be incomplete. */
-		if( s < eos && sscanf( s, "%x", &clen ) != 1 )
-			return CR_ERROR;
-		while( isxdigit( *s ) )
-			s ++;
-		
-		/* If we read anything here, it *must* be \r\n. */
-		if( strncmp( s, "\r\n", MIN( 2, eos - s ) ) != 0 )
-			return CR_ERROR;
-		s += 2;
-		
-		if( s >= eos )
-			break;
-		
-		/* 0-length chunk means end of response. */	
-		if( clen == 0 )
-			return CR_EOF;
-		
-		/* Wait for the whole chunk to arrive. */
-		if( s + clen > eos )
-			break;
-		if( http_process_data( req, s, clen ) != CR_OK )
-			return CR_ABORT;
-		
-		chunk = s + clen;
-	}
-	
-	if( chunk != req->cbuf )
-	{
-		req->cblen = eos - chunk;
-		s = g_memdup( chunk, req->cblen + 1 );
-		g_free( req->cbuf );
-		req->cbuf = s;
-	}
-	
-	return CR_OK;
-}
-
-static http_ret_t http_process_data( struct http_request *req, const char *buffer, int len )
-{
-	if( len <= 0 )
-		return CR_OK;
-	
-	if( !req->reply_body )
-	{
-		req->reply_headers = g_realloc( req->reply_headers, req->bytes_read + len + 1 );
-		memcpy( req->reply_headers + req->bytes_read, buffer, len );
-		req->bytes_read += len;
-		req->reply_headers[req->bytes_read] = '\0';
-		
-		if( strstr( req->reply_headers, "\r\n\r\n" ) ||
-		    strstr( req->reply_headers, "\n\n" ) )
-		{
-			/* We've now received all headers. Look for something
-			   interesting. */
-			if( !http_handle_headers( req ) )
-				return CR_ABORT;
-			
-			/* Start parsing the body as chunked if required. */
-			if( req->flags & HTTPC_CHUNKED )
-				return http_process_chunked_data( req, NULL, 0 );
-		}
-	}
-	else
-	{
-		int pos = req->reply_body - req->sbuf;
-		req->sbuf = g_realloc( req->sbuf, req->sblen + len + 1 );
-		memcpy( req->sbuf + req->sblen, buffer, len );
-		req->bytes_read += len;
-		req->sblen += len;
-		req->sbuf[req->sblen] = '\0';
-		req->reply_body = req->sbuf + pos;
-		req->body_size = req->sblen - pos;
-	}
-	
-	if( ( req->flags & HTTPC_STREAMING ) && req->reply_body )
-		req->func( req );
-	
-	return CR_OK;
-}
-
 /* Splits headers and body. Checks result code, in case of 300s it'll handle
    redirects. If this returns FALSE, don't call any callbacks! */
 static gboolean http_handle_headers( struct http_request *req )
 {
-	char *end1, *end2, *s;
+	char *end1, *end2;
 	int evil_server = 0;
 	
@@ -452,5 +377,5 @@
 	}
 	
-	*end1 = '\0';
+	*end1 = 0;
 	
 	if( getenv( "BITLBEE_DEBUG" ) )
@@ -462,8 +387,5 @@
 		req->reply_body = end1 + 2;
 	
-	/* Separately allocated space for headers and body. */
-	req->sblen = req->body_size = req->reply_headers + req->bytes_read - req->reply_body;
-	req->sbuf = req->reply_body = g_memdup( req->reply_body, req->body_size + 1 );
-	req->reply_headers = g_realloc( req->reply_headers, end1 - req->reply_headers + 1 );
+	req->body_size = req->reply_headers + req->bytes_read - req->reply_body;
 	
 	if( ( end1 = strchr( req->reply_headers, ' ' ) ) != NULL )
@@ -530,5 +452,5 @@
 			   don't need this yet anyway, I won't implement it. */
 			
-			req->status_string = g_strdup( "Can't handle relative redirects" );
+			req->status_string = g_strdup( "Can't handle recursive redirects" );
 			
 			return TRUE;
@@ -538,5 +460,5 @@
 			/* A whole URL */
 			url_t *url;
-			char *s, *version, *headers;
+			char *s;
 			const char *new_method;
 			
@@ -566,5 +488,4 @@
 				return TRUE;
 			}
-			headers = s;
 			
 			/* More or less HTTP/1.0 compliant, from my reading of RFC 2616.
@@ -586,17 +507,7 @@
 				new_method = "POST";
 			
-			if( ( version = strstr( req->request, " HTTP/" ) ) &&
-			    ( s = strstr( version, "\r\n" ) ) )
-			{
-				version ++;
-				version = g_strndup( version, s - version );
-			}
-			else
-				version = g_strdup( "HTTP/1.0" );
-			
 			/* Okay, this isn't fun! We have to rebuild the request... :-( */
-			new_request = g_strdup_printf( "%s %s %s\r\nHost: %s%s",
-			                               new_method, url->file, version,
-			                               url->host, headers );
+			new_request = g_strdup_printf( "%s %s HTTP/1.0\r\nHost: %s%s",
+			                               new_method, url->file, url->host, s );
 			
 			new_host = g_strdup( url->host );
@@ -610,5 +521,4 @@
 			
 			g_free( url );
-			g_free( version );
 		}
 		
@@ -647,32 +557,10 @@
 		g_free( req->request );
 		g_free( req->reply_headers );
-		g_free( req->sbuf );
 		req->request = new_request;
 		req->request_length = strlen( new_request );
 		req->bytes_read = req->bytes_written = req->inpa = 0;
 		req->reply_headers = req->reply_body = NULL;
-		req->sbuf = req->cbuf = NULL;
-		req->sblen = req->cblen = 0;
 		
 		return FALSE;
-	}
-
-	if( ( s = get_rfc822_header( req->reply_headers, "Content-Length", 0 ) ) &&
-	    sscanf( s, "%d", &req->content_length ) != 1 )
-		req->content_length = -1;
-	g_free( s );
-	
-	if( ( s = get_rfc822_header( req->reply_headers, "Transfer-Encoding", 0 ) ) )
-	{
-		if( strcasestr( s, "chunked" ) )
-		{
-			req->flags |= HTTPC_CHUNKED;
-			req->cbuf = req->sbuf;
-			req->cblen = req->sblen;
-			
-			req->reply_body = req->sbuf = g_strdup( "" );
-			req->body_size = req->sblen = 0;
-		}
-		g_free( s );
 	}
 	
@@ -719,5 +607,4 @@
 	g_free( req->status_string );
 	g_free( req->sbuf );
-	g_free( req->cbuf );
 	g_free( req );
 }
Index: lib/http_client.h
===================================================================
--- lib/http_client.h	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ lib/http_client.h	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -42,5 +42,4 @@
 	HTTPC_STREAMING = 1,
 	HTTPC_EOF = 2,
-	HTTPC_CHUNKED = 4,
 	
 	/* Let's reserve 0x1000000+ for lib users. */
@@ -78,13 +77,8 @@
 	int bytes_written;
 	int bytes_read;
-	int content_length;     /* "Content-Length:" header or -1 */
 	
 	/* Used in streaming mode. Caller should read from reply_body. */
 	char *sbuf;
 	size_t sblen;
-	
-	/* Chunked encoding only. Raw chunked stream is decoded from here. */
-	char *cbuf;
-	size_t cblen;
 };
 
Index: lib/oauth.c
===================================================================
--- lib/oauth.c	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ lib/oauth.c	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -262,4 +262,5 @@
 	                     "Content-Type: application/x-www-form-urlencoded\r\n"
 	                     "Content-Length: %zd\r\n"
+	                     "Connection: close\r\n"
 	                     "\r\n"
 	                     "%s", url_p.file, url_p.host, strlen( post ), post );
Index: lib/oauth2.c
===================================================================
--- lib/oauth2.c	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ lib/oauth2.c	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -2,7 +2,7 @@
 *                                                                           *
 *  BitlBee - An IRC to IM gateway                                           *
-*  Simple OAuth2 client (consumer) implementation.                          *
+*  Simple OAuth client (consumer) implementation.                           *
 *                                                                           *
-*  Copyright 2010-2013 Wilmer van der Gaast <wilmer@gaast.net>              *
+*  Copyright 2010-2012 Wilmer van der Gaast <wilmer@gaast.net>              *
 *                                                                           *
 *  This program is free software; you can redistribute it and/or modify     *
@@ -22,20 +22,4 @@
 \***************************************************************************/
 
-/* Out of protest, I should rename this file. OAuth2 is a pathetic joke, and
-   of all things, DEFINITELY NOT A STANDARD. The only thing various OAuth2
-   implementations have in common is that name, wrongfully stolen from
-   a pretty nice standard called OAuth 1.0a. That, and the fact that they
-   use JSON. Wait, no, Facebook's version doesn't use JSON. For some of its
-   responses.
-   
-   Apparently too many people were too retarded to comprehend the elementary
-   bits of crypto in OAuth 1.0a (took me one afternoon to implement) so
-   the standard was replaced with what comes down to a complicated scheme
-   around what's really just application-specific passwords.
-   
-   And then a bunch of mostly incompatible implementations. Great work, guys.
-   
-   http://hueniverse.com/2012/07/oauth-2-0-and-the-road-to-hell/ */
-
 #include <glib.h>
 #include "http_client.h"
@@ -43,5 +27,4 @@
 #include "oauth.h"
 #include "json.h"
-#include "json_util.h"
 #include "url.h"
 
@@ -96,4 +79,5 @@
 	                     "Content-Type: application/x-www-form-urlencoded\r\n"
 	                     "Content-Length: %zd\r\n"
+	                     "Connection: close\r\n"
 	                     "\r\n"
 	                     "%s", url_p.file, url_p.host, strlen( args_s ), args_s );
@@ -115,33 +99,8 @@
 }
 
-static char* oauth2_parse_error( json_value *e )
-{
-	/* This does a reasonable job with some of the flavours of error
-	   responses I've seen. Because apparently it's not standardised. */
-	
-	if( e->type == json_object )
-	{
-		/* Facebook style */
-		const char *msg = json_o_str( e, "message" );
-		const char *type = json_o_str( e, "type" );
-		json_value *code_o = json_o_get( e, "code" );
-		int code = 0;
-		
-		if( code_o && code_o->type == json_integer )
-			code = code_o->u.integer;
-		
-		return g_strdup_printf( "Error %d: %s", code, msg ? msg : type ? type : "Unknown error" );
-	}
-	else if( e->type == json_string )
-	{
-		return g_strdup( e->u.string.ptr );
-	}
-	return NULL;
-}
-
 static void oauth2_access_token_done( struct http_request *req )
 {
 	struct oauth2_access_token_data *cb_data = req->data;
-	char *atoken = NULL, *rtoken = NULL, *error = NULL;
+	char *atoken = NULL, *rtoken = NULL;
 	char *content_type;
 	
@@ -151,20 +110,22 @@
 	content_type = get_rfc822_header( req->reply_headers, "Content-Type", 0 );
 	
-	if( content_type && ( strstr( content_type, "application/json" ) ||
-	                      strstr( content_type, "text/javascript" ) ) )
+	if( req->status_code != 200 )
+	{
+	}
+	else if( content_type && strstr( content_type, "application/json" ) )
 	{
 		json_value *js = json_parse( req->reply_body );
 		if( js && js->type == json_object )
 		{
-			JSON_O_FOREACH( js, k, v )
+			int i;
+			
+			for( i = 0; i < js->u.object.length; i ++ )
 			{
-				if( strcmp( k, "error" ) == 0 )
-					error = oauth2_parse_error( v );
-				if( v->type != json_string )
+				if( js->u.object.values[i].value->type != json_string )
 					continue;
-				if( strcmp( k, "access_token" ) == 0 )
-					atoken = g_strdup( v->u.string.ptr );
-				if( strcmp( k, "refresh_token" ) == 0 )
-					rtoken = g_strdup( v->u.string.ptr );
+				if( strcmp( js->u.object.values[i].name, "access_token" ) == 0 )
+					atoken = g_strdup( js->u.object.values[i].value->u.string.ptr );
+				if( strcmp( js->u.object.values[i].name, "refresh_token" ) == 0 )
+					rtoken = g_strdup( js->u.object.values[i].value->u.string.ptr );
 			}
 		}
@@ -183,12 +144,9 @@
 	if( getenv( "BITLBEE_DEBUG" ) )
 		printf( "Extracted atoken=%s rtoken=%s\n", atoken, rtoken );
-	if( !atoken && !rtoken && !error )
-		error = g_strdup( "Unusuable response" );
 	
-	cb_data->func( cb_data->data, atoken, rtoken, error );
+	cb_data->func( cb_data->data, atoken, rtoken );
 	g_free( content_type );
 	g_free( atoken );
 	g_free( rtoken );
-	g_free( error );
 	g_free( cb_data );
 }
Index: lib/oauth2.h
===================================================================
--- lib/oauth2.h	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ lib/oauth2.h	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -4,5 +4,5 @@
 *  Simple OAuth2 client (consumer) implementation.                          *
 *                                                                           *
-*  Copyright 2010-2013 Wilmer van der Gaast <wilmer@gaast.net>              *
+*  Copyright 2010-2011 Wilmer van der Gaast <wilmer@gaast.net>              *
 *                                                                           *
 *  This program is free software; you can redistribute it and/or modify     *
@@ -25,6 +25,5 @@
    module, and from http://code.google.com/apis/accounts/docs/OAuth2.html . */
 
-typedef void (*oauth2_token_callback)( gpointer data, const char *atoken,
-                                       const char *rtoken, const char *error );
+typedef void (*oauth2_token_callback)( gpointer data, const char *atoken, const char *rtoken );
 
 struct oauth2_service
Index: lib/proxy.c
===================================================================
--- lib/proxy.c	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ lib/proxy.c	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -158,5 +158,5 @@
 		}
 
-		event_debug("proxy_connect_none( \"%s\", %d ) = %d\n", host, port_, fd);
+		event_debug("proxy_connect_none( \"%s\", %d ) = %d\n", host, port, fd);
 	
 		if (connect(fd, phb->gai_cur->ai_addr, phb->gai_cur->ai_addrlen) < 0 && !sockerr_again()) {
Index: lib/ssl_nss.c
===================================================================
--- lib/ssl_nss.c	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ lib/ssl_nss.c	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -152,5 +152,5 @@
 	conn->func = func;
 	conn->data = data;
-	conn->hostname = g_strdup(hostname);
+	conn->hostname = hostname;
 
 	/* For now, SSL verification is globally enabled by setting the cafile
@@ -296,5 +296,5 @@
 		PR_Close(conn->prfd);
 
-	g_free(conn->hostname);
+        g_free(conn->hostname);
 	g_free(conn);
 }
Index: nick.c
===================================================================
--- nick.c	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ nick.c	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -392,6 +392,5 @@
 	
 	for( i = 0; nick[i]; i ++ )
-		if( nick[i] < 0x7f )
-			nick[i] = tab[(int)nick[i]];
+		nick[i] = tab[(int)nick[i]];
 	
 	return nick_ok( irc, nick );
Index: protocols/jabber/sasl.c
===================================================================
--- protocols/jabber/sasl.c	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ protocols/jabber/sasl.c	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -483,5 +483,5 @@
 }
 
-static void sasl_oauth2_got_token( gpointer data, const char *access_token, const char *refresh_token, const char *error );
+static void sasl_oauth2_got_token( gpointer data, const char *access_token, const char *refresh_token );
 
 int sasl_oauth2_get_refresh_token( struct im_connection *ic, const char *msg )
@@ -514,5 +514,5 @@
 }
 
-static void sasl_oauth2_got_token( gpointer data, const char *access_token, const char *refresh_token, const char *error )
+static void sasl_oauth2_got_token( gpointer data, const char *access_token, const char *refresh_token )
 {
 	struct im_connection *ic = data;
@@ -527,5 +527,5 @@
 	if( access_token == NULL )
 	{
-		imcb_error( ic, "OAuth failure (%s)", error );
+		imcb_error( ic, "OAuth failure (missing access token)" );
 		imc_logout( ic, TRUE );
 		return;
Index: protocols/oscar/oscar.c
===================================================================
--- protocols/oscar/oscar.c	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ protocols/oscar/oscar.c	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -981,5 +981,5 @@
 		
 		if (args->icbmflags & AIM_IMFLAGS_UNICODE)
-			src = "UCS-2BE";
+			src = "UNICODEBIG";
 		else
 			src = "ISO8859-1";
@@ -1769,5 +1769,5 @@
 				args.flags |= AIM_IMFLAGS_ISO_8859_1;
 				len = ret;
-			} else if ((ret = do_iconv("UTF-8", "UCS-2BE", message, s, len, BUF_LONG)) >= 0) {
+			} else if ((ret = do_iconv("UTF-8", "UNICODEBIG", message, s, len, BUF_LONG)) >= 0) {
 				args.flags |= AIM_IMFLAGS_UNICODE;
 				len = ret;
@@ -2406,5 +2406,5 @@
 			flags |= AIM_CHATFLAGS_ISO_8859_1;
 			len = ret;
-		} else if ((ret = do_iconv("UTF-8", "UCS-2BE", message, s, len, BUF_LONG)) >= 0) {
+		} else if ((ret = do_iconv("UTF-8", "UNICODEBIG", message, s, len, BUF_LONG)) >= 0) {
 			flags |= AIM_CHATFLAGS_UNICODE;
 			len = ret;
Index: protocols/skype/README
===================================================================
--- protocols/skype/README	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ protocols/skype/README	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -58,8 +58,13 @@
 connects to Skype, finally BitlBee can connect to `skyped`.
 
-=== Installing
-
-Either use your package manager to install the Skype plugin, using something
-like:
+=== Installing under Frugalware or Debian
+
+- Install the necessary packages:
+
+----
+# pacman-g2 -S bitlbee-skype
+----
+
+or
 
 ----
@@ -67,6 +72,74 @@
 ----
 
-Or install http://sourceforge.net/projects/skype4py/[Skype4Py], and build
-BitlBee with `--skype=1`.
+(the later from the unstable repo)
+
+and you don't have to compile anything manually.
+
+=== Installing under OS X
+
+- Install the necessary packages from ports:
+
+NOTE: You have to edit the Portfile manually to include the install-dev target,
+just append install-dev after install-etc.
+
+----
+# port -v install bitlbee
+----
+
+and you have to install `bitlbee-skype` and `skype4py` from
+source.
+
+=== Installing from source
+
+NOTE: bitlbee-skype by default builds and installs skyped and the
+plugin. In case you just want to install the plugin for a public server
+or you want to use skyped with a public server (like
+`bitlbee1.asnetinc.net`), you don't need both.
+
+- You need the latest stable BitlBee release (unless you want to use a
+  public server):
+
+----
+$ wget http://get.bitlbee.org/src/bitlbee-@BITLBEE_VERSION@.tar.gz
+$ tar xf bitlbee-@BITLBEE_VERSION@.tar.gz
+$ cd bitlbee-@BITLBEE_VERSION@
+----
+
+- Now compile and install it:
+
+----
+$ ./configure
+$ make
+# make install install-dev
+----
+
+- To install http://skype4py.sourceforge.net/[Skype4Py] from source
+  (unless you want to install the plugin for a public server):
+
+----
+$ tar -zxvf Skype4Py-x.x.x.x.tar.gz
+$ cd Skype4Py-x.x.x.x
+# python setup.py install
+----
+
+- Get the plugin code (in an empty dir, or whereever you want, it does
+  not matter):
+
+----
+$ wget http://vmiklos.hu/project/bitlbee-skype/bitlbee-skype-@VERSION@.tar.gz
+$ tar xf bitlbee-skype-@VERSION@.tar.gz
+$ cd bitlbee-skype-@VERSION@
+----
+
+- Compile and install it:
+
+----
+$ ./configure
+$ make
+# make install
+----
+
+This will install the plugin to where BitlBee expects them, which is
+`/usr/local/lib/bitlbee` if you installed BitlBee from source.
 
 === Configuring
Index: protocols/skype/skype.c
===================================================================
--- protocols/skype/skype.c	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ protocols/skype/skype.c	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -344,9 +344,9 @@
 	ptr++;
 	if (!strncmp(ptr, "ONLINESTATUS ", 13)) {
-		if (!strlen(user) || !strcmp(user, sd->username))
-			return;
-		if (!set_getbool(&ic->acc->set, "test_join")
+			if (!strcmp(user, sd->username))
+				return;
+			if (!set_getbool(&ic->acc->set, "test_join")
 				&& !strcmp(user, "echo123"))
-			return;
+				return;
 		ptr = g_strdup_printf("%s@skype.com", user);
 		imcb_add_buddy(ic, ptr, skype_group_by_username(ic, user));
@@ -1016,8 +1016,5 @@
 		}
 	} else if (!strncmp(info, "MEMBERS ", 8) || !strncmp(info, "ACTIVEMEMBERS ", 14) ) {
-		if (!strncmp(info, "MEMBERS ", 8))
-			info += 8;
-		else
-			info += 14;
+		info += 8;
 		gc = bee_chat_by_title(ic->bee, ic, id);
 		/* Hack! We set ->data to TRUE
@@ -1567,5 +1564,5 @@
 
 	s = set_add(&acc->set, "mood_text", NULL, skype_set_mood_text, acc);
-	s->flags |= SET_NOSAVE | ACC_SET_ONLINE_ONLY;
+	s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY;
 
 	s = set_add(&acc->set, "call", NULL, skype_set_call, acc);
Index: protocols/skype/skyped.py
===================================================================
--- protocols/skype/skyped.py	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ protocols/skype/skyped.py	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -273,5 +273,5 @@
 		if options.log:
 			sock = open(options.log, "a")
-			sock.write("%s: %s\n" % (prefix, sanitized))
+			sock.write(prefix + ": " + sanitized)
 			sock.close()
 
Index: otocols/skype/t/away-set-bitlbee.mock
===================================================================
--- protocols/skype/t/away-set-bitlbee.mock	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ 	(revision )
@@ -1,10 +1,0 @@
->> NOTICE AUTH
-<< NICK alice
-<< USER alice alice localhost :Alice
->> PRIVMSG &bitlbee
-<< PRIVMSG &bitlbee :account add skype alice foo
-<< PRIVMSG &bitlbee :account skype set skypeconsole_receive true
-<< PRIVMSG &bitlbee :account skype on
->> PRIVMSG &bitlbee :skype - Logging in: Logged in
-<< AWAY :work
->> PRIVMSG &bitlbee :alice: USERSTATUS AWAY
Index: otocols/skype/t/away-set-skyped.mock
===================================================================
--- protocols/skype/t/away-set-skyped.mock	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ 	(revision )
@@ -1,20 +1,0 @@
->> SEARCH GROUPS CUSTOM
-<< GROUPS 48, 49
->> SEARCH FRIENDS
-<< USERS echo123, bob
->> SET USERSTATUS ONLINE
-<< USERSTATUS ONLINE
->> SET USERSTATUS ONLINE
-<< USERSTATUS ONLINE
->> GET USER echo123 ONLINESTATUS
-<< USER echo123 ONLINESTATUS ONLINE
->> GET USER echo123 FULLNAME
-<< USER echo123 FULLNAME Echo / Sound Test Service
->> GET USER bob ONLINESTATUS
-<< USER bob ONLINESTATUS ONLINE
->> GET USER bob FULLNAME
-<< USER bob FULLNAME Bob
->> SET USERSTATUS AWAY
-<< USERSTATUS AWAY
-<< USER alice ONLINESTATUS AWAY
-<< USERSTATUS AWAY
Index: otocols/skype/t/group-add-bitlbee.mock
===================================================================
--- protocols/skype/t/group-add-bitlbee.mock	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ 	(revision )
@@ -1,14 +1,0 @@
->> NOTICE AUTH
-<< NICK alice
-<< USER alice alice localhost :Alice
->> PRIVMSG &bitlbee
-<< PRIVMSG &bitlbee :account add skype alice foo
-<< PRIVMSG &bitlbee :account skype set read_groups true
-<< PRIVMSG &bitlbee :account skype on
->> :bob!bob@skype.com JOIN :&bitlbee
->> :cecil!cecil@skype.com JOIN :&bitlbee
->> :daniel!daniel@skype.com JOIN :&bitlbee
-<< JOIN &family
->> 353 alice = &family :@alice +bob +cecil @root
-<< INVITE daniel &family
->> :daniel!daniel@skype.com JOIN :&family
Index: otocols/skype/t/group-add-skyped.mock
===================================================================
--- protocols/skype/t/group-add-skyped.mock	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ 	(revision )
@@ -1,38 +1,0 @@
->> SEARCH GROUPS CUSTOM
-<< GROUPS 70, 71
->> SEARCH FRIENDS
-<< USERS echo123, bob, cecil, daniel, emily
->> SET USERSTATUS ONLINE
-<< USERSTATUS ONLINE
->> SET USERSTATUS ONLINE
-<< USERSTATUS ONLINE
->> GET GROUP 70 DISPLAYNAME
-<< GROUP 70 DISPLAYNAME Family
->> GET GROUP 70 USERS
-<< GROUP 70 USERS bob, cecil
->> GET GROUP 71 DISPLAYNAME
-<< GROUP 71 DISPLAYNAME Work
->> GET GROUP 71 USERS
-<< GROUP 71 USERS daniel, emily
->> GET USER echo123 ONLINESTATUS
-<< USER echo123 ONLINESTATUS ONLINE
->> GET USER echo123 FULLNAME
-<< USER echo123 FULLNAME Echo / Sound Test Service
->> GET USER bob ONLINESTATUS
-<< USER bob ONLINESTATUS ONLINE
->> GET USER bob FULLNAME
-<< USER bob FULLNAME Bob
->> GET USER cecil ONLINESTATUS
-<< USER cecil ONLINESTATUS ONLINE
->> GET USER cecil FULLNAME
-<< USER cecil FULLNAME Cecil
->> GET USER daniel ONLINESTATUS
-<< USER daniel ONLINESTATUS ONLINE
->> GET USER daniel FULLNAME
-<< USER daniel FULLNAME Daniel
->> GET USER emily ONLINESTATUS
-<< USER emily ONLINESTATUS OFFLINE
->> GET USER emily FULLNAME
-<< USER emily FULLNAME Emily
->> ALTER GROUP 70 ADDUSER daniel
-<< ALTER GROUP 70 ADDUSER daniel
Index: otocols/skype/t/groupchat-msg-bitlbee.mock
===================================================================
--- protocols/skype/t/groupchat-msg-bitlbee.mock	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ 	(revision )
@@ -1,11 +1,0 @@
->> NOTICE AUTH
-<< NICK alice
-<< USER alice alice localhost :Alice
->> PRIVMSG &bitlbee
-<< PRIVMSG &bitlbee :account add skype alice foo
-<< PRIVMSG &bitlbee :account skype set skypeconsole_receive true
-<< PRIVMSG &bitlbee :account skype on
->> JOIN :##cecil/$bob;4d8cc9965791
->> 353 alice = ##cecil/$bob;4d8cc9965791 :@alice bob cecil @root
-<< PRIVMSG ##cecil/$bob;4d8cc9965791 :hello
->> PRIVMSG &bitlbee :alice: CHAT #cecil/$bob;4d8cc9965791c6b9 ACTIVITY_TIMESTAMP
Index: otocols/skype/t/groupchat-msg-skyped.mock
===================================================================
--- protocols/skype/t/groupchat-msg-skyped.mock	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ 	(revision )
@@ -1,60 +1,0 @@
->> SEARCH GROUPS CUSTOM
-<< GROUPS 48, 49
->> SEARCH FRIENDS
-<< USERS echo123, bob, cecil
->> SET USERSTATUS ONLINE
-<< USERSTATUS ONLINE
->> SET USERSTATUS ONLINE
-<< USERSTATUS ONLINE
->> GET USER echo123 ONLINESTATUS
-<< USER echo123 ONLINESTATUS ONLINE
->> GET USER echo123 FULLNAME
-<< USER echo123 FULLNAME Echo / Sound Test Service
->> GET USER bob ONLINESTATUS
-<< USER bob ONLINESTATUS OFFLINE
->> GET USER bob FULLNAME
-<< USER bob FULLNAME Bob
->> GET USER cecil ONLINESTATUS
-<< USER cecil ONLINESTATUS OFFLINE
->> GET USER cecil FULLNAME
-<< USER cecil FULLNAME Cecil
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 NAME #cecil/$bob;4d8cc9965791c6b9
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 STATUS MULTI_SUBSCRIBED
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 STATUS MULTI_SUBSCRIBED
-<< CHATMEMBER 186 ROLE USER
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 MYROLE USER
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 MEMBERS bob cecil alice
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 FRIENDLYNAME bob, cecil
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 ACTIVEMEMBERS bob alice
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 TIMESTAMP 1358276196
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER bob
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC 
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 STATUS MULTI_SUBSCRIBED
-<< CHATMESSAGE 188 STATUS RECEIVED
->> GET CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER bob
->> GET CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC 
->> GET CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER bob
->> GET CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC 
->> GET CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER bob
->> GET CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC 
->> GET CHATMESSAGE 188 FROM_HANDLE
-<< CHATMESSAGE 188 FROM_HANDLE bob
->> GET CHATMESSAGE 188 BODY
-<< CHATMESSAGE 188 BODY 
->> GET CHATMESSAGE 188 TYPE
-<< CHATMESSAGE 188 TYPE ADDEDMEMBERS
->> GET CHATMESSAGE 188 CHATNAME
-<< CHATMESSAGE 188 CHATNAME #cecil/$bob;4d8cc9965791c6b9
-<< CHATMESSAGE 189 STATUS READ
-<< CHATMESSAGE 189 STATUS READ
-<< CHATMEMBER 186 IS_ACTIVE TRUE
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 ACTIVEMEMBERS bob cecil alice
-<< CHATMESSAGE 190 STATUS SENT
->> CHATMESSAGE #cecil/$bob;4d8cc9965791c6b9 hello
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 ACTIVITY_TIMESTAMP 1364652882
Index: otocols/skype/t/groupchat-topic-bitlbee.mock
===================================================================
--- protocols/skype/t/groupchat-topic-bitlbee.mock	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ 	(revision )
@@ -1,10 +1,0 @@
->> NOTICE AUTH
-<< NICK alice
-<< USER alice alice localhost :Alice
->> PRIVMSG &bitlbee
-<< PRIVMSG &bitlbee :account add skype alice foo
-<< PRIVMSG &bitlbee :account skype on
->> JOIN :##cecil/$bob;4d8cc9965791
->> 353 alice = ##cecil/$bob;4d8cc9965791 :@alice bob cecil @root
-<< TOPIC ##cecil/$bob;4d8cc9965791 :topic
->> TOPIC ##cecil/$bob;4d8cc9965791 :topic
Index: otocols/skype/t/groupchat-topic-skyped.mock
===================================================================
--- protocols/skype/t/groupchat-topic-skyped.mock	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ 	(revision )
@@ -1,60 +1,0 @@
->> SEARCH GROUPS CUSTOM
-<< GROUPS 48, 49
->> SEARCH FRIENDS
-<< USERS echo123, bob, cecil
->> SET USERSTATUS ONLINE
-<< USERSTATUS ONLINE
->> SET USERSTATUS ONLINE
-<< USERSTATUS ONLINE
->> GET USER echo123 ONLINESTATUS
-<< USER echo123 ONLINESTATUS ONLINE
->> GET USER echo123 FULLNAME
-<< USER echo123 FULLNAME Echo / Sound Test Service
->> GET USER bob ONLINESTATUS
-<< USER bob ONLINESTATUS OFFLINE
->> GET USER bob FULLNAME
-<< USER bob FULLNAME Bob
->> GET USER cecil ONLINESTATUS
-<< USER cecil ONLINESTATUS OFFLINE
->> GET USER cecil FULLNAME
-<< USER cecil FULLNAME Cecil
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 NAME #cecil/$bob;4d8cc9965791c6b9
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 STATUS MULTI_SUBSCRIBED
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 STATUS MULTI_SUBSCRIBED
-<< CHATMEMBER 186 ROLE USER
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 MYROLE USER
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 MEMBERS bob cecil alice
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 FRIENDLYNAME bob, cecil
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 ACTIVEMEMBERS bob alice
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 TIMESTAMP 1358276196
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER bob
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC 
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 STATUS MULTI_SUBSCRIBED
-<< CHATMESSAGE 188 STATUS RECEIVED
->> GET CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER bob
->> GET CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC 
->> GET CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER bob
->> GET CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC 
->> GET CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER bob
->> GET CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC 
->> GET CHATMESSAGE 188 FROM_HANDLE
-<< CHATMESSAGE 188 FROM_HANDLE bob
->> GET CHATMESSAGE 188 BODY
-<< CHATMESSAGE 188 BODY 
->> GET CHATMESSAGE 188 TYPE
-<< CHATMESSAGE 188 TYPE ADDEDMEMBERS
->> GET CHATMESSAGE 188 CHATNAME
-<< CHATMESSAGE 188 CHATNAME #cecil/$bob;4d8cc9965791c6b9
-<< CHATMESSAGE 189 STATUS READ
-<< CHATMESSAGE 189 STATUS READ
-<< CHATMEMBER 186 IS_ACTIVE TRUE
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 ACTIVEMEMBERS bob cecil alice
-<< CHATMESSAGE 190 STATUS SENT
->> ALTER CHAT #cecil/$bob;4d8cc9965791c6b9 SETTOPIC topic
-<< CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC topic
Index: protocols/skype/test.py
===================================================================
--- protocols/skype/test.py	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ protocols/skype/test.py	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -113,10 +113,4 @@
 		self.mock("groupchat-leave")
 	
-	def testGroupchatMsg(self):
-		self.mock("groupchat-msg")
-	
-	def testGroupchatTopic(self):
-		self.mock("groupchat-topic")
-	
 	def testCalledYes(self):
 		self.mock("called-yes")
@@ -131,7 +125,4 @@
 		self.mock("group-read")
 
-	def testGroupAdd(self):
-		self.mock("group-add")
-
 	def testCtcpHelp(self):
 		self.mock("ctcp-help")
@@ -139,7 +130,4 @@
 	def testSetMoodText(self):
 		self.mock("set-mood-text")
-	
-	def testAwaySet(self):
-		self.mock("away-set")
 
 if __name__ == '__main__':
Index: protocols/twitter/twitter.c
===================================================================
--- protocols/twitter/twitter.c	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ protocols/twitter/twitter.c	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -158,11 +158,6 @@
 {
 	struct twitter_data *td = ic->proto_data;
-	const char *url = set_getstr(&ic->acc->set, "base_url");
 
 	imcb_log(ic, "Requesting OAuth request token");
-	
-	if (!strstr(url, "twitter.com") && !strstr(url, "identi.ca"))
-		imcb_log(ic, "Warning: OAuth only works with identi.ca and "
-		             "Twitter.");
 
 	td->oauth_info = oauth_request_token(get_oauth_service(ic), twitter_oauth_callback, ic);
@@ -183,5 +178,5 @@
 	td = ic->proto_data;
 	if (info->stage == OAUTH_REQUEST_TOKEN) {
-		char *name, *msg;
+		char name[strlen(ic->acc->user) + 9], *msg;
 
 		if (info->request_token == NULL) {
@@ -191,10 +186,9 @@
 		}
 
-		name = g_strdup_printf("%s_%s", td->prefix, ic->acc->user);
+		sprintf(name, "%s_%s", td->prefix, ic->acc->user);
 		msg = g_strdup_printf("To finish OAuth authentication, please visit "
 				      "%s and respond with the resulting PIN code.",
 				      info->auth_url);
 		imcb_buddy_msg(ic, name, msg, 0, 0);
-		g_free(name);
 		g_free(msg);
 	} else if (info->stage == OAUTH_ACCESS_TOKEN) {
@@ -289,14 +283,11 @@
 	char *def_url;
 	char *def_tul;
-	char *def_mentions;
 
 	if (strcmp(acc->prpl->name, "twitter") == 0) {
 		def_url = TWITTER_API_URL;
 		def_tul = "20";
-		def_mentions = "true";
 	} else {		/* if( strcmp( acc->prpl->name, "identica" ) == 0 ) */
 		def_url = IDENTICA_API_URL;
 		def_tul = "0";
-		def_mentions = "false";
 	}
 
@@ -311,5 +302,5 @@
 	s->flags |= ACC_SET_OFFLINE_ONLY;
 
-	s = set_add(&acc->set, "fetch_mentions", def_mentions, set_eval_bool, acc);
+	s = set_add(&acc->set, "fetch_mentions", "true", set_eval_bool, acc);
 
 	s = set_add(&acc->set, "message_length", "140", set_eval_int, acc);
Index: protocols/twitter/twitter_http.c
===================================================================
--- protocols/twitter/twitter_http.c	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ protocols/twitter/twitter_http.c	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -78,5 +78,5 @@
 	
 	// Make the request.
-	g_string_printf(request, "%s %s%s%s%s HTTP/1.1\r\n"
+	g_string_printf(request, "%s %s%s%s%s HTTP/1.0\r\n"
 			"Host: %s\r\n"
 			"User-Agent: BitlBee " BITLBEE_VERSION " " ARCH "/" CPU "\r\n",
Index: protocols/twitter/twitter_lib.h
===================================================================
--- protocols/twitter/twitter_lib.h	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ protocols/twitter/twitter_lib.h	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -29,5 +29,5 @@
 #include "twitter_http.h"
 
-#define TWITTER_API_URL "https://api.twitter.com/1.1"
+#define TWITTER_API_URL "http://api.twitter.com/1.1"
 #define IDENTICA_API_URL "https://identi.ca/api"
 
Index: storage_xml.c
===================================================================
--- storage_xml.c	(revision 1a2c1c0c413ea1124544cdc9a24a0d2faa5dbb8f)
+++ storage_xml.c	(revision 5cb946132871ef97fe9eabacafa62f1064d80423)
@@ -174,5 +174,5 @@
 	char *fn, buf[2048];
 	int fd, st;
-	struct xt_parser *xp = NULL;
+	struct xt_parser *xp;
 	struct xt_node *node;
 	storage_status_t ret = STORAGE_OTHER_ERROR;
