Author: fmantek
Date: Wed Oct 17 06:01:08 2007
New Revision: 301

Modified:
   trunk/clients/cs/RELEASE_NOTES.HTML
   trunk/clients/cs/src/core/atombase.cs
   trunk/clients/cs/src/core/gauthrequest.cs
   trunk/clients/cs/src/core/service.cs
   trunk/clients/cs/src/core/serviceinterface.cs
   trunk/clients/cs/src/extensions/extcollections.cs
   trunk/clients/cs/src/extensions/mediarss.cs
   trunk/clients/cs/src/extensions/simplecontainer.cs
   trunk/clients/cs/src/unittests/authtest.cs

Log:
     <li>Fixed MediaGroup to allow the retrieval of multiple Thumbnails.
            Introduced the ThumbnailCollection for this. To enable this,
             SimpleContainer and AtomBase now implement 
IExtensionContainer, a
            common interface that encapsulates owning Extension elements.
            </li>
       <li>Added QueryAuthToken() on the service. If the Service is a
            Google authenticated service, you can use this to obtain an
            authentication token for ClientLogin</li>


Modified: trunk/clients/cs/RELEASE_NOTES.HTML
==============================================================================
--- trunk/clients/cs/RELEASE_NOTES.HTML (original)
+++ trunk/clients/cs/RELEASE_NOTES.HTML Wed Oct 17 06:01:08 2007
@@ -10,8 +10,10 @@
         <li>Added an EventId property to the EventEntry object. This one
              parses the atomId URI to just provided the EventId, which 
is used
             elsewhere (e.g., for recurring events).</li>
+        <li>Added QueryAuthToken() on the service. If the Service is a
+            Google authenticated service, you can use this to obtain an
+            authentication token for ClientLogin</li>

-
     </ul>
     <li>Bugfixes/Changes</li>
     <ul>
@@ -38,6 +40,11 @@
             object, hence retrieval of a calendar location was broken.</li>
         <li>Fixed ExtensionBase to not save NULL attributes as empty
             strings. This could cause Picasa updates to fail.</li>
+        <li>Fixed MediaGroup to allow the retrieval of multiple Thumbnails.
+            Introduced the ThumbnailCollection for this. To enable this,
+            SimpleContainer and AtomBase now implement 
IExtensionContainer, a
+            common interface that encapsulates owning Extension elements.
+            </li>
     </ul>
 </ul>


Modified: trunk/clients/cs/src/core/atombase.cs
==============================================================================
--- trunk/clients/cs/src/core/atombase.cs       (original)
+++ trunk/clients/cs/src/core/atombase.cs       Wed Oct 17 06:01:08 2007
@@ -109,7 +109,7 @@
     /// <summary>AtomBase object representation.
     /// </summary>
     //////////////////////////////////////////////////////////////////////
-    public abstract class AtomBase
+    public abstract class AtomBase : IExtensionContainer
     {
         /// <summary>holds the base Uri</summary>
         private AtomUri uriBase;

Modified: trunk/clients/cs/src/core/gauthrequest.cs
==============================================================================
--- trunk/clients/cs/src/core/gauthrequest.cs   (original)
+++ trunk/clients/cs/src/core/gauthrequest.cs   Wed Oct 17 06:01:08 2007
@@ -154,6 +154,16 @@
         }
         
/////////////////////////////////////////////////////////////////////////////

+        //////////////////////////////////////////////////////////////////////
+        /// <summary>Get's an authentication token for the current 
credentials</summary>
+        //////////////////////////////////////////////////////////////////////
+        public string QueryAuthToken(GDataCredentials gc)
+        {
+            GDataGAuthRequest request = new 
GDataGAuthRequest(GDataRequestType.Query, null, this);
+            return request.QueryAuthToken(gc);
+        }
+        
/////////////////////////////////////////////////////////////////////////////
+

         
////////////////////////////////////////////////////////////////////////////////
         /// <summary>accessor method public string UserAgent, with GFE 
support</summary>
@@ -424,7 +434,7 @@
          /// <summary>goes to the Google auth service, and gets a new 
auth token</summary>
         /// <returns>the auth token, or NULL if none received</returns>
         //////////////////////////////////////////////////////////////////////
