From 61e8c04b5d2a50c0195d6546d2c8ea5d9ace1111 Mon Sep 17 00:00:00 2001 From: cmuhammedrafi Date: Fri, 29 Nov 2024 11:10:13 +0000 Subject: [PATCH] ap to json empty string retun --- NetworkManagerGnomeEvents.cpp | 4 ++-- NetworkManagerGnomeUtils.cpp | 10 ++++------ NetworkManagerGnomeUtils.h | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/NetworkManagerGnomeEvents.cpp b/NetworkManagerGnomeEvents.cpp index 56e94be4..c5c5c723 100644 --- a/NetworkManagerGnomeEvents.cpp +++ b/NetworkManagerGnomeEvents.cpp @@ -624,8 +624,8 @@ namespace WPEFramework { JsonObject ssidObj; ap = static_cast(accessPoints->pdata[i]); - ssidObj = nmUtils::apToJsonObject(ap); - ssidList.Add(ssidObj); + if(nmUtils::apToJsonObject(ap, ssidObj)) + ssidList.Add(ssidObj); } ssidList.ToString(ssidListJson); diff --git a/NetworkManagerGnomeUtils.cpp b/NetworkManagerGnomeUtils.cpp index 062236a1..6b10ec2a 100644 --- a/NetworkManagerGnomeUtils.cpp +++ b/NetworkManagerGnomeUtils.cpp @@ -198,17 +198,15 @@ namespace WPEFramework return freq; } - JsonObject nmUtils::apToJsonObject(NMAccessPoint *ap) + bool nmUtils::apToJsonObject(NMAccessPoint *ap, JsonObject& ssidObj) { - GError *error = NULL; GBytes *ssid = NULL; int strength = 0; std::string freq; int security; guint32 flags, wpaFlags, rsnFlags, apFreq; - JsonObject ssidObj; if(ap == nullptr) - return ssidObj; + return false; ssid = nm_access_point_get_ssid(ap); if (ssid) { @@ -227,11 +225,11 @@ namespace WPEFramework ssidObj["security"] = security; ssidObj["strength"] = nmUtils::convertPercentageToSignalStrengtStr(strength); ssidObj["frequency"] = freq; + return true; } // else // NMLOG_DEBUG("hidden ssid found, bssid: %s", nm_access_point_get_bssid(ap)); - - return ssidObj; + return false; } void nmUtils::printActiveSSIDsOnly(NMDeviceWifi *wifiDevice) diff --git a/NetworkManagerGnomeUtils.h b/NetworkManagerGnomeUtils.h index f55e808f..d305fc7f 100644 --- a/NetworkManagerGnomeUtils.h +++ b/NetworkManagerGnomeUtils.h @@ -41,7 +41,7 @@ namespace WPEFramework static uint8_t wifiSecurityModeFromAp(guint32 flags, guint32 wpaFlags, guint32 rsnFlags); static std::string wifiFrequencyFromAp(guint32 apFreq); static std::string getSecurityModeString(guint32 flags, guint32 wpaFlags, guint32 rsnFlags); - static JsonObject apToJsonObject(NMAccessPoint *ap); + static bool apToJsonObject(NMAccessPoint *ap, JsonObject& ssidObj); static void printActiveSSIDsOnly(NMDeviceWifi *wifiDevice); static NMDeviceState ifaceState(NMClient *client, const char* interface); };