diff --git a/Sankore_3.1.pro b/Sankore_3.1.pro index 3b12b4cf..f1908440 100644 --- a/Sankore_3.1.pro +++ b/Sankore_3.1.pro @@ -49,7 +49,6 @@ include(src/podcast/podcast.pri) include(src/tools/tools.pri) include(src/desktop/desktop.pri) include(src/web/web.pri) -include(src/transition/transition.pri) include(src/interfaces/interfaces.pri) include(src/customWidgets/customWidgets.pri) diff --git a/src/adaptors/UBExportDocument.cpp b/src/adaptors/UBExportDocument.cpp index 81d49543..d06a2a55 100644 --- a/src/adaptors/UBExportDocument.cpp +++ b/src/adaptors/UBExportDocument.cpp @@ -37,8 +37,6 @@ THIRD_PARTY_WARNINGS_DISABLE #include "quazipfile.h" THIRD_PARTY_WARNINGS_ENABLE -#include "transition/UniboardSankoreTransition.h" - #include "core/memcheck.h" UBExportDocument::UBExportDocument(QObject *parent) @@ -78,9 +76,7 @@ void UBExportDocument::persist(UBDocumentProxy* pDocumentProxy) void UBExportDocument::persistsDocument(UBDocumentProxy* pDocumentProxy, QString filename) { - UniboardSankoreTransition document; QString documentPath(pDocumentProxy->persistencePath()); - document.checkDocumentDirectory(documentPath); QuaZip zip(filename); zip.setFileNameCodec("UTF-8"); diff --git a/src/adaptors/UBWebPublisher.cpp b/src/adaptors/UBWebPublisher.cpp index 7c9f8b18..d6cbf653 100644 --- a/src/adaptors/UBWebPublisher.cpp +++ b/src/adaptors/UBWebPublisher.cpp @@ -27,8 +27,6 @@ #include "adaptors/publishing/UBDocumentPublisher.h" -#include "transition/UniboardSankoreTransition.h" - #include "core/memcheck.h" UBWebPublisher::UBWebPublisher(QObject *parent) @@ -55,9 +53,7 @@ void UBWebPublisher::persist(UBDocumentProxy* pDocumentProxy) if (!pDocumentProxy) return; - UniboardSankoreTransition document; QString documentPath(pDocumentProxy->persistencePath()); - document.checkDocumentDirectory(documentPath); UBDocumentPublisher* publisher = new UBDocumentPublisher(pDocumentProxy, this); // the publisher will self delete when publication finishes publisher->publish(); diff --git a/src/core/UBApplication.cpp b/src/core/UBApplication.cpp index 80c51605..a0e12edb 100644 --- a/src/core/UBApplication.cpp +++ b/src/core/UBApplication.cpp @@ -72,7 +72,6 @@ UBApplicationController* UBApplication::applicationController = 0; UBBoardController* UBApplication::boardController = 0; UBWebController* UBApplication::webController = 0; UBDocumentController* UBApplication::documentController = 0; -UniboardSankoreTransition* UBApplication::mUniboardSankoreTransition = 0; UBMainWindow* UBApplication::mainWindow = 0; @@ -180,9 +179,6 @@ UBApplication::~UBApplication() delete mainWindow; mainWindow = 0; - delete mUniboardSankoreTransition; - mUniboardSankoreTransition = 0; - UBPersistenceManager::destroy(); UBDownloadManager::destroy(); @@ -365,7 +361,6 @@ int UBApplication::exec(const QString& pFileToImport) connect(mainWindow->actionMultiScreen, SIGNAL(triggered(bool)), applicationController, SLOT(useMultiScreen(bool))); connect(mainWindow->actionWidePageSize, SIGNAL(triggered(bool)), boardController, SLOT(setWidePageSize(bool))); connect(mainWindow->actionRegularPageSize, SIGNAL(triggered(bool)), boardController, SLOT(setRegularPageSize(bool))); - connect(mainWindow->actionImportUniboardDocuments, SIGNAL(triggered()), this, SLOT(importUniboardFiles())); connect(mainWindow->actionCut, SIGNAL(triggered()), applicationController, SLOT(actionCut())); connect(mainWindow->actionCopy, SIGNAL(triggered()), applicationController, SLOT(actionCopy())); @@ -399,12 +394,6 @@ void UBApplication::onScreenCountChanged(int newCount) mainWindow->actionMultiScreen->setEnabled(displayManager.numScreens() > 1); } -void UBApplication::importUniboardFiles() -{ - mUniboardSankoreTransition = new UniboardSankoreTransition(); - mUniboardSankoreTransition->documentTransition(); -} - #ifdef Q_WS_MAC void UBApplication::showMinimized() { @@ -545,7 +534,6 @@ void UBApplication::decorateActionMenu(QAction* action) menu->addSeparator(); menu->addAction(mainWindow->actionPreferences); menu->addAction(mainWindow->actionMultiScreen); - menu->addAction(mainWindow->actionImportUniboardDocuments); // SANKORE-48: Hide the check update action if the setting // EnableAutomaticSoftwareUpdates is false in Uniboard.config if(UBSettings::settings()->appEnableAutomaticSoftwareUpdates->get().toBool()) @@ -662,14 +650,11 @@ void UBApplication::cleanup() if (boardController) delete boardController; if (webController) delete webController; if (documentController) delete documentController; - if (mUniboardSankoreTransition) delete mUniboardSankoreTransition; - applicationController = NULL; boardController = NULL; webController = NULL; documentController = NULL; - mUniboardSankoreTransition = NULL; } void UBStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal, diff --git a/src/core/UBApplication.h b/src/core/UBApplication.h index b3d6aa27..618538b0 100644 --- a/src/core/UBApplication.h +++ b/src/core/UBApplication.h @@ -28,8 +28,6 @@ #include "qtsingleapplication.h" -#include "transition/UniboardSankoreTransition.h" - namespace Ui { class MainWindow; @@ -66,7 +64,6 @@ class UBApplication : public QtSingleApplication static UBBoardController* boardController; static UBWebController* webController; static UBDocumentController* documentController; - static UniboardSankoreTransition* mUniboardSankoreTransition; static UBMainWindow* mainWindow; @@ -123,8 +120,6 @@ class UBApplication : public QtSingleApplication #ifdef Q_WS_MAC void showMinimized(); #endif - void importUniboardFiles(); - void onScreenCountChanged(int newCount); private: diff --git a/src/core/UBDisplayManager.cpp b/src/core/UBDisplayManager.cpp index a436e383..7f648b6d 100644 --- a/src/core/UBDisplayManager.cpp +++ b/src/core/UBDisplayManager.cpp @@ -25,8 +25,10 @@ #include "frameworks/UBPlatformUtils.h" -#include "core/UBApplication.h" -#include "core/UBApplicationController.h" +#include "UBApplication.h" +#include "UBApplicationController.h" + +#include "UBSettings.h" #include "board/UBBoardView.h" diff --git a/src/transition/UniboardSankoreTransition.cpp b/src/transition/UniboardSankoreTransition.cpp deleted file mode 100644 index cce8ce7d..00000000 --- a/src/transition/UniboardSankoreTransition.cpp +++ /dev/null @@ -1,300 +0,0 @@ -/* - * Copyright (C) 2012 Webdoc SA - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#include "UniboardSankoreTransition.h" -#include "core/UBSettings.h" -#include "frameworks/UBFileSystemUtils.h" -#include "core/UBApplication.h" -#include "core/UBPersistenceManager.h" -#include "gui/UBMainWindow.h" - -#include "core/memcheck.h" - -UniboardSankoreTransition::UniboardSankoreTransition(QObject *parent) : - QObject(parent) - , mTransitionDlg(NULL) - , mThread(NULL) -{ - mOldSankoreDirectory = UBFileSystemUtils::normalizeFilePath(QDesktopServices::storageLocation(QDesktopServices::DataLocation)); - - mUniboardSourceDirectory = UBFileSystemUtils::normalizeFilePath(QDesktopServices::storageLocation(QDesktopServices::DataLocation)); -#if defined(Q_WS_MACX) - mOldSankoreDirectory.replace("Sankore/Sankore 3.1", "Sankore"); - mUniboardSourceDirectory.replace("Sankore/Sankore 3.1", "Uniboard"); -#else - mUniboardSourceDirectory.replace("Sankore/Sankore 3.1", "Mnemis/Uniboard"); -#endif - connect(this, SIGNAL(docAdded(UBDocumentProxy*)), UBPersistenceManager::persistenceManager(), SIGNAL(documentCreated(UBDocumentProxy*))); -} - -UniboardSankoreTransition::~UniboardSankoreTransition() -{ - if(NULL != mTransitionDlg) - { - delete mTransitionDlg; - mTransitionDlg = NULL; - } - - if(mThread){ - delete mThread; - mThread = NULL; - } -} - -void UniboardSankoreTransition::rollbackDocumentsTransition(QFileInfoList& fileInfoList) -{ - QFileInfoList::iterator fileInfo; - for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) { - if (fileInfo->isDir() && fileInfo->fileName().startsWith("Uniboard Document ")){ - QString sankoreDocumentName = fileInfo->fileName(); - sankoreDocumentName.replace("Uniboard","Sankore"); - QString sankoreDocumentDirectoryPath = UBSettings::userDocumentDirectory() + "/" + sankoreDocumentName; - if (QFileInfo(sankoreDocumentDirectoryPath).exists()){ - UBFileSystemUtils::deleteDir(sankoreDocumentDirectoryPath); - } - } - } -} - -bool UniboardSankoreTransition::checkDocumentDirectory(QString& documentDirectoryPath) -{ - bool result = true; - result = updateSankoreHRef(documentDirectoryPath); - QString sankoreWidgetPath = documentDirectoryPath + "/widgets"; - result &= updateIndexWidget(sankoreWidgetPath); - return result; -} - -void UniboardSankoreTransition::documentTransition() -{ - if (QFileInfo(mUniboardSourceDirectory).exists() || QFileInfo(mOldSankoreDirectory).exists()){ - QString uniboardDocumentDirectory = mUniboardSourceDirectory + "/document"; - - QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(uniboardDocumentDirectory); - fileInfoList << UBFileSystemUtils::allElementsInDirectory(mOldSankoreDirectory + "/document"); - - QString backupDirectoryPath = UBFileSystemUtils::normalizeFilePath(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)); - - if (fileInfoList.count() != 0){ - mTransitionDlg = new UBUpdateDlg(NULL, fileInfoList.count(), backupDirectoryPath); - connect(mTransitionDlg, SIGNAL(updateFiles()), this, SLOT(startDocumentTransition())); - connect(this, SIGNAL(transitionFinished(bool)), mTransitionDlg, SLOT(onFilesUpdated(bool))); - mTransitionDlg->show(); - } - } - else{ - UBApplication::mainWindow->information(tr("Import old Uniboard/Sankore documents"), tr("There are no documents that should be imported")); - } -} - -void UniboardSankoreTransition::startDocumentTransition() -{ - mThread = new UniboardSankoreThread(this); - mThread->start(); - connect(this,SIGNAL(transitioningFile(QString)),mTransitionDlg,SLOT(transitioningFile(QString))); -} - - -bool UniboardSankoreTransition::checkPage(QString& sankorePagePath) -{ - QFile file(sankorePagePath); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - return false; - - QByteArray documentByteArray = file.readAll(); - file.close(); - - QString sankoreDirectory = sankorePagePath.left(sankorePagePath.indexOf("/page")); - - sankoreDirectory = QUrl::fromLocalFile(sankoreDirectory).toString(); - QString documentString(documentByteArray); - - QRegExp videoRegExp(""); - videoRegExp.setMinimal(true); - - documentString.replace(videoRegExp,""); - - - QRegExp audioRegExp(""); - audioRegExp.setMinimal(true); - - documentString.replace(audioRegExp,""); - - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) - return false; - - file.write(documentString.toAscii()); - file.close(); - - return true; -} - - -bool UniboardSankoreTransition::checkWidget(QString& sankoreWidgetIndexPath) -{ - QFile file(sankoreWidgetIndexPath); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - return false; - - QByteArray documentByteArray = file.readAll(); - file.close(); - - QString documentString(documentByteArray); - - QRegExp swfOriginFilePathRegExp(""); - swfOriginFilePathRegExp.setMinimal(true); - swfOriginFilePathRegExp.indexIn(documentString); - QString origin = swfOriginFilePathRegExp.cap(1); - if(origin.contains("http://")){ - // an url is the source of the swf. The source is kept as is. - return true; - } - - //changing the path - QRegExp swfDataPathRegExp(""); - swfDataPathRegExp.setMinimal(true); - documentString.replace(swfDataPathRegExp,""); - - QRegExp swfMoviePathRegExp(""); - swfMoviePathRegExp.setMinimal(true); - documentString.replace(swfMoviePathRegExp,""); - - //copy the swf on the right place - QRegExp swfFileNameRegExp(""); - swfFileNameRegExp.setMinimal(true); - swfFileNameRegExp.indexIn(documentString); - QString swfFileName = swfFileNameRegExp.cap(1); - int lastDirectoryLevel = sankoreWidgetIndexPath.lastIndexOf("/"); - if (lastDirectoryLevel == -1) - lastDirectoryLevel = sankoreWidgetIndexPath.lastIndexOf("\\"); - - - QString destination(sankoreWidgetIndexPath.left(lastDirectoryLevel) + "/" + swfFileName); - QFile(origin).copy(destination); - - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) - return false; - - file.write(documentString.toAscii()); - file.close(); - - return true; -} - - -bool UniboardSankoreTransition::updateIndexWidget(QString& sankoreWidgetPath) -{ - bool result = true; - QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(sankoreWidgetPath); - - QFileInfoList::iterator fileInfo; - for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end() && result; fileInfo += 1) { - if (fileInfo->fileName().endsWith("wgt")){ - QString path = fileInfo->absolutePath() + "/" + fileInfo->fileName() + "/index.html"; - if (QFile(path).exists()) - result = checkWidget(path); - - path = fileInfo->absolutePath() + "/" + fileInfo->fileName() + "/index.htm"; - if (QFile(path).exists()) - result &= checkWidget(path); - } - } - - return result; -} - -bool UniboardSankoreTransition::updateSankoreHRef(QString& sankoreDocumentPath) -{ - bool result = true; - QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(sankoreDocumentPath); - - QFileInfoList::iterator fileInfo; - - for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end() && result; fileInfo += 1) { - if (fileInfo->fileName().endsWith("svg")){ - QString path = fileInfo->absolutePath() + "/" + fileInfo->fileName(); - result = checkPage(path); - } - } - - return result; -} - -void UniboardSankoreTransition::executeTransition() -{ - bool result = false; - QString backupDestinationPath = mTransitionDlg->backupPath() + "/OldSankoreAndUniboardVersionsBackup"; - result = UBFileSystemUtils::copyDir(mUniboardSourceDirectory + "/document", backupDestinationPath); - result &= UBFileSystemUtils::copyDir(mOldSankoreDirectory + "/document", backupDestinationPath); - - QString uniboardDocumentDirectory = mUniboardSourceDirectory + "/document"; - QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(uniboardDocumentDirectory); - fileInfoList.append(UBFileSystemUtils::allElementsInDirectory(mOldSankoreDirectory + "/document")); - - QFileInfoList::iterator fileInfo; - QString sankoreDocumentDirectory = UBSettings::userDocumentDirectory(); - - for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end() && result; fileInfo += 1) { - if (fileInfo->isDir() && (fileInfo->fileName().startsWith("Uniboard Document ") || fileInfo->fileName().startsWith("Sankore Document "))){ - QString sankoreDocumentName = fileInfo->fileName(); - emit transitioningFile(sankoreDocumentName); - sankoreDocumentName.replace("Uniboard","Sankore"); - QString sankoreDocumentPath = sankoreDocumentDirectory + "/" + sankoreDocumentName; - result = UBFileSystemUtils::copyDir(fileInfo->filePath(),sankoreDocumentPath); - result &= updateSankoreHRef(sankoreDocumentPath); - QString sankoreWidgetPath = sankoreDocumentDirectory + "/" + sankoreDocumentName + "/widgets"; - result &= updateIndexWidget(sankoreWidgetPath); - } - } - - if (!result){ - qWarning() << "The transition has failed"; - rollbackDocumentsTransition(fileInfoList); - UBFileSystemUtils::deleteDir(backupDestinationPath); - } - else{ - UBFileSystemUtils::deleteDir(mOldSankoreDirectory); - UBFileSystemUtils::deleteDir(mUniboardSourceDirectory); - } - - emit transitionFinished(result); -} - - -UniboardSankoreThread::UniboardSankoreThread(QObject* parent):QThread(parent) -{ - -} - -UniboardSankoreThread::~UniboardSankoreThread() -{ - -} - -void UniboardSankoreThread::run() -{ - UniboardSankoreTransition* pTransition = dynamic_cast(parent()); - - pTransition->executeTransition(); -} - diff --git a/src/transition/UniboardSankoreTransition.h b/src/transition/UniboardSankoreTransition.h deleted file mode 100644 index 7e4e5e41..00000000 --- a/src/transition/UniboardSankoreTransition.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2012 Webdoc SA - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#ifndef UNIBOARDSANKORETRANSITION_H -#define UNIBOARDSANKORETRANSITION_H - -#include -#include -#include -#include "gui/UBUpdateDlg.h" -#include "document/UBDocumentProxy.h" - -class UniboardSankoreThread : public QThread -{ - Q_OBJECT -public: - UniboardSankoreThread(QObject* parent = 0); - ~UniboardSankoreThread(); - - void run(); - -}; - -class UniboardSankoreTransition : public QObject -{ - Q_OBJECT -public: - explicit UniboardSankoreTransition(QObject *parent = 0); - ~UniboardSankoreTransition(); - - bool checkDocumentDirectory(QString& documentDirectoryPath); - - void documentTransition(); - bool checkPage(QString& sankorePagePath); - bool updateSankoreHRef(QString &sankoreDocumentPath); - bool checkWidget(QString& sankoreWidgetPath); - bool updateIndexWidget(QString& sankoreWidgetPath); - void executeTransition(); - - -private: - void rollbackDocumentsTransition(QFileInfoList& fileInfoList); - UBUpdateDlg* mTransitionDlg; - -protected: - QString mUniboardSourceDirectory; - QString mOldSankoreDirectory; - UniboardSankoreThread* mThread; - -signals: - void transitionFinished(bool result); - void docAdded(UBDocumentProxy* doc); - void transitioningFile(QString documentName); - -private slots: - void startDocumentTransition(); - -}; - -#endif // UNIBOARDSANKORETRANSITION_H diff --git a/src/transition/transition.pri b/src/transition/transition.pri deleted file mode 100644 index 4d2006f7..00000000 --- a/src/transition/transition.pri +++ /dev/null @@ -1,5 +0,0 @@ - -HEADERS += src/transition/UniboardSankoreTransition.h - - -SOURCES += src/transition/UniboardSankoreTransition.cpp