Author: fmantek
Date: Tue Sep 18 02:49:43 2007
New Revision: 257
Added:
trunk/clients/cs/src/gcalendar/calendarentry.cs
trunk/clients/cs/src/gcalendar/calendarfeed.cs
trunk/clients/cs/src/gcalendar/calendarquery.cs
Modified:
trunk/clients/cs/src/core/authsubutil.cs
trunk/clients/cs/src/extensions/gdatanametable.cs
trunk/clients/cs/src/gcalendar/calendarservice.cs
Log:
Added better support for other authentication handlers to authsubutil.cs
Added support for the calendar feed
Modified: trunk/clients/cs/src/core/authsubutil.cs
==============================================================================
--- trunk/clients/cs/src/core/authsubutil.cs (original)
+++ trunk/clients/cs/src/core/authsubutil.cs Tue Sep 18 02:49:43 2007
@@ -38,7 +38,8 @@
public class AuthSubUtil
{
private static string DEFAULT_PROTOCOL = "https";
- private static string DEFAULT_DOMAIN = "www.google.com";
+ private static string DEFAULT_DOMAIN = "www.google.com";
+ private static string DEFAULT_HANDLER = "/accounts/AuthSubRequest";
//////////////////////////////////////////////////////////////////////
/// <summary>Creates the request URL to be used to retrieve an AuthSub
@@ -92,17 +93,50 @@
bool secure,
bool session)
{
+ return getRequestUrl(protocol, domain, DEFAULT_HANDLER,
continueUrl,
+ scope, secure, session);
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ /// <summary>Creates the request URL to be used to retrieve an AuthSub
+ /// token. On success, the user will be redirected to the continue URL
+ /// with the AuthSub token appended to the URL.
+ /// Use getTokenFromReply(String) to retrieve the token from the reply.
+ /// </summary>
+ /// <param name="protocol">the protocol to use to communicate with the
+ /// server</param>
+ /// <param name="domain">the domain at which the authentication server
+ /// exists</param>
+ /// <param name="handler">the location of the authentication handler
+ /// (defaults to "/accounts/AuthSubRequest".</param>
+ /// <param name="continueUrl">the URL to redirect to on successful
+ /// token retrieval</param>
+ /// <param name="scope">the scope of the requested AuthSub
token</param>
+ /// <param name="secure">if the token will be used securely</param>
+ /// <param name="session"> if the token will be exchanged for a
+ /// session cookie</param>
+ /// <returns>the URL to be used to retrieve the AuthSub token</returns>
+ //////////////////////////////////////////////////////////////////////
+ public static string getRequestUrl(string protocol,
+ string domain,
+ string handler,
+ string continueUrl,
+ string scope,
+ bool secure,
+ bool session)
+ {
- StringBuilder url = new StringBuilder(protocol);
- url.Append("://");
+ StringBuilder url = new StringBuilder(protocol);
+ url.Append("://");
url.Append(domain);
- url.Append("/accounts/AuthSubRequest?");
+ url.Append(handler);
+ url.Append("?");
addParameter(url, "next", continueUrl);
- url.Append("&");
+ url.Append("&");
addParameter(url, "scope", scope);
- url.Append("&");
+ url.Append("&");
addParameter(url, "secure", secure ? "1" : "0");
- url.Append("&");
+ url.Append("&");
addParameter(url, "session", session ? "1" : "0");
return url.ToString();
}
Modified: trunk/clients/cs/src/extensions/gdatanametable.cs
==============================================================================
--- trunk/clients/cs/src/extensions/gdatanametable.cs (original)
+++ trunk/clients/cs/src/extensions/gdatanametable.cs Tue Sep 18 02:49:43 2007
@@ -74,6 +74,10 @@
public const string XmlReminderElement = "reminder";
/// <summary>static string for parsing</summary>
public const string XmlCommentsElement = "comments";
+ public const string XmlColorElement = "color";
+ public const string XmlSelectedElement = "selected";
+ public const string XmlAccessLevelElement = "accesslevel";
+ public const string XmlHiddenElement = "hidden";
#endregion
@@ -139,4 +143,5 @@
}
/////////////////////////////////////////////////////////////////////////////
+
Added: trunk/clients/cs/src/gcalendar/calendarentry.cs
==============================================================================
--- (empty file)
+++ trunk/clients/cs/src/gcalendar/calendarentry.cs Tue Sep 18 02:49:43 2007
@@ -0,0 +1,236 @@
+/* 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.IO;
+using System.Collections;
+using Google.GData.Client;
+using Google.GData.Extensions;
+
+namespace Google.GData.Calendar
+{
+
+ //////////////////////////////////////////////////////////////////////
+ /// <summary>
+ /// CalendarEntry API customization class for defining entries in a
calendar feed.
+ /// </summary>
+ //////////////////////////////////////////////////////////////////////
+ public class CalendarEntry : AbstractEntry
+ {
+
+
+ /// <summary>
+ /// Constructs a new CalenderEntry instance
+ /// </summary>
+ public CalendarEntry() : base()
+ {
+ this.AddExtension(new GCalHidden());
+ this.AddExtension(new GCalColor());
+ this.AddExtension(new GCalSelected());
+ this.AddExtension(new GCalAccessLevel());
+ //this.AddExtension(new Where());
+ //this.AddExtension(new TimeZone());
+ }
+
+ /// <summary>
+ /// Basic method for retrieving Calendar extension elements.
+ /// </summary>
+ /// <param name="extension">The name of the extension element to look
for</param>
+ /// <returns>SimpleElement, or NULL if the extension was not
found</returns>
+ public SimpleElement getCalendarExtension(string extension)
+ {
+ return FindExtension(extension, GDataParserNameTable.NSGCal) as
SimpleElement;
+ }
+
+ /// <summary>
+ /// Base method for retrieving Calendar extension element values.
+ /// </summary>
+ /// <param name="extension">The name of the Calendar extension element
to look for</param>
+ /// <returns>value as string, or NULL if the extension was not
found</returns>
+ public string getCalendarExtensionValue(string extension)
+ {
+ SimpleElement e = getCalendarExtension(extension);
+ if (e != null)
+ {
+ return (string) e.Attributes["value"];
+ }
+ return null;
+ }
+
+
+ /// <summary>
+ /// Base method for setting Calendar extension element values.
+ /// </summary>
+ /// <param name="extension">the name of the extension to look
for</param>
+ /// <param name="newValue">the new value for this extension
element</param>
+ /// <returns>SimpleElement, either a brand new one, or the one
+ /// returned by the service</returns>
+ public SimpleElement setCalendarExtension(string extension, string
newValue)
+ {
+ if (extension == null)
+ {
+ throw new System.ArgumentNullException("extension");
+ }
+
+ SimpleElement ele = getCalendarExtension(extension);
+ if (ele == null)
+ {
+ ele = CreateExtension(extension, GDataParserNameTable.NSGCal)
as SimpleElement;
+ this.ExtensionElements.Add(ele);
+ }
+ if (ele.Attributes.ContainsKey("value"))
+ {
+ ele.Attributes["value"] = newValue;
+ }
+ else
+ {
+ ele.Attributes.Add("value", newValue);
+ }
+
+ return ele;
+ }
+
+
+ /// <summary>
+ /// This field tells if the calendar is currently hidden in the UI list
+ /// </summary>
+ public bool Hidden
+ {
+ get
+ {
+ return
bool.Parse(getCalendarExtensionValue(GDataParserNameTable.XmlHiddenElement));
+ }
+ set
+ {
+ setCalendarExtension(GDataParserNameTable.XmlHiddenElement,
value.ToString());
+ }
+ }
+
+ /// <summary>
+ /// This field tells if the calendar is currently selected in the UI
+ /// </summary>
+ public bool Selected
+ {
+ get
+ {
+ return
bool.Parse(getCalendarExtensionValue(GDataParserNameTable.XmlSelectedElement));
+ }
+ set
+ {
+ setCalendarExtension(GDataParserNameTable.XmlSelectedElement,
value.ToString());
+ }
+ }
+
+ /// <summary>
+ /// This field manages the color of the calendar.
+ /// </summary>
+ public string Color
+ {
+ get
+ {
+ return
getCalendarExtensionValue(GDataParserNameTable.XmlColorElement);
+ }
+ set
+ {
+ setCalendarExtension(GDataParserNameTable.XmlColorElement,
value);
+ }
+ }
+
+ /// <summary>
+ /// This field deals with the access level of the current user on the
calendar.
+ /// </summary>
+ public string AccessLevel
+ {
+ get
+ {
+ return
getCalendarExtensionValue(GDataParserNameTable.XmlAccessLevelElement);
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// Color schema describing a gCal:color
+ /// </summary>
+ public class GCalColor : SimpleElement
+ {
+ public GCalColor()
+ : base("color", GDataParserNameTable.gCalPrefix,
GDataParserNameTable.NSGCal)
+ {
+ this.Attributes.Add("value", null);
+ }
+
+ public GCalColor(string initValue)
+ : base("color", GDataParserNameTable.gCalPrefix,
GDataParserNameTable.NSGCal)
+ {
+ this.Attributes.Add("value", initValue);
+ }
+ }
+
+ /// <summary>
+ /// Color schema describing a gCal:hidden
+ /// </summary>
+ public class GCalHidden : SimpleElement
+ {
+ public GCalHidden()
+ : base("hidden", GDataParserNameTable.gCalPrefix,
GDataParserNameTable.NSGCal)
+ {
+ this.Attributes.Add("value", null);
+ }
+
+ public GCalHidden(string initValue)
+ : base("hidden", GDataParserNameTable.gCalPrefix,
GDataParserNameTable.NSGCal)
+ {
+ this.Attributes.Add("value", initValue);
+ }
+ }
+
+ /// <summary>
+ /// Color schema describing a gCal:selected
+ /// </summary>
+ public class GCalSelected : SimpleElement
+ {
+ public GCalSelected()
+ : base("selected", GDataParserNameTable.gCalPrefix,
GDataParserNameTable.NSGCal)
+ {
+ this.Attributes.Add("value", null);
+ }
+
+ public GCalSelected(string initValue)
+ : base("selected", GDataParserNameTable.gCalPrefix,
GDataParserNameTable.NSGCal)
+ {
+ this.Attributes.Add("value", initValue);
+ }
+ }
+
+ /// <summary>
+ /// Color schema describing a gCal:accesslevel
+ /// </summary>
+ public class GCalAccessLevel : SimpleElement
+ {
+ public GCalAccessLevel()
+ : base("accesslevel", GDataParserNameTable.gCalPrefix,
GDataParserNameTable.NSGCal)
+ {
+ this.Attributes.Add("value", null);
+ }
+
+ public GCalAccessLevel(string initValue)
+ : base("accesslevel", GDataParserNameTable.gCalPrefix,
GDataParserNameTable.NSGCal)
+ {
+ this.Attributes.Add("value", initValue);
+ }
+ }
+}
Added: trunk/clients/cs/src/gcalendar/calendarfeed.cs
==============================================================================
--- (empty file)
+++ trunk/clients/cs/src/gcalendar/calendarfeed.cs Tue Sep 18 02:49:43 2007
@@ -0,0 +1,67 @@
+/* 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.Collections;
+using System.Text;
+using System.Xml;
+using Google.GData.Client;
+using Google.GData.Extensions;
+
+namespace Google.GData.Calendar
+{
+
+
+ //////////////////////////////////////////////////////////////////////
+ /// <summary>
+ /// This is the Google Calendar feed that lets you access and manage
+ /// the calendars you own and also lets you subscribe or
+ /// unsubscribe from calendars owned by others.
+ /// </summary>
+ //////////////////////////////////////////////////////////////////////
+ public class CalendarFeed : AbstractFeed
+ {
+
+ /// <summary>
+ /// default constructor
+ /// </summary>
+ /// <param name="uriBase">the base URI of the feedEntry</param>
+ /// <param name="iService">the Service to use</param>
+ public CalendarFeed(Uri uriBase, IService iService) : base(uriBase,
iService)
+ {
+ }
+
+ /// <summary>
+ /// This needs to get implemented by subclasses
+ /// </summary>
+ /// <returns>AtomEntry</returns>
+ public override AtomEntry CreateFeedEntry()
+ {
+ return new CalendarEntry();
+ }
+
+ /// <summary>
+ /// Is called after we already handled the custom entry, to handle all
+ /// other potential parsing tasks
+ /// </summary>
+ /// <param name="e"></param>
+ /// <param name="parser">the atom feed parser used</param>
+ protected override void
HandleExtensionElements(ExtensionElementEventArgs e, AtomFeedParser parser)
+ {
+ base.HandleExtensionElements(e, parser);
+ }
+
+ }
+}
Added: trunk/clients/cs/src/gcalendar/calendarquery.cs
==============================================================================
--- (empty file)
+++ trunk/clients/cs/src/gcalendar/calendarquery.cs Tue Sep 18 02:49:43 2007
@@ -0,0 +1,34 @@
+/* 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 Google.GData.Client;
+
+namespace Google.GData.Calendar
+{
+
+ //////////////////////////////////////////////////////////////////////
+ /// <summary>
+ /// A subclass of FeedQuery, to create a Calendar query URI.
+ /// Currently, there are no extra parameters specific to the calendar
feeds.
+ /// </summary>
+ //////////////////////////////////////////////////////////////////////
+ public class CalendarQuery : FeedQuery
+ {
+ public CalendarQuery() : base()
+ {
+ }
+ }
+}
Modified: trunk/clients/cs/src/gcalendar/calendarservice.cs
==============================================================================
--- trunk/clients/cs/src/gcalendar/calendarservice.cs (original)
+++ trunk/clients/cs/src/gcalendar/calendarservice.cs Tue Sep 18 02:49:43 2007
@@ -57,11 +57,22 @@
return base.Query(feedQuery) as EventFeed;
}
+ /// <summary>
+ /// overloaded to create typed version of Query for Calendar feeds
+ /// </summary>
+ /// <param name="calQuery">The query object for searching a calendar
feed.</param>
+ /// <returns>CalendarFeed of the returned calendar entries.</returns>
+ public CalendarFeed Query(CalendarQuery calQuery)
+ {
+ return base.Query(calQuery) as CalendarFeed;
+ }
+
/// <summary>
/// overloaded to create typed version of Query
/// </summary>
/// <param name="feedQuery"></param>
- /// <returns>EventFeed</returns>
public AclFeed Query(AclQuery feedQuery)
+ /// <returns>EventFeed</returns>
+ public AclFeed Query(AclQuery feedQuery)
{
return base.Query(feedQuery) as AclFeed;
}
@@ -82,8 +93,13 @@
if (e.Uri.AbsoluteUri.IndexOf("/acl/") != -1)
{
e.Feed = new AclFeed(e.Uri, e.Service);
- }
- else
+ }
+ else if ((e.Uri.AbsoluteUri.IndexOf("/allcalendars/") != -1) ||
+ (e.Uri.AbsoluteUri.IndexOf("/owncalendars/") != -1))
+ {
+ e.Feed = new CalendarFeed(e.Uri, e.Service);
+ }
+ else
{
e.Feed = new EventFeed(e.Uri, e.Service);
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---