CCookie Class Reference

class CCookie : public CBase

Class to store the data that makes up a cookie

Inherits from

Nested Classes and Structures

Public Member Functions
~CCookie ()
IMPORT_C void AddToRequestL ( RHTTPHeaders , TInt )
IMPORT_C TInt Attribute ( TCookieAttributeName , THTTPHdrVal &)
TInt Attribute ( TCookieAttributeName , THTTPHdrVal &, TBool &)
CCookie * CloneL (const CCookie &, const TDesC8 &, const TDesC8 &, const TDesC8 &)
void CopyFromL (const CCookie &, const TDesC8 &, const TDesC8 &, const TDesC8 &)
TBool Expired ()
TBool FromCookie2 ()
TBool FromNetscapeVersion ()
TBool IsUnknownVersion ()
IMPORT_C CCookie * NewL ( RHTTPHeaders , TInt , RStringF , RStringPool , const TUriC8 &)
IMPORT_C CCookie * NewL ( RStringPool )
TBool Persistent ()
void RemoveAttribute ( TCookieAttributeName )
TPtrC8 RemoveQuotes (const TDesC8 &)
IMPORT_C TInt SetAttribute ( TCookieAttributeName , const THTTPHdrVal &)
TInt SetAttribute ( TCookieAttributeName , const THTTPHdrVal &, TBool )
void SetCookie2 ( TBool )
void SetFromNetscape ( TBool )
TInt Size ( TBool )
RStringPool StringPool ()
Private Member Functions
CCookie ( RStringPool )
void AddDefaultPathL (const TUriC8 &)
void ConstructL ( RHTTPHeaders , TInt , RStringF , const TUriC8 &)
TBool ExpiredNetscapeL ( THTTPHdrVal )
TInt FindAttribute ( TCookieAttributeName , TCookieAttribute &)
TInt FindTokens (const TDesC8 &, const TDesC8 &, const TInt , TInt *)
HBufC8 * GetCleanedDateTimeLC ( HBufC8 *)
TInt GetLocalOffset ( HBufC8 *, TInt &, TInt &, TInt &)
TInt GetMilitaryOffset ( HBufC8 *, TInt &)
TInt GetTimeZone ( HBufC8 *, TInt &, TInt &)
void Log ( TInt )
void RemoveAttribute ( TInt )
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Public Member Enumerations
enum TCookieAttributeName {
EName , EValue , EComment , ECommentURI , EDiscard , EDomain , EMaxAge , EPath , EPort , ESecure , EVersion , EExpires , EDate , ELastAttribute
}
Private Attributes
RArray < TCookieAttribute > iAttributes
TBool iNetscape
TTime iReceivedTime
TBool iSetCookie2
TInt iSize
RStringPool iStringPool

Constructor & Destructor Documentation

CCookie(RStringPool)

CCookie ( RStringPool aStringPool ) [private]

Constructor.

Parameters

RStringPool aStringPool The current string pool.

~CCookie()

IMPORT_C ~CCookie ( ) [virtual]

Standard destructor.

Member Functions Documentation

AddDefaultPathL(const TUriC8 &)

void AddDefaultPathL ( const TUriC8 & aUri ) [private]

When the cookie does not have a Path attribute, we have to add a default Path attribute. This method does this addition.

Parameters

const TUriC8 & aUri An initialized URI parser.

AddToRequestL(RHTTPHeaders, TInt)

IMPORT_C void AddToRequestL ( RHTTPHeaders aRequestHeaders,
TInt aPartIndex
) const

This method writes the cookie (i.e. its attributes) into the specified part of the HTTP header. The method may leave if writing is not successful (e.g. when RHTTPHeaders::SetParamL leaves) or if the cookie is not properly initialized.

Parameters

RHTTPHeaders aRequestHeaders The current HTTP header collection to which we add this cookie,
TInt aPartIndex The part of the header.

Attribute(TCookieAttributeName, THTTPHdrVal &)

IMPORT_C TInt Attribute ( TCookieAttributeName aAttributeName,
THTTPHdrVal & aAttributeVal
) const

Attribute retrieves the value of an attribute

Parameters

TCookieAttributeName aAttributeName Identifies the attribute
THTTPHdrVal & aAttributeVal The value being retrieved

Attribute(TCookieAttributeName, THTTPHdrVal &, TBool &)

TInt Attribute ( TCookieAttributeName aAttributeName,
THTTPHdrVal & aAttributeVal,
TBool & aDefaulted
) const

Attribute retrieves the value of an attribute

Parameters

TCookieAttributeName aAttributeName Identifies the attribute
THTTPHdrVal & aAttributeVal The value being retrieved
TBool & aDefaulted A TBool indicating whether the current attribute's value is defaulted or specified.

CloneL(const CCookie &, const TDesC8 &, const TDesC8 &, const TDesC8 &)

CCookie * CloneL ( const CCookie & aCopy,
const TDesC8 & aDomain,
const TDesC8 & aPath,
const TDesC8 & aPort
) [static]

Parameters

const CCookie & aCopy
const TDesC8 & aDomain
const TDesC8 & aPath
const TDesC8 & aPort

ConstructL(RHTTPHeaders, TInt, RStringF, const TUriC8 &)

void ConstructL ( RHTTPHeaders aRequestHeaders,
TInt aPartIndex,
RStringF aFieldName,
const TUriC8 & aUri
) [private]

Constructor.

Parameters

RHTTPHeaders aRequestHeaders A collection of header fields associated with the current HTTP message,
TInt aPartIndex The index of the part in the header,
RStringF aFieldName The HTTP header name,
const TUriC8 & aUri HTTP request's URI.

CopyFromL(const CCookie &, const TDesC8 &, const TDesC8 &, const TDesC8 &)

void CopyFromL ( const CCookie & aCopyFrom,
const TDesC8 & aDomain,
const TDesC8 & aPath,
const TDesC8 & aPort
)

Copy from an already existing one.

Parameters

const CCookie & aCopyFrom The already existing CCookie object
const TDesC8 & aDomain
const TDesC8 & aPath
const TDesC8 & aPort

Expired()

TBool Expired ( ) const

Returns whether This cookie has expired or not.

ExpiredNetscapeL(THTTPHdrVal)

TBool ExpiredNetscapeL ( THTTPHdrVal aAttrVal ) const [private]

Determines if the cookie had expired in case of Netscape style Method may leave with KErrNoMemory KErrNotFound, if parsing the date string fails (not a well formed string)

Parameters

THTTPHdrVal aAttrVal The THTTPHdrVal holding the Expires date as a string

FindAttribute(TCookieAttributeName, TCookieAttribute &)

TInt FindAttribute ( TCookieAttributeName aAttributeName,
TCookieAttribute & aAttribute
) const [private]

Finds the specified attribute in this cookie

Parameters

TCookieAttributeName aAttributeName
TCookieAttribute & aAttribute

FindTokens(const TDesC8 &, const TDesC8 &, const TInt, TInt *)

TInt FindTokens ( const TDesC8 & aString,
const TDesC8 & aTokenSeparators,
const TInt aTokenCount,
TInt * aTokens
) const [private]

Tokenize a string.

Parameters

const TDesC8 & aString string to be tokenized
const TDesC8 & aTokenSeparators separator characters
const TInt aTokenCount expected number of tokens
TInt * aTokens position of token separators found in aString

FromCookie2()

TBool FromCookie2 ( ) const [inline]

Did this cookie come from a SetCookie2 header?

FromNetscapeVersion()

TBool FromNetscapeVersion ( ) const [inline]

Did this cookie come from a Netscape-version header?

GetCleanedDateTimeLC(HBufC8 *)

HBufC8 * GetCleanedDateTimeLC ( HBufC8 * aDate ) const [private]

Takes an HTTP header date-time information and returnes it in a format supported by TTime .

Parameters

HBufC8 * aDate

GetLocalOffset(HBufC8 *, TInt &, TInt &, TInt &)

TInt GetLocalOffset ( HBufC8 * aDate,
TInt & aHour,
TInt & aMinute,
TInt & aLength
) const [private]

Parameters

HBufC8 * aDate
TInt & aHour
TInt & aMinute
TInt & aLength

GetMilitaryOffset(HBufC8 *, TInt &)

TInt GetMilitaryOffset ( HBufC8 * aDate,
TInt & aHour
) const [private]

Parameters

HBufC8 * aDate
TInt & aHour

GetTimeZone(HBufC8 *, TInt &, TInt &)

TInt GetTimeZone ( HBufC8 * aDate,
TInt & aHour,
TInt & aLength
) const [private]

Parameters

HBufC8 * aDate
TInt & aHour
TInt & aLength

IsUnknownVersion()

TBool IsUnknownVersion ( ) const

Returns whether the cookie's Version attribute is known or not.

Log(TInt)

void Log ( TInt aAssociatedId = 0 ) const [private]

Parameters

TInt aAssociatedId = 0

NewL(RHTTPHeaders, TInt, RStringF, RStringPool, const TUriC8 &)

IMPORT_C CCookie * NewL ( RHTTPHeaders aRequestHeaders,
TInt aPartIndex,
RStringF aFieldName,
RStringPool aStringPool,
const TUriC8 & aUri
) [static]

Constructor.

Parameters

