|
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 "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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef ROAP_ENG_BASE_H |
|
20 #define ROAP_ENG_BASE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <f32file.h> |
|
25 #include <apmrec.h> |
|
26 #include <apparc.h> |
|
27 |
|
28 class CAiwGenericParamList; |
|
29 class CDRMRights; |
|
30 class CDRMRIContext; |
|
31 |
|
32 namespace Roap |
|
33 { |
|
34 // FORWARD DECLARATION |
|
35 |
|
36 class CRoapTrigger; |
|
37 class CRoapHttpHandler; |
|
38 class CRoapResponse; |
|
39 class CRoapMessage; |
|
40 class MRoapObserver; |
|
41 |
|
42 // CLASS DECLARATION |
|
43 |
|
44 enum TTriggerType |
|
45 { |
|
46 ERegistrationTrigger, |
|
47 ERoAcquisitionTrigger, |
|
48 EJoinDomainTrigger, |
|
49 ELeaveDomainTrigger, |
|
50 EExtendedTrigger, |
|
51 EMeteringReportTrigger |
|
52 }; |
|
53 |
|
54 enum TRiContextStatus |
|
55 { |
|
56 EValidContext, |
|
57 EInvalidContext, |
|
58 EInvalidContextNoConf |
|
59 }; |
|
60 |
|
61 enum TDomainOperation |
|
62 { |
|
63 ENotDomainOperation, |
|
64 EJoinDomainOperation, |
|
65 EKeyUpgradeOperation |
|
66 }; |
|
67 |
|
68 |
|
69 class CRoapEngBase: public CActive |
|
70 { |
|
71 public: |
|
72 |
|
73 enum TRoapState |
|
74 { |
|
75 EInit, |
|
76 EReady, |
|
77 ECreateConn, |
|
78 EStartTrans, |
|
79 ERespReceived, |
|
80 EComplete |
|
81 }; |
|
82 |
|
83 enum TRequestType |
|
84 { |
|
85 EDeviceHello, |
|
86 ERegistration, |
|
87 EROAcquisition, |
|
88 EJoinDomain, |
|
89 ELeaveDomain, |
|
90 EMeteringRequest |
|
91 }; |
|
92 |
|
93 |
|
94 public: // destructor |
|
95 |
|
96 IMPORT_C virtual ~CRoapEngBase(); |
|
97 |
|
98 public: |
|
99 |
|
100 /** |
|
101 * SetTriggerL |
|
102 * |
|
103 * The function takes in a ROAP Trigger and parses it. The the internal state |
|
104 * of ROAP Engine is changed accordingly. After the trigger is set a caller |
|
105 * can either accept the ROAP transaction by calling AcceptL or reject by calling |
|
106 * Reject. |
|
107 * |
|
108 * @since 3.0 |
|
109 * @param aXmlTrigger: An ROAP Trigger in XML format |
|
110 * |
|
111 * @param aParamList: Generic paramaters from application that lauched the ROAP UI |
|
112 * Can contain e.g. access point etc. |
|
113 * |
|
114 * @param aType: On return, defines the type of the parsed trigger |
|
115 * |
|
116 * @param aContextStatus: On return, indicates if the Device has stored a valid |
|
117 * RI context or not |
|
118 * |
|
119 * @param aDomainOper: On return, in the case of Join Domain protocol indicates |
|
120 * the intended Domain operation. Join Domain or Key upgrade. |
|
121 * |
|
122 * @param aContentIdList: Out parameter. ContentIDs that are related to the |
|
123 * RO acquisition. Can be used e.g. for opening the |
|
124 * content file after the ROAP has succesfully finished. |
|
125 * The elements inside the array must be deleted by the |
|
126 * caller |
|
127 * |
|
128 * @leave System wide error code |
|
129 */ |
|
130 |
|
131 IMPORT_C void SetTriggerL( const TDesC8& aXmlTrigger, |
|
132 const CAiwGenericParamList* aParamList, |
|
133 TTriggerType& aType, |
|
134 TRiContextStatus& aContextStatus, |
|
135 TDomainOperation& aDomainOperation, |
|
136 RPointerArray<HBufC8>& aContentIdList ); |
|
137 /** |
|
138 * AcceptL |
|
139 * |
|
140 * The function starts the ROAP operation. SetTriggerL must be called successfully |
|
141 * before calling this function. |
|
142 * |
|
143 * @since 3.0 |
|
144 * @param aObserver: An observer object. Can be NULL if the observer is not needed. |
|
145 * |
|
146 * @param aStatus: Indicates the completion status of ROAP. Contains an error code or |
|
147 * KErrNone is everything worked ok. |
|
148 * |
|
149 * @leave System wide error code |
|
150 */ |
|
151 |
|
152 IMPORT_C void AcceptL( MRoapObserver* aObserver, TRequestStatus* aStatus ); |
|
153 |
|
154 /** |
|
155 * Reject |
|
156 * |
|
157 * The function cancels the ROAP operation. The initial state (as it was before calling |
|
158 * SetTriggerL) is restored. The function handles cleanup of stored data internally |
|
159 * (by calling the DoCleanupL method) |
|
160 * |
|
161 * @since 3.0 |
|
162 */ |
|
163 |
|
164 IMPORT_C void Reject(); |
|
165 |
|
166 /** |
|
167 * DoCleanup |
|
168 * |
|
169 * The function deletes the data that has been stored during the last ROAP processing. |
|
170 * The asynchronous AcceptL call must be finished before it is useful to call this method. |
|
171 * |
|
172 * @since 3.0 |
|
173 * |
|
174 * @return System wide error code |
|
175 */ |
|
176 |
|
177 IMPORT_C TInt DoCleanup(); |
|
178 |
|
179 /** |
|
180 * HandleRoReponseL |
|
181 * |
|
182 * The function is for handling the 1-pass RO acquisition case. Takes in RO response |
|
183 * PDU and parses it and stores the Rights Object into the database. |
|
184 * |
|
185 * @since 3.0 |
|
186 * @param aResponse: RO acquisition response PDU in XML format. |
|
187 * @param aParsedRights: Out parameter. Contains pointers to stored ROs. The array |
|
188 * contents are owned by a caller. If the function leaves |
|
189 * the caller must cleanup and close aParsedRights |
|
190 * |
|
191 * @leave System wide error code |
|
192 */ |
|
193 |
|
194 IMPORT_C void HandleRoReponseL( const TDesC8& aResponse, RPointerArray<CDRMRights>& aParsedRights ); |
|
195 |
|
196 |
|
197 /** |
|
198 * Trigger |
|
199 * |
|
200 * The function returns a reference to the parsed CRoapTrigger object. The SetTriggerL |
|
201 * method must be called successfully before this method can be called. |
|
202 * |
|
203 * @since 3.0 |
|
204 * |
|
205 * @return Parsed CRoapTrigger obejct. |
|
206 */ |
|
207 |
|
208 IMPORT_C const CRoapTrigger& Trigger() const; |
|
209 |
|
210 protected: // Constructors |
|
211 |
|
212 CRoapEngBase(); |
|
213 |
|
214 void ConstructL(); |
|
215 |
|
216 |
|
217 protected: // from CActive |
|
218 |
|
219 virtual void DoCancel(); |
|
220 |
|
221 virtual void RunL(); |
|
222 |
|
223 virtual TInt RunError( TInt aError ); |
|
224 |
|
225 |
|
226 protected: |
|
227 |
|
228 void SetL(); |
|
229 |
|
230 void CreateConnectionL(); |
|
231 |
|
232 void StartTransactionL(); |
|
233 |
|
234 void HandleResponseL(); |
|
235 |
|
236 void SetProtocolL(); |
|
237 |
|
238 void CompleteL(); |
|
239 |
|
240 void CompleteRequest(); |
|
241 |
|
242 void Continue( TRoapState aNextState ); |
|
243 |
|
244 |
|
245 protected: |
|
246 |
|
247 virtual CRoapTrigger* ParseTriggerL( const TDesC8& aXmlTrigger ) = 0; |
|
248 |
|
249 virtual void GetRIContextL( TBool& aRegistered, const TDesC8& aRiId ) = 0; |
|
250 |
|
251 virtual void GetDomainContextL( TBool& aIsJoined, |
|
252 TBool& aIsValidGeneration, |
|
253 const TDesC8& aDomainId ) = 0; |
|
254 |
|
255 virtual void CreateReqMessageL() = 0; |
|
256 |
|
257 virtual void HandleRoapResponseL( const TDesC8& aXmlResponse ) = 0; |
|
258 |
|
259 virtual void HandleRightsResponsePduL( const TDesC8& aRightsResp, TBool aOnePass ) = 0; |
|
260 |
|
261 virtual void HandleMultipartL() = 0; |
|
262 |
|
263 virtual HBufC8* SignMessageL( const TDesC8& aMessage ) const = 0; |
|
264 |
|
265 virtual TInt MapStatusL() = 0; |
|
266 |
|
267 |
|
268 protected: |
|
269 |
|
270 CRoapTrigger* iTrigger; |
|
271 CRoapMessage* iRequest; |
|
272 CRoapMessage* iResponse; |
|
273 CRoapHttpHandler* iHttpHandler; |
|
274 CRoapResponse* iRoapResp; |
|
275 CDRMRIContext* iStoredRiContext; |
|
276 TRoapState iState; |
|
277 TInt iStatusCode; |
|
278 TInt iResult; |
|
279 TRequestStatus* iParentStatus; |
|
280 TUint32 iPreferredIap; |
|
281 TRequestType iReqMessage; |
|
282 TBool iCompleted; |
|
283 MRoapObserver* iObserver; |
|
284 TBool iTransTrackConf; |
|
285 RPointerArray<CDRMRights> iReturnedROs; |
|
286 TBool iAllowedToContactRi; |
|
287 TBool iUseRiContextUrl; |
|
288 TBool iImplicitJoinDomain; |
|
289 HBufC8* iDomainRightsResp; // for the implicit Join Domain |
|
290 TInt iProgressInBytes; |
|
291 TBool iReRegistered; |
|
292 HBufC8* iRiAlias; |
|
293 }; |
|
294 } |
|
295 |
|
296 #endif |