mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-20 20:26:42 +00:00
Add method for getting all contents with specified name.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13743 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
226b31f0b2
commit
906f779418
2 changed files with 44 additions and 0 deletions
|
@ -97,6 +97,7 @@
|
||||||
- (NSString*) contentName;
|
- (NSString*) contentName;
|
||||||
- (NSString*) contentSubType;
|
- (NSString*) contentSubType;
|
||||||
- (NSString*) contentType;
|
- (NSString*) contentType;
|
||||||
|
- (NSArray*) contentsByName: (NSString*)key;
|
||||||
- (NSData*) convertToData;
|
- (NSData*) convertToData;
|
||||||
- (NSString*) convertToText;
|
- (NSString*) convertToText;
|
||||||
- (void) deleteHeader: (GSMimeHeader*)aHeader;
|
- (void) deleteHeader: (GSMimeHeader*)aHeader;
|
||||||
|
|
|
@ -2884,6 +2884,49 @@ static NSCharacterSet *tokenSet = nil;
|
||||||
return [hdr objectForKey: @"Type"];
|
return [hdr objectForKey: @"Type"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search the content of this document to locate all parts whose content-type
|
||||||
|
* name or content-disposition name matches the specified key.
|
||||||
|
* Do <em>NOT</em> recurse into other documents.<br />
|
||||||
|
* Return nil if no match is found, an array of matching GSMimeDocument
|
||||||
|
* instances otherwise.
|
||||||
|
*/
|
||||||
|
- (NSArray*) contentsByName: (NSString*)key
|
||||||
|
{
|
||||||
|
NSMutableArray *a = nil;
|
||||||
|
|
||||||
|
if ([content isKindOfClass: [NSArray class]] == YES)
|
||||||
|
{
|
||||||
|
NSEnumerator *e = [content objectEnumerator];
|
||||||
|
GSMimeDocument *d;
|
||||||
|
|
||||||
|
while ((d = [e nextObject]) != nil)
|
||||||
|
{
|
||||||
|
GSMimeHeader *hdr;
|
||||||
|
BOOL match = YES;
|
||||||
|
|
||||||
|
hdr = [d headerNamed: @"content-type"];
|
||||||
|
if ([[hdr parameterForKey: @"name"] isEqualToString: key] == NO)
|
||||||
|
{
|
||||||
|
hdr = [d headerNamed: @"content-disposition"];
|
||||||
|
if ([[hdr parameterForKey: @"name"] isEqualToString: key] == NO)
|
||||||
|
{
|
||||||
|
match = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (match == YES)
|
||||||
|
{
|
||||||
|
if (a == nil)
|
||||||
|
{
|
||||||
|
a = [NSMutableArray arrayWithCapacity: 4];
|
||||||
|
}
|
||||||
|
[a addObject: d];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the content as an NSData object (unless it is multipart)
|
* Return the content as an NSData object (unless it is multipart)
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue