/// <summary> /// Decodes a user data header into information elements. /// </summary> /// <param name="userDataHeader">The user data header to be decoded.</param> /// <returns>The elements found as an array of <see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.InformationElement" /> objects.</returns> /// <remarks> /// <para>Known information elements are decoded into their respective objects, while unknown /// information elements are stored in generic <see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.UnknownInformationElement" /> objects.</para> /// <para>The list of known information elements consists of elements used within Smart Messaging, /// and does not aim to be a complete set of all existing elements.</para> /// <para>The currently recognized elements are:</para> /// <list type="bullet"> /// <item><description><see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.ConcatMessageElement8" /></description></item> /// <item><description><see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.ConcatMessageElement16" /></description></item> /// <item><description><see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.PortAddressElement16" /></description></item> /// </list> /// </remarks> public static InformationElement[] DecodeUserDataHeader(byte[] userDataHeader) { InformationElement unknownInformationElement; List <InformationElement> informationElements = new List <InformationElement>(); byte num = 0; byte num1 = userDataHeader[0]; if (num1 > 0) { num = (byte)(num + 1); do { byte num2 = num; num = (byte)(num2 + 1); byte num3 = userDataHeader[num2]; byte num4 = num; num = (byte)(num4 + 1); byte num5 = userDataHeader[num4]; byte[] numArray = new byte[num5 + 2]; Array.Copy(userDataHeader, num - 2, numArray, 0, num5 + 2); num = (byte)(num + num5); if (num3 != 0) { if (num3 != 8) { if (num3 != 5) { unknownInformationElement = new UnknownInformationElement(numArray); } else { unknownInformationElement = new PortAddressElement16(numArray); } } else { unknownInformationElement = new ConcatMessageElement16(numArray); } } else { unknownInformationElement = new ConcatMessageElement8(numArray); } informationElements.Add(unknownInformationElement); }while (num < num1); } return(informationElements.ToArray()); }
/// <summary> /// Creates an operator logo message. /// </summary> /// <param name="operatorLogo">The operator logo. Use <see cref="M:GSMCommunication.PDUDecoder.SmartMessaging.SmartMessageFactory.CreateOperatorLogo(GSMCommunication.PDUDecoder.SmartMessaging.OtaBitmap,System.String,System.String)" /> to create one.</param> /// <param name="destinationAddress">The message's destination address.</param> /// <returns>A set of <see cref="T:GSMCommunication.PDUDecoder.SmsSubmitPdu" /> objects that represent the message.</returns> /// <exception cref="T:System.ArgumentNullException">operatorLogo is null.</exception> /// <exception cref="T:System.ArgumentException"><para>operatorLogo is an empty array.</para> /// <para> -or- </para><para>destinationAddress is an empty string.</para> /// <para> -or- </para><para>operatorLogo is so big that it would create more than 255 message parts.</para></exception> public static SmsSubmitPdu[] CreateOperatorLogoMessage(byte[] operatorLogo, string destinationAddress) { int length; if (operatorLogo != null) { if ((int)operatorLogo.Length != 0) { PortAddressElement16 portAddressElement16 = new PortAddressElement16(5506, 0); byte num = (byte)((int)portAddressElement16.ToByteArray().Length); int num1 = num + 1; bool flag = (int)operatorLogo.Length > 140 - num1; if (flag) { ConcatMessageElement8 concatMessageElement8 = new ConcatMessageElement8(0, 0, 0); num = (byte)((int)portAddressElement16.ToByteArray().Length + (int)concatMessageElement8.ToByteArray().Length); num1 = num + 1; } ArrayList arrayLists = new ArrayList(); int num2 = 0; byte num3 = (byte)Math.Ceiling((double)((int)operatorLogo.Length) / (double)(140 - num1)); if (arrayLists.Count <= 255) { ushort num4 = 1; if (flag) { num4 = SmartMessageFactory.CalcNextRefNumber(); } for (byte i = 1; i <= num3; i = (byte)(i + 1)) { if ((int)operatorLogo.Length - num2 < 140 - num1) { length = (int)operatorLogo.Length - num2; } else { length = 140 - num1; } byte[] numArray = new byte[num1]; int length1 = 0; int num5 = length1; length1 = num5 + 1; numArray[num5] = num; portAddressElement16.ToByteArray().CopyTo(numArray, length1); length1 = length1 + (int)portAddressElement16.ToByteArray().Length; if (flag) { ConcatMessageElement8 concatMessageElement81 = new ConcatMessageElement8((byte)(num4 % 256), num3, i); concatMessageElement81.ToByteArray().CopyTo(numArray, length1); length1 = length1 + (int)concatMessageElement81.ToByteArray().Length; } byte[] numArray1 = new byte[(int)numArray.Length + length]; numArray.CopyTo(numArray1, 0); Array.Copy(operatorLogo, num2, numArray1, length1, length); SmsSubmitPdu smsSubmitPdu = new SmsSubmitPdu(); smsSubmitPdu.MessageFlags.UserDataHeaderPresent = true; smsSubmitPdu.DataCodingScheme = 21; smsSubmitPdu.DestinationAddress = destinationAddress; smsSubmitPdu.SetUserData(numArray1, (byte)((int)numArray1.Length)); arrayLists.Add(smsSubmitPdu); num2 = num2 + length; } SmsSubmitPdu[] smsSubmitPduArray = new SmsSubmitPdu[arrayLists.Count]; arrayLists.CopyTo(smsSubmitPduArray, 0); return(smsSubmitPduArray); } else { throw new ArgumentException("A concatenated message must not have more than 255 parts.", "operatorLogo"); } } else { throw new ArgumentException("operatorLogo must not be an empty array.", "operatorLogo"); } } else { throw new ArgumentNullException("operatorLogo"); } }
/// <summary> /// Decodes a user data header into information elements. /// </summary> /// <param name="userDataHeader">The user data header to be decoded.</param> /// <returns>The elements found as an array of <see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.InformationElement" /> objects.</returns> /// <remarks> /// <para>Known information elements are decoded into their respective objects, while unknown /// information elements are stored in generic <see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.UnknownInformationElement" /> objects.</para> /// <para>The list of known information elements consists of elements used within Smart Messaging, /// and does not aim to be a complete set of all existing elements.</para> /// <para>The currently recognized elements are:</para> /// <list type="bullet"> /// <item><description><see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.ConcatMessageElement8" /></description></item> /// <item><description><see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.ConcatMessageElement16" /></description></item> /// <item><description><see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.PortAddressElement16" /></description></item> /// </list> /// </remarks> public static InformationElement[] DecodeUserDataHeader(byte[] userDataHeader) { InformationElement unknownInformationElement; List<InformationElement> informationElements = new List<InformationElement>(); byte num = 0; byte num1 = userDataHeader[0]; if (num1 > 0) { num = (byte)(num + 1); do { byte num2 = num; num = (byte)(num2 + 1); byte num3 = userDataHeader[num2]; byte num4 = num; num = (byte)(num4 + 1); byte num5 = userDataHeader[num4]; byte[] numArray = new byte[num5 + 2]; Array.Copy(userDataHeader, num - 2, numArray, 0, num5 + 2); num = (byte)(num + num5); if (num3 != 0) { if (num3 != 8) { if (num3 != 5) { unknownInformationElement = new UnknownInformationElement(numArray); } else { unknownInformationElement = new PortAddressElement16(numArray); } } else { unknownInformationElement = new ConcatMessageElement16(numArray); } } else { unknownInformationElement = new ConcatMessageElement8(numArray); } informationElements.Add(unknownInformationElement); } while (num < num1); } return informationElements.ToArray(); }
/// <summary> /// Creates an operator logo message. /// </summary> /// <param name="operatorLogo">The operator logo. Use <see cref="M:GSMCommunication.PDUDecoder.SmartMessaging.SmartMessageFactory.CreateOperatorLogo(GSMCommunication.PDUDecoder.SmartMessaging.OtaBitmap,System.String,System.String)" /> to create one.</param> /// <param name="destinationAddress">The message's destination address.</param> /// <returns>A set of <see cref="T:GSMCommunication.PDUDecoder.SmsSubmitPdu" /> objects that represent the message.</returns> /// <exception cref="T:System.ArgumentNullException">operatorLogo is null.</exception> /// <exception cref="T:System.ArgumentException"><para>operatorLogo is an empty array.</para> /// <para> -or- </para><para>destinationAddress is an empty string.</para> /// <para> -or- </para><para>operatorLogo is so big that it would create more than 255 message parts.</para></exception> public static SmsSubmitPdu[] CreateOperatorLogoMessage(byte[] operatorLogo, string destinationAddress) { int length; if (operatorLogo != null) { if ((int)operatorLogo.Length != 0) { PortAddressElement16 portAddressElement16 = new PortAddressElement16(5506, 0); byte num = (byte)((int)portAddressElement16.ToByteArray().Length); int num1 = num + 1; bool flag = (int)operatorLogo.Length > 140 - num1; if (flag) { ConcatMessageElement8 concatMessageElement8 = new ConcatMessageElement8(0, 0, 0); num = (byte)((int)portAddressElement16.ToByteArray().Length + (int)concatMessageElement8.ToByteArray().Length); num1 = num + 1; } ArrayList arrayLists = new ArrayList(); int num2 = 0; byte num3 = (byte)Math.Ceiling((double)((int)operatorLogo.Length) / (double)(140 - num1)); if (arrayLists.Count <= 255) { ushort num4 = 1; if (flag) { num4 = SmartMessageFactory.CalcNextRefNumber(); } for (byte i = 1; i <= num3; i = (byte)(i + 1)) { if ((int)operatorLogo.Length - num2 < 140 - num1) { length = (int)operatorLogo.Length - num2; } else { length = 140 - num1; } byte[] numArray = new byte[num1]; int length1 = 0; int num5 = length1; length1 = num5 + 1; numArray[num5] = num; portAddressElement16.ToByteArray().CopyTo(numArray, length1); length1 = length1 + (int)portAddressElement16.ToByteArray().Length; if (flag) { ConcatMessageElement8 concatMessageElement81 = new ConcatMessageElement8((byte)(num4 % 256), num3, i); concatMessageElement81.ToByteArray().CopyTo(numArray, length1); length1 = length1 + (int)concatMessageElement81.ToByteArray().Length; } byte[] numArray1 = new byte[(int)numArray.Length + length]; numArray.CopyTo(numArray1, 0); Array.Copy(operatorLogo, num2, numArray1, length1, length); SmsSubmitPdu smsSubmitPdu = new SmsSubmitPdu(); smsSubmitPdu.MessageFlags.UserDataHeaderPresent = true; smsSubmitPdu.DataCodingScheme = 21; smsSubmitPdu.DestinationAddress = destinationAddress; smsSubmitPdu.SetUserData(numArray1, (byte)((int)numArray1.Length)); arrayLists.Add(smsSubmitPdu); num2 = num2 + length; } SmsSubmitPdu[] smsSubmitPduArray = new SmsSubmitPdu[arrayLists.Count]; arrayLists.CopyTo(smsSubmitPduArray, 0); return smsSubmitPduArray; } else { throw new ArgumentException("A concatenated message must not have more than 255 parts.", "operatorLogo"); } } else { throw new ArgumentException("operatorLogo must not be an empty array.", "operatorLogo"); } } else { throw new ArgumentNullException("operatorLogo"); } }