1 /****************************************************************************** 2 3 This source file is part of the MoleQueue project. 4 5 Copyright 2012 Kitware, Inc. 6 7 This source code is released under the New BSD License, (the "License"). 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 15 ******************************************************************************/ 16 17 #ifndef UITFILEUPLOADER_H_ 18 #define UITFILEUPLOADER_H_ 19 20 #include "filesystemoperation.h" 21 22 #include <QtCore/QObject> 23 #include <QtNetwork/QNetworkReply> 24 #include <QtCore/QQueue> 25 #include <QtCore/QFileInfo> 26 27 namespace MoleQueue { 28 namespace Uit { 29 30 class Session; 31 32 /** 33 * @brief File system operation to upload a directory to a remote UIT system. 34 */ 35 class DirectoryUpload: public FileSystemOperation 36 { 37 Q_OBJECT 38 public: 39 /** 40 * @param session The UIT session. 41 * @param parentObject The parent object. 42 */ 43 DirectoryUpload(Session *session, QObject *parentObject = 0); 44 45 /** 46 * @return The local path to be uploaded. 47 */ localPath()48 QString localPath() const 49 { 50 return m_localPath; 51 } 52 53 /** 54 * @param path The local path to be uploaded. 55 */ setLocalPath(const QString & path)56 void setLocalPath(const QString& path) 57 { 58 m_localPath = path; 59 } 60 61 /** 62 * @return The remote file path for the directory to be uploaded to. 63 */ targetPath()64 QString targetPath() const 65 { 66 return m_remotePath; 67 } 68 69 /** 70 * @param path The target path on the remote system. 71 */ setRemotePath(const QString & path)72 void setRemotePath(const QString& path) 73 { 74 m_remotePath = path; 75 } 76 77 void start(); 78 79 private slots: 80 void uploadInternal(); 81 void uploadNext(); 82 void uploadFile(const QFileInfo &fileInfo); 83 void finished(QNetworkReply *reply); 84 void createDirectoryComplete(); 85 86 private: 87 QString m_localPath; 88 QString m_remotePath; 89 QNetworkAccessManager *m_networkAccess; 90 QString m_url; 91 QQueue<QFileInfo> m_fileEntries; 92 93 void uploadFile(const QString &filePath); 94 95 96 }; 97 98 } /* namespace Uit */ 99 } /* namespace MoleQueue */ 100 #endif /* UITFILEUPLOADER_H_ */ 101