Skip to content

Commit

Permalink
Bug fix 13.10.2024
Browse files Browse the repository at this point in the history
  • Loading branch information
R9JAU committed Oct 13, 2024
1 parent 3c8f448 commit d10a641
Show file tree
Hide file tree
Showing 7 changed files with 1,279 additions and 5 deletions.
2 changes: 1 addition & 1 deletion QSOSU-desktop-app.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 14.0.1, 2024-10-09T01:46:03. -->
<!-- Written by QtCreator 14.0.1, 2024-10-12T01:25:27. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
Binary file not shown.
Binary file modified build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug/debug/httpapi.o
Binary file not shown.
973 changes: 973 additions & 0 deletions build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug/debug/log.txt

Large diffs are not rendered by default.

245 changes: 245 additions & 0 deletions build/HamDefs.xml

Large diffs are not rendered by default.

Binary file added build/data.db
Binary file not shown.
64 changes: 60 additions & 4 deletions httpapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ void HttpApi::SendQso(QVariantList data) {
}

/* TEST */
void HttpApi::getCallsign() {
void HttpApi::getCallsign()
{
if (accessToken.length() == 0) {
emit emptyToken();
return;
Expand Down Expand Up @@ -119,7 +120,8 @@ void HttpApi::getCallsign() {

//--------------------------------------------------------------------------------------------------------------------

void HttpApi::addCallsign(QVariantList data) {
void HttpApi::addCallsign(QVariantList data)
{
if (accessToken.length() == 0) {
emit emptyToken();
return;
Expand All @@ -129,7 +131,7 @@ void HttpApi::addCallsign(QVariantList data) {
m_reply->deleteLater();
m_reply = nullptr;
}
QNetworkRequest request((QUrl("https://api.qso.su/method/v1/addCallsign")));
QNetworkRequest request(QUrl("https://api.qso.su/method/v1/addCallsign"));
request.setHeader(QNetworkRequest::UserAgentHeader, "QSO.SU Agent");
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
request.setRawHeader(QByteArrayLiteral("Authorization"), QString("Bearer " + accessToken).toUtf8());
Expand Down Expand Up @@ -160,7 +162,7 @@ void HttpApi::addCallsign(QVariantList data) {
});
}
//--------------------------------------------------------------------------------------------------------------------

/*
void HttpApi::checkStatusCallsign(QString callsign)
{
if (accessToken.length() == 0) {
Expand All @@ -175,6 +177,7 @@ void HttpApi::checkStatusCallsign(QString callsign)
QNetworkRequest request = QNetworkRequest(QUrl("https://api.qso.su/method/v1/checkStatusCallsign"));
request.setHeader(QNetworkRequest::UserAgentHeader, "QSO.SU Agent");
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
request.setRawHeader(QByteArrayLiteral("Authorization"), QString("Bearer " + accessToken).toUtf8());
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
Expand All @@ -185,6 +188,7 @@ void HttpApi::checkStatusCallsign(QString callsign)
QByteArray jsonBA = doc.toJson();
qDebug().noquote() << "Checking Callsign from service." << jsonBA;
QNetworkReply *reply = m_manager.get(request);
//QNetworkReply *reply = m_manager.get(request, jsonBA);
connect(reply, &QNetworkReply::finished, this, [=]() {
Expand All @@ -205,9 +209,61 @@ void HttpApi::checkStatusCallsign(QString callsign)
reply->deleteLater();
});
}
*/
//--------------------------------------------------------------------------------------------------------------------

void HttpApi::checkStatusCallsign(QString callsign)
{
if (accessToken.length() == 0) {
emit emptyToken();
return;
}
if (m_reply) {
m_reply->abort();
m_reply->deleteLater();
m_reply = nullptr;
}

QJsonObject body;
body["callsign"] = callsign;
QJsonDocument doc(body);

QNetworkRequest request = QNetworkRequest(QUrl("https://api.qso.su/method/v1/checkStatusCallsign"));
request.setHeader(QNetworkRequest::UserAgentHeader, "QSO.SU Agent");
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
request.setRawHeader(QByteArrayLiteral("Authorization"), QString("Bearer " + accessToken).toUtf8());
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());

QByteArray postDataByteArray = doc.toJson();
QBuffer *buff = new QBuffer;
buff->setData(postDataByteArray);
buff->open(QIODevice::ReadOnly);

QNetworkReply *reply = m_manager.sendCustomRequest(request, "GET", buff);
buff->setParent(reply);

connect(reply, &QNetworkReply::finished, this, [=]() {
if (reply->error() == QNetworkReply::NoError) {
QByteArray data = reply->readAll();
qDebug() << data;

QJsonDocument jsonDocument = QJsonDocument::fromJson(data);
if (jsonDocument.object().contains("error")) {
QJsonObject errorObject = jsonDocument["error"].toObject();
qDebug() << "ERROR:" << errorObject["name"].toString() << errorObject["message"].toString();
return;
}
QJsonObject response = jsonDocument["response"].toObject();
QJsonValue callsign_status = response["status"].toInt();
emit callsignStatus(callsign_status.toInt());
}
reply->deleteLater();
});
}

//--------------------------------------------------------------------------------------------------------------------


void HttpApi::getListSubmodeDropDown()
{
if (accessToken.length() == 0) {
Expand Down

0 comments on commit d10a641

Please sign in to comment.