author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 18 Jan 2010 21:02:57 +0200 | |
changeset 27 | 02682e02e51f |
parent 26 | 5d0ec8b709be |
child 35 | 68159986cd41 |
permissions | -rw-r--r-- |
5 | 1 |
/* |
2 |
* Copyright (c) 2007 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 the License "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: Implements logging SAPI async class. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include "loggingasyncservice.h" |
|
20 |
#include "loggingevent.h" |
|
21 |
#include "loggingfilter.h" |
|
22 |
#include "logiter.h" |
|
23 |
||
26
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
24 |
// --------------------------------------------------------------------------- |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
25 |
// Two-phased constructor. |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
26 |
// --------------------------------------------------------------------------- |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
27 |
// |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
28 |
CAsyncWaiter* CAsyncWaiter::NewL(TInt aPriority) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
29 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
30 |
CAsyncWaiter* self = new(ELeave) CAsyncWaiter(aPriority); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
31 |
return self; |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
32 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
33 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
34 |
// --------------------------------------------------------------------------- |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
35 |
// Two-phased constructor. |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
36 |
// --------------------------------------------------------------------------- |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
37 |
// |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
38 |
CAsyncWaiter* CAsyncWaiter::NewLC(TInt aPriority) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
39 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
40 |
CAsyncWaiter* self = new(ELeave) CAsyncWaiter(aPriority); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
41 |
CleanupStack::PushL(self); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
42 |
return self; |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
43 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
44 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
45 |
// --------------------------------------------------------------------------- |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
46 |
// Two-phased constructor. |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
47 |
// --------------------------------------------------------------------------- |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
48 |
// |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
49 |
CAsyncWaiter::CAsyncWaiter(TInt aPriority) : CActive(aPriority) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
50 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
51 |
CActiveScheduler::Add(this); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
52 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
53 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
54 |
// --------------------------------------------------------------------------- |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
55 |
// Destructor. |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
56 |
// --------------------------------------------------------------------------- |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
57 |
// |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
58 |
CAsyncWaiter::~CAsyncWaiter() |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
59 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
60 |
Cancel(); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
61 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
62 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
63 |
// --------------------------------------------------------------------------- |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
64 |
// Starts the active scheduler. |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
65 |
// --------------------------------------------------------------------------- |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
66 |
// |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
67 |
void CAsyncWaiter::StartAndWait() |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
68 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
69 |
iStatus = KRequestPending; |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
70 |
SetActive(); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
71 |
iWait.Start(); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
72 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
73 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
74 |
// --------------------------------------------------------------------------- |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
75 |
// Returns the error |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
76 |
// --------------------------------------------------------------------------- |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
77 |
// |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
78 |
TInt CAsyncWaiter::Result() const |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
79 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
80 |
return iError; |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
81 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
82 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
83 |
// --------------------------------------------------------------------------- |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
84 |
// Inherited from CActive class |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
85 |
// --------------------------------------------------------------------------- |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
86 |
// |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
87 |
void CAsyncWaiter::RunL() |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
88 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
89 |
iError = iStatus.Int(); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
90 |
iWait.AsyncStop(); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
91 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
92 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
93 |
// --------------------------------------------------------------------------- |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
94 |
// Inherited from CActive class |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
95 |
// --------------------------------------------------------------------------- |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
96 |
// |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
97 |
void CAsyncWaiter::DoCancel() |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
98 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
99 |
iError = KErrCancel; |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
100 |
if( iStatus == KRequestPending ) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
101 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
102 |
TRequestStatus* s=&iStatus; |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
103 |
User::RequestComplete( s, KErrCancel ); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
104 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
105 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
106 |
iWait.AsyncStop(); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
107 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
108 |
|
5 | 109 |
/** |
110 |
* Default Constructor Method |
|
111 |
*/ |
|
112 |
CLogAsyncService :: CLogAsyncService(): CActive(EPriorityStandard) |
|
113 |
{ |
|
114 |
iTransId=0; |
|
115 |
} |
|
116 |
||
117 |
/** |
|
118 |
* Default Destructor |
|
119 |
*/ |
|
120 |
CLogAsyncService :: ~CLogAsyncService() |
|
121 |
{ |
|
122 |
Cancel(); |
|
26
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
123 |
delete iFilter; |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
124 |
delete iLogViewEvent; |
5 | 125 |
delete iLogClient ; |
126 |
iFs.Close() ; |
|
127 |
} |
|
128 |
||
129 |
/** |
|
130 |
* NewL() Constructs the ClogAsync object |
|
131 |
*/ |
|
132 |
EXPORT_C CLogAsyncService* CLogAsyncService :: NewL( MLoggingCallback* aCallback ) |
|
133 |
{ |
|
134 |
CLogAsyncService* self = CLogAsyncService::NewLC( aCallback ); |
|
135 |
CleanupStack :: Pop( self ) ; |
|
136 |
return self; |
|
137 |
} |
|
138 |
||
139 |
/** |
|
140 |
* NewLC Two phase constructor implementation |
|
141 |
*/ |
|
142 |
CLogAsyncService* CLogAsyncService :: NewLC( MLoggingCallback* aCallback ) |
|
143 |
{ |
|
144 |
CLogAsyncService* self = new((ELeave)) CLogAsyncService() ; |
|
145 |
CleanupStack :: PushL(self) ; |
|
146 |
self->ConstructL(aCallback) ; |
|
147 |
return self ; |
|
148 |
} |
|
149 |
||
150 |
/** |
|
151 |
* ConstructL, Constructs Members of AsyncService Class |
|
152 |
*/ |
|
153 |
void CLogAsyncService :: ConstructL( MLoggingCallback* aCallback ) |
|
154 |
{ |
|
155 |
User::LeaveIfError(iFs.Connect()); |
|
156 |
iLogClient = CLogClient::NewL(iFs); |
|
157 |
iCallback = aCallback; |
|
158 |
iIter = NULL ; |
|
159 |
iTask = ESleep; |
|
26
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
160 |
iLogViewEvent = CLogViewEvent::NewL(*iLogClient); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
161 |
iFilter = CLogFilter::NewL(); |
5 | 162 |
DoInitialiseL() ; |
163 |
} |
|
164 |
||
165 |
/** |
|
166 |
* DoInitalise, Initalises the Members of AsyncService Class |
|
167 |
*/ |
|
168 |
void CLogAsyncService :: DoInitialiseL() |
|
169 |
{ |
|
170 |
CActiveScheduler :: Add(this) ; |
|
171 |
} |
|
172 |
||
173 |
/** |
|
174 |
* RunL Method . |
|
175 |
*/ |
|
176 |
void CLogAsyncService :: RunL() |
|
177 |
{ |
|
178 |
TRAP_IGNORE(RunCmdL()); |
|
179 |
} |
|
180 |
||
181 |
/** |
|
182 |
* RunCmdL Method implementation, revices Notifications of completed |
|
183 |
* Async services: Add , Delete and GetEvent requests |
|
184 |
*/ |
|
185 |
void CLogAsyncService :: RunCmdL() |
|
186 |
{ |
|
187 |
switch( iTask ) |
|
188 |
{ |
|
189 |
case EAddEvent: |
|
190 |
{ |
|
191 |
CLogIter *iter = CLogIter :: NewL() ; |
|
192 |
iter->SetEventL(iUpdatedEvent) ; |
|
193 |
delete iUpdatedEvent ; |
|
194 |
iUpdatedEvent = NULL ; |
|
195 |
iCallback->HandleNotifyL(iTransId ,iStatus.Int() , iter ) ; |
|
196 |
iter = NULL; |
|
197 |
iTask = ESleep; |
|
198 |
this->Deque(); |
|
199 |
break; |
|
200 |
} |
|
201 |
||
202 |
case EDeleteEvent: |
|
203 |
{ |
|
204 |
iCallback->HandleNotifyL( iTransId, iStatus.Int(), NULL ) ; |
|
205 |
iTask = ESleep; |
|
206 |
this->Deque(); |
|
207 |
break; |
|
208 |
} |
|
209 |
||
210 |
case EReadEvents : |
|
211 |
{ |
|
212 |
iIter->SetTaskId(EReadEvents) ; |
|
213 |
iCallback->HandleNotifyL( iTransId, KErrNone, iIter ) ; |
|
214 |
iIter = NULL ; |
|
215 |
iTask = ESleep; |
|
216 |
break; |
|
217 |
} |
|
218 |
||
219 |
case EGetRecent: |
|
220 |
{ |
|
221 |
iIter->SetTaskId(EGetRecent) ; |
|
222 |
iCallback->HandleNotifyL( iTransId ,KErrNone, iIter ) ; |
|
223 |
iIter = NULL ; |
|
224 |
iTask = ESleep; |
|
225 |
break; |
|
226 |
} |
|
227 |
||
228 |
case EGetEvent : |
|
229 |
{ |
|
230 |
iIter->SetEventL( iUpdatedEvent ) ; |
|
231 |
iIter->SetTaskId( EGetEvent ) ; |
|
232 |
delete iUpdatedEvent ; |
|
233 |
iUpdatedEvent = NULL ; |
|
234 |
||
235 |
if( iStatus.Int() != KErrNone ) |
|
236 |
{ |
|
237 |
delete iIter; |
|
238 |
iIter = NULL ; |
|
239 |
} |
|
240 |
||
241 |
iCallback->HandleNotifyL(iTransId , KErrNone, iIter) ; |
|
242 |
iIter = NULL ; |
|
243 |
iTask = ESleep; |
|
244 |
break ; |
|
245 |
} |
|
246 |
case ENotification: |
|
247 |
{ |
|
26
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
248 |
CAsyncWaiter* waiter = CAsyncWaiter::NewL(); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
249 |
CleanupStack::PushL(waiter); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
250 |
TBool t = iLogViewEvent->SetFilterL(*iFilter,waiter->iStatus); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
251 |
waiter->StartAndWait(); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
252 |
iLogViewEvent->FirstL(waiter->iStatus); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
253 |
waiter->StartAndWait(); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
254 |
CleanupStack::PopAndDestroy(waiter); |
5 | 255 |
NotifyUpdates( iTransId, iInterval ); |
26
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
256 |
CLogsEvent* resultNotification = CLogsEvent::NewL(); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
257 |
resultNotification->SetEvent(iLogViewEvent->Event()); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
258 |
iCallback->HandleReqeustL( iTransId, KErrNone , resultNotification ) ; |
5 | 259 |
break; |
260 |
} |
|
261 |
||
262 |
case EErrorEvent: |
|
263 |
{ |
|
264 |
delete iIter; |
|
265 |
iIter = NULL ; |
|
266 |
iCallback->HandleNotifyL( iTransId ,KErrNone, iIter ) ; |
|
267 |
iTask = ESleep; |
|
268 |
break; |
|
269 |
} |
|
270 |
||
271 |
case ESleep: |
|
272 |
default: |
|
273 |
{ |
|
274 |
break ; |
|
275 |
} |
|
276 |
||
277 |
} |
|
278 |
} |
|
279 |
||
280 |
/** |
|
281 |
* Do Cancel Method for cancelling the outstanding async requests |
|
282 |
*/ |
|
283 |
void CLogAsyncService :: DoCancel() |
|
284 |
{ |
|
285 |
switch(iTask) |
|
286 |
{ |
|
287 |
case EAddEvent: |
|
288 |
{ |
|
289 |
iLogClient->Cancel(); |
|
290 |
break; |
|
291 |
} |
|
292 |
||
293 |
case EDeleteEvent: |
|
294 |
{ |
|
295 |
iLogClient->Cancel(); |
|
296 |
break; |
|
297 |
} |
|
298 |
case EGetRecent: |
|
299 |
case EGetEvent: |
|
300 |
case EErrorEvent: |
|
301 |
case EReadEvents : |
|
302 |
{ |
|
303 |
delete iIter ; |
|
304 |
break; |
|
305 |
} |
|
306 |
case ENotification: |
|
307 |
{ |
|
308 |
iLogClient->NotifyChangeCancel() ; |
|
309 |
break ; |
|
310 |
} |
|
311 |
case ESleep: |
|
312 |
default: |
|
313 |
{ |
|
314 |
break; |
|
315 |
} |
|
316 |
} |
|
317 |
||
318 |
iCallback->CancelNotifyL( iTransId ); |
|
319 |
||
320 |
if(iUpdatedEvent) |
|
321 |
{ |
|
322 |
delete iUpdatedEvent ; |
|
323 |
iUpdatedEvent = NULL ; |
|
324 |
} |
|
325 |
||
326 |
} |
|
327 |
||
328 |
/** |
|
329 |
* AddEvent, adds an event to event database asynchronously |
|
330 |
* @param aEvent, details of the event to be added to database |
|
331 |
*/ |
|
332 |
EXPORT_C void CLogAsyncService :: AddL( TUint aTransId ,CLogEvent* aEvent ) |
|
333 |
||
334 |
{ |
|
335 |
if(!iUpdatedEvent) |
|
336 |
{ |
|
337 |
iUpdatedEvent = CLogsEvent :: NewL() ; |
|
338 |
} |
|
339 |
iUpdatedEvent->Copy(aEvent); |
|
340 |
iLogClient->AddEvent(*(iUpdatedEvent->getEvent()) , iStatus); |
|
341 |
iTransId = aTransId ; |
|
342 |
SetActive() ; |
|
343 |
iTask = EAddEvent; |
|
344 |
} |
|
345 |
||
346 |
/** |
|
347 |
* Deletes a event from the event database |
|
348 |
* @param aLogId Event id of the event in the database |
|
349 |
* @param aFilter, search criteria for this event in event database |
|
350 |
*/ |
|
351 |
void CLogAsyncService :: Delete( TUint aTransId , TLogId aLogId ) |
|
352 |
{ |
|
353 |
iLogClient->DeleteEvent(aLogId , iStatus) ; |
|
354 |
iTransId = aTransId ; |
|
355 |
SetActive() ; |
|
356 |
iTask = EDeleteEvent; |
|
357 |
} |
|
358 |
||
359 |
/** |
|
360 |
* Gets eventList asynchronously |
|
361 |
* @param aFilter: Event filter for querying the event database |
|
362 |
* @param aCallback: callback address |
|
363 |
*/ |
|
364 |
void CLogAsyncService :: GetListL( TUint aTransId ,CLogFilter *aFilter ) |
|
365 |
{ |
|
366 |
if(!iIter) |
|
367 |
{ |
|
368 |
iIter = CLogIter :: NewL() ; |
|
369 |
} |
|
370 |
||
371 |
CLogClient *cli = CLogClient :: NewL(iIter->GetRFs()) ; |
|
372 |
CLogViewEvent *events = CLogViewEvent :: NewL(*cli) ; |
|
373 |
||
374 |
iIter->SetLogViewEvents( events ) ; |
|
375 |
iIter->SetLogClient( cli ) ; |
|
376 |
||
377 |
if( events->SetFilterL( *aFilter, iStatus ) ) |
|
378 |
{ |
|
379 |
iTask = EReadEvents ; |
|
380 |
iTransId = aTransId ; |
|
381 |
SetActive() ; |
|
382 |
} |
|
383 |
else //case where the setFilter fails but for the uniformity of the |
|
384 |
//behaviour of this API for all the inputs.. we are artificially |
|
385 |
//simulalting asyc behaviour to report the error to the user |
|
386 |
//as the other internal apis used in this command gives the error |
|
387 |
//in the callback i.e.., asycn error only |
|
388 |
{ |
|
389 |
iIter->SetTaskId( EReadEvents ) ; |
|
390 |
iTask = EErrorEvent; |
|
391 |
iTransId = aTransId ; |
|
392 |
iStatus = KRequestPending; |
|
393 |
SetActive(); |
|
394 |
TRequestStatus* temp = &iStatus; |
|
395 |
User::RequestComplete( temp, KErrNone ); |
|
396 |
} |
|
397 |
} |
|
398 |
/** |
|
399 |
* Reads recent events from the database aysnchronously |
|
400 |
* |
|
401 |
* @param Transaction id of the async event |
|
402 |
* @param RecentList |
|
403 |
* @param Filter for events to appear in the view. |
|
404 |
*/ |
|
405 |
TBool CLogAsyncService :: ReadRecentEventsL( TUint aTransId , |
|
406 |
TLogRecentList aList , |
|
407 |
const CLogFilter *aFilter ) |
|
408 |
{ |
|
409 |
if(!iIter) |
|
410 |
{ |
|
411 |
iIter = CLogIter :: NewL() ; |
|
412 |
} |
|
413 |
CLogClient *cli = CLogClient :: NewL(iIter->GetRFs()) ; |
|
414 |
CLogViewRecent *LogViewRecent = CLogViewRecent :: NewL(*cli) ; |
|
415 |
iIter->SetLogRecentView( LogViewRecent ) ; |
|
416 |
iIter->SetLogClient( cli ) ; |
|
417 |
||
418 |
if(LogViewRecent->SetRecentListL(aList, *aFilter, iStatus)) |
|
419 |
{ |
|
420 |
// set this active object active to get the events |
|
421 |
// from the main event database, see RunL() |
|
422 |
iTransId = aTransId ; |
|
423 |
iTask = EGetRecent; |
|
424 |
SetActive(); |
|
425 |
} |
|
426 |
else |
|
427 |
{ |
|
428 |
iIter->SetTaskId(EGetEvent) ; |
|
429 |
iTask = EErrorEvent; |
|
430 |
iTransId = aTransId ; |
|
431 |
iStatus = KRequestPending; |
|
432 |
SetActive(); |
|
433 |
TRequestStatus* temp = &iStatus; |
|
434 |
User::RequestComplete( temp, KErrNone ); |
|
435 |
} |
|
436 |
return ETrue ; |
|
437 |
||
438 |
} |
|
439 |
||
440 |
/** |
|
441 |
* Notifies the updates happening to the log database |
|
442 |
*/ |
|
443 |
void CLogAsyncService :: NotifyUpdates( TUint aTransId ,TTimeIntervalMicroSeconds32 aDelay ) |
|
444 |
{ |
|
445 |
iLogClient->NotifyChange( aDelay , iStatus ) ; |
|
446 |
iTask = ENotification ; |
|
447 |
iTransId = aTransId ; |
|
448 |
SetActive() ; |
|
449 |
} |
|
450 |
||
451 |
/** |
|
452 |
* Gets the details of the event as specified by the input |
|
453 |
* paramater asynchronously |
|
454 |
* |
|
455 |
* @param, Transaction id of this event |
|
456 |
* @param , Details of the event to be fetched from the database |
|
457 |
*/ |
|
458 |
void CLogAsyncService :: GetEventL( TUint aTransId, CLogEvent* aEvent ) |
|
459 |
{ |
|
460 |
if( !iUpdatedEvent ) |
|
461 |
{ |
|
462 |
iUpdatedEvent = CLogsEvent :: NewL() ; |
|
463 |
} |
|
464 |
||
465 |
iUpdatedEvent->SetEvent(*aEvent) ; |
|
466 |
iLogClient->GetEvent(*(iUpdatedEvent->getEvent()) , iStatus) ; |
|
467 |
||
468 |
if( !iIter ) |
|
469 |
{ |
|
470 |
iIter = CLogIter :: NewL() ; |
|
471 |
} |
|
472 |
iTransId = aTransId ; |
|
473 |
iTask = EGetEvent ; |
|
474 |
SetActive() ; |
|
475 |
} |
|
476 |
||
477 |