removed software update class

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent e6e960ba3f
commit b1eeea7fbb
  1. 1
      Sankore_3.1.pro
  2. 3
      src/core/UBApplicationController.cpp
  3. 142
      src/softwareupdate/UBRssHandler.cpp
  4. 59
      src/softwareupdate/UBRssHandler.h
  5. 52
      src/softwareupdate/UBSoftwareUpdate.cpp
  6. 40
      src/softwareupdate/UBSoftwareUpdate.h
  7. 261
      src/softwareupdate/UBSoftwareUpdateController.cpp
  8. 61
      src/softwareupdate/UBSoftwareUpdateController.h
  9. 8
      src/softwareupdate/softwareupdate.pri

@ -51,7 +51,6 @@ include(src/podcast/podcast.pri)
include(src/tools/tools.pri) include(src/tools/tools.pri)
include(src/desktop/desktop.pri) include(src/desktop/desktop.pri)
include(src/web/web.pri) include(src/web/web.pri)
include(src/softwareupdate/softwareupdate.pri)
include(src/transition/transition.pri) include(src/transition/transition.pri)
include(src/customWidgets/customWidgets.pri) include(src/customWidgets/customWidgets.pri)
include(src/interfaces/interfaces.pri) include(src/interfaces/interfaces.pri)

@ -24,9 +24,6 @@
#include "core/UBDocumentManager.h" #include "core/UBDocumentManager.h"
#include "core/UBDisplayManager.h" #include "core/UBDisplayManager.h"
#include "softwareupdate/UBSoftwareUpdateController.h"
#include "softwareupdate/UBSoftwareUpdate.h"
#include "board/UBBoardView.h" #include "board/UBBoardView.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "board/UBBoardPaletteManager.h" #include "board/UBBoardPaletteManager.h"

@ -1,142 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "frameworks/UBVersion.h"
#include "UBRssHandler.h"
#include "UBSoftwareUpdate.h"
#include "core/memcheck.h"
const QString UBRssHandler::sRssItemElementName = "item";
const QString UBRssHandler::sRssLinkElementName = "link";
const QString UBRssHandler::sUniboardVersionElementName = "ub:version"; // TODO UB 4.x map properly ub namespace
UBRssHandler::UBRssHandler()
: mRssTagParsed(false)
, mInItem(false)
, mInVersion(false)
{
// NOOP
}
UBRssHandler::~UBRssHandler(void)
{
while (!mSoftwareUpdates.isEmpty())
{
delete mSoftwareUpdates.takeFirst();
}
}
bool UBRssHandler::startElement(
const QString & /* namespaceURI */,
const QString & /* localName */,
const QString &qualifiedName,
const QXmlAttributes &attributes)
{
bool ok = true;
if (!mRssTagParsed && qualifiedName != "rss")
{
mError = "This file is not a RSS source.";
ok = false;
}
else if (qualifiedName == "rss")
{
QString version = attributes.value("version");
if (!version.isEmpty() && version != "2.0")
{
mError = "Can only handle RSS 2.0.";
ok = false;
}
else
{
mRssTagParsed = true;
}
}
else if (qualifiedName == sRssItemElementName)
{
mInItem = true;
}
else if (qualifiedName == sUniboardVersionElementName)
{
mInVersion = true;
}
mCurrentText = "";
return ok;
}
bool UBRssHandler::characters(const QString &str)
{
mCurrentText += str;
return true;
}
bool UBRssHandler::endElement(
const QString & /* namespaceURI */,
const QString & /* localName */,
const QString &qualifiedName)
{
bool ok = true;
if (qualifiedName == sRssItemElementName)
{
mInItem = false;
if (mVersion.isValid() && !mDownloadUrl.isEmpty())
{
UBSoftwareUpdate *softwareUpdate = new UBSoftwareUpdate(mVersion, mDownloadUrl);
mSoftwareUpdates.append(softwareUpdate);
}
mVersion = UBVersion();
mDownloadUrl = "";
}
else if (qualifiedName == sRssLinkElementName)
{
if (mInItem)
{
QUrl url(mCurrentText);
if (url.isValid())
mDownloadUrl = mCurrentText;
else
ok = false;
}
}
else if (qualifiedName == sUniboardVersionElementName)
{
if (mInItem)
{
mVersion.setString(mCurrentText);
ok = mVersion.isValid();
mInVersion = false;
}
}
return ok;
}
bool UBRssHandler::fatalError(const QXmlParseException &exception)
{
qWarning() << "Fatal error at line " << exception.lineNumber()
<< ", column " << exception.columnNumber() << ": "
<< exception.message() << mError;
return false;
}
QString UBRssHandler::error() const
{
return mError;
}
QList<UBSoftwareUpdate *> UBRssHandler::softwareUpdates() const
{
return mSoftwareUpdates;
}

@ -1,59 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBRSSHANDLER_H_
#define UBRSSHANDLER_H_
#include <QtXml>
#include <QList>
#include "frameworks/UBVersion.h"
class UBSoftwareUpdate;
class UBRssHandler: public QXmlDefaultHandler
{
public:
UBRssHandler();
virtual ~UBRssHandler(void);
// QXmlDefaultHandler
virtual bool startElement(const QString &namespaceURI,
const QString &localName, const QString &qualifiedName,
const QXmlAttributes &attributes);
virtual bool endElement(const QString &namespaceURI,
const QString &localName, const QString &qualifiedName);
virtual bool characters(const QString &str);
virtual bool fatalError(const QXmlParseException &exception);
// UBRssHandler
QString error() const;
QList<UBSoftwareUpdate *> softwareUpdates() const;
private:
QList<UBSoftwareUpdate *> mSoftwareUpdates;
bool mRssTagParsed;
bool mInItem;
bool mInVersion;
QString mError;
QString mCurrentText;
UBVersion mVersion;
QString mDownloadUrl;
static const QString sRssItemElementName;
static const QString sRssLinkElementName;
static const QString sUniboardVersionElementName;
};
#endif /* UBRSSHANDLER_H_ */

@ -1,52 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "frameworks/UBVersion.h"
#include "UBSoftwareUpdate.h"
#include "core/memcheck.h"
UBSoftwareUpdate::UBSoftwareUpdate()
{
// NOOP
}
UBSoftwareUpdate::UBSoftwareUpdate(UBVersion& version, const QString &downloadUrl)
: mVersion(version)
, mDownloadUrl(downloadUrl)
{
// NOOP
}
UBSoftwareUpdate::~UBSoftwareUpdate()
{
// NOOP
}
UBVersion UBSoftwareUpdate::version() const
{
return mVersion;
}
QString UBSoftwareUpdate::downloadUrl() const
{
return mDownloadUrl;
}
bool UBSoftwareUpdate::operator==(const UBSoftwareUpdate &other) const
{
return version() == other.version();
}

@ -1,40 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBSOFTWAREUPDATE_H_
#define UBSOFTWAREUPDATE_H_
#include <QtCore>
#include "frameworks/UBVersion.h"
class UBSoftwareUpdate
{
public:
UBSoftwareUpdate();
UBSoftwareUpdate(UBVersion& version, const QString &downloadUrl);
virtual ~UBSoftwareUpdate();
UBVersion version() const;
QString downloadUrl() const;
bool operator==(const UBSoftwareUpdate &other) const;
private:
UBVersion mVersion;
QString mDownloadUrl;
};
#endif // UBSOFTWAREUPDATE_H_

