PageRenderTime 30ms CodeModel.GetById 10ms app.highlight 17ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://macfuse.googlecode.com/
Objective C | 124 lines | 75 code | 30 blank | 19 comment | 8 complexity | 226ec5c912aec54d497f07eb345ef710 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//  GDataServiceGooglePhotos.m
 18//
 19
 20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_PHOTOS_SERVICE
 21
 22#define GDATASERVICEGOOGLEPHOTOS_DEFINE_GLOBALS 1
 23#import "GDataServiceGooglePhotos.h"
 24#import "GDataEntryPhotoBase.h"
 25#import "GDataQueryGooglePhotos.h"
 26#import "GDataPhotoConstants.h"
 27
 28@implementation GDataServiceGooglePhotos
 29
 30+ (NSURL *)photoFeedURLForUserID:(NSString *)userID
 31                         albumID:(NSString *)albumIDorNil
 32                       albumName:(NSString *)albumNameOrNil
 33                         photoID:(NSString *)photoIDorNil
 34                            kind:(NSString *)feedKindOrNil
 35                          access:(NSString *)accessOrNil {
 36
 37  NSString *albumID = @"";
 38  if (albumIDorNil) {
 39    albumID = [NSString stringWithFormat:@"/albumid/%@",
 40               [GDataUtilities stringByURLEncodingForURI:albumIDorNil]];
 41  }
 42
 43  NSString *albumName = @"";
 44  if (albumNameOrNil && !albumIDorNil) {
 45    albumName = [NSString stringWithFormat:@"/album/%@",
 46                 [GDataUtilities stringByURLEncodingForURI:albumNameOrNil]];
 47  }
 48
 49  NSString *photo = @"";
 50  if (photoIDorNil) {
 51    photo = [NSString stringWithFormat:@"/photoid/%@", photoIDorNil];
 52  }
 53
 54  // make an array for the kind and access query params, and join the arra items
 55  // into a query string
 56  NSString *query = @"";
 57  NSMutableArray *queryItems = [NSMutableArray array];
 58  if (feedKindOrNil) {
 59    feedKindOrNil = [GDataUtilities stringByURLEncodingStringParameter:feedKindOrNil];
 60
 61    NSString *kindStr = [NSString stringWithFormat:@"kind=%@", feedKindOrNil];
 62    [queryItems addObject:kindStr];
 63  }
 64
 65  if (accessOrNil) {
 66    accessOrNil = [GDataUtilities stringByURLEncodingStringParameter:accessOrNil];
 67
 68    NSString *accessStr = [NSString stringWithFormat:@"access=%@", accessOrNil];
 69    [queryItems addObject:accessStr];
 70  }
 71
 72  if ([queryItems count]) {
 73    NSString *queryList = [queryItems componentsJoinedByString:@"&"];
 74
 75    query = [NSString stringWithFormat:@"?%@", queryList];
 76  }
 77
 78  NSString *root = [self serviceRootURLString];
 79
 80  NSString *const templateStr = @"%@feed/api/user/%@%@%@%@%@";
 81  NSString *urlString = [NSString stringWithFormat:templateStr,
 82                         root, [GDataUtilities stringByURLEncodingForURI:userID],
 83                         albumID, albumName, photo, query];
 84
 85  return [NSURL URLWithString:urlString];
 86}
 87
 88+ (NSURL *)photoContactsFeedURLForUserID:(NSString *)userID {
 89
 90  NSString *root = [self serviceRootURLString];
 91
 92  NSString *const templateStr = @"%@feed/api/user/%@/contacts?kind=user";
 93
 94  NSString *urlString = [NSString stringWithFormat:templateStr,
 95                       root, [GDataUtilities stringByURLEncodingForURI:userID]];
 96
 97  return [NSURL URLWithString:urlString];
 98}
 99
100#pragma mark -
101
102+ (NSString *)serviceID {
103  return @"lh2";
104}
105
106+ (NSString *)serviceRootURLString {
107  return @"https://photos.googleapis.com/data/";
108}
109
110+ (NSString *)defaultServiceVersion {
111  return kGDataPhotosDefaultServiceVersion;
112}
113
114+ (NSUInteger)defaultServiceUploadChunkSize {
115  return kGDataStandardUploadChunkSize;
116}
117
118+ (NSDictionary *)standardServiceNamespaces {
119  return [GDataPhotoConstants photoNamespaces];
120}
121
122@end
123
124#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_PHOTOS_SERVICE