|
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 DRM_UDT_MODULE_H |
|
20 #define DRM_UDT_MODULE_H |
|
21 |
|
22 // INCLUDES |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <http.h> |
|
26 #include <stringpool.h> |
|
27 #include <http/mhttpauthenticationcallback.h> |
|
28 #include "DrmUdtObserver.h" |
|
29 |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CDrmUdtConn; |
|
33 class CPeriodic; |
|
34 class MDrmUdtObserver; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 class CDrmUdtHandler: public CActive, |
|
39 public MHTTPTransactionCallback, |
|
40 public MHTTPDataSupplier |
|
41 { |
|
42 public: // Constructors and destructor |
|
43 |
|
44 enum TUdtErrorCode |
|
45 { |
|
46 EUdtOk = KErrNone, |
|
47 EUdtClientError = -100, |
|
48 EUdtServerError = -101, |
|
49 EUdtInvalidServerAddress = -102, |
|
50 EUdtKeyRestoreFailed = -103 |
|
51 }; |
|
52 |
|
53 /** |
|
54 * Two-phased constructor |
|
55 */ |
|
56 IMPORT_C static CDrmUdtHandler* NewL(); |
|
57 |
|
58 /** |
|
59 * Destructor |
|
60 */ |
|
61 IMPORT_C virtual ~CDrmUdtHandler(); |
|
62 |
|
63 public: // new methods |
|
64 |
|
65 /** |
|
66 * DoUserDataTransferL |
|
67 * |
|
68 * |
|
69 * @since 3.0 |
|
70 * @param aOneTimePassword: |
|
71 * @param aRdbFileName: |
|
72 * @param aServiceUrl: |
|
73 * @param aStatus: |
|
74 * |
|
75 * |
|
76 * @leave System wide error code |
|
77 */ |
|
78 EXPORT_C void DoUserDataTransferL( const TDesC8& aOneTimePassword, |
|
79 const TDesC8& aServiceUrl, |
|
80 MDrmUdtObserver* aObserver, |
|
81 TRequestStatus& aStatus ); |
|
82 |
|
83 /** |
|
84 * SetPreferredIap |
|
85 * |
|
86 * |
|
87 * @since 3.0 |
|
88 * @param aPreferredIap: |
|
89 * |
|
90 * |
|
91 * @leave System wide error code |
|
92 */ |
|
93 IMPORT_C void SetPreferredIap( TUint32 aPreferredIap ); |
|
94 |
|
95 |
|
96 protected: // from CActive |
|
97 |
|
98 virtual void DoCancel(); |
|
99 |
|
100 virtual void RunL(); |
|
101 |
|
102 virtual TInt RunError( TInt aError ); |
|
103 |
|
104 protected: // from MHTTPTransactionCallback |
|
105 |
|
106 virtual void MHFRunL( RHTTPTransaction aTransaction, |
|
107 const THTTPEvent& aEvent ); |
|
108 |
|
109 virtual TInt MHFRunError ( TInt aError, |
|
110 RHTTPTransaction aTransaction, |
|
111 const THTTPEvent& aEvent ); |
|
112 |
|
113 protected: // from MHTTPDataSupplier |
|
114 |
|
115 virtual TBool GetNextDataPart( TPtrC8& aDataPart ); |
|
116 |
|
117 virtual void ReleaseData(); |
|
118 |
|
119 virtual TInt OverallDataSize(); |
|
120 |
|
121 virtual TInt Reset(); |
|
122 |
|
123 private: // functions |
|
124 |
|
125 void ConnectL(); |
|
126 |
|
127 void CreateSessionL(); |
|
128 |
|
129 void SendUdtMessageL(); |
|
130 |
|
131 void ResponseReceivedL(); |
|
132 |
|
133 void CreateUdtRequestL(); |
|
134 |
|
135 void ReadUdtDataL( TDes8& aTargetSerialNumber, |
|
136 TInt& aUdtKeyVersion, |
|
137 TDes8& aEncryptedRdbData ); |
|
138 |
|
139 HBufC* SerialNumberL(); |
|
140 |
|
141 void CreateStatusNotificationL(); |
|
142 |
|
143 void InstallHttpFiltersL(); |
|
144 |
|
145 void SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue); |
|
146 |
|
147 void HandleResponseHeadersL( RHTTPResponse aHttpResponse ); |
|
148 |
|
149 TBool CheckHttpCode( TInt aHttpStatus ); |
|
150 |
|
151 TInt AppendResponseData( const TDesC8& aDataChunk ); |
|
152 |
|
153 void TimeOut(); |
|
154 |
|
155 static TInt StaticTimeOut( TAny* aPointer ); |
|
156 |
|
157 void SelfComplete( TInt aResult ); |
|
158 |
|
159 void Complete(); |
|
160 |
|
161 private: // types |
|
162 |
|
163 enum TState |
|
164 { |
|
165 EInit, |
|
166 EStart, |
|
167 EConnect, |
|
168 ESendMessage, |
|
169 EResponseReceived, |
|
170 EComplete |
|
171 }; |
|
172 |
|
173 enum TRequestType |
|
174 { |
|
175 EUdtRequest, |
|
176 EStatusNotification |
|
177 }; |
|
178 |
|
179 private: // Constructors and destructor |
|
180 |
|
181 CDrmUdtHandler(); |
|
182 |
|
183 void ConstructL(); |
|
184 |
|
185 private: // Data |
|
186 |
|
187 RHTTPSession iSession; |
|
188 RHTTPTransaction iTransaction; |
|
189 CDrmUdtConn* iConnection; |
|
190 CPeriodic* iTimeout; |
|
191 TState iState; |
|
192 TRequestType iRequestType; |
|
193 TRequestStatus* iParentStatus; |
|
194 TInt iError; |
|
195 TUint32 iPreferredIap; |
|
196 TInt iUdtError; |
|
197 |
|
198 HBufC8* iUri; |
|
199 HBufC8* iOneTimePassword; |
|
200 HBufC8* iUdtRequest; |
|
201 HBufC8* iUdtResponse; |
|
202 MDrmUdtObserver* iObserver; |
|
203 TUdtStateInfo iStateInfo; |
|
204 |
|
205 }; |
|
206 |
|
207 #endif // DRM_UDT_HANDLER_H |