-        protected string QueryAuthToken(GDataCredentials gc)
+        internal string QueryAuthToken(GDataCredentials gc)
         {
              Tracing.Assert(gc != null, "Do not call QueryAuthToken 
with no network credentials");
             if (gc == null)

Modified: trunk/clients/cs/src/core/service.cs
==============================================================================
--- trunk/clients/cs/src/core/service.cs        (original)
+++ trunk/clients/cs/src/core/service.cs        Wed Oct 17 06:01:08 2007
@@ -178,6 +178,27 @@
         }
         
/////////////////////////////////////////////////////////////////////////////

+
+        /// <summary>
+        /// if the service is using a Google Request Factory it will 
use that
+        /// assuming credentials are set to retrieve the 
authentication token
+        /// for those credentials
+        /// </summary>
+        /// <returns>string</returns>
+        public string QueryAuthenticationToken()
+        {
+            if (this.Credentials != null)
+            {
+                GDataGAuthRequestFactory factory = 
this.GDataRequestFactory as GDataGAuthRequestFactory;
+                if (factory != null)
+                {
+                    return factory.QueryAuthToken(this.Credentials);
+                }
+            }
+            return null;
+
+        }
+

         //////////////////////////////////////////////////////////////////////
         /// <summary>the basic interface. Take a URI and just get it</summary>

Modified: trunk/clients/cs/src/core/serviceinterface.cs
==============================================================================
--- trunk/clients/cs/src/core/serviceinterface.cs       (original)
+++ trunk/clients/cs/src/core/serviceinterface.cs       Wed Oct 17 06:01:08 2007
@@ -20,7 +20,7 @@
 using System.Net;
 using System.IO;
 using System.Xml;
-using Google.GData.Client;
+using System.Collections;

 #endregion

@@ -182,6 +182,75 @@
         /// <returns></returns>
         IExtensionElement CreateInstance(XmlNode node, AtomFeedParser parser);
     }
+
+
+    //////////////////////////////////////////////////////////////////////
+    /// <summary>interface for commone extension container functionallity
+    /// used for AtomBase and SimpleContainer
+    /// </summary>
+    //////////////////////////////////////////////////////////////////////
+    public interface IExtensionContainer
+    {
+         //////////////////////////////////////////////////////////////////////
+        /// <summary>the list of extensions for this container
+        /// the elements in that list MUST implement IExtensionElementFactory
+        /// and IExtensionElement</summary>
+        /// <returns> </returns>
+        //////////////////////////////////////////////////////////////////////
+        ArrayList ExtensionElements { get; }
+
+        /// <summary>
+        /// Finds a specific ExtensionElement based on it's local name
+        /// and it's namespace. If namespace is NULL, the first one where
+        /// the localname matches is found. If there are 
extensionelements that do
+        /// not implment ExtensionElementFactory, they will not be 
taken into account
+        /// </summary>
+        /// <param name="localName">the xml local name of the element 
to find</param>
+        /// <param name="ns">the namespace of the elementToPersist</param>
+        /// <returns>Object</returns>
+        Object FindExtension(string localName, string ns);
+
+        /// <summary>
+        /// all extension elements that match a namespace/localname
+        /// given will be removed and the new one will be inserted
+        /// </summary>
+        /// <param name="localName">the local name to find</param>
+        /// <param name="ns">the namespace to match, if null, ns is 
ignored</param>
+        /// <param name="obj">the new element to put in</param>
+        void ReplaceExtension(string localName, string ns, Object obj);
+
+        /// <summary>
+        /// Finds all ExtensionElement based on it's local name
+        /// and it's namespace. If namespace is NULL, allwhere
+        /// the localname matches is found. If there are 
extensionelements that do
+        /// not implment ExtensionElementFactory, they will not be 
taken into account
+        /// Primary use of this is to find XML nodes
+        /// </summary>
+        /// <param name="localName">the xml local name of the element 
to find</param>
+        /// <param name="ns">the namespace of the elementToPersist</param>
+        /// <returns>none</returns>
+        ArrayList FindExtensions(string localName, string ns);
+
+        /// <summary>
+        /// Delete's all Extensions from the Extension list that match
+        /// a localName and a Namespace.
+        /// </summary>
+        /// <param name="localName">the local name to find</param>
+        /// <param name="ns">the namespace to match, if null, ns is 
ignored</param>
+        /// <returns>int - the number of deleted extensions</returns>
+        int DeleteExtensions(string localName, string ns);
+
+
+        //////////////////////////////////////////////////////////////////////
+        /// <summary>the list of extensions for this container
+        /// the elements in that list MUST implement IExtensionElementFactory
+        /// and IExtensionElement</summary>
+        /// <returns> </returns>
+        //////////////////////////////////////////////////////////////////////
+        ArrayList ExtensionFactories { get; }
+
+    }
+




Modified: trunk/clients/cs/src/extensions/extcollections.cs
==============================================================================
--- trunk/clients/cs/src/extensions/extcollections.cs   (original)
+++ trunk/clients/cs/src/extensions/extcollections.cs   Wed Oct 17 
06:01:08 2007
@@ -19,6 +19,7 @@
 using System;
 using System.Collections;
 using Google.GData.Client;
