PageRenderTime 51ms CodeModel.GetById 15ms app.highlight 33ms RepoModel.GetById 2ms app.codeStats 0ms

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