Updated update check using now the ftp directory to store the update.json

preferencesAboutTextFull
Claudio Valerio 14 years ago
parent 82cd2e5095
commit 98094ee758
  1. 39
      src/core/UBApplicationController.cpp
  2. 9
      src/core/UBApplicationController.h

@ -479,18 +479,44 @@ void UBApplicationController::showSankoreEditor()
void UBApplicationController::checkUpdate()
{
networkAccessManager->get (QNetworkRequest (QUrl ("http://getuniboard.com/dl/sankore/update.json")));
mFtp = new QFtp(this);
connect(mFtp, SIGNAL(commandFinished(int,bool)), this, SLOT(ftpCommandFinished(int,bool)));
mFtp->connectToHost("91.121.248.138",21);
mFtp->login("anonymous", "anonymous");
mFtp->get("update.json",0);
}
void UBApplicationController::downloadJsonFinished(QNetworkReply* pReply)
void UBApplicationController::ftpCommandFinished(int id, bool error)
{
if (error){
qWarning() << "ftp command id" << id << "return the error: " << mFtp->errorString();
mFtp->close();
}
else{
// 3 stand for the third command we have sent
// in our case
// 1->connect
// 2->login
// 3->get
if (id == 3){
QString updateString = QString(mFtp->readAll());
mFtp->close();
downloadJsonFinished(updateString);
}
}
}
void UBApplicationController::downloadJsonFinished(QString currentJson)
{
QString currentJson = pReply->readAll();
QScriptValue scriptValue;
QScriptEngine scriptEngine;
scriptValue = scriptEngine.evaluate ("(" + currentJson + ")");
UBVersion installedVersion (qApp->applicationVersion());
UBVersion jsonVersion (scriptValue.property("version").toString());
UBVersion installedVersion (qApp->applicationVersion().left(4));
UBVersion jsonVersion (scriptValue.property("version").toString().left(4));
if (installedVersion.isValid() && jsonVersion.isValid() && jsonVersion > installedVersion) {
QMessageBox msgBox;
@ -511,7 +537,8 @@ void UBApplicationController::downloadJsonFinished(QNetworkReply* pReply)
// should never be reached
break;
}
} else {
}
else {
if (isNoUpdateDisplayed) {
QMessageBox msgBox;
msgBox.setText (tr ("No update available"));

@ -3,6 +3,7 @@
#define UBAPPLICATIONCONTROLLER_H_
#include <QtGui>
#include <QFtp>
class UBBoardView;
class UBDocumentProxy;
@ -16,6 +17,7 @@ class UBSoftwareUpdate;
class QNetworkAccessManager;
class QNetworkReply;
class UBApplicationController : public QObject
{
Q_OBJECT;
@ -117,7 +119,9 @@ class UBApplicationController : public QObject
void checkUpdateRequest();
void checkUpdateAtLaunch();
void downloadJsonFinished(QNetworkReply* pReply);
private slots:
void ftpCommandFinished(int id, bool error);
protected:
@ -134,6 +138,7 @@ class UBApplicationController : public QObject
UBScreenMirror* mMirror;
int mInitialHScroll, mInitialVScroll;
QFtp* mFtp;
private:
@ -151,6 +156,8 @@ class UBApplicationController : public QObject
bool isNoUpdateDisplayed;
void checkUpdate ();
QNetworkAccessManager *networkAccessManager;
void downloadJsonFinished(QString updateString);
};
#endif /* UBAPPLICATIONCONTROLLER_H_ */

Loading…
Cancel
Save