diff -Nru libkeduvocdocument-15.12.3/CMakeLists.txt libkeduvocdocument-16.04.3/CMakeLists.txt --- libkeduvocdocument-15.12.3/CMakeLists.txt 2016-02-15 21:01:21.000000000 +0000 +++ libkeduvocdocument-16.04.3/CMakeLists.txt 2016-02-18 07:51:38.000000000 +0000 @@ -14,16 +14,18 @@ ${CMAKE_INSTALL_PREFIX}/include/KDE #FIXME ) -remove_definitions(-DQT_NO_CAST_TO_ASCII) + remove_definitions(-DQT_NO_CAST_FROM_ASCII) remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY) remove_definitions(-DQT_NO_KEYWORDS) +add_definitions(-DQT_NO_CAST_TO_ASCII) +add_definitions(-DQT_NO_URL_CAST_FROM_STRING) add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS) add_definitions(-DTRANSLATION_DOMAIN=\"libkeduvocdocument\") include(KDEInstallDirs) -include(KDECompilerSettings) +include(KDECompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) include(GenerateExportHeader) diff -Nru libkeduvocdocument-15.12.3/debian/changelog libkeduvocdocument-16.04.3/debian/changelog --- libkeduvocdocument-15.12.3/debian/changelog 2016-04-14 23:17:55.000000000 +0000 +++ libkeduvocdocument-16.04.3/debian/changelog 2016-09-30 04:38:24.000000000 +0000 @@ -1,3 +1,22 @@ +libkeduvocdocument (4:16.04.3-0ubuntu1) yakkety; urgency=medium + + [ Scarlett Clark ] + * New upstream release + + [ Philip Muškovac ] + * Update the Vcs URLs now that the repositories are hosted on + Launchpad + + [ Scarlett Clark ] + * New upstream bugfix release + * Refresh symbols. Remove MISSING. Rebuild? or ABI? + + [ Clive Johnston ] + * New upstream release (16.04.2) + * New upstream release (16.04.3) + + -- José Manuel Santamaría Lema Fri, 30 Sep 2016 06:38:24 +0200 + libkeduvocdocument (4:15.12.3-0ubuntu1) xenial; urgency=medium * New upstream bugfix release diff -Nru libkeduvocdocument-15.12.3/debian/control libkeduvocdocument-16.04.3/debian/control --- libkeduvocdocument-15.12.3/debian/control 2016-04-14 23:17:55.000000000 +0000 +++ libkeduvocdocument-16.04.3/debian/control 2016-09-30 04:38:24.000000000 +0000 @@ -5,17 +5,16 @@ Uploaders: Maximiliano Curia Build-Depends: cmake (>= 2.8.12), debhelper (>= 9), - extra-cmake-modules (>= 1.3.0), - kde-sc-dev-latest (>= 4:4.12), - kio-dev (>= 5.3.0), - libkf5archive-dev (>= 5.3.0), - libkf5i18n-dev (>= 5.3.0), + extra-cmake-modules (>= 5.24.0~), + kio-dev (>= 5.24.0~), + libkf5archive-dev (>= 5.24.0~), + libkf5i18n-dev (>= 5.24.0~), pkg-kde-tools (>> 0.15.15), - qtbase5-dev (>= 5.4) + qtbase5-dev (>= 5.6.1~) Standards-Version: 3.9.6 Homepage: http://edu.kde.org/ -Vcs-Browser: http://anonscm.debian.org/cgit/pkg-kde/applications/libkeduvocdocument.git -Vcs-Git: git://anonscm.debian.org/pkg-kde/applications/libkeduvocdocument.git +Vcs-Browser: https://code.launchpad.net/~kubuntu-packagers/kubuntu-packaging/+git/libkeduvocdocument +Vcs-Git: git://git.launchpad.net/~kubuntu-packagers/kubuntu-packaging/+git/libkeduvocdocument Package: libkeduvocdocument5 Architecture: any diff -Nru libkeduvocdocument-15.12.3/debian/libkeduvocdocument5.symbols libkeduvocdocument-16.04.3/debian/libkeduvocdocument5.symbols --- libkeduvocdocument-15.12.3/debian/libkeduvocdocument5.symbols 2016-04-14 23:17:55.000000000 +0000 +++ libkeduvocdocument-16.04.3/debian/libkeduvocdocument5.symbols 2016-09-30 04:38:24.000000000 +0000 @@ -1,4 +1,4 @@ -# SymbolsHelper-Confirmed: 4:14.12.2 amd64 +# SymbolsHelper-Confirmed: 4:16.04.1 amd64 i386 libKEduVocDocument.so.5 libkeduvocdocument5 #MINVER# _ZN11KEduVocText10fromKVTML2ER11QDomElement@Base 14.11.95 _ZN11KEduVocText11incBadCountEv@Base 14.11.95 @@ -22,22 +22,6 @@ _ZN11KEduVocTextD1Ev@Base 14.11.95 _ZN11KEduVocTextD2Ev@Base 14.11.95 _ZN11KEduVocTextaSERKS_@Base 14.11.95 - _ZN12LexiAutoSave13KAutoSaveFile10staleFilesERK4QUrlRK7QString@Base 14.11.95 - _ZN12LexiAutoSave13KAutoSaveFile11qt_metacallEN11QMetaObject4CallEiPPv@Base 14.11.95 - _ZN12LexiAutoSave13KAutoSaveFile11qt_metacastEPKc@Base 14.11.95 - _ZN12LexiAutoSave13KAutoSaveFile11releaseLockEv@Base 14.11.95 - _ZN12LexiAutoSave13KAutoSaveFile13allStaleFilesERK7QString@Base 14.11.95 - _ZN12LexiAutoSave13KAutoSaveFile14setManagedFileERK4QUrl@Base 14.11.95 - _ZN12LexiAutoSave13KAutoSaveFile16staticMetaObjectE@Base 14.11.95 - _ZN12LexiAutoSave13KAutoSaveFile4openE6QFlagsIN9QIODevice12OpenModeFlagEE@Base 14.11.95 - _ZN12LexiAutoSave13KAutoSaveFile6removeEv@Base 14.11.95 - _ZN12LexiAutoSave13KAutoSaveFileC1EP7QObject@Base 14.11.95 - _ZN12LexiAutoSave13KAutoSaveFileC1ERK4QUrlP7QObject@Base 14.11.95 - _ZN12LexiAutoSave13KAutoSaveFileC2EP7QObject@Base 14.11.95 - _ZN12LexiAutoSave13KAutoSaveFileC2ERK4QUrlP7QObject@Base 14.11.95 - _ZN12LexiAutoSave13KAutoSaveFileD0Ev@Base 14.11.95 - _ZN12LexiAutoSave13KAutoSaveFileD1Ev@Base 14.11.95 - _ZN12LexiAutoSave13KAutoSaveFileD2Ev@Base 14.11.95 _ZN13KEduVocLesson10entryCountEN16KEduVocContainer20EnumEntriesRecursiveE@Base 14.11.95 _ZN13KEduVocLesson11appendEntryEP17KEduVocExpression@Base 14.11.95 _ZN13KEduVocLesson11insertEntryEiP17KEduVocExpression@Base 14.11.95 @@ -295,8 +279,6 @@ _ZNK11KEduVocText8intervalEv@Base 14.11.95 _ZNK11KEduVocText8preGradeEv@Base 14.11.95 _ZNK11KEduVocTexteqERKS_@Base 14.11.95 - _ZNK12LexiAutoSave13KAutoSaveFile10metaObjectEv@Base 14.11.95 - _ZNK12LexiAutoSave13KAutoSaveFile11managedFileEv@Base 14.11.95 _ZNK14KEduVocArticle9isArticleERK7QString@Base 14.11.95 _ZNK15KEduVocDocument10identifierEi@Base 14.11.95 _ZNK15KEduVocDocument10isModifiedEv@Base 14.11.95 @@ -307,7 +289,7 @@ _ZNK15KEduVocDocument15identifierCountEv@Base 14.11.95 _ZNK15KEduVocDocument15queryIdentifierER7QStringS1_@Base 14.11.95 _ZNK15KEduVocDocument17indexOfIdentifierERK7QString@Base 14.11.95 - _ZNK15KEduVocDocument22KEduVocDocumentPrivate19initializeKAutoSaveERN12LexiAutoSave13KAutoSaveFileERK7QStringNS_17FileHandlingFlagsE@Base 14.11.95 + _ZNK15KEduVocDocument22KEduVocDocumentPrivate19initializeKAutoSaveER13KAutoSaveFileRK7QStringNS_17FileHandlingFlagsE@Base 4:16.04.1 _ZNK15KEduVocDocument3urlEv@Base 14.11.95 _ZNK15KEduVocDocument5titleEv@Base 14.11.95 _ZNK15KEduVocDocument6authorEv@Base 14.11.95 @@ -361,17 +343,16 @@ _ZTI16KEduVocContainer@Base 14.11.95 _ZTI16QXmlStreamReader@Base 14.11.95 _ZTI17KEduVocLeitnerBox@Base 14.11.95 - _ZTIN12LexiAutoSave13KAutoSaveFileE@Base 14.11.95 _ZTS13KEduVocLesson@Base 14.11.95 _ZTS15KEduVocDocument@Base 14.11.95 _ZTS15KEduVocWordType@Base 14.11.95 _ZTS16KEduVocContainer@Base 14.11.95 _ZTS16QXmlStreamReader@Base 14.11.95 _ZTS17KEduVocLeitnerBox@Base 14.11.95 - _ZTSN12LexiAutoSave13KAutoSaveFileE@Base 14.11.95 +#MISSING: 4:16.04.1# _ZTSN12LexiAutoSave13KAutoSaveFileE@Base 14.11.95 _ZTV13KEduVocLesson@Base 14.11.95 _ZTV15KEduVocDocument@Base 14.11.95 _ZTV15KEduVocWordType@Base 14.11.95 _ZTV16KEduVocContainer@Base 14.11.95 _ZTV17KEduVocLeitnerBox@Base 14.11.95 - _ZTVN12LexiAutoSave13KAutoSaveFileE@Base 14.11.95 +#MISSING: 4:16.04.1# _ZTVN12LexiAutoSave13KAutoSaveFileE@Base 14.11.95 diff -Nru libkeduvocdocument-15.12.3/keduvocdocument/autosave/kautosavefile.cpp libkeduvocdocument-16.04.3/keduvocdocument/autosave/kautosavefile.cpp --- libkeduvocdocument-15.12.3/keduvocdocument/autosave/kautosavefile.cpp 2016-02-15 21:01:21.000000000 +0000 +++ libkeduvocdocument-16.04.3/keduvocdocument/autosave/kautosavefile.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,211 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 2006 Jacob R Rideout - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kautosavefile.h" -#include "kautosavefileprivate.h" - -#include // for FILENAME_MAX - -#include -#include -#include -#include "qlockfile.h" -#include -#include "krandom.h" -#include "qstandardpaths.h" - -#include "qdebug.h" - -/** - * @file - * The implementation of the kAutoSaveFile is as follows: - * Given a file, called filez. Find a directory that is writable. - * In that directory create 3 files called - * filez_mangled_nameXXXXX, filez_mangled_nameXXXXX.lock and filez_mangled_nameXXXXX.kalock - * filez_mangled_nameXXXXX is the auto save file passed back to the user. - * filez_mangled_nameXXXXX.lock is the QLock file used to preserve the lock - * filez_mangled_nameXXXXX.kalock stores the meta information: real file URL and autosavefile location. - * - * Only 4 of the 16 possible states of these 3 files existing/not existing are valid. - * Here is a table indicating which are good - * - * autosave lock kalock valid - * 0 0 0 good - no files - * 1 0 0 bad - no kalock to find autosave - * 0 1 0 bad - no kalock to find autosave - * 1 1 0 bad - no kalock to find autosave - * 0 0 1 bad - kalock but no file - * 1 0 1 good - unlocked autosave - * 0 1 1 good - locked empty autosave - * 1 1 1 good - locked non-empty autosave - * - * - * **/ - -namespace LexiAutoSave { - -KAutoSaveFile::KAutoSaveFile(const QUrl &filename, QObject *parent) - : QFile(parent), - d(new KAutoSaveFilePrivate) -{ - d->managedFileNameChanged = true; - d->managedFile = filename; -} - -KAutoSaveFile::KAutoSaveFile(QObject *parent) - : QFile(parent), - d(new KAutoSaveFilePrivate) -{ - -} - -KAutoSaveFile::~KAutoSaveFile() -{ - if ( d->isLocked() ) { - QFile::remove(); - d->unkalock(); - } - - d->unlock(); - delete d; -} - -void KAutoSaveFile::releaseLock() -{ - if (d->isLocked()) { - d->unlock(); - - if ( !exists() ) { - d->unkalock(); - } - } - QFile::close(); -} - -bool KAutoSaveFile::remove() -{ - if (d->isLocked()) { - bool ret = QFile::remove(); - return ret; - } else { - return false; - } - -} - -bool KAutoSaveFile::open(OpenMode openmode) -{ - if (d->managedFile.isEmpty()) { - return false; - } - - if (d->managedFileNameChanged) { - - QString staleFilesDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) - + QString::fromLatin1("/stalefiles/") - + QCoreApplication::instance()->applicationName(); - if (!QDir().mkpath(staleFilesDir)) { - return false; - } - - QString tempplate = KAutoSaveFilePrivate::fileNameTemplate(d->managedFile, QString(), true ) ; - - //Generate a file name - QTemporaryFile myname( tempplate ); - if ( ! myname.open() ) { - return false; - } - myname.setAutoRemove( false ); - - setFileName(myname.fileName()); - - d->autosaveRoot = myname.fileName(); - d->managedFileNameChanged = false; - } - - if (openmode & QIODevice::WriteOnly) { - - if (!QFile::open(openmode) || ! d->kalock() || !d->tryLock()) { - d->unkalock(); - QFile::close(); - return false; - } - - return true; - } else { - releaseLock(); - return QFile::open(openmode); - } -} - -QUrl KAutoSaveFile::managedFile() const -{ - return d->managedFile; -} - -//remove set managed it only makes the initialization overly complicated -void KAutoSaveFile::setManagedFile(const QUrl &filename) -{ - if ( filename == d->managedFile ) { - return; - } - - if ( ! filename.isEmpty() ) { - if ( d->isLocked() ) { - remove(); - d->unkalock(); - d->unlock(); - } - } - - d->managedFileNameChanged = true; - d->managedFile = filename; -} - -QList KAutoSaveFile::staleFiles(const QUrl &filename, const QString &appName) -{ - - // get stale files - const QList< KAutoSaveFilePrivate::NamePair > files - = KAutoSaveFilePrivate::findFilteredStales(filename, appName); - - QList list; - KAutoSaveFile *asFile; - - // contruct a KAutoSaveFile for each stale file - Q_FOREACH (const KAutoSaveFilePrivate::NamePair & filenames, files) { - asFile = new KAutoSaveFile( QUrl( filenames.first ) ); - asFile -> setFileName( filenames.second ); - asFile->d->autosaveRoot = filenames.second; - asFile->d->managedFileNameChanged = false; - - list.append(asFile); - } - - return list; -} - -QList KAutoSaveFile::allStaleFiles(const QString &applicationName) -{ - return staleFiles( QUrl(), applicationName ); -} - -} - -#include "moc_kautosavefile.cpp" diff -Nru libkeduvocdocument-15.12.3/keduvocdocument/autosave/kautosavefile.h libkeduvocdocument-16.04.3/keduvocdocument/autosave/kautosavefile.h --- libkeduvocdocument-15.12.3/keduvocdocument/autosave/kautosavefile.h 2016-02-15 21:01:21.000000000 +0000 +++ libkeduvocdocument-16.04.3/keduvocdocument/autosave/kautosavefile.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,293 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 2006 Jacob R Rideout - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -/** @file This is a version of the KAutoSaveFile from kcoreaddons/src/lib/io -that works. At the time this was commited KAutoSaveFile would no permit -more than one autosave file per application and this fix was under review, -but gating further development. -The only change from the proposed patch is adding the namespace LexiAutoSave -**/ - -#ifndef LKAUTOSAVEFILE_H -#define LKAUTOSAVEFILE_H - -#include "keduvocdocument_export.h" - -#include -#include -#include - -/// @brief distinguish the working local copy of autosave from the broken global copy -namespace LexiAutoSave { - -class KAutoSaveFilePrivate; -/** - * \class KAutoSaveFile kautosavefile.h - * - * @brief Creates and manages a temporary "auto-save" file. - * Autosave files are temporary files that applications use to store - * the unsaved data in a file that they have open for - * editing. KAutoSaveFile allows you to easily create and manage such - * files, as well as to recover the unsaved data left over by a - * crashed or otherwise terminated process. - * - * Each KAutoSaveFile object is associated with one specific file that - * the application holds open. KAutoSaveFile is also a QObject, so it - * can be reparented to the actual opened file object, so as to manage - * the lifetime of the temporary file. - * - * Typical use consists of: - * - verifying whether stale autosave files exist for the opened file - * - deciding whether to recover the old, autosaved data - * - if not recovering, creating a KAutoSaveFile object for the opened file - * - during normal execution of the program, periodically save unsaved - * data into the KAutoSaveFile file. - * - * KAutoSaveFile holds a lock on the autosave file, so it's safe to - * delete the file and recreate it later. Because of that, disposing - * of stale autosave files should be done by opening the file for write - * and then destroying the KAutoSaveFile. The default setting of - * autoRemove will clean up the lock and remove the autosave file. - * - * No lock is held on the managed file. - * - * Examples: - * Opening a new file: - * @code - * void Document::open(const QUrl &url) - * { - * // check whether autosave files exist: - * QList staleFiles = KAutoSaveFile::staleFiles(url); - * if (!staleFiles.isEmpty()) { - * if (KMessageBox::questionYesNo(parent, - * "Auto-saved files exist. Do you want to recover them now?", - * "File Recovery", - * "Recover", "Don't recover") == KMessage::Yes) { - * recoverFiles(staleFiles); - * return; - * } else { - * // remove the stale files - * foreach (KAutoSaveFile *stale, staleFiles) { - * stale->open(QIODevice::WriteOnly); - * delete stale; - * } - * } - * } - * - * // create new autosave object - * m_autosave = new KAutoSaveFile(url, this); - * - * // continue the process of opening file 'url' - * ... - * } - * @endcode - * - * The function recoverFiles could loop over the list of files and do this: - * @code - * foreach (KAutoSaveFile *stale, staleFiles) { - * if (!stale->open(QIODevice::ReadWrite)) { - * // show an error message; we could not steal the lockfile - * // maybe another application got to the file before us? - * delete stale; - * continue; - * } - * Document *doc = new Document; - * doc->m_autosave = stale; - * stale->setParent(doc); // reparent - * - * doc->setUrl(stale->managedFile()); - * doc->setContents(stale->readAll()); - * doc->setState(Document::Modified); // mark it as modified and unsaved - * - * documentManager->addDocument(doc); - * } - * @endcode - * - * If the file is unsaved, periodically write the contents to the save file: - * @code - * if (!m_autosave->isOpen() && !m_autosave->open(QIODevice::ReadWrite)) { - * // show error: could not open the autosave file - * } - * m_autosave->write(contents()); - * @endcode - * - * When the user saves the file, the autosaved file is no longer - * necessary and can be removed or emptied. - * @code - * m_autosave->resize(0); // leaves the file open - * @endcode - * - * @code - * m_autosave->remove(); // closes the file - * @endcode - * - * @author Jacob R Rideout - */ -class KEDUVOCDOCUMENT_EXPORT KAutoSaveFile : public QFile -{ - Q_OBJECT -public: - /** - * Constructs a KAutoSaveFile for file @p filename. The temporary - * file is not opened or created until actually needed. The file - * @p filename does not have to exist for KAutoSaveFile to be - * constructed (if it exists, it will not be touched). - * - * @param filename the filename that this KAutoSaveFile refers to - * @param parent the parent object - */ - explicit KAutoSaveFile(const QUrl &filename, QObject *parent = 0); - - /** - * @overload - * Constructs a KAutoSaveFile object. Note that you need to call - * setManagedFile() before calling open(). - * @todo make this constructor private and initialize only with the filename - * Allows removal of setManagedFile() - * - * @param parent the parent object - */ - explicit KAutoSaveFile(QObject *parent = 0); - - /** - * Destroys the KAutoSaveFile object. - * If it holds the lock then it removes the autosave - * file and drops the lock being held. If it does not - * hold the lock then it drops the lock but does not remove the autosave file. - * - * This supports two different usage scenarios: - * 1. Autosave for error recovery only. Open the autosave for write. - * The autosave file will be removed whenever delete() is called. The staleFile - * will only show up after a crash when delete() was not called. - * 2. Autosave for timed/rotating backups. Open the autosave for write - * , but release the lock before the application exits. - * The autosave file will not be removed when delete() is called and - * will persist between restarts. The autosave file can still be deleted with remove(). - */ - ~KAutoSaveFile(); - - /** - * Retrieves the URL of the file managed by KAutoSaveFile. This - * is the same URL that was given to setManagedFile() or the - * KAutoSaveFile constructor. - * - * This is the name of the real file being edited by the - * application. To get the name of the temporary file where data - * can be saved, use fileName() (after you have called open()). - */ - QUrl managedFile() const; - - /** - * Sets the URL of the file managed by KAutoSaveFile. This should - * be the name of the real file being edited by the application. - * If the file is unchanged this does nothing. - * If the file was previously set to a different file, this function calls close(). - * - * @param filename the filename that this KAutoSaveFile refers to - * - * @todo remove setManagedFile in favor of simply creating a new autoSaveFile - */ - void setManagedFile(const QUrl &filename); - - /** - * Closes the autosave file resource and removes the lock - * file. The file name returned by fileName() will no longer be - * protected and can be overwritten by another application at any - * time. To obtain a new lock, call open() again. - * - * This function calls close(), so the autosave temporary file - * will be closed. - * - * The autosave file will not be automatically removed when the destructor is called. - */ - virtual void releaseLock(); - - /** - * Opens the autosave file and locks it when in write mode if it wasn't already - * locked. The name of the temporary file where data can be saved - * to will be set by this function and can be retrieved with - * fileName(). It will not change unless releaseLock() is called. No - * other application will attempt to edit such a file either while - * the lock is held. - * - * @param openmode the mode that should be used to open the file, - * probably QIODevice::ReadWrite - * @returns true if the file could be opened (= locked and - * created), false if the operation failed - */ - virtual bool open(OpenMode openmode); - - /** - * Removes the file specified by fileName(), only if it is already locked. - * i.e. open for write. - * It keeps the lock if it has the lock. - * @return true if successful - */ - virtual bool remove(); - - /** - * Checks for stale autosave files for the file @p url. Returns a list - * of autosave files that contain autosaved data left behind by - * other instances of the application, due to crashing or - * otherwise uncleanly exiting. - * - * It is the application's job to determine what to do with such - * unsaved data. Generally, this is done by asking the user if he - * wants to see the recovered data, and then allowing the user to - * save if he wants to. - * - * If not given, the application name is obtained from - * QCoreApplication, so be sure to have set it correctly before - * calling this function. - * - * If @p url is not given it defaults to all of the stale autosavefiles. - * - * This function returns a list of unopened KAutoSaveFile - * objects. By calling open() on them, the application will steal - * the lock. Subsequent releaseLock() or deleting of the object will - * then erase the stale autosave file. - * - */ - static QList staleFiles(const QUrl &url, - const QString &applicationName = QString()); - - /** - * Returns all stale autosave files left behind by crashed or - * otherwise gone instances of this application. - * - * If not given, the application name is obtained from - * QCoreApplication, so be sure to have set it correctly before - * calling this function. - * - * See staleFiles() for information on the returned objects. - * - * allStaleFiles( x ) is an alias for staleFiles(QUrl(), x) - * - * @todo remove allStatelFiles from API when it changes - */ - static QList allStaleFiles(const QString &applicationName = QString()); - -private: - Q_DISABLE_COPY(KAutoSaveFile) - friend class KAutoSaveFilePrivate; - KAutoSaveFilePrivate *const d; -}; -} - -#endif // KAUTOSAVEFILE_H diff -Nru libkeduvocdocument-15.12.3/keduvocdocument/autosave/kautosavefileprivate.cpp libkeduvocdocument-16.04.3/keduvocdocument/autosave/kautosavefileprivate.cpp --- libkeduvocdocument-15.12.3/keduvocdocument/autosave/kautosavefileprivate.cpp 2016-02-15 21:01:21.000000000 +0000 +++ libkeduvocdocument-16.04.3/keduvocdocument/autosave/kautosavefileprivate.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 2014 Andreas Xavier - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kautosavefileprivate.h" - -#include // for FILENAME_MAX - -#include -#include - -#include -#include - -namespace LexiAutoSave { - - QList KAutoSaveFilePrivate::findFilteredStales( - const QUrl & fileQurl, const QString &applicationName) { - - QString appName(applicationName); - if (appName.isEmpty()) { - appName = QCoreApplication::instance()->applicationName(); - } - - QList files; - QString rootname( fileNameTemplate( fileQurl , appName, false) ); - - const QStringList dirs = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); - Q_FOREACH (const QString &dir, dirs) { - QDir appDir(dir + QString::fromLatin1("/stalefiles/") + appName); - - Q_FOREACH (const QString &filename, appDir.entryList(QDir::Files)) { - if ( !(filename.endsWith(QLatin1String(".kalock") ) ) ) { - continue; - } - - QFile file( (appDir.absolutePath() + QLatin1Char('/') + filename) ); - - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - file.close(); - continue; - } - - QTextStream in( &file ); - - QString kaSavefile( in.readLine() ); - QString mfile( in.readLine() ); - file.close(); - - NamePair package(qMakePair(mfile, kaSavefile)); - - if ( ! fileQurl.isEmpty() ) { - if ( kaSavefile.contains( rootname ) ){ - files << package; - } - } else { - files << package; - } - } - } - return files; -} - -QString KAutoSaveFilePrivate::encoded( const QString & str ) { - return QString::fromLatin1(QUrl::toPercentEncoding( str ).constData() ); -} - -QString KAutoSaveFilePrivate::fileNameTemplate( - const QUrl & file, const QString &applicationName, bool isPadded) -{ - static const int maxNameLength = FILENAME_MAX; - - // Note: we drop any query string and user/pass info - const QString protocol(encoded( file.scheme() )); - QString name1(encoded( file.fileName() ) ); - - QString path(file.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).toDisplayString()); - QString pathEncoded( encoded( path ) ); - - // Remove any part of the path to the right if it is longer than the max file size and - // ensure that the max filesize takes into account the other parts of the tempFileName - // Subtract 1 for the _ char, 7 is for the .kalock - int trimNumber = qMax( 0, - maxNameLength + pathEncoded.size() + paddingLength() - + name1.size() + protocol.size() + 1 + 7 ); - path.chop( trimNumber ); - QString pathEncodedFinal( encoded( path ) ); - - // tempName = fileName + protocol + _ + path.truncated + padding - // This is done so that the separation between the filename and path can be determined - QString name2(protocol + QLatin1Char('_') + pathEncodedFinal); - - - QString appName(applicationName); - if (appName.isEmpty()) { - appName = QCoreApplication::instance()->applicationName(); - } - - QString padding( QString::fromLatin1( "X" ) ); - padding.repeated( paddingLength() ); - - QString tempplate = lockDir( appName ) + QChar::fromLatin1('/') - + name1 + name2 + ( isPadded ? padding : QString( ) ); - - return tempplate; -} - -bool KAutoSaveFilePrivate::tryLock() -{ - unlock(); - - //Create a persistent long term lock - m_lock = new QLockFile(autosaveRoot + QString::fromLatin1(".lock")); - m_lock->setStaleLockTime(0); - - if (!m_lock->isLocked() && !m_lock->tryLock()) { - //Try harder. The only way the user found this file is using - //staleFiles so them must have decided to steal the lock - if ( ( m_lock->error() == QLockFile::LockFailedError ) ) { - m_lock->removeStaleLockFile(); - } - if (!m_lock->tryLock()) { - unlock(); - return false; - } - } - - return true; -} - -} diff -Nru libkeduvocdocument-15.12.3/keduvocdocument/autosave/kautosavefileprivate.h libkeduvocdocument-16.04.3/keduvocdocument/autosave/kautosavefileprivate.h --- libkeduvocdocument-15.12.3/keduvocdocument/autosave/kautosavefileprivate.h 2016-02-15 21:01:21.000000000 +0000 +++ libkeduvocdocument-16.04.3/keduvocdocument/autosave/kautosavefileprivate.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,133 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 2014 Andreas Xavier - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef LKAUTOSAVEFILEPRIVATE_H -#define LKAUTOSAVEFILEPRIVATE_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace LexiAutoSave { - -/**Private helper class for KAutoSaveFile*/ -class KAutoSaveFilePrivate -{ -public: - /** constructor */ - KAutoSaveFilePrivate() - : managedFile() - , autosaveRoot() - , m_lock(0) - , managedFileNameChanged(false) - {} - - typedef QPair NamePair; ///< (managedfilename, autosavefilename) pair - - /** @brief Filter the stale file list by @p appname and @p file. - * @details If file is QUrl() then grab all of the files. - * @returns a list of the managed and autosave files. - **/ - static QList< NamePair > findFilteredStales(const QUrl & file, const QString &appname); - - - /** @brief The directory of the locks for this @p appname - @return directory name **/ - static QString lockDir(const QString & appname ) { - return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) - + QString::fromLatin1("/stalefiles/") - + appname; - } - - - /** Constructs the root template of the three filenames from the @p qurl - * The .lock file will be used to lock the other two. - * The .kalock file will store the KAutoSaveFile meta information - * The third file will be passed back to the user as the - * autosavefile - * @p isPadded determines if the padding is added. - * @return the template for the filenames.**/ - static QString fileNameTemplate( const QUrl & qurl, const QString &appname , bool isPadded); - - /** safely encodes @p str **/ - static QString encoded( const QString & str ); - - /** length of random padding added by QTemporaryFile **/ - static int paddingLength(){ return 8;} - - /** @return true if is locked **/ - bool isLocked() const { - return (m_lock && m_lock->isLocked()); - } - - /** @return true if was locked **/ - bool tryLock(); - - /** unlocks the lock - and deletes the directory if empty **/ - void unlock() { - if( m_lock != NULL ) { - delete m_lock; - m_lock = NULL; - //this only succeeds it the directory is empty - QDir().rmdir(QFileInfo(autosaveRoot).absolutePath()); - } - } - - /** Write the meta information to the kalock file - @return true on success.**/ - bool kalock() - { - QFile kalockFile(autosaveRoot + QString::fromLatin1(".kalock" ) ); - bool goodOpen( kalockFile.open( QIODevice::ReadWrite )); - QTextStream out( & kalockFile ); - out << autosaveRoot << "\n" - << managedFile.toEncoded(QUrl::RemoveUserInfo | QUrl::RemoveQuery) << "\n"; - kalockFile.close(); - return goodOpen; - } - - /** Remove the kalock file - This must also be accompanied with removing the autosave file - and the directory if this is the last autosave file. - **/ - void unkalock() - { - QFile kalockFile(autosaveRoot + QString::fromLatin1(".kalock" ) ); - kalockFile.remove(); - //this only succeeds it the directory is empty - QDir().rmdir(QFileInfo(kalockFile).absolutePath()); - } - - QUrl managedFile; ///< url of the real file - QString autosaveRoot; ///< root for the filenames of the autosave - QLockFile *m_lock; ///< lock on the autosave file - bool managedFileNameChanged; ///< an initialization dirty bit - ///@todo remove this when setManaged is removed >/ -}; - -} -#endif diff -Nru libkeduvocdocument-15.12.3/keduvocdocument/autotests/CMakeLists.txt libkeduvocdocument-16.04.3/keduvocdocument/autotests/CMakeLists.txt --- libkeduvocdocument-15.12.3/keduvocdocument/autotests/CMakeLists.txt 2016-02-15 21:01:21.000000000 +0000 +++ libkeduvocdocument-16.04.3/keduvocdocument/autotests/CMakeLists.txt 2016-02-18 07:51:38.000000000 +0000 @@ -22,7 +22,6 @@ #Unit Tests linked to objects behind the API wall set(kvocdoc_unittests - kautosavefiletest readerkvtml2test readerwordquiztest readerpaukertest diff -Nru libkeduvocdocument-15.12.3/keduvocdocument/autotests/kautosavefiletest.cpp libkeduvocdocument-16.04.3/keduvocdocument/autotests/kautosavefiletest.cpp --- libkeduvocdocument-15.12.3/keduvocdocument/autotests/kautosavefiletest.cpp 2016-02-15 21:01:21.000000000 +0000 +++ libkeduvocdocument-16.04.3/keduvocdocument/autotests/kautosavefiletest.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,728 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 2006 Jacob R Rideout - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kautosavefiletest.h" - -#include -#include -#include - -#include -#include <../autosave/kautosavefile.h> - -#include -#include - -QTEST_MAIN(KAutoSaveFileTest) - -using namespace LexiAutoSave; - -void KAutoSaveFileTest::cleanupTestCase() -{ - Q_FOREACH (const QString &fileToRemove, filesToRemove) { - QFile::remove(fileToRemove); - } -} - - -void KAutoSaveFileTest::initTestCase() -{ - mainappname = QLatin1String("kautosavetest" ); - appname1 = QLatin1String("kautosavetest_app1" ); - appname2 = QLatin1String("kautosavetest_app2" ); - init(); -} -void KAutoSaveFileTest::init() -{ - QCoreApplication::instance()->setApplicationName(mainappname); - Q_FOREACH( KAutoSaveFile * afile, KAutoSaveFile::staleFiles(QUrl() , mainappname )) { - QVERIFY( afile->open(QIODevice::ReadWrite) ); - delete afile; - } - Q_FOREACH( KAutoSaveFile * afile, KAutoSaveFile::staleFiles(QUrl() , appname1 )) { - afile->open(QIODevice::ReadWrite); - delete afile; - } - Q_FOREACH( KAutoSaveFile * afile, KAutoSaveFile::staleFiles(QUrl() , appname2 )) { - afile->open(QIODevice::ReadWrite); - delete afile; - } -} - -void KAutoSaveFileTest::test_readWrite() -{ - QTemporaryFile file("test_readWrite"); - - QVERIFY(file.open()); - - QUrl normalFile(QFileInfo(file).absoluteFilePath()); - - //Test basic functionality - KAutoSaveFile saveFile(normalFile); - - QVERIFY(!QFile::exists(saveFile.fileName())); - QVERIFY(saveFile.open(QIODevice::ReadWrite)); - - QString inText = QString::fromLatin1("This is test data one.\n"); - - { - QTextStream ts(&saveFile); - ts << inText; - ts.flush(); - } - - saveFile.close(); - - { - QFile testReader(saveFile.fileName()); - testReader.open(QIODevice::ReadWrite); - QTextStream ts(&testReader); - - QString outText = ts.readAll(); - - QCOMPARE(outText, inText); - } - - filesToRemove << file.fileName(); -} - -void KAutoSaveFileTest::test_fileStaleFiles() -{ - // TODO -} - -void KAutoSaveFileTest::test_applicationStaleFiles() -{ - // TODO -} - - - -void KAutoSaveFileTest::test_crossContaminateFilename() -{ - // Create a temporary file with a unique filename - QTemporaryFile file( "test_crossContaminateFilename" ); - QVERIFY( file.open() ); - QUrl fileQurl ( QUrl::fromLocalFile( file.fileName() ) ); - - QVERIFY2( KAutoSaveFile::staleFiles(fileQurl).isEmpty() - , "An unused filename has an autosave file." ); - - // Create the autosave file lock - KAutoSaveFile autoSave1( fileQurl ); - QVERIFY(autoSave1.open(QIODevice::ReadWrite)); - - QVERIFY2( ! KAutoSaveFile::staleFiles(fileQurl).isEmpty() - , "An expected autosave file does not exist" ); - - // Create another temporary file with another unique filename - QTemporaryFile file2( "test_crossContaminateFilename" ); - QVERIFY( file2.open() ); - QUrl file2Qurl ( QUrl::fromLocalFile( file2.fileName() ) ); - - // Check for stale auto saves on a never used before filename - QVERIFY2( KAutoSaveFile::staleFiles(file2Qurl).isEmpty() - , "An unused filename has detected the autosave file of a different filename" ); -} - -void KAutoSaveFileTest::test_crossContaminateAppname() -{ - QString originalAppName( QCoreApplication::applicationName() ); - - // Create two tempfiles - QTemporaryFile file1( "test_crossContaminateAppname" ); - QVERIFY( file1.open() ); - QUrl file1Qurl ( QUrl::fromLocalFile( file1.fileName() ) ); - QTemporaryFile file2( "test_crossContaminateAppname" ); - QVERIFY( file2.open() ); - QUrl file2Qurl ( QUrl::fromLocalFile( file2.fileName() ) ); - - - //App1 - QCoreApplication::setApplicationName(appname1); - - // Create the autosave file lock - KAutoSaveFile autoSaveApp1File1( file1Qurl ); - QVERIFY(autoSaveApp1File1.open(QIODevice::ReadWrite)); - KAutoSaveFile autoSaveApp1File2( file2Qurl ); - QVERIFY(autoSaveApp1File2.open(QIODevice::ReadWrite)); - - QCoreApplication::setApplicationName(appname2); - - //App2 has nothing locked - QCOMPARE( KAutoSaveFile::allStaleFiles().size() , 0 ); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl, appname2).size() , 0 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl, appname2).size() , 0 ); - QCOMPARE( KAutoSaveFile::allStaleFiles(appname2).size() , 0 ); - QCOMPARE( KAutoSaveFile::allStaleFiles(appname1).size() , 2 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl, appname1).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl, appname1).size() , 1 ); - - // Create the autosave file lock - KAutoSaveFile autoSaveApp2File1( file1Qurl ); - QVERIFY(autoSaveApp2File1.open(QIODevice::ReadWrite)); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 0 ); - QCOMPARE( KAutoSaveFile::allStaleFiles(appname2).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl, appname1).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl, appname1).size() , 1 ); - QCOMPARE( KAutoSaveFile::allStaleFiles(appname1).size() , 2 ); - - QCoreApplication::setApplicationName(originalAppName); -} - -void KAutoSaveFileTest::test_freeStaleOnRelease() -{ - // Create a temporary file with a unique filename - QTemporaryFile file( "test_freeStaleOnRelease" ); - QVERIFY( file.open() ); - QUrl fileQurl ( QUrl::fromLocalFile( file.fileName() ) ); - - QVERIFY2( KAutoSaveFile::staleFiles(fileQurl).isEmpty() - , "An unused filename has an autosave file." ); - - // Create the autosave file lock - KAutoSaveFile autoSave1( fileQurl ); - QVERIFY(autoSave1.open(QIODevice::ReadWrite)); - - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).size() , 1 ); - - // Create another temporary file with another unique filename - QTemporaryFile file2( "test_freeStaleOnRelease" ); - QVERIFY( file2.open() ); - QUrl file2Qurl ( QUrl::fromLocalFile( file2.fileName() ) ); - - // Create the autosave file lock - KAutoSaveFile autoSave2( file2Qurl ); - QVERIFY(autoSave2.open(QIODevice::ReadWrite)); - - //Check that there is one of each autosave - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).at( 0 )->fileName() , autoSave1.fileName() ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).at( 0 )->fileName() , autoSave2.fileName() ); - - autoSave1.releaseLock(); - - //Releasing the lock doesn't remove the autosave file - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).at( 0 )->fileName() , autoSave1.fileName() ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).at( 0 )->fileName() , autoSave2.fileName() ); - - //Check that double release doesn't change anything. - autoSave1.releaseLock(); - - //Check that nothing changed - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).at( 0 )->fileName() , autoSave1.fileName() ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).at( 0 )->fileName() , autoSave2.fileName() ); - -} - -void KAutoSaveFileTest::test_freeStaleOnSetManaged() -{ - // Create a temporary file with a unique filename - QTemporaryFile file( "test_freeStaleOnSetManaged" ); - QVERIFY( file.open() ); - QUrl fileQurl ( QUrl::fromLocalFile( file.fileName() ) ); - - QTemporaryFile file2( "test_freeStaleOnSetManaged" ); - QVERIFY( file2.open() ); - QUrl file2Qurl ( QUrl::fromLocalFile( file2.fileName() ) ); - - QTemporaryFile file3( "test_freeStaleOnSetManaged" ); - QVERIFY( file3.open() ); - QUrl file3Qurl ( QUrl::fromLocalFile( file3.fileName() ) ); - - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).size() , 0 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 0 ); - QCOMPARE( KAutoSaveFile::staleFiles(file3Qurl).size() , 0 ); - - // Create the autosave1 file lock - KAutoSaveFile autoSave1( fileQurl ); - QVERIFY(autoSave1.open(QIODevice::ReadWrite)); - - // Create the autosave file lock - KAutoSaveFile autoSave2( file2Qurl ); - QVERIFY(autoSave2.open(QIODevice::ReadWrite)); - - //Check that there is one of each autosave - QCOMPARE( autoSave1.managedFile() , fileQurl ); - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file3Qurl).size() , 0 ); - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).at( 0 )->fileName() , autoSave1.fileName() ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).at( 0 )->fileName() , autoSave2.fileName() ); - - //Check that repeated setManaged on the same locked file doesn't unlock the file - autoSave1.setManagedFile(fileQurl ); - - //Check that there is one of each autosave - QCOMPARE( autoSave1.managedFile() , fileQurl ); - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file3Qurl).size() , 0 ); - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).at( 0 )->fileName() , autoSave1.fileName() ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).at( 0 )->fileName() , autoSave2.fileName() ); - - //Check that setManaged to a new file unlocks the old file - //but doesn't lock the new file until it is opened for write - autoSave1.setManagedFile(file3Qurl ); - - QCOMPARE( autoSave1.managedFile() , file3Qurl ); - QVERIFY2( !autoSave1.isWritable(), "autosave1 is still locked" ); - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).size() , 0 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file3Qurl).size() , 0 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).at( 0 )->fileName() , autoSave2.fileName() ); - - autoSave1.open(QIODevice::ReadWrite); - - QCOMPARE( autoSave1.managedFile() , file3Qurl ); - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).size() , 0 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file3Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file3Qurl).at( 0 )->fileName() , autoSave1.fileName() ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).at( 0 )->fileName() , autoSave2.fileName() ); - -} - -void KAutoSaveFileTest::test_freeStaleOnDestroy() -{ - // Create a temporary file with a unique filename - QTemporaryFile file( "test_freeStaleOnDestroy" ); - QVERIFY( file.open() ); - QUrl fileQurl ( QUrl::fromLocalFile( file.fileName() ) ); - - QTemporaryFile file2( "test_freeStaleOnDestroy" ); - QVERIFY( file2.open() ); - QUrl file2Qurl ( QUrl::fromLocalFile( file2.fileName() ) ); - - // Create the autosave1 file lock - KAutoSaveFile * autoSave1 = new KAutoSaveFile( fileQurl ); - QVERIFY(autoSave1->open(QIODevice::ReadWrite)); - - // Create the autosave2 file lock - KAutoSaveFile * autoSave2 = new KAutoSaveFile( file2Qurl ); - QVERIFY(autoSave2->open(QIODevice::ReadWrite)); - - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).at( 0 )->fileName() , autoSave1->fileName() ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).at( 0 )->fileName() , autoSave2->fileName() ); - - //Destroying an autosave removes the file and doesn't remove any other file - QString autoSave1FileName( autoSave1->fileName() ); - delete autoSave1; - - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).size() , 0 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).at( 0 )->fileName() , autoSave2->fileName() ); - - delete autoSave2; - - QCOMPARE( KAutoSaveFile::staleFiles(fileQurl).size() , 0 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 0 ); - -} - -void KAutoSaveFileTest::test_multipleAutoSavesSameFile() -{ - QSet expected, actual; - - QCOMPARE( KAutoSaveFile::allStaleFiles().size() , 0 ); - - // Create two tempfiles - QTemporaryFile file1( "test_multipleAutoSavesSameFile" ); - QVERIFY( file1.open() ); - QUrl file1Qurl ( QUrl::fromLocalFile( file1.fileName() ) ); - QTemporaryFile file2( "test_multipleAutoSavesSameFile" ); - QVERIFY( file2.open() ); - QUrl file2Qurl ( QUrl::fromLocalFile( file2.fileName() ) ); - - // Create the autosave file lock - KAutoSaveFile autoSave1( file1Qurl ); - QVERIFY(autoSave1.open(QIODevice::ReadWrite)); - KAutoSaveFile autoSave2( file2Qurl ); - QVERIFY(autoSave2.open(QIODevice::ReadWrite)); - - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 1 ); - // repeat doesn't cause error - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::allStaleFiles().size() , 2 ); - - expected << autoSave2.fileName() << autoSave1.fileName(); - Q_FOREACH(const KAutoSaveFile * kasave, KAutoSaveFile::allStaleFiles()) { - actual << kasave->fileName(); - } - - QVERIFY2( actual.contains( expected ), "All expected autosaves are not present" ); - - //Duplicate autosaves are independent - KAutoSaveFile * autoSave1p1 = new KAutoSaveFile( file1Qurl ); - QVERIFY(autoSave1p1->open(QIODevice::ReadWrite)); - - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 2 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::allStaleFiles().size() , 3 ); - - expected.clear(); - actual.clear(); - expected << autoSave1.fileName() << autoSave1p1->fileName(); - actual << KAutoSaveFile::staleFiles(file1Qurl).at( 0 )->fileName() - << KAutoSaveFile::staleFiles(file1Qurl).at( 1 )->fileName(); - - QVERIFY2( actual == expected, "Both autosaves with same filename are not present" ); - - //Releasing the lock on 1 autosave doesn't release the lock on both autosaves - autoSave1p1->releaseLock(); - - QVERIFY2( autoSave1.isWritable(), "autosave1 is not locked" ); - QVERIFY2( !autoSave1p1->isWritable(), "autosave1p1 is locked" ); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 2 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::allStaleFiles().size() , 3 ); - - expected.clear(); - actual.clear(); - expected << autoSave1.fileName() << autoSave1p1->fileName(); - actual << KAutoSaveFile::staleFiles(file1Qurl).at( 0 )->fileName() - << KAutoSaveFile::staleFiles(file1Qurl).at( 1 )->fileName(); - - //remove doesn't release the lock on either autosave - QVERIFY(autoSave1p1->open(QIODevice::ReadWrite)); - autoSave1p1->remove(); - QVERIFY2( autoSave1.isWritable(), "autosave1 is not locked" ); - QVERIFY2( !autoSave1p1->isWritable(), "autosave1p1 is locked" ); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 2 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::allStaleFiles().size() , 3 ); - - expected.clear(); - actual.clear(); - expected << autoSave1.fileName() << autoSave1p1->fileName(); - actual << KAutoSaveFile::staleFiles(file1Qurl).at( 0 )->fileName() - << KAutoSaveFile::staleFiles(file1Qurl).at( 1 )->fileName(); - - //releaseLock on removed file removes the now staleFile - autoSave1p1->releaseLock(); - QVERIFY2( !autoSave1p1->isWritable(), "autosave1p1 is locked" ); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::staleFiles(file2Qurl).size() , 1 ); - QCOMPARE( KAutoSaveFile::allStaleFiles().size() , 2 ); - - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).at( 0 )->fileName() , autoSave1.fileName() ); - -} - -void KAutoSaveFileTest::test_requireExplicitRemoval() -{ - - // Create tempfiles - QTemporaryFile file1( "test_requireExplicitRemoval" ); - QVERIFY( file1.open() ); - QUrl file1Qurl ( QUrl::fromLocalFile( file1.fileName() ) ); - - // Create the autosave file lock - KAutoSaveFile * autoSave1 = new KAutoSaveFile( file1Qurl ); - - QVERIFY(autoSave1->open(QIODevice::ReadWrite)); - - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 1 ); - - autoSave1->releaseLock(); - QVERIFY(!autoSave1->isWritable() ); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 1 ); - - QVERIFY(autoSave1->open(QIODevice::ReadWrite)); - autoSave1->remove(); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 1 ); - - delete autoSave1; - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 0 ); - -} - -void KAutoSaveFileTest::test_stealAbandonedLock() -{ - // Create a tempfile - QTemporaryFile file1( "test_stealAbandonedLock" ); - QVERIFY( file1.open() ); - QUrl file1Qurl ( QUrl::fromLocalFile( file1.fileName() ) ); - - // Create the autosave file lock - KAutoSaveFile * autoSave1 = new KAutoSaveFile( file1Qurl ); - - QVERIFY(autoSave1->open(QIODevice::ReadWrite)); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 1 ); - - autoSave1->releaseLock(); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 1 ); - - delete autoSave1; - KAutoSaveFile * autoSave2 = KAutoSaveFile::staleFiles(file1Qurl).at( 0 ); - - //Manipulating a read only file, you do not have the lock, you can't remove the lock - QVERIFY(autoSave2->open(QIODevice::ReadOnly)); - autoSave2->close(); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 1 ); - QVERIFY(!autoSave2->remove()); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 1 ); - - QVERIFY(autoSave2->open(QIODevice::ReadWrite)); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 1 ); - - QTextStream out( autoSave2 ); - out << "A couple of lines\n of text.\n"; - - //Closing a file doesn't remove the lock - autoSave2->close(); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 1 ); - - //resizing a file doesn't remove the lock - QVERIFY(autoSave2->resize(0)); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 1 ); - - //removing a file doesn't delete the lock - QVERIFY(autoSave2->open(QIODevice::ReadWrite)); - QVERIFY(autoSave2->remove()); - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 1 ); - - //deleting a non-existent locked file will remove the lock - delete autoSave2; - QCOMPARE( KAutoSaveFile::staleFiles(file1Qurl).size() , 0 ); - -} - - -void KAutoSaveFileTest::test_locking() -{ - QUrl normalFile(QString::fromLatin1("fish://user@example.com/home/remote/test.txt")); - - KAutoSaveFile saveFile(normalFile); - - QVERIFY(!QFile::exists(saveFile.fileName())); - QVERIFY(saveFile.open(QIODevice::ReadWrite)); - - const QList staleFiles(KAutoSaveFile::staleFiles(normalFile)); - - QVERIFY(!staleFiles.isEmpty()); - - KAutoSaveFile *saveFile2 = staleFiles.at(0); - - const QString fn = saveFile2->fileName(); - // It looks like $XDG_DATA_HOME/stalefiles/qttest/test.txtXXXfish_%2Fhome%2FremoteXXXXXXX - QVERIFY2(fn.contains(QLatin1String("stalefiles/" ) + mainappname - + QLatin1String("/test.txt")), qPrintable(fn)); - QVERIFY2(fn.contains(QLatin1String("fish%3A%2F%2Fuser%40example.com%2Fhome%2Fremote")), qPrintable(fn)); - - QVERIFY(QFile::exists(saveFile.fileName())); - QVERIFY(QFile::exists(saveFile2->fileName())); - QVERIFY(!saveFile2->open(QIODevice::ReadWrite)); - - saveFile.releaseLock(); - - QVERIFY(saveFile2->open(QIODevice::ReadWrite)); - - delete saveFile2; - -} - - -/** - * This code is the same as the example code other than the QVERIFY and setup statements. - * **/ -class Document : public QObject -{ - // Q_OBJECT // INTENTIONALLY commented out to not generate a 2nd moc -public: - /**Setup the example code to answer the userdialog @p userResponse**/ - void exampleCodeWrapper(bool userResponse); - - void exampleOpen(const QUrl &url - , bool userResponse - , const QString &recoverableName - , const QString &unrecoverableName ); - - void recoverFiles( QList staleFiles - , const QString &recoverableName - , const QString &unrecoverableName ); - KAutoSaveFile * m_autosave; -}; - -void Document::exampleOpen(QUrl const & url - , bool userResponse - , const QString &recoverableName - , const QString &unrecoverableName) -{ - // check whether autosave files exist: - QList staleFiles = KAutoSaveFile::staleFiles(url); - QCOMPARE( staleFiles.size(), 2 ); - QVERIFY( !staleFiles.isEmpty() ); - if (!staleFiles.isEmpty()) { - if ( userResponse ) { - recoverFiles(staleFiles, recoverableName, unrecoverableName); - return; - } else { - // remove the stale files - foreach (KAutoSaveFile *stale, staleFiles) { - if ( stale->open(QIODevice::WriteOnly) ) { - QCOMPARE( stale->fileName(), recoverableName ); - } else { - QCOMPARE( stale->fileName(), unrecoverableName ); - } - delete stale; - } - } - } - - // create new autosave object - m_autosave = new KAutoSaveFile(url, this); - QVERIFY( m_autosave ); - - // continue the process of opening file 'url' -} - -void Document::recoverFiles( QList staleFiles - , const QString &recoverableName - , const QString &unrecoverableName - ) { - foreach (KAutoSaveFile *stale, staleFiles) { - if (!stale->open(QIODevice::ReadWrite)) { - // show an error message; we could not steal the lockfile - // maybe another application got to the file before us? - QCOMPARE( stale->fileName() , unrecoverableName ); - delete stale; - continue; - } - QCOMPARE( stale->fileName() , recoverableName ); - - Document *doc = new Document; - doc->m_autosave = stale; - - QCOMPARE( QString( stale->readAll() ), QString( "Auto Save1 File\n" ) ); - - // NOT part of example code, just cleanup - delete stale; - } -} - -void Document::exampleCodeWrapper(bool userResponse) -{ - // Create a tempfile - QTemporaryFile managedFile; - QVERIFY( managedFile.open() ); - QTextStream out( &managedFile ); - out << "Managed File\n"; - - QUrl managedFileQurl ( QUrl::fromLocalFile( managedFile.fileName() ) ); - - // Create the recoverable locked file - KAutoSaveFile * autoSaveRecoverable = new KAutoSaveFile( managedFileQurl ); - - QVERIFY(autoSaveRecoverable->open(QIODevice::ReadWrite)); - QUrl recoverableQurl( autoSaveRecoverable->fileName() ); - QString recoverableFileName( autoSaveRecoverable->fileName() ); - QTextStream out2( autoSaveRecoverable ); - out2 << "Auto Save1 File\n"; - autoSaveRecoverable->releaseLock(); - delete autoSaveRecoverable; - - KAutoSaveFile autoSaveHard( managedFileQurl ); - - QVERIFY(autoSaveHard.open(QIODevice::ReadWrite)); - QUrl unrecoverableQurl( autoSaveHard.fileName() ); - - exampleOpen( managedFileQurl, userResponse - , recoverableFileName, autoSaveHard.fileName()); - -} - -void KAutoSaveFileTest::test_exampleCode() -{ - Document doc1, doc2; - doc1.exampleCodeWrapper( false); - doc2.exampleCodeWrapper( true); -} - - -void KAutoSaveFileTest::test_deleteDirectory() -{ - QTemporaryFile file( "test_freeStaleOnDestroy" ); - QVERIFY( file.open() ); - QUrl fileQurl ( QUrl::fromLocalFile( file.fileName() ) ); - - // Create the autosave1 file lock - KAutoSaveFile * autoSave1 = new KAutoSaveFile( fileQurl ); - QVERIFY(autoSave1->open(QIODevice::ReadWrite)); - - delete autoSave1; - - //The last autosave is gone and so should be the directory. - QString staleFilesDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) - + QString::fromLatin1("/stalefiles/") - + mainappname; - - QVERIFY2( ! QDir( staleFilesDir ).exists() - , "application directory in stalefiles still exists after last kautosave is deleted" ); - -} - -// void KAutoSaveFileTest::test_housekeeping() -// { -// /*Implementation specific: -// * There are 4 bad combinations of autosavefile, kalock and lock files*/ - -// QString housekeepFile( "houseKeep" ); -// QString tempplate = KAutoSaveFilePrivate::fileNameTemplate(housekeepFile, true ); - - - -// //* Only autosave file -// QTemporaryFile asaveOnlyfile( tempplate ); -// QVERIFY( asaveOnlyfile.open() ); - -// //* Only lock file -// //* autosave with lock file -// //* Only kalock file - - -// // Create a tempfile - -// // Create the autosave file lock -// KAutoSaveFile * autoSave1 = new KAutoSaveFile( file1Qurl ); -// filesToRemove << autoSave1->fileName(); - -// autoSave1->setAutoRemove( false ); -// QVERIFY(autoSave1->open(QIODevice::ReadWrite)); - - - -// QTemporaryFile randfile1("test_exampleCode"); -// QVERIFY( randfile1.open() ); -// QUrl randomQurl ( QUrl::fromLocalFile( randfile1.fileName() ) ); - -// QCOMPARE( KAutoSaveFile::staleFiles(randomQurl).size() , 0 ); - - - -// } diff -Nru libkeduvocdocument-15.12.3/keduvocdocument/autotests/kautosavefiletest.h libkeduvocdocument-16.04.3/keduvocdocument/autotests/kautosavefiletest.h --- libkeduvocdocument-15.12.3/keduvocdocument/autotests/kautosavefiletest.h 2016-02-15 21:01:21.000000000 +0000 +++ libkeduvocdocument-16.04.3/keduvocdocument/autotests/kautosavefiletest.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 2006 Jacob R Rideout - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef kautosavefiletest_h -#define kautosavefiletest_h - -#include -#include - -class KAutoSaveFileTest : public QObject -{ - Q_OBJECT - -private Q_SLOTS: - /** Remove all autosaveFiles for the qtest application */ - void initTestCase(); - /** Remove all autosaveFiles for the qtest application */ - void init(); - - void test_readWrite(); - void test_fileStaleFiles(); - void test_applicationStaleFiles(); - - /** Check that staleFiles only detects the same filename. */ - void test_crossContaminateFilename(); - - /** Checks that staleFiles only detects the same appname. */ - void test_crossContaminateAppname(); - - /** Checks that staleFiles are unlocked but not removed on releaseLock. */ - void test_freeStaleOnRelease(); - - /** Checks that stateFiles are unlocked on setManaged, when appropriate. */ - void test_freeStaleOnSetManaged(); - - /** Checks that file locks are unlocked but not removed when the autosave is destroyed. */ - void test_freeStaleOnDestroy(); - - /** Checks that multiple autosaves on same file have different names and indepedent locks. */ - void test_multipleAutoSavesSameFile(); - - /** Checks that unlocking and then removing the autosave file cleans up everything. */ - void test_requireExplicitRemoval(); - - /** Checks that an abandoned lock can be recovered. */ - void test_stealAbandonedLock(); - - void test_locking(); - - /** Checks that the example code works. */ - void test_exampleCode(); - - /** Check that autosave, kalock and lockfiles in inappropriate combinations are removed. */ - /* void test_housekeeping(); */ - - - /* Implementation specific tests*/ - /** Checks deletion of directory when last autosave is removed**/ - void test_deleteDirectory(); - - void cleanupTestCase(); - -private: - QString mainappname, appname1, appname2; ///< names of the fake applications - QStringList filesToRemove; -}; - -#endif diff -Nru libkeduvocdocument-15.12.3/keduvocdocument/CMakeLists.txt libkeduvocdocument-16.04.3/keduvocdocument/CMakeLists.txt --- libkeduvocdocument-15.12.3/keduvocdocument/CMakeLists.txt 2016-02-15 21:01:21.000000000 +0000 +++ libkeduvocdocument-16.04.3/keduvocdocument/CMakeLists.txt 2016-02-18 07:51:38.000000000 +0000 @@ -30,8 +30,6 @@ keduvockvtmlcompability.cpp keduvockvtml2writer.cpp keduvoccsvwriter.cpp - autosave/kautosavefile.cpp - autosave/kautosavefileprivate.cpp readerwriters/dummyreader.cpp readerwriters/failedreader.cpp readerwriters/keduvockvtmlreader.cpp diff -Nru libkeduvocdocument-15.12.3/keduvocdocument/keduvoccontainer.cpp libkeduvocdocument-16.04.3/keduvocdocument/keduvoccontainer.cpp --- libkeduvocdocument-15.12.3/keduvocdocument/keduvoccontainer.cpp 2016-02-15 21:01:21.000000000 +0000 +++ libkeduvocdocument-16.04.3/keduvocdocument/keduvoccontainer.cpp 2016-02-18 07:51:38.000000000 +0000 @@ -297,6 +297,9 @@ // make that a percentage // There are KV_MAX_GRADE grades from 0 -> 100 % // There are KV_MAX_GRADE preGrades within the first grade. + if (count == 0) { + return 100.0; + } return ((sum * 100.0 / KV_MAX_GRADE) + (presum * 100.0 / (KV_MAX_GRADE * KV_MAX_GRADE))) / count; } diff -Nru libkeduvocdocument-15.12.3/keduvocdocument/keduvoccsvwriter.cpp libkeduvocdocument-16.04.3/keduvocdocument/keduvoccsvwriter.cpp --- libkeduvocdocument-15.12.3/keduvocdocument/keduvoccsvwriter.cpp 2016-02-15 21:01:21.000000000 +0000 +++ libkeduvocdocument-16.04.3/keduvocdocument/keduvoccsvwriter.cpp 2016-02-18 07:51:38.000000000 +0000 @@ -26,12 +26,11 @@ #include "keduvocexpression.h" KEduVocCsvWriter::KEduVocCsvWriter( QFile *file ) + : m_outputFile(file) // the file must be already open + , m_doc(nullptr) { - // the file must be already open - m_outputFile = file; } - bool KEduVocCsvWriter::writeDoc( KEduVocDocument *doc, const QString &generator ) { Q_UNUSED( generator ); diff -Nru libkeduvocdocument-15.12.3/keduvocdocument/keduvocdocument.cpp libkeduvocdocument-16.04.3/keduvocdocument/keduvocdocument.cpp --- libkeduvocdocument-15.12.3/keduvocdocument/keduvocdocument.cpp 2016-02-15 21:01:21.000000000 +0000 +++ libkeduvocdocument-16.04.3/keduvocdocument/keduvocdocument.cpp 2016-02-18 07:51:38.000000000 +0000 @@ -30,7 +30,7 @@ #include #include #include -#include "autosave/kautosavefile.h" +#include #include "keduvocexpression.h" #include "keduvoclesson.h" @@ -49,8 +49,6 @@ #define TXT_EXT "txt" #define WQL_EXT "wql" -using namespace LexiAutoSave; - /** @details Private Data class for KEduVocDocument */ class KEduVocDocument::KEduVocDocumentPrivate { @@ -62,7 +60,7 @@ m_lessonContainer = 0; m_wordTypeContainer = 0; m_leitnerContainer = 0; - m_autosave = new LexiAutoSave::KAutoSaveFile; + m_autosave = new KAutoSaveFile; init(); } @@ -78,7 +76,7 @@ * Note: It is a pointer to allow locking a new file, saving results and * then transfering the lock to m_autosave without risking loss of lock. * See saveAs for clarification*/ - LexiAutoSave::KAutoSaveFile *m_autosave; + KAutoSaveFile *m_autosave; bool m_dirty; ///< dirty bit bool m_isReadOnly; ///< FileOpenReadOnly was used for opening @@ -159,7 +157,7 @@ m_isReadOnly = false; m_queryorg = ""; m_querytrans = ""; - m_autosave->setManagedFile( i18n( "Untitled" ) ); + m_autosave->setManagedFile( QUrl() ); m_author = ""; m_title = ""; m_comment = ""; @@ -174,7 +172,7 @@ KEduVocDocument::ErrorCode KEduVocDocument::KEduVocDocumentPrivate::initializeKAutoSave(KAutoSaveFile &autosave, QString const & fpath, FileHandlingFlags flags) const { - QList staleFiles = KAutoSaveFile::staleFiles( fpath, + QList staleFiles = KAutoSaveFile::staleFiles( QUrl::fromLocalFile(fpath), QCoreApplication::instance()->applicationName()); if ( !staleFiles.isEmpty()) { if ( flags & FileIgnoreLock ) { @@ -189,7 +187,7 @@ } } - autosave.setManagedFile( fpath ); + autosave.setManagedFile( QUrl::fromLocalFile(fpath) ); if ( !autosave.open( QIODevice::ReadWrite ) ) { qWarning() << i18n( "Cannot lock file %1", autosave.fileName() ); return FileCannotLock; @@ -256,9 +254,9 @@ qWarning() << i18n("Cannot open tempfile %1", tempFile.fileName()); return Unknown; } - KIO::FileCopyJob *job = KIO::file_copy(url, tempFile.fileName()); + KIO::FileCopyJob *job = KIO::file_copy(url, QUrl::fromLocalFile(tempFile.fileName()), -1, KIO::Overwrite); if (!job->exec()) { - qWarning() << i18n("Cannot download %1", url.toDisplayString()); + qWarning() << i18n("Cannot download %1: %2", url.toDisplayString(), job->errorString()); return FileDoesNotExist; } temporaryFile = tempFile.fileName(); diff -Nru libkeduvocdocument-15.12.3/keduvocdocument/tests/converter.cpp libkeduvocdocument-16.04.3/keduvocdocument/tests/converter.cpp --- libkeduvocdocument-15.12.3/keduvocdocument/tests/converter.cpp 2016-02-15 21:01:21.000000000 +0000 +++ libkeduvocdocument-16.04.3/keduvocdocument/tests/converter.cpp 2016-02-18 07:51:38.000000000 +0000 @@ -53,9 +53,9 @@ QStringList files = parser.positionalArguments(); if ( files.count() > 0 ) { - QUrl infile = files.at( 0 ); + QUrl infile = QUrl::fromLocalFile(files.at( 0 )); if ( files.count() > 1 ) { - QUrl outfile = files.at( 1 ); + QUrl outfile = QUrl::fromLocalFile(files.at( 1 )); KEduVocDocument document; qDebug() << "Reading " << infile;