/plugins/nftp/nftp.h

00001 /* $Id: nftp.h,v 1.22 2003/10/01 19:45:27 ndiin Exp $
00002  *
00003  * nftp.h FTP Handling Implementation
00004  *
00005  *    Written by Eric Andresen
00006  *
00007  * Copyright 2002-2003 Eric Andresen
00008  * See COPYING for license information
00009  */
00010 
00011 #ifndef NFTP_H
00012 #define NFTP_H
00013 
00014 #include <queue>
00015 
00016 #include <unistd.h>
00017 
00018 #include <qurlinfo.h>
00019 #include <qfile.h>
00020 
00021 #include "nnet.h"
00022 #include "nserversocket.h"
00023 #include "nftpdefoptions.h"
00024 
00028 class NFtp : public NNet
00029 {
00030    Q_OBJECT
00031 public:
00033    NFtp( int id, QObject * parent = 0, const char *name = 0 );
00034    virtual ~NFtp();
00035 
00036    virtual const char* name() const { return PROTOCOL_NAME; }
00037    virtual const char* protocol() const { return PROTOCOL_PREFIX; }
00038    virtual int connectToHost( NHostInfo hInfo, bool batch );
00039    virtual int sendRawCommand(QString command);
00040    virtual int list();
00041    virtual int cd(QString dir);
00042    virtual int move(QString newname, QString oldname);
00043    virtual int remove(QString name, bool recursive=false);
00044    virtual int makedir(QString dir);
00045    virtual int abort();
00046    virtual int get(QString file, QString sourcefile, bool resume = false);
00047    virtual int put(QString file, QString sourcefile, bool resume = false);
00048 
00049 public slots:
00050    virtual int closeConnection();
00051 
00052 private slots:
00053    void commandReadyRead();
00054    void commandConnClosed();
00055    void commandError(int);
00056    void commandConnected();
00057    void dataConnected();
00058    void dataReadyRead();
00059    void dataConnClosed();
00060    void dataError(int);
00061    void dataBytesWritten(int);
00062    void dataPortConnection(int);
00063    void sendNextCommand();
00064 
00065 private:
00066    void resetDataSock();
00067    void sendCommand(QString command);
00068    void parseDirListing(const QString &buf, QUrlInfo &info);
00069    void handleReply(QString reply);
00070    void dataUpload();
00071    int prepareDataSock();
00072 
00073    void replyConnected(QString reply);
00074    void replyLogin(QString reply);
00075    void replyLoginDone(QString reply);
00076    void replyFileAction(QString reply);
00077    void replyPWD(QString reply);
00078    void replyOK(QString reply);
00079    void replyServiceNA(QString reply);
00080    void replyPassiveMode(QString reply);
00081    void replyDataConnOpening(QString reply);
00082    void replyTransferDone(QString reply);
00083    void replySize(QString reply);
00084    void replyDataConnFailed(QString reply);
00085    void reply550(QString reply);
00086    void replyPermDenied(QString reply);
00087 //   void replyRestartAt(QString reply);
00088 
00089    bool waitingReply;
00090    bool waitingFinish;
00091    bool dataOpened;
00092    unsigned int transferSize;
00093    unsigned int transferBytes;
00094    unsigned int transferOffset;
00095    QTime transferStart;
00096    QString nextOp;
00097    QFile targetFile;
00098    NServerSocket *dataServerSock;
00099    std::queue<QString> commandQ;
00100 };
00101 
00102 #endif // NFTP_H

Generated on Wed Oct 22 20:32:04 2003 for nvemftp by doxygen1.3