|
1 // Copyright (c) 2004-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 // TestMessCreateCdmsSmsUtil.cpp |
|
15 // This class creates the Cdma sms header and the service settings |
|
16 // |
|
17 // |
|
18 |
|
19 #include "TestMessCreateCdmaSmsUtil.h" |
|
20 #include "TestMessCreateSmsAccount.h" |
|
21 |
|
22 // EPOC includes |
|
23 #include <csmsaccount.h> |
|
24 |
|
25 /*@{*/ |
|
26 _LIT(KPtDeliveryAck, "DeliveryAck"); |
|
27 _LIT(KPtUserAck, "UserAck"); |
|
28 _LIT(KPtReadAck, "ReadAck"); |
|
29 _LIT(KPtMessageConversion, "MessageConversion"); |
|
30 _LIT(KPtPriorityIndicator, "PriorityIndicator"); |
|
31 _LIT(KPtPrivacyIndicator, "PrivacyIndicator"); |
|
32 _LIT(KPtReplyOption, "ReplyOption"); |
|
33 _LIT(KPtAlertonDelivery, "AlertonDelivery"); |
|
34 _LIT(KPtLanguageIndicator, "LanguageIndicator"); |
|
35 |
|
36 //Constants used |
|
37 _LIT(KPtTeleService, "TeleService"); |
|
38 _LIT(KPtSubmit, "Submit"); |
|
39 _LIT(KPtCancel, "Cancel"); |
|
40 |
|
41 // Supported Teleservices |
|
42 _LIT(KPtTeleWmt, "WMT"); |
|
43 _LIT(KPtTeleWemt, "WEMT"); |
|
44 _LIT(KPtTeleWpt, "WPT"); |
|
45 _LIT(KPtTeleVmn, "VMN"); |
|
46 _LIT(KPtTeleScpt, "SCPT"); |
|
47 _LIT(KPtTeleCatpt, "CATPT"); |
|
48 _LIT(KPtTeleCmt91, "CMT91"); |
|
49 _LIT(KPtTeleWap, "WAP"); |
|
50 |
|
51 // Supported message conversion formats |
|
52 _LIT(KPtPidFax, "Fax"); |
|
53 _LIT(KPtPidX400, "X400"); |
|
54 _LIT(KPtPidPaging, "Paging"); |
|
55 _LIT(KPtPidMail, "Mail"); |
|
56 _LIT(KPtPidErmes, "Ermes"); |
|
57 _LIT(KPtPidSpeech, "Speech"); |
|
58 /*@}*/ |
|
59 |
|
60 /** |
|
61 Constructor |
|
62 */ |
|
63 CTestMessCreateCdmaSmsUtil ::CTestMessCreateCdmaSmsUtil(CTestMessBase& aTestStep) |
|
64 : CTestMessCreateSmsUtilBase(aTestStep) |
|
65 { |
|
66 aTestStep.INFO_PRINTF1(_L("The CDMA SMS util is created")); |
|
67 } |
|
68 |
|
69 /** |
|
70 Prepares the SMS account details for CSendAs/RSendAs |
|
71 @leave - KErrNoMemory |
|
72 @leave - System wide error codes |
|
73 */ |
|
74 void CTestMessCreateCdmaSmsUtil::PrepareAccountL(CMsvSession& /*aSession*/) |
|
75 { |
|
76 // Reads the teleservice |
|
77 tia637::TTeleserviceId teleServiceId=tia637::KTeleserviceWMT; |
|
78 TPtrC ptrTeleService; |
|
79 if( !(iTestStep.GetStringFromConfig(iTestStep.ConfigSection(), KPtTeleService, ptrTeleService))) |
|
80 { |
|
81 iTestStep.INFO_PRINTF1(_L("Teleservice is not provided. Default teleservice (WMT) is used")); |
|
82 } |
|
83 else |
|
84 { |
|
85 iTestStep.INFO_PRINTF2(_L("Teleservice to be set is : %S"), &ptrTeleService); |
|
86 |
|
87 //Get the teleservice Id |
|
88 teleServiceId = GetTeleServiceId(ptrTeleService); |
|
89 } |
|
90 |
|
91 if ( teleServiceId!=tia637::KTeleserviceWEMT ) |
|
92 { |
|
93 teleServiceId=tia637::KTeleserviceWMT; |
|
94 } |
|
95 |
|
96 CSmsSettings* smsSettings = CSmsSettings::NewL(); |
|
97 CleanupStack::PushL(smsSettings); |
|
98 |
|
99 CSmsAccount* smsAccount=CSmsAccount::NewLC(); |
|
100 smsAccount->LoadSettingsL(*smsSettings); |
|
101 smsSettings->SetDefaultTeleservice(teleServiceId); |
|
102 smsAccount->SaveSettingsL(*smsSettings); |
|
103 CleanupStack::PopAndDestroy(smsAccount); |
|
104 CleanupStack::PopAndDestroy(smsSettings); |
|
105 } |
|
106 |
|
107 /** |
|
108 Creates a new CDMA sms header object |
|
109 @param aBodyText - body text of the message |
|
110 @return CSmsHeader - pointer of the CSmsHeader object |
|
111 @leave - KErrNoMemory |
|
112 @leave - System wide error codes |
|
113 */ |
|
114 CSmsHeader* CTestMessCreateCdmaSmsUtil::NewHeaderL(CRichText& aBodyText) |
|
115 { |
|
116 return CSmsHeader::NewL(KSmsTypeSubmit, aBodyText); |
|
117 } |
|
118 |
|
119 /** |
|
120 Fill up the header object with data read from the ini file |
|
121 @param aSmsHeader - reference for the sms header object |
|
122 @leave - System wide error codes |
|
123 */ |
|
124 void CTestMessCreateCdmaSmsUtil::PrepareHeaderL(CSmsHeader& aSmsHeader) |
|
125 { |
|
126 // Get bearer data |
|
127 TPtrC ptrBearer; |
|
128 TBool returnValue=iTestStep.GetStringFromConfig(iTestStep.ConfigSection(), KBearer, ptrBearer); |
|
129 if ( !returnValue ) |
|
130 { |
|
131 //If no bearer provided, the bearer is read from the default section ofthe |
|
132 // ini file |
|
133 returnValue=iTestStep.GetStringFromConfig(KDef, KDefBearer, ptrBearer); |
|
134 } |
|
135 |
|
136 if ( returnValue ) |
|
137 { |
|
138 //default value for the bearer |
|
139 TBioMsgIdType bearer = EBioMsgIdNbs; |
|
140 |
|
141 iTestStep.INFO_PRINTF2(_L("Bearer = %S"), &ptrBearer); |
|
142 if (ptrBearer.CompareF(KBearerWap) == 0) |
|
143 { |
|
144 //Wap message ID |
|
145 bearer = EBioMsgIdWap; |
|
146 } |
|
147 else if (ptrBearer.CompareF(KBearerWapSecure) == 0) |
|
148 { |
|
149 //WapSecure message ID |
|
150 bearer = EBioMsgIdWapSecure; |
|
151 } |
|
152 else |
|
153 { |
|
154 iTestStep.ERR_PRINTF1(_L("No bearer provided. Default is used")); |
|
155 } |
|
156 |
|
157 //Set the BIO Message ID type |
|
158 aSmsHeader.BioMessage().SetBioMsgIdType(bearer); |
|
159 } |
|
160 |
|
161 // Get encoding data |
|
162 TInt encoding; |
|
163 returnValue=iTestStep.GetIntFromConfig(iTestStep.ConfigSection(), KEncoding, encoding); |
|
164 if ( !returnValue ) |
|
165 { |
|
166 //If no encoding is provided, the encoding is read from the default section |
|
167 //of the ini file |
|
168 returnValue=iTestStep.GetIntFromConfig(KDef, KDefEncoding, encoding); |
|
169 } |
|
170 if ( returnValue ) |
|
171 { |
|
172 //Default encoding value. |
|
173 TSmsCharacterEncoding charEncoding = KSmsEncodingUnicode; |
|
174 |
|
175 iTestStep.INFO_PRINTF2(_L("Encoding = %d"), encoding); |
|
176 switch (encoding) |
|
177 { |
|
178 case 7: |
|
179 //7 bit encoding format |
|
180 charEncoding = KSmsEncoding7BitASCII; |
|
181 break; |
|
182 case 8: |
|
183 //8 bit encoding format |
|
184 charEncoding = KSmsEncodingBinary; |
|
185 break; |
|
186 case 16: |
|
187 //unicode encoding format |
|
188 charEncoding = KSmsEncodingUnicode; |
|
189 break; |
|
190 default: |
|
191 //default encoding format |
|
192 charEncoding = KSmsEncodingUnicode; |
|
193 break; |
|
194 } |
|
195 //Set the character encoding format |
|
196 aSmsHeader.BioMessage().SetEncoding(charEncoding); |
|
197 } |
|
198 |
|
199 |
|
200 TBool deliveryAck = EFalse; |
|
201 TBool userAck = EFalse; |
|
202 TBool readAck = EFalse; |
|
203 |
|
204 // Get acknowledgements report request |
|
205 TPtrC ptrDeliveryReport; |
|
206 returnValue=iTestStep.GetStringFromConfig(iTestStep.ConfigSection(), KDeliveryReport, ptrDeliveryReport); |
|
207 if ( !returnValue ) |
|
208 { |
|
209 returnValue=iTestStep.GetStringFromConfig(KDef, KDefDeliveryReport, ptrDeliveryReport); |
|
210 } |
|
211 if ( returnValue ) |
|
212 { |
|
213 iTestStep.INFO_PRINTF2(_L("The acknowledgement request flag : %S"), &ptrDeliveryReport); |
|
214 if(ptrDeliveryReport.Compare(_L("NO")) == 0) |
|
215 { |
|
216 deliveryAck = EFalse; |
|
217 userAck = EFalse; |
|
218 readAck = EFalse; |
|
219 } |
|
220 if(ptrDeliveryReport.Compare(_L("YES")) == 0) |
|
221 { |
|
222 // Read different type of acknowledgements |
|
223 iTestStep.GetBoolFromConfig(iTestStep.ConfigSection(), KPtDeliveryAck, deliveryAck); |
|
224 iTestStep.INFO_PRINTF2(_L("The Delivery acknowledgement request flag : %d"), deliveryAck); |
|
225 iTestStep.GetBoolFromConfig(iTestStep.ConfigSection(), KPtUserAck, userAck); |
|
226 iTestStep.INFO_PRINTF2(_L("The User acknowledgement request flag : %d"), userAck); |
|
227 iTestStep.GetBoolFromConfig(iTestStep.ConfigSection(), KPtReadAck, readAck); |
|
228 iTestStep.INFO_PRINTF2(_L("The Read acknowledgement request flag : %d"), readAck); |
|
229 } |
|
230 } |
|
231 |
|
232 aSmsHeader.SetAcknowledgementRequest(ESmsAckTypeDelivery, deliveryAck); |
|
233 aSmsHeader.SetAcknowledgementRequest(ESmsAckTypeUser, userAck); |
|
234 aSmsHeader.SetAcknowledgementRequest(ESmsAckTypeRead, readAck); |
|
235 |
|
236 //Get the message conversion type |
|
237 TPtrC ptrMessageConversion; |
|
238 TSmsPIDConversion smsPidConversion = ESmsConvPIDNone; |
|
239 returnValue=iTestStep.GetStringFromConfig(iTestStep.ConfigSection(), KPtMessageConversion, ptrMessageConversion); |
|
240 if ( !returnValue ) |
|
241 { |
|
242 iTestStep.INFO_PRINTF1(_L("The message conversion is not provided. Default (PIDNone) is taken")); |
|
243 } |
|
244 if ( returnValue ) |
|
245 { |
|
246 iTestStep.INFO_PRINTF2(_L("The message conversion to be set is : %S"), &ptrMessageConversion); |
|
247 //Get the Message conversion id |
|
248 smsPidConversion = GetMessageConversionId(ptrMessageConversion); |
|
249 } |
|
250 //Set the message conversion. |
|
251 CSmsSettings *smsSettings = CSmsSettings::NewL(); |
|
252 CleanupStack::PushL(smsSettings); |
|
253 aSmsHeader.GetDefaultMessageSettingsL(*smsSettings); |
|
254 smsSettings->SetMessageConversion(smsPidConversion); |
|
255 CleanupStack::Pop(smsSettings); |
|
256 |
|
257 // Set the other message settings |
|
258 aSmsHeader.CdmaMessage().SetPrivacyIndicatorL(tia637::KBdRestricted); |
|
259 aSmsHeader.CdmaMessage().SetPriorityIndicatorL(tia637::KBdUrgent); |
|
260 aSmsHeader.CdmaMessage().SetAlertOnDeliveryL(tia637::KBdUseMediumPriorityAlert); |
|
261 aSmsHeader.CdmaMessage().SetLanguageIndicatorL(tia637::KLanguageEnglish); |
|
262 } |
|
263 |
|
264 /** |
|
265 Sets the cdma sms service settings fields using data read from the |
|
266 ini file. If no data is provided/read from ini file, the default |
|
267 account settings is used. |
|
268 @param aSmsSettings - reference of the CSmsSettings |
|
269 */ |
|
270 void CTestMessCreateCdmaSmsUtil::SetSmsAccountSettings(CSmsSettings& aSmsSettings) |
|
271 { |
|
272 iTestStep.INFO_PRINTF1(_L("Set SMS account Settings....")); |
|
273 TBool boolTemp; |
|
274 |
|
275 // Set the Reply quoted setting. |
|
276 if ( iTestStep.GetBoolFromConfig(iTestStep.ConfigSection(), KReplyQuoted, boolTemp) ) |
|
277 { |
|
278 aSmsSettings.SetReplyQuoted(boolTemp); |
|
279 } |
|
280 |
|
281 // Set the priority indicator |
|
282 if ( iTestStep.GetBoolFromConfig(iTestStep.ConfigSection(), KPtPriorityIndicator, boolTemp) ) |
|
283 { |
|
284 aSmsSettings.MessageSettings().Cdma().ActivateMessageSetting(tia637::KTPriorityIndicator, boolTemp); |
|
285 } |
|
286 |
|
287 //Set the Privacy Indicator |
|
288 if ( iTestStep.GetBoolFromConfig(iTestStep.ConfigSection(), KPtPrivacyIndicator, boolTemp) ) |
|
289 { |
|
290 aSmsSettings.MessageSettings().Cdma().ActivateMessageSetting(tia637::KTPrivacyIndicator, boolTemp); |
|
291 } |
|
292 |
|
293 //Set the Reply option |
|
294 if ( iTestStep.GetBoolFromConfig(iTestStep.ConfigSection(), KPtReplyOption, boolTemp) ) |
|
295 { |
|
296 aSmsSettings.MessageSettings().Cdma().ActivateMessageSetting(tia637::KTReplyOption, boolTemp); |
|
297 } |
|
298 |
|
299 //Set the alert on Message deliver |
|
300 if ( iTestStep.GetBoolFromConfig(iTestStep.ConfigSection(), KPtAlertonDelivery, boolTemp) ) |
|
301 { |
|
302 aSmsSettings.MessageSettings().Cdma().ActivateMessageSetting(tia637::KTAlertOnMessageDelivery, boolTemp); |
|
303 } |
|
304 |
|
305 //Set the Language Indicator |
|
306 if ( iTestStep.GetBoolFromConfig(iTestStep.ConfigSection(), KPtLanguageIndicator, boolTemp) ) |
|
307 { |
|
308 aSmsSettings.MessageSettings().Cdma().ActivateMessageSetting(tia637::KTLanguageIndicator, boolTemp); |
|
309 } |
|
310 |
|
311 aSmsSettings.SetValidityPeriod(ESmsVPWeek); // week |
|
312 aSmsSettings.SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFInteger); //relative |
|
313 aSmsSettings.SetDelivery(ESmsDeliveryImmediately); |
|
314 } |
|
315 |
|
316 /** |
|
317 Get the message type id |
|
318 @param aMessageType - TPtrC object holding the message type |
|
319 @return TSmsMessageType - message type id |
|
320 */ |
|
321 TSmsMessageType CTestMessCreateCdmaSmsUtil::GetMessageTypeId(const TDesC& aMessageType) |
|
322 { |
|
323 //Default message type is assigned |
|
324 TSmsMessageType smsMessageType = KSmsTypeSubmit; |
|
325 |
|
326 if( aMessageType.Compare(KPtSubmit) ==0) |
|
327 { |
|
328 smsMessageType = KSmsTypeSubmit; |
|
329 } |
|
330 else if( aMessageType.Compare(KPtCancel) ==0) |
|
331 { |
|
332 smsMessageType = KSmsTypeCdmaCancellation; |
|
333 } |
|
334 else |
|
335 { |
|
336 iTestStep.WARN_PRINTF1(_L("Invalid message type provided. Default is used")); |
|
337 } |
|
338 return smsMessageType; |
|
339 } |
|
340 |
|
341 /** |
|
342 Gets the Teleservice Id |
|
343 @param aTeleService - TPtrC holding the tele service name |
|
344 @return tia637::TTeleserviceId - teleservice id |
|
345 */ |
|
346 tia637::TTeleserviceId CTestMessCreateCdmaSmsUtil::GetTeleServiceId(const TDesC& aTeleService) |
|
347 { |
|
348 //default teleservice ID assigned |
|
349 tia637::TTeleserviceId teleServiceId = tia637::KTeleserviceWMT; |
|
350 |
|
351 iTestStep.INFO_PRINTF2(_L("Teleservice set is : %S"), &aTeleService); |
|
352 if( aTeleService.Compare(KPtTeleScpt) ==0) |
|
353 { |
|
354 teleServiceId = tia637::KTeleserviceSCPT; |
|
355 } |
|
356 else if( aTeleService.Compare(KPtTeleCatpt) ==0) |
|
357 { |
|
358 teleServiceId = tia637::KTeleserviceCATPT; |
|
359 } |
|
360 else if( aTeleService.Compare(KPtTeleCmt91) ==0) |
|
361 { |
|
362 teleServiceId = tia637::KTeleserviceCMT91; |
|
363 } |
|
364 else if( aTeleService.Compare(KPtTeleVmn) ==0) |
|
365 { |
|
366 teleServiceId = tia637::KTeleserviceVMN; |
|
367 } |
|
368 else if( aTeleService.Compare(KPtTeleWap) ==0) |
|
369 { |
|
370 teleServiceId = tia637::KTeleserviceWAP; |
|
371 } |
|
372 else if( aTeleService.Compare(KPtTeleWemt) ==0) |
|
373 { |
|
374 teleServiceId = tia637::KTeleserviceWEMT; |
|
375 } |
|
376 else if( aTeleService.Compare(KPtTeleWmt) ==0) |
|
377 { |
|
378 teleServiceId = tia637::KTeleserviceWMT; |
|
379 } |
|
380 else if( aTeleService.Compare(KPtTeleWpt) ==0) |
|
381 { |
|
382 teleServiceId = tia637::KTeleserviceWPT; |
|
383 } |
|
384 else |
|
385 { |
|
386 iTestStep.WARN_PRINTF1(_L("Invalid Teleservice provided. Default WMT used")); |
|
387 } |
|
388 |
|
389 return teleServiceId; |
|
390 } |
|
391 |
|
392 /** |
|
393 Gets the Message Conversion Id |
|
394 @param aTeleService - TPtrC holding the tele service name |
|
395 @return tia637::TTeleserviceId - teleservice id |
|
396 */ |
|
397 TSmsPIDConversion CTestMessCreateCdmaSmsUtil::GetMessageConversionId(const TDesC& aMessageConversion) |
|
398 { |
|
399 TSmsPIDConversion smsPidConv = ESmsConvPIDNone; |
|
400 |
|
401 iTestStep.INFO_PRINTF2(_L("The message conversion set is : %S"), &aMessageConversion); |
|
402 if( aMessageConversion.Compare(KPtPidFax) ==0) |
|
403 { |
|
404 smsPidConv = ESmsConvFax; |
|
405 } |
|
406 else if( aMessageConversion.Compare(KPtPidX400) ==0) |
|
407 { |
|
408 smsPidConv = ESmsConvX400; |
|
409 } |
|
410 else if( aMessageConversion.Compare(KPtPidPaging) ==0) |
|
411 { |
|
412 smsPidConv = ESmsConvPaging; |
|
413 } |
|
414 else if( aMessageConversion.Compare(KPtPidMail) ==0) |
|
415 { |
|
416 smsPidConv = ESmsConvMail; |
|
417 } |
|
418 else if( aMessageConversion.Compare(KPtPidErmes) ==0) |
|
419 { |
|
420 smsPidConv = ESmsConvErmes; |
|
421 } |
|
422 else if( aMessageConversion.Compare(KPtPidSpeech) ==0) |
|
423 { |
|
424 smsPidConv = ESmsConvSpeech; |
|
425 } |
|
426 else |
|
427 { |
|
428 iTestStep.INFO_PRINTF1(_L("The message conversion provided is invalid")); |
|
429 iTestStep.INFO_PRINTF1(_L("The default NONE message conversion is set")); |
|
430 } |
|
431 |
|
432 return smsPidConv; |
|
433 } |