mirror of
https://gitlab.com/niansa/qcommsy.git
synced 2025-03-06 20:53:33 +01:00
Remove accidentally added file
This commit is contained in:
parent
9f5861b9f9
commit
dee579771e
1 changed files with 0 additions and 70 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
};
|
Loading…
Add table
Reference in a new issue