Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions plugin/gnome/NetworkManagerGnomeEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,11 @@ namespace WPEFramework
std::string ifname = nm_device_get_iface(device);
if(ifname == nmUtils::wlanIface()) {
GnomeNetworkManagerEvents::onInterfaceStateChangeCb(Exchange::INetworkManager::INTERFACE_ADDED, nmUtils::wlanIface());
NMLOG_INFO("WIFI device added: %s", ifname.c_str());
}
else if(ifname == nmUtils::ethIface()) {
GnomeNetworkManagerEvents::onInterfaceStateChangeCb(Exchange::INetworkManager::INTERFACE_ADDED, nmUtils::ethIface());
NMLOG_INFO("ETHERNET device added: %s", ifname.c_str());
}

/* ip events added only for eth0 and wlan0 */
Expand Down Expand Up @@ -376,10 +378,12 @@ namespace WPEFramework
if(ifname == nmUtils::wlanIface()) {
GnomeNetworkManagerEvents::onInterfaceStateChangeCb(Exchange::INetworkManager::INTERFACE_REMOVED, nmUtils::wlanIface());
g_signal_handlers_disconnect_by_func(device, (gpointer)GnomeNetworkManagerEvents::deviceStateChangeCb, nmEvents);
NMLOG_INFO("WIFI device removed: %s", ifname.c_str());
}
else if(ifname == nmUtils::ethIface()) {
GnomeNetworkManagerEvents::onInterfaceStateChangeCb(Exchange::INetworkManager::INTERFACE_REMOVED, nmUtils::ethIface());
g_signal_handlers_disconnect_by_func(device, (gpointer)GnomeNetworkManagerEvents::deviceStateChangeCb, nmEvents);
NMLOG_INFO("ETHERNET device removed: %s", ifname.c_str());
}
}

Expand Down Expand Up @@ -445,35 +449,41 @@ namespace WPEFramework
if((ifname == nmUtils::ethIface()) || (ifname == nmUtils::wlanIface()))
{
NMDeviceState devState = nm_device_get_state(device);
// NM_DEVICE_STATE_UNAVAILABLE can occur for an Ethernet interface when it is disconnected (e.g., no cable connected).
bool isDeviceEnabled = devState >= NM_DEVICE_STATE_UNAVAILABLE && devState <= NM_DEVICE_STATE_ACTIVATED;
if(!isDeviceEnabled)

if(devState > NM_DEVICE_STATE_DISCONNECTED && devState <= NM_DEVICE_STATE_ACTIVATED)
{
NMLOG_WARNING("device %s is not enabled, So no event monitor", ifname.c_str());
continue;
// posting device state change event if interface already connected
GnomeNetworkManagerEvents::deviceStateChangeCb(device, nullptr, nullptr);
}
GnomeNetworkManagerEvents::deviceStateChangeCb(device, nullptr, nullptr); //posting event if interface already connected

/* Register device state change event */
g_signal_connect(device, "notify::" NM_DEVICE_STATE, G_CALLBACK(GnomeNetworkManagerEvents::deviceStateChangeCb), nmEvents);
if(NM_IS_DEVICE_WIFI(device)) {
nmEvents->wifiDevice = NM_DEVICE_WIFI(device);
g_signal_connect(nmEvents->wifiDevice, "notify::" NM_DEVICE_WIFI_LAST_SCAN, G_CALLBACK(GnomeNetworkManagerEvents::onAvailableSSIDsCb), nmEvents);
}

NMIPConfig *ipv4Config = nm_device_get_ip4_config(device);
NMIPConfig *ipv6Config = nm_device_get_ip6_config(device);
if (ipv4Config) {
ip4ChangedCb(ipv4Config, NULL, device); // posting event if interface already connected
g_signal_connect(ipv4Config, "notify::addresses", G_CALLBACK(ip4ChangedCb), device);
}
else
NMLOG_WARNING("IPv4 config is null for device: %s, No IPv4 monitor", ifname.c_str());

if (ipv6Config) {
ip6ChangedCb(ipv6Config, NULL, device);
g_signal_connect(ipv6Config, "notify::addresses", G_CALLBACK(ip6ChangedCb), device);
}

if(NM_IS_DEVICE_WIFI(device)) {
nmEvents->wifiDevice = NM_DEVICE_WIFI(device);
g_signal_connect(nmEvents->wifiDevice, "notify::" NM_DEVICE_WIFI_LAST_SCAN, G_CALLBACK(GnomeNetworkManagerEvents::onAvailableSSIDsCb), nmEvents);
}
else
NMLOG_WARNING("IPv6 config is null for device: %s, No IPv6 monitor", ifname.c_str());
}
else
NMLOG_DEBUG("device type not eth/wifi %s", ifname.c_str());
}
else
NMLOG_WARNING("device error null");
}

NMLOG_INFO("registered all networkmnager dbus events");
Expand Down
Loading