|
1 /* |
|
2 * Copyright (c) 2008 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: WMDRM DLA Default Metering |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_WMDRMDLADEFAULMETERING_H |
|
20 #define C_WMDRMDLADEFAULMETERING_H |
|
21 |
|
22 #include "wmdrmdladefaulthttpmanagerobserver.h" |
|
23 |
|
24 class CWmDrmDlaDefaultHttpPlugin; |
|
25 class CWmDrmDlaUiNotifier; |
|
26 class CWmDrmDlaDefaultHttpManager; |
|
27 class CHTTPFormEncoder; |
|
28 |
|
29 /** |
|
30 * WMDRM DLA Default Metering |
|
31 * Reference implementation to demonstrate how to handle metering |
|
32 * with the MS test site. |
|
33 * |
|
34 * @lib wmdrmdladefaulthttpplugin.lib |
|
35 * @since S60 v9.1 |
|
36 */ |
|
37 NONSHARABLE_CLASS( CWmDrmDlaDefaultMetering ) |
|
38 : public CBase, |
|
39 public MWmDrmDlaDefaltHttpManagerObserver |
|
40 { |
|
41 |
|
42 public: |
|
43 |
|
44 static CWmDrmDlaDefaultMetering* NewL( |
|
45 CWmDrmDlaDefaultHttpPlugin* aPlugin ); |
|
46 ~CWmDrmDlaDefaultMetering(); |
|
47 |
|
48 /** |
|
49 * Check if metering certificate is supported by this plugin |
|
50 * |
|
51 * @param aCertificate Metering certificate |
|
52 * @param aUiNotifer If certificate is supported, contains initialized UI |
|
53 * Notifier upon completion. Will be deleted by the |
|
54 * caller after the plugin has been deleted. |
|
55 * @return ETrue if certificate is supported by this plugin |
|
56 * @leave with standard Symbian error code in case of error |
|
57 */ |
|
58 TBool SupportedMeteringCertificateL( const TDesC8& aCertificate, |
|
59 CWmDrmDlaUiNotifier*& aUiNotifier ); |
|
60 |
|
61 /** |
|
62 * Process metering challenge. |
|
63 * |
|
64 * @param aMeteringChallenge Metering challenge |
|
65 * @param aUrl Url to be used in metering request |
|
66 * @param aStatus Request status, will contain error code upon completion |
|
67 * including but not limited to: |
|
68 * - KErrCommsBreak if network connection was lost during communication |
|
69 * with server |
|
70 * - KErrGeneral if unspecified error happened |
|
71 */ |
|
72 void ProcessMeteringChallenge( const TDesC8& aMeteringChallenge, |
|
73 const TDesC& aUrl, |
|
74 TRequestStatus& aStatus ); |
|
75 |
|
76 /** |
|
77 * Get metering response. |
|
78 * |
|
79 * @param aResponse Contains metering response upon completion. |
|
80 * Will be deleted by the caller. |
|
81 * @param aStatus Request status, will contain error code upon completion |
|
82 */ |
|
83 void GetMeteringResponse( HBufC8*& aResponse, TRequestStatus& aStatus ); |
|
84 |
|
85 /** |
|
86 * Inform plugin that metering finished. |
|
87 * |
|
88 */ |
|
89 void MeteringFinished(); |
|
90 |
|
91 /* |
|
92 * Cancel metering |
|
93 */ |
|
94 void CancelMetering(); |
|
95 |
|
96 /** |
|
97 * Sets the IAP to be used in the HTTP transactions |
|
98 * |
|
99 * @param aIapId Internet Access Point id |
|
100 */ |
|
101 void SetIapId( TInt aIapId ); |
|
102 |
|
103 private: // From MWmDrmDlaDefaltHttpManagerObserver |
|
104 |
|
105 TBool OnGetUsernamePasswordL( HBufC8*& aUsername, HBufC8*& aPassword ); |
|
106 void OnResponseHeadersL( const RHTTPResponse& aResponse, |
|
107 const RHTTPHeaders& aHeaders, |
|
108 const RStringPool& aStringPool, |
|
109 TInt aHttpStatus ); |
|
110 void OnResponseBodyDataL( const TPtrC8 aDataChunk ); |
|
111 void OnTransactionComplete( TInt aSystemError ); |
|
112 |
|
113 private: |
|
114 |
|
115 CWmDrmDlaDefaultMetering( CWmDrmDlaDefaultHttpPlugin* aPlugin ); |
|
116 void ConstructL(); |
|
117 |
|
118 void CompleteClientRequest( TInt aError ); |
|
119 |
|
120 void ProcessMeteringChallengeL( const TDesC8& aMeteringChallenge ); |
|
121 |
|
122 private: // data |
|
123 |
|
124 enum TMeteringState |
|
125 { |
|
126 ENotActive, |
|
127 ESendingMeteringChallenge |
|
128 }; |
|
129 |
|
130 TMeteringState iState; |
|
131 CWmDrmDlaDefaultHttpManager* iHttpManager; |
|
132 CHTTPFormEncoder* iFormEncoder; |
|
133 TInt iHttpStatus; |
|
134 HBufC8* iMeteringResponse; |
|
135 HBufC* iMeteringServerUrl; |
|
136 |
|
137 //Not owned |
|
138 CWmDrmDlaDefaultHttpPlugin* iPlugin; |
|
139 TRequestStatus* iClientStatus; |
|
140 |
|
141 }; |
|
142 |
|
143 #endif // C_WMDRMDLADEFAULMETERING_H |