Catchup to latest Symbian^4 GCC_SURGE
authorWilliam Roberts <williamr@symbian.org>
Thu, 22 Jul 2010 16:38:27 +0100
branchGCC_SURGE
changeset 32 0713fb089b10
parent 24 2af57effcf41 (current diff)
parent 28 dd1f62411ef8 (diff)
Catchup to latest Symbian^4
httpfilters/cookie/Group/CookieManager.mmp
--- a/applayerpluginsandutils/bookmarksupport/test/Integration/TestBookmarksSuite/bld.inf	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerpluginsandutils/bookmarksupport/test/Integration/TestBookmarksSuite/bld.inf	Thu Jul 22 16:38:27 2010 +0100
@@ -21,28 +21,28 @@
 PRJ_TESTEXPORTS
 
 // Main Script file
-TestBookmarksSuite.script		C:\TestData\Scripts\TestBookmarksSuite.script
+TestBookmarksSuite.script		c:/testdata/scripts/testbookmarkssuite.script
 // Main ini file
-TestBookmarksSuite.ini			C:\TestData\Ini\TestBookmarksSuite.ini
+TestBookmarksSuite.ini			c:/testdata/ini/testbookmarkssuite.ini
 // Main Bat file to help running the tests
-TestBookmarksSuite.bat			\epoc32\tools\TestBookmarksSuite.bat
+TestBookmarksSuite.bat			/epoc32/tools/testbookmarkssuite.bat
 
 // Security tests scripts
-TestBookmarksSuite_Security.script	C:\TestData\Scripts\TestBookmarksSuite_Security.script
-Preliminary.script			C:\TestData\Scripts\Preliminary.script
-Cleanup.script				C:\TestData\Scripts\Cleanup.script
-Cap_00000000_TestBookmarks.script	C:\TestData\Scripts\Cap_00000000_TestBookmarks.script
-Cap_00000010_TestBookmarks.script	C:\TestData\Scripts\Cap_00000010_TestBookmarks.script
-Cap_00000020_TestBookmarks.script	C:\TestData\Scripts\Cap_00000020_TestBookmarks.script
-Cap_00008000_TestBookmarks.script	C:\TestData\Scripts\Cap_00008000_TestBookmarks.script
-Cap_00010000_TestBookmarks.script	C:\TestData\Scripts\Cap_00010000_TestBookmarks.script
-Cap_00018000_TestBookmarks.script	C:\TestData\Scripts\Cap_00018000_TestBookmarks.script
+TestBookmarksSuite_Security.script	c:/testdata/scripts/testbookmarkssuite_security.script
+Preliminary.script			c:/testdata/scripts/preliminary.script
+Cleanup.script				c:/testdata/scripts/cleanup.script
+Cap_00000000_TestBookmarks.script	c:/testdata/scripts/cap_00000000_testbookmarks.script
+Cap_00000010_TestBookmarks.script	c:/testdata/scripts/cap_00000010_testbookmarks.script
+Cap_00000020_TestBookmarks.script	c:/testdata/scripts/cap_00000020_testbookmarks.script
+Cap_00008000_TestBookmarks.script	c:/testdata/scripts/cap_00008000_testbookmarks.script
+Cap_00010000_TestBookmarks.script	c:/testdata/scripts/cap_00010000_testbookmarks.script
+Cap_00018000_TestBookmarks.script	c:/testdata/scripts/cap_00018000_testbookmarks.script
 
 // Security tests ini
-TestBookmarksSuite_Security.ini		C:\TestData\Ini\TestBookmarksSuite_Security.ini
+TestBookmarksSuite_Security.ini		c:/testdata/ini/testbookmarkssuite_security.ini
 
 // Security tests bat file
-TestBookmarksSuite_Security.bat		\epoc32\tools\TestBookmarksSuite_Security.bat
+TestBookmarksSuite_Security.bat		/epoc32/tools/testbookmarkssuite_security.bat
 
 // IBY file for H/W
-TestBookmarksSuite.IBY			\epoc32\rom\include\TestBookmarksSuite.IBY
+TestBookmarksSuite.IBY			/epoc32/rom/include/testbookmarkssuite.iby
--- a/applayerpluginsandutils/httpprotocolplugins/httpclient/chttprequestbatcher.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerpluginsandutils/httpprotocolplugins/httpclient/chttprequestbatcher.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -316,9 +316,12 @@
 	return iObserver->SendTimeOutVal();
 	}
 
-void CHttpRequestBatcher::SetTCPCorking(TBool /* aValue */)
+void CHttpRequestBatcher::SetTCPCorking(TBool  aValue )
     {
-    
+    if (iOutputStream)
+            {
+            iOutputStream->SetTCPCorking(aValue);
+            }
     }
 
 
--- a/applayerpluginsandutils/httpprotocolplugins/httpheadercodec/chttpgeneralheaderwriter.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerpluginsandutils/httpprotocolplugins/httpheadercodec/chttpgeneralheaderwriter.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -22,6 +22,7 @@
 #include "CHeaderField.h"
 
 _LIT8(KSemiSpaceSep,"; ");
+_LIT8(KCommaSpaceSep,", ");
 
 CHttpGeneralHeaderWriter* CHttpGeneralHeaderWriter::NewL(RStringPool aStringPool)
 /** 
@@ -91,7 +92,53 @@
 				directly
 */
 	{
-	DoTokenCsvListHeaderL(aHeader, KErrHttpEncodeCacheControl);
+	THeaderFieldPartIter iter = aHeader.PartsL();
+    iter.First();
+	if (iter.AtEnd())
+	   User::Leave(KErrHttpEncodeCacheControl);
+	
+	aHeader.BeginRawDataL();
+	do
+	    {
+	    const CHeaderFieldPart* part = iter();
+	    if(part == NULL)
+	        User::Leave(KErrHttpEncodeCacheControl);	    
+	    THTTPHdrVal ptVal = part->Value();
+	    if (ptVal.Type() != THTTPHdrVal::KStrFVal)
+	        User::Leave(KErrHttpEncodeCacheControl);
+	    const TDesC8& val = ptVal.StrF().DesC(); 
+	    if(val.Length() > 0)
+	        {
+	        aHeader.WriteRawDataL(val);
+	        }
+	    else
+	        {
+	        // Now we must have part as the strF value is KNulLDesC8
+	        THeaderFieldParamIter iter2 = part->Parameters();
+	        if(!iter2.AtEnd())
+	            {
+	            const CHeaderFieldParam* param = iter2();
+	            aHeader.WriteRawDataL(param->Name().DesC());
+	            aHeader.WriteRawDataL('=');
+	            THTTPHdrVal val2 = param->Value();
+	            if(val2.Type() == THTTPHdrVal::KTIntVal)
+	                {
+	                TBuf8<32> desc;
+	                desc.AppendNum(val2.Int());
+	                aHeader.WriteRawDataL(desc);
+	                }
+	            else if(val2.Type() == THTTPHdrVal::KStrFVal)
+	                {
+	                aHeader.WriteRawDataL(param->Name().DesC());
+	                }	            
+	            }
+	        }
+	    ++iter;
+	    if(!iter.AtEnd())
+	        aHeader.WriteRawDataL(KCommaSpaceSep());
+	    
+	    }while(!iter.AtEnd());
+	aHeader.CommitRawData();
 	}
 
 void CHttpGeneralHeaderWriter::EncodeConnectionL(RHeaderField& aHeader) const
--- a/applayerpluginsandutils/httptransportplugins/httptransporthandler/csocket.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerpluginsandutils/httptransportplugins/httptransporthandler/csocket.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -43,6 +43,21 @@
 	return self;
 	}
 
+CSocket* CSocket::New(MCommsInfoProvider& aCommsInfoProvider, TSocketType aSocketType)
+    {
+    CSocket* self = new CSocket(aCommsInfoProvider);
+    if(self)
+        {
+        TInt error = self->Construct(aSocketType);
+        if(error != KErrNone)
+            {
+            delete self;
+            self = NULL;
+            }
+        }
+    return self;
+    }
+
 CSocket::~CSocket()
 /**
 	Destructor.
@@ -70,54 +85,62 @@
 	@param		aSocketType	The type of the socket.
 */
 	{
-	switch( aSocketType )
-		{
-	case EProtocolSocket:
-		{
-		if ( iCommsInfoProvider.HasConnection() )
-			{
-			// Open a protocol socket with a RConnection
-			User::LeaveIfError(iSocket.Open(
-										   iCommsInfoProvider.SocketServer(),
-										   iCommsInfoProvider.ProtocolDescription().iAddrFamily, 
-										   iCommsInfoProvider.ProtocolDescription().iSockType, 
-										   iCommsInfoProvider.ProtocolDescription().iProtocol,
-										   iCommsInfoProvider.Connection()
-										   ));				
-			}
-		else
-			{
-			// Open a protocol socket without a RConnection, we don't need one ( Loopback address )
-			User::LeaveIfError(iSocket.Open(
-										   iCommsInfoProvider.SocketServer(),
-										   iCommsInfoProvider.ProtocolDescription().iAddrFamily, 
-										   iCommsInfoProvider.ProtocolDescription().iSockType, 
-										   iCommsInfoProvider.ProtocolDescription().iProtocol
-										   ));											
-			}
-		} break;
-	case EBlankSocket:
-		{
-		// Open a blank socket
-		User::LeaveIfError(iSocket.Open(iCommsInfoProvider.SocketServer()));
-		} break;
-	default:
-		User::Invariant();
-		}
-	TInt id = iCommsInfoProvider.SessionId();
-	if(id>=0) 
-		{
-		// set socket option
-		iSocket.SetOpt(KSOHttpSessionId, KSOLHttpSessionInfo, id);
-		iSocket.SetOpt(KSoTcpKeepAlive, KSolInetTcp, KTcpTriggeredKeepAlive);
-		}
-	if(aSocketType != EBlankSocket)
-	    {
-	    iSocket.SetOpt(KSoTcpNoDelay,KSolInetTcp,1);  // Disable the nagle.
-        iSocket.SetOpt(KSORecvBuf, KSOLSocket, KSocketRecvBufSize); // Set the socket recv buf to be 16K
-	    }
+    User::LeaveIfError(Construct(aSocketType));
 	}
 
+TInt CSocket::Construct(TSocketType aSocketType)
+    {
+    TInt error = KErrNone;
+    switch( aSocketType )
+        {
+    case EProtocolSocket:
+        {
+        if ( iCommsInfoProvider.HasConnection() )
+            {
+            // Open a protocol socket with a RConnection
+            error = iSocket.Open(iCommsInfoProvider.SocketServer(),
+                                 iCommsInfoProvider.ProtocolDescription().iAddrFamily, 
+                                 iCommsInfoProvider.ProtocolDescription().iSockType, 
+                                 iCommsInfoProvider.ProtocolDescription().iProtocol,
+                                 iCommsInfoProvider.Connection()
+                                 );              
+            }
+        else
+            {
+            // Open a protocol socket without a RConnection, we don't need one ( Loopback address )
+            error = iSocket.Open(iCommsInfoProvider.SocketServer(),
+                                 iCommsInfoProvider.ProtocolDescription().iAddrFamily, 
+                                 iCommsInfoProvider.ProtocolDescription().iSockType, 
+                                 iCommsInfoProvider.ProtocolDescription().iProtocol
+                                 );                                          
+            }
+        } break;
+    case EBlankSocket:
+        {
+        // Open a blank socket
+        error = iSocket.Open(iCommsInfoProvider.SocketServer());
+        } break;
+    default:
+        User::Invariant();
+        }
+    if(error == KErrNone)
+        {
+        TInt id = iCommsInfoProvider.SessionId();
+        if(id>=0) 
+            {
+            // set socket option
+            iSocket.SetOpt(KSOHttpSessionId, KSOLHttpSessionInfo, id);
+            iSocket.SetOpt(KSoTcpKeepAlive, KSolInetTcp, KTcpTriggeredKeepAlive);
+            }
+        if(aSocketType != EBlankSocket)
+            {
+            iSocket.SetOpt(KSoTcpNoDelay,KSolInetTcp,1);  // Disable the nagle.
+            iSocket.SetOpt(KSORecvBuf, KSOLSocket, KSocketRecvBufSize); // Set the socket recv buf to be 16K
+            }
+        }
+    return error;
+    }
+
 TInt CSocket::Listen(TUint aQSize, TUint16 aPort)
 /**	
 	Start the listen service. The socket is bound to the local port specified by
--- a/applayerpluginsandutils/httptransportplugins/httptransporthandler/csocket.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerpluginsandutils/httptransportplugins/httptransporthandler/csocket.h	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -51,7 +51,9 @@
 public:	// methods
 
 	static CSocket* NewL(MCommsInfoProvider& aCommsInfoProvider, TSocketType aSocketType);
-
+	
+	static CSocket* New(MCommsInfoProvider& aCommsInfoProvider, TSocketType aSocketType);
+	
 	virtual ~CSocket();
 
 	TInt Listen(TUint aQSize, TUint16 aPort);
@@ -97,7 +99,8 @@
 	CSocket(MCommsInfoProvider& aCommsInfoProvider);
 
 	void ConstructL(TSocketType aSocketType);
-
+	
+	TInt Construct(TSocketType aSocketType);
 private:
 
 /**	The comms info provider
--- a/applayerpluginsandutils/httptransportplugins/httptransporthandler/csocketconnector.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerpluginsandutils/httptransportplugins/httptransporthandler/csocketconnector.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -55,7 +55,6 @@
 	// Cleanup...
 	delete iHost;
 	delete iConnectingSocket;
-	iHostResolver.Close();
 
 //	__FLOG_CLOSE;
 	}
@@ -104,20 +103,33 @@
 	iHost = HBufC::NewL(aRemoteHost.Length());
 	iHost->Des().Copy(aRemoteHost);
 	iPort = aRemotePort;
-
+		
+	TInt error = KErrNone;
     // Move to the PendingDNSLookup state and self complete.
     if(aRemoteAddress == NULL)
         {
+        RDebug::Printf("RemoteAddress is NULL so doing a DNS lookup");
+        iState = EPendingDNSLookup;
         // Address is unknown / DNS lookup is needed
-        iState = EPendingDNSLookup;
+        error = DoPendingDNSLookup();
         }
     else
         {
+        RDebug::Printf("Remote address is known so doing a direct connect");
+        iState = EConnecting;
         // Address is know. No lookup is needed. Just go and connect.
         iHostDnsEntry().iAddr = *aRemoteAddress;
-        iState = EConnecting;
+        error = DoConnect();
         }
-	CompleteSelf();
+    
+    if(error != KErrNone)
+        {
+        iState = EPendingDNSLookup;
+        // Error the AO and handle the error in the normal path.
+        TRequestStatus* pStat = &iStatus;
+        User::RequestComplete(pStat, error);
+        SetActive();      
+        }
 	}
 
 void CSocketConnector::CompleteSelf()
@@ -193,80 +205,11 @@
 		{
 	case EPendingDNSLookup:
 		{
-#if defined (_DEBUG) && defined (_LOGGING)
-		TBuf8<KHostNameSize> host;
-		host.Copy((*iHost).Left(KHostNameSize)); //just get the KHostNameSize characters
-
-		__FLOG_1(_T8("Doing DNS lookup -> searching for host %S"), &host);
-#endif
-
-		__OOM_LEAVE_TEST
-
-		if ( iCommsInfoProvider.HasConnection() )
-			{
-			// Open the host resolver session with the preffered connection
-			User::LeaveIfError(iHostResolver.Open(
-												 iCommsInfoProvider.SocketServer(),
-												 iCommsInfoProvider.ProtocolDescription().iAddrFamily, 
-												 KProtocolInetUdp,
-												 iCommsInfoProvider.Connection()
-												 ));				
-			}
-		else
-			{							
-			// Open the host resolver session with no connection
-			User::LeaveIfError(iHostResolver.Open(
-												 iCommsInfoProvider.SocketServer(),
-												 iCommsInfoProvider.ProtocolDescription().iAddrFamily, 
-												 KProtocolInetUdp
-												 ));				
-			}
-
-		// Start the DNS lookup for the remote host name.
-		iHostResolver.GetByName(*iHost, iHostDnsEntry, iStatus);
-
-		// Move to the Connecting state and go active
-		iState = EConnecting;
-		SetActive();
+		User::LeaveIfError(DoPendingDNSLookup());
 		} break;
 	case EConnecting:
 		{
-		__OOM_LEAVE_TEST
-
-		// DNS lookup successful - form the internet address object
-		iAddress = TInetAddr(iHostDnsEntry().iAddr);
-		iAddress.SetPort(iPort);
-
-#if defined (_DEBUG) && defined (_LOGGING)
-		TBuf8<KHostNameSize> host;
-		host.Copy((*iHost).Left(KHostNameSize)); //just get the KHostNameSize characters
-
-		TBuf<KIpv6MaxAddrSize> ip16bit;
-		iAddress.Output(ip16bit);
-
-		TBuf8<KIpv6MaxAddrSize> ip;
-		ip.Copy(ip16bit);
-		
-		__FLOG_2(_T8("DNS lookup complete -> host %S has IP address %S"), &host, &ip);
-#endif
-		
-		// Start a default RConnection, if one is not started and not local loopback address		
-		if ( !iCommsInfoProvider.HasConnection() && !iAddress.IsLoopback() )
-			{
-			iCommsInfoProvider.StartDefaultCommsConnectionL ();				
-			}
-
-		// Create the connecting socket
-		iConnectingSocket = CSocket::NewL(iCommsInfoProvider, CSocket::EProtocolSocket);
-
-		// Start connecting to the remote client
-		iConnectingSocket->Connect(iAddress, iStatus);
-
-		__FLOG_2(_T8("Connecting -> to host %S on IP address %S"), &host, &ip);
-
-		// Move to the Connected state and go active
-		iState = EConnected;
-		SetActive();
+		User::LeaveIfError(DoConnect());
 		} break;
 	case EConnected:
 		{
@@ -334,6 +277,7 @@
 		{
 		// DNS lookup is pending - cancel
 		iHostResolver.Cancel();
+		iCommsInfoProvider.AddToHostResolverCache(iHostResolver); // Add to the cache.
 		} break;
 	case EConnected:
 		{
@@ -431,3 +375,103 @@
 
 	return error;
 	}
+
+TInt CSocketConnector::DoPendingDNSLookup()
+    {
+#if defined (_DEBUG) && defined (_LOGGING)
+        TBuf8<KHostNameSize> host;
+        host.Copy((*iHost).Left(KHostNameSize)); //just get the KHostNameSize characters
+
+        __FLOG_1(_T8("Doing DNS lookup -> searching for host %S"), &host);
+#endif        
+     TInt error = KErrNone;
+     
+     iCommsInfoProvider.HostResolverFromCache(iHostResolver); // Get the RHostResolver from the cache
+     if(iHostResolver.SubSessionHandle() <= 0)
+         {
+         RDebug::Printf("No host resolver. Open a new one...");
+         if ( iCommsInfoProvider.HasConnection() )
+            {
+            // Open the host resolver session with the preffered connection
+            error = iHostResolver.Open(iCommsInfoProvider.SocketServer(),
+                                       iCommsInfoProvider.ProtocolDescription().iAddrFamily, 
+                                       KProtocolInetUdp,
+                                       iCommsInfoProvider.Connection());                
+             }
+          else
+            {                           
+            // Open the host resolver session with no connection
+            error = iHostResolver.Open(iCommsInfoProvider.SocketServer(),
+                                       iCommsInfoProvider.ProtocolDescription().iAddrFamily, 
+                                       KProtocolInetUdp);                
+            }
+         }
+     
+     if(error != KErrNone)
+        {
+        return error;
+        }
+        
+    // Start the DNS lookup for the remote host name.
+    iHostResolver.GetByName(*iHost, iHostDnsEntry, iStatus);
+
+    // Move to the Connecting state and go active
+    iState = EConnecting;
+    SetActive();    
+    return error;
+    }
+
+TInt CSocketConnector::DoConnect()
+    {
+    // DNS lookup successful - form the internet address object
+    iAddress = TInetAddr(iHostDnsEntry().iAddr);
+    iAddress.SetPort(iPort);
+    
+    // Add the RHostResolver to the cache.
+    if(iHostResolver.SubSessionHandle() > 0)
+        {
+        iCommsInfoProvider.AddToHostResolverCache(iHostResolver);
+        }
+    
+#if defined (_DEBUG) && defined (_LOGGING)
+    TBuf8<KHostNameSize> host;
+    host.Copy((*iHost).Left(KHostNameSize)); //just get the KHostNameSize characters
+
+    TBuf<KIpv6MaxAddrSize> ip16bit;
+    iAddress.Output(ip16bit);
+
+    TBuf8<KIpv6MaxAddrSize> ip;
+    ip.Copy(ip16bit);
+    
+    __FLOG_2(_T8("DNS lookup complete -> host %S has IP address %S"), &host, &ip);
+#endif
+   
+    // Start a default RConnection, if one is not started and not local loopback address        
+    if ( !iCommsInfoProvider.HasConnection() && !iAddress.IsLoopback() )
+        {
+        // it is ok to TRAP here as the method will be called only once.
+        TRAPD(error, iCommsInfoProvider.StartDefaultCommsConnectionL ());
+        if(error != KErrNone)
+            {
+            return error;
+            }
+        }
+
+    // Create the connecting socket
+    iConnectingSocket = CSocket::New(iCommsInfoProvider, CSocket::EProtocolSocket);
+    if(!iConnectingSocket)
+        {
+        return KErrNoMemory;
+        }
+    
+    // Start connecting to the remote client
+    iConnectingSocket->Connect(iAddress, iStatus);
+    SetActive();
+    __FLOG_2(_T8("Connecting -> to host %S on IP address %S"), &host, &ip);
+
+    // Move to the Connected state and go active
+    iState = EConnected;
+    return KErrNone;
+    }
+
+
--- a/applayerpluginsandutils/httptransportplugins/httptransporthandler/csocketconnector.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerpluginsandutils/httptransportplugins/httptransporthandler/csocketconnector.h	Thu Jul 22 16:38:27 2010 +0100
@@ -101,7 +101,9 @@
 	void CompleteSelf();
 
 	void Suicide();
-
+	
+	TInt DoPendingDNSLookup();
+	TInt DoConnect();
 private:	// enums
 
 /**	
--- a/applayerpluginsandutils/httptransportplugins/httptransporthandler/ctcptransportlayer.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerpluginsandutils/httptransportplugins/httptransporthandler/ctcptransportlayer.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2001-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -25,6 +25,9 @@
 
 _LIT(KTcpProtName, "tcp");
 
+const TInt KMaxHostResolverCacheCount = 8; // 8 Should be sufficient here as we can have maximum of 8 connections
+                                           // at anytime to the host. And it is not neccassarly mean that 8 host resolvers
+                                           // will be operating simulataneously. 
 CTcpTransportLayer* CTcpTransportLayer::NewL(TAny* aTransportConstructionParams)
 /**	
 	The factory constructor.
@@ -54,7 +57,12 @@
 
 	// Delete the socket controllers
 	iControllerStore.ResetAndDestroy();
-
+	
+	
+	// Empty and close the host resolver cache.
+	EmptyHostResolverCache();
+	iHostResolverCache.Close();
+	
 	// Close the socket server session if owned
 	if( iOwnsConnection )
 		{
@@ -73,7 +81,7 @@
 	}
 
 CTcpTransportLayer::CTcpTransportLayer(MConnectionPrefsProvider& aTransLayerObserver)
-: CHttpTransportLayer(), iConnectionPrefsProvider(aTransLayerObserver)
+: CHttpTransportLayer(), iConnectionPrefsProvider(aTransLayerObserver), iHostResolverCache(KMaxHostResolverCacheCount)
 /**	
 	Constructor.
 */
@@ -191,6 +199,7 @@
                     // Socket and controller will be deleted by itself
                     }
                 iConnectorStore.ResetAndDestroy();
+                EmptyHostResolverCacheIfNeeded();
                 }
             }	        
         }		
@@ -332,6 +341,9 @@
 	// Remove the socket connector from the store and compress the store.
 	iConnectorStore.Remove(index);
 	iConnectorStore.Compress();
+	
+	// Empty the host resolver cache if needed
+	EmptyHostResolverCacheIfNeeded();
 	}
 
 /*
@@ -355,6 +367,9 @@
 	// Remove the socket controller from the store and compress the store.
 	iControllerStore.Remove(index);
 	iControllerStore.Compress();
+	
+   // Empty the host resolver cache if needed
+    EmptyHostResolverCacheIfNeeded();
 	}
 
 /*
@@ -474,4 +489,48 @@
 	return ( iConnection != NULL );
 	}
 
+void CTcpTransportLayer::HostResolverFromCache(RHostResolver& aResolver)
+    {
+    TInt count = iHostResolverCache.Count();
+    if(count > 0)
+        {
+        RDebug::Printf("Returning the host resolver from cache...");
+        // Returns the last host resolver that is added
+        aResolver = iHostResolverCache[count - 1];
+        iHostResolverCache.Remove(count - 1); // Remove from the cache.        
+        }
+    }
 
+void CTcpTransportLayer::AddToHostResolverCache(RHostResolver& aResolver)
+    {
+    if(iHostResolverCache.Append(aResolver) != KErrNone)
+        {
+        aResolver.Close();
+        }
+    }
+
+void CTcpTransportLayer::EmptyHostResolverCacheIfNeeded()
+    {
+    // Remove the host resolver if
+    // 1/ if the Connector store is empty and
+    // 2/ if the socket controller is empty
+    // This is important to get the mobility and one click connectivity cases working
+    // Otherwise the inconsistent behaviour will result as the RConnection & RSocketServ can be handled
+    // entirely outside of the HTTP stack, ie; from the application
+    if(iConnectorStore.Count() == 0 && iControllerStore.Count() == 0)
+        {
+        EmptyHostResolverCache();
+        }
+    }
+
+void CTcpTransportLayer::EmptyHostResolverCache()
+    {
+    TInt count = iHostResolverCache.Count();
+    while(count > 0)
+        {
+        // Close the RHostResolver and remove from the array
+        iHostResolverCache[count - 1].Close();
+        iHostResolverCache.Remove(--count);
+        }
+    iHostResolverCache.Compress();
+    }
--- a/applayerpluginsandutils/httptransportplugins/httptransporthandler/ctcptransportlayer.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerpluginsandutils/httptransportplugins/httptransporthandler/ctcptransportlayer.h	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -103,7 +103,11 @@
 
 	virtual TBool HasConnection();
 	
-	void StartDefaultCommsConnectionL ();
+	virtual void StartDefaultCommsConnectionL ();
+
+	virtual void HostResolverFromCache(RHostResolver& aResolver);
+	
+	virtual void AddToHostResolverCache(RHostResolver& aResolver);
 
 private:	// methods
 
@@ -119,6 +123,10 @@
 
 	inline MCommsInfoProvider& CommsInfoProvider();
 	
+	void EmptyHostResolverCacheIfNeeded();
+	
+	void EmptyHostResolverCache();
+	
 private:	// attributes
 
 /** The connection preferences provider
@@ -157,6 +165,8 @@
 */
 	RPointerArray<CSocketController>	iControllerStore;
 	
+	RArray<RHostResolver>               iHostResolverCache;
+	
 	TBool iPriority;
 
 /** Logger handle
--- a/applayerpluginsandutils/httptransportplugins/httptransporthandler/mcommsinfoprovider.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerpluginsandutils/httptransportplugins/httptransporthandler/mcommsinfoprovider.h	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -78,6 +78,17 @@
 	Starts a default RConnection
 	*/
 	virtual void StartDefaultCommsConnectionL () =0;
+	
+	/**
+	 Returns the RHostResolver if available in cache.
+	 */
+	virtual void HostResolverFromCache(RHostResolver& aResolver) =0;
+	
+	/**
+	 Add the RHostResolver to cache. If the adding fails then the RHostResolver will be
+	 closed
+	 */
+	virtual void AddToHostResolverCache(RHostResolver& aResolver) =0;
 	};
 
 #endif	// __MCOMMSINFOPROVIDER_H__
--- a/applayerpluginsandutils/uripermissionservices/Test/tineturilistserverunit.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerpluginsandutils/uripermissionservices/Test/tineturilistserverunit.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -100,11 +100,11 @@
 	RSqlDatabase::Delete ( KDatabaseName() );		
 	}
 
-LOCAL_C void TestUriListInitializerL ()
+/*LOCAL_C void TestUriListInitializerL ()
 	{
 	gListInterface = CUriListInterface::NewL ();
 //	delete listInterface;
-	}
+	}*/
 
 LOCAL_C CInetUriImpl* CreateUriL ( const TDesC8& aUri, TListType aListType, const TDesC8& aFavouriteName )
 	{
@@ -183,10 +183,10 @@
 	return uri;	
 	}
 
-LOCAL_C void CountUriL ()
+/*LOCAL_C void CountUriL ()
 	{
 	gTestWrapper->TEST ( gListInterface->CountUriL ( InetUriList::EBrowser, InetUriList::EWhiteList ) == 1 );
-	}
+	}*/
 	
 LOCAL_C void MatchUris ( const CInetUriImpl& aUri, const CInetUriImpl& aUri2 )
 	{
@@ -240,10 +240,11 @@
 	RemoveTestL ( uri3, KErrNone );
 	CInetUriImpl* uri4 = NULL;
 	TRAP ( err, uri4 = OpenUriL ( KTestUri() ) );
+	CleanupStack::PushL ( uri4 );
 	__LEAVEIFOOM__
 	gTestWrapper->TEST ( err == KErrUriNotFound );
 	
-	CleanupStack::PopAndDestroy (4); //uri, uri2, uri3, gListInterface		
+	CleanupStack::PopAndDestroy (5); //uri, uri2, uri3, uri4, gListInterface		
 	}
 
 LOCAL_C void AddMoreUrisTestL ()
--- a/applayerpluginsandutils/uripermissionservices/group/tineturilistserverunit.mmp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerpluginsandutils/uripermissionservices/group/tineturilistserverunit.mmp	Thu Jul 22 16:38:27 2010 +0100
@@ -48,6 +48,8 @@
 SOURCE  tineturilistserverunit.cpp
 SOURCE	testutils.cpp
 
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
 SOURCEPATH	../server/src
 SOURCE 		sqldbaccessor.cpp
 SOURCE 		urilistinterface.cpp
--- a/applayerprotocols/httpservice/EABI/httpserviceu.def	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/EABI/httpserviceu.def	Thu Jul 22 16:38:27 2010 +0100
@@ -90,5 +90,11 @@
 	_ZTV17CHttpDataReceiver @ 89 NONAME
 	_ZTV22CHttpClientTransaction @ 90 NONAME
 	_ZTV26CHttpClientTransactionImpl @ 91 NONAME
-	
+	_ZN12CHttpService17SetAuthenticationEP26MHTTPServiceAuthentication @ 92 NONAME
+	_ZN12CHttpService21HttpNetworkConnectionEv @ 93 NONAME
+	_ZN22CHttpNetworkConnection4StopEv @ 94 NONAME
+	_ZN22CHttpNetworkConnection5StartE15TCommDbConnPrefi @ 95 NONAME
+	_ZN22CHttpNetworkConnection5StartEv @ 96 NONAME
+	_ZTI22CHttpNetworkConnection @ 97 NONAME
+	_ZTV22CHttpNetworkConnection @ 98 NONAME
 
--- a/applayerprotocols/httpservice/bwins/httpserviceU.def	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/bwins/httpserviceU.def	Thu Jul 22 16:38:27 2010 +0100
@@ -64,4 +64,9 @@
 	??0THttpHeaderElementIterator@@QAE@XZ @ 63 NONAME ; THttpHeaderElementIterator::THttpHeaderElementIterator(void)
 	?Parameter@THttpHeaderElementIterator@@QBE?AVTHttpHeaderParamIterator@@XZ @ 64 NONAME ; class THttpHeaderParamIterator THttpHeaderElementIterator::Parameter(void) const
 	?Notify@THttpContentSourceOp@@QAEXABVTDesC8@@H@Z @ 65 NONAME ; void THttpContentSourceOp::Notify(class TDesC8 const &, int)
-	
+	?SetAuthentication@CHttpService@@QAEHPAVMHTTPServiceAuthentication@@@Z @ 66 NONAME ; int CHttpService::SetAuthentication(class MHTTPServiceAuthentication *)
+	?Start@CHttpNetworkConnection@@QAEHVTCommDbConnPref@@H@Z @ 67 NONAME ; int CHttpNetworkConnection::Start(class TCommDbConnPref, int)
+	?HttpNetworkConnection@CHttpService@@QAEPAVCHttpNetworkConnection@@XZ @ 68 NONAME ; class CHttpNetworkConnection * CHttpService::HttpNetworkConnection(void)
+	?Stop@CHttpNetworkConnection@@QAEXXZ @ 69 NONAME ; void CHttpNetworkConnection::Stop(void)
+	?Start@CHttpNetworkConnection@@QAEHXZ @ 70 NONAME ; int CHttpNetworkConnection::Start(void)
+
--- a/applayerprotocols/httpservice/group/bld.inf	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/group/bld.inf	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -29,6 +29,8 @@
 
 // top-level includes
 ../inc/mhttpcontentsource.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(mhttpcontentsource.h)
+../inc/mhttpserviceauthentication.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(mhttpserviceauthentication.h)
+../inc/chttpnetworkconnectioninfo.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(chttpnetworkconnectioninfo.h)
 ../inc/mhttpcontentsink.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(mhttpcontentsink.h)
 ../inc/httpheaderiter.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(httpheaderiter.h)
 ../inc/chttpservice.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(chttpservice.h)
@@ -39,20 +41,20 @@
 
 // rom definition file
 httpservice.iby	/epoc32/rom/include/httpservice.iby
-../Test/Group/httpservicetest.iby	/epoc32/rom/include/httpservicetest.iby
+../test/group/httpservicetest.iby	/epoc32/rom/include/httpservicetest.iby
 
 PRJ_TESTEXPORTS
-../Test/testdata/scripts/HTTPServiceAPITest.script		c:/testdata/scripts/httpserviceapitest.script
-../Test/testdata/ini/httpclient.ini 				c:/httptest/httpservicetest/httpclient.ini
-../Test/testdata/configs/ethernetced_httpserviceapi.xml 		c:/testdata/configs/ethernetced_httpserviceapi.xml
-../Test/testdata/scripts/HTTPServiceAPITest.script		z:/testdata/scripts/httpserviceapitest.script
-../Test/testdata/ini/httpclient.ini 				z:/httptest/httpservicetest/httpclient.ini
-../Test/testdata/configs/ethernetced_httpserviceapi.xml 		z:/testdata/configs/ethernetced_httpserviceapi.xml
+../test/testdata/scripts/httpserviceapitest.script		c:/testdata/scripts/httpserviceapitest.script
+../test/testdata/ini/httpclient.ini 				c:/httptest/httpservicetest/httpclient.ini
+../test/testdata/configs/ethernetced_httpserviceapi.xml 		c:/testdata/configs/ethernetced_httpserviceapi.xml
+../test/testdata/scripts/httpserviceapitest.script		z:/testdata/scripts/httpserviceapitest.script
+../test/testdata/ini/httpclient.ini 				z:/httptest/httpservicetest/httpclient.ini
+../test/testdata/configs/ethernetced_httpserviceapi.xml 		z:/testdata/configs/ethernetced_httpserviceapi.xml
 
-../Test/testdata/httpservicetest/testdl.txt 			c:/httptest/httpservicetest/testdl.txt
-../Test/testdata/httpservicetest/testdl2.txt 			c:/httptest/httpservicetest/testdl2.txt
-../Test/testdata/httpservicetest/testdl.txt 			z:/httptest/httpservicetest/testdl.txt
-../Test/testdata/httpservicetest/testdl2.txt 			z:/httptest/httpservicetest/testdl2.txt
+../test/testdata/httpservicetest/testdl.txt 			c:/httptest/httpservicetest/testdl.txt
+../test/testdata/httpservicetest/testdl2.txt 			c:/httptest/httpservicetest/testdl2.txt
+../test/testdata/httpservicetest/testdl.txt 			z:/httptest/httpservicetest/testdl.txt
+../test/testdata/httpservicetest/testdl2.txt 			z:/httptest/httpservicetest/testdl2.txt
 
 
 PRJ_TESTMMPFILES
--- a/applayerprotocols/httpservice/group/httpservice.mmp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/group/httpservice.mmp	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -44,7 +44,7 @@
 SOURCE			chttpclienttransaction.cpp 
 SOURCE 			httpheaderiter.cpp
 SOURCE			httpclientutils.cpp chttpclienttransactionimpl.cpp
-SOURCE			chttpdatasender.cpp chttpdatareceiver.cpp chttpcontentreader.cpp chttpcontentwriter.cpp
+SOURCE			chttpdatasender.cpp chttpdatareceiver.cpp chttpcontentreader.cpp chttpcontentwriter.cpp chttpclientauthentication.cpp chttpnetworkconnectioninfo.cpp CConnectionMonitor.cpp
 
 LIBRARY			euser.lib
 LIBRARY			http.lib
@@ -53,6 +53,7 @@
 LIBRARY			inetprotutil.lib
 LIBRARY			bafl.lib
 LIBRARY 		efsrv.lib
+LIBRARY 		ecom.lib
 
 
 DEFFILE httpservice.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applayerprotocols/httpservice/inc/CConnectionMonitor.h	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,45 @@
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+#ifndef CCONNECTIONMONITOR_H_
+#define CCONNECTIONMONITOR_H_
+class CHttpNetworkConnection;
+
+NONSHARABLE_CLASS ( CConnectionMonitor ): public CActive
+    {
+    friend class CHttpNetworkConnection;
+    public:
+        static CConnectionMonitor* NewL( CHttpNetworkConnection* aNetworkConn );
+        static CConnectionMonitor* NewLC(CHttpNetworkConnection* aNetworkConn );
+        ~CConnectionMonitor();
+        void HandleConnectionEvent(TInt aEvent);
+
+
+    protected: // from CActive
+        void DoCancel();
+        void RunL();
+    
+    private:
+        CConnectionMonitor( CHttpNetworkConnection* aNetworkConn );
+        void ConstructL();
+        RConnection Connection() ;
+         
+    private:
+        TNifProgressBuf iProgress;
+        CHttpNetworkConnection* iNetworkConnInfo;
+    
+    
+    };
+
+#endif /* CCONNECTIONMONITOR_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applayerprotocols/httpservice/inc/chttpclientauthentication.h	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,42 @@
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#ifndef __CHTTPCLIENTAUTHENTICATION_H__
+#define __CHTTPCLIENTAUTHENTICATION_H__
+
+#include <e32base.h>
+#include <http/mhttpauthenticationcallback.h>
+class MHTTPServiceAuthentication;
+
+NONSHARABLE_CLASS(CHttpClientAuthentication) : public CBase, public MHTTPAuthenticationCallback
+    {
+public:
+    static CHttpClientAuthentication* New(RHTTPSession aSesion, MHTTPServiceAuthentication* aCallback);
+
+// methods inherited from MHTTPAuthenticationCallback
+    virtual TBool GetCredentialsL(const TUriC8& aURI, RString aRealm, 
+                                 RStringF aAuthenticationType,
+                                 RString& aUsername, 
+                                 RString& aPassword);
+
+protected:
+    TInt Construct(RHTTPSession aSesion, MHTTPServiceAuthentication* aCallback);
+    void FillCredentialsL(RString& aRealm, RString& aUsername, RString& aPassword, RBuf8& aClientUsername, RBuf8& aClientPassword);
+private:
+    MHTTPServiceAuthentication* iHTTPServiceAuthentication;    
+    };
+
+#endif  __CHTTPCLIENTAUTHENTICATION_H__
--- a/applayerprotocols/httpservice/inc/chttpclienttransaction.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/inc/chttpclienttransaction.h	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -90,7 +90,7 @@
 	
 	private:
 	// Reserved for future use.
-	inline virtual void Reserved();
+	inline virtual void Reserved1();
 	inline virtual void Reserved2();
 	
 	protected:
@@ -101,11 +101,10 @@
 	CHttpClientTransactionImpl* iHttpClientTrans;
 	};
 
-// Reserved for future use.
-inline void CHttpClientTransaction::Reserved()
-	{
-	}
-	
+inline void CHttpClientTransaction::Reserved1()
+    {
+    }
+
 inline void CHttpClientTransaction::Reserved2()
 	{
 	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applayerprotocols/httpservice/inc/chttpnetworkconnectioninfo.h	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,71 @@
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef CHTTPNETWORKCONNECTIONINFO_H_
+#define CHTTPNETWORKCONNECTIONINFO_H_
+
+#include <commdbconnpref.h>
+#include <es_sock.h>
+#include "chttpservice.h"
+
+
+class CConnectionMonitor;
+
+class CHttpNetworkConnection: public CBase
+    {
+    friend class CHttpClientTransactionImpl;    
+    friend class CConnectionMonitor;
+    friend class CHttpService;
+    
+    public:
+        static CHttpNetworkConnection* New();
+        IMPORT_C TInt Start();//start on default connection
+        IMPORT_C TInt Start(TCommDbConnPref aConnPref, TBool aAttachType=EFalse);
+
+        IMPORT_C void Stop();
+        
+
+
+    private:
+        TInt SetupConnection();
+        void AssociateConnectionWithHttpSession();
+        void HandleConnectionEvent(TInt aEvent); //Called whenever there is a connection event
+        void SetHttpService(CHttpService* aService);
+        RConnection Connection()
+            {
+            return iConnInfo->iConnection;
+            }
+        CHttpNetworkConnection();
+        void ConstructL();
+    
+        ~CHttpNetworkConnection();
+
+    
+    private:
+        class CConnectionInfo: public CBase
+            {
+            public:
+            TBool           iConnectionStatus;
+            TBool           iAttach;
+            TCommDbConnPref iConnPref;
+            RConnection     iConnection;
+            RSocketServ     iSocketServ;
+            };
+        CConnectionMonitor* iConnectionMonitor;
+        CConnectionInfo*    iConnInfo;
+        CHttpService*       iHttpService;
+    };
+
+#endif /* CHTTPNETWORKCONNECTIONINFO_H_ */
--- a/applayerprotocols/httpservice/inc/chttpservice.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/inc/chttpservice.h	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -20,7 +20,7 @@
 #include <http.h>
 #include <in_sock.h>
 #include "httpheaderiter.h"
-
+class CHttpNetworkConnection;
 /**
  * CHttpService represent a handle to the HTTP service instance for a set of client 
  * HTTP transactions[a request and its equivalent response]. The application can 
@@ -31,10 +31,12 @@
  * @publishedAll
  * @prototype 
  */
-
+class CHttpClientAuthentication;
+class MHTTPServiceAuthentication; 
 class CHttpService : public CBase
 	{
 	friend class CHttpClientTransactionImpl;	
+	friend class CHttpNetworkConnection;
 	public:
 	
 	IMPORT_C static CHttpService* NewL();
@@ -54,16 +56,21 @@
 	IMPORT_C TInt AddRequestHeader(TInt aHeaderId, const THttpHeaderValueVariant& aHeaderValue);		
 	IMPORT_C TInt AddCustomRequestHeader(const TDesC8& aHeaderName, const TDesC8& aHeaderValue);
 	
+	IMPORT_C TInt SetAuthentication(MHTTPServiceAuthentication* aCallback);
+	
+	IMPORT_C CHttpNetworkConnection* HttpNetworkConnection();
 	
 	private:
 	CHttpService();
 	void ConstructL();	
 	
-	class CHttpServiceStruct : public CBase
+	NONSHARABLE_CLASS(CHttpServiceStruct) : public CBase
 		{
 		public:
-		RHTTPSession	 iHttpSession;
-		RHTTPHeaders     iSessionHeaders; 
+		    ~CHttpServiceStruct();
+		RHTTPSession                  iHttpSession;
+		RHTTPHeaders                  iSessionHeaders; 
+		CHttpClientAuthentication*    iHttpClientAuthentication;
 		};
 	private:
 	   RHTTPSession Session()
@@ -73,7 +80,7 @@
 	private:
 	
 	
-	   CHttpServiceStruct* iHttpServiceStruct; // Implementation struct
+	   CHttpServiceStruct*         iHttpServiceStruct; // Implementation struct
 	};
 
 #endif // __CHTTPSERVICE_H__
--- a/applayerprotocols/httpservice/inc/httpservice.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/inc/httpservice.h	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -23,5 +23,7 @@
 #include <chttpservice.h>
 #include <thttpheadervaluevariant.h>
 #include <chttpclienttransaction.h>
+#include <mhttpserviceauthentication.h>
+#include <chttpnetworkconnectioninfo.h>
 
 #endif // __MHTTPDATARECIVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applayerprotocols/httpservice/inc/mhttpserviceauthentication.h	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,40 @@
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file MHTTPServiceAuthentication.h
+ */
+
+#ifndef __MHTTPSERVICEAUTHENTICATION_H__
+#define __MHTTPSERVICEAUTHENTICATION_H__ 
+
+// System includes
+#include <e32base.h>
+
+class MHTTPServiceAuthentication
+/** 
+The mixin that needs to be implemented if authentication is to be
+supported. This supplies the username and password when they are
+needed for authentication.
+
+@publishedAll
+@released
+*/
+    {
+ public:
+     virtual TInt OnAuthentication(const TDesC8& aUri, const TDesC8& aRealm, const TDesC8& aType, RBuf8& aUsername, RBuf8& aPassword) = 0;
+    };
+
+#endif //   __MHTTPSERVICEAUTHENTICATION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applayerprotocols/httpservice/src/CConnectionMonitor.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,141 @@
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+#include <commdbconnpref.h>
+#include <es_sock.h>
+#include "CConnectionMonitor.h"
+#include "chttpnetworkconnectioninfo.h"
+
+CConnectionMonitor* CConnectionMonitor::NewL(CHttpNetworkConnection* aNetworkConn )
+    {
+    CConnectionMonitor* self = NewLC( aNetworkConn );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CConnectionMonitor* CConnectionMonitor::NewLC( CHttpNetworkConnection* aNetworkConn )
+    {
+    CConnectionMonitor* self = new (ELeave) CConnectionMonitor( aNetworkConn );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CConnectionMonitor::CConnectionMonitor( CHttpNetworkConnection* aNetworkConnInfo )
+: CActive(CActive::EPriorityStandard)
+    {
+    iNetworkConnInfo = aNetworkConnInfo;
+    CActiveScheduler::Add(this);        
+    }
+
+CConnectionMonitor::~CConnectionMonitor()
+    {
+    Cancel();
+    }
+
+RConnection CConnectionMonitor::Connection() 
+    {
+    return iNetworkConnInfo->Connection();
+    }
+    
+void CConnectionMonitor::ConstructL()
+    {
+    iNetworkConnInfo->Connection().ProgressNotification(iProgress, iStatus);
+    SetActive();
+    }
+
+void CConnectionMonitor::DoCancel()
+    {
+    iNetworkConnInfo->Connection().CancelProgressNotification();
+    }
+
+void CConnectionMonitor::RunL()
+    {
+  
+    
+    switch ( iProgress().iStage )
+        {
+        
+        // Connection closed
+        case KConnectionClosed:
+        case KLinkLayerClosed:
+            if (iNetworkConnInfo)
+                {
+                iNetworkConnInfo->HandleConnectionEvent( iProgress().iStage );
+                }
+            break;
+
+        case KConnectionUninitialised:
+            break;
+
+        case KStartingSelection:
+            break;
+
+        case KFinishedSelection:
+            if (iProgress().iError == KErrNone)
+                {
+                // The user successfully selected an IAP to be used
+                }
+            else
+                {
+                // The user pressed e.g. "Cancel" and did not select an IAP
+                }
+            break;
+
+        case KConnectionFailure:
+            break;
+
+        // Prepearing connection (e.g. dialing)
+        case KPsdStartingConfiguration:
+        case KPsdFinishedConfiguration:
+        case KCsdFinishedDialling:
+        case KCsdScanningScript:
+        case KCsdGettingLoginInfo:
+        case KCsdGotLoginInfo:
+            break;
+        
+        // Creating connection (e.g. GPRS activation)
+        case KCsdStartingConnect:
+        case KCsdFinishedConnect:
+            break;
+
+        // Starting log in
+        case KCsdStartingLogIn:
+            break;
+
+        // Finished login
+        case KCsdFinishedLogIn:
+            break;
+
+        // Connection open
+        case KConnectionOpen:
+        case KLinkLayerOpen:
+            break;
+            
+        // Connection blocked or suspended
+        case KDataTransferTemporarilyBlocked:
+            break;
+
+        // Hangup or GRPS deactivation
+        case KConnectionStartingClose:
+            break;
+
+        // Unhandled state
+        default:
+            break;
+        }
+
+    Connection().ProgressNotification(iProgress, iStatus);
+    SetActive();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applayerprotocols/httpservice/src/chttpclientauthentication.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,62 @@
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "chttpclientauthentication.h"
+#include "mhttpserviceauthentication.h"
+
+CHttpClientAuthentication* CHttpClientAuthentication::New(RHTTPSession aSesion, MHTTPServiceAuthentication* aCallback)
+    {
+    CHttpClientAuthentication* self = new CHttpClientAuthentication;
+    TInt err = self->Construct(aSesion, aCallback);
+    if(err != KErrNone)
+        {
+        delete self;
+        self = NULL;
+        }
+    return self;
+    }
+
+TInt CHttpClientAuthentication::Construct(RHTTPSession aSession, MHTTPServiceAuthentication* aCallback)
+    {      
+    // Install this class as the callback for authentication requests
+    TRAPD(err, InstallAuthenticationL(aSession));
+    iHTTPServiceAuthentication = aCallback;
+    return err;
+    }
+
+void CHttpClientAuthentication::FillCredentialsL(RString& aRealm, RString& aUsername, RString& aPassword, RBuf8& aClientUsername, RBuf8& aClientPassword)
+    {  
+    aUsername = aRealm.Pool().OpenStringL(aClientUsername);
+    aPassword = aRealm.Pool().OpenStringL(aClientPassword);
+    }
+
+TBool CHttpClientAuthentication::GetCredentialsL(const TUriC8& aURI, RString aRealm, 
+                                   RStringF aAuthenticationType,
+                                   RString& aUsername, 
+                                   RString& aPassword)
+    {
+    //User credentials
+    RBuf8 clientUsername;
+    RBuf8 clientPassword;    
+     
+    User::LeaveIfError(iHTTPServiceAuthentication->OnAuthentication(aURI.UriDes(), aRealm.DesC(), aAuthenticationType.DesC(), clientUsername, clientPassword));
+    
+    FillCredentialsL(aRealm, aUsername, aPassword, clientUsername, clientPassword);
+    
+    clientUsername.Close();
+    clientPassword.Close();    
+    
+    return ETrue;    
+    }
--- a/applayerprotocols/httpservice/src/chttpclienttransaction.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/src/chttpclienttransaction.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -16,8 +16,8 @@
 #include "chttpclienttransaction.h"
 #include "chttpclienttransactionimpl.h"
 #include "httpclientutils.h"
-#include "cheaders.h"
-#include "cheaderfield.h"
+#include "CHeaders.h"
+#include "CHeaderField.h"
 #include "mhttpdatareceiver.h"
 #include "mhttpdatasender.h"
 
--- a/applayerprotocols/httpservice/src/chttpclienttransactionimpl.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/src/chttpclienttransactionimpl.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -19,7 +19,7 @@
 #include "chttpservice.h"
 #include "chttpdatareceiver.h"
 #include "chttpdatasender.h"
-#include "cheaders.h"
+#include "CHeaders.h"
 
 CHttpClientTransactionImpl* CHttpClientTransactionImpl::NewL(CHttpService& aClient, CHttpClientTransaction& aTrans, const TDesC8& aMethod, const TDesC8& aUri)
 	{
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applayerprotocols/httpservice/src/chttpnetworkconnectioninfo.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,204 @@
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+#include  <httpservice.h>
+#include <es_enum.h>
+#include "CConnectionMonitor.h"
+
+
+CHttpNetworkConnection::CHttpNetworkConnection()
+    {
+    }
+
+CHttpNetworkConnection::~CHttpNetworkConnection()
+    {
+    if (iConnInfo)
+        {
+        iConnInfo->iConnection.Close();
+        iConnInfo->iSocketServ.Close();
+        delete iConnInfo;
+        }
+    if (iConnectionMonitor)
+        {
+        delete iConnectionMonitor;
+        }
+    }
+CHttpNetworkConnection* CHttpNetworkConnection::New( )
+    {
+    CHttpNetworkConnection* self = new (ELeave)  CHttpNetworkConnection() ;
+    self->ConstructL();
+    return self;
+    }
+
+void CHttpNetworkConnection::ConstructL()
+    {
+    iConnInfo = new (ELeave) CConnectionInfo();
+    }
+
+void CHttpNetworkConnection::SetHttpService(CHttpService *aService)
+    {
+    iHttpService = aService;
+    }
+
+/**
+ * Start the network connection for  HTTP transactions.
+ * Default connection prefernces will be used.
+ * 
+ * @return KErrNone if connection opening is successful, otherwise relevant errors.
+ */
+EXPORT_C TInt CHttpNetworkConnection::Start()
+    {
+    TRequestStatus requestStatus;
+    TInt status;
+    if (! iConnInfo->iConnectionStatus)
+        {
+        status = SetupConnection();
+        if (status == KErrNone)
+            {
+            iConnInfo->iConnection.Start( requestStatus);
+            User::WaitForRequest(requestStatus);
+            status = requestStatus.Int();
+            }
+        }
+    else
+        {
+        status = KErrAlreadyExists;
+        }
+    if (status == KErrNone)
+        {
+        AssociateConnectionWithHttpSession();
+        }
+    return status;
+    }
+
+/**
+ * Start the network connection for  HTTP transactions.
+ * 
+ * @param aConnPref - connection prefernces can be specified.
+ * @param aAttachType - EFalse 
+ * 
+ * @return KErrNoMemory incase of failure otherwise KErrNone for success
+ * 
+ */
+EXPORT_C TInt CHttpNetworkConnection::Start(TCommDbConnPref aConnPref, TBool aAttachType)
+    {
+    TInt status;
+    iConnInfo->iConnPref = aConnPref;
+
+    if (aAttachType && !iConnInfo->iConnectionStatus )
+        {
+        TUint count;
+        TConnectionInfoBuf connInfoPckg;
+        
+        status = SetupConnection();
+                
+        if ( status == KErrNone && iConnInfo->iConnection.EnumerateConnections(count) == KErrNone )
+            {
+            for (TUint i=1; i<=count; i++)
+                {
+                // Note  GetConnectionInfo expects 1-based index
+                if ( iConnInfo->iConnection.GetConnectionInfo( i, connInfoPckg ) == KErrNone )
+                    {
+                    if ( connInfoPckg().iIapId == iConnInfo->iConnPref.IapId() )
+                        {
+                        status= iConnInfo->iConnection.Attach(iConnInfo->iConnPref, RConnection::EAttachTypeNormal);
+                        return status;
+                        }
+                    }   
+                }
+            }
+        return KErrNotFound;
+        }
+    else
+        {
+        if (!iConnInfo->iConnectionStatus)
+            {
+            status = SetupConnection();
+            if (status == KErrNone)
+                {
+                TRequestStatus requestStatus;
+                iConnInfo->iConnection.Start(iConnInfo->iConnPref,requestStatus);
+                User::WaitForRequest(requestStatus);
+                status = requestStatus.Int();
+                }
+          
+            }
+        else
+            {
+            status = KErrAlreadyExists;
+            }
+        if (status == KErrNone)
+            {
+            AssociateConnectionWithHttpSession();
+            }
+        
+        return status;
+        }
+    }
+
+
+/**
+ * To Stop the network connection 
+ * 
+  */
+EXPORT_C void CHttpNetworkConnection::Stop()
+    {
+    if (iConnInfo->iConnectionStatus)
+        {
+        iConnInfo->iConnectionStatus = EFalse;
+        iConnInfo->iConnection.Close();
+        iConnInfo->iSocketServ.Close();
+        }
+    }
+
+void CHttpNetworkConnection::AssociateConnectionWithHttpSession()
+    {
+    RStringPool strP = iHttpService->Session().StringPool();
+    RHTTPConnectionInfo connInfo = iHttpService->Session().ConnectionInfo();
+    connInfo.SetProperty(strP.StringF(HTTP::EHttpSocketServ,RHTTPSession::GetTable()), THTTPHdrVal(iConnInfo->iSocketServ.Handle()));
+    TInt connPtr = reinterpret_cast<TInt>(&(iConnInfo->iConnection));
+    connInfo.SetProperty(strP.StringF(HTTP::EHttpSocketConnection,RHTTPSession::GetTable()), THTTPHdrVal(connPtr));
+    }
+
+TInt CHttpNetworkConnection::SetupConnection()
+    {
+    TInt status = KErrAlreadyExists;
+    if (!iConnInfo->iConnectionStatus )
+        {
+        status = iConnInfo->iSocketServ.Connect() ;
+        if (status == KErrNone)
+            {
+            status = iConnInfo->iConnection.Open ( iConnInfo->iSocketServ ) ;
+            if (status != KErrNone)
+                {
+                iConnInfo->iSocketServ.Close();
+                }
+            else
+                {
+                iConnectionMonitor = CConnectionMonitor::NewL(this); 
+                iConnInfo->iConnectionStatus = ETrue;
+                }
+            }
+        }
+    return status;
+    }
+
+void CHttpNetworkConnection::HandleConnectionEvent(TInt aError)
+    {
+    if (aError == KLinkLayerClosed || aError == KLinkLayerClosed)
+        {
+        iConnInfo->iConnectionStatus = EFalse;
+        }
+    }
+    
--- a/applayerprotocols/httpservice/src/chttpservice.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/src/chttpservice.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -15,7 +15,9 @@
 
 #include "chttpservice.h"
 #include "httpclientutils.h"
-
+#include "chttpclientauthentication.h" 
+#include "mhttpserviceauthentication.h" 
+#include "chttpnetworkconnectioninfo.h"
 const TInt KMaxNoOfConnections = 6;
 const TInt KMaxTransToPipeline = 5;
 
@@ -45,6 +47,14 @@
 	}
 
 /**
+ * Destructor of the inner class CHttpServiceStruct
+ */ 
+CHttpService::CHttpServiceStruct::~CHttpServiceStruct()
+    {
+    delete iHttpClientAuthentication;
+    }
+
+/**
  * Retrieves the equivalent string for a give string ID from the 
  * HTTP string pool
  * 
@@ -212,6 +222,15 @@
 	return err;
 	}
 
+EXPORT_C TInt CHttpService::SetAuthentication(MHTTPServiceAuthentication* aCallback)
+    {
+    TInt error = KErrGeneral;
+    iHttpServiceStruct->iHttpClientAuthentication = CHttpClientAuthentication::New(iHttpServiceStruct->iHttpSession, aCallback);
+    if(iHttpServiceStruct->iHttpClientAuthentication)
+        error = KErrNone;
+    return error;
+    }
+
 /**
  * Constructor
  */
@@ -229,3 +248,9 @@
     SetMaxTransactionsToPipeline(KMaxTransToPipeline);    
 	}
 	
+EXPORT_C CHttpNetworkConnection* CHttpService::HttpNetworkConnection()
+    {
+    CHttpNetworkConnection *httpNetworkConn = CHttpNetworkConnection::New();
+    httpNetworkConn->SetHttpService(this);
+    return httpNetworkConn;
+    }
--- a/applayerprotocols/httpservice/src/httpheaderiter.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/src/httpheaderiter.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -14,8 +14,8 @@
 //
 
 #include "httpheaderiter.h"
-#include "cheaders.h"
-#include "cheaderfield.h"
+#include "CHeaders.h"
+#include "CHeaderField.h"
 #include "httpclientutils.h"
 
 // This class needs to be optimized.
--- a/applayerprotocols/httpservice/test/group/httpservicetest.mmp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/test/group/httpservicetest.mmp	Thu Jul 22 16:38:27 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -31,10 +31,10 @@
 SOURCE	ctestclienthttpget.cpp 
 SOURCE	ctestclienthttppost.cpp
 SOURCE	ctesthttpclientstep.cpp 
-SOURCE	chttpclienttestparams.cpp
+SOURCE	chttpclienttestparams.cpp ctesthttpserviceauthentication.cpp
 
 USERINCLUDE 		../../inc
-USERINCLUDE 		../../../httptransportfw/test/t_utils
+USERINCLUDE 		../../../httptransportfw/Test/t_utils
 USERINCLUDE 		../../../httptransportfw/utils
 SYSTEMINCLUDE 		../../../../applayerpluginsandutils/httptransportplugins/httptransporthandler
 
@@ -59,5 +59,5 @@
 LIBRARY				efsrv.lib 
 LIBRARY				httptestutils.lib
 LIBRARY				esock.lib insock.lib
-
+LIBRARY			commdb.lib
 SMPSAFE
--- a/applayerprotocols/httpservice/test/httpservicetest/chttpclienttestparams.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/test/httpservicetest/chttpclienttestparams.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -23,6 +23,8 @@
 _LIT(KUri, "Uri");
 _LIT(KRawRequest, "RawRequest");
 _LIT(KRawResponse, "RawResponse");
+_LIT(KRawEncodedAuthenticationRequest, "RawEncodedAuthenticationRequest");
+_LIT(KRawFinalResponse, "RawFinalResponse");
 _LIT(KResponseBody, "ResponseBody");
 _LIT(KStatusCode, "StatusCode");
 _LIT(KResponseFieldCount, "ResponseFieldCount");
@@ -58,7 +60,8 @@
 _LIT(KProxyAddress, "ProxyAddress");
 _LIT(KResponseTimeout, "ResponseTimeout");  
 _LIT(KRedirection, "Redirection"); 
-_LIT(KNotifyTransferProgress, "NotifyTransferProgress"); 
+_LIT(KNotifyTransferProgress, "NotifyTransferProgress");
+_LIT(KSetAuthentication, "SetAuthentication");
 
 _LIT8(KScriptLF8,   "\\n");
 _LIT8(KReplaceLF8,  "\n");
@@ -107,6 +110,8 @@
     TPtrC uri;
     TPtrC rawRequest;
     TPtrC rawResponse;
+    TPtrC rawEncodedAuthenticationRequest;
+    TPtrC rawFinalResponse;
     if(!aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KMethod(), method) || 
             !aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KUri(), uri) ||
              !aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), KStatusCode(), iStatusCode))
@@ -115,13 +120,21 @@
         }
     aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRawRequest(), rawRequest);
     aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRawResponse(), rawResponse);
+    aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRawEncodedAuthenticationRequest(), rawEncodedAuthenticationRequest);
+    aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRawFinalResponse(), rawFinalResponse);
     
     iMethod = EscapeUtils::ConvertFromUnicodeToUtf8L(method);
     iUri = EscapeUtils::ConvertFromUnicodeToUtf8L(uri);
     iRawRequest = EscapeUtils::ConvertFromUnicodeToUtf8L(rawRequest);
     iRawResponse = EscapeUtils::ConvertFromUnicodeToUtf8L(rawResponse);
+    iEncodedAuthenticationRequest = EscapeUtils::ConvertFromUnicodeToUtf8L(rawEncodedAuthenticationRequest);
+    iFinalResponse = EscapeUtils::ConvertFromUnicodeToUtf8L(rawFinalResponse);
+       
     ParseAndReplaceCRLF(iRawRequest);
     ParseAndReplaceCRLF(iRawResponse);
+    ParseAndReplaceCRLF(iEncodedAuthenticationRequest);
+    ParseAndReplaceCRLF(iFinalResponse);
+
     
     
     TPtrC responseBody;
@@ -321,6 +334,9 @@
     iNotifyTransferProgress = EFalse;
     aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KNotifyTransferProgress(), iNotifyTransferProgress);
     
+    iSetAuthentication = EFalse;
+    aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KSetAuthentication(), iSetAuthentication);
+    
     TPtrC proxyAddress;
     if(aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KProxyAddress, proxyAddress))
         {
@@ -335,6 +351,8 @@
     delete iMethod;
     delete iUri;
     delete iRawRequest;
+    delete iEncodedAuthenticationRequest;
+    delete iFinalResponse;
     delete iRawResponse;
     delete iResponseBody;
     iResponseHeaderInfos.ResetAndDestroy();
@@ -365,6 +383,30 @@
     return *iRawResponse;
     }
 
+const TDesC8& CHttpClientTestParams::EncodedAuthenticationRequest() const
+    {
+    return *iEncodedAuthenticationRequest;
+    }
+
+void CHttpClientTestParams::SetAuthReqRes() 
+    {
+    if (iRawRequest)
+        {
+        delete iRawRequest;
+        iRawRequest = NULL;
+        }        
+    if (iRawResponse)
+        {
+        delete iRawResponse;
+        iRawResponse = NULL;
+        }
+    iRawRequest = iEncodedAuthenticationRequest;
+    iRawResponse = iFinalResponse;
+    
+    iEncodedAuthenticationRequest = NULL;
+    iFinalResponse = NULL;
+    }
+
 const TDesC8& CHttpClientTestParams::ResponseBody() const
     {
     if(iResponseBody)
@@ -432,6 +474,11 @@
     return iNotifyTransferProgress;
     }
 
