📄 friendremarkopreplypacket.java
字号:
/*
* LumaQQ - Java QQ Client
*
* Copyright (C) 2004 luma <stubma@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
*/
package edu.tsinghua.lumaqq.qq.packets.in;
import java.nio.ByteBuffer;
import edu.tsinghua.lumaqq.qq.PacketParseException;
import edu.tsinghua.lumaqq.qq.QQ;
import edu.tsinghua.lumaqq.qq.beans.FriendRemark;
import edu.tsinghua.lumaqq.qq.packets.InPacket;
/**
* <pre>
* 上传下载好友备注的回复包,格式为:
* 1. 头部
* 2. 操作方式字节,上传是0x1,下载是0x3
* 3. 如果是0x1,后面的部分为
* i. 1字节应答码,0x0表示成功
* 如果是0x3,后面的部分为(后面也可能什么都没有,说明这个好友没有备注)
* i. 操作对象的QQ号,4字节
* ii. 一个未知字节0
* iii. 分隔符0x1
* iv. 以下为备注信息,一共7个域,域的顺序依次次是
* 姓名、手机、电话、地址、邮箱、邮编、备注
* 每个域都有一个前导字节,这个字节表示了这个域的字节长度
* 4. 尾部
* </pre>
*
* @author 马若劼
*/
public class FriendRemarkOpReplyPacket extends InPacket {
// 应答码,仅用在上传回复
public byte replyCode;
// 操作对象的QQ号
public int qqNum;
// 备注信息,仅用在下载时
public FriendRemark remark;
// 操作字节
public byte type;
// 是否有备注
public boolean hasRemark;
/**
* 构造函数
* @param buf 缓冲区
* @param length 包长度
* @throws PacketParseException 解析错误
*/
public FriendRemarkOpReplyPacket(ByteBuffer buf, int length) throws PacketParseException {
super(buf, length);
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.qq.packets.InPacket#parseBody(java.nio.ByteBuffer)
*/
protected void parseBody(ByteBuffer buf) throws PacketParseException {
// 操作字节
type = buf.get();
if(type == QQ.QQ_UPLOAD_FRIEND_REMARK)
replyCode = buf.get();
else {
if(buf.hasRemaining()) {
// 读取操作对象的QQ号
qqNum = buf.getInt();
// 创建备注对象
remark = new FriendRemark();
// 跳过一个未知字节0x0
buf.get();
// 读入备注对象
remark.readBean(buf);
hasRemark = true;
} else
hasRemark = false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -