public override bool Equals(object obj) { IntStringPair other = obj as IntStringPair; if (other == null) { return(false); } return(Equals(I, other.I) && Equals(S, other.S)); }
// ------------------------------ LoadMessageLines ---------------------------- // load the message lines of the part. public void LoadMessageLines(string InStream, int InStreamBx, int InLineCx) { int Ex = InStreamBx - 1; mMessageLines = new string[InLineCx]; for (int Ix = 0; Ix < InLineCx; ++Ix) { int Bx = Ex + 1; IntStringPair rv = MimeCommon.ScanEndLine(InStream, Bx); Ex = rv.a; mMessageLines[Ix] = rv.b; } }
// ------------------------------ LoadPropertyLines ---------------------------- // load the property lines of the part. public void LoadPropertyLines(string InStream, int InStreamBx, int InLineCx) { int Ex = InStreamBx - 1; mPropertyLines = new string[InLineCx]; for (int Ix = 0; Ix < InLineCx; ++Ix) { int Bx = Ex + 1; IntStringPair rv = MimeCommon.ScanEndUnfoldedLine(InStream, Bx); Ex = rv.a; mPropertyLines[Ix] = rv.b; } // load the property dictionary from the property lines. LoadPropertyDictionary( ); }
// -------------------------- MessagePartSplitter ----------------------- // input is an array holding the unfolded lines of the message. // Build and return a list of MimeMessagePart objects. Each part object holds the // lines of a part of the message. // ( a part is either the header part or the boundary string delimited content parts. public static InMail.MimeMessagePartList MessagePartSplitter(string InStream) { InMail.MimeMessagePartList parts = new InMail.MimeMessagePartList( ); bool currentlyBetweenParts = false; StringStack bdryStack = new StringStack( ); int Ex = -1; string line = null; MimeMessagePart.PartInProgress pip = new MimeMessagePart.PartInProgress(MimePartCode.Top); while (true) { // advance in string. int lineBx = Ex + 1; if (lineBx >= InStream.Length) { break; } // the next line in the stream. recognize folds depending on if currently within // a part header or within the message lines of the part ( no folding there ) if (pip.CurrentlyAmoungPropertyLines == true) { IntStringPair rv = ScanEndUnfoldedLine(InStream, lineBx); Ex = rv.a; line = rv.b; } else { IntStringPair rv = ScanEndLine(InStream, lineBx); Ex = rv.a; line = rv.b; } // calc what kind of a line in the mime document we have here. MimeLineCode lc = MimeParser.CalcLineCode(line, bdryStack.GetTop( )); if ((lc == MimeLineCode.Property) && (pip.CurrentlyAmoungMessageLines == true)) { lc = MimeLineCode.Text; } switch (lc) { case MimeLineCode.Property: { StringPair propPair = MimeParser.SplitPropertyLine(line); // the content-type property. Could have an boundary="xxxxx" element. // Boundary strings in a mime document have scope. That is, within one // boundary ( section ) of the document, there can be sub boundaries // ( sub sections ) if (propPair.a.ToLower( ) == "content-type") { PartProperty.ContentType ct = MimeParser.ParseContentType(propPair.b); if ((ct.Boundary != null) && (ct.Boundary != "")) { bdryStack.Push(ct.Boundary); } } pip.AddLine(lineBx, line); break; } // part boundary line. load the lines of the current part and reset the line // counter of this new part. case MimeLineCode.PartBdry: if (pip.HasLines == true) { parts.AddNewPart(InStream, pip); } pip = new MimeMessagePart.PartInProgress(MimePartCode.Content); currentlyBetweenParts = false; break; case MimeLineCode.PartEndBdry: if (pip.HasLines == true) { parts.AddNewPart(InStream, pip); } pip = new MimeMessagePart.PartInProgress(MimePartCode.Content); if (bdryStack.IsNotEmpty) { bdryStack.Pop( ); } currentlyBetweenParts = true; break; // we have a line which is not a property line, not a boundary line. default: { // just starting out. discard the "+OK" response sent by the server immed // before the start of the message. if ((pip.PartCode == MimePartCode.Top) && (pip.PartIsJustStarting == true) && (line.Length >= 3) && (line.Substring(0, 3) == "+OK")) { } // currently handling property lines. else if (pip.CurrentlyAmoungPropertyLines == true) { // a blank line switches from property lines to message lines. if (line.Length == 0) { pip.CurrentlyAmoungPropertyLines = false; pip.CurrentlyAmoungMessageLines = true; } // what is this text line doing amoung the property lines ?? // for now, just ignore it. else { } } else if (currentlyBetweenParts == false) { pip.AddLine(lineBx, line); } break; } } } // load the lines of the final in progress part. if (pip.HasLines == true) { parts.AddNewPart(InStream, pip); } return(parts); }