group.setCreateTime(new Date(ginfo.getInt("createtime")));
JSONArray members = ginfo.getJSONArray("members");
for(int i=0; i<members.length(); i++){
JSONObject memjson = members.getJSONObject(i);
QQGroupMember member = group.getMemberByUin(memjson.getLong("muin"));
if(member == null) {
member = new QQGroupMember();
group.getMembers().add(member);
}
member.setUin(memjson.getLong("muin"));
member.setGroup(group);
//memjson.getLong("mflag"); //TODO ...
}
//result/minfo
JSONArray minfos = json.getJSONArray("minfo");
for(int i=0; i<minfos.length(); i++){
JSONObject minfo = minfos.getJSONObject(i);
QQGroupMember member = group.getMemberByUin(minfo.getLong("uin"));
member.setNickname(minfo.getString("nick"));
member.setProvince(minfo.getString("province"));
member.setCountry(minfo.getString("country"));
member.setCity(minfo.getString("city"));
member.setGender(minfo.getString("gender"));
}
//result/stats
JSONArray stats = json.getJSONArray("stats");
for(int i=0; i<stats.length(); i++){
// 下面重新设置最新状态
JSONObject stat = stats.getJSONObject(i);
QQGroupMember member = group.getMemberByUin(stat.getLong("uin"));
member.setClientType(QQClientType.valueOfRaw(stat.getInt("client_type")));
member.setStatus(QQStatus.valueOfRaw(stat.getInt("stat")));
}
//results/cards
if(json.has("cards")){
JSONArray cards = json.getJSONArray("cards");
for(int i=0; i<cards.length(); i++){
JSONObject card = cards.getJSONObject(i);
QQGroupMember member = group.getMemberByUin(card.getLong("muin"));
if( card != null && card.has("card") && member != null ) {
member.setCard(card.getString("card"));
}
}
}
//results/vipinfo
JSONArray vipinfos = json.getJSONArray("vipinfo");
for(int i=0; i<vipinfos.length(); i++){
JSONObject vipinfo = vipinfos.getJSONObject(i);
QQGroupMember member = group.getMemberByUin(vipinfo.getLong("u"));
member.setVipLevel(vipinfo.getInt("vip_level"));
member.setVip(vipinfo.getInt("is_vip") == 1);
}
notifyActionEvent(QQActionEvent.Type.EVT_OK, group);
}else{
notifyActionEvent(QQActionEvent.Type.EVT_ERROR, QQErrorCode.UNEXPECTED_RESPONSE);