/soc/2013/ankitkv/gobjectification: 4477544f42a3: Merged default...

Ankit Vani a at nevitus.org
Thu Jul 18 17:58:04 EDT 2013


Changeset: 4477544f42a3c8db30efe7c5a383195967472414
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-19 03:27 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/4477544f42a3

Description:

Merged default branch

diffstat:

 libpurple/plugins/keyrings/internalkeyring.c |    5 +
 libpurple/protocols/mxit/Makefile.am         |    2 -
 libpurple/protocols/mxit/formcmds.c          |    2 +-
 libpurple/protocols/mxit/http.c              |  340 ---------------------------
 libpurple/protocols/mxit/http.h              |   47 ---
 libpurple/protocols/mxit/login.c             |    2 +-
 libpurple/protocols/mxit/markup.c            |    2 +-
 libpurple/protocols/mxit/protocol.c          |   65 +---
 libpurple/protocols/oscar/family_oservice.c  |  147 -----------
 libpurple/protocols/oscar/oscar.c            |  160 ------------
 libpurple/protocols/oscar/oscar.h            |    5 -
 libpurple/proxy.c                            |    3 -
 po/POTFILES.in                               |    2 -
 po/de.po                                     |    6 +-
 14 files changed, 31 insertions(+), 757 deletions(-)

diffs (truncated from 976 to 300 lines):

diff --git a/libpurple/plugins/keyrings/internalkeyring.c b/libpurple/plugins/keyrings/internalkeyring.c
--- a/libpurple/plugins/keyrings/internalkeyring.c
+++ b/libpurple/plugins/keyrings/internalkeyring.c
@@ -469,6 +469,11 @@ intkeyring_encrypt_password_if_needed(Pu
 	const gchar *plaintext;
 	gchar *ciphertext;
 
+	if (intkeyring_key == NULL) {
+		g_hash_table_remove(intkeyring_ciphertexts, account);
+		return;
+	}
+
 	ciphertext = g_hash_table_lookup(intkeyring_ciphertexts, account);
 	if (ciphertext != NULL)
 		return;
diff --git a/libpurple/protocols/mxit/Makefile.am b/libpurple/protocols/mxit/Makefile.am
--- a/libpurple/protocols/mxit/Makefile.am
+++ b/libpurple/protocols/mxit/Makefile.am
@@ -16,8 +16,6 @@ MXITSOURCES = \
 	filexfer.h \
 	formcmds.c \
 	formcmds.h \
-	http.c \
-	http.h \
 	login.c \
 	login.h \
 	markup.c \
diff --git a/libpurple/protocols/mxit/formcmds.c b/libpurple/protocols/mxit/formcmds.c
--- a/libpurple/protocols/mxit/formcmds.c
+++ b/libpurple/protocols/mxit/formcmds.c
@@ -26,7 +26,7 @@
 
 #include "internal.h"
 #include "debug.h"
-#include "libpurple/http.h"
+#include "http.h"
 
 #include "protocol.h"
 #include "mxit.h"
diff --git a/libpurple/protocols/mxit/http.c b/libpurple/protocols/mxit/http.c
deleted file mode 100644
--- a/libpurple/protocols/mxit/http.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- *					MXit Protocol libPurple Plugin
- *
- *			-- MXit client protocol implementation --
- *
- *				Pieter Loubser	<libpurple at mxit.com>
- *
- *			(C) Copyright 2009	MXit Lifestyle (Pty) Ltd.
- *				<http://www.mxitlifestyle.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
- */
-
-#include	"internal.h"
-#include	"debug.h"
-
-#include	"mxit.h"
-#include	"protocol.h"
-#include	"http.h"
-
-
-/* HTTP constants */
-#define		HTTP_11_200_OK		"HTTP/1.1 200 OK\r\n"
-#define		HTTP_11_100_CONT	"HTTP/1.1 100 Continue\r\n"
-#define		HTTP_11_SEPERATOR	"\r\n\r\n"
-#define		HTTP_CONTENT_LEN	"Content-Length: "
-
-
-/* define to enable HTTP debugging */
-#define		DEBUG_HTTP
-
-
-/*------------------------------------------------------------------------
- * This will freeup the memory used by a HTTP request structure
- *
- *	@param req		The HTTP structure's resources should be freed up
- */
-static void free_http_request( struct http_request* req )
-{
-	g_free( req->host );
-	g_free( req->data );
-	g_free( req );
-}
-
-
-/*------------------------------------------------------------------------
- * Write the request to the HTTP server.
- *
- *  @param fd			The file descriptor
- *  @param pktdata		The packet data
- *  @param pktlen		The length of the packet data
- *  @return				Return -1 on error, otherwise 0
- */
-static int mxit_http_raw_write( int fd, const char* pktdata, int pktlen )
-{
-	int		written;
-	int		res;
-
-	written = 0;
-	while ( written < pktlen ) {
-		res = write( fd, &pktdata[written], pktlen - written );
-		if ( res <= 0 ) {
-			/* error on socket */
-			if ( errno == EAGAIN )
-				continue;
-
-			purple_debug_error( MXIT_PLUGIN_ID, "Error while writing packet to HTTP server (%i)\n", res );
-			return -1;
-		}
-		written += res;
-	}
-
-	return 0;
-}
-
-
-/*------------------------------------------------------------------------
- * Callback when data is received from the HTTP server.
- *
- *  @param user_data		The MXit session object
- *  @param source			The file-descriptor on which data was received
- *  @param cond				Condition which caused the callback (PURPLE_INPUT_READ)
- */
-static void mxit_cb_http_read( gpointer user_data, gint source, PurpleInputCondition cond )
-{
-	struct MXitSession*	session		= (struct MXitSession*) user_data;
-	char				buf[256];
-	int					buflen;
-	char*				body;
-	int					bodylen;
-	char*				ch;
-	int					len;
-	char*				tmp;
-	int					res;
-#if 0
-	char*				next;
-#endif
-
-	purple_debug_info( MXIT_PLUGIN_ID, "mxit_cb_http_read\n" );
-
-	if ( session->rx_state == RX_STATE_RLEN ) {
-		/* we are reading in the HTTP headers */
-
-		/* copy partial headers if we have any part saved */
-		memcpy( buf, session->rx_dbuf, session->rx_i );
-		buflen = session->rx_i;
-
-		/* read bytes from the socket */
-		len = read( session->fd, buf + buflen, sizeof( buf ) - ( buflen + 1 ) );
-		if ( len <= 0 ) {
-			/* connection has been terminated, or error occurred */
-			goto done;
-		}
-		buf[buflen+len] = '\0';
-
-//nextpacket:
-
-#ifdef	DEBUG_HTTP
-		purple_debug_info( MXIT_PLUGIN_ID, "HTTP POST READ 1: (%i)\n", len );
-		dump_bytes( session, buf + buflen, len );
-#endif
-
-		/* see if we have all the HTTP headers yet */
-		ch = strstr( buf, HTTP_11_SEPERATOR );
-		if ( !ch ) {
-			/* we need to wait for more input, so save what we have */
-			session->rx_i = buflen + len;
-			memcpy( session->rx_dbuf, buf, session->rx_i );
-			return;
-		}
-		buflen += len;
-
-		/* we have the header's end now skip over the http separator to get the body offset */
-		ch += strlen( HTTP_11_SEPERATOR );
-		*(ch - 1) = '\0';
-		body = ch;
-
-		res = buflen - ( ch - buf );
-		if ( res > 0 ) {
-			/* we read more bytes than just the header so copy it over */
-			memcpy( session->rx_dbuf, ch, res );
-			session->rx_i = res;
-		}
-		else {
-			session->rx_i = 0;
-		}
-
-		/* test for a good response */
-		if ( ( strncmp( buf, HTTP_11_200_OK, strlen( HTTP_11_200_OK ) ) != 0 ) && ( strncmp( buf, HTTP_11_100_CONT, strlen( HTTP_11_100_CONT ) ) != 0 ) ) {
-			/* bad result */
-			purple_debug_error( MXIT_PLUGIN_ID, "HTTP error: %s\n", ch );
-			goto done;
-		}
-
-		/* find the content-length */
-		ch = (char*) purple_strcasestr( buf, HTTP_CONTENT_LEN );
-		if ( !ch ) {
-			/* bad request. it does not contain a content-length header */
-			purple_debug_error( MXIT_PLUGIN_ID, "HTTP reply received without content-length header (ignoring packet)\n" );
-			goto done;
-		}
-
-		/* parse the content-length */
-		ch += strlen( HTTP_CONTENT_LEN );
-		tmp = strchr( ch, '\r' );
-		if ( !tmp ) {
-			purple_debug_error( MXIT_PLUGIN_ID, "Received bad HTTP reply packet (ignoring packet)\n" );
-			goto done;
-		}
-		tmp = g_strndup( ch, tmp - ch );
-		bodylen = atoi( tmp );
-		g_free( tmp );
-		tmp = NULL;
-
-		if ( buflen + bodylen >= CP_MAX_PACKET ) {
-			/* this packet is way to big */
-			goto done;
-		}
-		else if ( buflen > ( ( body - buf ) + bodylen ) ) {
-			/* we have a second packet here */
-#if 0
-			next = body + bodylen;
-#endif
-			purple_debug_warning(MXIT_PLUGIN_ID, "Recieved many packets at once\n");
-			session->rx_res = 0;
-		}
-		else {
-			session->rx_res = bodylen - session->rx_i;
-		}
-
-		if ( session->rx_res == 0 ) {
-			/* we have read all the data */
-			session->rx_i = bodylen;
-			session->rx_state = RX_STATE_PROC;
-		}
-		else {
-			/* there is still some data outstanding */
-			session->rx_state = RX_STATE_DATA;
-		}
-	}
-	else if ( session->rx_state == RX_STATE_DATA ) {
-		/* we are reading the HTTP content (body) */
-
-		/* read bytes from the socket */
-		len = read( session->fd, &session->rx_dbuf[session->rx_i], session->rx_res );
-		if ( len <= 0 ) {
-			/* connection has been terminated, or error occurred */
-			goto done;
-		}
-
-#ifdef	DEBUG_HTTP
-		purple_debug_info( MXIT_PLUGIN_ID, "HTTP POST READ 2: (%i)\n", len );
-		dump_bytes( session, &session->rx_dbuf[session->rx_i], len );
-#endif
-		session->rx_i += len;
-		session->rx_res -= len;
-
-		if ( session->rx_res == 0 ) {
-			/* ok, so now we have read in the whole packet */
-			session->rx_state = RX_STATE_PROC;
-		}
-	}
-
-	if ( session->rx_state == RX_STATE_PROC ) {
-		mxit_parse_packet( session );
-
-#if	0
-		if ( next ) {
-			/* there is another packet of which we read some data */
-
-			/* reset input */
-			session->rx_state = RX_STATE_RLEN;
-			session->rx_lbuf[0] = '\0';
-			session->rx_i = 0;
-			session->rx_res = 0;
-
-			/* move read data */
-			len = next - buf;
-			buflen = len;
-			memcpy( buf, next, len );
-			goto nextpacket;
-		}
-#endif
-



More information about the Commits mailing list