Browse Source
Add support for public list of SDRangel servers that can be displayed on Map. Add FLAC and zlib IQ compression. Add IQ squelch for compression. Add remote device/antenna position and direction reporting. Add text messaging.chirpmodem-v8.0.0
41 changed files with 7155 additions and 774 deletions
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
IF(NOT FLAC_FOUND) |
||||
INCLUDE(FindPkgConfig) |
||||
PKG_CHECK_MODULES(PC_FLAC flac) |
||||
|
||||
FIND_PATH( |
||||
FLAC_INCLUDE_DIR |
||||
NAMES FLAC/stream_encoder.h |
||||
HINTS ${PC_FLAC_INCLUDE_DIRS} |
||||
PATHS /usr/local/include |
||||
/usr/include |
||||
) |
||||
|
||||
FIND_LIBRARY( |
||||
FLAC_LIBRARY |
||||
NAMES FLAC |
||||
libFLAC |
||||
HINTS ${FLAC_DIR}/lib |
||||
${PC_FLAC_LIBRARY_DIRS} |
||||
PATHS /usr/local/lib |
||||
/usr/lib |
||||
/usr/lib64 |
||||
) |
||||
|
||||
message(STATUS "FLAC LIBRARY " ${FLAC_LIBRARY}) |
||||
message(STATUS "FLAC INCLUDE DIR " ${FLAC_INCLUDE_DIR}) |
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs) |
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FLAC DEFAULT_MSG FLAC_LIBRARY FLAC_INCLUDE_DIR) |
||||
MARK_AS_ADVANCED(FLAC_LIBRARY FLAC_INCLUDE_DIR) |
||||
|
||||
ENDIF(NOT FLAC_FOUND) |
||||
@ -0,0 +1,370 @@
@@ -0,0 +1,370 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2024 Jon Beniston, M7RCE <jon@beniston.com> //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QFileDialog> |
||||
#include <QPushButton> |
||||
|
||||
#include "remotetcpsinksettingsdialog.h" |
||||
#include "ui_remotetcpsinksettingsdialog.h" |
||||
|
||||
RemoteTCPSinkSettingsDialog::RemoteTCPSinkSettingsDialog(RemoteTCPSinkSettings *settings, QWidget* parent) : |
||||
QDialog(parent), |
||||
ui(new Ui::RemoteTCPSinkSettingsDialog), |
||||
m_settings(settings), |
||||
m_availableRotatorHandler({"sdrangel.feature.gs232controller"}) |
||||
{ |
||||
ui->setupUi(this); |
||||
|
||||
ui->maxClients->setValue(m_settings->m_maxClients); |
||||
ui->timeLimit->setValue(m_settings->m_timeLimit); |
||||
ui->maxSampleRate->setValue(m_settings->m_maxSampleRate); |
||||
ui->iqOnly->setChecked(m_settings->m_iqOnly); |
||||
|
||||
ui->compressor->setCurrentIndex((int) m_settings->m_compression); |
||||
ui->compressionLevel->setValue(m_settings->m_compressionLevel); |
||||
ui->blockSize->setCurrentIndex(ui->blockSize->findText(QString::number(m_settings->m_blockSize))); |
||||
|
||||
ui->certificate->setText(m_settings->m_certificate); |
||||
ui->key->setText(m_settings->m_key); |
||||
|
||||
ui->publicListing->setChecked(m_settings->m_public); |
||||
ui->publicAddress->setText(m_settings->m_publicAddress); |
||||
ui->publicPort->setValue(m_settings->m_publicPort); |
||||
ui->minFrequency->setValue(m_settings->m_minFrequency / 1000000); |
||||
ui->maxFrequency->setValue(m_settings->m_maxFrequency / 1000000); |
||||
ui->antenna->setText(m_settings->m_antenna); |
||||
ui->location->setText(m_settings->m_location); |
||||
ui->isotropic->setChecked(m_settings->m_isotropic); |
||||
ui->azimuth->setValue(m_settings->m_azimuth); |
||||
ui->elevation->setValue(m_settings->m_elevation); |
||||
ui->rotator->setCurrentText(m_settings->m_rotator); |
||||
|
||||
for (const auto& ip : m_settings->m_ipBlacklist) { |
||||
ui->ipBlacklist->addItem(ip); |
||||
} |
||||
|
||||
QObject::connect( |
||||
&m_availableRotatorHandler, |
||||
&AvailableChannelOrFeatureHandler::channelsOrFeaturesChanged, |
||||
this, |
||||
&RemoteTCPSinkSettingsDialog::rotatorsChanged |
||||
); |
||||
m_availableRotatorHandler.scanAvailableChannelsAndFeatures(); |
||||
} |
||||
|
||||
RemoteTCPSinkSettingsDialog::~RemoteTCPSinkSettingsDialog() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
void RemoteTCPSinkSettingsDialog::accept() |
||||
{ |
||||
if (!isValid()) { |
||||
return; |
||||
} |
||||
|
||||
QDialog::accept(); |
||||
|
||||
if (ui->maxClients->value() != m_settings->m_maxClients) |
||||
{ |
||||
m_settings->m_maxClients = ui->maxClients->value(); |
||||
m_settingsKeys.append("maxClients"); |
||||
} |
||||
if (ui->timeLimit->value() != m_settings->m_timeLimit) |
||||
{ |
||||
m_settings->m_timeLimit = ui->timeLimit->value(); |
||||
m_settingsKeys.append("timeLimit"); |
||||
} |
||||
if (ui->maxSampleRate->value() != m_settings->m_maxSampleRate) |
||||
{ |
||||
m_settings->m_maxSampleRate = ui->maxSampleRate->value(); |
||||
m_settingsKeys.append("maxSampleRate"); |
||||
} |
||||
if (ui->iqOnly->isChecked() != m_settings->m_iqOnly) |
||||
{ |
||||
m_settings->m_iqOnly = ui->iqOnly->isChecked(); |
||||
m_settingsKeys.append("iqOnly"); |
||||
} |
||||
RemoteTCPSinkSettings::Compressor compressor = (RemoteTCPSinkSettings::Compressor) ui->compressor->currentIndex(); |
||||
if (compressor != m_settings->m_compression) |
||||
{ |
||||
m_settings->m_compression = compressor; |
||||
m_settingsKeys.append("compression"); |
||||
} |
||||
if (ui->compressionLevel->value() != m_settings->m_compressionLevel) |
||||
{ |
||||
m_settings->m_compressionLevel = ui->compressionLevel->value(); |
||||
m_settingsKeys.append("compressionLevel"); |
||||
} |
||||
int blockSize = ui->blockSize->currentText().toInt(); |
||||
if (blockSize != m_settings->m_blockSize) |
||||
{ |
||||
m_settings->m_blockSize = blockSize; |
||||
m_settingsKeys.append("blockSize"); |
||||
} |
||||
if (ui->certificate->text() != m_settings->m_certificate) |
||||
{ |
||||
m_settings->m_certificate = ui->certificate->text(); |
||||
m_settingsKeys.append("certificate"); |
||||
} |
||||
if (ui->key->text() != m_settings->m_key) |
||||
{ |
||||
m_settings->m_key = ui->key->text(); |
||||
m_settingsKeys.append("key"); |
||||
} |
||||
if (ui->publicListing->isChecked() != m_settings->m_public) |
||||
{ |
||||
m_settings->m_public = ui->publicListing->isChecked(); |
||||
m_settingsKeys.append("public"); |
||||
} |
||||
if (ui->publicAddress->text() != m_settings->m_publicAddress) |
||||
{ |
||||
m_settings->m_publicAddress = ui->publicAddress->text(); |
||||
m_settingsKeys.append("publicAddress"); |
||||
} |
||||
if (ui->publicPort->value() != m_settings->m_publicPort) |
||||
{ |
||||
m_settings->m_publicPort = ui->publicPort->value(); |
||||
m_settingsKeys.append("publicPort"); |
||||
} |
||||
qint64 minFrequency = ui->minFrequency->value() * 1000000; |
||||
if (minFrequency != m_settings->m_minFrequency) |
||||
{ |
||||
m_settings->m_minFrequency = minFrequency; |
||||
m_settingsKeys.append("minFrequency"); |
||||
} |
||||
qint64 maxFrequency = ui->maxFrequency->value() * 1000000; |
||||
if (maxFrequency != m_settings->m_maxFrequency) |
||||
{ |
||||
m_settings->m_maxFrequency = maxFrequency; |
||||
m_settingsKeys.append("maxFrequency"); |
||||
} |
||||
if (ui->antenna->text() != m_settings->m_antenna) |
||||
{ |
||||
m_settings->m_antenna = ui->antenna->text(); |
||||
m_settingsKeys.append("antenna"); |
||||
} |
||||
if (ui->location->text() != m_settings->m_location) |
||||
{ |
||||
m_settings->m_location = ui->location->text(); |
||||
m_settingsKeys.append("location"); |
||||
} |
||||
if (ui->isotropic->isChecked() != m_settings->m_isotropic) |
||||
{ |
||||
m_settings->m_isotropic = ui->isotropic->isChecked(); |
||||
m_settingsKeys.append("isotropic"); |
||||
} |
||||
if (ui->azimuth->value() != m_settings->m_azimuth) |
||||
{ |
||||
m_settings->m_azimuth = ui->azimuth->value(); |
||||
m_settingsKeys.append("azimuth"); |
||||
} |
||||
if (ui->elevation->value() != m_settings->m_elevation) |
||||
{ |
||||
m_settings->m_elevation = ui->elevation->value(); |
||||
m_settingsKeys.append("elevation"); |
||||
} |
||||
if (ui->rotator->currentText() != m_settings->m_rotator) |
||||
{ |
||||
m_settings->m_rotator = ui->rotator->currentText(); |
||||
m_settingsKeys.append("rotator"); |
||||
} |
||||
QStringList ipBlacklist; |
||||
for (int i = 0; i < ui->ipBlacklist->count(); i++) |
||||
{ |
||||
QString ip = ui->ipBlacklist->item(i)->text().trimmed(); |
||||
if (!ip.isEmpty()) { |
||||
ipBlacklist.append(ip); |
||||
} |
||||
} |
||||
if (ipBlacklist != m_settings->m_ipBlacklist) |
||||
{ |
||||
m_settings->m_ipBlacklist = ipBlacklist; |
||||
m_settingsKeys.append("ipBlacklist"); |
||||
} |
||||
} |
||||
|
||||
void RemoteTCPSinkSettingsDialog::on_browseCertificate_clicked() |
||||
{ |
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Select SSL Certificate"), |
||||
"", |
||||
tr("SSL certificate (*.cert *.pem)")); |
||||
if (!fileName.isEmpty()) { |
||||
ui->certificate->setText(fileName); |
||||
} |
||||
} |
||||
|
||||
void RemoteTCPSinkSettingsDialog::on_browseKey_clicked() |
||||
{ |
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Select SSL Key"), |
||||
"", |
||||
tr("SSL key (*.key *.pem)")); |
||||
if (!fileName.isEmpty()) { |
||||
ui->key->setText(fileName); |
||||
} |
||||
} |
||||
|
||||
void RemoteTCPSinkSettingsDialog::on_addIP_clicked() |
||||
{ |
||||
QListWidgetItem *item = new QListWidgetItem("1.1.1.1"); |
||||
item->setFlags(Qt::ItemIsEditable | item->flags()); |
||||
ui->ipBlacklist->addItem(item); |
||||
item->setSelected(true); |
||||
} |
||||
|
||||
void RemoteTCPSinkSettingsDialog::on_removeIP_clicked() |
||||
{ |
||||
qDeleteAll(ui->ipBlacklist->selectedItems()); |
||||
} |
||||
|
||||
void RemoteTCPSinkSettingsDialog::on_publicListing_toggled() |
||||
{ |
||||
displayValid(); |
||||
displayEnabled(); |
||||
} |
||||
|
||||
void RemoteTCPSinkSettingsDialog::on_publicAddress_textChanged() |
||||
{ |
||||
displayValid(); |
||||
} |
||||
|
||||
void RemoteTCPSinkSettingsDialog::on_compressor_currentIndexChanged(int index) |
||||
{ |
||||
if (index == 0) |
||||
{ |
||||
// FLAC settings
|
||||
ui->compressionLevel->setMaximum(8); |
||||
ui->blockSize->clear(); |
||||
ui->blockSize->addItem("4096"); |
||||
ui->blockSize->addItem("16384"); |
||||
ui->blockSize->setCurrentIndex(1); |
||||
} |
||||
else if (index == 1) |
||||
{ |
||||
// zlib settings
|
||||
ui->compressionLevel->setMaximum(9); |
||||
ui->blockSize->clear(); |
||||
ui->blockSize->addItem("4096"); |
||||
ui->blockSize->addItem("8192"); |
||||
ui->blockSize->addItem("16384"); |
||||
ui->blockSize->addItem("32768"); |
||||
ui->blockSize->setCurrentIndex(3); |
||||
} |
||||
} |
||||
|
||||
void RemoteTCPSinkSettingsDialog::on_iqOnly_toggled(bool checked) |
||||
{ |
||||
ui->compressionSettings->setEnabled(!checked); |
||||
} |
||||
|
||||
void RemoteTCPSinkSettingsDialog::on_isotropic_toggled(bool checked) |
||||
{ |
||||
displayEnabled(); |
||||
} |
||||
|
||||
void RemoteTCPSinkSettingsDialog::on_rotator_currentIndexChanged(int index) |
||||
{ |
||||
(void) index; |
||||
|
||||
displayEnabled(); |
||||
} |
||||
|
||||
bool RemoteTCPSinkSettingsDialog::isValid() |
||||
{ |
||||
bool valid = true; |
||||
|
||||
if (ui->publicListing->isChecked() && ui->publicAddress->text().isEmpty()) { |
||||
valid = false; |
||||
} |
||||
|
||||
return valid; |
||||
} |
||||
|
||||
void RemoteTCPSinkSettingsDialog::displayValid() |
||||
{ |
||||
bool valid = isValid(); |
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid); |
||||
} |
||||
|
||||
void RemoteTCPSinkSettingsDialog::displayEnabled() |
||||
{ |
||||
bool enabled = ui->publicListing->isChecked(); |
||||
bool none = ui->rotator->currentText() == "None"; |
||||
bool isotropic = ui->isotropic->isChecked(); |
||||
|
||||
ui->publicAddressLabel->setEnabled(enabled); |
||||
ui->publicAddress->setEnabled(enabled); |
||||
ui->publicPort->setEnabled(enabled); |
||||
ui->frequencyLabel->setEnabled(enabled); |
||||
ui->minFrequency->setEnabled(enabled); |
||||
ui->maxFrequency->setEnabled(enabled); |
||||
ui->frequencyUnits->setEnabled(enabled); |
||||
ui->antennaLabel->setEnabled(enabled); |
||||
ui->antenna->setEnabled(enabled); |
||||
ui->locationLabel->setEnabled(enabled); |
||||
ui->location->setEnabled(enabled); |
||||
ui->isotropicLabel->setEnabled(enabled); |
||||
ui->isotropic->setEnabled(enabled); |
||||
ui->rotatorLabel->setEnabled(enabled && !isotropic); |
||||
ui->rotator->setEnabled(enabled && !isotropic); |
||||
ui->directionLabel->setEnabled(enabled && !isotropic && none); |
||||
ui->azimuthLabel->setEnabled(enabled && !isotropic && none); |
||||
ui->azimuth->setEnabled(enabled && !isotropic && none); |
||||
ui->elevationLabel->setEnabled(enabled && !isotropic && none); |
||||
ui->elevation->setEnabled(enabled && !isotropic && none); |
||||
} |
||||
|
||||
void RemoteTCPSinkSettingsDialog::rotatorsChanged(const QStringList& renameFrom, const QStringList& renameTo) |
||||
{ |
||||
AvailableChannelOrFeatureList rotators = m_availableRotatorHandler.getAvailableChannelOrFeatureList(); |
||||
updateRotatorList(rotators, renameFrom, renameTo); |
||||
} |
||||
|
||||
void RemoteTCPSinkSettingsDialog::updateRotatorList(const AvailableChannelOrFeatureList& rotators, const QStringList& renameFrom, const QStringList& renameTo) |
||||
{ |
||||
// Update rotator settting if it has been renamed
|
||||
if (renameFrom.contains(m_settings->m_rotator)) { |
||||
m_settings->m_rotator = renameTo[renameFrom.indexOf(m_settings->m_rotator)]; |
||||
} |
||||
|
||||
// Update list of rotators
|
||||
ui->rotator->blockSignals(true); |
||||
ui->rotator->clear(); |
||||
ui->rotator->addItem("None"); |
||||
|
||||
for (const auto& rotator : rotators) { |
||||
ui->rotator->addItem(rotator.getLongId()); |
||||
} |
||||
|
||||
// Rotator feature can be created after this plugin, so select it
|
||||
// if the chosen rotator appears
|
||||
int rotatorIndex = ui->rotator->findText(m_settings->m_rotator); |
||||
|
||||
if (rotatorIndex >= 0) |
||||
{ |
||||
ui->rotator->setCurrentIndex(rotatorIndex); |
||||
} |
||||
else |
||||
{ |
||||
ui->rotator->setCurrentIndex(0); // return to None
|
||||
} |
||||
|
||||
ui->rotator->blockSignals(false); |
||||
|
||||
displayEnabled(); |
||||
} |
||||
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2024 Jon Beniston, M7RCE <jon@beniston.com> //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_REMOTETCPSINKSETTINGSDIALOG_H |
||||
#define INCLUDE_REMOTETCPSINKSETTINGSDIALOG_H |
||||
|
||||
#include <QDialog> |
||||
|
||||
#include "availablechannelorfeaturehandler.h" |
||||
|
||||
#include "remotetcpsinksettings.h" |
||||
|
||||
namespace Ui { |
||||
class RemoteTCPSinkSettingsDialog; |
||||
} |
||||
|
||||
class RemoteTCPSinkSettingsDialog : public QDialog { |
||||
Q_OBJECT |
||||
public: |
||||
explicit RemoteTCPSinkSettingsDialog(RemoteTCPSinkSettings *settings, QWidget* parent = nullptr); |
||||
~RemoteTCPSinkSettingsDialog(); |
||||
|
||||
const QStringList& getSettingsKeys() const { return m_settingsKeys; }; |
||||
|
||||
private slots: |
||||
void accept(); |
||||
void on_browseCertificate_clicked(); |
||||
void on_browseKey_clicked(); |
||||
void on_addIP_clicked(); |
||||
void on_removeIP_clicked(); |
||||
void on_publicListing_toggled(); |
||||
void on_publicAddress_textChanged(); |
||||
void on_compressor_currentIndexChanged(int index); |
||||
void on_iqOnly_toggled(bool checked); |
||||
void on_isotropic_toggled(bool checked); |
||||
void on_rotator_currentIndexChanged(int index); |
||||
void rotatorsChanged(const QStringList& renameFrom, const QStringList& renameTo); |
||||
|
||||
private: |
||||
Ui::RemoteTCPSinkSettingsDialog *ui; |
||||
RemoteTCPSinkSettings *m_settings; |
||||
QStringList m_settingsKeys; |
||||
AvailableChannelOrFeatureHandler m_availableRotatorHandler; |
||||
|
||||
bool isValid(); |
||||
void displayValid(); |
||||
void displayEnabled(); |
||||
void updateRotatorList(const AvailableChannelOrFeatureList& rotators, const QStringList& renameFrom, const QStringList& renameTo); |
||||
}; |
||||
|
||||
#endif // INCLUDE_REMOTETCPSINKSETTINGSDIALOG_H
|
||||
@ -0,0 +1,675 @@
@@ -0,0 +1,675 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>RemoteTCPSinkSettingsDialog</class> |
||||
<widget class="QDialog" name="RemoteTCPSinkSettingsDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>409</width> |
||||
<height>947</height> |
||||
</rect> |
||||
</property> |
||||
<property name="font"> |
||||
<font> |
||||
<pointsize>9</pointsize> |
||||
</font> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Settings</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QGroupBox" name="serverSettingsGroup"> |
||||
<property name="title"> |
||||
<string>Server Settings</string> |
||||
</property> |
||||
<layout class="QGridLayout" name="gridLayout_2"> |
||||
<item row="2" column="1"> |
||||
<widget class="QSpinBox" name="maxSampleRate"> |
||||
<property name="toolTip"> |
||||
<string>Maximum channel sample rate</string> |
||||
</property> |
||||
<property name="minimum"> |
||||
<number>2700</number> |
||||
</property> |
||||
<property name="maximum"> |
||||
<number>100000000</number> |
||||
</property> |
||||
<property name="value"> |
||||
<number>10000000</number> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="0"> |
||||
<widget class="QLabel" name="timeLimitLabel"> |
||||
<property name="text"> |
||||
<string>Time Limit</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="0"> |
||||
<widget class="QLabel" name="maxClientsLabel"> |
||||
<property name="text"> |
||||
<string>Max Clients</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="1"> |
||||
<widget class="QSpinBox" name="timeLimit"> |
||||
<property name="toolTip"> |
||||
<string>Connection time limit in minutes if max clients reached. 0 for no limit.</string> |
||||
</property> |
||||
<property name="maximum"> |
||||
<number>100000</number> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="0"> |
||||
<widget class="QLabel" name="maxSampleRateLabel"> |
||||
<property name="text"> |
||||
<string>Max Ch. Sample Rate</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="2"> |
||||
<widget class="QLabel" name="maxSampleRateUnits"> |
||||
<property name="text"> |
||||
<string>S/s</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="1"> |
||||
<widget class="QSpinBox" name="maxClients"> |
||||
<property name="toolTip"> |
||||
<string>Maximum number of simultaneous clients</string> |
||||
</property> |
||||
<property name="minimum"> |
||||
<number>0</number> |
||||
</property> |
||||
<property name="maximum"> |
||||
<number>10000</number> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="2"> |
||||
<widget class="QLabel" name="timeLimitUnits"> |
||||
<property name="text"> |
||||
<string>mins</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="0"> |
||||
<widget class="QLabel" name="iqOnlyLabel"> |
||||
<property name="text"> |
||||
<string>IQ only</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="1"> |
||||
<widget class="QCheckBox" name="iqOnly"> |
||||
<property name="toolTip"> |
||||
<string>Transmit uncompressed IQ only. Disables compression, position and messaging support.</string> |
||||
</property> |
||||
<property name="text"> |
||||
<string/> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QGroupBox" name="compressionSettings"> |
||||
<property name="title"> |
||||
<string>Compression</string> |
||||
</property> |
||||
<layout class="QFormLayout" name="formLayout"> |
||||
<item row="0" column="0"> |
||||
<widget class="QLabel" name="compressorLabel"> |
||||
<property name="text"> |
||||
<string>Compressor</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="1"> |
||||
<widget class="QComboBox" name="compressor"> |
||||
<item> |
||||
<property name="text"> |
||||
<string>FLAC</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>zlib</string> |
||||
</property> |
||||
</item> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="0"> |
||||
<widget class="QLabel" name="compressionLevelLabel"> |
||||
<property name="text"> |
||||
<string>Compression Level</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="1"> |
||||
<widget class="QSpinBox" name="compressionLevel"> |
||||
<property name="toolTip"> |
||||
<string>0 - Least compression. 8 - Most compression Higher compression requires more CPU.</string> |
||||
</property> |
||||
<property name="maximum"> |
||||
<number>8</number> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="0"> |
||||
<widget class="QLabel" name="blockSizeLabel"> |
||||
<property name="text"> |
||||
<string>Block size</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="1"> |
||||
<widget class="QComboBox" name="blockSize"> |
||||
<item> |
||||
<property name="text"> |
||||
<string>4096</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>16384</string> |
||||
</property> |
||||
</item> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QGroupBox" name="sslSettingsGroup"> |
||||
<property name="title"> |
||||
<string>SSL Settings</string> |
||||
</property> |
||||
<layout class="QGridLayout" name="gridLayout"> |
||||
<item row="0" column="1"> |
||||
<widget class="QLineEdit" name="certificate"> |
||||
<property name="toolTip"> |
||||
<string>SSL certificate</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="2"> |
||||
<widget class="QToolButton" name="browseKey"> |
||||
<property name="text"> |
||||
<string>...</string> |
||||
</property> |
||||
<property name="icon"> |
||||
<iconset resource="../../../sdrgui/resources/res.qrc"> |
||||
<normaloff>:/load.png</normaloff>:/load.png</iconset> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="0"> |
||||
<widget class="QLabel" name="keyLabel"> |
||||
<property name="text"> |
||||
<string>Key</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="1"> |
||||
<widget class="QLineEdit" name="key"> |
||||
<property name="toolTip"> |
||||
<string>SSL certificate key</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="0"> |
||||
<widget class="QLabel" name="certificateLabel"> |
||||
<property name="minimumSize"> |
||||
<size> |
||||
<width>0</width> |
||||
<height>0</height> |
||||
</size> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Certificate</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="2"> |
||||
<widget class="QToolButton" name="browseCertificate"> |
||||
<property name="text"> |
||||
<string>...</string> |
||||
</property> |
||||
<property name="icon"> |
||||
<iconset resource="../../../sdrgui/resources/res.qrc"> |
||||
<normaloff>:/load.png</normaloff>:/load.png</iconset> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QGroupBox" name="directorySettings"> |
||||
<property name="title"> |
||||
<string>Public Directory</string> |
||||
</property> |
||||
<layout class="QGridLayout" name="gridLayout_3"> |
||||
<item row="3" column="0"> |
||||
<widget class="QLabel" name="antennaLabel"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Antenna</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="1"> |
||||
<widget class="QSpinBox" name="minFrequency"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Minimum recommend frequency in MHz</string> |
||||
</property> |
||||
<property name="maximum"> |
||||
<number>20000</number> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="2"> |
||||
<widget class="QSpinBox" name="publicPort"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Publically accessible port number</string> |
||||
</property> |
||||
<property name="minimum"> |
||||
<number>1024</number> |
||||
</property> |
||||
<property name="maximum"> |
||||
<number>65535</number> |
||||
</property> |
||||
<property name="value"> |
||||
<number>1234</number> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="7" column="0"> |
||||
<widget class="QLabel" name="directionLabel"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Direction</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="4" column="1" colspan="3"> |
||||
<widget class="QLineEdit" name="location"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Town and country where antenna is located</string> |
||||
</property> |
||||
<property name="maxLength"> |
||||
<number>255</number> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="0"> |
||||
<widget class="QLabel" name="publicListingLabel"> |
||||
<property name="text"> |
||||
<string>List Server </string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="5" column="0"> |
||||
<widget class="QLabel" name="isotropicLabel"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Isotropic</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="7" column="1" colspan="3"> |
||||
<layout class="QHBoxLayout" name="directionLayout"> |
||||
<item> |
||||
<widget class="QLabel" name="azimuthLabel"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Az</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QDoubleSpinBox" name="azimuth"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="statusTip"> |
||||
<string>Antenna azimuth in degrees</string> |
||||
</property> |
||||
<property name="decimals"> |
||||
<number>3</number> |
||||
</property> |
||||
<property name="maximum"> |
||||
<double>360.000000000000000</double> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="Line" name="line"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Vertical</enum> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="elevationLabel"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="text"> |
||||
<string>El</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QDoubleSpinBox" name="elevation"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="statusTip"> |
||||
<string>Antenna elevation in degrees</string> |
||||
</property> |
||||
<property name="decimals"> |
||||
<number>3</number> |
||||
</property> |
||||
<property name="minimum"> |
||||
<double>-90.000000000000000</double> |
||||
</property> |
||||
<property name="maximum"> |
||||
<double>90.000000000000000</double> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer name="horizontalSpacer_2"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>40</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item row="2" column="2"> |
||||
<widget class="QSpinBox" name="maxFrequency"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Maximum recommend frequency in MHz</string> |
||||
</property> |
||||
<property name="maximum"> |
||||
<number>20000</number> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="0"> |
||||
<widget class="QLabel" name="publicAddressLabel"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Address</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="4" column="0"> |
||||
<widget class="QLabel" name="locationLabel"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Location</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="3"> |
||||
<widget class="QLabel" name="frequencyUnits"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="text"> |
||||
<string>MHz</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="1"> |
||||
<widget class="QLineEdit" name="publicAddress"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Publically accessible IP address or hostname</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="5" column="1"> |
||||
<widget class="QCheckBox" name="isotropic"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Check to indicate an antenna that is isotropic (non-directional)</string> |
||||
</property> |
||||
<property name="text"> |
||||
<string/> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="1"> |
||||
<widget class="QCheckBox" name="publicListing"> |
||||
<property name="toolTip"> |
||||
<string>Whether to list the server as publically accessible</string> |
||||
</property> |
||||
<property name="text"> |
||||
<string/> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="0"> |
||||
<widget class="QLabel" name="frequencyLabel"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Frequency Range</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="1" colspan="3"> |
||||
<widget class="QLineEdit" name="antenna"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Antenna description</string> |
||||
</property> |
||||
<property name="maxLength"> |
||||
<number>255</number> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="6" column="0"> |
||||
<widget class="QLabel" name="rotatorLabel"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Rotator</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="6" column="1" colspan="2"> |
||||
<widget class="QComboBox" name="rotator"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Rotator feature to get antenna direction from</string> |
||||
</property> |
||||
<item> |
||||
<property name="text"> |
||||
<string>None</string> |
||||
</property> |
||||
</item> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QGroupBox" name="ipBlacklistGroup"> |
||||
<property name="title"> |
||||
<string>IP Blacklist</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout_2"> |
||||
<item> |
||||
<widget class="QListWidget" name="ipBlacklist"> |
||||
<property name="toolTip"> |
||||
<string>List of IP addresses from which connections should not be allowed</string> |
||||
</property> |
||||
<property name="selectionMode"> |
||||
<enum>QAbstractItemView::MultiSelection</enum> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="ipBlacklistLayout"> |
||||
<item> |
||||
<widget class="QToolButton" name="addIP"> |
||||
<property name="text"> |
||||
<string>+</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QToolButton" name="removeIP"> |
||||
<property name="text"> |
||||
<string>-</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer name="horizontalSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>40</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="standardButtons"> |
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<tabstops> |
||||
<tabstop>maxClients</tabstop> |
||||
<tabstop>timeLimit</tabstop> |
||||
<tabstop>maxSampleRate</tabstop> |
||||
<tabstop>iqOnly</tabstop> |
||||
<tabstop>compressor</tabstop> |
||||
<tabstop>compressionLevel</tabstop> |
||||
<tabstop>blockSize</tabstop> |
||||
<tabstop>certificate</tabstop> |
||||
<tabstop>browseCertificate</tabstop> |
||||
<tabstop>key</tabstop> |
||||
<tabstop>browseKey</tabstop> |
||||
<tabstop>publicListing</tabstop> |
||||
<tabstop>publicAddress</tabstop> |
||||
<tabstop>publicPort</tabstop> |
||||
<tabstop>minFrequency</tabstop> |
||||
<tabstop>maxFrequency</tabstop> |
||||
<tabstop>antenna</tabstop> |
||||
<tabstop>location</tabstop> |
||||
<tabstop>isotropic</tabstop> |
||||
<tabstop>rotator</tabstop> |
||||
<tabstop>azimuth</tabstop> |
||||
<tabstop>elevation</tabstop> |
||||
<tabstop>ipBlacklist</tabstop> |
||||
<tabstop>addIP</tabstop> |
||||
<tabstop>removeIP</tabstop> |
||||
</tabstops> |
||||
<resources> |
||||
<include location="../../../sdrgui/resources/res.qrc"/> |
||||
</resources> |
||||
<connections> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>accepted()</signal> |
||||
<receiver>RemoteTCPSinkSettingsDialog</receiver> |
||||
<slot>accept()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>248</x> |
||||
<y>254</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>157</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>rejected()</signal> |
||||
<receiver>RemoteTCPSinkSettingsDialog</receiver> |
||||
<slot>reject()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>316</x> |
||||
<y>260</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>286</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
</connections> |
||||
</ui> |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,160 @@
@@ -0,0 +1,160 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2024 Jon Beniston, M7RCE <jon@beniston.com> //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <algorithm> |
||||
|
||||
#include "socket.h" |
||||
|
||||
Socket::Socket(QObject *socket, QObject *parent) : |
||||
QObject(parent), |
||||
m_socket(socket) |
||||
{ |
||||
} |
||||
|
||||
Socket::~Socket() |
||||
{ |
||||
delete m_socket; |
||||
} |
||||
|
||||
TCPSocket::TCPSocket(QTcpSocket *socket) : |
||||
Socket(socket) |
||||
{ |
||||
} |
||||
|
||||
qint64 TCPSocket::write(const char *data, qint64 length) |
||||
{ |
||||
QTcpSocket *socket = qobject_cast<QTcpSocket *>(m_socket); |
||||
|
||||
return socket->write(data, length); |
||||
} |
||||
|
||||
qint64 TCPSocket::read(char *data, qint64 length) |
||||
{ |
||||
QTcpSocket *socket = qobject_cast<QTcpSocket *>(m_socket); |
||||
|
||||
return socket->read(data, length); |
||||
} |
||||
|
||||
void TCPSocket::close() |
||||
{ |
||||
QTcpSocket *socket = qobject_cast<QTcpSocket *>(m_socket); |
||||
|
||||
socket->close(); |
||||
} |
||||
|
||||
qint64 TCPSocket::bytesAvailable() |
||||
{ |
||||
QTcpSocket *socket = qobject_cast<QTcpSocket *>(m_socket); |
||||
|
||||
return socket->bytesAvailable(); |
||||
} |
||||
|
||||
void TCPSocket::flush() |
||||
{ |
||||
QTcpSocket *socket = qobject_cast<QTcpSocket *>(m_socket); |
||||
|
||||
socket->flush(); |
||||
} |
||||
|
||||
QHostAddress TCPSocket::peerAddress() |
||||
{ |
||||
QTcpSocket *socket = qobject_cast<QTcpSocket *>(m_socket); |
||||
|
||||
return socket->peerAddress(); |
||||
} |
||||
|
||||
quint16 TCPSocket::peerPort() |
||||
{ |
||||
QTcpSocket *socket = qobject_cast<QTcpSocket *>(m_socket); |
||||
|
||||
return socket->peerPort(); |
||||
} |
||||
|
||||
WebSocket::WebSocket(QWebSocket *socket) : |
||||
Socket(socket) |
||||
{ |
||||
m_rxBuffer.reserve(64000); |
||||
m_txBuffer.reserve(64000); |
||||
connect(socket, &QWebSocket::binaryFrameReceived, this, &WebSocket::binaryFrameReceived); |
||||
} |
||||
|
||||
qint64 WebSocket::write(const char *data, qint64 length) |
||||
{ |
||||
//QWebSocket *socket = qobject_cast<QWebSocket *>(m_socket);
|
||||
//return socket->sendBinaryMessage(QByteArray(data, length));
|
||||
|
||||
m_txBuffer.append(data, length); |
||||
return length; |
||||
} |
||||
|
||||
void WebSocket::flush() |
||||
{ |
||||
QWebSocket *socket = qobject_cast<QWebSocket *>(m_socket); |
||||
if (m_txBuffer.size() > 0) |
||||
{ |
||||
qint64 len = socket->sendBinaryMessage(m_txBuffer); |
||||
if (len != m_txBuffer.size()) { |
||||
qDebug() << "WebSocket::flush: Failed to send all of message" << len << "/" << m_txBuffer.size(); |
||||
} |
||||
m_txBuffer.clear(); |
||||
} |
||||
socket->flush(); |
||||
} |
||||
|
||||
qint64 WebSocket::read(char *data, qint64 length) |
||||
{ |
||||
length = std::min(length, (qint64)m_rxBuffer.size()); |
||||
|
||||
memcpy(data, m_rxBuffer.constData(), length); |
||||
|
||||
m_rxBuffer = m_rxBuffer.mid(length); // Yep, not very efficient
|
||||
|
||||
return length; |
||||
} |
||||
|
||||
void WebSocket::close() |
||||
{ |
||||
QWebSocket *socket = qobject_cast<QWebSocket *>(m_socket); |
||||
|
||||
socket->close(); |
||||
} |
||||
|
||||
qint64 WebSocket::bytesAvailable() |
||||
{ |
||||
return m_rxBuffer.size(); |
||||
} |
||||
|
||||
void WebSocket::binaryFrameReceived(const QByteArray &frame, bool isLastFrame) |
||||
{ |
||||
(void) isLastFrame; |
||||
|
||||
m_rxBuffer.append(frame); |
||||
} |
||||
|
||||
QHostAddress WebSocket::peerAddress() |
||||
{ |
||||
QWebSocket *socket = qobject_cast<QWebSocket *>(m_socket); |
||||
|
||||
return socket->peerAddress(); |
||||
} |
||||
|
||||
quint16 WebSocket::peerPort() |
||||
{ |
||||
QWebSocket *socket = qobject_cast<QWebSocket *>(m_socket); |
||||
|
||||
return socket->peerPort(); |
||||
} |
||||
@ -0,0 +1,89 @@
@@ -0,0 +1,89 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2024 Jon Beniston, M7RCE <jon@beniston.com> //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_SOCKET_H_ |
||||
#define INCLUDE_SOCKET_H_ |
||||
|
||||
#include <QTcpSocket> |
||||
#include <QWebSocket> |
||||
|
||||
// Class to allow easy use of either QTCPSocket or QWebSocket
|
||||
class Socket : public QObject { |
||||
Q_OBJECT |
||||
protected: |
||||
Socket(QObject *socket, QObject *parent=nullptr); |
||||
|
||||
public: |
||||
virtual ~Socket(); |
||||
virtual qint64 write(const char *data, qint64 length) = 0; |
||||
virtual void flush() = 0; |
||||
virtual qint64 read(char *data, qint64 length) = 0; |
||||
virtual qint64 bytesAvailable() = 0; |
||||
virtual void close() = 0; |
||||
virtual QHostAddress peerAddress() = 0; |
||||
virtual quint16 peerPort() = 0; |
||||
|
||||
QObject *socket() { return m_socket; } |
||||
|
||||
protected: |
||||
|
||||
QObject *m_socket; |
||||
|
||||
}; |
||||
|
||||
class TCPSocket : public Socket { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
|
||||
TCPSocket(QTcpSocket *socket) ; |
||||
qint64 write(const char *data, qint64 length) override; |
||||
void flush() override; |
||||
qint64 read(char *data, qint64 length) override; |
||||
qint64 bytesAvailable() override; |
||||
void close() override; |
||||
QHostAddress peerAddress() override; |
||||
quint16 peerPort() override; |
||||
|
||||
}; |
||||
|
||||
class WebSocket : public Socket { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
|
||||
WebSocket(QWebSocket *socket); |
||||
qint64 write(const char *data, qint64 length) override; |
||||
void flush() override; |
||||
qint64 read(char *data, qint64 length) override; |
||||
qint64 bytesAvailable() override; |
||||
void close() override; |
||||
QHostAddress peerAddress() override; |
||||
quint16 peerPort() override; |
||||
|
||||
private slots: |
||||
|
||||
void binaryFrameReceived(const QByteArray &frame, bool isLastFrame); |
||||
|
||||
private: |
||||
|
||||
QByteArray m_rxBuffer; |
||||
QByteArray m_txBuffer; |
||||
|
||||
}; |
||||
|
||||
#endif // INCLUDE_SOCKET_H_
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,183 @@
@@ -0,0 +1,183 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2024 Jon Beniston, M7RCE <jon@beniston.com> //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "sdrangelserverlist.h" |
||||
|
||||
#include <QDebug> |
||||
#include <QUrl> |
||||
#include <QUrlQuery> |
||||
#include <QNetworkReply> |
||||
#include <QNetworkDiskCache> |
||||
#include <QRegularExpression> |
||||
|
||||
SDRangelServerList::SDRangelServerList() |
||||
{ |
||||
m_networkManager = new QNetworkAccessManager(); |
||||
QObject::connect(m_networkManager, &QNetworkAccessManager::finished, this, &SDRangelServerList::handleReply); |
||||
|
||||
QStringList locations = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation); |
||||
QDir writeableDir(locations[0]); |
||||
if (!writeableDir.mkpath(QStringLiteral("cache") + QDir::separator() + QStringLiteral("sdrangelserver"))) { |
||||
qDebug() << "Failed to create cache/sdrangelserver"; |
||||
} |
||||
|
||||
m_cache = new QNetworkDiskCache(); |
||||
m_cache->setCacheDirectory(locations[0] + QDir::separator() + QStringLiteral("cache") + QDir::separator() + QStringLiteral("sdrangelserver")); |
||||
m_cache->setMaximumCacheSize(100000000); |
||||
m_networkManager->setCache(m_cache); |
||||
|
||||
connect(&m_timer, &QTimer::timeout, this, &SDRangelServerList::update); |
||||
} |
||||
|
||||
SDRangelServerList::~SDRangelServerList() |
||||
{ |
||||
QObject::disconnect(m_networkManager, &QNetworkAccessManager::finished, this, &SDRangelServerList::handleReply); |
||||
delete m_networkManager; |
||||
} |
||||
|
||||
void SDRangelServerList::getData() |
||||
{ |
||||
QUrl url = QUrl("https://sdrangel.org/websdr/websdrs.json"); |
||||
m_networkManager->get(QNetworkRequest(url)); |
||||
} |
||||
|
||||
void SDRangelServerList::getDataPeriodically(int periodInMins) |
||||
{ |
||||
m_timer.setInterval(periodInMins*60*1000); |
||||
m_timer.start(); |
||||
update(); |
||||
} |
||||
|
||||
void SDRangelServerList::update() |
||||
{ |
||||
getData(); |
||||
} |
||||
|
||||
void SDRangelServerList::handleReply(QNetworkReply* reply) |
||||
{ |
||||
if (reply) |
||||
{ |
||||
if (!reply->error()) |
||||
{ |
||||
QString url = reply->url().toEncoded().constData(); |
||||
QByteArray bytes = reply->readAll(); |
||||
|
||||
handleJSON(url, bytes); |
||||
} |
||||
else |
||||
{ |
||||
qDebug() << "SDRangelServerList::handleReply: error: " << reply->error(); |
||||
} |
||||
reply->deleteLater(); |
||||
} |
||||
else |
||||
{ |
||||
qDebug() << "SDRangelServerList::handleReply: reply is null"; |
||||
} |
||||
} |
||||
|
||||
void SDRangelServerList::handleJSON(const QString& url, const QByteArray& bytes) |
||||
{ |
||||
(void) url; |
||||
|
||||
QList<SDRangelServer> sdrs; |
||||
QJsonDocument document = QJsonDocument::fromJson(bytes); |
||||
|
||||
if (document.isArray()) |
||||
{ |
||||
QJsonArray servers = document.array(); |
||||
|
||||
for (auto valRef : servers) |
||||
{ |
||||
if (valRef.isObject()) |
||||
{ |
||||
QJsonObject serverObj = valRef.toObject(); |
||||
SDRangelServer sdr; |
||||
|
||||
if (serverObj.contains(QStringLiteral("address"))) { |
||||
sdr.m_address = serverObj.value(QStringLiteral("address")).toString(); |
||||
} |
||||
if (serverObj.contains(QStringLiteral("port"))) { |
||||
sdr.m_port = serverObj.value(QStringLiteral("port")).toInt(); |
||||
} |
||||
if (serverObj.contains(QStringLiteral("minFrequency"))) { |
||||
sdr.m_minFrequency = serverObj.value(QStringLiteral("minFrequency")).toInt(); |
||||
} |
||||
if (serverObj.contains(QStringLiteral("maxFrequency"))) { |
||||
sdr.m_maxFrequency = serverObj.value(QStringLiteral("maxFrequency")).toInt(); |
||||
} |
||||
if (serverObj.contains(QStringLiteral("maxSampleRate"))) { |
||||
sdr.m_maxSampleRate = serverObj.value(QStringLiteral("maxSampleRate")).toInt(); |
||||
} |
||||
if (serverObj.contains(QStringLiteral("device"))) { |
||||
sdr.m_device = serverObj.value(QStringLiteral("device")).toString(); |
||||
} |
||||
if (serverObj.contains(QStringLiteral("antenna"))) { |
||||
sdr.m_antenna = serverObj.value(QStringLiteral("antenna")).toString(); |
||||
} |
||||
if (serverObj.contains(QStringLiteral("remoteControl"))) { |
||||
sdr.m_remoteControl = serverObj.value(QStringLiteral("remoteControl")).toInt() == 1; |
||||
} |
||||
if (serverObj.contains(QStringLiteral("stationName"))) { |
||||
sdr.m_stationName = serverObj.value(QStringLiteral("stationName")).toString(); |
||||
} |
||||
if (serverObj.contains(QStringLiteral("location"))) { |
||||
sdr.m_location = serverObj.value(QStringLiteral("location")).toString(); |
||||
} |
||||
if (serverObj.contains(QStringLiteral("latitude"))) { |
||||
sdr.m_latitude = serverObj.value(QStringLiteral("latitude")).toDouble(); |
||||
} |
||||
if (serverObj.contains(QStringLiteral("longitude"))) { |
||||
sdr.m_longitude = serverObj.value(QStringLiteral("longitude")).toDouble(); |
||||
} |
||||
if (serverObj.contains(QStringLiteral("altitude"))) { |
||||
sdr.m_altitude = serverObj.value(QStringLiteral("altitude")).toDouble(); |
||||
} |
||||
if (serverObj.contains(QStringLiteral("isotropic"))) { |
||||
sdr.m_isotropic = serverObj.value(QStringLiteral("isotropic")).toInt() == 1; |
||||
} |
||||
if (serverObj.contains(QStringLiteral("azimuth"))) { |
||||
sdr.m_azimuth = serverObj.value(QStringLiteral("azimuth")).toDouble(); |
||||
} |
||||
if (serverObj.contains(QStringLiteral("elevation"))) { |
||||
sdr.m_elevation = serverObj.value(QStringLiteral("elevation")).toDouble(); |
||||
} |
||||
if (serverObj.contains(QStringLiteral("clients"))) { |
||||
sdr.m_clients = serverObj.value(QStringLiteral("clients")).toInt(); |
||||
} |
||||
if (serverObj.contains(QStringLiteral("maxClients"))) { |
||||
sdr.m_maxClients = serverObj.value(QStringLiteral("maxClients")).toInt(); |
||||
} |
||||
if (serverObj.contains(QStringLiteral("timeLimit"))) { |
||||
sdr.m_timeLimit = serverObj.value(QStringLiteral("timeLimit")).toInt(); |
||||
} |
||||
|
||||
sdrs.append(sdr); |
||||
} |
||||
else |
||||
{ |
||||
qDebug() << "SDRangelServerList::handleJSON: Element not an object:\n" << valRef; |
||||
} |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
qDebug() << "SDRangelServerList::handleJSON: Doc doesn't contain an array:\n" << document; |
||||
} |
||||
|
||||
emit dataUpdated(sdrs); |
||||
} |
||||
@ -0,0 +1,81 @@
@@ -0,0 +1,81 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2024 Jon Beniston, M7RCE <jon@beniston.com> //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_SDRANGELSERVERLIST_H |
||||
#define INCLUDE_SDRANGELSERVERLIST_H |
||||
|
||||
#include <QtCore> |
||||
#include <QTimer> |
||||
|
||||
#include "export.h" |
||||
|
||||
class QNetworkAccessManager; |
||||
class QNetworkReply; |
||||
class QNetworkDiskCache; |
||||
|
||||
// Gets a list of public SDRangel Servers from https://sdrangel.org/websdr/
|
||||
class SDRBASE_API SDRangelServerList : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
|
||||
struct SDRangelServer { |
||||
QString m_address; |
||||
quint16 m_port; |
||||
qint64 m_minFrequency; |
||||
qint64 m_maxFrequency; |
||||
int m_maxSampleRate; |
||||
QString m_device; |
||||
QString m_antenna; |
||||
bool m_remoteControl; |
||||
QString m_stationName; |
||||
QString m_location; |
||||
float m_latitude; |
||||
float m_longitude; |
||||
float m_altitude; |
||||
bool m_isotropic; |
||||
float m_azimuth; |
||||
float m_elevation; |
||||
int m_clients; |
||||
int m_maxClients; |
||||
int m_timeLimit; // In minutes
|
||||
}; |
||||
|
||||
SDRangelServerList(); |
||||
~SDRangelServerList(); |
||||
|
||||
void getData(); |
||||
void getDataPeriodically(int periodInMins=1); |
||||
|
||||
public slots: |
||||
void handleReply(QNetworkReply* reply); |
||||
void update(); |
||||
|
||||
signals: |
||||
void dataUpdated(const QList<SDRangelServer>& sdrs); // Emitted when data are available.
|
||||
|
||||
private: |
||||
QNetworkAccessManager *m_networkManager; |
||||
QNetworkDiskCache *m_cache; |
||||
QTimer m_timer; // Timer for periodic updates
|
||||
|
||||
void handleJSON(const QString& url, const QByteArray& bytes); |
||||
|
||||
}; |
||||
|
||||
#endif /* INCLUDE_SDRANGELSERVERLIST_H */ |
||||
Loading…
Reference in new issue