#ifndef _H_CNETDCC
#define _H_CNETDCC

class CNetDCC;

#include "mbot.h"

enum dcc_type {
  DCC_STOP,			// nothing set, exit
  DCC_SEND_INIT,		// socket and file open for dcc send
  DCC_SEND,			// dcc send active
  DCC_CHAT_INIT,		// open socket for dcc chat
  DCC_CHAT_AUTH,		// ask password in chat
  DCC_CHAT			// dcc chat active
};

class CNetDCC : public CNet {
public:
  CNetDCC (CNetServer *, const char *, int, int);
  ~CNetDCC (void);

  void dcc_error (const char *);
  bool dcc_chat_start (void);
  bool dcc_send_start (const char *);
  void dcc_start_check (void);
  void dcc_chat_write (const char *);
  void dcc_chat_pass (void);
  void dcc_chat (void);
  void dcc_send (void);
  void dcc_stop (void);
  bool dcc_work (void);
  char *dcc_make_ctcp_chat (char *, size_t);
  char *dcc_make_ctcp_send (char *, size_t);

  char nick[NICK_SIZE+1];		// nick from the given mask
  CString mask;				// mask of who made the dcc
  dcc_type status;			// dcc status
  int index;				// this dcc's table index
  int dcc_from_index;	// index of dcc where _this_ dcc was started
  			// -1 if it was on a pvt

private:

  CNetServer *s;			// server to which belongs

  FILE *dfd;
  int filesize;				// total file size
  int filesent;				// number of bytes sent
  int socklocal, sockremote;
  time_t last_time;			// time of last change
  CString filename;			// name of file to send
  char dcc_buf[DCC_BUF_SIZE+1];
  char buf[BUF_SIZE+1];

};

#endif
