Commit d3bb0daf authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #9911: simplify network manager state reporting

parent 497f205c
...@@ -30,20 +30,23 @@ ...@@ -30,20 +30,23 @@
#include "networkmanager.h" #include "networkmanager.h"
#include "../manager.h" #include "../manager.h"
#include "array_size.h"
#include "logger.h" #include "logger.h"
const std::string NetworkManager::statesString[] = {"unknown", "asleep", namespace {
"connecting", "connected", const char *stateAsString(uint32_t state)
"disconnected", "unknown",}; {
static const char * STATES[] = {"unknown", "asleep", "connecting",
"connected", "disconnected"};
std::string NetworkManager::stateAsString(const uint32_t &state) const size_t idx = state < ARRAYSIZE(STATES) ? state : 0;
{ return STATES[idx];
return statesString[state < 6 ? state : 5]; }
} }
void NetworkManager::StateChanged(const uint32_t &state) void NetworkManager::StateChanged(const uint32_t &state)
{ {
WARN("Network state changed: %s", stateAsString(state).c_str()); WARN("Network state changed: %s", stateAsString(state));
} }
void NetworkManager::PropertiesChanged(const std::map<std::string, ::DBus::Variant> &argin0) void NetworkManager::PropertiesChanged(const std::map<std::string, ::DBus::Variant> &argin0)
......
...@@ -45,7 +45,6 @@ class NetworkManager : public org::freedesktop::NetworkManager_proxy, ...@@ -45,7 +45,6 @@ class NetworkManager : public org::freedesktop::NetworkManager_proxy,
NetworkManager(DBus::Connection &, const DBus::Path &, const char*); NetworkManager(DBus::Connection &, const DBus::Path &, const char*);
void StateChanged(const uint32_t &state); void StateChanged(const uint32_t &state);
void PropertiesChanged(const std::map<std::string, ::DBus::Variant> &argin0); void PropertiesChanged(const std::map<std::string, ::DBus::Variant> &argin0);
std::string stateAsString(const uint32_t &state);
private: private:
enum NMState { enum NMState {
...@@ -55,8 +54,6 @@ class NetworkManager : public org::freedesktop::NetworkManager_proxy, ...@@ -55,8 +54,6 @@ class NetworkManager : public org::freedesktop::NetworkManager_proxy,
NM_STATE_CONNECTED, NM_STATE_CONNECTED,
NM_STATE_DISCONNECTED NM_STATE_DISCONNECTED
}; };
static const std::string statesString[];
}; };
#endif #endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment