PageRenderTime 68ms CodeModel.GetById 12ms app.highlight 53ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Clients/YouTube/GDataEntryYouTubeUserProfile.m

http://macfuse.googlecode.com/
Objective C | 362 lines | 263 code | 80 blank | 19 comment | 2 complexity | aa937a5f3d4d9132aedd8a60756dffcf MD5 | raw file
  1/* Copyright (c) 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//  GDataEntryYouTubeUserProfile.m
 18//
 19
 20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_YOUTUBE_SERVICE
 21
 22#import "GDataEntryYouTubeUserProfile.h"
 23#import "GDataYouTubeConstants.h"
 24#import "GDataYouTubeElements.h"
 25
 26@implementation GDataEntryYouTubeUserProfile
 27
 28+ (GDataEntryYouTubeUserProfile *)userProfileEntry {
 29  
 30  GDataEntryYouTubeUserProfile *entry = [self object];
 31
 32  [entry setNamespaces:[GDataYouTubeConstants youTubeNamespaces]];
 33  
 34  return entry;
 35}
 36
 37#pragma mark -
 38
 39+ (NSString *)standardEntryKind {
 40  return kGDataCategoryYouTubeUserProfile;
 41}
 42
 43+ (void)load {
 44  [self registerEntryClass];
 45}
 46
 47- (void)addExtensionDeclarations {
 48  
 49  [super addExtensionDeclarations];
 50  
 51  [self addExtensionDeclarationForParentClass:[self class]
 52                                   childClasses:
 53     [GDataFeedLink class],
 54     
 55     // YouTube element extensions
 56     [GDataYouTubeAge class], [GDataYouTubeBooks class], 
 57     [GDataYouTubeCompany class], [GDataYouTubeAboutMe class], 
 58     [GDataYouTubeGender class], [GDataYouTubeHobbies class], 
 59     [GDataYouTubeHometown class], [GDataYouTubeLocation class], 
 60     [GDataYouTubeMovies class], [GDataYouTubeMusic class], 
 61     [GDataYouTubeOccupation class], [GDataYouTubeRelationship class], 
 62     [GDataYouTubeSchool class], [GDataYouTubeUsername class],
 63     [GDataYouTubeFirstName class],  [GDataYouTubeLastName class], 
 64     [GDataYouTubeStatistics class], 
 65     
 66     // media extensions
 67     [GDataMediaThumbnail class], nil];
 68}
 69
 70#if !GDATA_SIMPLE_DESCRIPTIONS
 71- (NSMutableArray *)itemsForDescription {
 72  
 73  static struct GDataDescriptionRecord descRecs[] = {
 74    { @"statistics",   @"statistics",          kGDataDescValueLabeled },
 75    { @"age",          @"age",                 kGDataDescValueLabeled },
 76    { @"thumbnail",    @"thumbnail",           kGDataDescValueLabeled },
 77    { @"company",      @"company",             kGDataDescValueLabeled },
 78    { @"gender",       @"gender",              kGDataDescValueLabeled },
 79    { @"hobbies",      @"hobbies",             kGDataDescValueLabeled },
 80    { @"hometown",     @"hometown",            kGDataDescValueLabeled },
 81    { @"location",     @"location",            kGDataDescValueLabeled },
 82    { @"movies",       @"movies",              kGDataDescValueLabeled },
 83    { @"music",        @"music",               kGDataDescValueLabeled },
 84    { @"occupation",   @"occupation",          kGDataDescValueLabeled },
 85    { @"relationship", @"relationship",        kGDataDescValueLabeled },
 86    { @"school",       @"school",              kGDataDescValueLabeled },
 87    { @"username",     @"username",            kGDataDescValueLabeled },
 88    { @"firstName",    @"firstName",           kGDataDescValueLabeled },
 89    { @"lastName",     @"lastName",            kGDataDescValueLabeled },
 90    { @"summary",      @"summary.stringValue", kGDataDescValueLabeled },
 91    { @"feedLinks",    @"feedLinks",           kGDataDescArrayCount },
 92    { nil, nil, (GDataDescRecTypes)0 }
 93  };
 94  
 95  NSMutableArray *items = [super itemsForDescription];
 96  [self addDescriptionRecords:descRecs toItems:items];
 97  return items;
 98}
 99#endif
100
101+ (NSString *)defaultServiceVersion {
102  return kGDataYouTubeDefaultServiceVersion;
103}
104
105#pragma mark -
106
107- (NSString *)channelType {
108  
109  NSArray *channelCats;
110  
111  channelCats = [self categoriesWithScheme:kGDataSchemeYouTubeChannel];
112  
113  if ([channelCats count] > 0) {
114    GDataCategory *category = [channelCats objectAtIndex:0];
115    NSString *term = [category term];
116    return term;
117  }
118  return nil;
119}
120
121#pragma mark -
122
123- (GDataYouTubeStatistics *)statistics {
124  return [self objectForExtensionClass:[GDataYouTubeStatistics class]];
125}
126
127- (void)setStatistics:(GDataYouTubeStatistics *)obj {
128  [self setObject:obj forExtensionClass:[GDataYouTubeStatistics class]];
129}
130
131- (NSString *)aboutMe {
132  GDATA_DEBUG_ASSERT_MIN_SERVICE_V2();
133  
134  GDataYouTubeAboutMe *obj = [self objectForExtensionClass:[GDataYouTubeAboutMe class]];
135  return [obj stringValue];
136}
137
138- (void)setAboutMe:(NSString *)str {
139  GDATA_DEBUG_ASSERT_MIN_SERVICE_V2();
140
141  GDataYouTubeAboutMe *obj = [GDataYouTubeAboutMe valueWithString:str];
142  [self setObject:obj forExtensionClass:[GDataYouTubeAboutMe class]];
143}
144
145- (NSString *)books {
146  GDataYouTubeBooks *obj = [self objectForExtensionClass:[GDataYouTubeBooks class]];
147  return [obj stringValue];
148}
149
150- (void)setBooks:(NSString *)str {
151  GDataYouTubeBooks *obj = [GDataYouTubeBooks valueWithString:str];
152  [self setObject:obj forExtensionClass:[GDataYouTubeBooks class]];
153}
154
155- (NSNumber *)age {
156  GDataYouTubeAge *obj = [self objectForExtensionClass:[GDataYouTubeAge class]];
157  return [obj intNumberValue];
158}
159
160- (void)setAge:(NSNumber *)num {
161  GDataYouTubeAge *obj = [GDataYouTubeAge valueWithNumber:num];
162  [self setObject:obj forExtensionClass:[GDataYouTubeAge class]];
163}
164
165- (GDataMediaThumbnail *)thumbnail {
166  GDataMediaThumbnail *obj = [self objectForExtensionClass:[GDataMediaThumbnail class]];
167  return obj;
168}
169
170- (void)setThumbnail:(GDataMediaThumbnail *)obj {
171  [self setObject:obj forExtensionClass:[GDataMediaThumbnail class]];
172}
173
174- (NSString *)company {
175  GDataYouTubeCompany *obj = [self objectForExtensionClass:[GDataYouTubeCompany class]];
176  return [obj stringValue];
177}
178
179- (void)setCompany:(NSString *)str {
180  GDataYouTubeCompany *obj = [GDataYouTubeCompany valueWithString:str];
181  [self setObject:obj forExtensionClass:[GDataYouTubeCompany class]];
182}
183
184- (NSString *)gender {
185  GDataYouTubeGender *obj = [self objectForExtensionClass:[GDataYouTubeGender class]];
186  return [obj stringValue];
187}
188
189- (void)setGender:(NSString *)str {
190  GDataYouTubeGender *obj = [GDataYouTubeGender valueWithString:str];
191  [self setObject:obj forExtensionClass:[GDataYouTubeGender class]];
192}
193
194- (NSString *)hobbies {
195  GDataYouTubeHobbies *obj = [self objectForExtensionClass:[GDataYouTubeHobbies class]];
196  return [obj stringValue];
197}
198
199- (void)setHobbies:(NSString *)str {
200  GDataYouTubeHobbies *obj = [GDataYouTubeHobbies valueWithString:str];
201  [self setObject:obj forExtensionClass:[GDataYouTubeHobbies class]];
202}
203
204- (NSString *)hometown {
205  GDataYouTubeHometown *obj = [self objectForExtensionClass:[GDataYouTubeHometown class]];
206  return [obj stringValue];
207}
208
209- (void)setHometown:(NSString *)str {
210  GDataYouTubeHometown *obj = [GDataYouTubeHometown valueWithString:str];
211  [self setObject:obj forExtensionClass:[GDataYouTubeHometown class]];
212}
213
214- (NSString *)location {
215  GDataYouTubeLocation *obj = [self objectForExtensionClass:[GDataYouTubeLocation class]];
216  return [obj stringValue];
217}
218
219- (void)setLocation:(NSString *)str {
220  GDataYouTubeLocation *obj = [GDataYouTubeLocation valueWithString:str];
221  [self setObject:obj forExtensionClass:[GDataYouTubeLocation class]];
222}
223
224- (NSString *)movies {
225  GDataYouTubeMovies *obj = [self objectForExtensionClass:[GDataYouTubeMovies class]];
226  return [obj stringValue];
227}
228
229- (void)setMovies:(NSString *)str {
230  GDataYouTubeMovies *obj = [GDataYouTubeMovies valueWithString:str];
231  [self setObject:obj forExtensionClass:[GDataYouTubeMovies class]];
232}
233
234- (NSString *)music {
235  GDataYouTubeMusic *obj = [self objectForExtensionClass:[GDataYouTubeMusic class]];
236  return [obj stringValue];
237}
238
239- (void)setMusic:(NSString *)str {
240  GDataYouTubeMusic *obj = [GDataYouTubeMusic valueWithString:str];
241  [self setObject:obj forExtensionClass:[GDataYouTubeMusic class]];
242}
243
244- (NSString *)occupation {
245  GDataYouTubeOccupation *obj = [self objectForExtensionClass:[GDataYouTubeOccupation class]];
246  return [obj stringValue];
247}
248
249- (void)setOccupation:(NSString *)str {
250  GDataYouTubeOccupation *obj = [GDataYouTubeOccupation valueWithString:str];
251  [self setObject:obj forExtensionClass:[GDataYouTubeOccupation class]];
252}
253
254- (NSString *)relationship {
255  GDataYouTubeRelationship *obj = [self objectForExtensionClass:[GDataYouTubeRelationship class]];
256  return [obj stringValue];
257}
258
259- (void)setRelationship:(NSString *)str {
260  GDataYouTubeRelationship *obj = [GDataYouTubeRelationship valueWithString:str];
261  [self setObject:obj forExtensionClass:[GDataYouTubeRelationship class]];
262}
263
264- (NSString *)school {
265  GDataYouTubeSchool *obj = [self objectForExtensionClass:[GDataYouTubeSchool class]];
266  return [obj stringValue];
267}
268
269- (void)setSchool:(NSString *)str {
270  GDataYouTubeSchool *obj = [GDataYouTubeSchool valueWithString:str];
271  [self setObject:obj forExtensionClass:[GDataYouTubeSchool class]];
272}
273
274- (NSString *)username {
275  GDataYouTubeUsername *obj = [self objectForExtensionClass:[GDataYouTubeUsername class]];
276  return [obj stringValue];
277}
278
279- (void)setUsername:(NSString *)str {
280  GDataYouTubeUsername *obj = [GDataYouTubeUsername valueWithString:str];
281  [self setObject:obj forExtensionClass:[GDataYouTubeUsername class]];
282}
283
284- (NSString *)firstName {
285  GDataYouTubeFirstName *obj = [self objectForExtensionClass:[GDataYouTubeFirstName class]];
286  return [obj stringValue];
287}
288
289- (void)setFirstName:(NSString *)str {
290  GDataYouTubeFirstName *obj = [GDataYouTubeFirstName valueWithString:str];
291  [self setObject:obj forExtensionClass:[GDataYouTubeFirstName class]];
292}
293
294- (NSString *)lastName {
295  GDataYouTubeLastName *obj = [self objectForExtensionClass:[GDataYouTubeLastName class]];
296  return [obj stringValue];
297}
298
299- (void)setLastName:(NSString *)str {
300  GDataYouTubeLastName *obj = [GDataYouTubeLastName valueWithString:str];
301  [self setObject:obj forExtensionClass:[GDataYouTubeLastName class]];
302}
303
304- (NSArray *)feedLinks {
305  return [self objectsForExtensionClass:[GDataFeedLink class]]; 
306}
307
308#pragma mark Convenience accessors
309
310- (GDataLink *)videoLogLink {
311  return [self linkWithRelAttributeValue:kGDataLinkYouTubeVlog];
312}
313
314- (GDataLink *)featuredVideoLink {
315  return [self linkWithRelAttributeValue:kGDataLinkYouTubeFeatured];
316}
317
318- (GDataFeedLink *)feedLinkForRel:(NSString *)rel {
319  return [GDataUtilities firstObjectFromArray:[self feedLinks]
320                                    withValue:rel
321                                   forKeyPath:@"rel"];
322}
323
324- (GDataFeedLink *)favoritesFeedLink {
325  return [self feedLinkForRel:kGDataLinkYouTubeFavorites];
326}
327
328- (GDataFeedLink *)contactsFeedLink {
329  return [self feedLinkForRel:kGDataLinkYouTubeContacts];
330}
331
332- (GDataFeedLink *)inboxFeedLink {
333  return [self feedLinkForRel:kGDataLinkYouTubeInbox];
334}
335
336- (GDataFeedLink *)playlistsFeedLink {
337  return [self feedLinkForRel:kGDataLinkYouTubePlaylists];
338}
339
340- (GDataFeedLink *)subscriptionsFeedLink {
341  return [self feedLinkForRel:kGDataLinkYouTubeSubscriptions];
342}
343
344- (GDataFeedLink *)uploadsFeedLink {
345  return [self feedLinkForRel:kGDataLinkYouTubeUploads];
346}
347
348- (GDataFeedLink *)recentSubscriptionVideosFeedLink {
349  return [self feedLinkForRel:kGDataLinkYouTubeNewSubscriptionVideos];
350}
351
352- (GDataFeedLink *)friendsActivityFeedLink {
353  return [self feedLinkForRel:kGDataLinkYouTubeFriendsActivity];
354}
355
356- (GDataFeedLink *)recentActivityFeedLink {
357  return [self feedLinkForRel:kGDataLinkYouTubeRecentActivity];
358}
359
360@end
361
362#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_YOUTUBE_SERVICE