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

http://macfuse.googlecode.com/ · Objective C · 352 lines · 243 code · 82 blank · 27 comment · 1 complexity · ed0f70a5a9bbf0365f9d393bdc9c246d 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. // GDataEntryPhoto.m
  17. //
  18. #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_PHOTOS_SERVICE
  19. #import "GDataEntryPhoto.h"
  20. #import "GDataPhotoElements.h"
  21. #import "GDataPhotoConstants.h"
  22. @implementation GDataEntryPhoto
  23. + (GDataEntryPhoto *)photoEntry {
  24. GDataEntryPhoto *entry = [self object];
  25. [entry setNamespaces:[GDataPhotoConstants photoNamespaces]];
  26. return entry;
  27. }
  28. #pragma mark -
  29. + (NSString *)standardEntryKind {
  30. return kGDataCategoryPhotosPhoto;
  31. }
  32. + (void)load {
  33. [self registerEntryClass];
  34. }
  35. - (void)addExtensionDeclarations {
  36. [super addExtensionDeclarations];
  37. Class entryClass = [self class];
  38. // Photo extensions
  39. [self addExtensionDeclarationForParentClass:entryClass
  40. childClasses:
  41. [GDataPhotoWidth class], [GDataPhotoHeight class],
  42. [GDataPhotoRotation class], [GDataPhotoSize class],
  43. [GDataPhotoAlbumID class], [GDataPhotoTimestamp class],
  44. [GDataPhotoCommentCount class], [GDataPhotoCommentingEnabled class],
  45. [GDataPhotoChecksum class], [GDataPhotoVideoStatus class],
  46. [GDataMediaGroup class], [GDataEXIFTags class],
  47. // V2 elements
  48. [GDataPhotoAlbumDesc class], [GDataPhotoAlbumTitle class],
  49. [GDataPhotoSnippet class], [GDataPhotoSnippetType class],
  50. [GDataPhotoTruncated class], [GDataPhotoLocation class],
  51. nil];
  52. [GDataGeo addGeoExtensionDeclarationsToObject:self
  53. forParentClass:entryClass];
  54. }
  55. #if !GDATA_SIMPLE_DESCRIPTIONS
  56. - (NSMutableArray *)itemsForDescription {
  57. static struct GDataDescriptionRecord descRecs[] = {
  58. { @"albumID", @"albumID", kGDataDescValueLabeled },
  59. { @"checksum", @"checksum", kGDataDescValueLabeled },
  60. { @"commentCount", @"commentCount", kGDataDescValueLabeled },
  61. { @"commentsEnabled", @"commentsEnabled", kGDataDescValueLabeled },
  62. { @"height", @"height", kGDataDescValueLabeled },
  63. { @"width", @"width", kGDataDescValueLabeled },
  64. { @"videoStatus", @"videoStatus", kGDataDescValueLabeled },
  65. { @"rotation", @"rotation", kGDataDescValueLabeled },
  66. { @"size", @"size", kGDataDescValueLabeled },
  67. { @"timestamp", @"timestamp", kGDataDescValueLabeled },
  68. { @"mediaGroup", @"mediaGroup", kGDataDescValueLabeled },
  69. { @"exifTags", @"EXIFTags", kGDataDescValueLabeled },
  70. { @"geoLocation", @"geoLocation", kGDataDescValueLabeled },
  71. { @"albumDesc", @"albumDescription", kGDataDescValueLabeled },
  72. { @"albumTitle", @"albumTitle", kGDataDescValueLabeled },
  73. { @"snippet", @"snippet", kGDataDescValueLabeled },
  74. { @"snippetType", @"snippetType", kGDataDescValueLabeled },
  75. { @"truncated", @"truncated", kGDataDescValueLabeled },
  76. { @"location", @"location", kGDataDescValueLabeled },
  77. { nil, nil, (GDataDescRecTypes)0 }
  78. };
  79. NSMutableArray *items = [super itemsForDescription];
  80. [self addDescriptionRecords:descRecs toItems:items];
  81. return items;
  82. }
  83. #endif
  84. #pragma mark -
  85. // binary photo uploading
  86. - (void)setPhotoData:(NSData *)data {
  87. [self setUploadData:data];
  88. }
  89. - (NSData *)photoData {
  90. return [self uploadData];
  91. }
  92. - (void)setPhotoMIMEType:(NSString *)str {
  93. [self setUploadMIMEType:str];
  94. }
  95. - (NSString *)photoMIMEType {
  96. return [self uploadMIMEType];
  97. }
  98. #pragma mark -
  99. - (NSString *)albumID {
  100. GDataPhotoAlbumID *obj = [self objectForExtensionClass:[GDataPhotoAlbumID class]];
  101. return [obj stringValue];
  102. }
  103. - (void)setAlbumID:(NSString *)str {
  104. GDataObject *obj = [GDataPhotoAlbumID valueWithString:str];
  105. [self setObject:obj forExtensionClass:[obj class]];
  106. }
  107. - (NSString *)checksum {
  108. GDataPhotoChecksum *obj = [self objectForExtensionClass:[GDataPhotoChecksum class]];
  109. return [obj stringValue];
  110. }
  111. - (void)setChecksum:(NSString *)str {
  112. GDataObject *obj = [GDataPhotoChecksum valueWithString:str];
  113. [self setObject:obj forExtensionClass:[obj class]];
  114. }
  115. - (NSNumber *)commentCount {
  116. // int
  117. GDataPhotoCommentCount *obj = [self objectForExtensionClass:[GDataPhotoCommentCount class]];
  118. return [obj intNumberValue];
  119. }
  120. - (void)setCommentCount:(NSNumber *)num {
  121. GDataObject *obj = [GDataPhotoCommentCount valueWithNumber:num];
  122. [self setObject:obj forExtensionClass:[obj class]];
  123. }
  124. - (NSNumber *)commentsEnabled {
  125. // BOOL
  126. GDataPhotoCommentingEnabled *obj = [self objectForExtensionClass:[GDataPhotoCommentingEnabled class]];
  127. return [obj boolNumberValue];
  128. }
  129. - (void)setCommentsEnabled:(NSNumber *)num {
  130. GDataObject *obj = [GDataPhotoCommentingEnabled valueWithBool:[num boolValue]];
  131. [self setObject:obj forExtensionClass:[obj class]];
  132. }
  133. - (NSNumber *)height {
  134. // long long
  135. GDataPhotoHeight *obj = [self objectForExtensionClass:[GDataPhotoHeight class]];
  136. return [obj longLongNumberValue];
  137. }
  138. - (void)setHeight:(NSNumber *)num {
  139. GDataObject *obj = [GDataPhotoHeight valueWithNumber:num];
  140. [self setObject:obj forExtensionClass:[obj class]];
  141. }
  142. - (NSNumber *)rotation {
  143. // int
  144. GDataPhotoRotation *obj = [self objectForExtensionClass:[GDataPhotoRotation class]];
  145. return [obj intNumberValue];
  146. }
  147. - (void)setRotation:(NSNumber *)num {
  148. GDataObject *obj = [GDataPhotoRotation valueWithNumber:num];
  149. [self setObject:obj forExtensionClass:[obj class]];
  150. }
  151. - (NSNumber *)size {
  152. // long long
  153. GDataPhotoSize *obj = [self objectForExtensionClass:[GDataPhotoSize class]];
  154. return [obj longLongNumberValue];
  155. }
  156. - (void)setSize:(NSNumber *)num {
  157. GDataObject *obj = [GDataPhotoSize valueWithNumber:num];
  158. [self setObject:obj forExtensionClass:[obj class]];
  159. }
  160. - (GDataPhotoTimestamp *)timestamp {
  161. GDataPhotoTimestamp *obj = [self objectForExtensionClass:[GDataPhotoTimestamp class]];
  162. return obj ;
  163. }
  164. - (void)setTimestamp:(GDataPhotoTimestamp *)obj {
  165. [self setObject:obj forExtensionClass:[GDataPhotoTimestamp class]];
  166. }
  167. - (NSNumber *)width {
  168. // long long
  169. GDataPhotoWidth *obj = [self objectForExtensionClass:[GDataPhotoWidth class]];
  170. return [obj longLongNumberValue];
  171. }
  172. - (void)setWidth:(NSNumber *)num {
  173. GDataObject *obj = [GDataPhotoWidth valueWithNumber:num];
  174. [self setObject:obj forExtensionClass:[obj class]];
  175. }
  176. - (NSString *)videoStatus {
  177. GDataPhotoVideoStatus *obj = [self objectForExtensionClass:[GDataPhotoVideoStatus class]];
  178. return [obj stringValue];
  179. }
  180. - (void)setVideoStatus:(NSString *)str {
  181. GDataPhotoVideoStatus *obj = [GDataPhotoVideoStatus valueWithString:str];
  182. [self setObject:obj forExtensionClass:[obj class]];
  183. }
  184. - (GDataMediaGroup *)mediaGroup {
  185. return (GDataMediaGroup *) [self objectForExtensionClass:[GDataMediaGroup class]];
  186. }
  187. - (void)setMediaGroup:(GDataMediaGroup *)obj {
  188. [self setObject:obj forExtensionClass:[GDataMediaGroup class]];
  189. }
  190. #pragma mark -
  191. - (GDataGeo *)geoLocation {
  192. return [GDataGeo geoLocationForObject:self];
  193. }
  194. - (void)setGeoLocation:(GDataGeo *)geo {
  195. [GDataGeo setGeoLocation:geo forObject:self];
  196. }
  197. // EXIF tag support
  198. - (GDataEXIFTags *)EXIFTags {
  199. return (GDataEXIFTags *) [self objectForExtensionClass:[GDataEXIFTags class]];
  200. }
  201. - (void)setEXIFTags:(GDataEXIFTags *)tags {
  202. [self setObject:tags forExtensionClass:[GDataEXIFTags class]];
  203. }
  204. #pragma mark search response elements introduced in V2
  205. - (NSString *)albumDescription {
  206. GDATA_DEBUG_ASSERT_MIN_SERVICE_V2();
  207. GDataPhotoAlbumDesc *obj;
  208. obj = [self objectForExtensionClass:[GDataPhotoAlbumDesc class]];
  209. return [obj stringValue];
  210. }
  211. - (void)setAlbumDescription:(NSString *)str {
  212. GDATA_DEBUG_ASSERT_MIN_SERVICE_V2();
  213. GDataPhotoAlbumDesc *obj = [GDataPhotoAlbumDesc valueWithString:str];
  214. [self setObject:obj forExtensionClass:[GDataPhotoAlbumDesc class]];
  215. }
  216. - (NSString *)albumTitle {
  217. GDATA_DEBUG_ASSERT_MIN_SERVICE_V2();
  218. GDataPhotoAlbumTitle *obj;
  219. obj = [self objectForExtensionClass:[GDataPhotoAlbumTitle class]];
  220. return [obj stringValue];
  221. }
  222. - (void)setAlbumTitle:(NSString *)str {
  223. GDATA_DEBUG_ASSERT_MIN_SERVICE_V2();
  224. GDataPhotoAlbumTitle *obj = [GDataPhotoAlbumTitle valueWithString:str];
  225. [self setObject:obj forExtensionClass:[GDataPhotoAlbumTitle class]];
  226. }
  227. - (NSString *)snippet {
  228. GDATA_DEBUG_ASSERT_MIN_SERVICE_V2();
  229. GDataPhotoSnippet *obj;
  230. obj = [self objectForExtensionClass:[GDataPhotoSnippet class]];
  231. return [obj stringValue];
  232. }
  233. - (void)setSnippet:(NSString *)str {
  234. GDATA_DEBUG_ASSERT_MIN_SERVICE_V2();
  235. GDataPhotoSnippet *obj = [GDataPhotoSnippet valueWithString:str];
  236. [self setObject:obj forExtensionClass:[GDataPhotoSnippet class]];
  237. }
  238. - (NSString *)snippetType {
  239. GDATA_DEBUG_ASSERT_MIN_SERVICE_V2();
  240. GDataPhotoSnippetType *obj;
  241. obj = [self objectForExtensionClass:[GDataPhotoSnippetType class]];
  242. return [obj stringValue];
  243. }
  244. - (void)setSnippetType:(NSString *)str {
  245. GDataPhotoSnippetType *obj = [GDataPhotoSnippetType valueWithString:str];
  246. [self setObject:obj forExtensionClass:[GDataPhotoSnippetType class]];
  247. }
  248. - (NSNumber *)truncated { // int, 0 or 1
  249. GDATA_DEBUG_ASSERT_MIN_SERVICE_V2();
  250. GDataPhotoTruncated *obj;
  251. obj = [self objectForExtensionClass:[GDataPhotoTruncated class]];
  252. return [obj intNumberValue];
  253. }
  254. - (void)setTruncated:(NSNumber *)num {
  255. GDATA_DEBUG_ASSERT_MIN_SERVICE_V2();
  256. GDataPhotoTruncated *obj = [GDataPhotoTruncated valueWithNumber:num];
  257. [self setObject:obj forExtensionClass:[GDataPhotoTruncated class]];
  258. }
  259. - (NSString *)location {
  260. GDATA_DEBUG_ASSERT_MIN_SERVICE_V2();
  261. GDataPhotoLocation *obj = [self objectForExtensionClass:[GDataPhotoLocation class]];
  262. return [obj stringValue];
  263. }
  264. - (void)setLocation:(NSString *)str {
  265. GDATA_DEBUG_ASSERT_MIN_SERVICE_V2();
  266. GDataPhotoLocation *obj = [GDataPhotoLocation valueWithString:str];
  267. [self setObject:obj forExtensionClass:[GDataPhotoLocation class]];
  268. }
  269. @end
  270. #endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_PHOTOS_SERVICE