mirror of
https://gitlab.com/spaceti-app/integrations/acs/colnod-connector.git
synced 2026-07-12 13:10:45 +02:00
stopep using config file
This commit is contained in:
parent
83c77c9b1c
commit
94edc63f5e
@ -7,14 +7,14 @@ RequestManager::RequestManager()
|
|||||||
loginStatus = false; //should be false, true for testing request header
|
loginStatus = false; //should be false, true for testing request header
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
QFile configFile(QDir::current().filePath("config.json"));
|
QFile configFile(QDir::current().filePath("config.json"));
|
||||||
if (!configFile.open(QIODevice::ReadOnly)) {
|
if (!configFile.open(QIODevice::ReadOnly)) {
|
||||||
qCritical() << "Couldn't open config file config.json" << QDir::current().filePath("config.json");
|
qCritical() << "Couldn't open config file config.json" << QDir::current().filePath("config.json");
|
||||||
QCoreApplication::exit(-1);
|
QCoreApplication::exit(-1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->config = QJsonDocument::fromJson(configFile.readAll());
|
this->config = QJsonDocument::fromJson(configFile.readAll());*/
|
||||||
QObject::connect(manager, &QNetworkAccessManager::sslErrors, this, &RequestManager::onSSLError);
|
QObject::connect(manager, &QNetworkAccessManager::sslErrors, this, &RequestManager::onSSLError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,8 @@ void RequestManager::getRequest(QString endpoint)
|
|||||||
{
|
{
|
||||||
if (!loginStatus)
|
if (!loginStatus)
|
||||||
{
|
{
|
||||||
login(config.object()["host"].toString(), config.object()["username"].toString(), config.object()["password"].toString());
|
// login(config.object()["host"].toString(), config.object()["username"].toString(), config.object()["password"].toString());
|
||||||
|
login(host, user, password);
|
||||||
// QEventLoop loop;
|
// QEventLoop loop;
|
||||||
// QObject::connect(this, &RequestManager::successLogin, &loop, &QEventLoop::quit);
|
// QObject::connect(this, &RequestManager::successLogin, &loop, &QEventLoop::quit);
|
||||||
// loop.exec();
|
// loop.exec();
|
||||||
|
|||||||
@ -1,72 +1,74 @@
|
|||||||
#ifndef REQUESTMANAGER_H
|
#ifndef REQUESTMANAGER_H
|
||||||
#define REQUESTMANAGER_H
|
#define REQUESTMANAGER_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <qcoreapplication.h>
|
#include <qcoreapplication.h>
|
||||||
#include <qnetworkreply.h>
|
#include <qnetworkreply.h>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonParseError>
|
#include <QJsonParseError>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QMultiMap>
|
#include <QMultiMap>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QSslError>
|
#include <QSslError>
|
||||||
|
|
||||||
|
|
||||||
#include "databasemanager.h"
|
#include "databasemanager.h"
|
||||||
#include "token.h"
|
#include "token.h"
|
||||||
#include "subject.h"
|
#include "subject.h"
|
||||||
|
|
||||||
class RequestManager : public QObject
|
class RequestManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RequestManager();
|
RequestManager();
|
||||||
void getSubjects();
|
void getSubjects();
|
||||||
void login(QString endpoint, QString username, QString password);
|
void login(QString endpoint, QString username, QString password);
|
||||||
void getRequest(QString endpoint);
|
void getRequest(QString endpoint);
|
||||||
void loadSubjectsFromColnodToDB();
|
void loadSubjectsFromColnodToDB();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const QJsonDocument &getConfig() const {return config;}
|
const QJsonDocument &getConfig() const {return config;}
|
||||||
const QString &getResponse() const {return jsonResponse;}
|
const QString &getResponse() const {return jsonResponse;}
|
||||||
QString getToken(){return token;}
|
QString getToken(){return token;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString getFromJson(QString json, const QString &member);
|
QString getFromJson(QString json, const QString &member);
|
||||||
QString encryptedPassword(QString password);
|
QString encryptedPassword(QString password);
|
||||||
QString getLoginHeader(QString username, QString hash);
|
QString getLoginHeader(QString username, QString hash);
|
||||||
void prepareAuthHeader();
|
void prepareAuthHeader();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSSLError(QNetworkReply *reply, const QList<QSslError> &errors);
|
void onSSLError(QNetworkReply *reply, const QList<QSslError> &errors);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void successLogin();
|
void successLogin();
|
||||||
void responseReady();
|
void responseReady();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QNetworkAccessManager* manager;
|
QNetworkAccessManager* manager;
|
||||||
QJsonDocument config;
|
QJsonDocument config;
|
||||||
QString authHeader;
|
QString authHeader;
|
||||||
QString host;
|
QString host = "https://192.168.1.3:8443";
|
||||||
QString token;
|
QString password = "spaceti1";
|
||||||
QString jsonResponse;
|
QString user = "spaceti";
|
||||||
bool loginStatus;
|
QString token;
|
||||||
|
QString jsonResponse;
|
||||||
|
bool loginStatus;
|
||||||
};
|
|
||||||
|
|
||||||
#endif // REQUESTMANAGER_H
|
};
|
||||||
|
|
||||||
|
#endif // REQUESTMANAGER_H
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user