author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 22 | fc9cf246af83 |
permissions | -rw-r--r-- |
19 | 1 |
/* |
2 |
* Copyright (c) 2002 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: ?Description |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
||
21 |
// INCLUDE FILES |
|
22 |
#include <e32base.h> |
|
23 |
#include <e32svr.h> |
|
24 |
#include <StifParser.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
25 |
#include <StifTestInterface.h> |
19 | 26 |
//#include <senduiconsts.h> |
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
27 |
#include <cmsvattachment.h> |
19 | 28 |
#include "messagingservice.h" |
29 |
#include "messageheader.h" |
|
30 |
#include "get_header_message.h" |
|
31 |
||
32 |
// EXTERNAL DATA STRUCTURES |
|
33 |
//extern ?external_data; |
|
34 |
||
35 |
// EXTERNAL FUNCTION PROTOTYPES |
|
36 |
//extern ?external_function( ?arg_type,?arg_type ); |
|
37 |
||
38 |
// CONSTANTS |
|
39 |
//const ?type ?constant_var = ?constant; |
|
40 |
||
41 |
// MACROS |
|
42 |
//#define ?macro ?macro_def |
|
43 |
||
44 |
// LOCAL CONSTANTS AND MACROS |
|
45 |
//const ?type ?constant_var = ?constant; |
|
46 |
//#define ?macro_name ?macro_def |
|
47 |
||
48 |
// MODULE DATA STRUCTURES |
|
49 |
//enum ?declaration |
|
50 |
//typedef ?declaration |
|
51 |
||
52 |
// LOCAL FUNCTION PROTOTYPES |
|
53 |
//?type ?function_name( ?arg_type, ?arg_type ); |
|
54 |
||
55 |
// FORWARD DECLARATIONS |
|
56 |
//class ?FORWARD_CLASSNAME; |
|
57 |
||
58 |
// ============================= LOCAL FUNCTIONS =============================== |
|
59 |
||
60 |
// ----------------------------------------------------------------------------- |
|
61 |
// ?function_name ?description. |
|
62 |
// ?description |
|
63 |
// Returns: ?value_1: ?description |
|
64 |
// ?value_n: ?description_line1 |
|
65 |
// ?description_line2 |
|
66 |
// ----------------------------------------------------------------------------- |
|
67 |
// |
|
68 |
/* |
|
69 |
?type ?function_name( |
|
70 |
?arg_type arg, // ?description |
|
71 |
?arg_type arg) // ?description |
|
72 |
{ |
|
73 |
||
74 |
?code // ?comment |
|
75 |
||
76 |
// ?comment |
|
77 |
?code |
|
78 |
} |
|
79 |
*/ |
|
80 |
||
81 |
// ============================ MEMBER FUNCTIONS =============================== |
|
82 |
||
83 |
// ----------------------------------------------------------------------------- |
|
84 |
// Cget_header_message::Delete |
|
85 |
// Delete here all resources allocated and opened from test methods. |
|
86 |
// Called from destructor. |
|
87 |
// ----------------------------------------------------------------------------- |
|
88 |
// |
|
89 |
void Cget_header_message::Delete() |
|
90 |
{ |
|
91 |
||
92 |
} |
|
93 |
||
94 |
// ----------------------------------------------------------------------------- |
|
95 |
// Cget_header_message::RunMethodL |
|
96 |
// Run specified method. Contains also table of test mothods and their names. |
|
97 |
// ----------------------------------------------------------------------------- |
|
98 |
// |
|
99 |
TInt Cget_header_message::RunMethodL( |
|
100 |
CStifItemParser& aItem ) |
|
101 |
{ |
|
102 |
||
103 |
static TStifFunctionInfo const KFunctions[] = |
|
104 |
{ |
|
105 |
// Copy this line for every implemented function. |
|
106 |
// First string is the function name used in TestScripter script file. |
|
107 |
// Second is the actual implementation member function. |
|
108 |
ENTRY( "test_1", Cget_header_message::Test1L ), |
|
109 |
||
110 |
}; |
|
111 |
||
112 |
const TInt count = sizeof( KFunctions ) / |
|
113 |
sizeof( TStifFunctionInfo ); |
|
114 |
||
115 |
return RunInternalL( KFunctions, count, aItem ); |
|
116 |
||
117 |
} |
|
118 |
||
119 |
// ----------------------------------------------------------------------------- |
|
120 |
// Cget_header_message::ExampleL |
|
121 |
// Example test method function. |
|
122 |
// (other items were commented in a header). |
|
123 |
// ----------------------------------------------------------------------------- |
|
124 |
// |
|
125 |
TInt Cget_header_message::messageid_func(CStifItemParser& aItem,TInt& id) |
|
126 |
{ |
|
127 |
TInt err = aItem.GetNextInt(id); |
|
128 |
if(err) |
|
129 |
{ |
|
130 |
////iLog->Log(_L("Failed to Get message id")); |
|
131 |
return KErrGeneral; |
|
132 |
}; |
|
133 |
return KErrNone; |
|
134 |
} |
|
135 |
||
136 |
TInt Cget_header_message::fromarray_func(CStifItemParser& aItem,TPtrC& fromarray) |
|
137 |
{ |
|
138 |
TInt err = aItem.GetNextString(fromarray); |
|
139 |
if(err) |
|
140 |
{ |
|
141 |
//iLog->Log(_L("Failed to Get from array")); |
|
142 |
return KErrGeneral; |
|
143 |
}; |
|
144 |
return KErrNone; |
|
145 |
} |
|
146 |
||
147 |
TInt Cget_header_message::subject_func(CStifItemParser& aItem,TPtrC& subj) |
|
148 |
{ |
|
149 |
TInt err = aItem.GetNextString(subj); |
|
150 |
if(err) |
|
151 |
{ |
|
152 |
//iLog->Log(_L("Failed to Get subject")); |
|
153 |
return KErrGeneral; |
|
154 |
}; |
|
155 |
return KErrNone; |
|
156 |
} |
|
157 |
||
158 |
TInt Cget_header_message::sort_func(CStifItemParser& aItem,TInt& sorttype) |
|
159 |
{ |
|
160 |
TInt err = aItem.GetNextInt(sorttype); |
|
161 |
if(err) |
|
162 |
{ |
|
163 |
//iLog->Log(_L("Failed to Get sort type")); |
|
164 |
return KErrGeneral; |
|
165 |
}; |
|
166 |
return KErrNone; |
|
167 |
} |
|
168 |
||
169 |
TInt Cget_header_message::mtm_func(CStifItemParser& aItem,TPtrC& mtmtype) |
|
170 |
{ |
|
171 |
TInt err = aItem.GetNextString(mtmtype); |
|
172 |
if(err) |
|
173 |
{ |
|
174 |
//iLog->Log(_L("Failed to Get mtm type")); |
|
175 |
return KErrGeneral; |
|
176 |
}; |
|
177 |
return KErrNone; |
|
178 |
} |
|
179 |
||
180 |
TInt Cget_header_message::flag_func(CStifItemParser& aItem,TInt& flag) |
|
181 |
{ |
|
182 |
TInt err = aItem.GetNextInt(flag); |
|
183 |
if(err) |
|
184 |
{ |
|
185 |
//iLog->Log(_L("Failed to Get date flag or err code")); |
|
186 |
return KErrGeneral; |
|
187 |
}; |
|
188 |
return KErrNone; |
|
189 |
} |
|
190 |
||
191 |
TInt Cget_header_message::date_func(CStifItemParser& aItem,TInt& year,TInt& month,TInt& day,TInt& hour,TInt& min,TInt& sec,TInt& microsec) |
|
192 |
{ |
|
193 |
||
194 |
TInt err = aItem.GetNextInt(year); |
|
195 |
if(err) |
|
196 |
{ |
|
197 |
//iLog->Log(_L("Failed to Get year")); |
|
198 |
return KErrGeneral; |
|
199 |
}; |
|
200 |
||
201 |
err = aItem.GetNextInt(month); |
|
202 |
if(err) |
|
203 |
{ |
|
204 |
//iLog->Log(_L("Failed to Get month")); |
|
205 |
return KErrGeneral; |
|
206 |
}; |
|
207 |
||
208 |
err = aItem.GetNextInt(day); |
|
209 |
if(err) |
|
210 |
{ |
|
211 |
//iLog->Log(_L("Failed to Get day")); |
|
212 |
return KErrGeneral; |
|
213 |
}; |
|
214 |
||
215 |
err = aItem.GetNextInt(hour); |
|
216 |
if(err) |
|
217 |
{ |
|
218 |
//iLog->Log(_L("Failed to Get hour")); |
|
219 |
return KErrGeneral; |
|
220 |
}; |
|
221 |
||
222 |
err = aItem.GetNextInt(min); |
|
223 |
if(err) |
|
224 |
{ |
|
225 |
//iLog->Log(_L("Failed to Get min")); |
|
226 |
return KErrGeneral; |
|
227 |
}; |
|
228 |
||
229 |
err = aItem.GetNextInt(sec); |
|
230 |
if(err) |
|
231 |
{ |
|
232 |
//iLog->Log(_L("Failed to Get sec")); |
|
233 |
return KErrGeneral; |
|
234 |
}; |
|
235 |
||
236 |
err = aItem.GetNextInt(microsec); |
|
237 |
if(err) |
|
238 |
{ |
|
239 |
//iLog->Log(_L("Failed to Get microsec")); |
|
240 |
return KErrGeneral; |
|
241 |
}; |
|
242 |
return KErrNone; |
|
243 |
} |
|
244 |
||
245 |
TInt Cget_header_message::getsub_func(CStifItemParser& aItem,TPtrC& sub) |
|
246 |
{ |
|
247 |
TInt err = aItem.GetNextString(sub); |
|
248 |
if(err) |
|
249 |
{ |
|
250 |
//iLog->Log(_L("Failed to Get message subject to verify")); |
|
251 |
return KErrGeneral; |
|
252 |
}; |
|
253 |
return KErrNone; |
|
254 |
} |
|
255 |
||
256 |
||
257 |
||
258 |
TInt Cget_header_message::Test1L( CStifItemParser& aItem ) |
|
259 |
{ |
|
260 |
||
261 |
__UHEAP_MARK; |
|
262 |
||
263 |
TInt id,sorttype,flag,year,month,day,hour,min,sec,microsec; |
|
264 |
TPtrC subj,mtmtype,fromarray; |
|
265 |
bool test = TRUE; |
|
266 |
||
267 |
CMessagingService* service = (CMessagingService*)CMessagingService::NewL(); |
|
268 |
CleanupStack::PushL(service); |
|
269 |
||
270 |
CFilterParamInfo* filter = CFilterParamInfo::NewL(); |
|
271 |
||
272 |
||
273 |
TInt err1 = messageid_func(aItem,id); |
|
274 |
if(err1) |
|
275 |
{ |
|
276 |
return KErrGeneral; |
|
277 |
} |
|
278 |
||
279 |
if(id == 1) |
|
280 |
{ |
|
281 |
CMessagingService* mservice = (CMessagingService*)CMessagingService::NewL(); |
|
282 |
CleanupStack::PushL(mservice); |
|
283 |
CFilterParamInfo* mfilter = CFilterParamInfo::NewL(); |
|
284 |
CMsvEntrySelection* marray = NULL ; |
|
285 |
TRAPD(err,mservice->GetIdListL(mfilter,0,NULL ,marray)); |
|
286 |
TInt index = 0; |
|
287 |
CMessageHeader* headerarr = NULL; |
|
288 |
mservice->GetNextHeaderL(mfilter, marray, index, NULL, headerarr); |
|
289 |
TMsvId message_id; |
|
290 |
headerarr->GetMessageId(message_id); |
|
291 |
filter->SetMessageIdFilter(message_id); |
|
292 |
delete headerarr; |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
293 |
marray->Reset(); |
19 | 294 |
delete marray; |
295 |
delete mfilter; |
|
296 |
CleanupStack::PopAndDestroy(mservice); |
|
297 |
} |
|
298 |
else if(id == 0) |
|
299 |
{ |
|
300 |
filter->SetMessageIdFilter(NULL); |
|
301 |
} |
|
302 |
else |
|
303 |
{ |
|
304 |
TMsvId iD = id; |
|
305 |
filter->SetMessageIdFilter(iD); // message id filter |
|
306 |
} |
|
307 |
||
308 |
||
309 |
err1 = fromarray_func(aItem,fromarray); |
|
310 |
if(err1) |
|
311 |
{ |
|
312 |
return KErrGeneral; |
|
313 |
} |
|
314 |
||
315 |
_LIT(Knull,"NULL"); |
|
316 |
if(fromarray.CompareF(Knull)) |
|
317 |
{ |
|
318 |
_LIT(Kaddr,"AddrEnd"); |
|
319 |
while(fromarray != Kaddr) |
|
320 |
{ |
|
321 |
filter->AddFromL(fromarray); // from address filter |
|
322 |
err1 = fromarray_func(aItem,fromarray); |
|
323 |
if(err1) |
|
324 |
{ |
|
325 |
return KErrGeneral; |
|
326 |
} |
|
327 |
} |
|
328 |
} |
|
329 |
else |
|
330 |
{ |
|
331 |
// filter->AddFromL(NULL); |
|
332 |
} |
|
333 |
||
334 |
||
335 |
||
336 |
||
337 |
err1 = subject_func(aItem,subj); |
|
338 |
if(err1) |
|
339 |
{ |
|
340 |
return KErrGeneral; |
|
341 |
} |
|
342 |
if(subj.CompareF(Knull)) |
|
343 |
{ |
|
344 |
filter->SetSubjectL(subj); // subject filter |
|
345 |
} |
|
346 |
else |
|
347 |
{ |
|
348 |
// filter->SetSubjectL(NULL); |
|
349 |
} |
|
350 |
||
351 |
||
352 |
||
353 |
err1 = sort_func(aItem,sorttype); |
|
354 |
if(err1) |
|
355 |
{ |
|
356 |
return KErrGeneral; |
|
357 |
} |
|
358 |
||
359 |
TMsvSorting sort= (TMsvSorting)sorttype ; |
|
360 |
filter->SetSortType(sort) ; // sort filter |
|
361 |
||
362 |
||
363 |
||
364 |
||
365 |
err1 = mtm_func(aItem,mtmtype); |
|
366 |
if(err1) |
|
367 |
{ |
|
368 |
return KErrGeneral; |
|
369 |
} |
|
370 |
||
371 |
if(mtmtype.CompareF(Knull)) |
|
372 |
{ |
|
373 |
_LIT(Kmt,"MtmEnd"); |
|
374 |
while(mtmtype != Kmt) |
|
375 |
{ |
|
376 |
if( filter->AddMtmL(mtmtype) == KErrNone ) //code changed by Venkat |
|
377 |
{ |
|
378 |
err1 = mtm_func(aItem,mtmtype); |
|
379 |
if(err1) |
|
380 |
{ |
|
381 |
return KErrGeneral; |
|
382 |
} |
|
383 |
}// message type filter |
|
384 |
else |
|
385 |
{ |
|
386 |
delete filter; |
|
387 |
CleanupStack::PopAndDestroy( service ); |
|
388 |
return KErrNone; |
|
389 |
} |
|
390 |
} |
|
391 |
} |
|
392 |
else |
|
393 |
{ |
|
394 |
// filter.iMtmArray(NULL); |
|
395 |
} |
|
396 |
||
397 |
||
398 |
||
399 |
||
400 |
err1 = flag_func(aItem,flag); // start date as a filter(1) or not(0) |
|
401 |
if(err1) |
|
402 |
{ |
|
403 |
return KErrGeneral; |
|
404 |
} |
|
405 |
||
406 |
if(flag) |
|
407 |
{ |
|
408 |
err1 = date_func(aItem,year,month,day,hour,min,sec,microsec); |
|
409 |
if(err1) |
|
410 |
{ |
|
411 |
return KErrGeneral; |
|
412 |
} |
|
413 |
TDateTime start(year,(TMonth)month,day,hour,min,sec,microsec); |
|
414 |
TTime startdate(start); |
|
415 |
filter->SetStartDateFilter(startdate); // start date filter |
|
416 |
} |
|
417 |
else |
|
418 |
{ |
|
419 |
// filter->SetStartDateFilter(NULL) ; |
|
420 |
} |
|
421 |
||
422 |
||
423 |
||
424 |
||
425 |
err1 = flag_func(aItem,flag); // end date as a filter(1) or not(0) |
|
426 |
if(err1) |
|
427 |
{ |
|
428 |
return KErrGeneral; |
|
429 |
} |
|
430 |
||
431 |
if(flag) |
|
432 |
{ |
|
433 |
err1 = date_func(aItem,year,month,day,hour,min,sec,microsec); |
|
434 |
if(err1) |
|
435 |
{ |
|
436 |
return KErrGeneral; |
|
437 |
} |
|
438 |
||
439 |
TDateTime end(year,(TMonth)month,day,hour,min,sec,microsec); |
|
440 |
TTime enddate(end) ; |
|
441 |
filter->SetEndDate(enddate) ; // end date filter |
|
442 |
} |
|
443 |
else |
|
444 |
{ |
|
445 |
// filter->SetEndDate(NULL) ; |
|
446 |
} |
|
447 |
||
448 |
||
449 |
||
450 |
CMsvEntrySelection* array = NULL ; |
|
451 |
||
452 |
TRAPD(err,service->GetIdListL(filter,0,NULL ,array)); |
|
453 |
||
454 |
||
455 |
||
456 |
if(err == 0) |
|
457 |
{ |
|
458 |
||
459 |
TInt index = 0; |
|
460 |
for(;;) |
|
461 |
{ |
|
462 |
CMessageHeader* headers = NULL; |
|
463 |
service->GetNextHeaderL(filter, array, index, NULL, headers); |
|
464 |
if(headers) |
|
465 |
{ |
|
466 |
// if((header->Mtm().FindF(_L("SMS")) != KErrNotFound) && (header->From().FindF(_L("9008032761")) != KErrNotFound)) |
|
467 |
||
468 |
TPtrC subject = headers->Subject(); |
|
469 |
||
470 |
TBool attflag; |
|
471 |
headers->GetAttachFlag(attflag); |
|
472 |
TMsvPriority prior; |
|
473 |
headers->GetPriorityFlag(prior); |
|
474 |
TUid u_id; |
|
475 |
headers->GetMtmId(u_id); |
|
476 |
TTime time; |
|
477 |
headers->GetTime(time); |
|
478 |
||
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
479 |
//headers->SetPriorityFlag(TMsvPriority(0)); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
480 |
//headers->SetPriorityFlag(TMsvPriority(2)); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
481 |
//headers->SetPriorityFlag(TMsvPriority(6)); |
19 | 482 |
|
483 |
TMsvId id_l = headers->MessageId(); |
|
484 |
TBool fl_l = headers->AttachFlag(); |
|
485 |
TBool fg_l = headers->UnreadFlag(); |
|
486 |
TPtrC pr_l = headers->Priority(); |
|
487 |
TTime ti_l = headers->Time(); |
|
488 |
TPtrC mt_l = headers->Mtm(); |
|
489 |
TPtrC fr_l = headers->From(); |
|
490 |
TPtrC sub; |
|
491 |
_LIT(Kblank,"\x2029"); |
|
492 |
TInt err2 = getsub_func(aItem,sub); // get subject from cfg |
|
493 |
if(err2) |
|
494 |
{ |
|
495 |
delete headers; |
|
496 |
delete array; |
|
497 |
delete filter; |
|
498 |
CleanupStack::PopAndDestroy(service); |
|
499 |
return KErrGeneral; |
|
500 |
} |
|
501 |
||
502 |
if((subject.FindF(sub)!= KErrNotFound) || (subject == Kblank) || (attflag!=0) ) // compare message subject |
|
503 |
{ |
|
504 |
test = TRUE; |
|
505 |
} |
|
506 |
else |
|
507 |
{ |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
508 |
delete headers; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
509 |
headers = NULL; |
19 | 510 |
test = FALSE; |
511 |
break; |
|
512 |
} |
|
513 |
delete headers; |
|
514 |
} |
|
515 |
else |
|
516 |
break; |
|
517 |
||
518 |
} |
|
519 |
||
520 |
delete array; |
|
521 |
delete filter; |
|
522 |
||
523 |
CleanupStack::PopAndDestroy(service); |
|
524 |
||
525 |
if(test == TRUE) // all ids verified |
|
526 |
{ |
|
527 |
__UHEAP_MARKEND; |
|
528 |
return KErrNone; |
|
529 |
} |
|
530 |
else |
|
531 |
{ |
|
532 |
__UHEAP_MARKEND; |
|
533 |
return KErrGeneral; |
|
534 |
} |
|
535 |
} |
|
536 |
else |
|
537 |
{ |
|
538 |
err1 = flag_func(aItem,flag); // get err code from cfg |
|
539 |
if(err1) |
|
540 |
{ |
|
541 |
return KErrGeneral; |
|
542 |
} |
|
543 |
||
544 |
CleanupStack::PopAndDestroy(service); |
|
545 |
||
546 |
if(err == flag) |
|
547 |
{ |
|
548 |
__UHEAP_MARKEND; |
|
549 |
return KErrNone; |
|
550 |
} |
|
551 |
else |
|
552 |
{ |
|
553 |
__UHEAP_MARKEND; |
|
554 |
return KErrGeneral; |
|
555 |
} |
|
556 |
||
557 |
} |
|
558 |
} |
|
559 |
||
560 |
// ----------------------------------------------------------------------------- |
|
561 |
// Cget_header_message::?member_function |
|
562 |
// ?implementation_description |
|
563 |
// (other items were commented in a header). |
|
564 |
// ----------------------------------------------------------------------------- |
|
565 |
// |
|
566 |
/* |
|
567 |
TInt Cget_header_message::?member_function( |
|
568 |
CItemParser& aItem ) |
|
569 |
{ |
|
570 |
||
571 |
?code |
|
572 |
||
573 |
} |
|
574 |
*/ |
|
575 |
||
576 |
// ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
577 |
// None |
|
578 |
||
579 |
// End of File |