File indexing completed on 2024-04-28 12:45:29

0001 /*
0002     This file contains private helper classes for the Smb4KSynchronizer
0003     class.
0004 
0005     SPDX-FileCopyrightText: 2008-2023 Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef SMB4KSYNCHRONIZER_P_H
0010 #define SMB4KSYNCHRONIZER_P_H
0011 
0012 // application specific includes
0013 #include "smb4ksynchronizer.h"
0014 
0015 // Qt includes
0016 #include <QUrl>
0017 
0018 // KDE includes
0019 #include <KJob>
0020 #include <KProcess>
0021 #include <KUiServerJobTracker>
0022 
0023 class Smb4KSyncJob : public KJob
0024 {
0025     Q_OBJECT
0026 
0027 public:
0028     /**
0029      * Constructor
0030      */
0031     explicit Smb4KSyncJob(QObject *parent = nullptr);
0032 
0033     /**
0034      * Destructor
0035      */
0036     ~Smb4KSyncJob();
0037 
0038     /**
0039      * Starts the synchronization
0040      */
0041     void start() override;
0042 
0043     /**
0044      * Setup the synchronization process. This function must be
0045      * called before start() is run.
0046      *
0047      * @param sourceUrl         The source URL
0048      *
0049      * @param destinationUrl    The destination URL
0050      */
0051     void setupSynchronization(const QUrl &sourceUrl, const QUrl &destinationUrl);
0052 
0053 Q_SIGNALS:
0054     /**
0055      * This signal is emitted when a job is started. The emitted path
0056      * is the one of the destination.
0057      *
0058      * @param dest        The destination's URL
0059      */
0060     void aboutToStart(const QString &dest);
0061 
0062     /**
0063      * This signal is emitted when a job has finished. The emitted
0064      * URL is the one of the destination.
0065      *
0066      * @param dest        The destination's URL
0067      */
0068     void finished(const QString &dest);
0069 
0070 protected:
0071     /**
0072      * Reimplemented from KJob. Kills the internal process and
0073      * then the job itself.
0074      */
0075     bool doKill() override;
0076 
0077 protected Q_SLOTS:
0078     void slotStartSynchronization();
0079     void slotReadStandardOutput();
0080     void slotReadStandardError();
0081     void slotProcessFinished(int exitCode, QProcess::ExitStatus status);
0082 
0083 private:
0084     QUrl m_sourceUrl;
0085     QUrl m_destinationUrl;
0086     KProcess *m_process;
0087     KUiServerJobTracker *m_jobTracker;
0088     bool m_terminated;
0089 };
0090 
0091 class Smb4KSynchronizerPrivate
0092 {
0093 };
0094 
0095 class Smb4KSynchronizerStatic
0096 {
0097 public:
0098     Smb4KSynchronizer instance;
0099 };
0100 
0101 #endif