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

📄 kqqmidlet.java

📁 手机中用的MobileQQ源代码
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;

public class KQQMIDlet extends MIDlet
    implements CommandListener, HttpPosterListener, ItemStateListener
{

    public static KQQMIDlet instance = null;
    public static Display display = null;
    public static Runtime runtime = null;
    private Form MessageBox;
    private Form InputForm;
    protected Command cmdOk;
    protected Command cmdBack;
    protected Command cmdExit;
    protected Command cmdAgain;
    protected Command cmdBackToHelp;
    protected Command cmdStart;
    protected Command cmdHelp;
    private Gauge theGauge;
    public int gaugeState;
    public String strUserID;
    public String strPasswd;
    private TextField fldUserID;
    private TextField fldPasswd;
    private boolean bMaskable;
    private String strTruePasswd;
    private String oldOwner;
    public static String url = "http://218.18.95.203:21001/";
    public static MainMenu mainMenu;
    public static HttpPoster httpPoster;
    public static FriendRecord friendRecord;
    public static FriendList friendList;
    public static GetMsgDlg getMsgDlg;
    public static SendMsgDlg sendMsgDlg;
    public static AddFriend addFriend;
    public static Finger finger;
    public static AckSvrMsg ackSvrMsg;
    public static MainForm mainForm;//主窗体对象
    public static BlackList blackList;
    public static MultiLan sysString;
    public static HistoryMsg historyMsg;
    private boolean isPause;
    private boolean isLoginPaused;
    private Displayable dispPause;
    public boolean isWaitLogin;
    int loadCnt;
    private int logoTimer;
    private int timercnt;
    private Alert qqalr;
    private Displayable alrpre;

    public KQQMIDlet()
    {//构造函数,对变量进行初始化;
        MessageBox = null;
        InputForm = null;
        cmdOk = null;
        cmdBack = null;
        cmdExit = null;
        cmdAgain = null;
        cmdBackToHelp = null;
        cmdStart = null;
        cmdHelp = null;
        theGauge = null;
        gaugeState = 0;
        strUserID = null;
        strPasswd = null;
        fldUserID = null;
        fldPasswd = null;
        bMaskable = false;
        strTruePasswd = null;
        oldOwner = null;
        isPause = false;
        isLoginPaused = false;
        dispPause = null;
        isWaitLogin = false;
        loadCnt = 0;
        logoTimer = 0;
        timercnt = 0;
        qqalr = null;
        alrpre = null;
        instance = this;
        display = Display.getDisplay(this);
        sysString = new MultiLan();
        httpPoster = new HttpPoster();
        historyMsg = new HistoryMsg();
        mainMenu = new MainMenu();
        friendRecord = new FriendRecord();
        friendList = new FriendList();
        mainForm = new MainForm();
        getMsgDlg = new GetMsgDlg();
        sendMsgDlg = new SendMsgDlg();
        addFriend = new AddFriend();
        finger = new Finger();
        ackSvrMsg = new AckSvrMsg();
        blackList = new BlackList();
    }

    public void init()
    {
        addFriend.init();
        friendList.init();
        getMsgDlg.init();
        historyMsg.init();
        mainForm.init();
        mainMenu.init();
        sendMsgDlg.init();
    }

    public void startApp()
    {
        if(isPause)
        {//是暂停后再启动;
            isPause = false;
            if(isLoginPaused && !isWaitLogin)
                mainForm.show();
            else
                display.setCurrent(dispPause);
        } else
        {//第一次开始程序;
            javax.microedition.lcdui.Image image = PkgTools.createImage("/qq.png");//登录LOGO
            ImageItem imageitem = new ImageItem(null, image, 3, null);
            FullScreen fullscreen = new FullScreen(image);
            display.setCurrent(fullscreen);//全屏显示LOGO
            sysString.init();//Multilan类的初始化,该类负责多语种管理;
            cmdOk = new Command(sysString.sLogin, 1, 1);
            cmdBack = new Command(sysString.sBack, 2, 2);
            cmdExit = new Command(sysString.sExit, 2, 2);
            cmdAgain = new Command(sysString.sReLogin, 1, 1);
            cmdBackToHelp = new Command(sysString.sBack, 2, 2);
            cmdStart = new Command(sysString.sStart, 1, 1);
            cmdHelp = new Command(sysString.sHelp, 1, 2);
            createLoginForm();//创建登录窗体;
            sysString.init2();//Multilan类的初始化二,该类负责多语种管理;
            mainForm.startSysTimer();//启动系统时钟;每500毫秒执行一次MainForm中的run函数;
        }
    }

    public void pauseApp()
    {//暂停
        isPause = true;
        if(isWaitLogin)
        {
            isLoginPaused = true;
        } else
        {
            isLoginPaused = false;
            dispPause = getCurrent();
        }
    }

    public void destroyApp(boolean flag)
    {
    }

    public void quitApp()
    {
        mainForm.stopSysTimer();
        httpPoster.abort();
        destroyApp(false);
        notifyDestroyed();
    }

    public void onLoadEnd()
    {
        loadCnt++;
        if(loadCnt > 1 && isWaitLogin)
        {
            isWaitLogin = false;
            mainForm.show();
            stopTimer();
        }
    }

    protected void createLoginForm()
    {//创建登录窗口;
        String s = null;
        String s1 = null;
        bMaskable = false;
        if(strUserID != null && strPasswd != null)
        {//登录窗口中的QQ号和密码均不为空;
            s = strUserID;
            s1 = strPasswd;
        } else
        {//若登录窗口中的QQ号码和密码有一个为空;
            PkgTools.loadDB();
            oldOwner = PkgTools.getUIN();
            s = oldOwner;
            s1 = PkgTools.getPassWord();
        }
        if(s == null || s1 == null)
        {
            s = new String("");
            s1 = new String("");
        } else
        if(s.equals("0"))
        {
            s = new String("");
            s1 = new String("");
            bMaskable = false;
        } else
        {
            strTruePasswd = s1;
            s1 = new String("******");
            bMaskable = true;
        }
        fldUserID = new TextField(sysString.sQQNo, s, 10, 2);
        fldPasswd = new TextField(sysString.sQQPassWord, s1, 16, 0);
        InputForm = new Form(sysString.sLoginForm);
        InputForm.append(fldUserID);
        InputForm.append(fldPasswd);
        InputForm.addCommand(cmdOk);
        InputForm.addCommand(cmdHelp);
        InputForm.addCommand(cmdExit);
        InputForm.setCommandListener(this);
        InputForm.setItemStateListener(this);
        showLoginForm();//显示登录窗口
    }

    protected void showLoginForm()
    {
        isWaitLogin = false;//置等待登录标志为假;
        httpPoster.stopTimer();//httpPoster时钟停止;
        display.setCurrent(InputForm);//置当前显示窗口为输入窗口;
    }

    public void startTimer(int i)
    {//开始时钟;
        timercnt = 0;
        logoTimer = i;
    }

    public void stopTimer()
    {//停止时钟;
        logoTimer = 0;
    }

    public void OnTimer()
    {
        switch(logoTimer)
        {
        case 0: // '\0'
        default:
            break;

        case 1: // '\001'
            timercnt++;
            if(timercnt == 6)
                stopTimer();
            break;

        case 2: // '\002'
            timercnt++;
            if(gaugeState < 1)
            {
                if(timercnt > 16)
                    timercnt = 16;
            } else
            if(timercnt >= 38)
                timercnt = 38;
            theGauge.setValue((timercnt / 2) * 5);
            break;
        }
    }

    public void onNetError(boolean flag)
    {//网络错误时;
        httpPoster.stopTimer();
        mainForm.stopTimer();
        getMsgDlg.stopTimer();
        friendRecord.stopTimer();
        if(flag)
        {
            if(!isWaitLogin)
                showMessage(sysString.sNetError, sysString.sNetErrorMsg, this, cmdAgain, cmdExit);
        } else
        {
            showMessage(sysString.sNetError, sysString.sNetErrorMsg, this, cmdExit, null);
        }
    }

    public void showMessage(String s, String s1, CommandListener commandlistener, Command command, Command command1)
    {
        MessageBox = new Form(s);
        MessageBox.append(s1);
        if(command != null)
            MessageBox.addCommand(command);
        if(command1 != null)
            MessageBox.addCommand(command1);
        MessageBox.setCommandListener(commandlistener);
        display.setCurrent(MessageBox);
    }

    public void playAlert()
    {
        try
        {
            AlertType.CONFIRMATION.playSound(display);
        }
        catch(Exception exception) { }
    }

    public Displayable getCurrent()
    {
        Displayable displayable = display.getCurrent();
        if(displayable == qqalr)
            return alrpre;
        else
            return displayable;
    }

    public void showAlert(String s, String s1, Displayable displayable)
    {
        try
        {
            qqalr = new Alert(s, s1, null, null);
            qqalr.setType(AlertType.ERROR);
            if(displayable != null)
                alrpre = displayable;
            else
                alrpre = getCurrent();
            qqalr.setTimeout(2000);
            display.setCurrent(qqalr, alrpre);
        }
        catch(Exception exception) { }
    }

    public void showHelpForm()
    {
        showMessage(sysString.sQQHelp, sysString.sQQHelpMsg, this, cmdBack, null);
    }

    private void login()
    {
        httpPoster.startTimer();
        strUserID = fldUserID.getString();
        strPasswd = fldPasswd.getString();
        try
        {
            if(strUserID.length() < 5 || Long.parseLong(strUserID) < 10001L)
            {
                showAlert(sysString.sLoginFall, sysString.sInvalidQQNo, InputForm);
                return;
            }
        }
        catch(Exception exception)
        {
            showAlert(sysString.sLoginFall, sysString.sInvalidQQNo, InputForm);
            return;
        }
        if(bMaskable && strPasswd.equals("******"))
            strPasswd = strTruePasswd;
        isWaitLogin = true;
        showMessage(sysString.sTQQ, sysString.sLogining, this, null, cmdBack);
        theGauge = new Gauge("", false, 100, 0);
        MessageBox.append(theGauge);
        startTimer(2);
        theGauge.setValue(0);
        gaugeState = 0;
        httpPoster.login(strUserID, strPasswd, this);//登录;
    }

    public void commandAction(Command command, Displayable displayable)
    {
        if(command == cmdOk)
        {
            login();
            return;
        }
        if(command == cmdBack)
        {
            showLoginForm();
            return;
        }
        if(command == cmdAgain)
        {
            showLoginForm();
            return;
        }
        if(command == cmdExit)
        {
            quitApp();
            return;
        }
        try
        {
            if(command == cmdStart)
                createLoginForm();
            if(command == cmdHelp || command == cmdBackToHelp)
            {
                showHelpForm();
                return;
            }
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
        return;
    }

    public void receiveHttpResponse(String s)
    {
        if(!isWaitLogin)
            return;
        String s1 = PkgTools.GetParaVal("CMD", s);
        String s2 = PkgTools.GetParaVal("RES", s);
        String s3 = PkgTools.GetParaVal("RS", s);
        String s4 = PkgTools.GetParaVal("RA", s);
        s1 = s1.toUpperCase();
        if(s1.equals("LOGIN") && s2.equals("0") && s3.equals("0"))
        {
            if(!mainForm.iFirstTimeQuery)
            {
                httpPoster.getFriend(mainForm);
                mainForm.startTimer();
                mainForm.show();
                return;
            }
            gaugeState = 1;
            httpPoster.sendList(mainForm);
            if(strUserID.equals(oldOwner))
            {
                if(PkgTools.getControl().equals("0"))
                    getMsgDlg.switchControl();
                blackList.loadList();
            } else
            {
                PkgTools.setOtherInfo(strUserID, "1", blackList);
            }
            PkgTools.setUserInfo(strUserID, strPasswd);
        } else
        if(s2.equals("5"))
            showAlert(sysString.sLoginFall, sysString.sInvalidQQNo, InputForm);
        else
        if(s2.equals("0"))
            showAlert(sysString.sLoginFall, s4, InputForm);
        else
            showAlert(sysString.sLoginFall, sysString.sLoginFallMsg, InputForm);
    }

    public void handleHttpError(String s)
    {
        if(s == null && getCurrent() != MessageBox)
        {
            return;
        } else
        {
            showAlert(sysString.sLoginFall, sysString.sNetConnectFallMsg, InputForm);
            return;
        }
    }

    public void itemStateChanged(Item item)
    {
        if(item == fldPasswd)
            bMaskable = false;
    }

}

⌨️ 快捷键说明

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