From 7eba4a5a0125b665886b0dcbbd5b06168d764e1f Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 14 Dec 2010 20:54:07 +0000 Subject: [PATCH] Monotone-Parent: c35e5e0bbfa47c91a6b8c9b68bf31ca78ee421fc Monotone-Revision: 0866c0c584ab301776f7eea26a8ec8135a9c106c Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-12-14T20:54:07 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 10 ++++++ OpenChange/EOBitmaskQualifier.h | 45 ++++++++++++++++++++++++ OpenChange/EOBitmaskQualifier.m | 62 +++++++++++++++++++++++++++++++++ OpenChange/EOQualifier+MAPIFS.m | 25 +++++++++++++ 4 files changed, 142 insertions(+) create mode 100644 OpenChange/EOBitmaskQualifier.h create mode 100644 OpenChange/EOBitmaskQualifier.m diff --git a/ChangeLog b/ChangeLog index 3409738b4..cd347cf23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-12-14 Wolfgang Sourdeau + + * OpenChange/EOQualifier+MAPIFS.m (-[EOBitmaskQualifier + _evaluateMAPIFSMessageProperties:]): new method adapted to the new + class below. + + * OpenChange/EOBitmaskQualifier.[hm]: new class module + implementing a new EOQualifier subclass that's adapted to the MAPI + bitmask restrictions. + 2010-12-14 Ludovic Marcotte * Implemented the "bindAsCurrentUser" feature (when diff --git a/OpenChange/EOBitmaskQualifier.h b/OpenChange/EOBitmaskQualifier.h new file mode 100644 index 000000000..263e37fc1 --- /dev/null +++ b/OpenChange/EOBitmaskQualifier.h @@ -0,0 +1,45 @@ +/* EOBitmaskQualifier.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 EOBITMASKQUALIFIER_H +#define EOBITMASKQUALIFIER_H + +#import + +@interface EOBitmaskQualifier : EOQualifier +{ + NSString *key; + uint32_t mask; + BOOL isZero; +} + +- (id) initWithKey: (NSString *) newKey + mask: (uint32_t) newMask + isZero: (BOOL) newIsZero; + +- (NSString *) key; +- (uint32_t ) mask; +- (BOOL) isZero; + +@end + +#endif /* EOBITMASKQUALIFIER_H */ diff --git a/OpenChange/EOBitmaskQualifier.m b/OpenChange/EOBitmaskQualifier.m new file mode 100644 index 000000000..b0b58219c --- /dev/null +++ b/OpenChange/EOBitmaskQualifier.m @@ -0,0 +1,62 @@ +/* EOBitmaskQualifier.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 "EOBitmaskQualifier.h" + +@implementation EOBitmaskQualifier + +- (id) initWithKey: (NSString *) newKey + mask: (uint32_t) newMask + isZero: (BOOL) newIsZero +{ + if ((self = [self init])) + { + ASSIGN (key, newKey); + isZero = newIsZero; + mask = newMask; + } + + return self; +} + +- (void) dealloc +{ + [key release]; + [super dealloc]; +} + +- (NSString *) key +{ + return key; +} + +- (uint32_t ) mask +{ + return mask; +} + +- (BOOL) isZero +{ + return isZero; +} + +@end diff --git a/OpenChange/EOQualifier+MAPIFS.m b/OpenChange/EOQualifier+MAPIFS.m index e4d48802e..87b2052a5 100644 --- a/OpenChange/EOQualifier+MAPIFS.m +++ b/OpenChange/EOQualifier+MAPIFS.m @@ -29,6 +29,7 @@ #import "SOGoMAPIFSMessage.h" #import "EOQualifier+MAPIFS.h" +#import "EOBitmaskQualifier.h" @implementation EOQualifier (MAPIStoreRestrictions) @@ -110,3 +111,27 @@ } @end + +@implementation EOBitmaskQualifier (MAPIStoreRestrictionsPrivate) + +- (BOOL) _evaluateMAPIFSMessageProperties: (NSDictionary *) properties +{ + NSNumber *propTag; + id propValue; + uint32_t intValue; + BOOL rc; + + propTag = [NSNumber numberWithInt: [key intValue]]; + propValue = [properties objectForKey: propTag]; + intValue = [propValue unsignedIntValue]; + + rc = ((isZero && (intValue & mask) == 0) + || (!isZero && (intValue & mask) != 0)); + + [self logWithFormat: @"evaluating bitmask qualifier: (%.8x & %.8x) %s 0: %d", + intValue, mask, (isZero ? "==" : "!="), rc]; + + return rc; +} + +@end