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

📄 shellfactory.java

📁 java写的qq代码实现qq的部分功能
💻 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.ui.tool;

import edu.tsinghua.lumaqq.LumaQQ;
import edu.tsinghua.lumaqq.models.ClusterModel;
import edu.tsinghua.lumaqq.models.FriendModel;
import edu.tsinghua.lumaqq.models.IQQNode;
import edu.tsinghua.lumaqq.qq.Util;
import edu.tsinghua.lumaqq.ui.BatchDetectHiddenShell;
import edu.tsinghua.lumaqq.ui.BrowserShell;
import edu.tsinghua.lumaqq.ui.CheckUpdateShell;
import edu.tsinghua.lumaqq.ui.DetectHiddenShell;
import edu.tsinghua.lumaqq.ui.IPSeekerShell;
import edu.tsinghua.lumaqq.ui.MainShell;
import edu.tsinghua.lumaqq.ui.ReceiveIMWindow;
import edu.tsinghua.lumaqq.ui.ReceiveSMSShell;
import edu.tsinghua.lumaqq.ui.ReceiveSystemMessageShell;
import edu.tsinghua.lumaqq.ui.SendClusterIMWindow;
import edu.tsinghua.lumaqq.ui.SendIMWindow;
import edu.tsinghua.lumaqq.ui.SendSMSShell;
import edu.tsinghua.lumaqq.ui.SystemMessageListShell;
import edu.tsinghua.lumaqq.ui.config.cluster.ClusterInfoWindow;
import edu.tsinghua.lumaqq.ui.config.face.FaceWindow;
import edu.tsinghua.lumaqq.ui.config.sys.SystemOptionWindow;
import edu.tsinghua.lumaqq.ui.config.user.UserInfoWindow;
import edu.tsinghua.lumaqq.ui.wizard.WizardWindow;
import edu.tsinghua.lumaqq.ui.wizard.cluster.ClusterWizard;
import edu.tsinghua.lumaqq.ui.wizard.search.SearchWizard;

/**
 * Shell factory class, to encapsulate some creation code
 * 
 * @author luma
 */
public class ShellFactory {
    /**
	 * 创建一个查看消息窗口
	 * 
	 * @return
	 * 		查看消息窗口
	 */
	public static ReceiveIMWindow createReceiveIMWindow(MainShell main, FriendModel f) {
	    ReceiveIMWindow rms = new ReceiveIMWindow(main, f);
		main.getShellRegistry().addReceiveIMWindow(f, rms);

		// 设置ip地址信息
		byte[] ip = (byte[])f.getProperty(IQQNode.IP);
		if(ip == null || Util.isIpZero(ip)) {
			rms.setIp(LumaQQ.getString("tcp.login"));
			rms.setPlace(LumaQQ.getString("unknown.ip"));
		} else {
			String ipStr = Util.getIpStringFromBytes(ip);
			String port = (String)f.getProperty(IQQNode.PORT);
			String country = main.getIPSeeker().getCountry(ip);
			String area = main.getIPSeeker().getArea(ip);
			if(area.endsWith("CZ88.NET"))
				area = "";
			rms.setPlace(country + area);
			rms.setIp(ipStr + ":" + port);
		}
		
		return rms;
	}
	
	/**
	 * 创建一个发送消息窗口
	 * 
	 * @return
	 * 		发送消息窗口
	 */
	public static SendIMWindow createSendIMWindow(MainShell main, FriendModel f) {
	    SendIMWindow sms = new SendIMWindow(main, f);
		main.getShellRegistry().addSendIMWindow(f, sms);
		
		// 设置IP信息
		byte[] ip = (byte[])f.getProperty(IQQNode.IP);
		if(ip == null || Util.isIpZero(ip)) {
			sms.setIp(LumaQQ.getString("tcp.login"));
			sms.setPlace(LumaQQ.getString("unknown.ip"));
		} else {
			String ipStr = Util.getIpStringFromBytes(ip);
			String port = (String)f.getProperty(IQQNode.PORT);
			String country = main.getIPSeeker().getCountry(ip);
			String area = main.getIPSeeker().getArea(ip);
			if(area.endsWith("CZ88.NET"))
				area = "";
			sms.setPlace(country + area);
			sms.setIp(ipStr + ":" + port);
		}
		
		return sms;
	}
	
	/**
	 * 创建一个群消息发送窗口
	 * 
	 * @param main
	 * 		MainShell
	 * @return
	 * 		群消息发送窗口
	 */
	public static SendClusterIMWindow createSendClusterIMWindow(MainShell main, ClusterModel c) {
	    return new SendClusterIMWindow(main, c);
	}
	
    /**
     * 创建一个短消息发送窗口
     * 
     * @return
     * 		短消息发送窗口
     */
    public static SendSMSShell createSendSMSShell(MainShell main) {
        SendSMSShell ssms = new SendSMSShell(main);
        return ssms;
    }
    
