Package org.ajwcc.pduUtils.gsm3040

Examples of org.ajwcc.pduUtils.gsm3040.SmsDeliveryPdu


  {
    boolean ok = false;
    List<String> pdus = msg.getPdus(getSmscNumber(), this.outMpRefNo);
    for (String pdu : pdus)
    {
      Pdu newPdu = new PduParser().parsePdu(pdu);
      Logger.getInstance().logDebug(newPdu.toString(), null, getGatewayId());
      int j = pdu.length() / 2;
      if (getSmscNumber() == null)
      {
        // Do nothing on purpose!
      }
View Full Code Here


          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)
            {
              Logger.getInstance().logDebug(pdu.toString(), null, getGatewayId());
              InboundMessage msg;
              String memLocation = getATHandler().getStorageLocations().substring((ml * 2), (ml * 2) + 2);
              if (pdu.isBinary())
              {
                msg = new InboundBinaryMessage((SmsDeliveryPdu) pdu, memIndex, memLocation);
                if (Service.getInstance().getKeyManager().getKey(msg.getOriginator()) != null) msg = new InboundEncryptedMessage((SmsDeliveryPdu) pdu, memIndex, memLocation);
              }
              else
              {
                msg = new InboundMessage((SmsDeliveryPdu) pdu, memIndex, memLocation);
              }
              msg.setGatewayId(getGatewayId());
              Logger.getInstance().logDebug("IN-DTLS: MI:" + msg.getMemIndex() + " REF:" + msg.getMpRefNo() + " MAX:" + msg.getMpMaxNo() + " SEQ:" + msg.getMpSeqNo(), null, getGatewayId());
              if (msg.getMpRefNo() == 0)
              {
                // single message
                msgList.add(msg);
                incInboundMessageCount();
              }
              else
              {
                // multi-part message
                int k, l;
                List<InboundMessage> tmpList;
                InboundMessage listMsg;
                boolean found, duplicate;
                found = false;
                for (k = 0; k < this.mpMsgList.size(); k++)
                {
                  // List of List<InboundMessage>
                  tmpList = this.mpMsgList.get(k);
                  listMsg = tmpList.get(0);
                  // check if current message list is for this message
                  if (listMsg.getMpRefNo() == msg.getMpRefNo())
                  {
                    duplicate = false;
                    // check if the message is already in the message list
                    for (l = 0; l < tmpList.size(); l++)
                    {
                      listMsg = tmpList.get(l);
                      if (listMsg.getMpSeqNo() == msg.getMpSeqNo())
                      {
                        duplicate = true;
                        break;
                      }
                    }
                    if (!duplicate) tmpList.add(msg);
                    found = true;
                    break;
                  }
                }
                if (!found)
                {
                  // no existing list present for this message
                  // add one
                  tmpList = new ArrayList<InboundMessage>();
                  tmpList.add(msg);
                  this.mpMsgList.add(tmpList);
                }
              }
            }
            else if (pdu instanceof SmsStatusReportPdu)
            {
              StatusReportMessage msg;
              msg = new StatusReportMessage((SmsStatusReportPdu) pdu, memIndex, getATHandler().getStorageLocations().substring((ml * 2), (ml * 2) + 2));
              msg.setGatewayId(getGatewayId());
              msgList.add(msg);
              incInboundMessageCount();
            }
            else
            {
              // this theoretically will never happen, but it occasionally does with phones
              // like some Sony Ericssons (e.g. Z610i, SENT messages are included in this list)
              // instead of throwing a RuntimeException, just ignore any messages that are not of type
              // SmsDeliveryPdu
              // SmsStatusReportPdu
              if (this.displayIllegalReceivedMessages)
              {
                Logger.getInstance().logError("Wrong type of PDU detected: " + pdu.getClass().getName(), null, getGatewayId());
                Logger.getInstance().logError("ERROR PDU: " + pduString, null, getGatewayId());
              }
            }
          }
          catch (Exception e)
View Full Code Here

    if ((pdu.hasTpUdhi()) && (getEncoding() == MessageEncodings.ENC7BIT)) { throw new RuntimeException("getPduUserData() not supported for 7-bit messages with UDH"); }
    // sum up the ud parts
    StringBuffer ud = new StringBuffer();
    for (String pduString : pdus)
    {
      Pdu newPdu = new PduParser().parsePdu(pduString);
      ud.append(PduUtils.bytesToPdu(newPdu.getUserDataAsBytes()));
    }
    return ud.toString();
  }
