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

http://macfuse.googlecode.com/ · Objective C · 135 lines · 81 code · 36 blank · 18 comment · 2 complexity · 86de89960aee7dcb55c3e8daf4f6e4f6 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. // GDataEntryYouTubeSubscription.m
  17. //
  18. #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_YOUTUBE_SERVICE
  19. #import "GDataEntryYouTubeSubscription.h"
  20. #import "GDataYouTubeConstants.h"
  21. #import "GDataYouTubeElements.h"
  22. @implementation GDataEntryYouTubeSubscription
  23. + (GDataEntryYouTubeSubscription *)subscriptionEntry {
  24. GDataEntryYouTubeSubscription *entry = [self object];
  25. [entry setNamespaces:[GDataYouTubeConstants youTubeNamespaces]];
  26. return entry;
  27. }
  28. #pragma mark -
  29. + (NSString *)standardEntryKind {
  30. return kGDataCategoryYouTubeSubscription;
  31. }
  32. + (void)load {
  33. [self registerEntryClass];
  34. }
  35. - (void)addExtensionDeclarations {
  36. [super addExtensionDeclarations];
  37. Class entryClass = [self class];
  38. // YouTube element extensions
  39. [self addExtensionDeclarationForParentClass:entryClass
  40. childClasses:
  41. [GDataYouTubeUsername class],
  42. [GDataYouTubeQueryString class],
  43. [GDataYouTubePlaylistTitle class],
  44. nil];
  45. }
  46. #if !GDATA_SIMPLE_DESCRIPTIONS
  47. - (NSMutableArray *)itemsForDescription {
  48. static struct GDataDescriptionRecord descRecs[] = {
  49. { @"username", @"username", kGDataDescValueLabeled },
  50. { @"query", @"youTubeQueryString", kGDataDescValueLabeled },
  51. { @"playlistID", @"playlistID", kGDataDescValueLabeled },
  52. { @"playlistTitle", @"playlistTitle", kGDataDescValueLabeled },
  53. { nil, nil, (GDataDescRecTypes)0 }
  54. };
  55. NSMutableArray *items = [super itemsForDescription];
  56. [self addDescriptionRecords:descRecs toItems:items];
  57. return items;
  58. }
  59. #endif
  60. #pragma mark -
  61. - (NSString *)subscriptionType {
  62. NSArray *subs;
  63. subs = [self categoriesWithScheme:kGDataSchemeYouTubeSubscription];
  64. if ([subs count] > 0) {
  65. GDataCategory *subscription = [subs objectAtIndex:0];
  66. NSString *term = [subscription term];
  67. return term;
  68. }
  69. return nil;
  70. }
  71. #pragma mark -
  72. - (NSString *)username {
  73. GDataYouTubeUsername *obj = [self objectForExtensionClass:[GDataYouTubeUsername class]];
  74. return [obj stringValue];
  75. }
  76. - (void)setUsername:(NSString *)str {
  77. GDataYouTubeUsername *obj = [GDataYouTubeUsername valueWithString:str];
  78. [self setObject:obj forExtensionClass:[GDataYouTubeUsername class]];
  79. }
  80. - (NSString *)youTubeQueryString {
  81. GDataYouTubeQueryString *obj = [self objectForExtensionClass:[GDataYouTubeQueryString class]];
  82. return [obj stringValue];
  83. }
  84. - (void)setYouTubeQueryString:(NSString *)str {
  85. GDataYouTubeQueryString *obj = [GDataYouTubeQueryString valueWithString:str];
  86. [self setObject:obj forExtensionClass:[GDataYouTubeQueryString class]];
  87. }
  88. - (NSString *)playlistTitle {
  89. GDataYouTubePlaylistTitle *obj;
  90. obj = [self objectForExtensionClass:[GDataYouTubePlaylistTitle class]];
  91. return [obj stringValue];
  92. }
  93. - (void)setPlaylistTitle:(NSString *)str {
  94. GDataYouTubePlaylistTitle *obj;
  95. obj = [GDataYouTubePlaylistTitle valueWithString:str];
  96. [self setObject:obj forExtensionClass:[GDataYouTubePlaylistTitle class]];
  97. }
  98. @end
  99. #endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_YOUTUBE_SERVICE