File indexing completed on 2024-04-21 15:42:51
0001 /*************************************************************************** 0002 This file contains private helper classes for the Smb4KSynchronizer 0003 class. 0004 ------------------- 0005 begin : Fr Okt 24 2008 0006 copyright : (C) 2008-2019 by Alexander Reinholdt 0007 email : alexander.reinholdt@kdemail.net 0008 ***************************************************************************/ 0009 0010 /*************************************************************************** 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 * This program is distributed in the hope that it will be useful, but * 0017 * WITHOUT ANY WARRANTY; without even the implied warranty of * 0018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 0019 * General Public License for more details. * 0020 * * 0021 * You should have received a copy of the GNU General Public License * 0022 * along with this program; if not, write to the * 0023 * Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,* 0024 * MA 02110-1335, USA * 0025 ***************************************************************************/ 0026 0027 #ifndef SMB4KSYNCHRONIZER_P_H 0028 #define SMB4KSYNCHRONIZER_P_H 0029 0030 // application specific includes 0031 #include "smb4ksynchronizer.h" 0032 #include "smb4kglobal.h" 0033 0034 // Qt includes 0035 #include <QUrl> 0036 #include <QDialog> 0037 #include <QPushButton> 0038 0039 // KDE includes 0040 #include <KCoreAddons/KJob> 0041 #include <KCoreAddons/KProcess> 0042 #include <KIOWidgets/KUrlRequester> 0043 #include <KJobWidgets/KUiServerJobTracker> 0044 0045 0046 class Smb4KSyncJob : public KJob 0047 { 0048 Q_OBJECT 0049 0050 public: 0051 /** 0052 * Constructor 0053 */ 0054 explicit Smb4KSyncJob(QObject *parent = 0); 0055 0056 /** 0057 * Destructor 0058 */ 0059 ~Smb4KSyncJob(); 0060 0061 /** 0062 * Starts the synchronization 0063 */ 0064 void start() override; 0065 0066 /** 0067 * Setup the synchronization process. This function must be 0068 * called before start() is run. 0069 * 0070 * @param share The share 0071 */ 0072 void setupSynchronization(const SharePtr &share); 0073 0074 /** 0075 * Returns the source directory. 0076 * 0077 * @returns the source directory. 0078 */ 0079 const QUrl &source() { return m_src; } 0080 0081 /** 0082 * Returns the destination directory. 0083 * 0084 * @returns the destination directory. 0085 */ 0086 const QUrl &destination() { return m_dest; } 0087 0088 Q_SIGNALS: 0089 /** 0090 * This signal is emitted when a job is started. The emitted path 0091 * is the one of the destination. 0092 * 0093 * @param dest The destination's URL 0094 */ 0095 void aboutToStart(const QString &dest); 0096 0097 /** 0098 * This signal is emitted when a job has finished. The emitted 0099 * URL is the one of the destination. 0100 * 0101 * @param dest The destination's URL 0102 */ 0103 void finished(const QString &dest); 0104 0105 protected: 0106 /** 0107 * Reimplemented from KJob. Kills the internal process and 0108 * then the job itself. 0109 */ 0110 bool doKill() override; 0111 0112 protected Q_SLOTS: 0113 void slotStartSynchronization(); 0114 void slotReadStandardOutput(); 0115 void slotReadStandardError(); 0116 void slotProcessFinished(int exitCode, QProcess::ExitStatus status); 0117 0118 private: 0119 SharePtr m_share; 0120 QUrl m_src; 0121 QUrl m_dest; 0122 KProcess *m_process; 0123 KUiServerJobTracker *m_job_tracker; 0124 }; 0125 0126 0127 class Smb4KSynchronizationDialog : public QDialog 0128 { 0129 Q_OBJECT 0130 0131 public: 0132 /** 0133 * The constructor 0134 * 0135 * @param share The share item 0136 * 0137 * @param parent The parent widget 0138 */ 0139 explicit Smb4KSynchronizationDialog(const SharePtr &share, QWidget *parent = 0); 0140 0141 /** 0142 * The destructor 0143 */ 0144 ~Smb4KSynchronizationDialog(); 0145 0146 /** 0147 * The source URL 0148 */ 0149 const QUrl source(); 0150 0151 /** 0152 * The destination URL 0153 */ 0154 const QUrl destination(); 0155 0156 protected Q_SLOTS: 0157 void slotCancelClicked(); 0158 void slotSynchronizeClicked(); 0159 void slotSwapPathsClicked(); 0160 0161 private: 0162 QPushButton *m_swap_button; 0163 QPushButton *m_synchronize_button; 0164 QPushButton *m_cancel_button; 0165 0166 /** 0167 * A pointer to the share object 0168 */ 0169 SharePtr m_share; 0170 0171 /** 0172 * The source URL requester 0173 */ 0174 KUrlRequester *m_source; 0175 0176 /** 0177 * The destination URL requester 0178 */ 0179 KUrlRequester *m_destination; 0180 }; 0181 0182 0183 class Smb4KSynchronizerPrivate 0184 { 0185 }; 0186 0187 0188 class Smb4KSynchronizerStatic 0189 { 0190 public: 0191 Smb4KSynchronizer instance; 0192 }; 0193 0194 #endif