/***************************************************************************
 *   Copyright (C) 2004 by yunfan                                          *
 *   yunfan_zg@163.com                                                     *
 *                                                                         *
 *   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.             *
 ***************************************************************************/

#ifndef LIBEVAIMSEND_H
#define LIBEVAIMSEND_H

#include "evapacket.h"
#include "evautil.h"
#include <string>

// note that all text in SendIMPacket class is assumed as
//  encoded in locale "GBK"
class SendIM : public OutPacket
{
public:
	SendIM() {}
	SendIM(short type);
	SendIM(const SendIM &rhs) ;
	virtual ~SendIM() {}
		
	const int getReceiver() const { return receiver; };                       // your friend's qq number
	void setReceiver(int receiver) { this->receiver = receiver; }
	
	const char getFaceCode() const { return face; }
	void setFaceCode(char face) { this->face = face; }                      // set my face code	
	
	const short getContentType() const  { return contentType; }
	SendIM &operator=(const SendIM &rhs);
protected:
	virtual int putBody(unsigned char *buf);
	virtual int putContents(unsigned char *buf);
private:	
	int receiver; 
	char face;
	short contentType;    
};


class SendTextIMPacket : public SendIM
{
public:
	SendTextIMPacket();
	SendTextIMPacket(const SendTextIMPacket &rhs) ;
	virtual ~SendTextIMPacket() {}

	
	OutPacket * copy() { return new SendTextIMPacket(*this);}
	SendTextIMPacket &operator=(const SendTextIMPacket &rhs);
	
	const std::string &getFontName() const { return fontName; }               // font setting
	void setFontName(std::string &fontName) { this->fontName = fontName; }
	const char getFontSize() const { return fontSize; }
	void setFontSize(char fontSize); 
	const short getEncoding() const { return encoding; }
	void setEncoding(short encoding) { this->encoding = encoding; }

	const bool isUnderline() const { return underline;}                      // U B I setting
	void setUnderline(bool underline) ;
	const bool isItalic() const { return italic; }
	void setItalic(bool italic);
	const bool isBold() const { return bold; };
	void setBold(bool bold);
	
	const char getBlue() const { return blue; }                         // color setting
	void setBlue(char blue) { this->blue = blue; }
	const char getGreen() const { return green; }
	void setGreen(char green)  {this->green = green; }
	const char getRed() const { return red; }
	void setRed(char red) { this->red = red; }
	
	/*
	      the message is plain text, which means the smiley code is already
	      replaced with plain text.  
	*/
	const std::string &getMessage() const { return message; }              // message you want to send
	void setMessage(std::string message) { this->message = message; }   // and just put your plain text message here
	const char getReplyType() const { return replyType; }
	void setReplyType(char replyType) { this->replyType = replyType; }
	void setAutoReply(const bool isNormal);
		
	
protected:
	virtual int putContents(unsigned char *buf);
private:
	std::string convertToSend(const std::string &text);
	short encoding;
	std::string fontName;
	char red, green, blue;
	bool bold, italic, underline;
	unsigned char fontSize;
	unsigned char fontFlag; 
	   
	std::string message; 
	char replyType;
	EvaUtil util;
	
};

class SendIMReplyPacket : public InPacket
{
public:
	SendIMReplyPacket() {};
	SendIMReplyPacket(unsigned char *buf, int len);
	SendIMReplyPacket(const SendIMReplyPacket &rhs );
	virtual ~SendIMReplyPacket() {}
	
	const char getReplyCode() const { return replyCode; };
	const bool isSentOK() const ;
	
	SendIMReplyPacket &operator=(const SendIMReplyPacket &rhs );

protected:
	virtual void parseBody();
private: 
	char replyCode;
};

#endif

