/* Generated by GGZComm/ruby version 0.4 */
/* Protocol 'dots', version '4' */
/* Do NOT edit this file! */

#ifndef GGZCOMM_DOTS_H
#define GGZCOMM_DOTS_H

#include <qobject.h>

class KGGZRaw;

class dotsOpcodes
{
	public:
	enum Opcode
	{
		message_reqsync = 2,
		message_reqnewgame = 4,
		message_sndmoveh = 0,
		message_sndmovev = 1,
		message_sndoptions = 3,
		message_msgseat = 0,
		message_msgplayers = 1,
		message_msgmoveh = 2,
		message_msgmovev = 3,
		message_msggameover = 4,
		message_reqmove = 5,
		message_rspmove = 6,
		message_sndsync = 7,
		message_msgoptions = 8,
		message_reqoptions = 9
	};

	enum MoveFailed
	{
		err_none = 0,
		err_state = -1,
		err_turn = -2,
		err_bound = -3,
		err_full = -4
	};
};

class msg
{
	public:
	msg(dotsOpcodes::Opcode type){m_type = type;}
	dotsOpcodes::Opcode type() const{return m_type;}
	private:
	dotsOpcodes::Opcode m_type;
};

class reqsync : public msg
{
	public:
	reqsync() : msg(dotsOpcodes::message_reqsync){}

};

class reqnewgame : public msg
{
	public:
	reqnewgame() : msg(dotsOpcodes::message_reqnewgame){}

};

class sndmoveh : public msg
{
	public:
	sndmoveh() : msg(dotsOpcodes::message_sndmoveh){}
	qint8 x;
	qint8 y;
};

class sndmovev : public msg
{
	public:
	sndmovev() : msg(dotsOpcodes::message_sndmovev){}
	qint8 x;
	qint8 y;
};

class sndoptions : public msg
{
	public:
	sndoptions() : msg(dotsOpcodes::message_sndoptions){}
	qint8 width;
	qint8 height;
};

class msgseat : public msg
{
	public:
	msgseat() : msg(dotsOpcodes::message_msgseat){}
	int seat;
};

class msgplayers : public msg
{
	public:
	msgplayers() : msg(dotsOpcodes::message_msgplayers){}
	int seat[2];
	QString player[2];
	int i1;
};

class msgmoveh : public msg
{
	public:
	msgmoveh() : msg(dotsOpcodes::message_msgmoveh){}
	qint8 nx;
	qint8 ny;
	qint8 s;
	qint8 x[100];
	qint8 y[100];
	int i1;
};

class msgmovev : public msg
{
	public:
	msgmovev() : msg(dotsOpcodes::message_msgmovev){}
	qint8 nx;
	qint8 ny;
	qint8 s;
	qint8 x[100];
	qint8 y[100];
	int i1;
};

class msggameover : public msg
{
	public:
	msggameover() : msg(dotsOpcodes::message_msggameover){}
	qint8 winner;
};

class reqmove : public msg
{
	public:
	reqmove() : msg(dotsOpcodes::message_reqmove){}

};

class rspmove : public msg
{
	public:
	rspmove() : msg(dotsOpcodes::message_rspmove){}
	qint8 status;
	qint8 s;
	qint8 x[100];
	qint8 y[100];
	int i1;
};

class sndsync : public msg
{
	public:
	sndsync() : msg(dotsOpcodes::message_sndsync){}
	qint8 turn;
	int score0;
	int score1;
};

class msgoptions : public msg
{
	public:
	msgoptions() : msg(dotsOpcodes::message_msgoptions){}
	qint8 width;
	qint8 height;
};

class reqoptions : public msg
{
	public:
	reqoptions() : msg(dotsOpcodes::message_reqoptions){}

};

class dots : public QObject
{
	Q_OBJECT
	public:
	dots();
        ~dots();
	void ggzcomm_network_main();

	void ggzcomm_reqsync(const reqsync& message);
	void ggzcomm_reqnewgame(const reqnewgame& message);
	void ggzcomm_sndmoveh(const sndmoveh& message);
	void ggzcomm_sndmovev(const sndmovev& message);
	void ggzcomm_sndoptions(const sndoptions& message);

	void ggzcomm_set_fd(int usefd);
	void ggzcomm_set_socket(KGGZRaw *useraw);

	signals:
	void signalNotification(dotsOpcodes::Opcode messagetype, const msg& message);
	void signalError();

	private:
	void handle(bool ret);
	void ggzcomm_msgseat();
	void ggzcomm_msgplayers();
	void ggzcomm_msgmoveh();
	void ggzcomm_msgmovev();
	void ggzcomm_msggameover();
	void ggzcomm_reqmove();
	void ggzcomm_rspmove();
	void ggzcomm_sndsync();
	void ggzcomm_msgoptions();
	void ggzcomm_reqoptions();

	int fd;
	int ret;
	int requirelink;
	int nextlink;
	KGGZRaw *raw;
};

#endif

