Improved mime parsing API and fixed NSUserDefaults bug.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@8136 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 2000-11-16 12:10:37 +00:00
parent c51e0e9750
commit cc89366d9f
10 changed files with 827 additions and 763 deletions

View file

@ -1,3 +1,13 @@
2000-11-16 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSUserDefaults.m: ([-userLanguages]) updated to ensure we
don't get empty strings in the language list.
* Headers/Foundation/GSMime.h: Revised API
* Source/GSMime.m: Revised API to make more sense
* Documentation/gsdoc/GSMime.gsdoc: ditto
* Documentation/gsdoc/GSMimeDocument.gsdoc: ditto
* Documentation/gsdoc/GSMimeParser.gsdoc: ditto
2000-11-16 Richard Frith-Macdonald <rfm@gnu.org> 2000-11-16 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSURL.m: ([-explode]) bugfix for parsing username/password * Source/NSURL.m: ([-explode]) bugfix for parsing username/password

View file

@ -7,8 +7,8 @@
<email address="rfm@gnu.org"/> <email address="rfm@gnu.org"/>
<url url="http://www.gnustep.org/developers/whoiswho.html"/> <url url="http://www.gnustep.org/developers/whoiswho.html"/>
</author> </author>
<version>0.1</version> <version>0.2</version>
<date>26 Ovctober, 2000</date> <date>16 November, 2000</date>
</head> </head>
<body> <body>
<chapter> <chapter>
@ -21,8 +21,8 @@
<section> <section>
<heading>The classes</heading> <heading>The classes</heading>
<list> <list>
<item><uref url="GSXMLDocument.html">GSXMLDocument</uref></item> <item><uref url="GSMimeDocument.html">GSMimeDocument</uref></item>
<item><uref url="GSXMLParser.html">GSXMParser</uref></item> <item><uref url="GSMimeParser.html">GSMimearser</uref></item>
</list> </list>
</section> </section>
</chapter> </chapter>

View file

@ -9,8 +9,8 @@
<dt><a href ="http://www.gnustep.org/developers/whoiswho.html">Richard Frith-Macdonald</a> <dt><a href ="http://www.gnustep.org/developers/whoiswho.html">Richard Frith-Macdonald</a>
<dd> <dd>
</dl> </dl>
<p>Version: 0.1</p> <p>Version: 0.2</p>
<p>Date: 26 Ovctober, 2000</p> <p>Date: 16 November, 2000</p>
<h2><a name ="cont-0">Mime Parser</a></h2> <h2><a name ="cont-0">Mime Parser</a></h2>
<p> <p>
@ -20,8 +20,8 @@
</p> </p>
<h3><a name ="cont-1">The classes</a></h3> <h3><a name ="cont-1">The classes</a></h3>
<ul> <ul>
<li><a href ="GSXMLDocument.html">GSXMLDocument</a> <li><a href ="GSMimeDocument.html">GSMimeDocument</a>
<li><a href ="GSXMLParser.html">GSXMParser</a> <li><a href ="GSMimeParser.html">GSMimearser</a>
</ul> </ul>
</body> </body>

View file

@ -7,8 +7,8 @@
<email address="rfm@gnu.org"/> <email address="rfm@gnu.org"/>
<url url="http://www.gnustep.org/developers/whoiswho.html"/> <url url="http://www.gnustep.org/developers/whoiswho.html"/>
</author> </author>
<version>0.1</version> <version>0.2</version>
<date>25 October, 2000</date> <date>16 November, 2000</date>
</head> </head>
<body> <body>
<chapter> <chapter>
@ -62,23 +62,29 @@
<method type="BOOL"> <method type="BOOL">
<sel>addHeader:</sel> <sel>addHeader:</sel>
<arg type="NSString*">aHeader</arg> <arg type="NSDictionary*">headerInfo</arg>
<desc> <desc>
This method may be called to add a header to the document. <p>
The header must be a single line of text in the standard This method may be called to add a header to the document.
format (begining with a name and a colon). It will be The header must be a mutable dictionary object that contains
added after all other headers in the document. at least the fields that are standard for all headers.
</p>
</desc> </desc>
</method> </method>
<method type="NSData*"> <method type="NSArray">
<sel>boundary</sel> <sel>allHeaders</sel>
<desc> <desc>
For a multipart document, return the raw data used to <p>
delimit the parts of the document. This method returns an array containing NSDictionary objects
Otherwise, return nil. representing the headers associated with the document.
</desc> </p>
</method> <p>
The order of the headers in the array is the order of the
headers in the document.
</p>
</desc>
</method>
<method type="id"> <method type="id">
<sel>content</sel> <sel>content</sel>
@ -98,7 +104,7 @@
<method type="void"> <method type="void">
<sel>deleteHeader:</sel> <sel>deleteHeader:</sel>
<arg type="NSString*">aHeader</arg> <arg type="NSString*">rawHeader</arg>
<desc> <desc>
This method removes all occurrances of headers whose raw data This method removes all occurrances of headers whose raw data
exactly matches the supplied string. exactly matches the supplied string.
@ -114,16 +120,8 @@
</desc> </desc>
</method> </method>
<method type="NSArray">
<sel>infoForAllHeaders</sel>
<desc>
This method returns an array containing info dictionaries that
represent all the headers of the document.
</desc>
</method>
<method type="NSDictionary*"> <method type="NSDictionary*">
<sel>infoForHeaderNamed:</sel> <sel>headerNamed:</sel>
<arg type="NSString*">aName</arg> <arg type="NSString*">aName</arg>
<desc> <desc>
This method returns the info dictionary for the first header This method returns the info dictionary for the first header
@ -132,7 +130,7 @@
</method> </method>
<method type="NSArray*"> <method type="NSArray*">
<sel>infoForHeadersNamed:</sel> <sel>headersNamed:</sel>
<arg type="NSString*">aName</arg> <arg type="NSString*">aName</arg>
<desc> <desc>
This method returns an array of info dictionaries for all headers This method returns an array of info dictionaries for all headers
@ -140,59 +138,6 @@
</desc> </desc>
</method> </method>
<method type="BOOL">
<sel>parseHeader:</sel>
<arg type="NSScanner*">aScanner</arg>
<sel>named:</sel>
<arg type="NSString*">aName</arg>
<sel>inTo:</sel>
<arg type="NSMutableDictionary*">info</arg>
<desc>
This method is called to parse a header line and split its
contents into an info dictionary.
<p>
On entry, the dictionary is already partially filled,
the name argument is a lowercase representation of the
header name, and the scanner is set to a scan location
immediately after the colon in the header string.
</p>
<p>
If the header is parsed successfully, the method should
return YES, otherwise NO.
</p>
<p>
You should not call this method directly yourself, but may
override it to support parsing of new headers.
</p>
</desc>
</method>
<method type="NSString*">
<sel>scanSpecial:</sel>
<arg type="NSScanner*">aScanner</arg>
<desc>
A convenience method to use a scanner (that is set up to scan a
header line) to scan in a special character that terminated a
token previously scanned. If the token was terminated by
whitespace and no other special character, the string returned
will contain a single space character.
</desc>
</method>
<method type="NSString*">
<sel>scanToken:</sel>
<arg type="NSScanner*">aScanner</arg>
<desc>
A convenience method to use a scanner (that is set up to scan a
header line) to scan a header token - either a quoted string or
a simple word.
<list>
<item>Leading whitespace is ignored.</item>
<item>Backslash escapes in quoted text are converted</item>
</list>
</desc>
</method>
<method type="BOOL"> <method type="BOOL">
<sel>setContent:</sel> <sel>setContent:</sel>
<arg type="id">newContent</arg> <arg type="id">newContent</arg>
@ -203,12 +148,9 @@
<method type="BOOL"> <method type="BOOL">
<sel>setHeader:</sel> <sel>setHeader:</sel>
<arg type="NSString*">aHeader</arg> <arg type="NSDictionary*">headerInfo</arg>
<desc> <desc>
This method may be called to set a header in the document. This method may be called to set a header in the document.
The header must be a single line of text in the standard
format (begining with a name and a colon). It will be
added after all other headers in the document.
Any other headers with the same name will be removed from Any other headers with the same name will be removed from
the document. the document.
</desc> </desc>

View file

@ -10,8 +10,8 @@
<dt><a href ="http://www.gnustep.org/developers/whoiswho.html">Richard Frith-Macdonald</a> <dt><a href ="http://www.gnustep.org/developers/whoiswho.html">Richard Frith-Macdonald</a>
<dd> <dd>
</dl> </dl>
<p>Version: 0.1</p> <p>Version: 0.2</p>
<p>Date: 25 October, 2000</p> <p>Date: 16 November, 2000</p>
<h2><a name ="cont-0">GSMimeDocument</a></h2> <h2><a name ="cont-0">GSMimeDocument</a></h2>
<h2><a name ="GSMimeDocument">GSMimeDocument</a></h2> <h2><a name ="GSMimeDocument">GSMimeDocument</a></h2>
<p><b>Declared in: </b> Foundation/GSMime.h</p> <p><b>Declared in: </b> Foundation/GSMime.h</p>
@ -72,18 +72,14 @@
<ul> <ul>
<li><a href ="GSMimeDocument.html#method-0">+mimeDocument</a> <li><a href ="GSMimeDocument.html#method-0">+mimeDocument</a>
<li><a href ="GSMimeDocument.html#method-1">-addHeader:</a> <li><a href ="GSMimeDocument.html#method-1">-addHeader:</a>
<li><a href ="GSMimeDocument.html#method-2">-boundary</a> <li><a href ="GSMimeDocument.html#method-2">-allHeaders</a>
<li><a href ="GSMimeDocument.html#method-3">-content</a> <li><a href ="GSMimeDocument.html#method-3">-content</a>
<li><a href ="GSMimeDocument.html#method-4">-deleteHeader:</a> <li><a href ="GSMimeDocument.html#method-4">-deleteHeader:</a>
<li><a href ="GSMimeDocument.html#method-5">-deleteHeaderNamed:</a> <li><a href ="GSMimeDocument.html#method-5">-deleteHeaderNamed:</a>
<li><a href ="GSMimeDocument.html#method-6">-infoForAllHeaders</a> <li><a href ="GSMimeDocument.html#method-6">-headerNamed:</a>
<li><a href ="GSMimeDocument.html#method-7">-infoForHeaderNamed:</a> <li><a href ="GSMimeDocument.html#method-7">-headersNamed:</a>
<li><a href ="GSMimeDocument.html#method-8">-infoForHeadersNamed:</a> <li><a href ="GSMimeDocument.html#method-8">-setContent:</a>
<li><a href ="GSMimeDocument.html#method-9">-parseHeader:named:inTo:</a> <li><a href ="GSMimeDocument.html#method-9">-setHeader:</a>
<li><a href ="GSMimeDocument.html#method-10">-scanSpecial:</a>
<li><a href ="GSMimeDocument.html#method-11">-scanToken:</a>
<li><a href ="GSMimeDocument.html#method-12">-setContent:</a>
<li><a href ="GSMimeDocument.html#method-13">-setHeader:</a>
</ul> </ul>
<hr><h2>Class Methods </h2> <hr><h2>Class Methods </h2>
<h3><a name ="method-0">mimeDocument</a></h3> <h3><a name ="method-0">mimeDocument</a></h3>
@ -94,21 +90,33 @@
<hr> <hr>
<hr><h2>Instances Methods </h2> <hr><h2>Instances Methods </h2>
<h3><a name ="method-1">addHeader:</a></h3> <h3><a name ="method-1">addHeader:</a></h3>
- (BOOL) <b>addHeader:</b> (NSString*)aHeader;<br> - (BOOL) <b>addHeader:</b> (NSDictionary*)headerInfo;<br>
<p>
This method may be called to add a header to the document.
The header must be a mutable dictionary object that contains
at least the fields that are standard for all headers.
</p>
This method may be called to add a header to the document.
The header must be a single line of text in the standard
format (begining with a name and a colon). It will be
added after all other headers in the document.
<hr> <hr>
<h3><a name ="method-2">boundary</a></h3> <h3><a name ="method-2">allHeaders</a></h3>
- (NSData*) <b>boundary</b>;<br> - (NSArray) <b>allHeaders</b>;<br>
For a multipart document, return the raw data used to <p>
delimit the parts of the document.
Otherwise, return nil. This method returns an array containing NSDictionary objects
representing the headers associated with the document.
</p>
<p>
The order of the headers in the array is the order of the
headers in the document.
</p>
<hr> <hr>
<h3><a name ="method-3">content</a></h3> <h3><a name ="method-3">content</a></h3>
- (id) <b>content</b>;<br> - (id) <b>content</b>;<br>
@ -127,7 +135,7 @@
<hr> <hr>
<h3><a name ="method-4">deleteHeader:</a></h3> <h3><a name ="method-4">deleteHeader:</a></h3>
- (void) <b>deleteHeader:</b> (NSString*)aHeader;<br> - (void) <b>deleteHeader:</b> (NSString*)rawHeader;<br>
This method removes all occurrances of headers whose raw data This method removes all occurrances of headers whose raw data
exactly matches the supplied string. exactly matches the supplied string.
@ -140,90 +148,30 @@
matches the supplied string. matches the supplied string.
<hr> <hr>
<h3><a name ="method-6">infoForAllHeaders</a></h3> <h3><a name ="method-6">headerNamed:</a></h3>
- (NSArray) <b>infoForAllHeaders</b>;<br> - (NSDictionary*) <b>headerNamed:</b> (NSString*)aName;<br>
This method returns an array containing info dictionaries that
represent all the headers of the document.
<hr>
<h3><a name ="method-7">infoForHeaderNamed:</a></h3>
- (NSDictionary*) <b>infoForHeaderNamed:</b> (NSString*)aName;<br>
This method returns the info dictionary for the first header This method returns the info dictionary for the first header
whose name equals the supplied argument. whose name equals the supplied argument.
<hr> <hr>
<h3><a name ="method-8">infoForHeadersNamed:</a></h3> <h3><a name ="method-7">headersNamed:</a></h3>
- (NSArray*) <b>infoForHeadersNamed:</b> (NSString*)aName;<br> - (NSArray*) <b>headersNamed:</b> (NSString*)aName;<br>
This method returns an array of info dictionaries for all headers This method returns an array of info dictionaries for all headers
whose names equal the supplied argument. whose names equal the supplied argument.
<hr> <hr>
<h3><a name ="method-9">parseHeader:named:inTo:</a></h3> <h3><a name ="method-8">setContent:</a></h3>
- (BOOL) <b>parseHeader:</b> (NSScanner*)aScanner <b>named:</b> (NSString*)aName <b>inTo:</b> (NSMutableDictionary*)info;<br>
This method is called to parse a header line and split its
contents into an info dictionary.
<p>
On entry, the dictionary is already partially filled,
the name argument is a lowercase representation of the
header name, and the scanner is set to a scan location
immediately after the colon in the header string.
</p>
<p>
If the header is parsed successfully, the method should
return YES, otherwise NO.
</p>
<p>
You should not call this method directly yourself, but may
override it to support parsing of new headers.
</p>
<hr>
<h3><a name ="method-10">scanSpecial:</a></h3>
- (NSString*) <b>scanSpecial:</b> (NSScanner*)aScanner;<br>
A convenience method to use a scanner (that is set up to scan a
header line) to scan in a special character that terminated a
token previously scanned. If the token was terminated by
whitespace and no other special character, the string returned
will contain a single space character.
<hr>
<h3><a name ="method-11">scanToken:</a></h3>
- (NSString*) <b>scanToken:</b> (NSScanner*)aScanner;<br>
A convenience method to use a scanner (that is set up to scan a
header line) to scan a header token - either a quoted string or
a simple word.
<ul>
<li>Leading whitespace is ignored.
<li>Backslash escapes in quoted text are converted
</ul>
<hr>
<h3><a name ="method-12">setContent:</a></h3>
- (BOOL) <b>setContent:</b> (id)newContent;<br> - (BOOL) <b>setContent:</b> (id)newContent;<br>
Sets a new value for the content of the document. Sets a new value for the content of the document.
<hr> <hr>
<h3><a name ="method-13">setHeader:</a></h3> <h3><a name ="method-9">setHeader:</a></h3>
- (BOOL) <b>setHeader:</b> (NSString*)aHeader;<br> - (BOOL) <b>setHeader:</b> (NSDictionary*)headerInfo;<br>
This method may be called to set a header in the document. This method may be called to set a header in the document.
The header must be a single line of text in the standard
format (begining with a name and a colon). It will be
added after all other headers in the document.
Any other headers with the same name will be removed from Any other headers with the same name will be removed from
the document. the document.

View file

@ -7,8 +7,8 @@
<email address="rfm@gnu.org"/> <email address="rfm@gnu.org"/>
<url url="http://www.gnustep.org/developers/whoiswho.html"/> <url url="http://www.gnustep.org/developers/whoiswho.html"/>
</author> </author>
<version>0.1</version> <version>0.2</version>
<date>26 October, 2000</date> <date>16 November, 2000</date>
</head> </head>
<body> <body>
<chapter> <chapter>
@ -24,12 +24,21 @@
aspects of the parsing operation. aspects of the parsing operation.
</p> </p>
</desc> </desc>
<method type="GSMimeParser*" factory="yes"> <method type="GSMimeParser*" factory="yes">
<sel>mimeParser</sel> <sel>mimeParser</sel>
<desc> <desc>
Create a parser. Create a parser.
</desc> </desc>
</method> </method>
<method type="GSMimeDocument*">
<sel>document</sel>
<desc>
Returns the object into which raw mime data is being parsed.
</desc>
</method>
<method type="BOOL"> <method type="BOOL">
<sel>parse:</sel> <sel>parse:</sel>
<arg type="NSData*">rawData</arg> <arg type="NSData*">rawData</arg>
@ -40,12 +49,30 @@
all the available information. all the available information.
</desc> </desc>
</method> </method>
<method type="GSMimeDocument*">
<sel>document</sel> <method type="BOOL">
<sel>parseHeader:</sel>
<arg type="NSString*">aRawHeader</arg>
<desc> <desc>
Returns the object into which raw mime data is being parsed. <p>
</desc> This method is called to parse a header line <em>for the
</method> current document</em>, split its contents into an info
dictionary, and add that information to the document.
</p>
<p>
The standard implementation of this method scans basic
information and then calls <code>scanHeaders:named:into:</code>
to complete the parsing of the header.
</p>
<p>
This method also performs consistency checks on headers scanned
so it is recommended that it is not overridden, but that
subclasses override <code>scanHeaders:named:into:</code> to
implement custom scanning.
</p>
</desc>
</method>
<method type="BOOL"> <method type="BOOL">
<sel>parsingHeaders</sel> <sel>parsingHeaders</sel>
<desc> <desc>
@ -55,6 +82,62 @@
trhe mime message (or has been passed all data). trhe mime message (or has been passed all data).
</desc> </desc>
</method> </method>
<method type="BOOL">
<sel>scanHeader:</sel>
<arg type="NSScanner*">aScanner</arg>
<sel>named:</sel>
<arg type="NSString*">aName</arg>
<sel>inTo:</sel>
<arg type="NSMutableDictionary*">info</arg>
<desc>
<p>
This method is called to parse a header line and split its
contents into an info dictionary.
</p>
<p>
On entry, the dictionary is already partially filled,
the name argument is a lowercase representation of the
header name, and the scanner is set to a scan location
immediately after the colon in the header string.
</p>
<p>
If the header is parsed successfully, the method should
return YES, otherwise NO.
</p>
<p>
You should not call this method directly yourself, but may
override it to support parsing of new headers.
</p>
</desc>
</method>
<method type="NSString*">
<sel>scanSpecial:</sel>
<arg type="NSScanner*">aScanner</arg>
<desc>
A convenience method to use a scanner (that is set up to scan a
header line) to scan in a special character that terminated a
token previously scanned. If the token was terminated by
whitespace and no other special character, the string returned
will contain a single space character.
</desc>
</method>
<method type="NSString*">
<sel>scanToken:</sel>
<arg type="NSScanner*">aScanner</arg>
<desc>
A convenience method to use a scanner (that is set up to scan a
header line) to scan a header token - either a quoted string or
a simple word.
<list>
<item>Leading whitespace is ignored.</item>
<item>Backslash escapes in quoted text are converted</item>
</list>
</desc>
</method>
</class> </class>
</chapter> </chapter>
</body> </body>

View file

@ -10,8 +10,8 @@
<dt><a href ="http://www.gnustep.org/developers/whoiswho.html">Richard Frith-Macdonald</a> <dt><a href ="http://www.gnustep.org/developers/whoiswho.html">Richard Frith-Macdonald</a>
<dd> <dd>
</dl> </dl>
<p>Version: 0.1</p> <p>Version: 0.2</p>
<p>Date: 26 October, 2000</p> <p>Date: 16 November, 2000</p>
<h2><a name ="cont-0">GSMimeParser</a></h2> <h2><a name ="cont-0">GSMimeParser</a></h2>
<h2><a name ="GSMimeParser">GSMimeParser</a></h2> <h2><a name ="GSMimeParser">GSMimeParser</a></h2>
<p><b>Declared in: </b> Foundation/GSMime.h</p> <p><b>Declared in: </b> Foundation/GSMime.h</p>
@ -35,9 +35,13 @@
<h2>Methods </h2> <h2>Methods </h2>
<ul> <ul>
<li><a href ="GSMimeParser.html#method-0">+mimeParser</a> <li><a href ="GSMimeParser.html#method-0">+mimeParser</a>
<li><a href ="GSMimeParser.html#method-2">-document</a> <li><a href ="GSMimeParser.html#method-1">-document</a>
<li><a href ="GSMimeParser.html#method-1">-parse:</a> <li><a href ="GSMimeParser.html#method-2">-parse:</a>
<li><a href ="GSMimeParser.html#method-3">-parsingHeaders</a> <li><a href ="GSMimeParser.html#method-3">-parseHeader:</a>
<li><a href ="GSMimeParser.html#method-4">-parsingHeaders</a>
<li><a href ="GSMimeParser.html#method-5">-scanHeader:named:inTo:</a>
<li><a href ="GSMimeParser.html#method-6">-scanSpecial:</a>
<li><a href ="GSMimeParser.html#method-7">-scanToken:</a>
</ul> </ul>
<hr><h2>Class Methods </h2> <hr><h2>Class Methods </h2>
<h3><a name ="method-0">mimeParser</a></h3> <h3><a name ="method-0">mimeParser</a></h3>
@ -47,7 +51,13 @@
<hr> <hr>
<hr><h2>Instances Methods </h2> <hr><h2>Instances Methods </h2>
<h3><a name ="method-1">parse:</a></h3> <h3><a name ="method-1">document</a></h3>
- (GSMimeDocument*) <b>document</b>;<br>
Returns the object into which raw mime data is being parsed.
<hr>
<h3><a name ="method-2">parse:</a></h3>
- (BOOL) <b>parse:</b> (NSData*)rawData;<br> - (BOOL) <b>parse:</b> (NSData*)rawData;<br>
This method is called repeatedly to pass raw mime data into This method is called repeatedly to pass raw mime data into
@ -56,13 +66,34 @@
all the available information. all the available information.
<hr> <hr>
<h3><a name ="method-2">document</a></h3> <h3><a name ="method-3">parseHeader:</a></h3>
- (GSMimeDocument*) <b>document</b>;<br> - (BOOL) <b>parseHeader:</b> (NSString*)aRawHeader;<br>
Returns the object into which raw mime data is being parsed. <p>
This method is called to parse a header line <em>for the
current document</em>, split its contents into an info
dictionary, and add that information to the document.
</p>
<p>
The standard implementation of this method scans basic
information and then calls <code>scanHeaders:named:into:</code>
to complete the parsing of the header.
</p>
<p>
This method also performs consistency checks on headers scanned
so it is recommended that it is not overridden, but that
subclasses override <code>scanHeaders:named:into:</code> to
implement custom scanning.
</p>
<hr> <hr>
<h3><a name ="method-3">parsingHeaders</a></h3> <h3><a name ="method-4">parsingHeaders</a></h3>
- (BOOL) <b>parsingHeaders</b>;<br> - (BOOL) <b>parsingHeaders</b>;<br>
Returns YES if the parser is expecting to read mime headers, Returns YES if the parser is expecting to read mime headers,
@ -70,6 +101,60 @@
data containing headers, and is now waiting for the body of data containing headers, and is now waiting for the body of
trhe mime message (or has been passed all data). trhe mime message (or has been passed all data).
<hr>
<h3><a name ="method-5">scanHeader:named:inTo:</a></h3>
- (BOOL) <b>scanHeader:</b> (NSScanner*)aScanner <b>named:</b> (NSString*)aName <b>inTo:</b> (NSMutableDictionary*)info;<br>
<p>
This method is called to parse a header line and split its
contents into an info dictionary.
</p>
<p>
On entry, the dictionary is already partially filled,
the name argument is a lowercase representation of the
header name, and the scanner is set to a scan location
immediately after the colon in the header string.
</p>
<p>
If the header is parsed successfully, the method should
return YES, otherwise NO.
</p>
<p>
You should not call this method directly yourself, but may
override it to support parsing of new headers.
</p>
<hr>
<h3><a name ="method-6">scanSpecial:</a></h3>
- (NSString*) <b>scanSpecial:</b> (NSScanner*)aScanner;<br>
A convenience method to use a scanner (that is set up to scan a
header line) to scan in a special character that terminated a
token previously scanned. If the token was terminated by
whitespace and no other special character, the string returned
will contain a single space character.
<hr>
<h3><a name ="method-7">scanToken:</a></h3>
- (NSString*) <b>scanToken:</b> (NSScanner*)aScanner;<br>
A convenience method to use a scanner (that is set up to scan a
header line) to scan a header token - either a quoted string or
a simple word.
<ul>
<li>Leading whitespace is ignored.
<li>Backslash escapes in quoted text are converted
</ul>
<hr> <hr>
</body> </body>

View file

@ -43,26 +43,19 @@
{ {
NSMutableArray *headers; NSMutableArray *headers;
id content; id content;
NSData *boundary;
} }
+ (GSMimeDocument*) mimeDocument; + (GSMimeDocument*) mimeDocument;
- (BOOL) addHeader: (NSString*)aHeader; - (BOOL) addHeader: (NSDictionary*)headerInfo;
- (NSData*) boundary; - (NSArray*) allHeaders;
- (id) content; - (id) content;
- (void) deleteHeader: (NSString*)aHeader; - (void) deleteHeader: (NSString*)rawHeader;
- (void) deleteHeaderNamed: (NSString*)aName; - (void) deleteHeaderNamed: (NSString*)aName;
- (NSArray*) infoForAllHeaders; - (NSDictionary*) headerNamed: (NSString*)name;
- (NSDictionary*) infoForHeaderNamed: (NSString*)name; - (NSArray*) headersNamed: (NSString*)name;
- (NSArray*) infoForHeadersNamed: (NSString*)name;
- (BOOL) parseHeader: (NSScanner*)aScanner
named: (NSString*)name
inTo: (NSMutableDictionary*)info;
- (NSString*) scanSpecial: (NSScanner*)aScanner;
- (NSString*) scanToken: (NSScanner*)aScanner;
- (BOOL) setContent: (id)newContent; - (BOOL) setContent: (id)newContent;
- (BOOL) setHeader: (NSString*)aHeader; - (BOOL) setHeader: (NSDictionary*)headerInfo;
@end @end
@ -76,6 +69,7 @@
unsigned lineEnd; unsigned lineEnd;
unsigned input; unsigned input;
BOOL inBody; BOOL inBody;
NSData *boundary;
GSMimeDocument *document; GSMimeDocument *document;
GSMimeParser *child; GSMimeParser *child;
} }
@ -84,7 +78,13 @@
- (GSMimeDocument*) document; - (GSMimeDocument*) document;
- (BOOL) parse: (NSData*)input; - (BOOL) parse: (NSData*)input;
- (BOOL) parseHeader: (NSString*)aRawHeader;
- (BOOL) parsedHeaders; - (BOOL) parsedHeaders;
- (BOOL) scanHeader: (NSScanner*)aScanner
named: (NSString*)headerName
inTo: (NSMutableDictionary*)info;
- (NSString*) scanSpecial: (NSScanner*)aScanner;
- (NSString*) scanToken: (NSScanner*)aScanner;
@end @end

File diff suppressed because it is too large Load diff

View file

@ -290,53 +290,70 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */
+ (NSArray*) userLanguages + (NSArray*) userLanguages
{ {
NSArray *currLang = nil; NSArray *currLang = nil;
NSString *locale; NSString *locale;
if (userLanguages)
return userLanguages;
if (userLanguages != nil)
{
return userLanguages;
}
userLanguages = RETAIN([NSMutableArray arrayWithCapacity: 5]); userLanguages = RETAIN([NSMutableArray arrayWithCapacity: 5]);
locale = GSSetLocale(@""); locale = GSSetLocale(@"");
if (sharedDefaults == nil) if (sharedDefaults == nil)
{ {
/* Create our own defaults to get "Languages" since sharedDefaults /* Create our own defaults to get "Languages" since sharedDefaults
depends on us */ depends on us */
NSUserDefaults *tempDefaults; NSUserDefaults *tempDefaults;
tempDefaults = [[self alloc] init]; tempDefaults = [[self alloc] init];
if (tempDefaults) if (tempDefaults != nil)
{ {
[tempDefaults __createStandardSearchList]; [tempDefaults __createStandardSearchList];
currLang = [tempDefaults stringArrayForKey: @"Languages"]; currLang = [tempDefaults stringArrayForKey: @"Languages"];
RELEASE(tempDefaults); RELEASE(tempDefaults);
} }
} }
else else
currLang = [[self standardUserDefaults] stringArrayForKey: @"Languages"]; {
if (currLang == nil && locale && GSLanguageFromLocale(locale)) currLang = [[self standardUserDefaults] stringArrayForKey: @"Languages"];
currLang = [NSArray arrayWithObject: GSLanguageFromLocale(locale)]; }
if (currLang == nil && locale != 0 && GSLanguageFromLocale(locale))
{
currLang = [NSArray arrayWithObject: GSLanguageFromLocale(locale)];
}
if (currLang == nil) if (currLang == nil)
{ {
const char *env_list; const char *env_list;
NSString *env; NSString *env;
env_list = getenv("LANGUAGES"); env_list = getenv("LANGUAGES");
if (env_list) if (env_list != 0)
{ {
env = [NSStringClass stringWithCString: env_list]; env = [NSStringClass stringWithCString: env_list];
currLang = RETAIN([env componentsSeparatedByString: @";"]); currLang = [env componentsSeparatedByString: @";"];
} }
} }
if (currLang != nil) if (currLang != nil)
[userLanguages addObjectsFromArray: currLang]; {
if ([currLang containsObject: @""] == YES)
{
NSMutableArray *a = [currLang mutableCopy];
[a removeObject: @""];
currLang = (NSArray*)AUTORELEASE(a);
}
[userLanguages addObjectsFromArray: currLang];
}
/* Check if "English" is included. We do this to make sure all the /* Check if "English" is included. We do this to make sure all the
required language constants are set somewhere if they aren't set required language constants are set somewhere if they aren't set
in the default language */ in the default language */
if ([userLanguages containsObject: @"English"] == NO) if ([userLanguages containsObject: @"English"] == NO)
[userLanguages addObject: @"English"]; {
[userLanguages addObject: @"English"];
}
return userLanguages; return userLanguages;
} }
@ -683,14 +700,18 @@ static NSString *pathForUser(NSString *user)
{ {
id arr = [self arrayForKey: defaultName]; id arr = [self arrayForKey: defaultName];
if (arr) if (arr != nil)
{ {
NSEnumerator *enumerator = [arr objectEnumerator]; NSEnumerator *enumerator = [arr objectEnumerator];
id obj; id obj;
while ((obj = [enumerator nextObject])) while ((obj = [enumerator nextObject]))
if ( ! [obj isKindOfClass: NSStringClass]) {
return nil; if ([obj isKindOfClass: NSStringClass] == NO)
{
return nil;
}
}
return arr; return arr;
} }
return nil; return nil;