Skip to content

Commit

Permalink
Add support for delayed plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
BatchDrake committed Jul 31, 2023
1 parent dc2c808 commit 89e18cc
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
3 changes: 2 additions & 1 deletion App/Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ InitThread::run()
sing->init_ui_config();
emit change("Loading profile history");
sing->init_recent_list();
emit change("Init done, reloading devices");
emit change("Init done, triggering delayed plugin tasks...");
sing->trigger_delayed();
} catch (Suscan::Exception const &e) {
emit failure(QString(e.what()));
}
Expand Down
11 changes: 5 additions & 6 deletions Default/Source/SourceWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ SourceWidget::applySourceInfo(Suscan::AnalyzerSourceInfo const &info)
this->clearGains();

info.getGainInfo(gains);

for (auto p: gains) {
gain = new DeviceGain(nullptr, p);
this->gainControls.push_back(gain);
Expand All @@ -414,13 +413,13 @@ SourceWidget::applySourceInfo(Suscan::AnalyzerSourceInfo const &info)
SLOT(onGainChanged(QString, float)));
gain->setGain(p.getDefault());
}

if (this->gainControls.size() == 0)
this->ui->gainsFrame->hide();
else
this->ui->gainsFrame->show();
}

if (this->gainControls.size() == 0)
this->ui->gainsFrame->hide();
else
this->ui->gainsFrame->show();

// Everything is set, time to decide what is enabled and what is not
this->refreshUi();

Expand Down
2 changes: 1 addition & 1 deletion SigDigger.pro
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ INSTALL_HEADERS += \
include/Palette.h \
include/PersistentWidget.h \
include/RemoteControlConfig.h \
include/SourceConfigWidgetFactory.h \
include/TabWidgetFactory.h \
include/TLESourceConfig.h \
include/ToolWidgetFactory.h \
Expand Down Expand Up @@ -375,7 +376,6 @@ HEADERS += \
include/Loader.h \
include/SaveProfileDialog.h \
include/SNREstimator.h \
include/SourceConfigWidgetFactory.h \
include/TLESourceTab.h \
include/TimeWindow.h \
include/FileDataSaver.h \
Expand Down
13 changes: 13 additions & 0 deletions Suscan/Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,13 @@ Singleton::detect_devices(void)
this->refreshDevices();
}

void
Singleton::trigger_delayed(void)
{
for (auto p : pluginCallbacks)
(p.first)(p.second);
}

void
Singleton::init_ui_config(void)
{
Expand Down Expand Up @@ -728,6 +735,12 @@ Singleton::sync(void)
}

// Singleton methods
void
Singleton::registerDelayedCallback(DelayedPluginCallback cb, Plugin *plugin)
{
pluginCallbacks.push_back(std::pair(cb, plugin));
}

void
Singleton::registerSourceConfig(suscan_source_config_t *config)
{
Expand Down
8 changes: 8 additions & 0 deletions include/Suscan/Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace Suscan {
uint qHash(const Suscan::Source::Device &dev);

class MultitaskController;
class Plugin;

typedef std::map<std::string, Source::Config> ConfigMap;

Expand Down Expand Up @@ -249,6 +250,8 @@ namespace Suscan {
void debug(void) const;
};

typedef void (*DelayedPluginCallback) (Suscan::Plugin *);

class Singleton {
static Singleton *instance;
static Logger *logger;
Expand All @@ -271,6 +274,9 @@ namespace Suscan {
QMap<std::string, SpectrumUnit> spectrumUnits;
QHash<QString, Source::Config> networkProfiles;

// Delayed plugin callbacks
std::list<std::pair<DelayedPluginCallback, Suscan::Plugin *>> pluginCallbacks;

// Feature object factories
QList<SigDigger::ToolWidgetFactory *> toolWidgetFactories;
QList<SigDigger::TabWidgetFactory *> tabWidgetFactories;
Expand Down Expand Up @@ -323,11 +329,13 @@ namespace Suscan {
void init_tle(void);
void init_plugins(void);
void detect_devices(void);
void trigger_delayed(void);

void sync(void);

void killBackgroundTaskController(void);

void registerDelayedCallback(DelayedPluginCallback, Plugin *);
void registerSourceConfig(suscan_source_config_t *config);
void registerNetworkProfile(const suscan_source_config_t *config);
void registerSourceDevice(const suscan_source_device_t *dev);
Expand Down

0 comments on commit 89e18cc

Please sign in to comment.