+TBool CHttpClientTestParams::IsAuthenticationReqd() const   
+    {
+    return iSetAuthentication;
+    }
+
 TBool CHttpClientTestParams::CheckVariantValue(const THttpHeaderValueVariant& aVariant, const TDesC8& aValueToMatch)
     {
     TBool ret = EFalse;
--- a/applayerprotocols/httpservice/test/httpservicetest/chttpclienttestparams.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/test/httpservicetest/chttpclienttestparams.h	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -122,6 +122,8 @@
 	const TDesC8& Uri() const;
 	const TDesC8& RawRequest() const;
 	const TDesC8& RawResponse() const;
+	const TDesC8& EncodedAuthenticationRequest() const;
+	void SetAuthReqRes();
 	const TDesC8& ResponseBody() const;
 	const RPointerArray<CHeaderInfo>& HeaderInfos() const
 	{
@@ -151,6 +153,7 @@
     TBool ResponseTimeoutEnable() const; 
     TBool IsRedirecting() const;
     TBool TransferProgress() const;
+    TBool IsAuthenticationReqd() const;
     
     const TDesC8& RequestBody() const
     {
@@ -194,6 +197,8 @@
 	HBufC8*	iUri;
 	HBufC8* iRawRequest;
 	HBufC8* iRawResponse;
+	HBufC8* iEncodedAuthenticationRequest;
+	HBufC8* iFinalResponse;
 	HBufC8*	iResponseBody;
 	HBufC8* iRequestBody;
 	TInt    iExpectedError;
@@ -205,6 +210,7 @@
 	TBool          iResponseTimeout; 
 	TBool          iRedirection;
 	TBool          iNotifyTransferProgress;
+	TBool          iSetAuthentication;
 	HBufC8*        iProxyAddress;
 	};
 
--- a/applayerprotocols/httpservice/test/httpservicetest/ctestclienthttpget.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/test/httpservicetest/ctestclienthttpget.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -20,7 +20,6 @@
 #include <tinternetdate.h>
 _LIT8(KAcceptHeader, "Accept");
 _LIT8(KAcceptValue, "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
-_LIT(KTestHttpClientAPITestTitle, "HTTP client API Unit Test Harness");
 _LIT(KTransferProgress, "File size: %d kb , Downloaded so far: %d kb");
 
 CTestClientHttpSimpleGet* CTestClientHttpSimpleGet::NewL(CHttpClientTestParams& aParams, MLocalTestServerObserver& aObserver, CHttpService& aClient, const TDesC8& aUri, CHTTPTestUtils* aUtils)
--- a/applayerprotocols/httpservice/test/httpservicetest/ctestclienthttppost.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/test/httpservicetest/ctestclienthttppost.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -18,7 +18,6 @@
 #include <httpstringconstants.h>
 #include "mlocaltestserverobserver.h"
 #include "chttpclienttestparams.h"
-_LIT(KTestHttpClientAPITestTitle, "HTTP client API Unit Test Harness");
 _LIT(KTransferProgress, "File size: %d kb , Uploaded so far: %d kb"); 
 
 CTestClientHttpSimplePost* CTestClientHttpSimplePost::NewL(CHttpClientTestParams& aParams, MLocalTestServerObserver& aObserver, CHttpService& aClient, const TDesC8& aUri, CHTTPTestUtils& aUtils)
--- a/applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -19,9 +19,12 @@
 #include "ctestclienthttppost.h"
 #include <escapeutils.h>
 #include <thttphdrval.h>
+#include <commdbconnpref.h>
 #include "httptestutils.h"
 #include "clocaltestserver.h"
 #include "chttpclienttestparams.h"
+#include "ctesthttpserviceauthentication.h"
+#include "chttpnetworkconnectioninfo.h"
 
 _LIT(KTestCaseName, "TestCaseName");
 _LIT8(KUserAgent, "HTTP Client API Test");
@@ -43,6 +46,7 @@
     delete iTestUtils;    
     delete iTestParamArray;
     delete iActiveScheduler;
+    delete iTestHttpServiceAuthentication;
     }
 
 // TEF virtuals
@@ -52,10 +56,16 @@
     CActiveScheduler::Install(iActiveScheduler);
     iTestParamArray = new(ELeave) CHttpClientTestParamArray;
     iTestUtils = CHTTPTestUtils::NewL(KTestHttpClientAPITestTitle());
-    iTestUtils->InitCommsL();
+    
     
     iTestServer = CLocalTestServer::NewL(*iTestUtils, *this, *iTestParamArray);
     iHttpClient = CHttpService::NewL();
+    TCommDbConnPref connPref;
+    connPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
+    connPref.SetIapId(1);
+    connPref.SetNetId(0);
+    iHttpConnInfo = iHttpClient->HttpNetworkConnection();
+    User::LeaveIfError(iHttpConnInfo->Start());
     THttpHeaderValueVariant variant(KUserAgent());
     if(iHttpClient->AddRequestHeader(HTTP::EUserAgent, variant))
         {
@@ -99,6 +109,12 @@
             }
         }
     
+    if(param->IsAuthenticationReqd())
+        {
+        iTestHttpServiceAuthentication = new CTestHttpServiceAuthentication();
+        User::LeaveIfError(iHttpClient->SetAuthentication(iTestHttpServiceAuthentication));
+        }
+  
     if(param->Method().CompareF(KGetMethod) == 0)
         {
         if(param->OnlineTest())
@@ -126,12 +142,10 @@
         {
         iHttpTrans->SetNoRetry();
         }
-    
     if(param->ResponseTimeoutEnable())
         {
         iHttpTrans->SetResponseTimeout(10);
         }
-    
     const RPointerArray<CHeaderInfo>& info = param->RequestHeaderInfos();
     for(TInt i = 0; i < info.Count(); ++i)
         {
@@ -161,7 +175,7 @@
                     THTTPHdrVal::TQConv q(value);
                     TInt val2 = q;
                     THttpHeaderValueVariant variant2(val2);
-                    // Set the header with the param
+                    /// Set the header with the param
                     iHttpTrans->AddRequestHeader(headerName, variant, paramName, variant2);
                     }
                 }
--- a/applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.h	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -26,6 +26,8 @@
 class CLocalTestServer;
 class CHTTPTestUtils;
 class CHttpClientTestParamArray;
+class CHttpNetworkConnection;
+class CTestHttpServiceAuthentication;
 
 class CTestHttpClientStep : public CTestStep, public MLocalTestServerObserver
     {
@@ -48,6 +50,8 @@
     CHTTPTestUtils*     iTestUtils;
     CLocalTestServer*   iTestServer;
     CHttpClientTestParamArray* iTestParamArray;
+    CTestHttpServiceAuthentication* iTestHttpServiceAuthentication;
+    CHttpNetworkConnection* iHttpConnInfo;
     };
 
 #endif // __CTESTHTTPCLIENTSTEP_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applayerprotocols/httpservice/test/httpservicetest/ctesthttpserviceauthentication.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,42 @@
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+#include <e32base.h>
+#include <f32file.h>  
+#include "ctesthttpserviceauthentication.h"
+
+_LIT(KAuthURL, "Passing credentials for URL %S, realm %S\n");
+_LIT(KAuthType, "Using %S authentication\n");
+  
+CTestHttpServiceAuthentication::~CTestHttpServiceAuthentication()
+    {  
+    }
+    
+CTestHttpServiceAuthentication::CTestHttpServiceAuthentication()
+    {    
+    }
+    
+
+// From MHTTPServiceAuthentication
+TInt CTestHttpServiceAuthentication::OnAuthentication(const TDesC8& /*aUri*/, const TDesC8& /*aRealm*/, const TDesC8& /*aType*/, RBuf8& aUsername, RBuf8& aPassword)
+    {
+    //User credentials
+    _LIT8(KUserName,  "username");
+    _LIT8(KPassword,  "password");
+   
+    aUsername.Create(KUserName);
+    aPassword.Create(KPassword);
+    return KErrNone;
+    }
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applayerprotocols/httpservice/test/httpservicetest/ctesthttpserviceauthentication.h	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,35 @@
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __CTESTHTTPSERVICEAUTHENTICATION_H__
+#define __CTESTHTTPSERVICEAUTHENTICATION_H__
+
+#include <e32base.h>
+#include "mhttpserviceauthentication.h"
+
+class CTestHttpServiceAuthentication : public CBase, public MHTTPServiceAuthentication
+    {
+public:
+    CTestHttpServiceAuthentication();
+    ~CTestHttpServiceAuthentication();
+      
+    // inherited from MHTTPServiceAuthentication
+    TInt OnAuthentication(const TDesC8& aUri, const TDesC8& aRealm, const TDesC8& aType, RBuf8& aUsername, RBuf8& aPassword);
+     
+private:
+
+    };
+
+#endif // __CTESTHTTPSERVICEAUTHENTICATION_H__
--- a/applayerprotocols/httpservice/test/httpservicetest/ctestserverstreammanager.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/test/httpservicetest/ctestserverstreammanager.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -18,10 +18,8 @@
 #include <moutputstream.h>
 #include "httptestutils.h"
 #include "chttpclienttestparams.h"
+#include <escapeutils.h>
 
-const TUint KCarriageReturn = '\r';
-const TUint KLineFeed       = '\n';
-const TUint KSpace          = ' ';
 
 CLocalTestServerStreamManager* CLocalTestServerStreamManager::NewL(CHTTPTestUtils& aTestUtils, MInputStream* aInStream, MOutputStream* aOutStream, CHttpClientTestParamArray& aTestParamArray)
 	{
@@ -68,19 +66,27 @@
 	    }
 	else
 	    {
-	    // Check to see if the buffer needs to grow
-        TInt maxLength  = iRequestStream->Des().MaxLength();
-        TInt reqdLength = iRequestStream->Length() + aBuffer.Length();
-	    if (reqdLength > maxLength)
+	    if(aBuffer.CompareF(iCurrentTestParam->EncodedAuthenticationRequest()) != 0)
 	        {
-	        HBufC8* largerBuffer = iRequestStream->ReAllocL(maxLength + aBuffer.Length());
-
-	        // Switch buffers. The old one was removed by ReAlloc.
-	        iRequestStream = largerBuffer;
+            // Check to see if the buffer needs to grow
+            TInt maxLength  = iRequestStream->Des().MaxLength();
+            TInt reqdLength = iRequestStream->Length() + aBuffer.Length();
+            if (reqdLength > maxLength)
+                {
+                HBufC8* largerBuffer = iRequestStream->ReAllocL(maxLength + aBuffer.Length());
+    
+                // Switch buffers. The old one was removed by ReAlloc.
+                iRequestStream = largerBuffer;
+                }
+    
+            // Can now append confidently
+            iRequestStream->Des().Append(aBuffer);   
+            }
+	    else
+	        {
+	        iRequestStream = aBuffer.AllocL();
+	      	iCurrentTestParam->SetAuthReqRes();
 	        }
-
-	    // Can now append confidently
-	    iRequestStream->Des().Append(aBuffer);
 	    }
 	   iInputStream->ReceivedDataRes();	    
 	ProcessRequestStreamL();
--- a/applayerprotocols/httpservice/test/testdata/ini/httpclient.ini	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/test/testdata/ini/httpclient.ini	Thu Jul 22 16:38:27 2010 +0100
@@ -331,6 +331,23 @@
 RequestFileName= C:\HttpTest\httpservicetest\testdl2.txt
 RequestFileNameStore= C:\HttpTest\httpservicetest\testulstore3.txt
 
+[TEST20]
+TestCaseName= "HTTP CLIENT API GET17"
+Method=GET
+Uri= http://127.0.0.1/index19.html
+RawRequest= GET /index19.html HTTP/1.1\r\nHost: 127.0.0.1\r\nUser-Agent: HTTP Client API Test\r\n\r\n
+RawResponse= HTTP/1.1 401 Authorization Required\r\nContent-Length: 0\r\nWWW-Authenticate: Basic realm=\r\r"Something"\r\n\r\n
+RawEncodedAuthenticationRequest= GET /index19.html HTTP/1.1\r\nHost: 127.0.0.1\r\nAuthorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=\r\nUser-Agent: HTTP Client API Test\r\n\r\n
+RawFinalResponse= HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 0\r\n\r\n
+StatusCode= 200
+ResponseFieldCount= 2
+ResponseHeader1= Content-Length
+ResponseHeader1ValueCount= 1
+ResponseHeader1.Value1= 0
+ResponseHeader2= Content-Type
+ResponseHeader2ValueCount= 1
+ResponseHeader2.Value1= text/plain
+SetAuthentication= ETrue
 
 [#Done]
 
--- a/applayerprotocols/httpservice/test/testdata/scripts/httpserviceapitest.script	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httpservice/test/testdata/scripts/httpserviceapitest.script	Thu Jul 22 16:38:27 2010 +0100
@@ -1,5 +1,5 @@
 //
-// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -134,6 +134,11 @@
 RUN_TEST_STEP 	600 	httpserviceapitest 	httpserviceapiteststep 	C:\HttpTest\httpservicetest\httpclient.ini 	TEST19
 END_TESTCASE 	APPPROT-HTTP-SERVICE-API-00019
 
+START_TESTCASE	APPPROT-HTTP-SERVICE-API-00020
+RUN_TEST_STEP 	600 	httpserviceapitest 	httpserviceapiteststep 	C:\HttpTest\httpservicetest\httpclient.ini 	TEST20
+END_TESTCASE 	APPPROT-HTTP-SERVICE-API-00020
+
+
 PRINT Finishing_HTTP_Service_API_Test
 
 
--- a/applayerprotocols/httptransportfw/Test/EABI/httptestutilsU.def	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/Test/EABI/httptestutilsU.def	Thu Jul 22 16:38:27 2010 +0100
@@ -126,5 +126,4 @@
 	_ZN14CHTTPTestUtils23CleanupFailedTestsArrayEv @ 125 NONAME
 	_ZN14CHTTPTestUtils23CreateFailedTestsArrayLEv @ 126 NONAME
 	_ZN11CScriptFile7SectionERK7TDesC16 @ 127 NONAME
-	_ZZN14CHTTPTestUtils8OverflowER6TDes16E15KErrOverflowMsg @ 128 NONAME DATA 12
-
+	
\ No newline at end of file
--- a/applayerprotocols/httptransportfw/Test/Group/testhttpmessage.mmp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/Test/Group/testhttpmessage.mmp	Thu Jul 22 16:38:27 2010 +0100
@@ -17,7 +17,7 @@
 TARGETTYPE	  exe
 UID			 0 0xE30FF9B5
 
-USERINCLUDE	    ../testhttpMessage ../t_utils
+USERINCLUDE	    ../testhttpmessage ../t_utils
 SYSTEMINCLUDE	 ../../httpmessage
 
 #ifdef SYMBIAN_OLD_EXPORT_LOCATION
@@ -27,7 +27,7 @@
 SYSTEMINCLUDE	/epoc32/include/mw/http
 #endif
 
-SOURCEPATH	  ../testhttpMessage
+SOURCEPATH	  ../testhttpmessage
 SOURCE		  ctestengine.cpp ctestmessagecomposer.cpp testhttpmessage.cpp ctestmessageparser.cpp 
 
 LIBRARY		 euser.lib http.lib inetprotutil.lib bafl.lib httpmessage.lib efsrv.lib httptestutils.lib
--- a/applayerprotocols/httptransportfw/Test/T_HttpOffline/t_hdrcodec.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/Test/T_HttpOffline/t_hdrcodec.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -87,6 +87,7 @@
 	ResetTimeElapsed();
 
 	// Run tests on parsed -> OTA data conversions, for each header implemented
+	TestDecodeEncodeCacheControlL();
 	TestEncodeAcceptL();
 	TestEncodeAcceptCharsetL();
 	TestEncodeAuthorizationL();
@@ -292,6 +293,53 @@
 	}
 
 
+void CHttpHdrCodecTest::TestDecodeEncodeCacheControlL()
+	{
+	_LIT8(KCacheControlOTAVal, "private, max-age=360, must-revalidate");
+	RStringF cacheControl = iStrP.StringF(HTTP::ECacheControl,RHTTPSession::GetTable());
+	RStringF maxAge = iStrP.StringF(HTTP::EMaxAge,RHTTPSession::GetTable());
+	RHTTPHeaders hdr = GetHeadersLC();
+	hdr.SetRawFieldL(cacheControl, KCacheControlOTAVal, KFieldSeparator);
+	if(hdr.FieldPartsL(cacheControl) != 3)
+	    {
+        iEngine->Utils().LogIt(_L("\nCache-Control OTA comparison  failed -> [parts != 3]"));
+        User::Leave(KErrCorrupt);
+	    }
+	THTTPHdrVal hVal;
+	User::LeaveIfError(hdr.GetField(cacheControl,0,hVal));
+	if(hVal.StrF().DesC().Compare(_L8("private")) != 0)
+	    {
+	    iEngine->Utils().LogIt(_L("\nCache-Control OTA comparison  failed -> [private]"));
+	    User::Leave(KErrCorrupt);
+	    }
+	THTTPHdrVal paramVal;
+	User::LeaveIfError(hdr.GetParam(cacheControl, maxAge, paramVal, 1));
+	if(paramVal.Int() != 360)
+	    {
+	    iEngine->Utils().LogIt(_L("\nCache-Control OTA comparison  failed -> [300]"));
+	    User::Leave(KErrCorrupt);
+	    }
+	THTTPHdrVal hVal2;
+	User::LeaveIfError(hdr.GetField(cacheControl,2,hVal2));
+    if(hVal2.StrF().DesC().Compare(_L8("must-revalidate")) != 0)
+        {
+        iEngine->Utils().LogIt(_L("\nmust-revalidate OTA comparison  failed -> [private, max-age=300, must-revalidate]"));
+        User::Leave(KErrCorrupt);
+        }
+	
+	TPtrC8 rawHeader;
+	hdr.GetRawField(cacheControl, rawHeader);
+	if(rawHeader.CompareF(KCacheControlOTAVal) != 0)
+	    {
+	    iEngine->Utils().LogIt(_L("\nmust-revalidate OTA comparison  failed -> [300]"));
+	    User::Leave(KErrCorrupt);
+	    }
+	
+	ReleaseHeaders();
+	
+	iEngine->Utils().LogIt ( _L ("\nTestDecodeEncodeCacheControlL test success."));
+	}
+
 void CHttpHdrCodecTest::TestEncodeAcceptL()
 	{
 	// the result we expect and that we will validate
--- a/applayerprotocols/httptransportfw/Test/T_HttpOffline/t_hdrcodec.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/Test/T_HttpOffline/t_hdrcodec.h	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -79,6 +79,7 @@
 	void ResetTimeElapsed();
 	void DisplayTimeElapsed();
 	//
+	void TestDecodeEncodeCacheControlL();
 	void TestEncodeAcceptL();
 	void TestEncodeAcceptCharsetL();
 	void TestEncodeAuthorizationL();
--- a/applayerprotocols/httptransportfw/Test/T_HttpPipeliningTest/CRecvTimeOut.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/Test/T_HttpPipeliningTest/CRecvTimeOut.h	Thu Jul 22 16:38:27 2010 +0100
@@ -19,7 +19,7 @@
 #include <e32base.h>
 #include <http.h>
 
-#include "cpipeliningtestcase.h"
+#include "CPipeliningTestCase.h"
 
 class CHTTPTestUtils;
 
--- a/applayerprotocols/httptransportfw/Test/T_HttpPipeliningTest/CTestCasePipelineFallback.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/Test/T_HttpPipeliningTest/CTestCasePipelineFallback.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -16,7 +16,7 @@
 */
 
 
-#include "ctestcasepipelinefallback.h"
+#include "CTestCasePipelineFallback.h"
 #include "httptestutils.h"
 
 const TInt KTransactionCount = 30; // Submit 30 transactions
--- a/applayerprotocols/httptransportfw/Test/T_HttpPipeliningTest/CTestCasePipelineFallback.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/Test/T_HttpPipeliningTest/CTestCasePipelineFallback.h	Thu Jul 22 16:38:27 2010 +0100
@@ -22,7 +22,7 @@
 #include <e32base.h>
 #include <http.h>
 
-#include "cbatchingtestcase.h"
+#include "CBatchingTestCase.h"
 
 class CHTTPTestUtils;
 
--- a/applayerprotocols/httptransportfw/Test/T_HttpPipeliningTest/CTestServerStreamManager.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/Test/T_HttpPipeliningTest/CTestServerStreamManager.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -19,7 +19,7 @@
 #include "CTestServerStreamManager.h"
 #include "httptestutils.h"
 #include "MPipeliningTestCase.h"
-#include "ctestcasepipelinefallback.h"
+#include "CTestCasePipelineFallback.h"
 
 const TInt KTimeOut = 50000000;
 const TInt KResponseBatchSize = 5;
--- a/applayerprotocols/httptransportfw/Test/T_HttpPipeliningTest/cpipeliningtestengine.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/Test/T_HttpPipeliningTest/cpipeliningtestengine.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -58,7 +58,7 @@
 #include "ctestcase24.h"
 #include "ctestcase25.h"
 #include "ctestcase26.h"
-#include "ctestcasepipelinefallback.h"
+#include "CTestCasePipelineFallback.h"
 #include "CDEF143497.h"
 
 _LIT(KTestHttpPipeliningTestTitle, "HTTP Pipelining Unit Test Harness");
--- a/applayerprotocols/httptransportfw/Test/T_HttpPipeliningTest/ctestcase26.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/Test/T_HttpPipeliningTest/ctestcase26.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -13,7 +13,7 @@
 // Description:
 //
 
-#include "CTestCase26.h"
+#include "ctestcase26.h"
 #include "httptestutils.h"
 
 const TInt KTransactionCount = 14;
--- a/applayerprotocols/httptransportfw/Test/TestScriptTest/CPipeliningTestEngine.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/Test/TestScriptTest/CPipeliningTestEngine.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -538,7 +538,7 @@
 	iTestUtils->StartTestL( aTestCase.TestCaseName() );
 	__TESTNAME(aTestCase.TestCaseName());
 	
-	CPipeliningTestClient* testClient;
+	CPipeliningTestClient* testClient = NULL;
 	if(aSecName.FindF(_L("TSWDEFECT")) ==0)
 	    {
 	    RDebug::Print(_L("TSWDEFECT"));
@@ -546,6 +546,7 @@
 	    if(aTestCase.TestCaseName().CompareF(KTestCaseLocalAndRemoteHost) == 0)
 	        {
 	        testClient = CTestCaseLocalAndRemoteHost::NewL(*iTestUtils, *this);
+	        CleanupStack::PushL(testClient);
 	        }
 	    else
 	        {
@@ -554,10 +555,10 @@
 	    }
 	else
 	    {
-	    testClient = CPipeliningTestClient::NewL(*iTestUtils, *this);    
+	    testClient = CPipeliningTestClient::NewL(*iTestUtils, *this);   
+	    CleanupStack::PushL(testClient);
 	    }	
-	CleanupStack::PushL(testClient);
-	
+		
 	testClient->SetTestCase(&aTestCase);
 	iTestServer->SetTestCase(&aTestCase);
 	testClient->StartClientL();
--- a/applayerprotocols/httptransportfw/Test/TestScriptTest/ctestcaselocalandremotehost.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/Test/TestScriptTest/ctestcaselocalandremotehost.h	Thu Jul 22 16:38:27 2010 +0100
@@ -18,7 +18,7 @@
 
 #include <e32base.h>
 #include <http.h>
-#include "cpipeliningtestclient.h"
+#include "CPipeliningTestClient.h"
 
 
 class CHTTPTestUtils;
--- a/applayerprotocols/httptransportfw/Test/testfilter/testhttpfilter.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/Test/testfilter/testhttpfilter.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -18,17 +18,15 @@
 #include <http/rhttpresponse.h>
 #include <httperr.h>
 #include <httpstringconstants.h>
-#include <imcvcodc.h>      //for base64 en/decoding
 #include <bautils.h>
 #include <e32math.h>
 #include <hash.h>
 #include <e32const.h>
-#include <tconvbase64.h>
+#include <tconvbase64.h>  //for base64 en/decoding
 #include "testhttpfilter.h"
 _LIT8( KTESTHTTPFilterName, "TestHttp");
 _LIT8( KAuthenticationInfoStr, "Authentication-Info" );
 _LIT8( KUserAgentProductToken,"3gpp-gba");
-_LIT8( KColon, ":" );
 const TInt KB64KeySize = 64;
 _LIT(KTestHttpFilter, "TEST HTTP FILTER ");
 
@@ -243,7 +241,6 @@
 	
 	   TInt headerPart=0;    	
 	   THTTPHdrVal headerVal;
-       TInt cred = KErrNotFound;
        RStringF wwwAuthHeader = iStringPool.StringF(HTTP::EWWWAuthenticate,RHTTPSession::GetTable());
 	   RHTTPHeaders headers(aTrans.Response().GetHeaderCollection());
 
@@ -320,8 +317,6 @@
 	if(!found)
 	    hdr.SetFieldL(fieldname, iUserAgent);
 	
-    TInt cred = KErrNotFound;
-    
     if( iHaveCredentials )
         {
         TBuf8<KB64KeySize> keyBase64(_L8("Aladdin")); 
--- a/applayerprotocols/httptransportfw/Test/testhttpmessage/testhttpmessage.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/Test/testhttpmessage/testhttpmessage.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -13,7 +13,7 @@
 // Description:
 //
 
-#include "TestHttpMessage.h"
+#include "testhttpmessage.h"
 #include <e32base.h>
 #include <e32std.h>
 #include <e32cons.h>			// Console
--- a/applayerprotocols/httptransportfw/core/CHeaderField.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/core/CHeaderField.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -118,7 +118,9 @@
 	if ((aIndex < NumPartsL()) && (aIndex >= 0))
 		return iParts[aIndex];
 	else
-		return NULL;
+		User::Leave(KErrNotFound);
+	
+	return NULL;
 	}
 
 EXPORT_C
--- a/applayerprotocols/httptransportfw/core/CTransaction.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/core/CTransaction.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -82,7 +82,7 @@
 	CHeaderFieldPart::ClosePropertySet(iPropertySet);
 	delete iRequest;
 	delete iResponse;
-
+	
 	// Cancel the active object
 	Cancel();
 
--- a/applayerprotocols/httptransportfw/core/TFilterConfigurationIter.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/core/TFilterConfigurationIter.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -76,10 +76,10 @@
 		}
 	else
 		{
-		++iCurrentFilterIndex;
 		// If the next filter is a mandatory filter then move on to the next filter
 		if( iFilterInfoList[iCurrentFilterIndex]->iCategory == TSessionFilterInfo::EMandatory )
 			return Next();
+		++iCurrentFilterIndex;
 		}
 
 	return KErrNone;
--- a/applayerprotocols/httptransportfw/core/chttpformencoder.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/core/chttpformencoder.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -70,8 +70,8 @@
 	
 TInt CHTTPFormEncoder::Reset()
 	{
-	// Not implemented here
-	return KErrNotSupported;
+    iState = EAllowAppendData;
+	return KErrNone;
 	}
 
 EXPORT_C void CHTTPFormEncoder::AddFieldL(const TDesC8& aFieldName, const TDesC8& aFieldValue)
--- a/applayerprotocols/httptransportfw/group/httpcore.iby	Thu Jun 17 12:05:02 2010 +0100
+++ b/applayerprotocols/httptransportfw/group/httpcore.iby	Thu Jul 22 16:38:27 2010 +0100
@@ -20,7 +20,6 @@
 #include <InetProtUtil.iby>
 #endif
 
-#include <GtEmailMtm.iby>
 #include <httpservice.iby>
 
 // HTTP Core
--- a/httpfilters/cookie/BWinsCw/COOKIEMANAGERU_EKA2U.def	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/BWinsCw/COOKIEMANAGERU_EKA2U.def	Thu Jul 22 16:38:27 2010 +0100
@@ -11,4 +11,9 @@
 	?SetAttribute@CCookie@@QAEHW4TCookieAttributeName@1@ABVTHTTPHdrVal@@@Z @ 10 NONAME ; int CCookie::SetAttribute(enum CCookie::TCookieAttributeName, class THTTPHdrVal const &)
 	?StartCookieServer@@YAHPAX@Z @ 11 NONAME ; int StartCookieServer(void *)
 	?StoreCookie@RCookieManager@@QAEHABVCCookie@@ABVTUriC8@@@Z @ 12 NONAME ; int RCookieManager::StoreCookie(class CCookie const &, class TUriC8 const &)
-	?SetAppUidL@RCookieManager@@QAEHABK@Z @ 13 NONAME ; int RCookieManager::SetAppUidL(unsigned long const &)
\ No newline at end of file
+	?SetAppUidL@RCookieManager@@QAEHABK@Z @ 13 NONAME ; int RCookieManager::SetAppUidL(unsigned long const &)
+	?ClearAllAppUidCookies@RCookieManager@@QAEHABK@Z @ 14 NONAME ; int RCookieManager::ClearAllAppUidCookies(unsigned long const &)
+	?Close@RCookieManager@@QAEXXZ @ 15 NONAME ; void RCookieManager::Close(void)
+	?GetCookiesL@RCookieManager@@QAEXABVTDesC8@@AAV?$RPointerArray@VCCookie@@@@AAHAAK@Z @ 16 NONAME ; void RCookieManager::GetCookiesL(class TDesC8 const &, class RPointerArray<class CCookie> &, int &, unsigned long &)
+	?StoreCookie@RCookieManager@@QAEHABVCCookie@@ABVTUriC8@@AAK@Z @ 17 NONAME ; int RCookieManager::StoreCookie(class CCookie const &, class TUriC8 const &, unsigned long &)
+
--- a/httpfilters/cookie/EABI/COOKIEMANAGERU_EKA2U.def	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/EABI/COOKIEMANAGERU_EKA2U.def	Thu Jul 22 16:38:27 2010 +0100
@@ -16,4 +16,9 @@
 	_ZNK7CCookie9AttributeENS_20TCookieAttributeNameER11THTTPHdrVal @ 15 NONAME
 	_ZTI7CCookie @ 16 NONAME ; #<TI>#
 	_ZTV7CCookie @ 17 NONAME ; #<VT>#	
-	_ZN14RCookieManager10SetAppUidLERKm @ 18 NONAME
\ No newline at end of file
+	_ZN14RCookieManager10SetAppUidLERKm @ 18 NONAME
+	_ZN14RCookieManager11GetCookiesLERK6TDesC8R13RPointerArrayI7CCookieERiRm @ 19 NONAME
+	_ZN14RCookieManager11StoreCookieERK7CCookieRK6TUriC8Rm @ 20 NONAME
+	_ZN14RCookieManager21ClearAllAppUidCookiesERKm @ 21 NONAME
+	_ZN14RCookieManager5CloseEv @ 22 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/httpfilters/cookie/EABI/cookiemanageru.def	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,24 @@
+EXPORTS
+	_Z17StartCookieServerPv @ 1 NONAME
+	_ZN14RCookieManager10SetAppUidLERKm @ 2 NONAME
+	_ZN14RCookieManager11GetCookiesLERK6TDesC8R13RPointerArrayI7CCookieERi @ 3 NONAME
+	_ZN14RCookieManager11GetCookiesLERK6TDesC8R13RPointerArrayI7CCookieERiRm @ 4 NONAME
+	_ZN14RCookieManager11StoreCookieERK7CCookieRK6TUriC8 @ 5 NONAME
+	_ZN14RCookieManager11StoreCookieERK7CCookieRK6TUriC8Rm @ 6 NONAME
+	_ZN14RCookieManager12ClearCookiesERi @ 7 NONAME
+	_ZN14RCookieManager21ClearAllAppUidCookiesERKm @ 8 NONAME
+	_ZN14RCookieManager5CloseEv @ 9 NONAME
+	_ZN14RCookieManager7ConnectEv @ 10 NONAME
+	_ZN14RCookieManagerC1E11RStringPool @ 11 NONAME
+	_ZN14RCookieManagerC2E11RStringPool @ 12 NONAME
+	_ZN7CCookie12SetAttributeENS_20TCookieAttributeNameERK11THTTPHdrVal @ 13 NONAME
+	_ZN7CCookie4NewLE11RStringPool @ 14 NONAME
+	_ZN7CCookie4NewLE12RHTTPHeadersi8RStringF11RStringPoolRK6TUriC8 @ 15 NONAME
+	_ZN7CCookieD0Ev @ 16 NONAME
+	_ZN7CCookieD1Ev @ 17 NONAME
+	_ZN7CCookieD2Ev @ 18 NONAME
+	_ZNK7CCookie13AddToRequestLE12RHTTPHeadersi @ 19 NONAME
+	_ZNK7CCookie9AttributeENS_20TCookieAttributeNameER11THTTPHdrVal @ 20 NONAME
+	_ZTI7CCookie @ 21 NONAME ; #<TI>#
+	_ZTV7CCookie @ 22 NONAME ; #<VT>#
+
--- a/httpfilters/cookie/FilterSrc/CookieFilter.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/FilterSrc/CookieFilter.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -34,6 +34,9 @@
 _LIT8(KEmpty, "");
 _LIT8( KCookieUsage, "CookiesEnabled" );
 _LIT8( KAppUid, "Appuid" );
+_LIT8( KHttpConnectMethod, "CONNECT");
+_LIT8( KSecureHttpScheme, "https://");
+const TInt KSecureHttpSchemeLength = 8;
 
 // ---------------------------------------------------------
 // CCookieFilter::InstallFilterL
@@ -248,8 +251,21 @@
 
 	TBool cookie2Reqd = EFalse;
 	RPointerArray<CCookie> cookies(20);
+    HBufC8* requestUriBuf( NULL );
 	TPtrC8 requestUri( aTransaction.Request().URI().UriDes() );
-
+    TPtrC8 requestMethod( aTransaction.Request().Method().DesC() );
+    if( (requestMethod.CompareF(KHttpConnectMethod) == 0) && (requestUri.Left(KSecureHttpSchemeLength).CompareF(KSecureHttpScheme) == 0))
+        {
+        // if we are performing an HTTP CONNECT to create tunnel for original https:// request, we
+        // should not include secure cookies in this HTTP request since they will be in clear text.
+        // to ensure that Cookie manager does not add these into cookie array, change scheme so
+        // it appears as non-secure transaction
+        requestUriBuf = requestUri.Alloc();
+        CleanupStack::PushL(requestUriBuf);        
+        TPtr8 requestUriPtr = requestUriBuf->Des();
+        requestUriPtr.Delete(4, 1);  // remove char in pos 4 to change https:// to http:// 
+        requestUri.Set(requestUriPtr);
+        }
 	TBool ret;
 	RStringF appuid = iStringPool.OpenFStringL( KAppUid );
 	THTTPHdrVal hdrVal;
@@ -260,10 +276,14 @@
 	    {
     	appuidValue = hdrVal.Int();    	       
 	    }
-	iCookieManager.SetAppUidL(appuidValue); 
+	//iCookieManager.SetAppUidL(appuidValue); 
     appuid.Close();
     
-    iCookieManager.GetCookiesL( requestUri, cookies, cookie2Reqd );
+    iCookieManager.GetCookiesL( requestUri, cookies, cookie2Reqd,appuidValue );
+    if( requestUriBuf )
+        {
+        CleanupStack::PopAndDestroy( requestUriBuf );
+        }
 
 	TInt numCookies = cookies.Count();
 	for ( TInt ii = 0; ii < numCookies; ++ii )
@@ -343,11 +363,11 @@
     	    {
     	    appuidValue = hdrVal.Int();                                     
     	    }	
-        iCookieManager.SetAppUidL(appuidValue);    
+        //iCookieManager.SetAppUidL(appuidValue);    
         appuid.Close();       
         
 		User::LeaveIfError( iCookieManager.StoreCookie( *cookie,
-														requestUri ) );
+														requestUri,appuidValue ) );
 
 		CleanupStack::PopAndDestroy();	// cookie
         }
--- a/httpfilters/cookie/Group/CookieManager.mmp	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/Group/CookieManager.mmp	Thu Jul 22 16:38:27 2010 +0100
@@ -21,10 +21,11 @@
 TARGET		cookiemanager.dll
 TARGETTYPE	DLL
 
+UID	0x1000008D 	0x101F852F
+
 CAPABILITY	CAP_GENERAL_DLL
 
 
-UID	0x1000008D 	0x101F852F
 
 MW_LAYER_SYSTEMINCLUDE
 
@@ -42,7 +43,9 @@
 SOURCE			CookieManagerSession.cpp
 SOURCE			CookieManagerClient.cpp
 SOURCE			CookieManagerStart.cpp
-SOURCE			CookieServerPanic.cpp
+SOURCE			CookieServerPanic.cpp  
+SOURCE          CookieGroupData.cpp CookieGroupDataArray.cpp GroupIdInfoArray.cpp
+SOURCE          CookieClientDataArray.cpp CookieClientData.cpp
 
 
 // IMPORTED LIBRARIES
@@ -50,6 +53,7 @@
 LIBRARY		EUSER.LIB HTTP.LIB BAFL.LIB
 LIBRARY		INETPROTUTIL.LIB efsrv.lib 
 LIBRARY		SysUtil.lib
+LIBRARY         XmlEngineDOM.lib
 
 #if defined(EABI)
         DEFFILE ../EABI/COOKIEMANAGERU_EKA2.def
--- a/httpfilters/cookie/Group/bld.inf	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/Group/bld.inf	Thu Jul 22 16:38:27 2010 +0100
@@ -25,6 +25,10 @@
 
 PRJ_EXPORTS
 
+../data/CookieGroup.xml   /epoc32/data/z/private/101F8530/CookieGroup.xml
+
+
+
 // iby
 ../Rom/CookieFilter.iby	CORE_MW_LAYER_IBY_EXPORT_PATH(CookieFilter.iby)
 ../Rom/CookieManager.iby	CORE_MW_LAYER_IBY_EXPORT_PATH(CookieManager.iby)
--- a/httpfilters/cookie/ManagerInc/CookieArray.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/ManagerInc/CookieArray.h	Thu Jul 22 16:38:27 2010 +0100
@@ -87,6 +87,8 @@
 		*/
 		TInt GetCookies( const TDesC8& aRequestUri,
 						RPointerArray<CCookie>& aCookies );
