csmail-patches Mailing List for CS Mail API
Status: Pre-Alpha
Brought to you by:
mastergaurav
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(36) |
Aug
(25) |
Sep
(49) |
Oct
(28) |
Nov
(2) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(2) |
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2004 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <mas...@us...> - 2004-02-07 15:13:57
|
Update of /cvsroot/csmail/CVSROOT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5967 Modified Files: loginfo Log Message: 2004-02-07 Gaurav Vaish <mastergaurav@> * loginfo: I still insist on using my personal copy of syncmail. Index: loginfo =================================================================== RCS file: /cvsroot/csmail/CVSROOT/loginfo,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** loginfo 7 Feb 2004 14:55:02 -0000 1.3 --- loginfo 7 Feb 2004 15:11:03 -0000 1.4 *************** *** 26,32 **** #DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog ! #CVSROOT $CVSROOT/CVSROOT/syncmail %{sVv} mas...@us... ! #ALL $CVSROOT/CVSROOT/syncmail %{sVv} csm...@li... ! CVSROOT /cvsroot/sitedocs/CVSROOT/cvstools/syncmail %{sVv} mas...@us... ! ALL /cvsroot/sitedocs/CVSROOT/cvstools/syncmail %{sVv} csm...@li... --- 26,32 ---- #DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog ! CVSROOT $CVSROOT/CVSROOT/syncmail %{sVv} mas...@us... ! ALL $CVSROOT/CVSROOT/syncmail %{sVv} csm...@li... ! #CVSROOT /cvsroot/sitedocs/CVSROOT/cvstools/syncmail %{sVv} mas...@us... ! #ALL /cvsroot/sitedocs/CVSROOT/cvstools/syncmail %{sVv} csm...@li... |
From: <mas...@us...> - 2004-02-07 15:13:19
|
Update of /cvsroot/csmail/CVSROOT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5890 Modified Files: syncmail Log Message: 2004-02-07 Gaurav Vaish <mastergaurav@> * syncmail: My new copy. Index: syncmail =================================================================== RCS file: /cvsroot/csmail/CVSROOT/syncmail,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** syncmail 24 Jul 2002 10:18:21 -0000 1.1 --- syncmail 7 Feb 2004 15:10:18 -0000 1.2 *************** *** 1,4 **** #! /usr/bin/python ! # -*- Python -*- """Complicated notification for CVS checkins. --- 1,6 ---- #! /usr/bin/python ! ! # NOTE: Until SourceForge installs a modern version of Python on the cvs ! # servers, this script MUST be compatible with Python 1.5.2. """Complicated notification for CVS checkins. *************** *** 11,19 **** set this up, create a loginfo entry that looks something like this: ! mymodule /path/to/syncmail %%s som...@yo...main ! In this example, whenever a checkin that matches `mymodule' is made, the ! syncmail script is invoked, which will generate the diff containing email, and ! send it to som...@yo...main. Note: This module used to also do repository synchronizations via --- 13,21 ---- set this up, create a loginfo entry that looks something like this: ! mymodule /path/to/this/script %%s som...@yo...main ! In this example, whenever a checkin that matches `mymodule' is made, this ! script is invoked, which will generate the diff containing email, and send it ! to som...@yo...main. Note: This module used to also do repository synchronizations via *************** *** 21,26 **** this is no longer necessary. The syncing functionality has been ripped out in the 3.0, which simplifies it considerably. Access the 2.x versions ! to refer to this functionality. Because of this, the script's name is ! misleading. It no longer makes sense to run this script from the command line. Doing so --- 23,27 ---- this is no longer necessary. The syncing functionality has been ripped out in the 3.0, which simplifies it considerably. Access the 2.x versions ! to refer to this functionality. Because of this, the script is misnamed. It no longer makes sense to run this script from the command line. Doing so *************** *** 29,44 **** Usage: ! syncmail [options] <%%S> email-addr [email-addr ...] ! Where options is: --cvsroot=<path> ! Use <path> as the environment variable CVSROOT. Otherwise this ! variable must exist in the environment. ! --help ! -h Print this text. <%%S> CVS %%s loginfo expansion. When invoked by CVS, this will be a single --- 30,65 ---- Usage: ! %(PROGRAM)s [options] <%%S> email-addr [email-addr ...] ! Where options are: --cvsroot=<path> ! Use <path> as the environment variable CVSROOT. Otherwise this ! variable must exist in the environment. ! --context=# ! -C # ! Include # lines of context around lines that differ (default: 2). ! ! -c ! Produce a context diff (default). ! ! -u ! Produce a unified diff (smaller). ! ! --quiet / -q ! Don't print as much status to stdout. ! ! --fromhost=hostname ! -f hostname ! The hostname that email messages appear to be coming from. The From: ! header will of the outgoing message will look like user@hostname. By ! default, hostname is the machine's fully qualified domain name. ! ! --help / -h Print this text. + The rest of the command line arguments are: + <%%S> CVS %%s loginfo expansion. When invoked by CVS, this will be a single *************** *** 50,64 **** email-addrs At least one email address. - """ - import os import sys ! import string import time import getopt ! # Notification command ! MAILCMD = '/usr/bin/mail -s "CVS: %(SUBJECT)s" %(PEOPLE)s 2>&1 > /dev/null' # Diff trimming stuff --- 71,108 ---- email-addrs At least one email address. """ import os import sys ! import re import time + import string import getopt + import smtplib + import pwd + import socket ! try: ! from socket import getfqdn ! except ImportError: ! def getfqdn(): ! # Python 1.5.2 :( ! hostname = socket.gethostname() ! byaddr = socket.gethostbyaddr(socket.gethostbyname(hostname)) ! aliases = byaddr[1] ! aliases.insert(0, byaddr[0]) ! aliases.insert(0, hostname) ! for fqdn in aliases: ! if '.' in fqdn: ! break ! else: ! fqdn = 'localhost.localdomain' ! return fqdn ! ! ! from cStringIO import StringIO ! ! # Which SMTP server to do we connect to? Empty string means localhost. ! MAILHOST = '' ! MAILPORT = 25 # Diff trimming stuff *************** *** 66,96 **** DIFF_TAIL_LINES = 20 DIFF_TRUNCATE_IF_LARGER = 1000 - #DIFF_HEAD_LINES = 1 - #DIFF_TAIL_LINES = 1 - #DIFF_TRUNCATE_IF_LARGER = 1 ! def usage(errcode, msg=''): print __doc__ % globals() ! if msg: print msg ! sys.exit(errorcode) ! def calculate_diff(filespec): ! try: ! file, oldrev, newrev = string.split(filespec, ',') ! except ValueError: ! # No diff to report ! return '***** Bogus filespec: %s' % filespec if oldrev == 'NONE': try: ! fp = open(file) lines = fp.readlines() fp.close() ! lines.insert(0, '--- NEW FILE ---\n') except IOError, e: lines = ['***** Error reading new file: ', ! str(e)] elif newrev == 'NONE': lines = ['--- %s DELETED ---\n' % file] --- 110,183 ---- DIFF_TAIL_LINES = 20 DIFF_TRUNCATE_IF_LARGER = 1000 + EMPTYSTRING = '' + SPACE = ' ' + DOT = '.' + COMMASPACE = ', ' ! PROGRAM = sys.argv[0] ! ! BINARY_EXPLANATION_LINES = [ ! "(This appears to be a binary file; contents omitted.)\n" ! ] ! ! REVCRE = re.compile("^(NONE|[0-9.]+)$") ! NOVERSION = "Couldn't generate diff; no version number found in filespec: %s" ! BACKSLASH = "Couldn't generate diff: backslash in filespec's filename: %s" ! ! def usage(code, msg=''): print __doc__ % globals() ! if msg: ! print msg ! sys.exit(code) + def calculate_diff(filespec, contextlines): + file, oldrev, newrev = string.split(filespec, ',') + # Make sure we can find a CVS version number + if not REVCRE.match(oldrev): + return NOVERSION % filespec + if not REVCRE.match(newrev): + return NOVERSION % filespec + if string.find(file, '\\') <> -1: + # I'm sorry, a file name that contains a backslash is just too much. + # XXX if someone wants to figure out how to escape the backslashes in + # a safe way to allow filenames containing backslashes, this is the + # place to do it. --Zooko 2002-03-17 + return BACKSLASH % filespec ! if string.find(file, "'") <> -1: ! # Those crazy users put single-quotes in their file names! Now we ! # have to escape everything that is meaningful inside double-quotes. ! filestr = string.replace(file, '`', '\`') ! filestr = string.replace(filestr, '"', '\"') ! filestr = string.replace(filestr, '$', '\$') ! # and quote it with double-quotes. ! filestr = '"' + filestr + '"' ! else: ! # quote it with single-quotes. ! filestr = "'" + file + "'" if oldrev == 'NONE': try: ! if os.path.exists(file): ! fp = open(file) ! else: ! update_cmd = "cvs -fn update -r %s -p %s" % (newrev, filestr) ! fp = os.popen(update_cmd) lines = fp.readlines() fp.close() ! # Is this a binary file? Let's look at the first few ! # lines to figure it out: ! for line in lines[:5]: ! for c in string.rstrip(line): ! if c in string.whitespace: ! continue ! if c < ' ' or c > chr(127): ! lines = BINARY_EXPLANATION_LINES[:] ! break ! lines.insert(0, '--- NEW FILE: %s ---\n' % file) except IOError, e: lines = ['***** Error reading new file: ', ! str(e), '\n***** file: ', file, ' cwd: ', os.getcwd()] elif newrev == 'NONE': lines = ['--- %s DELETED ---\n' % file] *************** *** 98,103 **** # This /has/ to happen in the background, otherwise we'll run into CVS # lock contention. What a crock. ! diffcmd = '/usr/bin/cvs -f diff -kk -u -r %s -r %s %s' % ( ! oldrev, newrev, file) fp = os.popen(diffcmd) lines = fp.readlines() --- 185,194 ---- # This /has/ to happen in the background, otherwise we'll run into CVS # lock contention. What a crock. ! #if contextlines > 0: ! # difftype = "-C " + str(contextlines) ! #else: ! difftype = "-u" ! diffcmd = "/usr/bin/cvs -f diff -kk %s --minimal -r %s -r %s %s" \ ! % (difftype, oldrev, newrev, filestr) fp = os.popen(diffcmd) lines = fp.readlines() *************** *** 106,124 **** ## if sts: ## return 'Error code %d occurred during diff\n' % (sts >> 8) ! ## ! ##--------------------------------------------------------------- ! ## ALL LINES TO BE Printed. Doesn't matter how large is the diff ! ##--------------------------------------------------------------- ! ## ! ## if len(lines) > DIFF_TRUNCATE_IF_LARGER: ! ## removedlines = len(lines) - DIFF_HEAD_LINES - DIFF_TAIL_LINES ! ## del lines[DIFF_HEAD_LINES:-DIFF_TAIL_LINES] ! ## lines.insert(DIFF_HEAD_LINES, ! ## '[...%d lines suppressed...]\n' % removedlines) return string.join(lines, '') ! ! ! def blast_mail(mailcmd, filestodiff): # cannot wait for child process or that will cause parent to retain cvs # lock for too long. Urg! --- 197,208 ---- ## if sts: ## return 'Error code %d occurred during diff\n' % (sts >> 8) ! if len(lines) > DIFF_TRUNCATE_IF_LARGER: ! removedlines = len(lines) - DIFF_HEAD_LINES - DIFF_TAIL_LINES ! del lines[DIFF_HEAD_LINES:-DIFF_TAIL_LINES] ! lines.insert(DIFF_HEAD_LINES, ! '[...%d lines suppressed...]\n' % removedlines) return string.join(lines, '') ! def blast_mail(subject, people, filestodiff, contextlines, fromhost): # cannot wait for child process or that will cause parent to retain cvs # lock for too long. Urg! *************** *** 127,151 **** # give up the lock you cvs thang! time.sleep(2) ! fp = os.popen(mailcmd, 'w') ! fp.write(sys.stdin.read()) ! fp.write('\n') ! # append the diffs if available ! for file in filestodiff: ! fp.write(calculate_diff(file)) ! fp.write('\n') ! fp.close() ! # doesn't matter what code we return, it isn't waited on os._exit(0) - - # scan args for options def main(): try: ! opts, args = getopt.getopt(sys.argv[1:], 'h', ['cvsroot=', 'help']) except getopt.error, msg: usage(1, msg) # parse the options for opt, arg in opts: if opt in ('-h', '--help'): --- 211,255 ---- # give up the lock you cvs thang! time.sleep(2) ! # Create the smtp connection to the localhost ! conn = smtplib.SMTP() ! conn.connect(MAILHOST, MAILPORT) ! user = pwd.getpwuid(os.getuid())[0] ! domain = fromhost or getfqdn() ! author = '%s@%s' % (user, domain) ! s = StringIO() ! sys.stdout = s ! try: ! print '''\ ! From: %(author)s ! To: %(people)s ! Subject: %(subject)s ! ''' % {'author' : author, ! 'people' : string.join(people, COMMASPACE), ! 'subject': subject, ! } ! s.write(sys.stdin.read()) ! # append the diffs if available ! print ! for file in filestodiff: ! print calculate_diff(file, contextlines) ! finally: ! sys.stdout = sys.__stdout__ ! resp = conn.sendmail(author, people, s.getvalue()) ! conn.close() os._exit(0) # scan args for options def main(): try: ! opts, args = getopt.getopt( ! sys.argv[1:], 'hC:cuqf:', ! ['fromhost=', 'context=', 'cvsroot=', 'help', 'quiet']) except getopt.error, msg: usage(1, msg) # parse the options + contextlines = 2 + verbose = 1 + fromhost = None for opt, arg in opts: if opt in ('-h', '--help'): *************** *** 153,156 **** --- 257,271 ---- elif opt == '--cvsroot': os.environ['CVSROOT'] = arg + elif opt in ('-C', '--context'): + contextlines = int(arg) + elif opt == '-c': + if contextlines <= 0: + contextlines = 2 + elif opt == '-u': + contextlines = 0 + elif opt in ('-q', '--quiet'): + verbose = 0 + elif opt in ('-f', '--fromhost'): + fromhost = arg # What follows is the specification containing the files that were *************** *** 160,164 **** if not args: usage(1, 'No CVS module specified') ! SUBJECT = args[0] specs = string.split(args[0]) del args[0] --- 275,279 ---- if not args: usage(1, 'No CVS module specified') ! subject = args[0] specs = string.split(args[0]) del args[0] *************** *** 169,189 **** # Now do the mail command ! PEOPLE = string.join(args) ! mailcmd = MAILCMD % vars() - print 'Mailing %s...' % PEOPLE if specs == ['-', 'Imported', 'sources']: return if specs[-3:] == ['-', 'New', 'directory']: del specs[-3:] ! blast_mail(mailcmd, specs[1:]) ! if __name__ == '__main__': - print 'Running syncmail...' main() - print '...syncmail done.' sys.exit(0) - - --- 284,313 ---- # Now do the mail command ! people = args ! ! if verbose: ! print 'Mailing %s...' % string.join(people, COMMASPACE) if specs == ['-', 'Imported', 'sources']: return if specs[-3:] == ['-', 'New', 'directory']: del specs[-3:] ! elif len(specs) > 2: ! L = specs[:2] ! for s in specs[2:]: ! prev = L[-1] ! if string.count(prev, ',') < 2: ! L[-1] = "%s %s" % (prev, s) ! else: ! L.append(s) ! specs = L + if verbose: + print 'Generating notification message...' + blast_mail(subject, people, specs[1:], contextlines, fromhost) + if verbose: + print 'Generating notification message... done.' if __name__ == '__main__': main() sys.exit(0) |
From: <mas...@us...> - 2004-02-07 14:59:03
|
Update of /cvsroot/csmail/csmail In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3001 Modified Files: Release-Notes Log Message: 2004-02-07 * Release-Notes: Wish to resume soon. Index: Release-Notes =================================================================== RCS file: /cvsroot/csmail/csmail/Release-Notes,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Release-Notes 10 Sep 2002 04:48:52 -0000 1.1 --- Release-Notes 7 Feb 2004 14:56:09 -0000 1.2 *************** *** 27,29 **** - Coding stuff: ! => Gaurav Vaish \ No newline at end of file --- 27,32 ---- - Coding stuff: ! => Gaurav Vaish ! ! ! ******* I plan to resume this work very soon. Hopefully, by April ******* |
From: Gaurav V. <mas...@us...> - 2003-02-06 19:26:36
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory sc8-pr-cvs1:/tmp/cvs-serv3340 Modified Files: ChangeLog MimeBodyPart.cs Multipart.cs Log Message: 2003-02-07 * Multipart.cs : PartState { get; } - Removed. * MimeBodyPart.cs : UpdateHeaders() - Implemented. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- ChangeLog 22 Jan 2003 14:57:56 -0000 1.67 +++ ChangeLog 6 Feb 2003 19:26:31 -0000 1.68 @@ -1,12 +1,8 @@ -2003-01-22 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> +2003-02-07 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> - * ContentDisposition.cs : ctor(string) - Fixed bug. - -2003-01-03 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> - - * MimeBodyPart.cs : Size - Partial implementation. - : ContentDisposition - Completed. + * Multipart.cs : PartState { get; } - Removed. + * MimeBodyPart.cs : UpdateHeaders() - Implemented. 2002-11-07 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> Index: MimeBodyPart.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/MimeBodyPart.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- MimeBodyPart.cs 22 Jan 2003 13:48:36 -0000 1.11 +++ MimeBodyPart.cs 6 Feb 2003 19:26:32 -0000 1.12 @@ -10,6 +10,7 @@ using System; using System.IO; +using CSMail.Utils; namespace CSMail { @@ -27,10 +28,6 @@ /// The content of this part. /// </summary> protected byte[] content; - /// <summary> - /// The stream associated with the content for the part. - /// </summary> - protected StreamReader reader; /// <summary> /// Creates an empty part. @@ -49,7 +46,6 @@ [MailTODO] public MimeBodyPart(StreamReader reader) { - this.reader = reader; throw new NotImplementedException(); } @@ -71,15 +67,12 @@ /// The size of the headers plus the size of body /// (the actual message), in bytes, for this body part. /// </value> + [MailTODO] public override long Size { get { - if(content != null) - return content.Length; - if(reader != null && reader.BaseStream != null) - return reader.BaseStream.Length; - return -1; + throw new NotImplementedException(); } } @@ -167,14 +160,11 @@ { get { - return new ContentDisposition(Headers["Content-Disposition"]); + throw new NotImplementedException(); } set { - if(value != null) - Headers["Content-Disposition"] = value.ToString(); - else - Headers.Remove(Header.GetHeaderByName("Content-Disposition", true)); + throw new NotImplementedException(); } } @@ -305,10 +295,9 @@ /// called. /// </para> /// </remarks> - [MailTODO] public virtual void UpdateHeaders() { - throw new NotImplementedException(); + MimeUtils.UpdateHeaders(this); } /// <summary> Index: Multipart.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Multipart.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Multipart.cs 7 Nov 2002 09:56:35 -0000 1.7 +++ Multipart.cs 6 Feb 2003 19:26:33 -0000 1.8 @@ -92,6 +92,7 @@ } } +/* protected virtual StateBag PartState { get @@ -103,6 +104,7 @@ return partState; } } +*/ /// <summary> /// When implemented, writes the content to the stream. |
From: Gaurav V. <mas...@us...> - 2003-02-06 19:16:24
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory sc8-pr-cvs1:/tmp/cvs-serv30201 Modified Files: ChangeLog MimeUtils.cs Log Message: 2003-02-07 * MimeUtils.cs : UpdateHeaders(IMimePart) - Need for typcast to ContentType. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/ChangeLog,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- ChangeLog 6 Feb 2003 19:12:05 -0000 1.26 +++ ChangeLog 6 Feb 2003 19:16:17 -0000 1.27 @@ -1,4 +1,9 @@ +2003-02-07 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * MimeUtils.cs : UpdateHeaders(IMimePart) - Need + for typcast to ContentType. + 2003-02-06 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * MimeUtils.cs : UpdateHeaders(IMimePart) - No need Index: MimeUtils.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/MimeUtils.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- MimeUtils.cs 6 Feb 2003 19:12:06 -0000 1.7 +++ MimeUtils.cs 6 Feb 2003 19:16:19 -0000 1.8 @@ -263,7 +263,7 @@ { isMatched = true; } - if(!isMatched && ct == null) + if(!isMatched && ct == (ContentType)null) { ct = new ContentType("text/plain"); string charSet = ""; @@ -277,7 +277,7 @@ } ct.Parameters["charset"] = charSet; } - if(ct == null) + if(ct == (ContentType)null) { ContentDisposition cd = mimePart.Disposition; ct = new ContentType("text/plain"); |
From: Gaurav V. <mas...@us...> - 2003-02-06 19:12:41
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory sc8-pr-cvs1:/tmp/cvs-serv28344 Modified Files: ChangeLog MimeUtils.cs Log Message: 2003-02-06 * MimeUtils.cs : UpdateHeaders(IMimePart) - No need to typcast to ContentType. : Get/Set-TransferEncoding(StreamReader) - Stubbed. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/ChangeLog,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- ChangeLog 7 Nov 2002 09:58:04 -0000 1.25 +++ ChangeLog 6 Feb 2003 19:12:05 -0000 1.26 @@ -1,4 +1,12 @@ +2003-02-06 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * MimeUtils.cs : UpdateHeaders(IMimePart) - No need + to typcast to ContentType. + : Get/Set-TransferEncoding(StreamReader) + - Stubbed. + + 2002-11-07 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * MimeUtils.cs : UpdateHeaders(IMimePart) - Implemented. Index: MimeUtils.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/MimeUtils.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- MimeUtils.cs 7 Nov 2002 09:58:04 -0000 1.6 +++ MimeUtils.cs 6 Feb 2003 19:12:06 -0000 1.7 @@ -224,6 +224,21 @@ return TransferEncoding.Default; } + [MailTODO] + public static TransferEncoding GetTransferEncoding(StreamReader reader, + out string stringValue) + { + throw new NotImplementedException(); + } + + [MailTODO] + public static TransferEncoding SetTransferEncoding(StreamReader reader, + TransferEncoding encoding, + string userDefinedValue) + { + throw new NotImplementedException(); + } + public static string GetDefaultCharset() { Properties props = Properties.GetDefaultProperties(); @@ -235,7 +250,7 @@ " Don't know how to get from the VM"); return retVal; } - + public static void UpdateHeaders(IMimePart mimePart) { ContentType ct = mimePart.ContentType; @@ -248,7 +263,7 @@ { isMatched = true; } - if(!isMatched && ct == (ContentType)null) + if(!isMatched && ct == null) { ct = new ContentType("text/plain"); string charSet = ""; @@ -262,7 +277,7 @@ } ct.Parameters["charset"] = charSet; } - if(ct == (ContentType)null) + if(ct == null) { ContentDisposition cd = mimePart.Disposition; ct = new ContentType("text/plain"); |
From: Gaurav V. <mas...@us...> - 2003-02-06 17:15:03
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory sc8-pr-cvs1:/tmp/cvs-serv28660 Modified Files: EMailAddress.cs Log Message: Documentation error. Index: EMailAddress.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/EMailAddress.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- EMailAddress.cs 25 Oct 2002 09:22:18 -0000 1.8 +++ EMailAddress.cs 6 Feb 2003 17:14:57 -0000 1.9 @@ -303,7 +303,7 @@ /// <param name="right">Address on the right side of operator.</param> /// <returns> /// <c>true</c> if they are same, <c>false</c> otherwise. - /// <p>Note that a true is returned if both left as well as right are + /// <p>Note that a false is returned if both left as well as right are /// <c>null</c>. Am I right in this logic?</p> /// </returns> public static bool operator == (EMailAddress left, EMailAddress right) |
From: Gaurav V. <mas...@us...> - 2003-02-03 05:53:36
|
Update of /cvsroot/csmail/CVSROOT In directory sc8-pr-cvs1:/tmp/cvs-serv9517 Modified Files: modules Log Message: * modules: Added modules list Index: modules =================================================================== RCS file: /cvsroot/csmail/CVSROOT/modules,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- modules 18 Jun 2002 15:11:33 -0000 1.1 +++ modules 3 Feb 2003 05:53:33 -0000 1.2 @@ -24,3 +24,5 @@ # character to interpose another module into the current module. This # can be useful for creating a module that consists of many directories # spread out over the entire source repository. + +csmail csmail |
From: Gaurav V. <mas...@us...> - 2003-01-22 14:58:05
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory sc8-pr-cvs1:/tmp/cvs-serv1813 Modified Files: ChangeLog ContentDisposition.cs Log Message: 2003-01-22 * ContentDisposition.cs : ctor(string) - Fixed bug. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- ChangeLog 22 Jan 2003 13:48:36 -0000 1.66 +++ ChangeLog 22 Jan 2003 14:57:56 -0000 1.67 @@ -1,4 +1,8 @@ +2003-01-22 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * ContentDisposition.cs : ctor(string) - Fixed bug. + 2003-01-03 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * MimeBodyPart.cs : Size - Partial implementation. Index: ContentDisposition.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ContentDisposition.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ContentDisposition.cs 22 Jan 2003 13:48:36 -0000 1.5 +++ ContentDisposition.cs 22 Jan 2003 14:57:57 -0000 1.6 @@ -32,9 +32,9 @@ if(headerLine == null || headerLine.Length == 0) throw new ArgumentException("Illegal argument value" + " for headerLine"); - if(headerLine.ToLower().StartsWith("content-disposition")) + if(headerLine.ToLower().StartsWith("content-disposition:")) { - headerLine = headerLine.Substring(21); + headerLine = headerLine.Substring(20); } parameters = Parse(headerLine, out type); } |
From: Gaurav V. <mas...@us...> - 2003-01-22 13:48:40
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory sc8-pr-cvs1:/tmp/cvs-serv12466 Modified Files: ChangeLog ContentDisposition.cs MimeBodyPart.cs Log Message: 2003-01-03 * MimeBodyPart.cs : Size - Partial implementation. : ContentDisposition - Completed. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- ChangeLog 7 Nov 2002 09:56:35 -0000 1.65 +++ ChangeLog 22 Jan 2003 13:48:36 -0000 1.66 @@ -1,4 +1,9 @@ +2003-01-03 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * MimeBodyPart.cs : Size - Partial implementation. + : ContentDisposition - Completed. + 2002-11-07 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * ContentType.cs : op_== (ContentType, string) Index: ContentDisposition.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ContentDisposition.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ContentDisposition.cs 31 Oct 2002 06:30:13 -0000 1.4 +++ ContentDisposition.cs 22 Jan 2003 13:48:36 -0000 1.5 @@ -29,11 +29,13 @@ public ContentDisposition(string headerLine) { - if(!headerLine.ToLower().StartsWith("content-disposition")) - throw new ArgumentException("[ContentDisposition] " + - "Value does not start with " + - " \"Content-Disposition:\""); - headerLine = headerLine.Substring(21); + if(headerLine == null || headerLine.Length == 0) + throw new ArgumentException("Illegal argument value" + + " for headerLine"); + if(headerLine.ToLower().StartsWith("content-disposition")) + { + headerLine = headerLine.Substring(21); + } parameters = Parse(headerLine, out type); } Index: MimeBodyPart.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/MimeBodyPart.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- MimeBodyPart.cs 30 Oct 2002 09:54:16 -0000 1.10 +++ MimeBodyPart.cs 22 Jan 2003 13:48:36 -0000 1.11 @@ -27,6 +27,10 @@ /// The content of this part. /// </summary> protected byte[] content; + /// <summary> + /// The stream associated with the content for the part. + /// </summary> + protected StreamReader reader; /// <summary> /// Creates an empty part. @@ -45,6 +49,7 @@ [MailTODO] public MimeBodyPart(StreamReader reader) { + this.reader = reader; throw new NotImplementedException(); } @@ -66,12 +71,15 @@ /// The size of the headers plus the size of body /// (the actual message), in bytes, for this body part. /// </value> - [MailTODO] public override long Size { get { - throw new NotImplementedException(); + if(content != null) + return content.Length; + if(reader != null && reader.BaseStream != null) + return reader.BaseStream.Length; + return -1; } } @@ -159,11 +167,14 @@ { get { - throw new NotImplementedException(); + return new ContentDisposition(Headers["Content-Disposition"]); } set { - throw new NotImplementedException(); + if(value != null) + Headers["Content-Disposition"] = value.ToString(); + else + Headers.Remove(Header.GetHeaderByName("Content-Disposition", true)); } } |
From: Gaurav V. <mas...@us...> - 2002-11-07 09:58:07
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory usw-pr-cvs1:/tmp/cvs-serv18812 Modified Files: ChangeLog MimeUtils.cs Log Message: 2002-11-07 * MimeUtils.cs : UpdateHeaders(IMimePart) - Implemented. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/ChangeLog,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- ChangeLog 31 Oct 2002 10:41:57 -0000 1.24 +++ ChangeLog 7 Nov 2002 09:58:04 -0000 1.25 @@ -1,4 +1,8 @@ +2002-11-07 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * MimeUtils.cs : UpdateHeaders(IMimePart) - Implemented. + 2002-10-31 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * MimeUtils.cs : Get/Set-ContentLanguage - Implemented. Index: MimeUtils.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/MimeUtils.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- MimeUtils.cs 31 Oct 2002 10:41:58 -0000 1.5 +++ MimeUtils.cs 7 Nov 2002 09:58:04 -0000 1.6 @@ -223,5 +223,55 @@ } return TransferEncoding.Default; } + + public static string GetDefaultCharset() + { + Properties props = Properties.GetDefaultProperties(); + string retVal = String.Empty; + if(props["mail.mime.charset"] != null) + retVal = (string)props["mail.mime.charset"]; + else + throw new NotImplementedException("[GetDefaultCharset]" + + " Don't know how to get from the VM"); + return retVal; + } + + public static void UpdateHeaders(IMimePart mimePart) + { + ContentType ct = mimePart.ContentType; + bool isMatched = false; + if(ct == "multipart/*") + { + ((MimeMultipart)mimePart.Content).UpdateHeaders(); + isMatched = true; + } else if(ct == "message/rfc822") + { + isMatched = true; + } + if(!isMatched && ct == (ContentType)null) + { + ct = new ContentType("text/plain"); + string charSet = ""; + if(mimePart.TransferEncoding == TransferEncoding.Bit7) + { + charSet = "us-ascii"; + } else + { + // To get default MIME Charset + throw new NotImplementedException(); + } + ct.Parameters["charset"] = charSet; + } + if(ct == (ContentType)null) + { + ContentDisposition cd = mimePart.Disposition; + ct = new ContentType("text/plain"); + if(cd != null && cd.Filename != null && cd.Filename.Length > 0) + { + ct.Parameters["filename"] = cd.Filename; + } + } + mimePart.ContentType = ct; + } } } |
From: Gaurav V. <mas...@us...> - 2002-11-07 09:56:38
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv18191 Modified Files: ChangeLog ContentType.cs MimeMessage.cs Multipart.cs Log Message: 2002-11-07 * ContentType.cs : op_== (ContentType, string) - Implemented. * MimeMessage.cs : Write(StreamWriter) - Save changes. * Multipart.cs : UpdateHeaders() - Made public. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- ChangeLog 31 Oct 2002 10:41:21 -0000 1.64 +++ ChangeLog 7 Nov 2002 09:56:35 -0000 1.65 @@ -1,4 +1,11 @@ +2002-11-07 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * ContentType.cs : op_== (ContentType, string) + - Implemented. + * MimeMessage.cs : Write(StreamWriter) - Save changes. + * Multipart.cs : UpdateHeaders() - Made public. + 2002-10-31 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * MimeMessage.cs : ContentLanguage { get; set; }, Index: ContentType.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ContentType.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ContentType.cs 9 Oct 2002 07:09:30 -0000 1.8 +++ ContentType.cs 7 Nov 2002 09:56:35 -0000 1.9 @@ -214,11 +214,35 @@ if(left.SubType[0] == '*' || right.SubType[0] == '*') return retVal; - retVal &= (String.Compare(left.SubType, + retVal &= (String.Compare(left.SubType, right.SubType, false) == 0); return retVal; } + public static bool operator == (ContentType left, string right) + { + if(null == (object)left || null == (object)right) + return false; + + try + { + ContentType that = new ContentType(right); + if(left == that) + return true; + if(left.Parameters != that.Parameters) + return false; + } catch(ParseException) + { + return false; + } + return true; + } + + public static bool operator != (ContentType left, string right) + { + return !(left == right); + } + /// <summary> /// Compares two <see cref="T:CSMail.ContentType"/> /// objects. @@ -283,7 +307,7 @@ /// <param name="cType">Object to match with.</param> public bool Equals(ContentType cType) { - if(null != (Object)cType) + if(null != (object)cType) { return (this == cType); } @@ -311,7 +335,7 @@ { ContentType that = new ContentType(cType); if(this == that) - return false; + return true; if(this.Parameters != that.Parameters) return false; } catch(ParseException) Index: MimeMessage.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/MimeMessage.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- MimeMessage.cs 31 Oct 2002 10:41:21 -0000 1.8 +++ MimeMessage.cs 7 Nov 2002 09:56:35 -0000 1.9 @@ -501,6 +501,8 @@ [MailTODO] public override void Write(StreamWriter writer) { + if(!isSaved) + SaveChanges(); throw new NotImplementedException(); } } Index: Multipart.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Multipart.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Multipart.cs 24 Sep 2002 08:34:52 -0000 1.6 +++ Multipart.cs 7 Nov 2002 09:56:35 -0000 1.7 @@ -119,7 +119,7 @@ /// </remarks> protected abstract void ParseBodyParts(); - protected virtual void UpdateHeaders() + public virtual void UpdateHeaders() { for(int i = 0; i < BodyParts.Count; i++) { |
From: Gaurav V. <mas...@us...> - 2002-10-31 10:42:00
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory usw-pr-cvs1:/tmp/cvs-serv4420 Modified Files: ChangeLog MimeUtils.cs Log Message: 2002-10-31 * MimeUtils.cs : Get/Set-ContentLanguage - Implemented. : Get/Set-TransferEncoding - Implemented. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/ChangeLog,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- ChangeLog 31 Oct 2002 06:31:07 -0000 1.23 +++ ChangeLog 31 Oct 2002 10:41:57 -0000 1.24 @@ -1,5 +1,10 @@ -2002-10-30 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> +2002-10-31 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * MimeUtils.cs : Get/Set-ContentLanguage - Implemented. + : Get/Set-TransferEncoding - Implemented. + +2002-10-31 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * MimeUtils.cs : SetDisposition(IMimePart, ContentDisposition), : GetDisposition(IMimePart) Index: MimeUtils.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/MimeUtils.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- MimeUtils.cs 31 Oct 2002 06:31:07 -0000 1.4 +++ MimeUtils.cs 31 Oct 2002 10:41:58 -0000 1.5 @@ -9,6 +9,7 @@ */ using System; +using System.Collections; using System.IO; using System.Text; using CSMail; @@ -90,6 +91,137 @@ string encoding) { throw new NotImplementedException(); + } + + public static string[] GetContentLanguage(IMimePart mimePart) + { + if(mimePart != null) + { + string val = mimePart.Headers["Content-Language"]; + if(val != null && val.Trim().Length > 0) + { + HeaderTokenizer ht = new HeaderTokenizer(val.Trim(), + Constants.MIMEDelimiters); + ArrayList langs = new ArrayList(); + while(true) + { + HeaderToken token = ht.Next; + if(token.TokenType == HeaderTokenType.EOF) + break; + if(token.TokenType == HeaderTokenType.Atom) + langs.Add(token.Value); + } + if(langs.Count > 0) + { + string[] retVal = new string[langs.Count]; + langs.CopyTo(retVal); + return retVal; + } + } + } + return null; + } + + public static void SetContentLanguage(IMimePart mimePart, + string[] languages) + { + string headerLine = ","; + foreach(string clang in languages) + { + headerLine += (',' + clang); + } + headerLine = headerLine.Substring(1); + mimePart.Headers["Content-Language"] = headerLine; + } + + public static void SetTransferEncoding(IMimePart mimePart, + string encoding) + { + SetTransferEncoding(mimePart, TransferEncoding.UserDefined, + encoding); + } + + public static void SetTransferEncoding(IMimePart mimePart, + TransferEncoding tenc) + { + if(tenc == TransferEncoding.UserDefined) + throw new ArgumentException("[SetTransferEncoding]" + + " Cannot set user defined encoding" + + " using this method."); + SetTransferEncoding(mimePart, tenc, null); + } + + public static void SetTransferEncoding(IMimePart mimePart, + TransferEncoding tenc, + string userDefined) + { + if(!Enum.IsDefined(typeof(TransferEncoding), tenc)) + throw new ArgumentException("[SetTransferEncoding]" + + " Unknown value in transfer encoding" + + " parameter"); + if(mimePart != null) + { + string val = null; + switch(tenc) + { + case TransferEncoding.Default: + goto case TransferEncoding.Bit7; + case TransferEncoding.Bit7 : val = "7-bit"; + break; + case TransferEncoding.Bit8 : val = "8-bit"; + break; + case TransferEncoding.QuotedPrintable : + val = "quoted-printable"; + break; + case TransferEncoding.Base64 : val = "base64"; + break; + case TransferEncoding.Binary : val = "binary"; + break; + case TransferEncoding.UserDefined + : if(!userDefined.ToLower().StartsWith("x-")) + throw new ArgumentException( + "[SetTransferEncoding] User" + + " defined values must start" + + " with 'x-'"); + val = userDefined; + break; + } + mimePart.Headers["Content-Transfer-Encoding"] = val; + } + } + + public static TransferEncoding GetTransferEncoding(IMimePart mimePart, + out string stringValue) + { + stringValue = null; + if(mimePart != null) + { + string encVal = mimePart.Headers["Content-Transfer-Encoding"]; + if(encVal != null) + encVal = encVal.Trim(); + stringValue = encVal; + if(stringValue != null && stringValue.Length > 0) + { + TransferEncoding enc = TransferEncoding.UserDefined; + encVal = encVal.ToLower(); + switch(encVal) + { + case "7-bit" : enc = TransferEncoding.Bit7; + break; + case "8-bit" : enc = TransferEncoding.Bit8; + break; + case "quoted-printable" + : enc = TransferEncoding.QuotedPrintable; + break; + case "base64" : enc = TransferEncoding.Base64; + break; + case "binary" : enc = TransferEncoding.Binary; + break; + } + return enc; + } + } + return TransferEncoding.Default; } } } |
From: Gaurav V. <mas...@us...> - 2002-10-31 10:41:24
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv4205 Modified Files: ChangeLog MimeMessage.cs TransferEncoding.cs Log Message: 2002-10-31 * MimeMessage.cs : ContentLanguage { get; set; }, : ReplyTo { get; set; }, : TransferEncodingValue { get; set; }, : TransferEncoding { get; set; } - Implemented. * TransferEncoding.cs : UUEncode - Removed. Check http://www.freesoft.org/CIE/RFC/1521/5.htm for the possible values. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- ChangeLog 31 Oct 2002 06:30:12 -0000 1.63 +++ ChangeLog 31 Oct 2002 10:41:21 -0000 1.64 @@ -1,6 +1,17 @@ 2002-10-31 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * MimeMessage.cs : ContentLanguage { get; set; }, + : ReplyTo { get; set; }, + : TransferEncodingValue { get; set; }, + : TransferEncoding { get; set; } + - Implemented. + * TransferEncoding.cs : UUEncode - Removed. + Check http://www.freesoft.org/CIE/RFC/1521/5.htm + for the possible values. + +2002-10-31 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * ContentDisposition.cs : FileName - Changed to Filename. * MimeMessage.cs : Disposition { get; set; } - Implemented. Index: MimeMessage.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/MimeMessage.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- MimeMessage.cs 31 Oct 2002 06:30:13 -0000 1.7 +++ MimeMessage.cs 31 Oct 2002 10:41:21 -0000 1.8 @@ -193,7 +193,7 @@ return (toList + ccList); } } - + public override NewsAddressList NewsGroups { get @@ -201,7 +201,7 @@ return ngroupList; } } - + public override DateTime SentDate { get @@ -291,16 +291,21 @@ } } - [MailTODO] public override EMailAddressList ReplyTo { get { - throw new NotImplementedException(); + string rt = Headers["Reply-To"]; + if(rt != null && rt.Length > 0) + return new EMailAddressList(rt); + return new EMailAddressList(From); } set { - throw new NotImplementedException(); + if(value != null) + Headers["Reply-To"] = value.ToString(); + else + Headers["Reply-To"] = null; } } @@ -328,16 +333,15 @@ } } - [MailTODO] public virtual string[] ContentLanguage { get { - throw new NotImplementedException(); + return MimeUtils.GetContentLanguage(this); } set { - throw new NotImplementedException(); + MimeUtils.SetContentLanguage(this, value); } } @@ -370,11 +374,26 @@ { get { - throw new NotImplementedException(); + string hval; + return MimeUtils.GetTransferEncoding(this, out hval); } set { - throw new NotImplementedException(); + MimeUtils.SetTransferEncoding(this, value); + } + } + + public virtual string TransferEncodingValue + { + get + { + string hval; + MimeUtils.GetTransferEncoding(this, out hval); + return hval; + } + set + { + MimeUtils.SetTransferEncoding(this, value); } } Index: TransferEncoding.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/TransferEncoding.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TransferEncoding.cs 5 Sep 2002 05:17:49 -0000 1.2 +++ TransferEncoding.cs 31 Oct 2002 10:41:21 -0000 1.3 @@ -40,10 +40,6 @@ /// </summary> Binary, /// <summary> - /// The content is uuencode-d. - /// </summary> - UUEncode, - /// <summary> /// Any used defined encoding method. /// </summary> UserDefined |
From: Gaurav V. <mas...@us...> - 2002-10-31 08:42:35
|
Update of /cvsroot/csmail/csmail/tests In directory usw-pr-cvs1:/tmp/cvs-serv318/tests Log Message: Directory /cvsroot/csmail/csmail/tests added to the repository |
From: Gaurav V. <mas...@us...> - 2002-10-31 06:31:10
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory usw-pr-cvs1:/tmp/cvs-serv28709 Modified Files: ChangeLog MimeUtils.cs Log Message: 2002-10-30 * MimeUtils.cs : SetDisposition(IMimePart, ContentDisposition), : GetDisposition(IMimePart) - Removed. Don't need it. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/ChangeLog,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- ChangeLog 30 Oct 2002 09:58:29 -0000 1.22 +++ ChangeLog 31 Oct 2002 06:31:07 -0000 1.23 @@ -1,6 +1,12 @@ 2002-10-30 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * MimeUtils.cs : SetDisposition(IMimePart, ContentDisposition), + : GetDisposition(IMimePart) + - Removed. Don't need it. + +2002-10-30 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * MimeUtils.cs : GetDisposition(IMimePart) - Typo bug fix. 2002-10-30 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> Index: MimeUtils.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/MimeUtils.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MimeUtils.cs 30 Oct 2002 09:58:29 -0000 1.3 +++ MimeUtils.cs 31 Oct 2002 06:31:07 -0000 1.4 @@ -91,18 +91,5 @@ { throw new NotImplementedException(); } - - [MailTODO] - internal static void SetDisposition(IMimePart part, - ContentDisposition disposition) - { - throw new NotImplementedException(); - } - - [MailTODO] - internal static ContentDisposition GetDisposition(IMimePart part) - { - throw new NotImplementedException(); - } } } |
From: Gaurav V. <mas...@us...> - 2002-10-31 06:30:16
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv28383 Modified Files: ChangeLog ContentDisposition.cs MimeMessage.cs ParameterList.cs Log Message: 2002-10-31 * ContentDisposition.cs : FileName - Changed to Filename. * MimeMessage.cs : Disposition { get; set; } - Implemented. * ParameterList.cs : this[string] { set; } - Check for null values. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- ChangeLog 30 Oct 2002 09:54:16 -0000 1.62 +++ ChangeLog 31 Oct 2002 06:30:12 -0000 1.63 @@ -1,4 +1,11 @@ +2002-10-31 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * ContentDisposition.cs : FileName - Changed to Filename. + * MimeMessage.cs : Disposition { get; set; } + - Implemented. + * ParameterList.cs : this[string] { set; } - Check for null values. + 2002-10-30 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * ContentDisposition.cs : Made a class. Added fancy features. Index: ContentDisposition.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ContentDisposition.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ContentDisposition.cs 30 Oct 2002 09:54:16 -0000 1.3 +++ ContentDisposition.cs 31 Oct 2002 06:30:13 -0000 1.4 @@ -58,6 +58,16 @@ return retVal; } + public static ContentDisposition Parse(string headerValue) + { + ContentDispositionType type; + ParameterList pl = Parse(headerValue, out type); + ContentDisposition retVal = new ContentDisposition(); + retVal.DispositionType = type; + retVal.Parameters = pl; + return retVal; + } + public ContentDisposition(ContentDispositionType type, ParameterList parameters) { @@ -75,23 +85,20 @@ { if(!Enum.IsDefined(typeof(ContentDispositionType), value)) throw new ArgumentException("[DispositionType]" + - " Illegal value provided."); + " Given value does not exist."); type = value; } } - public string FileName + public string Filename { get { - return parameters["FileName"]; + return parameters["Filename"]; } set { - if(value == null || value.Length == 0) - parameters.Remove("FileName"); - else - parameters["FileName"] = value; + parameters["Filename"] = value; } } Index: MimeMessage.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/MimeMessage.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- MimeMessage.cs 1 Oct 2002 11:47:41 -0000 1.6 +++ MimeMessage.cs 31 Oct 2002 06:30:13 -0000 1.7 @@ -30,6 +30,8 @@ protected NewsAddressList ngroupList = new NewsAddressList(); protected EMailAddressList replyList = new EMailAddressList(); + protected ContentDisposition disposition = null; + private bool isStrict = false; public MimeMessage(Session session) : base(session) @@ -240,11 +242,19 @@ { get { - throw new NotImplementedException(); + if(disposition == null) + { + string disp = Headers["Content-Disposition"]; + if(disp != null && disp.Length > 0) + { + disposition = ContentDisposition.Parse(disp); + } + } + return disposition; } set { - throw new NotImplementedException(); + disposition = value; } } @@ -252,25 +262,11 @@ { get { - ParameterList list = MimeUtils.GetParametersAsList - (headers["Content-Disposition"], null); - if(list != null) - { - return list["Filename"]; - } - return null; + return Disposition.Filename; } set { - ParameterList list = MimeUtils.GetParametersAsList - (headers["Content-Disposition"], null); - if(list == null) - { - list = new ParameterList(); - } - list.Add(new Parameter("filename", - StringUtils.Escape(value))); - headers["Content-Disposition"] = list.ToString(); + disposition.Filename = value; } } Index: ParameterList.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ParameterList.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ParameterList.cs 9 Oct 2002 07:09:30 -0000 1.4 +++ ParameterList.cs 31 Oct 2002 06:30:13 -0000 1.5 @@ -61,7 +61,10 @@ } set { - parameters[name] = value; + if(value == null || value.Length == 0) + Remove(name); + else + parameters[name] = value; } } |
From: Gaurav V. <mas...@us...> - 2002-10-30 09:58:32
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory usw-pr-cvs1:/tmp/cvs-serv577 Modified Files: ChangeLog MimeUtils.cs Log Message: 2002-10-30 * MimeUtils.cs : GetDisposition(IMimePart) - Typo bug fix. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/ChangeLog,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- ChangeLog 30 Oct 2002 09:56:34 -0000 1.21 +++ ChangeLog 30 Oct 2002 09:58:29 -0000 1.22 @@ -1,8 +1,12 @@ 2002-10-30 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> - * MimeUtils.cs : SetDisposition(MimePart, ContentDisposition), - : GetDisposition(MimePart) + * MimeUtils.cs : GetDisposition(IMimePart) - Typo bug fix. + +2002-10-30 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * MimeUtils.cs : SetDisposition(IMimePart, ContentDisposition), + : GetDisposition(IMimePart) - Stubbed. 2002-10-08 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> Index: MimeUtils.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/MimeUtils.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MimeUtils.cs 30 Oct 2002 09:56:34 -0000 1.2 +++ MimeUtils.cs 30 Oct 2002 09:58:29 -0000 1.3 @@ -100,7 +100,7 @@ } [MailTODO] - internal static ContentDisposition SetDisposition(IMimePart part) + internal static ContentDisposition GetDisposition(IMimePart part) { throw new NotImplementedException(); } |
From: Gaurav V. <mas...@us...> - 2002-10-30 09:56:37
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory usw-pr-cvs1:/tmp/cvs-serv31467 Modified Files: ChangeLog MimeUtils.cs Log Message: 2002-10-30 * MimeUtils.cs : SetDisposition(MimePart, ContentDisposition), : GetDisposition(MimePart) - Stubbed. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/ChangeLog,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- ChangeLog 8 Oct 2002 12:26:42 -0000 1.20 +++ ChangeLog 30 Oct 2002 09:56:34 -0000 1.21 @@ -1,4 +1,10 @@ +2002-10-30 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * MimeUtils.cs : SetDisposition(MimePart, ContentDisposition), + : GetDisposition(MimePart) + - Stubbed. + 2002-10-08 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * HeaderToken.cs, Index: MimeUtils.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/MimeUtils.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MimeUtils.cs 30 Sep 2002 04:02:38 -0000 1.1 +++ MimeUtils.cs 30 Oct 2002 09:56:34 -0000 1.2 @@ -9,6 +9,8 @@ */ using System; +using System.IO; +using System.Text; using CSMail; namespace CSMail.Utils @@ -45,7 +47,7 @@ } return null; } - + public static ParameterList GetParametersAsList(string headerValue, char[] separators) { @@ -81,6 +83,26 @@ } } return null; + } + + [MailTODO] + public static StreamReader Decode(StreamReader reader, + string encoding) + { + throw new NotImplementedException(); + } + + [MailTODO] + internal static void SetDisposition(IMimePart part, + ContentDisposition disposition) + { + throw new NotImplementedException(); + } + + [MailTODO] + internal static ContentDisposition SetDisposition(IMimePart part) + { + throw new NotImplementedException(); } } } |
From: Gaurav V. <mas...@us...> - 2002-10-30 09:54:19
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv29562 Modified Files: ChangeLog ContentDisposition.cs MimeBodyPart.cs Added Files: ContentDispositionType.cs Log Message: 2002-10-30 * ContentDisposition.cs : Made a class. Added fancy features. * ContentDispositionType.cs : Replaces ContentDisposition. : Added member "NotDefined". * MimeBodyPart.cs : Disposition { get; set; } - Removed implementation. Will freshen it. --- NEW FILE --- /** * Namespace: CSMail * Enumeration: ContentDispositionType * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { /// <summary> /// The "Content-Disposition" options. /// </summary> public enum ContentDispositionType { /// <summary> /// Tells /// <M:CSMail.Utils.MimeUtils.SetDisposition(MimePart,ContentDisposition)/> /// to remove the "Content-Disposition" header. NotDefined, /// <summary> /// The current part is an attachment. /// </summary> Attachment, /// <summary> /// The current part is an inline content. /// </summary> Inline } } Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- ChangeLog 25 Oct 2002 10:33:00 -0000 1.61 +++ ChangeLog 30 Oct 2002 09:54:16 -0000 1.62 @@ -1,4 +1,13 @@ +2002-10-30 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * ContentDisposition.cs : Made a class. Added fancy features. + * ContentDispositionType.cs + : Replaces ContentDisposition. + : Added member "NotDefined". + * MimeBodyPart.cs : Disposition { get; set; } - Removed + implementation. Will freshen it. + 2002-10-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * InternetAddress.cs : Equals(InternetAddress) - Implemented. Index: ContentDisposition.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ContentDisposition.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ContentDisposition.cs 5 Sep 2002 05:17:49 -0000 1.2 +++ ContentDisposition.cs 30 Oct 2002 09:54:16 -0000 1.3 @@ -8,20 +8,117 @@ * (C) Gaurav Vaish (2002) */ +using System; +using CSMail.Utils; + namespace CSMail { /// <summary> /// The "Content-Disposition" options. /// </summary> - public enum ContentDisposition + public class ContentDisposition { - /// <summary> - /// The current part is an attachment. - /// </summary> - Attachment, - /// <summary> - /// The current part is an inline content. - /// </summary> - Inline + private ContentDispositionType type; + private ParameterList parameters; + + public ContentDisposition() + { + type = ContentDispositionType.NotDefined; + parameters = new ParameterList(); + } + + public ContentDisposition(string headerLine) + { + if(!headerLine.ToLower().StartsWith("content-disposition")) + throw new ArgumentException("[ContentDisposition] " + + "Value does not start with " + + " \"Content-Disposition:\""); + headerLine = headerLine.Substring(21); + parameters = Parse(headerLine, out type); + } + + public static ParameterList Parse(string headerValue, + out ContentDispositionType cdType) + { + HeaderTokenizer ht = new HeaderTokenizer(headerValue, + Constants.MIMEDelimiters); + HeaderToken token = ht.Next; + if(token.TokenType != HeaderTokenType.Atom) + throw new ParseException("[Parse] The value provided is" + + " illegal"); + cdType = (ContentDispositionType)Enum.Parse( + typeof(ContentDispositionType), + token.Value, true); + string param = ht.Remainder; + ParameterList retVal = null; + if(param != null && param.Trim().Length > 0) + retVal = new ParameterList(param.Trim()); + else + retVal = new ParameterList(); + return retVal; + } + + public ContentDisposition(ContentDispositionType type, + ParameterList parameters) + { + this.type = type; + this.parameters = parameters; + } + + public ContentDispositionType DispositionType + { + get + { + return type; + } + set + { + if(!Enum.IsDefined(typeof(ContentDispositionType), value)) + throw new ArgumentException("[DispositionType]" + + " Illegal value provided."); + type = value; + } + } + + public string FileName + { + get + { + return parameters["FileName"]; + } + set + { + if(value == null || value.Length == 0) + parameters.Remove("FileName"); + else + parameters["FileName"] = value; + } + } + + public ParameterList Parameters + { + get + { + return parameters; + } + set + { + parameters = value; + } + } + + public override string ToString() + { + string retVal = ""; + if(type != ContentDispositionType.NotDefined) + { + retVal = "Content-Disposition: "; + retVal += Enum.Format(typeof(ContentDispositionType), + type, "G").ToLower(); + if(parameters != null) + retVal += ("; " + parameters.ToString()); + } + return retVal; + } } } Index: MimeBodyPart.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/MimeBodyPart.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- MimeBodyPart.cs 9 Oct 2002 07:09:30 -0000 1.9 +++ MimeBodyPart.cs 30 Oct 2002 09:54:16 -0000 1.10 @@ -155,25 +155,15 @@ /// <summary> /// Gets or sets the value of "Content-Disposition" header. /// </summary> - /// <remarks> - /// I will changed the implementation to read from or - /// write to the headers of this part, and not as a part - /// of the PartState. - /// </remarks> public override ContentDisposition Disposition { get { - object o = PartState["Disposition"]; - if(o != null) - return (ContentDisposition)o; - return ContentDisposition.Inline; + throw new NotImplementedException(); } set { - if(!Enum.IsDefined(typeof(ContentDisposition), value)) - throw new ArgumentException("[Disposition] Value cannot be set"); - PartState["Disposition"] = value; + throw new NotImplementedException(); } } |
From: Gaurav V. <mas...@us...> - 2002-10-25 17:19:13
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv3428 Modified Files: ChangeLog InternetAddress.cs Log Message: 2002-10-25 * InternetAddress.cs : Equals(InternetAddress) - Implemented. : ctor(string) - Implemented. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- ChangeLog 25 Oct 2002 10:07:34 -0000 1.60 +++ ChangeLog 25 Oct 2002 10:33:00 -0000 1.61 @@ -1,6 +1,11 @@ 2002-10-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * InternetAddress.cs : Equals(InternetAddress) - Implemented. + : ctor(string) - Implemented. + +2002-10-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * MessagingException.cs : Meesage { get; }, : GetMessage() - Implemented. : BaseMessage { get; } - Default is Index: InternetAddress.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/InternetAddress.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- InternetAddress.cs 9 Sep 2002 06:23:01 -0000 1.6 +++ InternetAddress.cs 25 Oct 2002 10:33:00 -0000 1.7 @@ -58,10 +58,21 @@ /// Initialization with a URI string. /// </summary> /// <param name="fullURI">Complete URI to parse.</param> - [MailTODO] public InternetAddress(string fullURI) { - throw new NotImplementedException(); + int sep = fullURI.IndexOf("://"); + if(sep < 0) + throw new AddressException("[InternetAddress]" + + " No '://' found", fullURI, 0); + if(sep == 0) + throw new AddressException("[InternetAddress]" + + " '://' cannot be at start", fullURI, 0); + protocol = fullURI.Substring(0, sep); + int slash = fullURI.IndexOf('/', sep + 3); + if(slash == -1) + hostname = fullURI.Substring(sep + 3); + else + hostname = fullURI.Substring(sep + 3, slash - sep - 3); } /// <summary> @@ -220,10 +231,9 @@ /// <returns><c>true</c> if the two represent same URI, /// <c>false</c> otherwise. /// </returns> - [MailTODO] public bool Equals(InternetAddress address) { - throw new NotImplementedException(); + return (ToString().ToLower() == address.ToString().ToLower()); } /// <summary> |
From: Gaurav V. <mas...@us...> - 2002-10-25 17:10:49
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv23484 Modified Files: ChangeLog MessagingException.cs Log Message: 2002-10-25 * MessagingException.cs : Meesage { get; }, : GetMessage() - Implemented. : BaseMessage { get; } - Default is an empty string, not null string. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- ChangeLog 25 Oct 2002 09:22:18 -0000 1.59 +++ ChangeLog 25 Oct 2002 10:07:34 -0000 1.60 @@ -1,6 +1,13 @@ 2002-10-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * MessagingException.cs : Meesage { get; }, + : GetMessage() - Implemented. + : BaseMessage { get; } - Default is + an empty string, not null string. + +2002-10-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * EMailAddress.cs : Validate() - Implemented. : Unquote(string) - Implemented. * EMailAddressList.cs : Contains() - Implemented. Index: MessagingException.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/MessagingException.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- MessagingException.cs 16 Sep 2002 11:22:47 -0000 1.4 +++ MessagingException.cs 25 Oct 2002 10:07:34 -0000 1.5 @@ -9,6 +9,7 @@ */ using System; +using System.Text; namespace CSMail { @@ -37,12 +38,11 @@ } } - [MailTODO] public override string Message { get { - throw new NotImplementedException(); + return GetMessage(); } } @@ -50,8 +50,38 @@ { get { - return base.Message; + if(base.Message != null) + return base.Message; + return String.Empty; } + } + + private string GetMessage() + { + if(next == null) + return BaseMessage; + Exception nextException = next; + StringBuilder retVal = new StringBuilder(BaseMessage); + while(nextException != null) + { + retVal.Append(";\n Nested Exception is:\n\t"); + if(nextException is MessagingException) + { + MessagingException mex = (MessagingException)nextException; + retVal.Append(mex.GetType().ToString()); + string bm = mex.BaseMessage; + if(bm.Length > 0) + { + retVal.Append(": " + bm); + } + nextException = mex.Next; + } else + { + retVal.Append(nextException.ToString()); + nextException = null; + } + } + return retVal.ToString(); } } } |
From: Gaurav V. <mas...@us...> - 2002-10-25 17:07:10
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv4727 Modified Files: ChangeLog EMailAddress.cs EMailAddressList.cs Log Message: 2002-10-25 * EMailAddress.cs : Validate() - Implemented. : Unquote(string) - Implemented. * EMailAddressList.cs : Contains() - Implemented. : Parse(string, bool, bool) - Can now unquote. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.58 retrieving revision 1.59 diff -u -r1.58 -r1.59 --- ChangeLog 25 Oct 2002 08:52:12 -0000 1.58 +++ ChangeLog 25 Oct 2002 09:22:18 -0000 1.59 @@ -1,6 +1,13 @@ 2002-10-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * EMailAddress.cs : Validate() - Implemented. + : Unquote(string) - Implemented. + * EMailAddressList.cs : Contains() - Implemented. + : Parse(string, bool, bool) - Can now unquote. + +2002-10-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * Constants.cs : RFC822Phrase, : RFC822PhraseNoDot, : RFC822PhraseNoDotAt - New constants. Index: EMailAddress.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/EMailAddress.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- EMailAddress.cs 25 Oct 2002 08:52:13 -0000 1.7 +++ EMailAddress.cs 25 Oct 2002 09:22:18 -0000 1.8 @@ -9,6 +9,7 @@ */ using System; +using System.Text; namespace CSMail { @@ -26,6 +27,13 @@ private string host; private string name; + public EMailAddress() + { + user = null; + host = null; + name = null; + } + public EMailAddress(string email) { Parse(email); @@ -66,6 +74,32 @@ host = parts[1]; } + protected internal static string Unquote(string source) + { + if(source[0] == '"' && source[source.Length - 1] == '"') + { + source = source.Substring(1, source.Length - 2); + if(source.IndexOf('\\') >= 0) + { + StringBuilder sb = new StringBuilder(source.Length); + char c; + int len = source.Length; + for(int index = 0; index < len; index++) + { + c = source[index]; + if(c == '\\' && index < len - 1) + { + index++; + c = source[index]; + } + sb.Append(c); + } + source = sb.ToString(); + } + } + return source; + } + protected internal static void ValidateAddress(string address, bool isEmail) { @@ -138,7 +172,13 @@ { get { - return user; + if(user != null) + return user; + return String.Empty; + } + set + { + user = value; } } @@ -149,7 +189,13 @@ { get { - return host; + if(host != null) + return host; + return String.Empty; + } + set + { + host = value; } } @@ -160,7 +206,13 @@ { get { - return name; + if(name != null) + return name; + return String.Empty; + } + set + { + name = value; } } @@ -176,10 +228,9 @@ } } - [MailTODO] public void Validate() { - throw new NotImplementedException(); + ValidateAddress(user + '@' + host, true); } /// <summary> @@ -292,7 +343,7 @@ /// </returns> public override int GetHashCode() { - string em = user.ToLower() + "@" + host.ToLower(); + string em = User.ToLower() + "@" + Host.ToLower(); return em.GetHashCode(); } Index: EMailAddressList.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/EMailAddressList.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- EMailAddressList.cs 25 Oct 2002 08:52:13 -0000 1.6 +++ EMailAddressList.cs 25 Oct 2002 09:22:18 -0000 1.7 @@ -9,6 +9,7 @@ */ using System; +using System.Text; using System.Collections; namespace CSMail @@ -20,14 +21,13 @@ /// <seealso cref="IAddressList"/> public class EMailAddressList: IAddressList, IEnumerable { - private ArrayList emails; + private ArrayList emails = new ArrayList(); /// <summary> /// Creates an empty instance. /// </summary> public EMailAddressList() { - emails = new ArrayList(); } /// <summary> @@ -37,7 +37,6 @@ /// filled in the initial list.</param> public EMailAddressList(EMailAddress[] addresses) { - emails = new ArrayList(); foreach(EMailAddress current in addresses) { if(current != null) @@ -54,7 +53,6 @@ /// filled in the initial list.</param> public EMailAddressList(EMailAddressList addresses) { - emails = new ArrayList(); foreach(EMailAddress current in addresses) { if(current != null) @@ -64,10 +62,16 @@ } } - [MailTODO] public EMailAddressList(string headerValue) { - throw new NotImplementedException(); + EMailAddress[] values = Parse(headerValue); + if(values != null && values.Length > 0) + { + foreach(EMailAddress current in values) + { + emails.Add(current); + } + } } public static EMailAddress[] Parse(string headerValue) @@ -87,7 +91,6 @@ return Parse(headerValue, strict, true); } - [MailTODO] private static EMailAddress[] Parse(string headerValue, bool strict, bool validate) { @@ -286,9 +289,12 @@ toAdd = new EMailAddress(actVal); if(nameStartIndex >= 0) { - throw new NotImplementedException("[EMailAddressList]" + - " Don't know yet, how to unquote"); - // reset nameStartIndex and addressStartIndex + toAdd.Name = EMailAddress.Unquote( + headerValue.Substring( + nameStartIndex, + addressStartIndex - nameStartIndex).Trim()); + nameStartIndex = -1; + addressStartIndex = -1; } addressList.Add(toAdd); toAdd = null; @@ -327,9 +333,12 @@ toAdd = new EMailAddress(actVal); if(nameStartIndex >= 0) { - throw new NotImplementedException("[EMailAddressList]" + - " Don't know yet, how to unquote"); - // reset nameStartIndex and addressStartIndex + toAdd.Name = EMailAddress.Unquote( + headerValue.Substring( + nameStartIndex, + addressStartIndex - nameStartIndex).Trim()); + nameStartIndex = -1; + addressStartIndex = -1; } addressList.Add(toAdd); toAdd = null; @@ -419,10 +428,9 @@ } } - [MailTODO] public bool Contains(EMailAddress address) { - throw new NotImplementedException(); + return emails.Contains(address); } /// <summary> |
From: Gaurav V. <mas...@us...> - 2002-10-25 17:06:09
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv24268 Modified Files: ChangeLog Constants.cs EMailAddress.cs EMailAddressList.cs Log Message: 2002-10-25 * Constants.cs : RFC822Phrase, : RFC822PhraseNoDot, : RFC822PhraseNoDotAt - New constants. * EMailAddres.cs : Validate(string, bool) - Implemented. * EMailAddressList.cs : Parse(string, bool, bool) - Completed. 2002-10-24 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * EMailAddressList.cs : Parse(string, bool, bool) - Partial implementation. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- ChangeLog 17 Oct 2002 10:34:14 -0000 1.57 +++ ChangeLog 25 Oct 2002 08:52:12 -0000 1.58 @@ -1,4 +1,17 @@ +2002-10-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * Constants.cs : RFC822Phrase, + : RFC822PhraseNoDot, + : RFC822PhraseNoDotAt - New constants. + * EMailAddres.cs : Validate(string, bool) - Implemented. + * EMailAddressList.cs : Parse(string, bool, bool) - Completed. + +2002-10-24 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * EMailAddressList.cs : Parse(string, bool, bool) + - Partial implementation. + 2002-10-17 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * AddressException.cs : Added new exception class. Index: Constants.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Constants.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Constants.cs 4 Oct 2002 11:14:42 -0000 1.6 +++ Constants.cs 25 Oct 2002 08:52:13 -0000 1.7 @@ -60,8 +60,11 @@ public const char CR = '\r'; public const char LF = '\n'; - public const string RFC822Delimiters = "()<>@,;:\\\"\t []."; - public const string MIMEDelimiters = "()<>@,;:\\\"\t []/?="; + public const string RFC822Delimiters = "()<>@,;:\\\"\t []."; + public const string RFC822Phrase = "()<>@,;:\\\"[]."; + public const string RFC822PhraseNoDot = "()<>@,;:\\\"[]"; + public const string RFC822PhraseNoDotAt = "()<>,;:\\\"[]"; + public const string MIMEDelimiters = "()<>@,;:\\\"\t []/?="; /// <summary> /// Key that holds class-name for store service provider. Index: EMailAddress.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/EMailAddress.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- EMailAddress.cs 17 Oct 2002 10:34:14 -0000 1.6 +++ EMailAddress.cs 25 Oct 2002 08:52:13 -0000 1.7 @@ -26,6 +26,11 @@ private string host; private string name; + public EMailAddress(string email) + { + Parse(email); + } + /// <summary> /// Creates an instance using userid and hostname. /// </summary> @@ -50,6 +55,80 @@ public EMailAddress(string name, string user, string host): this(user, host) { this.name = name; + } + + private void Parse(string email) + { + string[] parts = email.Split(new char[] { '@' }); + if(parts.Length != 2) + throw new AddressException("[EMailAddress] Invalid EMail"); + user = parts[0]; + host = parts[1]; + } + + protected internal static void ValidateAddress(string address, + bool isEmail) + { + if(address.IndexOf('"') >= 0) + return; + int i = 0; + if(isEmail) + { + int j; + for(i = 0; (j = address.IndexOfAny(",:".ToCharArray(), + i)) >= 0; i = j + 1) + { + if(address[i] != '@') + throw new AddressException("[EMailAddressList]" + + " Illegal route-address", address, i); + if(address[j] == ':') + { + i = j + 1; + break; + } + } + } + int k = 0; + string tuser = null; + string thost = null; + k = address.IndexOf('@'); + if(k < 0) + throw new AddressException("[EMailAddressList] Missing" + + " final @domain", address, 0); + if(k == i) + throw new AddressException("[EMailAddressList] Missing" + + " userid", address, 0); + if(k == (address.Length - 1)) + throw new AddressException("[EMailAddressList] Missing" + + " domain", address, 0); + tuser = address.Substring(i, k - i); + thost = address.Substring(k + 1); + if(address.IndexOfAny(" \t\r\n".ToCharArray()) >= 0) + throw new AddressException("[EMailAddressList] Illegal" + + " whitespace in address", address, 0); + if(tuser.IndexOfAny(Constants.RFC822PhraseNoDot.ToCharArray()) >= 0) + throw new AddressException("[EMailAddressList] Illegal" + + " character in userid", address, 0); + if(thost.IndexOf('[') < 0 && + thost.IndexOfAny(Constants.RFC822PhraseNoDot.ToCharArray()) >= 0) + throw new AddressException("[EMailAddressList] Illegal" + + " character in domain", address, 0); + } + + public string EMail + { + get + { + if(user == null) + return String.Empty; + if(host == null) + return user; + return user + '@' + host; + } + set + { + Parse(value); + } } /// <summary> Index: EMailAddressList.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/EMailAddressList.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- EMailAddressList.cs 17 Oct 2002 10:34:14 -0000 1.5 +++ EMailAddressList.cs 25 Oct 2002 08:52:13 -0000 1.6 @@ -80,7 +80,7 @@ { return Parse(headerValue, strict, false); } - + public static EMailAddress[] ParseHeader(string headerValue, bool strict) { @@ -91,19 +91,20 @@ private static EMailAddress[] Parse(string headerValue, bool strict, bool validate) { - int i1 = -1; - int j1 = -1; + int nameStartIndex = -1; // i1 + int addressStartIndex = -1; // j1 int len = headerValue.Length; - - bool flag2 = false; - bool flag3 = false; // addressRead - bool startTag = false; // flag4 - + + bool isEmailPart = false; + bool startTag = false; + bool restart = false; + ArrayList addressList = new ArrayList(); - int j = -1; - int i = -1; + EMailAddress toAdd = null; + int quotedBraceIndex = -1; // j + int quoteIndex = -1; // i int index; - + for(index = 0; index < len; index++) { char c = headerValue[index]; @@ -113,12 +114,12 @@ case '\n' : break; case '\r' : break; case ' ' : break; - + case '(' : startTag = true; - if(i >= 0 && j == -1) - j = index; - if(i1 == -1) - i1 = index + 1; + if(quoteIndex >= 0 && quotedBraceIndex == -1) + quotedBraceIndex = index; + if(nameStartIndex == -1) + nameStartIndex = index + 1; index++; int unbalance; for(unbalance = 1; index < len && @@ -135,14 +136,219 @@ default : break; } } - + if(unbalance > 0) throw new AddressException("[EMailAddressList] Missing ')'", headerValue, index); - throw new NotImplementedException(); + index--; + if(addressStartIndex == -1) + addressStartIndex = index; + break; + case ')': throw new AddressException("[EMailAddressList] Missing ')'", + headerValue, index); + case '<': startTag = true; + if(isEmailPart) + throw new AddressException("Extra route-address", + headerValue, index); + nameStartIndex = quoteIndex; + if(nameStartIndex >= 0) + { + addressStartIndex = index; + } + quoteIndex = index+1; + bool isQuoted = false; + restart = false; + while(true) + { + for(index++; index < len; index++) + { + switch(headerValue[index]) + { + case '\\': index++; + restart = false; + break; + case '"' : isQuoted = !isQuoted; + restart = false; + break; + case '>' : if(!isQuoted) + { + restart = true; + } + break; + default : restart = false; + break; + } + if(restart) + break; + } + if(!restart) + break; + } + + if(index >= len) + if(isQuoted) + throw new AddressException("[EMailAddressList]" + + " Missing '\"'", headerValue, index); + else + throw new AddressException("[EMailAddressList]" + + " Missing '>'", headerValue, index); + isEmailPart = true; + quotedBraceIndex = index; + break; + case '>': throw new AddressException("[EMailAddressList]" + + " Missing '<'", headerValue, index); + case '"': startTag = true; + if(quoteIndex == -1) + quoteIndex = index; + restart = false; + while(true) + { + for(index++; index < len; index++) + { + switch(headerValue[index]) + { + case '"' : restart = true; + break; + case '\\': index++; + goto default; + default : index++; + restart = false; + break; + } + if(restart) + break; + } + if(!restart) + break; + } + if(index >= len) + throw new AddressException("[EMailAddressList]" + + " Missing '\"'", headerValue, index); + break; + case '[': startTag = true; + restart = false; + while(true) + { + for(index++; index < len; index++) + { + switch(headerValue[index]) + { + case ']' : restart = true; + break; + case '\\': restart = false; + index++; + goto default; + default : index++; + break; + } + if(restart) + break; + } + if(!restart) + break; + } + + if(index >= len) + throw new AddressException("[EMailAddressList]" + + "Missing ']'", headerValue, index); + break; + case ':': throw new AddressException("[EMailAddressList]" + + "Looks like a news group", headerValue, index); + case ';': if(quoteIndex == -1) + { + quoteIndex = index; + } + if(nameStartIndex == -1) + nameStartIndex = index; + quotedBraceIndex = index + 1; + string email = headerValue.Substring(quoteIndex, + quotedBraceIndex - quoteIndex).Trim(); + toAdd = new EMailAddress(email); + addressList.Add(toAdd); + isEmailPart = false; + quoteIndex = quotedBraceIndex = -1; + break; + case ',': if(quoteIndex == -1) + { + isEmailPart = false; + startTag = false; + quotedBraceIndex = -1; + break; + } + if(quotedBraceIndex == -1) + quotedBraceIndex = index; + string actVal = headerValue.Substring(quoteIndex, + index - quoteIndex).Trim(); + if(startTag || strict || validate) + { + if(strict || validate) + EMailAddress.ValidateAddress(actVal, isEmailPart); + toAdd = new EMailAddress(actVal); + if(nameStartIndex >= 0) + { + throw new NotImplementedException("[EMailAddressList]" + + " Don't know yet, how to unquote"); + // reset nameStartIndex and addressStartIndex + } + addressList.Add(toAdd); + toAdd = null; + } else + { + string[] allAddrs = actVal.Split(new char[] + {' ', '\t', '\n', '\r', '\f'}); + foreach(string currentAddress in allAddrs) + { + EMailAddress.ValidateAddress(currentAddress, false); + toAdd = new EMailAddress(currentAddress); + addressList.Add(toAdd); + } + } + isEmailPart = false; + startTag = false; + quoteIndex = quotedBraceIndex = -1; + break; + default: if(quoteIndex == -1) + { + quoteIndex = index; + } + break; } } - throw new NotImplementedException(); + + if(quoteIndex >= 0) + { + if(quotedBraceIndex == -1) + quotedBraceIndex = index; + string actVal = headerValue.Substring(quoteIndex, quotedBraceIndex - 1).Trim(); + if(startTag || strict || validate) + { + if(strict || validate) + EMailAddress.ValidateAddress(actVal, isEmailPart); + toAdd = new EMailAddress(actVal); + if(nameStartIndex >= 0) + { + throw new NotImplementedException("[EMailAddressList]" + + " Don't know yet, how to unquote"); + // reset nameStartIndex and addressStartIndex + } + addressList.Add(toAdd); + toAdd = null; + } else + { + string[] allAddrs = actVal.Split(new char[] + { ' ', '\t', '\n', '\r', '\f' }); + foreach(string currentAddress in allAddrs) + { + EMailAddress.ValidateAddress(currentAddress, false); + toAdd = new EMailAddress(currentAddress); + addressList.Add(toAdd); + } + } + } + + EMailAddress[] retVal = new EMailAddress[addressList.Count]; + addressList.CopyTo(retVal, 0); + return retVal; } /// <summary> |
From: Gaurav V. <mas...@us...> - 2002-10-17 10:34:17
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv20330 Modified Files: ChangeLog EMailAddress.cs EMailAddressList.cs Provider.cs Added Files: AddressException.cs Log Message: 2002-10-17 * AddressException.cs : Added new exception class. * EMailAddressList.cs : ParseHeaderLine(string) - Renamed to Parse(string). : Parse(string), : Parse(string, bool), : ParseHeader(string, bool), - Implemented. : ParseHeader(string, bool, bool), - Stubbed. * EMailAddress.cs : Validate() - Stubbed. --- NEW FILE --- /** * Namespace: CSMail * Class: AddressException * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public class AddressException : Exception { private int position = -1; private string actualString = null; public AddressException() : base() { } public AddressException(string message) : base(message) { } public AddressException(string message, string actualString, int position) : base(message) { this.actualString = actualString; this.position = position; } public AddressException(string message, Exception e) : base(message, e) { } } } Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- ChangeLog 9 Oct 2002 07:09:30 -0000 1.56 +++ ChangeLog 17 Oct 2002 10:34:14 -0000 1.57 @@ -1,4 +1,22 @@ +2002-10-17 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * AddressException.cs : Added new exception class. + * EMailAddressList.cs : ParseHeaderLine(string) + - Renamed to Parse(string). + : Parse(string), + : Parse(string, bool), + : ParseHeader(string, bool), + - Implemented. + : ParseHeader(string, bool, bool), + - Stubbed. + * EMailAddress.cs : Validate() - Stubbed. + +2002-10-16 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * EMailAddressList.cs : ParseHeaderLine(string) + - Stubbed. + 2002-10-09 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * ContentType.cs : ctor(string) - Implemented. Index: EMailAddress.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/EMailAddress.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- EMailAddress.cs 9 Oct 2002 07:09:30 -0000 1.5 +++ EMailAddress.cs 17 Oct 2002 10:34:14 -0000 1.6 @@ -97,6 +97,12 @@ } } + [MailTODO] + public void Validate() + { + throw new NotImplementedException(); + } + /// <summary> /// Checks for equality with another address. /// </summary> Index: EMailAddressList.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/EMailAddressList.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- EMailAddressList.cs 30 Sep 2002 12:27:22 -0000 1.4 +++ EMailAddressList.cs 17 Oct 2002 10:34:14 -0000 1.5 @@ -70,6 +70,81 @@ throw new NotImplementedException(); } + public static EMailAddress[] Parse(string headerValue) + { + return Parse(headerValue, true); + } + + public static EMailAddress[] Parse(string headerValue, + bool strict) + { + return Parse(headerValue, strict, false); + } + + public static EMailAddress[] ParseHeader(string headerValue, + bool strict) + { + return Parse(headerValue, strict, true); + } + + [MailTODO] + private static EMailAddress[] Parse(string headerValue, + bool strict, bool validate) + { + int i1 = -1; + int j1 = -1; + int len = headerValue.Length; + + bool flag2 = false; + bool flag3 = false; // addressRead + bool startTag = false; // flag4 + + ArrayList addressList = new ArrayList(); + int j = -1; + int i = -1; + int index; + + for(index = 0; index < len; index++) + { + char c = headerValue[index]; + switch(c) + { + case '\t' : break; + case '\n' : break; + case '\r' : break; + case ' ' : break; + + case '(' : startTag = true; + if(i >= 0 && j == -1) + j = index; + if(i1 == -1) + i1 = index + 1; + index++; + int unbalance; + for(unbalance = 1; index < len && + unbalance > 0; index++) + { + switch(headerValue[index]) + { + case '\\' : index++; + break; + case '(' : unbalance++; + break; + case ')' : unbalance--; + break; + default : break; + } + } + + if(unbalance > 0) + throw new AddressException("[EMailAddressList] Missing ')'", + headerValue, index); + throw new NotImplementedException(); + } + } + throw new NotImplementedException(); + } + /// <summary> /// Gets or sets an address at the specified index. /// </summary> Index: Provider.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Provider.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- Provider.cs 9 Oct 2002 07:09:30 -0000 1.8 +++ Provider.cs 17 Oct 2002 10:34:14 -0000 1.9 @@ -157,7 +157,7 @@ { if(obj != null && obj is Provider) { - return (this == (Provider)obj; + return (this == (Provider)obj); } return false; } |