From 7c649e4a656bbe711abe15c80261fa361aaf6982 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Mon, 23 Jul 2012 13:47:41 +0200 Subject: [PATCH] first draft for fixing 738 --- src/core/UBApplicationController.cpp | 35 +++++++--------------------- src/core/UBApplicationController.h | 4 +--- 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp index f744bfcf..ad2a19ae 100644 --- a/src/core/UBApplicationController.cpp +++ b/src/core/UBApplicationController.cpp @@ -63,7 +63,6 @@ UBApplicationController::UBApplicationController(UBBoardView *pControlView, UBBo , mControlView(pControlView) , mDisplayView(pDisplayView) , mMirror(0) - , mFtp(0) , mMainMode(Board) , mDisplayManager(0) , mAutomaticCheckForUpdates(false) @@ -120,7 +119,6 @@ UBApplicationController::~UBApplicationController() delete mBlackScene; delete mMirror; - if (mFtp) delete mFtp; if (mHttp) delete mHttp; } @@ -521,42 +519,27 @@ void UBApplicationController::showSankoreEditor() emit mainModeChanged(mMainMode); } -void UBApplicationController::runCheckUpdate(int id, bool error) -{ - Q_UNUSED(id); - if(!error){ - if(mFtp!=NULL) - delete mFtp; - 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::checkUpdate() { - //TODO change this when upgrade the qt version - // networkAccessible : NetworkAccessibility not yet available - if(mHttp) + if(mHttp) delete mHttp; - QUrl url("http://www.google.com"); + QUrl url("http://ftp.open-sankore.org/update.json"); mHttp = new QHttp(url.host()); - connect(mHttp, SIGNAL(requestFinished(int,bool)), this, SLOT(runCheckUpdate(int,bool))); + connect(mHttp, SIGNAL(requestFinished(int,bool)), this, SLOT(updateRequestFinished(int,bool))); mHttp->get(url.path()); } -void UBApplicationController::ftpCommandFinished(int id, bool error) +void UBApplicationController::updateRequestFinished(int id, bool error) { if (error){ - qWarning() << "ftp command id" << id << "return the error: " << mFtp->errorString(); - mFtp->close(); + qWarning() << "http command id" << id << "return the error: " << mHttp->errorString(); + mHttp->close(); } else{ - QString responseString = QString(mFtp->readAll()); + QString responseString = QString(mHttp->readAll()); + qDebug() << responseString; if (!responseString.isEmpty() && responseString.contains("version") && responseString.contains("url")){ - mFtp->close(); + mHttp->close(); downloadJsonFinished(responseString); } } diff --git a/src/core/UBApplicationController.h b/src/core/UBApplicationController.h index 3bc6f83d..88688d2d 100644 --- a/src/core/UBApplicationController.h +++ b/src/core/UBApplicationController.h @@ -134,8 +134,7 @@ class UBApplicationController : public QObject void checkUpdateAtLaunch(); private slots: - void ftpCommandFinished(int id, bool error); - void runCheckUpdate(int id, bool error); + void updateRequestFinished(int id, bool error); protected: @@ -152,7 +151,6 @@ class UBApplicationController : public QObject UBScreenMirror* mMirror; int mInitialHScroll, mInitialVScroll; - QFtp* mFtp; private: