📄 modelutils.java
字号:
/**
* 创建缺省组文件
* @param file 目的文件
* @throws IOException 创建失败
*/
public static void createDefaultGroupXmlFile(File file) throws IOException {
file.getParentFile().mkdirs();
file.createNewFile();
Groups groups = new GroupsImpl();
// 我的好友
Group group = new GroupImpl();
group.setName(LumaQQ.getString("group.default.friend"));
group.setBlacklist("false");
group.setFriendly("true");
group.setVisible("true");
group.setUpload("true");
group.setIsCluster("false");
groups.addGroup(group);
// 群/校友录
group = new GroupImpl();
group.setName(LumaQQ.getString("group.default.cluster"));
group.setBlacklist("false");
group.setFriendly("true");
group.setVisible("true");
group.setUpload("false");
group.setIsCluster("true");
groups.addGroup(group);
// 陌生人
group = new GroupImpl();
group.setName(LumaQQ.getString("group.default.stranger"));
group.setBlacklist("false");
group.setFriendly("false");
group.setVisible("true");
group.setUpload("false");
group.setIsCluster("false");
groups.addGroup(group);
// 黑名单
group = new GroupImpl();
group.setName(LumaQQ.getString("group.default.blacklist"));
group.setBlacklist("true");
group.setFriendly("false");
group.setVisible("true");
group.setUpload("false");
group.setIsCluster("false");
groups.addGroup(group);
// 最近联系人
group = new GroupImpl();
group.setName(LumaQQ.getString("group.default.latest"));
group.setBlacklist("false");
group.setFriendly("true");
group.setVisible("true");
group.setUpload("false");
group.setIsCluster("false");
groups.addGroup(group);
groups.marshal(file);
}
/**
* 创建缺省快捷回复信息文件
* @param file
* @throws IOException
*/
public static void createDefaultReplyXmlFile(File file) throws IOException {
file.getParentFile().mkdirs();
file.createNewFile();
Replies replies = new RepliesImpl();
replies.setCurrentAutoReply("0");
replies.setCurrentQuickReply("0");
replies.addQuickReply(LumaQQ.getString("menu.quick.reply.o"));
replies.addQuickReply(LumaQQ.getString("menu.quick.reply.ok"));
replies.addQuickReply(LumaQQ.getString("menu.quick.reply.enough"));
replies.addQuickReply(LumaQQ.getString("menu.quick.reply.understand"));
replies.addQuickReply(LumaQQ.getString("menu.quick.reply.bye"));
replies.addQuickReply(LumaQQ.getString("menu.quick.reply.kao"));
replies.addAutoReply(LumaQQ.getString("menu.status.away.absent"));
replies.addAutoReply(LumaQQ.getString("menu.status.away.working"));
replies.addAutoReply(LumaQQ.getString("menu.status.away.eating"));
replies.marshal(file);
}
/**
* 创建一个缺省的手机好友信息文件
*
* @param file
* 文件路径
* @throws IOException
* 出错则抛出IO异常
*/
public static void createDefaultMobileXmlFile(File file) throws IOException {
file.getParentFile().mkdirs();
file.createNewFile();
Mobiles mobiles = new MobilesImpl();
mobiles.marshal(file);
}
/**
* 创建缺省登陆历史信息文件
* @param file
* @throws IOException
*/
public static void createDefaultLoginXmlFile(File file) throws IOException {
file.createNewFile();
Logins logins = new LoginsImpl();
logins.setLastLogin("");
logins.marshal(file);
}
/**
* 创建缺省代理列表文件
* @param file
* @throws IOException
*/
public static void createDefaultProxyXmlFile(File file) throws IOException {
file.createNewFile();
Proxies proxies = new ProxiesImpl();
proxies.marshal(file);
}
/**
* 从GeneralNode创建一个Group元素对象,这相当于createGroupModel的反方法
* @param node
* @return Group元素对象
*/
public static Group createGroupElement(INode node) {
Group group = new GroupImpl();
group.setName((String)node.getProperty(INode.NAME));
group.setBlacklist((String)node.getProperty(IQQNode.BLACKLIST));
group.setFriendly((String)node.getProperty(IQQNode.FRIENDLY));
group.setVisible((String)node.getProperty(IQQNode.VISIBLE));
group.setUpload((String)node.getProperty(IQQNode.UPLOAD));
group.setIsCluster((String)node.getProperty(IQQNode.CLUSTER));
return group;
}
/**
* 从GeneralNode创建Friend元素,相当于createFriendModel的反方法
* @param f
* @return Friend元素对象
*/
public static Friend createFriendElement(FriendModel f) {
Friend friend = new FriendImpl();
ContactInfo info = (ContactInfo)f.getProperty(IQQNode.CONTACT);
if(info == null)
info = new ContactInfo();
friend.setQqNum(((Integer)f.getProperty(IQQNode.QQ_NUMBER)).toString());
friend.setNick((String)f.getProperty(IQQNode.NICK));
friend.setName(info.infos[info.name]);
friend.setAge(info.infos[info.age]);
friend.setFace(((Integer)f.getProperty(IQQNode.HEAD)).toString());
friend.setGender(info.infos[info.gender]);
friend.setCountry(info.infos[info.country]);
friend.setProvince(info.infos[info.province]);
friend.setCity(info.infos[info.city]);
friend.setEmail(info.infos[info.email]);
friend.setAddress(info.infos[info.address]);
friend.setZipcode(info.infos[info.zipcode]);
friend.setTelephone(info.infos[info.telephone]);
friend.setMobile(info.infos[info.mobile]);
friend.setCollege(info.infos[info.college]);
friend.setOccupation(info.infos[info.occupation]);
friend.setHomepage(info.infos[info.homepage]);
friend.setIntro(info.infos[info.intro]);
friend.setHoroscope(info.infos[info.horoscope]);
friend.setZodiac(info.infos[info.zodiac]);
friend.setBlood(info.infos[info.blood]);
friend.setOpenContact(info.infos[info.openContact]);
friend.setOpenHp(info.infos[info.openHp]);
friend.setAuthType(info.infos[info.authType]);
friend.setMember(String.valueOf(f.isMember()));
if(f.hasProperty(IQQNode.LOCATION_X))
friend.setLocationX(((Integer)f.getProperty(IQQNode.LOCATION_X)).toString());
if(f.hasProperty(IQQNode.LOCATION_Y))
friend.setLocationY(((Integer)f.getProperty(IQQNode.LOCATION_Y)).toString());
friend.setTalkMode(String.valueOf(f.isTalkMode()));
return friend;
}
/**
* 从GeneralNode对象创建一个Cluster元素
* @param node
*/
public static Cluster createClusterElement(INode node) {
ClusterModel c = (ClusterModel)node;
Cluster cluster = new ClusterImpl();
ClusterInfo info = c.getClusterInfo();
cluster.setClusterId(String.valueOf(c.getClusterId()));
cluster.setExternalId(String.valueOf(info.externalId));
cluster.setName(info.name);
cluster.setFace(String.valueOf(c.getFaceId()));
cluster.setMessage(c.getMessageOption());
cluster.setType(String.valueOf(info.type));
cluster.setCreator(String.valueOf(info.creator));
cluster.setCategory(String.valueOf((int)info.category));
cluster.setAuthType(String.valueOf(info.authType));
cluster.setDescription(info.description);
cluster.setNotice(info.notice);
return cluster;
}
/**
* 创建一个缺省的表情配置文件
*
* @param file
* @throws IOException
*/
public static void createDefaultFaceFile(File file) throws IOException {
Faces faces = new FacesImpl();
faces.setNextId("30");
faces.marshal(file);
}
/**
* 创建一个缺省的系统设置文件
* @param file
*/
public static void createDefaultSysOptFile(File file) throws IOException {
Options options = new OptionsImpl();
// 登陆设置
LoginOption lo = new LoginOptionImpl();
lo.setUseTcp("false");
lo.setAutoSelect("true");
lo.setServer("");
lo.setProxyType("None");
lo.setProxyServer("");
lo.setProxyPort("0");
lo.setProxyUsername("");
lo.setProxyPassword("");
lo.setTcpPort("80");
options.setLoginOption(lo);
// 界面设置
GUIOption go = new GUIOptionImpl();
go.setAutoHide("true");
go.setLocationX("50");
go.setLocationY("50");
go.setWidth("-1");
go.setHeight("-1");
go.setShowNick("true");
go.setSmallFace("true");
go.setShowTip("true");
go.setShowOnlineOnly("false");
go.setShowOnlineTip("true");
go.setOnlineTipLocationX("-1");
go.setOnlineTipLocationY("-1");
go.setFontName(LumaQQ.getString("default.font"));
go.setFontSize("9");
go.setBold("false");
go.setItalic("false");
go.setRed("0");
go.setGreen("0");
go.setBlue("0");
go.setShowViewBar("true");
go.setGroupBackground(LumaQQ.DEFAULT_GROUP_COLOR);
options.setGUIOption(go);
// 消息设置
MessageOption mo = new MessageOptionImpl();
mo.setAutoEject("false");
mo.setEnableSound("true");
mo.setRejectStranger("false");
mo.setUseEnterInMessageMode("false");
mo.setUseEnterInTalkMode("false");
options.setMessageOption(mo);
// 同步设置
SyncOption so = new SyncOptionImpl();
so.setAutoDownloadGroup("true");
so.setAutoUploadGroup("prompt");
so.setAutoDownloadFriendRemark("true");
options.setSyncOption(so);
// 其他设置
OtherOption oo = new OtherOptionImpl();
oo.setBrowser("");
oo.setKeepStrangerInLatest("false");
oo.setLatestSize("20");
oo.setEnableLatest("true");
oo.setShowFakeCam("false");
options.setOtherOption(oo);
// 写入文件
options.marshal(file);
}
/**
* 创建一个缺省的备注信息文件,什么也没有
* @param file
*/
public static void createDefaultRemarkXmlFile(File file) throws IOException {
Remarks remarks = new RemarksImpl();
remarks.marshal(file);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -