# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1277308101 -10800 # Node ID 974c3ee9bf20cae69f741345c61354850b1c6820 # Parent ea9c9681bbaf1635f288923592f8ec5220dca42f Revision: 201023 Kit: 2010125 diff -r ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/BWinsCw/COOKIEMANAGERU_EKA2U.def --- a/httpfilters/cookie/BWinsCw/COOKIEMANAGERU_EKA2U.def Fri Jun 11 14:06:05 2010 +0300 +++ b/httpfilters/cookie/BWinsCw/COOKIEMANAGERU_EKA2U.def Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/EABI/COOKIEMANAGERU_EKA2U.def --- a/httpfilters/cookie/EABI/COOKIEMANAGERU_EKA2U.def Fri Jun 11 14:06:05 2010 +0300 +++ b/httpfilters/cookie/EABI/COOKIEMANAGERU_EKA2U.def Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/EABI/cookiemanageru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/EABI/cookiemanageru.def Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/FilterSrc/CookieFilter.cpp --- a/httpfilters/cookie/FilterSrc/CookieFilter.cpp Fri Jun 11 14:06:05 2010 +0300 +++ b/httpfilters/cookie/FilterSrc/CookieFilter.cpp Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/Group/CookieManager.mmp --- a/httpfilters/cookie/Group/CookieManager.mmp Fri Jun 11 14:06:05 2010 +0300 +++ b/httpfilters/cookie/Group/CookieManager.mmp Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/Group/bld.inf --- a/httpfilters/cookie/Group/bld.inf Fri Jun 11 14:06:05 2010 +0300 +++ b/httpfilters/cookie/Group/bld.inf Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerInc/CookieArray.h --- a/httpfilters/cookie/ManagerInc/CookieArray.h Fri Jun 11 14:06:05 2010 +0300 +++ b/httpfilters/cookie/ManagerInc/CookieArray.h Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerInc/CookieClientData.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerInc/CookieClientData.h Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerInc/CookieClientDataArray.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerInc/CookieClientDataArray.h Wed Jun 23 18:48:21 2010 +0300 @@ -0,0 +1,119 @@ +/* + * CookieClientDataArray.h + * + * Created on: Dec 18, 2009 + * Author: mohanti + */ + +#ifndef COOKIECLIENTDATAARRAY_H_ +#define COOKIECLIENTDATAARRAY_H_ + +//System Includes + +//User Includes + +//Forward Class Declaration +class CCookieClientData; +class CCookieArray; + +//This class holds an array of CCookieClientdata objects. +//This a singleton class and is allocated in the Thread local storage(TLS) + +NONSHARABLE_CLASS( CCookieClientDataArray ):public CBase + { +public: + + /* Constructor + * + */ + + static CCookieClientDataArray* New(); + + /* Initialization + * + */ + void Init(); + + ~CCookieClientDataArray(); + + /* Constructor + * + */ + CCookieClientDataArray(); + + /* Finds the address of CCookieClientData object from the array based on group id and appuid + * @param aGroupId Indicates group id + * @param aWidgetUid Indicates appuid + */ + CCookieClientData* Find(const TUint32& aGroupId,const TUint32& aWidgetUid); + + /* Finds the Index of CCookieClientData object from the array based on group id and appuid + * @param aGroupId Indicates Group Id + * @param aWidgetUid Indicates Appuid + * @param aIndex On return of the method,it indicates the index no where the intended + * CCookieClientData Object is present + */ + TInt FindIndex(const TUint32& aGroupId, const TUint32& aWidgetUid,TInt& aIndex ); + + /* Adding CCookieClientData object in to the array. + * @param aCookieClientData Indiactes the address of CCookieClientData Object + */ + void AddClientGroupDataL(CCookieClientData* aCookieClientData); + + /* Returns the CCookieClientData object from the array based on index no. + * @param aIndex Indiactes index no. + */ + CCookieClientData* At(TInt aIndex) const; + + /* Subscripting operator + * + */ + CCookieClientData* operator[](TInt aIndex) const; + + /* Returns the no of CCookieClientData object in the array + * + */ + TInt Count()const; + + /* Returns the cookiearray from the array based on the index no. + * @param aIndex indeicates the index no + */ + CCookieArray* CookieArray(TInt aIndex); + + /* Removes a CCookieClientData object from the array based on index no. + * + */ + void Remove(TInt aIndex); + + /* Compresses the array + * + */ + void Compress(); + + /* Deletes a CCookieClientData object from the array based on appuid + * @param aAppUid Indicates appuid of a Secure Widget. + */ + TInt DestroyClientData(const TUint32 aAppUid); +protected: + +private: + + /* Constructor + * + */ + CCookieClientDataArray(const CCookieClientDataArray&); + + /* Assignment operator + * + */ + CCookieClientDataArray& operator=(const CCookieClientDataArray&); +public: + +protected: + +private: + RPointerArray* iCookieClientData; + }; + + +#endif /* COOKIECLIENTDATAARRAY_H_ */ diff -r ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerInc/CookieGroupData.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerInc/CookieGroupData.h Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerInc/CookieGroupDataArray.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerInc/CookieGroupDataArray.h Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerInc/CookieLogger.h --- a/httpfilters/cookie/ManagerInc/CookieLogger.h Fri Jun 11 14:06:05 2010 +0300 +++ b/httpfilters/cookie/ManagerInc/CookieLogger.h Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerInc/CookieManagerServer.h --- a/httpfilters/cookie/ManagerInc/CookieManagerServer.h Fri Jun 11 14:06:05 2010 +0300 +++ b/httpfilters/cookie/ManagerInc/CookieManagerServer.h Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerInc/CookieManagerSession.h --- a/httpfilters/cookie/ManagerInc/CookieManagerSession.h Fri Jun 11 14:06:05 2010 +0300 +++ b/httpfilters/cookie/ManagerInc/CookieManagerSession.h Wed Jun 23 18:48:21 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; @@ -145,7 +174,6 @@ // The size of the temporary cookie list in bytes TInt iGetCookieListSize; -// CCookieArray* iTransientCookies; }; #endif //__COOKIEMANAGER_SESSION_H__ diff -r ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerInc/GroupIdInfoArray.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerInc/GroupIdInfoArray.h Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerSrc/Cookie.cpp --- a/httpfilters/cookie/ManagerSrc/Cookie.cpp Fri Jun 11 14:06:05 2010 +0300 +++ b/httpfilters/cookie/ManagerSrc/Cookie.cpp Wed Jun 23 18:48:21 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, aDomain, aPath, aPort); + CleanupStack::Pop( self ); + return self; + } // --------------------------------------------------------- @@ -96,12 +199,15 @@ { // go through each attribute closing any attribute strings TInt numAttributes = iAttributes.Count(); + Log(); + CLOG( ( ECookie, 0, _L( "-> CCookie::~CCookie - this: 0x%08x, numAttributes: %d"), this, numAttributes ) ); for ( TInt ii = 0; ii < numAttributes; ++ii ) { iAttributes[ii].Close(); } iAttributes.Close(); + CLOG( ( ECookie, 0, _L( "<- CCookie::~CCookie - this: 0x%08x, count: %d"), this, numAttributes ) ); } @@ -111,6 +217,7 @@ // void CCookie::AddDefaultPathL( const TUriC8& aUri ) { + CLOG( ( ECookie, 0, _L( "-> CCookie::AddDefaultPathL") ) ); // RFC2965 : Defaults to the path of the request URL that generated the // Set-Cookie2 response, up to and including the right-most /. // Note : there is a contradiction as we must not include the right-most / @@ -139,6 +246,7 @@ THTTPHdrVal defPathVal( defPath ); SetAttribute( EPath, defPathVal, ETrue );// ignore the result defPath.Close(); + CLOG( ( ECookie, 0, _L( "<- CCookie::AddDefaultPathL") ) ); } // --------------------------------------------------------- @@ -148,6 +256,7 @@ EXPORT_C void CCookie::AddToRequestL( RHTTPHeaders aRequestHeaders, TInt aPartIndex ) const { + CLOG( ( ECookie, 0, _L( "-> CCookie::AddToRequestL") ) ); const TStringTable& commonStringTable = RHTTPSession::GetTable(); // We're writing out the "Cookie:" string @@ -169,15 +278,17 @@ } else { + CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - version is missing! - iSetCookie2: %d"), iSetCookie2 ) ); if ( iSetCookie2 ) { // if this is a new-style cookie (it is from a Set-Cookie2 header), // then it must have a Version attribute. // TBD : or should we insert a '$Version=1' string instead? + CLOG( ( ECookie, 0, _L( "<- CCookie::AddToRequestL - KErrCorrupt!") ) ); User::Leave( KErrCorrupt ); } } - + CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - adding name...") ) ); // We're writing out the NAME attribute - it is a serious error if this // attribute is missing User::LeaveIfError( Attribute( CCookie::EName, hVal ) ); @@ -187,6 +298,7 @@ hVal, aPartIndex ); + CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - adding value...") ) ); // We're writing out the VALUE attribute - it is a serious error if this // attribute is missing User::LeaveIfError( Attribute( CCookie::EValue, hVal ) ); @@ -201,6 +313,7 @@ // Writing out Domain attribute if ( Attribute( CCookie::EDomain, hVal ) == KErrNone && hVal.StrF().DesC().Length() > 0 ) { + CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - adding domain...") ) ); aRequestHeaders.SetParamL( cookieString, iStringPool.StringF( HTTP::EDomain, commonStringTable ), @@ -211,6 +324,7 @@ // Writing out Path attribute if ( Attribute( CCookie::EPath, hVal ) == KErrNone ) { + CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - adding path...") ) ); aRequestHeaders.SetParamL( cookieString, iStringPool.StringF( HTTP::EPath, commonStringTable ), @@ -221,12 +335,14 @@ // Writing out Port attribute if ( Attribute( CCookie::EPort, hVal ) == KErrNone ) { + CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - adding port...") ) ); aRequestHeaders.SetParamL( cookieString, iStringPool.StringF( HTTP::ECookiePort, commonStringTable ), hVal, aPartIndex ); } + CLOG( ( ECookie, 0, _L( "<- CCookie::AddToRequestL") ) ); } @@ -238,13 +354,15 @@ ( CCookie::TCookieAttributeName aAttributeName, THTTPHdrVal& aAttributeVal) const { + CLOG( ( ECookie, 0, _L( "-> CCookie::Attribute") ) ); TCookieAttribute attribute; if ( FindAttribute( aAttributeName, attribute ) != KErrNotFound ) { aAttributeVal = attribute.Value(); + CLOG( ( ECookie, 0, _L( "<- CCookie::Attribute") ) ); return KErrNone; } - + CLOG( ( ECookie, 0, _L( "<- CCookie::Attribute") ) ); return KErrNotFound; } @@ -270,14 +388,16 @@ THTTPHdrVal& aAttributeVal, TBool& aDefaulted ) const { + CLOG( ( ECookie, 0, _L( "-> CCookie::Attribute ") ) ); TCookieAttribute attribute; if ( FindAttribute( aAttributeName, attribute ) != KErrNotFound ) { aAttributeVal = attribute.Value(); aDefaulted = attribute.Defaulted(); + CLOG( ( ECookie, 0, _L( "<- CCookie::Attribute KErrNone") ) ); return KErrNone; } - + CLOG( ( ECookie, 0, _L( "<- CCookie::Attribute KErrNotFound") ) ); return KErrNotFound; } @@ -290,6 +410,7 @@ const THTTPHdrVal& aAttributeVal, TBool aDefaulted ) { + CLOG( ( ECookie, 0, _L( "-> CCookie::SetAttribute") ) ); TInt result( KErrNone ); TCookieAttribute attribute; @@ -315,6 +436,7 @@ newAttribute.Close(); } } + CLOG( ( ECookie, 0, _L( "<- CCookie::SetAttribute result: %d"),result ) ); return result; } @@ -322,73 +444,199 @@ // CCookie::CopyFromL // --------------------------------------------------------- // -void CCookie::CopyFromL( const CCookie& aCopyFrom ) +void CCookie::CopyFromL( const CCookie& aCopyFrom, const TDesC8& aDomain, const TDesC8& aPath, const TDesC8& aPort ) { - THTTPHdrVal attributevalue; - TBool aDefaulted( EFalse ); - - if ( aCopyFrom.Attribute( EName, attributevalue, aDefaulted ) != KErrNotFound ) + CLOG( ( ECookie, 0, _L( "-> CCookie::CopyFromL ") ) ); + TBool defaultDiscard( EFalse ); + THTTPHdrVal attributevalue; + TBool defaulted( EFalse ); + iSetCookie2 = aCopyFrom.iSetCookie2; + if ( aCopyFrom.Attribute( EName, attributevalue, defaulted ) != KErrNotFound ) { - SetAttribute( EName, attributevalue, aDefaulted ); + if ( attributevalue.Type() != THTTPHdrVal::KStrVal ) + { + RString correctedStringType = iStringPool.OpenStringL( attributevalue.StrF().DesC() ); + attributevalue.SetStr( correctedStringType ); + SetAttribute( EName, attributevalue, defaulted ); + correctedStringType.Close(); + const TPtrC8 pVal( attributevalue.Str().DesC() ); + CLOG( ( ECookie, 0, _L8( "CCookie::CopyFromL - attribute EName Value : %S" ), &pVal ) ); + } + else + { + SetAttribute( EName, attributevalue, defaulted ); + const TPtrC8 pVal( attributevalue.Str().DesC() ); + CLOG( ( ECookie, 0, _L8( "CCookie::CopyFromL - attribute EName Value : %S" ), &pVal ) ); + } } - if ( aCopyFrom.Attribute( EValue, attributevalue, aDefaulted ) != KErrNotFound ) + if ( aCopyFrom.Attribute( EValue, attributevalue, defaulted ) != KErrNotFound ) { - SetAttribute( EValue, attributevalue, aDefaulted ); - } - - if ( aCopyFrom.Attribute( EComment, attributevalue, aDefaulted ) != KErrNotFound ) - { - SetAttribute( EComment, attributevalue, aDefaulted ); + if ( attributevalue.Type() != THTTPHdrVal::KStrVal ) + { + RString correctedStringType = iStringPool.OpenStringL( attributevalue.StrF().DesC() ); + attributevalue.SetStr( correctedStringType ); + SetAttribute( EValue, attributevalue, defaulted ); + correctedStringType.Close(); + const TPtrC8 pVal( attributevalue.Str().DesC() ); + CLOG( ( ECookie, 0, _L8( "CCookie::CopyFromL - attribute EValue value: %S" ), &pVal ) ); + } + else + { + SetAttribute( EValue, attributevalue, defaulted ); + const TPtrC8 pVal( attributevalue.Str().DesC() ); + CLOG( ( ECookie, 0, _L8( "CCookie::CopyFromL - attribute EValue Value : %S" ), &pVal ) ); + } } - - if ( aCopyFrom.Attribute( ECommentURI, attributevalue, aDefaulted ) != KErrNotFound ) + if ( aCopyFrom.Attribute( EVersion, attributevalue, defaulted ) != KErrNotFound ) { - SetAttribute( ECommentURI, attributevalue, aDefaulted ); + SetAttribute( EVersion, attributevalue, defaulted ); + SetFromNetscape( EFalse ); } - - if ( aCopyFrom.Attribute( EDiscard, attributevalue, aDefaulted ) != KErrNotFound ) + else { - SetAttribute( EDiscard, attributevalue, aDefaulted ); + SetFromNetscape( ETrue ); } - if ( aCopyFrom.Attribute( EDomain, attributevalue, aDefaulted ) != KErrNotFound ) + if ( aCopyFrom.Attribute( EPath, attributevalue, defaulted ) != KErrNotFound ) { - SetAttribute( EDomain, attributevalue, aDefaulted ); - } - - if ( aCopyFrom.Attribute( EMaxAge, attributevalue, aDefaulted ) != KErrNotFound ) - { - SetAttribute( EMaxAge, attributevalue, aDefaulted ); + if ( attributevalue.Type() != THTTPHdrVal::KStrFVal ) + { + SetAttribute( EPath, attributevalue, defaulted ); + } } - - if ( aCopyFrom.Attribute( EPath, attributevalue, aDefaulted ) != KErrNotFound ) + else { - SetAttribute( EPath, attributevalue, aDefaulted ); - } - - if ( aCopyFrom.Attribute( EPort, attributevalue, aDefaulted ) != KErrNotFound ) - { - SetAttribute( EPort, attributevalue, aDefaulted ); + // defaulting + RStringF defPath = iStringPool.OpenFStringL( aPath ); + THTTPHdrVal defPathVal( defPath ); + SetAttribute( EPath, defPathVal, ETrue );// ignore the result + defPath.Close(); } - - if ( aCopyFrom.Attribute( ESecure, attributevalue, aDefaulted ) != KErrNotFound ) - { - SetAttribute( ESecure, attributevalue, aDefaulted ); - } + if ( aCopyFrom.Attribute( EDomain, attributevalue, defaulted ) != KErrNotFound ) + { + if ( attributevalue.Type() != THTTPHdrVal::KStrFVal ) + { + SetAttribute( EDomain, attributevalue, defaulted ); + } + } + else + { + // Default handling + // in this case the default is the effective request host + RStringF defDomain = iStringPool.OpenFStringL( aDomain ); + THTTPHdrVal defdomVal( defDomain ); + SetAttribute( EDomain, defdomVal, ETrue );// ignore the result + defDomain.Close(); + } + + + if ( aCopyFrom.Attribute( ESecure, attributevalue, defaulted ) != KErrNotFound ) + { + SetAttribute( ESecure, attributevalue, defaulted ); + } + if (iNetscape) + { + if ( aCopyFrom.Attribute( EExpires, attributevalue, defaulted ) != KErrNotFound ) + { + SetAttribute( EExpires, attributevalue, defaulted ); + } + else if ( aCopyFrom.Attribute( EComment, attributevalue, defaulted ) != KErrNotFound || + aCopyFrom.Attribute( EMaxAge, attributevalue, defaulted ) != KErrNotFound ) + { + iNetscape = EFalse; + } + } + if ( aCopyFrom.Attribute( EDate, attributevalue, defaulted ) != KErrNotFound ) + { + TDateTime attrTime = attributevalue.DateTime(); + THTTPHdrVal attributeVal( attrTime ); + SetAttribute( CCookie::EDate, attributeVal, defaulted ); + } + else + { + TTime nowTime; + nowTime.UniversalTime(); + TDateTime attrTime = nowTime.DateTime(); + THTTPHdrVal attributeVal( attrTime ); + SetAttribute( EDate, attributeVal, defaulted ); + } + if (iNetscape == EFalse) + { + if ( aCopyFrom.Attribute( EComment, attributevalue, defaulted ) != KErrNotFound ) + { + SetAttribute( EComment, attributevalue ); + } + else + { + + } + if ( aCopyFrom.Attribute( EMaxAge, attributevalue, defaulted ) != KErrNotFound) + { + SetAttribute( EMaxAge, attributevalue ); + } + else + { + if(iSetCookie2) + { + defaultDiscard = ETrue; + } + } + if(iSetCookie2) + { + if ( aCopyFrom.Attribute( ECommentURI, attributevalue, defaulted ) != KErrNotFound ) + { + SetAttribute( ECommentURI, attributevalue, defaulted ); + } + else + { + + } + if ( aCopyFrom.Attribute( EDiscard, attributevalue, defaulted ) != KErrNotFound ) + { + SetAttribute( EDiscard, attributevalue, defaulted ); + } + else + { + if (defaultDiscard) + { + RStringF emptyStr = iStringPool.OpenFStringL( KNullDesC8() ); + THTTPHdrVal emptyVal( emptyStr ); + SetAttribute( EDiscard, emptyVal, ETrue ); + emptyStr.Close(); + } + if (aCopyFrom.Attribute( EPort, attributevalue, defaulted ) != KErrNotFound) + { + SetAttribute( EPort, attributevalue, ETrue ); // ignore the result of this method + } + else + { + RStringF requestPort; + if(!aPort.Compare(KNullDesC8())) + { + requestPort = iStringPool.OpenFStringL( aPort ); + } + else + { + requestPort = iStringPool.OpenFStringL( KCookieDefaultRequestPort() ); + } + THTTPHdrVal portVal( requestPort ); + SetAttribute( EPort, portVal, ETrue ); + requestPort.Close(); + } + } + + } + + } + - if ( aCopyFrom.Attribute( EVersion, attributevalue, aDefaulted ) != KErrNotFound ) - { - SetAttribute( EVersion, attributevalue, aDefaulted ); - } - - if ( aCopyFrom.Attribute( EExpires, attributevalue, aDefaulted ) != KErrNotFound ) - { - SetAttribute( EExpires, attributevalue, aDefaulted ); - } - - SetCookie2( aCopyFrom.FromCookie2() ); - + //SetCookie2( aCopyFrom.FromCookie2() ); + // Other properties + + iSize = aCopyFrom.iSize; + iReceivedTime = aCopyFrom.iReceivedTime; + CLOG( ( ECookie, 0, _L( "<- CCookie::CopyFromL ") ) ); } @@ -411,6 +659,7 @@ // TBool CCookie::Expired() const { + CLOG( ( ECookie, 0, _L( "-> CCookie::Expired ") ) ); // the cookie has expired if: // 1. it's Age > Max-Age // 2. current_date > expires @@ -479,6 +728,7 @@ } } } + CLOG( ( ECookie, 0, _L( "<- CCookie::Expired retval : %d"),retval ) ); return retval; } // --------------------------------------------------------- @@ -487,7 +737,7 @@ // TPtrC8 CCookie::RemoveQuotes( const TDesC8& aDes ) { - + CLOG( ( ECookie, 0, _L( "-> CCookie::RemoveQuotes ") ) ); TInt firstChar = 0; // position of the first character TInt lastChar = aDes.Length() - 1; // position of the last character TPtrC8 result; @@ -518,7 +768,7 @@ result.Set( aDes.Mid( firstChar, lastChar - firstChar + 1 ) ); } } - + CLOG( ( ECookie, 0, _L( "<- CCookie::RemoveQuotes result : %d "),result ) ); return result; } @@ -530,6 +780,7 @@ // TBool CCookie::ExpiredNetscapeL( THTTPHdrVal aAttrVal) const { + CLOG( ( ECookie, 0, _L( "-> CCookie::ExpiredNetscapeL ") ) ); TBool retval( EFalse ); TPtrC8 datePtr8( aAttrVal.StrF().DesC() ); TInt dateLen( datePtr8.Length() ); @@ -736,6 +987,7 @@ retval = ETrue; } CleanupStack::PopAndDestroy( cleanupNum ); // temp1, temp2, desDate, desTime + CLOG( ( ECookie, 0, _L( "<- CCookie::ExpiredNetscapeL retval : %d "),retval ) ); return retval; } @@ -749,6 +1001,7 @@ const TInt aTokenCount, TInt* aTokens ) const { + CLOG( ( ECookie, 0, _L( "-> CCookie::FindTokens ") ) ); TLex8 lex = aString; TChar ch; TInt tokenCount( 0 ), ii; @@ -762,6 +1015,7 @@ aTokens[tokenCount++] = lex.Offset()-1; } } + CLOG( ( ECookie, 0, _L( "<- CCookie::FindTokens tokenCount : %d"),tokenCount ) ); return tokenCount; } @@ -771,6 +1025,7 @@ // TBool CCookie::Persistent() const { + CLOG( ( ECookie, 0, _L( "-> CCookie::Persistent ") ) ); TBool result( EFalse ); THTTPHdrVal attrVal; @@ -818,6 +1073,7 @@ } } } + CLOG( ( ECookie, 0, _L( "<- CCookie::Persistent result : %d"),result ) ); return result; } @@ -827,6 +1083,7 @@ // TBool CCookie::IsUnknownVersion() const { + CLOG( ( ECookie, 0, _L( "-> CCookie::IsUnknownVersion ") ) ); TBool unknownVersion( EFalse ); THTTPHdrVal attrVal; if( Attribute( CCookie::EVersion, attrVal ) != KErrNotFound ) @@ -836,6 +1093,7 @@ unknownVersion = ETrue; } } + CLOG( ( ECookie, 0, _L( "<- CCookie::IsUnknownVersion unknownVersion : %d"),unknownVersion ) ); return unknownVersion; } @@ -846,7 +1104,9 @@ CCookie::CCookie( RStringPool aStringPool ) : iStringPool( aStringPool ), iSetCookie2( EFalse ), iNetscape( EFalse ) { + CLOG( ( ECookie, 0, _L( "-> CCookie::CCookie ") ) ); iReceivedTime.UniversalTime(); + CLOG( ( ECookie, 0, _L( "<- CCookie::CCookie ") ) ); } @@ -857,6 +1117,7 @@ void CCookie::ConstructL( RHTTPHeaders aRequestHeaders, TInt aPartIndex, RStringF aFieldName, const TUriC8& aUri ) { + CLOG( ( ECookie, 0, _L( "-> CCookie::ConstructL ") ) ); const TStringTable& commonStringTable = RHTTPSession::GetTable(); // Determining if this object is constructed from a Set-Cookie2 HTTP header @@ -865,7 +1126,7 @@ iSetCookie2 = ( aFieldName == setCookie2Name ); - TBool DefaultDiscard( EFalse ); + TBool defaultDiscard( EFalse ); THTTPHdrVal hVal; @@ -1068,7 +1329,7 @@ // in case of SetCookie2, also set Discard, defaulted if ( iSetCookie2 ) { - DefaultDiscard = ETrue; + defaultDiscard = ETrue; } } @@ -1106,7 +1367,7 @@ { // Add default handling if applies // no defaulting for EDiscard // only if it is caused by MAx-Age beeing not supplied - if ( DefaultDiscard ) + if ( defaultDiscard ) { RStringF emptyStr = iStringPool.OpenFStringL( KNullDesC8() ); THTTPHdrVal emptyVal( emptyStr ); @@ -1160,6 +1421,7 @@ } } } + CLOG( ( ECookie, 0, _L( "<- CCookie::ConstructL ") ) ); } @@ -1171,16 +1433,18 @@ TInt CCookie::FindAttribute( TCookieAttributeName aAttributeName, TCookieAttribute& aAttribute ) const { + CLOG( ( ECookie, 0, _L( "-> CCookie::FindAttribute ") ) ); const TInt numAttributes = iAttributes.Count(); for ( TInt index = 0; index < numAttributes; ++index ) { if ( iAttributes[index].Name() == aAttributeName ) { aAttribute = iAttributes[index]; + CLOG( ( ECookie, 0, _L( "<- CCookie::FindAttribute index : %d"),index ) ); return index; } } - + CLOG( ( ECookie, 0, _L( "<- CCookie::FindAttribute KErrNotFound") ) ); return KErrNotFound; } @@ -1190,11 +1454,13 @@ // void CCookie::RemoveAttribute( TInt aIndex ) { + CLOG( ( ECookie, 0, _L( "-> CCookie::RemoveAttribute aIndex : %d"),aIndex ) ); iSize -= ( KCookieAttributePrefixLength + iAttributes[ aIndex ].Size() + KCookieAttributeDefaultedLength + KCookieAttributeFoundLength ); iAttributes[ aIndex ].Close(); iAttributes.Remove( aIndex ); + CLOG( ( ECookie, 0, _L( "<- CCookie::RemoveAttribute aIndex : %d"),aIndex ) ); } // --------------------------------------------------------- @@ -1203,12 +1469,14 @@ // void CCookie::RemoveAttribute( TCookieAttributeName aAttributeName ) { + CLOG( ( ECookie, 0, _L( "-> CCookie::RemoveAttribute - name: %d"), aAttributeName ) ); TCookieAttribute attribute; TInt index( FindAttribute( aAttributeName, attribute ) ); if( index != KErrNotFound ) { RemoveAttribute( index ); } + CLOG( ( ECookie, 0, _L( "<- CCookie::RemoveAttribute - name: %d, index: %d"), aAttributeName, index ) ); } // --------------------------------------------------------- @@ -1218,6 +1486,7 @@ TInt CCookie::GetLocalOffset( HBufC8* aDate, TInt& aHour, TInt& aMinute, TInt& aLength ) const { + CLOG( ( ECookie, 0, _L( "-> CCookie::GetLocalOffset ") ) ); TInt retval( 0 ); TInt pos(0); // TInt fwspos(0); @@ -1309,6 +1578,7 @@ lex1.Val( aMinute ); CleanupStack::PopAndDestroy( temp ); // temp } + CLOG( ( ECookie, 0, _L( "<- CCookie::GetLocalOffset retval : %d "),retval ) ); return retval; } @@ -1321,9 +1591,11 @@ // TInt CCookie::GetMilitaryOffset( HBufC8* /*aDate*/, TInt& aHour ) const { + CLOG( ( ECookie, 0, _L( "-> CCookie::GetMilitaryOffset ") ) ); // TODO: Add military timezone handling here... TInt retval( KErrNotFound ); aHour = 0; + CLOG( ( ECookie, 0, _L( "<- CCookie::GetMilitaryOffset retval : %d "),retval ) ); return retval; } @@ -1336,6 +1608,7 @@ TInt CCookie::GetTimeZone( HBufC8* aDate, TInt& aHour, TInt& aLength ) const { + CLOG( ( ECookie, 0, _L( "-> CCookie::GetTimeZone ") ) ); TInt retval( 0 ); TInt zonepos = aDate->Find( KUT() ); if ( zonepos != KErrNotFound ) @@ -1424,7 +1697,7 @@ // get the length aLength = aDate->Length() - zonepos; } - + CLOG( ( ECookie, 0, _L( "<- CCookie::GetTimeZone retval :%d "),retval ) ); return retval; } @@ -1436,6 +1709,7 @@ // HBufC8* CCookie::GetCleanedDateTimeLC( HBufC8* aDate ) const { + CLOG( ( ECookie, 0, _L( "-> CCookie::GetCleanedDateTimeLC ") ) ); // as http time might contain a "DayOfWeek," optional part // which is not understood by the parser, we need to // remove it @@ -1502,6 +1776,7 @@ *result = temp->Left( temp->Length() - length); // return ( temp->Left( temp->Length() - length).AllocLC() ); CleanupStack::PopAndDestroy( temp ); + CLOG( ( ECookie, 0, _L( "-> CCookie::GetCleanedDateTimeLC result : %d"),result ) ); return result; } @@ -1520,6 +1795,7 @@ : iName( aName ), iDefaulted( aDefaulted ) { + CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute") ) ); iValue = aHdrVal.Copy(); @@ -1528,28 +1804,34 @@ case THTTPHdrVal::KTIntVal : { iSize = sizeof( TInt ); + CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute iSize :%d "),iSize ) ); break; } case THTTPHdrVal::KStrVal : { iSize = iValue.Str().DesC().Length(); + CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute iSize :%d "),iSize ) ); break; } case THTTPHdrVal::KDateVal : { iSize = sizeof( TDateTime ); + CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute iSize :%d "),iSize ) ); break; } case THTTPHdrVal::KStrFVal : { iSize = iValue.StrF().DesC().Length(); + CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute iSize :%d "),iSize ) ); break; } default : // THTTPHdrVal::KNoType { iSize = 0; + CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute iSize :%d "),iSize ) ); } } + CLOG( ( ECookie, 0, _L( "<- CCookie::TCookieAttribute ") ) ); } @@ -1559,6 +1841,8 @@ // CCookie::TCookieAttribute::TCookieAttribute() { + CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute ") ) ); + CLOG( ( ECookie, 0, _L( "<- CCookie::TCookieAttribute ") ) ); } @@ -1568,18 +1852,22 @@ // void CCookie::TCookieAttribute::Close() { + CLOG( ( ECookie, 0, _L( "-> CCookie::Close ") ) ); THTTPHdrVal::THTTPValType type = iValue.Type(); if ( type == THTTPHdrVal::KStrVal ) { + CLOG( ( ECookie, 0, _L( "-> CCookie::Close KStrVal") ) ); iValue.Str().Close(); } else if ( type == THTTPHdrVal::KStrFVal ) { + CLOG( ( ECookie, 0, _L( "-> CCookie::Close KStrFVal") ) ); iValue.StrF().Close(); } // TBD : iValue = THTTPHdrVal();? iSize = 0; + CLOG( ( ECookie, 0, _L( "<- CCookie::Close ") ) ); } diff -r ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerSrc/CookieArray.cpp --- a/httpfilters/cookie/ManagerSrc/CookieArray.cpp Fri Jun 11 14:06:05 2010 +0300 +++ b/httpfilters/cookie/ManagerSrc/CookieArray.cpp Wed Jun 23 18:48:21 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 ) + { + CLOG( ( ECookieArray, 0, + _L( "-> CCookieArray::GetCookies for an URI" ) ) ); + TUriParser8 uriParser; + TInt err = uriParser.Parse( aRequestUri ); + if ( !err ) + { + // first get the details of the current requestUri, + // that is, Domain, Path and port + TPtrC8 requestPath( uriParser.IsPresent( EUriPath ) ? + uriParser.Extract( EUriPath ) : KNullDesC8() ); + TPtrC8 requestDomain( uriParser.IsPresent( EUriHost ) ? + uriParser.Extract( EUriHost ) : KNullDesC8() ); + TPtrC8 requestPort( uriParser.IsPresent( EUriPort ) ? + uriParser.Extract( EUriPort ) : KCookieDefaultRequestPort() ); + TPtrC8 requestScheme( uriParser.IsPresent( EUriScheme ) ? + uriParser.Extract( EUriScheme ) : KNullDesC8() ); + + // now check the existing cookies + // remove expired ones first, if there are any + RemoveExpired(); + // and finally, find the cookies... + TInt count = iCookies.Count(); + for ( TInt i = 0; i < count && err == KErrNone; i++ ) + { + // Does the cookie have Path attribute? + TPtrC8 cookiePath; + if ( !GetFoldedCookieAttr( *iCookies[i], + CCookie::EPath, + cookiePath ) ) + { + continue; + } + + // Does the cookie have Domain attribute? + TPtrC8 cookieDomain; + if ( !GetFoldedCookieAttr( *iCookies[i], + CCookie::EDomain, + cookieDomain ) ) + { + continue; + } + + TPtrC8 cookiePort; + GetFoldedCookiePortAttr( *iCookies[i], cookiePort ); + + if ( PathMatch( requestPath, cookiePath ) && + DomainMatch( requestDomain, cookieDomain, ETrue ) && + PortMatch( requestPort, cookiePort ) && + SecureMatch( requestScheme, *iCookies[i] ) ) + { + CCookie* clone = CCookie::CloneL( *iCookies[i],requestDomain,requestPath,requestPort ); + CleanupStack::PushL( clone ); + err = aCookies.Append(clone); + CleanupStack::Pop(clone); + aFound = ETrue; + } + } + aCookies.Sort( TLinearOrder (CCookieArray::CompareCookiesPath) ); + } + + + + CLOG( ( ECookieArray, 0, + _L( "<- CCookieArray::GetCookies for an URI" ) ) ); + return err; + } diff -r ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerSrc/CookieClientData.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerSrc/CookieClientData.cpp Wed Jun 23 18:48:21 2010 +0300 @@ -0,0 +1,213 @@ +/* + * CookieClientData.cpp + * + * Created on: Dec 28, 2009 + * Author: mohanti + */ +//User Includes +#include "CookieClientData.h" +#include "cookie.h" +#include "CookieArray.h" +#include "CookieLogger.h" +#include "CookieCommonConstants.h" +#include + +// --------------------------------------------------------- +// CCookieGroupData::NewL +// --------------------------------------------------------- +// +CCookieClientData* CCookieClientData::NewL(TUint32 aGroupId) + { + CCookieClientData* self = CCookieClientData::NewLC(aGroupId); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// CCookieClientData::NewLC +// --------------------------------------------------------- +// +CCookieClientData* CCookieClientData::NewLC(TUint32 aGroupId) + { + CCookieClientData* self = new (ELeave) CCookieClientData(aGroupId); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } +// --------------------------------------------------------- +// CCookieGroupData::NewL +// --------------------------------------------------------- +// +CCookieClientData* CCookieClientData::NewL(TUint32 aGroupId,TUint32 aWidgetUid,TBool aCookieSharableFlag, TBool aInitFlag) + { + CCookieClientData* self = CCookieClientData::NewLC(aGroupId, aWidgetUid, aCookieSharableFlag, aInitFlag); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// CCookieClientData::NewLC +// --------------------------------------------------------- +// +CCookieClientData* CCookieClientData::NewLC(TUint32 aGroupId,TUint32 aWidgetUid,TBool aCookieSharableFlag, TBool aInitFlag) + { + CCookieClientData* self = new (ELeave) CCookieClientData(aGroupId, aWidgetUid, aCookieSharableFlag, aInitFlag); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// --------------------------------------------------------- +// CCookieClientData::CCookieClientData +// --------------------------------------------------------- +// +CCookieClientData::CCookieClientData(TUint32 aGroupId,TUint32 aWidgetUid ,TBool aCookieSharableFlag , TBool aInitFlag) +:iInitFlag(aInitFlag),iCookieSharableFlag(aCookieSharableFlag),iGroupId(aGroupId),iWidgetUid(aWidgetUid) + { + + } +// --------------------------------------------------------- +// CCookieClientData::CCookieClientData +// --------------------------------------------------------- +// +CCookieClientData::CCookieClientData(TUint32 aGroupId):iInitFlag(EFalse),iCookieSharableFlag(EFalse),iGroupId(aGroupId),iWidgetUid(0) + { + + } +// --------------------------------------------------------- +// CCookieGroupData::ConstructL +// --------------------------------------------------------- +// +void CCookieClientData::ConstructL() + { + iCookieArray = new (ELeave) CCookieArray; + } + +// --------------------------------------------------------- +// CCookieClientData::~CCookieClientData +// --------------------------------------------------------- +// +CCookieClientData::~CCookieClientData() + { + CLOG(( EClient, 0, _L("-> CCookieClientData::~CCookieClientData iCookieArray: 0x%08x"), iCookieArray )); + delete iCookieArray; + iCookieArray = NULL; + CLOG(( EClient, 0, _L("<- CCookieClientData::~CCookieClientData") )); + } + +// --------------------------------------------------------- +// CCookieClientData::StorePersistentCookieL +// --------------------------------------------------------- +// +void CCookieClientData::StorePersistentCookieL( const CCookie* aCookie, + const TDesC8& aRequestUri, + const TInt aIndex ) + { + CLOG(( EClient, 0, _L("-> RCookieManager::StorePersistentCookieL") )); + if (aIndex == -1) + { + iCookieArray->AddL( aCookie, aRequestUri); + } + else + { + iCookieArray->InsertL( aCookie, aIndex); + } + CLOG(( EClient, 0, _L("<- RCookieManager::StorePersistentCookieL") )); + } + +// --------------------------------------------------------- +// RCookieManager::StoreCookieAtClientSideL +// --------------------------------------------------------- +// +void CCookieClientData::StoreCookieAtClientSideL(const CCookie* aCookie,const TDesC8& aUri ) + { + CLOG(( EClient, 0, _L("-> RCookieManager::StoreCookieAtClientSideL: aUri:%S"), &aUri )); + //Creates a clone of the passed cookie objects as the ownership of this object is held by Clint of Cookie Manager Dll + TUriParser8 uriParser; + + TInt err = uriParser.Parse( aUri ); + CCookie* clone(NULL); + if (err !=KErrNone) + return; + else + { + // first get the details of the current requestUri, + // that is, Domain, Path and port + TPtrC8 requestPath( uriParser.IsPresent( EUriPath ) ? + uriParser.Extract( EUriPath ) : KNullDesC8() ); + TPtrC8 requestDomain( uriParser.IsPresent( EUriHost ) ? + uriParser.Extract( EUriHost ) : KNullDesC8() ); + TPtrC8 requestPort( uriParser.IsPresent( EUriPort ) ? + uriParser.Extract( EUriPort ) : KCookieDefaultRequestPort() ); + + clone = CCookie::CloneL( *aCookie,requestDomain,requestPath,requestPort); + CleanupStack::PushL( clone ); + } + + //CCookie* clone = CCookie::CloneL( *aCookie,requestDomain,requestPath); + //CleanupStack::PushL( clone ); + + TInt index(0); + CCookieArray* perscookiearray = CookieArray(); + if ( perscookiearray->DoesAlreadyExists( clone, index ) ) + { // must overwrite !!! + // but first add the new one if needed + // just not to give a chance of beeing lost... + // persistence of the cookie will be handled on + // saving all cookies to disk + perscookiearray->MakeRoomForInsertIfNeededL(clone, aUri, index); + if(index >=0) + { + // insert cookie at valid index + //iCookieClientData->StorePersistentCookieL(aCookie,aUri,index); + StorePersistentCookieL(clone,aUri,index); + //iCookieClientData->StorePersistentCookieL( aCookie, aUri, index ); + // remove the old cookie + perscookiearray->Remove( index + 1 ); + } + else + { // invalid index means old cookie has been deleted in the process of making room + // append the new cookie to the end of array + //iCookieClientData->StorePersistentCookieL( aCookie, aUri ); + StorePersistentCookieL( clone, aUri ); + } + } + else + { // it is not in the array yet, add it now + //iCookieClientData->StorePersistentCookieL( aCookie, aUri ); + StorePersistentCookieL( clone, aUri ); + } + // Cookie supervisor API takes immediate ownership of both cookie and array + CleanupStack::Pop(clone); + CLOG(( EClient, 0, _L("<- RCookieManager::StoreCookieAtClientSideL") )); + } + +// --------------------------------------------------------- +// CCookieGroupData::Count +// --------------------------------------------------------- +// +TInt CCookieClientData::Count()const + { + return iCookieArray->Count(); + } + +// --------------------------------------------------------- + +// --------------------------------------------------------- +// CCookieGroupData::GetClientSideCookies +// --------------------------------------------------------- +// +TInt CCookieClientData::GetClientSideCookies(const TDesC8& aRequestUri,RPointerArray& aCookies,TBool& aCookieFound )const + { + return iCookieArray->GetCookies(aRequestUri,aCookies,aCookieFound); + } + +// --------------------------------------------------------- +// CCookieGroupData::CookieArray +// --------------------------------------------------------- +// +CCookieArray* CCookieClientData::CookieArray() + { + return iCookieArray; + } +//EOF diff -r ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerSrc/CookieClientDataArray.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerSrc/CookieClientDataArray.cpp Wed Jun 23 18:48:21 2010 +0300 @@ -0,0 +1,236 @@ +/* + * 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::New +// --------------------------------------------------------- +// + +CCookieClientDataArray* CCookieClientDataArray::New() + { + CCookieClientDataArray* arrayInstance = new CCookieClientDataArray(); + if (arrayInstance) + { + arrayInstance->Init(); + } + return arrayInstance ; + } + +CCookieClientDataArray::CCookieClientDataArray() + { + } + +void CCookieClientDataArray::Init() + { + iCookieClientData = new RPointerArray(KCookieArrayGranularity); + } + +// --------------------------------------------------------- +// CCookieClientDataArray::~CCookieClientDataArray +// --------------------------------------------------------- +// +CCookieClientDataArray::~CCookieClientDataArray() + { + CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::~CCookieClientDataArray" ) ) ); + if(iCookieClientData && iCookieClientData->Count()) + { + iCookieClientData->ResetAndDestroy(); + iCookieClientData->Close(); + //delete iCookieClientData; + iCookieClientData = NULL; + } + CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::~CCookieClientDataArray" ) ) ); + } + +// --------------------------------------------------------- +// CCookieClientDataArray::Count +// --------------------------------------------------------- +// +TInt CCookieClientDataArray::Count()const + { + if (iCookieClientData) + return iCookieClientData->Count(); + else + return 0; + } + +// --------------------------------------------------------- +// CCookieClientDataArray::Compress +// --------------------------------------------------------- +// +void CCookieClientDataArray::AddClientGroupDataL(CCookieClientData* aCookieClientData) + { + CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::AddGroupDataL" ) ) ); + iCookieClientData->AppendL(aCookieClientData); + CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::AddGroupDataL" ) ) ); + } + +// --------------------------------------------------------- +// CCookieClientDataArray::Compress +// --------------------------------------------------------- +// +void CCookieClientDataArray::Compress() + { + CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::Compress" ) ) ); + iCookieClientData->Compress(); + CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::Compress" ) ) ); + } + +// --------------------------------------------------------- +// CCookieClientDataArray::operator[] +// --------------------------------------------------------- +// +CCookieClientData* CCookieClientDataArray::operator[](TInt aIndex) const + { + return (*iCookieClientData)[aIndex]; + } + +// --------------------------------------------------------- +// CCookieClientDataArray::At +// --------------------------------------------------------- +// +CCookieClientData* CCookieClientDataArray::At(TInt aIndex) const + { + return (*iCookieClientData)[ aIndex ]; + } +// --------------------------------------------------------- +// CCookieClientDataArray::Find +// --------------------------------------------------------- +// +CCookieClientData* CCookieClientDataArray::Find(const TUint32& aGroupId, const TUint32& aWidgetUid ) + { + CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::Find GroupId = %x, WidgetUid = %x" ),aGroupId,aWidgetUid ) ); + TInt total = Count(); + TBool WidgetUidFound = EFalse; + TInt index = 0; + for ( TInt i = 0;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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerSrc/CookieGroupData.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerSrc/CookieGroupData.cpp Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerSrc/CookieGroupDataArray.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerSrc/CookieGroupDataArray.cpp Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerSrc/CookieManagerClient.cpp --- a/httpfilters/cookie/ManagerSrc/CookieManagerClient.cpp Fri Jun 11 14:06:05 2010 +0300 +++ b/httpfilters/cookie/ManagerSrc/CookieManagerClient.cpp Wed Jun 23 18:48:21 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 @@ -48,7 +49,7 @@ // --------------------------------------------------------- // EXPORT_C RCookieManager::RCookieManager( RStringPool aStringPool ) -: iStringPool( aStringPool ), iCookiePacker( iStringPool ) +: iStringPool( aStringPool ),iCookieMgrData(NULL) { CLOG(( EClient, 0, _L(" ") )); CLOG(( EClient, 0, _L("*****************") )); @@ -80,7 +81,10 @@ EXPORT_C TInt RCookieManager::Connect() { CLOG( ( EClientConnect, 0, _L( "-> RCookieManager::Connect" ) ) ); - + iCookieMgrData = new TCookieMgrInternalStruct(iStringPool); + if (!(iCookieMgrData && iCookieMgrData->Init() == KErrNone)) + return KErrNoMemory; + TInt error = KErrNone; RProcess server; error = server.Create( KCookieServerExe, TPtr( NULL, 0 ), @@ -116,7 +120,7 @@ } // --------------------------------------------------------- -// RCookieManager::GetCookies +// RCookieManager::DoGetCookies // --------------------------------------------------------- // TInt RCookieManager::DoGetCookies( TDes8& aBuffer ) const @@ -125,25 +129,53 @@ } // --------------------------------------------------------- -// RCookieManager::GetCookieSize +// RCookieManager::GetCookieSharableFlagFromServer +// --------------------------------------------------------- +// +TInt RCookieManager::GetCookieSharableFlagFromServer(TBool& aCookieSharableFlag )const + { + TPckg 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 +187,31 @@ TBool& aCookie2Reqd ) { CLOG( ( EClient, 0, _L( "-> RCookieManager::GetCookiesL" ) ) ); + TBool cookiefound(EFalse); + CCookieClientDataArray* cookieclientdataarray = iCookieMgrData->GetCookieClientDataArray(); + + if(cookieclientdataarray) + { + TInt clientarraycount = cookieclientdataarray->Count(); + if ( clientarraycount!=0 ) + { + TInt clerr = GetClientSideCookies(aUri,aCookies,cookiefound,0); + } + } + if(!cookiefound) + { aCookie2Reqd = EFalse; TInt size = 0; TPckg pkgSize( size ); - User::LeaveIfError( DoGetCookieSize( aUri, pkgSize ) ); - + //Appuid value only takes 8 chars + HBufC* appbuf = HBufC::New(8); + TPtr ptr(appbuf->Des()); + TUint32 appUid(0); + ptr.AppendNum(appUid,EHex); + User::LeaveIfError( DoGetCookieSize( aUri, pkgSize,ptr ) ); + delete appbuf; if ( size ) { HBufC8* buf = HBufC8::NewLC( size ); @@ -171,8 +221,7 @@ // it seems this is the only place where we cannot avoid leaving // ==> we allocate memory for cookies when we fill up the cookie array. - iCookiePacker.UnpackCookiesFromBufferL( *buf, aCookies ); - + iCookieMgrData->GetCookiePacker().UnpackCookiesFromBufferL( *buf, aCookies ); TInt count = aCookies.Count(); TInt i = 0; TBool anyCookie2( EFalse ); @@ -196,7 +245,7 @@ CleanupStack::PopAndDestroy(); // buf } - + } CLOG( ( EClient, 0, _L( "<- RCookieManager::GetCookiesL" ) ) ); } @@ -208,7 +257,7 @@ const TUriC8& aUri ) { CLOG( ( EClient, 0, _L( "-> RCookieManager::StoreCookie" ) ) ); - + StoreCookieAtClientSide(&aCookie,aUri.UriDes()); TInt err; TInt cookieSize = aCookie.Size( EFalse ); @@ -220,10 +269,17 @@ cookieSize ) ); TPtr8 bufDes( buf->Des() ); - err = iCookiePacker.CliPackCookie( bufDes, aCookie ); + err = iCookieMgrData->GetCookiePacker().CliPackCookie( bufDes, aCookie ); if ( !err ) { - err = DoStoreCookie( *buf, aUri.UriDes() ); + //Appuid value only takes 8 chars + HBufC* appbuf = HBufC::New(8); + TPtr ptr(appbuf->Des()); + TUint32 appUid(0); + ptr.AppendNum(appUid,EHex); + err = DoStoreCookie( *buf, aUri.UriDes(),ptr ); + delete appbuf; + //err = DoStoreCookie( *buf, aUri.UriDes() ); } delete buf; @@ -253,18 +309,307 @@ } // --------------------------------------------------------- -// RCookieManager::SetAppUidL +// RCookieManager::SetAppUidL This method is no longer being +// used in CookieFilter.As this method is exported so in order +// to provide backward compatibilty this API implementation is changed // --------------------------------------------------------- // EXPORT_C TInt RCookieManager::SetAppUidL( const TUint32& aAppUid ) { CLOG(( EClient, 0, _L("->RCookieManager::SetAppUid") )); - HBufC* buf = HBufC::NewLC(128); + TUint32 groupid = RProcess().SecureId().iId; + CCookieClientData* cookieclientdata = iCookieMgrData->GetCookieClientDataArray()->Find(groupid, const_cast (aAppUid)); + if(cookieclientdata) + { + cookieclientdata->SetWidgetUid(aAppUid); + } + else + { + TBool cookieSharableFlag(EFalse); + TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag); + cookieclientdata = CCookieClientData::NewL(groupid, aAppUid, cookieSharableFlag,ETrue); + cookieclientdata->SetInitFlag(ETrue); + iCookieMgrData->GetCookieClientDataArray()->AddClientGroupDataL(cookieclientdata); + } + //Appuid value only takes 8 chars + HBufC* buf = HBufC::NewLC(8); TPtr ptr(buf->Des()); - ptr.AppendNum(aAppUid,EHex); + ptr.AppendNum(aAppUid,EHex); TInt error = SendReceive(ESetAppUid,TIpcArgs(ptr.Length(),&ptr)); CleanupStack::PopAndDestroy(); CLOG(( EClient, 0, _L("<-RCookieManager::SetAppUid") )); return error; } +// --------------------------------------------------------- +// RCookieManager::Close +// --------------------------------------------------------- +// + +EXPORT_C void RCookieManager::Close() + { + CLOG(( EClient, 0, _L("-> RCookieManager::Close") )); + TInt deletestatus =0; + DestroyCookiesFromMemory(deletestatus); + delete iCookieMgrData; + iCookieMgrData = NULL; + CLOG(( EClient, 0, _L("-> RCookieManager::Close deletestatus = %d"), deletestatus )); + RSessionBase::Close(); + CLOG(( EClient, 0, _L("<- RCookieManager::Close") )); + } +// --------------------------------------------------------- +// RCookieManager::StoreCookie Newly Added +// --------------------------------------------------------- +// +EXPORT_C TInt RCookieManager::StoreCookie( const CCookie& aCookie, + const TUriC8& aUri,TUint32& aAppUid ) + { + CLOG( ( EClient, 0, _L( "-> RCookieManager::StoreCookie" ) ) ); + StoreCookieAtClientSide(&aCookie,aUri.UriDes(),aAppUid); + TInt err; + + TInt cookieSize = aCookie.Size( EFalse ); + HBufC8* buf = HBufC8::New( cookieSize ); + if ( buf ) + { + CLOG( ( EClient, 0, + _L( "RCookieManager::StoreCookie, cookie size:%d" ), + cookieSize ) ); + + TPtr8 bufDes( buf->Des() ); + err = iCookieMgrData->GetCookiePacker().CliPackCookie( bufDes, aCookie ); + + if ( !err ) + { + //Appuid value only takes 8 chars + HBufC* appbuf = HBufC::New(8); + TPtr ptr(appbuf->Des()); + ptr.AppendNum(aAppUid,EHex); + err = DoStoreCookie( *buf, aUri.UriDes(),ptr ); + delete appbuf; + } + + delete buf; + } + else + { + err = KErrNoMemory; + } + + CLOG( ( EClient, 0, + _L( "<- RCookieManager::StoreCookie errcode%d" ), err ) ); + + return err; + } + +// --------------------------------------------------------- +// RCookieManager::GetCookiesL Newly Added +// --------------------------------------------------------- +// +EXPORT_C void RCookieManager::GetCookiesL( const TDesC8& aUri, + RPointerArray& aCookies, + TBool& aCookie2Reqd,TUint32& aAppUid ) + { + CLOG( ( EClient, 0, _L( "-> RCookieManager::GetCookiesL" ) ) ); + TBool cookiefound(EFalse); + CCookieClientDataArray* cookieclientdataarray = iCookieMgrData->GetCookieClientDataArray(); + if(cookieclientdataarray) + { + TInt clientarraycount = cookieclientdataarray->Count(); + if (clientarraycount == 0) + { + TUint32 groupid = RProcess().SecureId().iId; + TBool cookieSharableFlag(EFalse); + TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag); + CCookieClientData* cookieclientdata = CCookieClientData::NewL(groupid, aAppUid, cookieSharableFlag,ETrue); + cookieclientdata->SetInitFlag(ETrue); + cookieclientdataarray->AddClientGroupDataL(cookieclientdata); + } + else + { + + CLOG( ( EClient, 0, _L( "-> RCookieManager::GetClientSideCookies:" ) ) ); + //Gets the Cookie objects for aUri in case it is present + TInt clerr = GetClientSideCookies(aUri,aCookies,cookiefound,aAppUid); + CLOG( ( EClient, 0, _L( "RCookieManager::GetClientSideCookies:cookiefound = %d" ), cookiefound ) ); + + } + } + if(!cookiefound) + { + aCookie2Reqd = EFalse; + //Appuid value only takes 8 chars + HBufC* appuidbuf = HBufC::NewL(8); + TPtr ptr(appuidbuf->Des()); + ptr.AppendNum(aAppUid,EHex); + TInt size = 0; + TPckg pkgSize( size ); + User::LeaveIfError( DoGetCookieSize( aUri, pkgSize, ptr ) ); + delete appuidbuf; + if ( size ) + { + HBufC8* buf = HBufC8::NewLC( size ); + + TPtr8 des( buf->Des() ); + User::LeaveIfError( DoGetCookies( des ) ); + + // it seems this is the only place where we cannot avoid leaving + // ==> we allocate memory for cookies when we fill up the cookie array. + iCookieMgrData->GetCookiePacker().UnpackCookiesFromBufferL( *buf, aCookies ); + TInt count = aCookies.Count(); + for(TInt j=0; j RCookieManager::StoreClientSideCookies: aUri=%S" ), &aUri ) ); + //cookieclientdata->StoreCookieAtClientSide( aCookies[j],aUri ); + StoreCookieAtClientSide( aCookies[j],aUri,aAppUid ); + } + TInt i = 0; + TBool anyCookie2( EFalse ); + TBool anyUnknownVersion( EFalse ); + for ( ; i < count; i++ ) + { + if ( aCookies[i]->FromCookie2() ) + { + anyCookie2 = ETrue; + anyUnknownVersion |= aCookies[i]->IsUnknownVersion(); + } + } + + // if there were no new-style cookies or a new version info is detected + // then we have to send an extra cookie header indicating that we're + // able to process new-style cookies + if ( !anyCookie2 || anyUnknownVersion ) + { + aCookie2Reqd = ETrue; + } + + CleanupStack::PopAndDestroy(); // buf + } + } + CLOG( ( EClient, 0, _L( "<- RCookieManager::GetCookiesL" ) ) ); + } + +// --------------------------------------------------------- +// RCookieManager::Close for Widget related destruction during +//uninstallation process of a widget +// --------------------------------------------------------- +// +EXPORT_C TInt RCookieManager::ClearAllAppUidCookies(const TUint32& aAppUid) + { + CLOG(( EClient, 0, _L("-> RCookieManager::ClearCookies") )); + //Client side cookie deletion specific to a appuid + iCookieMgrData->GetCookieClientDataArray()->DestroyClientData(aAppUid); + //Server side Cookie deletion specific to a appuid + //Appuid value only takes 8 chars + HBufC* buf = HBufC::NewLC(8); + TPtr ptr(buf->Des()); + ptr.AppendNum(aAppUid,EHex); + TInt error = SendReceive(EClearAppUidCookies,TIpcArgs(ptr.Length(),&ptr)); + CleanupStack::PopAndDestroy(); + return error; + } + +// --------------------------------------------------------- +// RCookieManager::StoreCookieAtClientSide +// --------------------------------------------------------- +// +void RCookieManager::StoreCookieAtClientSide( const CCookie* aCookie, const TDesC8& aUri,TUint32 aWidgetUid ) + { + CLOG( ( EClient, 0, _L( "-> RCookieManager::StoreCookieAtClientSide" ) ) ); + TUint32 groupid = RProcess().SecureId().iId; + CCookieClientDataArray* cookieclientdataarray = iCookieMgrData->GetCookieClientDataArray(); + CCookieClientData* cookieclientdata(NULL); + TInt count = cookieclientdataarray->Count(); + if (count == 0) + { + TBool cookieSharableFlag(EFalse); + TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag); + cookieclientdata = CCookieClientData::NewL(groupid, aWidgetUid, cookieSharableFlag,ETrue); + cookieclientdata->SetInitFlag(ETrue); + cookieclientdataarray->AddClientGroupDataL(cookieclientdata); + cookieclientdata->StoreCookieAtClientSideL(aCookie,aUri); + return; + } + TInt itemIndex =0; + for(TInt i=0; 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; + } + } + 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; + CCookieClientData* cookieclientdata = NULL; + CCookieClientDataArray* cookieclientdataarray = iCookieMgrData->GetCookieClientDataArray(); + TInt count = cookieclientdataarray->Count(); + if (count == 0) + { + TBool cookieSharableFlag(EFalse); + TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag); + cookieclientdata = CCookieClientData::NewL(groupid, aWidgetUid, cookieSharableFlag,ETrue); + cookieclientdata->SetInitFlag(ETrue); + cookieclientdataarray->AddClientGroupDataL(cookieclientdata); + } else + { + cookieclientdata = cookieclientdataarray->Find(groupid, aWidgetUid); + } + if(cookieclientdata) + { + if(!cookieclientdata->GetInitFlag()) + { + TBool cookieSharableFlag(EFalse); + TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag); + cookieclientdata->SetCookieCookieSharableFlag(cookieSharableFlag); + } + return cookieclientdata->GetClientSideCookies( aRequestUri,aCookies, aCookieFound ); + } else + { + TBool cookieSharableFlag(EFalse); + TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag); + if(err == KErrNone) + { + CCookieClientData* cookieclientdata + = CCookieClientData::NewL(groupid, aWidgetUid, cookieSharableFlag,ETrue); + cookieclientdataarray->AddClientGroupDataL(cookieclientdata); + } + } + CLOG( ( EClient, 0, _L( "<- RCookieManager::GetClientSideCookies" ) ) ); + return KErrNone; + } + +RCookieManager::TCookieMgrInternalStruct::~TCookieMgrInternalStruct() + { + delete iCookieClientDataArray; + } + +TInt RCookieManager::TCookieMgrInternalStruct::Init() + { + iCookieClientDataArray = CCookieClientDataArray::New(); + if (iCookieClientDataArray) + return KErrNone; + return KErrNoMemory; + + } + // End of file diff -r ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerSrc/CookieManagerServer.cpp --- a/httpfilters/cookie/ManagerSrc/CookieManagerServer.cpp Fri Jun 11 14:06:05 2010 +0300 +++ b/httpfilters/cookie/ManagerSrc/CookieManagerServer.cpp Wed Jun 23 18:48:21 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,18 @@ // CCookieManagerServer::~CCookieManagerServer() { + CLOG( ( EServer, 0, _L( "-> CCookieManagerServer::~CCookieManagerServer" ) ) ); iServerClosing = ETrue; - - delete iPersistentCookies; - - delete iCookieFileName; - - iFs.Close(); - iStringPool.Close(); - - delete iCookiePacker; + if(iCookieGroupDataArray) + { + delete iCookieGroupDataArray; + iCookieGroupDataArray = NULL; + } + delete iGroupIdArray; delete iCloseTimer; - - CLOG( ( EServer, 0, _L( "CCookieManagerServer::~CCookieManagerServer") ) ); + iStringPool.Close(); + CLOG( ( EServer, 0, _L( "<-CCookieManagerServer::~CCookieManagerServer") ) ); CLOG( ( EServer, 0, _L( "*****************" ) ) ); } @@ -277,199 +306,16 @@ // e.g. 1 minute before doing so as starting a server is expensive // in many ways. CLOG( ( EServer, 0, _L( "Closing Server" ) ) ); - iPersistentCookies->RemoveNonPersistent(); - iCloseTimer->After( KCookieCloseTime ); + iCloseTimer->After( KCookieCloseTime ); //just write cookies back to the file when browser is closed, //no need wait till cookie server is shutdown. - WriteCookiesToFile(); + //WriteCookiesToFile(); } CLOG( ( EServer, 0, _L( "<- CCookieManagerServer::CloseSession" ) ) ); } -// --------------------------------------------------------- -// CCookieManagerServer::ReadCookiesFromFile -// --------------------------------------------------------- -// -TInt CCookieManagerServer::ReadCookiesFromFile() - { - CLOG( ( EServer, 0, - _L( "-> CCookieManagerServer::ReadCookiesFromFile" ) ) ); - - TInt err; - if ( iCookieFileName->Length() != 0 ) - { - RFile file; - err = file.Open( iFs, *iCookieFileName, - EFileShareExclusive | EFileStream | EFileRead ); - if ( err == KErrNone ) // the file does exist and could be opened - { - TInt size; - err = file.Size( size ); - if ( err == KErrNone ) // size query was successful - { - HBufC8* fileBuffer = HBufC8::New( size ); - if ( fileBuffer )// there was enough memory for fileBuffer - { - TPtr8 fileBufferDes( fileBuffer->Des() ); - err = file.Read( fileBufferDes ); - if ( err == KErrNone ) - { - // unfortunately this method might leave, because - // it allocates memory for cookies dynamically - TRAP( err, - iCookiePacker->UnpackCookiesFromBufferL - ( *fileBuffer, iPersistentCookies->CookieArray() ) ); - if ( err != KErrNone ) - { - delete fileBuffer; - file.Close(); - iFs.Delete(*iCookieFileName); //Delete file. - return KErrNotFound; - } - } - - delete fileBuffer; - } - else - { - err = KErrNoMemory; - } - } - - file.Close(); - } - } - else // if iCookieFileName->Length() == 0 - { - err = KErrNotFound; - } - - CLOG( ( EServer, 0, - _L( "<- CCookieManagerServer::ReadCookiesFromFile, errcode%d"), - err ) ); - - return err; - } - -// --------------------------------------------------------- -// CCookieManagerServer::WriteCookiesToFile -// --------------------------------------------------------- -// -TInt CCookieManagerServer::WriteCookiesToFile() - { - CLOG( ( EServer, 0, - _L( "-> CCookieManagerServer::WriteCookiesToFile" ) ) ); - - TInt err(KErrNone); - if ( !iPersistentCookies->Count() ) - { - CLOG( ( EServer, 0, - _L( "<- CCookieManagerServer::WriteCookiesToFile, errcode%d" ), - KErrNone )); - - // delete cookie file - err = iFs.Delete( *iCookieFileName ); - return err; - } - - if ( iCookieFileName->Length() != 0 ) - { - if ( CheckDiskSpace( iFs, *iCookieFileName ) ) - { - iFs.CreatePrivatePath( EDriveC ); - RFile file; - iFs.MkDirAll(*iCookieFileName); - err = file.Replace( iFs, *iCookieFileName, - EFileShareExclusive | EFileStream | EFileWrite ); - if ( err == KErrNone ) - { - // get the maximum length of cookies - TInt cookieCount( iPersistentCookies->Count() ); - TInt size( 0 ); - TInt maxSize( 0 ); - for( TInt i = 0; i < cookieCount; i++ ) - { - if ( (*iPersistentCookies)[i]->Persistent() && - !(*iPersistentCookies)[i]->Expired() ) - { - size = (*iPersistentCookies)[i]->Size( EFalse ); - if( size > maxSize ) - { - maxSize = size; - } - } - } - maxSize++; - CLOG( ( EServer, 0, _L("maxSize: %d"), maxSize ) ); - // allocate buffer for it - HBufC8* fileBuffer = HBufC8::New( maxSize ); - if ( fileBuffer ) - { - TPtr8 fileBufferDes = fileBuffer->Des(); - - // we ignore a possible packing or file writing error - // in this loop as these kinds of errors are not fatal - // and may not reappear during the next iteration - for ( TInt i = 0; i < cookieCount; i++ ) - { - if ( (*iPersistentCookies)[i]->Persistent() && - !(*iPersistentCookies)[i]->Expired() ) - { - fileBufferDes.SetLength(0); - - // use CliPackCookie as SrvPackCookie will - // suppress the defaulted domain attribute... - err = iCookiePacker->CliPackCookie( fileBufferDes, - (*(*iPersistentCookies)[i]) ); - - if ( err == KErrNone ) - { - err = file.Write( *fileBuffer ); - } - } - } - - delete fileBuffer; - } - else - { - err = KErrNoMemory; - } - - file.Close(); - } - } - else // there is not enough disk space - { - err = KErrDiskFull; - } - } - else // if ( iCookieFileName->Length() == 0 ) - { - err = KErrNotFound; - } - - CLOG( ( EServer, 0, - _L( "<- CCookieManagerServer::WriteCookiesToFile, errcode%d" ), err ) ); - - return err; - } - -// --------------------------------------------------------- -// CCookieManagerServer::ClearCookies -// --------------------------------------------------------- -// -TInt CCookieManagerServer::ClearAllCookies() - { - TInt count = iPersistentCookies->ClearAllCookies(); - - // delete cookie file, just for sure - // this is done also in destructor - iFs.Delete( *iCookieFileName ); - return count; - } // --------------------------------------------------------- // CCookieManagerServer::StringPool @@ -485,73 +331,40 @@ // CCookieManagerServer::CookieArray // --------------------------------------------------------- // -CCookieArray* CCookieManagerServer::CookieArray() +CCookieArray* CCookieManagerServer::CookieArray(TInt aIndex) { - return iPersistentCookies; + return iCookieGroupDataArray->CookieArray(aIndex); + } + + +// --------------------------------------------------------- +// CCookieManagerServer::CookieGroupDataArray +// --------------------------------------------------------- +// +CCookieGroupDataArray* CCookieManagerServer::CookieGroupDataArray() + { + return iCookieGroupDataArray; } // --------------------------------------------------------- -// CCookieManagerServer::StorePersistentCookie +// CCookieManagerServer::GroupIdArray // --------------------------------------------------------- // -void CCookieManagerServer::StorePersistentCookieL( CCookie* aCookie, - const TDesC8& aRequestUri, - const TInt aIndex ) - { - if (aIndex == -1) - { - iPersistentCookies->AddL( aCookie, aRequestUri); - } - else - { - iPersistentCookies->InsertL( aCookie, aIndex); - } +CGroupIdArray* CCookieManagerServer::GroupIdArray() + { + return iGroupIdArray; } - // --------------------------------------------------------- // CCookieManagerServer::GetCookies // --------------------------------------------------------- // TInt CCookieManagerServer::GetCookies( const TDesC8& aRequestUri, - RPointerArray& 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 +413,154 @@ return self; } +// --------------------------------------------------------- +// CCookieTimer::LoadGroupDataFromFileL +// --------------------------------------------------------- +// +TInt CCookieManagerServer::LoadGroupDataFromFileL( RFs& afileSession ) + { + CLOG( ( EServer, 0, _L( "-> CCookieManagerServer::LoadGroupDataFromFileL" ) ) ); + TBuf<60> groupfile(KNullDesC); + groupfile.Copy( KDefaultCookieXmlFolder ); + groupfile.AppendNum( RProcess().SecureId(), EHex ); + groupfile.Append( KDefaultCookieGroupFile ); + RXmlEngDOMImplementation DOM_impl; + DOM_impl.OpenL(); + RXmlEngDocument doc; + RXmlEngDOMParser parser; + TInt error = parser.Open( DOM_impl ); + + if (error == KErrNone) + { + + + TRAPD( err, doc = parser.ParseFileL( afileSession, groupfile ) ); + if ( ! err ) + { + TXmlEngNode node; + TXmlEngElement element; + RXmlEngNodeList 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerSrc/CookieManagerSession.cpp --- a/httpfilters/cookie/ManagerSrc/CookieManagerSession.cpp Fri Jun 11 14:06:05 2010 +0300 +++ b/httpfilters/cookie/ManagerSrc/CookieManagerSession.cpp Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerSrc/CookieManagerStart.cpp --- a/httpfilters/cookie/ManagerSrc/CookieManagerStart.cpp Fri Jun 11 14:06:05 2010 +0300 +++ b/httpfilters/cookie/ManagerSrc/CookieManagerStart.cpp Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/ManagerSrc/GroupIdInfoArray.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/ManagerSrc/GroupIdInfoArray.cpp Wed Jun 23 18:48:21 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,aGroupId =%x" ), aClientId, aGroupId ) ); + TInt count = Count(); + TBool found(EFalse); + + for(TInt i=0;iCount(); + } diff -r ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/Rom/CookieManager.iby --- a/httpfilters/cookie/Rom/CookieManager.iby Fri Jun 11 14:06:05 2010 +0300 +++ b/httpfilters/cookie/Rom/CookieManager.iby Wed Jun 23 18:48:21 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 ea9c9681bbaf -r 974c3ee9bf20 httpfilters/cookie/data/CookieGroup.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpfilters/cookie/data/CookieGroup.xml Wed Jun 23 18:48:21 2010 +0300 @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff -r ea9c9681bbaf -r 974c3ee9bf20 netprotocols_plat/cookie_manager_api/inc/cookie.h --- a/netprotocols_plat/cookie_manager_api/inc/cookie.h Fri Jun 11 14:06:05 2010 +0300 +++ b/netprotocols_plat/cookie_manager_api/inc/cookie.h Wed Jun 23 18:48:21 2010 +0300 @@ -30,7 +30,7 @@ class RHTTPHeaders; class TUriC8; - +class TDesC8; // CONSTANTS // Attribute prefix : we have to pack cookies when either passing them over @@ -77,6 +77,7 @@ // cookie was generated. It is important to know it // for correct age calculation. //EAge, // The age of the cookie as estimated by the cache + ELastAttribute }; public : // exported methods @@ -239,7 +240,7 @@ * Copy from an already existing one. * @param aCopyFrom The already existing CCookie object */ - void CopyFromL( const CCookie& aCopyFrom ); + void CopyFromL( const CCookie& aCopyFrom, const TDesC8& aDomain, const TDesC8& aPath, const TDesC8& aPort ); /** * Returns this cookie's StringPool. @@ -266,7 +267,7 @@ * @return TBool indicating the cookies's Version attribute's notoriety. */ TBool IsUnknownVersion() const; - + static CCookie* CloneL( const CCookie& aCopy,const TDesC8& aDomain, const TDesC8& aPath, const TDesC8& aPort); private : // class for internal use /** @@ -278,7 +279,11 @@ * @return A TBool holding the result */ TBool ExpiredNetscapeL( THTTPHdrVal aAttrVal ) const; - + + /* For logging Cookie attributes + * + */ + void Log( TInt aAssociatedId = 0 ) const; /** * Tokenize a string. * @return actual number of tokens diff -r ea9c9681bbaf -r 974c3ee9bf20 netprotocols_plat/cookie_manager_api/inc/cookiemanagerclient.h --- a/netprotocols_plat/cookie_manager_api/inc/cookiemanagerclient.h Fri Jun 11 14:06:05 2010 +0300 +++ b/netprotocols_plat/cookie_manager_api/inc/cookiemanagerclient.h Wed Jun 23 18:48:21 2010 +0300 @@ -30,6 +30,8 @@ #include #include +//FORWARD Class Declaration +class CCookieClientDataArray; // CLASS DECLARATION /** @@ -87,6 +89,14 @@ * @return Error code indicating the result of the call. */ IMPORT_C TInt SetAppUidL(const TUint32& aAppUid ); + IMPORT_C void Close(); + IMPORT_C TInt StoreCookie( const CCookie& aCookie, + const TUriC8& aUri,TUint32& aAppUid); + IMPORT_C void GetCookiesL( const TDesC8& aUri, + RPointerArray& aCookies, + TBool& aCookie2Reqd,TUint32& aAppUid ); + IMPORT_C TInt ClearAllAppUidCookies(const TUint32& aAppUid); + private : // internal methods /** @@ -102,6 +112,9 @@ */ TInt DoGetCookieSize( const TDesC8& aRequestUri, TPckg& aPkgSize ) const; + + TInt DoGetCookieSize( const TDesC8& aRequestUri, + TPckg& aPkgSize,TDesC& aAppUidPtr ) const; /** * Puts those cookies in the buffer that have been previously selected @@ -115,17 +128,63 @@ * */ TInt DoStoreCookie( const TDesC8& aPackedCookie, - const TDesC8& aUri ) const; + const TDesC8& aUri,TDesC& aAppUidPtr ) const; /** * */ TVersion Version() const; - + + TInt DestroyCookiesFromMemory( TInt& aDeleteStatus ); + + void StoreCookieAtClientSide( const CCookie* aCookie, const TDesC8& aUri,TUint32 aWidgetUid =0); + + TInt GetClientSideCookies( const TDesC8& aRequestUri,RPointerArray& aCookies + ,TBool& aFound, TUint32 aWidgetUid ); + TInt GetCookieSharableFlagFromServer(TBool& aCookieSharableFlag ) const; + private : // data members - RStringPool iStringPool; + //internal data structure for supporting Client side caching. + class TCookieMgrInternalStruct + { + public: + /* Constructor + * + */ + TCookieMgrInternalStruct(RStringPool aStringPool) + : iCookiePacker(aStringPool), + iCookieClientDataArray(NULL) + { + } + + /* Destructor + * + */ + ~TCookieMgrInternalStruct(); + + /* Get Cookiepacker instance + * + */ + inline TCookiePacker& GetCookiePacker(){return iCookiePacker;} + + /* Get Client Data Array Instance + * + */ + inline CCookieClientDataArray* GetCookieClientDataArray(){return iCookieClientDataArray;} + + /* Initialization method for Cookie Client Data Array + * + */ + TInt Init(); + + private: + TCookiePacker iCookiePacker; + CCookieClientDataArray* iCookieClientDataArray; + }; - TCookiePacker iCookiePacker; + RStringPool iStringPool; + TCookieMgrInternalStruct* iCookieMgrData; + }; #endif //__COOKIEMANAGER_CLIENT_H__