diff --git a/ui_loader.hpp b/ui_loader.hpp deleted file mode 100644 index 18ce955..0000000 --- a/ui_loader.hpp +++ /dev/null @@ -1,70 +0,0 @@ -class _UILoader { - libCommsy *connector = nullptr; - libCommsyAuth *auther = nullptr; - bool cacheInvalidate = true; - -public: - void failureWindow(); - void overviewWindow(bool catchInvalidRoomError = true); - void loginWindow(const QString& failure = ""); - void infoWindow(); - void postViewWindow(commsyPost *thispost, QString description); - void offlineWindow(); - - _UILoader () { - auther = new libCommsyAuth(); - } - - void reconnect() { - // Destroy old connector - if (connector != nullptr) { - if (not cacheInvalidate) { - return; - } - delete connector; - connector = nullptr; - } - cacheInvalidate = false; - // Connect to commsy - connector = new libCommsy(settings->value("server_url").toString().toStdString(), settings->value("server_sid").toString().toStdString(), settings->value("server_room").toString().toStdString()); - } - - void logout() { - settings->remove("server_sid"); - } - - void downloadAndOpenFile(QNetworkRequest mNetReq, const QString& filename) { - auto mNetMan = new QNetworkAccessManager(); - - // Set SID in request so we're authenticated TODO: think about a cleaner way - mNetReq.setRawHeader("Cookie", "SID=" + settings->value("server_sid").toString().toUtf8()); - - // Connect to downloading - w->connect(mNetMan, &QNetworkAccessManager::finished, [this, mNetMan, filename] (QNetworkReply *mNetReply) { - // Save and open downloaded file - { - // Initialise - QString destPath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + '/' + filename; - QFile destFile(destPath); - - // Write downloaded data to file - if (!destFile.open(QIODevice::WriteOnly)) { - return failureWindow(); - } - destFile.write(mNetReply->readAll()); - destFile.close(); - - // Open file in some application - //QDesktopServices::openUrl(destPath); - QDesktopServices::openUrl(QUrl::fromLocalFile(destPath)); - } - - // Clean up - mNetMan->deleteLater(); - }); - - // Start download - mNetMan->get(mNetReq); - } - -};