Skip to content

Commit

Permalink
rearrange and update proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
cmuhammedrafi committed Oct 24, 2024
1 parent 03e8c7c commit 75fb81b
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 9 deletions.
29 changes: 20 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,23 @@ set_target_properties(${MODULE_NAME} PROPERTIES


if(ENABLE_GNOME_NETWORKMANAGER)
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})
if(ENABLE_GNOME_LIBNM_PROXY)
target_sources(${MODULE_NAME} PRIVATE
libnm/NetworkManagerGnomeProxy.cpp
libnm/NetworkManagerGnomeWIFI.cpp
libnm/NetworkManagerGnomeEvents.cpp
libnm/NetworkManagerGnomeUtils.cpp )
target_include_directories(${MODULE_NAME} PRIVATE ${GLIB_INCLUDE_DIRS} ${LIBNM_INCLUDE_DIRS})
target_link_libraries(${MODULE_NAME} PRIVATE ${LIBNM_LIBRARIES})
else()
target_sources(${MODULE_NAME} PRIVATE
gdbus/NetworkManagerGnomeProxy.cpp
gdbus/NetworkManagerGdbusClient.cpp
gdbus/NetworkManagerGdbusMgr.cpp
gdbus/NetworkManagerGdbusUtils.cpp )
target_include_directories(${MODULE_NAME} PRIVATE ${GLIB_INCLUDE_DIRS} ${LIBNM_INCLUDE_DIRS} gdbus)
target_link_libraries(${MODULE_NAME} PRIVATE ${GLIB_LIBRARIES} ${GIO_LIBRARIES} uuid )
endif()
else()
target_sources(${MODULE_NAME} PRIVATE NetworkManagerRDKProxy.cpp)
target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS})
Expand Down Expand Up @@ -157,7 +168,7 @@ set_target_properties(${PLUGIN_LEGACY_DEPRECATED_WIFI} PROPERTIES
install(TARGETS ${PLUGIN_LEGACY_DEPRECATED_WIFI} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/${STORAGE_DIRECTORY}/plugins)

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)
# 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/NetworkManagerGdbusTest.cmake)
include(Tests/raspberrypi/NetworkManagerGdbusTest.cmake)
195 changes: 195 additions & 0 deletions gdbus/NetworkManagerGnomeProxy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
/**
* 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 "NetworkManagerImplementation.h"
#include "NetworkManagerGdbusClient.h"

using namespace WPEFramework;
using namespace WPEFramework::Plugin;
using namespace std;

namespace WPEFramework
{
namespace Plugin
{
NetworkManagerImplementation* _instance = nullptr;
NetworkManagerClient* gnomeDbusClient = nullptr;
void NetworkManagerInternalEventHandler(const char *owner, int eventId, void *data, size_t len)
{
return;
}

void NetworkManagerImplementation::platform_init()
{
::_instance = this;
gnomeDbusClient = NetworkManagerClient::getInstance();
}

uint32_t NetworkManagerImplementation::GetAvailableInterfaces (Exchange::INetworkManager::IInterfaceDetailsIterator*& interfacesItr/* @out */)
{
return Core::ERROR_NONE;
}

uint32_t NetworkManagerImplementation::GetPrimaryInterface (string& interface /* @out */)
{
return Core::ERROR_NONE;
}

uint32_t NetworkManagerImplementation::SetPrimaryInterface (const string& interface/* @in */)
{
return Core::ERROR_NONE;
}

uint32_t NetworkManagerImplementation::SetInterfaceState(const string& interface/* @in */, const bool& enabled /* @in */)
{
return Core::ERROR_NONE;
}

uint32_t NetworkManagerImplementation::GetInterfaceState(const string& interface/* @in */, bool& isEnabled /* @out */)
{
return Core::ERROR_NONE;
}

uint32_t NetworkManagerImplementation::GetIPSettings(const string& interface /* @in */, const string& ipversion /* @in */, IPAddressInfo& result /* @out */)
{
return Core::ERROR_NONE;
}

uint32_t NetworkManagerImplementation::SetIPSettings(const string& interface /* @in */, const string &ipversion /* @in */, const IPAddressInfo& address /* @in */)
{
return Core::ERROR_NONE;
}

