|
1 // Copyright (c) 2003-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 #include <smutset.h> |
|
20 #include <msvapi.h> |
|
21 #include <smuthdr.h> |
|
22 #include <e32std.h> |
|
23 #include <txtfmlyr.h> |
|
24 #include <txtrich.h> |
|
25 |
|
26 #include "CMtfTestActionUtilsSmsScripts.h" |
|
27 #include "CMtfTestActionUtilsConfigFileParser.h" |
|
28 #include "CMtfTestCase.h" |
|
29 #include "TestFrameworkActionsUtils.h" |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 // Constants to read the values out of the settings file |
|
36 |
|
37 // Service Centre |
|
38 _LIT(KScriptItemSC, "SC"); |
|
39 |
|
40 // Default Service Centre |
|
41 _LIT(KScriptItemDefaultSC, "DefaultSC"); |
|
42 |
|
43 // Bearer |
|
44 _LIT(KScriptItemBearer, "SmsBearer"); |
|
45 |
|
46 // Encoding |
|
47 _LIT(KScriptItemEncoding, "Encoding"); |
|
48 |
|
49 // Delivery Report |
|
50 _LIT(KScriptItemDeliveryReport, "DeliveryReport"); |
|
51 |
|
52 // Reply Quoted |
|
53 _LIT(KScriptItemReplyQuoted, "ReplyQuoted"); |
|
54 |
|
55 // Description Length |
|
56 _LIT(KScriptItemDescriptionLength, "DescriptionLength"); |
|
57 |
|
58 // Can concatenate |
|
59 _LIT(KScriptItemCanConcatenate, "CanConcatenate"); |
|
60 |
|
61 // Reply Path |
|
62 _LIT(KScriptItemReplyPath, "ReplyPath"); |
|
63 |
|
64 // Reject duplicate |
|
65 _LIT(KScriptItemRejectDuplicate, "RejectDuplicate"); |
|
66 |
|
67 // Validity period |
|
68 _LIT(KScriptItemValidityPeriod, "ValidityPeriod"); |
|
69 |
|
70 // Delivery |
|
71 _LIT(KScriptItemDelivery, "Delivery"); |
|
72 |
|
73 // Status Report Handling |
|
74 _LIT(KScriptItemStatusReportHandling, "StatusReportHandling"); |
|
75 |
|
76 // Special Message Handling |
|
77 _LIT(KScriptItemSpecialMessageHandling, "SpecialMessageHandling"); |
|
78 |
|
79 // Commdb Action |
|
80 _LIT(KScriptItemSmsCommdbAction, "CommdbAction"); |
|
81 |
|
82 // Sms Bearer Action |
|
83 _LIT(KScriptItemSmsBearerAction, "SmsBearerAction"); |
|
84 |
|
85 // Message Conversion |
|
86 _LIT(KScriptItemSmsMessageConversion, "MessageConversion"); |
|
87 |
|
88 // Validity Period Format |
|
89 _LIT(KScriptItemSmsValidityPeriodFormat, "ValidityPeriodFormat"); |
|
90 |
|
91 // Class2 Folder |
|
92 _LIT(KScriptItemClass2Folder, "Class2Folder"); |
|
93 |
|
94 // Recipient |
|
95 _LIT(KRecipient, "Recipients"); |
|
96 |
|
97 // Message Body |
|
98 _LIT(KMessageBody, "Message"); |
|
99 |
|
100 //Bio Uid |
|
101 _LIT(KBioUId, "BioUIdType"); |
|
102 |
|
103 //Last Segment Delivery Report |
|
104 _LIT(KLastSegmentDeliveryReport, "LastSegmentDeliveryReport"); |
|
105 |
|
106 |
|
107 class MDummySessionObserver : public MMsvSessionObserver |
|
108 { |
|
109 public: |
|
110 void HandleSessionEventL(TMsvSessionEvent,TAny*,TAny*,TAny*) {}; |
|
111 }; |
|
112 |
|
113 |
|
114 |
|
115 void CMtfTestActionUtilsSmsScripts::ReadSmsSettingsFromConfigurationFileL(CMtfTestCase& aTestCase, const TDesC& aSettingsFile, CSmsSettings& aSmsSettings) |
|
116 { |
|
117 CMtfTestActionUtilsConfigFileParser* scriptFileParser = CMtfTestActionUtilsConfigFileParser::NewL(aSettingsFile); |
|
118 CleanupStack::PushL(scriptFileParser); |
|
119 |
|
120 TPtrC stringPtr; |
|
121 TInt intValue; |
|
122 |
|
123 // Service Centre |
|
124 if(scriptFileParser->GetFieldAsString(KScriptItemSC, stringPtr) == KErrNone) |
|
125 { |
|
126 // get the addresses from the config file |
|
127 TLex detailsToParse(stringPtr); |
|
128 TPtrC scName; |
|
129 TPtrC scNumber; |
|
130 |
|
131 detailsToParse.SkipSpaceAndMark(); |
|
132 while(!detailsToParse.Eos()) |
|
133 { |
|
134 scName.Set(_L("Unknown")); // default SC name |
|
135 |
|
136 while(detailsToParse.Peek() != ';' && !detailsToParse.Eos()) // SCs' details separated by semi-colon |
|
137 { |
|
138 if(detailsToParse.Peek() == ',') // name and number separated by comma |
|
139 { // has a name specified |
|
140 scName.Set(detailsToParse.MarkedToken()); |
|
141 detailsToParse.Inc(); |
|
142 detailsToParse.SkipSpaceAndMark(); |
|
143 } |
|
144 else |
|
145 detailsToParse.Inc(); |
|
146 } |
|
147 |
|
148 scNumber.Set(detailsToParse.MarkedToken()); |
|
149 |
|
150 // add the address to the SCs list |
|
151 |
|
152 aSmsSettings.AddServiceCenterL(scName, scNumber); |
|
153 |
|
154 |
|
155 detailsToParse.Inc(); |
|
156 detailsToParse.SkipSpaceAndMark(); |
|
157 } |
|
158 } |
|
159 |
|
160 // Default Service Centre |
|
161 if(scriptFileParser->GetFieldAsInteger(KScriptItemDefaultSC, intValue) == KErrNone) |
|
162 { |
|
163 |
|
164 aSmsSettings.SetDefaultServiceCenter(intValue); |
|
165 |
|
166 } |
|
167 |
|
168 // Bearer |
|
169 if(scriptFileParser->GetFieldAsString(KScriptItemBearer, stringPtr) == KErrNone) |
|
170 { |
|
171 CSmsSettings::TMobileSmsBearer smsBearer = ObtainValueParameterL<CSmsSettings::TMobileSmsBearer>(aTestCase, stringPtr); |
|
172 aSmsSettings.SetSmsBearer(smsBearer); |
|
173 } |
|
174 |
|
175 // Encoding |
|
176 if(scriptFileParser->GetFieldAsString(KScriptItemEncoding, stringPtr) == KErrNone) |
|
177 { |
|
178 TSmsDataCodingScheme::TSmsAlphabet characterSet = ObtainValueParameterL<TSmsDataCodingScheme::TSmsAlphabet>(aTestCase, stringPtr); |
|
179 aSmsSettings.SetCharacterSet(characterSet); |
|
180 } |
|
181 |
|
182 // Delivery Report |
|
183 if(scriptFileParser->GetFieldAsString(KScriptItemDeliveryReport, stringPtr) == KErrNone) |
|
184 { |
|
185 if (stringPtr.CompareF(_L("NO")) == 0) |
|
186 { |
|
187 aSmsSettings.SetDeliveryReport(EFalse); |
|
188 } |
|
189 else if (stringPtr.CompareF(_L("YES")) == 0) |
|
190 { |
|
191 aSmsSettings.SetDeliveryReport(ETrue); |
|
192 } |
|
193 } |
|
194 |
|
195 // Reply quoted |
|
196 if(scriptFileParser->GetFieldAsString(KScriptItemReplyQuoted, stringPtr) == KErrNone) |
|
197 { |
|
198 if (stringPtr.CompareF(_L("NO")) == 0) |
|
199 { |
|
200 aSmsSettings.SetReplyQuoted(EFalse); |
|
201 } |
|
202 else if (stringPtr.CompareF(_L("YES")) == 0) |
|
203 { |
|
204 aSmsSettings.SetReplyQuoted(ETrue); |
|
205 } |
|
206 } |
|
207 |
|
208 // Description length |
|
209 if(scriptFileParser->GetFieldAsInteger(KScriptItemDescriptionLength, intValue) == KErrNone) |
|
210 { |
|
211 aSmsSettings.SetDescriptionLength(intValue); |
|
212 } |
|
213 |
|
214 |
|
215 // Can Concatenate |
|
216 if(scriptFileParser->GetFieldAsString(KScriptItemCanConcatenate, stringPtr) == KErrNone) |
|
217 { |
|
218 if (stringPtr.CompareF(_L("NO")) == 0) |
|
219 { |
|
220 aSmsSettings.SetCanConcatenate(EFalse); |
|
221 } |
|
222 else if (stringPtr.CompareF(_L("YES")) == 0) |
|
223 { |
|
224 aSmsSettings.SetCanConcatenate(ETrue); |
|
225 } |
|
226 } |
|
227 |
|
228 // Reply path |
|
229 if(scriptFileParser->GetFieldAsString(KScriptItemReplyPath, stringPtr) == KErrNone) |
|
230 { |
|
231 if (stringPtr.CompareF(_L("NO")) == 0) |
|
232 { |
|
233 aSmsSettings.SetReplyPath(EFalse); |
|
234 } |
|
235 else if (stringPtr.CompareF(_L("YES")) == 0) |
|
236 { |
|
237 aSmsSettings.SetReplyPath(ETrue); |
|
238 } |
|
239 } |
|
240 |
|
241 // Reject duplicate |
|
242 if(scriptFileParser->GetFieldAsString(KScriptItemRejectDuplicate, stringPtr) == KErrNone) |
|
243 { |
|
244 if (stringPtr.CompareF(_L("NO")) == 0) |
|
245 { |
|
246 aSmsSettings.SetRejectDuplicate(EFalse); |
|
247 } |
|
248 else if (stringPtr.CompareF(_L("YES")) == 0) |
|
249 { |
|
250 aSmsSettings.SetRejectDuplicate(ETrue); |
|
251 } |
|
252 } |
|
253 |
|
254 // Validity period, value is read in minutes |
|
255 if(scriptFileParser->GetFieldAsInteger(KScriptItemValidityPeriod, intValue) == KErrNone) |
|
256 { |
|
257 aSmsSettings.SetValidityPeriod(TTimeIntervalMinutes(intValue)); |
|
258 } |
|
259 |
|
260 // Delivery |
|
261 if(scriptFileParser->GetFieldAsString(KScriptItemDelivery, stringPtr) == KErrNone) |
|
262 { |
|
263 TSmsDelivery delivery = ObtainValueParameterL<TSmsDelivery>(aTestCase, stringPtr); |
|
264 aSmsSettings.SetDelivery(delivery); |
|
265 } |
|
266 |
|
267 // Status Report Handling |
|
268 if(scriptFileParser->GetFieldAsString(KScriptItemStatusReportHandling, stringPtr) == KErrNone) |
|
269 { |
|
270 CSmsSettings::TSmsReportHandling statusReportHandling = ObtainValueParameterL<CSmsSettings::TSmsReportHandling>(aTestCase, stringPtr); |
|
271 aSmsSettings.SetStatusReportHandling(statusReportHandling); |
|
272 } |
|
273 |
|
274 // Special Message Handling |
|
275 if(scriptFileParser->GetFieldAsString(KScriptItemSpecialMessageHandling, stringPtr) == KErrNone) |
|
276 { |
|
277 CSmsSettings::TSmsReportHandling specialMessageHandling = ObtainValueParameterL<CSmsSettings::TSmsReportHandling>(aTestCase, stringPtr); |
|
278 aSmsSettings.SetSpecialMessageHandling(specialMessageHandling); |
|
279 } |
|
280 |
|
281 // Commdb action |
|
282 if(scriptFileParser->GetFieldAsString(KScriptItemSmsCommdbAction, stringPtr) == KErrNone) |
|
283 { |
|
284 CSmsSettings::TSmsSettingsCommDbAction commdbAction = ObtainValueParameterL<CSmsSettings::TSmsSettingsCommDbAction>(aTestCase, stringPtr); |
|
285 aSmsSettings.SetCommDbAction(commdbAction); |
|
286 } |
|
287 |
|
288 // Sms Bearer Action |
|
289 if(scriptFileParser->GetFieldAsString(KScriptItemSmsBearerAction, stringPtr) == KErrNone) |
|
290 { |
|
291 CSmsSettings::TSmsSettingsCommDbAction smsBearerAction = ObtainValueParameterL<CSmsSettings::TSmsSettingsCommDbAction>(aTestCase, stringPtr); |
|
292 aSmsSettings.SetSmsBearerAction(smsBearerAction); |
|
293 } |
|
294 |
|
295 // Message Conversion |
|
296 if(scriptFileParser->GetFieldAsString(KScriptItemSmsMessageConversion, stringPtr) == KErrNone) |
|
297 { |
|
298 TSmsPIDConversion messageConversion = ObtainValueParameterL<TSmsPIDConversion>(aTestCase, stringPtr); |
|
299 aSmsSettings.SetMessageConversion(messageConversion); |
|
300 } |
|
301 |
|
302 // Vailidity Period Format |
|
303 if(scriptFileParser->GetFieldAsString(KScriptItemSmsValidityPeriodFormat, stringPtr) == KErrNone) |
|
304 { |
|
305 TSmsFirstOctet::TSmsValidityPeriodFormat valPeriodFormat = ObtainValueParameterL<TSmsFirstOctet::TSmsValidityPeriodFormat>(aTestCase, stringPtr); |
|
306 aSmsSettings.SetValidityPeriodFormat(valPeriodFormat); |
|
307 } |
|
308 |
|
309 // Class2 Folder |
|
310 if(scriptFileParser->GetFieldAsString(KScriptItemClass2Folder, stringPtr) == KErrNone) |
|
311 { |
|
312 // Try to find a folder with that name |
|
313 MDummySessionObserver obser; |
|
314 CMsvSession* session = CMsvSession::OpenSyncL(obser); |
|
315 CleanupStack::PushL(session); |
|
316 |
|
317 CMsvEntry* entry = CMsvEntry::NewL(*session, KMsvLocalServiceIndexEntryId, TMsvSelectionOrdering(KMsvGroupByStandardFolders||KMsvGroupByType,EMsvSortByNone)); |
|
318 CleanupStack::PushL(entry); |
|
319 entry->SetEntryL(KMsvLocalServiceIndexEntryId); // Search only the local folders |
|
320 |
|
321 TMsvSelectionOrdering order; |
|
322 order.SetShowInvisibleEntries(ETrue); |
|
323 entry->SetSortTypeL(order); |
|
324 |
|
325 CMsvEntrySelection* selection = entry->ChildrenL(); |
|
326 CleanupStack::PushL(selection); |
|
327 |
|
328 TBool found = EFalse; |
|
329 TInt count = selection->Count(); |
|
330 for (TInt i=0; i<count; i++) |
|
331 { |
|
332 entry->SetEntryL((*selection)[i]); |
|
333 if ((stringPtr.CompareF(entry->Entry().iDescription) == 0) || |
|
334 (stringPtr.CompareF(entry->Entry().iDetails) == 0)) |
|
335 { |
|
336 found = ETrue; |
|
337 break; |
|
338 } |
|
339 } |
|
340 |
|
341 TMsvId entryId = KMsvGlobalInBoxIndexEntryId; |
|
342 if (found) |
|
343 entryId = entry->Entry().Id(); |
|
344 else |
|
345 User::Leave(KErrNotFound); |
|
346 |
|
347 aSmsSettings.SetClass2Folder(entryId); |
|
348 |
|
349 CleanupStack::PopAndDestroy(3, session); // selection, entry, session |
|
350 } |
|
351 |
|
352 //Last Segment Delivery Report |
|
353 if(scriptFileParser->GetFieldAsString(KLastSegmentDeliveryReport, stringPtr) == KErrNone) |
|
354 { |
|
355 if (stringPtr.CompareF(_L("NO")) == 0) |
|
356 { |
|
357 aSmsSettings.SetLastSegmentDeliveryReport(EFalse); |
|
358 } |
|
359 else if (stringPtr.CompareF(_L("YES")) == 0) |
|
360 { |
|
361 aSmsSettings.SetLastSegmentDeliveryReport(ETrue); |
|
362 } |
|
363 } |
|
364 |
|
365 CleanupStack::PopAndDestroy(scriptFileParser); |
|
366 } |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 TInt CMtfTestActionUtilsSmsScripts::SetSmsHeaderInfoFromConfigurationFileL(CMtfTestCase& aTestCase, const TDesC& aSettingsFile, CSmsHeader& aSmsHeader) |
|
372 { |
|
373 CMtfTestActionUtilsConfigFileParser* scriptFileParser = CMtfTestActionUtilsConfigFileParser::NewL(aSettingsFile); |
|
374 CleanupStack::PushL(scriptFileParser); |
|
375 |
|
376 // Recipient Number: If the recipient number is not present in the file, Leave. |
|
377 TPtrC stringPtr; |
|
378 User::LeaveIfError(scriptFileParser->GetFieldAsString(KRecipient,stringPtr)); |
|
379 |
|
380 CSmsNumber* recipientNumber = CSmsNumber::NewL(); |
|
381 CleanupStack::PushL(recipientNumber); |
|
382 recipientNumber->SetAddressL(stringPtr); |
|
383 aSmsHeader.Recipients().AppendL(recipientNumber); |
|
384 |
|
385 //Bio UId Type |
|
386 if((scriptFileParser->GetFieldAsString(KBioUId,stringPtr)) == KErrNone) |
|
387 { |
|
388 TBioMsgIdType bioIdType = ObtainValueParameterL<TBioMsgIdType>(aTestCase, stringPtr); |
|
389 aSmsHeader.SetBioMsgIdType(bioIdType); |
|
390 } |
|
391 else |
|
392 { |
|
393 aSmsHeader.SetBioMsgIdType(); //Sets the message's BIO message type identifier as EBioMsgIdNbs |
|
394 } |
|
395 |
|
396 CleanupStack::Pop(2); |
|
397 return KErrNone; |
|
398 } |
|
399 |
|
400 TInt CMtfTestActionUtilsSmsScripts::GetSmsMessageBodyL(const TDesC& aSettingsFile, TPtrC& aMessageBody) |
|
401 { |
|
402 CMtfTestActionUtilsConfigFileParser* scriptFileParser = CMtfTestActionUtilsConfigFileParser::NewL(aSettingsFile); |
|
403 CleanupStack::PushL(scriptFileParser); |
|
404 |
|
405 // Check if SMS message body is specified in the data file, if not leave |
|
406 TInt returnValue; |
|
407 returnValue = scriptFileParser->GetFieldAsString(KMessageBody, aMessageBody); |
|
408 CleanupStack::Pop(scriptFileParser); |
|
409 |
|
410 return returnValue; |
|
411 } |