|
1 /* |
|
2 * Copyright (c) 2002-2004 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 the License "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: This file contains the declaration of the default attrib of Download Mgr Server. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __DOWNLOADMGR_DEFATTRIB_H__ |
|
21 #define __DOWNLOADMGR_DEFATTRIB_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <HttpDownloadMgrCommon.h> |
|
26 |
|
27 // DATA TYPES |
|
28 typedef TPckgBuf< TInt32 > THttpDownloadMgrIntegerBuf; |
|
29 |
|
30 // CLASS DECLARATION |
|
31 class CDefaultAttrib; |
|
32 |
|
33 /** |
|
34 * Class for spack/unpack utils |
|
35 * |
|
36 * @lib - |
|
37 * @since Series 60 2.8 |
|
38 */ |
|
39 NONSHARABLE_CLASS( TDMgrUtils ) |
|
40 { |
|
41 public: // Constructor |
|
42 |
|
43 TDMgrUtils(); |
|
44 |
|
45 public: // New functions |
|
46 |
|
47 /** |
|
48 * Get the next default/event attribute from the packed attribute list. |
|
49 * @param aAttrib unpacked attribute |
|
50 * @param aCount the next attribute to be unpack |
|
51 * @param aPackedAttribs packed attribute list |
|
52 * @return TBool. |
|
53 */ |
|
54 TBool NextAttribL( CDefaultAttrib* aAttrib, |
|
55 const TDesC8& aPackedAttribs ); |
|
56 |
|
57 /** |
|
58 * Allocate buffer for default attributes. |
|
59 * @param aAttrib unpacked attributes |
|
60 * @return HBufC8*. |
|
61 */ |
|
62 static HBufC8* AllocDefAttribBufLC( CArrayPtrFlat< CDefaultAttrib >* aAttribs ); |
|
63 |
|
64 /** |
|
65 * Pack attributes. |
|
66 * @param aAttrib unpacked attributes |
|
67 * @return HBufC8*. |
|
68 */ |
|
69 static HBufC8* PackedAttributesL( CArrayPtrFlat< CDefaultAttrib >* aAttribs ); |
|
70 |
|
71 /** |
|
72 * Alloc and pack event attributes. |
|
73 * @param aUserData User data |
|
74 * @param aDownloadedSize Downloaded size |
|
75 * @param aAttrLength Attribute length |
|
76 * @return HBufC8*. |
|
77 */ |
|
78 static HBufC8* PackEventAttribL( TInt32 aUserData = 0, |
|
79 TInt32 aMODownloadedSize = 0, |
|
80 TInt32 aDownloadedSize = 0, |
|
81 TInt32 aMOAttrLength = 0, |
|
82 TInt32 aAttrLength = 0 ); |
|
83 |
|
84 /** |
|
85 * Unpack event attributes. |
|
86 * @param aPack Package |
|
87 * @param aUserData User data |
|
88 * @param aDownloadedSize Downloaded size |
|
89 * @param aAttrLength Attribute length |
|
90 * @return None. |
|
91 */ |
|
92 static void UnPackEventAttribL( const TDesC8& aPack, |
|
93 TInt32& aUserData, |
|
94 TInt32& aMODownloadedSize, |
|
95 TInt32& aDownloadedSize, |
|
96 TInt32& aMOAttrLength, |
|
97 TInt32& aAttrLength, |
|
98 TInt32& aMoIndex ); |
|
99 |
|
100 public: // Members |
|
101 |
|
102 // utils used by the default/event attributes |
|
103 TPtrC8 iPtr; |
|
104 TInt iCurrent; |
|
105 }; |
|
106 |
|
107 /** |
|
108 * Class for storing default attribute |
|
109 * |
|
110 * @lib - |
|
111 * @since Series 60 2.8 |
|
112 */ |
|
113 NONSHARABLE_CLASS( CDefaultAttrib ) : public CBase |
|
114 { |
|
115 public: |
|
116 |
|
117 /** |
|
118 * Default attribute type |
|
119 * |
|
120 * @lib - |
|
121 * @since Series 60 2.8 |
|
122 */ |
|
123 enum TAttribType |
|
124 { |
|
125 EInt, |
|
126 EBool, |
|
127 EString8, |
|
128 EString16 |
|
129 }; |
|
130 |
|
131 public: // Constructors and destructor |
|
132 |
|
133 /** |
|
134 * Two-phased constructors. |
|
135 */ |
|
136 static CDefaultAttrib* NewL(); |
|
137 |
|
138 static CDefaultAttrib* NewL( THttpDownloadAttrib aAttribute, |
|
139 TInt32 aValue ); |
|
140 |
|
141 static CDefaultAttrib* NewL( THttpDownloadAttrib aAttribute, |
|
142 TBool aValue ); |
|
143 |
|
144 static CDefaultAttrib* NewL( THttpDownloadAttrib aAttribute, |
|
145 const TDesC8& aValue ); |
|
146 |
|
147 static CDefaultAttrib* NewL( THttpDownloadAttrib aAttribute, |
|
148 const TDesC16& aValue ); |
|
149 |
|
150 /** |
|
151 * Destructor. |
|
152 */ |
|
153 virtual ~CDefaultAttrib(); |
|
154 |
|
155 protected: |
|
156 |
|
157 /** |
|
158 * C++ default constructor. |
|
159 */ |
|
160 CDefaultAttrib( THttpDownloadAttrib aAttribute, TAttribType aType ); |
|
161 CDefaultAttrib(); |
|
162 |
|
163 /** |
|
164 * By default Symbian 2nd phase constructors are private. |
|
165 */ |
|
166 void ConstructL(); |
|
167 void ConstructL( TInt32 aValue ); |
|
168 void ConstructL( TBool aValue ); |
|
169 void ConstructL( const TDesC8& aValue ); |
|
170 void ConstructL( const TDesC16& aValue ); |
|
171 |
|
172 public: |
|
173 |
|
174 TInt32 AsTInt32L() const; |
|
175 TBool AsTBoolL() const; |
|
176 TPtrC8 AsTPtrC8L() const; |
|
177 TPtrC16 AsTPtrC16L() const; |
|
178 |
|
179 void SetL( const TDesC8& aType, const TDesC8& aAttribute, const TDesC8& aValue ); |
|
180 void Reset(); |
|
181 |
|
182 void PackAttribute( TDes8& aPackage ); |
|
183 TInt PackedAttribSize(); |
|
184 |
|
185 public: // Data |
|
186 |
|
187 // attribute name |
|
188 THttpDownloadAttrib iAttribute; |
|
189 // attribute type |
|
190 TAttribType iType; |
|
191 // Possible attribute values |
|
192 TInt32 iInt32; // Storage for integer based data |
|
193 TBool iBool; // Storage for TBool |
|
194 HBufC8* iBufC8; // Storage for 8 bits buffer based data. |
|
195 HBufC16* iBufC16; // Storage for 16 bits buffer based data. |
|
196 |
|
197 }; |
|
198 |
|
199 #endif // __DOWNLOADMGR_DEFATTRIB_H__ |
|
200 |
|
201 // End of File |