|
1 /* |
|
2 * Copyright (c) 2006 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: CNcdProtocol declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_NCDPROTOCOL_H |
|
20 #define C_NCDPROTOCOL_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 #include "ncdparserobserver.h" |
|
25 #include "ncdprotocol.h" |
|
26 #include "ncddeviceservice.h" |
|
27 #include "ncduserconfiguration.h" |
|
28 #include "ncdprotocoldefaultobserver.h" |
|
29 |
|
30 class CNcdSessionHandler; |
|
31 class MNcdParser; |
|
32 class CNcdRequestBase; |
|
33 class CNcdRequestConfigurationData; |
|
34 class CNcdRequestConfigurationClient; |
|
35 class CNcdRequestConfigurationSoftware; |
|
36 class CNcdRequestConfigurationHardware; |
|
37 class CCatalogsSmsUtils; |
|
38 class CNcdKeyValuePair; |
|
39 class CNcdKeyValueMap; |
|
40 class MCatalogsContext; |
|
41 class MNcdDatabaseStorage; |
|
42 class MNcdStorageManager; |
|
43 class MNcdConfigurationManager; |
|
44 class CNcdProtocolDefaultObserverImpl; |
|
45 class MNcdProtocolDefaultObserver; |
|
46 class MNcdSessionHandler; |
|
47 class MNcdConfigurationProtocolCookie; |
|
48 class CNcdSubscriptionManager; |
|
49 class CNcdConfigurationProtocolDetailImpl; |
|
50 class TCatalogsVersion; |
|
51 |
|
52 /** |
|
53 * Protocol entry point. |
|
54 * |
|
55 * @note Requests are created with NcdRequestGenerator |
|
56 * |
|
57 */ |
|
58 class CNcdProtocol : public CBase, public MNcdProtocol |
|
59 { |
|
60 public: |
|
61 |
|
62 /** |
|
63 * Protocol options are set with SetProtocolOptions |
|
64 */ |
|
65 enum TNcdProtocolOptions |
|
66 { |
|
67 /** |
|
68 * Send IMEI in the client configuration |
|
69 */ |
|
70 ESendImei = 1 |
|
71 }; |
|
72 |
|
73 public: |
|
74 /** |
|
75 * Creator |
|
76 */ |
|
77 static CNcdProtocol* NewL( |
|
78 MNcdConfigurationManager& aConfigurationManager, |
|
79 CNcdSubscriptionManager& aSubscriptionManager ); |
|
80 |
|
81 /** |
|
82 * Destructor |
|
83 */ |
|
84 ~CNcdProtocol(); |
|
85 |
|
86 private: |
|
87 |
|
88 /** |
|
89 * Constructor |
|
90 */ |
|
91 CNcdProtocol( |
|
92 MNcdConfigurationManager& aConfigurationManager, |
|
93 CNcdSubscriptionManager& aSubscriptionManager ); |
|
94 |
|
95 /** |
|
96 * ConstructL |
|
97 */ |
|
98 void ConstructL(); |
|
99 |
|
100 public: // From MNcdProtocol |
|
101 |
|
102 /** |
|
103 * @see MNcdProtocol::CreateParserL() |
|
104 */ |
|
105 MNcdParser* CreateParserL( MCatalogsContext& aContext, |
|
106 const TDesC& aServerUri ); |
|
107 |
|
108 |
|
109 /** |
|
110 * @see MNcdProtocol::ProcessPreminetRequestL() |
|
111 */ |
|
112 HBufC8* ProcessPreminetRequestL( const MCatalogsContext& aContext, |
|
113 CNcdRequestBase& aRequest, |
|
114 const TDesC& aServerUri, |
|
115 TBool aForceConfigurationData = EFalse ); |
|
116 |
|
117 /** |
|
118 * @see MNcdProtocol::ProcessConfigurationRequestL() |
|
119 */ |
|
120 HBufC8* ProcessConfigurationRequestL( const MCatalogsContext& aContext, |
|
121 CNcdRequestConfiguration& aRequest ); |
|
122 |
|
123 |
|
124 /** |
|
125 * @see MNcdProtocol::SessionHandler() |
|
126 */ |
|
127 MNcdSessionHandler& SessionHandlerL( |
|
128 const MCatalogsContext& aContext ) const; |
|
129 |
|
130 |
|
131 public: // New methods |
|
132 |
|
133 /** |
|
134 * Sets protocol options |
|
135 * |
|
136 * @param aOptions A combination of TNcdProtocolOptions |
|
137 */ |
|
138 void SetProtocolOptions( TUint32 aOptions ); |
|
139 |
|
140 private: // New methods |
|
141 |
|
142 // Adds client-info to the given request configuration (except cookies) |
|
143 void AddClientInfoToRequestL( |
|
144 const MCatalogsContext& aContext, |
|
145 CNcdRequestConfigurationData& aConfig ); |
|
146 |
|
147 |
|
148 // Adds engine's client-info the request |
|
149 void AddEngineClientInfoToRequestL( |
|
150 CNcdRequestConfigurationData& aConfig ); |
|
151 |
|
152 void SetNetworkInfoL( CNcdRequestConfigurationData& aConfig ); |
|
153 |
|
154 void AddSoftwareConfigurationL( const MCatalogsContext& aContext, |
|
155 CNcdRequestConfigurationClient& aClient, |
|
156 RPointerArray<CNcdKeyValuePair>& aConfigPairs ); |
|
157 |
|
158 void SetHardwareConfigurationL( |
|
159 CNcdRequestConfigurationHardware& aConfig, |
|
160 RPointerArray<CNcdKeyValuePair>& aConfigPairs ); |
|
161 |
|
162 // Adds user configurations to the request config |
|
163 void AddConfigurationsToSoftwareDetailsL( |
|
164 CNcdRequestConfigurationSoftware& aConfig, |
|
165 RPointerArray<CNcdKeyValuePair>& aUserConfig) const; |
|
166 |
|
167 // Adds a single protocol detail |
|
168 CNcdConfigurationProtocolDetailImpl* CreateDetailLC( |
|
169 const TDesC& aKey, const TDesC& aValue ) const; |
|
170 |
|
171 void AddSoftwareUserConfigurationL( |
|
172 CNcdRequestConfigurationSoftware& aConfig, |
|
173 void (CNcdRequestConfigurationSoftware::*aValueSetter)( const TDesC& ), |
|
174 RPointerArray<CNcdKeyValuePair>& aUserConfig, |
|
175 const TDesC& aKey ) const; |
|
176 |
|
177 // Adds client's capabilities and engine's/provider's hardcoded capabilities |
|
178 void AddCapabilitiesL( |
|
179 CNcdRequestConfigurationSoftware& aConfig, |
|
180 RPointerArray<CNcdKeyValuePair>& aUserConfig ) const; |
|
181 |
|
182 // Checks if the engine supports the given capability or not |
|
183 // Engine's caps are hardcoded in this method |
|
184 TBool IsCapabilitySupported( const TDesC& aCapability ) const; |
|
185 |
|
186 // Adds cookies to the array |
|
187 // Returns ETrue if cookies were removed due to expiration |
|
188 TBool AddCookiesL( const MCatalogsContext& aContext, |
|
189 RPointerArray<MNcdConfigurationProtocolCookie>& aCookies, |
|
190 const TDesC& aServerUri, |
|
191 const TDesC& aNamespace ); |
|
192 |
|
193 // Adds the cookies from the array to the request and removes them |
|
194 // from the array |
|
195 void AddCookiesToRequestL( |
|
196 CNcdRequestBase& aRequest, |
|
197 RPointerArray<MNcdConfigurationProtocolCookie>& aCookies ); |
|
198 |
|
199 // Adds the cookies from the array to the configuration request |
|
200 // and removes them from the array |
|
201 void AddCookiesToConfigRequestL( |
|
202 CNcdRequestConfigurationData& aConfig, |
|
203 RPointerArray<MNcdConfigurationProtocolCookie>& aCookies ); |
|
204 |
|
205 // Searches for the given key |
|
206 TInt FindKey( const TDesC& aKey, |
|
207 const RPointerArray<CNcdKeyValuePair>& aArray ) const; |
|
208 |
|
209 |
|
210 // Adds display details to aConfig from aConfigPairs |
|
211 TInt AddDisplayDetailsL( |
|
212 CNcdRequestConfigurationHardware& aConfig, |
|
213 RPointerArray<CNcdKeyValuePair>& aConfigPairs ); |
|
214 |
|
215 // Interprets the given display value |
|
216 TInt InterpretDisplayValue( |
|
217 const TDesC& aValue, TInt& aDispNumber, TInt& aWidth, |
|
218 TInt& aHeight, TInt& aColors ) const; |
|
219 |
|
220 // Adds the possible product code to the hardware details. |
|
221 void AddProductCodeToHardwareDetailsL( |
|
222 CNcdRequestConfigurationHardware& aConfig, |
|
223 RPointerArray<CNcdKeyValuePair>& aConfigPairs ); |
|
224 |
|
225 /** |
|
226 * Gets flash player UID and version. |
|
227 * |
|
228 * @param aUid On return, contains the UID of flash-player installed |
|
229 * on the device. |
|
230 * @param aVersion On return, contains the version of flash-player |
|
231 * installed on the device. |
|
232 * @return ETrue If the flash player data was found, otherwise false. |
|
233 */ |
|
234 TBool FlashPlayerDataL( TUid& aUid, TCatalogsVersion& aVersion ); |
|
235 |
|
236 /** |
|
237 * Adds additional firmware details to hardware details |
|
238 */ |
|
239 void AddFirmwareDetailsToHardwareDetailsL( |
|
240 CNcdRequestConfigurationHardware& aConfig ); |
|
241 |
|
242 /** |
|
243 * A helper method for adding a hardware detail |
|
244 */ |
|
245 void AddHardwareDetailL( |
|
246 CNcdRequestConfigurationHardware& aConfig, |
|
247 const TDesC& aKey, |
|
248 const TDesC& aValue ); |
|
249 |
|
250 private: |
|
251 |
|
252 // forward declaration |
|
253 class CContextData; |
|
254 |
|
255 CContextData& CreateContextDataL( const MCatalogsContext& aContext ); |
|
256 TInt FindContextData( const MCatalogsContext& aContext ) const; |
|
257 |
|
258 static TBool MatchContextDatas( const CContextData& aFirst, |
|
259 const CContextData& aSecond ); |
|
260 |
|
261 |
|
262 private: // Data types |
|
263 |
|
264 /** |
|
265 * Context-specific data |
|
266 */ |
|
267 class CContextData : public CBase, |
|
268 public MNcdParserSessionObserver |
|
269 { |
|
270 public: |
|
271 CContextData( const MCatalogsContext& aContext, |
|
272 CNcdSessionHandler* aSessionHandler ); |
|
273 |
|
274 ~CContextData(); |
|
275 |
|
276 /** |
|
277 * Session handler getter |
|
278 */ |
|
279 MNcdSessionHandler& SessionHandler() const; |
|
280 |
|
281 |
|
282 TUid FamilyId() const; |
|
283 |
|
284 private: // From MNcdParserSessionObserver |
|
285 |
|
286 /** |
|
287 * @see MNcdParserSessionObserver::SessionL |
|
288 */ |
|
289 void SessionL( const TDesC& aSessionId, const TDesC& aServerUri, |
|
290 const TDesC& aNameSpace ); |
|
291 |
|
292 private: |
|
293 // Context's family id |
|
294 TUid iFamilyId; |
|
295 |
|
296 // Session handler |
|
297 CNcdSessionHandler* iSessionHandler; |
|
298 |
|
299 }; |
|
300 |
|
301 |
|
302 private: // Data |
|
303 |
|
304 MNcdConfigurationManager& iConfigurationManager; |
|
305 CNcdSubscriptionManager& iSubscriptionManager; |
|
306 |
|
307 // Owned |
|
308 CCatalogsSmsUtils* iSmsUtils; |
|
309 |
|
310 // Not owned |
|
311 MNcdDeviceService* iDeviceService; |
|
312 |
|
313 TBuf<MNcdDeviceService::KMccLength> iHomeMcc; |
|
314 TBuf<MNcdDeviceService::KMncLength> iHomeMnc; |
|
315 |
|
316 // Context-specific data, owned |
|
317 RPointerArray<CContextData> iContexts; |
|
318 |
|
319 TUint32 iProtocolOptions; |
|
320 }; |
|
321 |
|
322 |
|
323 #endif |