⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 q3ftp.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    \fn void Q3Ftp::commandFinished( int id, bool error )    This signal is emitted when processing the command identified by    \a id has finished. \a error is true if an error occurred during    the processing; otherwise \a error is false.    \sa commandStarted() done() error() errorString()*//*!    \fn void Q3Ftp::done( bool error )    This signal is emitted when the last pending command has finished;    (it is emitted after the last command's commandFinished() signal).    \a error is true if an error occurred during the processing;    otherwise \a error is false.    \sa commandFinished() error() errorString()*//*!    \fn void Q3Ftp::readyRead()    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 \e 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.    \sa get() readBlock() readAll() bytesAvailable()*//*!    \fn void Q3Ftp::dataTransferProgress( int done, int total )    This signal is emitted in response to a get() or put() request to    indicate the current progress of the download or upload.    \a done is the amount of data that has already been transferred    and \a total is the total amount of data to be read or written. It    is possible that the Q3Ftp class is not able to determine the total    amount of data that should be transferred, in which case \a total    is 0. (If you connect this signal to a QProgressBar, the progress    bar shows a busy indicator if the total is 0).    \warning \a done and \a total are not necessarily the size in    bytes, since for large files these values might need to be    "scaled" to avoid overflow.    \sa get() put()*//*!    \fn void Q3Ftp::rawCommandReply( int replyCode, const QString &detail );    This signal is emitted in response to the rawCommand() function.    \a replyCode is the 3 digit reply code and \a detail is the text    that follows the reply code.    \sa rawCommand()*//*!    Connects to the FTP server \a host using port \a port.    The stateChanged() signal is emitted when the state of the    connecting process changes, e.g. to \c HostLookup, then \c    Connecting, then \c 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.    \sa stateChanged() commandStarted() commandFinished()*/int Q3Ftp::connectToHost( const QString &host, Q_UINT16 port ){    QStringList cmds;    cmds << host;    cmds << QString::number( (uint)port );    return addCommand( new Q3FtpCommand( ConnectToHost, cmds ) );}/*!    Logs in to the FTP server with the username \a user and the    password \a password.    The stateChanged() signal is emitted when the state of the    connecting process changes, e.g. to \c 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.    \sa commandStarted() commandFinished()*/int Q3Ftp::login( const QString &user, const QString &password ){    QStringList cmds;    cmds << ( QString(QLatin1String("USER ")) + ( user.isNull() ? QString(QLatin1String("anonymous")) : user ) + QLatin1String("\r\n") );    cmds << ( QString(QLatin1String("PASS ")) + ( password.isNull() ? QString(QLatin1String("anonymous@")) : password ) + QLatin1String("\r\n") );    return addCommand( new Q3FtpCommand( Login, cmds ) );}/*!    Closes the connection to the FTP server.    The stateChanged() signal is emitted when the state of the    connecting process changes, e.g. to \c Closing, then \c    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.    \sa stateChanged() commandStarted() commandFinished()*/int Q3Ftp::close(){    return addCommand( new Q3FtpCommand( Close, QStringList(QLatin1String("QUIT\r\n")) ) );}/*!    Lists the contents of directory \a dir on the FTP server. If \a    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.    \sa listInfo() commandStarted() commandFinished()*/int Q3Ftp::list( const QString &dir ){    QStringList cmds;    cmds << QLatin1String("TYPE A\r\n");    cmds << QLatin1String("PASV\r\n");    if ( dir.isEmpty() )	cmds << QLatin1String("LIST\r\n");    else	cmds << ( QLatin1String("LIST ") + dir + QLatin1String("\r\n") );    return addCommand( new Q3FtpCommand( List, cmds ) );}/*!    Changes the working directory of the server to \a 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.    \sa commandStarted() commandFinished()*/int Q3Ftp::cd( const QString &dir ){    return addCommand( new Q3FtpCommand( Cd, QStringList(QLatin1String("CWD ")+dir+QLatin1String("\r\n")) ) );}/*!    Downloads the file \a file from the server.    If \a 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 \a dev is not 0, the data is written directly to the device \a    dev. Make sure that the \a 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 \e 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.    \sa readyRead() dataTransferProgress() commandStarted()    commandFinished()*/int Q3Ftp::get( const QString &file, QIODevice *dev ){    QStringList cmds;    cmds << ( QLatin1String("SIZE ") + file + QLatin1String("\r\n") );    cmds << QLatin1String("TYPE I\r\n");    cmds << QLatin1String("PASV\r\n");    cmds << ( QLatin1String("RETR ") + file + QLatin1String("\r\n") );    if ( dev )	return addCommand( new Q3FtpCommand( Get, cmds, dev ) );    return addCommand( new Q3FtpCommand( Get, cmds ) );}/*!    \overload    Writes the data \a data to the file called \a 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.    \sa dataTransferProgress() commandStarted() commandFinished()*/int Q3Ftp::put( const QByteArray &data, const QString &file ){    QStringList cmds;    cmds << QLatin1String("TYPE I\r\n");    cmds << QLatin1String("PASV\r\n");    cmds << ( QLatin1String("ALLO ") + QString::number(data.size()) + QLatin1String("\r\n") );    cmds << ( QLatin1String("STOR ") + file + QLatin1String("\r\n") );    return addCommand( new Q3FtpCommand( Put, cmds, data ) );}/*!    Reads the data from the IO device \a dev, and writes it to the    file called \a 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 \a dev pointer is valid for the duration of the    operation (it is safe to delete it when the commandFinished() is    emitted).*/int Q3Ftp::put( QIODevice *dev, const QString &file ){    QStringList cmds;    cmds << QLatin1String("TYPE I\r\n");    cmds << QLatin1String("PASV\r\n");    if ( !dev->isSequentialAccess() )	cmds << ( QLatin1String("ALLO ") + QString::number(dev->size()) + QLatin1String("\r\n") );    cmds << ( QLatin1String("STOR ") + file + QLatin1String("\r\n") );    return addCommand( new Q3FtpCommand( Put, cmds, dev ) );}/*!    Deletes the file called \a 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.    \sa commandStarted() commandFinished()*/int Q3Ftp::remove( const QString &file ){    return addCommand( new Q3FtpCommand( Remove, QStringList(QLatin1String("DELE ")+file+QLatin1String("\r\n")) ) );}/*!    Creates a directory called \a 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.    \sa commandStarted() commandFinished()*/int Q3Ftp::mkdir( const QString &dir ){    return addCommand( new Q3FtpCommand( Mkdir, QStringList(QLatin1String("MKD ")+dir+QLatin1String("\r\n")) ) );}/*!    Removes the directory called \a 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.    \sa commandStarted() commandFinished()*/int Q3Ftp::rmdir( const QString &dir ){    return addCommand( new Q3FtpCommand( Rmdir, QStringList(QLatin1String("RMD ")+dir+QLatin1String("\r\n")) ) );}/*!    Renames the file called \a oldname to \a 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.    \sa commandStarted() commandFinished()*/int Q3Ftp::rename( const QString &oldname, const QString &newname ){    QStringList cmds;    cmds << ( QLatin1String("RNFR ") + oldname + QLatin1String("\r\n") );    cmds << ( QLatin1String("RNTO ") + newname + QLatin1String("\r\n") );    return addCommand( new Q3FtpCommand( Rename, cmds ) );}/*!    Sends the raw FTP command \a command to the FTP server. This is    useful for low-level FTP access. If the operation you wish to    perform has an equivalent Q3Ftp 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.    \sa rawCommandReply() commandStarted() commandFinished()*/int Q3Ftp::rawCommand( const QString &command ){    QString cmd = command.stripWhiteSpace() + QLatin1String("\r\n");    return addCommand( new Q3FtpCommand( RawCommand, QStringList(cmd) ) );}/*!    Returns the number of bytes that can be read from the data socket    at the moment.    \sa get() readyRead() readBlock() readAll()*/Q_ULONG Q3Ftp::bytesAvailable() const{    Q3FtpPrivate *d = ::d( this );    return d->pi.dtp.bytesAvailable();}/*!    Reads \a maxlen bytes from the data socket into \a data and    returns the number of bytes read. Returns -1 if an error occurred.    \sa get() readyRead() bytesAvailable() readAll()*/Q_LONG Q3Ftp::readBlock( char *data, Q_ULONG maxlen ){    Q3FtpPrivate *d = ::d( this );    return d->pi.dtp.readBlock( data, maxlen );}/*!    Reads all the bytes available from the data socket and returns    them.    \sa get() readyRead() bytesAvailable() readBlock()*/QByteArray Q3Ftp::readAll(){    Q3FtpPrivate *d = ::d( this );    return d->pi.dtp.readAll();}/*!    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 \c ABORT command to the server. When the server replies    that the command is aborted, the commandFinished() signal with the    \c error argument set to \c 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 \c error    argument set to \c 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.    \warning 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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -