/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. // GDataEntryACL.m
  17. //
  18. #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_ACLS \
  19. || GDATA_INCLUDE_CALENDAR_SERVICE || GDATA_INCLUDE_DOCS_SERVICE
  20. #define GDATAENTRYACL_DEFINE_GLOBALS 1
  21. #import "GDataEntryACL.h"
  22. #import "GDataACLRole.h"
  23. #import "GDataACLScope.h"
  24. #import "GDataACLKeyedRole.h"
  25. @implementation GDataEntryACL
  26. + (NSDictionary *)ACLNamespaces {
  27. NSMutableDictionary *namespaces;
  28. namespaces = [NSMutableDictionary dictionaryWithObject:kGDataNamespaceACL
  29. forKey:kGDataNamespaceACLPrefix];
  30. [namespaces addEntriesFromDictionary:[GDataEntryBase baseGDataNamespaces]];
  31. return namespaces;
  32. }
  33. + (id)ACLEntryWithScope:(GDataACLScope *)scope
  34. role:(GDataACLRole *)role {
  35. GDataEntryACL *obj = [self object];
  36. [obj setNamespaces:[self ACLNamespaces]];
  37. [obj setScope:scope];
  38. [obj setRole:role];
  39. return obj;
  40. }
  41. + (NSString *)standardEntryKind {
  42. return kGDataCategoryACL;
  43. }
  44. + (void)load {
  45. [self registerEntryClass];
  46. }
  47. - (void)addExtensionDeclarations {
  48. [super addExtensionDeclarations];
  49. Class entryClass = [self class];
  50. // ACLEntry extensions
  51. [self addExtensionDeclarationForParentClass:entryClass
  52. childClasses:
  53. [GDataACLRole class],
  54. [GDataACLScope class],
  55. [GDataACLKeyedRole class],
  56. [GDataACLAdditionalRole class],
  57. nil];
  58. }
  59. #if !GDATA_SIMPLE_DESCRIPTIONS
  60. - (NSMutableArray *)itemsForDescription {
  61. static struct GDataDescriptionRecord descRecs[] = {
  62. { @"role", @"role", kGDataDescValueLabeled },
  63. { @"keyedRole", @"keyedRole", kGDataDescValueLabeled },
  64. { @"scope", @"scope", kGDataDescValueLabeled },
  65. { @"additional", @"additionalRoles", kGDataDescArrayDescs },
  66. { nil, nil, (GDataDescRecTypes)0 }
  67. };
  68. NSMutableArray *items = [super itemsForDescription];
  69. [self addDescriptionRecords:descRecs toItems:items];
  70. return items;
  71. }
  72. #endif
  73. #pragma mark -
  74. - (void)setRole:(GDataACLRole *)obj {
  75. [self setObject:obj forExtensionClass:[GDataACLRole class]];
  76. }
  77. - (GDataACLRole *)role {
  78. return [self objectForExtensionClass:[GDataACLRole class]];
  79. }
  80. - (void)setKeyedRole:(GDataACLKeyedRole *)obj {
  81. [self setObject:obj forExtensionClass:[GDataACLKeyedRole class]];
  82. }
  83. - (GDataACLKeyedRole *)keyedRole {
  84. return [self objectForExtensionClass:[GDataACLKeyedRole class]];
  85. }
  86. - (NSArray *)additionalRoles {
  87. return [self objectsForExtensionClass:[GDataACLAdditionalRole class]];
  88. }
  89. - (void)setAdditionalRoles:(NSArray *)array {
  90. [self setObjects:array forExtensionClass:[GDataACLAdditionalRole class]];
  91. }
  92. - (void)addAdditionalRole:(GDataACLAdditionalRole *)obj {
  93. [self addObject:obj forExtensionClass:[GDataACLAdditionalRole class]];
  94. }
  95. - (void)setScope:(GDataACLScope *)obj {
  96. [self setObject:obj forExtensionClass:[GDataACLScope class]];
  97. }
  98. - (GDataACLScope *)scope {
  99. return [self objectForExtensionClass:[GDataACLScope class]];
  100. }
  101. #pragma mark -
  102. - (GDataLink *)controlledObjectLink {
  103. return [self linkWithRelAttributeValue:kGDataLinkRelControlledObject];
  104. }
  105. @end
  106. @implementation GDataEntryBase (GDataACLLinks)
  107. - (GDataLink *)ACLLink {
  108. return [self linkWithRelAttributeValue:kGDataLinkRelACL];
  109. }
  110. @end
  111. #endif // !GDATA_REQUIRE_SERVICE_INCLUDE || GDATA_INCLUDE_*