/***************************************************************************
 *   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 LIBEVADEFINES_H
#define LIBEVADEFINES_H
    

/**
 * define all constants for eva use */

static const unsigned char login_23_51[]= {
			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
			0x00, 0x00, 0x00, 0x00, 0x9a, 0x93, 0xfe, 0x85,
			0xd3, 0xd9, 0x2a, 0x41, 0xc8, 0x0d, 0xff, 0xb6,
			0x40, 0xb8, 0xac, 0x32, 0x01 
			};    
    
/** bytes from 53 to  68,  used in login request  */
static const unsigned char login_53_68 []= {
			0x82, 0x2A, 0x91, 0xFD, 0xA5, 0xCA, 0x67, 0x4C,
			0xAC, 0x81, 0x1F, 0x6F, 0x52, 0x05, 0xA7, 0xBF
			};      

/**  eva, URL of applying free qq acount */
static const char QQ_APPLY_FREE_NUMBER_URL[] = "http://freeqq2.qq.com/1.shtml";


/** udp  */
static const int QQ_LOGIN_UDP = 0;
/** tcp */
static const int QQ_LOGIN_TCP = 1;

/** QQ UDP packet header length*/
const int QQ_UDP_HEADER_LENGTH = 7;
/** QQ TCP packet header length */
const int QQ_TCP_HEADER_LENGTH = 9;
/** QQ packet tail length*/
const int QQ_TAIL_LENGTH = 1;

/**  the number of send times*/ 
const int QQ_ACK_PACKET_SEND_TIME = 4;


/** QQ packet maximum size*/
const int MAX_PACKET_SIZE = 65535;
/** the maximum bytes to send at once*/
const int MAX_SEND_IM_SIZE = 400;
/**  QQ key length*/
const int QQ_KEY_LENGTH = 16;
/** QQ login data  length */
const int QQ_LOGIN_DATA_LENGTH = 69;

/** QQ default encoding */
const short QQ_IM_ENCODING_GB = 0x8602;

/** packet queue time out */
const long QQ_SENDQUEUE_TIMEOUT = 5000;
/** the times of maximum re-send a packet */
const int QQ_RESEND_MAX = 5;
/** Keep Alive time interval   unit: ms */
const unsigned long QQ_KEEP_ALIVE_INTERVAL = 60000;

const int QQ_MAX_GROUP_NAME_BYTE = 16;
const int QQ_NAME_LENGTH_MAX = 250;
const int QQ_MSG_IM_MAX = 1500;
const int QQ_CONTACT_FIELDS = 37;
const int QQ_REMARK_FIELDS = 7;

/**  client GB QQ2000c build 630 */
const short QQ_CLIENT_062E = 0x062E;
/** client En QQ2000c build 305 */
const short QQ_CLIENT_072E = 0x072E;
/** client En QQ2000c build 630 */
const short QQ_CLIENT_0801 = 0x0801;
/** client Gb QQ2003c build 0808 */
const short QQ_CLIENT_0A1D = 0x0A1D;
/** client Gb QQ2003c build 0925 */
const short QQ_CLIENT_0B07 = 0x0B07;
/** client GB QQ2003iii build 0117 */
const short QQ_CLIENT_0B2F = 0x0B2f;
/** GB QQ2003iii build 0304 (offical release) */
const short QQ_CLIENT_0B35 = 0x0B35;
/** QQ20003  */
const short QQ_CLIENT_0B37 = 0x0B37;
/** QQ2004 */
const short QQ_CLIENT_0C0B = 0x0C0B;
/** QQ2004 preview*/
const short QQ_CLIENT_0C0D = 0x0C0D;
/** QQ server  number*/
const short QQ_SERVER_0100 = 0x0100;

/**  default client version*/
const short QQ_CLIENT_VERSION = QQ_CLIENT_0B37;
/**  qq header tag*/
const unsigned char QQ_PACKET_TAG = 0x02;
/** QQ tail byte*/
const unsigned char QQ_PACKET_TAIL = 0x03;

const unsigned char QQ_LOGIN_MODE_NORMAL = 0x0A;
const unsigned char QQ_LOGIN_MODE_INVISIBLE = 0x28;

const unsigned char QQ_FRIEND_GENDER_GG = 0x0;
const unsigned char QQ_FRIEND_GENDER_MM = 0x1;

const unsigned char QQ_FRIEND_GENDER_UNKNOWN = 0xFF;

const unsigned char QQ_FRIEND_FLAG_QQ_MEMBER = 0x01;
const unsigned char QQ_FRIEND_FLAG_MOBILE = 0x10;
const unsigned char QQ_FRIEND_FLAG_BIND_MOBILE = 0x20;

const unsigned char QQ_FRIEND_STATUS_ONLINE = 10;
const unsigned char QQ_FRIEND_STATUS_OFFLINE = 20;
const unsigned char QQ_FRIEND_STATUS_LEAVE = 30;
const unsigned char QQ_FRIEND_STATUS_INVISIBLE = 40;

const int QQ_MISC_STATUS_HAVING_VIDEO = 0x00000001;

const unsigned char QQ_LOGIN_REPLY_OK = 0x00;
const unsigned char QQ_LOGIN_REPLY_REDIRECT = 0x01;
const unsigned char QQ_LOGIN_REPLY_PWD_ERROR = 0x05;
const unsigned char QQ_LOGIN_REPLY_MISC_ERROR = 0x06;

const unsigned char QQ_UPLOAD_GROUP_FRIEND_OK = 0x00;
const unsigned char QQ_UPLOAD_FRIEND_REMARK_OK = 0x00;
const unsigned char QQ_CHANGE_STATUS_REPLY_OK = 0x30;

const unsigned char QQ_SEND_IM_REPLY_OK = 0x00;

const unsigned char QQ_ADD_FRIEND_AUTH_REPLY_OK = 0x30;
const unsigned char QQ_DELETE_FRIEND_REPLY_OK = 0x00;
const unsigned char QQ_DELETE_ME_REPLY_OK = 0x00;

const unsigned char QQ_REQUEST_KEY_REPLY_OK = 0x00;

const short QQ_FRIEND_LIST_POSITION_START = 0x0000;
const short QQ_FRIEND_LIST_POSITION_END = 0xFFFF;
const char QQ_FRIEND_ONLINE_LIST_POSITION_START = 0x00;
const char QQ_FRIEND_ONLINE_LIST_POSITION_END = 0xFF; 
const unsigned char QQ_FRIEND_LIST_UNSORTED = 0;
const unsigned char QQ_FRIEND_LIST_SORTED = 1;


/* QQ commands */
const short QQ_CMD_LOGOUT = 0x0001;
const short QQ_CMD_KEEP_ALIVE = 0x0002;
const short QQ_CMD_MODIFY_INFO = 0x0004;
const short QQ_CMD_SEARCH_USER = 0x0005;
const short QQ_CMD_GET_USER_INFO = 0x0006;
const short QQ_CMD_ADD_FRIEND = 0x0009;
const short QQ_CMD_DELETE_FRIEND = 0x000A;
const short QQ_CMD_ADD_FRIEND_AUTH = 0x000B;
const short QQ_CMD_CHANGE_STATUS = 0x000D;
const short QQ_CMD_ACK_SYS_MSG = 0x0012;
const short QQ_CMD_SEND_IM = 0x0016;
const short QQ_CMD_RECV_IM = 0x0017;
const short QQ_CMD_DELETE_ME = 0x001C;
const short QQ_CMD_REQUEST_KEY = 0x001D;
const short QQ_CMD_CELL_PHONE_1 = 0x0021;
const short QQ_CMD_LOGIN = 0x0022;
const short QQ_CMD_GET_FRIEND_LIST = 0x0026;
const short QQ_CMD_GET_FRIEND_ONLINE = 0x0027;
const short QQ_CMD_CELL_PHONE_2 = 0x0029;
const short QQ_CMD_CLUSTER_CMD = 0x0030;
const short QQ_CMD_TEST = 0x0031;
const short QQ_CMD_GROUP_NAME_OP = 0x003C;
const short QQ_CMD_UPLOAD_GROUP_FRIEND = 0x003D;
const short QQ_CMD_FRIEND_REMARK_OP = 0x003E;
const short QQ_CMD_DOWNLOAD_GROUP_FRIEND = 0x0058;
const short QQ_CMD_RECV_MSG_SYS = 0x0080;
const short QQ_CMD_RECV_MSG_FRIEND_CHANGE_STATUS = 0x0081;

const unsigned char QQ_REQUEST_UNKNOWN_KEY = 0x3;


const unsigned char QQ_IM_NORMAL_REPLY = 0x01;
const unsigned char QQ_IM_AUTO_REPLY = 0x02;

/* group operation commands */
const unsigned char QQ_UPLOAD_GROUP_NAME = 0x2;
const unsigned char QQ_DOWNLOAD_GROUP_NAME = 0x1;

/* remark operation commands */
const unsigned char QQ_UPLOAD_FRIEND_REMARK = 0x1;
const unsigned char QQ_DOWNLOAD_FRIEND_REMARK = 0x3;

/* used in download grouped friends */
const unsigned char QQ_ID_IS_FRIEND = 0x1;
const unsigned char QQ_ID_IS_CLUSTER = 0x4;

/** types of received message */
const short QQ_RECV_IM_TO_BUDDY = 0x0009;
const short QQ_RECV_IM_TO_UNKNOWN = 0x000A;
/** message from Qun */
const short QQ_RECV_IM_CLUSTER_IM = 0x0020;
const short QQ_RECV_IM_ADDED_TO_CLUSTER = 0x0021;
const short QQ_RECV_IM_DELETED_FROM_CLUSTER = 0x0022;
const short QQ_RECV_IM_REQUEST_JOIN_CLUSTER = 0x0023;
const short QQ_RECV_IM_APPROVE_JOIN_CLUSTER = 0x0024;
const short QQ_RECV_IM_REJECT_JOIN_CLUSTER = 0x0025;
const short QQ_RECV_IM_CREATE_CLUSTER = 0x0026;
const short QQ_RECV_IM_SYS_MESSAGE = 0x0030;
const short QQ_RECV_IM_KICK_OUT = 0x0001;

/* sub types of QQ_RECV_IM_TO_BUDDY */
const short QQ_IM_NORMAL_TEXT = 0x000B;
const short QQ_IM_TCP_REQUEST = 0x0001;
const short QQ_IM_ACCEPT_TCP_REQUEST = 0x0003;
const short QQ_IM_REJECT_TCP_REQUEST = 0x0005;
const short QQ_IM_UDP_REQUEST = 0x0035;
const short QQ_IM_ACCEPT_UDP_REQUEST = 0x0037;
const short QQ_IM_REJECT_UDP_REQUEST = 0x0039;
const short QQ_IM_NOTIFY_IP = 0x003B;
const short QQ_IM_ARE_YOU_BEHIND_FIREWALL = 0x003F;
const short QQ_IM_ARE_YOU_BEHIND_PROXY = 0x0041;
const short QQ_IM_YES_I_AM_BEHIND_PROXY = 0x0042;
const short QQ_IM_NOTIFY_FILE_AGENT_INFO = 0x004B;
const short QQ_IM_REQUEST_CANCELED = 0x0049;

/** authorization */
const unsigned char QQ_AUTH_NO_AUTH = 0;
const unsigned char QQ_AUTH_NEED_AUTH = 1;
const unsigned char QQ_AUTH_NO_ADD = 2;

const unsigned char QQ_MY_AUTH_APPROVE = 0x30;
const unsigned char QQ_MY_AUTH_REJECT = 0x31;
const unsigned char QQ_MY_AUTH_REQUEST = 0x32;

const int QQ_CONTACT_OPEN = 0;
const int QQ_CONTACT_ONLY_FRIENDS = 1;
const int QQ_CONTACT_CLOSE = 2;

const short QQ_MSG_SYS_BEING_ADDED = 1;
const short QQ_MSG_SYS_ADD_FRIEND_REQUEST = 2;
const short QQ_MSG_SYS_ADD_FRIEND_APPROVED = 3;
const short QQ_MSG_SYS_ADD_FRIEND_REJECTED = 4;
const short QQ_MSG_SYS_UPDATE_HINT = 9;

const unsigned char QQ_SEARCH_ALL = 0x31;
const unsigned char QQ_SEARCH_CUSTOM = 0x30;

#endif
