mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Add convenience
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13912 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e1074fa54a
commit
351d09cae4
3 changed files with 59 additions and 6 deletions
|
@ -3,6 +3,7 @@
|
|||
* Source/NSURL.m: Cope with a URL where the path is missing.
|
||||
Check user, password, host, port parts for illegal characters.
|
||||
Thanks to bug report by Marco Manfredini <mldb@gmx.org>
|
||||
* Source/GSMime.m: add convenience method for setting document type.
|
||||
|
||||
2002-06-17 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -112,6 +112,9 @@
|
|||
- (GSMimeHeader*) makeContentID;
|
||||
- (NSMutableData*) rawMimeData;
|
||||
- (void) setContent: (id)newContent;
|
||||
- (void) setContent: (id)newContent
|
||||
type: (NSString*)type
|
||||
name: (NSString*)name;
|
||||
- (void) setContent: (id)newContent
|
||||
type: (NSString*)type
|
||||
subType: (NSString*)subType
|
||||
|
|
|
@ -1353,17 +1353,18 @@ selectCharacterSet(NSString *str, NSData **d)
|
|||
if ([type isEqualToString: @"text"] == YES)
|
||||
{
|
||||
if (subtype == nil)
|
||||
subtype = @"plain";
|
||||
}
|
||||
else if ([type isEqualToString: @"application"] == YES)
|
||||
{
|
||||
if (subtype == nil)
|
||||
subtype = @"octet-stream";
|
||||
{
|
||||
subtype = @"plain";
|
||||
}
|
||||
}
|
||||
else if ([type isEqualToString: @"multipart"] == YES)
|
||||
{
|
||||
NSString *tmp = [info parameterForKey: @"boundary"];
|
||||
|
||||
if (subtype == nil)
|
||||
{
|
||||
subtype = @"mixed";
|
||||
}
|
||||
supported = YES;
|
||||
if (tmp != nil)
|
||||
{
|
||||
|
@ -1381,6 +1382,13 @@ selectCharacterSet(NSString *str, NSData **d)
|
|||
return NO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (subtype == nil)
|
||||
{
|
||||
subtype = @"octet-stream";
|
||||
}
|
||||
}
|
||||
|
||||
[document deleteHeaderNamed: name]; // Should be unique
|
||||
}
|
||||
|
@ -3574,6 +3582,47 @@ static NSCharacterSet *tokenSet = nil;
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method calling -setContent:type:subType:name: to set
|
||||
* content and type. If the type argument contains a slash '/')
|
||||
* then it is split into type and subtype parts, otherwise, the
|
||||
* subtype is assumed to be nil.
|
||||
*/
|
||||
- (void) setContent: (id)newContent
|
||||
type: (NSString*)type
|
||||
name: (NSString*)name
|
||||
{
|
||||
NSString *subtype = nil;
|
||||
|
||||
if (type != nil)
|
||||
{
|
||||
NSRange r;
|
||||
|
||||
r = [type rangeOfString: @"/"];
|
||||
if (r.length > 0)
|
||||
{
|
||||
subtype = [type substringFromIndex: NSMaxRange(r)];
|
||||
type = [type substringToIndex: r.location];
|
||||
}
|
||||
else if ([type isEqual: @"text"] == YES)
|
||||
{
|
||||
subtype = @"plain";
|
||||
}
|
||||
else if ([type isEqual: @"multipart"] == YES)
|
||||
{
|
||||
subtype = @"mixed";
|
||||
}
|
||||
else
|
||||
{
|
||||
subtype = @"octet-stream";
|
||||
}
|
||||
}
|
||||
[self setContent: newContent
|
||||
type: type
|
||||
subType: subtype
|
||||
name: name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to set the content of the document along with
|
||||
* creating a content-type header for it.
|
||||
|
|
Loading…
Reference in a new issue