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

http://macfuse.googlecode.com/ · Objective C · 231 lines · 155 code · 51 blank · 25 comment · 1 complexity · 6fcb4cce1b47c0efb077d48981558f32 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 "GDataFeedPhoto.h"
  20. #import "GDataPhotoConstants.h"
  21. @implementation GDataFeedPhoto
  22. + (GDataFeedPhoto *)photoFeed {
  23. GDataFeedPhoto *feed = [self object];
  24. [feed setNamespaces:[GDataPhotoConstants photoNamespaces]];
  25. return feed;
  26. }
  27. + (NSString *)standardFeedKind {
  28. return kGDataCategoryPhotosPhoto;
  29. }
  30. + (void)load {
  31. [self registerFeedClass];
  32. }
  33. - (void)addExtensionDeclarations {
  34. [super addExtensionDeclarations];
  35. Class feedClass = [self class];
  36. // Photo extensions
  37. [self addExtensionDeclarationForParentClass:feedClass
  38. childClasses:
  39. [GDataPhotoWidth class], [GDataPhotoHeight class],
  40. [GDataPhotoRotation class], [GDataPhotoSize class],
  41. [GDataPhotoAlbumID class], [GDataPhotoTimestamp class],
  42. [GDataPhotoCommentCount class], [GDataPhotoCommentingEnabled class],
  43. [GDataPhotoChecksum class],
  44. [GDataMediaGroup class], [GDataEXIFTags class],
  45. [GDataPhotoVideoStatus class],
  46. nil];
  47. [GDataGeo addGeoExtensionDeclarationsToObject:self
  48. forParentClass:feedClass];
  49. }
  50. #if !GDATA_SIMPLE_DESCRIPTIONS
  51. - (NSMutableArray *)itemsForDescription {
  52. static struct GDataDescriptionRecord descRecs[] = {
  53. { @"albumID", @"albumID", kGDataDescValueLabeled },
  54. { @"checksum", @"checksum", kGDataDescValueLabeled },
  55. { @"commentCount", @"commentCount", kGDataDescValueLabeled },
  56. { @"commentsEnabled", @"commentsEnabled", kGDataDescValueLabeled },
  57. { @"height", @"height", kGDataDescValueLabeled },
  58. { @"width", @"width", kGDataDescValueLabeled },
  59. { @"status", @"videoStatus", kGDataDescValueLabeled },
  60. { @"rotation", @"rotation", kGDataDescValueLabeled },
  61. { @"size", @"size", kGDataDescValueLabeled },
  62. { @"timestamp", @"timestamp", kGDataDescValueLabeled },
  63. { @"mediaGroup", @"mediaGroup", kGDataDescValueLabeled },
  64. { @"exifTags", @"EXIFTags", kGDataDescValueLabeled },
  65. { @"geoLocation", @"geoLocation", kGDataDescValueLabeled },
  66. { nil, nil, (GDataDescRecTypes)0 }
  67. };
  68. NSMutableArray *items = [super itemsForDescription];
  69. [self addDescriptionRecords:descRecs toItems:items];
  70. return items;
  71. }
  72. #endif
  73. #pragma mark -
  74. - (NSString *)albumID {
  75. GDataPhotoAlbumID *obj = [self objectForExtensionClass:[GDataPhotoAlbumID class]];
  76. return [obj stringValue];
  77. }
  78. - (void)setAlbumID:(NSString *)str {
  79. GDataObject *obj = [GDataPhotoAlbumID valueWithString:str];
  80. [self setObject:obj forExtensionClass:[obj class]];
  81. }
  82. - (NSString *)checksum {
  83. GDataPhotoChecksum *obj = [self objectForExtensionClass:[GDataPhotoChecksum class]];
  84. return [obj stringValue];
  85. }
  86. - (void)setChecksum:(NSString *)str {
  87. GDataObject *obj = [GDataPhotoChecksum valueWithString:str];
  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. GDataObject *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. GDataObject *obj = [GDataPhotoCommentingEnabled valueWithBool:[num boolValue]];
  106. [self setObject:obj forExtensionClass:[obj class]];
  107. }
  108. - (NSNumber *)height {
  109. // long long
  110. GDataPhotoHeight *obj = [self objectForExtensionClass:[GDataPhotoHeight class]];
  111. return [obj longLongNumberValue];
  112. }
  113. - (void)setHeight:(NSNumber *)num {
  114. GDataObject *obj = [GDataPhotoHeight valueWithNumber:num];
  115. [self setObject:obj forExtensionClass:[obj class]];
  116. }
  117. - (NSNumber *)rotation {
  118. // int
  119. GDataPhotoRotation *obj = [self objectForExtensionClass:[GDataPhotoRotation class]];
  120. return [obj intNumberValue];
  121. }
  122. - (void)setRotation:(NSNumber *)num {
  123. GDataObject *obj = [GDataPhotoRotation valueWithNumber:num];
  124. [self setObject:obj forExtensionClass:[obj class]];
  125. }
  126. - (NSNumber *)size {
  127. // long long
  128. GDataPhotoSize *obj = [self objectForExtensionClass:[GDataPhotoSize class]];
  129. return [obj longLongNumberValue];
  130. }
  131. - (void)setSize:(NSNumber *)num {
  132. GDataObject *obj = [GDataPhotoSize valueWithNumber:num];
  133. [self setObject:obj forExtensionClass:[obj class]];
  134. }
  135. - (GDataPhotoTimestamp *)timestamp {
  136. GDataPhotoTimestamp *obj = [self objectForExtensionClass:[GDataPhotoTimestamp class]];
  137. return obj ;
  138. }
  139. - (void)setTimestamp:(GDataPhotoTimestamp *)obj {
  140. [self setObject:obj forExtensionClass:[GDataPhotoTimestamp class]];
  141. }
  142. - (NSNumber *)width {
  143. // long long
  144. GDataPhotoWidth *obj = [self objectForExtensionClass:[GDataPhotoWidth class]];
  145. return [obj longLongNumberValue];
  146. }
  147. - (NSString *)videoStatus {
  148. GDataPhotoVideoStatus *obj = [self objectForExtensionClass:[GDataPhotoVideoStatus class]];
  149. return [obj stringValue];
  150. }
  151. - (void)setVideoStatus:(NSString *)str {
  152. GDataPhotoVideoStatus *obj = [GDataPhotoVideoStatus valueWithString:str];
  153. [self setObject:obj forExtensionClass:[obj class]];
  154. }
  155. - (void)setWidth:(NSNumber *)num {
  156. GDataObject *obj = [GDataPhotoWidth valueWithNumber:num];
  157. [self setObject:obj forExtensionClass:[obj class]];
  158. }
  159. - (GDataMediaGroup *)mediaGroup {
  160. return (GDataMediaGroup *) [self objectForExtensionClass:[GDataMediaGroup class]];
  161. }
  162. - (void)setMediaGroup:(GDataMediaGroup *)obj {
  163. [self setObject:obj forExtensionClass:[GDataMediaGroup class]];
  164. }
  165. #pragma mark -
  166. - (GDataGeo *)geoLocation {
  167. return [GDataGeo geoLocationForObject:self];
  168. }
  169. - (void)setGeoLocation:(GDataGeo *)geo {
  170. [GDataGeo setGeoLocation:geo forObject:self];
  171. }
  172. // EXIF tag support
  173. - (GDataEXIFTags *)EXIFTags {
  174. return (GDataEXIFTags *) [self objectForExtensionClass:[GDataEXIFTags class]];
  175. }
  176. - (void)setEXIFTags:(GDataEXIFTags *)tags {
  177. [self setObject:tags forExtensionClass:[GDataEXIFTags class]];
  178. }
  179. @end
  180. #endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_PHOTOS_SERVICE