PageRenderTime 40ms CodeModel.GetById 19ms app.highlight 18ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Clients/Contacts/GDataServiceGoogleContact.m

http://macfuse.googlecode.com/
Objective C | 124 lines | 75 code | 31 blank | 18 comment | 1 complexity | 52d3081cde75102a461daf032f147f7c 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//  GDataServiceGoogleContact.m
 18//
 19
 20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CONTACTS_SERVICE
 21
 22#define GDATASERVICEGOOGLECONTACT_DEFINE_GLOBALS 1
 23
 24#import "GDataServiceGoogleContact.h"
 25#import "GDataQueryContact.h"
 26#import "GDataFeedContact.h"
 27#import "GDataContactConstants.h"
 28
 29@implementation GDataServiceGoogleContact
 30
 31// feed is contacts or groups; projection is thin, default, or property-<key>
 32+ (NSURL *)contactURLForFeedName:(NSString *)feedName
 33                          userID:(NSString *)userID
 34                      projection:(NSString *)projection {
 35
 36  NSString *baseURLString = [self serviceRootURLString];
 37
 38  NSString *const templateStr = @"%@%@/%@/%@";
 39
 40  NSString *feedURLString = [NSString stringWithFormat:templateStr,
 41                             baseURLString,
 42                             [GDataUtilities stringByURLEncodingForURI:feedName],
 43                             [GDataUtilities stringByURLEncodingForURI:userID],
 44                             [GDataUtilities stringByURLEncodingForURI:projection]];
 45
 46  NSURL *url = [NSURL URLWithString:feedURLString];
 47
 48  return url;
 49}
 50
 51+ (NSURL *)contactFeedURLForPropertyName:(NSString *)property {
 52
 53  NSString *projection = [NSString stringWithFormat:@"property-%@", property];
 54  NSURL *url = [self contactURLForFeedName:kGDataGoogleContactAllContactsFeedName
 55                                    userID:kGDataServiceDefaultUser
 56                                projection:projection];
 57  return url;
 58}
 59
 60+ (NSURL *)contactGroupFeedURLForPropertyName:(NSString *)property {
 61
 62  NSString *projection = [NSString stringWithFormat:@"property-%@", property];
 63  NSURL *url = [self contactURLForFeedName:kGDataGoogleContactGroupsFeedName
 64                                    userID:kGDataServiceDefaultUser
 65                                projection:projection];
 66  return url;
 67}
 68
 69+ (NSURL *)contactFeedURLForUserID:(NSString *)userID {
 70
 71  NSURL *url = [self contactURLForFeedName:kGDataGoogleContactAllContactsFeedName
 72                                    userID:userID
 73                                projection:kGDataGoogleContactFullProjection];
 74  return url;
 75}
 76
 77+ (NSURL *)groupFeedURLForUserID:(NSString *)userID {
 78
 79  NSURL *url = [self contactURLForFeedName:kGDataGoogleContactGroupsFeedName
 80                                    userID:userID
 81                                projection:kGDataGoogleContactFullProjection];
 82  return url;
 83}
 84
 85+ (NSURL *)contactFeedURLForUserID:(NSString *)userID
 86                        projection:(NSString *)projection {
 87
 88  NSURL *url = [self contactURLForFeedName:kGDataGoogleContactAllContactsFeedName
 89                                    userID:userID
 90                                projection:projection];
 91  return url;
 92}
 93
 94- (GDataServiceTicket *)fetchContactFeedForUsername:(NSString *)username
 95                                           delegate:(id)delegate
 96                                  didFinishSelector:(SEL)finishedSelector {
 97
 98  NSURL *url = [[self class] contactFeedURLForUserID:username];
 99
100  return [self fetchFeedWithURL:url
101                       delegate:delegate
102              didFinishSelector:finishedSelector];
103}
104
105
106+ (NSString *)serviceID {
107  return @"cp";
108}
109
110+ (NSString *)serviceRootURLString {
111  return @"https://www.google.com/m8/feeds/";
112}
113
114+ (NSString *)defaultServiceVersion {
115  return kGDataContactDefaultServiceVersion;
116}
117
118+ (NSDictionary *)standardServiceNamespaces {
119  return [GDataContactConstants contactNamespaces];
120}
121
122@end
123
124#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CONTACTS_SERVICE