KIO

slaveinterface.h
1 /* This file is part of the KDE project
2  Copyright (C) 2000 David Faure <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef __kio_slaveinterface_h
21 #define __kio_slaveinterface_h
22 
23 #include <qplatformdefs.h>
24 
25 #include <QObject>
26 #include <QHostInfo>
27 
28 #include <kio/global.h>
29 #include <kio/udsentry.h>
30 #include <kio/authinfo.h>
31 
32 class QUrl;
33 
34 namespace KIO
35 {
36 
37 class Connection;
38 // better there is one ...
39 class SlaveInterfacePrivate;
40 
41 // Definition of enum Command has been moved to global.h
42 
46 enum Info {
47  INF_TOTAL_SIZE = 10,
48  INF_PROCESSED_SIZE = 11,
49  INF_SPEED,
50  INF_REDIRECTION = 20,
51  INF_MIME_TYPE = 21,
52  INF_ERROR_PAGE = 22,
53  INF_WARNING = 23,
54 #if KIOCORE_ENABLE_DEPRECATED_SINCE(3, 0)
56 #else
57  INF_GETTING_FILE_DEPRECATED_DO_NOT_USE,
58 #endif
59  INF_UNUSED = 25,
60  INF_INFOMESSAGE,
61  INF_META_DATA,
62  INF_NETWORK_STATUS,
63  INF_MESSAGEBOX,
64  INF_POSITION,
65  INF_TRUNCATED
66  // add new ones here once a release is done, to avoid breaking binary compatibility
67 };
68 
72 enum Message {
73  MSG_DATA = 100,
74  MSG_DATA_REQ,
75  MSG_ERROR,
76  MSG_CONNECTED,
77  MSG_FINISHED,
78  MSG_STAT_ENTRY, // 105
79  MSG_LIST_ENTRIES,
81  MSG_RESUME,
82 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 45)
84 #else
85  MSG_SLAVE_STATUS_DEPRECATED_DO_NOT_USE,
86 #endif
87  MSG_SLAVE_ACK, // 110
88  MSG_NET_REQUEST,
89  MSG_NET_DROP,
90  MSG_NEED_SUBURL_DATA,
91  MSG_CANRESUME,
92 #if KIOCORE_ENABLE_DEPRECATED_SINCE(3, 1)
95 #else
96  MSG_AUTH_KEY_DEPRECATED_DO_NOT_USE,
97  MSG_DEL_AUTH_KEY_DEPRECATED_DO_NOT_USE,
98 #endif
99  MSG_OPENED,
100  MSG_WRITTEN,
101  MSG_HOST_INFO_REQ,
102  MSG_PRIVILEGE_EXEC,
103  MSG_SLAVE_STATUS_V2
104  // add new ones here once a release is done, to avoid breaking binary compatibility
105 };
106 
116 class KIOCORE_EXPORT SlaveInterface : public QObject
117 {
118  Q_OBJECT
119 
120 protected:
121  SlaveInterface(SlaveInterfacePrivate &dd, QObject *parent = nullptr);
122 public:
123 
124  virtual ~SlaveInterface();
125 
126 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
127  // TODO KF6: remove these methods, Connection isn't an exported class
128  KIOCORE_DEPRECATED_VERSION(5, 0, "Do not use")
129  void setConnection(Connection *connection);
130  KIOCORE_DEPRECATED_VERSION(5, 0, "Do not use")
131  Connection *connection() const;
132 #endif
133 
134  // Send our answer to the MSG_RESUME (canResume) request
135  // (to tell the "put" job whether to resume or not)
136  void sendResumeAnswer(bool resume);
137 
143  void sendMessageBoxAnswer(int result);
144 
145  void setOffset(KIO::filesize_t offset);
146  KIO::filesize_t offset() const;
147 
148 Q_SIGNALS:
150  // Messages sent by the slave
152 
153  void data(const QByteArray &);
154  void dataReq();
155  void error(int, const QString &);
156  void connected();
157  void finished();
158  void slaveStatus(qint64, const QByteArray &, const QString &, bool);
159  void listEntries(const KIO::UDSEntryList &);
160  void statEntry(const KIO::UDSEntry &);
161  void needSubUrlData();
162 
163  void canResume(KIO::filesize_t);
164 
165  void open();
166  void written(KIO::filesize_t);
167  void close();
168 
169  void privilegeOperationRequested();
170 
172  // Info sent by the slave
174  void metaData(const KIO::MetaData &);
175  void totalSize(KIO::filesize_t);
176  void processedSize(KIO::filesize_t);
177  void redirection(const QUrl &);
178  void position(KIO::filesize_t);
179  void truncated(KIO::filesize_t);
180 
181  void speed(unsigned long);
182  void errorPage();
183  void mimeType(const QString &);
184  void warning(const QString &);
185  void infoMessage(const QString &);
186  //void connectFinished(); //it does not get emitted anywhere
187 
188 protected:
190  // Dispatching
192 
193  virtual bool dispatch();
194  virtual bool dispatch(int _cmd, const QByteArray &data);
195 
196  void messageBox(int type, const QString &text, const QString &caption,
197  const QString &buttonYes, const QString &buttonNo);
198 
199  void messageBox(int type, const QString &text, const QString &caption,
200  const QString &buttonYes, const QString &buttonNo,
201  const QString &dontAskAgainName);
202 
203  // I need to identify the slaves
204  void requestNetwork(const QString &, const QString &);
205  void dropNetwork(const QString &, const QString &);
206 
207 protected Q_SLOTS:
208  void calcSpeed();
209 protected:
210  SlaveInterfacePrivate *const d_ptr;
211  Q_DECLARE_PRIVATE(SlaveInterface)
212 private:
213  Q_PRIVATE_SLOT(d_func(), void slotHostInfo(QHostInfo))
214 };
215 
216 }
217 
218 #endif
qulonglong filesize_t
64-bit file size
Definition: global.h:51
Universal Directory Service.
Definition: udsentry.h:88
A namespace for KIO globals.
Definition: authinfo.h:34
There are two classes that specifies the protocol between application ( KIO::Job) and kioslave...
MetaData is a simple map of key/value strings.
Definition: metadata.h:34
Info
Identifiers for KIO informational messages.
Message
Identifiers for KIO data messages.
now unused
KIOCORE_EXPORT FileJob * open(const QUrl &url, QIODevice::OpenMode mode)
Open ( random access I/O )
Definition: filejob.cpp:242
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Jul 11 2020 23:00:28 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.