File indexing completed on 2025-01-05 05:23:50

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 "bytearrayrawfilewritetojob.hpp"
0010 
0011 // lib
0012 // #include "externalbookmarkstorage.hpp"
0013 #include "bytearrayrawfilesynchronizer.hpp"
0014 #include "bytearrayrawfilewritethread.hpp"
0015 #include "bytearraydocument.hpp"
0016 // Qt
0017 #include <QUrl>
0018 #include <QCoreApplication>
0019 
0020 namespace Kasten {
0021 
0022 ByteArrayRawFileWriteToJob::ByteArrayRawFileWriteToJob(ByteArrayRawFileSynchronizer* synchronizer,
0023                                                        const QUrl& url, AbstractModelSynchronizer::ConnectOption option)
0024     : AbstractFileSystemSyncWithRemoteJob(synchronizer, url, option)
0025 {}
0026 
0027 ByteArrayRawFileWriteToJob::~ByteArrayRawFileWriteToJob() = default;
0028 
0029 void ByteArrayRawFileWriteToJob::startSyncWithRemote()
0030 {
0031     auto* document = qobject_cast<ByteArrayDocument*>(synchronizer()->document());
0032     auto* writeThread = new ByteArrayRawFileWriteThread(this, document, file());
0033     writeThread->start();
0034     while (!writeThread->wait(100)) {
0035         QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);
0036     }
0037 
0038     const bool success = writeThread->success();
0039     delete writeThread;
0040 
0041 //     if( success )
0042 //         ExternalBookmarkStorage().writeBookmarks( document, synchronizer()->url() );
0043 
0044     completeSync(success);
0045 }
0046 
0047 }
0048 
0049 #include "moc_bytearrayrawfilewritetojob.cpp"