mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Add content location methods.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19903 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9d463e9e59
commit
71f88092d1
4 changed files with 69 additions and 8 deletions
|
@ -1,3 +1,7 @@
|
|||
2004-08-23 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Additions/GSMime.m: Add content location methods.
|
||||
|
||||
2004-08-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSString.m: Various minor optimisations ... uppercaseString
|
||||
|
|
|
@ -113,10 +113,12 @@
|
|||
- (NSArray*) allHeaders;
|
||||
- (id) content;
|
||||
- (id) contentByID: (NSString*)key;
|
||||
- (id) contentByLocation: (NSString*)key;
|
||||
- (id) contentByName: (NSString*)key;
|
||||
- (id) copyWithZone: (NSZone*)z;
|
||||
- (NSString*) contentFile;
|
||||
- (NSString*) contentID;
|
||||
- (NSString*) contentLocation;
|
||||
- (NSString*) contentName;
|
||||
- (NSString*) contentSubtype;
|
||||
- (NSString*) contentType;
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
static NSCharacterSet *whitespace = nil;
|
||||
static NSCharacterSet *rfc822Specials = nil;
|
||||
static NSCharacterSet *rfc2045Specials = nil;
|
||||
static Class NSArrayClass = 0;
|
||||
|
||||
/*
|
||||
* Name - decodebase64()
|
||||
|
@ -652,6 +653,14 @@ wordData(NSString *word)
|
|||
return AUTORELEASE(newDocument);
|
||||
}
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
if (NSArrayClass == 0)
|
||||
{
|
||||
NSArrayClass = [NSArray class];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and return a parser.
|
||||
*/
|
||||
|
@ -2635,6 +2644,10 @@ static NSCharacterSet *tokenSet = nil;
|
|||
tokenSet = [ms copy];
|
||||
RELEASE(ms);
|
||||
nonToken = RETAIN([tokenSet invertedSet]);
|
||||
if (NSArrayClass == 0)
|
||||
{
|
||||
NSArrayClass = [NSArray class];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3379,6 +3392,10 @@ static NSCharacterSet *tokenSet = nil;
|
|||
[m removeCharactersInString: @"."];
|
||||
rfc2045Specials = [m copy];
|
||||
whitespace = RETAIN([NSCharacterSet whitespaceAndNewlineCharacterSet]);
|
||||
if (NSArrayClass == 0)
|
||||
{
|
||||
NSArrayClass = [NSArray class];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3543,7 +3560,7 @@ static NSCharacterSet *tokenSet = nil;
|
|||
{
|
||||
key = [NSString stringWithFormat: @"<%@>", key];
|
||||
}
|
||||
if ([content isKindOfClass: [NSArray class]] == YES)
|
||||
if ([content isKindOfClass: NSArrayClass] == YES)
|
||||
{
|
||||
NSEnumerator *e = [content objectEnumerator];
|
||||
GSMimeDocument *d;
|
||||
|
@ -3564,6 +3581,35 @@ static NSCharacterSet *tokenSet = nil;
|
|||
return nil;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the content of this document to locate a part whose content ID
|
||||
* matches the specified key. Recursively descend into other documents.<br />
|
||||
* Wraps the supplied key in angle brackets if they are not present.<br />
|
||||
* Return nil if no match is found, the matching GSMimeDocument otherwise.
|
||||
*/
|
||||
- (id) contentByLocation: (NSString*)key
|
||||
{
|
||||
if ([content isKindOfClass: NSArrayClass] == YES)
|
||||
{
|
||||
NSEnumerator *e = [content objectEnumerator];
|
||||
GSMimeDocument *d;
|
||||
|
||||
while ((d = [e nextObject]) != nil)
|
||||
{
|
||||
if ([[d contentLocation] isEqualToString: key] == YES)
|
||||
{
|
||||
return d;
|
||||
}
|
||||
d = [d contentByLocation: key];
|
||||
if (d != nil)
|
||||
{
|
||||
return d;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the content of this document to locate a part whose content-type
|
||||
* name or content-disposition name matches the specified key.
|
||||
|
@ -3573,7 +3619,7 @@ static NSCharacterSet *tokenSet = nil;
|
|||
- (id) contentByName: (NSString*)key
|
||||
{
|
||||
|
||||
if ([content isKindOfClass: [NSArray class]] == YES)
|
||||
if ([content isKindOfClass: NSArrayClass] == YES)
|
||||
{
|
||||
NSEnumerator *e = [content objectEnumerator];
|
||||
GSMimeDocument *d;
|
||||
|
@ -3622,6 +3668,16 @@ static NSCharacterSet *tokenSet = nil;
|
|||
return [hdr value];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to fetch the content location from the header.
|
||||
*/
|
||||
- (NSString*) contentLocation
|
||||
{
|
||||
GSMimeHeader *hdr = [self headerNamed: @"content-location"];
|
||||
|
||||
return [hdr value];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to fetch the content name from the header.
|
||||
*/
|
||||
|
@ -3716,7 +3772,7 @@ static NSCharacterSet *tokenSet = nil;
|
|||
{
|
||||
NSMutableArray *a = nil;
|
||||
|
||||
if ([content isKindOfClass: [NSArray class]] == YES)
|
||||
if ([content isKindOfClass: NSArrayClass] == YES)
|
||||
{
|
||||
NSEnumerator *e = [content objectEnumerator];
|
||||
GSMimeDocument *d;
|
||||
|
@ -3816,7 +3872,7 @@ static NSCharacterSet *tokenSet = nil;
|
|||
c->headers = [[NSMutableArray allocWithZone: z] initWithArray: headers
|
||||
copyItems: YES];
|
||||
|
||||
if ([content isKindOfClass: [NSArray class]] == YES)
|
||||
if ([content isKindOfClass: NSArrayClass] == YES)
|
||||
{
|
||||
c->content = [[NSMutableArray allocWithZone: z] initWithArray: content
|
||||
copyItems: YES];
|
||||
|
@ -4123,7 +4179,7 @@ static NSCharacterSet *tokenSet = nil;
|
|||
}
|
||||
}
|
||||
|
||||
if ([content isKindOfClass: [NSArray class]] == YES)
|
||||
if ([content isKindOfClass: NSArrayClass] == YES)
|
||||
{
|
||||
count = [content count];
|
||||
partData = [NSMutableArray arrayWithCapacity: count];
|
||||
|
@ -4540,7 +4596,7 @@ static NSCharacterSet *tokenSet = nil;
|
|||
ASSIGNCOPY(content, newContent);
|
||||
}
|
||||
}
|
||||
else if ([newContent isKindOfClass: [NSArray class]] == YES)
|
||||
else if ([newContent isKindOfClass: NSArrayClass] == YES)
|
||||
{
|
||||
if (newContent != content)
|
||||
{
|
||||
|
@ -4670,7 +4726,7 @@ static NSCharacterSet *tokenSet = nil;
|
|||
|
||||
if ([type isEqualToString: @"multipart"] == NO
|
||||
&& [type isEqualToString: @"application"] == NO
|
||||
&& [content isKindOfClass: [NSArray class]] == YES)
|
||||
&& [content isKindOfClass: NSArrayClass] == YES)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@ -%@] content doesn't match content-type",
|
||||
|
|
|
@ -1027,7 +1027,6 @@ GSPropertyListFromStringsFormat(NSString *string)
|
|||
NSMutableDictionary *dict;
|
||||
pldata _pld;
|
||||
pldata *pld = &_pld;
|
||||
unsigned length;
|
||||
NSData *d;
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue