Skip to content

Commit

Permalink
Replace enum to enum class
Browse files Browse the repository at this point in the history
  • Loading branch information
jlatusek committed Apr 9, 2024
1 parent f29ccbe commit 7ae0dd1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
36 changes: 18 additions & 18 deletions src/platform/Linux/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ bool ConnectivityManagerImpl::_IsWiFiStationConnected()

std::lock_guard<std::mutex> lock(mWpaSupplicantMutex);

if (mWpaSupplicant.state != GDBusWpaSupplicant::WPA_INTERFACE_CONNECTED)
if (mWpaSupplicant.state != GDBusWpaSupplicant::WpaState::WPA_INTERFACE_CONNECTED)
{
ChipLogProgress(DeviceLayer, "wpa_supplicant: _IsWiFiStationConnected: interface not connected");
return false;
Expand Down Expand Up @@ -238,7 +238,7 @@ bool ConnectivityManagerImpl::_IsWiFiStationProvisioned()

std::lock_guard<std::mutex> lock(mWpaSupplicantMutex);

if (mWpaSupplicant.state != GDBusWpaSupplicant::WPA_INTERFACE_CONNECTED)
if (mWpaSupplicant.state != GDBusWpaSupplicant::WpaState::WPA_INTERFACE_CONNECTED)
{
ChipLogProgress(DeviceLayer, "wpa_supplicant: _IsWiFiStationProvisioned: interface not connected");
return false;
Expand All @@ -257,7 +257,7 @@ void ConnectivityManagerImpl::_ClearWiFiStationProvision()
{
std::lock_guard<std::mutex> lock(mWpaSupplicantMutex);

if (mWpaSupplicant.state != GDBusWpaSupplicant::WPA_INTERFACE_CONNECTED)
if (mWpaSupplicant.state != GDBusWpaSupplicant::WpaState::WPA_INTERFACE_CONNECTED)
{
ChipLogProgress(DeviceLayer, "wpa_supplicant: _ClearWiFiStationProvision: interface not connected");
return;
Expand All @@ -280,8 +280,8 @@ bool ConnectivityManagerImpl::_CanStartWiFiScan()
{
std::lock_guard<std::mutex> lock(mWpaSupplicantMutex);

bool ret = mWpaSupplicant.state == GDBusWpaSupplicant::WPA_INTERFACE_CONNECTED &&
mWpaSupplicant.scanState == GDBusWpaSupplicant::WIFI_SCANNING_IDLE;
bool ret = mWpaSupplicant.state == GDBusWpaSupplicant::WpaState::WPA_INTERFACE_CONNECTED &&
mWpaSupplicant.scanState == GDBusWpaSupplicant::WpaScanning::WIFI_SCANNING_IDLE;

return ret;
}
Expand Down Expand Up @@ -507,7 +507,7 @@ void ConnectivityManagerImpl::_OnWpaInterfaceProxyReady(GObject * sourceObject,
if (iface != nullptr && err == nullptr)
{
mWpaSupplicant.iface = iface;
mWpaSupplicant.state = GDBusWpaSupplicant::WPA_INTERFACE_CONNECTED;
mWpaSupplicant.state = GDBusWpaSupplicant::WpaState::WPA_INTERFACE_CONNECTED;
ChipLogProgress(DeviceLayer, "wpa_supplicant: connected to wpa_supplicant interface proxy");

g_signal_connect(
Expand All @@ -527,7 +527,7 @@ void ConnectivityManagerImpl::_OnWpaInterfaceProxyReady(GObject * sourceObject,
ChipLogProgress(DeviceLayer, "wpa_supplicant: failed to create wpa_supplicant interface proxy %s: %s",
mWpaSupplicant.interfacePath, err ? err->message : "unknown error");

mWpaSupplicant.state = GDBusWpaSupplicant::WPA_NOT_CONNECTED;
mWpaSupplicant.state = GDBusWpaSupplicant::WpaState::WPA_NOT_CONNECTED;
}

// We need to stop auto scan or it will block our network scan.
Expand Down Expand Up @@ -584,7 +584,7 @@ void ConnectivityManagerImpl::_OnWpaInterfaceReady(GObject * sourceObject, GAsyn
&err.GetReceiver());
if (result)
{
mWpaSupplicant.state = GDBusWpaSupplicant::WPA_GOT_INTERFACE_PATH;
mWpaSupplicant.state = GDBusWpaSupplicant::WpaState::WPA_GOT_INTERFACE_PATH;
ChipLogProgress(DeviceLayer, "wpa_supplicant: WiFi interface: %s", mWpaSupplicant.interfacePath);

wpa_fi_w1_wpa_supplicant1_interface_proxy_new_for_bus(
Expand Down Expand Up @@ -623,7 +623,7 @@ void ConnectivityManagerImpl::_OnWpaInterfaceReady(GObject * sourceObject, GAsyn

if (result)
{
mWpaSupplicant.state = GDBusWpaSupplicant::WPA_GOT_INTERFACE_PATH;
mWpaSupplicant.state = GDBusWpaSupplicant::WpaState::WPA_GOT_INTERFACE_PATH;
ChipLogProgress(DeviceLayer, "wpa_supplicant: WiFi interface: %s", mWpaSupplicant.interfacePath);

Platform::CopyString(sWiFiIfName, CHIP_DEVICE_CONFIG_WIFI_STATION_IF_NAME);
Expand All @@ -649,7 +649,7 @@ void ConnectivityManagerImpl::_OnWpaInterfaceReady(GObject * sourceObject, GAsyn
ChipLogProgress(DeviceLayer, "wpa_supplicant: failed to create interface %s: %s",
CHIP_DEVICE_CONFIG_WIFI_STATION_IF_NAME, error ? error->message : "unknown error");

mWpaSupplicant.state = GDBusWpaSupplicant::WPA_NO_INTERFACE_PATH;
mWpaSupplicant.state = GDBusWpaSupplicant::WpaState::WPA_NO_INTERFACE_PATH;

if (mWpaSupplicant.interfacePath)
{
Expand All @@ -676,7 +676,7 @@ void ConnectivityManagerImpl::_OnWpaInterfaceAdded(WpaFiW1Wpa_supplicant1 * prox
mWpaSupplicant.interfacePath = const_cast<gchar *>(path);
if (mWpaSupplicant.interfacePath)
{
mWpaSupplicant.state = GDBusWpaSupplicant::WPA_GOT_INTERFACE_PATH;
mWpaSupplicant.state = GDBusWpaSupplicant::WpaState::WPA_GOT_INTERFACE_PATH;
ChipLogProgress(DeviceLayer, "wpa_supplicant: WiFi interface added: %s", mWpaSupplicant.interfacePath);

wpa_fi_w1_wpa_supplicant1_interface_proxy_new_for_bus(
Expand Down Expand Up @@ -710,7 +710,7 @@ void ConnectivityManagerImpl::_OnWpaInterfaceRemoved(WpaFiW1Wpa_supplicant1 * pr
{
ChipLogProgress(DeviceLayer, "wpa_supplicant: WiFi interface removed: %s", StringOrNullMarker(path));

mWpaSupplicant.state = GDBusWpaSupplicant::WPA_NO_INTERFACE_PATH;
mWpaSupplicant.state = GDBusWpaSupplicant::WpaState::WPA_NO_INTERFACE_PATH;

if (mWpaSupplicant.interfacePath)
{
Expand All @@ -730,7 +730,7 @@ void ConnectivityManagerImpl::_OnWpaInterfaceRemoved(WpaFiW1Wpa_supplicant1 * pr
mWpaSupplicant.bss = nullptr;
}

mWpaSupplicant.scanState = GDBusWpaSupplicant::WIFI_SCANNING_IDLE;
mWpaSupplicant.scanState = GDBusWpaSupplicant::WpaScanning::WIFI_SCANNING_IDLE;
}
}

Expand All @@ -747,7 +747,7 @@ void ConnectivityManagerImpl::_OnWpaProxyReady(GObject * sourceObject, GAsyncRes
mWpaSupplicant.proxy = wpa_fi_w1_wpa_supplicant1_proxy_new_for_bus_finish(res, &err.GetReceiver());
if (mWpaSupplicant.proxy != nullptr && err.get() == nullptr)
{
mWpaSupplicant.state = GDBusWpaSupplicant::WPA_CONNECTED;
mWpaSupplicant.state = GDBusWpaSupplicant::WpaState::WPA_CONNECTED;
ChipLogProgress(DeviceLayer, "wpa_supplicant: connected to wpa_supplicant proxy");

g_signal_connect(
Expand All @@ -773,7 +773,7 @@ void ConnectivityManagerImpl::_OnWpaProxyReady(GObject * sourceObject, GAsyncRes
{
ChipLogProgress(DeviceLayer, "wpa_supplicant: failed to create wpa_supplicant proxy %s",
err ? err->message : "unknown error");
mWpaSupplicant.state = GDBusWpaSupplicant::WPA_NOT_CONNECTED;
mWpaSupplicant.state = GDBusWpaSupplicant::WpaState::WPA_NOT_CONNECTED;
}
}

Expand All @@ -793,7 +793,7 @@ bool ConnectivityManagerImpl::IsWiFiManagementStarted()
{
std::lock_guard<std::mutex> lock(mWpaSupplicantMutex);

bool ret = mWpaSupplicant.state == GDBusWpaSupplicant::WPA_INTERFACE_CONNECTED;
bool ret = mWpaSupplicant.state == GDBusWpaSupplicant::WpaState::WPA_INTERFACE_CONNECTED;

return ret;
}
Expand Down Expand Up @@ -1322,7 +1322,7 @@ CHIP_ERROR ConnectivityManagerImpl::CommitConfig()

std::lock_guard<std::mutex> lock(mWpaSupplicantMutex);

if (mWpaSupplicant.state != GDBusWpaSupplicant::WPA_INTERFACE_CONNECTED)
if (mWpaSupplicant.state != GDBusWpaSupplicant::WpaState::WPA_INTERFACE_CONNECTED)
{
ChipLogError(DeviceLayer, "wpa_supplicant: CommitConfig: interface proxy not connected");
return CHIP_ERROR_INCORRECT_STATE;
Expand Down Expand Up @@ -1391,7 +1391,7 @@ CHIP_ERROR ConnectivityManagerImpl::GetWiFiSecurityType(SecurityTypeEnum & secur

std::lock_guard<std::mutex> lock(mWpaSupplicantMutex);

if (mWpaSupplicant.state != GDBusWpaSupplicant::WPA_INTERFACE_CONNECTED)
if (mWpaSupplicant.state != GDBusWpaSupplicant::WpaState::WPA_INTERFACE_CONNECTED)
{
ChipLogError(DeviceLayer, "wpa_supplicant: GetWiFiSecurityType: interface proxy not connected");
return CHIP_ERROR_INCORRECT_STATE;
Expand Down
8 changes: 4 additions & 4 deletions src/platform/Linux/ConnectivityManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace DeviceLayer {
#if CHIP_DEVICE_CONFIG_ENABLE_WPA
struct GDBusWpaSupplicant
{
enum WpaState
enum class WpaState
{
INIT,
WPA_CONNECTING,
Expand All @@ -77,14 +77,14 @@ struct GDBusWpaSupplicant
WPA_INTERFACE_CONNECTED,
};

enum WpaScanning
enum class WpaScanning
{
WIFI_SCANNING_IDLE,
WIFI_SCANNING,
};

WpaState state = INIT;
WpaScanning scanState = WIFI_SCANNING_IDLE;
WpaState state = WpaState::INIT;
WpaScanning scanState = WpaScanning::WIFI_SCANNING_IDLE;
WpaFiW1Wpa_supplicant1 * proxy = nullptr;
WpaFiW1Wpa_supplicant1Interface * iface = nullptr;
WpaFiW1Wpa_supplicant1BSS * bss = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Linux/bluez/ChipDeviceScanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ChipDeviceScanner : public BluezObjectManagerAdapterNotificationsDelegate
void OnDeviceRemoved(BluezDevice1 & device) override {}

private:
enum ChipDeviceScannerState
enum class ChipDeviceScannerState
{
SCANNER_UNINITIALIZED,
SCANNER_INITIALIZED,
Expand Down

0 comments on commit 7ae0dd1

Please sign in to comment.