if (line == null) break;
line = line.trim();
if (line.length() > 0) break;
}
// use the parser to determine the message type
PduParser parser = new PduParser();
while (true)
{
if (line == null) break;
line = line.trim();
if (line.length() <= 0 || line.equalsIgnoreCase("OK")) break;
if (line.length() <= 0 || line.equalsIgnoreCase("ERROR")) break;
i = line.indexOf(':');
j = line.indexOf(',');
memIndex = 0;
try
{
memIndex = Integer.parseInt(line.substring(i + 1, j).trim());
}
catch (NumberFormatException e)
{
// TODO: What to do here?
Logger.getInstance().logWarn("Incorrect Memory Index number parsed!", e, getGatewayId());
}
// Start modifications by Wim Stevens
// A line contains something like +CMGL: 1,1,,25
// first parameter is the memory index
// last parameter is the length of the PDU, not counting the addressing part
// the parser must always have an addressing part -> we will add it if required
i = line.lastIndexOf(',');
j = line.length();
int pduSize = 0;
try
{
pduSize = Integer.parseInt(line.substring(i + 1, j).trim());
}
catch (NumberFormatException e)
{
// TODO: What to do here?
Logger.getInstance().logWarn("Incorrect pdu size parsed!", e, getGatewayId());
}
pduString = reader.readLine().trim();
if ((pduSize > 0) && ((pduSize * 2) == pduString.length()))
{
pduString = "00" + pduString;
}
try
{
Logger.getInstance().logDebug("READ PDU: " + pduString, null, getGatewayId());
// this will throw an exception for PDUs
// it can't classify
Pdu pdu = parser.parsePdu(pduString);
// NOTE: maybe a message validity vs the current
// date should be put here.
// if the message is invalid, the message should
// be ignored and but logged
if (pdu instanceof SmsDeliveryPdu)