Skip to content

Commit

Permalink
DELIA-65998 Implement GNOME NetworkManager plugin events (#5610)
Browse files Browse the repository at this point in the history
* Gnome event monitor added

* updated onSignalStrength Change Cb

* GnomeEvent class move to singleton class

---------

Co-authored-by: Karunakaran A <[email protected]>
  • Loading branch information
cmuhammedrafi and karuna2git committed Aug 19, 2024
1 parent f72ba11 commit 7f83b94
Show file tree
Hide file tree
Showing 13 changed files with 1,493 additions and 646 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/${STORAGE
# Build the implementation that runs out-of-process behind a COM-RPC interface

if(ENABLE_GNOME_NETWORKMANAGER)
target_sources(${MODULE_NAME} PRIVATE NetworkManagerGnomeProxy.cpp NetworkManagerGnomeWIFI.cpp)
target_sources(${MODULE_NAME} PRIVATE NetworkManagerGnomeProxy.cpp
NetworkManagerGnomeWIFI.cpp
NetworkManagerGnomeEvents.cpp
NetworkManagerGnomeUtils.cpp )
target_include_directories(${MODULE_NAME} PRIVATE ${GLIB_INCLUDE_DIRS} ${LIBNM_INCLUDE_DIRS})
target_link_libraries(${MODULE_NAME} PRIVATE ${LIBNM_LIBRARIES})
else()
Expand All @@ -102,7 +105,6 @@ endif()
target_link_libraries(${MODULE_NAME} PRIVATE ${CURL_LIBRARIES})
target_include_directories(${MODULE_NAME} PRIVATE ${CURL_INCLUDE_DIRS})


add_library(${PLUGIN_LEGACY_DEPRECATED_NETWORK} SHARED
LegacyPlugin_NetworkAPIs.cpp
NetworkManagerLogger.cpp
Expand Down
620 changes: 620 additions & 0 deletions NetworkManagerGnomeEvents.cpp

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions NetworkManagerGnomeEvents.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once
#include <NetworkManager.h>
#include <libnm/NetworkManager.h>
#include <string.h>
#include <iostream>
#include <atomic>

namespace WPEFramework
{
namespace Plugin
{

typedef struct {
NMClient *client;
GMainLoop *loop;
NMDevice *device;
NMDeviceWifi *wifiDevice;
NMActiveConnection *activeConn;
std::string ifnameWlan0;
std::string ifnameEth0;
} NMEvents;

class GnomeNetworkManagerEvents
{

public:
static void onInterfaceStateChangeCb(uint8_t newState, std::string iface); // ReportInterfaceStateChangedEvent
static void onAddressChangeCb(std::string iface, std::string ipAddress, bool acqired, bool isIPv6); // ReportIPAddressChangedEvent
static void onActiveInterfaceChangeCb(std::string newInterface); // ReportActiveInterfaceChangedEvent
static void onAvailableSSIDsCb(NMDeviceWifi *wifiDevice, GParamSpec *pspec, gpointer userData); // ReportAvailableSSIDsEvent
static void onWIFIStateChanged(uint8_t state); // ReportWiFiStateChangedEvent

public:
static GnomeNetworkManagerEvents* getInstance();
bool startNetworkMangerEventMonitor();
void stopNetworkMangerEventMonitor();
void setwifiScanOptions(bool doScan, bool enableLogs = false);

private:
static void* networkMangerEventMonitor(void *arg);
GnomeNetworkManagerEvents();
~GnomeNetworkManagerEvents();
std::atomic<bool>isEventThrdActive = {false};
std::atomic<bool>stopWifiScan = {false};
std::atomic<bool>debugLogs = {false};
NMEvents nmEvents;
GThread *eventThrdID;
};

} // Plugin
} // WPEFramework
Loading

0 comments on commit 7f83b94

Please sign in to comment.