File indexing completed on 2025-02-09 07:11:25

0001 /*
0002     This file is part of the Kasten Framework, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2007-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 #ifndef KASTEN_ABSTRACTMODELFILESYSTEMSYNCHRONIZER_P_HPP
0010 #define KASTEN_ABSTRACTMODELFILESYSTEMSYNCHRONIZER_P_HPP
0011 
0012 #include "abstractmodelfilesystemsynchronizer.hpp"
0013 
0014 // lib
0015 #include <abstractmodelsynchronizer_p.hpp>
0016 // Qt
0017 #include <QDateTime>
0018 
0019 class QNetworkConfigurationManager;
0020 
0021 namespace Kasten {
0022 
0023 class AbstractModelFileSystemSynchronizerPrivate : public AbstractModelSynchronizerPrivate
0024 {
0025 public:
0026     explicit AbstractModelFileSystemSynchronizerPrivate(AbstractModelFileSystemSynchronizer* parent);
0027 
0028     ~AbstractModelFileSystemSynchronizerPrivate() override;
0029 
0030 public:
0031     RemoteSyncState remoteSyncState() const;
0032 
0033 public:
0034     void setRemoteState(RemoteSyncState remoteState);
0035     void setFileDateTimeOnSync(const QDateTime& fileDateTime);
0036 
0037     void startFileWatching();
0038     void stopFileWatching();
0039     void pauseFileWatching();
0040     void unpauseFileWatching();
0041 
0042     void startNetworkWatching();
0043     void stopNetworkWatching();
0044 
0045 public:
0046     void onFileDirty(const QString& fileName);
0047     void onFileCreated(const QString& fileName);
0048     void onFileDeleted(const QString& fileName);
0049     void onOnlineStateChanged(bool isOnline);
0050 
0051 protected:
0052     QDateTime mFileDateTime;
0053     RemoteSyncState mRemoteState = RemoteUnknown;
0054     QNetworkConfigurationManager* mNetworkConfigurationManager = nullptr;
0055     mutable KDirWatch* mDirWatch = nullptr;
0056 
0057 private:
0058     Q_DECLARE_PUBLIC(AbstractModelFileSystemSynchronizer)
0059 };
0060 
0061 inline AbstractModelFileSystemSynchronizerPrivate::AbstractModelFileSystemSynchronizerPrivate(AbstractModelFileSystemSynchronizer* parent)
0062     : AbstractModelSynchronizerPrivate(parent)
0063 {
0064 }
0065 inline RemoteSyncState AbstractModelFileSystemSynchronizerPrivate::remoteSyncState() const { return mRemoteState; }
0066 
0067 inline void AbstractModelFileSystemSynchronizerPrivate::setRemoteState(RemoteSyncState remoteState)
0068 {
0069     Q_Q(AbstractModelFileSystemSynchronizer);
0070 
0071     if (mRemoteState == remoteState) {
0072         return;
0073     }
0074 
0075     mRemoteState = remoteState;
0076     Q_EMIT q->remoteSyncStateChanged(remoteState);
0077 }
0078 inline void AbstractModelFileSystemSynchronizerPrivate::setFileDateTimeOnSync(const QDateTime& fileDateTime)
0079 {
0080     mFileDateTime = fileDateTime;
0081 }
0082 
0083 }
0084 
0085 #endif