+using Google.GData.Extensions.MediaRss;

 #endregion

@@ -39,7 +40,7 @@
     public class ExtensionCollection : CollectionBase
     {
              /// <summary>holds the owning feed</summary>
-         private AtomBase atomElement;
+         private IExtensionContainer container;

          /// <summary>
          /// protected default constructor, not usable by outside
@@ -56,10 +57,10 @@
          /// <param name="atomElement">the base element holding the 
extension list</param>
         /// <param name="localName">the local name of the extension</param>
         /// <param name="ns">the namespace</param>
-        public ExtensionCollection(AtomBase atomElement, string 
localName, string ns) : base()
+        public ExtensionCollection(IExtensionContainer 
containerElement, string localName, string ns) : base()
         {
-             this.atomElement = atomElement;
-             ArrayList arr = atomElement.FindExtensions(localName, ns);
+             this.container = containerElement;
+             ArrayList arr = this.container.FindExtensions(localName, ns);
              foreach (object o in arr )
              {
                  List.Add(o);
@@ -75,12 +76,12 @@
         {
             if (List[index] != null)
             {
-                this.atomElement.ExtensionElements.Remove(List[index]);
+                this.container.ExtensionElements.Remove(List[index]);
             }
             List[index] = item;
             if (item != null)
             {
-                this.atomElement.ExtensionElements.Add(item);
+                this.container.ExtensionElements.Add(item);
             }
         }

@@ -93,7 +94,7 @@
         /// <returns></returns>
         public int Add(object value)
         {
-            this.atomElement.ExtensionElements.Add(value);
+            this.container.ExtensionElements.Add(value);
             return( List.Add( value ) );
         }

@@ -104,11 +105,11 @@
         /// <param name="value"></param>
         public void Insert( int index, object value )
         {
-            if (this.atomElement.ExtensionElements.Contains(value))
+            if (this.container.ExtensionElements.Contains(value))
             {
-                this.atomElement.ExtensionElements.Remove(value);
+                this.container.ExtensionElements.Remove(value);
             }
-            this.atomElement.ExtensionElements.Add(value);
+            this.container.ExtensionElements.Add(value);
             List.Insert( index, value );
         }

@@ -118,7 +119,7 @@
         /// <param name="value"></param>
         public void Remove( object value )
         {
-            this.atomElement.ExtensionElements.Remove(value);
+            this.container.ExtensionElements.Remove(value);
             List.Remove( value );
         }

@@ -127,7 +128,7 @@
         {
             for (int i=0; i< this.Count;i++)
             {
-                this.atomElement.ExtensionElements.Remove(List[i]);
+                this.container.ExtensionElements.Remove(List[i]);
             }
         }
     }
@@ -142,7 +143,7 @@
         }

         /// <summary>constructor</summary>
-        public WhenCollection(AtomBase atomElement)
+        public WhenCollection(IExtensionContainer atomElement)
             : base(atomElement, GDataParserNameTable.XmlWhenElement, 
BaseNameTable.gNamespace)
         {
         }
@@ -211,7 +212,7 @@
         }

         /// <summary>constructor</summary>
-        public WhereCollection(AtomBase atomElement)
+        public WhereCollection(IExtensionContainer atomElement)
             : base(atomElement, GDataParserNameTable.XmlWhereElement, 
BaseNameTable.gNamespace)
         {
         }
@@ -280,7 +281,7 @@
         }

         /// <summary>constructor</summary>
-        public WhoCollection(AtomBase atomElement)
+        public WhoCollection(IExtensionContainer atomElement)
             : base(atomElement, GDataParserNameTable.XmlWhoElement, 
BaseNameTable.gNamespace)
         {
         }
@@ -337,5 +338,74 @@
         }
     }
     
/////////////////////////////////////////////////////////////////////////////
+
+    //////////////////////////////////////////////////////////////////////
+    /// <summary>Typed collection for Thumbnails Extensions.</summary>
+    //////////////////////////////////////////////////////////////////////
+    public class ThumbnailCollection : ExtensionCollection
+    {
+        private ThumbnailCollection() : base()
+        {
+        }
+
+        /// <summary>constructor</summary>
+        public ThumbnailCollection(IExtensionContainer atomElement)
+            : base(atomElement, MediaRssNameTable.MediaRssThumbnail, 
MediaRssNameTable.NSMediaRss)
+        {
+        }
+
+        /// <summary>standard typed accessor method </summary>
+        public MediaThumbnail this[int index]
+        {
+            get
+            {
+                return ((MediaThumbnail)List[index]);
+            }
+            set
+            {
+                setItem(index,value);
+            }
+        }
+
+        /// <summary>standard typed add method </summary>
+        public int Add(MediaThumbnail value)
+        {
+            return base.Add(value);
+        }
+
+        /// <summary>standard typed indexOf method </summary>
+        public int IndexOf(MediaThumbnail value)
+        {
+            return (List.IndexOf(value));
+        }
+
+        /// <summary>standard typed insert method </summary>
+        public void Insert(int index, MediaThumbnail value)
+        {
+            base.Insert(index, value);
+        }
+
+        /// <summary>standard typed remove method </summary>
+        public void Remove(MediaThumbnail value)
+        {
+            base.Remove(value);
+        }
+
+        /// <summary>standard typed Contains method </summary>
+        public bool Contains(MediaThumbnail value)
+        {
+            // If value is not of type AtomEntry, this will return false.
+            return (List.Contains(value));
+        }
+
+        /// <summary>standard typed OnValidate Override </summary>
+        protected override void OnValidate(Object value)
+        {
+            if (value as MediaThumbnail == null)
+                throw new ArgumentException("value must be of type 
Google.GData.Extensions.MediaRss.MediaThumbnail.", "value");
+        }
+    }
+    
/////////////////////////////////////////////////////////////////////////////
+

 }

Modified: trunk/clients/cs/src/extensions/mediarss.cs
==============================================================================
--- trunk/clients/cs/src/extensions/mediarss.cs (original)
+++ trunk/clients/cs/src/extensions/mediarss.cs Wed Oct 17 06:01:08 2007
@@ -71,6 +71,7 @@
     /// </summary>
     public class MediaGroup : SimpleContainer
     {
+        private ThumbnailCollection thumbnails;
         /// <summary>
         /// default constructor for media:group
         /// </summary>
@@ -156,23 +157,23 @@
                                 value);
             }
         }
+
+
         /// <summary>
-        /// returns the media:thumbnail element
+        ///  property accessor for the Thumbnails
         /// </summary>
-        public MediaThumbnail Thumbnail
+        public ThumbnailCollection Thumbnails
         {
-            get
+            get
             {
-                return FindExtension(MediaRssNameTable.MediaRssThumbnail,
-                                     MediaRssNameTable.NSMediaRss) as 
MediaThumbnail;
-            }
-            set
-            {
-                ReplaceExtension(MediaRssNameTable.MediaRssThumbnail,
-                                MediaRssNameTable.NSMediaRss,
-                                value);
+                if (this.thumbnails == null)
+                {
+                    this.thumbnails =  new ThumbnailCollection(this);
+                }
+                return this.thumbnails;
             }
         }
+
         /// <summary>
         /// returns the media:content element
         /// </summary>

Modified: trunk/clients/cs/src/extensions/simplecontainer.cs
==============================================================================
--- trunk/clients/cs/src/extensions/simplecontainer.cs  (original)
+++ trunk/clients/cs/src/extensions/simplecontainer.cs  Wed Oct 17 
06:01:08 2007
@@ -27,7 +27,7 @@
     /// TODO: at one point think about using this as the base for atom:base
     /// as there is some utility overlap between the 2 of them
     /// </summary>
-    public class SimpleContainer : ExtensionBase
+    public class SimpleContainer : ExtensionBase, IExtensionContainer
     {
         private ArrayList extensions;
         private ArrayList extensionFactories;

Modified: trunk/clients/cs/src/unittests/authtest.cs
==============================================================================
--- trunk/clients/cs/src/unittests/authtest.cs  (original)
+++ trunk/clients/cs/src/unittests/authtest.cs  Wed Oct 17 06:01:08 2007
@@ -148,6 +148,27 @@
         }
         
////////////////////////////////////////////////////////////////////////////

+        //////////////////////////////////////////////////////////////////////
+        /// <summary>runs an authentication test</summary>
+        //////////////////////////////////////////////////////////////////////
+        [Test] public void TestFactoryCredentialRetrieval()
+        {
+            Tracing.TraceMsg("Entering TestFactoryCredentialRetrieval");
+
+            Service service = new Service("lh2", "test");
+
+            if (this.defaultUri != null)
+            {
+                if (this.userName != null)
+                {
+                    service.Credentials = new 
GDataCredentials(this.userName, this.passWord);
+                }
+                string token = service.QueryAuthenticationToken();
+            }
+        }
+        
////////////////////////////////////////////////////////////////////////////
+
+
          //////////////////////////////////////////////////////////////////////
         /// <summary>correct account, invalid password</summary>
         //////////////////////////////////////////////////////////////////////

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to