[gnome-bluetooth/gnome-2-30] Better debug for killswitch code



commit d9efff3c94b12ed42d560f92c92038ee879888bf
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Jun 18 15:23:41 2010 +0100

    Better debug for killswitch code
    
    Print out strings, rather than indices that we'd need to
    look up every time.

 lib/bluetooth-killswitch.c |   29 ++++++++++++++++++++++++-----
 1 files changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/lib/bluetooth-killswitch.c b/lib/bluetooth-killswitch.c
index fa95248..5825878 100644
--- a/lib/bluetooth-killswitch.c
+++ b/lib/bluetooth-killswitch.c
@@ -89,6 +89,23 @@ event_to_state (guint soft, guint hard)
 		return KILLSWITCH_STATE_UNBLOCKED;
 }
 
+static const char *
+state_to_string (KillswitchState state)
+{
+	switch (state) {
+	case KILLSWITCH_STATE_NO_ADAPTER:
+		return "KILLSWITCH_STATE_NO_ADAPTER";
+	case KILLSWITCH_STATE_SOFT_BLOCKED:
+		return "KILLSWITCH_STATE_SOFT_BLOCKED";
+	case KILLSWITCH_STATE_UNBLOCKED:
+		return "KILLSWITCH_STATE_UNBLOCKED";
+	case KILLSWITCH_STATE_HARD_BLOCKED:
+		return "KILLSWITCH_STATE_HARD_BLOCKED";
+	default:
+		g_assert_not_reached ();
+	}
+}
+
 static void
 update_killswitch (BluetoothKillswitch *killswitch,
 		   guint index, guint soft, guint hard)
@@ -111,7 +128,9 @@ update_killswitch (BluetoothKillswitch *killswitch,
 	}
 
 	if (changed != FALSE) {
-		g_message ("updating killswitch status %d", index);
+		g_message ("updating killswitch status %d to %s",
+			   index,
+			   state_to_string (bluetooth_killswitch_get_state (killswitch)));
 		g_signal_emit (G_OBJECT (killswitch),
 			       signals[STATE_CHANGED],
 			       0, bluetooth_killswitch_get_state (killswitch));
@@ -161,8 +180,8 @@ bluetooth_killswitch_get_state (BluetoothKillswitch *killswitch)
 	for (l = priv->killswitches ; l ; l = l->next) {
 		BluetoothIndKillswitch *ind = l->data;
 
-		g_message ("killswitch %d is %d",
-			   ind->index, ind->state);
+		g_message ("killswitch %d is %s",
+			   ind->index, state_to_string (ind->state));
 
 		if (ind->state == KILLSWITCH_STATE_HARD_BLOCKED) {
 			state = KILLSWITCH_STATE_HARD_BLOCKED;
@@ -177,7 +196,7 @@ bluetooth_killswitch_get_state (BluetoothKillswitch *killswitch)
 		state = ind->state;
 	}
 
-	g_message ("killswitches state %d", state);
+	g_message ("killswitches state %s", state_to_string (state));
 
 	return state;
 }
@@ -222,7 +241,7 @@ add_killswitch (BluetoothKillswitch *killswitch,
 	BluetoothKillswitchPrivate *priv = BLUETOOTH_KILLSWITCH_GET_PRIVATE (killswitch);
 	BluetoothIndKillswitch *ind;
 
-	g_message ("adding killswitch idx %d state %d", index, state);
+	g_message ("adding killswitch idx %d state %s", index, state_to_string (state));
 	ind = g_new0 (BluetoothIndKillswitch, 1);
 	ind->index = index;
 	ind->state = state;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]