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