|
1 /* |
|
2 * Copyright (c) 2003 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: Client side class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "DRMClockClient.h" |
|
21 #include "DRMClientServer.h" |
|
22 |
|
23 #include "DRMLog.h" |
|
24 |
|
25 // EXTERNAL DATA STRUCTURES |
|
26 // EXTERNAL FUNCTION PROTOTYPES |
|
27 |
|
28 // CONSTANTS |
|
29 // MACROS |
|
30 |
|
31 // LOCAL CONSTANTS AND MACROS |
|
32 // To initialize C/S parameters. |
|
33 #define PARAMS TAny* params[ KMaxMessageArguments ]; \ |
|
34 for ( TUint8 i = 0; i < KMaxMessageArguments; ++i ) { params[ i ] = NULL; } |
|
35 #define CLEARPARAM Mem::FillZ( params, \ |
|
36 KMaxMessageArguments * sizeof( TAny* ) ); |
|
37 |
|
38 // Maximum number of message slots that we use |
|
39 const TInt KMaxMessageSlots = 3; |
|
40 |
|
41 |
|
42 // MODULE DATA STRUCTURES |
|
43 // LOCAL FUNCTION PROTOTYPES |
|
44 |
|
45 // FORWARD DECLARATIONS |
|
46 |
|
47 // ============================= LOCAL FUNCTIONS =============================== |
|
48 |
|
49 // ============================ MEMBER FUNCTIONS =============================== |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // RDRMClockClient::RDRMClockClient |
|
53 // C++ default constructor can NOT contain any code, that |
|
54 // might leave. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 EXPORT_C RDRMClockClient::RDRMClockClient() |
|
58 { |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // RDRMClockClient::~RDRMClockClient |
|
63 // Destructor. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 EXPORT_C RDRMClockClient::~RDRMClockClient() |
|
67 { |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // RDRMClockClient::Connect |
|
72 // Opens connection to the server. |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 EXPORT_C TInt RDRMClockClient::Connect() |
|
76 { |
|
77 TInt ret = KErrNone; |
|
78 |
|
79 DRMLOG( _L( "RDRMClockClient::Connect" ) ); |
|
80 |
|
81 const TVersion requiredVersion( |
|
82 DRMClock::KServerMajorVersion, |
|
83 DRMClock::KServerMinorVersion, |
|
84 DRMClock::KServerBuildVersion ); |
|
85 |
|
86 DRMLOG( _L("RDRMClockClient: Create a new session" ) ); |
|
87 ret = CreateSession( DRMClock::KDRMServerName, |
|
88 requiredVersion, |
|
89 KMaxMessageSlots ); |
|
90 |
|
91 DRMLOG2( _L( "Result: %d") , ret ); |
|
92 |
|
93 return ret; |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // RDRMClockClient::Close |
|
98 // Closes the connection to the server. |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 EXPORT_C void RDRMClockClient::Close() |
|
102 { |
|
103 DRMLOG( _L( "RDRMClockClient::Close" ) ); |
|
104 |
|
105 RHandleBase::Close(); |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // RDRMClockClient::GetSecureTime |
|
110 // Gets the secure time from the DRMClockServer |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 EXPORT_C TInt RDRMClockClient::GetSecureTime( TTime& aTime, TInt& aTimeZone, |
|
114 DRMClock::ESecurityLevel& aSecurityLevel ) |
|
115 { |
|
116 TPckg<TTime> package(aTime); |
|
117 TPckg<TInt> package2(aTimeZone); |
|
118 TPckg<DRMClock::ESecurityLevel> package3(aSecurityLevel); |
|
119 |
|
120 DRMLOG( _L( "RDRMClockClient::GetSecureTime" ) ); |
|
121 TInt error = KErrNone; |
|
122 |
|
123 // For C/S communications. |
|
124 PARAMS; |
|
125 |
|
126 // Set the parameters. |
|
127 params[ 0 ] = reinterpret_cast< TAny* >( &package ); |
|
128 params[ 1 ] = reinterpret_cast< TAny* >( &package2 ); |
|
129 params[ 2 ] = reinterpret_cast< TAny* >( &package3 ); |
|
130 |
|
131 // Send the message. |
|
132 error = SendReceive( DRMClock::EGetDRMTime, params ); |
|
133 |
|
134 // Reset |
|
135 CLEARPARAM; |
|
136 |
|
137 DRMLOG2( _L( "RDRMClockClient::GetSecureTime: %d" ), error ); |
|
138 |
|
139 return error; |
|
140 } |
|
141 |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // RDRMClockClient::UpdateSecureTime |
|
145 // Updates the secure time on the DRMClockServer |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 EXPORT_C TInt RDRMClockClient::UpdateSecureTime( const TTime& aTime, const TInt& aTimeZone ) |
|
149 { |
|
150 TInt error = KErrNone; |
|
151 TPckg<TTime> package(aTime); |
|
152 TPckg<TInt> package2(aTimeZone); |
|
153 |
|
154 DRMLOG( _L( "RDRMClockClient::UpdateSecureTime" ) ); |
|
155 |
|
156 // For C/S communications. |
|
157 PARAMS; |
|
158 |
|
159 params[ 0 ] = reinterpret_cast< TAny* >( &package ); |
|
160 params[ 1 ] = reinterpret_cast< TAny* >( &package2 ); |
|
161 |
|
162 error = SendReceive( DRMClock::EUpdateDRMTime, params ); |
|
163 |
|
164 CLEARPARAM; |
|
165 |
|
166 DRMLOG2( _L( "RDRMClockClient::UpdateSecureTime: " ), error ); |
|
167 |
|
168 // All done. |
|
169 return error; |
|
170 } |
|
171 |
|
172 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
173 |
|
174 // End of File |