Esempio n. 1
0
static void process_sys_im( struct qqclient* qq, qqpacket* p, qqmessage* msg )
{
	bytebuffer *buf = p->buf;
	msg->msg_time = time(NULL);
	uchar content_type;
	content_type = get_byte( buf );
	uchar len = get_byte( buf );
	get_data( buf, (uchar*)msg->msg_content, len );
	msg->msg_content[len] = 0;
	buddy_msg_callback( qq, msg->from, msg->msg_time, msg->msg_content );
	if( strstr( msg->msg_content, "另一地点登录" ) != NULL ){
		qqclient_set_process( qq, P_BUSY );
	}else{
		qqclient_set_process( qq, P_ERROR );
	}
	DBG("sysim(type:%x): %s", content_type, msg->msg_content );
}
Esempio n. 2
0
static void process_buddy_im_text( struct qqclient* qq, qqpacket* p, qqmessage* msg )
{
	bytebuffer *buf = p->buf;
	char tmp[MSG_CONTENT_LEN];
	get_word( buf );	//session id
	msg->msg_time = get_int( buf );
	get_word( buf );	//face
	buf->pos += 4; 	//0000001
	//分片
	msg->slice_count = get_byte( buf );
	msg->slice_no = get_byte( buf );
	msg->msg_id = get_word( buf );
	msg->auto_reply = get_byte( buf );
	switch( msg->im_type ){
	case QQ_RECV_IM_BUDDY_09:
	case QQ_RECV_IM_BUDDY_09SP1:
		parse_message_09( p, msg, tmp, MSG_CONTENT_LEN );
		strcpy( msg->msg_content, tmp );
		break;
	case QQ_RECV_IM_BUDDY_0801:
		get_string( buf, tmp, MSG_CONTENT_LEN );
		gb_to_utf8( tmp, tmp, MSG_CONTENT_LEN-1 );
		trans_faces( tmp, msg->msg_content, MSG_CONTENT_LEN );
		break;
	case QQ_RECV_IM_BUDDY_0802:
		buf->pos += 8;
		get_string( buf, tmp, MSG_CONTENT_LEN );
		gb_to_utf8( tmp, tmp, MSG_CONTENT_LEN-1 );
		trans_faces( tmp, msg->msg_content, MSG_CONTENT_LEN );
		break;
	}
//	DBG("buddy msg from %u:", msg->from );
	if( qq->auto_reply[0]!='\0' ){ //
		prot_im_send_msg( qq, msg->from, qq->auto_reply );
		return;
	}
	buddy_msg_callback( qq, msg->from, msg->msg_time, msg->msg_content );
}
Esempio n. 3
0
int packetmgr_check_packet( struct qqclient* qq, int timeout )
{
	qqpacketmgr *mgr = &qq->packetmgr;
	qqpacket* p;
	time_t timeout_time = time(NULL) - timeout;
	//when locked, cannot recv packet till unlock.
	do{
		p = loop_search( &mgr->sent_loop, (void*)timeout_time, timeout_searcher );
		if( p ){
			loop_remove( &mgr->sent_loop, p );
		}
		if( p ){
			if( p->send_times >= 10 ){
				MSG("[%u] Failed to send the packet. command: %x\n", qq->number, p->command );
				if( p->command == QQ_CMD_SEND_IM ){
					buddy_msg_callback( qq, 10000, time(NULL), "刚才某条消息发送失败。" );
				}
				//make an event to tell the program that we have a
				//problem.
				char event[64];
				sprintf( event, "sendfailed^$%d^$%d", p->command, p->seqno );
				qqclient_put_event( qq, event );
				delete_func( p );
				mgr->failed_packets ++;
				//To avoid too many failed packets, just shut it down.
				if( mgr->failed_packets > 5 || qq->process != P_LOGIN ){
					qqclient_set_process( qq, P_ERROR );
				}
			}else{
				DBG("[%u] resend packet cmd: %x", qq->number, p->command );
				packetmgr_put_urge( qq, p, 1 );
			}
		}
	}while( 0 && p );
	check_ready_packets(qq);
	return 0;
}