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

📄 groupnameopreplypacket.java

📁 很多人都在开发的QQ代码
💻 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 java.util.ArrayList;
import java.util.List;

import edu.tsinghua.lumaqq.qq.PacketParseException;
import edu.tsinghua.lumaqq.qq.QQ;
import edu.tsinghua.lumaqq.qq.Utils;
import edu.tsinghua.lumaqq.qq.packets.InPacket;

/**
 * <pre>
 * 上传下载分组名称的回复包,格式为
 * 1. 头部
 * 2. 操作标志字节,下载是0x1
 * 3. 4个未知字节,全0
 * 5. 一个未知字节
 * 6. 组序号,从1开始,0表示我的好友组,因为是缺省组,所以不包含在包中
 * 7. 16字节的组信息,最先的组名,以0结尾,0之后的字节含义未知
 * 8. 若有多个组,重复6,7部分
 * 9. 尾部
 * 
 * 说明:如果是下载回复包,则9部分全部都要,如果是上传回复,仅包含1,2,9部分
 * </pre>
 *  
 * @author 马若劼
 */
public class GroupNameOpReplyPacket extends InPacket {
	public List groupNames;
	public byte type;
	
    /**
     * 构造函数
     * @param buf 缓冲区
     * @param length 包长度
     * @throws PacketParseException 解析错误
     */
    public GroupNameOpReplyPacket(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 {
        byte[] b = buf.array();
    	// 得到操作类型
    	type = b[0];
    	// 如果是下载包,继续解析内容
    	if(type == QQ.QQ_DOWNLOAD_GROUP_NAME) {
        	// 创建list
        	groupNames = new ArrayList();
        	// 读取每个组名
        	int j = 0, i = 7;
        	while((j = Utils.indexOf(b, i, (byte)0)) != -1) {
        		String name = Utils.getString(b, i, j - i, QQ.QQ_CHARSET_DEFAULT);
        		groupNames.add(name);
        		i += 17;
        	}        		
        	if(i < b.length) {
        		String name = Utils.getString(b, i, b.length - i, QQ.QQ_CHARSET_DEFAULT);
        		groupNames.add(name);
        	}
    	}
    }
}

⌨️ 快捷键说明

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