class FtpWorker : public QThread{ Q_OBJECTprivate: QFtp *ftp;private slots: void ftpCommandFinished(int commandId, bool error); void ftpCommandStarted(int commandId);};FtpWorker::FtpWorker(FtpDialog *parent, QUrl *p_url): QThread(parent){ ftp=new QFtp(); connect(ftp, SIGNAL(commandFinished(int, bool)), this, SLOT(ftpCommandFinished(int, bool))); connect(ftp, SIGNAL(commandStarted(int)), this, SLOT(ftpCommandStarted(int)));}void FtpWorker::run(){ ftp->connectToHost(p_url->host(), p_url->port()); ftp->login();}void FtpWorker::ftpCommandStarted(int commandId){ printf("ftpCommandStarted, cmd is: %d \n",ftp->currentCommand()); if (ftp->currentCommand() == QFtp::Login) printf("LoginStarted\n");}void FtpWorker::ftpCommandFinished(int commandId, bool error){ printf("ftpCommandFinished command is %d\n",ftp->currentCommand()); if (ftp->currentCommand() == QFtp::ConnectToHost) { if (error) { printf("ftpCommandFinished, error occured while connecting\n"); return; } printf("Connected to host\n"); return; } if (ftp->currentCommand() == QFtp::Login){ printf("Got connected"); return; }}
void FtpWorker::run(){ ftp->connectToHost(p_url->host(), p_url->port()); ftp->login();}