File indexing completed on 2024-04-28 16:13:03

0001 /***************************************************************************
0002     This is the new synchronizer of Smb4K.
0003                              -------------------
0004     begin                : Fr Feb 04 2011
0005     copyright            : (C) 2011-2019 by Alexander Reinholdt
0006     email                : alexander.reinholdt@kdemail.net
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *   This program is free software; you can redistribute it and/or modify  *
0011  *   it under the terms of the GNU General Public License as published by  *
0012  *   the Free Software Foundation; either version 2 of the License, or     *
0013  *   (at your option) any later version.                                   *
0014  *                                                                         *
0015  *   This program is distributed in the hope that it will be useful, but   *
0016  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
0017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
0018  *   General Public License for more details.                              *
0019  *                                                                         *
0020  *   You should have received a copy of the GNU General Public License     *
0021  *   along with this program; if not, write to the                         *
0022  *   Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,*
0023  *   MA 02110-1335, USA                                                    *
0024  ***************************************************************************/
0025 
0026 #ifndef SMB4KSYNCHRONIZER_H
0027 #define SMB4KSYNCHRONIZER_H
0028 
0029 // application specific includes
0030 #include "smb4kglobal.h"
0031 
0032 // Qt includes
0033 #include <QString>
0034 #include <QScopedPointer>
0035 
0036 // KDE includes
0037 #include <KCoreAddons/KCompositeJob>
0038 
0039 // forward declarations
0040 class Smb4KSynchronizerPrivate;
0041 
0042 class Q_DECL_EXPORT Smb4KSynchronizer : public KCompositeJob
0043 {
0044   Q_OBJECT
0045 
0046   friend class Smb4KSynchronizerPrivate;
0047 
0048   public:
0049     /**
0050      * The constructor
0051      */
0052     explicit Smb4KSynchronizer(QObject *parent = 0);
0053 
0054     /**
0055      * The destructor
0056      */
0057     ~Smb4KSynchronizer();
0058     
0059     /**
0060      * This function returns a static pointer to this class.
0061      *
0062      * @returns a static pointer to the Smb4KSynchronizer class.
0063      */
0064     static Smb4KSynchronizer *self();
0065 
0066     /**
0067      * Sets the URL for the source and destination by showing the user a
0068      * dialog for URL input. The URLs are then passed to the actual job that
0069      * does all the work.
0070      *
0071      * @param share         The Smb4KShare object
0072      */
0073     void synchronize(const SharePtr &share);
0074 
0075     /**
0076      * This function tells you whether the synchronizer is running
0077      * or not.
0078      *
0079      * @returns TRUE if the synchronizer is running and FALSE otherwise
0080      */
0081     bool isRunning();
0082 
0083     /**
0084      * With this function you can test whether a synchronization job 
0085      * for a certain share @param share is already running.
0086      * 
0087      * @returns TRUE if a synchronization process is already running
0088      */
0089     bool isRunning(const SharePtr &share);
0090 
0091     /**
0092      * This function either aborts the synchronization for a certain 
0093      * mounted share, if a valid pointer is passed, or aborts all running
0094      * processes.
0095      *
0096      * @param share         The Smb4KShare object
0097      */
0098     void abort(const SharePtr &share = SharePtr());
0099 
0100     /**
0101      * This function starts the composite job
0102      */
0103     void start() override;
0104 
0105   Q_SIGNALS:
0106     /**
0107      * This signal is emitted when a job is started. The emitted path
0108      * is the one of the destination.
0109      *
0110      * @param dest        The destination's URL
0111      */
0112     void aboutToStart(const QString &dest);
0113 
0114     /**
0115      * This signal is emitted when a job has finished. The emitted
0116      * URL is the one of the destination.
0117      *
0118      * @param dest        The destination's URL
0119      */
0120     void finished(const QString &dest);
0121     
0122   protected Q_SLOTS:
0123     /**
0124      * Invoked by start() function
0125      */
0126     void slotStartJobs();
0127     
0128     /**
0129      * Invoked when a job finished
0130      */
0131     void slotJobFinished(KJob *job);
0132 
0133     /**
0134      * Invoked when the application goes down
0135      */
0136     void slotAboutToQuit();
0137 
0138   private:
0139     /**
0140      * Pointer to Smb4KSearchPrivate class
0141      */
0142     const QScopedPointer<Smb4KSynchronizerPrivate> d;
0143 };
0144 
0145 #endif