#include "Configurator.h" #include #include #include Configurator::Configurator(int &argc, char **&argv):QApplication(argc, argv),_nam(this) { setQuitOnLastWindowClosed(false); _loginDialog = new FederatedLogin(0); _loginDialog->setModal(true); connect(_loginDialog, &QDialog::accepted, this, &Configurator::loginRequested); connect(_loginDialog, &QDialog::rejected, this, &QApplication::quit); _loginDialog->show(); } void Configurator::loginRequested() { QNetworkRequest *req=new QNetworkRequest("https://dashboard." + _loginDialog->domain() + "/apps"); connect(&_nam, &QNetworkAccessManager::finished, this, &Configurator::appListReceived); QNetworkReply *r=_nam.get(*req); } void Configurator::appListReceived(QNetworkReply *reply) { disconnect(&_nam, &QNetworkAccessManager::finished, this, &Configurator::appListReceived); if(reply->error() != QNetworkReply::NoError) { _loginDialog->setMessage(tr("Failed to retrieve app list. Is the domain name correct?")); _loginDialog->show(); return; } QJsonDocument services = QJsonDocument::fromJson(reply->readAll()); if(!services.isArray()) { _loginDialog->setMessage(tr("App list did not return an array. Is the domain name correct?")); _loginDialog->show(); return; } _services = services.array(); for(auto i : _services) std::cerr << qPrintable(i.title) << std::endl; }