Eneboo - Documentación para desarrolladores
Tipos públicos | Slots públicos | Señales | Métodos públicos | Slots protegidos | Métodos protegidos | Atributos protegidos
Referencia de la Clase QFtp

The QFtp class provides an implementation of the FTP protocol.network. Más...

#include <qftp.h>

Diagrama de herencias de QFtp
QNetworkProtocol QNetworkProtocol QObject QObject QObject QObject Qt Qt Qt Qt Qt Qt Qt Qt

Lista de todos los miembros.

Tipos públicos

enum  State {
  Unconnected, HostLookup, Connecting, Connected,
  LoggedIn, Closing, Unconnected, HostLookup,
  Connecting, Connected, LoggedIn, Closing
}
enum  Error {
  NoError, UnknownError, HostNotFound, ConnectionRefused,
  NotConnected, NoError, UnknownError, HostNotFound,
  ConnectionRefused, NotConnected
}
enum  Command {
  None, ConnectToHost, Login, Close,
  List, Cd, Get, Put,
  Remove, Mkdir, Rmdir, Rename,
  RawCommand, None, ConnectToHost, Login,
  Close, List, Cd, Get,
  Put, Remove, Mkdir, Rmdir,
  Rename, RawCommand
}
enum  State {
  Unconnected, HostLookup, Connecting, Connected,
  LoggedIn, Closing, Unconnected, HostLookup,
  Connecting, Connected, LoggedIn, Closing
}
enum  Error {
  NoError, UnknownError, HostNotFound, ConnectionRefused,
  NotConnected, NoError, UnknownError, HostNotFound,
  ConnectionRefused, NotConnected
}
enum  Command {
  None, ConnectToHost, Login, Close,
  List, Cd, Get, Put,
  Remove, Mkdir, Rmdir, Rename,
  RawCommand, None, ConnectToHost, Login,
  Close, List, Cd, Get,
  Put, Remove, Mkdir, Rmdir,
  Rename, RawCommand
}

Slots públicos

void abort ()
void abort ()

Señales

void stateChanged (int)
void listInfo (const QUrlInfo &)
void readyRead ()
void dataTransferProgress (int, int)
void rawCommandReply (int, const QString &)
void commandStarted (int)
void commandFinished (int, bool)
void done (bool)
void stateChanged (int)
void listInfo (const QUrlInfo &)
void readyRead ()
void dataTransferProgress (int, int)
void rawCommandReply (int, const QString &)
void commandStarted (int)
void commandFinished (int, bool)
void done (bool)

Métodos públicos

 QFtp ()
 QFtp (QObject *parent, const char *name=0)
virtual ~QFtp ()
int supportedOperations () const
int connectToHost (const QString &host, Q_UINT16 port=21)
int login (const QString &user=QString::null, const QString &password=QString::null)
int close ()
int list (const QString &dir=QString::null)
int cd (const QString &dir)
int get (const QString &file, QIODevice *dev=0)
int put (const QByteArray &data, const QString &file)
int put (QIODevice *dev, const QString &file)
int remove (const QString &file)
int mkdir (const QString &dir)
int rmdir (const QString &dir)
int rename (const QString &oldname, const QString &newname)
int rawCommand (const QString &command)
Q_ULONG bytesAvailable () const
Q_LONG readBlock (char *data, Q_ULONG maxlen)
QByteArray readAll ()
int currentId () const
QIODevicecurrentDevice () const
Command currentCommand () const
bool hasPendingCommands () const
void clearPendingCommands ()
State state () const
Error error () const
QString errorString () const
 QFtp ()
 QFtp (QObject *parent, const char *name=0)
virtual ~QFtp ()
int supportedOperations () const
int connectToHost (const QString &host, Q_UINT16 port=21)
int login (const QString &user=QString::null, const QString &password=QString::null)
int close ()
int list (const QString &dir=QString::null)
int cd (const QString &dir)
int get (const QString &file, QIODevice *dev=0)
int put (const QByteArray &data, const QString &file)
int put (QIODevice *dev, const QString &file)
int remove (const QString &file)
int mkdir (const QString &dir)
int rmdir (const QString &dir)
int rename (const QString &oldname, const QString &newname)
int rawCommand (const QString &command)
Q_ULONG bytesAvailable () const
Q_LONG readBlock (char *data, Q_ULONG maxlen)
QByteArray readAll ()
int currentId () const
QIODevicecurrentDevice () const
Command currentCommand () const
bool hasPendingCommands () const
void clearPendingCommands ()
State state () const
Error error () const
QString errorString () const

