Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
awawa-dev committed Jun 3, 2024
1 parent d46a021 commit 9594606
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion sources/base/Smoothing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ unsigned Smoothing::AddEffectConfig(unsigned cfgID, int settlingTime_ms, double
}
else
{
for (int currentCfgID = SMOOTHING_EFFECT_CONFIGS_START; currentCfgID < _configurations.size(); currentCfgID++)
for (unsigned int currentCfgID = SMOOTHING_EFFECT_CONFIGS_START; currentCfgID < _configurations.size(); currentCfgID++)
{
auto& element = _configurations[currentCfgID];
if ((element->settlingTime == settlingTime_ms &&
Expand Down
8 changes: 4 additions & 4 deletions sources/db/DBManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ bool DBManager::getRecord(const VectorPair& conditions, QVariantMap& results, co
query.next();

SqlRecord rec = query.record();
for (int i = 0; i < rec.count(); i++)
for (unsigned int i = 0; i < rec.count(); i++)
{
results[rec.fieldName(i)] = rec.value(i);
}
Expand Down Expand Up @@ -315,7 +315,7 @@ bool DBManager::getRecords(QVector<QVariantMap>& results, const QStringList& tCo
{
QVariantMap entry;
SqlRecord rec = query.record();
for (int i = 0; i < rec.count(); i++)
for (unsigned int i = 0; i < rec.count(); i++)
{
entry[rec.fieldName(i)] = rec.value(i);
}
Expand Down Expand Up @@ -523,7 +523,7 @@ const QJsonObject DBManager::getBackup()
{
QJsonObject entry;
SqlRecord rec = queryInst.record();
for (int i = 0; i < rec.count(); i++)
for (unsigned int i = 0; i < rec.count(); i++)
if (instanceKeys.contains(rec.fieldName(i), Qt::CaseInsensitive) && !rec.value(i).isNull())
{
entry[rec.fieldName(i)] = QJsonValue::fromVariant(rec.value(i));
Expand All @@ -539,7 +539,7 @@ const QJsonObject DBManager::getBackup()
SqlRecord rec = querySet.record();
bool valid = false;

for (int i = 0; i < rec.count(); i++)
for (unsigned int i = 0; i < rec.count(); i++)
if (settingsKeys.contains(rec.fieldName(i), Qt::CaseInsensitive) && !rec.value(i).isNull())
{
QVariant column = rec.value(i);
Expand Down
6 changes: 3 additions & 3 deletions sources/db/SQLite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ bool SqlDatabase::doesColumnExist(QString table, QString column)
bool hasRow = false;
QString query = QString("SELECT * FROM pragma_table_info('%1') WHERE name='%2';").arg(table).arg(column);
const QByteArray& text = query.toUtf8().constData();
auto result = sqlite3_exec(_handle, text, [](void* _hasRow, int argc, char** argv, char** azColName) {
sqlite3_exec(_handle, text, [](void* _hasRow, int argc, char** argv, char** azColName) {
*(reinterpret_cast<bool*>(_hasRow)) = true;
return 0;
}, &hasRow, NULL);
Expand All @@ -143,7 +143,7 @@ bool SqlDatabase::doesTableExist(QString table)
bool hasRow = false;
QString query = QString("SELECT name FROM sqlite_master WHERE type = 'table' AND name = '%1';").arg(table);
const QByteArray& text = query.toUtf8().constData();
auto result = sqlite3_exec(_handle, text, [](void* _hasRow, int argc, char** argv, char** azColName) {
sqlite3_exec(_handle, text, [](void* _hasRow, int argc, char** argv, char** azColName) {
*(reinterpret_cast<bool*>(_hasRow)) = true;
return 0;
}, &hasRow, NULL);
Expand All @@ -155,7 +155,7 @@ bool SqlDatabase::isEmpty()
bool hasRow = false;
QString query = QString("SELECT name FROM sqlite_master WHERE type = 'table';");
const QByteArray& text = query.toUtf8().constData();
auto result = sqlite3_exec(_handle, text, [](void* _hasRow, int argc, char** argv, char** azColName) {
sqlite3_exec(_handle, text, [](void* _hasRow, int argc, char** argv, char** azColName) {
*(reinterpret_cast<bool*>(_hasRow)) = true;
return 0;
}, &hasRow, NULL);
Expand Down
20 changes: 12 additions & 8 deletions sources/leddevice/dev_net/ProviderUdpSSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@
Q_IMPORT_PLUGIN(QTlsBackendOpenSSLPlugin)
#endif

const int MAX_RETRY = 20;
const ushort MAX_PORT_SSL = 65535;

ProviderUdpSSL::ProviderUdpSSL(const QJsonObject& deviceConfig)
: LedDevice(deviceConfig)
, _transport_type("DTLS")
Expand Down Expand Up @@ -127,7 +124,7 @@ bool ProviderUdpSSL::init(const QJsonObject& deviceConfig)

int config_port = deviceConfig["sslport"].toInt(_port);

if (config_port <= 0 || config_port > MAX_PORT_SSL)
if (config_port <= 0 || config_port > 65535)
{
QString errortext = QString("Invalid target port [%1]!").arg(config_port);
this->setInError(errortext);
Expand Down Expand Up @@ -189,7 +186,8 @@ bool ProviderUdpSSL::initNetwork()
});

connect(_socket, &QUdpSocket::errorOccurred, this, [&](QAbstractSocket::SocketError socketError) {
errorHandling(QString("Socket error nr: %1").arg(QString::number(socketError)));
QString message = QString("Socket error nr: %1").arg(QString::number(socketError));
QUEUE_CALL_1(this, errorHandling, QString, message);
});

connect(_socket, &QUdpSocket::readyRead, this, [&](){
Expand All @@ -206,7 +204,11 @@ bool ProviderUdpSSL::initNetwork()
dgram.resize(bytesRead);

if (!_dtls->doHandshake(_socket, dgram))
errorHandling("Failed to continue the handshake");
{
QString message = "Failed to continue the handshake";
QUEUE_CALL_1(this, errorHandling, QString, message);
return;
}

if (_dtls->isConnectionEncrypted())
{
Expand Down Expand Up @@ -274,12 +276,14 @@ void ProviderUdpSSL::handshakeTimeout()

if (!_dtls->handleTimeout(_socket))
{
errorHandling("Failed to resume the handshake after timeout");
QString message = "Failed to resume the handshake after timeout";
QUEUE_CALL_1(this, errorHandling, QString, message);
}
}
else
{
errorHandling("Another timeout. Give up");
QString message = "Another timeout. Give up";
QUEUE_CALL_1(this, errorHandling, QString, message);
}
}

Expand Down
4 changes: 2 additions & 2 deletions sources/leddevice/dev_net/ProviderUdpSSL.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ class ProviderUdpSSL : public LedDevice
protected:
bool init(const QJsonObject& deviceConfig) override;
int closeNetwork();
bool initNetwork();
void errorHandling(QString message);
bool initNetwork();
void writeBytes(unsigned int size, const uint8_t* data, bool flush = false);
virtual std::list<QString> getCiphersuites();

public slots:
void pskRequired(QSslPreSharedKeyAuthenticator* authenticator);
void handshakeTimeout();
void errorHandling(QString message);

private:
QString _transport_type;
Expand Down
2 changes: 1 addition & 1 deletion sources/systray/SystrayLinux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ extern "C"
{
void SystrayUpdate(SystrayMenu* tray)
{
app_indicator_set_icon(indicator, const_cast<char*>(tray->tooltip.c_str()));
app_indicator_set_icon_full(indicator, const_cast<char*>(tray->tooltip.c_str()), "HyperHDR");
app_indicator_set_menu(indicator, GTK_MENU(_tray_menu(tray->submenu.get())));
}

Expand Down

0 comments on commit 9594606

Please sign in to comment.