|
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "logclientop.h" |
|
17 |
|
18 // User includes |
|
19 #include "logservcli.h" |
|
20 |
|
21 |
|
22 CLogClientOp::CLogClientOp(RLogSession& aSession, CLogPackage& aPackage, TLogOperationType aType, TInt aPriority) |
|
23 : CActive(aPriority), iPackage(aPackage), iSession(aSession) |
|
24 // |
|
25 // Base client side operation |
|
26 // |
|
27 { |
|
28 iData().iOperationType = aType; |
|
29 CActiveScheduler::Add(this); |
|
30 } |
|
31 |
|
32 CLogClientOp::~CLogClientOp() |
|
33 { |
|
34 Cancel(); |
|
35 } |
|
36 |
|
37 void CLogClientOp::Start(TRequestStatus& aObserver) |
|
38 // |
|
39 // Start the ball rolling - InitiateRequestToServerL called in RunL so it can leave |
|
40 // |
|
41 { |
|
42 iObserver = &aObserver; |
|
43 aObserver = KRequestPending; |
|
44 |
|
45 // Just complete ourselves |
|
46 TRequestStatus* status = &iStatus; |
|
47 User::RequestComplete(status, KErrNone); |
|
48 SetActive(); |
|
49 } |
|
50 |
|
51 TInt CLogClientOp::Start() |
|
52 // |
|
53 // Synchronous way of running operations |
|
54 // |
|
55 { |
|
56 TInt result = KErrNone; |
|
57 TRAP(result, result = DoStartL()); |
|
58 iData().iOperationId = KLogNullOperationId; |
|
59 return result; |
|
60 } |
|
61 |
|
62 TInt CLogClientOp::DoStartL() |
|
63 { |
|
64 iData().iOperationId = iSession.AllocateIdOperation(); |
|
65 InitiateRequestToServerL(); |
|
66 User::WaitForRequest(iStatus); |
|
67 //We have an asynchronous request completed synchronously. |
|
68 //We have to do some iStatus cleanups. |
|
69 TRequestStatus status;//New TRequestStatus local variable. The default constructor will set iFlags data memebr to 0. |
|
70 status = iStatus.Int();//Only iStatus data member getzs initialized. |
|
71 iStatus = status;//Return back the same iStatus value but with iFlags data memeber cleared. |
|
72 User::LeaveIfError(iStatus.Int()); |
|
73 |
|
74 TInt result = iStatus.Int(); |
|
75 CompleteL(result); |
|
76 iData().iOperationId = KLogNullOperationId; |
|
77 return result; |
|
78 } |
|
79 |
|
80 void CLogClientOp::RunL() |
|
81 { |
|
82 LOGTEXT2("CLogClientOp::RunL(%d)", iStatus.Int()); |
|
83 |
|
84 User::LeaveIfError(iStatus.Int()); |
|
85 |
|
86 // Set ourselves up - make the actual request? |
|
87 if (iData().iOperationId == KLogNullOperationId) |
|
88 { |
|
89 // Get the id of the operation |
|
90 iData().iOperationId = iSession.AllocateIdOperation(); |
|
91 |
|
92 InitiateRequestToServerL(); |
|
93 SetActive(); |
|
94 } |
|
95 else |
|
96 { |
|
97 // Finish off the request |
|
98 iData().iOperationId = KLogNullOperationId; |
|
99 TInt result = iStatus.Int(); |
|
100 CompleteL(result); |
|
101 User::RequestComplete(iObserver, result); |
|
102 } |
|
103 |
|
104 LOGTEXT("CLogClientOp::RunL() - end"); |
|
105 } |
|
106 |
|
107 void CLogClientOp::DoCancel() |
|
108 // |
|
109 // Cancel the request to the server if we initiated one |
|
110 // |
|
111 { |
|
112 LOGTEXT2("CLogClientOp::DoCancel() - OperationId: %d", iData().iOperationId); |
|
113 |
|
114 // Cancel this operation if we have an id |
|
115 if (iData().iOperationId > 0) |
|
116 { |
|
117 iSession.Send(ELogOperationCancel, TIpcArgs(&iData)); |
|
118 // |
|
119 iData().iOperationId = KLogNullOperationId; |
|
120 } |
|
121 |
|
122 User::RequestComplete(iObserver, KErrCancel); |
|
123 LOGTEXT("CLogClientOp::DoCancel() - end"); |
|
124 } |
|
125 |
|
126 // Just complete the observer on error |
|
127 TInt CLogClientOp::RunError(TInt aError) |
|
128 { |
|
129 iData().iOperationId = KLogNullOperationId; |
|
130 User::RequestComplete(iObserver, aError); |
|
131 return KErrNone; |
|
132 } |
|
133 |
|
134 void CLogClientOp::CompleteL(TInt& /*aCompletionCode*/) |
|
135 // |
|
136 // By default operations don't do anything after completion |
|
137 // |
|
138 { |
|
139 } |
|
140 |
|
141 void CLogClientOp::FetchResultFromServerL(TInt aResult) |
|
142 { |
|
143 iPackage.ResizeL(aResult); |
|
144 TPtr8 ptr(iPackage.Ptr()); |
|
145 |
|
146 User::LeaveIfError(iSession.Send(ELogOperationGetResult, TIpcArgs(&iData,&ptr,ptr.Length()))); |
|
147 } |
|
148 |
|
149 /** |
|
150 * Initialise the data slot values |
|
151 */ |
|
152 void CLogClientOp::SetDataSlot1(TInt aValue) |
|
153 { |
|
154 iData().iDataSlot1 = aValue; |
|
155 } |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 CLogAddEventClientOp::CLogAddEventClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority) |
|
164 : CLogClientOp(aSession, aPackage, ELogOperationEventAdd, aPriority) |
|
165 { |
|
166 } |
|
167 |
|
168 void CLogAddEventClientOp::Start(CLogEvent& aEvent, TRequestStatus& aObserver) |
|
169 { |
|
170 iEvent = &aEvent; |
|
171 CLogClientOp::Start(aObserver); |
|
172 } |
|
173 |
|
174 void CLogAddEventClientOp::InitiateRequestToServerL() |
|
175 { |
|
176 iPackage.SetLogEventL(*iEvent); |
|
177 iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, &iPackage.Ptr()), iStatus); |
|
178 } |
|
179 |
|
180 void CLogAddEventClientOp::CompleteL(TInt& aResult) |
|
181 { |
|
182 FetchResultFromServerL(aResult); |
|
183 iPackage.GetLogEventL(*iEvent); |
|
184 } |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 CLogChangeEventClientOp::CLogChangeEventClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority) |
|
193 : CLogClientOp(aSession, aPackage, ELogOperationEventChange, aPriority) |
|
194 { |
|
195 } |
|
196 |
|
197 void CLogChangeEventClientOp::Start(const CLogEvent& aEvent, TRequestStatus& aObserver) |
|
198 { |
|
199 iEvent = &aEvent; |
|
200 CLogClientOp::Start(aObserver); |
|
201 } |
|
202 |
|
203 void CLogChangeEventClientOp::InitiateRequestToServerL() |
|
204 { |
|
205 iPackage.SetLogEventL(*iEvent); |
|
206 iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, &iPackage.Ptr()), iStatus); |
|
207 } |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 CLogGetEventClientOp::CLogGetEventClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority) |
|
215 : CLogClientOp(aSession, aPackage, ELogOperationEventGet, aPriority) |
|
216 { |
|
217 } |
|
218 |
|
219 void CLogGetEventClientOp::Start(CLogEvent& aEvent, TRequestStatus& aObserver) |
|
220 { |
|
221 iEvent = &aEvent; |
|
222 CLogClientOp::Start(aObserver); |
|
223 } |
|
224 |
|
225 void CLogGetEventClientOp::InitiateRequestToServerL() |
|
226 { |
|
227 iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, iEvent->Id()), iStatus); |
|
228 } |
|
229 |
|
230 void CLogGetEventClientOp::CompleteL(TInt& aResult) |
|
231 { |
|
232 FetchResultFromServerL(aResult); |
|
233 iPackage.GetLogEventL(*iEvent); |
|
234 } |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 CLogDeleteEventClientOp::CLogDeleteEventClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority) |
|
243 : CLogClientOp(aSession, aPackage, ELogOperationEventDelete, aPriority) |
|
244 { |
|
245 } |
|
246 |
|
247 void CLogDeleteEventClientOp::Start(TLogId aId, TRequestStatus& aObserver) |
|
248 { |
|
249 iId = aId; |
|
250 CLogClientOp::Start(aObserver); |
|
251 } |
|
252 |
|
253 void CLogDeleteEventClientOp::InitiateRequestToServerL() |
|
254 { |
|
255 iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, iId), iStatus); |
|
256 } |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 CLogAddTypeClientOp::CLogAddTypeClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority) |
|
267 : CLogClientOp(aSession, aPackage, ELogOperationTypeAdd, aPriority) |
|
268 { |
|
269 } |
|
270 |
|
271 void CLogAddTypeClientOp::Start(const CLogEventType& aEventType, TRequestStatus& aObserver) |
|
272 { |
|
273 iEventType = &aEventType; |
|
274 CLogClientOp::Start(aObserver); |
|
275 } |
|
276 |
|
277 void CLogAddTypeClientOp::InitiateRequestToServerL() |
|
278 { |
|
279 iPackage.SetLogEventTypeL(*iEventType); |
|
280 iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, &iPackage.Ptr()), iStatus); |
|
281 } |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 CLogChangeTypeClientOp::CLogChangeTypeClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority) |
|
291 : CLogClientOp(aSession, aPackage, ELogOperationTypeChange, aPriority) |
|
292 { |
|
293 } |
|
294 |
|
295 void CLogChangeTypeClientOp::Start(const CLogEventType& aEventType, TRequestStatus& aObserver) |
|
296 { |
|
297 iEventType = &aEventType; |
|
298 CLogClientOp::Start(aObserver); |
|
299 } |
|
300 |
|
301 void CLogChangeTypeClientOp::InitiateRequestToServerL() |
|
302 { |
|
303 iPackage.SetLogEventTypeL(*iEventType); |
|
304 iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, &iPackage.Ptr()), iStatus); |
|
305 } |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 CLogGetTypeClientOp::CLogGetTypeClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority) |
|
314 : CLogClientOp(aSession, aPackage, ELogOperationTypeGet, aPriority) |
|
315 { |
|
316 } |
|
317 |
|
318 void CLogGetTypeClientOp::Start(CLogEventType& aEventType, TRequestStatus& aObserver) |
|
319 { |
|
320 iEventType = &aEventType; |
|
321 CLogClientOp::Start(aObserver); |
|
322 } |
|
323 |
|
324 void CLogGetTypeClientOp::InitiateRequestToServerL() |
|
325 { |
|
326 TIpcArgs args(&iData, iEventType->Uid().iUid); |
|
327 iSession.Send(ELogOperationInitiate, args, iStatus); |
|
328 } |
|
329 |
|
330 void CLogGetTypeClientOp::CompleteL(TInt& aResult) |
|
331 { |
|
332 FetchResultFromServerL(aResult); |
|
333 iPackage.GetLogEventTypeL(*iEventType); |
|
334 } |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 CLogDeleteTypeClientOp::CLogDeleteTypeClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority) |
|
344 : CLogClientOp(aSession, aPackage, ELogOperationTypeDelete, aPriority) |
|
345 { |
|
346 } |
|
347 |
|
348 void CLogDeleteTypeClientOp::Start(TUid aUid, TRequestStatus& aObserver) |
|
349 { |
|
350 iUid = aUid; |
|
351 CLogClientOp::Start(aObserver); |
|
352 } |
|
353 |
|
354 void CLogDeleteTypeClientOp::InitiateRequestToServerL() |
|
355 { |
|
356 TIpcArgs args(&iData, iUid.iUid); |
|
357 iSession.Send(ELogOperationInitiate, args, iStatus); |
|
358 } |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 CLogGetConfigClientOp::CLogGetConfigClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority) |
|
368 : CLogClientOp(aSession, aPackage, ELogOperationConfigGet, aPriority) |
|
369 { |
|
370 } |
|
371 |
|
372 void CLogGetConfigClientOp::Start(TLogConfig& aConfig, TRequestStatus& aObserver) |
|
373 { |
|
374 iConfig = &aConfig; |
|
375 CLogClientOp::Start(aObserver); |
|
376 } |
|
377 |
|
378 void CLogGetConfigClientOp::InitiateRequestToServerL() |
|
379 { |
|
380 iSession.Send(ELogOperationInitiate, TIpcArgs(&iData), iStatus); |
|
381 } |
|
382 |
|
383 void CLogGetConfigClientOp::CompleteL(TInt& aResult) |
|
384 { |
|
385 FetchResultFromServerL(aResult); |
|
386 iPackage.GetLogConfigL(*iConfig); |
|
387 } |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 CLogChangeConfigClientOp::CLogChangeConfigClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority) |
|
398 : CLogClientOp(aSession, aPackage, ELogOperationConfigChange, aPriority) |
|
399 { |
|
400 } |
|
401 |
|
402 void CLogChangeConfigClientOp::Start(const TLogConfig& aConfig, TRequestStatus& aObserver) |
|
403 { |
|
404 iConfig = &aConfig; |
|
405 CLogClientOp::Start(aObserver); |
|
406 } |
|
407 |
|
408 void CLogChangeConfigClientOp::InitiateRequestToServerL() |
|
409 { |
|
410 iPackage.SetLogConfigL(*iConfig); |
|
411 iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, &iPackage.Ptr()), iStatus); |
|
412 } |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 CLogClearLogClientOp::CLogClearLogClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority) : |
|
423 CLogClientOp(aSession, aPackage, ELogOperationClearLog, aPriority) |
|
424 { |
|
425 } |
|
426 |
|
427 void CLogClearLogClientOp::Start(const TTime& aDate, TRequestStatus& aObserver |
|
428 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM |
|
429 , TSimId aSimId |
|
430 #endif |
|
431 ) |
|
432 { |
|
433 iDate = aDate; // UTC |
|
434 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM |
|
435 iSimId = aSimId; |
|
436 #endif |
|
437 CLogClientOp::Start(aObserver); |
|
438 } |
|
439 |
|
440 void CLogClearLogClientOp::InitiateRequestToServerL() |
|
441 { |
|
442 const TInt64 dateVal(iDate.Int64()); |
|
443 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM |
|
444 TIpcArgs args(&iData, I64LOW(dateVal), I64HIGH(dateVal), iSimId); |
|
445 #else |
|
446 TIpcArgs args(&iData, I64LOW(dateVal), I64HIGH(dateVal)); |
|
447 #endif |
|
448 iSession.Send(ELogOperationInitiate, args, iStatus); |
|
449 } |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 CLogClearRecentClientOp::CLogClearRecentClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority) |
|
459 : CLogClientOp(aSession, aPackage, ELogOperationClearRecent, aPriority) |
|
460 { |
|
461 } |
|
462 |
|
463 void CLogClearRecentClientOp::Start(TLogRecentList aList, TRequestStatus& aObserver |
|
464 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM |
|
465 , TSimId aSimId |
|
466 #endif |
|
467 ) |
|
468 { |
|
469 iList = aList; |
|
470 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM |
|
471 iSimId = aSimId; |
|
472 #endif |
|
473 CLogClientOp::Start(aObserver); |
|
474 } |
|
475 |
|
476 void CLogClearRecentClientOp::InitiateRequestToServerL() |
|
477 { |
|
478 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM |
|
479 iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, iList, iSimId), iStatus); |
|
480 #else |
|
481 iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, iList), iStatus); |
|
482 #endif |
|
483 } |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 CLogMaintainClientOp::CLogMaintainClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority) |
|
492 : CLogClientOp(aSession, aPackage, ELogOperationMaintain, aPriority) |
|
493 { |
|
494 } |
|
495 |
|
496 void CLogMaintainClientOp::InitiateRequestToServerL() |
|
497 { |
|
498 iSession.Send(ELogOperationInitiate, TIpcArgs(&iData), iStatus); |
|
499 } |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 CLogViewSetupClientOp::CLogViewSetupClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority) |
|
509 : CLogClientOp(aSession, aPackage, ELogOperationViewSetup, aPriority) |
|
510 { |
|
511 } |
|
512 |
|
513 TInt CLogViewSetupClientOp::Start(TLogViewId aViewId, const CLogFilterList& aFilterList, TInt aParam, TLogFilterConstructionType aFilterConstructionType) |
|
514 { |
|
515 // Synchronous! |
|
516 iViewId = aViewId; |
|
517 iFilterList = &aFilterList; |
|
518 iParam = aParam; |
|
519 SetDataSlot1(aFilterConstructionType); |
|
520 // |
|
521 return CLogClientOp::Start(); |
|
522 } |
|
523 |
|
524 void CLogViewSetupClientOp::InitiateRequestToServerL() |
|
525 { |
|
526 TIpcArgs args (&iData, iViewId, &iPackage.Ptr(), iParam); |
|
527 iSession.Send(ELogViewOperationInitiate, args, iStatus); |
|
528 } |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 CLogViewRemoveEventClientOp::CLogViewRemoveEventClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority) |
|
537 : CLogClientOp(aSession, aPackage, ELogOperationViewRemoveEvent, aPriority) |
|
538 { |
|
539 } |
|
540 |
|
541 TInt CLogViewRemoveEventClientOp::Start(TLogViewId aViewId, TLogId aId) |
|
542 { |
|
543 // Synchronous! |
|
544 iViewId = aViewId; |
|
545 iId = aId; |
|
546 return CLogClientOp::Start(); |
|
547 } |
|
548 |
|
549 void CLogViewRemoveEventClientOp::InitiateRequestToServerL() |
|
550 { |
|
551 TIpcArgs args(&iData, iViewId, iId, 0); |
|
552 iSession.Send(ELogViewOperationInitiate, args, iStatus); |
|
553 } |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |