Results 1 to 2 of 2

Thread: QFtp bug ?? When in active mode

  1. #1
    Join Date
    May 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QFtp bug ?? When in active mode

    SO I´m into some problems, because my application is ready and the ftp part is not working very well as I had to change the Ftp Client (QFtp) to active mode, due to firewall into the network here.

    So the Ftp protocol should work like this for uploading a file: It is the resume of the packets captured from a working ftp Client

    Client Server
    PORT command from myPort --> destination port 21
    to myPort <-- PORT Command sucessfull.
    STOR fileName.ext --> destination port 21
    to myPort <-- Opening mode data connection for fileName.ext
    to port PORT <-- from port 20 (SYN) *TCP PROTOCOL
    from port PORT --> to port 20 (SYN, ACK) *TCP PROTOCOL
    to port PORT <-- from port 20 (ACK) *TCP PROTOCOL
    from port PORT DATA --> DATA to port 20




    So here is what is happening with my QFtp application using Active mode:

    Client [i[Server[/i]
    PORT command from myPort --> destination port 21
    to myPort <-- PORT Command sucessfull.
    ALLO command from myPort --> destination port 21
    to myPort <-- ALLO Command sucessfull.

    STOR fileName.ext --> destination port 21
    to myPort <-- Opening mode data connection for fileName.ext
    to port PORT <-- from port 20 (SYN) *TCP PROTOCOL
    from port PORT --> to port 20 (SYN, ACK) *TCP PROTOCOL
    to port PORT <-- from port 20 (ACK) *TCP PROTOCOL
    from myPort --> to port 21 (ACK) *TCP Protocol
    ----------- NO MORE CONVERSATION-----------------------


    on both transfers I got TYPE SET TO I ok....
    Also, when listing the files it does work perfectly....

    The server type is, from WS_FTP
    SYST
    215 Windows_NT
    Host type (2): Microsoft NT

    But the error also happens in other servers, but not always

    It does create the file on the server, but it has 0 bytes!
    No, its not permission problem...it worked OK with all other Ftp clients

    I hope someone here can help me...I´m stuck on this for some weeks...
    Cheers


    Oh, this is the code I use to upload the files...

    #include "FtpFileSender.h"

    FtpFileSender::FtpFileSender(QFtp *ftp) : nomeArquivoEnviando(NULL), barraDeProgresso(NULL)
    {
    this->ftp = ftp;
    connect(ftp, SIGNAL(commandFinished(int, bool)), this, SLOT(comandoFinalizado(int, bool)));
    }

    void FtpFileSender::enviarArquivos(QStringList caminhoArquivos) throw (QString*)
    {
    arquivosErro.clear();
    mapaDeArquivos.clear();
    QString nome;
    QFile *file = NULL;
    for(int i=0; i<caminhoArquivos.size(); i++)
    {
    file = new QFile(caminhoArquivos.at(i));
    file->open(QIODevice::ReadOnly);
    nome = this->getNomeArquivo(file->fileName());
    mapaDeArquivos.insert(ftp->put(file, nome, QFtp::Binary), file);
    }
    }

    QString FtpFileSender::getNomeArquivo(QString caminhoArquivo)
    {
    QString nome;
    QStringList nomeAux;
    nome = caminhoArquivo;
    if(nome.contains("/"))
    {
    nomeAux = nome.split("/");
    nome = nomeAux.at(nomeAux.size()-1);
    }
    else if(nome.contains("\\"))
    {
    nomeAux = nome.split("\\");
    nome = nomeAux.at(nomeAux.size()-1);
    }
    return nome;
    }

    void FtpFileSender::comandoFinalizado(int id, bool erro)
    {
    if(!this->mapaDeArquivos.contains(id))
    return;
    QFile* arquivo = mapaDeArquivos.take(id);
    if(erro)
    arquivosErro.append(arquivo->fileName());
    arquivo->close();
    delete arquivo;
    if(mapaDeArquivos.empty())
    {
    emit(fim(arquivosErro));
    }
    }

    void FtpFileSender::setLabelArquivoSendoEnviado(QLabel* label)
    {
    this->nomeArquivoEnviando = label;
    connect(ftp, SIGNAL(commandStarted(int)), this, SLOT(comandoIniciado(int)));
    }

    void FtpFileSender::unsetLabelArquivoSendoEnviado()
    {
    disconnect(ftp, SIGNAL(commandStarted(int)), this, SLOT(comandoIniciado(int)));
    this->nomeArquivoEnviando = NULL;
    }



    void FtpFileSender::unsetProgressBar()
    {
    disconnect(ftp, SIGNAL(dataTransferProgress(qint64, qint64)), barraDeProgresso, SLOT(setDataTransferProgress(qint64, qint64)));
    this->barraDeProgresso = NULL;
    }


    void FtpFileSender::comandoIniciado(int id)
    {
    if(this->nomeArquivoEnviando == NULL)
    return;
    if(!this->mapaDeArquivos.contains(id))
    return;
    QString nome(this->mapaDeArquivos.value(id)->fileName());
    this->nomeArquivoEnviando->setText(this->getNomeArquivo(nome));
    }

    void FtpFileSender::setProgressBar(BarraDeProgresso* barra)
    {
    this->barraDeProgresso = barra;
    connect(ftp, SIGNAL(dataTransferProgress(qint64, qint64)), barraDeProgresso, SLOT(setDataTransferProgress(qint64, qint64)));
    }


    FtpFileSender::~FtpFileSender()
    {

    }

  2. #2
    Join Date
    May 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFtp bug ?? When in active mode

    Oh well,
    using Java and apache commons net it worked OK, so I think its a BUG from QFtp.... How can I report it?

Similar Threads

  1. Replies: 1
    Last Post: 2nd November 2009, 12:02
  2. Replies: 9
    Last Post: 15th April 2009, 06:23
  3. Replies: 8
    Last Post: 10th October 2007, 18:20
  4. Replies: 0
    Last Post: 23rd September 2007, 11:54
  5. active child
    By evgenM in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2006, 12:16

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.