From ad416ef1e027b0cfccfc28c17018825a406680d3 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 13 Dec 2010 17:06:22 +0000 Subject: [PATCH] Monotone-Parent: 33c27aebfdbf4c4a04a550aef20cd2049b1c4575 Monotone-Revision: fffc8593a1392a49172e584c88de206cd6d7081b Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-12-13T17:06:22 Monotone-Branch: ca.inverse.sogo --- OpenChange/MAPIStoreCalendarContext.h | 4 +- OpenChange/MAPIStoreCalendarContext.m | 51 +++++++++++++++++++++-- OpenChange/MAPIStoreContactsContext.h | 4 +- OpenChange/MAPIStoreContactsContext.m | 42 +++++++++++++++---- OpenChange/MAPIStoreGCSBaseContext.h | 31 ++++++++++++++ OpenChange/MAPIStoreGCSBaseContext.m | 60 +++++++++++++++++++++++++++ OpenChange/MAPIStoreTasksContext.h | 4 +- OpenChange/MAPIStoreTasksContext.m | 35 ++++++++++++++-- 8 files changed, 210 insertions(+), 21 deletions(-) create mode 100644 OpenChange/MAPIStoreGCSBaseContext.h create mode 100644 OpenChange/MAPIStoreGCSBaseContext.m diff --git a/OpenChange/MAPIStoreCalendarContext.h b/OpenChange/MAPIStoreCalendarContext.h index 6a5dc7b80..96df4d1c2 100644 --- a/OpenChange/MAPIStoreCalendarContext.h +++ b/OpenChange/MAPIStoreCalendarContext.h @@ -23,9 +23,9 @@ #ifndef MAPISTORECALENDARCONTEXT_H #define MAPISTORECALENDARCONTEXT_H -#import "MAPIStoreContext.h" +#import "MAPIStoreGCSBaseContext.h" -@interface MAPIStoreCalendarContext : MAPIStoreContext +@interface MAPIStoreCalendarContext : MAPIStoreGCSBaseContext @end diff --git a/OpenChange/MAPIStoreCalendarContext.m b/OpenChange/MAPIStoreCalendarContext.m index 2aa4ab9c4..cb03b3616 100644 --- a/OpenChange/MAPIStoreCalendarContext.m +++ b/OpenChange/MAPIStoreCalendarContext.m @@ -26,6 +26,8 @@ #import +#import + #import #import @@ -51,7 +53,7 @@ + (void) registerFixedMappings: (MAPIStoreMapping *) mapping { - [mapping registerURL: @"sogo://openchange:openchange@calendar/personal" + [mapping registerURL: @"sogo://openchange:openchange@calendar/personal/" withID: 0x190001]; } @@ -71,8 +73,29 @@ } - (NSArray *) getFolderMessageKeys: (SOGoFolder *) folder + matchingQualifier: (EOQualifier *) qualifier { - return [(SOGoGCSFolder *) folder componentKeysWithType: @"vevent"]; + EOQualifier *componentQualifier, *calendarQualifier; + + componentQualifier + = [[EOKeyValueQualifier alloc] initWithKey: @"c_component" + operatorSelector: EOQualifierOperatorEqual + value: @"vevent"]; + [componentQualifier autorelease]; + if (qualifier) + { + calendarQualifier = [[EOAndQualifier alloc] + initWithQualifiers: + componentQualifier, + qualifier, + nil]; + [calendarQualifier autorelease]; + } + else + calendarQualifier = componentQualifier; + + return [super getFolderMessageKeys: folder + matchingQualifier: calendarQualifier]; } - (enum MAPISTATUS) getMessageTableChildproperty: (void **) data @@ -203,6 +226,28 @@ // return rc; // } +- (MAPIRestrictionState) evaluatePropertyRestriction: (struct mapi_SPropertyRestriction *) res + intoQualifier: (EOQualifier **) qualifier +{ + MAPIRestrictionState rc; + id value; + + value = NSObjectFromMAPISPropValue (&res->lpProp); + switch (res->ulPropTag) + { + case PR_MESSAGE_CLASS_UNICODE: + if ([value isEqualToString: @"IPM.Appointment"]) + rc = MAPIRestrictionStateAlwaysTrue; + else + rc = MAPIRestrictionStateAlwaysFalse; + break; + default: + rc = [super evaluatePropertyRestriction: res intoQualifier: qualifier]; + } + + return rc; +} + - (NSString *) backendIdentifierForProperty: (enum MAPITAGS) property { static NSMutableDictionary *knownProperties = nil; @@ -212,7 +257,7 @@ knownProperties = [NSMutableDictionary new]; } - return [knownProperties objectForKey: MAPIPropertyNumber (property)]; + return [knownProperties objectForKey: MAPIPropertyKey (property)]; } @end diff --git a/OpenChange/MAPIStoreContactsContext.h b/OpenChange/MAPIStoreContactsContext.h index 447d23a96..9e1e45498 100644 --- a/OpenChange/MAPIStoreContactsContext.h +++ b/OpenChange/MAPIStoreContactsContext.h @@ -23,9 +23,9 @@ #ifndef MAPISTORECONTACTSCONTEXT_H #define MAPISTORECONTACTSCONTEXT_H -#import "MAPIStoreContext.h" +#import "MAPIStoreGCSBaseContext.h" -@interface MAPIStoreContactsContext : MAPIStoreContext +@interface MAPIStoreContactsContext : MAPIStoreGCSBaseContext @end diff --git a/OpenChange/MAPIStoreContactsContext.m b/OpenChange/MAPIStoreContactsContext.m index 5f1734a0f..3e6fa1522 100644 --- a/OpenChange/MAPIStoreContactsContext.m +++ b/OpenChange/MAPIStoreContactsContext.m @@ -25,6 +25,8 @@ #import #import +#import + #import #import @@ -52,7 +54,7 @@ + (void) registerFixedMappings: (MAPIStoreMapping *) mapping { - [mapping registerURL: @"sogo://openchange:openchange@contacts/personal" + [mapping registerURL: @"sogo://openchange:openchange@contacts/personal/" withID: 0x1a0001]; } @@ -71,9 +73,32 @@ [moduleFolder retain]; } + - (NSArray *) getFolderMessageKeys: (SOGoFolder *) folder + matchingQualifier: (EOQualifier *) qualifier { - return [(SOGoGCSFolder *) folder componentKeysWithType: @"vcard"]; + EOQualifier *componentQualifier, *contactsQualifier; + + /* TODO: we need to support vlist as well */ + componentQualifier + = [[EOKeyValueQualifier alloc] initWithKey: @"c_component" + operatorSelector: EOQualifierOperatorEqual + value: @"vcard"]; + [componentQualifier autorelease]; + if (qualifier) + { + contactsQualifier = [[EOAndQualifier alloc] + initWithQualifiers: + componentQualifier, + qualifier, + nil]; + [contactsQualifier autorelease]; + } + else + contactsQualifier = componentQualifier; + + return [super getFolderMessageKeys: folder + matchingQualifier: contactsQualifier]; } // - (enum MAPISTATUS) getCommonTableChildproperty: (void **) data @@ -328,16 +353,16 @@ { knownProperties = [NSMutableDictionary new]; [knownProperties setObject: @"c_mail" - forKey: MAPIPropertyNumber (0x81ae001f)]; + forKey: MAPIPropertyKey (0x81ae001f)]; [knownProperties setObject: @"c_mail" - forKey: MAPIPropertyNumber (0x81b3001f)]; + forKey: MAPIPropertyKey (0x81b3001f)]; [knownProperties setObject: @"c_mail" - forKey: MAPIPropertyNumber (PR_EMS_AB_GROUP_BY_ATTR_2_UNICODE)]; + forKey: MAPIPropertyKey (PR_EMS_AB_GROUP_BY_ATTR_2_UNICODE)]; [knownProperties setObject: @"c_cn" - forKey: MAPIPropertyNumber (PR_DISPLAY_NAME_UNICODE)]; + forKey: MAPIPropertyKey (PR_DISPLAY_NAME_UNICODE)]; } - return [knownProperties objectForKey: MAPIPropertyNumber (property)]; + return [knownProperties objectForKey: MAPIPropertyKey (property)]; } /* restrictions */ @@ -352,8 +377,7 @@ switch (res->ulPropTag) { case PR_MESSAGE_CLASS_UNICODE: - if ([value isKindOfClass: [NSString class]] - && [value isEqualToString: @"IPM.Contact"]) + if ([value isEqualToString: @"IPM.Contact"]) rc = MAPIRestrictionStateAlwaysTrue; else rc = MAPIRestrictionStateAlwaysFalse; diff --git a/OpenChange/MAPIStoreGCSBaseContext.h b/OpenChange/MAPIStoreGCSBaseContext.h new file mode 100644 index 000000000..cc5e2aefd --- /dev/null +++ b/OpenChange/MAPIStoreGCSBaseContext.h @@ -0,0 +1,31 @@ +/* MAPIStoreGCSBaseContext.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 3, 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 MAPISTOREGCSBASECONTEXT_H +#define MAPISTOREGCSBASECONTEXT_H + +#import "MAPIStoreContext.h" + +@interface MAPIStoreGCSBaseContext : MAPIStoreContext +@end + +#endif /* MAPISTOREGCSBASECONTEXT_H */ diff --git a/OpenChange/MAPIStoreGCSBaseContext.m b/OpenChange/MAPIStoreGCSBaseContext.m new file mode 100644 index 000000000..0f482c21d --- /dev/null +++ b/OpenChange/MAPIStoreGCSBaseContext.m @@ -0,0 +1,60 @@ +/* MAPIStoreGCSBaseContext.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 3, 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 + +#import + +#import +#import + +#import "MAPIStoreGCSBaseContext.h" + +@implementation MAPIStoreGCSBaseContext + ++ (NSString *) MAPIModuleName +{ + return nil; +} + +- (NSArray *) getFolderMessageKeys: (SOGoFolder *) folder + matchingQualifier: (EOQualifier *) qualifier +{ + NSArray *records; + static NSArray *fields = nil; + + if (!fields) + fields = [[NSArray alloc] + initWithObjects: @"c_name", @"c_version", nil]; + + records = [[(SOGoGCSFolder *) folder ocsFolder] + fetchFields: fields matchingQualifier: qualifier]; + + return [records objectsForKey: @"c_name" + notFoundMarker: nil]; +} + +@end diff --git a/OpenChange/MAPIStoreTasksContext.h b/OpenChange/MAPIStoreTasksContext.h index bd0017a3c..b26b580cc 100644 --- a/OpenChange/MAPIStoreTasksContext.h +++ b/OpenChange/MAPIStoreTasksContext.h @@ -23,9 +23,9 @@ #ifndef MAPISTORETASKSCONTEXT_H #define MAPISTORETASKSCONTEXT_H -#import "MAPIStoreContext.h" +#import "MAPIStoreGCSBaseContext.h" -@interface MAPIStoreTasksContext : MAPIStoreContext +@interface MAPIStoreTasksContext : MAPIStoreGCSBaseContext @end diff --git a/OpenChange/MAPIStoreTasksContext.m b/OpenChange/MAPIStoreTasksContext.m index c94432f06..73e6ecd6f 100644 --- a/OpenChange/MAPIStoreTasksContext.m +++ b/OpenChange/MAPIStoreTasksContext.m @@ -24,6 +24,8 @@ #import +#import + #import #import @@ -49,7 +51,7 @@ + (void) registerFixedMappings: (MAPIStoreMapping *) mapping { - [mapping registerURL: @"sogo://openchange:openchange@tasks/personal" + [mapping registerURL: @"sogo://openchange:openchange@tasks/personal/" withID: 0x1d0001]; } @@ -69,8 +71,29 @@ } - (NSArray *) getFolderMessageKeys: (SOGoFolder *) folder + matchingQualifier: (EOQualifier *) qualifier { - return [(SOGoGCSFolder *) folder componentKeysWithType: @"vtodo"]; + EOQualifier *componentQualifier, *tasksQualifier; + + componentQualifier + = [[EOKeyValueQualifier alloc] initWithKey: @"c_component" + operatorSelector: EOQualifierOperatorEqual + value: @"vtodo"]; + [componentQualifier autorelease]; + if (qualifier) + { + tasksQualifier = [[EOAndQualifier alloc] + initWithQualifiers: + componentQualifier, + qualifier, + nil]; + [tasksQualifier autorelease]; + } + else + tasksQualifier = componentQualifier; + + return [super getFolderMessageKeys: folder + matchingQualifier: tasksQualifier]; } - (enum MAPISTATUS) getMessageTableChildproperty: (void **) data @@ -187,7 +210,7 @@ knownProperties = [NSMutableDictionary new]; } - return [knownProperties objectForKey: MAPIPropertyNumber (property)]; + return [knownProperties objectForKey: MAPIPropertyKey (property)]; } /* restrictions */ @@ -208,6 +231,12 @@ else rc = MAPIRestrictionStateAlwaysFalse; break; + case PR_RULE_PROVIDER_UNICODE: // TODO: what's this? + rc = MAPIRestrictionStateAlwaysTrue; + break; + case 0x81200003: // seems to be PR_CE_CHECK_INTERVAL + rc = MAPIRestrictionStateAlwaysTrue; + break; default: rc = [super evaluatePropertyRestriction: res intoQualifier: qualifier];