OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / libs / utils / ssh / sftpchannel.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef SFTCHANNEL_H
34 #define SFTCHANNEL_H
35
36 #include "sftpdefs.h"
37 #include "sftpincomingpacket_p.h"
38
39 #include <utils/utils_global.h>
40
41 #include <QtCore/QByteArray>
42 #include <QtCore/QObject>
43 #include <QtCore/QSharedPointer>
44 #include <QtCore/QString>
45
46 namespace Utils {
47
48 namespace Internal {
49 class SftpChannelPrivate;
50 class SshChannelManager;
51 class SshSendFacility;
52 } // namespace Internal
53
54 class QTCREATOR_UTILS_EXPORT SftpChannel : public QObject
55 {
56     Q_OBJECT
57
58     friend class Internal::SftpChannelPrivate;
59     friend class Internal::SshChannelManager;
60 public:
61     typedef QSharedPointer<SftpChannel> Ptr;
62
63     enum State { Uninitialized, Initializing, Initialized, Closing, Closed };
64     State state() const;
65
66     void initialize();
67     void closeChannel();
68
69     SftpJobId listDirectory(const QString &dirPath);
70     SftpJobId createDirectory(const QString &dirPath);
71     SftpJobId removeDirectory(const QString &dirPath);
72     SftpJobId removeFile(const QString &filePath);
73     SftpJobId renameFileOrDirectory(const QString &oldPath,
74         const QString &newPath);
75     SftpJobId createFile(const QString &filePath, SftpOverwriteMode mode);
76     SftpJobId uploadFile(const QString &localFilePath,
77         const QString &remoteFilePath, SftpOverwriteMode mode);
78     SftpJobId downloadFile(const QString &remoteFilePath,
79         const QString &localFilePath, SftpOverwriteMode mode);
80     SftpJobId uploadDir(const QString &localDirPath,
81         const QString &remoteParentDirPath);
82
83     ~SftpChannel();
84
85 signals:
86     void initialized();
87     void initializationFailed(const QString &reason);
88     void closed();
89
90     // error.isEmpty <=> finished successfully
91     void finished(Utils::SftpJobId job, const QString &error = QString());
92
93     /*
94      * This signal is only emitted by the "List Directory" operation,
95      * one file at a time.
96      // TODO: Also emit for each file copied by uploadDir().
97      */
98     void dataAvailable(Utils::SftpJobId job, const QString &data);
99
100 private:
101     SftpChannel(quint32 channelId, Internal::SshSendFacility &sendFacility);
102
103     Internal::SftpChannelPrivate *d;
104 };
105
106 } // namespace Utils
107
108 #endif // SFTPCHANNEL_H