|
1 /* |
|
2 * Copyright (c) 2005 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: Notification Event object base class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "DRMEventTimeChange.h" |
|
22 |
|
23 // EXTERNAL DATA STRUCTURES |
|
24 // EXTERNAL FUNCTION PROTOTYPES |
|
25 // CONSTANTS |
|
26 // MACROS |
|
27 // LOCAL CONSTANTS AND MACROS |
|
28 // MODULE DATA STRUCTURES |
|
29 // LOCAL FUNCTION PROTOTYPES |
|
30 // FORWARD DECLARATIONS |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CDRMEventTimeChange::NewLC |
|
38 // two phased constructor |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 EXPORT_C CDRMEventTimeChange* CDRMEventTimeChange::NewLC() |
|
42 { |
|
43 CDRMEventTimeChange* self = new (ELeave) CDRMEventTimeChange(); |
|
44 CleanupStack::PushL( self ); |
|
45 return self; |
|
46 }; |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CDRMEventTimeChange::NewL |
|
50 // two phased constructor |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 EXPORT_C CDRMEventTimeChange* CDRMEventTimeChange::NewL() |
|
54 { |
|
55 CDRMEventTimeChange* self = NewLC(); |
|
56 CleanupStack::Pop(); |
|
57 return self; |
|
58 }; |
|
59 |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CDRMEventTimeChange::CDRMEventTimeChange |
|
63 // C++ default constructor can NOT contain any code, that |
|
64 // might leave. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CDRMEventTimeChange::CDRMEventTimeChange() : |
|
68 MDRMEvent( KEventTimeChange ), |
|
69 iOldTime( Time::NullTTime() ), |
|
70 iNewTime( Time::NullTTime() ), |
|
71 iOldTimeZone( 0 ), |
|
72 iNewTimeZone( 0 ), |
|
73 iOldSecurityLevel( DRMClock::KInsecure ), |
|
74 iNewSecurityLevel( DRMClock::KInsecure ) |
|
75 { |
|
76 }; |
|
77 |
|
78 // Destructor |
|
79 EXPORT_C CDRMEventTimeChange::~CDRMEventTimeChange() |
|
80 { |
|
81 }; |
|
82 |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CDRMEventTimeChange::SetOldTime |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C void CDRMEventTimeChange::SetOldTime( const TTime& aTime ) |
|
89 { |
|
90 iOldTime = aTime; |
|
91 }; |
|
92 |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CDRMEventTimeChange::GetOldTime |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 EXPORT_C const TTime& CDRMEventTimeChange::GetOldTime() const |
|
99 { |
|
100 return iOldTime; |
|
101 }; |
|
102 |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CDRMEventTimeChange::SetNewTime |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 EXPORT_C void CDRMEventTimeChange::SetNewTime( const TTime& aTime ) |
|
109 { |
|
110 iNewTime = aTime; |
|
111 }; |
|
112 |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CDRMEventTimeChange::GetNewTime |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 EXPORT_C const TTime& CDRMEventTimeChange::GetNewTime() const |
|
119 { |
|
120 return iNewTime; |
|
121 }; |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CDRMEventTimeChange::SetOldTimeZone |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 EXPORT_C void CDRMEventTimeChange::SetOldTimeZone( const TInt aTimeZone ) |
|
128 { |
|
129 iOldTimeZone = aTimeZone; |
|
130 }; |
|
131 |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CDRMEventTimeChange::GetOldTimeZone |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 EXPORT_C TInt CDRMEventTimeChange::GetOldTimeZone() const |
|
138 { |
|
139 return iOldTimeZone; |
|
140 }; |
|
141 |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CDRMEventTimeChange::SetNewTimeZone |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 EXPORT_C void CDRMEventTimeChange::SetNewTimeZone( const TInt aTimeZone ) |
|
148 { |
|
149 iNewTimeZone = aTimeZone; |
|
150 }; |
|
151 |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CDRMEventTimeChange::GetNewTimeZone |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 EXPORT_C TInt CDRMEventTimeChange::GetNewTimeZone() const |
|
158 { |
|
159 return iNewTimeZone; |
|
160 }; |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CDRMEventTimeChange::SetOldSecurityLevel |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 EXPORT_C void CDRMEventTimeChange::SetOldSecurityLevel( |
|
167 const DRMClock::ESecurityLevel aSecLevel ) |
|
168 { |
|
169 iOldSecurityLevel = aSecLevel; |
|
170 }; |
|
171 |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CDRMEventTimeChange::GetOldSecurityLevel |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 EXPORT_C DRMClock::ESecurityLevel CDRMEventTimeChange::GetOldSecurityLevel() const |
|
178 { |
|
179 return iOldSecurityLevel; |
|
180 }; |
|
181 |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CDRMEventTimeChange::SetNewSecurityLevel |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 EXPORT_C void CDRMEventTimeChange::SetNewSecurityLevel( |
|
188 const DRMClock::ESecurityLevel aSecLevel ) |
|
189 { |
|
190 iNewSecurityLevel = aSecLevel; |
|
191 }; |
|
192 |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CDRMEventTimeChange::GetNewSecurityLevel |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 EXPORT_C DRMClock::ESecurityLevel CDRMEventTimeChange::GetNewSecurityLevel() const |
|
199 { |
|
200 return iNewSecurityLevel; |
|
201 }; |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CDRMEventTimeChange::ExternalizeL |
|
205 // Writes the data of the object into the given stream |
|
206 // (other items were commented in a header). |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 EXPORT_C void CDRMEventTimeChange::ExternalizeL( |
|
210 RWriteStream& aOutput) |
|
211 { |
|
212 TInt8 securityLevel = 0; |
|
213 |
|
214 MDRMEvent::ExternalizeL(aOutput); |
|
215 |
|
216 // output the old time |
|
217 WriteInt64L( iOldTime.Int64(), aOutput ); |
|
218 |
|
219 // output the new time |
|
220 WriteInt64L( iNewTime.Int64(), aOutput ); |
|
221 |
|
222 // output the old timezone |
|
223 aOutput.WriteInt32L( iOldTimeZone ); |
|
224 |
|
225 // output the new timezone |
|
226 aOutput.WriteInt32L( iNewTimeZone ); |
|
227 |
|
228 // output the old security level |
|
229 securityLevel = iOldSecurityLevel; |
|
230 aOutput.WriteInt8L( securityLevel ); |
|
231 |
|
232 // output the new security level |
|
233 securityLevel = iNewSecurityLevel; |
|
234 aOutput.WriteInt8L( securityLevel ); |
|
235 |
|
236 }; |
|
237 |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CDRMEventTimeChange::Internalize |
|
241 // Reads the data of the object from the given stream |
|
242 // (other items were commented in a header). |
|
243 // ----------------------------------------------------------------------------- |
|
244 // |
|
245 EXPORT_C void CDRMEventTimeChange::InternalizeL( |
|
246 RReadStream& aInput) |
|
247 { |
|
248 TInt8 securityLevel = 0; |
|
249 TInt64 timeData = 0; |
|
250 |
|
251 MDRMEvent::InternalizeL(aInput); |
|
252 |
|
253 // input the old time |
|
254 ReadInt64L( timeData, aInput ); |
|
255 iOldTime = timeData; |
|
256 |
|
257 // input the new time |
|
258 ReadInt64L( timeData, aInput ); |
|
259 iNewTime = timeData; |
|
260 |
|
261 // input the old time zone |
|
262 iOldTimeZone = aInput.ReadInt32L(); |
|
263 |
|
264 // input the new time zone |
|
265 iNewTimeZone = aInput.ReadInt32L(); |
|
266 |
|
267 // input the old security level |
|
268 securityLevel = aInput.ReadInt8L(); |
|
269 iOldSecurityLevel = static_cast<DRMClock::ESecurityLevel>(securityLevel); |
|
270 |
|
271 // input the new security level |
|
272 securityLevel = aInput.ReadInt8L(); |
|
273 iNewSecurityLevel = static_cast<DRMClock::ESecurityLevel>(securityLevel); |
|
274 |
|
275 }; |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // CDRMEventTimeChange::WriteInt64L |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 void CDRMEventTimeChange::WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const |
|
282 { |
|
283 TPtr8 output(NULL,0,0); |
|
284 |
|
285 output.Set( reinterpret_cast<TUint8*>(const_cast<TInt64*>(&aWrite)), |
|
286 sizeof(TInt64), sizeof(TInt64) ); |
|
287 |
|
288 aStream.WriteL( output, sizeof(TInt64) ); |
|
289 }; |
|
290 |
|
291 // ----------------------------------------------------------------------------- |
|
292 // CDRMEventTimeChange::ReadInt64L |
|
293 // ----------------------------------------------------------------------------- |
|
294 // |
|
295 void CDRMEventTimeChange::ReadInt64L( TInt64& aRead, RReadStream& aStream ) |
|
296 { |
|
297 TPtr8 input(NULL,0,0); |
|
298 |
|
299 input.Set( reinterpret_cast<TUint8*>(&aRead), 0, sizeof(TInt64) ); |
|
300 |
|
301 aStream.ReadL( input, sizeof(TInt64) ); |
|
302 }; |
|
303 |
|
304 // End of File |