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

📄 qqfriend.java

📁 类似于MSN
💻 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.beans;

import java.nio.ByteBuffer;

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


/**
 * 好友的信息
 * 
 * @author 马若劼
 */
public class QQFriend {
    // QQ号
    public int qqNum;
    // 头像,参看ContactInfo的头像注释
    public byte face;
    // 年龄
    public byte age;
    // 性别
    public byte gender;
    // 昵称
    public String nick;
    // 状态
    public byte status;
    // 扩展标志,bit1表示是否有QQ Show,其他未知
    public byte extFlag;
    // 通用标志
	//     bit1 => 会员
	//     bit4 => TCP方式登陆
	//     bit5 => 开发移动QQ
	//     bit6 => 绑定到手机
	// 	   bit7 => 是否有摄像头
    public byte commonFlag;
    // 登陆时间,实际大小4字节
    public long loginTime;
    // Idle时间,实际大小4字节
    public long idleTime;
    // 上次刷新时间(??,不明白),实际大小4字节
    public long lastRefreshTime;
    
    /**
     * @return true如果好友是会员,否则为false
     */
    public boolean isMember() {
    	return (commonFlag & 0x2) != 0;
    }
    
    /**
     * @return true如果是男性的话
     */
    public boolean isGG() {
    	return gender == QQ.QQ_FRIEND_GENDER_GG;
    }
    
    /**
     * 给定一个输入流,解析QQFriend结构
     * @param buf
     */
    public void readBean(ByteBuffer buf) {
        // 000-003: 好友QQ号
        qqNum = buf.getInt();
        // 004: 1字节,如果好友就是自己,为0xFF,否则为0x00
        buf.get();
        // 005: 头像
        face = buf.get();
        // 006: 年龄
        age = buf.get();
        // 007: 性别
        gender = buf.get();
        // 008: 昵称长度
        int len = buf.get() & 0xFF;
        // 009-009+昵称长度: 昵称
        byte[] b = new byte[len];
        buf.get(b);
        nick = Utils.getString(b, QQ.QQ_CHARSET_DEFAULT);
        // 2个未知字节
        buf.getChar();
        // 1字节扩展标志
        extFlag = buf.get();
        // 1字节通用标志
        commonFlag = buf.get();
    }
}

⌨️ 快捷键说明

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