pidgin: d01e8083: There's no reason to call into oscar.c a...

markdoliner at pidgin.im markdoliner at pidgin.im
Sun Apr 11 06:05:41 EDT 2010


-----------------------------------------------------------------
Revision: d01e8083d0684431926f58d90a40dccb3458cf68
Ancestor: c29a22bdca4eda3a26dc5cb7840c9160cb7b13a9
Author: markdoliner at pidgin.im
Date: 2010-04-11T10:02:02
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/d01e8083d0684431926f58d90a40dccb3458cf68

Modified files:
        libpurple/protocols/oscar/family_oservice.c
        libpurple/protocols/oscar/oscar.c

ChangeLog: 

There's no reason to call into oscar.c anymore, so move this icon stuff
directly into family_oservice.c

2 files changed, 38 insertions(+), 71 deletions(-)
But more importantly, this is simpler and oscar.c is smaller.

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/family_oservice.c	c6a40af622ddb11f602a143d7d6a39205e3ab415
+++ libpurple/protocols/oscar/family_oservice.c	e0dc2fa7f9149a5493566ef9849fd69c9b609b58
@@ -1094,8 +1094,6 @@ aim_parse_extstatus(OscarData *od, FlapC
 static int
 aim_parse_extstatus(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
 {
-	int ret = 0;
-	aim_rxcallback_t userfunc;
 	guint16 type;
 	guint8 flags, length;
 
@@ -1108,25 +1106,54 @@ aim_parse_extstatus(OscarData *od, FlapC
 	 * A flag of 0x40 could mean "I don't have your icon, upload it"
 	 */
 
-	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) {
-		switch (type) {
+	switch (type) {
 		case 0x0000:
 		case 0x0001: { /* buddy icon checksum */
 			/* not sure what the difference between 1 and 0 is */
 			guint8 *md5 = byte_stream_getraw(bs, length);
-			ret = userfunc(od, conn, frame, type, flags, length, md5);
+
+			if ((flags == 0x00) || (flags == 0x41)) {
+				if (!flap_connection_getbytype(od, SNAC_FAMILY_BART) && !od->iconconnecting) {
+					od->iconconnecting = TRUE;
+					od->set_icon = TRUE;
+					aim_srv_requestnew(od, SNAC_FAMILY_BART);
+				} else {
+					PurpleAccount *account = purple_connection_get_account(od->gc);
+					PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account);
+					if (img == NULL) {
+						aim_ssi_delicon(od);
+					} else {
+
+						purple_debug_info("oscar",
+										"Uploading icon to icon server\n");
+						aim_bart_upload(od, purple_imgstore_get_data(img),
+						                purple_imgstore_get_size(img));
+						purple_imgstore_unref(img);
+					}
+				}
+			} else if (flags == 0x81) {
+				PurpleAccount *account = purple_connection_get_account(od->gc);
+				PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account);
+				if (img == NULL)
+					aim_ssi_delicon(od);
+				else {
+					aim_ssi_seticon(od, md5, length);
+					purple_imgstore_unref(img);
+				}
+			}
+
 			g_free(md5);
-			} break;
-		case 0x0002: { /* available message */
+		} break;
+
+		case 0x0002: {
+			/* We just set an available message? */
 			/* there is a second length that is just for the message */
 			char *msg = byte_stream_getstr(bs, byte_stream_get16(bs));
-			ret = userfunc(od, conn, frame, type, msg);
 			g_free(msg);
-			} break;
-		}
+		} break;
 	}
 
-	return ret;
+	return 0;
 }
 
 static int
============================================================
--- libpurple/protocols/oscar/oscar.c	759a5050ec50a7e7092b20520b52251646d97dd6
+++ libpurple/protocols/oscar/oscar.c	e3b05ea62c59df9de9d055efb5f1469fe1eb73eb
@@ -202,7 +202,6 @@ static int purple_icon_parseicon   (Osca
 static int purple_conv_chat_incoming_msg(OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_email_parseupdate(OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_icon_parseicon   (OscarData *, FlapConnection *, FlapFrame *, ...);
-static int oscar_icon_req        (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_parse_msgack     (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_parse_evilnotify (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_parse_searcherror(OscarData *, FlapConnection *, FlapFrame *, ...);
@@ -1562,7 +1561,6 @@ oscar_login(PurpleAccount *account)
 	oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x0001, purple_parse_genericerr, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x000f, purple_selfinfo, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x001f, purple_memrequest, 0);
-	oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x0021, oscar_icon_req,0);
 	oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, SNAC_SUBTYPE_OSERVICE_REDIRECT, purple_handle_redirect, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, SNAC_SUBTYPE_OSERVICE_MOTD, purple_parse_motd, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, SNAC_SUBTYPE_OSERVICE_EVIL, purple_parse_evilnotify, 0);
@@ -6243,64 +6241,6 @@ char *oscar_status_text(PurpleBuddy *b)
 	return ret;
 }
 
-
-static int oscar_icon_req(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
-	PurpleConnection *gc = od->gc;
-	va_list ap;
-	guint16 type;
-	guint8 flags = 0, length = 0;
-	guchar *md5 = NULL;
-
-	va_start(ap, fr);
-	type = va_arg(ap, int);
-
-	switch(type) {
-		case 0x0000:
-		case 0x0001: {
-			flags = va_arg(ap, int);
-			length = va_arg(ap, int);
-			md5 = va_arg(ap, guchar *);
-
-			if ((flags == 0x00) || (flags == 0x41)) {
-				if (!flap_connection_getbytype(od, SNAC_FAMILY_BART) && !od->iconconnecting) {
-					od->iconconnecting = TRUE;
-					od->set_icon = TRUE;
-					aim_srv_requestnew(od, SNAC_FAMILY_BART);
-				} else {
-					PurpleAccount *account = purple_connection_get_account(gc);
-					PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account);
-					if (img == NULL) {
-						aim_ssi_delicon(od);
-					} else {
-
-						purple_debug_info("oscar",
-										"Uploading icon to icon server\n");
-						aim_bart_upload(od, purple_imgstore_get_data(img),
-						                purple_imgstore_get_size(img));
-						purple_imgstore_unref(img);
-					}
-				}
-			} else if (flags == 0x81) {
-				PurpleAccount *account = purple_connection_get_account(gc);
-				PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account);
-				if (img == NULL)
-					aim_ssi_delicon(od);
-				else {
-					aim_ssi_seticon(od, md5, length);
-					purple_imgstore_unref(img);
-				}
-			}
-		} break;
-
-		case 0x0002: { /* We just set an "available" message? */
-		} break;
-	}
-
-	va_end(ap);
-
-	return 0;
-}
-
 void oscar_set_permit_deny(PurpleConnection *gc) {
 	PurpleAccount *account = purple_connection_get_account(gc);
 	OscarData *od = purple_connection_get_protocol_data(gc);


More information about the Commits mailing list