24
|
1 |
// Copyright (c) 1999-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 |
/**
|
|
17 |
@file
|
|
18 |
*/
|
|
19 |
|
|
20 |
#include "logcheck.h"
|
|
21 |
|
|
22 |
CSmsLogChecker* CSmsLogChecker::NewL(RFs& aFs, CSmsBaseTestStep* aTest, TInt aPriority)
|
|
23 |
{
|
|
24 |
CSmsLogChecker* self = new (ELeave) CSmsLogChecker(aFs, aTest, aPriority);
|
|
25 |
CleanupStack::PushL(self);
|
|
26 |
|
|
27 |
self->ConstructL();
|
|
28 |
|
|
29 |
CleanupStack::Pop(self);
|
|
30 |
|
|
31 |
return self;
|
|
32 |
}
|
|
33 |
|
|
34 |
void CSmsLogChecker::ConstructL()
|
|
35 |
{
|
|
36 |
iClient = CLogClient::NewL(iFs);
|
|
37 |
iView = CLogViewEvent::NewL(*iClient, Priority());
|
|
38 |
iFilter = CLogFilter::NewL();
|
|
39 |
|
|
40 |
iFilter->SetEventType(KLogShortMessageEventTypeUid);
|
|
41 |
iClient->GetString(iDirection, R_LOG_DIR_IN);
|
|
42 |
iFilter->SetDirection(iDirection);
|
|
43 |
}
|
|
44 |
|
|
45 |
CSmsLogChecker::CSmsLogChecker(RFs& aFs, CSmsBaseTestStep* aTest, TInt aPriority)
|
|
46 |
:CActive(aPriority), iFs(aFs), iTest(aTest)
|
|
47 |
{
|
|
48 |
CActiveScheduler::Add(this);
|
|
49 |
}
|
|
50 |
|
|
51 |
CSmsLogChecker::~CSmsLogChecker()
|
|
52 |
{
|
|
53 |
Cancel();
|
|
54 |
iOriginalIds.Close();
|
|
55 |
iNewIds.Close();
|
|
56 |
|
|
57 |
delete iView;
|
|
58 |
delete iFilter;
|
|
59 |
delete iClient;
|
|
60 |
}
|
|
61 |
|
|
62 |
void CSmsLogChecker::CountOriginalIdsL(TRequestStatus& aStatus)
|
|
63 |
/**
|
|
64 |
* Finds all incoming SMS Log Events,
|
|
65 |
* and appends each LogId to iOriginalIds.
|
|
66 |
*
|
|
67 |
* This function must be called before any new log events are added
|
|
68 |
* or SMS messages received.
|
|
69 |
*/
|
|
70 |
{
|
|
71 |
// __UHEAP_MARK;
|
|
72 |
iOriginalIds.Reset();
|
|
73 |
|
|
74 |
iNewIds.Reset();
|
|
75 |
iMessageLogIds = NULL;
|
|
76 |
|
|
77 |
StartTaskL(ECountOriginal, iOriginalIds, aStatus);
|
|
78 |
// __UHEAP_MARKEND;
|
|
79 |
}
|
|
80 |
|
|
81 |
void CSmsLogChecker::CompareNewIdsL(const RArray<TLogId>& aMessageLogIds, TRequestStatus& aStatus)
|
|
82 |
/**
|
|
83 |
* Compares array aMessageLogIds with the "new" incoming SMS Log Events.
|
|
84 |
*
|
|
85 |
* The "new" incoming SMS Log Events are determined by taking the difference between
|
|
86 |
* the current Log Events in the Log Engine and array iOriginalIds.
|
|
87 |
*
|
|
88 |
* Pre: CountOriginalIdsL() has already been called.
|
|
89 |
*/
|
|
90 |
{
|
|
91 |
iMessageLogIds = &aMessageLogIds;
|
|
92 |
iNewIds.Reset();
|
|
93 |
StartTaskL(ECountNew, iNewIds, aStatus);
|
|
94 |
}
|
|
95 |
|
|
96 |
void CSmsLogChecker::Complete(TInt aError)
|
|
97 |
{
|
|
98 |
//INFO_PRINTF6(_L("CSmsLogChecker Complete Task %d Error %d Orig %d New %d Msg %d"), iTask, aError, iOriginalIds.Count(), iNewIds.Count(), iMessageLogIds ? iMessageLogIds->Count() : 0))
|
|
99 |
iTest->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo,_L("CSmsLogChecker Complete Task %d Error %d Orig %d New %d Msg %d\n"), iTask, aError, iOriginalIds.Count(), iNewIds.Count(), iMessageLogIds ? iMessageLogIds->Count() : 0);
|
|
100 |
|
|
101 |
if (iReport)
|
|
102 |
{
|
|
103 |
User::RequestComplete(iReport, aError);
|
|
104 |
}
|
|
105 |
|
|
106 |
iTask = ENone;
|
|
107 |
iState = EIdle;
|
|
108 |
iMessageLogIds = NULL;
|
|
109 |
}
|
|
110 |
|
|
111 |
void CSmsLogChecker::RunL()
|
|
112 |
{
|
|
113 |
User::LeaveIfError(iStatus.Int());
|
|
114 |
TBool found = EFalse;
|
|
115 |
|
|
116 |
switch (iState)
|
|
117 |
{
|
|
118 |
case EFilter:
|
|
119 |
|
|
120 |
found = iView->FirstL(iStatus);
|
|
121 |
|
|
122 |
if (found)
|
|
123 |
{
|
|
124 |
iState = EFirst;
|
|
125 |
SetActive();
|
|
126 |
}
|
|
127 |
else
|
|
128 |
{
|
|
129 |
CompleteTaskL();
|
|
130 |
}
|
|
131 |
|
|
132 |
break;
|
|
133 |
|
|
134 |
case EFirst:
|
|
135 |
case ENext:
|
|
136 |
|
|
137 |
User::LeaveIfError(iCurrentArray->Append(iView->Event().Id()));
|
|
138 |
found = iView->NextL(iStatus);
|
|
139 |
|
|
140 |
if (found)
|
|
141 |
{
|
|
142 |
iState = ENext;
|
|
143 |
SetActive();
|
|
144 |
}
|
|
145 |
else
|
|
146 |
{
|
|
147 |
CompleteTaskL();
|
|
148 |
}
|
|
149 |
|
|
150 |
break;
|
|
151 |
|
|
152 |
default:
|
|
153 |
Complete(KErrGeneral); //should not get here
|
|
154 |
break;
|
|
155 |
}
|
|
156 |
}
|
|
157 |
|
|
158 |
void CSmsLogChecker::CompleteTaskL()
|
|
159 |
{
|
|
160 |
//INFO_PRINTF2(_L("CSmsLogChecker CompleteTask Task %d"), iTask);
|
|
161 |
iTest->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo,_L("CSmsLogChecker CompleteTask Task %d\n"), iTask );
|
|
162 |
|
|
163 |
// __UHEAP_MARK;
|
|
164 |
switch (iTask)
|
|
165 |
{
|
|
166 |
case ECountOriginal:
|
|
167 |
|
|
168 |
Complete(KErrNone);
|
|
169 |
break;
|
|
170 |
|
|
171 |
case ECountNew:
|
|
172 |
{
|
|
173 |
TInt count = iNewIds.Count();
|
|
174 |
|
|
175 |
while (count--)
|
|
176 |
{
|
|
177 |
if (iOriginalIds.Find(iNewIds[count]) != KErrNotFound)
|
|
178 |
iNewIds.Remove(count);
|
|
179 |
}
|
|
180 |
|
|
181 |
count = iNewIds.Count();
|
|
182 |
TInt err = KErrNone;
|
|
183 |
|
|
184 |
while (count-- && !err)
|
|
185 |
{
|
|
186 |
if (iMessageLogIds->Find(iNewIds[count]) == KErrNotFound)
|
|
187 |
err = KErrOverflow;
|
|
188 |
}
|
|
189 |
|
|
190 |
count = iMessageLogIds->Count();
|
|
191 |
|
|
192 |
while (count-- && !err)
|
|
193 |
{
|
|
194 |
if (iNewIds.Find((*iMessageLogIds)[count]) == KErrNotFound)
|
|
195 |
err = KErrUnderflow;
|
|
196 |
}
|
|
197 |
|
|
198 |
Complete(err);
|
|
199 |
break;
|
|
200 |
}
|
|
201 |
|
|
202 |
default:
|
|
203 |
Complete(KErrGeneral); //should not get here
|
|
204 |
break;
|
|
205 |
}
|
|
206 |
// __UHEAP_MARKEND;
|
|
207 |
}
|
|
208 |
|
|
209 |
TInt CSmsLogChecker::RunError(TInt aError)
|
|
210 |
{
|
|
211 |
Complete(aError);
|
|
212 |
return KErrNone;
|
|
213 |
}
|
|
214 |
|
|
215 |
void CSmsLogChecker::DoCancel()
|
|
216 |
{
|
|
217 |
switch (iState)
|
|
218 |
{
|
|
219 |
case EFilter:
|
|
220 |
case EFirst:
|
|
221 |
case ENext:
|
|
222 |
iView->Cancel();
|
|
223 |
break;
|
|
224 |
|
|
225 |
default:
|
|
226 |
break; //should not get here!!
|
|
227 |
}
|
|
228 |
|
|
229 |
Complete(KErrCancel);
|
|
230 |
}
|
|
231 |
|
|
232 |
void CSmsLogChecker::StartTaskL(TTask aTask, RArray<TLogId>& aIds, TRequestStatus& aStatus)
|
|
233 |
{
|
|
234 |
//INFO_PRINTF2(_L("CSmsLogChecker StartTask Task %d"), aTask);
|
|
235 |
iTest->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo,_L("CSmsLogChecker StartTask Task %d\n"),aTask );
|
|
236 |
|
|
237 |
iReport = &aStatus;
|
|
238 |
aStatus = KRequestPending;
|
|
239 |
// __UHEAP_MARK;
|
|
240 |
iTask = aTask;
|
|
241 |
iCurrentArray = &aIds;
|
|
242 |
iState = EFilter;
|
|
243 |
// __UHEAP_MARKEND;
|
|
244 |
|
|
245 |
|
|
246 |
TBool found = iView->SetFilterL(*iFilter, iStatus);
|
|
247 |
|
|
248 |
|
|
249 |
if (found)
|
|
250 |
{
|
|
251 |
SetActive();
|
|
252 |
}
|
|
253 |
else
|
|
254 |
{
|
|
255 |
CompleteTaskL();
|
|
256 |
}
|
|
257 |
}
|