|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Declaration of class TCookiePacker |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __COOKIE_IPC_H__ |
|
21 #define __COOKIE_IPC_H__ |
|
22 |
|
23 // INCLUDE FILES |
|
24 // System includes |
|
25 #include <cookie.h> |
|
26 #include <e32base.h> |
|
27 #include <http.h> |
|
28 |
|
29 // CLASS DECLARATIONS |
|
30 |
|
31 /** |
|
32 * TCookiePackedCookie |
|
33 * Packs a CCookie's content into a buffer for sending across IPC. |
|
34 * Also unpacks the data into a CCookie |
|
35 * |
|
36 */ |
|
37 class TCookiePacker |
|
38 { |
|
39 public : // construction |
|
40 /** |
|
41 * |
|
42 */ |
|
43 TCookiePacker( RStringPool aStringPool ); // DONE |
|
44 |
|
45 public : // common methods |
|
46 /** |
|
47 * |
|
48 */ |
|
49 TInt CliPackCookie( TDes8& aBuffer, const CCookie& aCookie ) const; |
|
50 |
|
51 /** |
|
52 * |
|
53 */ |
|
54 TInt SrvPackCookie( TDes8& aBuffer, const CCookie& aCookie ) const; |
|
55 |
|
56 /** |
|
57 * This method unpacks a cookie from a flat buffer to a cookie object. |
|
58 * It is used from both client and server side. |
|
59 */ |
|
60 void UnpackCookieL( const TDesC8& aPtr, CCookie& aCookie ) const; |
|
61 |
|
62 /** |
|
63 * Processes the buffer and inserts cookies into the array. |
|
64 * @param aBuffer Buffer to be processed. It contains the cookies in a |
|
65 * form that makes it possible to transfer the cookies over client- |
|
66 * server boundary, |
|
67 * @param aCookies The array that is supposed to contain the cookies. |
|
68 */ |
|
69 void UnpackCookiesFromBufferL( const TDesC8& aBuffer, |
|
70 RPointerArray<CCookie>& aCookies ) const; |
|
71 |
|
72 private : |
|
73 /** |
|
74 * Add a named (string type) attribute from cookie to the string buffer. |
|
75 */ |
|
76 TInt AddStringF( const CCookie::TCookieAttributeName aAttrib, |
|
77 const CCookie& aCookie, |
|
78 TDes8& aBuffer, |
|
79 TBool aNoDefaulted = EFalse ) const; |
|
80 /** |
|
81 * Add Date attribute from cookie to the string buffer. |
|
82 */ |
|
83 TInt AddDateL( const CCookie& aCookie, |
|
84 TDes8& aBuffer, |
|
85 TBool aNoDefaulted = EFalse ) const; |
|
86 |
|
87 /** |
|
88 * |
|
89 */ |
|
90 void AppendAttributeLength( TInt aLength, TDes8& aBuffer ) const; |
|
91 |
|
92 /** |
|
93 * Unpack a named (string type) attribute from the buffer to the cookie. |
|
94 */ |
|
95 void GetPackedAttributeL( const CCookie::TCookieAttributeName aAttrib, |
|
96 CCookie& aCookie, |
|
97 const TUint8*& aPtrStart ) const; |
|
98 |
|
99 /** |
|
100 * Unpack the Date attribute from the buffer to the cookie. |
|
101 */ |
|
102 void GetPackedDateAttributeL( CCookie& aCookie, |
|
103 const TUint8*& aPtrStart ) const; |
|
104 |
|
105 /** |
|
106 * This method unpacks a cookie from a flat buffer to a cookie object. |
|
107 * It is used from both client and server side. |
|
108 */ |
|
109 void UnpackCookieL( const TUint8*& aPtr, CCookie& aCookie ) const; |
|
110 |
|
111 /** |
|
112 * |
|
113 */ |
|
114 TInt DoPackCookie( TDes8& aBuffer, |
|
115 const CCookie& aCookie, TBool aSevrer ) const; |
|
116 |
|
117 /** |
|
118 * Decrease a numeric value in a numeric formatted buffer. |
|
119 * (underflow is handled) |
|
120 * @param aBuffer contains numeric value |
|
121 * @param aIndex position where to decrease |
|
122 * @return KErrNone if no error occurs, otherwise KErrGeneral |
|
123 * Leave code: KErrNoMemory |
|
124 */ |
|
125 TInt DecreaseNumericValueL( TDes& aBuffer, const TInt aIndex ) const; |
|
126 |
|
127 /** |
|
128 * Trim cookie's name and value if their size is bigger than 4K. |
|
129 * @param aCookie identifies the cookie |
|
130 */ |
|
131 void TrimNameAndValueL( CCookie& aCookie ) const; |
|
132 |
|
133 private : // data members |
|
134 RStringPool iStringPool; |
|
135 }; |
|
136 |
|
137 #endif // __COOKIE_IPC_H__ |