📄 smsutil.java
字号:
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
// Source File Name: SmsUtil.java
package org.cross.sms.msg;
import java.io.PrintStream;
import java.util.Vector;
import javax.comm.CommDriver;
// Referenced classes of package org.cross.sms.msg:
// SMSMsgOut, WapUrlPack, SMSMsgWapPush, _CharacterUtil
public class SmsUtil
{
public SmsUtil()
{
}
public static void loadLib()
{
String driverName = "com.sun.comm.Win32Driver";
CommDriver driver = null;
try
{
System.loadLibrary("win32com");
driver = (CommDriver)Class.forName(driverName).newInstance();
driver.initialize();
}
catch(InstantiationException e1)
{
System.out.println("1:" + e1.getMessage());
}
catch(IllegalAccessException e1)
{
System.out.println("2:" + e1.getMessage());
}
catch(ClassNotFoundException e1)
{
System.out.println(e1.getMessage());
}
}
public static int getSMSSize(String pdu)
{
int j = pdu.length();
j /= 2;
if(SMSC_CODE != null)
if(SMSC_CODE.length() == 0)
{
j--;
} else
{
j -= (SMSC_CODE.length() - 1) / 2;
j -= 2;
}
j--;
return j;
}
public static boolean isSMSMsgIn(String pdu)
{
int i = Integer.parseInt(pdu.substring(0, 2), 16);
int index = (i + 1) * 2;
i = Integer.parseInt(pdu.substring(index, index + 2), 16);
return (i & 3) == 0;
}
public static Vector buildMsgOut(String receiver, String text, boolean concacencted)
{
Vector v = new Vector();
int maxLen = 160;
String encoding = "gsm_default";
if(_CharacterUtil.isContainsChineseChar(text))
{
maxLen = 70;
encoding = "gsm_unicode";
}
if(text.length() > maxLen && concacencted)
return buildConcatenatedMsgOut(receiver, text);
for(String tmp = text; tmp != null;)
if(tmp.length() > maxLen)
{
String str = tmp.substring(0, maxLen);
tmp = tmp.substring(maxLen);
SMSMsgOut m = new SMSMsgOut(receiver, str);
m.setMessageEncoding(encoding);
v.add(m);
} else
{
SMSMsgOut m = new SMSMsgOut(receiver, tmp);
m.setMessageEncoding(encoding);
v.add(m);
tmp = null;
}
return v;
}
public static Vector buildConcatenatedMsgOut(String receiver, String text)
{
Vector v = new Vector();
int maxLen = 152;
String encoding = "gsm_default";
if(_CharacterUtil.isContainsChineseChar(text))
{
maxLen = 67;
encoding = "gsm_unicode";
}
String tmp = text;
int max = text.length() / maxLen;
if(text.length() % maxLen > 0)
max++;
int indication = 0;
if(max > 0)
indication = getNextMsgIndicator();
int no = 1;
while(tmp != null)
if(tmp.length() > maxLen)
{
String str = tmp.substring(0, maxLen);
tmp = tmp.substring(maxLen);
SMSMsgOut m = new SMSMsgOut(receiver, str);
m.setMessageEncoding(encoding);
m.m_withUserHeader = true;
m.indication = indication;
m.max = max;
m.no = no++;
v.add(m);
} else
{
SMSMsgOut m = new SMSMsgOut(receiver, tmp);
m.setMessageEncoding(encoding);
if(max > 0)
{
m.m_withUserHeader = true;
m.indication = indication;
m.max = max;
m.no = no++;
}
v.add(m);
tmp = null;
}
return v;
}
public static Vector buildWapMsg(String receiver, String url, String text)
{
Vector v = new Vector();
WapUrlPack p = new WapUrlPack(text, url);
int count = p.getPackCount();
int ind = getNextMsgIndicator();
for(int i = 0; i < count; i++)
{
SMSMsgWapPush m = new SMSMsgWapPush(receiver, text, url);
m.indication = ind;
m.max = count;
m.no = i + 1;
m.m_udpdu = p.getPackByNo(i);
v.add(m);
}
return v;
}
private static int getNextMsgIndicator()
{
if(msgIndicator > 254)
msgIndicator = 1;
return msgIndicator++;
}
public static String SMSC_CODE = "";
public static int msgIndicator = 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -