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