| 
									
										
										
										
											2019-05-18 06:30:37 +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) 2019 Davide Gerhard <rainbow@irh.it>                            //
 | 
					
						
							|  |  |  | // Copyright (C) 2020-2021 Jon Beniston, M7RCE <jon@beniston.com>                //
 | 
					
						
							|  |  |  | // Copyright (C) 2020 Kacper Michajłow <kasper93@gmail.com>                      //
 | 
					
						
							| 
									
										
										
										
											2019-05-18 06:30:37 +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                  //
 | 
					
						
							|  |  |  | // (at your option) any later version.                                           //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | #ifndef INCLUDE_PLUGINMANAGER_H
 | 
					
						
							|  |  |  | #define INCLUDE_PLUGINMANAGER_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-26 10:35:29 +02:00
										 |  |  | #include <stdint.h>
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | #include <QObject>
 | 
					
						
							|  |  |  | #include <QDir>
 | 
					
						
							| 
									
										
										
										
											2017-11-01 08:32:44 +01:00
										 |  |  | #include <QList>
 | 
					
						
							|  |  |  | #include <QString>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | #include "plugin/plugininterface.h"
 | 
					
						
							|  |  |  | #include "plugin/pluginapi.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-20 13:49:21 +01:00
										 |  |  | #include "export.h"
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | class QComboBox; | 
					
						
							|  |  |  | class QPluginLoader; | 
					
						
							|  |  |  | class Message; | 
					
						
							| 
									
										
										
										
											2016-05-12 10:31:57 +02:00
										 |  |  | class MessageQueue; | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  | class DeviceAPI; | 
					
						
							| 
									
										
										
										
											2020-11-20 19:47:04 +01:00
										 |  |  | struct DeviceUserArgs; | 
					
						
							| 
									
										
										
										
											2020-09-20 01:06:34 +02:00
										 |  |  | class WebAPIAdapterInterface; | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-03 20:23:38 +01:00
										 |  |  | class SDRBASE_API PluginManager : public QObject { | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2015-08-09 04:09:05 +02:00
										 |  |  | 	struct Plugin | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 		QString filename; | 
					
						
							| 
									
										
										
										
											2015-09-30 08:55:58 +02:00
										 |  |  | 		PluginInterface* pluginInterface; | 
					
						
							| 
									
										
										
										
											2015-08-09 04:09:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-22 08:31:07 +02:00
										 |  |  | 		Plugin(const QString& _filename, PluginInterface* _plugin) : | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 			filename(_filename), | 
					
						
							| 
									
										
										
										
											2015-09-30 08:55:58 +02:00
										 |  |  | 			pluginInterface(_plugin) | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2015-08-09 04:09:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	typedef QList<Plugin> Plugins; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-24 14:15:08 +02:00
										 |  |  | 	explicit PluginManager(QObject* parent = 0); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	~PluginManager(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-24 14:15:08 +02:00
										 |  |  | 	PluginAPI *getPluginAPI() { return &m_pluginAPI; } | 
					
						
							| 
									
										
										
										
											2022-04-30 12:52:25 +02:00
										 |  |  |     void setEnableSoapy(bool enableSoapy) { m_enableSoapy = enableSoapy; } | 
					
						
							| 
									
										
										
										
											2017-12-17 10:36:22 +01:00
										 |  |  | 	void loadPlugins(const QString& pluginsSubDir); | 
					
						
							| 
									
										
										
										
											2018-08-18 21:30:51 +02:00
										 |  |  | 	void loadPluginsPart(const QString& pluginsSubDir); | 
					
						
							|  |  |  | 	void loadPluginsFinal(); | 
					
						
							| 
									
										
										
										
											2019-12-16 01:03:47 +01:00
										 |  |  |     void loadPluginsNonDiscoverable(const DeviceUserArgs& deviceUserArgs); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	const Plugins& getPlugins() const { return m_plugins; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 18:12:39 +02:00
										 |  |  | 	// Callbacks from the plugins
 | 
					
						
							| 
									
										
										
										
											2017-11-23 01:19:32 +01:00
										 |  |  | 	void registerRxChannel(const QString& channelIdURI, const QString& channelId, PluginInterface* plugin); | 
					
						
							|  |  |  | 	void registerTxChannel(const QString& channelIdURI, const QString& channelId, PluginInterface* plugin); | 
					
						
							| 
									
										
										
										
											2019-09-02 18:36:56 +02:00
										 |  |  | 	void registerMIMOChannel(const QString& channelIdURI, const QString& channelId, PluginInterface* plugin); | 
					
						
							|  |  |  | 	void registerSampleSource(const QString& sourceName, PluginInterface* plugin); | 
					
						
							| 
									
										
										
										
											2019-05-18 06:30:37 +02:00
										 |  |  | 	void registerSampleSink(const QString& sinkName, PluginInterface* plugin); | 
					
						
							|  |  |  |     void registerSampleMIMO(const QString& mimoName, PluginInterface* plugin); | 
					
						
							| 
									
										
										
										
											2020-09-20 01:06:34 +02:00
										 |  |  | 	void registerFeature(const QString& featureIdURI, const QString& featureId, PluginInterface* plugin); | 
					
						
							| 
									
										
										
										
											2016-05-14 18:12:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-02 03:30:54 +01:00
										 |  |  | 	PluginAPI::SamplingDeviceRegistrations& getSourceDeviceRegistrations() { return m_sampleSourceRegistrations; } | 
					
						
							|  |  |  | 	PluginAPI::SamplingDeviceRegistrations& getSinkDeviceRegistrations() { return m_sampleSinkRegistrations; } | 
					
						
							| 
									
										
										
										
											2019-05-18 06:30:37 +02:00
										 |  |  |     PluginAPI::SamplingDeviceRegistrations& getMIMODeviceRegistrations() { return m_sampleMIMORegistrations; } | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 	PluginAPI::ChannelRegistrations *getRxChannelRegistrations() { return &m_rxChannelRegistrations; } | 
					
						
							| 
									
										
										
										
											2016-10-19 18:07:27 +02:00
										 |  |  | 	PluginAPI::ChannelRegistrations *getTxChannelRegistrations() { return &m_txChannelRegistrations; } | 
					
						
							| 
									
										
										
										
											2019-09-02 18:36:56 +02:00
										 |  |  | 	PluginAPI::ChannelRegistrations *getMIMOChannelRegistrations() { return &m_mimoChannelRegistrations; } | 
					
						
							| 
									
										
										
										
											2020-09-20 01:06:34 +02:00
										 |  |  | 	PluginAPI::FeatureRegistrations *getFeatureRegistrations() { return &m_featureRegistrations; } | 
					
						
							| 
									
										
										
										
											2016-05-16 18:53:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-01 08:32:44 +01:00
										 |  |  |     void listRxChannels(QList<QString>& list); | 
					
						
							|  |  |  | 	void listTxChannels(QList<QString>& list); | 
					
						
							| 
									
										
										
										
											2019-09-02 18:36:56 +02:00
										 |  |  | 	void listMIMOChannels(QList<QString>& list); | 
					
						
							| 
									
										
										
										
											2020-09-20 01:06:34 +02:00
										 |  |  | 	void listFeatures(QList<QString>& list); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-01 18:50:21 +02:00
										 |  |  | 	const PluginInterface *getChannelPluginInterface(const QString& channelIdURI) const; | 
					
						
							| 
									
										
										
										
											2019-08-03 11:21:46 +02:00
										 |  |  | 	const PluginInterface *getDevicePluginInterface(const QString& deviceId) const; | 
					
						
							| 
									
										
										
										
											2020-09-24 05:38:05 +02:00
										 |  |  | 	const PluginInterface *getFeaturePluginInterface(const QString& featureIdURI) const; | 
					
						
							| 
									
										
										
										
											2019-08-01 18:50:21 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-26 20:25:48 +00:00
										 |  |  |     // Map channel/feature URI to short form Id
 | 
					
						
							|  |  |  |     QString uriToId(const QString& uri) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-08 00:59:04 +02:00
										 |  |  | 	static const QString& getFileInputDeviceId() { return m_fileInputDeviceTypeID; } | 
					
						
							| 
									
										
										
										
											2020-11-10 12:08:58 +01:00
										 |  |  |     static const QString& getTestMIMODeviceId() { return m_testMIMODeviceTypeID; } | 
					
						
							| 
									
										
										
										
											2020-08-04 00:53:34 +02:00
										 |  |  | 	static const QString& getFileOutputDeviceId() { return m_fileOutputDeviceTypeID; } | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-02 03:30:54 +01:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2017-11-01 13:03:12 +01:00
										 |  |  | 	struct SamplingDevice { //!< This is the device registration
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 		PluginInterface* m_plugin; | 
					
						
							|  |  |  | 		QString m_displayName; | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  | 		QString m_hadrwareId; | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 		QString m_deviceId; | 
					
						
							|  |  |  | 		QString m_deviceSerial; | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | 		uint32_t m_deviceSequence; | 
					
						
							| 
									
										
										
										
											2015-09-30 06:57:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 		SamplingDevice(PluginInterface* plugin, | 
					
						
							| 
									
										
										
										
											2015-09-30 06:57:40 +02:00
										 |  |  | 				const QString& displayName, | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  | 				const QString& hadrwareId, | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 				const QString& deviceId, | 
					
						
							|  |  |  | 				const QString& deviceSerial, | 
					
						
							|  |  |  | 				int deviceSequence) : | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 			m_plugin(plugin), | 
					
						
							|  |  |  | 			m_displayName(displayName), | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  | 			m_hadrwareId(hadrwareId), | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 			m_deviceId(deviceId), | 
					
						
							|  |  |  | 			m_deviceSerial(deviceSerial), | 
					
						
							|  |  |  | 			m_deviceSequence(deviceSequence) | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2016-05-17 00:04:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 22:23:43 +02:00
										 |  |  | 	typedef QList<SamplingDevice> SamplingDevices; | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	PluginAPI m_pluginAPI; | 
					
						
							|  |  |  | 	Plugins m_plugins; | 
					
						
							| 
									
										
										
										
											2022-04-30 12:52:25 +02:00
										 |  |  |     bool m_enableSoapy; | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-02 03:30:54 +01:00
										 |  |  | 	PluginAPI::ChannelRegistrations m_rxChannelRegistrations;           //!< Channel plugins register here
 | 
					
						
							| 
									
										
										
										
											2019-09-02 18:36:56 +02:00
										 |  |  | 	PluginAPI::ChannelRegistrations m_txChannelRegistrations;           //!< Channel plugins register here
 | 
					
						
							|  |  |  | 	PluginAPI::ChannelRegistrations m_mimoChannelRegistrations;         //!< Channel plugins register here
 | 
					
						
							| 
									
										
										
										
											2016-10-19 18:07:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-02 18:36:56 +02:00
										 |  |  | 	PluginAPI::SamplingDeviceRegistrations m_sampleSourceRegistrations; //!< Input source plugins (one per device kind) register here
 | 
					
						
							|  |  |  | 	PluginAPI::SamplingDeviceRegistrations m_sampleSinkRegistrations;   //!< Output sink plugins (one per device kind) register here
 | 
					
						
							|  |  |  | 	PluginAPI::SamplingDeviceRegistrations m_sampleMIMORegistrations;   //!< MIMO sink plugins (one per device kind) register here
 | 
					
						
							| 
									
										
										
										
											2019-05-18 06:30:37 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-20 01:06:34 +02:00
										 |  |  | 	PluginAPI::FeatureRegistrations m_featureRegistrations;             //!< Feature plugins register here
 | 
					
						
							| 
									
										
										
										
											2020-09-08 15:47:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-23 00:21:13 +02:00
										 |  |  | 	// "Local" sample source device IDs
 | 
					
						
							| 
									
										
										
										
											2019-05-02 04:02:40 +02:00
										 |  |  |     static const QString m_localInputHardwareID;     //!< Local input hardware ID
 | 
					
						
							|  |  |  |     static const QString m_localInputDeviceTypeID;   //!< Local input plugin ID
 | 
					
						
							| 
									
										
										
										
											2019-02-03 01:52:11 +01:00
										 |  |  |     static const QString m_remoteInputHardwareID;    //!< Remote input hardware ID
 | 
					
						
							|  |  |  |     static const QString m_remoteInputDeviceTypeID;  //!< Remote input plugin ID
 | 
					
						
							| 
									
										
										
										
											2019-07-08 00:59:04 +02:00
										 |  |  |     static const QString m_fileInputHardwareID;      //!< File input hardware ID
 | 
					
						
							|  |  |  |     static const QString m_fileInputDeviceTypeID;    //!< File input plugin ID
 | 
					
						
							| 
									
										
										
										
											2016-10-19 18:07:27 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // "Local" sample sink device IDs
 | 
					
						
							| 
									
										
										
										
											2019-05-10 23:38:52 +02:00
										 |  |  |     static const QString m_localOutputHardwareID;    //!< Local output hardware ID
 | 
					
						
							|  |  |  |     static const QString m_localOutputDeviceTypeID;  //!< Local output plugin ID
 | 
					
						
							| 
									
										
										
										
											2019-02-03 01:52:11 +01:00
										 |  |  |     static const QString m_remoteOutputHardwareID;   //!< Remote output hardware ID
 | 
					
						
							|  |  |  |     static const QString m_remoteOutputDeviceTypeID; //!< Remote output plugin ID
 | 
					
						
							| 
									
										
										
										
											2020-08-04 00:29:15 +02:00
										 |  |  |     static const QString m_fileOutputHardwareID;     //!< FileOutput sink hardware ID
 | 
					
						
							|  |  |  |     static const QString m_fileOutputDeviceTypeID;   //!< FileOutput sink plugin ID
 | 
					
						
							| 
									
										
										
										
											2016-05-22 21:56:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-10 12:08:58 +01:00
										 |  |  |     // "Local" sample MIMO device IDs
 | 
					
						
							|  |  |  |     static const QString m_testMIMOHardwareID;       //!< Test MIMO hardware ID
 | 
					
						
							|  |  |  |     static const QString m_testMIMODeviceTypeID;     //!< Test MIMO plugin ID
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-17 10:36:22 +01:00
										 |  |  | 	void loadPluginsDir(const QDir& dir); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline bool operator<(const PluginManager::Plugin& a, const PluginManager::Plugin& b) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-09-30 08:55:58 +02:00
										 |  |  | 	return a.pluginInterface->getPluginDescriptor().displayedName < b.pluginInterface->getPluginDescriptor().displayedName; | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // INCLUDE_PLUGINMANAGER_H
 |