Skip to content

Commit

Permalink
getavailable ssid added
Browse files Browse the repository at this point in the history
  • Loading branch information
cmuhammedrafi committed Nov 1, 2024
1 parent 407c287 commit afe84da
Showing 1 changed file with 38 additions and 29 deletions.
67 changes: 38 additions & 29 deletions NetworkManagerGnomeProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Exchange::INetworkManager::InterfaceDetails> 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<GPtrArray *>(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<Exchange::INetworkManager::IInterfaceDetailsIterator>;
interfacesItr = Core::Service<Implementation>::Create<Exchange::INetworkManager::IInterfaceDetailsIterator>(interfaceList);
rc = Core::ERROR_NONE;
return rc;
}

Expand Down

0 comments on commit afe84da

Please sign in to comment.