From 0c742dd5ca7a3c44b6c6cf97ebd565fee7e14139 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 1 Oct 2010 21:24:15 +0000 Subject: [PATCH] Monotone-Parent: e46203402a1f2d996395599061c75452a98958d3 Monotone-Revision: b178183ad97d53d251135c909db06ab534f73a1f Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-10-01T21:24:15 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 11 +++++ OpenChange/GNUmakefile | 2 + OpenChange/MAPIStoreCalendarContext.m | 6 +++ OpenChange/MAPIStoreContactsContext.m | 10 ++++- OpenChange/MAPIStoreContext.h | 3 ++ OpenChange/MAPIStoreContext.m | 65 ++++++++++++++++----------- OpenChange/MAPIStoreMailContext.m | 5 +++ OpenChange/SOGoGCSFolder+MAPIStore.h | 34 ++++++++++++++ OpenChange/SOGoGCSFolder+MAPIStore.m | 54 ++++++++++++++++++++++ 9 files changed, 162 insertions(+), 28 deletions(-) create mode 100644 OpenChange/SOGoGCSFolder+MAPIStore.h create mode 100644 OpenChange/SOGoGCSFolder+MAPIStore.m diff --git a/ChangeLog b/ChangeLog index 3213fbd71..02f18e068 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2010-10-01 Wolfgang Sourdeau + * OpenChange/SOGoGCSFolder+MAPIStore.m (-componentKeysWithType:): + new method that return the keys of components corresponding to the + type passed as parameter. + + * OpenChange/SOGoGCSFolder+MAPIStore.[hm]: new category module. + + * OpenChange/MAPIStoreContext.m (-lookupObject): return nil when + the parsed URL is nil. + (-getFolderMessageKeys:): new subclass method designed to return + the appropriate "message" keys depending on the folder type. + * SoObjects/SOGo/SOGoObject.m (-displayName): new accessor. 2010-09-30 Wolfgang Sourdeau diff --git a/OpenChange/GNUmakefile b/OpenChange/GNUmakefile index cebaa23ff..d59135ca5 100644 --- a/OpenChange/GNUmakefile +++ b/OpenChange/GNUmakefile @@ -25,6 +25,8 @@ $(MAPISTORESOGO)_OBJC_FILES += \ MAPIStoreContactsContext.m \ MAPIStoreMailContext.m \ \ + SOGoGCSFolder+MAPIStore.m \ + \ NSCalendarDate+MAPIStore.m \ NSString+MAPIStore.m diff --git a/OpenChange/MAPIStoreCalendarContext.m b/OpenChange/MAPIStoreCalendarContext.m index c1515569b..6c2eae714 100644 --- a/OpenChange/MAPIStoreCalendarContext.m +++ b/OpenChange/MAPIStoreCalendarContext.m @@ -29,6 +29,7 @@ #import "MAPIStoreAuthenticator.h" #import "NSCalendarDate+MAPIStore.h" #import "NSString+MAPIStore.h" +#import "SOGoGCSFolder+MAPIStore.h" #import "MAPIStoreCalendarContext.h" @@ -59,6 +60,11 @@ static Class SOGoUserFolderK; [moduleFolder retain]; } +- (NSArray *) getFolderMessageKeys: (SOGoFolder *) folder +{ + return [(SOGoGCSFolder *) folder componentKeysWithType: @"vevent"]; +} + - (int) getMessageTableChildproperty: (void **) data atURL: (NSString *) childURL withTag: (uint32_t) proptag diff --git a/OpenChange/MAPIStoreContactsContext.m b/OpenChange/MAPIStoreContactsContext.m index cde993ce3..d53184a58 100644 --- a/OpenChange/MAPIStoreContactsContext.m +++ b/OpenChange/MAPIStoreContactsContext.m @@ -27,12 +27,13 @@ #import #import -#import -#import +#import +#import #import "MAPIApplication.h" #import "MAPIStoreAuthenticator.h" #import "NSString+MAPIStore.h" +#import "SOGoGCSFolder+MAPIStore.h" #import "MAPIStoreContactsContext.h" @@ -63,6 +64,11 @@ static Class SOGoUserFolderK; [moduleFolder retain]; } +- (NSArray *) getFolderMessageKeys: (SOGoFolder *) folder +{ + return [(SOGoGCSFolder *) folder componentKeysWithType: @"vcard"]; +} + // - (int) getCommonTableChildproperty: (void **) data // atURL: (NSString *) childURL // withTag: (uint32_t) proptag diff --git a/OpenChange/MAPIStoreContext.h b/OpenChange/MAPIStoreContext.h index fbfe549d2..d233bc121 100644 --- a/OpenChange/MAPIStoreContext.h +++ b/OpenChange/MAPIStoreContext.h @@ -30,6 +30,7 @@ #define SENSITIVITY_PRIVATE 2 #define SENSITIVITY_COMPANY_CONFIDENTIAL 3 +@class NSArray; @class NSMutableDictionary; @class NSString; @@ -110,6 +111,8 @@ /* subclass methods */ +- (NSArray *) getFolderMessageKeys: (SOGoFolder *) folder; + - (int) getCommonTableChildproperty: (void **) data atURL: (NSString *) childURL withTag: (uint32_t) proptag diff --git a/OpenChange/MAPIStoreContext.m b/OpenChange/MAPIStoreContext.m index 0a6351dad..5564c0e2d 100644 --- a/OpenChange/MAPIStoreContext.m +++ b/OpenChange/MAPIStoreContext.m @@ -251,40 +251,46 @@ static MAPIStoreMapping *mapping = nil; NSString *pathString, *nameInContainer; objectURL = [NSURL URLWithString: objectURLString]; - if (!objectURL) - [self errorWithFormat: @"url string gave nil NSURL: '%@'", objectURLString]; - object = moduleFolder; - - pathString = [objectURL path]; - if ([pathString hasPrefix: @"/"]) - pathString = [pathString substringFromIndex: 1]; - if ([pathString length] > 0) + if (objectURL) { - path = [pathString componentsSeparatedByString: @"/"]; - max = [path count]; - if (max > 0) + object = moduleFolder; + + pathString = [objectURL path]; + if ([pathString hasPrefix: @"/"]) + pathString = [pathString substringFromIndex: 1]; + if ([pathString length] > 0) { - for (count = 0; - object && count < max; - count++) + path = [pathString componentsSeparatedByString: @"/"]; + max = [path count]; + if (max > 0) { - nameInContainer = [[path objectAtIndex: count] + for (count = 0; + object && count < max; + count++) + { + nameInContainer = [[path objectAtIndex: count] stringByUnescapingURL]; - object = [object lookupName: nameInContainer - inContext: woContext - acquire: NO]; - if ([object isKindOfClass: SOGoObjectK]) - [woContext setClientObject: object]; - else - object = nil; + object = [object lookupName: nameInContainer + inContext: woContext + acquire: NO]; + if ([object isKindOfClass: SOGoObjectK]) + [woContext setClientObject: object]; + else + object = nil; + } } } - } - else - object = nil; + else + object = nil; // [self _setNewLastObject: object]; // ASSIGN (lastObjectURL, objectURLString); + } + else + { + object = nil; + [self errorWithFormat: @"url string gave nil NSURL: '%@'", objectURLString]; + } [woContext setClientObject: object]; @@ -437,7 +443,7 @@ static MAPIStoreMapping *mapping = nil; { folder = [self lookupObject: folderURL]; if (folder) - keys = [folder toOneRelationshipKeys]; + keys = [self getFolderMessageKeys: folder]; else keys = (NSArray *) [NSNull null]; [messageCache setObject: keys forKey: folderURL]; @@ -446,6 +452,13 @@ static MAPIStoreMapping *mapping = nil; return keys; } +- (NSArray *) getFolderMessageKeys: (SOGoFolder *) folder +{ + [self subclassResponsibility: _cmd]; + + return (NSArray *) [NSNull null]; +} + - (NSArray *) _subfolderKeysForFolderURL: (NSString *) folderURL { NSArray *keys; diff --git a/OpenChange/MAPIStoreMailContext.m b/OpenChange/MAPIStoreMailContext.m index 55daf3d89..d17e33860 100644 --- a/OpenChange/MAPIStoreMailContext.m +++ b/OpenChange/MAPIStoreMailContext.m @@ -76,6 +76,11 @@ static Class SOGoUserFolderK; [moduleFolder retain]; } +- (NSArray *) getFolderMessageKeys: (SOGoFolder *) folder +{ + return [(SOGoMailFolder *) folder toOneRelationshipKeys]; +} + // - (int) getCommonTableChildproperty: (void **) data // atURL: (NSString *) childURL // withTag: (uint32_t) proptag diff --git a/OpenChange/SOGoGCSFolder+MAPIStore.h b/OpenChange/SOGoGCSFolder+MAPIStore.h new file mode 100644 index 000000000..07c96e72a --- /dev/null +++ b/OpenChange/SOGoGCSFolder+MAPIStore.h @@ -0,0 +1,34 @@ +/* SOGoGCSFolder+MAPIStore.h - this file is part of SOGo + * + * Copyright (C) 2010 Inverse inc. + * + * Author: Wolfgang Sourdeau + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef SOGOGCSFOLDER_MAPISTORE_H +#define SOGOGCSFOLDER_MAPISTORE_H + +#import + +@interface SOGoGCSFolder (MAPIStore) + +- (NSArray *) componentKeysWithType: (NSString *) component; + +@end + +#endif /* SOGOGCSFOLDER+MAPISTORE_H */ diff --git a/OpenChange/SOGoGCSFolder+MAPIStore.m b/OpenChange/SOGoGCSFolder+MAPIStore.m new file mode 100644 index 000000000..e4894edf2 --- /dev/null +++ b/OpenChange/SOGoGCSFolder+MAPIStore.m @@ -0,0 +1,54 @@ +/* SOGoGCSFolder+MAPIStore.m - this file is part of SOGo + * + * Copyright (C) 2010 Inverse inc. + * + * Author: Wolfgang Sourdeau + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#import +#import +#import + +#import "SOGoGCSFolder+MAPIStore.h" + +@implementation SOGoGCSFolder (MAPIStore) + +- (NSArray *) componentKeysWithType: (NSString *) component +{ + NSArray *records; + NSMutableArray *keys; + NSInteger count, max; + NSDictionary *record; + + [self toOneRelationshipKeys]; + + records = [childRecords allValues]; + max = [records count]; + keys = [NSMutableArray arrayWithCapacity: max]; + for (count = 0; count < max; count++) + { + record = [records objectAtIndex: count]; + if ([[record objectForKey: @"c_component"] + isEqualToString: component]) + [keys addObject: [record objectForKey: @"c_name"]]; + } + + return keys; +} + +@end