View Full Code Here

    // NOTE: - the mpRefNo is arbitrarily set to 1
    // - if the user wishes to extract the UDH per part, he would need to get all pduStrings
    // using getPdus(String smscNumber, int mpRefNo), use a
    // PduParser on each pduString in the returned list, then access the UDH via the Pdu object
    List<String> pdus = pduGenerator.generatePduList(pdu, 1);
    Pdu newPdu = new PduParser().parsePdu(pdus.get(0));
    byte[] udh = newPdu.getUDHData();
    if (udh != null) return PduUtils.bytesToPdu(udh);
    return null;
  }
View Full Code Here

    return str;
  }

  public List<String> getPdus(String smscNumber, int mpRefNo)
  {
    PduGenerator pduGenerator = new PduGenerator();
    SmsSubmitPdu pdu = createPduObject();
    initPduObject(pdu, smscNumber);
    return pduGenerator.generatePduList(pdu, mpRefNo);
  }
View Full Code Here

  @Override
  public String getPduUserData()
  {
    // generate
    PduGenerator pduGenerator = new PduGenerator();
    SmsSubmitPdu pdu = createPduObject();
    initPduObject(pdu, "");
    // NOTE: - the mpRefNo is arbitrarily set to 1
    // - this won't matter since we aren't looking at the UDH in this method
    // - this method is not allowed for 7-bit messages with UDH
    // since it is probable that the returned value will not be
    // correct due to the encoding's dependence on the UDH
    // - if the user wishes to extract the UD per part, he would need to get all pduStrings
    // using getPdus(String smscNumber, int mpRefNo), use a
    // PduParser on each pduString in the returned list, then access the UD via the Pdu object
    List<String> pdus = pduGenerator.generatePduList(pdu, 1);
    // my this point, pdu will be updated with concat info (in udhi), if present
    if ((pdu.hasTpUdhi()) && (getEncoding() == MessageEncodings.ENC7BIT)) { throw new RuntimeException("getPduUserData() not supported for 7-bit messages with UDH"); }
    // sum up the ud parts
    StringBuffer ud = new StringBuffer();
    for (String pduString : pdus)
View Full Code Here

  @Override
  public String getPduUserDataHeader()
  {
    // generate
    PduGenerator pduGenerator = new PduGenerator();
    SmsSubmitPdu pdu = createPduObject();
    initPduObject(pdu, "");
    // NOTE: - the mpRefNo is arbitrarily set to 1
    // - if the user wishes to extract the UDH per part, he would need to get all pduStrings
    // using getPdus(String smscNumber, int mpRefNo), use a
    // PduParser on each pduString in the returned list, then access the UDH via the Pdu object
    List<String> pdus = pduGenerator.generatePduList(pdu, 1);
    Pdu newPdu = new PduParser().parsePdu(pdus.get(0));
    byte[] udh = newPdu.getUDHData();
    if (udh != null) return PduUtils.bytesToPdu(udh);
    return null;
  }
View Full Code Here

  {
    boolean ok = false;
    List<String> pdus = msg.getPdus(getSmscNumber(), this.outMpRefNo);
    for (String pdu : pdus)
    {
      Pdu newPdu = new PduParser().parsePdu(pdu);
      Logger.getInstance().logDebug(newPdu.toString(), null, getGatewayId());
      int j = pdu.length() / 2;
      if (getSmscNumber() == null)
      {
        // Do nothing on purpose!
View Full Code Here

          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)
View Full Code Here

    if ((pdu.hasTpUdhi()) && (getEncoding() == MessageEncodings.ENC7BIT)) { throw new RuntimeException("getPduUserData() not supported for 7-bit messages with UDH"); }
    // sum up the ud parts
    StringBuffer ud = new StringBuffer();
    for (String pduString : pdus)
    {
      Pdu newPdu = new PduParser().parsePdu(pduString);
      ud.append(PduUtils.bytesToPdu(newPdu.getUserDataAsBytes()));
    }
    return ud.toString();
  }
View Full Code Here

TOP

Related Classes of org.ajwcc.pduUtils.gsm3040.SmsDeliveryPdu

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.