Tryign to debug code where TidMessage decides what type of decoding to use.

Giganews Newsgroups
Subject: Tryign to debug code where TidMessage decides what type of decoding to use.
Posted by:  Jason Chapman (jason@nospamjac2.co.uk)
Date: Mon, 13 Dec 2004

All,

Have not tried debugging the actual INDY code before and having a bit of
difficulty.

I have an attachment (inbound from a pop3 server) that INDY 9 & 10 are
intepreting at plain text.  The header for the section is:

Content-Type: application/octet-stream; charsetiso-8859-1; nameSTMT.20=
041209.6072.zm9
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename"STMT.20041209.6072.zm9"

UEsDBBQAAQBjAMquiTEAAAAAbwMAAIwiAAAWAAsAU1RNVC4yMDA0MTIwOS42MDcyLkNTVg=
GZBwAC

When I ask that the message gets decoded I get:
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Content-Type: application/octet-stream; charsetiso-8859-1; nameSTMT.20=
041209.6072.zm9
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename"STMT.20041209.6072.zm9"

As I step through the code, I can see that in TIdMessageClient.ReceiveBody
there is some decision code.  All the work seems to be done in:
          LLine := IOHandler.ReadLn;
          if LLine = ADelim then begin
            Break;
          end;
          if LActiveDecoder = nil then begin
            LActiveDecoder := TIdMessageDecoderList.CheckForStart(AMsg,
LLine);
          end;
          // Check again, the if above can set it.
          if LActiveDecoder = nil then begin
            if (LLine <> '') and (LLine[1] = '.') then begin            {do
not localize}
              Delete(LLine, 1, 1);
            end;
            AMsg.Body.Add(LLine);
          end else begin
            RemoveLastBlankLine(AMsg.Body);
            while LActiveDecoder <> nil do begin
              LActiveDecoder.SourceStream := TIdTCPStream.Create(Self);
              LPreviousParentPart := AMsg.MIMEBoundary.ParentPart;
              LActiveDecoder.ReadHeader;
              case LActiveDecoder.PartType of
                mcptUnknown:
                  EIdException.Toss(RSMsgClientUnkownMessagePartType);
                mcptText:
                  LActiveDecoder := ProcessTextPart(LActiveDecoder);
                mcptAttachment:
                  LActiveDecoder := ProcessAttachment(LActiveDecoder);
              end;

I am struggling to find the bit of code that has a conditional or case
statement based on the content-type.  It is a bit "wood for trees" as there
is a lot of abstraction in the code and I am never sure whether the data
being processed is part of the raw text, or something indy has added.

So Q
1) Should indy handle:
Content-Type: application/octet-stream; charsetiso-8859-1; nameSTMT.20=
041209.6072.zm9
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename"STMT.20041209.6072.zm9"
2) Where should I be looking to actually deal with this and check why it is
failing and marking as a text attachment.

TIA.

JAC.

Replies