    /**
     * 创建一个系统消息列表窗口
     * 
     * @param main
     * 		MainShell
     * @return
     * 		系统消息列表窗口
     */
    public static SystemMessageListShell createSystemMessageListShell(MainShell main) {
        return new SystemMessageListShell(main);
    }
    
    /**
     * 创建一个搜索窗口
     * 
     * @param main
     * 		MainShell 
     * @return
     * 		搜索窗口
     */
    public static WizardWindow createSearchWizard(MainShell main) {
        return createSearchWizard(main, SearchWizard.SEARCH_WHAT);
    }
    
    /**
     * 创建一个搜索窗口
     * 
     * @param main
     * 		MainShell
     * @param startPage
     * 		起始页
     * @return
     * 		搜索窗口
     */
    public static WizardWindow createSearchWizard(MainShell main, String startPage) {
	    SearchWizard wizard = new SearchWizard();
	    wizard.setStartPage(startPage);
	    WizardWindow window = new WizardWindow(main, wizard);
	    wizard.init(main);
	    window.create();
        return window;
    }
    
    /**
     * 创建一个创建群向导
     * 
     * @param main
     * 		MainShell 
     * @return
     * 		群向导
     */
    public static WizardWindow createClusterWizard(MainShell main) {
	    ClusterWizard wizard = new ClusterWizard();
	    WizardWindow window = new WizardWindow(main, wizard);
	    wizard.init(main);
	    window.create();
        return window;
    }
    
    /**
     * 创建一个系统设置窗口
     * 
     * @param main
     * 		MainShell 
     * @return
     * 		系统设置窗口
     */
    public static SystemOptionWindow createSystemOptionWindow(MainShell main) {
        return new SystemOptionWindow(main);
    }
    
    /**
     * 创建一个短消息查看窗口
     * 
     * @param main
     * 		MainShell 
     * @return
     * 		短消息查看窗口
     */
    public static ReceiveSMSShell createReceiveSMSShell(MainShell main) {
        return new ReceiveSMSShell(main);
    }
    
    /**
     * 创建一个检测更新窗口
     * 
     * @param main
     * 		MainShell 
     * @return
     * 		检测更新窗口
     */
    public static CheckUpdateShell createCheckUpdateShell(MainShell main) {
        return new CheckUpdateShell(main);
    }
    
    /**
     * 创建一个如来神掌窗口
     * 
     * @param main
     * 		MainShell
     * @param f
     * 		好友model
     * @return
     * 		如来神掌窗口
     */
    public static DetectHiddenShell createDetectHiddenShell(MainShell main, FriendModel f) {
        return new DetectHiddenShell(main, f);
    }
    
    /**
     * 创建一个如来神掌之乱舞窗口
     * 
     * @param main
     * 		MainShell
     * @return
     * 		如来神掌之乱舞窗口
     */
    public static BatchDetectHiddenShell createBatchDetectHiddenShell(MainShell main) {
        return new BatchDetectHiddenShell(main);
    }
    
    /**
     * 创建一个查看系统消息窗口
     * 
     * @param main
     * 		MainShell
     * @return
     * 		查看系统消息窗口
     */
    public static ReceiveSystemMessageShell createReceiveSystemMessageShell(MainShell main) {
        return new ReceiveSystemMessageShell(main);
    }
    
    /**
     * 创建一个IP查询窗口
     * 
     * @param main
     * 		MainShell
     * @return
     * 		IP查询窗口
     */
    public static IPSeekerShell createIPSeekerShell(MainShell main) {
        return new IPSeekerShell(main);
    }
    
    /**
     * 创建一个群资料窗口
     * 
     * @param main
     * 		MainShell
     * @return
     * 		群资料窗口
     */
    public static ClusterInfoWindow createClusterInfoWindow(MainShell main, ClusterModel c) {    	
        return new ClusterInfoWindow(main, c, (c.getCreator() == main.getMyModel().getQQ()) ? ClusterInfoWindow.EDITABLE : ClusterInfoWindow.READ_ONLY);
    }
    
    /**
     * 创建一个浏览器窗口
     * 
     * @param main
     * 		MainShell
     * @return
     * 		浏览器窗口
     */
    public static BrowserShell createBrowserShell(MainShell main) {
        return new BrowserShell(main);
    }
    
    /**
     * 创建一个好友资料窗口
     * 
     * @param main
     * 		MainShell
     * @param model
     * 		好友model
     * @param style
     * 		窗口样式
     * @return
     * 		好友资料窗口
     */
    public static UserInfoWindow createUserInfoWindow(MainShell main, FriendModel model, int style) {
        return new UserInfoWindow(main, model, style);
    }
    
    /**
     * 创建一个表情管理窗口
     * 
     * @param main
     * 		MainShell
     * @return
     * 		FaceWindow对象
     */
    public static FaceWindow createFaceWindow(MainShell main) {
        return new FaceWindow(main);
    }
}

⌨️ 快捷键说明

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