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 logiter class.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <e32base.h>
|
|
19 |
#include <e32def.h>
|
|
20 |
#include <logwrap.h>
|
|
21 |
#include <logcli.h>
|
|
22 |
|
|
23 |
#include "loggingevent.h"
|
|
24 |
#include "logiter.h"
|
|
25 |
#include "loggingasyncservice.h"
|
|
26 |
|
|
27 |
|
|
28 |
/**
|
|
29 |
* Two phase constructors
|
|
30 |
*
|
|
31 |
* @param aClient, CLogClient handle for log database
|
|
32 |
* @param aRecent , CLogViewRecent handle
|
|
33 |
* @param aViewEvents ,CLogViewEvents handle
|
|
34 |
*/
|
|
35 |
EXPORT_C CLogIter* CLogIter :: NewL()
|
|
36 |
{
|
|
37 |
CLogIter *self = CLogIter :: NewLC() ;
|
|
38 |
CleanupStack :: Pop(self);
|
|
39 |
return self ;
|
|
40 |
}
|
|
41 |
|
|
42 |
CLogIter* CLogIter :: NewLC()
|
|
43 |
{
|
|
44 |
CLogIter *self = new(ELeave) CLogIter() ;
|
|
45 |
CleanupStack :: PushL(self);
|
|
46 |
self->ConstructL() ;
|
|
47 |
return self ;
|
|
48 |
}
|
|
49 |
|
|
50 |
/**
|
|
51 |
* ConstructL Method to construct the internal members of
|
|
52 |
* CLogIter class
|
|
53 |
*/
|
|
54 |
void CLogIter :: ConstructL()
|
|
55 |
{
|
|
56 |
User :: LeaveIfError(iFs.Connect()) ;
|
|
57 |
CActiveScheduler :: Add(this) ;
|
|
58 |
iScheduler = new CActiveSchedulerWait();
|
|
59 |
}
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Default Constructor
|
|
63 |
* This object holds the ownership of its members and
|
|
64 |
*
|
|
65 |
*/
|
|
66 |
CLogIter :: CLogIter() : CActive(EPriorityStandard) , iLogViewEvents(NULL) , iLogViewRecent(NULL) ,
|
|
67 |
iTaskId(-1), iCount(0)
|
|
68 |
{
|
|
69 |
;
|
|
70 |
}
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Default Destructor
|
|
74 |
*/
|
|
75 |
CLogIter :: ~CLogIter()
|
|
76 |
{
|
|
77 |
if(this->IsAdded())
|
|
78 |
{
|
|
79 |
Deque() ;
|
|
80 |
}
|
|
81 |
|
|
82 |
delete iLogViewEvents ;
|
|
83 |
delete iLogViewRecent ;
|
|
84 |
delete iLogClient ;
|
|
85 |
delete iEvent ;
|
|
86 |
delete iScheduler;
|
|
87 |
iFs.Close() ;
|
|
88 |
|
|
89 |
}
|
|
90 |
|
|
91 |
/**
|
|
92 |
* Do Cancel Method, From CActive
|
|
93 |
*/
|
|
94 |
void CLogIter :: DoCancel()
|
|
95 |
{
|
|
96 |
switch(iTaskId)
|
|
97 |
{
|
|
98 |
case EReadEvents :
|
|
99 |
{
|
|
100 |
iLogViewEvents->Cancel() ;
|
|
101 |
break ;
|
|
102 |
}
|
|
103 |
|
|
104 |
case EGetRecent :
|
|
105 |
{
|
|
106 |
iLogViewRecent->Cancel() ;
|
|
107 |
break ;
|
|
108 |
}
|
|
109 |
|
|
110 |
case EGetEvent :
|
|
111 |
{
|
|
112 |
break ;
|
|
113 |
}
|
|
114 |
|
|
115 |
default :
|
|
116 |
{
|
|
117 |
break ;
|
|
118 |
}
|
|
119 |
}
|
|
120 |
}
|
|
121 |
/**
|
|
122 |
* RunL Method to handle async events
|
|
123 |
* Read , ReadRecent and Get an event
|
|
124 |
*/
|
|
125 |
void CLogIter :: RunL()
|
|
126 |
{
|
|
127 |
iScheduler->AsyncStop();
|
|
128 |
}
|
|
129 |
|
|
130 |
/**
|
|
131 |
* NextL method to iterate on the getlist result
|
|
132 |
*/
|
|
133 |
|
|
134 |
EXPORT_C CLogsEvent* CLogIter :: NextL()
|
|
135 |
{
|
|
136 |
CLogsEvent* currEvent = NULL ;
|
|
137 |
switch(iTaskId)
|
|
138 |
{
|
|
139 |
case EReadEvents :
|
|
140 |
{
|
|
141 |
if(!iCount)
|
|
142 |
{
|
|
143 |
iCount = iLogViewEvents->CountL() ;
|
|
144 |
}
|
|
145 |
if(iOps++ >= iCount)
|
|
146 |
{
|
|
147 |
return currEvent ;
|
|
148 |
}
|
|
149 |
currEvent = CLogsEvent :: NewL() ;
|
|
150 |
currEvent->SetEvent(iLogViewEvents->Event()) ;
|
|
151 |
|
|
152 |
if((iLogViewEvents->NextL(iStatus)))
|
|
153 |
{
|
|
154 |
SetActive() ;
|
|
155 |
iScheduler->Start() ;
|
|
156 |
}
|
|
157 |
break ;
|
|
158 |
}
|
|
159 |
|
|
160 |
case EGetRecent :
|
|
161 |
{
|
|
162 |
if(!iCount)
|
|
163 |
{
|
|
164 |
iCount = iLogViewRecent->CountL() ;
|
|
165 |
}
|
|
166 |
|
|
167 |
if(iOps++ >= iCount)
|
|
168 |
{
|
|
169 |
return currEvent ;
|
|
170 |
}
|
|
171 |
|
|
172 |
currEvent = CLogsEvent :: NewL() ;
|
|
173 |
currEvent->SetEvent(iLogViewRecent->Event()) ;
|
|
174 |
|
|
175 |
if(iLogViewRecent->NextL(iStatus) )
|
|
176 |
{
|
|
177 |
SetActive() ;
|
|
178 |
iScheduler->Start() ;
|
|
179 |
}
|
|
180 |
break ;
|
|
181 |
}
|
|
182 |
|
|
183 |
case EGetEvent :
|
|
184 |
{
|
|
185 |
if ( iEvent && !iOps )
|
|
186 |
{
|
|
187 |
++iOps;
|
|
188 |
currEvent = iEvent;
|
|
189 |
iEvent = NULL;
|
|
190 |
}
|
|
191 |
|
|
192 |
break ;
|
|
193 |
}
|
|
194 |
|
|
195 |
default :
|
|
196 |
{
|
|
197 |
break ;
|
|
198 |
}
|
|
199 |
|
|
200 |
}
|
|
201 |
return currEvent ;
|
|
202 |
}
|
|
203 |
|
|
204 |
|
|
205 |
/**
|
|
206 |
* Reset
|
|
207 |
*/
|
|
208 |
|
|
209 |
EXPORT_C void CLogIter :: Reset()
|
|
210 |
{
|
|
211 |
iOps = 0 ;
|
|
212 |
}
|
|
213 |
|
|
214 |
/**
|
|
215 |
* Function to set the event
|
|
216 |
*
|
|
217 |
* @param aEvent , event to be set
|
|
218 |
*/
|
|
219 |
|
|
220 |
|
|
221 |
EXPORT_C void CLogIter :: SetEventL(CLogsEvent* aEvent)
|
|
222 |
{
|
|
223 |
if( iEvent )
|
|
224 |
{
|
|
225 |
delete iEvent ;
|
|
226 |
}
|
|
227 |
|
|
228 |
iEvent = CLogsEvent :: NewL() ;
|
|
229 |
iEvent->Copy(aEvent->getEvent()) ;
|
|
230 |
}
|
|
231 |
|
|
232 |
|
|
233 |
|
|
234 |
/**
|
|
235 |
* Sets the LogClient Handle
|
|
236 |
*
|
|
237 |
* @param aLogClient, Handle to
|
|
238 |
* the logclient
|
|
239 |
*/
|
|
240 |
void CLogIter :: SetLogClient(CLogClient *aLogClient)
|
|
241 |
{
|
|
242 |
iLogClient = aLogClient ;
|
|
243 |
}
|
|
244 |
|
|
245 |
|
|
246 |
/**
|
|
247 |
* SetLogViewEvents, sets the handle to view the events
|
|
248 |
*
|
|
249 |
* @param CLogViewEvent , handle to view the events
|
|
250 |
*/
|
|
251 |
|
|
252 |
void CLogIter :: SetLogViewEvents(CLogViewEvent *aViewEvents)
|
|
253 |
{
|
|
254 |
iLogViewEvents = aViewEvents ;
|
|
255 |
}
|
|
256 |
|
|
257 |
/**
|
|
258 |
* SetLogViewRecent, sets the handle to the recent view
|
|
259 |
*
|
|
260 |
* @param aRecentView, recent view handle
|
|
261 |
*/
|
|
262 |
|
|
263 |
void CLogIter :: SetLogRecentView(CLogViewRecent *aViewRecent)
|
|
264 |
{
|
|
265 |
iLogViewRecent = aViewRecent ;
|
|
266 |
}
|
|
267 |
|
|
268 |
|
|
269 |
|