2004-10-08 Helge Hess <helge.hess@opengroupware.org>
+ * v0.9.29
+
+ * SOGoMailObject.m: added toOneRelationshipKeys/toManyRelationshipKeys
+ (return the contained body parts)
+
+ * SOGoMailFolder.m: added toOneRelationshipKeys (returns the message
+ uids)
+
* marked collections as WebDAV collections (v0.9.28)
2004-10-06 Helge Hess <helge.hess@opengroupware.org>
return [[self mailManager] subfoldersForURL:[self imap4URL]
password:[self imap4Password]];
}
+- (NSArray *)toOneRelationshipKeys {
+ return [[self fetchUIDsMatchingQualifier:nil sortOrdering:@"DATE"]
+ valueForKey:@"stringValue"];
+}
/* messages */
- (NSArray *)fetchUIDsMatchingQualifier:(id)_q sortOrdering:(id)_so {
+ /* seems to return an NSArray of NSNumber's */
return [[self mailManager] fetchUIDsInURL:[self imap4URL]
qualifier:_q sortOrdering:_so
password:[self imap4Password]];
return self;
}
+/* part hierarchy */
+
+- (NSString *)keyExtensionForPart:(id)_partInfo {
+ NSString *mt, *st;
+
+ if (_partInfo == nil)
+ return nil;
+
+ mt = [_partInfo valueForKey:@"type"];
+ st = [[_partInfo valueForKey:@"subtype"] lowercaseString];
+ if ([mt isEqualToString:@"text"]) {
+ if ([st isEqualToString:@"plain"])
+ return @".txt";
+ if ([st isEqualToString:@"html"])
+ return @".html";
+ }
+ else if ([mt isEqualToString:@"image"])
+ return [@"." stringByAppendingString:st];
+
+ return nil;
+}
+
+- (NSArray *)relationshipKeysWithParts:(BOOL)_withParts {
+ /* should return non-multipart children */
+ NSMutableArray *ma;
+ NSArray *parts;
+ unsigned i, count;
+
+ parts = [[self bodyStructure] valueForKey:@"parts"];
+ if (![parts isNotNull])
+ return nil;
+ if ((count = [parts count]) == 0)
+ return nil;
+
+ for (i = 0, ma = nil; i < count; i++) {
+ NSString *key, *ext;
+ id part;
+ BOOL hasParts;
+
+ part = [parts objectAtIndex:i];
+ hasParts = [part valueForKey:@"parts"] != nil ? YES:NO;
+ if ((hasParts && !_withParts) || (_withParts && !hasParts))
+ continue;
+
+ if (ma == nil)
+ ma = [NSMutableArray arrayWithCapacity:count - i];
+
+ ext = [self keyExtensionForPart:part];
+ key = [[NSString alloc] initWithFormat:@"%d%@", i, ext?ext:@""];
+ [ma addObject:key];
+ [key release];
+ }
+ return ma;
+}
+
+- (NSArray *)toOneRelationshipKeys {
+ return [self relationshipKeysWithParts:NO];
+}
+- (NSArray *)toManyRelationshipKeys {
+ return [self relationshipKeysWithParts:YES];
+}
+
/* message */
- (id)fetchParts:(NSArray *)_parts {
if ([self respondsToSelector:@selector(contentAsString)])
return [self contentAsString];
- return [NSException exceptionWithHTTPStatus:502 /* not implemented */
+ return [NSException exceptionWithHTTPStatus:501 /* not implemented */
reason:@"no WebDAV GET support?!"];
}