Slots protegidos

void hostFound ()
void connected ()
void closed ()
void dataHostFound ()
void dataConnected ()
void dataClosed ()
void dataReadyRead ()
void dataBytesWritten (int nbytes)
void error (int)
void hostFound ()
void connected ()
void closed ()
void dataHostFound ()
void dataConnected ()
void dataClosed ()
void dataReadyRead ()
void dataBytesWritten (int nbytes)
void error (int)

Métodos protegidos

void parseDir (const QString &buffer, QUrlInfo &info)
void operationListChildren (QNetworkOperation *op)
void operationMkDir (QNetworkOperation *op)
void operationRemove (QNetworkOperation *op)
void operationRename (QNetworkOperation *op)
void operationGet (QNetworkOperation *op)
void operationPut (QNetworkOperation *op)
void parseDir (const QString &buffer, QUrlInfo &info)
void operationListChildren (QNetworkOperation *op)
void operationMkDir (QNetworkOperation *op)
void operationRemove (QNetworkOperation *op)
void operationRename (QNetworkOperation *op)
void operationGet (QNetworkOperation *op)
void operationPut (QNetworkOperation *op)

Atributos protegidos

QSocketcommandSocket
QSocketdataSocket
bool connectionReady
bool passiveMode
int getTotalSize
int getDoneSize
bool startGetOnFail
int putToWrite
int putWritten
bool errorInListChildren

Descripción detallada

The QFtp class provides an implementation of the FTP protocol.

network.

This class provides two different interfaces: one is the QNetworkProtocol interface that allows you to use FTP through the QUrlOperator abstraction. The other is a direct interface to FTP that gives you lower-level access to the FTP protocol for finer control. Using the direct interface you can also execute arbitrary FTP commands.

Don't mix the two interfaces, since the behavior is not well-defined.

If you want to use QFtp with the QNetworkProtocol interface, you do not use it directly, but rather through a QUrlOperator, for example:

    QUrlOperator op( "ftp://ftp.trolltech.com" );
    op.listChildren(); // Asks the server to provide a directory listing

This code will only work if the QFtp class is registered; to register the class, you must call qInitNetworkProtocols() before using a QUrlOperator with QFtp.

The rest of this descrption describes the direct interface to FTP.

The class works asynchronously, so there are no blocking functions. If an operation cannot be executed immediately, the function will still return straight away and the operation will be scheduled for later execution. The results of scheduled operations are reported via signals. This approach depends on the event loop being in operation.

The operations that can be scheduled (they are called "commands" in the rest of the documentation) are the following: connectToHost(), login(), close(), list(), cd(), get(), put(), remove(), mkdir(), rmdir(), rename() and rawCommand().

All of these commands return a unique identifier that allows you to keep track of the command that is currently being executed. When the execution of a command starts, the commandStarted() signal with the command's identifier is emitted. When the command is finished, the commandFinished() signal is emitted with the command's identifier and a bool that indicates whether the command finished with an error.

In some cases, you might want to execute a sequence of commands, e.g. if you want to connect and login to a FTP server. This is simply achieved:

    QFtp *ftp = new QFtp( this ); // this is an optional QObject parent
    ftp->connectToHost( "ftp.trolltech.com" );
    ftp->login();

In this case two FTP commands have been scheduled. When the last scheduled command has finished, a done() signal is emitted with a bool argument that tells you whether the sequence finished with an error.

If an error occurs during the execution of one of the commands in a sequence of commands, all the pending commands (i.e. scheduled, but not yet executed commands) are cleared and no signals are emitted for them.

Some commands, e.g. list(), emit additional signals to report their results.

Example: If you want to download the INSTALL file from Trolltech's FTP server, you would write this:

    ftp->connectToHost( "ftp.trolltech.com" );  // id == 1
    ftp->login();                               // id == 2
    ftp->cd( "qt" );                            // id == 3
    ftp->get( "INSTALL" );                      // id == 4
    ftp->close();                               // id == 5

For this example the following sequence of signals is emitted (with small variations, depending on network traffic, etc.):

    start( 1 )
    stateChanged( HostLookup )
    stateChanged( Connecting )
    stateChanged( Connected )
    finished( 1, FALSE )

    start( 2 )
    stateChanged( LoggedIn )
    finished( 2, FALSE )

    start( 3 )
    finished( 3, FALSE )

    start( 4 )
    dataTransferProgress( 0, 3798 )
    dataTransferProgress( 2896, 3798 )
    readyRead()
    dataTransferProgress( 3798, 3798 )
    readyRead()
    finished( 4, FALSE )

    start( 5 )
    stateChanged( Closing )
    stateChanged( Unconnected )
    finished( 5, FALSE )

    done( FALSE )

The dataTransferProgress() signal in the above example is useful if you want to show a progressbar to inform the user about the progress of the download. The readyRead() signal tells you that there is data ready to be read. The amount of data can be queried then with the bytesAvailable() function and it can be read with the readBlock() or readAll() function.

If the login fails for the above example, the signals would look like this:

    start( 1 )
    stateChanged( HostLookup )
    stateChanged( Connecting )
    stateChanged( Connected )
    finished( 1, FALSE )

    start( 2 )
    finished( 2, TRUE )

    done( TRUE )

You can then get details about the error with the error() and errorString() functions.

The functions currentId() and currentCommand() provide more information about the currently executing command.

The functions hasPendingCommands() and clearPendingCommands() allow you to query and clear the list of pending commands.

The safest and easiest way to use the FTP protocol is to use QUrlOperator() or the FTP commands described above. If you are an experienced network programmer and want to have complete control you can use rawCommand() to execute arbitrary FTP commands.

Ver también:
Qt Network Documentation QNetworkProtocol, QUrlOperator QHttp

Documentación de las enumeraciones miembro de la clase

This enum is used as the return value for the currentCommand() function. This allows you to perform specific actions for particular commands, e.g. in a FTP client, you might want to clear the directory view when a list() command is started; in this case you can simply check in the slot connected to the start() signal if the currentCommand() is List.

None No command is being executed. ConnectToHost connectToHost() is being executed. Login login() is being executed. Close close() is being executed. List list() is being executed. Cd cd() is being executed. Get get() is being executed. Put put() is being executed. Remove remove() is being executed. Mkdir mkdir() is being executed. Rmdir rmdir() is being executed. Rename rename() is being executed. RawCommand rawCommand() is being executed.

Ver también:
currentCommand()
Valores de enumeraciones:
None 
ConnectToHost 
Login 
Close 
List 
Cd 
Get 
Put 
Remove 
Mkdir 
Rmdir 
Rename 
RawCommand 
None 
ConnectToHost 
Login 
Close 
List 
Cd 
Get 
Put 
Remove 
Mkdir 
Rmdir 
Rename 
RawCommand 
Valores de enumeraciones:
None 
ConnectToHost 
Login 
Close 
List 
Cd 
Get 
Put 
Remove 
Mkdir 
Rmdir 
Rename 
RawCommand 
None 
ConnectToHost 
Login 
Close 
List 
Cd 
Get 
Put 
Remove 
Mkdir 
Rmdir 
Rename 
RawCommand 

When an operation fails (finishes unsuccessfully), the QNetworkOperation of the operation returns an error code which has one of the following values:

NoError No error occurred.

ErrValid The URL you are operating on is not valid.

ErrUnknownProtocol There is no protocol implementation available for the protocol of the URL you are operating on (e.g. if the protocol is http and no http implementation has been registered).

ErrUnsupported The operation is not supported by the protocol.

ErrParse The URL could not be parsed correctly.

ErrLoginIncorrect You needed to login but the username or password is wrong.

ErrHostNotFound The specified host (in the URL) couldn't be found.

ErrListChildren An error occurred while listing the children (files).

ErrMkDir An error occurred when creating a directory.

ErrRemove An error occurred when removing a child (file).

ErrRename An error occurred when renaming a child (file).

ErrGet An error occurred while getting (retrieving) data.

ErrPut An error occurred while putting (uploading) data.

ErrFileNotExisting A file which is needed by the operation doesn't exist.

ErrPermissionDenied Permission for doing the operation has been denied.

You should also use these error codes when implementing custom network protocols. If this is not possible, you can define your own error codes by using integer values that don't conflict with any of these values.

Valores de enumeraciones:
NoError 
UnknownError 
HostNotFound 
ConnectionRefused 
NotConnected 
NoError 
UnknownError 
HostNotFound 
ConnectionRefused 
NotConnected 

Reimplementado de QNetworkProtocol.

This enum identifies the error that occurred.

NoError No error occurred. HostNotFound The host name lookup failed. ConnectionRefused The server refused the connection. NotConnected Tried to send a command, but there is no connection to a server. UnknownError An error other than those specified above occurred.

Ver también:
error()
Valores de enumeraciones:
NoError 
UnknownError 
HostNotFound 
ConnectionRefused 
NotConnected 
NoError 
UnknownError 
HostNotFound 
ConnectionRefused 
NotConnected 

Reimplementado de QNetworkProtocol.

This enum contains the state that a QNetworkOperation can have.

StWaiting The operation is in the QNetworkProtocol's queue waiting to be prcessed.

StInProgress The operation is being processed.

StDone The operation has been processed succesfully.

StFailed The operation has been processed but an error occurred.

StStopped The operation has been processed but has been stopped before it finished, and is waiting to be processed.

Valores de enumeraciones:
Unconnected 
HostLookup 
Connecting 
Connected 
LoggedIn 
Closing 
Unconnected 
HostLookup 
Connecting 
Connected 
LoggedIn 
Closing 

Reimplementado de QNetworkProtocol.

This enum defines the connection state:

Unconnected There is no connection to the host. HostLookup A host name lookup is in progress. Connecting An attempt to connect to the host is in progress. Connected Connection to the host has been achieved. LoggedIn Connection and user login have been achieved. Closing The connection is closing down, but it is not yet closed. (The state will be Unconnected when the connection is closed.)

Ver también:
stateChanged() state()
Valores de enumeraciones:
Unconnected 
HostLookup 
Connecting 
Connected 
LoggedIn 
Closing 
Unconnected 
HostLookup 
Connecting 
Connected 
LoggedIn 
Closing 

Reimplementado de QNetworkProtocol.


Documentación del constructor y destructor

QFtp::QFtp ( )

Constructs a QFtp object.

QFtp::QFtp ( QObject parent,
const char *  name = 0 
)

Constructs a QFtp object. The parent and name parameters are passed to the QObject constructor.

QFtp::~QFtp ( ) [virtual]

Destructor.

QFtp::QFtp ( )
QFtp::QFtp ( QObject parent,
const char *  name = 0 
)
virtual QFtp::~QFtp ( ) [virtual]

Documentación de las funciones miembro

void QFtp::abort ( ) [slot]

Aborts the current command and deletes all scheduled commands.

If there is an unfinished command (i.e. a command for which the commandStarted() signal has been emitted, but for which the commandFinished() signal has not been emitted), this function sends an ABORT command to the server. When the server replies that the command is aborted, the commandFinished() signal with the error argument set to TRUE is emitted for the command. Due to timing issues, it is possible that the command had already finished before the abort request reached the server, in which case, the commandFinished() signal is emitted with the error argument set to FALSE.

For all other commands that are affected by the abort(), no signals are emitted.

If you don't start further FTP commands directly after the abort(), there won't be any scheduled commands and the done() signal is emitted.

Atención:
Some FTP servers, for example the BSD FTP daemon (version 0.3), wrongly return a positive reply even when an abort has occurred. For these servers the commandFinished() signal has its error flag set to FALSE, even though the command did not complete successfully.
Ver también:
clearPendingCommands()
void QFtp::abort ( ) [slot]
Q_ULONG QFtp::bytesAvailable ( ) const
Q_ULONG QFtp::bytesAvailable ( ) const

Returns the number of bytes that can be read from the data socket at the moment.

Ver también:
get() readyRead() readBlock() readAll()
int QFtp::cd ( const QString dir)

Changes the working directory of the server to dir.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

Ver también:
commandStarted() commandFinished()
int QFtp::cd ( const QString dir)
void QFtp::clearPendingCommands ( )

Deletes all pending commands from the list of scheduled commands. This does not affect the command that is being executed. If you want to stop this this as well, use abort().

Ver también:
hasPendingCommands() abort()
void QFtp::clearPendingCommands ( )
int QFtp::close ( )
int QFtp::close ( void  )

Closes the connection to the FTP server.

The stateChanged() signal is emitted when the state of the connecting process changes, e.g. to Closing, then Unconnected.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

Ver también:
stateChanged() commandStarted() commandFinished()
void QFtp::closed ( ) [protected, slot]
void QFtp::closed ( ) [protected, slot]
void QFtp::commandFinished ( int  id,
bool  error 
) [signal]

This signal is emitted when processing the command identified by id has finished. error is TRUE if an error occurred during the processing; otherwise error is FALSE.

Ver también:
commandStarted() done() error() errorString()
void QFtp::commandFinished ( int  ,
bool   
) [signal]
void QFtp::commandStarted ( int  id) [signal]

This signal is emitted when processing the command identified by id starts.

Ver también:
commandFinished() done()
void QFtp::commandStarted ( int  ) [signal]
void QFtp::connected ( ) [protected, slot]
void QFtp::connected ( ) [protected, slot]
int QFtp::connectToHost ( const QString host,
Q_UINT16  port = 21 
)

Connects to the FTP server host using port port.

The stateChanged() signal is emitted when the state of the connecting process changes, e.g. to HostLookup, then Connecting, then Connected.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

Ver también:
stateChanged() commandStarted() commandFinished()
int QFtp::connectToHost ( const QString host,
Q_UINT16  port = 21 
)
Command QFtp::currentCommand ( ) const
QFtp::Command QFtp::currentCommand ( ) const

Returns the command type of the FTP command being executed or None if there is no command being executed.

Ver también:
currentId()
QIODevice * QFtp::currentDevice ( ) const

Returns the QIODevice pointer that is used by the FTP command to read data from or store data to. If there is no current FTP command being executed or if the command does not use an IO device, this function returns 0.

This function can be used to delete the QIODevice in the slot connected to the commandFinished() signal.

Ver también:
get() put()
QIODevice* QFtp::currentDevice ( ) const
int QFtp::currentId ( ) const
int QFtp::currentId ( ) const

Returns the identifier of the FTP command that is being executed or 0 if there is no command being executed.

Ver también:
currentCommand()
void QFtp::dataBytesWritten ( int  nbytes) [protected, slot]
void QFtp::dataBytesWritten ( int  nbytes) [protected, slot]
void QFtp::dataClosed ( ) [protected, slot]
void QFtp::dataClosed ( ) [protected, slot]
void QFtp::dataConnected ( ) [protected, slot]
void QFtp::dataConnected ( ) [protected, slot]
void QFtp::dataHostFound ( ) [protected, slot]
void QFtp::dataHostFound ( ) [protected, slot]
void QFtp::dataReadyRead ( ) [protected, slot]
void QFtp::dataReadyRead ( ) [protected, slot]
void QFtp::dataTransferProgress ( int  ,
int   
) [signal]
void QFtp::dataTransferProgress ( int  done,
int  total 
) [signal]

This signal is emitted in response to a get() or put() request to indicate the current progress of the download or upload.

done is the amount of data that has already been transferred and total is the total amount of data to be read or written. It is possible that the QFtp class is not able to determine the total amount of data that should be transferred, in which case total is 0. (If you connect this signal to a QProgressBar, the progress bar shows a busy indicator if the total is 0).

Atención:
done and total are not necessarily the size in bytes, since for large files these values might need to be "scaled" to avoid overflow.
Ver también:
get() put() QProgressBar::setProgress()
void QFtp::done ( bool  error) [signal]

This signal is emitted when the last pending command has finished; (it is emitted after the last command's commandFinished() signal). error is TRUE if an error occurred during the processing; otherwise error is FALSE.

Ver también:
commandFinished() error() errorString()
void QFtp::done ( bool  ) [signal]
Error QFtp::error ( ) const
void QFtp::error ( int  ) [protected, slot]
void QFtp::error ( int  ) [protected, slot]
QFtp::Error QFtp::error ( ) const

Returns the last error that occurred. This is useful to find out what when wrong when receiving a commandFinished() or a done() signal with the error argument set to TRUE.

If you start a new command, the error status is reset to NoError.

QString QFtp::errorString ( ) const
QString QFtp::errorString ( ) const

Returns a human-readable description of the last error that occurred. This is useful for presenting a error message to the user when receiving a commandFinished() or a done() signal with the error argument set to TRUE.

The error string is often (but not always) the reply from the server, so it is not always possible to translate the string. If the message comes from Qt, the string has already passed through tr().

int QFtp::get ( const QString file,
QIODevice dev = 0 
)
int QFtp::get ( const QString file,
QIODevice dev = 0 
)

Downloads the file file from the server.

If dev is 0, then the readyRead() signal is emitted when there is data available to read. You can then read the data with the readBlock() or readAll() functions.

If dev is not 0, the data is written directly to the device dev. Make sure that the dev pointer is valid for the duration of the operation (it is safe to delete it when the commandFinished() signal is emitted). In this case the readyRead() signal is not emitted and you cannot read data with the readBlock() or readAll() functions.

If you don't read the data immediately it becomes available, i.e. when the readyRead() signal is emitted, it is still available until the next command is started.

For example, if you want to present the data to the user as soon as there is something available, connect to the readyRead() signal and read the data immediately. On the other hand, if you only want to work with the complete data, you can connect to the commandFinished() signal and read the data when the get() command is finished.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

Ver también:
readyRead() dataTransferProgress() commandStarted() commandFinished()
bool QFtp::hasPendingCommands ( ) const
bool QFtp::hasPendingCommands ( ) const

Returns TRUE if there are any commands scheduled that have not yet been executed; otherwise returns FALSE.

The command that is being executed is not considered as a scheduled command.

Ver también:
clearPendingCommands() currentId() currentCommand()
void QFtp::hostFound ( ) [protected, slot]
void QFtp::hostFound ( ) [protected, slot]
int QFtp::list ( const QString dir = QString::null)

Lists the contents of directory dir on the FTP server. If dir is empty, it lists the contents of the current directory.

The listInfo() signal is emitted for each directory entry found.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

Ver también:
listInfo() commandStarted() commandFinished()
int QFtp::list ( const QString dir = QString::null)
void QFtp::listInfo ( const QUrlInfo ) [signal]
void QFtp::listInfo ( const QUrlInfo i) [signal]

This signal is emitted for each directory entry the list() command finds. The details of the entry are stored in i.

Ver también:
list()
int QFtp::login ( const QString user = QString::null,
const QString password = QString::null 
)

Logs in to the FTP server with the username user and the password password.

The stateChanged() signal is emitted when the state of the connecting process changes, e.g. to LoggedIn.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

Ver también:
commandStarted() commandFinished()
int QFtp::login ( const QString user = QString::null,
const QString password = QString::null 
)
int QFtp::mkdir ( const QString dir)

Creates a directory called dir on the server.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

Ver también:
commandStarted() commandFinished()
int QFtp::mkdir ( const QString dir)
void QFtp::operationGet ( QNetworkOperation op) [protected, virtual]

When implementing a new network protocol, this method should be reimplemented if the protocol supports getting data; this method should then process the QNetworkOperation.

When you reimplement this method it's very important that you emit the correct signals at the correct time (especially the finished() signal after processing an operation). Take a look at the Qt Network Documentation which describes in detail how to reimplement this method. You may also want to look at the example implementation in examples/network/networkprotocol/nntp.cpp.

op is the pointer to the operation object which contains all the information on the operation that has finished, including the state, etc.

Reimplementado de QNetworkProtocol.

void QFtp::operationGet ( QNetworkOperation op) [protected, virtual]

Reimplementado de QNetworkProtocol.

void QFtp::operationListChildren ( QNetworkOperation op) [protected, virtual]

Reimplementado de QNetworkProtocol.

void QFtp::operationListChildren ( QNetworkOperation op) [protected, virtual]

When implementing a new network protocol, this method should be reimplemented if the protocol supports listing children (files); this method should then process this QNetworkOperation.

When you reimplement this method it's very important that you emit the correct signals at the correct time (especially the finished() signal after processing an operation). Take a look at the Qt Network Documentation which describes in detail how to reimplement this method. You may also want to look at the example implementation in examples/network/networkprotocol/nntp.cpp.

op is the pointer to the operation object which contains all the information on the operation that has finished, including the state, etc.

Reimplementado de QNetworkProtocol.

void QFtp::operationMkDir ( QNetworkOperation op) [protected, virtual]

When implementing a new network protocol, this method should be reimplemented if the protocol supports making directories; this method should then process this QNetworkOperation.

When you reimplement this method it's very important that you emit the correct signals at the correct time (especially the finished() signal after processing an operation). Take a look at the Qt Network Documentation which describes in detail how to reimplement this method. You may also want to look at the example implementation in examples/network/networkprotocol/nntp.cpp.

op is the pointer to the operation object which contains all the information on the operation that has finished, including the state, etc.

Reimplementado de QNetworkProtocol.

void QFtp::operationMkDir ( QNetworkOperation op) [protected, virtual]

Reimplementado de QNetworkProtocol.

void QFtp::operationPut ( QNetworkOperation op) [protected, virtual]

When implementing a new network protocol, this method should be reimplemented if the protocol supports putting (uploading) data; this method should then process the QNetworkOperation.

When you reimplement this method it's very important that you emit the correct signals at the correct time (especially the finished() signal after processing an operation). Take a look at the Qt Network Documentation which describes in detail how to reimplement this method. You may also want to look at the example implementation in examples/network/networkprotocol/nntp.cpp.

op is the pointer to the operation object which contains all the information on the operation that has finished, including the state, etc.

Reimplementado de QNetworkProtocol.

void QFtp::operationPut ( QNetworkOperation op) [protected, virtual]

Reimplementado de QNetworkProtocol.

void QFtp::operationRemove ( QNetworkOperation op) [protected, virtual]

When implementing a new network protocol, this method should be reimplemented if the protocol supports removing children (files); this method should then process this QNetworkOperation.

When you reimplement this method it's very important that you emit the correct signals at the correct time (especially the finished() signal after processing an operation). Take a look at the Qt Network Documentation which is describes in detail how to reimplement this method. You may also want to look at the example implementation in examples/network/networkprotocol/nntp.cpp.

op is the pointer to the operation object which contains all the information on the operation that has finished, including the state, etc.

Reimplementado de QNetworkProtocol.

void QFtp::operationRemove ( QNetworkOperation op) [protected, virtual]

Reimplementado de QNetworkProtocol.

void QFtp::operationRename ( QNetworkOperation op) [protected, virtual]

Reimplementado de QNetworkProtocol.

void QFtp::operationRename ( QNetworkOperation op) [protected, virtual]

When implementing a new newtork protocol, this method should be reimplemented if the protocol supports renaming children (files); this method should then process this QNetworkOperation.

When you reimplement this method it's very important that you emit the correct signals at the correct time (especially the finished() signal after processing an operation). Take a look at the Qt Network Documentation which describes in detail how to reimplement this method. You may also want to look at the example implementation in examples/network/networkprotocol/nntp.cpp.

op is the pointer to the operation object which contains all the information on the operation that has finished, including the state, etc.

Reimplementado de QNetworkProtocol.

void QFtp::parseDir ( const QString buffer,
QUrlInfo info 
) [protected]
void QFtp::parseDir ( const QString buffer,
QUrlInfo info 
) [protected]
int QFtp::put ( const QByteArray data,
const QString file 
)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Writes the data data to the file called file on the server. The progress of the upload is reported by the dataTransferProgress() signal.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

Ver también:
dataTransferProgress() commandStarted() commandFinished()
int QFtp::put ( QIODevice dev,
const QString file 
)

Reads the data from the IO device dev, and writes it to the file called file on the server. The data is read in chunks from the IO device, so this overload allows you to transmit large amounts of data without the need to read all the data into memory at once.

Make sure that the dev pointer is valid for the duration of the operation (it is safe to delete it when the commandFinished() is emitted).

int QFtp::put ( QIODevice dev,
const QString file 
)
int QFtp::put ( const QByteArray data,
const QString file 
)
int QFtp::rawCommand ( const QString command)
int QFtp::rawCommand ( const QString command)

Sends the raw FTP command command to the FTP server. This is useful for low-level FTP access. If the operation you wish to perform has an equivalent QFtp function, we recommend using the function instead of raw FTP commands since the functions are easier and safer.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

Ver también:
rawCommandReply() commandStarted() commandFinished()
void QFtp::rawCommandReply ( int  ,
const QString  
) [signal]
void QFtp::rawCommandReply ( int  replyCode,
const QString detail 
) [signal]

This signal is emitted in response to the rawCommand() function. replyCode is the 3 digit reply code and detail is the text that follows the reply code.

Ver también:
rawCommand()
QByteArray QFtp::readAll ( )

Reads all the bytes available from the data socket and returns them.

Ver también:
get() readyRead() bytesAvailable() readBlock()
QByteArray QFtp::readAll ( )
Q_LONG QFtp::readBlock ( char *  data,
Q_ULONG  maxlen 
)
Q_LONG QFtp::readBlock ( char *  data,
Q_ULONG  maxlen 
)

Reads maxlen bytes from the data socket into data and returns the number of bytes read. Returns -1 if an error occurred.

Ver también:
get() readyRead() bytesAvailable() readAll()
void QFtp::readyRead ( ) [signal]
void QFtp::readyRead ( ) [signal]

This signal is emitted in response to a get() command when there is new data to read.

If you specify a device as the second argument in the get() command, this signal is not emitted; instead the data is written directly to the device.

You can read the data with the readAll() or readBlock() functions.

This signal is useful if you want to process the data in chunks as soon as it becomes available. If you are only interested in the complete data, just connect to the commandFinished() signal and read the data then instead.

Ver también:
get() readBlock() readAll() bytesAvailable()
int QFtp::remove ( const QString file)
int QFtp::remove ( const QString file)

Deletes the file called file from the server.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

Ver también:
commandStarted() commandFinished()
int QFtp::rename ( const QString oldname,
const QString newname 
)

Renames the file called oldname to newname on the server.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

Ver también:
commandStarted() commandFinished()
int QFtp::rename ( const QString oldname,
const QString newname 
)
int QFtp::rmdir ( const QString dir)
int QFtp::rmdir ( const QString dir)

Removes the directory called dir from the server.

The function does not block and returns immediately. The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().

When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.

Ver también:
commandStarted() commandFinished()
QFtp::State QFtp::state ( ) const

Returns the current state of the object. When the state changes, the stateChanged() signal is emitted.

Ver también:
State stateChanged()
State QFtp::state ( ) const
void QFtp::stateChanged ( int  ) [signal]
void QFtp::stateChanged ( int  state) [signal]

This signal is emitted when the state of the connection changes. The argument state is the new state of the connection; it is one of the State values.

It is usually emitted in response to a connectToHost() or close() command, but it can also be emitted "spontaneously", e.g. when the server closes the connection unexpectedly.

Ver también:
connectToHost() close() state() State
int QFtp::supportedOperations ( ) const [virtual]

Returns an int that is OR'd together using the enum values of {QNetworkProtocol::Operation}, which describes which operations are supported by the network protocol. Should be reimplemented by new network protocols.

Reimplementado de QNetworkProtocol.

int QFtp::supportedOperations ( ) const [virtual]

Reimplementado de QNetworkProtocol.


Documentación de los datos miembro

QSocket * QFtp::dataSocket [protected]
int QFtp::getDoneSize [protected]
int QFtp::getTotalSize [protected]
bool QFtp::passiveMode [protected]
int QFtp::putToWrite [protected]
int QFtp::putWritten [protected]

La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'