Skip to content

Commit

Permalink
SHV API: event path + API key
Browse files Browse the repository at this point in the history
  • Loading branch information
Fanda Vacek committed Jun 19, 2024
1 parent 9af2be0 commit 3a55887
Show file tree
Hide file tree
Showing 16 changed files with 293 additions and 164 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/libshv
Submodule libshv updated 73 files
+16 −7 .github/actions/cmake/action.yml
+2 −1 .github/actions/run-linter/action.yml
+22 −0 .github/workflows/delete-pr-cache.yml
+1 −0 .github/workflows/lupdate.yml
+44 −1 .github/workflows/test.yml
+1 −1 3rdparty/necrolog
+2 −0 CMakeLists.txt
+1 −1 README.md
+2 −0 examples/gui/samplegraph/CMakeLists.txt
+73 −0 examples/gui/samplegraph/histogramgraphwidget.cpp
+27 −0 examples/gui/samplegraph/histogramgraphwidget.h
+67 −0 examples/gui/samplegraph/histogramgraphwidget.ui
+2 −2 examples/gui/samplegraph/main.cpp
+12 −162 examples/gui/samplegraph/mainwindow.cpp
+2 −7 examples/gui/samplegraph/mainwindow.h
+28 −48 examples/gui/samplegraph/mainwindow.ui
+179 −0 examples/gui/samplegraph/timelinegraphwidget.cpp
+27 −0 examples/gui/samplegraph/timelinegraphwidget.h
+67 −0 examples/gui/samplegraph/timelinegraphwidget.ui
+0 −1 libshvbroker/CMakeLists.txt
+2 −2 libshvbroker/src/aclmanager.cpp
+1 −0 libshvbroker/src/brokeraclnode.h
+0 −1 libshvchainpack/CMakeLists.txt
+0 −1 libshvchainpack/c/CMakeLists.txt
+3 −3 libshvchainpack/include/shv/chainpack/datachange.h
+5 −5 libshvchainpack/src/datachange.cpp
+5 −1 libshvchainpack/src/rpcvalue.cpp
+0 −1 libshvcore/CMakeLists.txt
+1 −1 libshvcore/include/shv/core/utils/shvtypeinfo.h
+3 −2 libshvcore/src/utils/shvfilejournal.cpp
+5 −4 libshvcore/src/utils/shvjournalfilereader.cpp
+10 −5 libshvcore/src/utils/shvtypeinfo.cpp
+0 −1 libshvcoreqt/CMakeLists.txt
+1 −0 libshvcoreqt/include/shv/coreqt/rpc.h
+5 −0 libshvcoreqt/src/rpc.cpp
+2 −10 libshvcoreqt/src/utils.cpp
+0 −1 libshviotqt/CMakeLists.txt
+1 −0 libshviotqt/include/shv/iotqt/node/shvnode.h
+1 −1 libshviotqt/src/node/localfsnode.cpp
+0 −1 libshvvisu/CMakeLists.txt
+2 −0 libshvvisu/images/images.qrc
+1 −0 libshvvisu/images/raw-off.svg
+1 −0 libshvvisu/images/raw.svg
+1 −0 libshvvisu/include/shv/visu/logview/dataviewwidget.h
+5 −0 libshvvisu/include/shv/visu/svgscene/graphicsview.h
+1 −0 libshvvisu/include/shv/visu/svgscene/types.h
+8 −5 libshvvisu/include/shv/visu/timeline/channelfiltermodel.h
+2 −0 libshvvisu/include/shv/visu/timeline/channelprobe.h
+9 −6 libshvvisu/include/shv/visu/timeline/graph.h
+6 −0 libshvvisu/include/shv/visu/timeline/graphmodel.h
+42 −10 libshvvisu/libshvvisu.cs_CZ.ts
+36 −16 libshvvisu/libshvvisu.de_DE.ts
+36 −16 libshvvisu/libshvvisu.fi_FI.ts
+36 −16 libshvvisu/libshvvisu.hu_HU.ts
+36 −16 libshvvisu/libshvvisu.it_IT.ts
+36 −16 libshvvisu/libshvvisu.nl_BE.ts
+141 −109 libshvvisu/libshvvisu.pl_PL.ts
+532 −0 libshvvisu/libshvvisu.sk_SK.ts
+36 −16 libshvvisu/libshvvisu.sr_RS.ts
+12 −0 libshvvisu/src/logview/dataviewwidget.cpp
+16 −2 libshvvisu/src/logview/dataviewwidget.ui
+2 −2 libshvvisu/src/logview/dlgloginspector.ui
+30 −1 libshvvisu/src/svgscene/graphicsview.cpp
+1 −0 libshvvisu/src/svgscene/types.cpp
+2 −2 libshvvisu/src/timeline/channelfilterdialog.cpp
+55 −21 libshvvisu/src/timeline/channelfiltermodel.cpp
+20 −3 libshvvisu/src/timeline/channelprobe.cpp
+27 −12 libshvvisu/src/timeline/channelprobewidget.cpp
+233 −137 libshvvisu/src/timeline/graph.cpp
+33 −16 libshvvisu/src/timeline/graphmodel.cpp
+13 −7 libshvvisu/src/timeline/graphview.cpp
+25 −6 libshvvisu/src/timeline/graphwidget.cpp
+0 −1 libshvvisu/src/widgets/timezonecombobox.cpp
2 changes: 1 addition & 1 deletion 3rdparty/necrolog
4 changes: 2 additions & 2 deletions quickevent/app/quickevent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ add_executable(quickevent
if(WITH_QE_SHVAPI)
target_compile_definitions(quickevent PRIVATE WITH_QE_SHVAPI)
target_sources(quickevent PRIVATE
plugins/Event/src/services/shvapi/client.cpp
plugins/Event/src/services/shvapi/clientwidget.cpp
plugins/Event/src/services/shvapi/shvclientservice.cpp plugins/Event/src/services/shvapi/shvclientservice.h
plugins/Event/src/services/shvapi/shvclientservicewidget.cpp plugins/Event/src/services/shvapi/shvclientservicewidget.h plugins/Event/src/services/shvapi/shvclientservicewidget.ui
plugins/Event/src/services/shvapi/shvnode.cpp
plugins/Event/src/services/shvapi/sqlapinode.cpp
plugins/Event/src/services/shvapi/nodes.cpp
Expand Down
15 changes: 15 additions & 0 deletions quickevent/app/quickevent/plugins/Core/src/coreplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <qf/core/sql/connection.h>
#include <qf/core/log.h>
#include <qf/core/utils/crypt.h>

#include <QCoreApplication>
#include <QProcess>
Expand Down Expand Up @@ -44,6 +45,20 @@ const QString CorePlugin::SETTINGS_PREFIX_APPLICATION_LOCALE_LANGUAGE()
return s;
}

namespace {
qf::core::utils::Crypt s_crypt(qf::core::utils::Crypt::createGenerator(16808, 11, 2147483647));
}

QByteArray CorePlugin::encrypt(const QByteArray &data, int min_length)
{
return s_crypt.encrypt(data, min_length);
}

QByteArray CorePlugin::decrypt(const QByteArray &data)
{
return s_crypt.decrypt(data);
}

void CorePlugin::onInstalled()
{
qff::MainWindow *fwk = qff::MainWindow::frameWork();
Expand Down
3 changes: 3 additions & 0 deletions quickevent/app/quickevent/plugins/Core/src/coreplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class CorePlugin : public qf::qmlwidgets::framework::Plugin

static const QString SETTINGS_PREFIX_APPLICATION_LOCALE_LANGUAGE();

Q_REQUIRED_RESULT static QByteArray encrypt(const QByteArray &data, int min_length = 16);
Q_REQUIRED_RESULT static QByteArray decrypt(const QByteArray &data);

void onInstalled();
private:
SettingsDialog *m_settingsDialog = nullptr;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "connectionsettings.h"

#include <qf/core/utils/crypt.h>
#include <plugins/Core/src/coreplugin.h>

#include <qf/core/log.h>

#include <QStandardPaths>
Expand All @@ -17,8 +18,6 @@ static const auto USER = QStringLiteral("user");
static const auto PASSWORD = QStringLiteral("password");
static const auto WORKING_DIR = QStringLiteral("workingDir");
static const auto EVENT_NAME = QStringLiteral("eventName");

qf::core::utils::Crypt s_crypt(qf::core::utils::Crypt::createGenerator(16808, 11, 2147483647));
}

ConnectionSettings::ConnectionSettings(QObject *parent)
Expand Down Expand Up @@ -55,7 +54,7 @@ void ConnectionSettings::setServerUser(const QString &s)

void ConnectionSettings::setServerPassword(const QString &s)
{
QByteArray ba = s_crypt.encrypt(s.toUtf8(), 32);
QByteArray ba = Core::CorePlugin::encrypt(s.toUtf8(), 32);
setValue(EVENT + '/' + DATA_STORAGE + '/' + SQL_SERVER + '/' + PASSWORD, QString::fromLatin1(ba));
}

Expand Down Expand Up @@ -95,7 +94,7 @@ QString ConnectionSettings::serverUser()
QString ConnectionSettings::serverPassword()
{
QByteArray ba = value(EVENT + '/' + DATA_STORAGE + '/' + SQL_SERVER + '/' + PASSWORD).toString().toLatin1();
return QString::fromUtf8(s_crypt.decrypt(ba));
return QString::fromUtf8(Core::CorePlugin::decrypt(ba));
}

QString ConnectionSettings::singleWorkingDir()
Expand Down
25 changes: 23 additions & 2 deletions quickevent/app/quickevent/plugins/Event/src/eventplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
#include "dbschema.h"
#include "stagedocument.h"
#include "stagewidget.h"
#include "../../Core/src/coreplugin.h"
#include "../../Core/src/widgets/appstatusbar.h"

#include "services/serviceswidget.h"
#include "services/emmaclient.h"
#ifdef WITH_QE_SHVAPI
#include "services/shvapi/client.h"
#include "services/shvapi/shvclientservice.h"
#endif

#include <quickevent/core/og/timems.h>
Expand Down Expand Up @@ -52,6 +53,7 @@
#include <QJsonParseError>
#include <QJsonDocument>
#include <QTimer>
#include <QRandomGenerator>

#include <regex>

Expand Down Expand Up @@ -378,7 +380,7 @@ void EventPlugin::onInstalled()
services::Service::addService(emma_client);

#ifdef WITH_QE_SHVAPI
auto shvapi_client = new services::shvapi::Client(this);
auto shvapi_client = new services::shvapi::ShvClientService(this);
services::Service::addService(shvapi_client);
#endif

Expand Down Expand Up @@ -501,6 +503,25 @@ QString EventPlugin::classNameById(int class_id)
return m_classNameCache.value(class_id);
}

QString EventPlugin::shvApiEventId() const
{
return eventName() + "-" + QString::number(m_eventConfig->importId());
}

QString EventPlugin::createShvApiKey()
{
QString key;
QList<char> cc;
for (auto i = 'a'; i <= 'z'; i++) { cc << i; }
for (auto i = 'A'; i <= 'Z'; i++) { cc << i; }
for (auto i = '0'; i <= '9'; i++) { cc << i; }
for (int i = 0; i < 16; i++) {
quint32 ix = QRandomGenerator::global()->generate() % cc.size();
key += cc[ix];
}
return key;
}

DbSchema *EventPlugin::dbSchema()
{
return new DbSchema(this);
Expand Down
3 changes: 3 additions & 0 deletions quickevent/app/quickevent/plugins/Event/src/eventplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ class EventPlugin : public qf::qmlwidgets::framework::Plugin

Q_INVOKABLE QString classNameById(int class_id);

QString shvApiEventId() const;
static QString createShvApiKey();

DbSchema* dbSchema();
static int dbVersion();

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 3a55887

Please sign in to comment.