Exemple #1
0
		/// <summary>
		/// Initializes a new instance of the <see cref="T:GSMCommunication.PDUDecoder.SmsSubmitPdu" /> class
		/// using the specified PDU string.
		/// </summary>
		/// <param name="pdu">The PDU string to convert.</param>
		/// <param name="includesSmscData">Specifies if the string contains
		/// SMSC data octets at the beginning.</param>
		/// <param name="actualLength">Specifies the actual PDU length, that is the length in bytes without
		/// the SMSC header. Set to -1 if unknown.</param>
		/// <remarks>
		/// <para>This constructor assumes that the string contains an <b>SMS-SUBMIT</b>
		/// PDU data stream as specified
		/// by GSM 07.05.</para>
		/// <para>AbsuluteValidityPeriod and EnhancedValidityPeriod are not
		/// supported and will generate a <see cref="T:System.NotSupportedException" />
		/// when encountered.
		/// </para>
		/// </remarks>
		/// <exception cref="T:System.NotSupportedException">The string contains a
		/// validity and the validity period format is not relative validity.
		/// </exception>
		public SmsSubmitPdu(string pdu, bool includesSmscData, int actualLength)
		{
			byte num = 0;
			byte[] numArray = null;
			int num1;
			if (pdu != string.Empty)
			{
				bool flag = actualLength >= 0;
				int num2 = actualLength;
				if (!flag || num2 > 0)
				{
					int num3 = 0;
					if (!includesSmscData)
					{
						base.SmscAddress = string.Empty;
					}
					else
					{
						int num4 = num3;
						num3 = num4 + 1;
						byte num5 = BcdWorker.GetByte(pdu, num4);
						if (num5 <= 0)
						{
							base.SmscAddress = string.Empty;
						}
						else
						{
							int num6 = num3;
							num3 = num6 + 1;
							byte num7 = BcdWorker.GetByte(pdu, num6);
							int num8 = num5 - 1;
							string bytesString = BcdWorker.GetBytesString(pdu, num3, num8);
							num3 = num3 + num8;
							string str = BcdWorker.DecodeSemiOctets(bytesString);
							if (str.EndsWith("F") || str.EndsWith("f"))
							{
								str = str.Substring(0, str.Length - 1);
							}
							base.SetSmscAddress(str, num7);
						}
					}
					int num9 = num3;
					num3 = num9 + 1;
					this.messageFlags = new SmsSubmitMessageFlags(BcdWorker.GetByte(pdu, num9));
					if (flag)
					{
						num2--;
						if (num2 <= 0)
						{
							base.ConstructLength = num3 * 2;
							return;
						}
					}
					int num10 = num3;
					num3 = num10 + 1;
					base.MessageReference = BcdWorker.GetByte(pdu, num10);
					int num11 = num3;
					num3 = num11 + 1;
					byte num12 = BcdWorker.GetByte(pdu, num11);
					int num13 = num3;
					num3 = num13 + 1;
					byte num14 = BcdWorker.GetByte(pdu, num13);
					if (num12 <= 0)
					{
						this.DestinationAddress = string.Empty;
					}
					else
					{
						if (num12 % 2 != 0)
						{
							num1 = num12 + 1;
						}
						else
						{
							num1 = (int)num12;
						}
						int num15 = num1 / 2;
						string bytesString1 = BcdWorker.GetBytesString(pdu, num3, num15);
						num3 = num3 + num15;
						string str1 = BcdWorker.DecodeSemiOctets(bytesString1).Substring(0, num12);
						this.SetDestinationAddress(str1, num14);
					}
					int num16 = num3;
					num3 = num16 + 1;
					base.ProtocolID = BcdWorker.GetByte(pdu, num16);
					int num17 = num3;
					num3 = num17 + 1;
					base.DataCodingScheme = BcdWorker.GetByte(pdu, num17);
					ValidityPeriodFormat validityPeriodFormat = this.MessageFlags.ValidityPeriodFormat;
					if (validityPeriodFormat == ValidityPeriodFormat.Unspecified)
					{
						this.ValidityPeriod = null;
					}
					else if (validityPeriodFormat == ValidityPeriodFormat.Relative)
					{
						int num18 = num3;
						num3 = num18 + 1;
						this.ValidityPeriod = new RelativeValidityPeriod(BcdWorker.GetByte(pdu, num18));
					}
					else if (validityPeriodFormat == ValidityPeriodFormat.Absolute)
					{
						throw new NotSupportedException("Absolute validity period format not supported.");
					}
					else if (validityPeriodFormat == ValidityPeriodFormat.Enhanced)
					{
						throw new NotSupportedException("Enhanced validity period format not supported.");
					}
					else
					{
						throw new NotSupportedException(string.Concat("Validity period format \"", (object)this.MessageFlags.ValidityPeriodFormat.ToString(), "\" not supported."));
					}
					PduParts.DecodeUserData(pdu, ref num3, base.DataCodingScheme, out num, out numArray);
					base.SetUserData(numArray, num);
					base.ConstructLength = num3 * 2;
					return;
				}
				else
				{
					return;
				}
			}
			else
			{
				throw new ArgumentException("pdu must not be an empty string.");
			}
		}
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:GSMCommunication.PDUDecoder.SmsSubmitPdu" /> class
        /// using the specified PDU string.
        /// </summary>
        /// <param name="pdu">The PDU string to convert.</param>
        /// <param name="includesSmscData">Specifies if the string contains
        /// SMSC data octets at the beginning.</param>
        /// <param name="actualLength">Specifies the actual PDU length, that is the length in bytes without
        /// the SMSC header. Set to -1 if unknown.</param>
        /// <remarks>
        /// <para>This constructor assumes that the string contains an <b>SMS-SUBMIT</b>
        /// PDU data stream as specified
        /// by GSM 07.05.</para>
        /// <para>AbsuluteValidityPeriod and EnhancedValidityPeriod are not
        /// supported and will generate a <see cref="T:System.NotSupportedException" />
        /// when encountered.
        /// </para>
        /// </remarks>
        /// <exception cref="T:System.NotSupportedException">The string contains a
        /// validity and the validity period format is not relative validity.
        /// </exception>
        public SmsSubmitPdu(string pdu, bool includesSmscData, int actualLength)
        {
            byte num = 0;

            byte[] numArray = null;
            int    num1;

            if (pdu != string.Empty)
            {
                bool flag = actualLength >= 0;
                int  num2 = actualLength;
                if (!flag || num2 > 0)
                {
                    int num3 = 0;
                    if (!includesSmscData)
                    {
                        base.SmscAddress = string.Empty;
                    }
                    else
                    {
                        int num4 = num3;
                        num3 = num4 + 1;
                        byte num5 = BcdWorker.GetByte(pdu, num4);
                        if (num5 <= 0)
                        {
                            base.SmscAddress = string.Empty;
                        }
                        else
                        {
                            int num6 = num3;
                            num3 = num6 + 1;
                            byte   num7        = BcdWorker.GetByte(pdu, num6);
                            int    num8        = num5 - 1;
                            string bytesString = BcdWorker.GetBytesString(pdu, num3, num8);
                            num3 = num3 + num8;
                            string str = BcdWorker.DecodeSemiOctets(bytesString);
                            if (str.EndsWith("F") || str.EndsWith("f"))
                            {
                                str = str.Substring(0, str.Length - 1);
                            }
                            base.SetSmscAddress(str, num7);
                        }
                    }
                    int num9 = num3;
                    num3 = num9 + 1;
                    this.messageFlags = new SmsSubmitMessageFlags(BcdWorker.GetByte(pdu, num9));
                    if (flag)
                    {
                        num2--;
                        if (num2 <= 0)
                        {
                            base.ConstructLength = num3 * 2;
                            return;
                        }
                    }
                    int num10 = num3;
                    num3 = num10 + 1;
                    base.MessageReference = BcdWorker.GetByte(pdu, num10);
                    int num11 = num3;
                    num3 = num11 + 1;
                    byte num12 = BcdWorker.GetByte(pdu, num11);
                    int  num13 = num3;
                    num3 = num13 + 1;
                    byte num14 = BcdWorker.GetByte(pdu, num13);
                    if (num12 <= 0)
                    {
                        this.DestinationAddress = string.Empty;
                    }
                    else
                    {
                        if (num12 % 2 != 0)
                        {
                            num1 = num12 + 1;
                        }
                        else
                        {
                            num1 = (int)num12;
                        }
                        int    num15        = num1 / 2;
                        string bytesString1 = BcdWorker.GetBytesString(pdu, num3, num15);
                        num3 = num3 + num15;
                        string str1 = BcdWorker.DecodeSemiOctets(bytesString1).Substring(0, num12);
                        this.SetDestinationAddress(str1, num14);
                    }
                    int num16 = num3;
                    num3            = num16 + 1;
                    base.ProtocolID = BcdWorker.GetByte(pdu, num16);
                    int num17 = num3;
                    num3 = num17 + 1;
                    base.DataCodingScheme = BcdWorker.GetByte(pdu, num17);
                    ValidityPeriodFormat validityPeriodFormat = this.MessageFlags.ValidityPeriodFormat;
                    if (validityPeriodFormat == ValidityPeriodFormat.Unspecified)
                    {
                        this.ValidityPeriod = null;
                    }
                    else if (validityPeriodFormat == ValidityPeriodFormat.Relative)
                    {
                        int num18 = num3;
                        num3 = num18 + 1;
                        this.ValidityPeriod = new RelativeValidityPeriod(BcdWorker.GetByte(pdu, num18));
                    }
                    else if (validityPeriodFormat == ValidityPeriodFormat.Absolute)
                    {
                        throw new NotSupportedException("Absolute validity period format not supported.");
                    }
                    else if (validityPeriodFormat == ValidityPeriodFormat.Enhanced)
                    {
                        throw new NotSupportedException("Enhanced validity period format not supported.");
                    }
                    else
                    {
                        throw new NotSupportedException(string.Concat("Validity period format \"", (object)this.MessageFlags.ValidityPeriodFormat.ToString(), "\" not supported."));
                    }
                    PduParts.DecodeUserData(pdu, ref num3, base.DataCodingScheme, out num, out numArray);
                    base.SetUserData(numArray, num);
                    base.ConstructLength = num3 * 2;
                    return;
                }
                else
                {
                    return;
                }
            }
            else
            {
                throw new ArgumentException("pdu must not be an empty string.");
            }
        }
Exemple #3
0
		/// <summary>
		/// Initializes a new <see cref="T:GSMCommunication.PDUDecoder.SmsSubmitPdu" /> instance using default values.
		/// </summary>
		public SmsSubmitPdu()
		{
			this.messageFlags = new SmsSubmitMessageFlags();
			this.DestinationAddress = string.Empty;
			this.ValidityPeriod = new RelativeValidityPeriod(167);
		}
Exemple #4
0
 /// <summary>
 /// Initializes a new <see cref="T:GSMCommunication.PDUDecoder.SmsSubmitPdu" /> instance using default values.
 /// </summary>
 public SmsSubmitPdu()
 {
     this.messageFlags       = new SmsSubmitMessageFlags();
     this.DestinationAddress = string.Empty;
     this.ValidityPeriod     = new RelativeValidityPeriod(167);
 }