|
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 <e32cons.h> |
|
24 #include <e32base.h> |
|
25 #include <StifParser.h> |
|
26 #include <Stiftestinterface.h> |
|
27 #include "change_status_message.h" |
|
28 //#include <senduiconsts.h> |
|
29 #include <CMsvAttachment.h> |
|
30 #include "messagingservice.h" |
|
31 #include "messageheader.h" |
|
32 |
|
33 // EXTERNAL DATA STRUCTURES |
|
34 //extern ?external_data; |
|
35 |
|
36 // EXTERNAL FUNCTION PROTOTYPES |
|
37 //extern ?external_function( ?arg_type,?arg_type ); |
|
38 |
|
39 // CONSTANTS |
|
40 //const ?type ?constant_var = ?constant; |
|
41 |
|
42 // MACROS |
|
43 //#define ?macro ?macro_def |
|
44 |
|
45 // LOCAL CONSTANTS AND MACROS |
|
46 //const ?type ?constant_var = ?constant; |
|
47 //#define ?macro_name ?macro_def |
|
48 |
|
49 // MODULE DATA STRUCTURES |
|
50 //enum ?declaration |
|
51 //typedef ?declaration |
|
52 |
|
53 // LOCAL FUNCTION PROTOTYPES |
|
54 //?type ?function_name( ?arg_type, ?arg_type ); |
|
55 |
|
56 // FORWARD DECLARATIONS |
|
57 //class ?FORWARD_CLASSNAME; |
|
58 |
|
59 // ============================= LOCAL FUNCTIONS =============================== |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // ?function_name ?description. |
|
63 // ?description |
|
64 // Returns: ?value_1: ?description |
|
65 // ?value_n: ?description_line1 |
|
66 // ?description_line2 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 /* |
|
70 ?type ?function_name( |
|
71 ?arg_type arg, // ?description |
|
72 ?arg_type arg) // ?description |
|
73 { |
|
74 |
|
75 ?code // ?comment |
|
76 |
|
77 // ?comment |
|
78 ?code |
|
79 } |
|
80 */ |
|
81 |
|
82 // ============================ MEMBER FUNCTIONS =============================== |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // Cchange_status_message::Delete |
|
86 // Delete here all resources allocated and opened from test methods. |
|
87 // Called from destructor. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void Cchange_status_message::Delete() |
|
91 { |
|
92 |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // Cchange_status_message::RunMethodL |
|
97 // Run specified method. Contains also table of test mothods and their names. |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 TInt Cchange_status_message::RunMethodL( |
|
101 CStifItemParser& aItem ) |
|
102 { |
|
103 |
|
104 static TStifFunctionInfo const KFunctions[] = |
|
105 { |
|
106 // Copy this line for every implemented function. |
|
107 // First string is the function name used in TestScripter script file. |
|
108 // Second is the actual implementation member function. |
|
109 ENTRY( "test_1", Cchange_status_message::Test1L ), |
|
110 |
|
111 }; |
|
112 |
|
113 const TInt count = sizeof( KFunctions ) / |
|
114 sizeof( TStifFunctionInfo ); |
|
115 |
|
116 return RunInternalL( KFunctions, count, aItem ); |
|
117 |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // Cchange_status_message::ExampleL |
|
122 // Example test method function. |
|
123 // (other items were commented in a header). |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 |
|
127 TInt Cchange_status_message::messageid_func(CStifItemParser& aItem,TInt& id) |
|
128 { |
|
129 TInt err = aItem.GetNextInt(id); |
|
130 if(err) |
|
131 { |
|
132 ////iLog->Log(_L("Failed to Get message id")); |
|
133 return KErrGeneral; |
|
134 }; |
|
135 return KErrNone; |
|
136 } |
|
137 |
|
138 TInt Cchange_status_message::status_func(CStifItemParser& aItem,TInt& status) |
|
139 { |
|
140 TInt err = aItem.GetNextInt(status); |
|
141 if(err) |
|
142 { |
|
143 //iLog->Log(_L("Failed to Get status ")); |
|
144 return KErrGeneral; |
|
145 }; |
|
146 return KErrNone; |
|
147 } |
|
148 |
|
149 TInt Cchange_status_message::flag_func(CStifItemParser& aItem,TInt& flag) |
|
150 { |
|
151 TInt err = aItem.GetNextInt(flag); |
|
152 if(err) |
|
153 { |
|
154 ////iLog->Log(_L("Failed to Get status flag or err code ")); |
|
155 return KErrGeneral; |
|
156 }; |
|
157 return KErrNone; |
|
158 } |
|
159 |
|
160 |
|
161 TInt Cchange_status_message::Test1L( CStifItemParser& aItem ) |
|
162 { |
|
163 |
|
164 __UHEAP_MARK; |
|
165 |
|
166 TInt id,status,flag; |
|
167 TMsvId iD; |
|
168 |
|
169 TInt err1 = messageid_func(aItem,id); |
|
170 if(err1) |
|
171 { |
|
172 return KErrGeneral; |
|
173 } |
|
174 |
|
175 if(id == 1) |
|
176 { |
|
177 CMessagingService* mservice = (CMessagingService*)CMessagingService::NewL(); |
|
178 CleanupStack::PushL(mservice); |
|
179 CFilterParamInfo* mfilter = CFilterParamInfo::NewL(); |
|
180 CMsvEntrySelection* marray = NULL ; |
|
181 TRAPD(err,mservice->GetIdListL(mfilter,0,NULL ,marray)); |
|
182 TInt index = 0; |
|
183 CMessageHeader* headerarr = NULL; |
|
184 mservice->GetNextHeaderL(mfilter, marray, index, NULL, headerarr); |
|
185 TMsvId message_id; |
|
186 headerarr->GetMessageId(message_id); |
|
187 iD = message_id; |
|
188 delete headerarr; |
|
189 delete marray; |
|
190 delete mfilter; |
|
191 CleanupStack::PopAndDestroy(mservice); |
|
192 } |
|
193 else |
|
194 { |
|
195 iD = id; // message id specified |
|
196 } |
|
197 |
|
198 err1 = status_func(aItem,status); |
|
199 if(err1) |
|
200 { |
|
201 return KErrGeneral; |
|
202 } |
|
203 |
|
204 TMessageStatusFlag State = (TMessageStatusFlag)status; |
|
205 |
|
206 err1 = flag_func(aItem,flag); |
|
207 if(err1) |
|
208 { |
|
209 return KErrGeneral; |
|
210 } |
|
211 |
|
212 |
|
213 CMessagingService* service = (CMessagingService*)CMessagingService::NewL(); |
|
214 CleanupStack::PushL(service); |
|
215 |
|
216 TRAPD(err, service->ChangeStatusL(iD,State,flag,NULL)); |
|
217 |
|
218 if(err == 0) |
|
219 { |
|
220 |
|
221 CFilterParamInfo* filter = CFilterParamInfo::NewL(); |
|
222 filter->SetMessageIdFilter(iD); |
|
223 |
|
224 CMsvEntrySelection* array = NULL ; |
|
225 TRAPD(error,service->GetIdListL(filter,0,NULL ,array)); |
|
226 |
|
227 TInt index = 0; |
|
228 CMessageHeader* headers = NULL; |
|
229 service->GetNextHeaderL(filter, array, index, NULL, headers); |
|
230 |
|
231 TBool fl; |
|
232 headers->GetUnreadFlag(fl); |
|
233 |
|
234 TInt fla = fl; |
|
235 |
|
236 delete headers; |
|
237 delete array; |
|
238 delete filter; |
|
239 CleanupStack::PopAndDestroy(service); |
|
240 |
|
241 if((status == 0) && (flag == 1)) |
|
242 { |
|
243 if(fla == 32) |
|
244 { |
|
245 __UHEAP_MARKEND; |
|
246 return KErrNone; |
|
247 } |
|
248 else |
|
249 { |
|
250 __UHEAP_MARKEND; |
|
251 return KErrGeneral; |
|
252 } |
|
253 } |
|
254 else if((status == 0) && (flag == 0)) |
|
255 { |
|
256 if(fla == 0) |
|
257 { |
|
258 __UHEAP_MARKEND; |
|
259 return KErrNone; |
|
260 } |
|
261 else |
|
262 { |
|
263 __UHEAP_MARKEND; |
|
264 return KErrGeneral; |
|
265 } |
|
266 } |
|
267 else |
|
268 { |
|
269 __UHEAP_MARKEND; |
|
270 return KErrGeneral; |
|
271 } |
|
272 } |
|
273 else |
|
274 { |
|
275 err1 = flag_func(aItem,flag); // get err code from cfg |
|
276 if(err1) |
|
277 { |
|
278 return KErrGeneral; |
|
279 } |
|
280 |
|
281 CleanupStack::PopAndDestroy(service); |
|
282 |
|
283 if(err == flag) |
|
284 { |
|
285 __UHEAP_MARKEND; |
|
286 return KErrNone; |
|
287 } |
|
288 else |
|
289 { |
|
290 __UHEAP_MARKEND; |
|
291 return KErrGeneral; |
|
292 } |
|
293 } |
|
294 |
|
295 } |
|
296 |
|
297 // ----------------------------------------------------------------------------- |
|
298 // Cchange_status_message::?member_function |
|
299 // ?implementation_description |
|
300 // (other items were commented in a header). |
|
301 // ----------------------------------------------------------------------------- |
|
302 // |
|
303 /* |
|
304 TInt Cchange_status_message::?member_function( |
|
305 CItemParser& aItem ) |
|
306 { |
|
307 |
|
308 ?code |
|
309 |
|
310 } |
|
311 */ |
|
312 |
|
313 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
314 // None |
|
315 |
|
316 // End of File |