pidgin: 594b0119: ft: Add some useful debug logging.

darkrain42 at pidgin.im darkrain42 at pidgin.im
Wed Dec 30 22:30:53 EST 2009


-----------------------------------------------------------------
Revision: 594b0119a09fc439905256b90ccb6bb14b347ced
Ancestor: 0caff498282376143dafe8a090cdcd2b3235ef4a
Author: darkrain42 at pidgin.im
Date: 2009-12-30T23:00:54
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/594b0119a09fc439905256b90ccb6bb14b347ced

Modified files:
        libpurple/ft.c

ChangeLog: 

ft: Add some useful debug logging.

-------------- next part --------------
============================================================
--- libpurple/ft.c	807bdd027a1c6a7c67f680a29d4147981503b588
+++ libpurple/ft.c	6d6ca9832846fcf8df42a0c89f8e644bcf60bf02
@@ -69,6 +69,30 @@ purple_xfer_priv_data_destroy(gpointer d
 	g_free(priv);
 }
 
+static const gchar *
+purple_xfer_status_type_to_string(PurpleXferStatusType type)
+{
+	static const struct {
+		PurpleXferStatusType type;
+		const char *name;
+	} type_names[] = {
+		{ PURPLE_XFER_STATUS_UNKNOWN, "unknown" },
+		{ PURPLE_XFER_STATUS_NOT_STARTED, "not started" },
+		{ PURPLE_XFER_STATUS_ACCEPTED, "accepted" },
+		{ PURPLE_XFER_STATUS_STARTED, "started" },
+		{ PURPLE_XFER_STATUS_DONE, "done" },
+		{ PURPLE_XFER_STATUS_CANCEL_LOCAL, "cancelled locally" },
+		{ PURPLE_XFER_STATUS_CANCEL_REMOTE, "cancelled remotely" }
+	};
+	int i;
+
+	for (i = 0; i < G_N_ELEMENTS(type_names); ++i)
+		if (type_names[i].type == type)
+			return type_names[i].name;
+
+	return "invalid state";
+}
+
 GList *
 purple_xfers_get_all()
 {
@@ -180,6 +204,11 @@ purple_xfer_set_status(PurpleXfer *xfer,
 {
 	g_return_if_fail(xfer != NULL);
 
+	if (purple_debug_is_verbose())
+		purple_debug_info("xfer", "Changing status of xfer %p from %s to %s\n",
+				xfer, purple_xfer_status_type_to_string(xfer->status),
+				purple_xfer_status_type_to_string(status));
+
 	if (xfer->status == status)
 		return;
 
@@ -539,6 +568,8 @@ purple_xfer_request_accepted(PurpleXfer 
 	type = purple_xfer_get_type(xfer);
 	account = purple_xfer_get_account(xfer);
 
+	purple_debug_misc("xfer", "request accepted for %p\n", xfer); 
+
 	if (!filename && type == PURPLE_XFER_RECEIVE) {
 		xfer->status = PURPLE_XFER_STATUS_ACCEPTED;
 		xfer->ops.init(xfer);
@@ -616,6 +647,8 @@ purple_xfer_request_denied(PurpleXfer *x
 {
 	g_return_if_fail(xfer != NULL);
 
+	purple_debug_misc("xfer", "xfer %p denied\n", xfer);
+
 	if (xfer->ops.request_denied != NULL)
 		xfer->ops.request_denied(xfer);
 
@@ -1144,6 +1177,8 @@ transfer_cb(gpointer data, gint source, 
 
 			purple_input_remove(xfer->watcher);
 			xfer->watcher = 0;
+
+			purple_debug_misc("xfer", "prpl is ready on ft %p, waiting for UI\n", xfer);
 			return;
 		}
 	}
@@ -1206,9 +1241,13 @@ purple_xfer_ui_ready(PurpleXfer *xfer)
 	priv = g_hash_table_lookup(xfers_data, xfer);
 	priv->ready |= PURPLE_XFER_READY_UI;
 
-	if (0 == (priv->ready & PURPLE_XFER_READY_PRPL))
+	if (0 == (priv->ready & PURPLE_XFER_READY_PRPL)) {
+		purple_debug_misc("xfer", "UI is ready on ft %p, waiting for prpl\n", xfer);
 		return;
+	}
 
+	purple_debug_misc("xfer", "UI (and prpl) ready on ft %p, so proceeding\n", xfer);
+
 	type = purple_xfer_get_type(xfer);
 	if (type == PURPLE_XFER_SEND)
 		cond = PURPLE_INPUT_WRITE;
@@ -1234,9 +1273,13 @@ purple_xfer_prpl_ready(PurpleXfer *xfer)
 	priv->ready |= PURPLE_XFER_READY_PRPL;
 
 	/* I don't think fwrite/fread are ever *not* ready */
-	if (xfer->dest_fp == NULL && 0 == (priv->ready & PURPLE_XFER_READY_UI))
+	if (xfer->dest_fp == NULL && 0 == (priv->ready & PURPLE_XFER_READY_UI)) {
+		purple_debug_misc("xfer", "prpl is ready on ft %p, waiting for UI\n", xfer);
 		return;
+	}
 
+	purple_debug_misc("xfer", "Prpl (and UI) ready on ft %p, so proceeding\n", xfer);
+
 	priv->ready = PURPLE_XFER_READY_NONE;
 
 	do_transfer(xfer);


More information about the Commits mailing list