diff --git a/Sankore_3.1.pro b/Sankore_3.1.pro index 96c00aa1..28e017c5 100644 --- a/Sankore_3.1.pro +++ b/Sankore_3.1.pro @@ -52,7 +52,6 @@ include(src/podcast/podcast.pri) include(src/tools/tools.pri) include(src/desktop/desktop.pri) include(src/web/web.pri) -include(src/softwareupdate/softwareupdate.pri) include(src/transition/transition.pri) include(src/customWidgets/customWidgets.pri) include(src/interfaces/interfaces.pri) diff --git a/src/softwareupdate/UBRssHandler.cpp b/src/softwareupdate/UBRssHandler.cpp deleted file mode 100644 index 5097600a..00000000 --- a/src/softwareupdate/UBRssHandler.cpp +++ /dev/null @@ -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 . - */ - -#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 UBRssHandler::softwareUpdates() const -{ - return mSoftwareUpdates; -} diff --git a/src/softwareupdate/UBRssHandler.h b/src/softwareupdate/UBRssHandler.h deleted file mode 100644 index 04d75dcc..00000000 --- a/src/softwareupdate/UBRssHandler.h +++ /dev/null @@ -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 . - */ - -#ifndef UBRSSHANDLER_H_ -#define UBRSSHANDLER_H_ - -#include -#include - -#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 softwareUpdates() const; - - private: - QList 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_ */ diff --git a/src/softwareupdate/UBSoftwareUpdate.cpp b/src/softwareupdate/UBSoftwareUpdate.cpp deleted file mode 100644 index 84a3e450..00000000 --- a/src/softwareupdate/UBSoftwareUpdate.cpp +++ /dev/null @@ -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 . - */ - -#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(); -} diff --git a/src/softwareupdate/UBSoftwareUpdate.h b/src/softwareupdate/UBSoftwareUpdate.h deleted file mode 100644 index 0cdf9f90..00000000 --- a/src/softwareupdate/UBSoftwareUpdate.h +++ /dev/null @@ -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 . - */ - -#ifndef UBSOFTWAREUPDATE_H_ -#define UBSOFTWAREUPDATE_H_ - -#include - -#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_ diff --git a/src/softwareupdate/UBSoftwareUpdateController.cpp b/src/softwareupdate/UBSoftwareUpdateController.cpp deleted file mode 100644 index 6f651db1..00000000 --- a/src/softwareupdate/UBSoftwareUpdateController.cpp +++ /dev/null @@ -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 . - */ - -//#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 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 &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; -//} diff --git a/src/softwareupdate/UBSoftwareUpdateController.h b/src/softwareupdate/UBSoftwareUpdateController.h deleted file mode 100644 index 306efe4c..00000000 --- a/src/softwareupdate/UBSoftwareUpdateController.h +++ /dev/null @@ -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 . - */ - -//#ifndef UBSOFTWAREUPDATECONTROLLER_H_ -//#define UBSOFTWAREUPDATECONTROLLER_H_ - -//#include -//#include - -//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 &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_ diff --git a/src/softwareupdate/softwareupdate.pri b/src/softwareupdate/softwareupdate.pri deleted file mode 100644 index 3e496778..00000000 --- a/src/softwareupdate/softwareupdate.pri +++ /dev/null @@ -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 \ No newline at end of file