+        TInt GetCookies( const TDesC8& aRequestUri,
+                                       RPointerArray<CCookie>& aCookies, TBool& iFound );
 
 		/**
 		*
@@ -123,6 +125,7 @@
 
 
         RPointerArray<CCookie>& CookieArray();
+        void ReserveL( TInt aNumberOfCookies );
 
 	private :	// internal method for cookie comparison
 		/**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/httpfilters/cookie/ManagerInc/CookieClientData.h	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,135 @@
+/*
+ * CookieClientData.h
+ *
+ *  Created on: Dec 28, 2009
+ *      Author: mohanti
+ */
+
+#ifndef COOKIECLIENTDATA_H_
+#define COOKIECLIENTDATA_H_
+
+//System Includes
+#include <e32base.h>
+
+//Forward Declaration
+class CCookieArray;
+class CCookie;
+
+//THis class holds the client side cookies of a specific Client 
+NONSHARABLE_CLASS( CCookieClientData ):public CBase
+    {
+public:
+    /**Constructor 
+    */
+    static CCookieClientData* NewL(TUint32 aGroupId);
+    
+    /**Constructor 
+    */
+    static CCookieClientData* NewLC(TUint32 aGroupId);
+    
+    static CCookieClientData* NewL(TUint32 aGroupId, TUint32 aWidgetUid, TBool aCookieSharableFlag = EFalse, TBool aInitFlag = EFalse);
+    
+    static CCookieClientData* NewLC(TUint32 aGroupId, TUint32 aWidgetUid, TBool aCookieSharableFlag, TBool aInitFlag);
+    /**Standard Constructor
+    */
+    void ConstructL();
+    
+    /**Standard Destructor 
+    */
+    ~CCookieClientData();
+
+    /** Cookie Array Handle
+     * @return returns the pointer of CookieArray object. 
+    */
+    CCookieArray* CookieArray();
+    
+    /** Stores the CCookie objects for a specific Uri .
+        @param aCookie Indicates the Cookie Objects to be Stored      
+        @param aRequestUri Indicates the Uri for which cookie Objects needs to be Stored
+        @param aIndex   
+        @return  void 
+1    */
+    void StorePersistentCookieL( const CCookie* aCookie, const TDesC8& aRequestUri, const TInt aIndex = -1 );
+    
+    /** Stores the CCookie objects for a specific Uri in Client Address Space.
+        @param aCookie Indicates the Cookie object to be stored.      
+        @param aUri    Indicates the Uri for which the Cookie Information need to be stored.
+        @return void .
+        
+    */
+    void StoreCookieAtClientSideL( const CCookie* aCookie,const TDesC8& aUri );
+
+    /** Finds the CCookie objects for a specific Uri in Client Address Space
+        @param aRequestUri Indicates the Uri for which Cookie info is required       
+        @param aCookies Reference to an array of Cookie objects for a uri after completion of the method.
+        @param aFound   Indiacates whether cookie info for a requested Uri is present or not in the Client address space or not.
+        @return .
+    */
+    TInt GetClientSideCookies( const TDesC8& aRequestUri,RPointerArray<CCookie>& aCookies,TBool& aCookieFound ) const;
+        /*Setting the AppUid
+     * @param aAppUid Appuid to be set in case of Widgets running in the same process  
+     */
+    void SetAppUid(TUint32 aAppUid );
+
+    /** Number of CCookie objects present in Array.
+     * @return Number of Cookie objects present in the array
+    */
+    TInt Count()const;
+    
+    /* Sets appuid
+     * @param aWidgetUid indicates appuid of the widget
+     */
+    inline void SetWidgetUid(TUint32 aWidgetUid ){iWidgetUid = aWidgetUid;}
+    /*Sets Cookie Sharable flag
+     * @param  aCookieSharableFlag indicates whether cookie sharing is allowed or not
+     */
+    inline void SetCookieCookieSharableFlag(TBool aCookieSharableFlag){iCookieSharableFlag = aCookieSharableFlag;}
+    
+    /*Sets the initailization flag once the initialization of CCookieClientData object has been completed 
+     * @param aInitFlag indicates initialization flag
+     */
+    inline void SetInitFlag(TBool aInitFlag){iInitFlag = aInitFlag;}
+    
+    /*Gets Cookie Sharable flag 
+     * @return iCookieSharableFlag indicates Cookie Sharable flag
+     */
+    inline const TBool& GetCookieSharableFlag(){return iCookieSharableFlag;}
+    
+    /*Gets Initialization flag
+     * @return iInitFlag indicates initialization flag for CCookieClientData object
+     */
+    inline const TBool& GetInitFlag(){return iInitFlag;}
+    
+    /*Gets Groupid of the CCookieClientData object
+     * @return iGroupId indicates group id of CCookieClientData object
+     */
+    inline const TUint32& GetGroupId(){return iGroupId;}
+    
+    /*Gets AppUid in case of WRT Widget 
+     * @return iWidgetUid indicates appuid of the WRT Widget
+     */
+    inline const TUint32& GetWidgetUid(){return iWidgetUid;}
+protected:
+private:
+    /*Constructor
+     * 
+     */
+    CCookieClientData(TUint32 aGroupId);
+    /*Constructor
+     * 
+     */
+    CCookieClientData(TUint32 aGroupId, TUint32 aWidgetUid, TBool aCookieSharableFlag, TBool aInitFlag);
+public:
+protected:
+    
+private:
+    TBool iInitFlag;
+    TBool iCookieSharableFlag;
+    TUint32 iGroupId;
+    //Appuid of client in case of secure WRT Widget
+    TUint32 iWidgetUid;
+    CCookieArray* iCookieArray;
+    };
+
+
+#endif /* COOKIECLIENTDATA_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/httpfilters/cookie/ManagerInc/CookieClientDataArray.h	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,119 @@
+/*
+ * CookieClientDataArray.h
+ *
+ *  Created on: Dec 18, 2009
+ *      Author: mohanti
+ */
+
+#ifndef COOKIECLIENTDATAARRAY_H_
+#define COOKIECLIENTDATAARRAY_H_
+
+//System Includes
+
+//User Includes
+
+//Forward Class Declaration
+class CCookieClientData;
+class CCookieArray;
+
+//This class holds an array of CCookieClientdata objects.
+//This a singleton class and is allocated in the Thread local storage(TLS)
+
+NONSHARABLE_CLASS( CCookieClientDataArray ):public CBase
+    {
+public:
+    
+    /* Constructor 
+     * 
+     */
+
+     static CCookieClientDataArray* New();
+
+	/* Initialization
+     *
+	 */
+	void Init();
+         
+    ~CCookieClientDataArray();
+    
+    /* Constructor
+     * 
+     */
+    CCookieClientDataArray();
+
+    /* Finds the address of CCookieClientData object from the array based on group id and appuid
+     * @param aGroupId Indicates group id
+     * @param aWidgetUid Indicates appuid
+     */
+    CCookieClientData*  Find(const TUint32& aGroupId,const TUint32& aWidgetUid);
+    
+    /* Finds the Index of CCookieClientData object from the array based on group id and appuid
+     * @param aGroupId Indicates Group Id 
+     * @param aWidgetUid Indicates Appuid
+     * @param aIndex On return of the method,it indicates the index no where the intended 
+     *        CCookieClientData Object is present
+     */
+    TInt FindIndex(const TUint32& aGroupId, const TUint32& aWidgetUid,TInt& aIndex );
+
+    /* Adding CCookieClientData object in to the array.
+     * @param aCookieClientData Indiactes the address of CCookieClientData Object
+     */
+    void AddClientGroupDataL(CCookieClientData* aCookieClientData);
+    
+    /* Returns the CCookieClientData object from the array based on index no.
+     * @param aIndex Indiactes index no.
+     */
+    CCookieClientData* At(TInt aIndex) const;
+    
+    /* Subscripting operator
+     * 
+     */
+    CCookieClientData* operator[](TInt aIndex) const;
+    
+    /* Returns the no of CCookieClientData object in the array
+     * 
+     */
+    TInt Count()const;
+    
+    /* Returns the cookiearray from the array based on the index no.
+     * @param aIndex indeicates the index no
+     */
+    CCookieArray* CookieArray(TInt aIndex); 
+    
+    /* Removes a CCookieClientData object from the array based on index no.
+     * 
+     */
+    void Remove(TInt aIndex);
+    
+    /* Compresses the array
+     * 
+     */
+    void Compress();
+    
+    /* Deletes a CCookieClientData object from the array based on appuid 
+     * @param aAppUid Indicates appuid of a Secure Widget.
+     */
+    TInt DestroyClientData(const TUint32 aAppUid);
+protected:
+    
+private:
+
+    /* Constructor
+     * 
+     */
+    CCookieClientDataArray(const CCookieClientDataArray&);
+    
+    /* Assignment operator
+     * 
+     */
+    CCookieClientDataArray& operator=(const CCookieClientDataArray&);
+public:
+    
+protected:
+    
+private:
+    RPointerArray<CCookieClientData>* iCookieClientData;
+    };
+
+
+#endif /* COOKIECLIENTDATAARRAY_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/httpfilters/cookie/ManagerInc/CookieGroupData.h	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,182 @@
+/*
+ * CCookieGroupData.h
+ *
+ *  Created on: Nov 24, 2009
+ *      Author: mohanti
+ */
+
+#ifndef COOKIEGROUPDATA_H_
+#define COOKIEGROUPDATA_H_
+
+//System Includes
+#include <stringpool.h> 
+#include <f32file.h>
+#include <e32def.h>
+#include <e32base.h>
+#include <e32cmn.h>
+
+//Forward Class declaration
+class CCookieArray;
+class CCookie;
+class TCookiePacker;
+
+//Constants
+
+const TInt KCookieMaxFileNameLength = 256;
+
+/** Class to store the Cookie Data based on secure id and appuid
+*/
+
+NONSHARABLE_CLASS( CCookieGroupData ):public CBase
+    {
+public:
+    /**Constructor.
+    * 
+    * @param aGroupId identifies the secure id of a client request
+    * @param aAppUid  identifies the Appuid sets in the transaction property of a client request
+    * @return instance of CCookieGroupData
+    */
+    static CCookieGroupData* NewL(TUint32 aGroupId,const RArray<TUint32>& aAppuid, TBool aCookieSharableFlag = EFalse );
+
+    /**Constructor.
+    * 
+    * @param aGroupId identifies the secure id of a client request
+    * @param aAppUid  identifies the Appuid sets in the transaction property of a client request
+    * @return instance of CCookieGroupData
+    */
+    static CCookieGroupData* NewLC(TUint32 aGroupId,const RArray<TUint32>& aAppuid,TBool aCookieSharableFlag = EFalse);
+
+
+    /**Standard destructor.
+    */
+    ~CCookieGroupData();
+
+    /**
+    * @return Instance of CCookieArray object.
+    */
+    CCookieArray* CookieArray();
+    
+    /**
+    * @return GroupId
+    */
+    inline const TUint32 GetGroupId(){return iGroupId;}
+
+    /* Gets Shared uid based on index no.
+    *@param aIndex Indicates index no. 
+    * @return AppUid
+    */
+    TUint32 GetSharedUid(TInt aIndex);
+    
+    /*Gets Cookie Sharable Flag
+     * @return iCookieSharableFlag indicates sharable flag
+     */
+    inline TBool GetCookieSharableFlag(){return iCookieSharableFlag;}
+    
+    /*Returns appuid based on index no
+     * 
+     */
+    TUint32 At(TInt aIndex) const;
+    
+    /* Subscripting Operator
+     * 
+     */
+    TUint32 operator[](TInt aIndex) const;
+
+    /**
+    * Store a cookie in a persistent way. We take over the ownership
+    * of the cookie.
+    * If the cookie exists, that is, there is already a cookie whose NAME
+    * attribute is the same, then the new cookie supersedes the old when :
+    *   - the old and new Domain attribute value compare equal (case-
+    * insensitive),
+    *   - the old and new Path attribute values string-compare equal
+    * (case-sensitive).
+    * However, if the Max-Age attribute is zero, then the old and new cookies
+    * are discarded.
+    * @param aCookie The cookie to be stored.
+    * @param aRequestUri The current HTTP request-URI.
+    * @param aIndex Cookie is inserted at the position of existing cookie, and exisiting cookie is removed.
+    */
+    void StorePersistentCookieL( CCookie* aCookie, const TDesC8& aRequestUri, const TInt aIndex = -1 );
+
+    
+    //void StorePersistentCookieL( CCookie* aCookie,const TDesC8& aRequestUri,const TInt aIndex );
+
+    /**Reads the Cookie related info specific for a group for a file. 
+    * 
+    * @return KErrNotFound in case of File not found from the path
+    *         KErrNoMemory in case no Memory
+    *         KErrNone Incase of successful reading of the cookie info from the file.
+    */
+    TInt ReadCookiesFromFile();
+
+    /**
+    * @return KErrNone if Succesfully Writes the Cookie info in to the file.
+    */
+    TInt WriteCookiesToFile();
+    
+    /**All the cookies will be deleted from the memory as well as from the file for a group. 
+    * @return the number of files deleted.
+    */
+    TInt ClearAllCookies();
+
+    /** Returns the Number of Cookie objects present for a group
+    * @return Numaaber of Cookie Objects
+    */
+    TInt Count()const;
+
+    /* Return Filename
+    * @return returns the Filename 
+    */
+    const TDesC& GetFileName() const;
+
+    /** Sets Filename 
+    * 
+    * @param aAppUid Indicates appuid
+    * @param aSecureId Indicates Client Id
+    * @return void
+    */
+    void SetFileName(TUint32& aAppUid,TUint32& aSecureId);
+    
+    /* Constructor
+     * 
+     */
+    void ConstructL(const RArray<TUint32>& aAppuid);
+    
+    /*Total Appuids
+     * 
+     */
+    TInt TotalAppUid();
+protected:
+private:
+    /*Constructor
+     * aGroupId Indicates group Id
+     * aCookieSharableFlag CookieSharable Flag
+     */
+    CCookieGroupData(TUint32 aGroupId, TBool aCookieSharableFlag = EFalse);
+ 
+    /* Check Diskspace available before saving the cookies in to File System
+    * @param 
+    * @param 
+    * @param
+    * @return 
+    */
+    TBool CheckDiskSpace( RFs& aFileSystem, const TDesC& aFileName ) const;
+
+public:
+    
+protected:
+    
+private:
+    CCookieArray*           iCookieArray;
+    HBufC*                  iCookieFileName;
+    RStringPool             iStringPool;
+    TCookiePacker*          iCookiePacker;
+    RFs                   iFs;
+    TUint32 iGroupId;
+    TBool iCookieSharableFlag;
+    RArray<TUint32> iSharedUid;
+    //TUint32 iAppUid;
+    };
+
+#endif /* COOKIEGROUPDATA_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/httpfilters/cookie/ManagerInc/CookieGroupDataArray.h	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,140 @@
+/*
+ * CCookieGroupDataArray.h
+ *
+ *  Created on: Nov 24, 2009
+ *      Author: mohanti
+ */
+
+#ifndef CCOOKIEGROUPDATAARRAY_H_
+#define CCOOKIEGROUPDATAARRAY_H_
+//System Include
+
+//User Includes
+
+//Forward Declaration
+class CCookieGroupData;
+class CGroupIdArray;
+class CCookieArray;
+class CCookie;
+
+/*This class is used to hold an array of CCookieGroupData objects. 
+ * 
+ */
+NONSHARABLE_CLASS( CCookieGroupDataArray ):public CBase
+    {
+public:
+
+    /* Constructor
+     * 
+     */
+    static CCookieGroupDataArray* NewL();
+    
+    /* Constructor
+     * 
+     */
+    static CCookieGroupDataArray* NewLC();
+        
+    /* Destructor
+     * 
+     */
+    ~CCookieGroupDataArray();
+    
+    
+    /*Gets CCookieGroupData object index in the array based on Group Id and appuid
+     * @param aGroupId Indicates group id
+     * @param aAppUid Indicates appuid
+     * @param  aCookieSharable On return of this method it holds the Cookie Sharable 
+     *         status for the CCookieGroupData Object
+     * @param aIndex On return of this method it holds the Index value of the CCookieGroupData Object
+     *               in the array         
+     */
+    void GetGroupDataIndexL(TUint32 aGroupId,TUint32 aAppUid,TBool& aCookieSharable, TInt& aIndex);
+    
+    /* Find the Index value of the CCookieGroupData Object based on Group Id
+     * @param aGroupId Indicates Group Id
+     * @param  aIndex Indicates the Index value
+     */
+    TInt FindIndex(TUint32 aGroupId,TInt& aIndex );
+    
+    /*Find the Index value of the CCookieGroupData Object based on Group Id and appuid
+     * @param aGroupId Indicates group Id
+     * @param aAppUid Indicates appuid
+     * @aIndex On return of this method,it indicates the index value of CCookieGroupData object.  
+     */
+    TInt FindIndex(TUint32 aGroupId,TUint32 aAppUid,TInt& aIndex );
+    
+    /* Gets the address of CCookieGroupData object from the array based on the index value.
+     * @param aIndex Indicates the index value
+     */
+    CCookieGroupData* GetGroupData(TInt aIndex);
+    
+    /* Adding CCookieGroupData object in to the array
+     * @param address of CCookieGroupData object
+    */
+    void AddGroupDataL(CCookieGroupData* aCookieGroupData);
+    
+    /* Getting the address of CCookieGroupData object based on index value
+     * 
+     */
+    CCookieGroupData* At(TInt aIndex) const;
+    
+    /* Subscripting Operator
+     * 
+     */
+    CCookieGroupData* operator[](TInt aIndex) const;
+    
+    /* Return the number of CCookieGroupData objects from the array.
+     * 
+     */
+    TInt Count()const;
+     
+    /* Returns the address of CCookieArray object based on Index Value
+     * 
+     */
+    CCookieArray* CookieArray(TInt aIndex);
+    
+    /** 
+    * Get the relevant cookies for a transaction
+    * @param aRequestUri The URI of the current HTTP request.
+    * @param aCookies An array which will be filled with the cookies
+    * for aTransaction based on the index value.
+    * @param aIndex Indiactes Index Value.
+    */    
+    TInt GetCookies( const TDesC8& aRequestUri,RPointerArray<CCookie>& aCookies,TInt aIndex ) const;
+    
+    /* Removes CCookieGroupData object from the array based on Index value.
+     * @param aIndex Indicates index value.
+     */
+    void Remove(TInt aIndex);
+    
+    /* Compreses the Array
+     * 
+     */
+    void Compress();
+    
+    /* Destroys a CCookieGroupData object from the array based on Group id 
+     * 
+     */
+    TInt DestroyGroupData(TUint32 aGroupId);
+    
+protected:
+private:
+    
+    /* Constructor
+     * 
+     */
+    void ConstructL();
+    
+    /*Constructor
+     * 
+     */
+    CCookieGroupDataArray();
+public:
+    
+protected:
+    
+private:
+    RPointerArray<CCookieGroupData>* iCookieGroupData;
+    };
+
+#endif /* CCOOKIEGROUPDATAARRAY_H_ */
--- a/httpfilters/cookie/ManagerInc/CookieLogger.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/ManagerInc/CookieLogger.h	Thu Jul 22 16:38:27 2010 +0100
@@ -39,6 +39,7 @@
     ECookieArray    = 0x00000010,   ///< Log CCookieArray activity.
     EServerStart    = 0x00000020,   ///< Log server start-up activity.
     EClientConnect  = 0x00000040,   ///< Log client connecting activity.
+    ECookie         = 0x00000080,   ///< Log CCookie activity.
     ELogAll         = 0xFFFFFFFF    ///< Log all.
     };
 
--- a/httpfilters/cookie/ManagerInc/CookieManagerServer.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/ManagerInc/CookieManagerServer.h	Thu Jul 22 16:38:27 2010 +0100
@@ -25,15 +25,19 @@
 #include <http.h>
 #include <f32file.h>
 #include <e32def.h>
+#include <stringpool.h> 
 
 // Opcodes used in message passing between client and server
 enum TCookieServerRqst 
 	{
 	EStoreCookie,
-  EClearAllCookies,
+    EClearAllCookies,
 	EGetCookieSize,
 	EGetCookies,
-	ESetAppUid
+	ESetAppUid,
+	EDestroyCookies,
+	EGetCookieSharableFlag,
+	EClearAppUidCookies
     };
 
 // FORWARD DECLARATIONS
@@ -43,7 +47,9 @@
 class CCookieTimer;
 class CCookieManagerSession;
 class TCookiePacker;
-
+class CCookieGroupDataArray;
+class CGroupIdArray;
+class TXmlEngElement;
 // CLASS DECLARATIONS
 
 /**
@@ -83,7 +89,7 @@
     * Clears all cookies
     * @return The number of cookies removed
     */
-    TInt ClearAllCookies();
+    //TInt ClearAllCookies();
 
     /**
     * Returns a pointer to the stringpool we currently use.
@@ -94,7 +100,7 @@
     /**
     * Returns a poitner for the persistent cookies we currently have.
     */
-    CCookieArray* CookieArray();
+    //CCookieArray* CookieArray();
 
 
     /**
@@ -112,24 +118,69 @@
 	* @param aRequestUri The current HTTP request-URI.
 	* @param aIndex Cookie is inserted at the position of existing cookie, and exisiting cookie is removed.
     */
-    void StorePersistentCookieL( CCookie* aCookie, const TDesC8& aRequestUri, const TInt aIndex = -1 );
+    //void StorePersistentCookieL( CCookie* aCookie, const TDesC8& aRequestUri, const TInt aIndex = -1 );
 
 	/**
 	*
 	*/
-	TInt GetCookies( const TDesC8& aRequestUri,
-					RPointerArray<CCookie>& aCookies ) const;
+//	TInt GetCookies( const TDesC8& aRequestUri,
+//					RPointerArray<CCookie>& aCookies ) const;
 	
 	/**
 	*Sets the File Name of the Cookie File using AppUid				
     *@param aFileName The AppUid of the Application
     */
-    void SetFileName(TUint32& aAppUid);
+    //void SetFileName(TUint32& aAppUid);
     
     /**
     *@return the File Name of the Cookie file
     */    
     TDesC& GetFileName() const;
+    
+    /* Loading the group specific info from CookieGroupData.xml file
+     * 
+     */
+    TInt LoadGroupDataFromFileL( RFs& aFileSession );
+   
+    /* Parsing the  Xml elements
+     * 
+     */
+    void ParseElement( TXmlEngElement& aElement );
+    
+    /* 
+     * 
+     */    
+    CCookieArray* CookieArray( TInt aIndex );
+    
+    /*
+     * 
+     */
+    CCookieGroupDataArray* CookieGroupDataArray();
+    
+    /** 
+    * Get the relevant cookies for a transaction
+    * @param aRequestUri The URI of the current HTTP request.
+    * @param aCookies An array which will be filled with the cookies
+    * for aTransaction based on the index value.
+    * @param aIndex Indiactes Index Value.
+    */    
+    TInt GetCookies( const TDesC8& aRequestUri, RPointerArray<CCookie>& aCookies, TInt aIndex ) const;
+    
+    /* 
+     * 
+     */
+    CGroupIdArray* GroupIdArray();
+    
+    /*Changes Hexadecimal value to Decimal Value
+     * 
+     */
+    TInt ChangeToDecimal( TDes8& aBuf,TUint32& aUid );
+    
+    /* Extracting the attribute information from parsed xml element
+     * 
+     */
+    void SettingAttribute(TDesC8& aAttr, TDesC8& aVal,TUint32& aGroupId
+            , RArray<TUint32>& aSharedAppUidArray, TBool& aCookieSharableFlag  );
 
 private:
 	/**
@@ -162,7 +213,7 @@
 	* content we can process it by calling ParseCookiesFromBufferL method.
 	* @return The error code indicating the type of failure.
     */
-    TInt ReadCookiesFromFile();
+    //TInt ReadCookiesFromFile();
 
 
     /**
@@ -173,7 +224,7 @@
 	* cookie, but it may not neccessarily be true for ALL cookies.
 	* @return The error code indicating the type of failure.
     */
-    TInt WriteCookiesToFile();
+    //TInt WriteCookiesToFile();
 
 private:
     TUint32                 iSessionCount;
@@ -181,17 +232,18 @@
 
 	CCookieTimer*           iCloseTimer;
 
-	HBufC*                  iCookieFileName;
-
-    RFs 					iFs;
-    CCookieArray*			iPersistentCookies;	// new-style
+	//HBufC*                  iCookieFileName;
+    //RFs 					iFs;
+    //CCookieArray*			iPersistentCookies;	// new-style
 
     RStringPool             iStringPool;
 
 	// As we open our string pool only in ConstructL we cannot instantiate the
 	// cookie packer in the constructor :(
 	TCookiePacker*			iCookiePacker;
-
+	CCookieGroupDataArray*  iCookieGroupDataArray;
+	CGroupIdArray*          iGroupIdArray;
+	
 	};
 
 
--- a/httpfilters/cookie/ManagerInc/CookieManagerSession.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/ManagerInc/CookieManagerSession.h	Thu Jul 22 16:38:27 2010 +0100
@@ -77,27 +77,37 @@
 
 	private :	// internal methods
 
-		/**
+		/**Clear all Cookies from file system belongs to a Client
 		*
 		*/
 		TInt ClearAllCookies( const RMessage2& aMessage );
 
+		/** Clear all Cookies from File System based on appuid 
+        *
+        */
+        TInt ClearAllAppUidCookies( const RMessage2& aMessage );
+
 		/**
 		*
 		*/
 		TInt DoClearAllCookies( const RMessage2& aMessage );
 
-		/**
+        /**
+        *
+        */
+        TInt DoClearAllAppUidCookies( const RMessage2& aMessage );
+
+		/**Gets Cookie Size for a Url
 		*
 		*/
 		TInt DoGetCookieSize( const RMessage2& aMessage );
 
-		/**
+		/** Gets Cookie info for a Url
 		*
 		*/
 		TInt DoGetCookies( const RMessage2& aMessage );
 
-		/**
+		/**Stores cookie info for a specific url.
 		*
 		*/
 		void DoStoreCookieL( const RMessage2& aMessage );
@@ -122,12 +132,31 @@
 		*
 		*/
 		TInt StoreCookie( const RMessage2& aMessage );
-		
-		
-		/**
+
+		/**Sets the appuid for a request
 		*
 		*/
 		TInt SetAppUidL(const RMessage2& aMessage );
+		
+		/*Delets cookie from Server memory and writes the cookie Info in to a file 
+		 * 
+		 */
+		TInt DestroyCookies( const RMessage2& aMessage );
+		
+		/*
+		 * 
+		 */
+		TInt DoDestroyCookies( const RMessage2& aMessage );
+		
+		/*
+		 * 
+		 */
+        TInt GetCookieSharableFlag( const RMessage2& aMessage );
+
+        /*
+         * 
+         */
+	    TInt DoGetCookieSharableFlag( const RMessage2& aMessage );
 
 	private:
 		CCookieManagerServer&   iCookieServer;
@@ -145,7 +174,6 @@
 		// The size of the temporary cookie list in bytes
 		TInt iGetCookieListSize;
 
-//		CCookieArray* iTransientCookies;
 	};
 
 #endif //__COOKIEMANAGER_SESSION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/httpfilters/cookie/ManagerInc/GroupIdInfoArray.h	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,113 @@
+/*
+ * CGroupIdInfoArray.h
+ *
+ *  Created on: Nov 24, 2009
+ *      Author: mohanti
+ */
+
+#ifndef GROUPIDINFOARRAY_H_
+#define GROUPIDINFOARRAY_H_
+//System Includes
+#include <e32base.h>
+#include <e32def.h>
+#include <e32cmn.h>
+//User Includes
+
+//Constants
+
+/*This class is used to hold group related info present in the xml file
+ * 
+ */
+NONSHARABLE_CLASS( CGroupIdInfo ):public CBase
+    {
+  public:
+      /*Constructor
+       * 
+       */
+    static CGroupIdInfo* NewL(TUint32 aGroupId, const RArray<TUint32>& aAppuid, TBool aCookieSharableFlag = EFalse );
+    
+    /*Constructor
+     * 
+     */
+    static CGroupIdInfo* NewLC(TUint32 aGroupId, const RArray<TUint32>& aAppuid, TBool aCookieSharableFlag = EFalse );
+    
+    /*Standard Constructor
+     * 
+     */
+    CGroupIdInfo( TUint32 aGroupId,TBool aCookieSharableFlag = EFalse );
+    
+    /*Standard Destructor
+     * 
+     */
+    ~CGroupIdInfo();
+    
+    /*
+     * 
+     */
+    TInt GetGroupName(TUint32 aSecureId,TUint32& aGroupId);
+     
+    /*
+     * 
+     */
+    void AddClientL(TUint32 aClientId);
+    
+    /*
+     * 
+     */
+    TUint32 At(TInt aIndex) const;
+    
+    /*
+     * 
+     */
+    TUint32 operator[](TInt aIndex) const;
+    
+    /*
+     * 
+     */
+    const TUint32& GetGroupId();
+    TBool GetCookieSharableFlag();
+    TBool IsThisPartOfSharedGroup( TUint32& aClientId );
+  protected :
+  private:
+       
+      /*
+       * 
+       */
+      void ConstructL(const RArray<TUint32>& aAppuid);
+  public:    
+  protected:
+      
+  private:
+    TBool iCookieSharableFlag;  
+    TUint32 iGroupId;
+    //TUint32 iSecureId;
+    RArray<TUint32> iAppUid;//List of application uid with which Group Info is shared
+    };
+
+/*This class is used to hold an array of CGroupIdInfo objects
+ * 
+ */
+
+NONSHARABLE_CLASS( CGroupIdArray ): public CBase
+    {
+   public:
+       static CGroupIdArray* NewL();
+       static CGroupIdArray* NewLC();
+       void ConstructL();
+       ~CGroupIdArray();
+   protected:
+   private:
+       CGroupIdArray();
+   public:
+       TInt Count();
+       CGroupIdInfo& At(TInt aIndex) const;
+       CGroupIdInfo& operator[](TInt aIndex) const;
+       void AddGroupIdL(CGroupIdInfo* aCGroupIdInfo);
+       TInt GetGroupId(TUint32 aClientId,TUint32& aGroupId);
+       TInt GetGroupId(TUint32 aClientId,TUint32& aGroupId,TBool& aCookieSharableFlag);
+   protected:    
+   private:
+   RPointerArray<CGroupIdInfo>* iGroupIdInfoArray;     
+    };
+
+#endif /* GROUPIDINFOARRAY_H_ */
--- a/httpfilters/cookie/ManagerSrc/Cookie.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/ManagerSrc/Cookie.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -26,6 +26,7 @@
 
 	// User includes
 #include "cookie.h"
+#include "CookieLogger.h"
 #include "CookieCommonConstants.h"
 
 
@@ -55,7 +56,97 @@
 
 _LIT8( KLocalMonthNames, "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec" );
 
+#ifdef __TEST_COOKIE_LOG__
+static void LogCookieAttribute( const CCookie& aCookie, const RStringPool& aPool, TInt aId, const TDesC8& aTextName, CCookie::TCookieAttributeName aAttributeName )
+    {
+    _LIT(KDateFormat,"%D%M%Y%/0%1%/1%2%/2%3%/3 %:0%H%:1%T%:2%S.%C%:3");
+    THTTPHdrVal fieldVal;
 
+    const TInt attribErr = aCookie.Attribute( aAttributeName, fieldVal );
+    if ( attribErr == KErrNone )
+        {
+        switch ( fieldVal.Type() )
+            {
+        case THTTPHdrVal::KTIntVal:
+            CLOG( ( ECookie, 0, _L8( "{%3d}  [Int]  %S = (%d)"), aId, &aTextName, fieldVal.Int() ) );
+            break;
+
+        case THTTPHdrVal::KStrFVal:
+            {
+            RStringF fieldValStr = aPool.StringF( fieldVal.StrF() );
+            const TDesC8& fieldValDesC = fieldValStr.DesC();
+            CLOG( ( ECookie, 0, _L8( "{%3d}  [StrF] %S = (%S)"), aId, &aTextName, &fieldValDesC ) );
+            }
+            break;
+
+        case THTTPHdrVal::KStrVal:
+            {
+            RString fieldValStr = aPool.String( fieldVal.Str() );
+            const TDesC8& fieldValDesC = fieldValStr.DesC();
+            CLOG( ( ECookie, 0, _L8( "{%3d}  [Str]  %S = (%S)"), aId, &aTextName, &fieldValDesC ) );
+            }
+            break;
+
+        case THTTPHdrVal::KDateVal:
+            {
+            TDateTime date = fieldVal.DateTime();
+            TBuf<40> dateTimeString;
+            TTime t( date );
+            TRAP_IGNORE( t.FormatL( dateTimeString, KDateFormat ) );
+            TBuf8<40> dateTimeString8;
+            dateTimeString8.Copy( dateTimeString );
+            CLOG( ( ECookie, 0, _L8( "{%3d}  [Date] %S = (%S)"), aId, &aTextName, &dateTimeString8 ) );
+            } 
+            break;
+
+        default:
+            CLOG(( ECookie, 0, _L8("{%3d}  [????] %S = (%d)"), aId, &aTextName, fieldVal.Type() ));
+            break;
+            }
+        }
+    else
+        {
+        //CLOG( ( ECookie, 0, _L8( "{%3d}  LogCookie - absent: %S"), aId, &aTextName ) );
+        }
+    }
+#endif
+
+// ---------------------------------------------------------
+// CCookie::Log
+// ---------------------------------------------------------
+//
+void CCookie::Log( TInt aAssociatedId ) const
+    {
+	TInt associateId = aAssociatedId;
+	CLOG( ( ECookie, 0, _L( "-> CCookie::Log() - Associate Id:%d"), associateId ) );
+#ifdef __TEST_COOKIE_LOG__
+    const TInt count = iAttributes.Count();
+    CLOG( ( ECookie, 0, _L( "-> CCookie::Log() - %d attributes..."), count ) );
+    for( TInt i=0; i<count; i++ )
+        {
+        // Calculating/fetching size is enough to generate usable logs
+        const TCookieAttribute& attrib = iAttributes[ i ];
+        const TInt size = attrib.Size();
+        }
+
+    LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Name"), CCookie::EName );
+    LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Value"), CCookie::EValue );
+    LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Domain"), CCookie::EDomain );
+    LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Path"), CCookie::EPath );
+    LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Date"), CCookie::EDate );
+    LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Version"), CCookie::EVersion );
+    LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Expires"), CCookie::EExpires );
+    LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("MaxAge"), CCookie::EMaxAge );
+    LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Discard"), CCookie::EDiscard );
+    LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Port"), CCookie::EPort );
+    LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Secure"), CCookie::ESecure );
+    LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Comment"), CCookie::EComment );
+    LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Comment URI"), CCookie::ECommentURI );
+    CLOG( ( ECookie, 0, _L( "{%3d}         fromCookie2: %d, fromNetscapeVersion: %d"), aAssociatedId, FromCookie2(), FromNetscapeVersion() ) );
+    CLOG( ( ECookie, 0, _L( "{%3d}         expired: %d, persists: %d, unknownVer: %d"), aAssociatedId, Expired(), Persistent(), IsUnknownVersion() ) );
+    CLOG( ( ECookie, 0, _L( "<- CCookie::Log() - %d attributes..."), count ) );
+#endif
+    }
 
 
 // ---------------------------------------------------------
@@ -86,6 +177,18 @@
 	{
 	return new (ELeave) CCookie( aStringPool );
 	}
+// ---------------------------------------------------------
+// CCookie::NewL
+// ---------------------------------------------------------
+//
+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, aDomain, aPath, aPort);
+    CleanupStack::Pop( self );
+    return self;
+    }
 	
 
 // ---------------------------------------------------------
@@ -96,12 +199,15 @@
 	{
 	// go through each attribute closing any attribute strings	
 	TInt numAttributes = iAttributes.Count();
+	Log();
+	CLOG( ( ECookie, 0, _L( "-> CCookie::~CCookie - this: 0x%08x, numAttributes: %d"), this, numAttributes ) );
 	for ( TInt ii = 0; ii < numAttributes; ++ii )
 		{
 		iAttributes[ii].Close();
 		}
 
 	iAttributes.Close();
+	CLOG( ( ECookie, 0, _L( "<- CCookie::~CCookie - this: 0x%08x, count: %d"), this, numAttributes ) );
 	}
 
 
@@ -111,6 +217,7 @@
 //
 void CCookie::AddDefaultPathL( const TUriC8& aUri )
 	{
+	CLOG( ( ECookie, 0, _L( "-> CCookie::AddDefaultPathL") ) );
 	// RFC2965 : Defaults to the path of the request URL that generated the
 	// Set-Cookie2 response, up to and including the right-most /.
 	// Note : there is a contradiction as we must not include the right-most /
@@ -139,6 +246,7 @@
     THTTPHdrVal defPathVal( defPath );
 	SetAttribute( EPath, defPathVal, ETrue );// ignore the result 
     defPath.Close();
+    CLOG( ( ECookie, 0, _L( "<- CCookie::AddDefaultPathL") ) );
 	}
 
 // ---------------------------------------------------------
@@ -148,6 +256,7 @@
 EXPORT_C void CCookie::AddToRequestL( RHTTPHeaders aRequestHeaders,
 									 TInt aPartIndex ) const
 	{
+	CLOG( ( ECookie, 0, _L( "-> CCookie::AddToRequestL") ) );
 	const TStringTable& commonStringTable = RHTTPSession::GetTable();
 
 	// We're writing out the "Cookie:" string
@@ -169,15 +278,17 @@
 		}
 	else
 		{
+		CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - version is missing! - iSetCookie2: %d"), iSetCookie2 ) );
 		if ( iSetCookie2 )
 			{
 			// if this is a new-style cookie (it is from a Set-Cookie2 header),
 			// then it must have a Version attribute.
 			// TBD : or should we insert a '$Version=1' string instead?
+			CLOG( ( ECookie, 0, _L( "<- CCookie::AddToRequestL - KErrCorrupt!") ) );
 			User::Leave( KErrCorrupt );
 			}
 		}
-
+	CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - adding name...") ) );
 	// We're writing out the NAME attribute - it is a serious error if this
 	// attribute is missing
 	User::LeaveIfError( Attribute( CCookie::EName, hVal ) );
@@ -187,6 +298,7 @@
 							hVal,
 							aPartIndex );
 
+	CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - adding value...") ) );
 	// We're writing out the VALUE attribute - it is a serious error if this
 	// attribute is missing
 	User::LeaveIfError( Attribute( CCookie::EValue, hVal ) );
@@ -201,6 +313,7 @@
 	// Writing out Domain attribute
 	if ( Attribute( CCookie::EDomain, hVal ) == KErrNone && hVal.StrF().DesC().Length() > 0 )
         {
+        CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - adding domain...") ) );
 		aRequestHeaders.SetParamL( cookieString,
 								iStringPool.StringF( HTTP::EDomain,
 													commonStringTable ),
@@ -211,6 +324,7 @@
 	// Writing out Path attribute
 	if ( Attribute( CCookie::EPath, hVal ) == KErrNone )
         {
+        CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - adding path...") ) );
 		aRequestHeaders.SetParamL( cookieString,
 								iStringPool.StringF( HTTP::EPath,
 													commonStringTable ),
@@ -221,12 +335,14 @@
 	// Writing out Port attribute
 	if ( Attribute( CCookie::EPort, hVal ) == KErrNone )
         {
+        CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - adding port...") ) );
 		aRequestHeaders.SetParamL( cookieString,
 								iStringPool.StringF( HTTP::ECookiePort,
 													commonStringTable ),
 								hVal,
 								aPartIndex );
         }
+	CLOG( ( ECookie, 0, _L( "<- CCookie::AddToRequestL") ) );
 	}
 
 
@@ -238,13 +354,15 @@
 							( CCookie::TCookieAttributeName aAttributeName,
 								THTTPHdrVal& aAttributeVal) const
 	{
+	CLOG( ( ECookie, 0, _L( "-> CCookie::Attribute") ) );
 	TCookieAttribute attribute;
 	if ( FindAttribute( aAttributeName, attribute ) != KErrNotFound )
 		{
 		aAttributeVal = attribute.Value();
+		CLOG( ( ECookie, 0, _L( "<- CCookie::Attribute") ) );
 		return KErrNone;
 		}
-
+	CLOG( ( ECookie, 0, _L( "<- CCookie::Attribute") ) );
 	return KErrNotFound;
 	}
 
@@ -270,14 +388,16 @@
 						 THTTPHdrVal& aAttributeVal,
 						 TBool& aDefaulted ) const
 	{
+	CLOG( ( ECookie, 0, _L( "-> CCookie::Attribute ") ) );
 	TCookieAttribute attribute;
 	if ( FindAttribute( aAttributeName, attribute ) != KErrNotFound )
 		{
 		aAttributeVal = attribute.Value();
 		aDefaulted = attribute.Defaulted();
+		CLOG( ( ECookie, 0, _L( "<- CCookie::Attribute KErrNone") ) );
 		return KErrNone;
 		}
-
+	CLOG( ( ECookie, 0, _L( "<- CCookie::Attribute KErrNotFound") ) );
 	return KErrNotFound;
 	}
 
@@ -290,6 +410,7 @@
 							const THTTPHdrVal& aAttributeVal,
 							TBool aDefaulted )
 {
+    CLOG( ( ECookie, 0, _L( "-> CCookie::SetAttribute") ) );
 	TInt result( KErrNone );
 
 	TCookieAttribute attribute;
@@ -315,6 +436,7 @@
 			newAttribute.Close();
 			}
 		}
+	CLOG( ( ECookie, 0, _L( "<- CCookie::SetAttribute result: %d"),result ) );
 	return result;
 }
 
@@ -322,73 +444,199 @@
 // CCookie::CopyFromL
 // ---------------------------------------------------------
 //
-void CCookie::CopyFromL( const CCookie& aCopyFrom  )
+void CCookie::CopyFromL( const CCookie& aCopyFrom, const TDesC8& aDomain, const TDesC8& aPath, const TDesC8& aPort  )
     {
-	THTTPHdrVal attributevalue;
-    TBool aDefaulted( EFalse );
-
-    if ( aCopyFrom.Attribute( EName, attributevalue, aDefaulted ) != KErrNotFound )
+    CLOG( ( ECookie, 0, _L( "-> CCookie::CopyFromL ") ) );
+    TBool defaultDiscard( EFalse );
+    THTTPHdrVal attributevalue;
+    TBool defaulted( EFalse );
+    iSetCookie2 = aCopyFrom.iSetCookie2;
+    if ( aCopyFrom.Attribute( EName, attributevalue, defaulted ) != KErrNotFound )
         {
-        SetAttribute( EName, attributevalue, aDefaulted );
+        if ( attributevalue.Type() != THTTPHdrVal::KStrVal )
+             {
+             RString correctedStringType = iStringPool.OpenStringL( attributevalue.StrF().DesC() );
+             attributevalue.SetStr( correctedStringType );
+             SetAttribute( EName, attributevalue, defaulted );
+             correctedStringType.Close();
+             const TPtrC8 pVal( attributevalue.Str().DesC() );
+             CLOG( ( ECookie, 0, _L8( "CCookie::CopyFromL - attribute EName Value : %S" ), &pVal ) );
+             }
+        else 
+            {
+            SetAttribute( EName, attributevalue, defaulted );    
+            const TPtrC8 pVal( attributevalue.Str().DesC() );
+            CLOG( ( ECookie, 0, _L8( "CCookie::CopyFromL - attribute EName Value : %S" ), &pVal ) );
+            }
         }
 
-	if ( aCopyFrom.Attribute( EValue, attributevalue, aDefaulted ) != KErrNotFound )
+    if ( aCopyFrom.Attribute( EValue, attributevalue, defaulted ) != KErrNotFound )
         {
-        SetAttribute( EValue, attributevalue, aDefaulted );
-        }
-
-	if ( aCopyFrom.Attribute( EComment, attributevalue, aDefaulted ) != KErrNotFound )
-        {
-        SetAttribute( EComment, attributevalue, aDefaulted );
+         if ( attributevalue.Type() != THTTPHdrVal::KStrVal )
+            {
+            RString correctedStringType = iStringPool.OpenStringL( attributevalue.StrF().DesC() );
+            attributevalue.SetStr( correctedStringType );
+            SetAttribute( EValue, attributevalue, defaulted );
+            correctedStringType.Close();
+            const TPtrC8 pVal( attributevalue.Str().DesC() );
+            CLOG( ( ECookie, 0, _L8( "CCookie::CopyFromL - attribute EValue value: %S" ), &pVal ) );
+            }
+         else
+             {
+             SetAttribute( EValue, attributevalue, defaulted );
+             const TPtrC8 pVal( attributevalue.Str().DesC() );
+             CLOG( ( ECookie, 0, _L8( "CCookie::CopyFromL - attribute EValue Value : %S" ), &pVal ) );
+             }
         }
-
-	if ( aCopyFrom.Attribute( ECommentURI, attributevalue, aDefaulted ) != KErrNotFound )
+    if ( aCopyFrom.Attribute( EVersion, attributevalue, defaulted ) != KErrNotFound )
         {
-        SetAttribute( ECommentURI, attributevalue, aDefaulted );
+        SetAttribute( EVersion, attributevalue, defaulted );    
+        SetFromNetscape( EFalse );
         }
-
-	if ( aCopyFrom.Attribute( EDiscard, attributevalue, aDefaulted ) != KErrNotFound )
+    else
         {
-        SetAttribute( EDiscard, attributevalue, aDefaulted );
+        SetFromNetscape( ETrue );
         }
 
-	if ( aCopyFrom.Attribute( EDomain, attributevalue, aDefaulted ) != KErrNotFound )
+    if ( aCopyFrom.Attribute( EPath, attributevalue, defaulted ) != KErrNotFound )
         {
-        SetAttribute( EDomain, attributevalue, aDefaulted );
-        }
-
-	if ( aCopyFrom.Attribute( EMaxAge, attributevalue, aDefaulted ) != KErrNotFound )
-        {
-        SetAttribute( EMaxAge, attributevalue, aDefaulted );
+         if ( attributevalue.Type() != THTTPHdrVal::KStrFVal )
+             {
+             SetAttribute( EPath, attributevalue, defaulted );    
+             }
         }
-
-	if ( aCopyFrom.Attribute( EPath, attributevalue, aDefaulted ) != KErrNotFound )
+    else
         {
-        SetAttribute( EPath, attributevalue, aDefaulted );
-        }
-
-	if ( aCopyFrom.Attribute( EPort, attributevalue, aDefaulted ) != KErrNotFound )
-        {
-        SetAttribute( EPort, attributevalue, aDefaulted );
+        // defaulting
+        RStringF defPath = iStringPool.OpenFStringL( aPath );
+        THTTPHdrVal defPathVal( defPath );
+        SetAttribute( EPath, defPathVal, ETrue );// ignore the result 
+        defPath.Close();
         }
-
-	if ( aCopyFrom.Attribute( ESecure, attributevalue, aDefaulted ) != KErrNotFound )
-        {
-        SetAttribute( ESecure, attributevalue, aDefaulted );
-        }
+    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();
+                     }
+                }
+             
+             }
+             
+         }
+	
 
-	if ( aCopyFrom.Attribute( EVersion, attributevalue, aDefaulted ) != KErrNotFound )
-        {
-        SetAttribute( EVersion, attributevalue, aDefaulted );
-        }
-
-	if ( aCopyFrom.Attribute( EExpires, attributevalue, aDefaulted ) != KErrNotFound )
-        {
-        SetAttribute( EExpires, attributevalue, aDefaulted );
-        }
-
-    SetCookie2( aCopyFrom.FromCookie2() );
-
+    //SetCookie2( aCopyFrom.FromCookie2() );
+    // Other properties
+    
+    iSize = aCopyFrom.iSize;
+    iReceivedTime = aCopyFrom.iReceivedTime;
+    CLOG( ( ECookie, 0, _L( "<- CCookie::CopyFromL ") ) );
     }
 
 
@@ -411,6 +659,7 @@
 //
 TBool CCookie::Expired() const
 	{
+	CLOG( ( ECookie, 0, _L( "-> CCookie::Expired ") ) );
     // the cookie has expired if:
     // 1. it's Age > Max-Age
     // 2. current_date > expires
@@ -479,6 +728,7 @@
                 }
 			}
 		}
+	CLOG( ( ECookie, 0, _L( "<- CCookie::Expired retval : %d"),retval ) );
 	return retval;
 	}
 // ---------------------------------------------------------
@@ -487,7 +737,7 @@
 //
  TPtrC8 CCookie::RemoveQuotes( const TDesC8& aDes ) 
 	{
-   
+	CLOG( ( ECookie, 0, _L( "-> CCookie::RemoveQuotes ") ) );
 	TInt firstChar = 0;					// position of the first character
 	TInt lastChar = aDes.Length() - 1;	// position of the last character
 	TPtrC8 result;
@@ -518,7 +768,7 @@
 			result.Set( aDes.Mid( firstChar, lastChar - firstChar + 1 ) );
 			}
 		}
-
+	CLOG( ( ECookie, 0, _L( "<- CCookie::RemoveQuotes result : %d "),result ) );
     return result;
 	}
 
@@ -530,6 +780,7 @@
 //
 TBool CCookie::ExpiredNetscapeL( THTTPHdrVal aAttrVal) const
     {
+    CLOG( ( ECookie, 0, _L( "-> CCookie::ExpiredNetscapeL ") ) );
     TBool retval( EFalse );
     TPtrC8 datePtr8( aAttrVal.StrF().DesC() );
     TInt dateLen( datePtr8.Length() );
@@ -736,6 +987,7 @@
         retval = ETrue;
         }
     CleanupStack::PopAndDestroy( cleanupNum ); // temp1, temp2, desDate, desTime
+    CLOG( ( ECookie, 0, _L( "<- CCookie::ExpiredNetscapeL retval : %d "),retval ) );
     return retval;
     }
 
@@ -749,6 +1001,7 @@
                          const TInt aTokenCount, 
                          TInt* aTokens ) const
     {
+    CLOG( ( ECookie, 0, _L( "-> CCookie::FindTokens ") ) );
     TLex8 lex = aString;
     TChar ch;
     TInt tokenCount( 0 ), ii;
@@ -762,6 +1015,7 @@
             aTokens[tokenCount++] = lex.Offset()-1;
             }
         }
+    CLOG( ( ECookie, 0, _L( "<- CCookie::FindTokens tokenCount : %d"),tokenCount ) );
     return tokenCount;
     }
 
@@ -771,6 +1025,7 @@
 //
 TBool CCookie::Persistent() const
     {
+    CLOG( ( ECookie, 0, _L( "-> CCookie::Persistent ") ) );
     TBool result( EFalse );
 	THTTPHdrVal attrVal;
 
@@ -818,6 +1073,7 @@
                 }
             }
         }
+    CLOG( ( ECookie, 0, _L( "<- CCookie::Persistent result : %d"),result ) );
     return result;
     }
 
@@ -827,6 +1083,7 @@
 //
 TBool CCookie::IsUnknownVersion() const
     {
+    CLOG( ( ECookie, 0, _L( "-> CCookie::IsUnknownVersion ") ) );
     TBool unknownVersion( EFalse );
     THTTPHdrVal attrVal;
     if( Attribute( CCookie::EVersion, attrVal ) != KErrNotFound )
@@ -836,6 +1093,7 @@
             unknownVersion = ETrue;
             }
         }
+    CLOG( ( ECookie, 0, _L( "<- CCookie::IsUnknownVersion unknownVersion : %d"),unknownVersion ) );
     return unknownVersion;
     }
 
@@ -846,7 +1104,9 @@
 CCookie::CCookie( RStringPool aStringPool )
 : iStringPool( aStringPool ), iSetCookie2( EFalse ), iNetscape( EFalse )
 	{
+	CLOG( ( ECookie, 0, _L( "-> CCookie::CCookie ") ) );
 	iReceivedTime.UniversalTime();
+	CLOG( ( ECookie, 0, _L( "<- CCookie::CCookie ") ) );
 	}
 
 
@@ -857,6 +1117,7 @@
 void CCookie::ConstructL( RHTTPHeaders aRequestHeaders, TInt aPartIndex,
 						RStringF aFieldName, const TUriC8& aUri )
 	{
+	CLOG( ( ECookie, 0, _L( "-> CCookie::ConstructL ") ) );
 	const TStringTable& commonStringTable = RHTTPSession::GetTable();
 
 	// Determining if this object is constructed from a Set-Cookie2 HTTP header
@@ -865,7 +1126,7 @@
 
 	iSetCookie2 = ( aFieldName == setCookie2Name );
 
-    TBool DefaultDiscard( EFalse );
+    TBool defaultDiscard( EFalse );
 
 	THTTPHdrVal hVal;
 
@@ -1068,7 +1329,7 @@
             // in case of SetCookie2, also set Discard, defaulted
             if ( iSetCookie2 )
                 {
-                DefaultDiscard = ETrue;
+                defaultDiscard = ETrue;
                 }
            }
 
@@ -1106,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 );
@@ -1160,6 +1421,7 @@
                 }
             }
         }
+    CLOG( ( ECookie, 0, _L( "<- CCookie::ConstructL ") ) );
 	}
 
 
@@ -1171,16 +1433,18 @@
 TInt CCookie::FindAttribute( TCookieAttributeName aAttributeName,
 							TCookieAttribute& aAttribute ) const
 	{
+	CLOG( ( ECookie, 0, _L( "-> CCookie::FindAttribute ") ) );
 	const TInt numAttributes = iAttributes.Count();
 	for ( TInt index = 0; index < numAttributes; ++index )
 		{
 		if ( iAttributes[index].Name() == aAttributeName )
 			{
 			aAttribute = iAttributes[index];
+			CLOG( ( ECookie, 0, _L( "<- CCookie::FindAttribute index : %d"),index ) );
 			return index;
 			}
 		}
-
+	CLOG( ( ECookie, 0, _L( "<- CCookie::FindAttribute KErrNotFound") ) );
 	return KErrNotFound;
 	}
 
@@ -1190,11 +1454,13 @@
 //
 void CCookie::RemoveAttribute( TInt aIndex )
 	{
+	CLOG( ( ECookie, 0, _L( "-> CCookie::RemoveAttribute aIndex : %d"),aIndex ) );
 	iSize -= ( KCookieAttributePrefixLength + iAttributes[ aIndex ].Size() + 
                KCookieAttributeDefaultedLength + 
                KCookieAttributeFoundLength );
 	iAttributes[ aIndex ].Close();
 	iAttributes.Remove( aIndex );
+	CLOG( ( ECookie, 0, _L( "<- CCookie::RemoveAttribute aIndex : %d"),aIndex ) );
 	}
 
 // ---------------------------------------------------------
@@ -1203,12 +1469,14 @@
 //
 void CCookie::RemoveAttribute( TCookieAttributeName aAttributeName )
     {
+    CLOG( ( ECookie, 0, _L( "-> CCookie::RemoveAttribute - name: %d"), aAttributeName ) );
     TCookieAttribute attribute;
     TInt index( FindAttribute( aAttributeName, attribute ) );
     if( index != KErrNotFound )
         {
         RemoveAttribute( index );
         }
+    CLOG( ( ECookie, 0, _L( "<- CCookie::RemoveAttribute - name: %d, index: %d"), aAttributeName, index ) );
     }
 
 // ---------------------------------------------------------
@@ -1218,6 +1486,7 @@
 TInt CCookie::GetLocalOffset( HBufC8* aDate, TInt& aHour, 
                          TInt& aMinute, TInt& aLength ) const
     {
+    CLOG( ( ECookie, 0, _L( "-> CCookie::GetLocalOffset ") ) );
     TInt retval( 0 );
     TInt pos(0);
 //    TInt fwspos(0);
@@ -1309,6 +1578,7 @@
         lex1.Val( aMinute );
         CleanupStack::PopAndDestroy( temp ); // temp
         }
+    CLOG( ( ECookie, 0, _L( "<- CCookie::GetLocalOffset retval : %d "),retval ) );
     return retval;
     }
 
@@ -1321,9 +1591,11 @@
 //
 TInt CCookie::GetMilitaryOffset( HBufC8* /*aDate*/, TInt& aHour ) const
     {
+    CLOG( ( ECookie, 0, _L( "-> CCookie::GetMilitaryOffset  ") ) );
     // TODO: Add military timezone handling here...
     TInt retval( KErrNotFound );
     aHour = 0;
+    CLOG( ( ECookie, 0, _L( "<- CCookie::GetMilitaryOffset retval : %d "),retval ) );
     return retval;
     }
 
@@ -1336,6 +1608,7 @@
 TInt CCookie::GetTimeZone( HBufC8* aDate, TInt& aHour, 
                          TInt& aLength ) const
     {
+    CLOG( ( ECookie, 0, _L( "-> CCookie::GetTimeZone  ") ) );
     TInt retval( 0 );
     TInt zonepos = aDate->Find( KUT() );
     if ( zonepos != KErrNotFound )
@@ -1424,7 +1697,7 @@
         // get the length
         aLength = aDate->Length() - zonepos;
         }
-
+    CLOG( ( ECookie, 0, _L( "<- CCookie::GetTimeZone retval :%d "),retval ) );
     return retval;
     }
 
@@ -1436,6 +1709,7 @@
 //
 HBufC8* CCookie::GetCleanedDateTimeLC( HBufC8* aDate ) const
     {
+    CLOG( ( ECookie, 0, _L( "-> CCookie::GetCleanedDateTimeLC ") ) );
     // as http time might contain a "DayOfWeek," optional part
     // which is not understood by the parser, we need to 
     // remove it 
@@ -1502,6 +1776,7 @@
     *result = temp->Left( temp->Length() - length);
     // return ( temp->Left( temp->Length() - length).AllocLC() );
     CleanupStack::PopAndDestroy( temp );
+    CLOG( ( ECookie, 0, _L( "-> CCookie::GetCleanedDateTimeLC result : %d"),result ) );
     return result;
     }
 
@@ -1520,6 +1795,7 @@
 : iName( aName ),
 iDefaulted( aDefaulted )
 	{
+	CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute") ) );
 	iValue = aHdrVal.Copy();
 	
 
@@ -1528,28 +1804,34 @@
 		case THTTPHdrVal::KTIntVal :
 			{
 			iSize = sizeof( TInt );
+			CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute iSize :%d "),iSize ) );
 			break;
 			}
 		case THTTPHdrVal::KStrVal :
 			{
 			iSize = iValue.Str().DesC().Length();
+			CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute iSize :%d "),iSize ) );
 			break;
 			}
 		case THTTPHdrVal::KDateVal :
 			{
 			iSize = sizeof( TDateTime );
+			CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute iSize :%d "),iSize ) );
 			break;
 			}
 		case THTTPHdrVal::KStrFVal :
 			{
 			iSize = iValue.StrF().DesC().Length();
+			CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute iSize :%d "),iSize ) );
 			break;
 			}
 		default :	// THTTPHdrVal::KNoType
 			{
 			iSize = 0;
+			CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute iSize :%d "),iSize ) );
 			}
 		}
+	CLOG( ( ECookie, 0, _L( "<- CCookie::TCookieAttribute  ") ) );
 	}
 
 
@@ -1559,6 +1841,8 @@
 //
 CCookie::TCookieAttribute::TCookieAttribute()
 	{
+	CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute  ") ) );
+	CLOG( ( ECookie, 0, _L( "<- CCookie::TCookieAttribute  ") ) );
 	}
 
 
@@ -1568,18 +1852,22 @@
 //
 void CCookie::TCookieAttribute::Close()
 	{
+	CLOG( ( ECookie, 0, _L( "-> CCookie::Close  ") ) );
 	THTTPHdrVal::THTTPValType type = iValue.Type();
 	if ( type == THTTPHdrVal::KStrVal )
 		{
+		CLOG( ( ECookie, 0, _L( "-> CCookie::Close  KStrVal") ) );
 		iValue.Str().Close();
 		}
 	else if ( type == THTTPHdrVal::KStrFVal )
 		{
+		CLOG( ( ECookie, 0, _L( "-> CCookie::Close  KStrFVal") ) );
 		iValue.StrF().Close();
 		}
 
 	// TBD : iValue = THTTPHdrVal();?
 	iSize = 0;
+	CLOG( ( ECookie, 0, _L( "<- CCookie::Close  ") ) );
 	}
 
 
--- a/httpfilters/cookie/ManagerSrc/CookieArray.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/ManagerSrc/CookieArray.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -1027,3 +1027,84 @@
         Remove( 0 );
         };
     }
+// ---------------------------------------------------------
+// CCookieArray::ReserveL
+// ---------------------------------------------------------
+//
+void CCookieArray::ReserveL( TInt aNumberOfCookies )
+    {
+    iCookies.ReserveL( aNumberOfCookies );
+    }
+// ---------------------------------------------------------
+// CCookieArray::GetCookies
+// ---------------------------------------------------------
+//
+TInt CCookieArray::GetCookies( const TDesC8& aRequestUri,
+                               RPointerArray<CCookie>& aCookies, TBool& aFound )
+    {
+    CLOG( ( ECookieArray, 0,
+            _L( "-> CCookieArray::GetCookies for an URI" ) ) );
+    TUriParser8 uriParser;
+    TInt err = uriParser.Parse( aRequestUri );
+    if ( !err )
+        {
+        // 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() );
+        TPtrC8 requestScheme( uriParser.IsPresent( EUriScheme ) ?
+                            uriParser.Extract( EUriScheme ) : KNullDesC8() );
+
+        // now check the existing cookies
+        // remove expired ones first, if there are any
+        RemoveExpired();
+        // and finally, find the cookies...
+        TInt count = iCookies.Count();
+        for ( TInt i = 0; i < count && err == KErrNone; i++ )
+            {
+            // Does the cookie have Path attribute?
+            TPtrC8 cookiePath;
+            if ( !GetFoldedCookieAttr( *iCookies[i],
+                                        CCookie::EPath,
+                                        cookiePath ) )
+                {
+                continue;
+                }
+
+            // Does the cookie have Domain attribute?
+            TPtrC8 cookieDomain;
+            if ( !GetFoldedCookieAttr( *iCookies[i],
+                                        CCookie::EDomain,
+                                        cookieDomain ) )
+                {
+                continue;
+                }
+
+            TPtrC8 cookiePort;
+            GetFoldedCookiePortAttr( *iCookies[i], cookiePort );
+
+            if ( PathMatch( requestPath, cookiePath ) &&
+                DomainMatch( requestDomain, cookieDomain, ETrue ) &&
+                PortMatch( requestPort, cookiePort ) &&
+                SecureMatch( requestScheme, *iCookies[i] ) )
+                {
+                CCookie* clone = CCookie::CloneL( *iCookies[i],requestDomain,requestPath,requestPort );
+                CleanupStack::PushL( clone );
+                err = aCookies.Append(clone);
+                CleanupStack::Pop(clone);
+                aFound = ETrue;
+                }
+            }
+        aCookies.Sort( TLinearOrder<CCookie> (CCookieArray::CompareCookiesPath) );
+        }
+    
+    
+
+    CLOG( ( ECookieArray, 0,
+            _L( "<- CCookieArray::GetCookies  for an URI" ) ) );
+    return err;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/httpfilters/cookie/ManagerSrc/CookieClientData.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,213 @@
+/*
+ * CookieClientData.cpp
+ *
+ *  Created on: Dec 28, 2009
+ *      Author: mohanti
+ */
+//User Includes
+#include "CookieClientData.h"
+#include "cookie.h"
+#include "CookieArray.h"
+#include "CookieLogger.h"
+#include "CookieCommonConstants.h"
+#include <uri8.h>
+
+// ---------------------------------------------------------
+// CCookieGroupData::NewL
+// ---------------------------------------------------------
+//
+CCookieClientData* CCookieClientData::NewL(TUint32 aGroupId)
+    {
+    CCookieClientData* self = CCookieClientData::NewLC(aGroupId);
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CCookieClientData::NewLC
+// ---------------------------------------------------------
+//
+CCookieClientData* CCookieClientData::NewLC(TUint32 aGroupId)
+    {
+    CCookieClientData* self = new (ELeave) CCookieClientData(aGroupId);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+// ---------------------------------------------------------
+// CCookieGroupData::NewL
+// ---------------------------------------------------------
+//
+CCookieClientData* CCookieClientData::NewL(TUint32 aGroupId,TUint32 aWidgetUid,TBool aCookieSharableFlag, TBool aInitFlag)
+    {
+    CCookieClientData* self = CCookieClientData::NewLC(aGroupId, aWidgetUid, aCookieSharableFlag, aInitFlag);
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CCookieClientData::NewLC
+// ---------------------------------------------------------
+//
+CCookieClientData* CCookieClientData::NewLC(TUint32 aGroupId,TUint32 aWidgetUid,TBool aCookieSharableFlag, TBool aInitFlag)
+    {
+    CCookieClientData* self = new (ELeave) CCookieClientData(aGroupId, aWidgetUid, aCookieSharableFlag, aInitFlag);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CCookieClientData::CCookieClientData
+// ---------------------------------------------------------
+//
+CCookieClientData::CCookieClientData(TUint32 aGroupId,TUint32 aWidgetUid ,TBool aCookieSharableFlag , TBool aInitFlag)
+:iInitFlag(aInitFlag),iCookieSharableFlag(aCookieSharableFlag),iGroupId(aGroupId),iWidgetUid(aWidgetUid)
+    {
+    
+    }
+// ---------------------------------------------------------
+// CCookieClientData::CCookieClientData
+// ---------------------------------------------------------
+//
+CCookieClientData::CCookieClientData(TUint32 aGroupId):iInitFlag(EFalse),iCookieSharableFlag(EFalse),iGroupId(aGroupId),iWidgetUid(0)
+    {
+    
+    }
+// ---------------------------------------------------------
+// CCookieGroupData::ConstructL
+// ---------------------------------------------------------
+//
+void CCookieClientData::ConstructL()
+    {
+    iCookieArray = new (ELeave) CCookieArray;
+    }
+
+// ---------------------------------------------------------
+// CCookieClientData::~CCookieClientData
+// ---------------------------------------------------------
+//
+CCookieClientData::~CCookieClientData()
+    {
+    CLOG(( EClient, 0, _L("-> CCookieClientData::~CCookieClientData iCookieArray: 0x%08x"), iCookieArray ));
+    delete iCookieArray;
+    iCookieArray = NULL;
+    CLOG(( EClient, 0, _L("<- CCookieClientData::~CCookieClientData") ));
+    }
+
+// ---------------------------------------------------------
+// CCookieClientData::StorePersistentCookieL
+// ---------------------------------------------------------
+//
+void CCookieClientData::StorePersistentCookieL( const CCookie* aCookie,
+                                                 const TDesC8& aRequestUri,
+                                                 const TInt aIndex )
+    {
+    CLOG(( EClient, 0, _L("-> RCookieManager::StorePersistentCookieL") ));
+    if (aIndex == -1)
+        {
+        iCookieArray->AddL( aCookie, aRequestUri);
+        }
+    else
+        {
+        iCookieArray->InsertL( aCookie, aIndex);
+        }
+    CLOG(( EClient, 0, _L("<- RCookieManager::StorePersistentCookieL") ));
+    }
+
+// ---------------------------------------------------------
+// RCookieManager::StoreCookieAtClientSideL
+// ---------------------------------------------------------
+//
+void CCookieClientData::StoreCookieAtClientSideL(const CCookie* aCookie,const TDesC8& aUri )
+    {
+    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;
+    
+    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();
+        if ( perscookiearray->DoesAlreadyExists( clone, index ) )
+        { // must overwrite !!!
+        // but first add the new one if needed
+        // just not to give a chance of beeing lost...
+        // persistence of the cookie will be handled on 
+        // saving all cookies to disk
+        perscookiearray->MakeRoomForInsertIfNeededL(clone, aUri, index);            
+        if(index >=0)
+            {
+            // insert cookie at valid index 
+            //iCookieClientData->StorePersistentCookieL(aCookie,aUri,index);
+            StorePersistentCookieL(clone,aUri,index);
+            //iCookieClientData->StorePersistentCookieL( aCookie, aUri, index );
+            // remove the old cookie
+            perscookiearray->Remove( index + 1 );
+            }
+        else
+            {   // invalid index means old cookie has been deleted in the process of making room
+                // append the new cookie to the end of array
+            //iCookieClientData->StorePersistentCookieL( aCookie, aUri );
+            StorePersistentCookieL( clone, aUri );
+            }
+        }
+    else
+        { // it is not in the array yet, add it now
+        //iCookieClientData->StorePersistentCookieL( aCookie, aUri );
+        StorePersistentCookieL( clone, aUri );
+        }
+    // Cookie supervisor API takes immediate ownership of both cookie and array
+    CleanupStack::Pop(clone);
+    CLOG(( EClient, 0, _L("<- RCookieManager::StoreCookieAtClientSideL") )); 
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupData::Count
+// ---------------------------------------------------------
+//
+TInt CCookieClientData::Count()const
+    {
+    return iCookieArray->Count(); 
+    }
+
+// ---------------------------------------------------------
+
+// ---------------------------------------------------------
+// CCookieGroupData::GetClientSideCookies
+// ---------------------------------------------------------
+//
+TInt CCookieClientData::GetClientSideCookies(const TDesC8& aRequestUri,RPointerArray<CCookie>& aCookies,TBool& aCookieFound )const
+    {
+    return iCookieArray->GetCookies(aRequestUri,aCookies,aCookieFound);
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupData::CookieArray
+// ---------------------------------------------------------
+//
+CCookieArray* CCookieClientData::CookieArray()
+    {
+    return iCookieArray;
+    }
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/httpfilters/cookie/ManagerSrc/CookieClientDataArray.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,236 @@
+/*
+ * CookieClientDataArray.cpp
+ *
+ *  Created on: Dec 18, 2009
+ *      Author: mohanti
+ */
+
+//System Includes
+#include <e32cmn.h>
+#include <e32base.h>
+#include <e32std.h>
+
+//User Includes
+#include "CookieClientDataArray.h"
+#include "cookiemanagerclient.h"
+#include "CookieArray.h"
+#include "CookieLogger.h"
+#include "CookieClientData.h"
+
+//Constatnts
+const TInt KCookieArrayGranularity = 10;
+
+
+// ---------------------------------------------------------
+// CCookieClientDataArray::New
+// ---------------------------------------------------------
+//
+
+CCookieClientDataArray* CCookieClientDataArray::New()
+    {
+    CCookieClientDataArray* arrayInstance = new CCookieClientDataArray();
+	if (arrayInstance)
+		{
+		arrayInstance->Init();
+		}
+    return arrayInstance ;
+    }
+
+CCookieClientDataArray::CCookieClientDataArray()
+    {
+    }
+
+void CCookieClientDataArray::Init()
+    {
+    iCookieClientData = new RPointerArray<CCookieClientData>(KCookieArrayGranularity);
+    }    
+
+// ---------------------------------------------------------
+// CCookieClientDataArray::~CCookieClientDataArray
+// ---------------------------------------------------------
+//
+CCookieClientDataArray::~CCookieClientDataArray()
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::~CCookieClientDataArray" ) ) );
+    if(iCookieClientData && iCookieClientData->Count())
+        {
+         iCookieClientData->ResetAndDestroy();
+         iCookieClientData->Close();
+         //delete iCookieClientData;
+         iCookieClientData = NULL;
+        }
+    CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::~CCookieClientDataArray" ) ) );
+    }
+
+// ---------------------------------------------------------
+// CCookieClientDataArray::Count
+// ---------------------------------------------------------
+//
+TInt CCookieClientDataArray::Count()const
+    {
+     if (iCookieClientData)
+       return iCookieClientData->Count();
+     else 
+       return 0;
+    }
+
+// ---------------------------------------------------------
+// CCookieClientDataArray::Compress
+// ---------------------------------------------------------
+//
+void CCookieClientDataArray::AddClientGroupDataL(CCookieClientData* aCookieClientData)
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::AddGroupDataL" ) ) );
+    iCookieClientData->AppendL(aCookieClientData);
+    CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::AddGroupDataL" ) ) );
+    }
+
+// ---------------------------------------------------------
+// CCookieClientDataArray::Compress
+// ---------------------------------------------------------
+//
+void CCookieClientDataArray::Compress()
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::Compress" ) ) );
+    iCookieClientData->Compress();
+    CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::Compress" ) ) );
+    }
+
+// ---------------------------------------------------------
+// CCookieClientDataArray::operator[]
+// ---------------------------------------------------------
+//
+CCookieClientData* CCookieClientDataArray::operator[](TInt aIndex) const
+    {
+    return (*iCookieClientData)[aIndex];
+    }
+
+// ---------------------------------------------------------
+// CCookieClientDataArray::At
+// ---------------------------------------------------------
+//
+CCookieClientData* CCookieClientDataArray::At(TInt aIndex) const
+    {
+    return (*iCookieClientData)[ aIndex ];
+    }
+// ---------------------------------------------------------
+// CCookieClientDataArray::Find
+// ---------------------------------------------------------
+//
+CCookieClientData*  CCookieClientDataArray::Find(const TUint32& aGroupId, const TUint32& aWidgetUid )
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::Find GroupId = %x, WidgetUid = %x" ),aGroupId,aWidgetUid ) );
+    TInt total = Count();
+    TBool WidgetUidFound = EFalse;
+    TInt index = 0;
+    for ( TInt i = 0;i<total;i++ )
+        {
+         if (At(i)->GetGroupId()== aGroupId && (At(i)->GetCookieSharableFlag()))
+           {
+            WidgetUidFound = ETrue;
+            index = i;
+            break;
+           }
+         else if (At(i)->GetGroupId()== aGroupId && !(At(i)->GetCookieSharableFlag()) 
+            && (At(i)->GetWidgetUid()== aWidgetUid))
+           {
+            WidgetUidFound = ETrue;
+            index = i;
+            break;
+           }
+        }
+  if ( WidgetUidFound )
+      {
+      CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::Find found with index = %d" ),index ) );
+      return At(index);
+      }
+  else
+      {
+      CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::Find not found " ) ) );
+      return NULL;
+      }
+    }
+// ---------------------------------------------------------
+// CCookieClientDataArray::FindIndex
+// ---------------------------------------------------------
+//
+TInt CCookieClientDataArray::FindIndex(const TUint32& aGroupId, const TUint32& aWidgetUid,TInt& aIndex )
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::FindIndex GroupId = %x,WidgetUid = %x" )
+            ,aGroupId,aWidgetUid ) );
+    TInt total = Count();
+    TBool WidgetUidFound = EFalse;
+    TInt index = 0;
+    for ( TInt i = 0;i<total;i++ )
+        {
+         if (At(i)->GetGroupId()== aGroupId && (At(i)->GetCookieSharableFlag()))
+           {
+            WidgetUidFound = ETrue;
+            index = i;
+            break;
+           }
+         else if (At(i)->GetGroupId()== aGroupId && !(At(i)->GetCookieSharableFlag()) 
+            && (At(i)->GetWidgetUid()== aWidgetUid))
+           {
+            WidgetUidFound = ETrue;
+            index = i;
+            break;
+           }
+        }
+  if ( WidgetUidFound )
+      {
+      aIndex = index;
+      CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::FindIndex found with index = %d" ),index ) );
+      return KErrNone;
+      }
+  else
+      {
+      CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::FindIndex not found " ) ) );
+      return KErrNotFound;
+      }
+    }
+
+// ---------------------------------------------------------
+// CCookieClientDataArray::CookieArray
+// ---------------------------------------------------------
+//
+CCookieArray* CCookieClientDataArray::CookieArray(TInt aIndex)
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::CookieArray Index =%d" ),aIndex ) );
+    CCookieClientData* cookieclientdata = At(aIndex);
+    return cookieclientdata->CookieArray();
+    }
+
+
+// ---------------------------------------------------------
+// CCookieClientDataArray::Remove
+// ---------------------------------------------------------
+//
+void CCookieClientDataArray::Remove(TInt aIndex)
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::Remove %d" ), aIndex ) );
+    delete (*iCookieClientData)[ aIndex ];
+    iCookieClientData->Remove(aIndex);
+    iCookieClientData->Compress();
+    CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::Remove " )) );
+    }
+
+
+// ---------------------------------------------------------
+// CCookieClientDataArray::DestroyGroupData
+// ---------------------------------------------------------
+//
+TInt CCookieClientDataArray::DestroyClientData(const TUint32 aAppUid)
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::DestroyClientData" ) ) );
+    TUint32 groupid = RProcess().SecureId().iId;
+    TInt index = -1;
+    TInt err = FindIndex(groupid,aAppUid,index);
+    if ( err == KErrNone )
+      {
+       Remove(index);
+      }
+    CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::DestroyClientData removed index = %d" ),index ) );
+    return err;
+    }
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/httpfilters/cookie/ManagerSrc/CookieGroupData.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,457 @@
+/*
+ * CCookieGroupData.cpp
+ *
+ *  Created on: Nov 24, 2009
+ *      Author: mohanti
+ */
+
+//System Includes
+#include <e32base.h>
+#include <sysutil.h>
+#include <e32cmn.h>
+
+//User Includes
+#include "CookieGroupData.h"
+#include "CookieArray.h"
+#include "cookieipc.h"
+#include "CookieLogger.h"
+//Constants
+
+// Literals
+_LIT( KDefaultCookieFolder, "C:\\Private\\" );
+_LIT( KDefaultCookieFile,   "\\Cookies" );
+_LIT( KDefaultExtension, ".dat");
+_LIT( KUnderScore, "_");
+
+//Member Functions
+
+// ---------------------------------------------------------
+// CCookieGroupData::NewL
+// ---------------------------------------------------------
+//
+CCookieGroupData* CCookieGroupData::NewL(TUint32 aGroupId, const RArray<TUint32>& aAppuid, TBool aCookieSharableFlag)
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupData::NewL" ) ) );
+    
+    CCookieGroupData* self = CCookieGroupData::NewLC(aGroupId,aAppuid,aCookieSharableFlag);
+    CleanupStack::Pop();
+    
+    CLOG( ( EClient, 0, _L( "<- CCookieGroupData::NewL" ) ) );
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupData::NewLC
+// ---------------------------------------------------------
+//
+CCookieGroupData* CCookieGroupData::NewLC(TUint32 aGroupId,const RArray<TUint32>& aAppuid,TBool aCookieSharableFlag)
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupData::NewLC" ) ) );
+    
+    CCookieGroupData* self = new (ELeave) CCookieGroupData(aGroupId,aCookieSharableFlag);
+    CleanupStack::PushL(self);
+    self->ConstructL(aAppuid);
+    
+    CLOG( ( EClient, 0, _L( "<- CCookieGroupData::NewLC:" ) ) );
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupData::CCookieGroupData
+// ---------------------------------------------------------
+//
+CCookieGroupData::CCookieGroupData(TUint32 aGroupId, TBool aCookieSharableFlag)
+  :iGroupId(aGroupId),iCookieSharableFlag(aCookieSharableFlag)
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupData::CCookieGroupData:" ) ) );
+    CLOG( ( EClient, 0, _L( "<- CCookieGroupData::CCookieGroupData:" ) ) );
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupData::CookieArray
+// ---------------------------------------------------------
+//
+CCookieArray* CCookieGroupData::CookieArray()
+    {
+    return iCookieArray;
+    }
+TInt CCookieGroupData::TotalAppUid()
+    {
+    return iSharedUid.Count();
+    }
+// ---------------------------------------------------------
+// CCookieGroupData::~CCookieGroupData
+// ---------------------------------------------------------
+//
+CCookieGroupData::~CCookieGroupData()
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupData::~CCookieGroupData:" ) ) );
+    
+    WriteCookiesToFile();
+    delete iCookieArray;
+    delete iCookieFileName;
+    iStringPool.Close();
+    delete iCookiePacker;
+    iFs.Close();
+    iSharedUid.Close();
+    CLOG( ( EClient, 0, _L( "<- CCookieGroupData::~CCookieGroupData:" ) ) );
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupData::StorePersistentCookieL
+// ---------------------------------------------------------
+//
+void CCookieGroupData::StorePersistentCookieL( CCookie* aCookie,
+                                                 const TDesC8& aRequestUri,
+                                                 const TInt aIndex )
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupData::StorePersistentCookieL:aRequestUri = %S" ), &aRequestUri) );
+    
+    if (aIndex == -1)
+        {
+        iCookieArray->AddL( aCookie, aRequestUri);
+        }
+    else
+        {
+        iCookieArray->InsertL( aCookie, aIndex);
+        }
+    
+    CLOG( ( EClient, 0, _L( "<- CCookieGroupData::StorePersistentCookieL:" ) ) );
+
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupData::Count
+// ---------------------------------------------------------
+//
+TInt CCookieGroupData::Count()const
+    {
+    return iCookieArray->Count();
+    }
+
+TUint32 CCookieGroupData::operator[](TInt aIndex) const
+    {
+    return (iSharedUid[aIndex]);
+    }
+
+// ---------------------------------------------------------
+// CGroupIdInfo::At
+// ---------------------------------------------------------
+//
+TUint32 CCookieGroupData::At(TInt aIndex) const
+    {
+    return (iSharedUid[ aIndex ]);
+    }
+
+// ---------------------------------------------------------
+// CGroupIdInfo::GetSharedUid
+// ---------------------------------------------------------
+//
+TUint32 CCookieGroupData::GetSharedUid(TInt aIndex)
+    {
+    return At(aIndex);
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupData::ConstructL
+// ---------------------------------------------------------
+//
+void CCookieGroupData::ConstructL(const RArray<TUint32>& aAppuid)
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupData::ConstructL:" ) ) );
+    TInt count = aAppuid.Count();
+    CLOG( ( EClient, 0, _L( "-> CGroupIdArray::count = %d" ), count ) );
+    for(TInt i=0; i<count; i++)
+        {
+        CLOG( ( EClient, 0, _L( "-> CGroupIdArray::aAppuid[%d] = %x " ), aAppuid[i] ) );
+        iSharedUid.AppendL(aAppuid[i]);
+        }
+    iCookieArray = new (ELeave) CCookieArray;
+    iStringPool.OpenL();
+    iCookiePacker = new (ELeave) TCookiePacker( iStringPool );
+    iCookieFileName = HBufC::NewL( KCookieMaxFileNameLength );
+
+    TPtr fileName( iCookieFileName->Des() );
+    fileName.Copy( KDefaultCookieFolder );
+    //fileName.AppendNum( iGroupId, EHex );
+    fileName.AppendNum( RProcess().SecureId(), EHex );
+    TBuf<KMaxFileName> buf(KDefaultCookieFile);
+    buf.Append(KUnderScore);
+    buf.AppendNum(iGroupId,EHex);
+    //For Widget case file name shobe becookie_<sid>_<appuid>.dat
+    if(!iCookieSharableFlag && iSharedUid[0]!=0)
+        {
+        buf.Append(KUnderScore);
+        buf.AppendNum(iSharedUid[0],EHex);
+        }
+    fileName.Append(buf);
+    fileName.Append(KDefaultExtension);
+    if ( iFs.Connect() == KErrNone )
+        {
+        ReadCookiesFromFile();
+        }
+
+    CLOG( ( EClient, 0, _L( "<- CCookieGroupData:::ConstructL:" ) ) );
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupData::ReadCookiesFromFile
+// ---------------------------------------------------------
+//
+TInt CCookieGroupData::ReadCookiesFromFile()
+    {
+    CLOG( ( EServer, 0,_L( "-> CCookieGroupData::ReadCookiesFromFile" ) ) );
+    
+    TInt err;
+    if ( iCookieFileName->Length() != 0 )
+        {
+//        RFs iFs;
+//        User::LeaveIfError(iFs.Connect());
+        RFile file;
+        err = file.Open( iFs, *iCookieFileName,
+                            EFileShareExclusive | EFileStream | EFileRead );
+            if ( err == KErrNone )  // the file does exist and could be opened
+                {
+                TInt size;
+                err = file.Size( size );
+                if ( err == KErrNone )  // size query was successful
+                    {
+                    HBufC8* fileBuffer = HBufC8::New( size );
+                    if ( fileBuffer )// there was enough memory for fileBuffer
+                        {
+                        TPtr8 fileBufferDes( fileBuffer->Des() );
+                        err = file.Read( fileBufferDes );
+                        if ( err == KErrNone )
+                            {
+                            // unfortunately this method might leave, because
+                            // it allocates memory for cookies dynamically
+                            TRAP( err,
+                                iCookiePacker->UnpackCookiesFromBufferL
+                                                ( *fileBuffer, iCookieArray->CookieArray() ) );
+                            if ( err != KErrNone )
+                                {
+                                delete fileBuffer;
+                                file.Close();
+                                iFs.Delete(*iCookieFileName); //Delete file.
+                                //iFs.Close();
+                                return KErrNotFound;
+                                }
+                            }
+
+                        delete fileBuffer;
+                        }
+                    else
+                        {
+                        err = KErrNoMemory;
+                        }
+                    }
+
+                file.Close();
+                //iFs.Close();
+            }
+        }
+    else    // if iCookieFileName->Length() == 0
+        {
+        err = KErrNotFound;
+        }
+
+    CLOG( ( EServer, 0,_L( "<- CCookieGroupData::ReadCookiesFromFile, errcode%d"), err ) );
+
+    return err;
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupData::WriteCookiesToFile
+// ---------------------------------------------------------
+//
+TInt CCookieGroupData::WriteCookiesToFile()
+    {
+    CLOG( ( EServer, 0,_L( "-> CCookieGroupData::WriteCookiesToFile" ) ) );
+//    RFs iFs;
+//    User::LeaveIfError(iFs.Connect());
+
+    TInt err(KErrNone);
+    if ( !iCookieArray->Count() )
+        {
+         CLOG( ( EServer, 0,_L( "<- CCookieGroupData::WriteCookiesToFile, errcode%d" ), KErrNone ));
+
+         // delete cookie file
+         err = iFs.Delete( *iCookieFileName );
+         return err;
+        }
+
+    if ( iCookieFileName->Length() != 0 )
+        {
+        if ( CheckDiskSpace( iFs, *iCookieFileName ) )
+            {
+            iFs.CreatePrivatePath( EDriveC );
+            RFile file;
+            iFs.MkDirAll(*iCookieFileName);
+            err = file.Replace( iFs, *iCookieFileName,
+                            EFileShareExclusive | EFileStream | EFileWrite );
+                if ( err == KErrNone )
+                    {
+                    // get the maximum length of cookies
+                    TInt cookieCount( iCookieArray->Count() );
+                    TInt size( 0 );
+                    TInt maxSize( 0 );
+                    for( TInt i = 0; i < cookieCount; i++ )
+                        {
+                        if ( (*iCookieArray)[i]->Persistent() &&
+                             !(*iCookieArray)[i]->Expired() )
+                            {
+                            size = (*iCookieArray)[i]->Size( EFalse );
+                            if( size > maxSize )
+                                {
+                                maxSize = size;
+                                }
+                            }
+                        }
+                    maxSize++;
+                    CLOG( ( EServer, 0, _L("maxSize: %d"), maxSize ) );
+                    // allocate buffer for it
+                    HBufC8* fileBuffer = HBufC8::New( maxSize );
+                    if ( fileBuffer )
+                        {
+                        TPtr8 fileBufferDes = fileBuffer->Des();
+
+                        // we ignore a possible packing or file writing error
+                        // in this loop as these kinds of errors are not fatal
+                        // and may not reappear during the next iteration
+                        for ( TInt i = 0; i < cookieCount; i++ )
+                            {
+                        if ( (*iCookieArray)[i]->Persistent() &&
+                             !(*iCookieArray)[i]->Expired() )
+                            {
+                                fileBufferDes.SetLength(0);
+
+                                // use CliPackCookie as SrvPackCookie will
+                                // suppress the defaulted domain attribute...
+                                err = iCookiePacker->CliPackCookie( fileBufferDes,
+                                                                (*(*iCookieArray)[i]) );
+
+                                if ( err == KErrNone )
+                                    {
+                                    err = file.Write( *fileBuffer );
+                                    }
+                                }
+                            }
+
+                        delete fileBuffer;
+                        }
+                    else
+                        {
+                        err = KErrNoMemory;
+                        }
+
+                    file.Close();
+                    //iFs.Close();
+                    }
+                }
+            else    // there is not enough disk space
+                {
+                err = KErrDiskFull;
+            }
+        }
+    else    // if ( iCookieFileName->Length() == 0 )
+        {
+        err = KErrNotFound;
+        }
+
+    CLOG( ( EServer, 0,
+        _L( "<- CCookieGroupData::WriteCookiesToFile, errcode%d" ), err ) );
+
+    return err;
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupData::CheckDiskSpace
+// ---------------------------------------------------------
+//
+TBool CCookieGroupData::CheckDiskSpace( RFs& aFileSystem,
+                                           const TDesC& aFileName ) const
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupData::CheckDiskSpace:" ) ) );
+
+    TInt err;
+    TParse parse;
+    err = parse.SetNoWild( aFileName, NULL, NULL );
+    if ( err == KErrNone )
+        {
+        // This is in the form : drive-letter: (letter + semi-colon)
+        TBuf<2> driveBuf( parse.Drive() );
+        TCharF driveLetter( driveBuf[0] );
+        TCharF driveALetter( 'A' );
+        TDriveNumber driveNum = (TDriveNumber)( (TUint)(driveLetter) -
+                                                (TUint)(driveALetter) );
+
+        TBool noSpace = EFalse;
+        TRAP( err, noSpace = SysUtil::DiskSpaceBelowCriticalLevelL
+                    ( &aFileSystem, KCookieMaxFileLength, driveNum ) );
+        if ( err == KErrNone && noSpace )
+            {
+            err = KErrDiskFull;
+            }
+        }
+    CLOG( ( EClient, 0, _L( "<- CCookieGroupData::CheckDiskSpace:" ) ) );
+    
+    return ( err == KErrNone ? ETrue : EFalse );
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupData::ClearCookies
+// ---------------------------------------------------------
+//
+TInt CCookieGroupData::ClearAllCookies()
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupData::ClearAllCookies:" ) ) );
+    
+    TInt count = iCookieArray->ClearAllCookies();
+    iFs.Delete( *iCookieFileName );
+
+    CLOG( ( EClient, 0, _L( "<- CCookieGroupData::ClearAllCookies:count = %d " ), count ) );
+    return count;
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupData::GetFileName
+// ---------------------------------------------------------
+//
+const TDesC& CCookieGroupData::GetFileName() const
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupData:::GetFileName" ) ) );
+
+    if ( iCookieFileName )
+        {
+        CLOG( ( EClient, 0, _L( "<- CCookieGroupData::GetFileName:iCookieFileName = %S" ), &iCookieFileName ) );
+        return *iCookieFileName;
+        }
+    CLOG( ( EClient, 0, _L( "<- CCookieGroupData::GetFileName:iCookieFileName = %S" ), &iCookieFileName ) );
+    return KNullDesC();
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupData::SetFileName
+// ---------------------------------------------------------
+//
+void CCookieGroupData::SetFileName(TUint32& aAppUid,TUint32& aSecureId)
+    {
+    CLOG( ( EClient, 0, _L( "<- CCookieGroupData::SetFileName" ) ) );
+    *iCookieFileName = KNullDesC;
+    TPtr fileName( iCookieFileName->Des() );
+    fileName.Copy( KDefaultCookieFolder );
+    fileName.AppendNum( RProcess().SecureId(), EHex );
+    TBuf<KMaxFileName> buf(KDefaultCookieFile);
+    buf.Append(KUnderScore);
+    buf.AppendNum(aSecureId,EHex);
+    //For Widget case file name shobe becookie_<sid>_<appuid>.dat
+    if(!iCookieSharableFlag && iSharedUid[0]!=0)
+        {
+        buf.Append(KUnderScore);
+        buf.AppendNum(aAppUid,EHex);
+        }
+    fileName.Append(buf);
+    fileName.Append(KDefaultExtension);
+    CLOG( ( EClient, 0, _L( "<- CCookieGroupData::SetFileName" ) ) );
+    }
+//eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/httpfilters/cookie/ManagerSrc/CookieGroupDataArray.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,336 @@
+/*
+ * CCookieGroupDataArray.cpp
+ *
+ *  Created on: Nov 24, 2009
+ *      Author: mohanti
+ */
+//System Includes
+#include <e32cmn.h>
+#include <e32base.h>
+
+//User Includes
+#include "CookieGroupDataArray.h"
+#include "CookieGroupData.h"
+#include "GroupIdInfoArray.h"
+#include "CookieArray.h"
+#include "CookieLogger.h"
+
+//Constatnts
+const TInt KCookieArrayGranularity = 10;
+
+
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::NewL
+// ---------------------------------------------------------
+//
+
+CCookieGroupDataArray* CCookieGroupDataArray::NewL()
+    {
+    CCookieGroupDataArray* self = CCookieGroupDataArray::NewLC();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::NewLC
+// ---------------------------------------------------------
+//
+
+CCookieGroupDataArray* CCookieGroupDataArray::NewLC()
+    {
+    CCookieGroupDataArray* self = new (ELeave) CCookieGroupDataArray();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::ConstructL
+// ---------------------------------------------------------
+//
+
+void CCookieGroupDataArray::ConstructL()
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupDataArray::ConstructL" ) ) );
+    iCookieGroupData = new (ELeave) RPointerArray<CCookieGroupData>(KCookieArrayGranularity);
+    CLOG( ( EClient, 0, _L( "<- CCookieGroupDataArray::ConstructL" ) ) );
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::CCookieGroupDataArray
+// ---------------------------------------------------------
+//
+
+CCookieGroupDataArray::CCookieGroupDataArray()
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupDataArray::CCookieGroupDataArray" ) ) );
+    CLOG( ( EClient, 0, _L( "<- CCookieGroupDataArray::CCookieGroupDataArray" ) ) );
+    }
+// ---------------------------------------------------------
+// CCookieGroupDataArray::~CCookieGroupDataArray
+// ---------------------------------------------------------
+//
+
+CCookieGroupDataArray::~CCookieGroupDataArray()
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupDataArray::~CCookieGroupDataArray" ) ) );
+    if(iCookieGroupData && Count())
+        {
+         iCookieGroupData->ResetAndDestroy();
+         iCookieGroupData->Close();
+         //delete iCookieGroupData;
+         iCookieGroupData = NULL;
+        }
+    CLOG( ( EClient, 0, _L( "<- CCookieGroupDataArray::~CCookieGroupDataArray" ) ) );
+    }
+// ---------------------------------------------------------
+// CCookieGroupDataArray::Count
+// ---------------------------------------------------------
+//
+TInt CCookieGroupDataArray::Count()const
+    {
+    return iCookieGroupData->Count(); 
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::FindIndex
+// ---------------------------------------------------------
+//
+TInt CCookieGroupDataArray::FindIndex(TUint32 aGroupId,TInt& aIndex )
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupDataArray::FindIndex aGroupId = %x" ), aGroupId ) );
+    TInt count = Count();
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupDataArray::count = %d" ), count ) );
+    for(TInt i=0;i<count;i++)
+        {
+        CCookieGroupData* p = At(i);
+        if( p->GetGroupId() == aGroupId)
+            {
+            aIndex=i;
+            CLOG( ( EClient, 0, _L( "<- CCookieGroupDataArray::FindIndex found for GroupId %x with Index = %d" )
+                    , aGroupId,aIndex ) );
+            return KErrNone;
+            }
+        }
+     CLOG( ( EClient, 0, _L( "<- CCookieGroupDataArray::FindIndex NotFound for GroupId %x with Index = %d" )
+             , aGroupId ,aIndex) );    
+     return KErrNotFound;
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::FindIndex
+// ---------------------------------------------------------
+//
+TInt CCookieGroupDataArray::FindIndex(TUint32 aGroupId,TUint32 aAppUid,TInt& aIndex )
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupDataArray::FindIndex aGroupId = %x,aAppUid = %x" ), aGroupId, aAppUid ) );
+    TInt count = Count();
+    for(TInt i=0;i<count;i++)
+        {
+        CCookieGroupData* p = At(i);
+        TInt appCount = p->TotalAppUid();
+        TInt appUidFound(EFalse);
+        if( p->GetGroupId() == aGroupId)
+            {
+             for(TInt j=0; j<appCount; j++)
+                 {
+                  if (p->GetSharedUid(j)== aAppUid)
+                      appUidFound = ETrue;
+                  break;
+                 }
+             if (appUidFound)
+                 {
+                 aIndex=i;
+                 return KErrNone;
+                 }
+            }
+        }
+     return KErrNotFound;
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::Compress
+// ---------------------------------------------------------
+//
+void CCookieGroupDataArray::AddGroupDataL(CCookieGroupData* aCcookieGroupData)
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupDataArray::AddGroupDataL" ) ) );
+    iCookieGroupData->AppendL(aCcookieGroupData);
+    CLOG( ( EClient, 0, _L( "<- CCookieGroupDataArray::AddGroupDataL" ) ) );
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::Compress
+// ---------------------------------------------------------
+//
+void CCookieGroupDataArray::Compress()
+    {
+    iCookieGroupData->Compress();
+    }
+
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::operator[]
+// ---------------------------------------------------------
+//
+CCookieGroupData* CCookieGroupDataArray::operator[](TInt aIndex) const
+    {
+    return (*iCookieGroupData)[aIndex];
+    }
+
+  // ---------------------------------------------------------
+  // CCookieGroupDataArray::GetGroupData
+  // ---------------------------------------------------------
+  //
+CCookieGroupData* CCookieGroupDataArray::At(TInt aIndex) const
+    {
+    return (*iCookieGroupData)[ aIndex ];
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::GetGroupData
+// ---------------------------------------------------------
+//
+CCookieGroupData* CCookieGroupDataArray::GetGroupData(TInt aIndex)
+    {
+    return(At(aIndex));
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::GetGroupDataIndexL
+// ---------------------------------------------------------
+//
+void CCookieGroupDataArray::GetGroupDataIndexL(TUint32 aGroupId,TUint32 aAppUid,TBool& aCookieSharableFlag, TInt& aIndex)
+    {
+     CLOG( ( EClient, 0, _L( "-> CCookieGroupDataArray::GetGroupDataIndexL aGroupId = %x, aAppUid = %x" ), aGroupId, aAppUid ) );
+     TInt count = Count();
+     TBool found(EFalse);
+     CLOG( ( EClient, 0, _L( "-> CCookieGroupDataArray::GetGroupDataIndexL count = %d" ), count ) );
+     if ( count == 0 )
+         {
+         RArray<TUint32> appUidArray(1);
+         appUidArray.Append(aAppUid);
+         CCookieGroupData* cookiegroupdata = CCookieGroupData::NewL(aGroupId,appUidArray,aCookieSharableFlag);
+         CleanupStack::PushL( cookiegroupdata );
+         AddGroupDataL(cookiegroupdata);
+         aIndex = 0;
+         CleanupStack::Pop(cookiegroupdata);
+         appUidArray.Close();
+         } else {
+                
+                TInt totalappUid = iCookieGroupData->Count();
+                for ( TInt i=0; i<count; i++ )
+                   {
+                    CCookieGroupData* cookiegroupdata = At(i);
+                    if ( cookiegroupdata->GetGroupId() == aGroupId && !(cookiegroupdata->GetCookieSharableFlag()) )
+                      {
+                      found = ETrue;
+                      aIndex = i;
+                      break;
+                      }else if (cookiegroupdata->GetGroupId() == aGroupId && (cookiegroupdata->GetCookieSharableFlag()))
+                          {
+                           TBool groupMatch(ETrue);
+                           TBool sharedUidMatch(EFalse);
+                           TInt total = cookiegroupdata->TotalAppUid();
+                           for(TInt j=0;j<total;j++)
+                              {
+                               if (cookiegroupdata->GetSharedUid(j)== aAppUid)
+                                   {
+                                       sharedUidMatch = ETrue;
+                                       break;
+                                   }
+                              }
+                           if (groupMatch || sharedUidMatch)
+                               {
+                               found = ETrue;
+                               aIndex = i;
+                               break;
+                               }
+                          }
+                          
+                        
+                   CLOG( ( EClient, 0, _L( "-> CCookieGroupDataArray::GetGroupDataIndexL aGroupId %x and aAppUid %x found at index %d" ), aGroupId, aAppUid, aIndex ) );
+                      }
+                    }
+               if(!found)
+                {
+                 RArray<TUint32> appUidArray(1);
+                 appUidArray.Append(aAppUid);
+                 CCookieGroupData* cookiegroupdata = CCookieGroupData::NewL(aGroupId, appUidArray, aCookieSharableFlag);
+                 CleanupStack::PushL( cookiegroupdata );
+                 AddGroupDataL(cookiegroupdata);
+                 TInt total = Count();
+                 aIndex = total-1;
+                 CleanupStack::Pop(cookiegroupdata);
+                 appUidArray.Close();
+                }
+     CLOG( ( EClient, 0, _L( "<- CCookieGroupDataArray::GetGroupDataIndexL" ) ) );
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::CookieArray
+// ---------------------------------------------------------
+//
+CCookieArray* CCookieGroupDataArray::CookieArray(TInt aIndex)
+    {
+    CCookieGroupData* cookiegroupdata = At(aIndex);
+    return cookiegroupdata->CookieArray();
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::GetCookies
+// ---------------------------------------------------------
+//
+TInt CCookieGroupDataArray::GetCookies( const TDesC8& aRequestUri,
+                                      RPointerArray<CCookie>& aCookies,TInt aIndex ) const
+    {
+    CCookieArray* cookieArray = At(aIndex)->CookieArray();
+    return cookieArray->GetCookies( aRequestUri, aCookies );
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::Remove
+// ---------------------------------------------------------
+//
+void CCookieGroupDataArray::Remove(TInt aIndex)
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupDataArray:: Remove %d" ), aIndex ) );
+    delete (*iCookieGroupData)[ aIndex ];
+    iCookieGroupData->Remove(aIndex);
+    iCookieGroupData->Compress();
+    CLOG( ( EClient, 0, _L( "<- CCookieGroupDataArray::Remove " ) ) );
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::DestroyGroupData
+// ---------------------------------------------------------
+//
+TInt CCookieGroupDataArray::DestroyGroupData(TUint32 aGroupId)
+    {
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupDataArray::DestroyGroupData aGroupId = %x" ), aGroupId ) );
+    TInt count = Count();
+    CLOG( ( EClient, 0, _L( "-> CCookieGroupDataArray::DestroyGroupData count = %d" ), count ) );
+    if (count == 0)
+        {
+         return KErrNotFound;
+        }
+    
+    TBool found(EFalse);
+    for (TInt i=0; i<count; i++)
+        {
+        CCookieGroupData* cookiegroupdata = At(i);
+        if ( cookiegroupdata->GetGroupId() == aGroupId)
+            {
+            found = ETrue;
+            Remove(i);
+            --i;
+            --count;
+            CLOG( ( EClient, 0, _L( "<- CCookieGroupDataArray::DestroyGroupData aGroupId = %x removed from Array" ), aGroupId ) );
+            }
+        }
+    if ( found )
+        return KErrNone;
+	else
+		return KErrNotFound;
+    }
--- a/httpfilters/cookie/ManagerSrc/CookieIPC.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/ManagerSrc/CookieIPC.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -526,7 +526,11 @@
 
 	while ( bufferPtr < bufferEndPtr )
 		{
+		// coverity [alloc_fn]
+		// coverity [assign]	
 		CCookie* cookie = CCookie::NewL( iStringPool );
+		
+		// coverity [push]
 		CleanupStack::PushL( cookie );
 
 		UnpackCookieL( bufferPtr, *cookie );
@@ -540,9 +544,11 @@
 			// The cookie pointer array (i.e. iCookies) takes over the
 			// ownership
 			User::LeaveIfError( aCookies.Append( cookie ) );
-
+			
+			// coverity [pop]
 			CleanupStack::Pop();	// cookie
 			}
+		// coverity [memory_leak]	
 		}
     }
 
--- a/httpfilters/cookie/ManagerSrc/CookieManagerClient.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/ManagerSrc/CookieManagerClient.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -23,6 +23,7 @@
 
 	// User includes
 #include "cookie.h"
+#include "CookieArray.h"
 #include "cookieipc.h"
 #include "CookieCommonConstants.h"
 #include "CookieLogger.h"
@@ -30,9 +31,9 @@
 #include "CookieManagerServer.h"
 #include "CookieManagerStart.h"
 #include "CookieServerDef.h"
-
+#include "CookieClientDataArray.h"
+#include "CookieClientData.h"
 // CONSTANTS
-
 // TBD : do we have to set limits to the number of cookies at all?
 // Possible answer : as we store cookies in an RPointerArray that has a
 // restriction on the number of elements (max. 640 can be stored in an RArray
@@ -48,7 +49,7 @@
 // ---------------------------------------------------------
 //
 EXPORT_C RCookieManager::RCookieManager( RStringPool aStringPool )
-: iStringPool( aStringPool ), iCookiePacker( iStringPool )
+: iStringPool( aStringPool ),iCookieMgrData(NULL)
     {
     CLOG(( EClient, 0, _L(" ") ));
     CLOG(( EClient, 0, _L("*****************") ));
@@ -80,7 +81,10 @@
 EXPORT_C TInt RCookieManager::Connect()
     {
     CLOG( ( EClientConnect, 0, _L( "-> RCookieManager::Connect" ) ) );
-
+    iCookieMgrData = new TCookieMgrInternalStruct(iStringPool);
+    if (!(iCookieMgrData && iCookieMgrData->Init() == KErrNone))
+        return KErrNoMemory;
+            
     TInt error = KErrNone;
     RProcess server;
     error = server.Create( KCookieServerExe, TPtr( NULL, 0 ),
@@ -116,7 +120,7 @@
     }
 
 // ---------------------------------------------------------
-// RCookieManager::GetCookies
+// RCookieManager::DoGetCookies
 // ---------------------------------------------------------
 //
 TInt RCookieManager::DoGetCookies( TDes8& aBuffer ) const
@@ -125,25 +129,53 @@
 	}
 
 // ---------------------------------------------------------
-// RCookieManager::GetCookieSize
+// RCookieManager::GetCookieSharableFlagFromServer
+// ---------------------------------------------------------
+//
+TInt RCookieManager::GetCookieSharableFlagFromServer(TBool& aCookieSharableFlag )const
+    {
+    TPckg<TBool> cookieSharableFlag(aCookieSharableFlag);
+    return SendReceive( EGetCookieSharableFlag, TIpcArgs( &cookieSharableFlag ) );
+    }
+
+// ---------------------------------------------------------
+// RCookieManager::DoGetCookieSize
 // ---------------------------------------------------------
 //
 TInt RCookieManager::DoGetCookieSize( const TDesC8& aRequestUri,
-									  TPckg<TInt>& aPkgSize ) const
+									  TPckg<TInt>& aPkgSize,TDesC& aAppuidPtr ) const
 	{
-    return SendReceive( EGetCookieSize, TIpcArgs( aRequestUri.Length(), 
+    return SendReceive( EGetCookieSize, TIpcArgs( &aAppuidPtr,aRequestUri.Length(), 
                                                   &aRequestUri, &aPkgSize ) );
 	}
+// ---------------------------------------------------------
+// RCookieManager::DestroyCookiesFromMemory
+// ---------------------------------------------------------
+//
+TInt RCookieManager::DestroyCookiesFromMemory( TInt& aDeleteStatus )
+    {
+    CLOG(( EClient, 0, _L("-> RCookieManager::DestroyCookies") ));
+
+    TPckg<TInt> pkgStatus( aDeleteStatus );
+    TInt ret = SendReceive( EDestroyCookies, TIpcArgs( &pkgStatus ) ) ;
+
+    CLOG(( EClient, 0, 
+        _L("<- RCookieManager::DestroyCookies cleared %d cookies, errcode%d"),
+        aDeleteStatus, ret ) );
+
+    return ret;
+
+    }
 
 // ---------------------------------------------------------
 // RCookieManager::DoStoreCookie
 // ---------------------------------------------------------
 //
 TInt RCookieManager::DoStoreCookie( const TDesC8& aPackedCookie,
-								   const TDesC8& aUri ) const
+								   const TDesC8& aUri,TDesC& aAppUidPtr ) const
 	{
     return SendReceive( EStoreCookie, TIpcArgs( aPackedCookie.Length(), 
-                                      &aPackedCookie, aUri.Length(), &aUri ) );
+                                      &aPackedCookie, &aUri,&aAppUidPtr ) );
 	}
 
 // ---------------------------------------------------------
@@ -155,13 +187,31 @@
 										TBool& aCookie2Reqd )
     {
     CLOG( ( EClient, 0, _L( "-> RCookieManager::GetCookiesL" ) ) );
+    TBool cookiefound(EFalse);
+    CCookieClientDataArray* cookieclientdataarray = iCookieMgrData->GetCookieClientDataArray();
+    
+    if(cookieclientdataarray) 
+        {
+    TInt clientarraycount = cookieclientdataarray->Count();
+    if ( clientarraycount!=0 )
+        {
+        TInt clerr = GetClientSideCookies(aUri,aCookies,cookiefound,0);
+        }
+      } 
 
+    if(!cookiefound)
+        {
 	aCookie2Reqd = EFalse;
 
 	TInt size = 0;
 	TPckg<TInt> pkgSize( size );
-	User::LeaveIfError( DoGetCookieSize( aUri, pkgSize ) );
-
+	//Appuid value only takes 8 chars
+    HBufC* appbuf = HBufC::New(8);
+    TPtr ptr(appbuf->Des());
+    TUint32 appUid(0);
+    ptr.AppendNum(appUid,EHex);    
+	User::LeaveIfError( DoGetCookieSize( aUri, pkgSize,ptr ) );
+    delete appbuf;
 	if ( size )
 		{
 		HBufC8* buf = HBufC8::NewLC( size );
@@ -171,8 +221,7 @@
 
 		// it seems this is the only place where we cannot avoid leaving
 		// ==> we allocate memory for cookies when we fill up the cookie array.
-		iCookiePacker.UnpackCookiesFromBufferL( *buf, aCookies );
-
+		iCookieMgrData->GetCookiePacker().UnpackCookiesFromBufferL( *buf, aCookies );
 		TInt count = aCookies.Count();
 		TInt i = 0;
 		TBool anyCookie2( EFalse );
@@ -196,7 +245,7 @@
 
 		CleanupStack::PopAndDestroy();	// buf
 		}
-
+      }
     CLOG( ( EClient, 0, _L( "<- RCookieManager::GetCookiesL" ) ) );
     }
 
@@ -208,7 +257,7 @@
 								 const TUriC8& aUri )
     {
     CLOG( ( EClient, 0, _L( "-> RCookieManager::StoreCookie" ) ) );
-
+    StoreCookieAtClientSide(&aCookie,aUri.UriDes()); 
 	TInt err;
 
 	TInt cookieSize = aCookie.Size( EFalse );
@@ -220,10 +269,17 @@
                 cookieSize ) );
 
 		TPtr8 bufDes( buf->Des() );
-		err = iCookiePacker.CliPackCookie( bufDes, aCookie );
+		err = iCookieMgrData->GetCookiePacker().CliPackCookie( bufDes, aCookie );
 		if ( !err )
 			{
-			err = DoStoreCookie( *buf, aUri.UriDes() );
+			//Appuid value only takes 8 chars
+            HBufC* appbuf = HBufC::New(8);
+            TPtr ptr(appbuf->Des());
+            TUint32 appUid(0);
+            ptr.AppendNum(appUid,EHex);    
+            err = DoStoreCookie( *buf, aUri.UriDes(),ptr );
+            delete appbuf;
+			//err = DoStoreCookie( *buf, aUri.UriDes() );
 			}
 
 		delete buf;
@@ -253,18 +309,307 @@
     }
     
 // ---------------------------------------------------------
-// RCookieManager::SetAppUidL
+// RCookieManager::SetAppUidL This method is no longer being 
+// used in CookieFilter.As this method is exported so in order
+// to provide backward compatibilty this API implementation is changed 
 // ---------------------------------------------------------
 //
 EXPORT_C TInt RCookieManager::SetAppUidL( const TUint32& aAppUid )
     {
     CLOG(( EClient, 0, _L("->RCookieManager::SetAppUid") ));   
-    HBufC* buf = HBufC::NewLC(128);
+    TUint32 groupid = RProcess().SecureId().iId;
+    CCookieClientData* cookieclientdata = iCookieMgrData->GetCookieClientDataArray()->Find(groupid, const_cast<TUint32&> (aAppUid));
+    if(cookieclientdata)
+        {
+        cookieclientdata->SetWidgetUid(aAppUid);
+        }
+    else
+        {
+        TBool cookieSharableFlag(EFalse);
+        TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag);
+        cookieclientdata = CCookieClientData::NewL(groupid, aAppUid, cookieSharableFlag,ETrue);
+        cookieclientdata->SetInitFlag(ETrue);
+        iCookieMgrData->GetCookieClientDataArray()->AddClientGroupDataL(cookieclientdata);
+        }
+    //Appuid value only takes 8 chars
+    HBufC* buf = HBufC::NewLC(8);
     TPtr ptr(buf->Des());
-    ptr.AppendNum(aAppUid,EHex);    
+    ptr.AppendNum(aAppUid,EHex);
     TInt error = SendReceive(ESetAppUid,TIpcArgs(ptr.Length(),&ptr)); 
     CleanupStack::PopAndDestroy();
     CLOG(( EClient, 0, _L("<-RCookieManager::SetAppUid") ));
     return error;
     }
+// ---------------------------------------------------------
+// RCookieManager::Close
+// ---------------------------------------------------------
+//
+
+EXPORT_C void RCookieManager::Close()
+    {
+    CLOG(( EClient, 0, _L("-> RCookieManager::Close") ));
+    TInt deletestatus =0;
+    DestroyCookiesFromMemory(deletestatus);
+    delete iCookieMgrData;
+    iCookieMgrData = NULL;
+    CLOG(( EClient, 0, _L("-> RCookieManager::Close deletestatus = %d"), deletestatus ));
+    RSessionBase::Close();
+    CLOG(( EClient, 0, _L("<- RCookieManager::Close") ));
+    }
+// ---------------------------------------------------------
+// RCookieManager::StoreCookie Newly Added
+// ---------------------------------------------------------
+//
+EXPORT_C TInt RCookieManager::StoreCookie( const CCookie& aCookie,
+                                 const TUriC8& aUri,TUint32& aAppUid )
+    {
+    CLOG( ( EClient, 0, _L( "-> RCookieManager::StoreCookie" ) ) );
+    StoreCookieAtClientSide(&aCookie,aUri.UriDes(),aAppUid);
+    TInt err;
+
+    TInt cookieSize = aCookie.Size( EFalse );
+    HBufC8* buf = HBufC8::New( cookieSize );
+    if ( buf )
+        {
+        CLOG( ( EClient, 0,
+                _L( "RCookieManager::StoreCookie, cookie size:%d" ), 
+                cookieSize ) );
+
+        TPtr8 bufDes( buf->Des() );
+        err = iCookieMgrData->GetCookiePacker().CliPackCookie( bufDes, aCookie );
+        
+        if ( !err )
+            {
+            //Appuid value only takes 8 chars
+            HBufC* appbuf = HBufC::New(8);
+            TPtr ptr(appbuf->Des());
+            ptr.AppendNum(aAppUid,EHex);    
+            err = DoStoreCookie( *buf, aUri.UriDes(),ptr );
+            delete appbuf;
+            }
+
+        delete buf;
+        }
+    else
+        {
+        err = KErrNoMemory;
+        }
+
+    CLOG( ( EClient, 0,
+            _L( "<- RCookieManager::StoreCookie errcode%d" ), err ) );
+
+    return err;
+    }
+
+// ---------------------------------------------------------
+// RCookieManager::GetCookiesL Newly Added
+// ---------------------------------------------------------
+//
+EXPORT_C void RCookieManager::GetCookiesL( const TDesC8& aUri,
+                                        RPointerArray<CCookie>& aCookies,
+                                        TBool& aCookie2Reqd,TUint32& aAppUid )
+    {
+    CLOG( ( EClient, 0, _L( "-> RCookieManager::GetCookiesL" ) ) );
+    TBool cookiefound(EFalse);
+    CCookieClientDataArray* cookieclientdataarray = iCookieMgrData->GetCookieClientDataArray();
+    if(cookieclientdataarray)
+        {
+         TInt clientarraycount = cookieclientdataarray->Count();
+         if (clientarraycount == 0)
+           {
+            TUint32 groupid = RProcess().SecureId().iId;
+            TBool cookieSharableFlag(EFalse);
+            TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag);
+            CCookieClientData* cookieclientdata = CCookieClientData::NewL(groupid, aAppUid, cookieSharableFlag,ETrue);
+            cookieclientdata->SetInitFlag(ETrue);
+            cookieclientdataarray->AddClientGroupDataL(cookieclientdata);
+           }
+         else
+           {
+        
+            CLOG( ( EClient, 0, _L( "-> RCookieManager::GetClientSideCookies:" ) ) );
+            //Gets the Cookie objects for aUri in case it is present
+            TInt clerr = GetClientSideCookies(aUri,aCookies,cookiefound,aAppUid);
+            CLOG( ( EClient, 0, _L( "RCookieManager::GetClientSideCookies:cookiefound = %d" ), cookiefound ) );
+        
+           }
+        } 
+    if(!cookiefound)
+        {
+            aCookie2Reqd = EFalse;
+            //Appuid value only takes 8 chars
+            HBufC* appuidbuf = HBufC::NewL(8);
+            TPtr ptr(appuidbuf->Des());
+            ptr.AppendNum(aAppUid,EHex);    
+            TInt size = 0;
+            TPckg<TInt> pkgSize( size );
+            User::LeaveIfError( DoGetCookieSize( aUri, pkgSize, ptr ) );
+            delete appuidbuf;
+        if ( size )
+            {
+            HBufC8* buf = HBufC8::NewLC( size );
+    
+            TPtr8 des( buf->Des() );
+            User::LeaveIfError( DoGetCookies( des ) );
+    
+            // it seems this is the only place where we cannot avoid leaving
+            // ==> we allocate memory for cookies when we fill up the cookie array.
+            iCookieMgrData->GetCookiePacker().UnpackCookiesFromBufferL( *buf, aCookies );
+            TInt count = aCookies.Count();
+            for(TInt j=0; j<count; j++)
+                {
+                CLOG( ( EClient, 0, _L( "-> RCookieManager::StoreClientSideCookies: aUri=%S" ), &aUri ) );
+                //cookieclientdata->StoreCookieAtClientSide( aCookies[j],aUri );
+                StoreCookieAtClientSide( aCookies[j],aUri,aAppUid );
+                }
+            TInt i = 0;
+            TBool anyCookie2( EFalse );
+            TBool anyUnknownVersion( EFalse );
+            for ( ; i < count; i++ )
+                {
+                if ( aCookies[i]->FromCookie2() )
+                    {
+                    anyCookie2 = ETrue;
+                    anyUnknownVersion |= aCookies[i]->IsUnknownVersion();
+                    }
+                }
+    
+            // if there were no new-style cookies or a new version info is detected
+            // then we have to send an extra cookie header indicating that we're 
+            // able to process new-style cookies
+            if ( !anyCookie2 || anyUnknownVersion )
+                {
+                aCookie2Reqd = ETrue;
+                }
+    
+            CleanupStack::PopAndDestroy();  // buf
+            }
+      }
+    CLOG( ( EClient, 0, _L( "<- RCookieManager::GetCookiesL" ) ) );
+    }
+
+// ---------------------------------------------------------
+// RCookieManager::Close for Widget related destruction during 
+//uninstallation process of a widget
+// ---------------------------------------------------------
+//
+EXPORT_C TInt RCookieManager::ClearAllAppUidCookies(const TUint32& aAppUid)
+    {
+    CLOG(( EClient, 0, _L("-> RCookieManager::ClearCookies") ));
+    //Client side cookie deletion specific to a appuid
+    iCookieMgrData->GetCookieClientDataArray()->DestroyClientData(aAppUid);
+    //Server side Cookie deletion specific to a appuid
+    //Appuid value only takes 8 chars
+    HBufC* buf = HBufC::NewLC(8);
+    TPtr ptr(buf->Des());
+    ptr.AppendNum(aAppUid,EHex);
+    TInt error = SendReceive(EClearAppUidCookies,TIpcArgs(ptr.Length(),&ptr)); 
+    CleanupStack::PopAndDestroy();
+    return error;
+    }
+
+// ---------------------------------------------------------
+// RCookieManager::StoreCookieAtClientSide
+// ---------------------------------------------------------
+//
+void RCookieManager::StoreCookieAtClientSide( const CCookie* aCookie, const TDesC8& aUri,TUint32 aWidgetUid )
+    {
+    CLOG( ( EClient, 0, _L( "-> RCookieManager::StoreCookieAtClientSide" ) ) );
+    TUint32 groupid = RProcess().SecureId().iId;
+    CCookieClientDataArray* cookieclientdataarray = iCookieMgrData->GetCookieClientDataArray();
+    CCookieClientData* cookieclientdata(NULL);
+    TInt count = cookieclientdataarray->Count();
+    if (count == 0)
+        {
+        TBool cookieSharableFlag(EFalse);
+        TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag);
+        cookieclientdata = CCookieClientData::NewL(groupid, aWidgetUid, cookieSharableFlag,ETrue);
+        cookieclientdata->SetInitFlag(ETrue);
+        cookieclientdataarray->AddClientGroupDataL(cookieclientdata);
+        cookieclientdata->StoreCookieAtClientSideL(aCookie,aUri);
+        return;
+        }
+    TInt itemIndex =0;
+    for(TInt i=0; i<count; i++)
+        {
+          if (cookieclientdataarray->At(i)->GetGroupId() == groupid 
+                  && cookieclientdataarray->At(i)->GetCookieSharableFlag())
+              {
+              itemIndex = i;
+              break;
+              }
+          else if(cookieclientdataarray->At(i)->GetGroupId() == groupid
+                  && !(cookieclientdataarray->At(i)->GetCookieSharableFlag()) 
+                  && cookieclientdataarray->At(i)->GetWidgetUid() == aWidgetUid)
+              {
+              itemIndex = i;
+              break;
+              }
+        }
+    cookieclientdata = cookieclientdataarray->At(itemIndex);
+    cookieclientdata->StoreCookieAtClientSideL(aCookie,aUri);
+    CLOG( ( EClient, 0, _L( "<- RCookieManager::StoreCookieAtClientSide" ) ) );
+    }
+
+// ---------------------------------------------------------
+// RCookieManager::GetClientSideCookies
+// ---------------------------------------------------------
+//
+TInt RCookieManager::GetClientSideCookies( const TDesC8& aRequestUri,RPointerArray<CCookie>& aCookies
+                ,TBool& aCookieFound, TUint32 aWidgetUid )
+    {
+    CLOG( ( EClient, 0, _L( "-> RCookieManager::GetClientSideCookies" ) ) );
+    TUint32 groupid = RProcess().SecureId().iId;
+    CCookieClientData* cookieclientdata = NULL;
+    CCookieClientDataArray* cookieclientdataarray = iCookieMgrData->GetCookieClientDataArray();
+    TInt count = cookieclientdataarray->Count();
+    if (count == 0)
+        {
+        TBool cookieSharableFlag(EFalse);
+        TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag);
+        cookieclientdata = CCookieClientData::NewL(groupid, aWidgetUid, cookieSharableFlag,ETrue);
+        cookieclientdata->SetInitFlag(ETrue);
+        cookieclientdataarray->AddClientGroupDataL(cookieclientdata);
+        } else 
+           {
+           cookieclientdata = cookieclientdataarray->Find(groupid, aWidgetUid);
+           }
+     if(cookieclientdata)
+        {
+         if(!cookieclientdata->GetInitFlag())
+           {
+            TBool cookieSharableFlag(EFalse);
+            TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag);
+            cookieclientdata->SetCookieCookieSharableFlag(cookieSharableFlag);
+           }
+           return cookieclientdata->GetClientSideCookies( aRequestUri,aCookies, aCookieFound );
+         } else 
+              {
+               TBool cookieSharableFlag(EFalse);
+               TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag);
+               if(err == KErrNone)
+                 {
+                   CCookieClientData* cookieclientdata 
+                    = CCookieClientData::NewL(groupid, aWidgetUid, cookieSharableFlag,ETrue);
+                    cookieclientdataarray->AddClientGroupDataL(cookieclientdata);
+                  }
+               }
+    CLOG( ( EClient, 0, _L( "<- RCookieManager::GetClientSideCookies" ) ) );
+    return KErrNone;
+    }
+
+RCookieManager::TCookieMgrInternalStruct::~TCookieMgrInternalStruct()
+    {
+    delete iCookieClientDataArray;
+    }
+
+TInt RCookieManager::TCookieMgrInternalStruct::Init()
+    {
+    iCookieClientDataArray = CCookieClientDataArray::New();
+    if (iCookieClientDataArray)
+        return KErrNone;
+    return KErrNoMemory;
+        
+    }
+
 // End of file
--- a/httpfilters/cookie/ManagerSrc/CookieManagerServer.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/ManagerSrc/CookieManagerServer.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -22,6 +22,14 @@
 #include <e32std.h>
 
 #include <sysutil.h>
+#include <bautils.h>
+#include <xmlengdomimplementation.h>
+#include <xmlengdocument.h>
+#include <xmlengdomparser.h>
+#include <xmlengattr.h>
+#include <xmlengnodelist.h>
+#include <xmlengelement.h>
+
 // #include <thttphdrval.h>
 
 // User includes
@@ -32,6 +40,9 @@
 #include "CookieManagerServer.h"
 #include "CookieManagerSession.h"
 #include "CookieServerDef.h"
+#include "CookieGroupDataArray.h"
+#include "GroupIdInfoArray.h"
+#include "CookieGroupData.h"
 
 // CONSTANTS
 
@@ -50,7 +61,7 @@
 #endif
 
 // This means 128 characters, considering Unicode
-const TInt KCookieMaxFileNameLength = 256;
+//const TInt KCookieMaxFileNameLength = 256;
 
 // Maximum file length
 //const TInt KCookieMaxFileLength = 204800;	// 200 kilobytes
@@ -58,12 +69,20 @@
 
 // Literals
 _LIT( KDefaultCookieFolder, "C:\\Private\\" );
+_LIT( KDefaultCookieXmlFolder, "Z:\\Private\\" );
 _LIT( KDefaultCookieFile,   "\\Cookies" );
 _LIT( KDefaultExtension, ".dat");
 _LIT( KUnderScore, "_");
+_LIT8(KHexDel,"0x");
+_LIT( KDefaultCookieGroupFile,   "\\CookieGroup.xml" );
+_LIT8(KGroupId,"id");
+_LIT8(KUid3,"uid3");
+_LIT8(KCookieSharable,"cookie_apps_share");
+_LIT8(KGroupName,"name");
+_LIT8(KOff,"off");
 
 // capability checking structures
-const TUint cookieServerPolicyRangeCount = 6;
+const TUint cookieServerPolicyRangeCount = 9;
 
 // server messages
 const TInt  cookieServerPolicyRanges[ cookieServerPolicyRangeCount ] =
@@ -73,7 +92,10 @@
     2,  // EGetCookieSize
     3,  // EGetCookies
     4,  // ESetAppUid
-    5
+    5,   //EDestroyCookies
+    6,  //EGetCookieSharableFlag
+    7,  //EClearAppUidCookies
+    8
     };
 
 // connection between messages and events
@@ -84,6 +106,9 @@
     1,  // EGetCookieSize
     1,  // EGetCookies
     0,  // ESetAppUid
+    0,  // EDestroyCookies
+    0,  //EGetCookieSharableFlag
+    0,  //EClearAppUidCookies
    	CPolicyServer::ENotSupported 	// applies all out of range requests
     };
 
@@ -131,22 +156,28 @@
 
     iStringPool.OpenL();
 
-	iCookiePacker = new (ELeave) TCookiePacker( iStringPool );
-
-	iCookieFileName = HBufC::NewL( KCookieMaxFileNameLength );
-
-	iPersistentCookies = new (ELeave) CCookieArray;
-
-    TPtr fileName( iCookieFileName->Des() );
+    //iCookiePacker = new (ELeave) TCookiePacker( iStringPool );
+    iCookieGroupDataArray = CCookieGroupDataArray::NewL();
+    iGroupIdArray = CGroupIdArray::NewL();
 
-    fileName.Copy( KDefaultCookieFolder );
-    fileName.AppendNum( RProcess().SecureId(), EHex );
-    fileName.Append( KDefaultCookieFile );
-    fileName.Append( KDefaultExtension );
-
+    RFs iFs;
     if ( iFs.Connect() == KErrNone )  // we could connect to the file server
-    ReadCookiesFromFile();
-
+        {
+         TBuf<60> groupfilePath(KNullDesC);
+         groupfilePath.Copy( KDefaultCookieXmlFolder );
+         groupfilePath.AppendNum( RProcess().SecureId(), EHex );
+         groupfilePath.Append( KDefaultCookieGroupFile );
+         if ( BaflUtils::FileExists( iFs, groupfilePath ) )
+            {
+             TRAPD(ret, LoadGroupDataFromFileL(iFs) );
+             if( ret != KErrNone )
+                 {
+                 CLOG( ( EServer, 0, _L( "CCookieManagerServer::ConstructL: Loading Group data Failed" ) ) );
+                 //Do Nothing
+                 }
+            }
+         iFs.Close();
+        }
 	StartL( KCookieServerName );
 
     CLOG( ( EServer, 0, _L( "<- CCookieManagerServer::ConstructL" ) ) );
@@ -180,20 +211,18 @@
 //
 CCookieManagerServer::~CCookieManagerServer()
     {
+    CLOG( ( EServer, 0, _L( "-> CCookieManagerServer::~CCookieManagerServer" ) ) );
     iServerClosing = ETrue;
-
-	delete iPersistentCookies;
-
-	delete iCookieFileName;
-
-	iFs.Close();
-    iStringPool.Close();
-
-	delete iCookiePacker;
+    if(iCookieGroupDataArray)
+        {
+        delete iCookieGroupDataArray;
+        iCookieGroupDataArray = NULL;
+        }
+    delete iGroupIdArray;
 
     delete iCloseTimer;
-
-    CLOG( ( EServer, 0, _L( "CCookieManagerServer::~CCookieManagerServer") ) );
+    iStringPool.Close();
+    CLOG( ( EServer, 0, _L( "<-CCookieManagerServer::~CCookieManagerServer") ) );
     CLOG( ( EServer, 0, _L( "*****************" ) ) );
     }
 
@@ -277,199 +306,16 @@
         // e.g. 1 minute before doing so as starting a server is expensive
         // in many ways.
         CLOG( ( EServer, 0, _L( "Closing Server" ) ) );
-        iPersistentCookies->RemoveNonPersistent();
-		iCloseTimer->After( KCookieCloseTime );
+        iCloseTimer->After( KCookieCloseTime );
         //just write cookies back to the file when browser is closed,
         //no need wait till cookie server is shutdown.
-        WriteCookiesToFile();
+        //WriteCookiesToFile();
         }
 
     CLOG( ( EServer, 0, _L( "<- CCookieManagerServer::CloseSession" ) ) );
     }
 
 
-// ---------------------------------------------------------
-// CCookieManagerServer::ReadCookiesFromFile
-// ---------------------------------------------------------
-//
-TInt CCookieManagerServer::ReadCookiesFromFile()
-    {
-	CLOG( ( EServer, 0,
-					_L( "-> CCookieManagerServer::ReadCookiesFromFile" ) ) );
-
-	TInt err;
-	if ( iCookieFileName->Length() != 0 )
-		{
-		RFile file;
-		err = file.Open( iFs, *iCookieFileName,
-							EFileShareExclusive | EFileStream | EFileRead );
-			if ( err == KErrNone )	// the file does exist and could be opened
-				{
-				TInt size;
-				err = file.Size( size );
-				if ( err == KErrNone )	// size query was successful
-					{
-					HBufC8* fileBuffer = HBufC8::New( size );
-					if ( fileBuffer )// there was enough memory for fileBuffer
-						{
-						TPtr8 fileBufferDes( fileBuffer->Des() );
-						err = file.Read( fileBufferDes );
-						if ( err == KErrNone )
-							{
-							// unfortunately this method might leave, because
-							// it allocates memory for cookies dynamically
-							TRAP( err,
-								iCookiePacker->UnpackCookiesFromBufferL
-												( *fileBuffer, iPersistentCookies->CookieArray() ) );
-							if ( err != KErrNone )
-							    {
-								delete fileBuffer;
-								file.Close();
-								iFs.Delete(*iCookieFileName); //Delete file.
-								return KErrNotFound;
-							    }
-							}
-
-						delete fileBuffer;
-						}
-					else
-						{
-						err = KErrNoMemory;
-						}
-					}
-
-				file.Close();
-			}
-		}
-	else	// if iCookieFileName->Length() == 0
-		{
-		err = KErrNotFound;
-		}
-
-	CLOG( ( EServer, 0,
-				_L( "<- CCookieManagerServer::ReadCookiesFromFile, errcode%d"),
-				err ) );
-
-	return err;
-    }
-
-// ---------------------------------------------------------
-// CCookieManagerServer::WriteCookiesToFile
-// ---------------------------------------------------------
-//
-TInt CCookieManagerServer::WriteCookiesToFile()
-    {
-    CLOG( ( EServer, 0,
-				_L( "-> CCookieManagerServer::WriteCookiesToFile" ) ) );
-
-    TInt err(KErrNone);
-	if ( !iPersistentCookies->Count() )
-		{
-		CLOG( ( EServer, 0,
-				_L( "<- CCookieManagerServer::WriteCookiesToFile, errcode%d" ),
-				KErrNone ));
-
-        // delete cookie file
-    err = iFs.Delete( *iCookieFileName );
-		return err;
-		}
-
-	if ( iCookieFileName->Length() != 0 )
-		{
-		if ( CheckDiskSpace( iFs, *iCookieFileName ) )
-			{
-      iFs.CreatePrivatePath( EDriveC );
-			RFile file;
-			iFs.MkDirAll(*iCookieFileName);
-			err = file.Replace( iFs, *iCookieFileName,
-							EFileShareExclusive | EFileStream | EFileWrite );
-				if ( err == KErrNone )
-					{
-					// get the maximum length of cookies
-    				TInt cookieCount( iPersistentCookies->Count() );
-    				TInt size( 0 );
-    				TInt maxSize( 0 );
-					for( TInt i = 0; i < cookieCount; i++ )
-    					{
-    					if ( (*iPersistentCookies)[i]->Persistent() && 
-    						 !(*iPersistentCookies)[i]->Expired() )
-    						{
-	    					size = (*iPersistentCookies)[i]->Size( EFalse );
-	    					if( size > maxSize )
-	        					{
-		    				    maxSize = size;
-		    				    }
-		    				}
-		    			}
-		    		maxSize++;
-		    		CLOG( ( EServer, 0, _L("maxSize: %d"), maxSize ) );
-		    		// allocate buffer for it
-					HBufC8* fileBuffer = HBufC8::New( maxSize );
-					if ( fileBuffer )
-						{
-						TPtr8 fileBufferDes = fileBuffer->Des();
-
-						// we ignore a possible packing or file writing error
-						// in this loop as these kinds of errors are not fatal
-						// and may not reappear during the next iteration
-						for ( TInt i = 0; i < cookieCount; i++ )
-							{
-    					if ( (*iPersistentCookies)[i]->Persistent() && 
-    						 !(*iPersistentCookies)[i]->Expired() )
-    						{
-								fileBufferDes.SetLength(0);
-	
-								// use CliPackCookie as SrvPackCookie will 
-	                            // suppress the defaulted domain attribute...
-	                            err = iCookiePacker->CliPackCookie( fileBufferDes,
-																(*(*iPersistentCookies)[i]) );
-	
-								if ( err == KErrNone )
-									{
-									err = file.Write( *fileBuffer );
-									}
-								}
-							}
-
-						delete fileBuffer;
-						}
-					else
-						{
-						err = KErrNoMemory;
-						}
-
-					file.Close();
-					}
-				}
-			else	// there is not enough disk space
-				{
-				err = KErrDiskFull;
-			}
-		}
-	else	// if ( iCookieFileName->Length() == 0 )
-		{
-		err = KErrNotFound;
-		}
-
-	CLOG( ( EServer, 0,
-		_L( "<- CCookieManagerServer::WriteCookiesToFile, errcode%d" ), err ) );
-
-	return err;
-    }
-
-// ---------------------------------------------------------
-// CCookieManagerServer::ClearCookies
-// ---------------------------------------------------------
-//
-TInt CCookieManagerServer::ClearAllCookies()
-    {
-    TInt count = iPersistentCookies->ClearAllCookies();
-
-    // delete cookie file, just for sure
-    // this is done also in destructor
-    iFs.Delete( *iCookieFileName );
-    return count;
-    }
 
 // ---------------------------------------------------------
 // CCookieManagerServer::StringPool
@@ -485,73 +331,40 @@
 // CCookieManagerServer::CookieArray
 // ---------------------------------------------------------
 //
-CCookieArray* CCookieManagerServer::CookieArray()
+CCookieArray* CCookieManagerServer::CookieArray(TInt aIndex)
     {
-    return iPersistentCookies;
+    return iCookieGroupDataArray->CookieArray(aIndex);
+    }
+
+
+// ---------------------------------------------------------
+// CCookieManagerServer::CookieGroupDataArray
+// ---------------------------------------------------------
+//
+CCookieGroupDataArray* CCookieManagerServer::CookieGroupDataArray()
+    {
+    return iCookieGroupDataArray;
     }
 
 // ---------------------------------------------------------
-// CCookieManagerServer::StorePersistentCookie
+// CCookieManagerServer::GroupIdArray
 // ---------------------------------------------------------
 //
-void CCookieManagerServer::StorePersistentCookieL( CCookie* aCookie,
-												 const TDesC8& aRequestUri,
-												 const TInt aIndex )
-	{	 
-	if (aIndex == -1)
-		{
-		iPersistentCookies->AddL( aCookie, aRequestUri);
-		}
-	else
-		{
-		iPersistentCookies->InsertL( aCookie, aIndex);
-		}
+CGroupIdArray* CCookieManagerServer::GroupIdArray()
+    {
+    return iGroupIdArray;
     }
 
-
 // ---------------------------------------------------------
 // CCookieManagerServer::GetCookies
 // ---------------------------------------------------------
 //
 TInt CCookieManagerServer::GetCookies( const TDesC8& aRequestUri,
-									  RPointerArray<CCookie>& aCookies ) const
+                                      RPointerArray<CCookie>& aCookies,TInt aIndex ) const
 	{
-	return iPersistentCookies->GetCookies( aRequestUri, aCookies );
+    return iCookieGroupDataArray->GetCookies( aRequestUri, aCookies, aIndex);
 	}
 
-// ---------------------------------------------------------
-// CCookieManagerServer::SetFileName
-// ---------------------------------------------------------
-//
-void CCookieManagerServer::SetFileName(TUint32& aAppUid) 
-    {
-    *iCookieFileName = KNullDesC;
-    TPtr fileName( iCookieFileName->Des() );
-    fileName.Copy( KDefaultCookieFolder );
-    fileName.AppendNum( RProcess().SecureId(), EHex );
-    TBuf<KMaxFileName> buf(KDefaultCookieFile);
-    if(aAppUid)
-        {       
-        buf.Append(KUnderScore);        
-        buf.AppendNum(aAppUid,EHex);        
-        }
-    fileName.Append(buf);
-    fileName.Append(KDefaultExtension);      
-	//just write cookies back to the file before clearallcookies
-	WriteCookiesToFile();
-    //Delete the cookie list as we are going to read from File
-    iPersistentCookies->ClearAllCookies() ;
-    ReadCookiesFromFile();
-    }
-
-// ---------------------------------------------------------
-// CCookieManagerServer::GetFileName
-// ---------------------------------------------------------
-//
-TDesC& CCookieManagerServer::GetFileName() const
-    {
-    return *iCookieFileName;
-    }
 
 //**********************************
 // CCookieTimer
@@ -600,3 +413,154 @@
 
 	return self;
 	}
+// ---------------------------------------------------------
+// CCookieTimer::LoadGroupDataFromFileL
+// ---------------------------------------------------------
+//
+TInt CCookieManagerServer::LoadGroupDataFromFileL( RFs& afileSession )
+    {
+    CLOG( ( EServer, 0, _L( "-> CCookieManagerServer::LoadGroupDataFromFileL" ) ) );
+    TBuf<60> groupfile(KNullDesC);
+    groupfile.Copy( KDefaultCookieXmlFolder );
+    groupfile.AppendNum( RProcess().SecureId(), EHex );
+    groupfile.Append( KDefaultCookieGroupFile );
+    RXmlEngDOMImplementation DOM_impl;
+    DOM_impl.OpenL();
+    RXmlEngDocument doc;
+    RXmlEngDOMParser parser;
+    TInt error = parser.Open( DOM_impl );
+    
+    if (error == KErrNone)
+     {
+
+
+       TRAPD( err, doc = parser.ParseFileL( afileSession, groupfile ) );
+       if ( ! err )
+           {
+           TXmlEngNode node;
+           TXmlEngElement element;
+           RXmlEngNodeList<TXmlEngElement> nodelist1;
+           RXmlEngNodeList<TXmlEngElement> nodelist2;
+           node = doc.DocumentElement();
+           node.AsElement().GetChildElements(nodelist1);
+           CleanupClosePushL(nodelist1);
+           CleanupClosePushL(nodelist2);
+           
+           while ( nodelist1.HasNext() ) //Parent Node
+             {
+                element = nodelist1.Next();
+                element.GetChildElements(nodelist2);
+                TPtrC8 name = element.Name();
+                     RArray<TUint32> sharedAppUidArray(5);
+                     TUint32 groupId = 0;
+                     TBool cookieSharableFlag;
+                     TBool entryHasAttributes = element.HasAttributes();
+                     if ( entryHasAttributes )
+                      {
+                        RXmlEngNodeList<TXmlEngAttr> attributeList;
+                        element.GetAttributes(attributeList);
+                        CleanupClosePushL(attributeList);
+                        while ( attributeList.HasNext() )
+                            {
+                            TXmlEngAttr attr = attributeList.Next();
+                            TPtrC8 attrName = attr.Name();
+                            TPtrC8 attrData = attr.Value();
+                            SettingAttribute(attrName,attrData,groupId,sharedAppUidArray,cookieSharableFlag );
+                            }
+                        CleanupStack::PopAndDestroy(); //attributeList
+                       }
+                         while( nodelist2.HasNext() )//Child Node
+                            {
+                              element = nodelist2.Next();
+                              if ( ! element.IsNull() )
+                                {
+                                  TPtrC8 name = element.Name();
+                                  TBool hasAttributes = element.HasAttributes();
+                                  RXmlEngNodeList<TXmlEngAttr> attributeList;
+                                  element.GetAttributes(attributeList);
+                                  TInt count = attributeList.Count();
+                                  CleanupClosePushL(attributeList);
+                                  while ( attributeList.HasNext() )
+                                      {
+                                      TXmlEngAttr attr = attributeList.Next();
+                                      TPtrC8 attrName = attr.Name();
+                                      TPtrC8 attrData = attr.Value();
+                                      SettingAttribute(attrName,attrData,groupId,sharedAppUidArray,cookieSharableFlag );
+                                      }
+                                  CleanupStack::PopAndDestroy(); //attributeList
+                                }
+                            }
+                     CGroupIdInfo* groupIdInfo = CGroupIdInfo::NewL( groupId, sharedAppUidArray, cookieSharableFlag );
+                     CleanupStack::PushL( groupIdInfo );
+                     iGroupIdArray->AddGroupIdL( groupIdInfo );
+                     CleanupStack::Pop( groupIdInfo );
+                     CCookieGroupData* cookieGroupData = CCookieGroupData::NewL(groupId,sharedAppUidArray,cookieSharableFlag);
+                     CleanupStack::PushL( groupIdInfo );
+                     iCookieGroupDataArray->AddGroupDataL(cookieGroupData);
+                     CleanupStack::Pop( groupIdInfo );
+                     sharedAppUidArray.Close();
+                 }
+           CleanupStack::PopAndDestroy(); //nodelist2
+           CleanupStack::PopAndDestroy(); //nodelist1
+           }
+     }
+    doc.Close();               
+    parser.Close();
+    DOM_impl.Close();
+    CLOG( ( EServer, 0, _L( "<- CCookieManagerServer::LoadGroupDataFromFileL" ) ) );
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------
+// CCookieTimer::SettingAttribute
+// ---------------------------------------------------------
+//
+void CCookieManagerServer::SettingAttribute(TDesC8& attrName, TDesC8& attrData,TUint32& aGroupId
+        , RArray<TUint32>& aSharedAppUidArray, TBool& aCookieSharableFlag  )
+    {
+    CLOG( ( EServer, 0, _L( "-> CCookieManagerServer::SettingAttribute" ) ) );
+    TBuf8<100> groupname(KNullDesC8);
+    TBuf8<100> bufGroupId(KNullDesC8);
+    TBuf8<100> bufSharedAppUidName(KNullDesC8);
+    TUint32 sharedAppUid = 0;
+    if ( ! attrName.CompareF(KGroupName))
+         {
+          groupname.Copy(attrData);
+         } else if ( ! attrName.CompareF(KGroupId)) 
+              {
+              bufGroupId.Copy(attrData);
+              TInt err = ChangeToDecimal(bufGroupId, aGroupId);
+              
+              }else if ( ! attrName.CompareF(KUid3))
+                 {
+                 bufSharedAppUidName.Copy(attrData);
+                 TInt err = ChangeToDecimal(bufSharedAppUidName, sharedAppUid);
+                 if (err == KErrNone)
+                     aSharedAppUidArray.AppendL(sharedAppUid);
+                 
+                 } else if (! attrName.CompareF(KCookieSharable))
+                     {
+                      if ( !attrData.CompareF(KOff) )
+                          aCookieSharableFlag = EFalse;
+                      else
+                          aCookieSharableFlag = ETrue;
+                     }
+    CLOG( ( EServer, 0, _L( "<- CCookieManagerServer::SettingAttribute" ) ) );
+    }
+
+// ---------------------------------------------------------
+// CCookieTimer::ChangeToDecimal
+// ---------------------------------------------------------
+//
+TInt CCookieManagerServer::ChangeToDecimal( TDes8& aBuf,TUint32& aUid )
+    {
+    CLOG( ( EServer, 0, _L( "-> CCookieManagerServer::ChangeToDecimal" ) ) );
+     TBuf8<100> tempBuf;
+     TPtrC8 tempPtr = aBuf.Mid( KHexDel().Length());
+     tempBuf.Copy(tempPtr);
+     TLex8 lex(tempBuf);
+     TInt ret = lex.Val(aUid,EHex);
+     CLOG( ( EServer, 0, _L( "<- CCookieManagerServer::ChangeToDecimal" ) ) );
+     return ret;
+    }
+//EOF
--- a/httpfilters/cookie/ManagerSrc/CookieManagerSession.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/ManagerSrc/CookieManagerSession.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -30,7 +30,9 @@
 #include "CookieManagerSession.h"
 
 #include "CookieServerDef.h"
-
+#include "CookieGroupDataArray.h"
+#include "CookieGroupData.h"
+#include "GroupIdInfoArray.h"
 
 // ---------------------------------------------------------
 // CCookieManagerSession::CCookieManagerSession
@@ -118,22 +120,185 @@
 	TInt err = DoClearAllCookies( aMessage );
 
     CLOG( ( EServerSession, 0,
-				_L( "-> CCookieManagerSession::ClearAllCookies" ) ) );
+				_L( "<- CCookieManagerSession::ClearAllCookies" ) ) );
+
+    return err;
+    }
+// ---------------------------------------------------------
+// CCookieManagerSession::ClearAllCookies
+// ---------------------------------------------------------
+//
+TInt CCookieManagerSession::ClearAllAppUidCookies( const RMessage2& aMessage )
+    {
+    CLOG( ( EServerSession, 0,
+                _L( "-> CCookieManagerSession::ClearAllAppUidCookies" ) ) );
+
+    TInt err = DoClearAllAppUidCookies( aMessage );
+
+    CLOG( ( EServerSession, 0,
+                _L( "<- CCookieManagerSession::ClearAllAppUidCookies" ) ) );
 
     return err;
     }
 
+// ---------------------------------------------------------
+// CCookieManagerSession::DestroyCookies
+// ---------------------------------------------------------
+//
+TInt CCookieManagerSession::DestroyCookies( const RMessage2& aMessage )
+    {
+    CLOG( ( EServerSession, 0,
+                _L( "-> CCookieManagerSession::DestroyCookies" ) ) );
+
+    TInt err = DoDestroyCookies( aMessage );
+
+    CLOG( ( EServerSession, 0,
+                _L( "<- CCookieManagerSession::DestroyCookies" ) ) );
+
+    return err;
+    }
+// ---------------------------------------------------------
+// CCookieManagerSession::GetCookieSharableFlag
+// ---------------------------------------------------------
+//
+TInt CCookieManagerSession::GetCookieSharableFlag( const RMessage2& aMessage )
+    {
+    CLOG( ( EServerSession, 0,
+                _L( "-> CCookieManagerSession::GetCookieSharableFlag" ) ) );
+
+    TInt err = DoGetCookieSharableFlag( aMessage );
+
+    CLOG( ( EServerSession, 0,
+                _L( "<- CCookieManagerSession::GetCookieSharableFlag" ) ) );
+
+    return err;
+    }
 
 // ---------------------------------------------------------
+// CCookieManagerSession::DoGetCookieSharableFlag
+// ---------------------------------------------------------
+//
+TInt CCookieManagerSession::DoGetCookieSharableFlag( const RMessage2& aMessage )
+    {
+    CLOG( ( EServerSession, 0,
+                _L( "-> CCookieManagerSession::DoGetCookieSharableFlag" ) ) );
+    TUint32 secureId = aMessage.SecureId().iId;
+    TBool cookiesharableflag(EFalse);
+    TInt count = iCookieServer.CookieGroupDataArray()->Count();
+    CCookieGroupDataArray* cookiegroupdataarray = iCookieServer.CookieGroupDataArray();
+    for (TInt i=0; i<count; i++)
+        {
+         if (cookiegroupdataarray->At(i)->GetGroupId()== secureId )
+             {
+             cookiesharableflag = cookiegroupdataarray->At(i)->GetCookieSharableFlag();
+             break;         
+             }
+         else 
+             {
+             TInt shared = cookiegroupdataarray->At(i)->TotalAppUid();
+             for (TInt j=0;j<shared;j++)
+                 {
+                  if (cookiegroupdataarray->At(i)->GetSharedUid(j)== secureId)
+                      {
+                      cookiesharableflag = cookiegroupdataarray->At(i)->GetCookieSharableFlag();
+                      break;
+                      }
+                 }
+             }
+         
+        }
+    TPckg<TBool> iFlag(cookiesharableflag);
+    CLOG( ( EServerSession, 0,_L( "<- CCookieManagerSession::DoGetCookieSharableFlag cookiesharableflag = %d" )
+            , cookiesharableflag ) );
+
+    return aMessage.Write( 0, iFlag );
+ 
+    
+    }
+//----------------------------------------------------------
 // CCookieManagerSession::DoClearAllCookies
 // ---------------------------------------------------------
 //
 TInt CCookieManagerSession::DoClearAllCookies( const RMessage2& aMessage )
 	{
-    TPckg<TInt> count( iCookieServer.ClearAllCookies() );
-    return aMessage.Write( 0, count );
+    CLOG( ( EServerSession, 0,
+                _L( "-> CCookieManagerSession::DoClearAllCookies" ) ) );
+
+    TUint32 secureId = aMessage.SecureId().iId;
+    TInt groupDataIndex =0;
+   
+    if(iCookieServer.CookieGroupDataArray()->Count())
+        {
+        TInt err = iCookieServer.CookieGroupDataArray()->FindIndex(secureId, groupDataIndex);
+        if ( err == KErrNone )
+            {
+            CCookieGroupData* cookiegroupdata = iCookieServer.CookieGroupDataArray()->At(groupDataIndex);
+            TPckg<TInt>count(cookiegroupdata->ClearAllCookies());
+            iCookieServer.CookieGroupDataArray()->Remove(groupDataIndex);
+            return aMessage.Write( 0, count );
+            }
+        }
+    TPckg<TInt>count2(0);
+    CLOG( ( EServerSession, 0,
+                _L( "<- CCookieManagerSession::DoClearAllCookies" ) ) );
+    return aMessage.Write( 0, count2 );
 	}
 
+//----------------------------------------------------------
+// CCookieManagerSession::DoClearAllAppUidCookies
+// For deleting cookies belongs to a specific appuid during 
+// uninstallation process of a widget
+// ---------------------------------------------------------
+//
+TInt CCookieManagerSession::DoClearAllAppUidCookies( const RMessage2& aMessage )
+    {
+    CLOG( ( EServerSession, 0,
+                _L( "-> CCookieManagerSession::DoClearAllAppUidCookies" ) ) );
+
+    TUint32 secureId = aMessage.SecureId().iId;
+    TInt groupDataIndex =-1;
+    
+    //READ FROM MESSAGE
+    HBufC* packedAppUidBuf = HBufC::NewLC( aMessage.Int0() );
+    TPtr packedAppUidPtr( packedAppUidBuf->Des() );
+    aMessage.ReadL( 1, packedAppUidPtr );   
+    TLex lex(packedAppUidPtr);
+    TUint32 appUid(0);
+    TInt ret = lex.Val(appUid,EHex);
+
+    if(iCookieServer.CookieGroupDataArray()->Count())
+        {
+        TInt err = iCookieServer.CookieGroupDataArray()->FindIndex(secureId,appUid,groupDataIndex);
+        if ( err == KErrNone )
+            {
+            CCookieGroupData* cookiegroupdata = iCookieServer.CookieGroupDataArray()->At(groupDataIndex);
+            TPckg<TInt>count(cookiegroupdata->ClearAllCookies());
+            iCookieServer.CookieGroupDataArray()->Remove(groupDataIndex);
+            return aMessage.Write( 0, count );
+            }
+        }
+    TPckg<TInt>count2(0);
+    CLOG( ( EServerSession, 0,
+                 _L( "<- CCookieManagerSession::DoClearAllAppUidCookies" ) ) );
+    return aMessage.Write( 0, count2 );
+    }
+
+// ---------------------------------------------------------
+// CCookieManagerSession::DoDestroyCookies
+// ---------------------------------------------------------
+//
+TInt CCookieManagerSession::DoDestroyCookies( const RMessage2& aMessage )
+    {
+    CLOG( ( EServerSession, 0,
+                 _L( "-> CCookieManagerSession::DoDestroyCookies" ) ) );
+
+    TUint32 secureId = aMessage.SecureId().iId;
+    TInt err = iCookieServer.CookieGroupDataArray()->DestroyGroupData(secureId);
+    TPckg<TInt>status(err);
+    CLOG( ( EServerSession, 0,
+                _L( "<- CCookieManagerSession::DoDestroyCookies err = %d" ),err ) );
+    return aMessage.Write( 0, status );
+    }
 
 // ---------------------------------------------------------
 // CCookieManagerSession::DoGetCookieSize
@@ -141,8 +306,27 @@
 //
 TInt CCookieManagerSession::DoGetCookieSize( const RMessage2& aMessage )
 	{
+	CLOG( ( EServerSession, 0,
+	                 _L( "-> CCookieManagerSession::DoGetCookieSize" ) ) );
+
     TInt err = KErrNone;
-
+    HBufC* CookieBuf = HBufC::NewL(128);
+    TPtr CookiePtr( CookieBuf->Des() );
+    aMessage.ReadL( 0, CookiePtr );   
+    TLex lex(CookiePtr);
+    TUint32 appUid(0);
+    TInt ret = lex.Val(appUid,EHex);
+    delete CookieBuf;
+    TUint32 secureId = aMessage.SecureId().iId;
+    TUint32 groupId=0;
+    TBool cookieSharable(EFalse);
+    TInt retstatus = iCookieServer.GroupIdArray()->GetGroupId(secureId,groupId, cookieSharable);
+    if( groupId && retstatus != KErrNotFound )
+        {
+        secureId = groupId;
+        }
+    TInt groupDataIndex =0;
+    iCookieServer.CookieGroupDataArray()->GetGroupDataIndexL(secureId,appUid,cookieSharable,groupDataIndex);        
 	if ( iGetCookieList.Count() || iGetCookieListSize )
 		{
 		iGetCookieList.Reset();
@@ -151,19 +335,19 @@
 	else
 		{
 		// read in the size of the URI in bytes
-		TInt uriSize = aMessage.Int0();
+		TInt uriSize = aMessage.Int1();
 		HBufC8* uriBuf = HBufC8::New( uriSize );
         if ( uriBuf ) 
             {
 		    // read in the URI
 		    TPtr8 uriDes( uriBuf->Des() );
-		    err = aMessage.Read( 1, uriDes );
+		    err = aMessage.Read( 2, uriDes );
             if ( err == KErrNone )
                 {
 		        // fill the cookie array with the appropriate cookies :
 		        // both from the server (persistent cookies) and from our local 
 		        // cookie list (transient cookies)
-		        err = iCookieServer.GetCookies( uriDes, iGetCookieList );
+		        err = iCookieServer.GetCookies( uriDes, iGetCookieList,groupDataIndex );
                 if ( err == KErrNone )
                     {
         /*
@@ -182,7 +366,7 @@
 
 		            // writing back the result - the number of bytes to be copied
 		            TPckg<TInt> pkgSize( iGetCookieListSize );
-                    err = aMessage.Write( 2, pkgSize );
+                    err = aMessage.Write( 3, pkgSize );
                     }
                 }
 
@@ -193,7 +377,8 @@
             err = KErrNoMemory;
             }
 		}
-
+    CLOG( ( EServerSession, 0,
+                     _L( "<- CCookieManagerSession::DoGetCookieSize err = %d" ),err ) );
     return err;
 	}
 
@@ -266,7 +451,26 @@
     {
     CLOG( ( EServerSession, 0,
 			_L( "-> CCookieManagerSession::DoStoreCookie ") ) );
-
+    HBufC* cookiebuf = HBufC::NewL(128);
+    TPtr cookiePtr( cookiebuf->Des() );
+    aMessage.ReadL( 3, cookiePtr );   
+    TLex lex(cookiePtr);
+    TUint32 appUid(0);
+    TInt ret = lex.Val(appUid,EHex);
+    delete cookiebuf;
+    //Get THe Secure ID
+    TUint32 secureId = aMessage.SecureId().iId;
+    TInt groupDataIndex =0;
+    TUint32 groupId=0;
+    TBool cookieSharableFlag(EFalse);
+    TInt retstatus = iCookieServer.GroupIdArray()->GetGroupId(secureId,groupId, cookieSharableFlag);
+    if( groupId && retstatus != KErrNotFound )
+        {
+        secureId = groupId;
+        }
+    iCookieServer.CookieGroupDataArray()->GetGroupDataIndexL(secureId,appUid, cookieSharableFlag,groupDataIndex);        
+    CCookieGroupData* cookiegroupdata = iCookieServer.CookieGroupDataArray()->At(groupDataIndex);
+    //iGrDataArray->GetGroupDataIndexL(secureId, groupDataIndex);
     HBufC8* packedCookieBuf = HBufC8::NewLC( aMessage.Int0() );
     TPtr8 packedCookiePtr( packedCookieBuf->Des() );
     aMessage.ReadL( 1, packedCookiePtr );
@@ -282,15 +486,20 @@
     if( err == KErrNone )
         {
 	    // aMessage.Int2() == request-URI length
-	    HBufC8* uriBuf = HBufC8::NewLC( aMessage.Int2() );
+        //Hrdcoded value has taken as 4 slots has already been occupied and 
+        //there is no way to pass the uri length from client to Server
+        //this length is sufficient enough to accomodate a uri.
+        
+	    HBufC8* uriBuf = HBufC8::NewLC(500);
 	    TPtr8 uriPtr( uriBuf->Des() );
 
-    	aMessage.ReadL( 3, uriPtr );
+    	aMessage.ReadL( 2, uriPtr );
 
         // first need to check if it is present in the array as it must 
         // overwrite already existing cookies...
         TInt index(0);
-        CCookieArray* perscookiearray = iCookieServer.CookieArray();
+        //CCookieArray* perscookiearray = iCookieServer.CookieArray();
+        CCookieArray* perscookiearray = iCookieServer.CookieArray(groupDataIndex);
         if ( perscookiearray->DoesAlreadyExists( cookie, index ) )
             { // must overwrite !!!
             // but first add the new one if needed
@@ -301,19 +510,19 @@
      		if(index >=0)
      			{
      			// insert cookie at valid index    
-            	iCookieServer.StorePersistentCookieL( cookie, *uriBuf, index );
+     			cookiegroupdata->StorePersistentCookieL( cookie, *uriBuf, index );
             	// remove the old cookie
             	perscookiearray->Remove( index + 1 );
             	}
             else
                 {   // invalid index means old cookie has been deleted in the process of making room
                     // append the new cookie to the end of array
-                    iCookieServer.StorePersistentCookieL( cookie, *uriBuf );
+                cookiegroupdata->StorePersistentCookieL( cookie, *uriBuf );
                 }
             }
         else
             { // it is not in the array yet, add it now
-            iCookieServer.StorePersistentCookieL( cookie, *uriBuf );
+            cookiegroupdata->StorePersistentCookieL( cookie, *uriBuf );
             }
 
 	    CleanupStack::PopAndDestroy( uriBuf );
@@ -467,7 +676,41 @@
 		    aMessage.Complete(result);
 		    break;
 		    }
-		default :
+        case EDestroyCookies :
+            {
+            if ( result == KErrNone )
+                {
+                result = DestroyCookies( aMessage );
+                }
+
+            aMessage.Complete( result );
+
+            break;
+            }
+        case EGetCookieSharableFlag :
+            {
+            if ( result == KErrNone )
+                {
+                result = GetCookieSharableFlag( aMessage );
+                }
+
+            aMessage.Complete( result );
+
+            break;
+            }
+        case EClearAppUidCookies :
+            {
+            if ( result == KErrNone )
+                {
+                result = ClearAllAppUidCookies( aMessage );
+                }
+
+            aMessage.Complete( result );
+
+            break;
+            }
+
+        default :
 			PanicClient( aMessage, ECookieBadRequest );
 			break;
 		}
@@ -502,29 +745,25 @@
 //
 TInt CCookieManagerSession::SetAppUidL(const RMessage2& aMessage )
     {
-   TInt ret(KErrNone);
-   //READ FROM MESSAGE
+    CLOG( ( EServerSession, 0,
+            _L( "-> CCookieManagerSession::SetAppUidL" ) ) );
+    TInt ret(KErrNone);
+    //READ FROM MESSAGE
     HBufC* packedCookieBuf = HBufC::NewLC( aMessage.Int0() );
     TPtr packedCookiePtr( packedCookieBuf->Des() );
     aMessage.ReadL( 1, packedCookiePtr );   
     TLex lex(packedCookiePtr);
     TUint32 appUid(0);
     ret = lex.Val(appUid,EHex);    
+    TUint32 secureId = aMessage.SecureId().iId;
+    TInt groupDataIndex =0;
+    //iCookieServer.CookieGroupDataArray()->GetGroupDataIndexL(secureId,appUid,groupDataIndex);
+    CCookieGroupData* cookiegroupdata = iCookieServer.CookieGroupDataArray()->At(groupDataIndex);
+    cookiegroupdata->SetFileName(appUid,secureId);
+    CleanupStack::PopAndDestroy(packedCookieBuf);
+    CLOG( ( EServerSession, 0,
+                _L( "<- CCookieManagerSession::SetAppUidL" ) ) );
 
-    //Extract Appuid from File Name
-    TPtrC buf = iCookieServer.GetFileName();
-    TInt len = buf.LocateReverse('_');
-    TPtrC ptr(iCookieServer.GetFileName().Mid(len+1));
-    TInt len1 = ptr.LocateReverse('.');
-    TPtrC ptr1(ptr.Left(len1));
-    if(!packedCookiePtr.Compare(ptr1) || (len == KErrNotFound && !appUid ))
-        {
-        //Already the Same File
-        CleanupStack::PopAndDestroy(packedCookieBuf);
-        return ret;    
-        }                
-    iCookieServer.SetFileName(appUid);
-    CleanupStack::PopAndDestroy(packedCookieBuf);
     return ret;    
     }
 // End of file
--- a/httpfilters/cookie/ManagerSrc/CookieManagerStart.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/ManagerSrc/CookieManagerStart.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -42,7 +42,7 @@
     CLOG( ( EServerStart, 0, _L( "*****************" ) ) );
     CLOG( ( EServerStart, 0, _L( "-> StartCookieServerStart" ) ) );
 
-	__UHEAP_MARK;
+	//__UHEAP_MARK;
 
 	TBuf<32> name( KCookieServerThreadName );
 
@@ -96,7 +96,7 @@
 		delete cleanup;
 		}
 
-	__UHEAP_MARKEND;
+	//__UHEAP_MARKEND;
 
     CLOG( ( EServerStart, 0, _L( "<- StartCookieServerStart err%d" ),
                             result ) );
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/httpfilters/cookie/ManagerSrc/GroupIdInfoArray.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,312 @@
+/*
+ * CGroupIdInfoArray.cpp
+ *
+ *  Created on: Nov 24, 2009
+ *      Author: mohanti
+ */
+//System Includes
+
+//User Includes
+#include "GroupIdInfoArray.h"
+#include "CookieLogger.h"
+
+//Constatnts
+
+const TInt KGroupArrayGranularity = 10;
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::NewL
+// ---------------------------------------------------------
+//
+
+CGroupIdInfo* CGroupIdInfo::NewL( TUint32 aGroupId, const RArray<TUint32>& aAppuid, TBool aCookieSharableFlag )
+    {
+    CLOG( ( EClient, 0, _L( "-> CGroupIdArray::NewL aGroupId = %x, CookieSharableFlag = %x" )
+            ,aGroupId,aCookieSharableFlag ) );
+    CGroupIdInfo* self = CGroupIdInfo::NewLC(aGroupId, aAppuid, aCookieSharableFlag);
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::NewLC
+// ---------------------------------------------------------
+//
+
+CGroupIdInfo* CGroupIdInfo::NewLC(TUint32 aGroupId, const RArray<TUint32>& aAppuid, TBool aCookieSharableFlag)
+    {
+    CGroupIdInfo* self = new (ELeave) CGroupIdInfo( aGroupId, aCookieSharableFlag );
+    CleanupStack::PushL(self);
+    self->ConstructL(aAppuid);
+    return self;
+    }
+// ---------------------------------------------------------
+// CCookieGroupDataArray::NewLC
+// ---------------------------------------------------------
+//
+
+CGroupIdInfo::~CGroupIdInfo()
+    {
+    CLOG( ( EClient, 0, _L( "-> CGroupIdArray::~CGroupIdInfo" ) ) );
+    iAppUid.Close();
+    CLOG( ( EClient, 0, _L( "<- CGroupIdArray::~CGroupIdInfo" ) ) );
+    }
+// ---------------------------------------------------------
+// CCookieGroupDataArray::NewLC
+// ---------------------------------------------------------
+//
+
+void CGroupIdInfo::ConstructL(const RArray<TUint32>& aAppuid)
+    {
+    CLOG( ( EClient, 0, _L( "-> CGroupIdArray::ConstructL" ) ) );
+    TInt count = aAppuid.Count();
+    CLOG( ( EClient, 0, _L( "-> CGroupIdArray::count = %d" ), count ) );
+    for(TInt i=0; i<count; i++)
+        {
+        CLOG( ( EClient, 0, _L( "-> CGroupIdArray::aAppuid[%d] = %x " ), aAppuid[i] ) );
+        iAppUid.AppendL(aAppuid[i]);
+        }
+    CLOG( ( EClient, 0, _L( "<- CGroupIdArray::ConstructL" ) ) );
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::CGroupIdInfo
+// ---------------------------------------------------------
+//
+
+CGroupIdInfo::CGroupIdInfo( TUint32 aGroupId,TBool aCookieSharableFlag ):iCookieSharableFlag( aCookieSharableFlag ), iGroupId(aGroupId)
+    {
+    CLOG( ( EClient, 0, _L( "-> CGroupIdArray::CGroupIdInfo" ) ) );
+    CLOG( ( EClient, 0, _L( "-> CGroupIdArray::CGroupIdInfo" ) ) );
+    }
+TBool CGroupIdInfo::GetCookieSharableFlag()
+    {
+    return iCookieSharableFlag;
+    }
+// ---------------------------------------------------------
+// CGroupIdInfo::GetGroupName
+// ---------------------------------------------------------
+//
+
+TInt CGroupIdInfo::GetGroupName(TUint32 aSecureId,TUint32& aGroupId)
+    {
+    CLOG( ( EClient, 0, _L( "-> CGroupIdArray::GetGroupName aSecureId = %x,aGroupId = %x" )
+            , aSecureId, aGroupId ) );
+    if(aSecureId == iGroupId)
+        {
+        aGroupId = iGroupId; 
+        return KErrNone;
+        }
+    else
+        {
+        return KErrNotFound;
+        }
+    }
+TBool CGroupIdInfo::IsThisPartOfSharedGroup( TUint32& aClientId )
+    {
+    TBool found(EFalse);
+    if(!GetCookieSharableFlag())
+        return EFalse;
+    TInt count = iAppUid.Count();
+    for (TInt i=0;i<count;i++)
+        {
+         if ( aClientId == At(i) )
+             {
+             found = ETrue;
+             CLOG( ( EClient, 0, _L( "-> CGroupIdInfo::IsThisPartOfSharedGroup aClientId %x is Part of Group " ), aClientId ) );
+             break;
+             }
+        }
+    return found;
+    }
+// ---------------------------------------------------------
+// CGroupIdInfo::AddClientL
+// ---------------------------------------------------------
+//
+
+void CGroupIdInfo::AddClientL(TUint32 aClientId)
+    {
+    CLOG( ( EClient, 0, _L( "-> CGroupIdArray::AddClientL aClientId %x" ), aClientId  ) );
+    iAppUid.AppendL(aClientId);
+    CLOG( ( EClient, 0, _L( "<- CGroupIdArray::AddClientL aClientId %x" ) ) );
+    }
+// ---------------------------------------------------------
+// CGroupIdInfo::operator[]
+// ---------------------------------------------------------
+//
+
+TUint32 CGroupIdInfo::operator[](TInt aIndex) const
+    {
+    return (iAppUid[aIndex]);
+    }
+
+// ---------------------------------------------------------
+// CGroupIdInfo::At
+// ---------------------------------------------------------
+//
+
+TUint32 CGroupIdInfo::At(TInt aIndex) const
+    {
+    return (iAppUid[ aIndex ]);
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::GetSecureId
+// ---------------------------------------------------------
+//
+const TUint32& CGroupIdInfo::GetGroupId()
+    {
+    return iGroupId;
+    }
+// ---------------------------------------------------------
+// CCookieGroupDataArray::NewL
+// ---------------------------------------------------------
+//
+
+CGroupIdArray* CGroupIdArray::NewL()
+    {
+    CGroupIdArray* self = CGroupIdArray::NewLC();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::NewLC
+// ---------------------------------------------------------
+//
+
+CGroupIdArray* CGroupIdArray::NewLC()
+    {
+    CGroupIdArray* self = new (ELeave) CGroupIdArray();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::CGroupIdArray
+// ---------------------------------------------------------
+//
+CGroupIdArray::CGroupIdArray()
+    {
+    CLOG( ( EClient, 0, _L( "-> CGroupIdArray::CGroupIdArray" ) ) );
+    CLOG( ( EClient, 0, _L( "<- CGroupIdArray::CGroupIdArray" ) ) );
+    }
+// ---------------------------------------------------------
+// CCookieGroupDataArray::~CGroupIdArray
+// ---------------------------------------------------------
+//
+
+CGroupIdArray::~CGroupIdArray()
+    {
+    CLOG( ( EClient, 0, _L( "-> CGroupIdArray::~CGroupIdArray" ) ) );
+    if(iGroupIdInfoArray && Count())
+        {
+        iGroupIdInfoArray->ResetAndDestroy();
+        iGroupIdInfoArray->Close();
+        //delete iGroupIdInfoArray;
+        iGroupIdInfoArray = NULL;
+        }
+    CLOG( ( EClient, 0, _L( "<- CGroupIdArray::~CGroupIdArray" ) ) );
+    }
+// ---------------------------------------------------------
+// CCookieGroupDataArray::ConstructL
+// ---------------------------------------------------------
+//
+void CGroupIdArray::ConstructL()
+    {
+    CLOG( ( EClient, 0, _L( "-> CGroupIdArray::ConstructL" ) ) );
+    iGroupIdInfoArray = new (ELeave) RPointerArray<CGroupIdInfo>(KGroupArrayGranularity);
+    CLOG( ( EClient, 0, _L( "<- CGroupIdArray::ConstructL" ) ) );
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::AddGroupIdL
+// ---------------------------------------------------------
+//
+
+void CGroupIdArray::AddGroupIdL(CGroupIdInfo* aCGroupIdInfo)
+    {
+    return iGroupIdInfoArray->AppendL(aCGroupIdInfo);
+    }
+
+// ---------------------------------------------------------
+// CGroupIdArray::operator[]
+// ---------------------------------------------------------
+//
+CGroupIdInfo& CGroupIdArray::operator[](TInt aIndex) const
+    {
+    return *(*iGroupIdInfoArray)[aIndex];
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::At
+// ---------------------------------------------------------
+//
+CGroupIdInfo& CGroupIdArray::At(TInt aIndex) const
+    {
+    return *(*iGroupIdInfoArray)[ aIndex ];
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::GetGroupId
+// ---------------------------------------------------------
+//
+TInt CGroupIdArray::GetGroupId(TUint32 aClientId,TUint32& aGroupId)
+    {
+    CLOG( ( EClient, 0, _L( "-> CGroupIdArray::GetGroupId aClientId = %x" ), aClientId ) );
+    TInt count = Count();
+    TBool found(EFalse);
+    TUint32 groupId =0;
+    for(TInt i=0;i<count;i++)
+        {
+        TInt ret = At(i).GetGroupName(aClientId,groupId);
+         if ( ret == KErrNone )
+             {
+             aGroupId = groupId;
+             found = ETrue;
+             CLOG( ( EClient, 0, _L( "<- CGroupIdArray::Group Id of aClientId= %x is %x" ), aClientId, aGroupId ) );
+             break;
+             }
+           }
+    if(found)
+        return KErrNone;
+    else
+        return KErrNotFound;
+    }
+// ---------------------------------------------------------
+// CCookieGroupDataArray::GetGroupId
+// ---------------------------------------------------------
+//
+
+TInt CGroupIdArray::GetGroupId(TUint32 aClientId,TUint32& aGroupId,TBool& aCookieSharableFlag)
+    {
+    CLOG( ( EClient, 0, _L( "-> CGroupIdArray::GetGroupId aClientId = %x,aGroupId =%x" ), aClientId, aGroupId ) );
+    TInt count = Count();
+    TBool found(EFalse);
+    
+    for(TInt i=0;i<count;i++)
+        {
+         if( At(i).GetGroupId() == aClientId || At(i).IsThisPartOfSharedGroup(aClientId) )
+           {
+           aGroupId = At(i).GetGroupId();
+           aCookieSharableFlag = At(i).GetCookieSharableFlag();
+           found = ETrue;
+           break;
+           }
+        }
+    if(found)
+        return KErrNone;
+    else
+        return KErrNotFound;
+
+    }
+
+// ---------------------------------------------------------
+// CCookieGroupDataArray::Count
+// ---------------------------------------------------------
+//
+TInt CGroupIdArray::Count()
+    {
+    return iGroupIdInfoArray->Count();
+    }
--- a/httpfilters/cookie/Rom/CookieManager.iby	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/cookie/Rom/CookieManager.iby	Thu Jul 22 16:38:27 2010 +0100
@@ -20,5 +20,6 @@
 
 file=ABI_DIR\BUILD_DIR\CookieManager.dll        SHARED_LIB_DIR\CookieManager.dll
 file=ABI_DIR\BUILD_DIR\CookieServer.exe         PROGRAMS_DIR\CookieServer.exe
+data=EPOCROOT##epoc32\data\z\private\101F8530\CookieGroup.xml  private\101F8530\CookieGroup.xml
 
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/httpfilters/cookie/data/CookieGroup.xml	Thu Jul 22 16:38:27 2010 +0100
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?> 
+<CookieManagerSettings>
+	<ShareGroup name="Web Browser" id="0x10008d39" cookie_apps_share="on">
+        <SharedApp name="WebBrowser" uid3="0x10008d39" >
+		</SharedApp>
+		<SharedApp name="DownloadManager" uid3="0x10008D60">
+  	    </SharedApp>
+        <SharedApp name="Ovi Music" uid3="0x101ffb51">
+            </SharedApp>
+		<SharedApp name="Music Player " uid3="0x102072C3">
+         </SharedApp>           
+	
+	</ShareGroup>
+
+	<ShareGroup name="WRT Widget" id="0x10282822" cookie_apps_share="off">
+         <SharedApp name="WRT Widget" uid3="0x10282822" >
+	     </SharedApp>
+	</ShareGroup>
+</CookieManagerSettings>
--- a/httpfilters/group/bld.inf	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/group/bld.inf	Thu Jul 22 16:38:27 2010 +0100
@@ -19,12 +19,12 @@
 #include "../httpfiltercommon/group/bld.inf"
 #include "../cookie/Group/bld.inf"
 #include "../deflatefilter/group/bld.inf"
-#include "../httpfilteracceptheader/group/bld.inf"
+//#include "../httpfilteracceptheader/group/bld.inf"
 #include "../httpfilterauthentication/group/bld.inf"
 #include "../httpfilterconnhandler/group/bld.inf"
 #include "../httpfilteriop/group/bld.inf"
 #include "../httpfilterproxy/group/bld.inf"
-#include "../uaproffilter/group/bld.inf"
+//#include "../uaproffilter/group/bld.inf"
 
 
 
--- a/httpfilters/httpfilteracceptheader/Src/HttpFilterAcceptHeader.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/httpfilteracceptheader/Src/HttpFilterAcceptHeader.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -551,8 +551,12 @@
 
 	// Declare a language arrays
 	CArrayFixFlat<TInt>* systemEpocLanguageCodes = 0;
-	// Get installed language codes 
-	User::LeaveIfError( SysLangUtil::GetInstalledLanguages(systemEpocLanguageCodes) ); 
+	// Get installed language codes
+	// coverity [alloc_fn]
+	// coverity [freed_arg]
+	User::LeaveIfError( SysLangUtil::GetInstalledLanguages(systemEpocLanguageCodes) );
+		
+	// coverity [double_free] 
 	CleanupStack::PushL( systemEpocLanguageCodes ); 
 
 	// Compose the String such as "en;q=1.0, es;q=0.5, fr;q=0.5"
--- a/httpfilters/httpfilterauthentication/Src/HttpFilterAuthentication.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/httpfilterauthentication/Src/HttpFilterAuthentication.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -656,7 +656,8 @@
         {
         THTTPHdrVal fieldVal; // The name of the current field.
         THTTPHdrVal hdrVal; //A scratch hdrVal
-		// coverity [CHECKED_RETURN]
+				// coverity [check_return]
+				// coverity [unchecked_value]
         headers.GetField( wwwAuthenticate, ii, fieldVal );
 
         switch ( fieldVal.StrF().Index( RHTTPSession::GetTable() ) )
--- a/httpfilters/httpfilterauthentication/Src/HttpFilterDigestAuthentication.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/httpfilterauthentication/Src/HttpFilterDigestAuthentication.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -508,8 +508,10 @@
         {
         THTTPHdrVal fieldVal; // The name of the current field.
         THTTPHdrVal hdrVal; //A scratch hdrVal
-		// coverity [CHECKED_RETURN]
-        headers.GetField( wwwAuthenticate, ii, fieldVal );
+        
+				// coverity [check_return]
+				// coverity [unchecked_value]
+				headers.GetField( wwwAuthenticate, ii, fieldVal );
 
         switch ( fieldVal.StrF().Index( RHTTPSession::GetTable() ) )
             {
--- a/httpfilters/httpfiltercommon/src/HttpFilterCommonStringsExt.cpp	Thu Jun 17 12:05:02 2010 +0100
+++ b/httpfilters/httpfiltercommon/src/HttpFilterCommonStringsExt.cpp	Thu Jul 22 16:38:27 2010 +0100
@@ -926,6 +926,7 @@
         index = EMacedonian;
         break;
         case ELangMalay:                     // 70
+        case ELangMalay_Apac:                // 326
         index = EMalay;
         break;
         case ELangMalayalam:                 // 71
--- a/netprotocols_plat/cookie_manager_api/inc/cookie.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/netprotocols_plat/cookie_manager_api/inc/cookie.h	Thu Jul 22 16:38:27 2010 +0100
@@ -30,7 +30,7 @@
 
 class RHTTPHeaders;
 class TUriC8;
-
+class TDesC8;
 // CONSTANTS
 
 // Attribute prefix : we have to pack cookies when either passing them over
@@ -77,6 +77,7 @@
                             // cookie was generated. It is important to know it 
                             // for correct age calculation.
             //EAge,           // The age of the cookie as estimated by the cache
+            ELastAttribute
 			};
 
 	public :	// exported methods
@@ -239,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.
@@ -266,7 +267,7 @@
         * @return TBool indicating the cookies's Version attribute's notoriety.
         */
         TBool IsUnknownVersion() const;
-
+        static CCookie* CloneL( const CCookie& aCopy,const TDesC8& aDomain, const TDesC8& aPath, const TDesC8& aPort);
 
 	private :	// class for internal use
         /**
@@ -278,7 +279,11 @@
         * @return A TBool holding the result
         */
         TBool ExpiredNetscapeL( THTTPHdrVal aAttrVal ) const;
-
+        
+        /* For logging Cookie attributes
+         * 
+         */
+        void Log( TInt aAssociatedId = 0 ) const;
         /**
         * Tokenize a string.
         * @return actual number of tokens
--- a/netprotocols_plat/cookie_manager_api/inc/cookiemanagerclient.h	Thu Jun 17 12:05:02 2010 +0100
+++ b/netprotocols_plat/cookie_manager_api/inc/cookiemanagerclient.h	Thu Jul 22 16:38:27 2010 +0100
@@ -30,6 +30,8 @@
 #include <cookie.h>
 #include <cookieipc.h>
 
+//FORWARD Class Declaration
+class CCookieClientDataArray;
 // CLASS DECLARATION
 	
 /** 
@@ -87,6 +89,14 @@
 		* @return Error code indicating the result of the call.
 		*/		
 		IMPORT_C TInt SetAppUidL(const TUint32& aAppUid );
+        IMPORT_C void Close();
+        IMPORT_C TInt StoreCookie( const CCookie& aCookie,
+                                            const TUriC8& aUri,TUint32& aAppUid);
+        IMPORT_C void GetCookiesL( const TDesC8& aUri,
+                                   RPointerArray<CCookie>& aCookies, 
+                                   TBool& aCookie2Reqd,TUint32& aAppUid );
+        IMPORT_C TInt ClearAllAppUidCookies(const TUint32& aAppUid);
+
 
 	private :	// internal methods
 		/**
@@ -102,6 +112,9 @@
 		*/
 		TInt DoGetCookieSize( const TDesC8& aRequestUri,
 							TPckg<TInt>& aPkgSize ) const;
+							
+	    TInt DoGetCookieSize( const TDesC8& aRequestUri,
+							TPckg<TInt>& aPkgSize,TDesC& aAppUidPtr ) const;
 
 		/**
 		* Puts those cookies in the buffer that have been previously selected
@@ -115,17 +128,63 @@
 		*
 		*/
 		TInt DoStoreCookie( const TDesC8& aPackedCookie,
-							const TDesC8& aUri ) const;
+							const TDesC8& aUri,TDesC& aAppUidPtr ) const;
 
 		/**
 		*
 		*/
 		TVersion Version() const;
-
+		
+		TInt DestroyCookiesFromMemory( TInt& aDeleteStatus );
+		
+		void StoreCookieAtClientSide( const CCookie* aCookie, const TDesC8& aUri,TUint32 aWidgetUid =0);
+		
+		TInt GetClientSideCookies( const TDesC8& aRequestUri,RPointerArray<CCookie>& aCookies
+		        ,TBool& aFound, TUint32 aWidgetUid );
+		TInt GetCookieSharableFlagFromServer(TBool& aCookieSharableFlag ) const;
+		
 	private :	// data members
-		RStringPool iStringPool;
+	    //internal data structure for supporting Client side caching.
+        class TCookieMgrInternalStruct
+               {
+               public:
+               /* Constructor
+                * 
+                */    
+               TCookieMgrInternalStruct(RStringPool aStringPool)
+               : iCookiePacker(aStringPool),
+               iCookieClientDataArray(NULL)
+               {          
+               }
+               
+               /* Destructor
+                * 
+                */
+               ~TCookieMgrInternalStruct();
+               
+               /* Get Cookiepacker instance
+                * 
+                */
+               inline TCookiePacker& GetCookiePacker(){return iCookiePacker;}
+               
+               /* Get Client Data Array Instance
+                * 
+                */
+               inline CCookieClientDataArray* GetCookieClientDataArray(){return iCookieClientDataArray;}
+               
+               /* Initialization method for Cookie Client Data Array
+                * 
+                */
+               TInt Init();
+               
+               private:
+               TCookiePacker iCookiePacker;
+               CCookieClientDataArray* iCookieClientDataArray;
+               };
 
-		TCookiePacker iCookiePacker;
+     RStringPool iStringPool;
+     TCookieMgrInternalStruct* iCookieMgrData;  
+		
 	};
 
 #endif //__COOKIEMANAGER_CLIENT_H__