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

📄 configure.java

📁 MilyQQ是一个使用控制台的QQ客户端,基于LumaQQ的核心JQL包开发,只有一个可执行的jar包(MilyQQ.jar),携带方便,由于是Java程序,因此理论上应该可以运行于所有平台,不过基于
💻 JAVA
字号:
/*
* MilyQQ - Simple Java QQ Client with a console interface
*
* Copyright (C) 2006 spadger <echo.xjtu@gmail.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.xjtu.spadger.milyqq;

import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.File;
import java.util.Properties;
import java.util.Scanner;

public class Configure {
	private  String server;
	private  boolean udp;
	private  int qqno;
	private  String qqpass;
	private  boolean initHide;
	private  boolean sound;
	private  boolean debug;
	private  boolean useProxy;
	private  String proxyServer;
	private  int proxyPort;
	private  String proxyUser;
	private  String proxyPass;
	private  String proxyType;

	public String getServer(){return server;}
	public boolean isUdp(){return udp;}
	public boolean isSound(){return sound;}
	public boolean isDebug(){return debug;}
	public int getQQno(){return qqno;}
	public String getQQpass(){return qqpass;}
	public boolean isInitHide(){return initHide;}
	public boolean isUseProxy(){return useProxy;}
	public String getProxyServer(){return proxyServer;}
	public int getProxyPort(){return proxyPort;}
	public String getProxyUser(){return proxyUser;}
	public String getProxyPass(){return proxyPass;}
	public String getProxyType(){return proxyType;}	

	private final String udpServerList[] = {
		"sz.tencent.com",	// 61.144.238.145
		"sz2.tencent.com",	// 61.144.238.146
		"sz3.tencent.com",	// 202.104.129.251
		"sz4.tencent.com",	// 202.104.129.254
		"sz5.tencent.com",	// 61.141.194.203
		"sz6.tencent.com",	// 202.104.129.252
		"sz7.tencent.com",	// 202.104.129.253
		"219.133.41.75",
		"219.133.49.167",
		"219.133.49.77",
		"219.133.38.129",
		"219.133.38.130",
		"219.133.38.43",
		"219.133.38.44",
		"219.133.40.216",
		"219.133.48.100"
	};
	private String tcpServerList[] = {
		"tcpconn.tencent.com",	// 218.17.209.23
		"tcpconn2.tencent.com",	// 218.18.95.153
		"tcpconn3.tencent.com",	// 218.17.209.23
		"tcpconn4.tencent.com",	// 218.18.95.153
		"219.133.38.5",
		"218.17.209.23"
	};
	
	public Configure(){	
		File configFile=new File("MilyQQ.ini");
		Scanner scan = new Scanner(System.in);
		if(!configFile.exists()){
			createConfigFile();
			System.out.println("您可以在MilyQQ.ini写下配置信息.");
		}
		dealWithConfigFile();
		try{
			if(qqno == 0){
				String str = new String();
				for(;;){
					System.out.print("请输入您的QQ号码:");
					str=scan.next();			
					if(Util.isInt(str)){
						qqno = Integer.parseInt(str);
						break;
					} else {
						System.out.print("\n我从来没见过这么奇怪的QQ号,重新输一次吧\n");
					}
				}
			}
			if(qqpass.length()==0){
				InputMasking masking = new InputMasking();
				qqpass=masking.getPassword("请输入您的QQ密码:");
			}			
			if(server.equals("0") || server.length()==0)
				server=udpServerList[(int)Math.round(Math.random()*udpServerList.length)];
		} catch (Exception ex) {
			if(MilyQQ.isDebug) ex.printStackTrace();
			System.out.println("输入过程中发生错误,退出");
			System.exit(-1);
		}
		//统统使用UDP方式
		udp=true;
		useProxy = false;
		proxyServer = "";
		proxyPort = 0;
		proxyUser = "";
		proxyPass = "";
		proxyType = "";
	}


	private void dealWithConfigFile(){
		Properties config = new Properties();
		try {
			config.load(new FileInputStream("MilyQQ.ini"));
		} catch (Exception e) {
			if(MilyQQ.isDebug) e.printStackTrace();
			System.out.println("处理配置文件错误,MilyQQ将要退出.");
			System.exit(-1);
		}
		String str = config.getProperty("qqno","0");
		qqno = Integer.parseInt(Util.isInt(str) ? str : "0");
		qqpass=config.getProperty("qqpass","");
		if(config.getProperty("hide").equals("0"))
			initHide = false;
		else
			initHide = true;

		if(config.getProperty("sound").equals("1"))
			sound = true;
		else
			sound = false;

		if(config.getProperty("debug").equals("1"))
			debug = true;
		else
			debug = false;
		
		server = config.getProperty("server","0");			
	}
	
	private void createConfigFile() {
		String outText =
			 "# 您的QQ号码 \nqqno=\n\n"
			+"# 您的QQ密码(为了您的密码安全,强烈推荐留空此项!!!) \nqqpass=\n\n"
			+"# 登陆模式:0-在线登陆; 1-隐身登陆(默认) \nhide=1\n\n"
			+"# 是否启用声音:1-启用(默认);0-不启用  \nsound=1\n\n"
			+"# 调试模式:1-启用;0-不启用(默认) \ndebug=0\n\n"
			+"# OICQ服务器. 设为0让MilyQQ为您随机选择一个\nserver=0\n\n";
		try {
			BufferedWriter outFile=
				new BufferedWriter(new FileWriter("MilyQQ.ini"));
			outFile.write(outText);
			outFile.close();
		} catch (IOException ex) {
			System.err.println("Can not create MilyQQ.ini.");
			if(MilyQQ.isDebug) ex.printStackTrace();
		}
	}
}


/**
  *		1.0中使用的配置文件
  *
			String outText=
				 "# 您的QQ号码 \nqqno=\n\n"
				+"# 您的QQ密码(为了您的密码安全,强烈推荐留空此项!!!) \nqqpass=\n\n"
				+"# 登陆模式:0-在线登陆; 1-隐身登陆 \nhide=\n\n"
				+"# OICQ服务器. 设为0让MilyQQ为您随机选择一个\nserver=0\n\n"
				+"# 使用udp还是tcp方式连接服务器: 0-tcp; 1-udp\nudp=1\n\n"
				+"# 如果使用代理服务器请设为1 \nproxy=0\n"
				+"proxyserver=XXX.XXX.com\n"
				+"proxyport=1080\n"
				+"proxyuser=XXXX\n"
				+"proxypass=****\n"
				+"# Http还是Socket5 \nproxytype=Http\n";
*/

⌨️ 快捷键说明

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