Skip to content

Commit 120a563

Browse files
authored
Merge pull request #987 from m-seker/refactor/cleanup
Cleanup
2 parents 6cd7fc6 + 0a2961a commit 120a563

File tree

7 files changed

+17
-65
lines changed

7 files changed

+17
-65
lines changed

include/effectengine/Effect.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <QSize>
1313
#include <QImage>
1414
#include <QPainter>
15-
#include <QMap>
1615

1716
// Hyperion includes
1817
#include <utils/Components.h>

libsrc/api/JsonAPI.cpp

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
// project includes
22
#include <api/JsonAPI.h>
33

4-
// stl includes
5-
#include <iostream>
6-
#include <iterator>
7-
84
// Qt includes
95
#include <QResource>
106
#include <QDateTime>
11-
#include <QCryptographicHash>
127
#include <QImage>
138
#include <QBuffer>
149
#include <QByteArray>
@@ -18,7 +13,6 @@
1813

1914
// hyperion includes
2015
#include <leddevice/LedDeviceWrapper.h>
21-
2216
#include <leddevice/LedDevice.h>
2317
#include <leddevice/LedDeviceFactory.h>
2418

@@ -49,33 +43,13 @@ using namespace hyperion;
4943

5044
JsonAPI::JsonAPI(QString peerAddress, Logger *log, bool localConnection, QObject *parent, bool noListener)
5145
: API(log, localConnection, parent)
52-
/* , _authManager(AuthManager::getInstance()) // moved to API
53-
, _authorized(false)
54-
, _adminAuthorized(false)
55-
, _apiAuthRequired(_authManager->isAuthRequired())
56-
, _noListener(noListener)
57-
, _peerAddress(peerAddress)
58-
, _log(log) // moved to API
59-
, _localConnection(localConnection)
60-
, _instanceManager(HyperionIManager::getInstance())
61-
, _hyperion(nullptr) // moved
62-
, _jsonCB(new JsonCB(this))
63-
, _streaming_logging_activated(false)
64-
, _ledStreamTimer(new QTimer(this)) */
6546
{
66-
//_authManager = AuthManager::getInstance(); // moved to API init
67-
//_authorized = false; // moved INIT api
68-
//_adminAuthorized = false; // moved INIT api
69-
//_apiAuthRequired = _authManager->isAuthRequired();
7047
_noListener = noListener;
7148
_peerAddress = peerAddress;
72-
//_log = log; // moved to API
73-
// _localConnection = localConnection; moved init ti api
74-
//_instanceManager = HyperionIManager::getInstance();
75-
//_hyperion = nullptr; // moved
7649
_jsonCB = new JsonCB(this);
7750
_streaming_logging_activated = false;
7851
_ledStreamTimer = new QTimer(this);
52+
7953
Q_INIT_RESOURCE(JSONRPC_schemas);
8054
}
8155

@@ -199,7 +173,7 @@ void JsonAPI::handleMessage(const QString &messageString, const QString &httpAut
199173
else if (command == "leddevice")
200174
handleLedDeviceCommand(message, command, tan);
201175

202-
// BEGIN | The following commands are derecated but used to ensure backward compatibility with hyperion Classic remote control
176+
// BEGIN | The following commands are deprecated but used to ensure backward compatibility with hyperion Classic remote control
203177
else if (command == "clearall")
204178
handleClearallCommand(message, command, tan);
205179
else if (command == "transform" || command == "correction" || command == "temperature")
@@ -330,7 +304,7 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject &message, const QString
330304
activePriorities.removeAll(255);
331305
int currentPriority = _hyperion->getCurrentPriority();
332306

333-
foreach (int priority, activePriorities)
307+
for(int priority : activePriorities)
334308
{
335309
const Hyperion::InputInfo &priorityInfo = _hyperion->getPriorityInfo(priority);
336310
QJsonObject item;

libsrc/effectengine/Effect.cpp

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
1-
// stl includes
2-
#include <iostream>
3-
#include <sstream>
4-
#include <cmath>
5-
61
// Qt includes
72
#include <QDateTime>
83
#include <QFile>
9-
#include <Qt>
10-
#include <QLinearGradient>
11-
#include <QConicalGradient>
12-
#include <QRadialGradient>
13-
#include <QRect>
14-
#include <QImageReader>
154
#include <QResource>
165

176
// effect engin eincludes
@@ -20,11 +9,8 @@
209
#include <utils/Logger.h>
2110
#include <hyperion/Hyperion.h>
2211

23-
// python utils/ global mainthread
12+
// python utils
2413
#include <python/PythonProgram.h>
25-
#include <python/PythonUtils.h>
26-
//impl
27-
PyThreadState* mainThreadState;
2814

2915
Effect::Effect(Hyperion *hyperion, int priority, int timeout, const QString &script, const QString &name, const QJsonObject &args, const QString &imageData)
3016
: QThread()
@@ -100,19 +86,13 @@ void Effect::run()
10086

10187
// Run the effect script
10288
QFile file (_script);
103-
QByteArray python_code;
10489
if (file.open(QIODevice::ReadOnly))
10590
{
106-
python_code = file.readAll();
91+
program.execute(file.readAll());
10792
}
10893
else
10994
{
11095
Error(_log, "Unable to open script file %s.", QSTRING_CSTR(_script));
11196
}
11297
file.close();
113-
114-
if (!python_code.isEmpty())
115-
{
116-
program.execute(python_code);
117-
}
11898
}

libsrc/effectengine/EffectEngine.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44

55
// Qt includes
66
#include <QResource>
7-
#include <QMetaType>
8-
#include <QFile>
9-
#include <QDir>
10-
#include <QMap>
117

128
// hyperion util includes
139
#include <utils/jsonschema/QJsonSchemaChecker.h>

libsrc/leddevice/dev_hid/deactivated/LedDeviceLightpack-hidapi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ LedDeviceLightpackHidapi::~LedDeviceLightpackHidapi()
5353
_deviceHandle = nullptr;
5454
}
5555

