PageRenderTime 26ms CodeModel.GetById 4ms app.highlight 20ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://macfuse.googlecode.com/
Objective C | 122 lines | 81 code | 24 blank | 17 comment | 6 complexity | cee41a1bf0eef36aa5d5cdac6d1faf88 MD5 | raw file
  1/* Copyright (c) 2008 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//  GDataQueryGooglePhotos.m
 18//
 19
 20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_PHOTOS_SERVICE
 21
 22#define GDATAQUERYGOOGLEPHOTOS_DEFINE_GLOBALS 1
 23#import "GDataQueryGooglePhotos.h"
 24
 25#import "GDataServiceGooglePhotos.h"
 26
 27static NSString *const kKindParamName = @"kind";
 28static NSString *const kAccessParamName = @"access";
 29static NSString *const kThumbsizeParamName = @"thumbsize";
 30static NSString *const kImageSizeParamName = @"imgmax";
 31static NSString *const kTagParamName = @"tag";
 32
 33static NSString *const kImageSizeOriginalPhoto = @"d";
 34
 35@implementation GDataQueryGooglePhotos
 36
 37+ (GDataQueryGooglePhotos *)photoQueryWithFeedURL:(NSURL *)feedURL {
 38  return [self queryWithFeedURL:feedURL];   
 39}
 40
 41+ (GDataQueryGooglePhotos *)photoQueryForUserID:(NSString *)userID
 42                                        albumID:(NSString *)albumIDorNil
 43                                      albumName:(NSString *)albumNameOrNil
 44                                        photoID:(NSString *)photoIDorNil {  
 45  NSURL *url;
 46  url = [GDataServiceGooglePhotos photoFeedURLForUserID:userID
 47                                                albumID:albumIDorNil
 48                                              albumName:albumNameOrNil
 49                                                photoID:photoIDorNil
 50                                                   kind:nil
 51                                                 access:nil];
 52  return [self photoQueryWithFeedURL:url];
 53}
 54
 55- (NSString *)stringParamOrNilForInt:(NSInteger)val {
 56  if (val > 0) {
 57    return [NSString stringWithFormat:@"%ld", (long)val]; 
 58  }
 59  return nil;
 60}
 61
 62- (void)setThumbsize:(NSInteger)val {
 63  [self addCustomParameterWithName:kThumbsizeParamName
 64                             value:[self stringParamOrNilForInt:val]];
 65}
 66
 67- (NSInteger)thumbsize {
 68  return [self intValueForParameterWithName:kThumbsizeParamName
 69                      missingParameterValue:0];
 70}
 71
 72- (void)setKind:(NSString *)str {
 73  [self addCustomParameterWithName:kKindParamName
 74                             value:str];
 75}
 76
 77- (NSString *)kind {
 78  return [self valueForParameterWithName:kKindParamName];
 79}
 80
 81- (void)setAccess:(NSString *)str {
 82  [self addCustomParameterWithName:kAccessParamName
 83                             value:str];
 84}
 85
 86- (NSString *)access {
 87  return [self valueForParameterWithName:kAccessParamName];
 88}
 89
 90- (void)setImageSize:(NSInteger)val {
 91  NSString *valStr;
 92  
 93  if (val == kGDataGooglePhotosImageSizeDownloadable) {
 94    valStr = kImageSizeOriginalPhoto; // imgmax=d
 95  } else {
 96    valStr = [self stringParamOrNilForInt:val];
 97  }
 98  
 99  [self addCustomParameterWithName:kImageSizeParamName
100                             value:valStr]; 
101}
102
103- (NSInteger)imageSize {
104  NSString *valStr = [self valueForParameterWithName:kImageSizeParamName];
105  
106  if ([valStr isEqual:kImageSizeOriginalPhoto]) {
107    return kGDataGooglePhotosImageSizeDownloadable;
108  }
109  return [valStr intValue];
110}
111
112- (void)setTag:(NSString *)str {
113  [self addCustomParameterWithName:kTagParamName
114                             value:str];
115}
116
117- (NSString *)tag {
118  return [self valueForParameterWithName:kTagParamName];
119}
120@end
121
122#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_PHOTOS_SERVICE