?? searchuserpacket.java
字號(hào):
/*
* 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.QQ;
import edu.tsinghua.lumaqq.qq.Util;
import edu.tsinghua.lumaqq.qq.annotation.DocumentalPacket;
import edu.tsinghua.lumaqq.qq.annotation.PacketName;
import edu.tsinghua.lumaqq.qq.annotation.RelatedPacket;
import edu.tsinghua.lumaqq.qq.beans.QQUser;
import edu.tsinghua.lumaqq.qq.packets.BasicOutPacket;
import edu.tsinghua.lumaqq.qq.packets.PacketParseException;
import edu.tsinghua.lumaqq.qq.packets.in.SearchUserReplyPacket;
/**
* <pre>
* 搜索在線用戶的包,格式為
* 1. 頭部
* 2. 1個(gè)字節(jié),表示搜索類型,比如搜索全部在線用戶是0x31,自定義搜索是0x30
* 3. 1字節(jié)分隔符: 0x1F
* 4. 搜索參數(shù)
* i. 對(duì)于搜索全部在線用戶的請(qǐng)求,是一個(gè)頁號(hào),用字符串表示,從0開始
* ii. 對(duì)于自定義搜索類型,是4個(gè)域,用0x1F分隔,依次是
* a. 要搜索的用戶的QQ號(hào)的字符串形式
* b. 要搜索的用戶的昵稱
* c. 要搜索的用戶的email
* d. 頁號(hào)的字符串形式,這后面沒有分隔符了,是用0x0結(jié)尾的
* 5. 尾部
* </pre>
*
* @author luma
*/
@DocumentalPacket
@PacketName("搜索用戶請(qǐng)求包")
@RelatedPacket({SearchUserReplyPacket.class})
public class SearchUserPacket extends BasicOutPacket {
private byte searchType;
private String page;
private String qqStr;
private String nick;
private String email;
/** 分隔符 */
private static final byte DELIMIT = 0x1F;
/** 如果字段為空,用0x2D替代,即'-'字符 */
private static final byte NULL = 0x2D;
/**
* 構(gòu)造函數(shù)
*/
public SearchUserPacket(QQUser user) {
super(QQ.QQ_CMD_SEARCH_USER, true, user);
page = "0";
searchType = QQ.QQ_SEARCH_ALL;
qqStr = nick = email = "";
}
/**
* @param buf
* @param length
* @throws PacketParseException
*/
public SearchUserPacket(ByteBuffer buf, int length, QQUser user)
throws PacketParseException {
super(buf, length, user);
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.qq.packets.OutPacket#getPacketName()
*/
@Override
public String getPacketName() {
return "Search User Packet";
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.qq.packets.OutPacket#putBody(java.nio.ByteBuffer)
*/
@Override
protected void putBody(ByteBuffer buf) {
// 開始組裝內(nèi)容
if(searchType == QQ.QQ_SEARCH_ALL) {
buf.put(searchType);
buf.put(DELIMIT);
buf.put(page.getBytes());
} else if(searchType == QQ.QQ_SEARCH_CUSTOM) {
buf.put(searchType);
buf.put(DELIMIT);
// QQ號(hào)
if(qqStr == null || qqStr.equals("")) buf.put(NULL);
else buf.put(qqStr.getBytes());
buf.put(DELIMIT);
// 昵稱
if(nick == null || nick.equals("")) buf.put(NULL);
else
buf.put(Util.getBytes(nick));
buf.put(DELIMIT);
// email
if(email == null || email.equals("")) buf.put(NULL);
else
buf.put(email.getBytes());
buf.put(DELIMIT);
// 結(jié)尾
buf.put(page.getBytes());
buf.put((byte)0x0);
}
}
/**
* @param page The page to set.
*/
public void setPage(int page) {
this.page = String.valueOf(page);
}
/**
* @param searchType The searchType to set.
*/
public void setSearchType(byte searchType) {
this.searchType = searchType;
}
/**
* @param nick The nick to set.
*/
public void setNick(String nick) {
this.nick = nick;
}
/**
* @param qqNum The qqNum to set.
*/
public void setQQStr(int qqNum) {
this.qqStr = String.valueOf(qqNum);
}
/**
* @param qqStr
*/
public void setQQStr(String qqStr) {
this.qqStr = qqStr;
}
/**
* @param email The email to set.
*/
public void setEmail(String email) {
this.email = email;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -