/core/externals/update-engine/externals/gdata-objectivec-client/Source/Clients/Calendar/GDataServiceGoogleCalendar.m

http://macfuse.googlecode.com/ · Objective C · 124 lines · 65 code · 39 blank · 20 comment · 1 complexity · a5e769bfb8fb31482a7359e58ecc592c MD5 · raw file

  1. /* Copyright (c) 2007 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. // GDataServiceGoogleCalendar.m
  17. //
  18. #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CALENDAR_SERVICE
  19. #define GDATASERVICEGOOGLECALENDAR_DEFINE_GLOBALS 1
  20. #import "GDataServiceGoogleCalendar.h"
  21. #import "GDataEntryCalendar.h"
  22. @implementation GDataServiceGoogleCalendar
  23. + (NSURL *)calendarFeedURLForUsername:(NSString *)username {
  24. // the calendar feed is the base feed plus the username
  25. NSString *usernameEscaped = [GDataUtilities stringByURLEncodingForURI:username];
  26. NSString *rootURLString = [self serviceRootURLString];
  27. NSString *feedURLString = [rootURLString stringByAppendingString:usernameEscaped];
  28. NSURL *url = [NSURL URLWithString:feedURLString];
  29. return url;
  30. }
  31. + (NSURL *)settingsFeedURLForUsername:(NSString *)username {
  32. NSString *usernameEscaped = [GDataUtilities stringByURLEncodingForURI:username];
  33. NSString *rootURLString = [self serviceRootURLString];
  34. NSString *const templateStr = @"%@%@/settings";
  35. NSString *feedURLString = [NSString stringWithFormat:templateStr,
  36. rootURLString, usernameEscaped];
  37. NSURL *url = [NSURL URLWithString:feedURLString];
  38. return url;
  39. }
  40. + (NSURL *)freeBusyURLForUsername:(NSString *)username {
  41. NSString *usernameEscaped = [GDataUtilities stringByURLEncodingForURI:username];
  42. NSString *rootURLString = [self serviceRootURLString];
  43. NSString *const templateStr = @"%@default/freebusy/busy-times/%@";
  44. NSString *feedURLString = [NSString stringWithFormat:templateStr,
  45. rootURLString, usernameEscaped];
  46. NSURL *url = [NSURL URLWithString:feedURLString];
  47. return url;
  48. }
  49. + (NSURL *)freeBusyURLForGroup:(NSString *)groupname {
  50. NSString *nameEscaped = [GDataUtilities stringByURLEncodingForURI:groupname];
  51. NSString *rootURLString = [self serviceRootURLString];
  52. NSString *const templateStr = @"%@default/freebusy/group/%@/busy-times";
  53. NSString *feedURLString = [NSString stringWithFormat:templateStr,
  54. rootURLString, nameEscaped];
  55. NSURL *url = [NSURL URLWithString:feedURLString];
  56. return url;
  57. }
  58. - (GDataServiceTicket *)fetchCalendarFeedForUsername:(NSString *)username
  59. delegate:(id)delegate
  60. didFinishSelector:(SEL)finishedSelector {
  61. NSURL *url = [[self class] calendarFeedURLForUsername:username];
  62. return [self fetchFeedWithURL:url
  63. delegate:delegate
  64. didFinishSelector:finishedSelector];
  65. }
  66. #pragma mark -
  67. + (NSString *)serviceID {
  68. return @"cl";
  69. }
  70. + (NSString *)serviceRootURLString {
  71. return @"https://www.google.com/calendar/feeds/";
  72. }
  73. + (NSString *)authorizationScope {
  74. // avoid Calendar's "Unknown authorization header" error by specifying a
  75. // non-https scope
  76. return @"http://www.google.com/calendar/feeds/";
  77. }
  78. + (NSString *)defaultServiceVersion {
  79. return kGDataCalendarDefaultServiceVersion;
  80. }
  81. + (NSDictionary *)standardServiceNamespaces {
  82. return [GDataEntryCalendar calendarNamespaces];
  83. }
  84. @end
  85. #endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CALENDAR_SERVICE