|
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 "DRMclockClientServer.h" |
|
22 #include "DRMTypes.h" |
|
23 |
|
24 #include "DRMLog.h" |
|
25 |
|
26 |
|
27 // EXTERNAL DATA STRUCTURES |
|
28 // EXTERNAL FUNCTION PROTOTYPES |
|
29 |
|
30 // CONSTANTS |
|
31 // MACROS |
|
32 |
|
33 // LOCAL CONSTANTS AND MACROS |
|
34 |
|
35 // Maximum number of message slots that we use |
|
36 LOCAL_C const TInt KMaxMessageSlots = 3; |
|
37 |
|
38 #ifndef __DRM_CLOCK |
|
39 LOCAL_C const TInt KMinuteInMicroseconds = 60000000; |
|
40 LOCAL_C const TInt KTimeZoneIncrement = 15; |
|
41 #endif |
|
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 #ifdef __DRM_CLOCK |
|
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::KServerName, |
|
88 requiredVersion, |
|
89 KMaxMessageSlots ); |
|
90 DRMLOG2( _L( "Result: %d") , ret ); |
|
91 #else |
|
92 DRMLOG( _L( "RDRMClockClient: No Session Created, DRMClock is off") ); |
|
93 #endif // __DRM_CLOCK |
|
94 |
|
95 return ret; |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // RDRMClockClient::Close |
|
100 // Closes the connection to the server. |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 EXPORT_C void RDRMClockClient::Close() |
|
104 { |
|
105 DRMLOG( _L( "RDRMClockClient::Close" ) ); |
|
106 |
|
107 RHandleBase::Close(); |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // RDRMClockClient::GetSecureTime |
|
112 // Gets the secure time from the DRMClockServer |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 EXPORT_C TInt RDRMClockClient::GetSecureTime( TTime& aTime, TInt& aTimeZone, |
|
116 DRMClock::ESecurityLevel& aSecurityLevel ) const |
|
117 { |
|
118 #ifdef __DRM_CLOCK |
|
119 TPckg<TTime> package(aTime); |
|
120 TPckg<TInt> package2(aTimeZone); |
|
121 TPckg<DRMClock::ESecurityLevel> package3(aSecurityLevel); |
|
122 |
|
123 DRMLOG( _L( "RDRMClockClient::GetSecureTime" ) ); |
|
124 TInt error = KErrNone; |
|
125 |
|
126 // Send the message. |
|
127 error = SendReceive( DRMClock::EGetDRMTime, TIpcArgs( &package, &package2, &package3 ) ); |
|
128 |
|
129 DRMLOG2( _L( "RDRMClockClient::GetSecureTime: %d" ), error ); |
|
130 return error; |
|
131 #else |
|
132 DRMLOG( _L( "RDRMClockClient::GetSecureTime, UI Time is returned, DRMClock is off" ) ); |
|
133 TTime currentLocal; |
|
134 TInt64 result = 0; |
|
135 |
|
136 // aTime: |
|
137 aTime.UniversalTime(); |
|
138 currentLocal.HomeTime(); |
|
139 |
|
140 result = currentLocal.Int64() - aTime.Int64(); |
|
141 result /= KMinuteInMicroseconds; |
|
142 result /= KTimeZoneIncrement; |
|
143 |
|
144 // aTimeZone: |
|
145 aTimeZone = I64INT(result); |
|
146 |
|
147 // aSecurityLevel: |
|
148 aSecurityLevel = DRMClock::KSecure; |
|
149 return KErrNone; |
|
150 #endif // __DRM_CLOCK |
|
151 } |
|
152 |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // RDRMClockClient::UpdateSecureTime |
|
156 // Updates the secure time on the DRMClockServer |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 EXPORT_C TInt RDRMClockClient::UpdateSecureTime( const TTime& aTime, const TInt& aTimeZone ) |
|
160 { |
|
161 TInt error = KErrNone; |
|
162 #ifdef __DRM_CLOCK |
|
163 TPckg<TTime> package(aTime); |
|
164 TPckg<TInt> package2(aTimeZone); |
|
165 |
|
166 DRMLOG( _L( "RDRMClockClient::UpdateSecureTime" ) ); |
|
167 |
|
168 error = SendReceive( DRMClock::EUpdateDRMTime, TIpcArgs( &package, &package2 ) ); |
|
169 |
|
170 DRMLOG2( _L( "RDRMClockClient::UpdateSecureTime: " ), error ); |
|
171 #else |
|
172 DRMLOG( _L("RDRMClockClient::UpdateSecureTime, Did nothing DRMClock is off") ); |
|
173 #endif |
|
174 // All done. |
|
175 return error; |
|
176 } |
|
177 |
|
178 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
179 |
|
180 // End of File |