From 3ce6578b25ccbcbbabe133edadf2398040f35165 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 2 Aug 2011 20:43:33 +0000 Subject: [PATCH] Monotone-Parent: 19b842fa105a28640ea4883c6641a51413844f17 Monotone-Revision: 5b9fba133560acdca3843326561c729dd28fc4cc Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-08-02T20:43:33 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 + OpenChange/GNUmakefile | 1 + OpenChange/MAPIStorePermissionsTable.h | 31 ++++++ OpenChange/MAPIStorePermissionsTable.m | 129 +++++++++++++++++++++++++ 4 files changed, 165 insertions(+) create mode 100644 OpenChange/MAPIStorePermissionsTable.h create mode 100644 OpenChange/MAPIStorePermissionsTable.m diff --git a/ChangeLog b/ChangeLog index 6961311ec..400093289 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011-08-02 Wolfgang Sourdeau + * OpenChange/MAPIStorePermissionsTable.[hm]: new class module for + handling permission objects. Currently only provide stub entries + for the "anonymous" and "default" users. + * OpenChange/MAPIStoreContactsMessageTable.m (-evaluateContentRestriction:intoQualifier:): overriden method in order to evaluate PR_MESSAGE_CLASS_UNICODE. diff --git a/OpenChange/GNUmakefile b/OpenChange/GNUmakefile index f1a6d55d5..2a3b4c693 100644 --- a/OpenChange/GNUmakefile +++ b/OpenChange/GNUmakefile @@ -47,6 +47,7 @@ $(SOGOBACKEND)_OBJC_FILES += \ MAPIStoreTable.m \ MAPIStoreMessageTable.m \ MAPIStoreFolderTable.m \ + MAPIStorePermissionsTable.m \ \ MAPIStoreFSBaseContext.m \ MAPIStoreFSFolder.m \ diff --git a/OpenChange/MAPIStorePermissionsTable.h b/OpenChange/MAPIStorePermissionsTable.h new file mode 100644 index 000000000..20a98e37d --- /dev/null +++ b/OpenChange/MAPIStorePermissionsTable.h @@ -0,0 +1,31 @@ +/* MAPIStorePermissionsTable.h - this file is part of SOGo + * + * Copyright (C) 2011 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 MAPISTOREPERMISSIONSTABLE_H +#define MAPISTOREPERMISSIONSTABLE_H + +#import "MAPIStoreTable.h" + +@interface MAPIStorePermissionsTable : MAPIStoreTable +@end + +#endif /* MAPISTOREPERMISSIONSTABLE_H */ diff --git a/OpenChange/MAPIStorePermissionsTable.m b/OpenChange/MAPIStorePermissionsTable.m new file mode 100644 index 000000000..48bab8ecb --- /dev/null +++ b/OpenChange/MAPIStorePermissionsTable.m @@ -0,0 +1,129 @@ +/* MAPIStorePermissionsTable.m - this file is part of SOGo + * + * Copyright (C) 2011 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 "MAPIStoreObject.h" +#import "MAPIStoreTypes.h" +#import "NSData+MAPIStore.h" +#import "NSString+MAPIStore.h" + +#import "MAPIStorePermissionsTable.h" + +#include + +@interface MAPIStorePermissionEntry : MAPIStoreObject +{ + NSString *userId; +} + ++ (id) entryWithUserId: (NSString *) newUserId; +- (id) initWithUserId: (NSString *) newUserId; + +@end + +@implementation MAPIStorePermissionEntry + ++ (id) entryWithUserId: (NSString *) newUserId +{ + MAPIStorePermissionEntry *newEntry; + + newEntry = [[self alloc] initWithUserId: newUserId]; + [newEntry autorelease]; + + return newEntry; +} + +- (id) initWithUserId: (NSString *) newUserId +{ + if ((self = [self init])) + { + ASSIGN (userId, newUserId); + } + + return self; +} + +- (void) dealloc +{ + [userId release]; + [super dealloc]; +} + +- (int) getPrMemberId: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + uint64_t value = 0; + + if ([userId isEqualToString: @"anonymous"]) + value = 0xffffffffffffffff; + + *data = MAPILongLongValue (memCtx, value); + + return MAPISTORE_SUCCESS; +} + +- (int) getPrEntryid: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + *data = [[NSData data] asBinaryInMemCtx: memCtx]; + + return MAPISTORE_SUCCESS; +} + +- (int) getPrMemberName: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + *data = [userId asUnicodeInMemCtx: memCtx]; + + return MAPISTORE_SUCCESS; +} + +- (int) getPrMemberRights: (void **) data + inMemCtx: (TALLOC_CTX *) memCtx +{ + *data = MAPILongValue (memCtx, 0); + + return MAPISTORE_SUCCESS; +} + +@end + +@implementation MAPIStorePermissionsTable + +- (NSArray *) childKeys +{ + return [NSArray arrayWithObjects: @"default", @"anonymous", nil]; +} + +- (NSArray *) restrictedChildKeys +{ + return [self childKeys]; +} + +- (id) lookupChild: (NSString *) childKey +{ + return [MAPIStorePermissionEntry entryWithUserId: childKey]; +} + +@end