comparison libpurple/ft.c @ 29215:07ec4a569da1

ft: Add some useful debug logging.
author Paul Aurich <paul@darkrain42.org>
date Wed, 30 Dec 2009 23:00:54 +0000
parents 16dfa8df7dd1
children a41724547756 dcd52d2b1b97
comparison
equal deleted inserted replaced
29214:24b341ae63f7 29215:07ec4a569da1
67 PurpleXferPrivData *priv = data; 67 PurpleXferPrivData *priv = data;
68 68
69 g_free(priv); 69 g_free(priv);
70 } 70 }
71 71
72 static const gchar *
73 purple_xfer_status_type_to_string(PurpleXferStatusType type)
74 {
75 static const struct {
76 PurpleXferStatusType type;
77 const char *name;
78 } type_names[] = {
79 { PURPLE_XFER_STATUS_UNKNOWN, "unknown" },
80 { PURPLE_XFER_STATUS_NOT_STARTED, "not started" },
81 { PURPLE_XFER_STATUS_ACCEPTED, "accepted" },
82 { PURPLE_XFER_STATUS_STARTED, "started" },
83 { PURPLE_XFER_STATUS_DONE, "done" },
84 { PURPLE_XFER_STATUS_CANCEL_LOCAL, "cancelled locally" },
85 { PURPLE_XFER_STATUS_CANCEL_REMOTE, "cancelled remotely" }
86 };
87 int i;
88
89 for (i = 0; i < G_N_ELEMENTS(type_names); ++i)
90 if (type_names[i].type == type)
91 return type_names[i].name;
92
93 return "invalid state";
94 }
95
72 GList * 96 GList *
73 purple_xfers_get_all() 97 purple_xfers_get_all()
74 { 98 {
75 return xfers; 99 return xfers;
76 } 100 }
177 201
178 static void 202 static void
179 purple_xfer_set_status(PurpleXfer *xfer, PurpleXferStatusType status) 203 purple_xfer_set_status(PurpleXfer *xfer, PurpleXferStatusType status)
180 { 204 {
181 g_return_if_fail(xfer != NULL); 205 g_return_if_fail(xfer != NULL);
206
207 if (purple_debug_is_verbose())
208 purple_debug_info("xfer", "Changing status of xfer %p from %s to %s\n",
209 xfer, purple_xfer_status_type_to_string(xfer->status),
210 purple_xfer_status_type_to_string(status));
182 211
183 if (xfer->status == status) 212 if (xfer->status == status)
184 return; 213 return;
185 214
186 xfer->status = status; 215 xfer->status = status;
537 return; 566 return;
538 567
539 type = purple_xfer_get_type(xfer); 568 type = purple_xfer_get_type(xfer);
540 account = purple_xfer_get_account(xfer); 569 account = purple_xfer_get_account(xfer);
541 570
571 purple_debug_misc("xfer", "request accepted for %p\n", xfer);
572
542 if (!filename && type == PURPLE_XFER_RECEIVE) { 573 if (!filename && type == PURPLE_XFER_RECEIVE) {
543 xfer->status = PURPLE_XFER_STATUS_ACCEPTED; 574 xfer->status = PURPLE_XFER_STATUS_ACCEPTED;
544 xfer->ops.init(xfer); 575 xfer->ops.init(xfer);
545 return; 576 return;
546 } 577 }
613 644
614 void 645 void
615 purple_xfer_request_denied(PurpleXfer *xfer) 646 purple_xfer_request_denied(PurpleXfer *xfer)
616 { 647 {
617 g_return_if_fail(xfer != NULL); 648 g_return_if_fail(xfer != NULL);
649
650 purple_debug_misc("xfer", "xfer %p denied\n", xfer);
618 651
619 if (xfer->ops.request_denied != NULL) 652 if (xfer->ops.request_denied != NULL)
620 xfer->ops.request_denied(xfer); 653 xfer->ops.request_denied(xfer);
621 654
622 purple_xfer_unref(xfer); 655 purple_xfer_unref(xfer);
1142 if (0 == (priv->ready & PURPLE_XFER_READY_UI)) { 1175 if (0 == (priv->ready & PURPLE_XFER_READY_UI)) {
1143 priv->ready |= PURPLE_XFER_READY_PRPL; 1176 priv->ready |= PURPLE_XFER_READY_PRPL;
1144 1177
1145 purple_input_remove(xfer->watcher); 1178 purple_input_remove(xfer->watcher);
1146 xfer->watcher = 0; 1179 xfer->watcher = 0;
1180
1181 purple_debug_misc("xfer", "prpl is ready on ft %p, waiting for UI\n", xfer);
1147 return; 1182 return;
1148 } 1183 }
1149 } 1184 }
1150 1185
1151 do_transfer(xfer); 1186 do_transfer(xfer);
1204 g_return_if_fail(xfer != NULL); 1239 g_return_if_fail(xfer != NULL);
1205 1240
1206 priv = g_hash_table_lookup(xfers_data, xfer); 1241 priv = g_hash_table_lookup(xfers_data, xfer);
1207 priv->ready |= PURPLE_XFER_READY_UI; 1242 priv->ready |= PURPLE_XFER_READY_UI;
1208 1243
1209 if (0 == (priv->ready & PURPLE_XFER_READY_PRPL)) 1244 if (0 == (priv->ready & PURPLE_XFER_READY_PRPL)) {
1245 purple_debug_misc("xfer", "UI is ready on ft %p, waiting for prpl\n", xfer);
1210 return; 1246 return;
1247 }
1248
1249 purple_debug_misc("xfer", "UI (and prpl) ready on ft %p, so proceeding\n", xfer);
1211 1250
1212 type = purple_xfer_get_type(xfer); 1251 type = purple_xfer_get_type(xfer);
1213 if (type == PURPLE_XFER_SEND) 1252 if (type == PURPLE_XFER_SEND)
1214 cond = PURPLE_INPUT_WRITE; 1253 cond = PURPLE_INPUT_WRITE;
1215 else /* if (type == PURPLE_XFER_RECEIVE) */ 1254 else /* if (type == PURPLE_XFER_RECEIVE) */
1232 1271
1233 priv = g_hash_table_lookup(xfers_data, xfer); 1272 priv = g_hash_table_lookup(xfers_data, xfer);
1234 priv->ready |= PURPLE_XFER_READY_PRPL; 1273 priv->ready |= PURPLE_XFER_READY_PRPL;
1235 1274
1236 /* I don't think fwrite/fread are ever *not* ready */ 1275 /* I don't think fwrite/fread are ever *not* ready */
1237 if (xfer->dest_fp == NULL && 0 == (priv->ready & PURPLE_XFER_READY_UI)) 1276 if (xfer->dest_fp == NULL && 0 == (priv->ready & PURPLE_XFER_READY_UI)) {
1277 purple_debug_misc("xfer", "prpl is ready on ft %p, waiting for UI\n", xfer);
1238 return; 1278 return;
1279 }
1280
1281 purple_debug_misc("xfer", "Prpl (and UI) ready on ft %p, so proceeding\n", xfer);
1239 1282
1240 priv->ready = PURPLE_XFER_READY_NONE; 1283 priv->ready = PURPLE_XFER_READY_NONE;
1241 1284
1242 do_transfer(xfer); 1285 do_transfer(xfer);
1243 } 1286 }