Author: fmantek Date: Thu Sep 6 01:26:33 2007 New Revision: 235 Modified: trunk/clients/cs/RELEASE_NOTES.HTML trunk/clients/cs/src/gcalendar/eventquery.cs
Log: Added ctz parameter for EventQuery Modified: trunk/clients/cs/RELEASE_NOTES.HTML ============================================================================== --- trunk/clients/cs/RELEASE_NOTES.HTML (original) +++ trunk/clients/cs/RELEASE_NOTES.HTML Thu Sep 6 01:26:33 2007 @@ -32,7 +32,11 @@ that ever happens, this could/should be typed).</li> <li>Support for Google Calendar WebContent Gadgets is included. A WebContent element has a SortedList property to set and retrieve those preferences. See caltest.cs for an example.</li> -<li>Modified data model for Spreadsheets worksheets to make it easier to change and construct associated meta-data</li> +<li>Modified data model for Spreadsheets worksheets to make it easier to change +and construct associated meta-data</li> +<li>Added the ctz parameter to the EventQuery class. This parameter allows + to specify the timezone that is used to calculate start/end times for the + returned events</li> </ul> <h1>1.0.9.9</h1> Modified: trunk/clients/cs/src/gcalendar/eventquery.cs ============================================================================== --- trunk/clients/cs/src/gcalendar/eventquery.cs (original) +++ trunk/clients/cs/src/gcalendar/eventquery.cs Thu Sep 6 01:26:33 2007 @@ -1,290 +1,312 @@ -/* Copyright (c) 2006 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -*/ - -using System; -using System.Xml; -using System.Text; -using System.Globalization; -using System.Diagnostics; -using Google.GData.Client; - -namespace Google.GData.Calendar { - - ////////////////////////////////////////////////////////////////////// - /// <summary>Enum to describe the different sort orders - /// </summary> - ////////////////////////////////////////////////////////////////////// - public enum CalendarSortOrder - { - /// <summary> do not create the parameter, do whatever the server does</summary> - serverDefault, - /// <summary>sort in ascending order</summary> - ascending, - /// <summary>sort in descending order</summary> - descending - } - ///////////////////////////////////////////////////////////////////////////// - - - ////////////////////////////////////////////////////////////////////// - /// <summary> - /// A subclass of FeedQuery, to create a Calendar query URI. - /// Provides public properties that describe the different - /// aspects of the URI, as well as a composite URI. - /// </summary> - ////////////////////////////////////////////////////////////////////// - public class EventQuery : FeedQuery - { - - /// <summary> - /// base constructor - /// </summary> - public EventQuery() - : base() - { - this.sortOrder = CalendarSortOrder.serverDefault; - this.singleEvents = false; - this.futureEvents = false; - } - - /// <summary> - /// base constructor, with initial queryUri - /// </summary> - /// <param name="queryUri">the query to use</param> - public EventQuery(string queryUri) - : base(queryUri) - { - this.sortOrder = CalendarSortOrder.serverDefault; - this.singleEvents = false; - this.futureEvents = false; - } - - private DateTime startTime; - private DateTime endTime; - private DateTime recurrenceStart; - private DateTime recurrenceEnd; - private CalendarSortOrder sortOrder; - private bool singleEvents; - private bool futureEvents; - - - ////////////////////////////////////////////////////////////////////// - /// <summary>indicates the sortorder of the returned feed</summary> - /// <returns> </returns> - ////////////////////////////////////////////////////////////////////// - public CalendarSortOrder SortOrder - { - get {return this.sortOrder;} - set {this.sortOrder = value;} - } - // end of accessor public CalendarSortOrder SortOrder - - - ////////////////////////////////////////////////////////////////////// - /// <summary>Decides wether recurring events should be expanded or not</summary> - /// <returns> </returns> - ////////////////////////////////////////////////////////////////////// - public bool SingleEvents - { - get {return this.singleEvents;} - set {this.singleEvents = value;} - } - // end of accessor public bool SingleEvents - - - ////////////////////////////////////////////////////////////////////// - /// <summary>Decides wether events in the past should be returned. Defa</summary> - /// <returns> </returns> - ////////////////////////////////////////////////////////////////////// - public bool FutureEvents - { - get {return this.futureEvents;} - set {this.futureEvents = value;} - } - // end of accessor public bool FutureEvents - - - - /// <summary> - /// Accessor method for StartTime - /// </summary> - public DateTime StartTime - { - get { return startTime;} - set { startTime = value;} - } - - - /// <summary> - /// Accessor method for EndTime - /// </summary> - public DateTime EndTime - { - get { return endTime;} - set { endTime = value;} - } - - - /// <summary> - /// Accessor method for RecurrenceStart - /// </summary> - public DateTime RecurrenceStart - { - get { return recurrenceStart;} - set { recurrenceStart = value;} - } - - - /// <summary> - /// Accessor method for RecurrenceEnd - /// </summary> - public DateTime RecurrenceEnd - { - get { return recurrenceEnd;} - set { recurrenceEnd = value;} - } - - -#if WindowsCE || PocketPC -#else - ////////////////////////////////////////////////////////////////////// - /// <summary>protected void ParseUri</summary> - /// <param name="targetUri">takes an incoming Uri string and parses all the properties out of it</param> - /// <returns>throws a query exception when it finds something wrong with the input, otherwise returns a baseuri</returns> - ////////////////////////////////////////////////////////////////////// - protected override Uri ParseUri(Uri targetUri) - { - base.ParseUri(targetUri); - if (targetUri != null) - { - char[] deli = { '?', '&'}; - - TokenCollection tokens = new TokenCollection(targetUri.Query, deli); - foreach (String token in tokens) - { - if (token.Length > 0) - { - char[] otherDeli = { '='}; - String[] parameters = token.Split(otherDeli, 2); - switch (parameters[0]) - { - case "start-min": - this.startTime = DateTime.Parse(parameters[1], CultureInfo.InvariantCulture); - break; - case "start-max": - this.endTime = DateTime.Parse(parameters[1], CultureInfo.InvariantCulture); - break; - case "recurrence-expansion-start": - this.recurrenceStart = DateTime.Parse(parameters[1], CultureInfo.InvariantCulture); - break; - case "recurrence-expansion-end": - this.recurrenceEnd = DateTime.Parse(parameters[1], CultureInfo.InvariantCulture); - break; - case "singleevents": - this.singleEvents = bool.Parse(parameters[1]); - break; - case "futureevents": - this.futureEvents = bool.Parse(parameters[1]); - break; - case "sortorder": - this.sortOrder = (CalendarSortOrder) Enum.Parse(typeof(CalendarSortOrder), parameters[1]); - break; - } - } - } - } - return this.Uri; - } -#endif - - ////////////////////////////////////////////////////////////////////// - /// <summary>Resets object state to default, as if newly created. - /// </summary> - ////////////////////////////////////////////////////////////////////// - protected override void Reset() - { - base.Reset(); - startTime = endTime = Utilities.EmptyDate; - recurrenceStart = recurrenceEnd = Utilities.EmptyDate; - } - - ////////////////////////////////////////////////////////////////////// - /// <summary>Creates the partial URI query string based on all - /// set properties.</summary> - /// <returns> string => the query part of the URI </returns> - ////////////////////////////////////////////////////////////////////// - protected override string CalculateQuery() - { - string path = base.CalculateQuery(); - StringBuilder newPath = new StringBuilder(path, 2048); - - char paramInsertion; - - if (path.IndexOf('?') == -1) - { - paramInsertion = '?'; - } - else - { - paramInsertion = '&'; - } - if (Utilities.IsPersistable(this.StartTime)) - { - newPath.Append(paramInsertion); - newPath.AppendFormat(CultureInfo.InvariantCulture, "start-min={0}", Utilities.UriEncodeReserved(Utilities.LocalDateTimeInUTC(this.StartTime))); - paramInsertion = '&'; - } - if (Utilities.IsPersistable(this.EndTime)) - { - newPath.Append(paramInsertion); - newPath.AppendFormat(CultureInfo.InvariantCulture, "start-max={0}", Utilities.UriEncodeReserved(Utilities.LocalDateTimeInUTC(this.EndTime))); - paramInsertion = '&'; - } - if (Utilities.IsPersistable(this.RecurrenceStart)) - { - newPath.Append(paramInsertion); - newPath.AppendFormat(CultureInfo.InvariantCulture, "recurrence-expansion-start={0}", Utilities.UriEncodeReserved(Utilities.LocalDateTimeInUTC(this.RecurrenceStart))); - paramInsertion = '&'; - } - if (Utilities.IsPersistable(this.RecurrenceEnd)) - { - newPath.Append(paramInsertion); - newPath.AppendFormat(CultureInfo.InvariantCulture, "recurrence-expansion-end={0}", Utilities.UriEncodeReserved(Utilities.LocalDateTimeInUTC(this.RecurrenceEnd))); - paramInsertion = '&'; - } - if (this.sortOrder != CalendarSortOrder.serverDefault) - { - newPath.Append(paramInsertion); - newPath.AppendFormat(CultureInfo.InvariantCulture, "sortorder={0}", this.sortOrder.ToString()); - paramInsertion = '&'; - } - if (this.futureEvents == true) - { - newPath.Append(paramInsertion); - newPath.AppendFormat(CultureInfo.InvariantCulture, "futureevents=true"); - paramInsertion = '&'; - } - if (this.singleEvents == true) - { - newPath.Append(paramInsertion); - newPath.AppendFormat(CultureInfo.InvariantCulture, "singleevents=true"); - paramInsertion = '&'; - } - - - return newPath.ToString(); - } - } -} +/* Copyright (c) 2006 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +using System; +using System.Xml; +using System.Text; +using System.Globalization; +using System.Diagnostics; +using Google.GData.Client; + +namespace Google.GData.Calendar { + + ////////////////////////////////////////////////////////////////////// + /// <summary>Enum to describe the different sort orders + /// </summary> + ////////////////////////////////////////////////////////////////////// + public enum CalendarSortOrder + { + /// <summary> do not create the parameter, do whatever the server does</summary> + serverDefault, + /// <summary>sort in ascending order</summary> + ascending, + /// <summary>sort in descending order</summary> + descending + } + ///////////////////////////////////////////////////////////////////////////// + + + ////////////////////////////////////////////////////////////////////// + /// <summary> + /// A subclass of FeedQuery, to create a Calendar query URI. + /// Provides public properties that describe the different + /// aspects of the URI, as well as a composite URI. + /// </summary> + ////////////////////////////////////////////////////////////////////// + public class EventQuery : FeedQuery + { + + /// <summary> + /// base constructor + /// </summary> + public EventQuery() + : base() + { + this.sortOrder = CalendarSortOrder.serverDefault; + this.singleEvents = false; + this.futureEvents = false; + } + + /// <summary> + /// base constructor, with initial queryUri + /// </summary> + /// <param name="queryUri">the query to use</param> + public EventQuery(string queryUri) + : base(queryUri) + { + this.sortOrder = CalendarSortOrder.serverDefault; + this.singleEvents = false; + this.futureEvents = false; + } + + private DateTime startTime; + private DateTime endTime; + private DateTime recurrenceStart; + private DateTime recurrenceEnd; + private CalendarSortOrder sortOrder; + private bool singleEvents; + private bool futureEvents; + private string timeZone; + + ////////////////////////////////////////////////////////////////////// + /// <summary>this indicates the ctz parameter in the query. It + /// allows you specify the timezone that is used to calculate the + /// start/end times for events</summary> + /// <returns> </returns> + ////////////////////////////////////////////////////////////////////// + public string TimeZone + { + get {return this.timeZone;} + set {this.timeZone = value;} + } + // end of accessor public string TimeZone + + ////////////////////////////////////////////////////////////////////// + /// <summary>indicates the sortorder of the returned feed</summary> + /// <returns> </returns> + ////////////////////////////////////////////////////////////////////// + public CalendarSortOrder SortOrder + { + get {return this.sortOrder;} + set {this.sortOrder = value;} + } + // end of accessor public CalendarSortOrder SortOrder + + + ////////////////////////////////////////////////////////////////////// + /// <summary>Decides wether recurring events should be expanded or not</summary> + /// <returns> </returns> + ////////////////////////////////////////////////////////////////////// + public bool SingleEvents + { + get {return this.singleEvents;} + set {this.singleEvents = value;} + } + // end of accessor public bool SingleEvents + + + ////////////////////////////////////////////////////////////////////// + /// <summary>Decides wether events in the past should be returned. Defa</summary> + /// <returns> </returns> + ////////////////////////////////////////////////////////////////////// + public bool FutureEvents + { + get {return this.futureEvents;} + set {this.futureEvents = value;} + } + // end of accessor public bool FutureEvents + + + + /// <summary> + /// Accessor method for StartTime + /// </summary> + public DateTime StartTime + { + get { return startTime;} + set { startTime = value;} + } + + + /// <summary> + /// Accessor method for EndTime + /// </summary> + public DateTime EndTime + { + get { return endTime;} + set { endTime = value;} + } + + + /// <summary> + /// Accessor method for RecurrenceStart + /// </summary> + public DateTime RecurrenceStart + { + get { return recurrenceStart;} + set { recurrenceStart = value;} + } + + + /// <summary> + /// Accessor method for RecurrenceEnd + /// </summary> + public DateTime RecurrenceEnd + { + get { return recurrenceEnd;} + set { recurrenceEnd = value;} + } + + +#if WindowsCE || PocketPC +#else + ////////////////////////////////////////////////////////////////////// + /// <summary>protected void ParseUri</summary> + /// <param name="targetUri">takes an incoming Uri string and parses all the properties out of it</param> + /// <returns>throws a query exception when it finds something wrong with the input, otherwise returns a baseuri</returns> + ////////////////////////////////////////////////////////////////////// + protected override Uri ParseUri(Uri targetUri) + { + base.ParseUri(targetUri); + if (targetUri != null) + { + char[] deli = { '?', '&'}; + + TokenCollection tokens = new TokenCollection(targetUri.Query, deli); + foreach (String token in tokens) + { + if (token.Length > 0) + { + char[] otherDeli = { '='}; + String[] parameters = token.Split(otherDeli, 2); + switch (parameters[0]) + { + case "start-min": + this.startTime = DateTime.Parse(parameters[1], CultureInfo.InvariantCulture); + break; + case "start-max": + this.endTime = DateTime.Parse(parameters[1], CultureInfo.InvariantCulture); + break; + case "recurrence-expansion-start": + this.recurrenceStart = DateTime.Parse(parameters[1], CultureInfo.InvariantCulture); + break; + case "recurrence-expansion-end": + this.recurrenceEnd = DateTime.Parse(parameters[1], CultureInfo.InvariantCulture); + break; + case "singleevents": + this.singleEvents = bool.Parse(parameters[1]); + break; + case "futureevents": + this.futureEvents = bool.Parse(parameters[1]); + break; + case "sortorder": + this.sortOrder = (CalendarSortOrder) Enum.Parse(typeof(CalendarSortOrder), parameters[1]); + break; + case "ctz": + this.timeZone = parameters[1]; + break; + } + } + } + } + return this.Uri; + } +#endif + + ////////////////////////////////////////////////////////////////////// + /// <summary>Resets object state to default, as if newly created. + /// </summary> + ////////////////////////////////////////////////////////////////////// + protected override void Reset() + { + base.Reset(); + startTime = endTime = Utilities.EmptyDate; + recurrenceStart = recurrenceEnd = Utilities.EmptyDate; + } + + ////////////////////////////////////////////////////////////////////// + /// <summary>Creates the partial URI query string based on all + /// set properties.</summary> + /// <returns> string => the query part of the URI </returns> + ////////////////////////////////////////////////////////////////////// + protected override string CalculateQuery() + { + string path = base.CalculateQuery(); + StringBuilder newPath = new StringBuilder(path, 2048); + + char paramInsertion; + + if (path.IndexOf('?') == -1) + { + paramInsertion = '?'; + } + else + { + paramInsertion = '&'; + } + if (Utilities.IsPersistable(this.StartTime)) + { + newPath.Append(paramInsertion); + newPath.AppendFormat(CultureInfo.InvariantCulture, "start-min={0}", Utilities.UriEncodeReserved(Utilities.LocalDateTimeInUTC(this.StartTime))); + paramInsertion = '&'; + } + if (Utilities.IsPersistable(this.EndTime)) + { + newPath.Append(paramInsertion); + newPath.AppendFormat(CultureInfo.InvariantCulture, "start-max={0}", Utilities.UriEncodeReserved(Utilities.LocalDateTimeInUTC(this.EndTime))); + paramInsertion = '&'; + } + if (Utilities.IsPersistable(this.RecurrenceStart)) + { + newPath.Append(paramInsertion); + newPath.AppendFormat(CultureInfo.InvariantCulture, "recurrence-expansion-start={0}", Utilities.UriEncodeReserved(Utilities.LocalDateTimeInUTC(this.RecurrenceStart))); + paramInsertion = '&'; + } + if (Utilities.IsPersistable(this.TimeZone)) + { + newPath.Append(paramInsertion); + newPath.AppendFormat(CultureInfo.InvariantCulture, "ctz={0}", Utilities.UriEncodeReserved(this.TimeZone)); + paramInsertion = '&'; + } + if (Utilities.IsPersistable(this.RecurrenceEnd)) + { + newPath.Append(paramInsertion); + newPath.AppendFormat(CultureInfo.InvariantCulture, "recurrence-expansion-end={0}", Utilities.UriEncodeReserved(Utilities.LocalDateTimeInUTC(this.RecurrenceEnd))); + paramInsertion = '&'; + } + if (this.sortOrder != CalendarSortOrder.serverDefault) + { + newPath.Append(paramInsertion); + newPath.AppendFormat(CultureInfo.InvariantCulture, "sortorder={0}", this.sortOrder.ToString()); + paramInsertion = '&'; + } + if (this.futureEvents == true) + { + newPath.Append(paramInsertion); + newPath.AppendFormat(CultureInfo.InvariantCulture, "futureevents=true"); + paramInsertion = '&'; + } + if (this.singleEvents == true) + { + newPath.Append(paramInsertion); + newPath.AppendFormat(CultureInfo.InvariantCulture, "singleevents=true"); + paramInsertion = '&'; + } + + + return newPath.ToString(); + } + } +} --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Data API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/google-help-dataapi?hl=en -~----------~----~----~----~------~----~------~--~---
