source: trunk/doc/html/qftp.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 42.1 KB
RevLine 
[190]1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/network/qftp.cpp:1063 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QFtp Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QFtp Class Reference<br><small>[<a href="network.html">network module</a>]</small></h1>
33
34<p>The QFtp class provides an implementation of the FTP protocol.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qftp-h.html">qftp.h</a>&gt;</tt>
37<p>Inherits <a href="qnetworkprotocol.html">QNetworkProtocol</a>.
38<p><a href="qftp-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn><a href="#QFtp"><b>QFtp</b></a> ()</li>
42<li class=fn><a href="#QFtp-2"><b>QFtp</b></a> ( QObject&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
43<li class=fn>virtual <a href="#~QFtp"><b>~QFtp</b></a> ()</li>
44<li class=fn>enum <a href="#State-enum"><b>State</b></a> { Unconnected, HostLookup, Connecting, Connected, LoggedIn, Closing }</li>
45<li class=fn>enum <a href="#Error-enum"><b>Error</b></a> { NoError, UnknownError, HostNotFound, ConnectionRefused, NotConnected }</li>
46<li class=fn>enum <a href="#Command-enum"><b>Command</b></a> { None, ConnectToHost, Login, Close, List, Cd, Get, Put, Remove, Mkdir, Rmdir, Rename, RawCommand }</li>
47<li class=fn>int <a href="#connectToHost"><b>connectToHost</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;host, Q_UINT16&nbsp;port = 21 )</li>
48<li class=fn>int <a href="#login"><b>login</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;user = QString::null, const&nbsp;QString&nbsp;&amp;&nbsp;password = QString::null )</li>
49<li class=fn>int <a href="#close"><b>close</b></a> ()</li>
50<li class=fn>int <a href="#list"><b>list</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;dir = QString::null )</li>
51<li class=fn>int <a href="#cd"><b>cd</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;dir )</li>
52<li class=fn>int <a href="#get"><b>get</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;file, QIODevice&nbsp;*&nbsp;dev = 0 )</li>
53<li class=fn>int <a href="#put-2"><b>put</b></a> ( const&nbsp;QByteArray&nbsp;&amp;&nbsp;data, const&nbsp;QString&nbsp;&amp;&nbsp;file )</li>
54<li class=fn>int <a href="#put"><b>put</b></a> ( QIODevice&nbsp;*&nbsp;dev, const&nbsp;QString&nbsp;&amp;&nbsp;file )</li>
55<li class=fn>int <a href="#remove"><b>remove</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;file )</li>
56<li class=fn>int <a href="#mkdir"><b>mkdir</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;dir )</li>
57<li class=fn>int <a href="#rmdir"><b>rmdir</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;dir )</li>
58<li class=fn>int <a href="#rename"><b>rename</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;oldname, const&nbsp;QString&nbsp;&amp;&nbsp;newname )</li>
59<li class=fn>int <a href="#rawCommand"><b>rawCommand</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;command )</li>
60<li class=fn>Q_ULONG <a href="#bytesAvailable"><b>bytesAvailable</b></a> () const</li>
61<li class=fn>Q_LONG <a href="#readBlock"><b>readBlock</b></a> ( char&nbsp;*&nbsp;data, Q_ULONG&nbsp;maxlen )</li>
62<li class=fn>QByteArray <a href="#readAll"><b>readAll</b></a> ()</li>
63<li class=fn>int <a href="#currentId"><b>currentId</b></a> () const</li>
64<li class=fn>QIODevice * <a href="#currentDevice"><b>currentDevice</b></a> () const</li>
65<li class=fn>Command <a href="#currentCommand"><b>currentCommand</b></a> () const</li>
66<li class=fn>bool <a href="#hasPendingCommands"><b>hasPendingCommands</b></a> () const</li>
67<li class=fn>void <a href="#clearPendingCommands"><b>clearPendingCommands</b></a> ()</li>
68<li class=fn>State <a href="#state"><b>state</b></a> () const</li>
69<li class=fn>Error <a href="#error"><b>error</b></a> () const</li>
70<li class=fn>QString <a href="#errorString"><b>errorString</b></a> () const</li>
71</ul>
72<h2>Public Slots</h2>
73<ul>
74<li class=fn>void <a href="#abort"><b>abort</b></a> ()</li>
75</ul>
76<h2>Signals</h2>
77<ul>
78<li class=fn>void <a href="#stateChanged"><b>stateChanged</b></a> ( int&nbsp;state )</li>
79<li class=fn>void <a href="#listInfo"><b>listInfo</b></a> ( const&nbsp;QUrlInfo&nbsp;&amp;&nbsp;i )</li>
80<li class=fn>void <a href="#readyRead"><b>readyRead</b></a> ()</li>
81<li class=fn>void <a href="#dataTransferProgress"><b>dataTransferProgress</b></a> ( int&nbsp;done, int&nbsp;total )</li>
82<li class=fn>void <a href="#rawCommandReply"><b>rawCommandReply</b></a> ( int&nbsp;replyCode, const&nbsp;QString&nbsp;&amp;&nbsp;detail )</li>
83<li class=fn>void <a href="#commandStarted"><b>commandStarted</b></a> ( int&nbsp;id )</li>
84<li class=fn>void <a href="#commandFinished"><b>commandFinished</b></a> ( int&nbsp;id, bool&nbsp;error )</li>
85<li class=fn>void <a href="#done"><b>done</b></a> ( bool&nbsp;error )</li>
86</ul>
87<hr><a name="details"></a><h2>Detailed Description</h2>
88
89
90The QFtp class provides an implementation of the FTP protocol.
91
92<p>
93
94<p> This class provides two different interfaces: one is the
95<a href="qnetworkprotocol.html">QNetworkProtocol</a> interface that allows you to use FTP through the
96<a href="qurloperator.html">QUrlOperator</a> abstraction. The other is a direct interface to FTP
97that gives you lower-level access to the FTP protocol for finer
98control. Using the direct interface you can also execute arbitrary
99FTP commands.
100<p> Don't mix the two interfaces, since the behavior is not
101well-defined.
102<p> If you want to use QFtp with the QNetworkProtocol interface, you
103do not use it directly, but rather through a QUrlOperator, for
104example:
105<p> <pre>
106 <a href="qurloperator.html">QUrlOperator</a> op( "ftp://ftp.trolltech.com" );
107 op.<a href="qurloperator.html#listChildren">listChildren</a>(); // Asks the server to provide a directory listing
108 </pre>
109
110<p> This code will only work if the QFtp class is registered; to
111register the class, you must call <a href="qurloperator.html#qInitNetworkProtocols">qInitNetworkProtocols</a>() before
112using a QUrlOperator with QFtp.
113<p> The rest of this descrption describes the direct interface to FTP.
114<p> The class works asynchronously, so there are no blocking
115functions. If an operation cannot be executed immediately, the
116function will still return straight away and the operation will be
117scheduled for later execution. The results of scheduled operations
118are reported via signals. This approach depends on the event loop
119being in operation.
120<p> The operations that can be scheduled (they are called "commands"
121in the rest of the documentation) are the following:
122<a href="#connectToHost">connectToHost</a>(), <a href="#login">login</a>(), <a href="#close">close</a>(), <a href="#list">list</a>(), <a href="#cd">cd</a>(), <a href="#get">get</a>(), <a href="#put">put</a>(),
123<a href="#remove">remove</a>(), <a href="#mkdir">mkdir</a>(), <a href="#rmdir">rmdir</a>(), <a href="#rename">rename</a>() and <a href="#rawCommand">rawCommand</a>().
124<p> All of these commands return a unique identifier that allows you
125to keep track of the command that is currently being executed.
126When the execution of a command starts, the <a href="#commandStarted">commandStarted</a>()
127signal with the command's identifier is emitted. When the command
128is finished, the <a href="#commandFinished">commandFinished</a>() signal is emitted with the
129command's identifier and a bool that indicates whether the command
130finished with an error.
131<p> In some cases, you might want to execute a sequence of commands,
132e.g. if you want to connect and login to a FTP server. This is
133simply achieved:
134<p> <pre>
135 QFtp *ftp = new QFtp( this ); // this is an optional QObject parent
136 ftp-&gt;<a href="#connectToHost">connectToHost</a>( "ftp.trolltech.com" );
137 ftp-&gt;<a href="#login">login</a>();
138 </pre>
139
140<p> In this case two FTP commands have been scheduled. When the last
141scheduled command has finished, a <a href="#done">done</a>() signal is emitted with
142a bool argument that tells you whether the sequence finished with
143an error.
144<p> If an error occurs during the execution of one of the commands in
145a sequence of commands, all the pending commands (i.e. scheduled,
146but not yet executed commands) are cleared and no signals are
147emitted for them.
148<p> Some commands, e.g. <a href="#list">list</a>(), emit additional signals to report
149their results.
150<p> Example: If you want to download the INSTALL file from Trolltech's
151FTP server, you would write this:
152<p> <pre>
153 ftp-&gt;connectToHost( "ftp.trolltech.com" ); // id == 1
154 ftp-&gt;login(); // id == 2
155 ftp-&gt;cd( "qt" ); // id == 3
156 ftp-&gt;get( "INSTALL" ); // id == 4
157 ftp-&gt;close(); // id == 5
158 </pre>
159
160<p> For this example the following sequence of signals is emitted
161(with small variations, depending on network traffic, etc.):
162<p> <pre>
163 <a href="qnetworkprotocol.html#start">start</a>( 1 )
164 <a href="#stateChanged">stateChanged</a>( <a href="#State-enum">HostLookup</a> )
165 <a href="#stateChanged">stateChanged</a>( <a href="#State-enum">Connecting</a> )
166 <a href="#stateChanged">stateChanged</a>( <a href="#State-enum">Connected</a> )
167 <a href="qnetworkprotocol.html#finished">finished</a>( 1, FALSE )
168
169 <a href="qnetworkprotocol.html#start">start</a>( 2 )
170 <a href="#stateChanged">stateChanged</a>( <a href="#State-enum">LoggedIn</a> )
171 <a href="qnetworkprotocol.html#finished">finished</a>( 2, FALSE )
172
173 <a href="qnetworkprotocol.html#start">start</a>( 3 )
174 <a href="qnetworkprotocol.html#finished">finished</a>( 3, FALSE )
175
176 <a href="qnetworkprotocol.html#start">start</a>( 4 )
177 <a href="#dataTransferProgress">dataTransferProgress</a>( 0, 3798 )
178 <a href="#dataTransferProgress">dataTransferProgress</a>( 2896, 3798 )
179 <a href="#readyRead">readyRead</a>()
180 <a href="#dataTransferProgress">dataTransferProgress</a>( 3798, 3798 )
181 <a href="#readyRead">readyRead</a>()
182 <a href="qnetworkprotocol.html#finished">finished</a>( 4, FALSE )
183
184 <a href="qnetworkprotocol.html#start">start</a>( 5 )
185 <a href="#stateChanged">stateChanged</a>( <a href="#State-enum">Closing</a> )
186 <a href="#stateChanged">stateChanged</a>( <a href="#State-enum">Unconnected</a> )
187 <a href="qnetworkprotocol.html#finished">finished</a>( 5, FALSE )
188
189 <a href="#done">done</a>( FALSE )
190 </pre>
191
192<p> The <a href="#dataTransferProgress">dataTransferProgress</a>() signal in the above example is useful
193if you want to show a <a href="qprogressbar.html">progressbar</a> to
194inform the user about the progress of the download. The
195<a href="#readyRead">readyRead</a>() signal tells you that there is data ready to be read.
196The amount of data can be queried then with the <a href="#bytesAvailable">bytesAvailable</a>()
197function and it can be read with the <a href="#readBlock">readBlock</a>() or <a href="#readAll">readAll</a>()
198function.
199<p> If the login fails for the above example, the signals would look
200like this:
201<p> <pre>
202 <a href="qnetworkprotocol.html#start">start</a>( 1 )
203 <a href="#stateChanged">stateChanged</a>( <a href="#State-enum">HostLookup</a> )
204 <a href="#stateChanged">stateChanged</a>( <a href="#State-enum">Connecting</a> )
205 <a href="#stateChanged">stateChanged</a>( <a href="#State-enum">Connected</a> )
206 <a href="qnetworkprotocol.html#finished">finished</a>( 1, FALSE )
207
208 <a href="qnetworkprotocol.html#start">start</a>( 2 )
209 <a href="qnetworkprotocol.html#finished">finished</a>( 2, TRUE )
210
211 <a href="#done">done</a>( TRUE )
212 </pre>
213
214<p> You can then get details about the error with the <a href="#error">error</a>() and
215<a href="#errorString">errorString</a>() functions.
216<p> The functions <a href="#currentId">currentId</a>() and <a href="#currentCommand">currentCommand</a>() provide more
217information about the currently executing command.
218<p> The functions <a href="#hasPendingCommands">hasPendingCommands</a>() and <a href="#clearPendingCommands">clearPendingCommands</a>()
219allow you to query and clear the list of pending commands.
220<p> The safest and easiest way to use the FTP protocol is to use
221<a href="qurloperator.html">QUrlOperator</a>() or the FTP commands described above. If you are an
222experienced network programmer and want to have complete control
223you can use <a href="#rawCommand">rawCommand</a>() to execute arbitrary FTP commands.
224<p> <p>See also <a href="network.html">Qt Network Documentation</a>, <a href="qnetworkprotocol.html">QNetworkProtocol</a>, <a href="qurloperator.html">QUrlOperator</a>, <a href="qhttp.html">QHttp</a>, and <a href="io.html">Input/Output and Networking</a>.
225
226<hr><h2>Member Type Documentation</h2>
227<h3 class=fn><a name="Command-enum"></a>QFtp::Command</h3>
228
229<p> This enum is used as the return value for the <a href="#currentCommand">currentCommand</a>() function.
230This allows you to perform specific actions for particular
231commands, e.g. in a FTP client, you might want to clear the
232directory view when a <a href="#list">list</a>() command is started; in this case you
233can simply check in the slot connected to the <a href="qnetworkprotocol.html#start">start</a>() signal if
234the currentCommand() is <a href="#Command-enum">List</a>.
235<ul>
236<li><tt>QFtp::None</tt> - No command is being executed.
237<li><tt>QFtp::ConnectToHost</tt> - <a href="#connectToHost">connectToHost</a>() is being executed.
238<li><tt>QFtp::Login</tt> - <a href="#login">login</a>() is being executed.
239<li><tt>QFtp::Close</tt> - <a href="#close">close</a>() is being executed.
240<li><tt>QFtp::List</tt> - list() is being executed.
241<li><tt>QFtp::Cd</tt> - <a href="#cd">cd</a>() is being executed.
242<li><tt>QFtp::Get</tt> - <a href="#get">get</a>() is being executed.
243<li><tt>QFtp::Put</tt> - <a href="#put">put</a>() is being executed.
244<li><tt>QFtp::Remove</tt> - <a href="#remove">remove</a>() is being executed.
245<li><tt>QFtp::Mkdir</tt> - <a href="#mkdir">mkdir</a>() is being executed.
246<li><tt>QFtp::Rmdir</tt> - <a href="#rmdir">rmdir</a>() is being executed.
247<li><tt>QFtp::Rename</tt> - <a href="#rename">rename</a>() is being executed.
248<li><tt>QFtp::RawCommand</tt> - <a href="#rawCommand">rawCommand</a>() is being executed.
249</ul><p> <p>See also <a href="#currentCommand">currentCommand</a>().
250
251<h3 class=fn><a name="Error-enum"></a>QFtp::Error</h3>
252
253<p> This enum identifies the error that occurred.
254<ul>
255<li><tt>QFtp::NoError</tt> - No error occurred.
256<li><tt>QFtp::HostNotFound</tt> - The host name lookup failed.
257<li><tt>QFtp::ConnectionRefused</tt> - The server refused the connection.
258<li><tt>QFtp::NotConnected</tt> - Tried to send a command, but there is no connection to
259a server.
260<li><tt>QFtp::UnknownError</tt> - An error other than those specified above
261occurred.
262</ul><p> <p>See also <a href="#error">error</a>().
263
264<h3 class=fn><a name="State-enum"></a>QFtp::State</h3>
265
266<p> This enum defines the connection state:
267<ul>
268<li><tt>QFtp::Unconnected</tt> - There is no connection to the host.
269<li><tt>QFtp::HostLookup</tt> - A host name lookup is in progress.
270<li><tt>QFtp::Connecting</tt> - An attempt to connect to the host is in progress.
271<li><tt>QFtp::Connected</tt> - Connection to the host has been achieved.
272<li><tt>QFtp::LoggedIn</tt> - Connection and user login have been achieved.
273<li><tt>QFtp::Closing</tt> - The connection is closing down, but it is not yet
274closed. (The state will be <a href="#State-enum">Unconnected</a> when the connection is
275closed.)
276</ul><p> <p>See also <a href="#stateChanged">stateChanged</a>() and <a href="#state">state</a>().
277
278<hr><h2>Member Function Documentation</h2>
279<h3 class=fn><a name="QFtp"></a>QFtp::QFtp ()
280</h3>
281Constructs a QFtp object.
282
283<h3 class=fn><a name="QFtp-2"></a>QFtp::QFtp ( <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )
284</h3>
285Constructs a QFtp object. The <em>parent</em> and <em>name</em> parameters
286are passed to the <a href="qobject.html">QObject</a> constructor.
287
288<h3 class=fn><a name="~QFtp"></a>QFtp::~QFtp ()<tt> [virtual]</tt>
289</h3>
290Destructor.
291
292<h3 class=fn>void <a name="abort"></a>QFtp::abort ()<tt> [slot]</tt>
293</h3>
294Aborts the current command and deletes all scheduled commands.
295<p> If there is an unfinished command (i.e. a command for which the
296<a href="#commandStarted">commandStarted</a>() signal has been emitted, but for which the
297<a href="#commandFinished">commandFinished</a>() signal has not been emitted), this function
298sends an <tt>ABORT</tt> command to the server. When the server replies
299that the command is aborted, the commandFinished() signal with the
300<tt>error</tt> argument set to <tt>TRUE</tt> is emitted for the command. Due
301to timing issues, it is possible that the command had already
302finished before the abort request reached the server, in which
303case, the commandFinished() signal is emitted with the <tt>error</tt>
304argument set to <tt>FALSE</tt>.
305<p> For all other commands that are affected by the <a href="#abort">abort</a>(), no
306signals are emitted.
307<p> If you don't start further FTP commands directly after the
308abort(), there won't be any scheduled commands and the <a href="#done">done</a>()
309signal is emitted.
310<p> <b>Warning:</b> Some FTP servers, for example the BSD FTP daemon (version
3110.3), wrongly return a positive reply even when an abort has
312occurred. For these servers the commandFinished() signal has its
313error flag set to <tt>FALSE</tt>, even though the command did not
314complete successfully.
315<p> <p>See also <a href="#clearPendingCommands">clearPendingCommands</a>().
316
317<p>Example: <a href="ftpclient-example.html#x744">network/ftpclient/ftpmainwindow.ui.h</a>.
318<h3 class=fn>Q_ULONG <a name="bytesAvailable"></a>QFtp::bytesAvailable () const
319</h3>
320Returns the number of bytes that can be read from the data socket
321at the moment.
322<p> <p>See also <a href="#get">get</a>(), <a href="#readyRead">readyRead</a>(), <a href="#readBlock">readBlock</a>(), and <a href="#readAll">readAll</a>().
323
324<h3 class=fn>int <a name="cd"></a>QFtp::cd ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;dir )
325</h3>
326Changes the working directory of the server to <em>dir</em>.
327<p> The function does not block and returns immediately. The command
328is scheduled, and its execution is performed asynchronously. The
329function returns a unique identifier which is passed by
330<a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
331<p> When the command is started the commandStarted() signal is
332emitted. When it is finished the commandFinished() signal is
333emitted.
334<p> <p>See also <a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
335
336<p>Example: <a href="ftpclient-example.html#x745">network/ftpclient/ftpmainwindow.ui.h</a>.
337<h3 class=fn>void <a name="clearPendingCommands"></a>QFtp::clearPendingCommands ()
338</h3>
339Deletes all pending commands from the list of scheduled commands.
340This does not affect the command that is being executed. If you
341want to stop this this as well, use <a href="#abort">abort</a>().
342<p> <p>See also <a href="#hasPendingCommands">hasPendingCommands</a>() and <a href="#abort">abort</a>().
343
344<h3 class=fn>int <a name="close"></a>QFtp::close ()
345</h3>
346Closes the connection to the FTP server.
347<p> The <a href="#stateChanged">stateChanged</a>() signal is emitted when the state of the
348connecting process changes, e.g. to <a href="#State-enum">Closing</a>, then <a href="#State-enum">Unconnected</a>.
349<p> The function does not block and returns immediately. The command
350is scheduled, and its execution is performed asynchronously. The
351function returns a unique identifier which is passed by
352<a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
353<p> When the command is started the commandStarted() signal is
354emitted. When it is finished the commandFinished() signal is
355emitted.
356<p> <p>See also <a href="#stateChanged">stateChanged</a>(), <a href="#commandStarted">commandStarted</a>(), and <a href="#commandFinished">commandFinished</a>().
357
358<p>Example: <a href="ftpclient-example.html#x746">network/ftpclient/ftpmainwindow.ui.h</a>.
359<h3 class=fn>void <a name="commandFinished"></a>QFtp::commandFinished ( int&nbsp;id, bool&nbsp;error )<tt> [signal]</tt>
360</h3>
361
362<p> This signal is emitted when processing the command identified by
363<em>id</em> has finished. <em>error</em> is TRUE if an error occurred during
364the processing; otherwise <em>error</em> is FALSE.
365<p> <p>See also <a href="#commandStarted">commandStarted</a>(), <a href="#done">done</a>(), <a href="#error">error</a>(), and <a href="#errorString">errorString</a>().
366
367<p>Example: <a href="ftpclient-example.html#x747">network/ftpclient/ftpmainwindow.ui.h</a>.
368<h3 class=fn>void <a name="commandStarted"></a>QFtp::commandStarted ( int&nbsp;id )<tt> [signal]</tt>
369</h3>
370
371<p> This signal is emitted when processing the command identified by
372<em>id</em> starts.
373<p> <p>See also <a href="#commandFinished">commandFinished</a>() and <a href="#done">done</a>().
374
375<p>Example: <a href="ftpclient-example.html#x748">network/ftpclient/ftpmainwindow.ui.h</a>.
376<h3 class=fn>int <a name="connectToHost"></a>QFtp::connectToHost ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;host, Q_UINT16&nbsp;port = 21 )
377</h3>
378Connects to the FTP server <em>host</em> using port <em>port</em>.
379<p> The <a href="#stateChanged">stateChanged</a>() signal is emitted when the state of the
380connecting process changes, e.g. to <a href="#State-enum">HostLookup</a>, then <a href="#State-enum">Connecting</a>, then <a href="#State-enum">Connected</a>.
381<p> The function does not block and returns immediately. The command
382is scheduled, and its execution is performed asynchronously. The
383function returns a unique identifier which is passed by
384<a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
385<p> When the command is started the commandStarted() signal is
386emitted. When it is finished the commandFinished() signal is
387emitted.
388<p> <p>See also <a href="#stateChanged">stateChanged</a>(), <a href="#commandStarted">commandStarted</a>(), and <a href="#commandFinished">commandFinished</a>().
389
390<p>Example: <a href="ftpclient-example.html#x749">network/ftpclient/ftpmainwindow.ui.h</a>.
391<h3 class=fn><a href="qftp.html#Command-enum">Command</a> <a name="currentCommand"></a>QFtp::currentCommand () const
392</h3>
393Returns the command type of the FTP command being executed or <a href="#Command-enum">None</a> if there is no command being executed.
394<p> <p>See also <a href="#currentId">currentId</a>().
395
396<p>Example: <a href="ftpclient-example.html#x750">network/ftpclient/ftpmainwindow.ui.h</a>.
397<h3 class=fn><a href="qiodevice.html">QIODevice</a>&nbsp;* <a name="currentDevice"></a>QFtp::currentDevice () const
398</h3>
399Returns the <a href="qiodevice.html">QIODevice</a> pointer that is used by the FTP command to read data
400from or store data to. If there is no current FTP command being executed or
401if the command does not use an IO device, this function returns 0.
402<p> This function can be used to delete the QIODevice in the slot connected to
403the <a href="#commandFinished">commandFinished</a>() signal.
404<p> <p>See also <a href="#get">get</a>() and <a href="#put">put</a>().
405
406<p>Example: <a href="ftpclient-example.html#x751">network/ftpclient/ftpmainwindow.ui.h</a>.
407<h3 class=fn>int <a name="currentId"></a>QFtp::currentId () const
408</h3>
409Returns the identifier of the FTP command that is being executed
410or 0 if there is no command being executed.
411<p> <p>See also <a href="#currentCommand">currentCommand</a>().
412
413<h3 class=fn>void <a name="dataTransferProgress"></a>QFtp::dataTransferProgress ( int&nbsp;done, int&nbsp;total )<tt> [signal]</tt>
414</h3>
415
416<p> This signal is emitted in response to a <a href="#get">get</a>() or <a href="#put">put</a>() request to
417indicate the current progress of the download or upload.
418<p> <em>done</em> is the amount of data that has already been transferred
419and <em>total</em> is the total amount of data to be read or written. It
420is possible that the QFtp class is not able to determine the total
421amount of data that should be transferred, in which case <em>total</em>
422is 0. (If you connect this signal to a <a href="qprogressbar.html">QProgressBar</a>, the progress
423bar shows a busy indicator if the total is 0).
424<p> <b>Warning:</b> <em>done</em> and <em>total</em> are not necessarily the size in
425bytes, since for large files these values might need to be
426"scaled" to avoid overflow.
427<p> <p>See also <a href="#get">get</a>(), <a href="#put">put</a>(), and <a href="qprogressbar.html#progress-prop">QProgressBar::progress</a>.
428
429<p>Example: <a href="ftpclient-example.html#x752">network/ftpclient/ftpmainwindow.ui.h</a>.
430<h3 class=fn>void <a name="done"></a>QFtp::done ( bool&nbsp;error )<tt> [signal]</tt>
431</h3>
432
433<p> This signal is emitted when the last pending command has finished;
434(it is emitted after the last command's <a href="#commandFinished">commandFinished</a>() signal).
435<em>error</em> is TRUE if an error occurred during the processing;
436otherwise <em>error</em> is FALSE.
437<p> <p>See also <a href="#commandFinished">commandFinished</a>(), <a href="#error">error</a>(), and <a href="#errorString">errorString</a>().
438
439<p>Example: <a href="ftpclient-example.html#x753">network/ftpclient/ftpmainwindow.ui.h</a>.
440<h3 class=fn><a href="qftp.html#Error-enum">Error</a> <a name="error"></a>QFtp::error () const
441</h3>
442Returns the last error that occurred. This is useful to find out
443what when wrong when receiving a <a href="#commandFinished">commandFinished</a>() or a <a href="#done">done</a>()
444signal with the <tt>error</tt> argument set to <tt>TRUE</tt>.
445<p> If you start a new command, the error status is reset to <a href="#Error-enum">NoError</a>.
446
447<h3 class=fn><a href="qstring.html">QString</a> <a name="errorString"></a>QFtp::errorString () const
448</h3>
449Returns a human-readable description of the last error that
450occurred. This is useful for presenting a error message to the
451user when receiving a <a href="#commandFinished">commandFinished</a>() or a <a href="#done">done</a>() signal with
452the <tt>error</tt> argument set to <tt>TRUE</tt>.
453<p> The error string is often (but not always) the reply from the
454server, so it is not always possible to translate the string. If
455the message comes from Qt, the string has already passed through
456<a href="qobject.html#tr">tr</a>().
457
458<p>Example: <a href="ftpclient-example.html#x754">network/ftpclient/ftpmainwindow.ui.h</a>.
459<h3 class=fn>int <a name="get"></a>QFtp::get ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;file, <a href="qiodevice.html">QIODevice</a>&nbsp;*&nbsp;dev = 0 )
460</h3>
461Downloads the file <em>file</em> from the server.
462<p> If <em>dev</em> is 0, then the <a href="#readyRead">readyRead</a>() signal is emitted when there
463is data available to read. You can then read the data with the
464<a href="#readBlock">readBlock</a>() or <a href="#readAll">readAll</a>() functions.
465<p> If <em>dev</em> is not 0, the data is written directly to the device <em>dev</em>. Make sure that the <em>dev</em> pointer is valid for the duration
466of the operation (it is safe to delete it when the
467<a href="#commandFinished">commandFinished</a>() signal is emitted). In this case the readyRead()
468signal is <em>not</em> emitted and you cannot read data with the
469readBlock() or readAll() functions.
470<p> If you don't read the data immediately it becomes available, i.e.
471when the readyRead() signal is emitted, it is still available
472until the next command is started.
473<p> For example, if you want to present the data to the user as soon
474as there is something available, connect to the readyRead() signal
475and read the data immediately. On the other hand, if you only want
476to work with the complete data, you can connect to the
477commandFinished() signal and read the data when the <a href="#get">get</a>() command
478is finished.
479<p> The function does not block and returns immediately. The command
480is scheduled, and its execution is performed asynchronously. The
481function returns a unique identifier which is passed by
482<a href="#commandStarted">commandStarted</a>() and commandFinished().
483<p> When the command is started the commandStarted() signal is
484emitted. When it is finished the <a href="#commandFinished">commandFinished</a>() signal is
485emitted.
486<p> <p>See also <a href="#readyRead">readyRead</a>(), <a href="#dataTransferProgress">dataTransferProgress</a>(), <a href="#commandStarted">commandStarted</a>(), and <a href="#commandFinished">commandFinished</a>().
487
488<p>Example: <a href="ftpclient-example.html#x755">network/ftpclient/ftpmainwindow.ui.h</a>.
489<h3 class=fn>bool <a name="hasPendingCommands"></a>QFtp::hasPendingCommands () const
490</h3>
491Returns TRUE if there are any commands scheduled that have not yet
492been executed; otherwise returns FALSE.
493<p> The command that is being executed is <em>not</em> considered as a
494scheduled command.
495<p> <p>See also <a href="#clearPendingCommands">clearPendingCommands</a>(), <a href="#currentId">currentId</a>(), and <a href="#currentCommand">currentCommand</a>().
496
497<h3 class=fn>int <a name="list"></a>QFtp::list ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;dir = QString::null )
498</h3>
499Lists the contents of directory <em>dir</em> on the FTP server. If <em>dir</em> is empty, it lists the contents of the current directory.
500<p> The <a href="#listInfo">listInfo</a>() signal is emitted for each directory entry found.
501<p> The function does not block and returns immediately. The command
502is scheduled, and its execution is performed asynchronously. The
503function returns a unique identifier which is passed by
504<a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
505<p> When the command is started the commandStarted() signal is
506emitted. When it is finished the commandFinished() signal is
507emitted.
508<p> <p>See also <a href="#listInfo">listInfo</a>(), <a href="#commandStarted">commandStarted</a>(), and <a href="#commandFinished">commandFinished</a>().
509
510<p>Example: <a href="ftpclient-example.html#x756">network/ftpclient/ftpmainwindow.ui.h</a>.
511<h3 class=fn>void <a name="listInfo"></a>QFtp::listInfo ( const&nbsp;<a href="qurlinfo.html">QUrlInfo</a>&nbsp;&amp;&nbsp;i )<tt> [signal]</tt>
512</h3>
513
514<p> This signal is emitted for each directory entry the <a href="#list">list</a>() command
515finds. The details of the entry are stored in <em>i</em>.
516<p> <p>See also <a href="#list">list</a>().
517
518<p>Example: <a href="ftpclient-example.html#x757">network/ftpclient/ftpmainwindow.ui.h</a>.
519<h3 class=fn>int <a name="login"></a>QFtp::login ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;user = QString::null, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;password = QString::null )
520</h3>
521Logs in to the FTP server with the username <em>user</em> and the
522password <em>password</em>.
523<p> The <a href="#stateChanged">stateChanged</a>() signal is emitted when the state of the
524connecting process changes, e.g. to <a href="#State-enum">LoggedIn</a>.
525<p> The function does not block and returns immediately. The command
526is scheduled, and its execution is performed asynchronously. The
527function returns a unique identifier which is passed by
528<a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
529<p> When the command is started the commandStarted() signal is
530emitted. When it is finished the commandFinished() signal is
531emitted.
532<p> <p>See also <a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
533
534<p>Example: <a href="ftpclient-example.html#x758">network/ftpclient/ftpmainwindow.ui.h</a>.
535<h3 class=fn>int <a name="mkdir"></a>QFtp::mkdir ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;dir )
536</h3>
537Creates a directory called <em>dir</em> on the server.
538<p> The function does not block and returns immediately. The command
539is scheduled, and its execution is performed asynchronously. The
540function returns a unique identifier which is passed by
541<a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
542<p> When the command is started the commandStarted() signal is
543emitted. When it is finished the commandFinished() signal is
544emitted.
545<p> <p>See also <a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
546
547<h3 class=fn>int <a name="put"></a>QFtp::put ( <a href="qiodevice.html">QIODevice</a>&nbsp;*&nbsp;dev, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;file )
548</h3>
549Reads the data from the IO device <em>dev</em>, and writes it to the
550file called <em>file</em> on the server. The data is read in chunks from
551the IO device, so this overload allows you to transmit large
552amounts of data without the need to read all the data into memory
553at once.
554<p> Make sure that the <em>dev</em> pointer is valid for the duration of the
555operation (it is safe to delete it when the <a href="#commandFinished">commandFinished</a>() is
556emitted).
557
558<p>Example: <a href="ftpclient-example.html#x759">network/ftpclient/ftpmainwindow.ui.h</a>.
559<h3 class=fn>int <a name="put-2"></a>QFtp::put ( const&nbsp;<a href="qbytearray.html">QByteArray</a>&nbsp;&amp;&nbsp;data, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;file )
560</h3>
561This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
562<p> Writes the data <em>data</em> to the file called <em>file</em> on the server.
563The progress of the upload is reported by the
564<a href="#dataTransferProgress">dataTransferProgress</a>() signal.
565<p> The function does not block and returns immediately. The command
566is scheduled, and its execution is performed asynchronously. The
567function returns a unique identifier which is passed by
568<a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
569<p> When the command is started the commandStarted() signal is
570emitted. When it is finished the commandFinished() signal is
571emitted.
572<p> <p>See also <a href="#dataTransferProgress">dataTransferProgress</a>(), <a href="#commandStarted">commandStarted</a>(), and <a href="#commandFinished">commandFinished</a>().
573
574<h3 class=fn>int <a name="rawCommand"></a>QFtp::rawCommand ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;command )
575</h3>
576Sends the raw FTP command <em>command</em> to the FTP server. This is
577useful for low-level FTP access. If the operation you wish to
578perform has an equivalent QFtp function, we recommend using the
579function instead of raw FTP commands since the functions are
580easier and safer.
581<p> The function does not block and returns immediately. The command
582is scheduled, and its execution is performed asynchronously. The
583function returns a unique identifier which is passed by
584<a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
585<p> When the command is started the commandStarted() signal is
586emitted. When it is finished the commandFinished() signal is
587emitted.
588<p> <p>See also <a href="#rawCommandReply">rawCommandReply</a>(), <a href="#commandStarted">commandStarted</a>(), and <a href="#commandFinished">commandFinished</a>().
589
590<p>Example: <a href="ftpclient-example.html#x760">network/ftpclient/ftpmainwindow.ui.h</a>.
591<h3 class=fn>void <a name="rawCommandReply"></a>QFtp::rawCommandReply ( int&nbsp;replyCode, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;detail )<tt> [signal]</tt>
592</h3>
593
594<p> This signal is emitted in response to the <a href="#rawCommand">rawCommand</a>() function.
595<em>replyCode</em> is the 3 digit reply code and <em>detail</em> is the text
596that follows the reply code.
597<p> <p>See also <a href="#rawCommand">rawCommand</a>().
598
599<p>Example: <a href="ftpclient-example.html#x761">network/ftpclient/ftpmainwindow.ui.h</a>.
600<h3 class=fn><a href="qbytearray.html">QByteArray</a> <a name="readAll"></a>QFtp::readAll ()
601</h3>
602Reads all the bytes available from the data socket and returns
603them.
604<p> <p>See also <a href="#get">get</a>(), <a href="#readyRead">readyRead</a>(), <a href="#bytesAvailable">bytesAvailable</a>(), and <a href="#readBlock">readBlock</a>().
605
606<h3 class=fn>Q_LONG <a name="readBlock"></a>QFtp::readBlock ( char&nbsp;*&nbsp;data, Q_ULONG&nbsp;maxlen )
607</h3>
608Reads <em>maxlen</em> bytes from the data socket into <em>data</em> and
609returns the number of bytes read. Returns -1 if an error occurred.
610<p> <p>See also <a href="#get">get</a>(), <a href="#readyRead">readyRead</a>(), <a href="#bytesAvailable">bytesAvailable</a>(), and <a href="#readAll">readAll</a>().
611
612<h3 class=fn>void <a name="readyRead"></a>QFtp::readyRead ()<tt> [signal]</tt>
613</h3>
614
615<p> This signal is emitted in response to a <a href="#get">get</a>() command when there
616is new data to read.
617<p> If you specify a device as the second argument in the get()
618command, this signal is <em>not</em> emitted; instead the data is
619written directly to the device.
620<p> You can read the data with the <a href="#readAll">readAll</a>() or <a href="#readBlock">readBlock</a>() functions.
621<p> This signal is useful if you want to process the data in chunks as
622soon as it becomes available. If you are only interested in the
623complete data, just connect to the <a href="#commandFinished">commandFinished</a>() signal and
624read the data then instead.
625<p> <p>See also <a href="#get">get</a>(), <a href="#readBlock">readBlock</a>(), <a href="#readAll">readAll</a>(), and <a href="#bytesAvailable">bytesAvailable</a>().
626
627<h3 class=fn>int <a name="remove"></a>QFtp::remove ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;file )
628</h3>
629Deletes the file called <em>file</em> from the server.
630<p> The function does not block and returns immediately. The command
631is scheduled, and its execution is performed asynchronously. The
632function returns a unique identifier which is passed by
633<a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
634<p> When the command is started the commandStarted() signal is
635emitted. When it is finished the commandFinished() signal is
636emitted.
637<p> <p>See also <a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
638
639<p>Example: <a href="ftpclient-example.html#x762">network/ftpclient/ftpmainwindow.ui.h</a>.
640<h3 class=fn>int <a name="rename"></a>QFtp::rename ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;oldname, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;newname )
641</h3>
642Renames the file called <em>oldname</em> to <em>newname</em> on the server.
643<p> The function does not block and returns immediately. The command
644is scheduled, and its execution is performed asynchronously. The
645function returns a unique identifier which is passed by
646<a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
647<p> When the command is started the commandStarted() signal is
648emitted. When it is finished the commandFinished() signal is
649emitted.
650<p> <p>See also <a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
651
652<h3 class=fn>int <a name="rmdir"></a>QFtp::rmdir ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;dir )
653</h3>
654Removes the directory called <em>dir</em> from the server.
655<p> The function does not block and returns immediately. The command
656is scheduled, and its execution is performed asynchronously. The
657function returns a unique identifier which is passed by
658<a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
659<p> When the command is started the commandStarted() signal is
660emitted. When it is finished the commandFinished() signal is
661emitted.
662<p> <p>See also <a href="#commandStarted">commandStarted</a>() and <a href="#commandFinished">commandFinished</a>().
663
664<h3 class=fn><a href="qftp.html#State-enum">State</a> <a name="state"></a>QFtp::state () const
665</h3>
666Returns the current state of the object. When the state changes,
667the <a href="#stateChanged">stateChanged</a>() signal is emitted.
668<p> <p>See also <a href="#State-enum">State</a> and <a href="#stateChanged">stateChanged</a>().
669
670<p>Example: <a href="ftpclient-example.html#x763">network/ftpclient/ftpmainwindow.ui.h</a>.
671<h3 class=fn>void <a name="stateChanged"></a>QFtp::stateChanged ( int&nbsp;state )<tt> [signal]</tt>
672</h3>
673
674<p> This signal is emitted when the state of the connection changes.
675The argument <em>state</em> is the new state of the connection; it is
676one of the <a href="#State-enum">State</a> values.
677<p> It is usually emitted in response to a <a href="#connectToHost">connectToHost</a>() or <a href="#close">close</a>()
678command, but it can also be emitted "spontaneously", e.g. when the
679server closes the connection unexpectedly.
680<p> <p>See also <a href="#connectToHost">connectToHost</a>(), <a href="#close">close</a>(), <a href="#state">state</a>(), and <a href="#State-enum">State</a>.
681
682<p>Example: <a href="ftpclient-example.html#x764">network/ftpclient/ftpmainwindow.ui.h</a>.
683<!-- eof -->
684<hr><p>
685This file is part of the <a href="index.html">Qt toolkit</a>.
686Copyright &copy; 1995-2007
687<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
688<table width=100% cellspacing=0 border=0><tr>
689<td>Copyright &copy; 2007
690<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
691<td align=right><div align=right>Qt 3.3.8</div>
692</table></div></address></body>
693</html>
Note: See TracBrowser for help on using the repository browser.