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