19 #include "loggingasyncservice.h" |
19 #include "loggingasyncservice.h" |
20 #include "loggingevent.h" |
20 #include "loggingevent.h" |
21 #include "loggingfilter.h" |
21 #include "loggingfilter.h" |
22 #include "logiter.h" |
22 #include "logiter.h" |
23 |
23 |
|
24 // --------------------------------------------------------------------------- |
|
25 // Two-phased constructor. |
|
26 // --------------------------------------------------------------------------- |
|
27 // |
|
28 CAsyncWaiter* CAsyncWaiter::NewL(TInt aPriority) |
|
29 { |
|
30 CAsyncWaiter* self = new(ELeave) CAsyncWaiter(aPriority); |
|
31 return self; |
|
32 } |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // Two-phased constructor. |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 CAsyncWaiter* CAsyncWaiter::NewLC(TInt aPriority) |
|
39 { |
|
40 CAsyncWaiter* self = new(ELeave) CAsyncWaiter(aPriority); |
|
41 CleanupStack::PushL(self); |
|
42 return self; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // Two-phased constructor. |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CAsyncWaiter::CAsyncWaiter(TInt aPriority) : CActive(aPriority) |
|
50 { |
|
51 CActiveScheduler::Add(this); |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // Destructor. |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 CAsyncWaiter::~CAsyncWaiter() |
|
59 { |
|
60 Cancel(); |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // Starts the active scheduler. |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 void CAsyncWaiter::StartAndWait() |
|
68 { |
|
69 iStatus = KRequestPending; |
|
70 SetActive(); |
|
71 iWait.Start(); |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // Returns the error |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 TInt CAsyncWaiter::Result() const |
|
79 { |
|
80 return iError; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // Inherited from CActive class |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void CAsyncWaiter::RunL() |
|
88 { |
|
89 iError = iStatus.Int(); |
|
90 iWait.AsyncStop(); |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // Inherited from CActive class |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 void CAsyncWaiter::DoCancel() |
|
98 { |
|
99 iError = KErrCancel; |
|
100 if( iStatus == KRequestPending ) |
|
101 { |
|
102 TRequestStatus* s=&iStatus; |
|
103 User::RequestComplete( s, KErrCancel ); |
|
104 } |
|
105 |
|
106 iWait.AsyncStop(); |
|
107 } |
|
108 |
24 /** |
109 /** |
25 * Default Constructor Method |
110 * Default Constructor Method |
26 */ |
111 */ |
27 CLogAsyncService :: CLogAsyncService(): CActive(EPriorityStandard) |
112 CLogAsyncService :: CLogAsyncService(): CActive(EPriorityStandard) |
28 { |
113 { |
68 User::LeaveIfError(iFs.Connect()); |
155 User::LeaveIfError(iFs.Connect()); |
69 iLogClient = CLogClient::NewL(iFs); |
156 iLogClient = CLogClient::NewL(iFs); |
70 iCallback = aCallback; |
157 iCallback = aCallback; |
71 iIter = NULL ; |
158 iIter = NULL ; |
72 iTask = ESleep; |
159 iTask = ESleep; |
|
160 iLogViewEvent = CLogViewEvent::NewL(*iLogClient); |
|
161 iFilter = CLogFilter::NewL(); |
73 DoInitialiseL() ; |
162 DoInitialiseL() ; |
74 } |
163 } |
75 |
164 |
76 /** |
165 /** |
77 * DoInitalise, Initalises the Members of AsyncService Class |
166 * DoInitalise, Initalises the Members of AsyncService Class |
154 iTask = ESleep; |
243 iTask = ESleep; |
155 break ; |
244 break ; |
156 } |
245 } |
157 case ENotification: |
246 case ENotification: |
158 { |
247 { |
|
248 CAsyncWaiter* waiter = CAsyncWaiter::NewL(); |
|
249 CleanupStack::PushL(waiter); |
|
250 TBool t = iLogViewEvent->SetFilterL(*iFilter,waiter->iStatus); |
|
251 waiter->StartAndWait(); |
|
252 iLogViewEvent->FirstL(waiter->iStatus); |
|
253 waiter->StartAndWait(); |
|
254 CleanupStack::PopAndDestroy(waiter); |
159 NotifyUpdates( iTransId, iInterval ); |
255 NotifyUpdates( iTransId, iInterval ); |
160 iCallback->HandleNotifyL( iTransId, KErrNone , NULL ) ; |
256 CLogsEvent* resultNotification = CLogsEvent::NewL(); |
|
257 resultNotification->SetEvent(iLogViewEvent->Event()); |
|
258 iCallback->HandleReqeustL( iTransId, KErrNone , resultNotification ) ; |
161 break; |
259 break; |
162 } |
260 } |
163 |
261 |
164 case EErrorEvent: |
262 case EErrorEvent: |
165 { |
263 { |