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

📄 clustermodifyinfopacket.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.out;

import java.nio.ByteBuffer;

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

/**
 * <pre>
 * 修改群信息的请求包,格式为:
 * 1. 头部
 * 2. 命令类型,1字节,加入群是0x07
 * 3. 群的内部ID,4字节
 * 4. 群的类型,1字节
 * 5. 群的认证类型,1字节
 * 6. 两个未知字节,全0
 * 7. 群的种类,2字节
 * 8. 群名称长度,1字节
 * 9. 群名称
 * 10. 未知的两字节,全0
 * 11. 群声明长度,1字节
 * 12. 群声明
 * 13. 群简介长度,1字节
 * 14. 群简介
 * 15. 群现有成员的QQ号列表,每个QQ号4字节
 * 16. 尾部
 * </pre>
 * 
 * @author 马若劼
 */
public class ClusterModifyInfoPacket extends ClusterCommandPacket {
	private byte type;
	private byte authType;
	private char category;
	private String name;
	private String notice;
	private String description;
	private int[] members;
	
	/**
	 * 构造函数
	 */
	public ClusterModifyInfoPacket() {
		super();		
		subCommand = QQ.QQ_CLUSTER_CMD_MODIFY_CLUSTER_INFO;
		authType = QQ.QQ_CLUSTER_NEED_AUTH;
		type = QQ.QQ_CLUSTER_TYPE_PERMANENT;
		name = description = notice = "";
	}

    /**
     * @param buf
     * @param length
     * @throws PacketParseException
     */
    public ClusterModifyInfoPacket(ByteBuffer buf, int length)
            throws PacketParseException {
        super(buf, length);
    }
    
    /* (non-Javadoc)
     * @see edu.tsinghua.lumaqq.qq.packets.OutPacket#putBody(java.nio.ByteBuffer)
     */
    protected void putBody(ByteBuffer buf) {
		// 群命令类型
		buf.put(subCommand);
		// 群内部ID
		buf.putInt(clusterId);
		// 群类型
		buf.put(type);
		// 认证类型
		buf.put(authType);
		// 未知的2字节
		buf.putChar((char)0);
		// 群种类
		buf.putChar(category);
		// 群名称长度和群名称
		byte[] b = name.getBytes();
		buf.put((byte)(b.length & 0xFF));
		buf.put(b);
		// 未知的2字节
		buf.putChar((char)0);
		// 群声明长度和群声明
		b = notice.getBytes();
		buf.put((byte)(b.length & 0xFF));
		buf.put(b);
		// 群描述长度和群描述
		b = description.getBytes();
		buf.put((byte)(b.length & 0xFF));
		buf.put(b);
		// 群中的好友
		for(int i = 0; i < members.length; i++)
		    buf.putInt(members[i]);
    }
    
    /* (non-Javadoc)
     * @see edu.tsinghua.lumaqq.qq.packets.OutPacket#parseBody(java.nio.ByteBuffer)
     */
    protected void parseBody(ByteBuffer buf) throws PacketParseException {
        subCommand = buf.get();
        clusterId = buf.getInt();
        type = buf.get();
        authType = buf.get();
        buf.getChar();
        category = buf.getChar();            
        name = Utils.getString(buf, buf.get() & 0xFF);
        buf.getChar();
        notice = Utils.getString(buf, buf.get() & 0xFF);
        description = Utils.getString(buf, buf.get() & 0xFF);
        
        int m = buf.remaining() / 4;
        members = new int[m];
        for(int i = 0; i < m; i++)
            members[i] = buf.getInt();
    }
    
	/**
	 * @return Returns the authType.
	 */
	public byte getAuthType() {
		return authType;
	}
	
	/**
	 * @param authType The authType to set.
	 */
	public void setAuthType(byte authType) {
		this.authType = authType;
	}
	
	/**
	 * @return Returns the description.
	 */
	public String getDescription() {
		return description;
	}
	
	/**
	 * @param description The description to set.
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	
	/**
	 * @return Returns the members.
	 */
	public int[] getMembers() {
		return members;
	}
	
	/**
	 * @param members The members to set.
	 */
	public void setMembers(int[] members) {
		this.members = members;
	}
	
	/**
	 * @return Returns the name.
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * @param name The name to set.
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * @return Returns the notice.
	 */
	public String getNotice() {
		return notice;
	}
	
	/**
	 * @param notice The notice to set.
	 */
	public void setNotice(String notice) {
		this.notice = notice;
	}
	
	/**
	 * @return Returns the type.
	 */
	public byte getType() {
		return type;
	}
	
	/**
	 * @param type The type to set.
	 */
	public void setType(byte type) {
		this.type = type;
	}
	
	/**
	 * @return Returns the category.
	 */
	public char getCategory() {
		return category;
	}
	
	/**
	 * @param category The category to set.
	 */
	public void setCategory(char category) {
		this.category = category;
	}
}

⌨️ 快捷键说明

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