PageRenderTime 34ms CodeModel.GetById 13ms app.highlight 18ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Clients/Maps/GDataServiceGoogleMaps.m

http://macfuse.googlecode.com/
Objective C | 87 lines | 44 code | 21 blank | 22 comment | 5 complexity | fc67356961e74fd98b105756435d89d6 MD5 | raw file
 1/* Copyright (c) 2009 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//  GDataServiceGoogleMaps.m
18//
19
20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_MAPS_SERVICE
21
22#define GDATASERVICEGOOGLEMAPS_DEFINE_GLOBALS 1
23#import "GDataServiceGoogleMaps.h"
24
25#import "GDataMapConstants.h"
26#import "GDataEntryMapFeature.h"
27
28@implementation GDataServiceGoogleMaps
29
30+ (NSURL *)mapsFeedURLForUserID:(NSString *)userID
31                     projection:(NSString *)projection {
32
33  NSString *const template = @"%@maps/%@/%@";
34
35  NSString *encodedUserID = [GDataUtilities stringByURLEncodingStringParameter:userID];
36
37  NSString *rootURLStr = [self serviceRootURLString];
38
39  NSString *urlString = [NSString stringWithFormat:template,
40                         rootURLStr, encodedUserID, projection];
41
42  return [NSURL URLWithString:urlString];
43}
44
45// override the superclass's update method to use the namespaces that match
46// those provided by the server
47- (GDataServiceTicket *)fetchEntryByUpdatingEntry:(GDataEntryBase *)entryToUpdate
48                                         delegate:(id)delegate
49                                didFinishSelector:(SEL)finishedSelector {
50
51  if ([entryToUpdate namespaces] == nil) {
52    if ([entryToUpdate isKindOfClass:[GDataEntryMapFeature class]]) {
53      // we're updating a feature. Presumably it was supplied by the server
54      // with a default kml namespace
55      [entryToUpdate setNamespaces:[GDataMapConstants mapsServerNamespaces]];
56    } else {
57      // for other kinds of entries, the default namespace is atom
58      [entryToUpdate setNamespaces:[GDataMapConstants mapsNamespaces]];
59    }
60  }
61
62  return [super fetchEntryByUpdatingEntry:entryToUpdate
63                                 delegate:delegate
64                        didFinishSelector:finishedSelector];
65}
66
67#pragma mark -
68
69+ (NSString *)serviceID {
70  return @"local";
71}
72
73+ (NSString *)serviceRootURLString {
74  return @"https://maps.google.com/maps/feeds/";
75}
76
77+ (NSString *)defaultServiceVersion {
78  return kGDataMapsDefaultServiceVersion;
79}
80
81+ (NSDictionary *)standardServiceNamespaces {
82  return [GDataMapConstants mapsNamespaces];
83}
84
85@end
86
87#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_MAPS_SERVICE