pidgin: e4ac907b: Move two logging statements from oscar.c...

markdoliner at pidgin.im markdoliner at pidgin.im
Tue Feb 2 18:20:22 EST 2010


-----------------------------------------------------------------
Revision: e4ac907bad6138766e0ccd0f47d17103a0b0a75c
Ancestor: 5cb44bc3238fe4c7df3f9112833306a80c2df57d
Author: markdoliner at pidgin.im
Date: 2010-02-02T23:18:09
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/e4ac907bad6138766e0ccd0f47d17103a0b0a75c

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

ChangeLog: 

Move two logging statements from oscar.c to family_oservice.c so we
can stop passing a billion parameters around.
2 files changed, 22 insertions(+), 61 deletions(-)

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/family_oservice.c	c96167552b16b5cbb0a89ea373c885522c9f1aa1
+++ libpurple/protocols/oscar/family_oservice.c	c0e09144b5d44b46bc204def448345f42986da6f
@@ -333,7 +333,6 @@ rateresp(OscarData *od, FlapConnection *
 		rateclass->disconnect = byte_stream_get32(bs);
 		rateclass->current = byte_stream_get32(bs);
 		rateclass->max = byte_stream_get32(bs);
-
 		if (mod->version >= 3) {
 			delta = byte_stream_get32(bs);
 			rateclass->dropping_snacs = byte_stream_get8(bs);
@@ -341,6 +340,7 @@ rateresp(OscarData *od, FlapConnection *
 			delta = 0;
 			rateclass->dropping_snacs = 0;
 		}
+
 		rateclass->last.tv_sec = now.tv_sec - delta / 1000;
 		delta %= 1000;
 		rateclass->last.tv_usec = now.tv_usec - delta * 1000;
@@ -448,12 +448,17 @@ ratechange(OscarData *od, FlapConnection
 static int
 ratechange(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
 {
-	int ret = 0;
-	aim_rxcallback_t userfunc;
 	guint16 code, classid;
 	struct rateclass *rateclass;
 	guint32 delta;
 	struct timeval now;
+	static const char *codes[5] = {
+		"invalid",
+		"change",
+		"warning",
+		"limit",
+		"limit cleared",
+	};
 
 	gettimeofday(&now, NULL);
 	code = byte_stream_get16(bs);
@@ -471,7 +476,6 @@ ratechange(OscarData *od, FlapConnection
 	rateclass->disconnect = byte_stream_get32(bs);
 	rateclass->current = byte_stream_get32(bs);
 	rateclass->max = byte_stream_get32(bs);
-
 	if (mod->version >= 3) {
 		delta = byte_stream_get32(bs);
 		rateclass->dropping_snacs = byte_stream_get8(bs);
@@ -479,17 +483,26 @@ ratechange(OscarData *od, FlapConnection
 		delta = 0;
 		rateclass->dropping_snacs = 0;
 	}
+
 	rateclass->last.tv_sec = now.tv_sec - delta / 1000;
 	delta %= 1000;
 	rateclass->last.tv_usec = now.tv_usec - delta * 1000;
 
-	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) {
-		/* Can't pass in guint8 via ... varargs, so we use an unsigned int */
-		unsigned int dropping_snacs = rateclass->dropping_snacs;
-		ret = userfunc(od, conn, frame, code, classid, rateclass->windowsize, rateclass->clear, rateclass->alert, rateclass->limit, rateclass->disconnect, rateclass->current, rateclass->max, delta, dropping_snacs);
+	purple_debug_misc("oscar", "rate %s (param ID 0x%04hx): curavg = %u, "
+			"maxavg = %u, alert at %u, clear warning at %u, limit at %u, "
+			"disconnect at %u, delta is %u, dropping is %u (window size = %u)\n",
+			(code < 5) ? codes[code] : codes[0], rateclass->classid,
+			rateclass->current, rateclass->max, rateclass->alert,
+			rateclass->clear, rateclass->limit, rateclass->disconnect,
+			delta, rateclass->dropping_snacs, rateclass->windowsize);
+
+	if (code == AIM_RATE_CODE_LIMIT) {
+		purple_debug_warning("oscar",  _("The last action you attempted "
+				"could not be performed because you are over the rate "
+				"limit. Please wait 10 seconds and try again.\n"));
 	}
 
-	return ret;
+	return 1;
 }
 
 /*
============================================================
--- libpurple/protocols/oscar/oscar.c	12d0d6cf454e91c3cce6774f24f21062318ea04d
+++ libpurple/protocols/oscar/oscar.c	e7fbe71ebc6381e9b15c1e8d9dd709733d6932df
@@ -190,7 +190,6 @@ static int purple_parse_msgack     (Osca
 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_ratechange (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_parse_evilnotify (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_parse_searcherror(OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_parse_searchreply(OscarData *, FlapConnection *, FlapFrame *, ...);
@@ -1526,7 +1525,6 @@ oscar_login(PurpleAccount *account)
 	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_RATECHANGE, purple_parse_ratechange, 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);
@@ -3838,56 +3836,6 @@ static int purple_parse_msgack(OscarData
 	return 1;
 }
 
-static int purple_parse_ratechange(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
-	static const char *codes[5] = {
-		"invalid",
-		"change",
-		"warning",
-		"limit",
-		"limit cleared",
-	};
-	va_list ap;
-	guint16 code, rateclass;
-	guint32 windowsize, clear, alert, limit, disconnect, currentavg, maxavg, delta;
-	guint8 dropping_snacs;
-
-	va_start(ap, fr);
-	code = (guint16)va_arg(ap, unsigned int);
-	rateclass= (guint16)va_arg(ap, unsigned int);
-	windowsize = va_arg(ap, guint32);
-	clear = va_arg(ap, guint32);
-	alert = va_arg(ap, guint32);
-	limit = va_arg(ap, guint32);
-	disconnect = va_arg(ap, guint32);
-	currentavg = va_arg(ap, guint32);
-	maxavg = va_arg(ap, guint32);
-	delta = va_arg(ap, guint32);
-	dropping_snacs = (guint8)va_arg(ap, unsigned int);
-	va_end(ap);
-
-	purple_debug_misc("oscar",
-			   "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, "
-		     "clear warning at %u, limit at %u, disconnect at %u, delta is %u, dropping is %u (window size = %u)\n",
-		     (code < 5) ? codes[code] : codes[0],
-		     rateclass,
-		     currentavg, maxavg,
-		     alert, clear,
-		     limit, disconnect,
-		     delta,
-		     dropping_snacs,
-		     windowsize
-		     );
-
-	if (code == AIM_RATE_CODE_LIMIT)
-	{
-		purple_debug_warning("oscar",  _("The last action you attempted could not be "
-				"performed because you are over the rate limit. "
-				"Please wait 10 seconds and try again.\n"));
-	}
-
-	return 1;
-}
-
 static int purple_parse_evilnotify(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
 #ifdef CRAZY_WARNING
 	va_list ap;


More information about the Commits mailing list