# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1270063935 -10800 # Node ID 2611c08ee28e2a3e1d2f6fce8f544fb335dc2c5b # Parent fa2fd8b2d6ccf7249939373d1e609b1344c39501 Revision: 201011 Kit: 201013 diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerpluginsandutils/httpprotocolplugins/httpclient/chttpclienthandler.cpp --- a/applayerpluginsandutils/httpprotocolplugins/httpclient/chttpclienthandler.cpp Mon Mar 15 12:42:40 2010 +0200 +++ b/applayerpluginsandutils/httpprotocolplugins/httpclient/chttpclienthandler.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -1004,6 +1004,7 @@ // Transaction is still alive - ask its connection manager to cancel it. MHttpRequest& request = static_cast(aTransaction.TxData()); MHttpResponse& response = static_cast(aTransaction.RxData()); + response.FlushBodyDataIfNotRead(); manager->CancelSubmission(request, response); // Connection is now cancelled - remove the connection manager from the diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerpluginsandutils/httpprotocolplugins/httpclient/chttpresponseparser.cpp --- a/applayerpluginsandutils/httpprotocolplugins/httpclient/chttpresponseparser.cpp Mon Mar 15 12:42:40 2010 +0200 +++ b/applayerpluginsandutils/httpprotocolplugins/httpclient/chttpresponseparser.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -792,4 +792,18 @@ User::Invariant(); } - +void CHttpResponseParser::FlushBodyDataIfNotRead() +{ + // Message is completed but the client is not yet read the complete body data + // and we are cancelling. So we need to clear the parsed body data as another + // request would have been sent via the connection. The flushing of the body + // data is needed to make the connection manager to read further response from the + // socket otherwise it hangs. See the error: + + // Note: This function should be called from CancelTransactionHook and only in the + // case of client cancelling the transaction. ie; using RHTTPTransaction::Cancel(); + if(MessageComplete() && iBodyParts.Count() > 0) + { + iBodyParts.Reset(); // Reset the body array. + } +} diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerpluginsandutils/httpprotocolplugins/httpclient/chttpresponseparser.h --- a/applayerpluginsandutils/httpprotocolplugins/httpclient/chttpresponseparser.h Mon Mar 15 12:42:40 2010 +0200 +++ b/applayerpluginsandutils/httpprotocolplugins/httpclient/chttpresponseparser.h Wed Mar 31 22:32:15 2010 +0300 @@ -63,6 +63,7 @@ virtual void OnResponseReceiveTimeOut (); virtual TInt ReceiveTimeOutValue (); TBool ResponseInformational (); + virtual void FlushBodyDataIfNotRead(); private: // methods from MHttpMessageParserObserver diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerpluginsandutils/httpprotocolplugins/httpclient/mhttpresponse.h --- a/applayerpluginsandutils/httpprotocolplugins/httpclient/mhttpresponse.h Mon Mar 15 12:42:40 2010 +0200 +++ b/applayerpluginsandutils/httpprotocolplugins/httpclient/mhttpresponse.h Wed Mar 31 22:32:15 2010 +0300 @@ -42,6 +42,8 @@ virtual void FailTransactionL() = 0; virtual TBool ResponseInformational () =0; + + virtual void FlushBodyDataIfNotRead() =0; }; diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerprotocols/httpservice/EABI/httpserviceu.def --- a/applayerprotocols/httpservice/EABI/httpserviceu.def Mon Mar 15 12:42:40 2010 +0200 +++ b/applayerprotocols/httpservice/EABI/httpserviceu.def Wed Mar 31 22:32:15 2010 +0300 @@ -91,4 +91,10 @@ _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 diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerprotocols/httpservice/bwins/httpserviceU.def --- a/applayerprotocols/httpservice/bwins/httpserviceU.def Mon Mar 15 12:42:40 2010 +0200 +++ b/applayerprotocols/httpservice/bwins/httpserviceU.def Wed Mar 31 22:32:15 2010 +0300 @@ -65,4 +65,8 @@ ?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) diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerprotocols/httpservice/group/bld.inf --- a/applayerprotocols/httpservice/group/bld.inf Mon Mar 15 12:42:40 2010 +0200 +++ b/applayerprotocols/httpservice/group/bld.inf Wed Mar 31 22:32:15 2010 +0300 @@ -36,6 +36,7 @@ ../inc/chttpclienttransaction.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(chttpclienttransaction.h) ../inc/httpservice.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(httpservice.h) ../inc/mhttpserviceauthentication.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(mhttpserviceauthentication.h) +../inc/chttpnetworkconnectioninfo.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(chttpnetworkconnectioninfo.h) // rom definition file diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerprotocols/httpservice/group/httpservice.mmp --- a/applayerprotocols/httpservice/group/httpservice.mmp Mon Mar 15 12:42:40 2010 +0200 +++ b/applayerprotocols/httpservice/group/httpservice.mmp Wed Mar 31 22:32:15 2010 +0300 @@ -44,7 +44,7 @@ SOURCE chttpclienttransaction.cpp SOURCE httpheaderiter.cpp SOURCE httpclientutils.cpp chttpclienttransactionimpl.cpp -SOURCE chttpdatasender.cpp chttpdatareceiver.cpp chttpcontentreader.cpp chttpcontentwriter.cpp chttpclientauthentication.cpp +SOURCE chttpdatasender.cpp chttpdatareceiver.cpp chttpcontentreader.cpp chttpcontentwriter.cpp chttpclientauthentication.cpp chttpnetworkconnectioninfo.cpp CConnectionMonitor.cpp LIBRARY euser.lib LIBRARY http.lib diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerprotocols/httpservice/inc/cconnectionmonitor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/applayerprotocols/httpservice/inc/cconnectionmonitor.h Wed Mar 31 22:32:15 2010 +0300 @@ -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_ */ diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerprotocols/httpservice/inc/chttpnetworkconnectioninfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/applayerprotocols/httpservice/inc/chttpnetworkconnectioninfo.h Wed Mar 31 22:32:15 2010 +0300 @@ -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 +#include +#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_ */ diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerprotocols/httpservice/inc/chttpservice.h --- a/applayerprotocols/httpservice/inc/chttpservice.h Mon Mar 15 12:42:40 2010 +0200 +++ b/applayerprotocols/httpservice/inc/chttpservice.h Wed Mar 31 22:32:15 2010 +0300 @@ -20,7 +20,7 @@ #include #include #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 @@ -36,6 +36,7 @@ class CHttpService : public CBase { friend class CHttpClientTransactionImpl; + friend class CHttpNetworkConnection; public: IMPORT_C static CHttpService* NewL(); @@ -57,6 +58,8 @@ IMPORT_C TInt SetAuthentication(MHTTPServiceAuthentication* aCallback); + IMPORT_C CHttpNetworkConnection* HttpNetworkConnection(); + private: CHttpService(); void ConstructL(); diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerprotocols/httpservice/inc/httpservice.h --- a/applayerprotocols/httpservice/inc/httpservice.h Mon Mar 15 12:42:40 2010 +0200 +++ b/applayerprotocols/httpservice/inc/httpservice.h Wed Mar 31 22:32:15 2010 +0300 @@ -24,5 +24,6 @@ #include #include #include +#include #endif // __MHTTPDATARECIVER_H__ diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerprotocols/httpservice/src/cconnectionmonitor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/applayerprotocols/httpservice/src/cconnectionmonitor.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -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 +#include +#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(); + } diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerprotocols/httpservice/src/chttpnetworkconnectioninfo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/applayerprotocols/httpservice/src/chttpnetworkconnectioninfo.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -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 +#include +#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(&(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; + } + } + diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerprotocols/httpservice/src/chttpservice.cpp --- a/applayerprotocols/httpservice/src/chttpservice.cpp Mon Mar 15 12:42:40 2010 +0200 +++ b/applayerprotocols/httpservice/src/chttpservice.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -17,6 +17,7 @@ #include "httpclientutils.h" #include "chttpclientauthentication.h" #include "mhttpserviceauthentication.h" +#include "chttpnetworkconnectioninfo.h" const TInt KMaxNoOfConnections = 6; const TInt KMaxTransToPipeline = 5; @@ -247,3 +248,9 @@ SetMaxTransactionsToPipeline(KMaxTransToPipeline); } +EXPORT_C CHttpNetworkConnection* CHttpService::HttpNetworkConnection() + { + CHttpNetworkConnection *httpNetworkConn = CHttpNetworkConnection::New(); + httpNetworkConn->SetHttpService(this); + return httpNetworkConn; + } diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerprotocols/httpservice/test/group/httpservicetest.mmp --- a/applayerprotocols/httpservice/test/group/httpservicetest.mmp Mon Mar 15 12:42:40 2010 +0200 +++ b/applayerprotocols/httpservice/test/group/httpservicetest.mmp Wed Mar 31 22:32:15 2010 +0300 @@ -59,5 +59,5 @@ LIBRARY efsrv.lib LIBRARY httptestutils.lib LIBRARY esock.lib insock.lib - +LIBRARY commdb.lib SMPSAFE diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.cpp --- a/applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.cpp Mon Mar 15 12:42:40 2010 +0200 +++ b/applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -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,10 +19,12 @@ #include "ctestclienthttppost.h" #include #include +#include #include "httptestutils.h" #include "clocaltestserver.h" #include "chttpclienttestparams.h" #include "ctesthttpserviceauthentication.h" +#include "chttpnetworkconnectioninfo.h" _LIT(KTestCaseName, "TestCaseName"); _LIT8(KUserAgent, "HTTP Client API Test"); @@ -50,14 +52,21 @@ // TEF virtuals TVerdict CTestHttpClientStep::doTestStepPreambleL() { + TInt status; iActiveScheduler = new (ELeave) CActiveScheduler(); 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(); + status = iHttpConnInfo->Start(); THttpHeaderValueVariant variant(KUserAgent()); if(iHttpClient->AddRequestHeader(HTTP::EUserAgent, variant)) { @@ -134,12 +143,10 @@ { iHttpTrans->SetNoRetry(); } - if(param->ResponseTimeoutEnable()) { iHttpTrans->SetResponseTimeout(10); } - const RPointerArray& info = param->RequestHeaderInfos(); for(TInt i = 0; i < info.Count(); ++i) { @@ -169,7 +176,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); } } diff -r fa2fd8b2d6cc -r 2611c08ee28e applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.h --- a/applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.h Mon Mar 15 12:42:40 2010 +0200 +++ b/applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.h Wed Mar 31 22:32:15 2010 +0300 @@ -26,6 +26,7 @@ class CLocalTestServer; class CHTTPTestUtils; class CHttpClientTestParamArray; +class CHttpNetworkConnection; class CTestHttpServiceAuthentication; class CTestHttpClientStep : public CTestStep, public MLocalTestServerObserver @@ -50,6 +51,7 @@ CLocalTestServer* iTestServer; CHttpClientTestParamArray* iTestParamArray; CTestHttpServiceAuthentication* iTestHttpServiceAuthentication; + CHttpNetworkConnection* iHttpConnInfo; }; #endif // __CTESTHTTPCLIENTSTEP_H__ diff -r fa2fd8b2d6cc -r 2611c08ee28e brdo.layers.sysdef.xml --- a/brdo.layers.sysdef.xml Mon Mar 15 12:42:40 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ - - ]> - - - - - - - - - - - - - - - - - - - - - - - diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/BWinsCw/COOKIEMANAGERU_EKA2U.def --- a/httpfilters/cookie/BWinsCw/COOKIEMANAGERU_EKA2U.def Mon Mar 15 12:42:40 2010 +0200 +++ b/httpfilters/cookie/BWinsCw/COOKIEMANAGERU_EKA2U.def Wed Mar 31 22:32:15 2010 +0300 @@ -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 &, int &, unsigned long &) + ?StoreCookie@RCookieManager@@QAEHABVCCookie@@ABVTUriC8@@AAK@Z @ 17 NONAME ; int RCookieManager::StoreCookie(class CCookie const &, class TUriC8 const &, unsigned long &) + diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/EABI/COOKIEMANAGERU_EKA2U.def --- a/httpfilters/cookie/EABI/COOKIEMANAGERU_EKA2U.def Mon Mar 15 12:42:40 2010 +0200 +++ b/httpfilters/cookie/EABI/COOKIEMANAGERU_EKA2U.def Wed Mar 31 22:32:15 2010 +0300 @@ -16,4 +16,9 @@ _ZNK7CCookie9AttributeENS_20TCookieAttributeNameER11THTTPHdrVal @ 15 NONAME _ZTI7CCookie @ 16 NONAME ; ## _ZTV7CCookie @ 17 NONAME ; ## - _ZN14RCookieManager10SetAppUidLERKm @ 18 NONAME \ No newline at end of file + _ZN14RCookieManager10SetAppUidLERKm @ 18 NONAME + _ZN14RCookieManager11GetCookiesLERK6TDesC8R13RPointerArrayI7CCookieERiRm @ 19 NONAME + _ZN14RCookieManager11StoreCookieERK7CCookieRK6TUriC8Rm @ 20 NONAME + _ZN14RCookieManager21ClearAllAppUidCookiesERKm @ 21 NONAME + _ZN14RCookieManager5CloseEv @ 22 NONAME + diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/EABI/cookiemanageru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/EABI/cookiemanageru.def Wed Mar 31 22:32:15 2010 +0300 @@ -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 ; ## + _ZTV7CCookie @ 22 NONAME ; ## + diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/FilterSrc/CookieFilter.cpp --- a/httpfilters/cookie/FilterSrc/CookieFilter.cpp Mon Mar 15 12:42:40 2010 +0200 +++ b/httpfilters/cookie/FilterSrc/CookieFilter.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -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 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 } diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/Group/CookieManager.mmp --- a/httpfilters/cookie/Group/CookieManager.mmp Mon Mar 15 12:42:40 2010 +0200 +++ b/httpfilters/cookie/Group/CookieManager.mmp Wed Mar 31 22:32:15 2010 +0300 @@ -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(ARMCC) DEFFILE ../EABI/COOKIEMANAGERU_EKA2.def diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/Group/bld.inf --- a/httpfilters/cookie/Group/bld.inf Mon Mar 15 12:42:40 2010 +0200 +++ b/httpfilters/cookie/Group/bld.inf Wed Mar 31 22:32:15 2010 +0300 @@ -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) diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerInc/CookieArray.h --- a/httpfilters/cookie/ManagerInc/CookieArray.h Mon Mar 15 12:42:40 2010 +0200 +++ b/httpfilters/cookie/ManagerInc/CookieArray.h Wed Mar 31 22:32:15 2010 +0300 @@ -87,6 +87,8 @@ */ TInt GetCookies( const TDesC8& aRequestUri, RPointerArray& aCookies ); + TInt GetCookies( const TDesC8& aRequestUri, + RPointerArray& aCookies, TBool& iFound ); /** * @@ -123,6 +125,7 @@ RPointerArray& CookieArray(); + void ReserveL( TInt aNumberOfCookies ); private : // internal method for cookie comparison /** diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerInc/CookieClientData.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerInc/CookieClientData.h Wed Mar 31 22:32:15 2010 +0300 @@ -0,0 +1,135 @@ +/* + * CookieClientData.h + * + * Created on: Dec 28, 2009 + * Author: mohanti + */ + +#ifndef COOKIECLIENTDATA_H_ +#define COOKIECLIENTDATA_H_ + +//System Includes +#include + +//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& 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_ */ diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerInc/CookieClientDataArray.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerInc/CookieClientDataArray.h Wed Mar 31 22:32:15 2010 +0300 @@ -0,0 +1,126 @@ +/* + * 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* GetInstance(); + + /* Reference Count method + * + */ + inline void Ref(){++iRefCount;} + + /*Dereference count method and will delete the CCookieClientDataArray object once the iRefCount is zero + * + */ + void DeRef(); + + /* Destructor + * + */ + ~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: + TInt iRefCount; + RPointerArray* iCookieClientData; + }; + + +#endif /* COOKIECLIENTDATAARRAY_H_ */ diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerInc/CookieGroupData.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerInc/CookieGroupData.h Wed Mar 31 22:32:15 2010 +0300 @@ -0,0 +1,182 @@ +/* + * CCookieGroupData.h + * + * Created on: Nov 24, 2009 + * Author: mohanti + */ + +#ifndef COOKIEGROUPDATA_H_ +#define COOKIEGROUPDATA_H_ + +//System Includes +#include +#include +#include +#include +#include + +//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& 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& 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& 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 iSharedUid; + //TUint32 iAppUid; + }; + +#endif /* COOKIEGROUPDATA_H_ */ diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerInc/CookieGroupDataArray.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerInc/CookieGroupDataArray.h Wed Mar 31 22:32:15 2010 +0300 @@ -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& 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* iCookieGroupData; + }; + +#endif /* CCOOKIEGROUPDATAARRAY_H_ */ diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerInc/CookieLogger.h --- a/httpfilters/cookie/ManagerInc/CookieLogger.h Mon Mar 15 12:42:40 2010 +0200 +++ b/httpfilters/cookie/ManagerInc/CookieLogger.h Wed Mar 31 22:32:15 2010 +0300 @@ -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. }; diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerInc/CookieManagerServer.h --- a/httpfilters/cookie/ManagerInc/CookieManagerServer.h Mon Mar 15 12:42:40 2010 +0200 +++ b/httpfilters/cookie/ManagerInc/CookieManagerServer.h Wed Mar 31 22:32:15 2010 +0300 @@ -25,15 +25,19 @@ #include #include #include +#include // 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& aCookies ) const; +// TInt GetCookies( const TDesC8& aRequestUri, +// RPointerArray& 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& 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& 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; + }; diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerInc/CookieManagerSession.h --- a/httpfilters/cookie/ManagerInc/CookieManagerSession.h Mon Mar 15 12:42:40 2010 +0200 +++ b/httpfilters/cookie/ManagerInc/CookieManagerSession.h Wed Mar 31 22:32:15 2010 +0300 @@ -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; @@ -144,8 +173,6 @@ // The size of the temporary cookie list in bytes TInt iGetCookieListSize; - -// CCookieArray* iTransientCookies; }; #endif //__COOKIEMANAGER_SESSION_H__ diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerInc/GroupIdInfoArray.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerInc/GroupIdInfoArray.h Wed Mar 31 22:32:15 2010 +0300 @@ -0,0 +1,113 @@ +/* + * CGroupIdInfoArray.h + * + * Created on: Nov 24, 2009 + * Author: mohanti + */ + +#ifndef GROUPIDINFOARRAY_H_ +#define GROUPIDINFOARRAY_H_ +//System Includes +#include +#include +#include +//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& aAppuid, TBool aCookieSharableFlag = EFalse ); + + /*Constructor + * + */ + static CGroupIdInfo* NewLC(TUint32 aGroupId, const RArray& 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& aAppuid); + public: + protected: + + private: + TBool iCookieSharableFlag; + TUint32 iGroupId; + //TUint32 iSecureId; + RArray 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* iGroupIdInfoArray; + }; + +#endif /* GROUPIDINFOARRAY_H_ */ diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerSrc/Cookie.cpp --- a/httpfilters/cookie/ManagerSrc/Cookie.cpp Mon Mar 15 12:42:40 2010 +0200 +++ b/httpfilters/cookie/ManagerSrc/Cookie.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -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; iCopyFromL( aCopy ); + 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; } @@ -324,71 +446,99 @@ // void CCookie::CopyFromL( const CCookie& aCopyFrom ) { - THTTPHdrVal attributevalue; - TBool aDefaulted( EFalse ); - - if ( aCopyFrom.Attribute( EName, attributevalue, aDefaulted ) != KErrNotFound ) + CLOG( ( ECookie, 0, _L( "-> CCookie::CopyFromL ") ) ); + THTTPHdrVal attributevalue; + TBool defaulted( EFalse ); + if ( aCopyFrom.Attribute( EName, attributevalue, defaulted ) != KErrNotFound ) { - SetAttribute( EName, attributevalue, aDefaulted ); - } - - if ( aCopyFrom.Attribute( EValue, attributevalue, aDefaulted ) != KErrNotFound ) - { - SetAttribute( EValue, 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 ); + } } - if ( aCopyFrom.Attribute( EComment, attributevalue, aDefaulted ) != KErrNotFound ) + if ( aCopyFrom.Attribute( EValue, attributevalue, defaulted ) != 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 ); + } + } + if ( aCopyFrom.Attribute( EComment, attributevalue, defaulted ) != KErrNotFound ) + { + SetAttribute( EComment, attributevalue, defaulted ); } - if ( aCopyFrom.Attribute( ECommentURI, attributevalue, aDefaulted ) != KErrNotFound ) - { - SetAttribute( ECommentURI, attributevalue, aDefaulted ); - } - - if ( aCopyFrom.Attribute( EDiscard, attributevalue, aDefaulted ) != KErrNotFound ) + if ( aCopyFrom.Attribute( ECommentURI, attributevalue, defaulted ) != KErrNotFound ) { - SetAttribute( EDiscard, attributevalue, aDefaulted ); - } - - if ( aCopyFrom.Attribute( EDomain, attributevalue, aDefaulted ) != KErrNotFound ) - { - SetAttribute( EDomain, attributevalue, aDefaulted ); + SetAttribute( ECommentURI, attributevalue, defaulted ); } - if ( aCopyFrom.Attribute( EMaxAge, attributevalue, aDefaulted ) != KErrNotFound ) + if ( aCopyFrom.Attribute( EDiscard, attributevalue, defaulted ) != KErrNotFound ) { - SetAttribute( EMaxAge, attributevalue, aDefaulted ); + SetAttribute( EDiscard, attributevalue, defaulted ); } - if ( aCopyFrom.Attribute( EPath, attributevalue, aDefaulted ) != KErrNotFound ) + if ( aCopyFrom.Attribute( EDomain, attributevalue, defaulted ) != KErrNotFound ) { - SetAttribute( EPath, attributevalue, aDefaulted ); + SetAttribute( EDomain, attributevalue, defaulted ); } - if ( aCopyFrom.Attribute( EPort, attributevalue, aDefaulted ) != KErrNotFound ) + if ( aCopyFrom.Attribute( EMaxAge, attributevalue, defaulted ) != KErrNotFound ) { - SetAttribute( EPort, attributevalue, aDefaulted ); + SetAttribute( EMaxAge, attributevalue, defaulted ); + } + + if ( aCopyFrom.Attribute( EPath, attributevalue, defaulted ) != KErrNotFound ) + { + SetAttribute( EPath, attributevalue, defaulted ); } - if ( aCopyFrom.Attribute( ESecure, attributevalue, aDefaulted ) != KErrNotFound ) + if ( aCopyFrom.Attribute( EPort, attributevalue, defaulted ) != KErrNotFound ) { - SetAttribute( ESecure, attributevalue, aDefaulted ); + SetAttribute( EPort, attributevalue, defaulted ); + } + + if ( aCopyFrom.Attribute( ESecure, attributevalue, defaulted ) != KErrNotFound ) + { + SetAttribute( ESecure, attributevalue, defaulted ); } - if ( aCopyFrom.Attribute( EVersion, attributevalue, aDefaulted ) != KErrNotFound ) + if ( aCopyFrom.Attribute( EVersion, attributevalue, defaulted ) != KErrNotFound ) { - SetAttribute( EVersion, attributevalue, aDefaulted ); + SetAttribute( EVersion, attributevalue, defaulted ); } - if ( aCopyFrom.Attribute( EExpires, attributevalue, aDefaulted ) != KErrNotFound ) + if ( aCopyFrom.Attribute( EExpires, attributevalue, defaulted ) != KErrNotFound ) { - SetAttribute( EExpires, attributevalue, aDefaulted ); + SetAttribute( EExpires, attributevalue, defaulted ); } - SetCookie2( aCopyFrom.FromCookie2() ); - + //SetCookie2( aCopyFrom.FromCookie2() ); + // Other properties + iSetCookie2 = aCopyFrom.iSetCookie2; + iNetscape = aCopyFrom.iNetscape; + iSize = aCopyFrom.iSize; + iReceivedTime = aCopyFrom.iReceivedTime; + CLOG( ( ECookie, 0, _L( "<- CCookie::CopyFromL ") ) ); } @@ -411,6 +561,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 +630,7 @@ } } } + CLOG( ( ECookie, 0, _L( "<- CCookie::Expired retval : %d"),retval ) ); return retval; } // --------------------------------------------------------- @@ -487,7 +639,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 +670,7 @@ result.Set( aDes.Mid( firstChar, lastChar - firstChar + 1 ) ); } } - + CLOG( ( ECookie, 0, _L( "<- CCookie::RemoveQuotes result : %d "),result ) ); return result; } @@ -530,6 +682,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 +889,7 @@ retval = ETrue; } CleanupStack::PopAndDestroy( cleanupNum ); // temp1, temp2, desDate, desTime + CLOG( ( ECookie, 0, _L( "<- CCookie::ExpiredNetscapeL retval : %d "),retval ) ); return retval; } @@ -749,6 +903,7 @@ const TInt aTokenCount, TInt* aTokens ) const { + CLOG( ( ECookie, 0, _L( "-> CCookie::FindTokens ") ) ); TLex8 lex = aString; TChar ch; TInt tokenCount( 0 ), ii; @@ -762,6 +917,7 @@ aTokens[tokenCount++] = lex.Offset()-1; } } + CLOG( ( ECookie, 0, _L( "<- CCookie::FindTokens tokenCount : %d"),tokenCount ) ); return tokenCount; } @@ -771,6 +927,7 @@ // TBool CCookie::Persistent() const { + CLOG( ( ECookie, 0, _L( "-> CCookie::Persistent ") ) ); TBool result( EFalse ); THTTPHdrVal attrVal; @@ -818,6 +975,7 @@ } } } + CLOG( ( ECookie, 0, _L( "<- CCookie::Persistent result : %d"),result ) ); return result; } @@ -827,6 +985,7 @@ // TBool CCookie::IsUnknownVersion() const { + CLOG( ( ECookie, 0, _L( "-> CCookie::IsUnknownVersion ") ) ); TBool unknownVersion( EFalse ); THTTPHdrVal attrVal; if( Attribute( CCookie::EVersion, attrVal ) != KErrNotFound ) @@ -836,6 +995,7 @@ unknownVersion = ETrue; } } + CLOG( ( ECookie, 0, _L( "<- CCookie::IsUnknownVersion unknownVersion : %d"),unknownVersion ) ); return unknownVersion; } @@ -846,7 +1006,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 +1019,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 @@ -1160,6 +1323,7 @@ } } } + CLOG( ( ECookie, 0, _L( "<- CCookie::ConstructL ") ) ); } @@ -1171,16 +1335,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 +1356,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 +1371,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 +1388,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 +1480,7 @@ lex1.Val( aMinute ); CleanupStack::PopAndDestroy( temp ); // temp } + CLOG( ( ECookie, 0, _L( "<- CCookie::GetLocalOffset retval : %d "),retval ) ); return retval; } @@ -1321,9 +1493,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 +1510,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 +1599,7 @@ // get the length aLength = aDate->Length() - zonepos; } - + CLOG( ( ECookie, 0, _L( "<- CCookie::GetTimeZone retval :%d "),retval ) ); return retval; } @@ -1436,6 +1611,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 +1678,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 +1697,7 @@ : iName( aName ), iDefaulted( aDefaulted ) { + CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute") ) ); iValue = aHdrVal.Copy(); @@ -1528,28 +1706,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 +1743,8 @@ // CCookie::TCookieAttribute::TCookieAttribute() { + CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute ") ) ); + CLOG( ( ECookie, 0, _L( "<- CCookie::TCookieAttribute ") ) ); } @@ -1568,18 +1754,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 ") ) ); } diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerSrc/CookieArray.cpp --- a/httpfilters/cookie/ManagerSrc/CookieArray.cpp Mon Mar 15 12:42:40 2010 +0200 +++ b/httpfilters/cookie/ManagerSrc/CookieArray.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -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& aCookies, TBool& aFound )// harendra: aFound is redundant + { + 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] ); + CleanupStack::PushL( clone ); + err = aCookies.Append(clone); + CleanupStack::Pop(clone); + aFound = ETrue; + } + } + aCookies.Sort( TLinearOrder (CCookieArray::CompareCookiesPath) ); + } + + + + CLOG( ( ECookieArray, 0, + _L( "<- CCookieArray::GetCookies for an URI" ) ) ); + return err; + } diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerSrc/CookieClientData.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerSrc/CookieClientData.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -0,0 +1,192 @@ +/* + * CookieClientData.cpp + * + * Created on: Dec 28, 2009 + * Author: mohanti + */ +//User Includes +#include "CookieClientdata.h" +#include "Cookie.h" +#include "CookieArray.h" +#include "cookielogger.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 + + CCookie* clone = CCookie::CloneL( *aCookie ); + 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& aCookies,TBool& aCookieFound )const + { + return iCookieArray->GetCookies(aRequestUri,aCookies,aCookieFound); + } + +// --------------------------------------------------------- +// CCookieGroupData::CookieArray +// --------------------------------------------------------- +// +CCookieArray* CCookieClientData::CookieArray() + { + return iCookieArray; + } +//EOF diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerSrc/CookieClientDataArray.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerSrc/CookieClientDataArray.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -0,0 +1,255 @@ +/* + * CookieClientDataArray.cpp + * + * Created on: Dec 18, 2009 + * Author: mohanti + */ + +//System Includes +#include +#include +#include + +//User Includes +#include "CookieClientDataArray.h" +#include "CookieManagerClient.h" +#include "CookieArray.h" +#include "CookieLogger.h" +#include "CookieClientData.h" + +//Constatnts +const TInt KCookieArrayGranularity = 10; + +// --------------------------------------------------------- +// CCookieClientDataArray::GetInstance +// --------------------------------------------------------- +// +CCookieClientDataArray* CCookieClientDataArray::GetInstance() + { + CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::GetInstance" ) ) ); + CCookieClientDataArray *clientInstance = static_cast (Dll::Tls()); + if (!clientInstance) + { + clientInstance = new (ELeave) CCookieClientDataArray(); + Dll::SetTls(clientInstance); + } + CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::GetInstance instance = %x" ),clientInstance ) ); + return clientInstance; + } +// --------------------------------------------------------- +// CCookieClientDataArray::DeRef +// --------------------------------------------------------- +// +void CCookieClientDataArray::DeRef() + { + CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::Deref" ) ) ); + --iRefCount; + if (iRefCount <= 0) + { + delete iCookieClientData; + iCookieClientData = NULL; + Dll::SetTls(0); + CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::Deref deletes iCookieClientData" ) ) ); + } + CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::Deref" ) ) ); + } +// --------------------------------------------------------- +// CCookieClientDataArray::ConstructL +// --------------------------------------------------------- +// +CCookieClientDataArray::CCookieClientDataArray():iRefCount(0) + { + CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::ConstructL" ) ) ); + iCookieClientData = new (ELeave) RPointerArray(KCookieArrayGranularity); + CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::ConstructL" ) ) ); + } + +// --------------------------------------------------------- +// 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;iGetGroupId()== 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;iGetGroupId()== 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 diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerSrc/CookieGroupData.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerSrc/CookieGroupData.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -0,0 +1,457 @@ +/* + * CCookieGroupData.cpp + * + * Created on: Nov 24, 2009 + * Author: mohanti + */ + +//System Includes +#include +#include +#include + +//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& 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& 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& aAppuid) + { + CLOG( ( EClient, 0, _L( "-> CCookieGroupData::ConstructL:" ) ) ); + TInt count = aAppuid.Count(); + CLOG( ( EClient, 0, _L( "-> CGroupIdArray::count = %d" ), count ) ); + for(TInt i=0; i 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 buf(KDefaultCookieFile); + buf.Append(KUnderScore); + buf.AppendNum(iGroupId,EHex); + //For Widget case file name shobe becookie__.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 buf(KDefaultCookieFile); + buf.Append(KUnderScore); + buf.AppendNum(aSecureId,EHex); + //For Widget case file name shobe becookie__.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 diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerSrc/CookieGroupDataArray.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerSrc/CookieGroupDataArray.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -0,0 +1,336 @@ +/* + * CCookieGroupDataArray.cpp + * + * Created on: Nov 24, 2009 + * Author: mohanti + */ +//System Includes +#include +#include + +//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(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;iGetGroupId() == 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;iTotalAppUid(); + TInt appUidFound(EFalse); + if( p->GetGroupId() == aGroupId) + { + for(TInt j=0; jGetSharedUid(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 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; iGetGroupId() == 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;jGetSharedUid(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 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& 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; iGetGroupId() == 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; + } diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerSrc/CookieManagerClient.cpp --- a/httpfilters/cookie/ManagerSrc/CookieManagerClient.cpp Mon Mar 15 12:42:40 2010 +0200 +++ b/httpfilters/cookie/ManagerSrc/CookieManagerClient.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -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 @@ -80,7 +81,7 @@ EXPORT_C TInt RCookieManager::Connect() { CLOG( ( EClientConnect, 0, _L( "-> RCookieManager::Connect" ) ) ); - + CCookieClientDataArray::GetInstance()->Ref(); TInt error = KErrNone; RProcess server; error = server.Create( KCookieServerExe, TPtr( NULL, 0 ), @@ -116,7 +117,7 @@ } // --------------------------------------------------------- -// RCookieManager::GetCookies +// RCookieManager::DoGetCookies // --------------------------------------------------------- // TInt RCookieManager::DoGetCookies( TDes8& aBuffer ) const @@ -125,25 +126,53 @@ } // --------------------------------------------------------- -// RCookieManager::GetCookieSize +// RCookieManager::GetCookieSharableFlagFromServer +// --------------------------------------------------------- +// +TInt RCookieManager::GetCookieSharableFlagFromServer(TBool& aCookieSharableFlag )const + { + TPckg cookieSharableFlag(aCookieSharableFlag); + return SendReceive( EGetCookieSharableFlag, TIpcArgs( &cookieSharableFlag ) ); + } + +// --------------------------------------------------------- +// RCookieManager::DoGetCookieSize // --------------------------------------------------------- // TInt RCookieManager::DoGetCookieSize( const TDesC8& aRequestUri, - TPckg& aPkgSize ) const + TPckg& 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 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 +184,30 @@ TBool& aCookie2Reqd ) { CLOG( ( EClient, 0, _L( "-> RCookieManager::GetCookiesL" ) ) ); + TBool cookiefound(EFalse); + CCookieClientDataArray* cookieclientdataarray = CCookieClientDataArray::GetInstance(); + if(cookieclientdataarray) // redundant check + { + TInt clientarraycount = cookieclientdataarray->Count(); + if ( clientarraycount!=0 ) + { + TInt clerr = GetClientSideCookies(aUri,aCookies,cookiefound,0); + } + } + if(!cookiefound) + { aCookie2Reqd = EFalse; TInt size = 0; TPckg 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 ); @@ -196,7 +242,7 @@ CleanupStack::PopAndDestroy(); // buf } - + } CLOG( ( EClient, 0, _L( "<- RCookieManager::GetCookiesL" ) ) ); } @@ -223,7 +269,14 @@ err = iCookiePacker.CliPackCookie( bufDes, aCookie ); if ( !err ) { - err = DoStoreCookie( *buf, aUri.UriDes() ); + //Appuid value only takes 8 chars + HBufC* appbuf = HBufC::New(8); // harendra: 8 chars needed + 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,13 +306,30 @@ } // --------------------------------------------------------- -// 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 = CCookieClientDataArray::GetInstance()->Find(groupid, const_cast (aAppUid)); + if(cookieclientdata) + { + cookieclientdata->SetWidgetUid(aAppUid); + } + else + { + TBool cookieSharableFlag(EFalse); + TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag); + CCookieClientData* cookieclientdata = CCookieClientData::NewL(groupid, aAppUid, cookieSharableFlag,ETrue); + cookieclientdata->SetInitFlag(ETrue); + CCookieClientDataArray::GetInstance()->AddClientGroupDataL(cookieclientdata); + } + //Appuid value only takes 8 chars + HBufC* buf = HBufC::NewLC(8); TPtr ptr(buf->Des()); ptr.AppendNum(aAppUid,EHex); TInt error = SendReceive(ESetAppUid,TIpcArgs(ptr.Length(),&ptr)); @@ -267,4 +337,255 @@ CLOG(( EClient, 0, _L("<-RCookieManager::SetAppUid") )); return error; } +// --------------------------------------------------------- +// RCookieManager::Close +// --------------------------------------------------------- +// + +EXPORT_C void RCookieManager::Close() + { + CLOG(( EClient, 0, _L("-> RCookieManager::Close") )); + CCookieClientDataArray::GetInstance()->DeRef(); + TInt deletestatus =0; + DestroyCookiesFromMemory(deletestatus); + 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 = iCookiePacker.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& aCookies, + TBool& aCookie2Reqd,TUint32& aAppUid ) + { + CLOG( ( EClient, 0, _L( "-> RCookieManager::GetCookiesL" ) ) ); + TBool cookiefound(EFalse); + CCookieClientDataArray* cookieclientdataarray = CCookieClientDataArray::GetInstance(); + 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 = cookieclientdata->GetClientSideCookies(aUri,aCookies,cookiefound); + 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 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. + iCookiePacker.UnpackCookiesFromBufferL( *buf, aCookies ); + + TInt count = aCookies.Count(); + for(TInt j=0; j 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 + CCookieClientDataArray::GetInstance()->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 = CCookieClientDataArray::GetInstance(); + TInt count = cookieclientdataarray->Count(); + TInt itemIndex =0; + for(TInt i=0; iAt(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; + } + } + CCookieClientData* cookieclientdata = cookieclientdataarray->At(itemIndex); + cookieclientdata->StoreCookieAtClientSideL(aCookie,aUri); + CLOG( ( EClient, 0, _L( "<- RCookieManager::StoreCookieAtClientSide" ) ) ); + } + +// --------------------------------------------------------- +// RCookieManager::GetClientSideCookies +// --------------------------------------------------------- +// +TInt RCookieManager::GetClientSideCookies( const TDesC8& aRequestUri,RPointerArray& aCookies + ,TBool& aCookieFound, TUint32 aWidgetUid ) + { + CLOG( ( EClient, 0, _L( "-> RCookieManager::GetClientSideCookies" ) ) ); + TUint32 groupid = RProcess().SecureId().iId; + //TInt itemIndex =0; + CCookieClientData* cookieclientdata = NULL; + CCookieClientDataArray* cookieclientdataarray = CCookieClientDataArray::GetInstance(); + 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 + { + //harendra: move this for loop in CCookieClientDataArray::Find(), it should index or object + cookieclientdata = cookieclientdataarray->Find(groupid, aWidgetUid); + } + if(cookieclientdata) + { + if(!cookieclientdata->GetInitFlag()) + { + TBool cookieSharableFlag(EFalse); + TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag); + cookieclientdata->SetCookieCookieSharableFlag(cookieSharableFlag); + } + //cookieclientdata->SetInitFlag(ETrue); + 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; + } + // End of file diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerSrc/CookieManagerServer.cpp --- a/httpfilters/cookie/ManagerSrc/CookieManagerServer.cpp Mon Mar 15 12:42:40 2010 +0200 +++ b/httpfilters/cookie/ManagerSrc/CookieManagerServer.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -22,6 +22,14 @@ #include #include +#include +#include +#include +#include +#include +#include +#include + // #include // 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,26 @@ // CCookieManagerServer::~CCookieManagerServer() { + CLOG( ( EServer, 0, _L( "-> CCookieManagerServer::~CCookieManagerServer" ) ) ); iServerClosing = ETrue; - delete iPersistentCookies; + // delete iPersistentCookies; - delete iCookieFileName; + //delete iCookieFileName; - iFs.Close(); + //iFs.Close(); iStringPool.Close(); - - delete iCookiePacker; +// delete iCookiePacker; + if(iCookieGroupDataArray) + { + delete iCookieGroupDataArray; + iCookieGroupDataArray = NULL; + } + delete iGroupIdArray; delete iCloseTimer; - CLOG( ( EServer, 0, _L( "CCookieManagerServer::~CCookieManagerServer") ) ); + CLOG( ( EServer, 0, _L( "<-CCookieManagerServer::~CCookieManagerServer") ) ); CLOG( ( EServer, 0, _L( "*****************" ) ) ); } @@ -277,199 +314,17 @@ // e.g. 1 minute before doing so as starting a server is expensive // in many ways. CLOG( ( EServer, 0, _L( "Closing Server" ) ) ); - iPersistentCookies->RemoveNonPersistent(); + //iPersistentCookies->RemoveNonPersistent(); 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 +340,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& aCookies ) const + RPointerArray& 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 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 +422,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 nodelist1; + RXmlEngNodeList 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 sharedAppUidArray(5); + TUint32 groupId = 0; + TBool cookieSharableFlag; + TBool entryHasAttributes = element.HasAttributes(); + if ( entryHasAttributes ) + { + RXmlEngNodeList 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 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& 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 diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerSrc/CookieManagerSession.cpp --- a/httpfilters/cookie/ManagerSrc/CookieManagerSession.cpp Mon Mar 15 12:42:40 2010 +0200 +++ b/httpfilters/cookie/ManagerSrc/CookieManagerSession.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -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; iAt(i)->GetGroupId()== secureId ) + { + cookiesharableflag = cookiegroupdataarray->At(i)->GetCookieSharableFlag(); + break; + } + else + { + TInt shared = cookiegroupdataarray->At(i)->TotalAppUid(); + for (TInt j=0;jAt(i)->GetSharedUid(j)== secureId) + { + cookiesharableflag = cookiegroupdataarray->At(i)->GetCookieSharableFlag(); + break; + } + } + } + + } + TPckg 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 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); + TPckgcount(cookiegroupdata->ClearAllCookies()); + iCookieServer.CookieGroupDataArray()->Remove(groupDataIndex); + return aMessage.Write( 0, count ); + } + } + TPckgcount2(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); + TPckgcount(cookiegroupdata->ClearAllCookies()); + iCookieServer.CookieGroupDataArray()->Remove(groupDataIndex); + return aMessage.Write( 0, count ); + } + } + TPckgcount2(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); + TPckgstatus(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 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 diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerSrc/CookieManagerStart.cpp --- a/httpfilters/cookie/ManagerSrc/CookieManagerStart.cpp Mon Mar 15 12:42:40 2010 +0200 +++ b/httpfilters/cookie/ManagerSrc/CookieManagerStart.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -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 ) ); diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/ManagerSrc/GroupIdInfoArray.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerSrc/GroupIdInfoArray.cpp Wed Mar 31 22:32:15 2010 +0300 @@ -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& 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& 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& aAppuid) + { + CLOG( ( EClient, 0, _L( "-> CGroupIdArray::ConstructL" ) ) ); + TInt count = aAppuid.Count(); + CLOG( ( EClient, 0, _L( "-> CGroupIdArray::count = %d" ), count ) ); + for(TInt i=0; i 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 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(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 CGroupIdArray::GetGroupId aClientId = %x,aAppUid =%x" ), aClientId, aAppUid ) ); + TInt count = Count(); + TBool found(EFalse); + + for(TInt i=0;iCount(); + } diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/Rom/CookieManager.iby --- a/httpfilters/cookie/Rom/CookieManager.iby Mon Mar 15 12:42:40 2010 +0200 +++ b/httpfilters/cookie/Rom/CookieManager.iby Wed Mar 31 22:32:15 2010 +0300 @@ -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 diff -r fa2fd8b2d6cc -r 2611c08ee28e httpfilters/cookie/data/CookieGroup.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/data/CookieGroup.xml Wed Mar 31 22:32:15 2010 +0300 @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff -r fa2fd8b2d6cc -r 2611c08ee28e netprotocols_plat/cookie_manager_api/inc/cookie.h --- a/netprotocols_plat/cookie_manager_api/inc/cookie.h Mon Mar 15 12:42:40 2010 +0200 +++ b/netprotocols_plat/cookie_manager_api/inc/cookie.h Wed Mar 31 22:32:15 2010 +0300 @@ -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 @@ -266,7 +267,7 @@ * @return TBool indicating the cookies's Version attribute's notoriety. */ TBool IsUnknownVersion() const; - + static CCookie* CloneL( const CCookie& aCopy ); 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 diff -r fa2fd8b2d6cc -r 2611c08ee28e netprotocols_plat/cookie_manager_api/inc/cookiemanagerclient.h --- a/netprotocols_plat/cookie_manager_api/inc/cookiemanagerclient.h Mon Mar 15 12:42:40 2010 +0200 +++ b/netprotocols_plat/cookie_manager_api/inc/cookiemanagerclient.h Wed Mar 31 22:32:15 2010 +0300 @@ -87,6 +87,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& aCookies, + TBool& aCookie2Reqd,TUint32& aAppUid ); + IMPORT_C TInt ClearAllAppUidCookies(const TUint32& aAppUid); + private : // internal methods /** @@ -102,6 +110,9 @@ */ TInt DoGetCookieSize( const TDesC8& aRequestUri, TPckg& aPkgSize ) const; + + TInt DoGetCookieSize( const TDesC8& aRequestUri, + TPckg& aPkgSize,TDesC& aAppUidPtr ) const; /** * Puts those cookies in the buffer that have been previously selected @@ -115,12 +126,21 @@ * */ 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 ); + + TInt GetClientSideCookies( const TDesC8& aRequestUri,RPointerArray& aCookies + ,TBool& aFound, TUint32 aWidgetUid ); + TInt GetCookieSharableFlagFromServer(TBool& aCookieSharableFlag ) const; + private : // data members RStringPool iStringPool;