Update test for windows.. Please Don't touch.

This commit is contained in:
Mark Watkins 2011-12-17 19:56:21 +10:00
parent eda531a6fd
commit 6bfdbc74c2
2 changed files with 19 additions and 2 deletions

View File

@ -81,10 +81,16 @@ void UpdaterWindow::checkForUpdates()
}
mainwin->Notify("Checking for SleepyHead Updates");
update_url=QUrl("http://192.168.1.8/update.xml");
downloadUpdateXML();
}
void UpdaterWindow::downloadUpdateXML()
{
requestmode=RM_CheckUpdates;
reply=netmanager->get(QNetworkRequest(QUrl("http://192.168.1.8/update.xml")));
ui->plainTextEdit->appendPlainText("Requesting "+reply->url().toString());
reply=netmanager->get(QNetworkRequest(update_url));
ui->plainTextEdit->appendPlainText("Requesting "+update_url.toString());
netmanager->connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this, SLOT(downloadProgress(qint64,qint64)));
dltime.start();
}
@ -259,7 +265,16 @@ void UpdaterWindow::replyFinished(QNetworkReply * reply)
{
netmanager->disconnect(reply,SIGNAL(downloadProgress(qint64,qint64)),this, SLOT(downloadProgress(qint64,qint64)));
if (reply->error()==QNetworkReply::NoError) {
if (requestmode==RM_CheckUpdates) {
QUrl redirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
if (!redirectUrl.isEmpty() && (redirectUrl!=reply->url())) {
update_url = redirectUrl;
reply->deleteLater();
QTimer::singleShot(100,this,SLOT(downloadUpdateXML()));
return;
}
ui->plainTextEdit->appendPlainText(QString::number(reply->size())+" bytes received.");
QString filename=QApplication::applicationDirPath()+QDir::separator()+reply->url().toString().section("/",-1);
qDebug() << filename;

View File

@ -31,6 +31,7 @@ protected slots:
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
void dataReceived();
void requestFile();
void downloadUpdateXML();
private slots:
void on_CloseButton_clicked();
@ -58,6 +59,7 @@ private:
QList<Update *> updates;
int current_row;
bool success;
QUrl update_url; // for update.xml redirects..
};
#endif // UPDATEWINDOW_H