[csmaild-cvs] csmaild/src/Imap/Commands FetchCommand.cs,1.4,1.5 ImapCommand.cs,1.6,1.7
Brought to you by:
tamc
From: <ta...@us...> - 2003-07-26 23:55:50
|
Update of /cvsroot/csmaild/csmaild/src/Imap/Commands In directory sc8-pr-cvs1:/tmp/cvs-serv6574/src/Imap/Commands Modified Files: FetchCommand.cs ImapCommand.cs Log Message: FETCH *should* be working, more testing to ensue but need to eat. Oh, did I mention that the code fricken sucks and it should be rewritten, but it works for now ;) Index: FetchCommand.cs =================================================================== RCS file: /cvsroot/csmaild/csmaild/src/Imap/Commands/FetchCommand.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FetchCommand.cs 26 Jul 2003 23:09:25 -0000 1.4 --- FetchCommand.cs 26 Jul 2003 23:55:47 -0000 1.5 *************** *** 1,4 **** --- 1,5 ---- using System; using System.Collections; + using System.Text.RegularExpressions; namespace Imap.Commands *************** *** 19,23 **** { mConnection.SendUntaggedMessage(mParsedArguments[0].ToString()); ! mConnection.SendTaggedMessage(mParsedArguments[1].ToString()); if(mParsedArguments[1] is string) --- 20,24 ---- { mConnection.SendUntaggedMessage(mParsedArguments[0].ToString()); ! mConnection.SendUntaggedMessage(mParsedArguments[1].ToString()); if(mParsedArguments[1] is string) *************** *** 33,37 **** if(parts != null) { ! // process fetch } else --- 34,38 ---- if(parts != null) { ! mConnection.SendTaggedMessage("OK"); } else *************** *** 123,127 **** private FetchParts ParseBodySection(FetchParts rv, string section) { - bool isGood = false; int idx = 0; if(CommandPart.DigitNz.IndexOf(section[idx]) != -1) // a section part --- 124,127 ---- *************** *** 181,185 **** if(!ParseHeaderList(rv.BodySectionPartHeaderFields)) return null; ! ++mListIdx; // move into closing item break; case "HEADER.FIELDS.NOT": --- 181,186 ---- if(!ParseHeaderList(rv.BodySectionPartHeaderFields)) return null; ! section = mList[++mListIdx].ToString(); ! idx = -1; break; case "HEADER.FIELDS.NOT": *************** *** 187,194 **** if(!ParseHeaderList(rv.BodySectionPartHeaderFieldsNot)) return null; ! ++mListIdx; // move into closing item break; default: ! return null; } } --- 188,200 ---- if(!ParseHeaderList(rv.BodySectionPartHeaderFieldsNot)) return null; ! section = mList[++mListIdx].ToString(); ! idx = -1; break; default: ! if(section[idx] != ']') ! return null; ! else ! ++idx; ! break; } } *************** *** 198,205 **** else // must be a named section { - // section-msgtext = "HEADER" / "HEADER.FIELDS" [".NOT"] SP header-list / "TEXT" ; top-level or MESSAGE/RFC822 part - // header-fld-name = astring - // header-list = "(" header-fld-name *(SP header-fld-name) ")" - string left = section.Substring(idx); switch(left) --- 204,207 ---- *************** *** 217,221 **** if(!ParseHeaderList(rv.BodySectionPartHeaderFields)) return null; ! ++mListIdx; // move into closing item break; case "HEADER.FIELDS.NOT": --- 219,228 ---- if(!ParseHeaderList(rv.BodySectionPartHeaderFields)) return null; ! section = mList[++mListIdx].ToString(); ! idx = 0; ! if(section[idx] != ']') ! return null; ! else ! ++idx; break; case "HEADER.FIELDS.NOT": *************** *** 223,243 **** if(!ParseHeaderList(rv.BodySectionPartHeaderFieldsNot)) return null; ! ++mListIdx; // move into closing item break; default: ! return null; } } ! // ["<" number "." nz-number ">"] ! // if(isGood && idx < pieceOfItem.Length) ! // { ! // if(pieceOfItem[idx] == '<') ! // { ! // // TODO: this ! // } ! // else // if their is more, and it's not this, oops ! // return null; ! // } return rv; --- 230,267 ---- if(!ParseHeaderList(rv.BodySectionPartHeaderFieldsNot)) return null; ! section = mList[++mListIdx].ToString(); ! idx = 0; ! if(section[idx] != ']') ! return null; ! else ! ++idx; break; default: ! if(section[idx] != ']') ! return null; ! else ! ++idx; ! break; } } ! // ["<" number "." nz-number ">"] ! if(idx < section.Length) ! { ! if(section[idx] == '<' && section[section.Length-1] == '>') ! { ! string offsetLengthString = section.Substring(idx+1, section.Length-idx-2); ! Match match = Regex.Match(offsetLengthString, @"^([0-9]{0,10}).([1-9][0-9]{0,9})$"); ! if(!match.Success) ! return null; ! ! // TODO: some where we need to make sure that this isn't bigger then uint.Max (4,294,967,295) before we put it into the variable ! rv.BodySectionOffsetLength = true; ! rv.BodySectionOffset = uint.Parse(match.Groups[1].ToString()); ! rv.BodySectionLength = uint.Parse(match.Groups[2].ToString()); ! } ! else // if their is more, and it's not this, oops ! return null; ! } return rv; *************** *** 246,250 **** private bool ParseHeaderList(ArrayList destinationList) { ! return true; } --- 270,287 ---- private bool ParseHeaderList(ArrayList destinationList) { ! if(mList[mListIdx].IsNestedList) ! { ! ParenthesizedList headerList = mList[mListIdx].NestedList; ! for(int idx = 0; idx < headerList.Count; ++idx) ! { ! if(headerList[idx].IsNestedList) ! return false; ! else ! destinationList.Add(headerList[idx].ToString()); ! } ! return true; ! } ! else ! return false; } *************** *** 253,256 **** --- 290,297 ---- public bool Body; public bool BodyPeek; + + public bool BodySectionOffsetLength; + public uint BodySectionOffset; + public uint BodySectionLength; private ArrayList mBodySectionParts; // TODO: make this a strongly typed for ints Index: ImapCommand.cs =================================================================== RCS file: /cvsroot/csmaild/csmaild/src/Imap/Commands/ImapCommand.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ImapCommand.cs 26 Jul 2003 23:09:25 -0000 1.6 --- ImapCommand.cs 26 Jul 2003 23:55:47 -0000 1.7 *************** *** 528,531 **** --- 528,539 ---- } + public bool IsNestedList + { + get + { + return (mNestedList != null); + } + } + public ParenthesizedListItem(object data) { |