#ifndef FTPCLIENT_H
#define FTPCLIENT_H

#include "TCPClient.h"
#include "FTPServer.h"
#include "Dictionary.h"

class FTPClient : public TCPClient
{
  template<typename T>
  friend class FTPServer;
  public:
	FTPClient(WiFiClient client, uint8_t id, uint16_t clientCommandDataBufferSize = 255);
	virtual ~FTPClient();
  protected:
  private:
    FTPClient(const FTPClient &Object) : TCPClient(Object){}
    void setDataClient(WiFiClient dataClient); //Also known as the data socket
    boolean parseCommandAndParameters(void);
    void setUsername(const char *username);
    void setCurrentDirectory(const char *dir);
    void setCurrentFile(const char *file);
    void startTimeout();

    char _ftpCommand[5];
    Dictionary<DictionaryHelper::StringEntity> *_cmdParameters;
    boolean _loggedIn;
    char *_username;
    char *_currentDirectory;
    char *_currentFile;
    uint64_t _fileSentBytes;
    uint64_t _fileRecvBytes;
    boolean _waitingForDataConnection;
    boolean _fileIsBeeingReceived;
    uint64_t _actionTimeout;
    
    FTPServer<FTPClient>::FTPClientState _ftpClientState;
    FTPServer<FTPClient>::BinaryFlag _binaryFlag;
    FTPServer<FTPClient>::FTPClientDataTransfer _dataTransferPending;
    WiFiClient _dataClient; //data socket
};

#endif //FTPCLIENT_H
