File indexing completed on 2024-05-26 05:56:52

0001 /*
0002     This file is part of the Okteta Kasten module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2008-2009 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #include "bytearrayrawfileloadjob.hpp"
0010 
0011 // lib
0012 // #include "externalbookmarkstorage.hpp"
0013 #include "bytearrayrawfilesynchronizer.hpp"
0014 #include "bytearrayrawfileloadthread.hpp"
0015 #include "bytearraydocument.hpp"
0016 // Qt
0017 #include <QCoreApplication>
0018 #include <QUrl>
0019 
0020 namespace Kasten {
0021 
0022 ByteArrayRawFileLoadJob::ByteArrayRawFileLoadJob(ByteArrayRawFileSynchronizer* synchronizer, const QUrl& url)
0023     : AbstractFileSystemLoadJob(synchronizer, url)
0024 {}
0025 
0026 ByteArrayRawFileLoadJob::~ByteArrayRawFileLoadJob() = default;
0027 
0028 void ByteArrayRawFileLoadJob::startLoadFromFile()
0029 {
0030     auto* loadThread = new ByteArrayRawFileLoadThread(this, file());
0031     loadThread->start();
0032     while (!loadThread->wait(100)) {
0033         QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);
0034     }
0035 
0036     ByteArrayDocument* document = loadThread->document();
0037     qobject_cast<ByteArrayRawFileSynchronizer*>(synchronizer())->setDocument(document);
0038 
0039     if (document) {
0040 //         ExternalBookmarkStorage().readBookmarks( document, url() );
0041     } else {
0042         // TODO: these reports should go to a notification system, for log or popup
0043         setError(KJob::KilledJobError);
0044         setErrorText(loadThread->errorString());
0045     }
0046 
0047     delete loadThread;
0048 
0049     setDocument(document);
0050 }
0051 
0052 }
0053 
0054 #include "moc_bytearrayrawfileloadjob.cpp"