/core/externals/update-engine/externals/gdata-objectivec-client/Source/Clients/Photos/GDataFeedPhotoAlbum.m

http://macfuse.googlecode.com/ · Objective C · 215 lines · 145 code · 47 blank · 23 comment · 1 complexity · 4bd6799b3c2e8166ba4e82de216e47e4 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. // GDataFeedPhotoBase.m
  17. //
  18. #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_PHOTOS_SERVICE
  19. #import "GDataFeedPhotoAlbum.h"
  20. #import "GDataPhotoConstants.h"
  21. @implementation GDataFeedPhotoAlbum
  22. + (GDataFeedPhotoAlbum *)albumFeed {
  23. GDataFeedPhotoAlbum *entry = [self object];
  24. [entry setNamespaces:[GDataPhotoConstants photoNamespaces]];
  25. return entry;
  26. }
  27. + (NSString *)standardFeedKind {
  28. return kGDataCategoryPhotosAlbum;
  29. }
  30. + (void)load {
  31. [self registerFeedClass];
  32. }
  33. - (void)addExtensionDeclarations {
  34. [super addExtensionDeclarations];
  35. Class feedClass = [self class];
  36. // common photo extensions
  37. [self addExtensionDeclarationForParentClass:feedClass
  38. childClasses:
  39. [GDataPhotoAccess class], [GDataPhotoBytesUsed class],
  40. [GDataPhotoCommentCount class], [GDataPhotoCommentingEnabled class],
  41. [GDataPhotoTimestamp class], [GDataPhotoNumberUsed class],
  42. [GDataPhotoNumberLeft class], [GDataPhotoBytesUsed class],
  43. [GDataPhotoUser class], [GDataPhotoNickname class],
  44. [GDataPhotoLocation class], [GDataMediaGroup class],
  45. nil];
  46. [GDataGeo addGeoExtensionDeclarationsToObject:self
  47. forParentClass:feedClass];
  48. }
  49. #if !GDATA_SIMPLE_DESCRIPTIONS
  50. - (NSMutableArray *)itemsForDescription {
  51. static struct GDataDescriptionRecord descRecs[] = {
  52. { @"access", @"access", kGDataDescValueLabeled },
  53. { @"bytesUsed", @"bytesUsed", kGDataDescValueLabeled },
  54. { @"commentCount", @"commentCount", kGDataDescValueLabeled },
  55. { @"commentsEnabled", @"commentsEnabled", kGDataDescValueLabeled },
  56. { @"date", @"timestamp", kGDataDescValueLabeled },
  57. { @"location", @"location", kGDataDescValueLabeled },
  58. { @"nickname", @"nickname", kGDataDescValueLabeled },
  59. { @"photosLeft", @"photosLeft", kGDataDescValueLabeled },
  60. { @"photosUsed", @"photosUsed", kGDataDescValueLabeled },
  61. { @"username", @"username", kGDataDescValueLabeled },
  62. { @"mediaGroup", @"mediaGroup", kGDataDescValueLabeled },
  63. { @"geoLocation", @"geoLocation", kGDataDescValueLabeled },
  64. { nil, nil, (GDataDescRecTypes)0 }
  65. };
  66. NSMutableArray *items = [super itemsForDescription];
  67. [self addDescriptionRecords:descRecs toItems:items];
  68. return items;
  69. }
  70. #endif
  71. #pragma mark -
  72. - (NSString *)access {
  73. GDataPhotoAccess *obj = [self objectForExtensionClass:[GDataPhotoAccess class]];
  74. return [obj stringValue];
  75. }
  76. - (void)setAccess:(NSString *)str {
  77. GDataPhotoAccess *obj = [GDataPhotoAccess valueWithString:str];
  78. [self setObject:obj forExtensionClass:[GDataPhotoAccess class]];
  79. }
  80. - (NSNumber *)bytesUsed {
  81. // long long
  82. GDataPhotoBytesUsed *obj = [self objectForExtensionClass:[GDataPhotoBytesUsed class]];
  83. return [obj longLongNumberValue];
  84. }
  85. - (void)setBytesUsed:(NSNumber *)num {
  86. GDataPhotoBytesUsed *obj = [GDataPhotoBytesUsed valueWithNumber:num];
  87. [self setObject:obj forExtensionClass:[obj class]];
  88. }
  89. - (NSNumber *)commentCount {
  90. // int
  91. GDataPhotoCommentCount *obj = [self objectForExtensionClass:[GDataPhotoCommentCount class]];
  92. return [obj intNumberValue];
  93. }
  94. - (void)setCommentCount:(NSNumber *)num {
  95. GDataPhotoCommentCount *obj = [GDataPhotoCommentCount valueWithNumber:num];
  96. [self setObject:obj forExtensionClass:[obj class]];
  97. }
  98. - (NSNumber *)commentsEnabled {
  99. // BOOL
  100. GDataPhotoCommentingEnabled *obj = [self objectForExtensionClass:[GDataPhotoCommentingEnabled class]];
  101. return [obj boolNumberValue];
  102. }
  103. - (void)setCommentsEnabled:(NSNumber *)num {
  104. GDataPhotoCommentingEnabled *obj = [GDataPhotoCommentingEnabled valueWithBool:[num boolValue]];
  105. [self setObject:obj forExtensionClass:[obj class]];
  106. }
  107. - (GDataPhotoTimestamp *)timestamp {
  108. return [self objectForExtensionClass:[GDataPhotoTimestamp class]];
  109. }
  110. - (void)setTimestamp:(GDataPhotoTimestamp *)obj {
  111. [self setObject:obj forExtensionClass:[GDataPhotoTimestamp class]];
  112. }
  113. - (NSString *)location {
  114. GDataPhotoLocation *obj = [self objectForExtensionClass:[GDataPhotoLocation class]];
  115. return [obj stringValue];
  116. }
  117. - (void)setLocation:(NSString *)str {
  118. GDataPhotoLocation *obj = [GDataPhotoLocation valueWithString:str];
  119. [self setObject:obj forExtensionClass:[GDataPhotoLocation class]];
  120. }
  121. - (NSString *)nickname {
  122. GDataPhotoNickname *obj = [self objectForExtensionClass:[GDataPhotoNickname class]];
  123. return [obj stringValue];
  124. }
  125. - (void)setNickname:(NSString *)str {
  126. GDataPhotoNickname *obj = [GDataPhotoNickname valueWithString:str];
  127. [self setObject:obj forExtensionClass:[GDataPhotoNickname class]];
  128. }
  129. - (NSNumber *)photosLeft {
  130. // int
  131. GDataPhotoNumberLeft *obj = [self objectForExtensionClass:[GDataPhotoNumberLeft class]];
  132. return [obj intNumberValue];
  133. }
  134. - (void)setPhotosLeft:(NSNumber *)num {
  135. GDataPhotoNumberLeft *obj = [GDataPhotoNumberLeft valueWithNumber:num];
  136. [self setObject:obj forExtensionClass:[obj class]];
  137. }
  138. - (NSNumber *)photosUsed {
  139. // int
  140. GDataPhotoNumberUsed *obj = [self objectForExtensionClass:[GDataPhotoNumberUsed class]];
  141. return [obj intNumberValue];
  142. }
  143. - (void)setPhotosUsed:(NSNumber *)num {
  144. GDataPhotoNumberUsed *obj = [GDataPhotoNumberUsed valueWithNumber:num];
  145. [self setObject:obj forExtensionClass:[obj class]];
  146. }
  147. - (NSString *)username {
  148. GDataPhotoUser *obj = [self objectForExtensionClass:[GDataPhotoUser class]];
  149. return [obj stringValue];
  150. }
  151. - (void)setUsername:(NSString *)str {
  152. GDataPhotoUser *obj = [GDataPhotoUser valueWithString:str];
  153. [self setObject:obj forExtensionClass:[obj class]];
  154. }
  155. - (GDataGeo *)geoLocation {
  156. return [GDataGeo geoLocationForObject:self];
  157. }
  158. - (void)setGeoLocation:(GDataGeo *)geo {
  159. [GDataGeo setGeoLocation:geo forObject:self];
  160. }
  161. - (GDataMediaGroup *)mediaGroup {
  162. return (GDataMediaGroup *) [self objectForExtensionClass:[GDataMediaGroup class]];
  163. }
  164. - (void)setMediaGroup:(GDataMediaGroup *)obj {
  165. [self setObject:obj forExtensionClass:[GDataMediaGroup class]];
  166. }
  167. @end
  168. #endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_PHOTOS_SERVICE