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