PageRenderTime 30ms CodeModel.GetById 10ms app.highlight 18ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/ACL/GDataEntryACL.m

http://macfuse.googlecode.com/
Objective C | 147 lines | 93 code | 36 blank | 18 comment | 3 complexity | 2b2c68e0814e1aa615c255016799a29a MD5 | raw file
  1/* Copyright (c) 2007 Google Inc.
  2*
  3* Licensed under the Apache License, Version 2.0 (the "License");
  4* you may not use this file except in compliance with the License.
  5* You may obtain a copy of the License at
  6*
  7*     http://www.apache.org/licenses/LICENSE-2.0
  8*
  9* Unless required by applicable law or agreed to in writing, software
 10* distributed under the License is distributed on an "AS IS" BASIS,
 11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12* See the License for the specific language governing permissions and
 13* limitations under the License.
 14*/
 15
 16//
 17//  GDataEntryACL.m
 18//
 19
 20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_ACLS \
 21  || GDATA_INCLUDE_CALENDAR_SERVICE || GDATA_INCLUDE_DOCS_SERVICE
 22
 23#define GDATAENTRYACL_DEFINE_GLOBALS 1
 24#import "GDataEntryACL.h"
 25
 26#import "GDataACLRole.h"
 27#import "GDataACLScope.h"
 28#import "GDataACLKeyedRole.h"
 29
 30@implementation GDataEntryACL
 31
 32+ (NSDictionary *)ACLNamespaces {
 33  NSMutableDictionary *namespaces;
 34  namespaces = [NSMutableDictionary dictionaryWithObject:kGDataNamespaceACL
 35                                                  forKey:kGDataNamespaceACLPrefix];
 36
 37  [namespaces addEntriesFromDictionary:[GDataEntryBase baseGDataNamespaces]];
 38
 39  return namespaces;
 40}
 41
 42+ (id)ACLEntryWithScope:(GDataACLScope *)scope
 43                   role:(GDataACLRole *)role {
 44
 45  GDataEntryACL *obj = [self object];
 46  [obj setNamespaces:[self ACLNamespaces]];
 47  [obj setScope:scope];
 48  [obj setRole:role];
 49  return obj;
 50}
 51
 52+ (NSString *)standardEntryKind {
 53  return kGDataCategoryACL;
 54}
 55
 56+ (void)load {
 57  [self registerEntryClass];
 58}
 59
 60- (void)addExtensionDeclarations {
 61
 62  [super addExtensionDeclarations];
 63
 64  Class entryClass = [self class];
 65
 66  // ACLEntry extensions
 67
 68  [self addExtensionDeclarationForParentClass:entryClass
 69                                 childClasses:
 70   [GDataACLRole class],
 71   [GDataACLScope class],
 72   [GDataACLKeyedRole class],
 73   [GDataACLAdditionalRole class],
 74   nil];
 75}
 76
 77#if !GDATA_SIMPLE_DESCRIPTIONS
 78- (NSMutableArray *)itemsForDescription {
 79
 80  static struct GDataDescriptionRecord descRecs[] = {
 81    { @"role",       @"role",            kGDataDescValueLabeled },
 82    { @"keyedRole",  @"keyedRole",       kGDataDescValueLabeled },
 83    { @"scope",      @"scope",           kGDataDescValueLabeled },
 84    { @"additional", @"additionalRoles", kGDataDescArrayDescs },
 85    { nil, nil, (GDataDescRecTypes)0 }
 86  };
 87
 88  NSMutableArray *items = [super itemsForDescription];
 89  [self addDescriptionRecords:descRecs toItems:items];
 90  return items;
 91}
 92#endif
 93
 94#pragma mark -
 95
 96- (void)setRole:(GDataACLRole *)obj {
 97  [self setObject:obj forExtensionClass:[GDataACLRole class]];
 98}
 99
100- (GDataACLRole *)role {
101  return [self objectForExtensionClass:[GDataACLRole class]];
102}
103
104- (void)setKeyedRole:(GDataACLKeyedRole *)obj {
105  [self setObject:obj forExtensionClass:[GDataACLKeyedRole class]];
106}
107
108- (GDataACLKeyedRole *)keyedRole {
109  return [self objectForExtensionClass:[GDataACLKeyedRole class]];
110}
111
112- (NSArray *)additionalRoles {
113  return [self objectsForExtensionClass:[GDataACLAdditionalRole class]];
114}
115
116- (void)setAdditionalRoles:(NSArray *)array {
117  [self setObjects:array forExtensionClass:[GDataACLAdditionalRole class]];
118}
119
120- (void)addAdditionalRole:(GDataACLAdditionalRole *)obj {
121  [self addObject:obj forExtensionClass:[GDataACLAdditionalRole class]];
122}
123
124- (void)setScope:(GDataACLScope *)obj {
125  [self setObject:obj forExtensionClass:[GDataACLScope class]];
126}
127
128- (GDataACLScope *)scope {
129  return [self objectForExtensionClass:[GDataACLScope class]];
130}
131
132#pragma mark -
133
134- (GDataLink *)controlledObjectLink {
135  return [self linkWithRelAttributeValue:kGDataLinkRelControlledObject];
136}
137
138@end
139
140@implementation GDataEntryBase (GDataACLLinks)
141- (GDataLink *)ACLLink {
142  return [self linkWithRelAttributeValue:kGDataLinkRelACL];
143}
144
145@end
146
147#endif // !GDATA_REQUIRE_SERVICE_INCLUDE || GDATA_INCLUDE_*