56-
// TODO: Should be called to avoid memory loss, but only at the end of the application
56+
// TODO: Should be called to avoid memory leak, but only at the end of the application
5757
//hid_exit();
5858
}
5959

libsrc/python/PythonProgram.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include <QThread>
66

7+
PyThreadState* mainThreadState;
8+
79
PythonProgram::PythonProgram(const QString & name, Logger * log) :
810
_name(name), _log(log), _tstate(nullptr)
911
{

libsrc/ssdp/SSDPServer.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ static const QString UPNP_ALIVE_MESSAGE = "NOTIFY * HTTP/1.1\r\n"
2727
"NTS: ssdp:alive\r\n"
2828
"SERVER: %4\r\n"
2929
"USN: uuid:%5\r\n"
30-
"HYPERION-FBS-PORT: %6\r\n"
31-
"HYPERION-JSS-PORT: %7\r\n"
32-
"HYPERION-NAME: %8\r\n"
30+
"HYPERION-FBS-PORT: %6\r\n"
31+
"HYPERION-JSS-PORT: %7\r\n"
32+
"HYPERION-NAME: %8\r\n"
3333
"\r\n";
3434

3535
// Implement ssdp:update as per spec 1.1, section 1.2.4
@@ -45,7 +45,7 @@ static const QString UPNP_UPDATE_MESSAGE = "NOTIFY * HTTP/1.1\r\n"
4545
/* "CONFIGID.UPNP.ORG: %4\r\n"
4646
UPNP spec = 1.1 "NEXTBOOTID.UPNP.ORG: %5\r\n"
4747
"SEARCHPORT.UPNP.ORG: %6\r\n"
48-
*/ "\r\n";
48+
*/ "\r\n";
4949

5050
// TODO: Add this two fields commented below in the BYEBYE MESSAGE
5151
// as per upnp spec 1.1, section 1.2.2 and 1.2.3.
@@ -72,9 +72,9 @@ static const QString UPNP_MSEARCH_RESPONSE = "HTTP/1.1 200 OK\r\n"
7272
"SERVER: %4\r\n"
7373
"ST: %5\r\n"
7474
"USN: uuid:%6\r\n"
75-
"HYPERION-FBS-PORT: %7\r\n"
76-
"HYPERION-JSS-PORT: %8\r\n"
77-
"HYPERION-NAME: %9\r\n"
75+
"HYPERION-FBS-PORT: %7\r\n"
76+
"HYPERION-JSS-PORT: %8\r\n"
77+
"HYPERION-NAME: %9\r\n"
7878
"\r\n";
7979

8080
SSDPServer::SSDPServer(QObject * parent)
@@ -99,7 +99,8 @@ void SSDPServer::initServer()
9999
SysInfo::HyperionSysInfo data = SysInfo::get();
100100

101101
// create SERVER String
102-
_serverHeader = data.prettyName+"/"+data.productVersion+" UPnP/1.0 Hyperion/"+QString(HYPERION_VERSION);
102+
_serverHeader = QString("%1/%2 UPnP/1.0 Hyperion/%3")
103+
.arg(data.prettyName, data.productVersion, HYPERION_VERSION);
103104

104105
connect(_udpSocket, &QUdpSocket::readyRead, this, &SSDPServer::readPendingDatagrams);
105106
}

0 commit comments

Comments
 (0)