first draft for fixing 738

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent c7abe50538
commit 7c649e4a65
  1. 35
      src/core/UBApplicationController.cpp
  2. 4
      src/core/UBApplicationController.h

@ -63,7 +63,6 @@ UBApplicationController::UBApplicationController(UBBoardView *pControlView, UBBo
, mControlView(pControlView) , mControlView(pControlView)
, mDisplayView(pDisplayView) , mDisplayView(pDisplayView)
, mMirror(0) , mMirror(0)
, mFtp(0)
, mMainMode(Board) , mMainMode(Board)
, mDisplayManager(0) , mDisplayManager(0)
, mAutomaticCheckForUpdates(false) , mAutomaticCheckForUpdates(false)
@ -120,7 +119,6 @@ UBApplicationController::~UBApplicationController()
delete mBlackScene; delete mBlackScene;
delete mMirror; delete mMirror;
if (mFtp) delete mFtp;
if (mHttp) delete mHttp; if (mHttp) delete mHttp;
} }
@ -521,42 +519,27 @@ void UBApplicationController::showSankoreEditor()
emit mainModeChanged(mMainMode); 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() void UBApplicationController::checkUpdate()
{ {
//TODO change this when upgrade the qt version if(mHttp)
// networkAccessible : NetworkAccessibility not yet available
if(mHttp)
delete mHttp; delete mHttp;
QUrl url("http://www.google.com"); QUrl url("http://ftp.open-sankore.org/update.json");
mHttp = new QHttp(url.host()); 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()); mHttp->get(url.path());
} }
void UBApplicationController::ftpCommandFinished(int id, bool error) void UBApplicationController::updateRequestFinished(int id, bool error)
{ {
if (error){ if (error){
qWarning() << "ftp command id" << id << "return the error: " << mFtp->errorString(); qWarning() << "http command id" << id << "return the error: " << mHttp->errorString();
mFtp->close(); mHttp->close();
} }
else{ else{
QString responseString = QString(mFtp->readAll()); QString responseString = QString(mHttp->readAll());
qDebug() << responseString;
if (!responseString.isEmpty() && responseString.contains("version") && responseString.contains("url")){ if (!responseString.isEmpty() && responseString.contains("version") && responseString.contains("url")){
mFtp->close(); mHttp->close();
downloadJsonFinished(responseString); downloadJsonFinished(responseString);
} }
} }

@ -134,8 +134,7 @@ class UBApplicationController : public QObject
void checkUpdateAtLaunch(); void checkUpdateAtLaunch();
private slots: private slots:
void ftpCommandFinished(int id, bool error); void updateRequestFinished(int id, bool error);
void runCheckUpdate(int id, bool error);
protected: protected:
@ -152,7 +151,6 @@ class UBApplicationController : public QObject
UBScreenMirror* mMirror; UBScreenMirror* mMirror;
int mInitialHScroll, mInitialVScroll; int mInitialHScroll, mInitialVScroll;
QFtp* mFtp;
private: private:

Loading…
Cancel
Save