PageRenderTime 57ms CodeModel.GetById 13ms app.highlight 41ms RepoModel.GetById 1ms app.codeStats 0ms

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