| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2023-11-19 06:43:20 +01:00
										 |  |  | // Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
 | 
					
						
							|  |  |  | // written by Christian Daniel                                                   //
 | 
					
						
							|  |  |  | // Copyright (C) 2015-2020, 2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com>    //
 | 
					
						
							|  |  |  | // Copyright (C) 2016, 2018 Ziga S <ziga.svetina@gmail.com>                      //
 | 
					
						
							|  |  |  | // Copyright (C) 2019 Davide Gerhard <rainbow@irh.it>                            //
 | 
					
						
							|  |  |  | // Copyright (C) 2020-2022 Jon Beniston, M7RCE <jon@beniston.com>                //
 | 
					
						
							|  |  |  | // Copyright (C) 2020 Kacper Michajłow <kasper93@gmail.com>                      //
 | 
					
						
							|  |  |  | // Copyright (C) 2022 Jaroslav Škarvada <jskarvad@redhat.com>                    //
 | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // This program is free software; you can redistribute it and/or modify          //
 | 
					
						
							|  |  |  | // it under the terms of the GNU General Public License as published by          //
 | 
					
						
							|  |  |  | // the Free Software Foundation as version 3 of the License, or                  //
 | 
					
						
							| 
									
										
										
										
											2019-04-11 14:32:15 +02:00
										 |  |  | // (at your option) any later version.                                           //
 | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // This program is distributed in the hope that it will be useful,               //
 | 
					
						
							|  |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of                //
 | 
					
						
							|  |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
 | 
					
						
							|  |  |  | // GNU General Public License V3 for more details.                               //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // You should have received a copy of the GNU General Public License             //
 | 
					
						
							|  |  |  | // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-01 22:56:32 +01:00
										 |  |  | #include <QCoreApplication>
 | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | #include <QPluginLoader>
 | 
					
						
							| 
									
										
										
										
											2017-10-24 14:15:08 +02:00
										 |  |  | #include <QDebug>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | #include <cstdio>
 | 
					
						
							| 
									
										
										
										
											2020-04-19 06:13:32 +02:00
										 |  |  | #include <algorithm>
 | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-02 03:30:54 +01:00
										 |  |  | #include "device/deviceenumerator.h"
 | 
					
						
							| 
									
										
										
										
											2017-10-24 14:15:08 +02:00
										 |  |  | #include "plugin/pluginmanager.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-26 01:00:49 +01:00
										 |  |  | #ifndef LIB
 | 
					
						
							|  |  |  | #define LIB "lib"
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-02 04:02:40 +02:00
										 |  |  | const QString PluginManager::m_localInputHardwareID = "LocalInput"; | 
					
						
							|  |  |  | const QString PluginManager::m_localInputDeviceTypeID = "sdrangel.samplesource.localinput"; | 
					
						
							| 
									
										
										
										
											2019-02-03 01:52:11 +01:00
										 |  |  | const QString PluginManager::m_remoteInputHardwareID = "RemoteInput"; | 
					
						
							|  |  |  | const QString PluginManager::m_remoteInputDeviceTypeID = "sdrangel.samplesource.remoteinput"; | 
					
						
							| 
									
										
										
										
											2019-07-08 00:59:04 +02:00
										 |  |  | const QString PluginManager::m_fileInputHardwareID = "FileInput"; | 
					
						
							|  |  |  | const QString PluginManager::m_fileInputDeviceTypeID = "sdrangel.samplesource.fileinput"; | 
					
						
							| 
									
										
										
										
											2017-11-01 13:03:12 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-10 23:38:52 +02:00
										 |  |  | const QString PluginManager::m_localOutputHardwareID = "LocalOutput"; | 
					
						
							|  |  |  | const QString PluginManager::m_localOutputDeviceTypeID = "sdrangel.samplesource.localoutput"; | 
					
						
							| 
									
										
										
										
											2019-02-03 01:52:11 +01:00
										 |  |  | const QString PluginManager::m_remoteOutputHardwareID = "RemoteOutput"; | 
					
						
							|  |  |  | const QString PluginManager::m_remoteOutputDeviceTypeID = "sdrangel.samplesink.remoteoutput"; | 
					
						
							| 
									
										
										
										
											2020-08-04 00:29:15 +02:00
										 |  |  | const QString PluginManager::m_fileOutputHardwareID = "FileOutput"; | 
					
						
							|  |  |  | const QString PluginManager::m_fileOutputDeviceTypeID = "sdrangel.samplesink.fileoutput"; | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-10 12:08:58 +01:00
										 |  |  | const QString PluginManager::m_testMIMOHardwareID = "TestMI"; | 
					
						
							|  |  |  | const QString PluginManager::m_testMIMODeviceTypeID = "sdrangel.samplemimo.testmi"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-24 14:15:08 +02:00
										 |  |  | PluginManager::PluginManager(QObject* parent) : | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | 	QObject(parent), | 
					
						
							| 
									
										
										
										
											2022-04-30 12:52:25 +02:00
										 |  |  |     m_pluginAPI(this), | 
					
						
							|  |  |  |     m_enableSoapy(false) | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PluginManager::~PluginManager() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-01 15:17:27 +02:00
										 |  |  |   //  freeAll();
 | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-17 10:36:22 +01:00
										 |  |  | void PluginManager::loadPlugins(const QString& pluginsSubDir) | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-08-18 21:30:51 +02:00
										 |  |  |     loadPluginsPart(pluginsSubDir); | 
					
						
							|  |  |  |     loadPluginsFinal(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PluginManager::loadPluginsPart(const QString& pluginsSubDir) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QString applicationDirPath = QCoreApplication::instance()->applicationDirPath(); | 
					
						
							| 
									
										
										
										
											2019-05-01 15:17:27 +02:00
										 |  |  |     QStringList PluginsPath; | 
					
						
							| 
									
										
										
										
											2024-09-03 18:52:00 +03:00
										 |  |  |     QStringList filter; | 
					
						
							| 
									
										
										
										
											2019-05-01 15:17:27 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // NOTE: not the best solution but for now this is
 | 
					
						
							|  |  |  |     // on make install [PREFIX]/bin and [PREFIX]/lib/sdrangel
 | 
					
						
							| 
									
										
										
										
											2024-09-03 18:52:00 +03:00
										 |  |  | #if defined(ANDROID)
 | 
					
						
							|  |  |  |     PluginsPath = QStringList({applicationDirPath}); | 
					
						
							|  |  |  |     filter = QStringList({"libsdrangel_" + pluginsSubDir + "_*.so"}); | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  |     filter = QStringList({"*"}); | 
					
						
							| 
									
										
										
										
											2022-01-26 01:00:49 +01:00
										 |  |  |     PluginsPath << applicationDirPath + "/../" + LIB + "/sdrangel/" + pluginsSubDir; | 
					
						
							| 
									
										
										
										
											2019-05-01 15:17:27 +02:00
										 |  |  |     // on build
 | 
					
						
							| 
									
										
										
										
											2022-01-26 01:00:49 +01:00
										 |  |  |     PluginsPath << applicationDirPath + "/" + LIB + "/" + pluginsSubDir; | 
					
						
							| 
									
										
										
										
											2018-12-27 09:48:30 +01:00
										 |  |  | #ifdef __APPLE__
 | 
					
						
							| 
									
										
										
										
											2019-05-01 15:17:27 +02:00
										 |  |  |     // on SDRAngel.app
 | 
					
						
							| 
									
										
										
										
											2019-05-03 17:46:01 +02:00
										 |  |  |     PluginsPath << applicationDirPath + "/../Resources/lib/" + pluginsSubDir; | 
					
						
							| 
									
										
										
										
											2019-05-24 08:32:40 +02:00
										 |  |  | #elif defined(_WIN32) || defined(WIN32)
 | 
					
						
							|  |  |  |     PluginsPath << applicationDirPath + "/" + pluginsSubDir; | 
					
						
							| 
									
										
										
										
											2020-11-06 14:38:31 +01:00
										 |  |  |     // Give SoapySDR hint about modules location.
 | 
					
						
							|  |  |  |     // By default it searches in `$applicationDir/../lib/SoapySDR/`, which on Windows
 | 
					
						
							|  |  |  |     // is incorrect as both `bin` and `lib` dir are set to root application dir.
 | 
					
						
							|  |  |  |     qputenv("SOAPY_SDR_ROOT", applicationDirPath.toLocal8Bit()); | 
					
						
							| 
									
										
										
										
											2024-09-03 18:52:00 +03:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-12-27 09:48:30 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-12-16 13:39:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-01 15:17:27 +02:00
										 |  |  |     // NOTE: exit on the first folder found
 | 
					
						
							|  |  |  |     bool found = false; | 
					
						
							|  |  |  |     foreach (QString dir, PluginsPath) | 
					
						
							| 
									
										
										
										
											2019-05-18 18:58:35 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-05-01 15:17:27 +02:00
										 |  |  |         QDir d(dir); | 
					
						
							| 
									
										
										
										
											2019-05-16 13:14:38 +02:00
										 |  |  |         if (d.entryList(QDir::Files).count() == 0) { | 
					
						
							| 
									
										
										
										
											2019-05-18 18:58:35 +02:00
										 |  |  |             qDebug("PluginManager::loadPluginsPart folder %s is empty", qPrintable(dir)); | 
					
						
							|  |  |  |             continue; | 
					
						
							| 
									
										
										
										
											2019-05-01 15:17:27 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         found = true; | 
					
						
							| 
									
										
										
										
											2024-09-03 18:52:00 +03:00
										 |  |  |         loadPluginsDir(d, filter); | 
					
						
							| 
									
										
										
										
											2019-05-01 15:17:27 +02:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2019-05-18 18:58:35 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-05-01 15:17:27 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (!found) | 
					
						
							| 
									
										
										
										
											2019-05-18 18:58:35 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-05-01 15:17:27 +02:00
										 |  |  |         qCritical("No plugins found. Exit immediately."); | 
					
						
							|  |  |  |         exit(EXIT_FAILURE); | 
					
						
							| 
									
										
										
										
											2019-05-18 18:58:35 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-08-18 21:30:51 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-12-16 13:39:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-18 21:30:51 +02:00
										 |  |  | void PluginManager::loadPluginsFinal() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-04-19 06:13:32 +02:00
										 |  |  |     std::sort(m_plugins.begin(), m_plugins.end()); | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-18 21:30:51 +02:00
										 |  |  |     for (Plugins::const_iterator it = m_plugins.begin(); it != m_plugins.end(); ++it) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         it->pluginInterface->initPlugin(&m_pluginAPI); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 22:41:48 +08:00
										 |  |  |     DeviceEnumerator::instance()->enumerateAllDevices(this); | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-16 01:03:47 +01:00
										 |  |  | void PluginManager::loadPluginsNonDiscoverable(const DeviceUserArgs& deviceUserArgs) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     DeviceEnumerator::instance()->addNonDiscoverableDevices(this, deviceUserArgs); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-23 01:19:32 +01:00
										 |  |  | void PluginManager::registerRxChannel(const QString& channelIdURI, const QString& channelId, PluginInterface* plugin) | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     qDebug() << "PluginManager::registerRxChannel " | 
					
						
							|  |  |  |             << plugin->getPluginDescriptor().displayedName.toStdString().c_str() | 
					
						
							| 
									
										
										
										
											2017-11-23 01:19:32 +01:00
										 |  |  |             << " with channel name " << channelIdURI; | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-23 01:19:32 +01:00
										 |  |  | 	m_rxChannelRegistrations.append(PluginAPI::ChannelRegistration(channelIdURI, channelId, plugin)); | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-23 01:19:32 +01:00
										 |  |  | void PluginManager::registerTxChannel(const QString& channelIdURI, const QString& channelId, PluginInterface* plugin) | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     qDebug() << "PluginManager::registerTxChannel " | 
					
						
							|  |  |  |             << plugin->getPluginDescriptor().displayedName.toStdString().c_str() | 
					
						
							| 
									
										
										
										
											2017-11-23 01:19:32 +01:00
										 |  |  |             << " with channel name " << channelIdURI; | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-23 01:19:32 +01:00
										 |  |  | 	m_txChannelRegistrations.append(PluginAPI::ChannelRegistration(channelIdURI, channelId, plugin)); | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-02 18:36:56 +02:00
										 |  |  | void PluginManager::registerMIMOChannel(const QString& channelIdURI, const QString& channelId, PluginInterface* plugin) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     qDebug() << "PluginManager::registerMIMOChannel " | 
					
						
							|  |  |  |             << plugin->getPluginDescriptor().displayedName.toStdString().c_str() | 
					
						
							|  |  |  |             << " with channel name " << channelIdURI; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	m_mimoChannelRegistrations.append(PluginAPI::ChannelRegistration(channelIdURI, channelId, plugin)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | void PluginManager::registerSampleSource(const QString& sourceName, PluginInterface* plugin) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	qDebug() << "PluginManager::registerSampleSource " | 
					
						
							|  |  |  | 			<< plugin->getPluginDescriptor().displayedName.toStdString().c_str() | 
					
						
							| 
									
										
										
										
											2019-12-16 01:03:47 +01:00
										 |  |  | 			<< " with source name " << sourceName.toStdString().c_str() | 
					
						
							|  |  |  |             << " and hardware id " << plugin->getPluginDescriptor().hardwareId; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	m_sampleSourceRegistrations.append(PluginAPI::SamplingDeviceRegistration( | 
					
						
							|  |  |  |         plugin->getPluginDescriptor().hardwareId, | 
					
						
							|  |  |  |         sourceName, | 
					
						
							|  |  |  |         plugin | 
					
						
							|  |  |  |     )); | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PluginManager::registerSampleSink(const QString& sinkName, PluginInterface* plugin) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	qDebug() << "PluginManager::registerSampleSink " | 
					
						
							|  |  |  | 			<< plugin->getPluginDescriptor().displayedName.toStdString().c_str() | 
					
						
							| 
									
										
										
										
											2019-12-16 01:03:47 +01:00
										 |  |  | 			<< " with sink name " << sinkName.toStdString().c_str() | 
					
						
							|  |  |  |             << " and hardware id " << plugin->getPluginDescriptor().hardwareId; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	m_sampleSinkRegistrations.append(PluginAPI::SamplingDeviceRegistration( | 
					
						
							|  |  |  |         plugin->getPluginDescriptor().hardwareId, | 
					
						
							|  |  |  |         sinkName, | 
					
						
							|  |  |  |         plugin | 
					
						
							|  |  |  |     )); | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-18 06:30:37 +02:00
										 |  |  | void PluginManager::registerSampleMIMO(const QString& mimoName, PluginInterface* plugin) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	qDebug() << "PluginManager::registerSampleMIMO " | 
					
						
							|  |  |  | 			<< plugin->getPluginDescriptor().displayedName.toStdString().c_str() | 
					
						
							| 
									
										
										
										
											2019-12-16 01:03:47 +01:00
										 |  |  | 			<< " with MIMO name " << mimoName.toStdString().c_str() | 
					
						
							|  |  |  |             << " and hardware id " << plugin->getPluginDescriptor().hardwareId; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	m_sampleMIMORegistrations.append(PluginAPI::SamplingDeviceRegistration( | 
					
						
							|  |  |  |         plugin->getPluginDescriptor().hardwareId, | 
					
						
							|  |  |  |         mimoName, | 
					
						
							|  |  |  |         plugin | 
					
						
							|  |  |  |     )); | 
					
						
							| 
									
										
										
										
											2019-05-18 06:30:37 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-20 01:06:34 +02:00
										 |  |  | void PluginManager::registerFeature(const QString& featureIdURI, const QString& featureId, PluginInterface* plugin) | 
					
						
							| 
									
										
										
										
											2020-09-08 15:47:20 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-09-20 01:06:34 +02:00
										 |  |  |     qDebug() << "PluginManager::registerFeature " | 
					
						
							|  |  |  |             << plugin->getPluginDescriptor().displayedName.toStdString().c_str() | 
					
						
							|  |  |  |             << " with channel name " << featureIdURI; | 
					
						
							| 
									
										
										
										
											2020-09-08 15:47:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-20 01:06:34 +02:00
										 |  |  | 	m_featureRegistrations.append(PluginAPI::FeatureRegistration(featureIdURI, featureId, plugin)); | 
					
						
							| 
									
										
										
										
											2020-09-08 15:47:20 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-03 18:52:00 +03:00
										 |  |  | void PluginManager::loadPluginsDir(const QDir& dir, const QStringList& filter) | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-18 18:58:35 +02:00
										 |  |  |     QDir pluginsDir(dir); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-03 18:52:00 +03:00
										 |  |  |     foreach (QString fileName, pluginsDir.entryList(filter, QDir::Files)) | 
					
						
							| 
									
										
										
										
											2019-05-18 18:58:35 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (QLibrary::isLibrary(fileName)) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-13 22:34:01 +02:00
										 |  |  |             if (!m_enableSoapy && fileName.contains("soapysdr")) | 
					
						
							| 
									
										
										
										
											2022-04-30 12:52:25 +02:00
										 |  |  |             { | 
					
						
							|  |  |  |                 qInfo("PluginManager::loadPluginsDir: Soapy SDR disabled skipping %s", qPrintable(fileName)); | 
					
						
							|  |  |  |                 continue; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-18 18:58:35 +02:00
										 |  |  |             qDebug("PluginManager::loadPluginsDir: fileName: %s", qPrintable(fileName)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             QPluginLoader* pluginLoader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName)); | 
					
						
							|  |  |  |             if (!pluginLoader->load()) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 qWarning("PluginManager::loadPluginsDir: %s", qPrintable(pluginLoader->errorString())); | 
					
						
							|  |  |  |                 delete pluginLoader; | 
					
						
							|  |  |  |                 continue; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             PluginInterface* instance = qobject_cast<PluginInterface*>(pluginLoader->instance()); | 
					
						
							|  |  |  |             if (instance == nullptr) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 qWarning("PluginManager::loadPluginsDir: Unable to get main instance of plugin: %s", qPrintable(fileName) ); | 
					
						
							|  |  |  |                 delete pluginLoader; | 
					
						
							|  |  |  |                 continue; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-22 08:31:07 +02:00
										 |  |  |             delete(pluginLoader); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-18 18:58:35 +02:00
										 |  |  |             qInfo("PluginManager::loadPluginsDir: loaded plugin %s", qPrintable(fileName)); | 
					
						
							| 
									
										
										
										
											2019-05-22 08:31:07 +02:00
										 |  |  |             m_plugins.append(Plugin(fileName, instance)); | 
					
						
							| 
									
										
										
										
											2019-05-18 18:58:35 +02:00
										 |  |  |        } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-01 08:32:44 +01:00
										 |  |  | void PluginManager::listTxChannels(QList<QString>& list) | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-18 18:58:35 +02:00
										 |  |  |     list.clear(); | 
					
						
							| 
									
										
										
										
											2017-11-01 08:32:44 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-01 18:50:21 +02:00
										 |  |  |     for (PluginAPI::ChannelRegistrations::iterator it = m_txChannelRegistrations.begin(); it != m_txChannelRegistrations.end(); ++it) | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-05-18 18:58:35 +02:00
										 |  |  |         const PluginDescriptor& pluginDescipror = it->m_plugin->getPluginDescriptor(); | 
					
						
							|  |  |  |         list.append(pluginDescipror.displayedName); | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-01 08:32:44 +01:00
										 |  |  | void PluginManager::listRxChannels(QList<QString>& list) | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-18 18:58:35 +02:00
										 |  |  |     list.clear(); | 
					
						
							| 
									
										
										
										
											2017-11-01 08:32:44 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-01 18:50:21 +02:00
										 |  |  |     for (PluginAPI::ChannelRegistrations::iterator it = m_rxChannelRegistrations.begin(); it != m_rxChannelRegistrations.end(); ++it) | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-05-18 18:58:35 +02:00
										 |  |  |         const PluginDescriptor& pluginDesciptor = it->m_plugin->getPluginDescriptor(); | 
					
						
							|  |  |  |         list.append(pluginDesciptor.displayedName); | 
					
						
							| 
									
										
										
										
											2017-04-23 10:33:18 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-02 18:36:56 +02:00
										 |  |  | void PluginManager::listMIMOChannels(QList<QString>& list) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     list.clear(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (PluginAPI::ChannelRegistrations::iterator it = m_mimoChannelRegistrations.begin(); it != m_mimoChannelRegistrations.end(); ++it) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const PluginDescriptor& pluginDesciptor = it->m_plugin->getPluginDescriptor(); | 
					
						
							|  |  |  |         list.append(pluginDesciptor.displayedName); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-20 01:06:34 +02:00
										 |  |  | void PluginManager::listFeatures(QList<QString>& list) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     list.clear(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (PluginAPI::FeatureRegistrations::iterator it = m_featureRegistrations.begin(); it != m_featureRegistrations.end(); ++it) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const PluginDescriptor& pluginDesciptor = it->m_plugin->getPluginDescriptor(); | 
					
						
							|  |  |  |         list.append(pluginDesciptor.displayedName); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-01 18:50:21 +02:00
										 |  |  | const PluginInterface *PluginManager::getChannelPluginInterface(const QString& channelIdURI) const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-08-03 11:21:46 +02:00
										 |  |  |     for (PluginAPI::ChannelRegistrations::const_iterator it = m_rxChannelRegistrations.begin(); it != m_rxChannelRegistrations.end(); ++it) | 
					
						
							| 
									
										
										
										
											2019-08-01 18:50:21 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (it->m_channelIdURI == channelIdURI) { | 
					
						
							|  |  |  |             return it->m_plugin; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-03 11:21:46 +02:00
										 |  |  |     for (PluginAPI::ChannelRegistrations::const_iterator it = m_txChannelRegistrations.begin(); it != m_txChannelRegistrations.end(); ++it) | 
					
						
							| 
									
										
										
										
											2019-08-01 18:50:21 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (it->m_channelIdURI == channelIdURI) { | 
					
						
							|  |  |  |             return it->m_plugin; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return nullptr; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-08-03 11:21:46 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | const PluginInterface *PluginManager::getDevicePluginInterface(const QString& deviceId) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     for (PluginAPI::SamplingDeviceRegistrations::const_iterator it = m_sampleSourceRegistrations.begin(); it != m_sampleSourceRegistrations.end(); ++it) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (it->m_deviceId == deviceId) { | 
					
						
							|  |  |  |             return it->m_plugin; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (PluginAPI::SamplingDeviceRegistrations::const_iterator it = m_sampleSinkRegistrations.begin(); it != m_sampleSinkRegistrations.end(); ++it) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (it->m_deviceId == deviceId) { | 
					
						
							|  |  |  |             return it->m_plugin; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (PluginAPI::SamplingDeviceRegistrations::const_iterator it = m_sampleMIMORegistrations.begin(); it != m_sampleMIMORegistrations.end(); ++it) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (it->m_deviceId == deviceId) { | 
					
						
							|  |  |  |             return it->m_plugin; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return nullptr; | 
					
						
							| 
									
										
										
										
											2020-09-20 01:06:34 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-09-24 05:38:05 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | const PluginInterface *PluginManager::getFeaturePluginInterface(const QString& featureIdURI) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     for (PluginAPI::FeatureRegistrations::const_iterator it = m_featureRegistrations.begin(); it != m_featureRegistrations.end(); ++it) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (it->m_featureIdURI == featureIdURI) { | 
					
						
							|  |  |  |             return it->m_plugin; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return nullptr; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-02-26 20:25:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | QString PluginManager::uriToId(const QString& uri) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     for (int i = 0; i < m_rxChannelRegistrations.size(); i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (m_rxChannelRegistrations[i].m_channelIdURI == uri) | 
					
						
							|  |  |  |             return m_rxChannelRegistrations[i].m_channelId; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     for (int i = 0; i < m_txChannelRegistrations.size(); i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (m_txChannelRegistrations[i].m_channelIdURI == uri) | 
					
						
							|  |  |  |             return m_txChannelRegistrations[i].m_channelId; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     for (int i = 0; i < m_mimoChannelRegistrations.size(); i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (m_mimoChannelRegistrations[i].m_channelIdURI == uri) | 
					
						
							|  |  |  |             return m_mimoChannelRegistrations[i].m_channelId; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     for (int i = 0; i < m_featureRegistrations.size(); i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (m_featureRegistrations[i].m_featureIdURI == uri) | 
					
						
							|  |  |  |             return m_featureRegistrations[i].m_featureId; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return uri; | 
					
						
							|  |  |  | } |