/// <summary> /// Determines whether two messages are part of the same concatenated message. /// </summary> /// <param name="pdu1">The first message to compare.</param> /// <param name="pdu2">The second message to compare.</param> /// <returns>true if both messages appear to belong to the same concatenated message, false otherwise.</returns> /// <remarks> /// <para>This comparison is supported for <see cref="T:GSMCommunication.PDUDecoder.SmsSubmitPdu" /> and <see cref="T:GSMCommunication.PDUDecoder.SmsDeliverPdu" /> objects. /// For all other objects, this comparison always returns false.</para> /// <para>For <see cref="T:GSMCommunication.PDUDecoder.SmsSubmitPdu" /> objects, the <see cref="P:GSMCommunication.PDUDecoder.SmsSubmitPdu.DestinationAddress" />, /// <see cref="P:GSMCommunication.PDUDecoder.SmsSubmitPdu.DestinationAddressType" /> and <see cref="P:GSMCommunication.PDUDecoder.SmartMessaging.IConcatenationInfo.ReferenceNumber" /> properties are compared.</para> /// <para>For <see cref="T:GSMCommunication.PDUDecoder.SmsDeliverPdu" /> objects, the <see cref="P:GSMCommunication.PDUDecoder.SmsDeliverPdu.OriginatingAddress" />, /// <see cref="P:GSMCommunication.PDUDecoder.SmsDeliverPdu.OriginatingAddressType" /> and <see cref="P:GSMCommunication.PDUDecoder.SmartMessaging.IConcatenationInfo.ReferenceNumber" /> properties are compared.</para> /// </remarks> /// <exception cref="T:System.ArgumentNullException">pdu1 or pdu2 is null.</exception> public static bool ArePartOfSameMessage(SmsPdu pdu1, SmsPdu pdu2) { if (pdu1 != null) { if (pdu2 != null) { bool flag = false; if (pdu1 as SmsDeliverPdu == null || pdu2 as SmsDeliverPdu == null) { if (pdu1 is SmsSubmitPdu && pdu2 is SmsSubmitPdu) { SmsSubmitPdu smsSubmitPdu = (SmsSubmitPdu)pdu1; SmsSubmitPdu smsSubmitPdu1 = (SmsSubmitPdu)pdu2; if (smsSubmitPdu.DestinationAddress == smsSubmitPdu1.DestinationAddress && smsSubmitPdu.DestinationAddressType == smsSubmitPdu1.DestinationAddressType) { flag = SmartMessageDecoder.HaveSameReferenceNumber(pdu1, pdu2); } } } else { SmsDeliverPdu smsDeliverPdu = (SmsDeliverPdu)pdu1; SmsDeliverPdu smsDeliverPdu1 = (SmsDeliverPdu)pdu2; if (smsDeliverPdu.OriginatingAddress == smsDeliverPdu1.OriginatingAddress && smsDeliverPdu.OriginatingAddressType == smsDeliverPdu1.OriginatingAddressType) { flag = SmartMessageDecoder.HaveSameReferenceNumber(pdu1, pdu2); } } return flag; } else { throw new ArgumentNullException("pdu2"); } } else { throw new ArgumentNullException("pdu1"); } }
private static bool HaveSameReferenceNumber(SmsPdu pdu1, SmsPdu pdu2) { bool flag = false; if (SmartMessageDecoder.IsPartOfConcatMessage(pdu1) && SmartMessageDecoder.IsPartOfConcatMessage(pdu2)) { IConcatenationInfo concatenationInfo = SmartMessageDecoder.GetConcatenationInfo(pdu1); IConcatenationInfo concatenationInfo1 = SmartMessageDecoder.GetConcatenationInfo(pdu2); if (concatenationInfo.ReferenceNumber == concatenationInfo1.ReferenceNumber) { flag = true; } } return flag; }
/// <summary> /// Determines whether a message is part of a concatenated message. /// </summary> /// <param name="pdu">The message.</param> /// <returns>true if the message is part of a concatenated message, false otherwise.</returns> public static bool IsPartOfConcatMessage(SmsPdu pdu) { return SmartMessageDecoder.GetConcatenationInfo(pdu) != null; }
/// <summary> /// Gets the concatenation information of a message. /// </summary> /// <param name="pdu">The message to get the information of.</param> /// <returns>An object implementing <see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.IConcatenationInfo" />, if /// the message is a part of a concatenated message, null otherwise.</returns> /// <remarks> /// <para>The returned information can be used to discover the parts of a concatenated message /// or recombine the parts back into one message.</para> /// </remarks> public static IConcatenationInfo GetConcatenationInfo(SmsPdu pdu) { if (pdu != null) { IConcatenationInfo concatenationInfo = null; if (pdu.UserDataHeaderPresent) { byte[] userDataHeader = pdu.GetUserDataHeader(); InformationElement[] informationElementArray = SmartMessageDecoder.DecodeUserDataHeader(userDataHeader); InformationElement[] informationElementArray1 = informationElementArray; int num = 0; while (num < (int)informationElementArray1.Length) { InformationElement informationElement = informationElementArray1[num]; if (informationElement as IConcatenationInfo == null) { num++; } else { concatenationInfo = (IConcatenationInfo)informationElement; break; } } } return concatenationInfo; } else { throw new ArgumentNullException("pdu"); } }