📄 notificationprocessor.java
字号:
GroupList gl = msn.getBuddyGroup().getGroupList();
int index = msg.getInt(1);
String newName = MimeUtility.getURLDecodedString(msg.get(2), "UTF-8");
Group g = gl.getGroup(index);
g.setName(newName);
msn.storeLocalCopy(this.lastSerial = sn);
}
}
/**
* \uFFFD\u05BE\uFFFD\uFFFD\uFFFD loginName\uFFFD\uFFFD\uFFFD\uFFFD \uFFFD\uFFFD\u022D\uFFFD\uFFFD\u00FB \uFFFDwμ\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u03F0\uFFFD, \uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD \uFFFD\uFFFD\uFFFD\uFFFD\u0276\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD
* \uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u0678\uFFFD\uFFFD\uFFFD\uFFFD
*
* @since 2002/01/07, rath@linuxkorea.co.kr
* @return \uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFDSwitchboardSession
*/
public SwitchboardSession doCallFriendWait(String loginName) throws
IOException, InterruptedException {
// Callback cb = Callback.getInstance("connectToSwitchboard", this.getClass());
Callback cb = Callback.getInstance(CONNECT_SWITCHBOARD);
OutgoingMessage out = new OutgoingMessage("XFR");
markTransactionId(out);
out.add("SB");
out.setBackProcess(cb);
Integer tr = new Integer(out.getTransactionId());
callIdMap.put(tr, loginName);
sendMessage(out);
// For wait, create temporary lock object and push lock map.
// It will notify by callback process
Object lock = new Object();
lockMap.put(tr, lock);
synchronized (lock) {
lock.wait(10000);
}
return (SwitchboardSession) sessionMap.get(tr);
}
/**
* 连接到SB服务器
* @param msg IncomingMessage
* @throws IOException
*/
public void connectToSwitchboard(IncomingMessage msg) throws IOException {
if (callIdMap.size() == 0)
return;
String servIP = msg.getServerIP(1);
if (servIP == null)
return;
final Integer tr = new Integer(msg.getTransactionId());
final String cookie = msg.get(3);
final String toCallLoginName = (String) callIdMap.get(new Integer(msg.
getTransactionId()));
//SwitchboardSession 内部类
SwitchboardSession ss = new SwitchboardSession(msn, servIP, null) {
private String firstCallName = null;
private boolean isFirstJoin = true;
public void init() throws IOException {
isProcessInit = true;
this.firstCallName = toCallLoginName;
Callback cb = Callback.getInstance(PROCESS_USER_CALL);
OutgoingMessage out = new OutgoingMessage("USR");
markTransactionId(out);
out.add(msn.getLoginName());
out.add(cookie);
out.setBackProcess(cb);
sendMessage(out);
}
/**
* 处理邀请呼叫
* @param msg IncomingMessage
* @throws IOException
*/
public void processUserCall(IncomingMessage msg) throws IOException {
System.out.println(".......call");
isProcessInit = false;
Callback cb = Callback.getInstance(PROCESS_CALL_RESULT);
OutgoingMessage out = new OutgoingMessage("CAL");
markTransactionId(out);
out.add(firstCallName);
out.setBackProcess(cb);
sendMessage(out);
}
protected void processWhoJoined(IncomingMessage msg) throws Exception {
super.processWhoJoined(msg);
if (isFirstJoin) {
isFirstJoin = false;
if (lockMap.containsKey(tr)) {
sessionMap.put(tr, this);
Object lock = lockMap.remove(tr);
synchronized (lock) {
lock.notify();
}
}
}
}
public void processCallResult(IncomingMessage msg) throws IOException {
String sessionId = msg.get(1);
setSessionId(sessionId);
msn.fireSwitchboardSessionStartedEvent(this);
}
public void cleanUp() {
super.cleanUp();
if (getSessionId() == null)
msn.fireSwitchboardSessionAbandonEvent(this, firstCallName);
}
};///~~~end SwitchboardSession 内部类
ss.start();
}
public void cleanUp() {
if (callbackCleaner != null) {
//callbackCleaner.interrupt(); //cldc1.1
callbackCleaner.yield();
callbackCleaner = null;
}
msn.isLogged = false;
msn.fireLogoutNotifyEvent();
}
/**
* NS\uFFFD\uFFFD\uFFFD\uFFFD OUT\uFFFD\u06B5带 \uFFFD\uFFFD\uFFFD\uFFFD\u03F0\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD; ~\uFFFD\uFFFD\uFFFD\u0474\uFFFD.
*/
public void logout() throws IOException {
cleanUp();
isLive = false;
setAutoOutSend(true);
OutgoingMessage out = new OutgoingMessage("OUT");
sendMessage(out);
cancel();
}
private static String getContent( InputStream in, int len ) throws IOException
{
byte[] buf = new byte[len];//[ 8192 ];
int off = 0;
while( off < buf.length )
{
int readlen = in.read(buf, off, buf.length - off);
if( readlen<1 )
break;
off += readlen;
}
in.close();
return new String(buf, 0, off);
}
/**
* 获取采用TWN方式验证的登录验证字符串 (从class TWN改)
* @param userid String
* @param password String
* @param tpf String
* @throws IOException
* @return String
*/
private String getTNP2(String userid, String password, String tpf) {
String domain = "https://login.passport.com/login2.srf?lc=1033"; //\uFFFD\uFFFD\uFFFD\uFFFD帐号
if (userid.endsWith("@hotmail.com")) //hotmail帐号
domain = "https://loginnet.passport.com/ppsecure/post.srf?" + tpf.replace(',','&');
else
if (userid.endsWith("@msn.com")) //msn帐号
domain = "https://msnialogin.passport.com/login2.srf?lc=1033";
String authStr =
"Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in="
+ userid + ",pwd=" + password + "," + tpf;
String toOut = "login=" + userid + "&";
toOut += "passwd=" + password + "&";
toOut += "sec=&";
toOut += "mspp_shared=0&padding=";
toOut += "\r\n\r\n";
short tryTimes = 3;
while (tryTimes > 0) {
try {
System.out.println(domain);
HttpsConnection con1 = (HttpsConnection) Connector.open(domain, Connector.READ_WRITE);
con1.setRequestMethod("POST");
con1.setRequestProperty("Cache-Control", "no-cache");
con1.setRequestProperty("Cookie", "BrowserTest=Success?;Version=1");
// con1.setRequestProperty("Authorization", authStr);
OutputStream out = con1.openOutputStream();
out.write(toOut.getBytes());
String authInfo = con1.getHeaderField("Authentication-Info");
System.out.println("authInfo:" + authInfo);
String ret = getContent( con1.openInputStream(), 1200 );
System.out.println("ret:" + ret);
con1.close();
con1 = null;
domain = null;
authStr = null;
if (authInfo == null) {
tryTimes--;
continue;
}
tryTimes = 0; //读取成功,不继续
int i0 = authInfo.indexOf("'t=");
int i1 = authInfo.indexOf("',", i0);
if (i0 == -1 || i1 == -1) {
return "t=0&p=0";
}
else{
return authInfo.substring(i0 + 1, i1);
}
}
catch (IOException e) {
System.out.println("time" + tryTimes);
tryTimes--;
e.printStackTrace();
}
}
return "t=0&p=0";
}
/**
* 通过post.srf
* @param userid String
* @param password String
* @param tpf String
* @return String
*/
private String getTNP(String userid, String password, String tpf) {
String domain = "https://login.passport.com/login2.srf"; //\uFFFD\uFFFD\uFFFD\uFFFD帐号
if (userid.endsWith("@hotmail.com")) //hotmail帐号
domain = "https://loginnet.passport.com/login2.srf";
else
if (userid.endsWith("@msn.com")) //msn帐号
domain = "https://msnialogin.passport.com/login2.srf";
String AuthStr;
AuthStr = "Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in="
+ userid +",pwd="+password + "," + tpf;
short tryTimes = 0;
while (tryTimes < 3) { //连接失败尝试3次
try {
System.out.println(AuthStr);
HttpsConnection con1 = (HttpsConnection) Connector.open(domain, Connector.READ_WRITE);
con1.setRequestProperty("Authorization", AuthStr);
con1.setRequestProperty("User-Agent", "MSMSGS");
con1.setRequestProperty("Host", "loginnet.passport.com");
con1.setRequestProperty("Connection", "Keep-Alive");
con1.setRequestProperty("Cache-Control", "no-cache");
// con1.setRequestProperty("Program", "no-cache");
// con1.setRequestProperty("Cookie", "BrowserTest=Success?;Version=1");
int code = con1.getResponseCode();
System.out.println("code : " + code);
if (code != HttpsConnection.HTTP_OK) {
tryTimes++;
continue; //重试
}
for(int sss= 0; sss<20;sss++)
System.out.println(con1.getHeaderFieldKey(sss) + " :" + con1.getHeaderField(sss));
BufferedReader in1 = new BufferedReader(new InputStreamReader(con1.
openInputStream(),
"UTF-8"));
String authInfo = in1.readLine();
System.out.println("authInfo----> " + authInfo);
int i0 = authInfo.indexOf("&t=");
int i1 = authInfo.indexOf("\"", i0);
in1.close();
con1.close();
if (i0 == -1 || i1 == -1) {
return "t=0&p=0";
}
else
return authInfo.substring(i0 + 1, i1);
}
catch (IOException e) {
tryTimes++;
e.printStackTrace();
}
}
return "t=0&p=0";
}
public void callbackEvent(int proType, IncomingMessage args) {
try {
switch (proType) {
case PROCESS_VER:
// System.out.println("callbackEvent PROCESS_VER");//jj
processVER(args);
break;
case PROCESS_CVR:
// System.out.println("callbackEvent PROCESS_CVR");//jj
processCVR(args);
break;
case PROCESS_AUTH:
// System.out.println("callbackEvent PROCESS_AUTH");//jj
processAuth(args);
break;
case PROCESS_LOGON:
// System.out.println("callbackEvent PROCESS_LOGON");//jj
processLogon(args);
break;
case JUDGE_SERIAL:
// System.out.println("callbackEvent JUDGE_SERIAL");//jj
judgeSerial(args);
break;
case PROCESS_RENAME:
// System.out.println("callbackEvent PROCESS_RENAME");//jj
processRename(args);
break;
case CONNECT_SWITCHBOARD:
// System.out.println("callbackEvent CONNECT_SWITCHBOARD");//jj
connectToSwitchboard(args);
break;
case RESPONSE_ADD:
// System.out.println("callbackEvent RESPONSE_ADD");//jj
responseAdd(args);
break;
case RESPONSE_REMOVE:
// System.out.println("callbackEvent RESPONSE_REMOVE");//jj
responseRemove(args);
break;
case RESPONSE_BLOCK:
// System.out.println("callbackEvent RESPONSE_BLOCK");//jj
responseBlock(args);
break;
case RESPONSE_GROUPADD:
// System.out.println("callbackEvent RESPONSE_GROUPADD");//jj
responseGroupAdd(args);
break;
case RESPONSE_GROUPREMOVE:
// System.out.println("callbackEvent RESPONSE_GROUPREMOVE");//jj
responseGroupRemove(args);
break;
case RESPONSE_CREATEGROUP:
// System.out.println("callbackEvent RESPONSE_CREATEGROUP");//jj
responseCreateGroup(args);
break;
case RESPONSE_REMOVEGROUP:
// System.out.println("callbackEvent RESPONSE_REMOVEGROUP");//jj
responseRemoveGroup(args);
break;
case RESPONSE_RENAMEGROUP:
// System.out.println("callbackEvent RESPONSE_RENAMEGROUP");//jj
responseRenameGroup(args);
break;
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -