3 * This file is part of the KDE libraries
4 * Copyright (c) 2000 Waldo Bastian <bastian@kde.org>
5 * 2000 Stephan Kulow <coolo@kde.org>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License version 2 as published by the Free Software Foundation.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
25 #define KIO_SLAVE_EXPORT KIO_EXPORT
30 #include <QtCore/QObject>
34 #include "kio/slaveinterface.h"
39 // Attention developers: If you change the implementation of KIO::Slave,
40 // do *not* use connection() or slaveconn but the respective KIO::Slave
41 // accessor methods. Otherwise classes derived from Slave might break. (LS)
43 // Do not use this class directly, outside of KIO. Only use the Slave pointer
44 // that is returned by the scheduler for passing it around.
46 // TODO: KDE5: Separate public API and private stuff for this better
47 class KIO_SLAVE_EXPORT Slave
: public KIO::SlaveInterface
51 explicit Slave(const QString
&protocol
, QObject
*parent
= 0);
65 * @return true if the slave survived the last mission.
71 * @param host to connect to.
72 * @param port to connect to.
73 * @param user to login as
74 * @param passwd to login with
76 virtual void setHost( const QString
&host
, quint16 port
,
77 const QString
&user
, const QString
&passwd
);
87 virtual void setConfig(const MetaData
&config
);
90 * The protocol this slave handles.
92 * @return name of protocol handled by this slave, as seen by the user
96 void setProtocol(const QString
& protocol
);
98 * The actual protocol used to handle the request.
100 * This method will return a different protocol than
101 * the one obtained by using protocol() if a
102 * proxy-server is used for the given protocol. This
103 * usually means that this method will return "http"
104 * when the actuall request was to retrieve a resource
105 * from an "ftp" server by going through a proxy server.
107 * @return the actual protocol (io-slave) that handled the request
109 QString
slaveProtocol();
112 * @return Host this slave is (was?) connected to
117 * @return port this slave is (was?) connected to
122 * @return User this slave is (was?) logged in as
127 * @return Passwd used to log in
132 * Creates a new slave.
134 * @param protocol the protocol
135 * @param url is the url
136 * @param error is the error code on failure and undefined else.
137 * @param error_text is the error text on failure and undefined else.
139 * @return 0 on failure, or a pointer to a slave otherwise.
141 static Slave
* createSlave( const QString
&protocol
, const KUrl
& url
, int& error
, QString
& error_text
);
144 * Requests a slave on hold for ths url, from klauncher, if there is such a job.
147 static Slave
* holdSlave( const QString
&protocol
, const KUrl
& url
);
149 // == communication with connected kioslave ==
150 // whenever possible prefer these methods over the respective
151 // methods in connection()
153 * Suspends the operation of the attached kioslave.
155 virtual void suspend();
157 * Resumes the operation of the attached kioslave.
159 virtual void resume();
161 * Tells whether the kioslave is suspended.
162 * @return true if the kioslave is suspended.
164 virtual bool suspended();
166 * Sends the given command to the kioslave.
167 * @param cmd command id
168 * @param arr byte array containing data
170 virtual void send(int cmd
, const QByteArray
&arr
= QByteArray());
172 // == end communication with connected kioslave ==
174 * Puts the kioslave associated with @p url at halt, and return it to klauncher, in order
175 * to let another application connect to it and finish the job.
176 * This is for the krunner case: type a URL in krunner, it will start downloading
177 * to find the mimetype (KRun), and then hold the slave, publish the held slave using,
178 * this method, and the final application can continue the same download by requesting
181 virtual void hold(const KUrl
&url
); // TODO KDE5: no reason to be virtual
184 * @return The time this slave has been idle.
189 * Marks this slave as idle.
194 * @returns Whether the slave is connected
195 * (Connection oriented slaves only)
198 void setConnected(bool c
);
208 void slaveDied(KIO::Slave
*slave
);
211 Q_DECLARE_PRIVATE(Slave
)
215 #undef KIO_SLAVE_EXPORT