Beispiel #1
0
        /// <summary>
        /// Fills the object with values from the data byte.
        /// </summary>
        /// <param name="b">The byte value.</param>
        protected override void FromByte(byte b)
        {
            OutgoingMessageType outgoingMessageType = OutgoingMessageType.SmsSubmit;

            if ((b & 1) > 0)
            {
                outgoingMessageType = OutgoingMessageType.SmsSubmit;
            }
            if (outgoingMessageType == OutgoingMessageType.SmsSubmit)
            {
                this.rejectDuplicates     = (b & 4) > 0;
                this.validityPeriodFormat = ValidityPeriodFormat.Unspecified;
                if ((b & 24) > 0)
                {
                    this.validityPeriodFormat = ValidityPeriodFormat.Absolute;
                }
                if ((b & 16) > 0)
                {
                    this.validityPeriodFormat = ValidityPeriodFormat.Relative;
                }
                if ((b & 8) > 0)
                {
                    this.validityPeriodFormat = ValidityPeriodFormat.Enhanced;
                }
                this.requestStatusReport   = (b & 32) > 0;
                this.userDataHeaderPresent = (b & 64) > 0;
                this.replyPathExists       = (b & 128) > 0;
                return;
            }
            else
            {
                throw new ArgumentException("Not an SMS-SUBMIT message.");
            }
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:GSMCommunication.PDUDecoder.SmsSubmitMessageFlags" /> class.
 /// </summary>
 /// <remarks>
 /// Default settings are:
 /// <list type="bullet">
 /// <item><description>
 /// ReplyPathExists = false
 /// </description></item>
 /// <item><description>
 /// UserDataHeaderPresent = false
 /// </description></item>
 /// <item><description>
 /// RequestStatusReport = false
 /// </description></item>
 /// <item><description>
 /// ValidityPeriodFormat = ValidityPeriodFormat.Unspecified
 /// </description></item>
 /// <item><description>
 /// RejectDuplicates = false
 /// </description></item>
 /// <item><description>
 /// MessageType = OutgoingMessageType.SmsSubmit
 /// </description></item>
 /// </list>
 /// </remarks>
 public SmsSubmitMessageFlags()
 {
     this.rejectDuplicates      = false;
     this.validityPeriodFormat  = ValidityPeriodFormat.Unspecified;
     this.requestStatusReport   = false;
     this.userDataHeaderPresent = false;
     this.replyPathExists       = false;
 }
Beispiel #3
0
        /// <summary>
        /// Returns the byte equivalent of this instance.
        /// </summary>
        /// <returns>The byte value.</returns>
        public override byte ToByte()
        {
            byte num = 0;

            num = (byte)(num | 1);
            if (this.rejectDuplicates)
            {
                num = (byte)(num | 4);
            }
            ValidityPeriodFormat validityPeriodFormat = this.validityPeriodFormat;

            switch (validityPeriodFormat)
            {
            case ValidityPeriodFormat.Relative:
            {
                num = (byte)(num | 16);
                break;
            }

            case ValidityPeriodFormat.Absolute:
            {
                num = (byte)(num | 24);
                break;
            }

            case ValidityPeriodFormat.Enhanced:
            {
                num = (byte)(num | 8);
                break;
            }
            }
            if (this.requestStatusReport)
            {
                num = (byte)(num | 32);
            }
            if (this.userDataHeaderPresent)
            {
                num = (byte)(num | 64);
            }
            if (this.replyPathExists)
            {
                num = (byte)(num | 128);
            }
            return(num);
        }
		/// <summary>
		/// Fills the object with values from the data byte.
		/// </summary>
		/// <param name="b">The byte value.</param>
		protected override void FromByte(byte b)
		{
			OutgoingMessageType outgoingMessageType = OutgoingMessageType.SmsSubmit;
			if ((b & 1) > 0)
			{
				outgoingMessageType = OutgoingMessageType.SmsSubmit;
			}
			if (outgoingMessageType == OutgoingMessageType.SmsSubmit)
			{
				this.rejectDuplicates = (b & 4) > 0;
				this.validityPeriodFormat = ValidityPeriodFormat.Unspecified;
				if ((b & 24) > 0)
				{
					this.validityPeriodFormat = ValidityPeriodFormat.Absolute;
				}
				if ((b & 16) > 0)
				{
					this.validityPeriodFormat = ValidityPeriodFormat.Relative;
				}
				if ((b & 8) > 0)
				{
					this.validityPeriodFormat = ValidityPeriodFormat.Enhanced;
				}
				this.requestStatusReport = (b & 32) > 0;
				this.userDataHeaderPresent = (b & 64) > 0;
				this.replyPathExists = (b & 128) > 0;
				return;
			}
			else
			{
				throw new ArgumentException("Not an SMS-SUBMIT message.");
			}
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="T:GsmComm.PduConverter.SmsSubmitMessageFlags" /> class.
		/// </summary>
		/// <remarks>
		/// Default settings are:
		/// <list type="bullet">
		/// <item><description>
		/// ReplyPathExists = false
		/// </description></item>
		/// <item><description>
		/// UserDataHeaderPresent = false
		/// </description></item>
		/// <item><description>
		/// RequestStatusReport = false
		/// </description></item>
		/// <item><description>
		/// ValidityPeriodFormat = ValidityPeriodFormat.Unspecified
		/// </description></item>
		/// <item><description>
		/// RejectDuplicates = false
		/// </description></item>
		/// <item><description>
		/// MessageType = OutgoingMessageType.SmsSubmit
		/// </description></item>
		/// </list>
		/// </remarks>
		public SmsSubmitMessageFlags()
		{
			this.rejectDuplicates = false;
			this.validityPeriodFormat = ValidityPeriodFormat.Unspecified;
			this.requestStatusReport = false;
			this.userDataHeaderPresent = false;
			this.replyPathExists = false;
		}
Beispiel #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:GsmComm.PduConverter.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.");
            }
        }