/* This file is part of cardwords
   (c) 1999 Tobias Peters
   see file COPYING for the copyright terms.
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

// cardwords_textclient.hh

#ifndef CARDWORDS_TEXTCLIENT_HH
#define CARDWORDS_TEXTCLIENT_HH

/*
  This file contains the text client class CardWords_TextClient,
  a class derived from CardWords_CommClient.
*/
#include "cardwords_commclient.hh"
#include "cardwords_ncursesapp.hh"

class CardWords_TextClient
  : public CardWords_CommClient,
    public CardWords_NCursesApp
{
public:
  CardWords_TextClient(CardWords_Selector *);
  

  ///////////////////////////////////////////////////////////////////////////
  // All the functions from CardWords_CommClient that need to be overwritten:
  ///////////////////////////////////////////////////////////////////////////
  
  // When the state of the connection, the game or other things are changed,
  // this function is called. It should display the changes for the user or
  // do other neat things.
  virtual void
  state_changed(State_Change);


  // Test if the client is compatible with these charset, cardset, table
  // and bonus definitions:
  virtual bool
  test_client_compatible_with_server_settings();

  // The virtual method error() will be called with an Error_Number
  // parameter and should inform the user about that error.
  // The error() method should call disconnect() or
  // CardWords_CommClient::error() before returning to disconnect
  // from the server.
  virtual void
  error (CardWords_CommClient::Error_Number);

  // Functions for registering this object's fd in the selector:
  // call:
  virtual void
  register_reading(void);

  virtual void
  register_writing(void);

  virtual void
  deregister_reading(void);

  // If you want to discard all pending messages, use discard_messages() prior
  // to deregister_writing()
  virtual void
  deregister_writing(void);

  ///////////////////////////////////////////////////////////////////////////
  // All the functions from CardWords_NCursesApp that need to be overwritten:
  ///////////////////////////////////////////////////////////////////////////

  virtual void
  being_selected (int fd, int mode);
  virtual void
  timed_out (int fd, int mode);
  // fd is the registered file descriptor.
  // mode is READ_MODE or WRITE_MODE (or EXCEPTION_MODE).

};
#endif
