/Source/externals/GData/Source/Elements/GDataWho.m

http://google-email-uploader-mac.googlecode.com/ · Objective C · 152 lines · 93 code · 35 blank · 24 comment · 1 complexity · 1fcf3027573e8f085fcc3edea802da7b MD5 · raw file

  1. /* Copyright (c) 2007-2008 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. // GDataWho.m
  17. //
  18. #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CALENDAR_SERVICE
  19. #define GDATAWHO_DEFINE_GLOBALS 1
  20. #import "GDataWho.h"
  21. #import "GDataEntryLink.h"
  22. @implementation GDataAttendeeStatus
  23. + (NSString *)extensionElementURI { return kGDataNamespaceGData; }
  24. + (NSString *)extensionElementPrefix { return kGDataNamespaceGDataPrefix; }
  25. + (NSString *)extensionElementLocalName { return @"attendeeStatus"; }
  26. @end
  27. @implementation GDataAttendeeType
  28. + (NSString *)extensionElementURI { return kGDataNamespaceGData; }
  29. + (NSString *)extensionElementPrefix { return kGDataNamespaceGDataPrefix; }
  30. + (NSString *)extensionElementLocalName { return @"attendeeType"; }
  31. @end
  32. static NSString* const kRelAttr = @"rel";
  33. static NSString* const kValueStringAttr = @"valueString";
  34. static NSString* const kEmailAttr = @"email";
  35. @implementation GDataWho
  36. // a who entry, as in
  37. // <gd:who rel="http://schemas.google.com/g/2005#event.organizer" valueString="Fred Flintstone" email="fred@domain.com">
  38. // <gd:attendeeStatus value="http://schemas.google.com/g/2005#event.accepted"/>
  39. // </gd:who>
  40. //
  41. // http://code.google.com/apis/gdata/common-elements.html#gdWho
  42. + (NSString *)extensionElementURI { return kGDataNamespaceGData; }
  43. + (NSString *)extensionElementPrefix { return kGDataNamespaceGDataPrefix; }
  44. + (NSString *)extensionElementLocalName { return @"who"; }
  45. + (GDataWho *)whoWithRel:(NSString *)rel
  46. name:(NSString *)valueString
  47. email:(NSString *)email {
  48. GDataWho *obj = [self object];
  49. [obj setRel:rel];
  50. [obj setStringValue:valueString];
  51. [obj setEmail:email];
  52. return obj;
  53. }
  54. - (void)addExtensionDeclarations {
  55. [super addExtensionDeclarations];
  56. Class elementClass = [self class];
  57. [self addExtensionDeclarationForParentClass:elementClass
  58. childClass:[GDataAttendeeType class]];
  59. [self addExtensionDeclarationForParentClass:elementClass
  60. childClass:[GDataAttendeeStatus class]];
  61. [self addExtensionDeclarationForParentClass:elementClass
  62. childClass:[GDataEntryLink class]];
  63. }
  64. - (void)addParseDeclarations {
  65. NSArray *attrs = [NSArray arrayWithObjects:
  66. kRelAttr, kValueStringAttr, kEmailAttr, nil];
  67. [self addLocalAttributeDeclarations:attrs];
  68. }
  69. #if !GDATA_SIMPLE_DESCRIPTIONS
  70. - (NSMutableArray *)itemsForDescription {
  71. NSMutableArray *items = [super itemsForDescription];
  72. // add extensions to the description
  73. [self addToArray:items objectDescriptionIfNonNil:[self attendeeType] withName:@"attendeeType"];
  74. [self addToArray:items objectDescriptionIfNonNil:[self attendeeStatus] withName:@"attendeeStatus"];
  75. [self addToArray:items objectDescriptionIfNonNil:[self entryLink] withName:@"entryLink"];
  76. return items;
  77. }
  78. #endif
  79. #pragma mark -
  80. - (NSString *)rel {
  81. return [self stringValueForAttribute:kRelAttr];
  82. }
  83. - (void)setRel:(NSString *)str {
  84. [self setStringValue:str forAttribute:kRelAttr];
  85. }
  86. - (NSString *)email {
  87. return [self stringValueForAttribute:kEmailAttr];
  88. }
  89. - (void)setEmail:(NSString *)str {
  90. [self setStringValue:str forAttribute:kEmailAttr];
  91. }
  92. - (NSString *)stringValue {
  93. return [self stringValueForAttribute:kValueStringAttr];
  94. }
  95. - (void)setStringValue:(NSString *)str {
  96. [self setStringValue:str forAttribute:kValueStringAttr];
  97. }
  98. - (GDataAttendeeType *)attendeeType {
  99. return [self objectForExtensionClass:[GDataAttendeeType class]];
  100. }
  101. - (void)setAttendeeType:(GDataAttendeeType *)val {
  102. [self setObject:val forExtensionClass:[GDataAttendeeType class]];
  103. }
  104. - (GDataAttendeeStatus *)attendeeStatus {
  105. return [self objectForExtensionClass:[GDataAttendeeStatus class]];
  106. }
  107. - (void)setAttendeeStatus:(GDataAttendeeStatus *)val {
  108. [self setObject:val forExtensionClass:[GDataAttendeeStatus class]];
  109. }
  110. - (GDataEntryLink *)entryLink {
  111. return [self objectForExtensionClass:[GDataEntryLink class]];
  112. }
  113. - (void)setEntryLink:(GDataEntryLink *)entryLink {
  114. [self setObject:entryLink forExtensionClass:[GDataEntryLink class]];
  115. }
  116. @end
  117. #endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CALENDAR_SERVICE