/*
    slforum version 1.x - Simple chat room usable via telnet.
    Copyright (C) 1999-2002 Jeremy D. Monin, Dan Chin, Matt Lochansky
	(forum@shadowlands.org).
    Based on jdkchat version 1.3, J.D.Koftinoff Software, Ltd. (GPL'd)

    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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/


#ifndef __SLFORUMCMD_H
#define	__SLFORUMCMD_H


typedef void (SLForumUser::*ptr_slfu_member_func)(const char*);



/*  Use these as examples of how to write good user commands.
 *
 *  See SLForumUser::HandleUserCommand() comments for what
 *  a user command should do, and what values it should return.
 */


class SLForumRoom;
class SLForumUser;


// handy constant for "all" users; the command parser
// returns this as a JDMChatUser * if "all" is a valid target
// for a user (param type 'A')
#define SLF_USER_ALL ( (SLForumUser *) -1 )

// the implementing funcs are called in slforumuser.cc::HandleUserCommand .

// A macro for these declarations (they're very repetitive):
#define _decl_slfcmd_(x) \
	static int	x	\
	  (SLForumRoom *, SLForumUser *, int, slfparam *)

class SLForumCmd
{
public:
	friend class SLForumUser;
	friend class SLForumRoom;

/** return value from a usercmd to HandleUserCmd to always clear the user's
 *  input buffer, even when the line has wrapped; normally, if a command
 *  wraps, the cmdname is placed at the start of the new buffer.
 */
	static const int RVAL_ALWAYS_CLEAR = 4037;

/** Return value to retain the current contents of the buffer, instead of
 *  clearing it if it wasn't wrapped.  This is for commands that set the
 *  contents of the buffer.  If the line's wrapped, the buffer will contain
 *  the commandname followed by what the command put into the buffer.
 */
	static const int RVAL_RETAIN_BUFFER = 5091;

private:
	SLForumCmd ();
	~SLForumCmd();

	// We try to keep these in order of when they were added...
	// keeps featuritis in perspective a little.

	_decl_slfcmd_(c_exit);
	// _decl_slfcmd_(c_local);  // removed 19991031.0606; !zebra local
	_decl_slfcmd_(c_who);
	_decl_slfcmd_(c_away);
	_decl_slfcmd_(c_clear);
	_decl_slfcmd_(c_to);
	_decl_slfcmd_(c_accept);
	_decl_slfcmd_(c_kick);
	_decl_slfcmd_(c_msgchk);
	static bool i_msgchk_check
	  (SLForumUser *me, time_t &newmailt);  // used by c_msgchk, automsgchk
	static void i_msgchk_printmsg
	  (SLForumUser *me, time_t newmailt, bool beep);
	_decl_slfcmd_(c_time);
	_decl_slfcmd_(c_also);
	static int _i_toalso
	  (SLForumRoom *, SLForumUser *, int, slfparam *, bool);
	_decl_slfcmd_(c_ignore);
	_decl_slfcmd_(c_unignore);
	static int _i_ignore
	  (SLForumRoom *, SLForumUser *, const char *, bool);
	_decl_slfcmd_(c_listen);
	_decl_slfcmd_(c_help);
	_decl_slfcmd_(c_banner);
	_decl_slfcmd_(c_beep);
	_decl_slfcmd_(c_toall);
	_decl_slfcmd_(c_roll);
	_decl_slfcmd_(c_printwho);
	_decl_slfcmd_(c_rot13);
        _decl_slfcmd_(c_topic);   
        _decl_slfcmd_(c_comment); 
	_decl_slfcmd_(c_prevtopic);
 	_decl_slfcmd_(c_autowho);     // 19990922.1145 dschin
        _decl_slfcmd_(c_autotopic);
        _decl_slfcmd_(c_users);       // 19991012.0100 dschin
        _decl_slfcmd_(c_showaway);    // 19991012.0100 dschin
        _decl_slfcmd_(c_zebra);
	_decl_slfcmd_(c_here);
	_decl_slfcmd_(c_version);     // 19991108.0045 jer
	_decl_slfcmd_(c_uptime);      // 20020329.0210 jer
        _decl_slfcmd_(c_timer);       // 20000126.1730 matted
#ifdef ALLOW_LOCKOUT
        _decl_slfcmd_(c_lockout);     // 20000607.1730 jer
#endif
        _decl_slfcmd_(c_ban);	      // 20000610.1100 jer
	_decl_slfcmd_(c_admin);	      // 20000613.0000 jer
	_decl_slfcmd_(c_emote);	      // 20000703.1220 jer
#ifdef ALLOW_MACROS
	_decl_slfcmd_(c_macro);	      // 20001012.0130 jer
#endif
	_decl_slfcmd_(c_8ball);	      // 20010917.1710 jer

private:


	// for c_listen, c_ban
	static int i_listmanip
	  (LinkedList* &llist,
	   SLForumRoom *room, SLForumUser *me,
	   int argc, slfparam *flarg,
	   int maxlistsize,
	   ptr_slfu_member_func addlistmethod,
	   const char *listerlabel)
	  ;

	// for c_zebra

	static int _try_num_param
  (SLForumRoom *room, SLForumUser *me, int argc, slfparam *flarg,
   const char *paramname, const char *paramdescname,
   int &val, char *sbuf, int scale=1);

	static int _try_bool_param
  (SLForumRoom *room, SLForumUser *me, int argc, slfparam *flarg,
   const char *paramname, const char *paramdescname,
   bool &val, char *sbuf);

};

#undef _decl_slfcmd_

#endif	// __SLFORUMCMD_H
