2008-10-26 Dan Williams <dcbw@redhat.com>
authorDan Williams <dcbw@redhat.com>
Sun, 26 Oct 2008 16:32:29 +0000 (16:32 +0000)
committerDan Williams <dcbw@redhat.com>
Sun, 26 Oct 2008 16:32:29 +0000 (16:32 +0000)
* src/supplicant-manager/nm-supplicant-interface.c
  src/supplicant-manager/nm-supplicant-interface.h
  src/supplicant-manager/nm-supplicant-manager.c
  src/supplicant-manager/nm-supplicant-manager.h
- Add state-to-string conversion functions

* src/nm-device-wifi.c
  src/nm-device-ethernet.c
- Normalize state info logging and use strings instead of numbers

git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4213 4912f4e0-d625-0410-9fb7-b9a5a253dbdc

ChangeLog
src/nm-device-ethernet.c
src/nm-device-wifi.c
src/supplicant-manager/nm-supplicant-interface.c
src/supplicant-manager/nm-supplicant-interface.h
src/supplicant-manager/nm-supplicant-manager.c
src/supplicant-manager/nm-supplicant-manager.h

index 0bd9920..88ae26d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-10-26  Dan Williams  <dcbw@redhat.com>
+
+       * src/supplicant-manager/nm-supplicant-interface.c
+         src/supplicant-manager/nm-supplicant-interface.h
+         src/supplicant-manager/nm-supplicant-manager.c
+         src/supplicant-manager/nm-supplicant-manager.h
+               - Add state-to-string conversion functions
+
+       * src/nm-device-wifi.c
+         src/nm-device-ethernet.c
+               - Normalize state info logging and use strings instead of numbers
+
 2008-10-26  Dan Williams  <dcbw@redhat.com>
 
        * src/NetworkManagerPolicy.c
index db25dc1..a3350e2 100644 (file)
@@ -858,10 +858,10 @@ supplicant_mgr_state_cb (NMSupplicantInterface * iface,
                          guint32 old_state,
                          gpointer user_data)
 {
-       nm_info ("(%s) supplicant manager is now in state %d (from %d).",
-                   nm_device_get_iface (NM_DEVICE (user_data)),
-                   new_state,
-                   old_state);
+       nm_info ("(%s): supplicant manager state:  %s -> %s",
+                nm_device_get_iface (NM_DEVICE (user_data)),
+                nm_supplicant_manager_state_to_string (old_state),
+                nm_supplicant_manager_state_to_string (new_state));
 
        schedule_state_handler (NM_DEVICE_ETHERNET (user_data),
                                supplicant_mgr_state_cb_handler,
@@ -943,10 +943,10 @@ supplicant_iface_state_cb (NMSupplicantInterface * iface,
                            gpointer user_data)
 {
 
-       nm_info ("(%s) supplicant interface is now in state %d (from %d).",
-                   nm_device_get_iface (NM_DEVICE (user_data)),
-                   new_state,
-                   old_state);
+       nm_info ("(%s): supplicant interface state:  %s -> %s",
+                nm_device_get_iface (NM_DEVICE (user_data)),
+                nm_supplicant_interface_state_to_string (old_state),
+                nm_supplicant_interface_state_to_string (new_state));
 
        schedule_state_handler (NM_DEVICE_ETHERNET (user_data),
                                supplicant_iface_state_cb_handler,
@@ -993,8 +993,10 @@ supplicant_iface_connection_state_cb (NMSupplicantInterface * iface,
                                       guint32 old_state,
                                       gpointer user_data)
 {
-       nm_info ("(%s) Supplicant interface state change: %d -> %d",
-                nm_device_get_iface (NM_DEVICE (user_data)), old_state, new_state);
+       nm_info ("(%s) supplicant connection state:  %s -> %s",
+                nm_device_get_iface (NM_DEVICE (user_data)),
+                nm_supplicant_interface_connection_state_to_string (old_state),
+                nm_supplicant_interface_connection_state_to_string (new_state));
 
        schedule_state_handler (NM_DEVICE_ETHERNET (user_data),
                                supplicant_iface_connection_state_cb_handler,
index b66dcd1..7cabe0f 100644 (file)
@@ -2191,10 +2191,10 @@ supplicant_iface_state_cb_handler (gpointer user_data)
        self = task->self;
        priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
 
-       nm_info ("(%s): supplicant interface state change: %d -> %d.",
-             nm_device_get_iface (NM_DEVICE (self)),
-             task->old_state,
-             task->new_state);
+       nm_info ("(%s): supplicant interface state:  %s -> %s",
+                nm_device_get_iface (NM_DEVICE (self)),
+                nm_supplicant_interface_state_to_string (task->old_state),
+                nm_supplicant_interface_state_to_string (task->new_state));
 
        if (task->new_state == NM_SUPPLICANT_INTERFACE_STATE_READY) {
                priv->scan_interval = SCAN_INTERVAL_MIN;
@@ -2243,8 +2243,10 @@ supplicant_iface_connection_state_cb_handler (gpointer user_data)
                goto out;
        }
 
-       nm_info ("(%s): supplicant connection state change: %d -> %d",
-                nm_device_get_iface (dev), task->old_state, task->new_state);
+       nm_info ("(%s): supplicant connection state:  %s -> %s",
+                nm_device_get_iface (dev),
+                nm_supplicant_interface_connection_state_to_string (task->old_state),
+                nm_supplicant_interface_connection_state_to_string (task->new_state));
 
        priv->scanning = (task->new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_SCANNING);
 
@@ -2315,9 +2317,10 @@ supplicant_mgr_state_cb_handler (gpointer user_data)
        priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
        dev = NM_DEVICE (self);
 
-       nm_info ("(%s): supplicant manager is now in state %d (from %d).",
-             nm_device_get_iface (NM_DEVICE (self)),
-             task->new_state, task->old_state);
+       nm_info ("(%s): supplicant manager state:  %s -> %s",
+                nm_device_get_iface (NM_DEVICE (self)),
+                nm_supplicant_manager_state_to_string (task->old_state),
+                nm_supplicant_manager_state_to_string (task->new_state));
 
        /* If the supplicant went away, release the supplicant interface */
        if (task->new_state == NM_SUPPLICANT_MANAGER_STATE_DOWN) {
index 4a62120..37bfe60 100644 (file)
@@ -1250,3 +1250,48 @@ nm_supplicant_interface_get_connection_state (NMSupplicantInterface * self)
 
        return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->con_state;
 }
+
+const char *
+nm_supplicant_interface_state_to_string (guint32 state)
+{
+       switch (state) {
+       case NM_SUPPLICANT_INTERFACE_STATE_INIT:
+               return "init";
+       case NM_SUPPLICANT_INTERFACE_STATE_STARTING:
+               return "starting";
+       case NM_SUPPLICANT_INTERFACE_STATE_READY:
+               return "ready";
+       case NM_SUPPLICANT_INTERFACE_STATE_DOWN:
+               return "down";
+       default:
+               break;
+       }
+       return "unknown";
+}
+
+const char *
+nm_supplicant_interface_connection_state_to_string (guint32 state)
+{
+       switch (state) {
+       case NM_SUPPLICANT_INTERFACE_CON_STATE_DISCONNECTED:
+               return "disconnected";
+       case NM_SUPPLICANT_INTERFACE_CON_STATE_INACTIVE:
+               return "inactive";
+       case NM_SUPPLICANT_INTERFACE_CON_STATE_SCANNING:
+               return "scanning";
+       case NM_SUPPLICANT_INTERFACE_CON_STATE_ASSOCIATING:
+               return "associating";
+       case NM_SUPPLICANT_INTERFACE_CON_STATE_ASSOCIATED:
+               return "associated";
+       case NM_SUPPLICANT_INTERFACE_CON_STATE_4WAY_HANDSHAKE:
+               return "4-way handshake";
+       case NM_SUPPLICANT_INTERFACE_CON_STATE_GROUP_HANDSHAKE:
+               return "group handshake";
+       case NM_SUPPLICANT_INTERFACE_CON_STATE_COMPLETED:
+               return "completed";
+       default:
+               break;
+       }
+       return "unknown";
+}
+
index f68c238..7a8a5f2 100644 (file)
@@ -124,6 +124,10 @@ guint32 nm_supplicant_interface_get_state (NMSupplicantInterface * self);
 
 guint32 nm_supplicant_interface_get_connection_state (NMSupplicantInterface * self);
 
+const char *nm_supplicant_interface_state_to_string (guint32 state);
+
+const char *nm_supplicant_interface_connection_state_to_string (guint32 state);
+
 G_END_DECLS
 
 #endif /* NM_SUPPLICANT_INTERFACE_H */
index da4e108..8687be4 100644 (file)
@@ -321,3 +321,19 @@ nm_supplicant_manager_release_iface (NMSupplicantManager * self,
                }
        }
 }
+
+const char *
+nm_supplicant_manager_state_to_string (guint32 state)
+{
+       switch (state) {
+       case NM_SUPPLICANT_MANAGER_STATE_DOWN:
+               return "down";
+       case NM_SUPPLICANT_MANAGER_STATE_IDLE:
+               return "idle";
+       default:
+               break;
+       }
+       return "unknown";
+}
+
+
index fdff740..3ed7c6e 100644 (file)
@@ -83,4 +83,6 @@ NMSupplicantInterface * nm_supplicant_manager_get_iface (NMSupplicantManager * m
 void nm_supplicant_manager_release_iface (NMSupplicantManager * mgr,
                                           NMSupplicantInterface * iface);
 
+const char *nm_supplicant_manager_state_to_string (guint32 state);
+
 #endif /* NM_SUPPLICANT_MANAGER_H */