uint32_t NetworkManagerImplementation::StartWiFiScan(const WiFiFrequency frequency /* @in */)
{
uint32_t rc = Core::ERROR_GENERAL;
if(gnomeDbusClient->startWifiScan())
rc = Core::ERROR_NONE;
else
NMLOG_ERROR("StartWiFiScan failed");
return rc;
}

uint32_t NetworkManagerImplementation::StopWiFiScan(void)
{
// TODO FIX
uint32_t rc = Core::ERROR_GENERAL;
if(gnomeDbusClient->stopWiFiScan())
rc = Core::ERROR_NONE;
else
NMLOG_ERROR("stopWiFiScan failed");
return rc;
}

uint32_t NetworkManagerImplementation::GetKnownSSIDs(IStringIterator*& ssids /* @out */)
{
uint32_t rc = Core::ERROR_GENERAL;
std::list<string> ssidList;
if(gnomeDbusClient->getKnownSSIDs(ssidList) && !ssidList.empty())
{
ssids = Core::Service<RPC::StringIterator>::Create<RPC::IStringIterator>(ssidList);
rc = Core::ERROR_NONE;
}
else
NMLOG_ERROR("GetKnownSSIDs failed");

return rc;
}

uint32_t NetworkManagerImplementation::AddToKnownSSIDs(const WiFiConnectTo& ssid /* @in */)
{
uint32_t rc = Core::ERROR_GENERAL;
if(gnomeDbusClient->addToKnownSSIDs(ssid))
rc = Core::ERROR_NONE;
else
NMLOG_ERROR("addToKnownSSIDs failed");
return rc;
}

uint32_t NetworkManagerImplementation::RemoveKnownSSID(const string& ssid /* @in */)
{
uint32_t rc = Core::ERROR_GENERAL;
if(gnomeDbusClient->removeKnownSSIDs(ssid))
rc = Core::ERROR_NONE;
else
NMLOG_ERROR("RemoveKnownSSID failed");
return rc;
}

uint32_t NetworkManagerImplementation::WiFiConnect(const WiFiConnectTo& ssid /* @in */)
{
uint32_t rc = Core::ERROR_GENERAL;
if(gnomeDbusClient->wifiConnect(ssid))
rc = Core::ERROR_NONE;
else
NMLOG_ERROR("WiFiConnect failed");
return rc;
}

uint32_t NetworkManagerImplementation::WiFiDisconnect(void)
{
uint32_t rc = Core::ERROR_GENERAL;
if(gnomeDbusClient->wifiDisconnect())
rc = Core::ERROR_NONE;
else
NMLOG_ERROR("WiFiDisconnect failed");
return rc;
}

uint32_t NetworkManagerImplementation::GetConnectedSSID(WiFiSSIDInfo& ssidInfo /* @out */)
{
uint32_t rc = Core::ERROR_GENERAL;
if(gnomeDbusClient->getConnectedSSID(ssidInfo))
rc = Core::ERROR_NONE;
else
NMLOG_ERROR("getConnectedSSID failed");
return rc;
}

uint32_t NetworkManagerImplementation::GetWiFiSignalStrength(string& ssid /* @out */, string& signalStrength /* @out */, WiFiSignalQuality& quality /* @out */)
{
uint32_t rc = Core::ERROR_GENERAL;
if(gnomeDbusClient->getWiFiSignalStrength(ssid, signalStrength, quality))
rc = Core::ERROR_NONE;
else
NMLOG_ERROR("GetWiFiSignalStrength failed");
return rc;
}

uint32_t NetworkManagerImplementation::GetWifiState(WiFiState &state)
{
uint32_t rc = Core::ERROR_GENERAL;
if(gnomeDbusClient->getWifiState(state))
rc = Core::ERROR_NONE;
else
NMLOG_ERROR("GetWifiState failed");
return rc;
}

uint32_t NetworkManagerImplementation::StartWPS(const WiFiWPS& method /* @in */, const string& wps_pin /* @in */)
{
return Core::ERROR_NONE;
}

uint32_t NetworkManagerImplementation::StopWPS(void)
{
return Core::ERROR_NONE;
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 75fb81b

Please sign in to comment.