From f8ae1411d889bd47030d9e43f98c151b6712ab73 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 13 Dec 2010 17:15:54 +0000 Subject: [PATCH] Monotone-Parent: 788b2669df38ffd6d807dc86f384532b580f2876 Monotone-Revision: 8a88ed0919545d898ca1af80de43b6ab28ebe09d Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-12-13T17:15:54 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 3 + OpenChange/EOQualifier+MAPIFS.h | 36 ++++++++++ OpenChange/EOQualifier+MAPIFS.m | 112 ++++++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 OpenChange/EOQualifier+MAPIFS.h create mode 100644 OpenChange/EOQualifier+MAPIFS.m diff --git a/ChangeLog b/ChangeLog index dca61768f..e69854a10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2010-12-13 Wolfgang Sourdeau + * OpenChange/EOQualifier+MAPIFS.[hm]: new category module for + evaluating qualifiers with regards to SOGoMAPIFSMessage objects. + * OpenChange/MAPIStoreGCSBaseContext.[hm]: new class module containing all the code common to SOGoGCSFolder-based context classes, in particular with regards to restriction handling. diff --git a/OpenChange/EOQualifier+MAPIFS.h b/OpenChange/EOQualifier+MAPIFS.h new file mode 100644 index 000000000..54b4a79fd --- /dev/null +++ b/OpenChange/EOQualifier+MAPIFS.h @@ -0,0 +1,36 @@ +/* EOQualifier+MAPIFS.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 EOQUALIFIER_MAPIFS_H +#define EOQUALIFIER_MAPIFS_H + +#import + +@class SOGoMAPIFSMessage; + +@interface EOQualifier (MAPIStoreRestrictions) + +- (BOOL) evaluateMAPIFSMessage: (SOGoMAPIFSMessage *) message; + +@end + +#endif /* EOQUALIFIER_MAPIFS_H */ diff --git a/OpenChange/EOQualifier+MAPIFS.m b/OpenChange/EOQualifier+MAPIFS.m new file mode 100644 index 000000000..e4d48802e --- /dev/null +++ b/OpenChange/EOQualifier+MAPIFS.m @@ -0,0 +1,112 @@ +/* EOQualifier+MAPIFS.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 "SOGoMAPIFSMessage.h" + +#import "EOQualifier+MAPIFS.h" + +@implementation EOQualifier (MAPIStoreRestrictions) + +- (BOOL) _evaluateMAPIFSMessageProperties: (NSDictionary *) properties +{ + [self subclassResponsibility: _cmd]; + return NO; +} + +- (BOOL) evaluateMAPIFSMessage: (SOGoMAPIFSMessage *) message +{ + NSDictionary *properties; + + [self logWithFormat: @"evaluating message '%@'", message]; + + properties = [message properties]; + + return [self _evaluateMAPIFSMessageProperties: properties]; +} + +@end + +@implementation EOAndQualifier (MAPIStoreRestrictionsPrivate) + +- (BOOL) _evaluateMAPIFSMessageProperties: (NSDictionary *) properties +{ + NSUInteger i; + BOOL rc; + + rc = YES; + + for (i = 0; rc && i < count; i++) + rc = [[qualifiers objectAtIndex: i] + _evaluateMAPIFSMessageProperties: properties]; + + return rc; +} + +@end + +@implementation EOOrQualifier (MAPIStoreRestrictionsPrivate) + +- (BOOL) _evaluateMAPIFSMessageProperties: (NSDictionary *) properties +{ + NSUInteger i; + BOOL rc; + + rc = NO; + + for (i = 0; !rc && i < count; i++) + rc = [[qualifiers objectAtIndex: i] + _evaluateMAPIFSMessageProperties: properties]; + + return rc; +} + +@end + +@implementation EONotQualifier (MAPIStoreRestrictionsPrivate) + +- (BOOL) _evaluateMAPIFSMessageProperties: (NSDictionary *) properties +{ + return ![qualifier _evaluateMAPIFSMessageProperties: properties]; +} + +@end + +@implementation EOKeyValueQualifier (MAPIStoreRestrictionsPrivate) + +- (BOOL) _evaluateMAPIFSMessageProperties: (NSDictionary *) properties +{ + NSNumber *propTag; + id propValue; + + propTag = [NSNumber numberWithInt: [key intValue]]; + propValue = [properties objectForKey: propTag]; + + return [propValue performSelector: operator withObject: value] != nil; +} + +@end