RHTTPHeaders aRequestHeaders A collection of header fields associated with the current HTTP message,
TInt aPartIndex The index of the part in the header,
RStringF aFieldName The HTTP header name,
RStringPool aStringPool The current string pool,
const TUriC8 & aUri HTTP request's URI.

NewL(RStringPool)

IMPORT_C CCookie * NewL ( RStringPool aStringPool ) [static]

Constructor.

Parameters

RStringPool aStringPool The current string pool.

Persistent()

TBool Persistent ( ) const

Returns whether This cookie is persistent or not.

RemoveAttribute(TCookieAttributeName)

void RemoveAttribute ( TCookieAttributeName aAttributeName )

Removes a cookie attribute. The attribute is closed, removed from the attribute list and the cookie size is also updated.

Parameters

TCookieAttributeName aAttributeName identifies the attribute

RemoveAttribute(TInt)

void RemoveAttribute ( TInt aIndex ) [private]

Removes a cookie attribute. The attribute is closed, removed from the attribute list and the cookie size is also updated.

Parameters

TInt aIndex The position of the cooke attribute in the attribute list.

RemoveQuotes(const TDesC8 &)

TPtrC8 RemoveQuotes ( const TDesC8 & aDes ) [static]

Returns a descriptor which is equivalent to the input descriptor, but without the surrounding quotation marks. This method always returns the appropriate string even if there are no quotation marks, or at least one of them is missing. This is required because cookie attributes may be surrounded by double quotes.

Parameters

const TDesC8 & aDes The descriptor to be cleaned.

SetAttribute(TCookieAttributeName, const THTTPHdrVal &)

IMPORT_C TInt SetAttribute ( TCookieAttributeName aAttributeName,
const THTTPHdrVal & aAttributeVal
)

SetAttribute sets an attribute on the cookie. Adding an attribute where one exists will replace the existing one

Parameters

TCookieAttributeName aAttributeName identifies the attribute
const THTTPHdrVal & aAttributeVal the value being set

SetAttribute(TCookieAttributeName, const THTTPHdrVal &, TBool)

TInt SetAttribute ( TCookieAttributeName aAttributeName,
const THTTPHdrVal & aAttributeVal,
TBool aDefaulted
)

SetAttribute sets an attribute on the cookie. Adding an attribute where one exists will replace the existing one

Parameters

TCookieAttributeName aAttributeName identifies the attribute
const THTTPHdrVal & aAttributeVal the value being set
TBool aDefaulted a TBool indicating whether it is a defaulted or a supplied value

SetCookie2(TBool)

void SetCookie2 ( TBool aFromCookie2 ) [inline]

Use this method to specify whether this cookie came from a SetCookie2 header.

Parameters

TBool aFromCookie2 ETrue, if the cookie came from a SetCookie2 header, EFalse otherwise.

SetFromNetscape(TBool)

void SetFromNetscape ( TBool aFromNetscape ) [inline]

Use this method to specify whether this cookie is a Netscape style one or an RFC compliant.

Parameters

TBool aFromNetscape ETrue, if the cookie is a Netscape style one, EFalse otherwise.

Size(TBool)

TInt Size ( TBool aSuppressDefaulted ) const [inline]

Returns the number of bytes this cookie would require if it was stored in a flat buffer and one attribute followed the other. Note : the attributes are stored in a way that we first write out the size (TInt) of the attribute in question and then the attribute value. E.g. assuming a NAME attribute with the value of SESSIONID, we write out 9 as the length of NAME (again, stored as TInt) and then write out the value of NAME (i.e. SESSIONID).

Parameters

TBool aSuppressDefaulted If ETrue, the method does not add the size of defaulted attributes to the overall size of the cookie.

StringPool()

RStringPool StringPool ( )

Returns this cookie's StringPool.

Member Enumerations Documentation

Enum TCookieAttributeName

Enumeration of all the elements of data that make up a cookie

Enumerators

EName
EValue
EComment
ECommentURI
EDiscard
EDomain
EMaxAge
EPath
EPort
ESecure
EVersion
EExpires
EDate
ELastAttribute

Member Data Documentation

RArray< TCookieAttribute > iAttributes

RArray < TCookieAttribute > iAttributes [private]

Array of the attributes of this cookie

TBool iNetscape

TBool iNetscape [private]

Flag indicating whether this cookie is Netscape or RFC compliant It is important to know it as they have different fields, different defaulting and handling.

TTime iReceivedTime

TTime iReceivedTime [private]

TBool iSetCookie2

TBool iSetCookie2 [private]

Flag indicating whether this cookie was received in a SetCookie2 header

TInt iSize

TInt iSize [private]

RStringPool iStringPool

RStringPool iStringPool [private]

String pool that can be used by this cookie