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

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