Skip to content

Commit

Permalink
gdbus evnet memmory leak fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cmuhammedrafi committed Dec 11, 2024
1 parent a5d5c01 commit c7996ab
Show file tree
Hide file tree
Showing 8 changed files with 249 additions and 179 deletions.
2 changes: 1 addition & 1 deletion NetworkManagerLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#endif

namespace NetworkManagerLogger {
static LogLevel gDefaultLogLevel = INFO_LEVEL;
static LogLevel gDefaultLogLevel = DEBUG_LEVEL;


#ifdef USE_RDK_LOGGER
Expand Down
58 changes: 50 additions & 8 deletions Tests/raspberrypi/NetworkManagerGdbusTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "NetworkManagerGdbusEvent.h"
#include "INetworkManager.h"
#include "NetworkManagerGdbusUtils.h"
#include "NetworkManagerImplementation.h"
#include <iostream>
#include <thread>
#include <chrono>
Expand All @@ -15,7 +16,46 @@ using namespace WPEFramework::Plugin;
using namespace WPEFramework::Exchange;
using namespace std;

void displayMenu() {
namespace WPEFramework
{
namespace Plugin
{

void NetworkManagerImplementation::ReportInterfaceStateChange(const Exchange::INetworkManager::InterfaceState state, const string interface)
{
NMLOG_INFO("calling 'ReportInterfaceStateChange' cb");
}
void NetworkManagerImplementation::ReportActiveInterfaceChange(const string prevActiveInterface, const string currentActiveinterface)
{
NMLOG_INFO("calling 'ReportActiveInterfaceChange' cb");
}
void NetworkManagerImplementation::ReportIPAddressChange(const string interface, const string ipversion, const string ipaddress, const Exchange::INetworkManager::IPStatus status)
{
NMLOG_INFO("calling 'ReportIPAddressChange' cb");
}
void NetworkManagerImplementation::ReportInternetStatusChange(const Exchange::INetworkManager::InternetStatus prevState, const Exchange::INetworkManager::InternetStatus currState)
{
NMLOG_INFO("calling 'ReportInternetStatusChange' cb");
}
void NetworkManagerImplementation::ReportAvailableSSIDs(JsonArray &arrayofWiFiScanResults)
{
NMLOG_INFO("calling 'ReportAvailableSSIDs' cb");
}
void NetworkManagerImplementation::ReportWiFiStateChange(const Exchange::INetworkManager::WiFiState state)
{
NMLOG_INFO("calling 'ReportWiFiStateChange' cb");
}
void NetworkManagerImplementation::ReportWiFiSignalStrengthChange(const string ssid, const string strength, const Exchange::INetworkManager::WiFiSignalQuality quality)
{
NMLOG_INFO("calling 'ReportWiFiSignalStrengthChange' cb");
}

NetworkManagerImplementation* _instance = nullptr;
}
}

void displayMenu()
{
std::cout << "\n--- Network Manager API Test Menu ---" << std::endl;
std::cout << "1. Get Known SSIDs" << std::endl;
std::cout << "2. Get Available SSIDs" << std::endl;
Expand All @@ -31,7 +71,8 @@ void displayMenu() {
std::cout << "-------------------------------------" << std::endl;
}

WPEFramework::Exchange::INetworkManager::WIFISecurityMode getSecurityType() {
WPEFramework::Exchange::INetworkManager::WIFISecurityMode getSecurityType()
{
int securityChoice;
std::cout << "Select Security Type:" << std::endl;
std::cout << "1. WPA/WPA2 PSK AES" << std::endl;
Expand All @@ -52,8 +93,8 @@ WPEFramework::Exchange::INetworkManager::WIFISecurityMode getSecurityType() {
}
}


void printSSIDs(const std::list<std::string>& ssids) {
void printSSIDs(const std::list<std::string>& ssids)
{
if (ssids.empty()) {
std::cout << "No SSIDs found" << std::endl;
} else {
Expand All @@ -64,13 +105,14 @@ void printSSIDs(const std::list<std::string>& ssids) {
}
}

int main() {

DbusMgr test;

int main()
{

NetworkManagerClient* nmClient = NetworkManagerClient::getInstance();
NetworkManagerEvents* nmEvents = NetworkManagerEvents::getInstance();
int choice = -1;

while (choice != 0) {
displayMenu();
std::cout << "Enter your choice: \n";
Expand Down
22 changes: 6 additions & 16 deletions gdbus/NetworkManagerGdbusClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,7 @@ namespace WPEFramework
if(ConnProxy == NULL)
return false;

settingsProxy = g_dbus_proxy_call_sync(ConnProxy,
"GetSettings",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
settingsProxy = g_dbus_proxy_call_sync(ConnProxy, "GetSettings", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
if (!settingsProxy) {
g_dbus_error_strip_remote_error(error);
NMLOG_ERROR("Failed to get connection settings: %s", error->message);
Expand Down Expand Up @@ -156,13 +150,7 @@ namespace WPEFramework
if(ConnProxy == NULL)
return false;

deleteVar = g_dbus_proxy_call_sync(ConnProxy,
"Delete",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
deleteVar = g_dbus_proxy_call_sync(ConnProxy, "Delete", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
if (!deleteVar) {
g_dbus_error_strip_remote_error(error);
NMLOG_ERROR("Failed to get connection settings: %s", error->message);
Expand Down Expand Up @@ -886,17 +874,19 @@ namespace WPEFramework
wProxy = m_dbus.getNetworkManagerDeviceProxy(devInfo.path.c_str());
if(wProxy == NULL)
return false;

else
g_dbus_proxy_call_sync(wProxy, "Disconnect", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
return true;
if (error) {
NMLOG_ERROR("Error calling Disconnect method: %s", error->message);
g_error_free(error);
g_object_unref(wProxy);
return false;
}
else
NMLOG_INFO("wifi disconnected success");
NMLOG_INFO("wifi disconnected success");

g_object_unref(wProxy);
return true;
}

Expand Down
Loading

0 comments on commit c7996ab

Please sign in to comment.