Skip to content

Commit

Permalink
implimented wifi related following apis in dbus
Browse files Browse the repository at this point in the history
wifiConnect
wifiDisconnect
wifiScanRequest
getKnownSSIDs
addToKnownSSIDs
removeKnownSSID
  • Loading branch information
cmuhammedrafi committed Oct 11, 2024
1 parent bb42fa7 commit 71c5d08
Show file tree
Hide file tree
Showing 9 changed files with 1,467 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,4 @@ write_config()
write_config(PLUGINS LegacyPlugin_NetworkAPIs CLASSNAME Network LOCATOR lib${PLUGIN_LEGACY_DEPRECATED_NETWORK}.so)
write_config(PLUGINS LegacyPlugin_WiFiManagerAPIs CLASSNAME WiFiManager LOCATOR lib${PLUGIN_LEGACY_DEPRECATED_WIFI}.so)

include(Tests/raspberrypi/rpiTest.cmake)
68 changes: 68 additions & 0 deletions GnomeProxy/NetworkManagerDbusMgr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
*
* Copyright 2022 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.
**/

#include <glib.h>
#include <gio/gio.h>
#include <string>

#include "NetworkManagerDbusMgr.h"
#include "NetworkManagerLogger.h"

namespace WPEFramework
{
namespace Plugin
{

DbusConnectionManager::DbusConnectionManager() : connection(nullptr) {
NMLOG_INFO("DbusConnectionManager created");
}

DbusConnectionManager::~DbusConnectionManager() {
DeinitializeDbusConnection();
}

bool DbusConnectionManager::InitializeBusConnection(const std::string& busName) {
GError* error = nullptr;
connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &error);

if (!connection) {
NMLOG_ERROR("Failed to initialize D-Bus connection: %s ", error->message);
g_error_free(error);
return false;
}

NMLOG_INFO("D-Bus connection initialized successfully for bus: %s", busName.c_str());
return true;
}

void DbusConnectionManager::DeinitializeDbusConnection() {
if (connection) {
g_object_unref(connection);
connection = nullptr;
NMLOG_INFO("D-Bus connection deinitialized successfully");
}
}

GDBusConnection* DbusConnectionManager::getConnection() const {
return connection;
}

} // Plugin
} // WPEFramework

47 changes: 47 additions & 0 deletions GnomeProxy/NetworkManagerDbusMgr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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 <gio/gio.h>
#include <iostream>
#include <string>
#include <list>

/* include NetworkManager.h for the defines, but we don't link against libnm. */
#include <nm-dbus-interface.h>

namespace WPEFramework
{
namespace Plugin
{
class DbusConnectionManager {
public:
DbusConnectionManager();
~DbusConnectionManager();

bool InitializeBusConnection(const std::string& busName);
void DeinitializeDbusConnection();
GDBusConnection* getConnection() const;

private:
GDBusConnection* connection;
};

}
}
Loading

0 comments on commit 71c5d08

Please sign in to comment.