// Decompiled by DJ v3.10.10.93 Copyright 2007 Atanas Neshkov Date: 2011-04-06 15:49:08
// Home Page: http://members.fortunecity.com/neshkov/dj.html http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: WAPPdu.java
package inc.mms.util;
import android.util.Log;
import com.android.internal.util.HexDump;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.xml.sax.AttributeList;
import org.xml.sax.SAXException;
// Referenced classes of package oms.mms.util:
// WBXMLParser
public class WAPPdu
{
private static final String TAG = "WAPPdu";
public static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
private static final int LENGTH_QUOTE = 31;
private static final int SHORT_LENGTH_MAX = 30;
private static final int TYPE_PUSH = 6;
private static final int X_WAP_APPLICATION_ID = 175;
private static final int X_WAP_INITIATOR_URI = 177;
private static final int X_WAP_PUSH_FLAG = 180;
private String mAction;
private String mClass;
private long mCreate;
private String mCreateDatatime;
private String mHref;
private String mMimeType;
private long mSiExpires;
private String mSiExpiresDatatime;
private String mSiId;
private String mStringInline;
public static class SL
{
public static final byte MIME_PORT = -80;
public static final String MIME_TYPE = "application/vnd.wap.slc";
public static final String TAG_TABLE[] = new String[]{
"sl",
};
public static final String ATTR_START_TABLE[] = new String[]{
"execute-low",
"execute-high",
"cache",
"",
"http://",
"http://www.",
"https://",
"https://www.",
};
public static final String ATTR_NAME_TABLE[] = new String[]{
"action",
"action",
"action",
"href",
"href",
"href",
"href",
"href",
};
public static final String ATTR_VALUE_TABLE[] = new String[]{
".com/",
".edu/",
".net/",
".org/",
};
}
public static class SI
{
public static final byte MIME_PORT = -82;
public static final String MIME_TYPE = "application/vnd.wap.sic";
public static final String TAG_TABLE[] = new String[]{
"si", //5
"indication", //6
"info", //7
"item", //8
};
public static final String ATTR_START_TABLE[] = new String[]{
"signal-none",
"signal-low",
"signal-medium",
"signal-high",
"delete",
"",
"",
"http://",
"http://www.",
"https://",
"https://www.",
"",
"",
"",
};
public static final String ATTR_NAME_TABLE[] = new String[]{
"action", //5
"action", //6
"action", //7
"action", //8
"action",
"create",
"href",
"href",
"href",
"href",
"href",
"si-expires",
"si-id",
"class",
};
public static final String ATTR_VALUE_TABLE[] = new String[]{
".com/", //85
".edu/", //86
".net/", //87
".org/", //88
};
}
public WAPPdu()
{
}
private int BCDToInt(byte byte0)
{
int i = (byte0 >> 4 & 0xf) * 10;
int j = byte0 & 0xf;
return i + j;
}
private Date convertBCDDate(String bcdDate)
{
if(bcdDate == null)
return new Date(0, 0, 0, 0, 0, 0);
byte[] byteStream = HexDump.hexStringToByteArray(bcdDate);
byte[] dateStream = new byte[7];
int len;
if(byteStream.length < 7) {
if(byteStream.length <= 0 || byteStream.length > 7)
return new Date(0, 0, 0, 0, 0, 0);
len = byteStream.length;
} else {
len = 7;
}
System.arraycopy(byteStream, 0, dateStream, 0, len);
int year = (BCDToInt(dateStream[0]) * 100 + BCDToInt(dateStream[1])) - 1900;
int month = BCDToInt(dateStream[2]) - 1;
int day = BCDToInt(dateStream[3]);
int hour = BCDToInt(dateStream[4]);
int minute = BCDToInt(dateStream[5]);
int second = BCDToInt(dateStream[6]);
return new Date(year, month, day, hour, minute, second);
}
private String convertDateToUTC(Date date)
{
return (new SimpleDateFormat(DATE_FORMAT)).format(date);
}
private boolean parseWspHeader(byte[] data)
{
int j;
boolean flag = false;
j = 0;
if(data.length > 1 && data[0] == 3)
j = 0 + 1;
switch(data[j]) {
case SI.MIME_PORT:
mMimeType = "application/vnd.wap.sic";
break;
case SL.MIME_PORT:
mMimeType = "application/vnd.wap.slc";
break;
default:
Log.e("WAPPdu", "Received non-SI/SL.");
return flag;
}
int i = 0 + 1;
while(i < data.length) {
switch( data[i]){
case -81:
StringBuilder strBuilder = new StringBuilder();
while(data[i] != 0) {
int cur = i + 1;
if(cur >= data.length)
break;
char c = (char)data[cur];
strBuilder.append(c);
i = cur;
}
if(strBuilder != null && strBuilder.toString().toLowerCase().startsWith("application/x-oma-dcd:dcd.ua")){
return false;
}
i += 1;
break;
case -79:
while(data[i] != 0) {
i += 1;
}
i += 1;
break;
case -76:
i += 2;
break;
default:
while(i < data.length) {
int cur = i + 1;
if(data[i] == 0)
break;
i = cur;
}
if(i < data.length) {
i += 1;
}
break;
}
}
if(i >= data.length) {
return true;
} else {
return false;
}
}
public String getAction()
{
return mAction;
}
public String getBody()
{
String body = "";
if(mStringInline != null) {
body = "" + mStringInline;
}
if(mHref != null) {
body = body + "\n" + mHref;
}
return body;
}
public long getCreate()
{
return mCreate;
}
public String getCreateDatatime()
{
return mCreateDatatime;
}
public String getHref()
{
return mHref;
}
public String getMimeType()
{
return mMimeType;
}
public long getSiExpires()
{
return mSiExpires;
}
public String getSiExpiresDatatime()
{
return mSiExpiresDatatime;
}
public String getStringInline()
{
return mStringInline;
}
public boolean parseUserData(byte[] data)
{
boolean flag = false;
if(data == null) {
Log.e(TAG, "Parameter is null.");
return false;
}