⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 evaqun.cpp

📁 linux下的eva源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
QunSearchPacket::QunSearchPacket()	: QunPacket(QQ_QUN_CMD_SEARCH_QUN), 	type(QQ_SEARCH_QUN_BY_ID){}QunSearchPacket::QunSearchPacket( int type )	: QunPacket(QQ_QUN_CMD_SEARCH_QUN){	this->type = type;}QunSearchPacket::QunSearchPacket( const QunSearchPacket & rhs )	: QunPacket(rhs){	*this = rhs;}QunSearchPacket & QunSearchPacket::operator =( const QunSearchPacket & rhs ){	*((QunPacket *)this) = (QunPacket)rhs;	type = rhs.getSearchType();	externalID = rhs.getExtID();	return *this;}int QunSearchPacket::putBody( unsigned char * buf ){	int pos=0;	buf[pos++] = qunCommand; // qun command	buf[pos++] = type;       // qun type		int tmp4;	if(type == QQ_SEARCH_DEMO_QUN){		memset(buf+pos, 0, 4);	}else{		tmp4 = htonl(externalID);		memcpy(buf+pos, &tmp4, 4);	}	pos+=4;	return pos;	}/***************************************************************************************************************/ QunJoinPacket::QunJoinPacket(const unsigned int id)	: QunPacket(QQ_QUN_CMD_JOIN_QUN, id){}QunJoinPacket::QunJoinPacket(const QunJoinPacket &rhs)	: QunPacket(rhs){}QunJoinPacket::~QunJoinPacket(){}int QunJoinPacket::putBody(unsigned char *buf){	buf[0] = qunCommand;	int tmp4 = htonl(qunID);	memcpy(buf + 1, &tmp4, 4);	return 5;}/***************************************************************************************************************/ QunModifyPacket::QunModifyPacket( const QunInfo & inf )	: QunPacket( QQ_QUN_CMD_MODIFY_QUN_INFO, inf.getQunID()){	info = inf;}QunModifyPacket::QunModifyPacket( const QunModifyPacket & rhs )	: QunPacket(rhs){	info = rhs.getQunInfo();}QunModifyPacket & QunModifyPacket::operator =( const QunModifyPacket & rhs ){	*( (QunPacket*)this) = (QunPacket)rhs;	info = rhs.getQunInfo();	return *this;}int QunModifyPacket::putBody( unsigned char * buf ){	int pos=0;		buf[pos++] = qunCommand;		int tmp4 = htonl(info.getQunID());	memcpy(buf + pos, &tmp4, 4);	pos+=4;		buf[pos++] = 0x01;  // dose this byte means permenant Qun or some thing?		buf[pos++] = info.getAuthType();		memset(buf+pos, 0, 6);  // 6 bytes 0x00 s	pos+=6;		unsigned short tmp2;	tmp2 = htons(info.getCategory());	memcpy(buf+pos, &tmp2, 2);	pos+=2;		buf[pos++] = info.getName().length() & 0xff;		memcpy(buf+pos, info.getName().c_str(), buf[pos - 1]);	pos+= buf[pos - 1];		memset(buf+pos, 0, 2);	pos+=2;		buf[pos++] = info.getNotice().length() & 0xff;	memcpy(buf+pos, info.getNotice().c_str(), buf[pos - 1]);	pos+= buf[pos - 1];		buf[pos++] = info.getDescription().length() & 0xff;	memcpy(buf+pos, info.getDescription().c_str(), buf[pos - 1]);	pos+= buf[pos - 1];		return pos;}/***************************************************************************************************************/ QunModifyCardPacket::QunModifyCardPacket( const unsigned int qunID, const unsigned int qqID )	: QunPacket(QQ_QUN_CMD_MODIFY_CARD, qunID), qqNum(qqID){}QunModifyCardPacket::QunModifyCardPacket( const QunModifyCardPacket & rhs )	: QunPacket(rhs){	*this = rhs;}QunModifyCardPacket & QunModifyCardPacket::operator =( const QunModifyCardPacket & rhs ){	*((QunPacket *)this) = (QunPacket)rhs;	qqNum = rhs.getQQ();	name = rhs.getName();	gender = rhs.getGender();	phone = rhs.getPhone();	email = rhs.getEmail();	memo  = rhs.getMemo();	return *this;}int QunModifyCardPacket::putBody( unsigned char * buf ){	int pos=0;		buf[pos++] = qunCommand;		int tmp4 = htonl(qunID);	memcpy(buf + pos, &tmp4, 4);	pos+=4;		tmp4 = htonl(qqNum);	memcpy(buf + pos, &tmp4, 4);	pos+=4;		buf[pos++] = name.length() & 0xff;	memcpy(buf+pos, name.c_str(), buf[pos-1]);	pos+= buf[pos-1];		buf[pos++]=gender;		buf[pos++] = phone.length() & 0xff;	memcpy(buf+pos, phone.c_str(), buf[pos-1]);	pos+= buf[pos-1];		buf[pos++] = email.length() & 0xff;	memcpy(buf+pos, email.c_str(), buf[pos-1]);	pos+= buf[pos-1];	buf[pos++] = memo.length() & 0xff;	memcpy(buf+pos, memo.c_str(), buf[pos-1]);	pos+= buf[pos-1];		return pos;}/***************************************************************************************************************/ QunAdminOpPacket::QunAdminOpPacket( const int id, const int qqID, const bool isSetAdmin )	: QunPacket(QQ_QUN_CMD_ADMIN, id){	qqNum = qqID;	if(isSetAdmin)		action = QQ_QUN_SET_ADMIN;	else		action = QQ_QUN_UNSET_ADMIN;}QunAdminOpPacket::QunAdminOpPacket( const QunAdminOpPacket & rhs )	: QunPacket(rhs){	*this = rhs;}QunAdminOpPacket & QunAdminOpPacket::operator =( const QunAdminOpPacket & rhs ){	*((QunPacket *)this) = (QunPacket)rhs;	qqNum = rhs.getQQ();	action = rhs.getActionCode();	return *this;}int QunAdminOpPacket::putBody( unsigned char * buf ){	int pos=0;		buf[pos++] = qunCommand;		int tmp4 = htonl(qunID);	memcpy(buf + pos, &tmp4, 4);	pos+=4;		tmp4 = htonl(qqNum);	memcpy(buf + pos, &tmp4, 4);	pos+=4;		buf[pos++] = action;		return pos;}/***************************************************************************************************************/QunTransferPacket::QunTransferPacket( const unsigned int id, const unsigned int qqID )	: QunPacket(QQ_QUN_CMD_TRANSFER, id), qqNum(qqID){}QunTransferPacket::QunTransferPacket( const QunTransferPacket & rhs )	: QunPacket(rhs){	*this = rhs;}QunTransferPacket & QunTransferPacket::operator =( const QunTransferPacket & rhs ){	*((QunPacket *)this) = (QunPacket)rhs;	qqNum = rhs.getQQ();	return *this;}int QunTransferPacket::putBody( unsigned char * buf ){	int pos=0;		buf[pos++] = qunCommand;		int tmp4 = htonl(qunID);	memcpy(buf + pos, &tmp4, 4);	pos+=4;		tmp4 = htonl(qqNum);	memcpy(buf + pos, &tmp4, 4);	pos+=4;	return pos;}/***************************************************************************************************************/QunModifyMemberPacket::QunModifyMemberPacket( const unsigned int id, const bool isAdd )	: QunPacket(QQ_QUN_CMD_MODIFY_MEMBER, id), mIsAdd(isAdd){}QunModifyMemberPacket::QunModifyMemberPacket( const QunModifyMemberPacket & rhs )	: QunPacket(rhs){	*this = rhs;}QunModifyMemberPacket &QunModifyMemberPacket::operator=(const QunModifyMemberPacket &rhs){	*((QunPacket *)this) = (QunPacket)rhs;	mIsAdd = rhs.isAdd();	members = rhs.getMembers();	return *this;	}int QunModifyMemberPacket::putBody( unsigned char * buf ){	int pos=0;		buf[pos++] = qunCommand;		unsigned int tmp4 = htonl(qunID);	memcpy(buf + pos, &tmp4, 4);	pos+=4;		if(mIsAdd)		buf[pos++] = QQ_QUN_MEMBER_ADD;	else		buf[pos++] = QQ_QUN_MEMBER_REMOVE;		std::list<unsigned int>::iterator iter;	for(iter=members.begin(); iter!= members.end(); ++iter){		tmp4 = htonl(*iter);		memcpy(buf + pos, &tmp4, 4);		pos+=4;			}	return pos;}/***************************************************************************************************************/short QunSendIMExPacket::messageID = 0;QunSendIMExPacket::QunSendIMExPacket( const unsigned int id )	: QunSendIMPacket(id){	qunCommand = QQ_QUN_CMD_SEND_IM_EX;	numFragments = 1;	seqFragments = 0;	messageID++;}QunSendIMExPacket::QunSendIMExPacket(const QunSendIMExPacket &rhs)	: QunSendIMPacket(rhs){	*this = rhs;}QunSendIMExPacket & QunSendIMExPacket::operator =( const QunSendIMExPacket & rhs ){	*((QunSendIMPacket *)this) = (QunSendIMPacket)rhs;	numFragments = rhs.getNumFragments();	seqFragments = rhs.getSeqOfFragments();	messageID = rhs.getMessageID();	return *this;}int QunSendIMExPacket::putBody( unsigned char * buf ){	int pos=0;	buf[pos++] = qunCommand; // qun command		unsigned int tmp4 = htonl(qunID);	memcpy(buf+pos, &tmp4, 4); // qun internal ID	pos+=4;		int lenPos = pos;  // we record the index of the length of following contents, it takes 2 bytes	pos+=2; 		unsigned short tmp2 = htons(2); // luma said 0001 means pure text, 0002 represents text with customized picture	memcpy(buf+pos, &tmp2, 2); pos+=2;		buf[pos++] = numFragments;	buf[pos++] = seqFragments;		tmp2 = htons(messageID);	memcpy(buf+pos, &tmp2, 2); pos+=2;		memset(buf+pos, 0, 4); pos+=4;  // 4 unknown bytes		std::string str2send = EvaUtil::convertToSend(message);	memcpy(buf+pos, str2send.c_str(), str2send.length());	pos += str2send.length();		if(numFragments == seqFragments + 1){		//now we can set the length of message and font name;		unsigned short tmp2 = htons((short)(pos - lenPos -2 + fontName.length() + 10));		memcpy(buf + lenPos, &tmp2, 2);				buf[pos++] = 0x20; //  a space		buf[pos++] = 0x00;    //  C style string terminator				buf[pos++] = fontFlag;		buf[pos++] = red;		buf[pos++] = green;		buf[pos++] = blue;				buf[pos++] = 0;				unsigned short tmpEncoding = htons(encoding);  // encoding for text		memcpy(buf+pos,&tmpEncoding, 2);		pos+=2;				int len = fontName.length();     // font name		memcpy(buf+pos, fontName.c_str(), len);		pos+=len;				buf[pos++] = (unsigned char)(len + 9); 	}else{		short tmp2 = htons((short)(10 + str2send.length()));		memcpy(buf + lenPos, &tmp2, 2); pos+=2;	}// 	printf("before encrypted\n");// 	for(int i=0; i<pos; i++){// 		if(!(i%8)) printf("\n%d: ",i);// 		char t = buf[i];// 		printf("%2x ", (uint8_t)t);// 	}// 	printf("\n");	return pos;}/***************************************************************************************************************/QunRequestCardPacket::QunRequestCardPacket( const unsigned int qunID, const unsigned int qqID )	: QunPacket(QQ_QUN_CMD_REQUEST_CARD, qunID), qqNum(qqID){}QunRequestCardPacket::QunRequestCardPacket( const QunRequestCardPacket & rhs )	: QunPacket(rhs){	*this = rhs;}QunRequestCardPacket & QunRequestCardPacket::operator =( const QunRequestCardPacket & rhs ){	*((QunPacket *)this) = (QunPacket)rhs;	qqNum = rhs.getQQ();	return *this;}int QunRequestCardPacket::putBody( unsigned char * buf ){	int pos=0;		buf[pos++] = qunCommand;		unsigned int tmp4 = htonl(qunID);	memcpy(buf + pos, &tmp4, 4); pos+=4;		tmp4 = htonl(qqNum);	memcpy(buf + pos, &tmp4, 4); pos+=4;		return pos;}/***************************************************************************************************************/QunExitPacket::QunExitPacket( const unsigned int id )	: QunPacket(QQ_QUN_CMD_EXIT_QUN, id){}QunExitPacket::QunExitPacket( const QunExitPacket & rhs )	: QunPacket(rhs){	*this = rhs;}QunExitPacket & QunExitPacket::operator =( const QunExitPacket & rhs ){	*((QunPacket *)this) = (QunPacket)rhs;	return *this;}int QunExitPacket::putBody( unsigned char * buf ){	int pos=0;		buf[pos++] = qunCommand;		unsigned int tmp4 = htonl(qunID);	memcpy(buf + pos, &tmp4, 4); pos+=4;		return pos;}/***************************************************************************************************************/QunCreatePacket::QunCreatePacket( const std::string &name, const unsigned short category, 				const unsigned char auth)	: QunPacket(QQ_QUN_CMD_CREATE_QUN), qunAuth(auth), qunCategory(category),	 qunName(name), qunNotice(""), qunDescription(""){}QunCreatePacket::QunCreatePacket( const QunCreatePacket & rhs )	: QunPacket(rhs){	*this = rhs;	}QunCreatePacket & QunCreatePacket::operator =( const QunCreatePacket & rhs ){	*((QunPacket *)this) = (QunPacket)rhs;	qunName = rhs.getName();	qunCategory = rhs.getCategory();	qunAuth = rhs.getAuth();	qunNotice = rhs.getNotice();	qunDescription = rhs.getDescription();	qunMembers = rhs.getMembers();	return *this;}int QunCreatePacket::putBody( unsigned char * buf ){	int pos=0;		buf[pos++] = qunCommand;		buf[pos++] = QQ_QUN_TYPE_PERMANENT; 		buf[pos++] = qunAuth;		memset(buf+pos, 0, 6);  // 6 bytes 0x00 s	pos+=6;		unsigned short tmp2;	tmp2 = htons(qunCategory);	memcpy(buf+pos, &tmp2, 2);	pos+=2;		buf[pos++] = qunName.length() & 0xff;		memcpy(buf+pos, qunName.c_str(), buf[pos - 1]);	pos+= buf[pos - 1];		memset(buf+pos, 0, 2);	pos+=2;		buf[pos++] = qunNotice.length() & 0xff;	memcpy(buf+pos, qunNotice.c_str(), buf[pos - 1]);	pos+= buf[pos - 1];		buf[pos++] = qunDescription.length() & 0xff;	memcpy(buf+pos, qunDescription.c_str(), buf[pos - 1]);	pos+= buf[pos - 1];		unsigned int tmp4;	std::list<unsigned int>::iterator iter;	for(iter=qunMembers.begin(); iter!= qunMembers.end(); ++iter){		if(*iter == getQQ()) continue;		tmp4 = htonl(*iter);		memcpy(buf + pos, &tmp4, 4);		pos+=4;			}		return pos;}/***************************************************************************************************************/QunActivePacket::QunActivePacket( const unsigned int id )	: QunPacket(QQ_QUN_CMD_ACTIVATE_QUN, id){}QunActivePacket::QunActivePacket( const QunActivePacket & rhs )	: QunPacket(rhs){	*this = rhs;}QunActivePacket & QunActivePacket::operator =( const QunActivePacket & rhs ){	*((QunPacket *)this) = (QunPacket)rhs;	return *this;}int QunActivePacket::putBody( unsigned char * buf ){	int pos=0;		buf[pos++] = qunCommand;		unsigned int tmp4 = htonl(qunID);	memcpy(buf + pos, &tmp4, 4); pos+=4;		return pos;}/***************************************************************************************************************/QunRequestAllRealNames::QunRequestAllRealNames( const unsigned int id )	: QunPacket(QQ_QUN_CMD_REQUEST_ALL_REALNAMES, id),	m_StartIndex(0){}QunRequestAllRealNames::QunRequestAllRealNames( const QunRequestAllRealNames & rhs )	: QunPacket(rhs),	m_StartIndex(0){	*this = rhs;}QunRequestAllRealNames & QunRequestAllRealNames::operator =( const QunRequestAllRealNames & rhs ){	*((QunPacket *)this) = (QunPacket)rhs;	m_StartIndex = rhs.getStartIndex();	return *this;}int QunRequestAllRealNames::putBody( unsigned char * buf ){	int pos=0;		buf[pos++] = qunCommand;		pos+=EvaUtil::write32( buf + pos, qunID);	pos+=EvaUtil::write32( buf + pos, 0);	pos+=EvaUtil::write32( buf + pos, m_StartIndex);		return pos;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -