1 /* |
|
2 * Copyright (c) 2003 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: Handler for loading file scheme. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CFILEHANDLER_H |
|
21 #define CFILEHANDLER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "urlloader_urlloaderint.h" |
|
25 #include "urlloader_murlschemehandler.h" |
|
26 #include <f32file.h> |
|
27 |
|
28 // CONSTANTS |
|
29 |
|
30 // MACROS |
|
31 |
|
32 // DATA TYPES |
|
33 |
|
34 // FUNCTION PROTOTYPES |
|
35 |
|
36 // FORWARD DECLARATIONS |
|
37 |
|
38 // CLASS DECLARATION |
|
39 class CKFileLoader; |
|
40 /** |
|
41 * Handling the load of a specific file. A CFileHandler object is instantiated |
|
42 * to handle each file load request. |
|
43 * |
|
44 * @lib fileloader.lib |
|
45 * @since 2.0 |
|
46 */ |
|
47 class CFileHandler : public CActive |
|
48 { |
|
49 public: // Constructors and destructor |
|
50 |
|
51 /** |
|
52 * Two-phased constructor. |
|
53 * @param aUrl The request URL. |
|
54 * @param aTransId The request's transaction id. |
|
55 * @param aLoadContext The load context that should be returned with the response. |
|
56 * @param aLoadType The type of the load. |
|
57 * @param aLoadCallback The callback to call when the response is ready. |
|
58 * @param aFileLoader The context of the file loader, used to send back the response. |
|
59 * @return CFileHandler |
|
60 */ |
|
61 static CFileHandler* NewL(const TUint16 *aUrl, |
|
62 TUint8 aMethod, |
|
63 TUint16 aTransId, |
|
64 TUint8 aLoadType, |
|
65 void *aLoadContext, |
|
66 NW_Url_RespCallback_t *aLoadCallback, |
|
67 CKFileLoader* aFileLoader); |
|
68 |
|
69 /** |
|
70 * Destructor. |
|
71 */ |
|
72 virtual ~CFileHandler(); |
|
73 |
|
74 public: // New functions |
|
75 |
|
76 /** |
|
77 * Create a CFileHandler object and initiate the load. |
|
78 * @since 2.0 |
|
79 * @param aUrl The request URL. |
|
80 * @param aTransId The request's transaction id. |
|
81 * @param aLoadType The type of the load. |
|
82 * @param aLoadContext The load context that should be returned with the response. |
|
83 * @param aLoadCallback The callback to call when the response is ready. |
|
84 * @param aFileLoader The context of the file loader, used to send back the response. |
|
85 * @return void |
|
86 */ |
|
87 static void LoadFileL(const TUint16 *aUrl, |
|
88 TUint16 aTransId, |
|
89 TUint8 aLoadType, |
|
90 void *aLoadContext, |
|
91 NW_Url_RespCallback_t *aLoadCallback, |
|
92 CKFileLoader* aFileLoader); |
|
93 |
|
94 /** |
|
95 * Create a CFileHandler object and initiate a head request. |
|
96 * @since 2.6 |
|
97 * @param aUrl The request URL. |
|
98 * @param aTransId The request's transaction id. |
|
99 * @param aLoadType The type of the load. |
|
100 * @param aLoadContext The load context that should be returned with the response. |
|
101 * @param aLoadCallback The callback to call when the response is ready. |
|
102 * @param aFileLoader The context of the file loader, used to send back the response. |
|
103 * @return void |
|
104 */ |
|
105 static void GetFileInfoL(const TUint16 *aUrl, |
|
106 TUint16 aTransId, |
|
107 TUint8 aLoadType, |
|
108 void *aLoadContext, |
|
109 NW_Url_RespCallback_t *aLoadCallback, |
|
110 CKFileLoader* aFileLoader); |
|
111 |
|
112 public: // Functions from base classes |
|
113 |
|
114 /** |
|
115 * From CActive Return the response after file loading from the File system is complete. |
|
116 * @since 2.0 |
|
117 * @param |
|
118 * @return void |
|
119 */ |
|
120 void RunL(); |
|
121 |
|
122 /** |
|
123 * From CActive Noop. File loading cannot be cancelled. |
|
124 * @since 2.0 |
|
125 * @param |
|
126 * @return void |
|
127 */ |
|
128 void DoCancel(); |
|
129 |
|
130 private: |
|
131 |
|
132 /** |
|
133 * C++ default constructor. |
|
134 */ |
|
135 CFileHandler(const TUint16 *aUrl, |
|
136 TUint8 aMethod, |
|
137 TUint16 aTransId, |
|
138 TUint8 aLoadType, |
|
139 void *aLoadContext, |
|
140 NW_Url_RespCallback_t *aLoadCallback, |
|
141 CKFileLoader* aFileLoader); |
|
142 |
|
143 /** |
|
144 * By default Symbian 2nd phase constructor is private. |
|
145 */ |
|
146 void ConstructL(); |
|
147 |
|
148 /** |
|
149 * Determine the content type of the file. |
|
150 */ |
|
151 void ContentTypeL(TUint8** aContentTypeString); |
|
152 |
|
153 /** |
|
154 * Determine the content encoding of the file. |
|
155 */ |
|
156 TUint16 ContentEncoding(TUint8* aContentTypeString); |
|
157 |
|
158 /** |
|
159 * Translate the file name from a URL to a valid file name in the system. |
|
160 */ |
|
161 TBool GetFileNameL(); |
|
162 |
|
163 /** |
|
164 * Determine if the file is a saved deck or not. If it is saved deck, parse the file. |
|
165 */ |
|
166 TBool ParseSavedDeck(); |
|
167 |
|
168 private: // Data |
|
169 |
|
170 // The URL of the file to load |
|
171 const TUint16* iUrl; |
|
172 |
|
173 // The method |
|
174 TUint8 iMethod; |
|
175 |
|
176 // The loadType |
|
177 TUint8 iLoadType; |
|
178 |
|
179 // The URL of the loaded file. Could be different than the original URL in case of saved deck. |
|
180 TUint16* iRedirectedUrl; |
|
181 |
|
182 // The context to return in the response callback. |
|
183 void *iLoadContext; |
|
184 |
|
185 // The callback to call for the response. |
|
186 NW_Url_RespCallback_t *iLoadCallback; |
|
187 |
|
188 // The CFileLOader object used to return the response. |
|
189 CKFileLoader* iFileLoader; |
|
190 |
|
191 // The transaction's id. |
|
192 TUint16 iTransId; |
|
193 |
|
194 // A session to the file system. |
|
195 RFs iRfs; |
|
196 |
|
197 // A handle to the file being loaded. |
|
198 RFile iFile; |
|
199 |
|
200 // The file's content. |
|
201 TPtr8 iData; |
|
202 |
|
203 // The loaded file's name. This is different from the URL. It does not contain the scheme. |
|
204 TPtr iFileName; |
|
205 |
|
206 // A flag if opening RFs was successful and it needs to be closed. |
|
207 TBool iRfsOpen; |
|
208 |
|
209 // A flag if opening the file was successful and it needs to be closed. |
|
210 TBool iFileOpen; |
|
211 |
|
212 // The number of bytes in the file. |
|
213 TInt iSize; |
|
214 |
|
215 // The content-type of the file. |
|
216 TUint8* iContentType; |
|
217 |
|
218 }; |
|
219 |
|
220 #endif // CFILEHANDLER_H |
|
221 |
|
222 // End of File |
|