PageRenderTime 29ms CodeModel.GetById 2ms app.highlight 24ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://macfuse.googlecode.com/
Objective C | 168 lines | 112 code | 36 blank | 20 comment | 1 complexity | 39560d9614f44bd3b11ed07638ee54ab 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//  GDataQueryCalendar.m
 18//
 19
 20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CALENDAR_SERVICE
 21
 22#import "GDataQueryCalendar.h"
 23
 24// query params per
 25//   http://code.google.com/apis/calendar/reference.html#Parameters
 26
 27static NSString *const kMinimumStartTimeParamName  = @"start-min";
 28static NSString *const kMaximumStartTimeParamName  = @"start-max";
 29static NSString *const kRecurrenceExpansionStartTimeParamName  = @"recurrence-expansion-start";
 30static NSString *const kRecurrenceExpansionEndTimeParamName  = @"recurrence-expansion-end";
 31static NSString *const kFutureEventsParamName  = @"futureevents";
 32static NSString *const kSingleEventsParamName = @"singleevents";
 33static NSString *const kCurrentTimeZoneParamName = @"ctz";
 34static NSString *const kShowInlineCommentsParamName = @"showinlinecomments";
 35static NSString *const kShowHiddenParamName = @"showhidden";
 36static NSString *const kMaxAttendeesParamName = @"max-attendees";
 37
 38@implementation GDataQueryCalendar
 39
 40+ (GDataQueryCalendar *)calendarQueryWithFeedURL:(NSURL *)feedURL {
 41  return [self queryWithFeedURL:feedURL];   
 42}
 43
 44- (GDataDateTime *)minimumStartTime {
 45  GDataDateTime *dateTime;
 46
 47  dateTime = [self dateTimeForParameterWithName:kMinimumStartTimeParamName];
 48  return dateTime;
 49}
 50
 51- (void)setMinimumStartTime:(GDataDateTime *)dateTime {
 52  [self addCustomParameterWithName:kMinimumStartTimeParamName
 53                          dateTime:dateTime];
 54}
 55
 56- (GDataDateTime *)maximumStartTime {
 57  GDataDateTime *dateTime;
 58
 59  dateTime = [self dateTimeForParameterWithName:kMaximumStartTimeParamName];
 60  return dateTime;
 61}
 62
 63- (void)setMaximumStartTime:(GDataDateTime *)dateTime {
 64  [self addCustomParameterWithName:kMaximumStartTimeParamName
 65                          dateTime:dateTime];
 66}
 67
 68- (GDataDateTime *)recurrenceExpansionStartTime {
 69  GDataDateTime *dateTime;
 70
 71  dateTime = [self dateTimeForParameterWithName:kRecurrenceExpansionStartTimeParamName];
 72  return dateTime;
 73}
 74
 75- (void)setRecurrenceExpansionStartTime:(GDataDateTime *)dateTime {
 76  [self addCustomParameterWithName:kRecurrenceExpansionStartTimeParamName
 77                             dateTime:dateTime];
 78}
 79
 80- (GDataDateTime *)recurrenceExpansionEndTime {
 81  GDataDateTime *dateTime;
 82
 83  dateTime = [self dateTimeForParameterWithName:kRecurrenceExpansionEndTimeParamName];
 84  return dateTime;
 85}
 86
 87- (void)setRecurrenceExpansionEndTime:(GDataDateTime *)dateTime {
 88  [self addCustomParameterWithName:kRecurrenceExpansionEndTimeParamName
 89                          dateTime:dateTime];
 90}
 91
 92- (BOOL)shouldQueryAllFutureEvents {
 93  return [self boolValueForParameterWithName:kFutureEventsParamName
 94                                defaultValue:NO];
 95}
 96
 97- (void)setShouldQueryAllFutureEvents:(BOOL)flag {
 98  [self addCustomParameterWithName:kFutureEventsParamName
 99                         boolValue:flag
100                      defaultValue:NO];
101}
102
103- (BOOL)shouldExpandRecurrentEvents {
104  return [self boolValueForParameterWithName:kSingleEventsParamName
105                                defaultValue:NO];
106}
107
108- (void)setShouldExpandRecurrentEvents:(BOOL)flag {
109  [self addCustomParameterWithName:kSingleEventsParamName
110                         boolValue:flag
111                      defaultValue:NO];
112}
113
114- (BOOL)shouldShowInlineComments {
115  return [self boolValueForParameterWithName:kShowInlineCommentsParamName
116                                defaultValue:YES];
117}
118
119- (void)setShouldShowInlineComments:(BOOL)flag {
120  [self addCustomParameterWithName:kShowInlineCommentsParamName
121                         boolValue:flag
122                      defaultValue:YES];
123}
124
125- (BOOL)shouldShowHiddenEvents {
126  return [self boolValueForParameterWithName:kShowHiddenParamName
127                                defaultValue:NO];
128}
129
130- (void)setShouldShowHiddenEvents:(BOOL)flag {
131  [self addCustomParameterWithName:kShowHiddenParamName
132                         boolValue:flag
133                      defaultValue:NO];
134}
135
136- (NSString *)currentTimeZoneName {
137  NSString *str = [self valueForParameterWithName:kCurrentTimeZoneParamName];
138  return str;
139}
140
141- (void)setCurrentTimeZoneName:(NSString *)str {
142  
143  // replace underscores with spaces in the param value
144  NSMutableString *mutableStr = [NSMutableString stringWithString:str];
145  
146  [mutableStr replaceOccurrencesOfString:@" "
147                              withString:@"_"
148                                 options:0
149                                   range:NSMakeRange(0, [str length])];
150
151  [self addCustomParameterWithName:kCurrentTimeZoneParamName
152                             value:mutableStr];
153}
154
155- (NSInteger)maximumAttendees {
156  return [self intValueForParameterWithName:kMaxAttendeesParamName
157                      missingParameterValue:-1];
158}
159
160- (void)setMaximumAttendees:(NSInteger)val {
161  [self addCustomParameterWithName:kMaxAttendeesParamName
162                          intValue:val
163                    removeForValue:-1];
164}
165
166@end
167
168#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CALENDAR_SERVICE