?? kqqmidlet.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 + -