PageRenderTime 74ms CodeModel.GetById 23ms app.highlight 48ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Clients/Calendar/GDataEntryCalendar.m

http://macfuse.googlecode.com/
Objective C | 258 lines | 182 code | 56 blank | 20 comment | 5 complexity | a0384e208cd597ffec942202e475b8e6 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//  GDataEntryCalendar.m
 18//
 19
 20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CALENDAR_SERVICE
 21
 22#define GDATAENTRYCALENDAR_DEFINE_GLOBALS 1
 23#import "GDataEntryCalendar.h"
 24
 25// extensions
 26
 27#import "GDataTextConstruct.h"
 28#import "GDataWhen.h"
 29#import "GDataWhere.h"
 30#import "GDataEntryCalendarEvent.h"
 31
 32// CalendarEntry extensions
 33@implementation GDataHiddenProperty 
 34+ (NSString *)extensionElementURI       { return kGDataNamespaceGCal; }
 35+ (NSString *)extensionElementPrefix    { return kGDataNamespaceGCalPrefix; }
 36+ (NSString *)extensionElementLocalName { return @"hidden"; }
 37@end
 38
 39@implementation GDataAccessLevelProperty 
 40+ (NSString *)extensionElementURI       { return kGDataNamespaceGCal; }
 41+ (NSString *)extensionElementPrefix    { return kGDataNamespaceGCalPrefix; }
 42+ (NSString *)extensionElementLocalName { return @"accesslevel"; }
 43@end
 44
 45@implementation GDataSelectedProperty 
 46+ (NSString *)extensionElementURI       { return kGDataNamespaceGCal; }
 47+ (NSString *)extensionElementPrefix    { return kGDataNamespaceGCalPrefix; }
 48+ (NSString *)extensionElementLocalName { return @"selected"; }
 49@end
 50
 51@implementation GDataOverrideNameProperty 
 52+ (NSString *)extensionElementURI       { return kGDataNamespaceGCal; }
 53+ (NSString *)extensionElementPrefix    { return kGDataNamespaceGCalPrefix; }
 54+ (NSString *)extensionElementLocalName { return @"overridename"; }
 55@end
 56
 57@implementation GDataTimesCleanedProperty
 58+ (NSString *)extensionElementURI       { return kGDataNamespaceGCal; }
 59+ (NSString *)extensionElementPrefix    { return kGDataNamespaceGCalPrefix; }
 60+ (NSString *)extensionElementLocalName { return @"timesCleaned"; }
 61@end
 62
 63@implementation GDataTimeZoneProperty
 64+ (NSString *)extensionElementURI       { return kGDataNamespaceGCal; }
 65+ (NSString *)extensionElementPrefix    { return kGDataNamespaceGCalPrefix; }
 66+ (NSString *)extensionElementLocalName { return @"timezone"; }
 67@end
 68
 69@implementation GDataColorProperty
 70+ (NSString *)extensionElementURI       { return kGDataNamespaceGCal; }
 71+ (NSString *)extensionElementPrefix    { return kGDataNamespaceGCalPrefix; }
 72+ (NSString *)extensionElementLocalName { return @"color"; }
 73@end
 74
 75@implementation GDataEntryCalendar
 76
 77+ (NSDictionary *)calendarNamespaces {
 78  NSMutableDictionary *namespaces = [NSMutableDictionary dictionaryWithDictionary:
 79    [GDataEntryBase baseGDataNamespaces]];
 80
 81  [namespaces setObject:kGDataNamespaceGCal forKey:kGDataNamespaceGCalPrefix];
 82  
 83  return namespaces;
 84}
 85
 86+ (GDataEntryCalendar *)calendarEntry {
 87  GDataEntryCalendar *entry = [self object];
 88
 89  [entry setNamespaces:[GDataEntryCalendar calendarNamespaces]];
 90  return entry;
 91}
 92
 93#pragma mark -
 94
 95+ (NSString *)standardKindAttributeValue {
 96  return @"calendar#calendar";
 97}
 98
 99+ (void)load {
100  [self registerEntryClass];
101}
102
103- (void)addExtensionDeclarations {
104  
105  [super addExtensionDeclarations];
106  
107  Class entryClass = [self class];
108  
109  
110  // Calendar extensions
111  [self addExtensionDeclarationForParentClass:entryClass
112                                   childClasses:
113   [GDataAccessLevelProperty class],
114   [GDataColorProperty class],
115   [GDataHiddenProperty class],
116   [GDataOverrideNameProperty class],
117   [GDataSelectedProperty class],
118   [GDataTimeZoneProperty class],
119   [GDataTimesCleanedProperty class],
120   [GDataWhen class],  // are whens really a property of calendars? Java has the extension but not the accessor
121   [GDataWhere class],
122   nil];
123}
124
125#if !GDATA_SIMPLE_DESCRIPTIONS
126- (NSMutableArray *)itemsForDescription {
127
128  static struct GDataDescriptionRecord descRecs[] = {
129    { @"timezone",     @"timeZoneName.stringValue",  kGDataDescValueLabeled },
130    { @"timesCleaned", @"timesCleaned.stringValue",  kGDataDescValueLabeled },
131    { @"override",     @"overrideName.stringValue",  kGDataDescValueLabeled },
132    { @"accessLevel",  @"accessLevel.stringValue",   kGDataDescValueLabeled },
133    { @"hidden",       @"isHidden",                  kGDataDescBooleanPresent },
134    { @"selected",     @"isSelected",                kGDataDescBooleanPresent },
135    { @"whens",        @"whens",                     kGDataDescArrayCount },
136    { @"hidden",       @"locations",                 kGDataDescArrayCount },
137    { nil, nil, (GDataDescRecTypes)0 }
138  };
139
140  NSMutableArray *items = [super itemsForDescription];
141  [self addDescriptionRecords:descRecs toItems:items];
142  return items;
143}
144#endif
145
146- (NSString *)description {
147  return [super description];
148}
149
150+ (NSString *)defaultServiceVersion {
151  return kGDataCalendarDefaultServiceVersion;
152}
153
154#pragma mark Actual iVars
155
156- (GDataColorProperty *)color {
157  return [self objectForExtensionClass:[GDataColorProperty class]];
158}
159
160- (void)setColor:(GDataColorProperty *)val {
161  [self setObject:val forExtensionClass:[GDataColorProperty class]];
162}
163
164- (BOOL)isHidden {
165  GDataBoolValueConstruct *obj = [self objectForExtensionClass:[GDataHiddenProperty class]];
166  return [obj boolValue];
167}
168
169- (void)setIsHidden:(BOOL)flag {
170  GDataBoolValueConstruct *obj;
171  if (flag) {
172    obj = [GDataHiddenProperty boolValueWithBool:YES];
173  } else {
174    obj = nil; // removes the extension
175  }
176  [self setObject:obj forExtensionClass:[GDataHiddenProperty class]];
177}
178
179- (BOOL)isSelected {
180  GDataBoolValueConstruct *obj = [self objectForExtensionClass:[GDataSelectedProperty class]];
181  return [obj boolValue];
182}
183
184- (void)setIsSelected:(BOOL)flag {
185  GDataBoolValueConstruct *obj;
186  if (flag) {
187    obj = [GDataSelectedProperty boolValueWithBool:YES];
188  } else {
189    obj = nil; // removes the extension
190  }
191  [self setObject:obj forExtensionClass:[GDataSelectedProperty class]];
192}
193
194- (GDataAccessLevelProperty *)accessLevel {
195  return [self objectForExtensionClass:[GDataAccessLevelProperty class]];
196}
197
198- (void)setAccessLevel:(GDataAccessLevelProperty *)val {
199  [self setObject:val forExtensionClass:[GDataAccessLevelProperty class]];
200}
201
202- (GDataTimeZoneProperty *)timeZoneName {
203  return [self objectForExtensionClass:[GDataTimeZoneProperty class]];
204}
205
206- (void)setTimeZoneName:(GDataTimeZoneProperty *)val {
207  [self setObject:val forExtensionClass:[GDataTimeZoneProperty class]];
208}
209
210- (NSNumber *)timesCleaned { // int
211  GDataTimesCleanedProperty *obj;
212
213  obj = [self objectForExtensionClass:[GDataTimesCleanedProperty class]];
214  return [obj intNumberValue];
215}
216
217- (void)setTimesCleaned:(NSNumber *)num {
218  GDataTimesCleanedProperty *obj;
219
220  obj = [GDataTimesCleanedProperty valueWithNumber:num];
221  [self setObject:obj forExtensionClass:[GDataTimesCleanedProperty class]];
222}
223
224- (GDataOverrideNameProperty *)overrideName {
225  return [self objectForExtensionClass:[GDataOverrideNameProperty class]];
226}
227
228- (void)setOverrideName:(GDataOverrideNameProperty *)val {
229  [self setObject:val forExtensionClass:[GDataOverrideNameProperty class]];
230}
231
232- (NSArray *)whens {
233  return [self objectsForExtensionClass:[GDataWhen class]];
234}
235
236- (void)setWhens:(NSArray *)array {
237  [self setObjects:array forExtensionClass:[GDataWhen class]];
238}
239
240- (void)addWhen:(GDataWhen *)obj {
241  [self addObject:obj forExtensionClass:[obj class]]; 
242}
243
244- (NSArray *)locations {
245  return [self objectsForExtensionClass:[GDataWhere class]];
246}
247
248- (void)setLocations:(NSArray *)array {
249  [self setObjects:array forExtensionClass:[GDataWhere class]];
250}
251
252- (void)addLocation:(GDataWhere *)obj {
253  [self addObject:obj forExtensionClass:[obj class]]; 
254}
255
256@end
257
258#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CALENDAR_SERVICE