Revision: 201022 RCL_3 PDK_3.0.1
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 21 Jun 2010 16:17:02 +0300
branchRCL_3
changeset 26 bdd8a827a7de
parent 22 26ce6fb6aee2
child 36 a2a70ce3d4e8
Revision: 201022 Kit: 2010125
applayerprotocols/httptransportfw/core/CTransaction.cpp
httpfilters/cookie/ManagerSrc/Cookie.cpp
httpfilters/cookie/ManagerSrc/CookieArray.cpp
httpfilters/cookie/ManagerSrc/CookieClientData.cpp
netprotocols_plat/cookie_manager_api/inc/cookie.h
--- a/applayerprotocols/httptransportfw/core/CTransaction.cpp	Wed Jun 09 10:16:57 2010 +0300
+++ b/applayerprotocols/httptransportfw/core/CTransaction.cpp	Mon Jun 21 16:17:02 2010 +0300
@@ -42,7 +42,6 @@
 	Cancel();
 	// And send the cancel event
 	SynchronousSendEvent(THTTPEvent::ECancel, THTTPEvent::EOutgoing, aStart);
-
 	if (iStatus != EInFilter && iStatus != ECancelled)
 		iStatus = EPassive;
 	else
--- a/httpfilters/cookie/ManagerSrc/Cookie.cpp	Wed Jun 09 10:16:57 2010 +0300
+++ b/httpfilters/cookie/ManagerSrc/Cookie.cpp	Mon Jun 21 16:17:02 2010 +0300
@@ -181,11 +181,11 @@
 // CCookie::NewL
 // ---------------------------------------------------------
 //
-CCookie* CCookie::CloneL( const CCookie& aCopy )
+CCookie* CCookie::CloneL( const CCookie& aCopy,const TDesC8& aDomain,const TDesC8& aPath, const TDesC8& aPort)
     {
     CCookie* self = new(ELeave) CCookie( aCopy.iStringPool );
     CleanupStack::PushL( self );
-    self->CopyFromL( aCopy );
+    self->CopyFromL( aCopy, aDomain, aPath, aPort);
     CleanupStack::Pop( self );
     return self;
     }
@@ -444,11 +444,13 @@
 // CCookie::CopyFromL
 // ---------------------------------------------------------
 //
-void CCookie::CopyFromL( const CCookie& aCopyFrom  )
+void CCookie::CopyFromL( const CCookie& aCopyFrom, const TDesC8& aDomain, const TDesC8& aPath, const TDesC8& aPort  )
     {
     CLOG( ( ECookie, 0, _L( "-> CCookie::CopyFromL ") ) );
+    TBool defaultDiscard( EFalse );
     THTTPHdrVal attributevalue;
     TBool defaulted( EFalse );
+    iSetCookie2 = aCopyFrom.iSetCookie2;
     if ( aCopyFrom.Attribute( EName, attributevalue, defaulted ) != KErrNotFound )
         {
         if ( attributevalue.Type() != THTTPHdrVal::KStrVal )
@@ -463,6 +465,8 @@
         else 
             {
             SetAttribute( EName, attributevalue, defaulted );    
+            const TPtrC8 pVal( attributevalue.Str().DesC() );
+            CLOG( ( ECookie, 0, _L8( "CCookie::CopyFromL - attribute EName Value : %S" ), &pVal ) );
             }
         }
 
@@ -479,69 +483,157 @@
             }
          else
              {
-             SetAttribute( EValue, attributevalue, defaulted );             
+             SetAttribute( EValue, attributevalue, defaulted );
+             const TPtrC8 pVal( attributevalue.Str().DesC() );
+             CLOG( ( ECookie, 0, _L8( "CCookie::CopyFromL - attribute EValue Value : %S" ), &pVal ) );
              }
         }
-	if ( aCopyFrom.Attribute( EComment, attributevalue, defaulted ) != KErrNotFound )
-        {
-        SetAttribute( EComment, attributevalue, defaulted );
-        }
-
-	if ( aCopyFrom.Attribute( ECommentURI, attributevalue, defaulted ) != KErrNotFound )
-        {
-        SetAttribute( ECommentURI, attributevalue, defaulted );
-        }
-
-	if ( aCopyFrom.Attribute( EDiscard, attributevalue, defaulted ) != KErrNotFound )
+    if ( aCopyFrom.Attribute( EVersion, attributevalue, defaulted ) != KErrNotFound )
         {
-        SetAttribute( EDiscard, attributevalue, defaulted );
+        SetAttribute( EVersion, attributevalue, defaulted );    
+        SetFromNetscape( EFalse );
         }
-
-	if ( aCopyFrom.Attribute( EDomain, attributevalue, defaulted ) != KErrNotFound )
+    else
         {
-        SetAttribute( EDomain, attributevalue, defaulted );
-        }
-
-	if ( aCopyFrom.Attribute( EMaxAge, attributevalue, defaulted ) != KErrNotFound )
-        {
-        SetAttribute( EMaxAge, attributevalue, defaulted );
+        SetFromNetscape( ETrue );
         }
 
-	if ( aCopyFrom.Attribute( EPath, attributevalue, defaulted ) != KErrNotFound )
-        {
-        SetAttribute( EPath, attributevalue, defaulted );
-        }
-
-	if ( aCopyFrom.Attribute( EPort, attributevalue, defaulted ) != KErrNotFound )
+    if ( aCopyFrom.Attribute( EPath, attributevalue, defaulted ) != KErrNotFound )
         {
-        SetAttribute( EPort, attributevalue, defaulted );
+         if ( attributevalue.Type() != THTTPHdrVal::KStrFVal )
+             {
+             SetAttribute( EPath, attributevalue, defaulted );    
+             }
         }
-
-	if ( aCopyFrom.Attribute( ESecure, attributevalue, defaulted ) != KErrNotFound )
+    else
         {
-        SetAttribute( ESecure, attributevalue, defaulted );
+        // defaulting
+        RStringF defPath = iStringPool.OpenFStringL( aPath );
+        THTTPHdrVal defPathVal( defPath );
+        SetAttribute( EPath, defPathVal, ETrue );// ignore the result 
+        defPath.Close();
         }
-
-	if ( aCopyFrom.Attribute( EVersion, attributevalue, defaulted ) != KErrNotFound )
-        {
-        SetAttribute( EVersion, attributevalue, defaulted );
-        }
-
-	if ( aCopyFrom.Attribute( EExpires, attributevalue, defaulted ) != KErrNotFound )
-        {
-        SetAttribute( EExpires, attributevalue, defaulted );
-        }
-		
-	TTime nowTime;
-    nowTime.UniversalTime();
-    TDateTime attrTime = nowTime.DateTime();
-    THTTPHdrVal attributeVal( attrTime );
-    SetAttribute( EDate, attributeVal, defaulted );
+    if ( aCopyFrom.Attribute( EDomain, attributevalue, defaulted ) != KErrNotFound )
+          {
+          if ( attributevalue.Type() != THTTPHdrVal::KStrFVal )
+              {
+              SetAttribute( EDomain, attributevalue, defaulted );    
+              }
+          }
+    else
+       {
+         // Default handling 
+         // in this case the default is the effective request host        
+         RStringF defDomain = iStringPool.OpenFStringL( aDomain );
+         THTTPHdrVal defdomVal( defDomain );
+         SetAttribute( EDomain, defdomVal, ETrue );// ignore the result 
+         defDomain.Close();
+       }
+  
+    
+    if ( aCopyFrom.Attribute( ESecure, attributevalue, defaulted ) != KErrNotFound )
+	      {
+            SetAttribute( ESecure, attributevalue, defaulted );    
+	      }
+    if (iNetscape)
+         {
+         if ( aCopyFrom.Attribute( EExpires, attributevalue, defaulted ) != KErrNotFound )
+              {
+                  SetAttribute( EExpires, attributevalue, defaulted );    
+              }
+         else if ( aCopyFrom.Attribute( EComment, attributevalue, defaulted ) != KErrNotFound ||
+                           aCopyFrom.Attribute( EMaxAge, attributevalue, defaulted ) != KErrNotFound )
+             {
+             iNetscape = EFalse;
+             }
+         }
+     if ( aCopyFrom.Attribute( EDate, attributevalue, defaulted ) != KErrNotFound )
+          {
+          TDateTime attrTime = attributevalue.DateTime();
+          THTTPHdrVal attributeVal( attrTime );
+          SetAttribute( CCookie::EDate, attributeVal, defaulted );
+          }
+     else
+         {
+           TTime nowTime;
+           nowTime.UniversalTime();
+           TDateTime attrTime = nowTime.DateTime();
+           THTTPHdrVal attributeVal( attrTime );
+           SetAttribute( EDate, attributeVal, defaulted );
+         }
+     if (iNetscape == EFalse)
+         {
+         if ( aCopyFrom.Attribute( EComment, attributevalue, defaulted ) != KErrNotFound )
+             {
+             SetAttribute( EComment, attributevalue );
+             }
+         else
+             {
+             
+             }
+         if ( aCopyFrom.Attribute( EMaxAge, attributevalue, defaulted ) != KErrNotFound)
+             {
+             SetAttribute( EMaxAge, attributevalue );
+             }
+         else
+             {
+              if(iSetCookie2)
+                  {
+                  defaultDiscard = ETrue;
+                  }
+             }
+         if(iSetCookie2)
+             {
+             if ( aCopyFrom.Attribute( ECommentURI, attributevalue, defaulted ) != KErrNotFound )
+                 {
+                 SetAttribute( ECommentURI, attributevalue, defaulted );
+                 }
+             else
+                 {
+                 
+                 }
+             if ( aCopyFrom.Attribute( EDiscard, attributevalue, defaulted ) != KErrNotFound )
+                  {
+                      SetAttribute( EDiscard, attributevalue, defaulted );    
+                  }
+             else
+                {
+                 if (defaultDiscard)
+                     {
+                     RStringF emptyStr = iStringPool.OpenFStringL( KNullDesC8() );
+                     THTTPHdrVal emptyVal( emptyStr );
+                     SetAttribute( EDiscard, emptyVal, ETrue );
+                     emptyStr.Close();
+                     }
+                 if (aCopyFrom.Attribute( EPort, attributevalue, defaulted ) != KErrNotFound)
+                     {
+                     SetAttribute( EPort, attributevalue, ETrue );    // ignore the result of this method
+                     }
+                 else
+                     {
+                     RStringF requestPort;
+                     if(!aPort.Compare(KNullDesC8()))
+                         {
+                         requestPort = iStringPool.OpenFStringL( aPort );
+                         }
+                     else
+                         {
+                         requestPort = iStringPool.OpenFStringL( KCookieDefaultRequestPort() );
+                         }
+                     THTTPHdrVal portVal( requestPort );
+                     SetAttribute( EPort, portVal, ETrue );
+                     requestPort.Close();
+                     }
+                }
+             
+             }
+             
+         }
+	
 
     //SetCookie2( aCopyFrom.FromCookie2() );
     // Other properties
-    iSetCookie2 = aCopyFrom.iSetCookie2;
-    iNetscape = aCopyFrom.iNetscape;
+    
     iSize = aCopyFrom.iSize;
     iReceivedTime = aCopyFrom.iReceivedTime;
     CLOG( ( ECookie, 0, _L( "<- CCookie::CopyFromL ") ) );
@@ -1034,7 +1126,7 @@
 
 	iSetCookie2 = ( aFieldName == setCookie2Name );
 
-    TBool DefaultDiscard( EFalse );
+    TBool defaultDiscard( EFalse );
 
 	THTTPHdrVal hVal;
 
@@ -1237,7 +1329,7 @@
             // in case of SetCookie2, also set Discard, defaulted
             if ( iSetCookie2 )
                 {
-                DefaultDiscard = ETrue;
+                defaultDiscard = ETrue;
                 }
            }
 
@@ -1275,7 +1367,7 @@
                 { // Add default handling if applies
 		        // no defaulting for EDiscard
                 // only if it is caused by MAx-Age beeing not supplied
-                if ( DefaultDiscard )
+                if ( defaultDiscard )
                     {
 		            RStringF emptyStr = iStringPool.OpenFStringL( KNullDesC8() );
                     THTTPHdrVal emptyVal( emptyStr );
--- a/httpfilters/cookie/ManagerSrc/CookieArray.cpp	Wed Jun 09 10:16:57 2010 +0300
+++ b/httpfilters/cookie/ManagerSrc/CookieArray.cpp	Mon Jun 21 16:17:02 2010 +0300
@@ -1040,7 +1040,7 @@
 // ---------------------------------------------------------
 //
 TInt CCookieArray::GetCookies( const TDesC8& aRequestUri,
-                               RPointerArray<CCookie>& aCookies, TBool& aFound )// harendra: aFound is redundant
+                               RPointerArray<CCookie>& aCookies, TBool& aFound )
     {
     CLOG( ( ECookieArray, 0,
             _L( "-> CCookieArray::GetCookies for an URI" ) ) );
@@ -1092,7 +1092,7 @@
                 PortMatch( requestPort, cookiePort ) &&
                 SecureMatch( requestScheme, *iCookies[i] ) )
                 {
-                CCookie* clone = CCookie::CloneL( *iCookies[i] );
+                CCookie* clone = CCookie::CloneL( *iCookies[i],requestDomain,requestPath,requestPort );
                 CleanupStack::PushL( clone );
                 err = aCookies.Append(clone);
                 CleanupStack::Pop(clone);
--- a/httpfilters/cookie/ManagerSrc/CookieClientData.cpp	Wed Jun 09 10:16:57 2010 +0300
+++ b/httpfilters/cookie/ManagerSrc/CookieClientData.cpp	Mon Jun 21 16:17:02 2010 +0300
@@ -9,7 +9,8 @@
 #include "cookie.h"
 #include "CookieArray.h"
 #include "CookieLogger.h"
-
+#include "CookieCommonConstants.h"
+#include <uri8.h>
 
 // ---------------------------------------------------------
 // CCookieGroupData::NewL
@@ -122,9 +123,29 @@
     {
     CLOG(( EClient, 0, _L("-> RCookieManager::StoreCookieAtClientSideL: aUri:%S"), &aUri ));
     //Creates a clone of the passed cookie objects as the ownership of this object is held by Clint of Cookie Manager Dll
+    TUriParser8 uriParser;
     
-    CCookie* clone = CCookie::CloneL( *aCookie );
-    CleanupStack::PushL( clone );
+    TInt err = uriParser.Parse( aUri );
+    CCookie* clone(NULL);
+    if (err !=KErrNone)
+        return;
+    else
+        {
+        // first get the details of the current requestUri,
+        // that is, Domain, Path and port
+        TPtrC8 requestPath( uriParser.IsPresent( EUriPath ) ?
+                            uriParser.Extract( EUriPath ) : KNullDesC8() );
+        TPtrC8 requestDomain( uriParser.IsPresent( EUriHost ) ?
+                            uriParser.Extract( EUriHost ) : KNullDesC8() );
+        TPtrC8 requestPort( uriParser.IsPresent( EUriPort ) ?
+                uriParser.Extract( EUriPort ) : KCookieDefaultRequestPort() );
+
+        clone = CCookie::CloneL( *aCookie,requestDomain,requestPath,requestPort);
+        CleanupStack::PushL( clone );
+        }
+
+    //CCookie* clone = CCookie::CloneL( *aCookie,requestDomain,requestPath);
+    //CleanupStack::PushL( clone );
   
     TInt index(0);
     CCookieArray* perscookiearray = CookieArray();
--- a/netprotocols_plat/cookie_manager_api/inc/cookie.h	Wed Jun 09 10:16:57 2010 +0300
+++ b/netprotocols_plat/cookie_manager_api/inc/cookie.h	Mon Jun 21 16:17:02 2010 +0300
@@ -30,7 +30,7 @@
 
 class RHTTPHeaders;
 class TUriC8;
-
+class TDesC8;
 // CONSTANTS
 
 // Attribute prefix : we have to pack cookies when either passing them over
@@ -240,7 +240,7 @@
         * Copy from an already existing one.
         * @param aCopyFrom The already existing CCookie object
         */
-        void CopyFromL( const CCookie& aCopyFrom  );
+        void CopyFromL( const CCookie& aCopyFrom, const TDesC8& aDomain, const TDesC8& aPath, const TDesC8& aPort  );
 
         /**
         * Returns this cookie's StringPool.
@@ -267,7 +267,7 @@
         * @return TBool indicating the cookies's Version attribute's notoriety.
         */
         TBool IsUnknownVersion() const;
-        static CCookie* CloneL( const CCookie& aCopy );
+        static CCookie* CloneL( const CCookie& aCopy,const TDesC8& aDomain, const TDesC8& aPath, const TDesC8& aPort);
 
 	private :	// class for internal use
         /**