@ -1,261 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//#include "frameworks/UBVersion.h"
//#include "frameworks/UBFileSystemUtils.h"
//#include "frameworks/UBPlatformUtils.h"
//#include "UBSoftwareUpdateController.h"
//#include "UBRssHandler.h"
//#include "UBSoftwareUpdate.h"
//#include "core/UBApplication.h"
//#include "core/UBSettings.h"
//#include "core/UBSetting.h"
//#include "board/UBBoardController.h"
//#include "document/UBDocumentProxy.h"
//#include "network/UBHttpGet.h"
//#include "network/UBServerXMLHttpRequest.h"
//#include "network/UBNetworkAccessManager.h"
//const qreal UBSoftwareUpdateController::sProgressPercentageStep = 1;
//const int UBSoftwareUpdateController::sMinDisplayedDownloadedSizeInBytes = 2 * 1024 * 1024;
//UBSoftwareUpdateController::UBSoftwareUpdateController(QObject *parent)
// : QObject(parent)
// , mHttp(0)
//{
// // NOOP
//}
//UBSoftwareUpdateController::~UBSoftwareUpdateController()
//{
// delete mHttp;
//}
//void UBSoftwareUpdateController::beginRssDownload(const QUrl &url)
//{
// UBServerXMLHttpRequest * request = new UBServerXMLHttpRequest(UBNetworkAccessManager::defaultAccessManager());
// connect(request, SIGNAL(finished(bool, const QByteArray &)), this, SLOT(rssDownloadFinished(bool, const QByteArray &)));
// request->get(url);
//}
//void UBSoftwareUpdateController::beginInstallerDownload(const QUrl &url)
//{
// delete mHttp;
// mHttp = new UBHttpGet();
// connect(mHttp, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(installerDownloadProgress(qint64, qint64)));
// connect(mHttp, SIGNAL(downloadFinished(bool, QUrl, QString, QByteArray, QPointF, QSize, bool)),
// this, SLOT(installerDownloadFinished(bool, QUrl, QString, QByteArray)));
// mLastDisplayedProgress = 0;
// UBApplication::showMessage(tr("Downloading software update (%1%)").arg(0), true);
// mHttp->get(url, QPointF(), QSize());
//}
//void UBSoftwareUpdateController::rssDownloadFinished(bool success, const QByteArray &payload)
//{
// if (!success)
// {
// qWarning() << "Failed to download RSS file.";
// failedToRetrieveSoftwareUpdateInfo();
// return;
// }
// parseRss(payload);
//}
//void UBSoftwareUpdateController::installerDownloadProgress(qint64 receivedBytes, qint64 bytesTotal)
//{
// if (bytesTotal > sMinDisplayedDownloadedSizeInBytes)
// {
// qreal progress = ((qreal)(receivedBytes * 100) / bytesTotal);
// if (progress >= mLastDisplayedProgress + sProgressPercentageStep || receivedBytes == bytesTotal)
// {
// mLastDisplayedProgress = progress;
// UBApplication::showMessage(tr("Downloading software update (%1%)").arg(progress, 0, 'f', 0), true);
// }
// }
//}
//void UBSoftwareUpdateController::installerDownloadFinished(bool success, QUrl sourceUrl, QString contentTypeHeader, QByteArray data)
//{
// Q_UNUSED(contentTypeHeader);
// if (!success)
// {
// UBApplication::showMessage(tr("Downloading software update failed"));
// return;
// }
// UBApplication::showMessage(tr("Download finished"));
// QStringList urlParts = sourceUrl.toString().split("/");
// QString installerFileName = urlParts.last();
// QString tempDirPath = UBFileSystemUtils::createTempDir(UBFileSystemUtils::defaultTempDirName(), false);
// QString installerFilePath = tempDirPath + "/" + installerFileName;
// QFile file(installerFilePath);
// if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
// {
// qCritical() << "Cannot open " << installerFilePath << " for writing...";
// return;
// }
// file.write(data);
// file.flush();
// file.close();
// if (QMessageBox::question(
// QApplication::activeWindow(),
// tr("Software Update"),
// tr("Are you sure you want to install this new version of Uniboard now?\nThis session will close as soon as installation begins."),
// QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
// {
// UBDocumentProxy* document = UBApplication::boardController->activeDocument();
// int sceneIndex = UBApplication::boardController->activeSceneIndex();
// if (document)
// {
// UBSettings::settings()->appLastSessionDocumentUUID->set(UBStringUtils::toCanonicalUuid(document->uuid()));
// UBSettings::settings()->appLastSessionPageIndex->set(sceneIndex);
// }
// UBSettings::settings()->appIsInSoftwareUpdateProcess->set(true);
// UBPlatformUtils::runInstaller(installerFilePath);
// UBApplication::quit();
// }
//}
//void UBSoftwareUpdateController::parseRss(const QByteArray &rssContent)
//{
// UBRssHandler rssHandler;
// QXmlSimpleReader xmlReader;
// xmlReader.setContentHandler(&rssHandler);
// xmlReader.setErrorHandler(&rssHandler);
// QXmlInputSource source;
// source.setData(rssContent);
// if (!xmlReader.parse(source))
// {
// failedToRetrieveSoftwareUpdateInfo();
// return;
// }
// if (rssHandler.error().length() > 0)
// {
// qWarning() << "Failed to parse RSS file. Reason: " << rssHandler.error();
// failedToRetrieveSoftwareUpdateInfo();
// return;
// }
// if (rssHandler.softwareUpdates().isEmpty())
// {
// qWarning() << "RSS file does not contain software update info.";
// failedToRetrieveSoftwareUpdateInfo();
// return;
// }
// UBVersion installedVersion(qApp->applicationVersion());
// if (!installedVersion.isValid())
// {
// qWarning() << "Failed to parse installed version format: " << qApp->applicationVersion();
// failedToRetrieveSoftwareUpdateInfo();
// return;
// }
// QList<UBSoftwareUpdate *> softwareUpdates = rssHandler.softwareUpdates();
// const UBSoftwareUpdate *mostRecentSoftwareUpdate = searchForMoreRecentAndAsStableSoftwareUpdate(installedVersion, softwareUpdates);
// if (mostRecentSoftwareUpdate)
// {
// emit softwareUpdateAvailable(installedVersion, *mostRecentSoftwareUpdate);
// }
// else
// {
// emit noSoftwareUpdateAvailable();
// }
//}
//const UBSoftwareUpdate* UBSoftwareUpdateController::searchForMoreRecentAndAsStableSoftwareUpdate(const UBVersion &installedVersion, const QList<UBSoftwareUpdate *> &softwareUpdates)
//{
// const UBSoftwareUpdate *mostRecentSoftwareUpdate = 0;
// foreach (const UBSoftwareUpdate *softwareUpdate, softwareUpdates)
// {
// bool moreRecentAndAsStable = false;
// if (Alpha == installedVersion.releaseStage())
// {
// if (installedVersion < softwareUpdate->version() &&
// installedVersion.platformNumber() == softwareUpdate->version().platformNumber())
// {
// moreRecentAndAsStable = true;
// }
// }
// else if (Beta == installedVersion.releaseStage())
// {
// if (Alpha != softwareUpdate->version().releaseStage() &&
// installedVersion < softwareUpdate->version() &&
// installedVersion.platformNumber() == softwareUpdate->version().platformNumber())
// {
// moreRecentAndAsStable = true;
// }
// }
// else
// {
// if (ReleaseCandidate == softwareUpdate->version().releaseStage() &&
// installedVersion < softwareUpdate->version() &&
// installedVersion.platformNumber() == softwareUpdate->version().platformNumber())
// {
// moreRecentAndAsStable = true;
// }
// }
// if (moreRecentAndAsStable)
// {
// if (mostRecentSoftwareUpdate)
// {
// if (mostRecentSoftwareUpdate->version() < softwareUpdate->version())
// {
// mostRecentSoftwareUpdate = softwareUpdate;
// }
// }
// else
// {
// mostRecentSoftwareUpdate = softwareUpdate;
// }
// }
// }
// return mostRecentSoftwareUpdate;
//}

@ -1,61 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//#ifndef UBSOFTWAREUPDATECONTROLLER_H_
//#define UBSOFTWAREUPDATECONTROLLER_H_
//#include <QObject>
//#include <QUrl>
//class UBVersion;
//class UBSoftwareUpdate;
//class UBHttpGet;
//class UBSoftwareUpdateController : public QObject
//{
// Q_OBJECT;
// public:
// UBSoftwareUpdateController(QObject *parent = 0);
// virtual ~UBSoftwareUpdateController();
// void beginRssDownload(const QUrl &url);
// void beginInstallerDownload(const QUrl &url);
// static const UBSoftwareUpdate* searchForMoreRecentAndAsStableSoftwareUpdate(const UBVersion &installedVersion,
// const QList<UBSoftwareUpdate *> &softwareUpdates);
// signals:
// void softwareUpdateAvailable(const UBVersion &installedVersion, const UBSoftwareUpdate &softwareUpdate);
// void noSoftwareUpdateAvailable();
// void failedToRetrieveSoftwareUpdateInfo();
// private slots:
// void rssDownloadFinished(bool success, const QByteArray &payload);
// void installerDownloadProgress(qint64 receivedBytes, qint64 bytesTotal);
// void installerDownloadFinished(bool success, QUrl sourceUrl, QString header, QByteArray data);
// private:
// // Helpers
// void parseRss(const QByteArray &rssContent);
// UBHttpGet *mHttp;
// qreal mLastDisplayedProgress;
// static const int sMinDisplayedDownloadedSizeInBytes;
// static const qreal sProgressPercentageStep;
//};
//#endif // UBSOFTWAREUPDATECONTROLLER_H_

@ -1,8 +0,0 @@
HEADERS += src/softwareupdate/UBSoftwareUpdateController.h \
src/softwareupdate/UBRssHandler.h \
src/softwareupdate/UBSoftwareUpdate.h
SOURCES += src/softwareupdate/UBSoftwareUpdateController.cpp \
src/softwareupdate/UBRssHandler.cpp \
src/softwareupdate/UBSoftwareUpdate.cpp
Loading…
Cancel
Save