From 626a0b8994f518df8046c154716248b1b87c6b81 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 30 Dec 2010 14:35:52 +0000 Subject: [PATCH] Monotone-Parent: 02350430ab168e12b644600df191c30306030fe3 Monotone-Revision: 0c8a4c1cec3f6885752564a67a291de836bfa2a5 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-12-30T14:35:52 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 3 + OpenChange/MAPIStoreGCSBaseContext.h | 3 + OpenChange/MAPIStoreGCSBaseContext.m | 26 ----- OpenChange/MAPIStoreGCSMessageTable.h | 36 +++++++ OpenChange/MAPIStoreGCSMessageTable.m | 136 ++++++++++++++++++++++++++ 5 files changed, 178 insertions(+), 26 deletions(-) create mode 100644 OpenChange/MAPIStoreGCSMessageTable.h create mode 100644 OpenChange/MAPIStoreGCSMessageTable.m diff --git a/ChangeLog b/ChangeLog index f39e71112..3975110fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2010-12-30 Wolfgang Sourdeau + * OpenChange/MAPIStoreGCSBaseContext.m: Old table methods (see + below) split into the new "MAPIStoreGCSMessageTable" class. + * OpenChange/MAPIStoreContactsContext.m: Old table methods (see below) split into the new "MAPIStoreContactsMessageTable" class. (+registerFixedMappings:): changed handled uri to diff --git a/OpenChange/MAPIStoreGCSBaseContext.h b/OpenChange/MAPIStoreGCSBaseContext.h index cc5e2aefd..974c8cf54 100644 --- a/OpenChange/MAPIStoreGCSBaseContext.h +++ b/OpenChange/MAPIStoreGCSBaseContext.h @@ -25,7 +25,10 @@ #import "MAPIStoreContext.h" +@class EOQualifier; + @interface MAPIStoreGCSBaseContext : MAPIStoreContext + @end #endif /* MAPISTOREGCSBASECONTEXT_H */ diff --git a/OpenChange/MAPIStoreGCSBaseContext.m b/OpenChange/MAPIStoreGCSBaseContext.m index 0f482c21d..d3dd27376 100644 --- a/OpenChange/MAPIStoreGCSBaseContext.m +++ b/OpenChange/MAPIStoreGCSBaseContext.m @@ -20,16 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#import #import -#import - -#import - -#import - -#import -#import #import "MAPIStoreGCSBaseContext.h" @@ -40,21 +31,4 @@ 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/MAPIStoreGCSMessageTable.h b/OpenChange/MAPIStoreGCSMessageTable.h new file mode 100644 index 000000000..15498aecb --- /dev/null +++ b/OpenChange/MAPIStoreGCSMessageTable.h @@ -0,0 +1,36 @@ +/* MAPIStoreGCSMessageTable.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 MAPISTOREGCSMESSAGETABLE_H +#define MAPISTOREGCSMESSAGETABLE_H + +#import "MAPIStoreMessageTable.h" + +@class EOQualifier; + +@interface MAPIStoreGCSMessageTable : MAPIStoreMessageTable + +- (EOQualifier *) componentQualifier; + +@end + +#endif /* MAPISTOREGCSMESSAGETABLE_H */ diff --git a/OpenChange/MAPIStoreGCSMessageTable.m b/OpenChange/MAPIStoreGCSMessageTable.m new file mode 100644 index 000000000..64e48e898 --- /dev/null +++ b/OpenChange/MAPIStoreGCSMessageTable.m @@ -0,0 +1,136 @@ +/* MAPIStoreGCSMessageTable.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 "MAPIStoreTypes.h" + +#import "MAPIStoreGCSMessageTable.h" + +#undef DEBUG +#include +#include +#include + +@implementation MAPIStoreGCSMessageTable + +- (NSArray *) _childKeysUsingRestrictions: (BOOL) useRestrictions +{ + static NSArray *fields = nil; + NSArray *records; + EOQualifier *componentQualifier, *fetchQualifier; + NSArray *keys; + + if (!fields) + fields = [[NSArray alloc] + initWithObjects: @"c_name", @"c_version", nil]; + + componentQualifier = [self componentQualifier]; + + if (useRestrictions + && restrictionState != MAPIRestrictionStateAlwaysTrue) + { + if (restrictionState == MAPIRestrictionStateNeedsEval) + { + fetchQualifier = [[EOAndQualifier alloc] + initWithQualifiers: + componentQualifier, + restriction, + nil]; + [fetchQualifier autorelease]; + } + else + fetchQualifier = nil; + } + else + fetchQualifier = componentQualifier; + + if (fetchQualifier) + { + records = [[folder ocsFolder] fetchFields: fields + matchingQualifier: fetchQualifier]; + keys = [records objectsForKey: @"c_name" + notFoundMarker: nil]; + } + else + keys = [NSArray array]; + + return keys; +} + +- (NSArray *) childKeys +{ + return [self _childKeysUsingRestrictions: NO]; +} + +- (NSArray *) restrictedChildKeys +{ + return [self _childKeysUsingRestrictions: YES]; +} + +- (MAPIRestrictionState) evaluateDatePropertyRestriction: (struct mapi_SPropertyRestriction *) res + intoQualifier: (EOQualifier **) qualifier +{ + struct mapi_SPropertyRestriction translatedRes; + NSCalendarDate *dateValue; + int32_t longDate; + + translatedRes.ulPropTag = (res->ulPropTag & 0xffff0000) | PT_LONG; + translatedRes.relop = res->relop; + dateValue = NSObjectFromMAPISPropValue (&res->lpProp); + longDate = (int32_t) [dateValue timeIntervalSince1970]; + translatedRes.lpProp.ulPropTag = translatedRes.ulPropTag; + translatedRes.lpProp.value.l = longDate; + + return [super evaluatePropertyRestriction: &translatedRes + intoQualifier: qualifier]; +} + +- (MAPIRestrictionState) evaluatePropertyRestriction: (struct mapi_SPropertyRestriction *) res + intoQualifier: (EOQualifier **) qualifier +{ + MAPIRestrictionState rc; + + if ((res->ulPropTag & 0x0040) == 0x0040) /* is date ? */ + rc = [self evaluateDatePropertyRestriction: (struct mapi_SPropertyRestriction *) res + intoQualifier: qualifier]; + else + rc = [super evaluatePropertyRestriction: res intoQualifier: qualifier]; + + return rc; +} + +- (EOQualifier *) componentQualifier +{ + [self subclassResponsibility: _cmd]; + + return nil; +} + +@end