|
1 /* |
|
2 * Copyright (c) 2007 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: Implementation class for DrmServiceAPI.dll |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <drmserviceapi.h> |
|
21 |
|
22 #include "roapstorageclient.h" |
|
23 #include "drmclockclient.h" |
|
24 |
|
25 |
|
26 // ======== LOCAL FUNCTIONS ======== |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // two-phase costructor |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 EXPORT_C DRM::CDrmServiceApi* DRM::CDrmServiceApi::NewL() |
|
35 { |
|
36 CDrmServiceApi* self = CDrmServiceApi::NewLC(); |
|
37 CleanupStack::Pop( self ); |
|
38 return self; |
|
39 } |
|
40 |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // two-phase costructor |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 EXPORT_C DRM::CDrmServiceApi* DRM::CDrmServiceApi::NewLC() |
|
47 { |
|
48 CDrmServiceApi* self = new( ELeave ) CDrmServiceApi; |
|
49 CleanupStack::PushL( self ); |
|
50 self->ConstructL(); |
|
51 return self; |
|
52 } |
|
53 |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // Destructor |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 DRM::CDrmServiceApi::~CDrmServiceApi() |
|
60 { |
|
61 // Clock client |
|
62 if( iClockClient ) |
|
63 { |
|
64 iClockClient->Close(); |
|
65 delete iClockClient; |
|
66 iClockClient = NULL; |
|
67 } |
|
68 |
|
69 // Roap storage client |
|
70 if( iRoapStorageClient ) |
|
71 { |
|
72 iRoapStorageClient->Close(); |
|
73 delete iRoapStorageClient; |
|
74 iRoapStorageClient = NULL; |
|
75 } |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CDrmServiceApi::GetSecureTime |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 EXPORT_C TInt DRM::CDrmServiceApi::GetSecureTime( |
|
83 TTime& aTime, |
|
84 TInt& aTimeZone, |
|
85 DRMClock::ESecurityLevel& aSecurityLevel ) const |
|
86 { |
|
87 return iClockClient->GetSecureTime( aTime, aTimeZone, aSecurityLevel); |
|
88 }; |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // CDrmServiceApi::UpdateSecureTime |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 EXPORT_C TInt DRM::CDrmServiceApi::UpdateSecureTime( const TTime& aTime, const TInt& aTimeZone ) |
|
95 { |
|
96 return iClockClient->UpdateSecureTime( aTime, aTimeZone ); |
|
97 }; |
|
98 |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // CDrmServiceApi::GetDevicePublicKeyDerL |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 EXPORT_C void DRM::CDrmServiceApi::GetDevicePublicKeyDerL( HBufC8*& aPublicKey ) |
|
105 { |
|
106 iRoapStorageClient->GetDevicePublicKeyDerL( aPublicKey ); |
|
107 }; |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // CDrmServiceApi::SignL |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 EXPORT_C void DRM::CDrmServiceApi::SignL( const TDesC8& aHash, HBufC8*& aSignature ) |
|
114 { |
|
115 iRoapStorageClient->SignL( aHash, aSignature ); |
|
116 }; |
|
117 |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // Constructor |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 DRM::CDrmServiceApi::CDrmServiceApi() |
|
124 { |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // 2nd phase constructor |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 void DRM::CDrmServiceApi::ConstructL() |
|
132 { |
|
133 // Create an instance of the clock client |
|
134 iClockClient = new (ELeave) RDRMClockClient; |
|
135 |
|
136 // Connect to the server |
|
137 User::LeaveIfError( iClockClient->Connect() ); |
|
138 |
|
139 // Create and instance of the roap storage client |
|
140 iRoapStorageClient = new (ELeave) Roap::RRoapStorageClient; |
|
141 |
|
142 // Connect to the server |
|
143 User::LeaveIfError( iRoapStorageClient->Connect() ); |
|
144 } |