author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 19 | 989d2f495d90 |
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 <e32svr.h> |
|
23 |
#include <StifParser.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
24 |
#include <StifTestInterface.h> |
19 | 25 |
#include "register_message.h" |
26 |
//#include <senduiconsts.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
27 |
#include <cmsvattachment.h> |
19 | 28 |
#include "messagingservice.h" |
29 |
#include "messageheader.h" |
|
30 |
#include "async.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 |
// Cregister_message::Delete |
|
85 |
// Delete here all resources allocated and opened from test methods. |
|
86 |
// Called from destructor. |
|
87 |
// ----------------------------------------------------------------------------- |
|
88 |
// |
|
89 |
void Cregister_message::Delete() |
|
90 |
{ |
|
91 |
||
92 |
} |
|
93 |
||
94 |
// ----------------------------------------------------------------------------- |
|
95 |
// Cregister_message::RunMethodL |
|
96 |
// Run specified method. Contains also table of test mothods and their names. |
|
97 |
// ----------------------------------------------------------------------------- |
|
98 |
// |
|
99 |
TInt Cregister_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", Cregister_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 |
// Cregister_message::ExampleL |
|
121 |
// Example test method function. |
|
122 |
// (other items were commented in a header). |
|
123 |
// ----------------------------------------------------------------------------- |
|
124 |
// |
|
125 |
||
126 |
TInt iResult; |
|
127 |
||
128 |
CMsgCallbackHeader* CMsgCallbackHeader::NewL(CActiveSchedulerWait* aWaitSchedular, CMessagingService* s) |
|
129 |
{ |
|
130 |
CMsgCallbackHeader* self = new (ELeave) CMsgCallbackHeader(aWaitSchedular, s); |
|
131 |
return self; |
|
132 |
} |
|
133 |
||
134 |
Cheader_test* Cheader_test::NewL() |
|
135 |
{ |
|
136 |
Cheader_test* self = new(ELeave)Cheader_test(); |
|
137 |
self->ConstructL(); |
|
138 |
return self; |
|
139 |
} |
|
140 |
||
141 |
||
142 |
Cheader_test::~Cheader_test() |
|
143 |
{ |
|
144 |
Cancel(); |
|
145 |
||
146 |
if(iWaitSchedular->IsStarted()) |
|
147 |
iWaitSchedular->AsyncStop(); |
|
148 |
||
149 |
if(iMessagingService) |
|
150 |
delete iMessagingService; |
|
151 |
||
152 |
if(iWaitSchedular) |
|
153 |
delete iWaitSchedular; |
|
154 |
} |
|
155 |
||
156 |
||
157 |
void Cheader_test::ConstructL() |
|
158 |
{ |
|
159 |
CActiveScheduler::Add(this); |
|
160 |
iMessagingService = CMessagingService::NewL(); |
|
161 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
162 |
} |
|
163 |
||
164 |
||
165 |
Cheader_test::Cheader_test() : |
|
166 |
CActive(EPriorityStandard) |
|
167 |
{ |
|
168 |
} |
|
169 |
||
170 |
||
171 |
void Cheader_test::DoCancel() |
|
172 |
{ |
|
173 |
||
174 |
} |
|
175 |
||
176 |
||
177 |
void Cheader_test::RunL() |
|
178 |
{ |
|
179 |
TestFunc(); |
|
180 |
} |
|
181 |
||
182 |
||
183 |
void Cheader_test::Start() |
|
184 |
{ |
|
185 |
iCallBack = CMsgCallbackHeader::NewL(iWaitSchedular, iMessagingService); |
|
186 |
SetActive(); |
|
187 |
TRequestStatus* temp = &iStatus; |
|
188 |
User::RequestComplete(temp, KErrNone); |
|
189 |
iWaitSchedular->Start(); |
|
190 |
} |
|
191 |
||
192 |
||
193 |
void CMsgCallbackHeader::NotifyResultL(TInt aErrCode, TAny* aResult) |
|
194 |
{ |
|
195 |
||
196 |
if(aErrCode == KErrNone) |
|
197 |
{ |
|
198 |
CMessageHeader* headerArr = NULL; |
|
199 |
headerArr = (CMessageHeader*)aResult; |
|
200 |
headerArr->GetMessageId(messageid); |
|
201 |
||
202 |
CMessagingService* service = (CMessagingService*)CMessagingService::NewL(); |
|
203 |
CFilterParamInfo* filter = CFilterParamInfo::NewL(); |
|
204 |
filter->SetMessageIdFilter(messageid); |
|
205 |
// TMsvSorting sort = EMsvSortByDateReverse; |
|
206 |
// filter->SetSortType(sort); |
|
207 |
||
208 |
User::After(1000000); |
|
209 |
||
210 |
CMsvEntrySelection* array = NULL ; |
|
211 |
TRAPD(errc,service->GetIdListL(filter ,0 ,NULL ,array)); |
|
212 |
||
213 |
||
214 |
TInt index = 0; |
|
215 |
CMessageHeader* headers = NULL; |
|
216 |
||
217 |
service->GetNextHeaderL(filter, array, index, NULL, headers); |
|
218 |
||
219 |
if(headers == NULL) |
|
220 |
iResult = KErrGeneral; |
|
221 |
else |
|
222 |
{ |
|
223 |
TMsvId message_id; |
|
224 |
headers->GetMessageId(message_id); |
|
225 |
delete headers; |
|
226 |
delete array; |
|
227 |
delete filter; |
|
228 |
delete service; |
|
229 |
||
230 |
if(messageid == message_id) |
|
231 |
iResult = KErrNone; |
|
232 |
else |
|
233 |
iResult = KErrGeneral; |
|
234 |
} |
|
235 |
} |
|
236 |
else |
|
237 |
{ |
|
238 |
if(aErrCode) |
|
239 |
iResult = KErrNone; |
|
240 |
else |
|
241 |
iResult = KErrGeneral; |
|
242 |
} |
|
243 |
iWaitSchedular->AsyncStop(); |
|
244 |
||
245 |
} |
|
246 |
||
247 |
||
248 |
||
249 |
void Cheader_test::TestFunc() |
|
250 |
{ |
|
251 |
||
252 |
TRAPD(err, iMessagingService->RequestNotification(ENewMessage ,iCallBack)); |
|
253 |
||
254 |
} |
|
255 |
||
256 |
||
257 |
||
258 |
TInt Cregister_message::Test1L( CStifItemParser& aItem ) |
|
259 |
{ |
|
260 |
||
261 |
||
262 |
Cheader_test* test = Cheader_test::NewL(); |
|
263 |
||
264 |
test->Start(); |
|
265 |
||
266 |
test->CancelNotification(); |
|
267 |
delete test; |
|
268 |
||
269 |
TInt ret = iResult; |
|
270 |
return ret; |
|
271 |
||
272 |
||
273 |
} |
|
274 |
||
275 |
// ----------------------------------------------------------------------------- |
|
276 |
// Cregister_message::?member_function |
|
277 |
// ?implementation_description |
|
278 |
// (other items were commented in a header). |
|
279 |
// ----------------------------------------------------------------------------- |
|
280 |
// |
|
281 |
/* |
|
282 |
TInt Cregister_message::?member_function( |
|
283 |
CItemParser& aItem ) |
|
284 |
{ |
|
285 |
||
286 |
?code |
|
287 |
||
288 |
} |
|
289 |
*/ |
|
290 |
||
291 |
// ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
292 |
// None |
|
293 |
||
294 |
// End of File |