From afe84da69267771d24c70f882b55a06edcff8d03 Mon Sep 17 00:00:00 2001 From: rafi Date: Fri, 1 Nov 2024 09:23:45 +0530 Subject: [PATCH] getavailable ssid added --- NetworkManagerGnomeProxy.cpp | 67 ++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/NetworkManagerGnomeProxy.cpp b/NetworkManagerGnomeProxy.cpp index ae477f55..e2724a9f 100644 --- a/NetworkManagerGnomeProxy.cpp +++ b/NetworkManagerGnomeProxy.cpp @@ -47,47 +47,56 @@ namespace WPEFramework uint32_t NetworkManagerImplementation::GetAvailableInterfaces (Exchange::INetworkManager::IInterfaceDetailsIterator*& interfacesItr/* @out */) { - uint32_t rc = Core::ERROR_RPC_CALL_FAILED; - NMDeviceType type; - NMDeviceState state; - NMDevice *device = NULL; + uint32_t rc = Core::ERROR_GENERAL; static std::vector interfaceList; + std::string wifiname; + std::string ethname; + + if(!nmUtils::GetInterfacesName(wifiname, ethname)) { + NMLOG_FATAL("GetInterface Name Error !"); + return Core::ERROR_GENERAL; + } + + GPtrArray *devices = const_cast(nm_client_get_devices(client)); + if (devices == NULL) { + NMLOG_ERROR("Failed to get device list."); + return Core::ERROR_GENERAL; + } - if(interfaceList.empty()) + for (guint j = 0; j < devices->len; j++) { - std::string interfaces[2]; - if(!nmUtils::GetInterfacesName(interfaces[0], interfaces[1])) + NMDevice *device = NM_DEVICE(devices->pdata[j]); + if(device != NULL) { - NMLOG_WARNING("GetInterface Name Error !"); - return Core::ERROR_GENERAL; - } - for (size_t i = 0; i < 2; i++) - { - if(!interfaces[i].empty()) + NMDeviceType type = nm_device_get_device_type(device); + if(NM_DEVICE_TYPE_WIFI == type || NM_DEVICE_TYPE_ETHERNET== type ) // only wifi and ethenet taking { - Exchange::INetworkManager::InterfaceDetails tmp; - device = nm_client_get_device_by_iface(client, interfaces[i].c_str()); - if (device) - { - if(i == 0) - tmp.m_type = string("WIFI"); - else - tmp.m_type = string("ETHERNET"); - tmp.m_name = interfaces[i].c_str(); - tmp.m_mac = nm_device_get_hw_address(device); - state = nm_device_get_state(device); - tmp.m_isEnabled = (state > NM_DEVICE_STATE_UNAVAILABLE) ? true : false; - tmp.m_isConnected = (state > NM_DEVICE_STATE_DISCONNECTED) ? true : false; - interfaceList.push_back(tmp); - //g_clear_object(&device); + NMDeviceState deviceState = NM_DEVICE_STATE_UNKNOWN; + Exchange::INetworkManager::InterfaceDetails interface; + if(NM_DEVICE_TYPE_WIFI == type) { + interface.m_type = string("WIFI"); + interface.m_name = wifiname; + } + + if(NM_DEVICE_TYPE_ETHERNET == type) { + interface.m_type = string("ETHERNET"); + interface.m_name = ethname; } + interface.m_mac = nm_device_get_hw_address(device); + deviceState = nm_device_get_state(device); + interface.m_isEnabled = (deviceState > NM_DEVICE_STATE_UNAVAILABLE) ? true : false; + if(deviceState > NM_DEVICE_STATE_DISCONNECTED && deviceState < NM_DEVICE_STATE_DEACTIVATING) + interface.m_isConnected = true; + else + interface.m_isConnected = false; + interfaceList.push_back(interface); + rc = Core::ERROR_NONE; } } } using Implementation = RPC::IteratorType; interfacesItr = Core::Service::Create(interfaceList); - rc = Core::ERROR_NONE; return rc; }