First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "LogServOperations.h"
17 #include "logservpanic.h"
18 #include "LogServView.h"
19 #include "LogServTaskInterface.h"
21 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
22 ////////////////////////////// CLogServOpEventAdd ////////////////////////////////////////////////////////////
23 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
26 // Create an operation to add an event to the log
28 CLogServOpEventAdd::CLogServOpEventAdd(MLogServTaskInterface& aTaskInterface,
29 MLogServOperationManager& aOperationManager,
30 const RMessage2& aMessage,
31 CLogPackage& aPackage,
32 const TLogClientServerData& aCliServData,
33 TLogServSessionId aSessionId):
34 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId)
38 CLogServOpEventAdd::~CLogServOpEventAdd()
44 // Get stuff from the client and start doing the work
46 void CLogServOpEventAdd::StartL(TRequestStatus& aStatus)
48 // Read stuff from the client
49 const TInt length = Message().GetDesLengthL(1);
51 Package().ResizeL(length);
52 TPtr8 pPackage(Package().Ptr());
53 Message().ReadL(1,pPackage);
55 // Decode the parameters we've read from the client
56 iEvent = CLogEvent::NewL();
57 Package().GetLogEventL(*iEvent);
60 TaskInterface().TaskEventAddL(aStatus, *iEvent, Message());
64 // Complete the client request - we need to wait for the client to request a response
66 CLogServOperationBase::TCompletionStatus CLogServOpEventAdd::CompleteProcessingL(TInt /*aFinalCompletionCode*/)
68 Package().SetLogEventL(*iEvent);
69 const TInt size = Package().Ptr().Size();
72 return CLogServOperationBase::EOperationCompleteWaitForClient;
76 // Write stuff back to the client
78 void CLogServOpEventAdd::WriteL(const RMessage2& aMessage)
80 aMessage.WriteL(1, Package().Ptr());
83 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
84 ////////////////////////////// CLogServOpEventChange /////////////////////////////////////////////////////////
85 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
88 // Create an operation to change an event in the log
90 CLogServOpEventChange::CLogServOpEventChange(MLogServTaskInterface& aTaskInterface,
91 MLogServOperationManager& aOperationManager,
92 const RMessage2& aMessage,
93 CLogPackage& aPackage,
94 const TLogClientServerData& aCliServData,
95 TLogServSessionId aSessionId) :
96 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId)
100 CLogServOpEventChange::~CLogServOpEventChange()
106 // Get stuff from the client and start doing the work
108 void CLogServOpEventChange::StartL(TRequestStatus& aStatus)
110 // Read stuff from the client
111 Package().ResizeL(Message().GetDesLengthL(1));
112 Message().ReadL(1, Package().Ptr());
114 // Decode the parameters we've read from the client
115 iEvent = CLogEvent::NewL();
116 Package().GetLogEventL(*iEvent);
118 // Do the actual work
119 TaskInterface().TaskEventChangeL(aStatus, *iEvent, Message());
122 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
123 ////////////////////////////// CLogServOpEventGet ////////////////////////////////////////////////////////////
124 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
127 // Create an operation to get an event in the log
129 CLogServOpEventGet::CLogServOpEventGet(MLogServTaskInterface& aTaskInterface,
130 MLogServOperationManager& aOperationManager,
131 const RMessage2& aMessage,
132 CLogPackage& aPackage,
133 const TLogClientServerData& aCliServData,
134 TLogServSessionId aSessionId) :
135 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId)
139 CLogServOpEventGet::~CLogServOpEventGet()
145 // Get stuff from the client and start doing the work
147 void CLogServOpEventGet::StartL(TRequestStatus& aStatus)
150 iEvent = CLogEvent::NewL();
151 iEvent->SetId((TLogId)Message().Ptr1());
153 // Do the actual work
154 TaskInterface().TaskEventGetL(aStatus, *iEvent, Message());
158 // Complete the client request - we need to wait for the client to request a response
160 CLogServOperationBase::TCompletionStatus CLogServOpEventGet::CompleteProcessingL(TInt /*aFinalCompletionCode*/)
162 Package().SetLogEventL(*iEvent);
163 const TInt size = Package().Ptr().Size();
166 return CLogServOperationBase::EOperationCompleteWaitForClient;
170 // Write stuff back to the client
172 void CLogServOpEventGet::WriteL(const RMessage2& aMessage)
174 aMessage.WriteL(1, Package().Ptr());
177 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
178 ////////////////////////////// CLogServOpEventDelete /////////////////////////////////////////////////////////
179 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
182 // Create an operation to delete an event from the log
184 CLogServOpEventDelete::CLogServOpEventDelete(MLogServTaskInterface& aTaskInterface,
185 MLogServOperationManager& aOperationManager,
186 const RMessage2& aMessage,
187 CLogPackage& aPackage,
188 const TLogClientServerData& aCliServData,
189 TLogServSessionId aSessionId) :
190 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId)
194 void CLogServOpEventDelete::StartL(TRequestStatus& aStatus)
196 // Do the actual work
197 const TLogId eventId = static_cast<TLogId>(Message().Int1());
198 TaskInterface().TaskEventDeleteL(aStatus, eventId, Message());
201 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
202 ////////////////////////////// CLogServOpTypeAdd /////////////////////////////////////////////////////////////
203 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
206 // Add a new event type to the database
208 CLogServOpTypeAdd::CLogServOpTypeAdd(MLogServTaskInterface& aTaskInterface,
209 MLogServOperationManager& aOperationManager,
210 const RMessage2& aMessage,
211 CLogPackage& aPackage,
212 const TLogClientServerData& aCliServData,
213 TLogServSessionId aSessionId) :
214 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId)
218 CLogServOpTypeAdd::~CLogServOpTypeAdd()
224 // Get stuff from the client and start doing the work
226 void CLogServOpTypeAdd::StartL(TRequestStatus& aStatus)
228 // Read stuff from the client
229 Package().ResizeL(Message().GetDesLengthL(1));
230 Message().ReadL(1, Package().Ptr());
233 // Decode the parameters we've read from the client
234 iEventType = CLogEventType::NewL();
235 Package().GetLogEventTypeL(*iEventType);
237 // Do the actual work
238 TaskInterface().TaskEventTypeAddL(aStatus, *iEventType);
241 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
242 ////////////////////////////// CLogServOpTypeGet /////////////////////////////////////////////////////////////
243 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
246 // Get event type details from the database
248 CLogServOpTypeGet::CLogServOpTypeGet(MLogServTaskInterface& aTaskInterface,
249 MLogServOperationManager& aOperationManager,
250 const RMessage2& aMessage,
251 CLogPackage& aPackage,
252 const TLogClientServerData& aCliServData,
253 TLogServSessionId aSessionId) :
254 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId)
259 // Get stuff from the client and start doing the work
261 void CLogServOpTypeGet::StartL(TRequestStatus& aStatus)
263 // Do the actual work
264 const TUid eventTypeUid = { Message().Int1() };
265 const CLogEventType *eventType;
266 TaskInterface().TaskEventTypeGetL(aStatus, eventType, eventTypeUid);
267 iEventType = const_cast<CLogEventType*>(eventType);
271 // Complete the client request - we need to wait for the client to request a response
273 CLogServOperationBase::TCompletionStatus CLogServOpTypeGet::CompleteProcessingL(TInt /*aFinalCompletionCode*/)
275 Package().SetLogEventTypeL(*iEventType);
276 const TInt size = Package().Ptr().Size();
279 return CLogServOperationBase::EOperationCompleteWaitForClient;
283 // Write stuff back to the client
285 void CLogServOpTypeGet::WriteL(const RMessage2& aMessage)
287 aMessage.WriteL(1, Package().Ptr());
290 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
291 ////////////////////////////// CLogServOpTypeChange //////////////////////////////////////////////////////////
292 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
295 // Change event type details in the database
297 CLogServOpTypeChange::CLogServOpTypeChange(MLogServTaskInterface& aTaskInterface,
298 MLogServOperationManager& aOperationManager,
299 const RMessage2& aMessage,
300 CLogPackage& aPackage,
301 const TLogClientServerData& aCliServData,
302 TLogServSessionId aSessionId) :
303 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId)
307 CLogServOpTypeChange::~CLogServOpTypeChange()
313 // Get stuff from the client and start doing the work
315 void CLogServOpTypeChange::StartL(TRequestStatus& aStatus)
317 // Read stuff from the client
318 Package().ResizeL(Message().GetDesLengthL(1));
319 Message().ReadL(1, Package().Ptr());
321 // Decode the parameters we've read from the client
322 iEventType = CLogEventType::NewL();
323 Package().GetLogEventTypeL(*iEventType);
325 // Do the actual work
326 TaskInterface().TaskEventTypeChangeL(aStatus, *iEventType);
329 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
330 ////////////////////////////// CLogServOpTypeDelete //////////////////////////////////////////////////////////
331 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
334 // Delete event type details from the database
336 CLogServOpTypeDelete::CLogServOpTypeDelete(MLogServTaskInterface& aTaskInterface,
337 MLogServOperationManager& aOperationManager,
338 const RMessage2& aMessage,
339 CLogPackage& aPackage,
340 const TLogClientServerData& aCliServData,
341 TLogServSessionId aSessionId) :
342 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId)
347 // Get stuff from the client and start doing the work
349 void CLogServOpTypeDelete::StartL(TRequestStatus& aStatus)
351 // Do the actual work
352 const TUid eventTypeUid = { Message().Int1() };
353 TaskInterface().TaskEventTypeDeleteL(aStatus, eventTypeUid);
356 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
357 ////////////////////////////// CLogServOpConfigGet ///////////////////////////////////////////////////////////
358 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
361 // Get database config
363 CLogServOpConfigGet::CLogServOpConfigGet(MLogServTaskInterface& aTaskInterface,
364 MLogServOperationManager& aOperationManager,
365 const RMessage2& aMessage,
366 CLogPackage& aPackage,
367 const TLogClientServerData& aCliServData,
368 TLogServSessionId aSessionId) :
369 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId)
374 // Start doing the work
376 void CLogServOpConfigGet::StartL(TRequestStatus& aStatus)
378 // Do the actual work
379 TaskInterface().TaskConfigGetL(aStatus, iConfig);
383 // Complete the client request - we need to wait for the client to request a response
385 CLogServOperationBase::TCompletionStatus CLogServOpConfigGet::CompleteProcessingL(TInt /*aFinalCompletionCode*/)
387 Package().SetLogConfigL(iConfig);
388 const TInt size = Package().Ptr().Size();
391 return CLogServOperationBase::EOperationCompleteWaitForClient;
394 // Write stuff back to the client
395 void CLogServOpConfigGet::WriteL(const RMessage2& aMessage)
397 aMessage.WriteL(1, Package().Ptr());
400 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
401 ////////////////////////////// CLogServOpConfigChange ////////////////////////////////////////////////////////
402 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
405 // Change database config
407 CLogServOpConfigChange::CLogServOpConfigChange(MLogServTaskInterface& aTaskInterface,
408 MLogServOperationManager& aOperationManager,
409 const RMessage2& aMessage,
410 CLogPackage& aPackage,
411 const TLogClientServerData& aCliServData,
412 TLogServSessionId aSessionId) :
413 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId)
418 // Decode parameters from a client and start doing the work
420 void CLogServOpConfigChange::StartL(TRequestStatus& aStatus)
422 // Read stuff from the client
423 Package().ResizeL(Message().GetDesLengthL(1));
424 Message().ReadL(1, Package().Ptr());
426 // Decode the parameters we've read from the client
427 Package().GetLogConfigL(iConfig);
429 // Do the actual work
430 TaskInterface().TaskConfigChangeL(aStatus, iConfig);
433 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
434 ////////////////////////////// CLogServOpClearLog ////////////////////////////////////////////////////////////
435 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
438 // Clear the event log
440 CLogServOpClearLog::CLogServOpClearLog(MLogServTaskInterface& aTaskInterface,
441 MLogServOperationManager& aOperationManager,
442 const RMessage2& aMessage,
443 CLogPackage& aPackage,
444 const TLogClientServerData& aCliServData,
445 TLogServSessionId aSessionId) :
446 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId)
451 // Decode parameters from the client and start doing the work
453 void CLogServOpClearLog::StartL(TRequestStatus& aStatus)
455 // Do the actual work
456 TUint p2 = (TUint)Message().Ptr2();
457 TUint p1 = (TUint)Message().Ptr1();
458 const TTime time(MAKE_TINT64(p2, p1));
459 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
460 TSimId simId = (TSimId)Message().Int3();
461 TaskInterface().TaskClearLogL(aStatus, time, simId);
463 TaskInterface().TaskClearLogL(aStatus, time);
467 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
468 ////////////////////////////// CLogServOpClearRecent /////////////////////////////////////////////////////////
469 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
472 // Clear a recent list
474 CLogServOpClearRecent::CLogServOpClearRecent(MLogServTaskInterface& aTaskInterface,
475 MLogServOperationManager& aOperationManager,
476 const RMessage2& aMessage,
477 CLogPackage& aPackage,
478 const TLogClientServerData& aCliServData,
479 TLogServSessionId aSessionId) :
480 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId)
485 // Decode parameters from the client and start doing the work
487 void CLogServOpClearRecent::StartL(TRequestStatus& aStatus)
489 // Do the actual work
490 const TLogRecentList recentList = static_cast<TLogRecentList>(Message().Int1());
491 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
492 TSimId simId = (TSimId)Message().Int2();
493 TaskInterface().TaskClearRecentL(aStatus, recentList, simId);
495 TaskInterface().TaskClearRecentL(aStatus, recentList);
499 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
500 ////////////////////////////// CLogServOpMaintenance /////////////////////////////////////////////////////////
501 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
504 // Kicks the server to perform a maintain on the database.
505 // Always done after an op as necessary
507 CLogServOpMaintenance::CLogServOpMaintenance(MLogServTaskInterface& aTaskInterface,
508 MLogServOperationManager& aOperationManager,
509 const RMessage2& aMessage,
510 CLogPackage& aPackage,
511 const TLogClientServerData& aCliServData,
512 TLogServSessionId aSessionId) :
513 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId)
518 // Just complete ourselves
520 void CLogServOpMaintenance::StartL(TRequestStatus& aStatus)
522 TRequestStatus* status = &aStatus;
523 User::RequestComplete(status, KErrNone);
526 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
527 ////////////////////////////// CLogServOpViewSetup ///////////////////////////////////////////////////////////
528 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
531 CLogServOpViewSetup::CLogServOpViewSetup(MLogServTaskInterface& aTaskInterface,
532 MLogServOperationManager& aOperationManager,
533 const RMessage2& aMessage,
534 CLogPackage& aPackage,
535 CLogServViewBase& aView,
536 const TLogClientServerData& aCliServData,
537 TLogServSessionId aSessionId) :
538 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId),
544 // Decode parameters from the client and start doing the work
546 void CLogServOpViewSetup::StartL(TRequestStatus& aStatus)
548 // Read the filter construction type from the shared data slot
549 const TInt filterConstructionType = ClientServerData().iDataSlot1;
550 if (filterConstructionType == ELogFilterConstructFilterByFilterFieldByField || filterConstructionType == ELogFilterConstructFieldByFieldFilterByFilter)
552 // Do the actual work
553 iView.SetupL(Message(), static_cast<TLogFilterConstructionType>(filterConstructionType));
554 TRequestStatus* status = &aStatus;
555 User::RequestComplete(status, KErrNone);
558 ::PanicClientL(Message(), ELogBadFilterConstructionType);
562 // Complete the client request telling it the number of entries in the view
564 CLogServOperationBase::TCompletionStatus CLogServOpViewSetup::CompleteProcessingL(TInt /*aFinalCompletionCode*/)
566 const TInt viewCount = iView.Count();
569 return CLogServOperationBase::EOperationComplete;
572 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
573 ////////////////////////////// CLogServOpViewEventRemove /////////////////////////////////////////////////////
574 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
577 // Remove an event from a view
579 CLogServOpViewEventRemove::CLogServOpViewEventRemove(MLogServTaskInterface& aTaskInterface,
580 MLogServOperationManager& aOperationManager,
581 const RMessage2& aMessage,
582 CLogPackage& aPackage,
583 CLogServViewBase& aView,
584 const TLogClientServerData& aCliServData,
585 TLogServSessionId aSessionId):
586 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId),
592 // Decode parameters from the client and start doing the work
594 void CLogServOpViewEventRemove::StartL(TRequestStatus& aStatus)
596 iView.RemoveL(Message());
597 TRequestStatus* status = &aStatus;
598 User::RequestComplete(status, KErrNone);
601 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
602 ////////////////////////////// CLogServOpViewClearDuplicates /////////////////////////////////////////////////
603 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
605 CLogServOpViewClearDuplicates::CLogServOpViewClearDuplicates(MLogServTaskInterface& aTaskInterface,
606 MLogServOperationManager& aOperationManager,
607 const RMessage2& aMessage,
608 CLogPackage& aPackage,
609 CLogServViewBase& aView,
610 const TLogClientServerData& aCliServData,
611 TLogServSessionId aSessionId):
612 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId),
617 void CLogServOpViewClearDuplicates::StartL(TRequestStatus& aStatus)
619 iView.ClearDuplicatesL(Message());
620 TRequestStatus* status = &aStatus;
621 User::RequestComplete(status, KErrNone);
624 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
625 ////////////////////////////// CLogServOpViewSetFlags ////////////////////////////////////////////////////////
626 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
628 CLogServOpViewSetFlags::CLogServOpViewSetFlags(MLogServTaskInterface& aTaskInterface,
629 MLogServOperationManager& aOperationManager,
630 const RMessage2& aMessage,
631 CLogPackage& aPackage,
632 CLogServViewBase& aView,
633 const TLogClientServerData& aCliServData,
634 TLogServSessionId aSessionId) :
635 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId),
640 void CLogServOpViewSetFlags::StartL(TRequestStatus& aStatus)
642 iView.SetFlagsL(Message());
643 TRequestStatus* status = &aStatus;
644 User::RequestComplete(status, KErrNone);
647 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
648 ////////////////////////////// CLogServOpViewWindowFetcher ///////////////////////////////////////////////////
649 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
651 CLogServOpViewWindowFetcher::CLogServOpViewWindowFetcher(MLogServTaskInterface& aTaskInterface,
652 MLogServOperationManager& aOperationManager,
653 const RMessage2& aMessage,
654 CLogPackage& aPackage,
655 CLogServViewBase& aView,
656 const TLogClientServerData& aCliServData,
657 TLogServSessionId aSessionId) :
658 CLogServOperationBase(aTaskInterface, aOperationManager, aMessage, aPackage, aCliServData, aSessionId),
663 void CLogServOpViewWindowFetcher::StartL(TRequestStatus& aStatus)
666 TLogTransferWindow window;
667 TPckg<TLogTransferWindow> pWindow(window);
668 Message().ReadL(2, pWindow);
670 // Do the actual work
671 TaskInterface().TaskBuildWindowL(aStatus, iView, window, Message());
675 // Complete the client request - the final completion code tells us, in this instance, how many records were
676 // read from the view.
678 CLogServOperationBase::TCompletionStatus CLogServOpViewWindowFetcher::CompleteProcessingL(TInt aFinalCompletionCode)
680 Complete(aFinalCompletionCode);
682 // Don't need to wait for anything - we've already written back to the client's address space
683 // when we built the window.
684 return CLogServOperationBase::EOperationComplete;