?? wapptr.java~350~
字號:
}
/**
* ReadJwapConf
*/
public boolean ReadJwapConf() {
boolean ret = false;
FileWork m_fw = new FileWork();
Vector tempVector = new Vector();
try {
gwAddr = InetAddress.getByName("10.0.0.172");
} catch (UnknownHostException ex1) {
}
gwPort = 9201;
String oneline = new String("");
try {
m_fw.FW_ReadFile("Itouch.conf", tempVector);
for (int i = 0; i < tempVector.size(); i++) {
oneline = tempVector.elementAt(i).toString();
String[] StrArry = oneline.split("\\|");
if (StrArry[0].equals("0000")) {
int c = StrArry[1].indexOf(':');
if (c > 0) {
gwAddr = InetAddress.getByName(StrArry[1].substring(0,
c));
gwPort = Integer.parseInt(StrArry[1].substring(c + 1));
} else {
gwAddr = InetAddress.getByName(StrArry[1]);
gwPort = 9201;
}
ret = true;
} else if (StrArry[0].equals("2001")) {
AgentName = StrArry[1];
//xhtml_wml=1;
//String[] uaArry = oneline.split("\\:");
int pos = AgentName.lastIndexOf(":");
if (pos >= 0) {
String str1 = AgentName.substring(0, pos);
String str2 = AgentName.substring(pos + 1, pos + 2);
AgentName = str1;
if (str2.equals("2")) {
xhtml_wml = 1;
} else {
xhtml_wml = 0;
}
}
ret = true;
}
}
} catch (IOException ex) {
ex.printStackTrace();
ret = false;
}
return ret;
}
/**
* Post_Req
*
* @param m_url String
*/
public boolean Req(String m_url, String LogFileName) {
boolean ret = true;
String url = m_url;
long tc = DEFAULT_CONNECT_TIMEOUT;
long tx = DEFAULT_EXEC_TIMEOUT;
int RetCode = 0;
long BegMillisTims = 0;
long EndMillisTims = 0;
if (m_url.equals("")) {
return false;
}
int mIndex = 0;
String TempUrl = url;
String TempUrl2 = "";
if (downmms == 1) {
FileType = "mms";
} else {
mIndex = TempUrl.lastIndexOf(".");
if (mIndex != -1) {
String tempFile1ow = TempUrl.substring(mIndex + 1);
String tempFile = tempFile1ow.toUpperCase();
if (tempFile.equals("GIF") || tempFile.equals("JPG") ||
tempFile.equals("BMP") ||
tempFile.equals("WBMP") || tempFile.equals("PNG") ||
tempFile.equals("AMR") || tempFile.equals("WAV") ||
tempFile.equals("MID") || tempFile.equals("MP3") ||
tempFile.equals("RM") ||
tempFile.equals("JAR") || tempFile.equals("WAR") ||
tempFile.equals("JAD")) {
FileType = tempFile;
} else {
int ps = tempFile.indexOf("JAR");
int ps1 = tempFile.indexOf("WAR");
int ps2 = tempFile.indexOf("JAD");
if (ps >= 0) {
FileType = "JAR";
} else if (ps1 >= 0) {
FileType = "WAR";
} else if (ps2 >= 0) {
FileType = "JAD";
} else {
}
}
} else {
FileType = "null";
}
}
Request request = null;
request = new GetRequest(url);
try {
//開始連接網關
CWTPStatue.SetType(0);
BegMillisTims = System.currentTimeMillis();
LogStr[0] = Long.toString(BegMillisTims).substring(0, 10);
LogStr[1] = Long.toString(BegMillisTims).substring(10);
LogStr[2] = "0";
LogStr[9] = m_url;
WriteLog(LogFileName);
if (xhtml_wml == 1) {
RetCode = connect_http(tc);
} else {
RetCode = connect(tc);
}
//RetCode=connect(tc);
EndMillisTims = System.currentTimeMillis();
LogStr[0] = Long.toString(EndMillisTims).substring(0, 10);
LogStr[1] = Long.toString(EndMillisTims).substring(10);
LogStr[2] = Integer.toString(RetCode);
LogStr[7] = Long.toString(EndMillisTims - BegMillisTims);
LogStr[8] = Integer.toString(CWTPStatue.GetResultState());
WriteLog(LogFileName);
if (RetCode == 7) {
return false;
}
//開始下載
CWTPStatue.SetType(1);
BegMillisTims = System.currentTimeMillis();
LogStr[0] = Long.toString(BegMillisTims).substring(0, 10);
LogStr[1] = Long.toString(BegMillisTims).substring(10);
if (downmms == 1) {
LogStr[2] = "820";
} else {
LogStr[2] = "100";
}
LogStr[7] = "0";
LogStr[8] = "0";
WriteLog(LogFileName);
markflg.Setval(1);
Response response = null;
int xhtm_ret = -1;
if (xhtml_wml == 1) {
xhtm_ret = execute_http(request, tx);
} else {
response = execute(request, tx);
}
//Response response = execute(request, tx);
if (xhtml_wml == 1) {
EndMillisTims = downtime;
} else {
EndMillisTims = System.currentTimeMillis();
}
LogStr[0] = Long.toString(EndMillisTims).substring(0, 10);
LogStr[1] = Long.toString(EndMillisTims).substring(10);
LogStr[7] = Long.toString(EndMillisTims - BegMillisTims);
if (xhtml_wml == 1) {
if (xhtm_ret == -1) {
LogStr[8] = Integer.toString(50);
if (downmms == 1) {
LogStr[2] = "827";
} else {
LogStr[2] = "107";
}
System.out.println("下載失敗");
} else {
LogStr[8] = Integer.toString(32);
if (downmms == 1) {
LogStr[2] = "825";
} else {
LogStr[2] = "105";
}
//LogStr[2]="105";
ret = true;
System.out.println("下載成功");
downloadflg = 0;
}
} else {
LogStr[8] = Integer.toString(CWTPStatue.GetResultState());
if (response == null || downloadflg == 0) {
if (downmms == 1) {
LogStr[2] = "827";
} else {
LogStr[2] = "107";
}
System.out.println("下載失敗");
} else {
if (downmms == 1) {
LogStr[2] = "825";
} else {
LogStr[2] = "105";
}
//LogStr[2]="105";
ret = true;
System.out.println("下載成功");
downloadflg = 0;
}
}
markflg.Setval(0);
WriteLog(LogFileName);
} catch (IllegalStateException ex) {
System.out.println(ex.getMessage());
} catch (SocketException ex) {
System.out.println(ex.getMessage());
} catch (FileNotFoundException ex) {
System.out.println(ex.getMessage());
/** @todo Handle this exception */
} catch (IOException ex) {
System.out.println(ex.getMessage());
/** @todo Handle this exception */
}
//finally {
if (xhtml_wml == 1) {
http_disconnect();
} else {
// disconnect();
}
//}
return ret;
}
public boolean Post(String m_url, String postfile, String LogFileName) {
boolean ret = false;
String userAgent = null;
String output = null;
String contentType = "application/vnd.wap.mms-message";
String input = postfile;
String url = m_url;
int lp = CWTPSocket.DEFAULT_PORT;
long tc = DEFAULT_CONNECT_TIMEOUT;
long tx = DEFAULT_EXEC_TIMEOUT;
int RetCode = 0;
long BegMillisTims = 0;
long EndMillisTims = 0;
//xhtml_wml = 1;
int xhtm_ret = -1;
if (m_url.equals("")) {
return false;
}
Request request = null;
if (contentType == null) {
System.err.println("Warning: no content-type specified, assuming " +
DEFAULT_CONTENT_TYPE);
contentType = DEFAULT_CONTENT_TYPE;
}
byte[] postData = null;
try {
postData = readPostData(input);
} catch (IOException ex1) {
}
Sendflg = 1;
PostRequest preq = new PostRequest(url);
request = preq;
preq.setContentType(contentType);
preq.setRequestBody(postData);
try {
//開始連接網關
CWTPStatue.SetType(0);
BegMillisTims = System.currentTimeMillis();
LogStr[0] = Long.toString(BegMillisTims).substring(0, 10);
LogStr[1] = Long.toString(BegMillisTims).substring(10);
LogStr[2] = "0";
LogStr[9] = m_url;
WriteLog(LogFileName);
if (xhtml_wml == 1) {
RetCode = connect_http(tc);
} else {
RetCode = connect(tc);
}
//RetCode=connect(tc);
EndMillisTims = System.currentTimeMillis();
LogStr[0] = Long.toString(EndMillisTims).substring(0, 10);
LogStr[1] = Long.toString(EndMillisTims).substring(10);
LogStr[2] = Integer.toString(RetCode);
LogStr[7] = Long.toString(EndMillisTims - BegMillisTims);
LogStr[8] = Integer.toString(CWTPStatue.GetResultState());
WriteLog(LogFileName);
if (RetCode == 7) {
return false;
}
//開始下載
CWTPStatue.SetType(1);
BegMillisTims = System.currentTimeMillis();
LogStr[0] = Long.toString(BegMillisTims).substring(0, 10);
LogStr[1] = Long.toString(BegMillisTims).substring(10);
LogStr[2] = "820";
LogStr[7] = "0";
LogStr[8] = "0";
WriteLog(LogFileName);
markflg.Setval(1);
Response response = null;
if (xhtml_wml == 1) {
xhtm_ret = execute_http(request, tx);
} else {
response = execute(request, tx);
}
// Response response = execute(request, tx);
EndMillisTims = System.currentTimeMillis();
LogStr[0] = Long.toString(EndMillisTims).substring(0, 10);
LogStr[1] = Long.toString(EndMillisTims).substring(10);
LogStr[7] = Long.toString(EndMillisTims - BegMillisTims);
if (xhtml_wml == 1) {
if (xhtm_ret == -1) {
LogStr[8] = Integer.toString(50);
LogStr[2] = "827";
System.out.println("發送失敗");
} else {
LogStr[8] = Integer.toString(32);
LogStr[2] = "825";
ret = true;
System.out.println("發送成功");
}
} else {
LogStr[8] = Integer.toString(CWTPStatue.GetResultState());
if (response == null) {
LogStr[2] = "827";
System.out.println("發送失敗");
} else {
LogStr[2] = "825";
ret = true;
System.out.println("發送成功");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -