|
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 // This contains CTestMessCreateSmsAccount which creates an SMS |
|
15 // account folder for GSM or CDMA |
|
16 |
|
17 #include "TestMessCreateSmsAccount.h" |
|
18 #include "TestMess.h" |
|
19 |
|
20 // EPOC includes |
|
21 #include <msvids.h> |
|
22 #include <miutset.h> |
|
23 #include <msvstore.h> |
|
24 |
|
25 #include "TestMessCreateGsmSmsUtil.h" |
|
26 //Usage of Macro for CDMA mtm |
|
27 #if (defined CDMA_API_ENABLED) |
|
28 #include "TestMessCreateCdmaSmsUtil.h" |
|
29 #endif |
|
30 |
|
31 #include <csmsaccount.h> |
|
32 #include <MsvScheduleSettings.h> |
|
33 #include <MsvOffPeakTime.h> |
|
34 #include <MsvSendErrorAction.h> |
|
35 #include <MsvSysAgentAction.h> |
|
36 |
|
37 /*@{*/ |
|
38 _LIT(KSCName, "scname"); |
|
39 _LIT(KSCNumber, "scnumber"); |
|
40 |
|
41 _LIT(KPtGSM, "GSM"); |
|
42 #if (defined CDMA_API_ENABLED) |
|
43 _LIT(KPtMessageBearerType, "MessageBearerType"); |
|
44 _LIT(KPtCDMA, "CDMA"); |
|
45 #endif |
|
46 /*@}*/ |
|
47 |
|
48 CTestMessCreateSmsAccount::CTestMessCreateSmsAccount() |
|
49 : CTestMessBase(EFalse) |
|
50 { |
|
51 SetTestStepName(_L("CreateSmsAccount")); |
|
52 } |
|
53 |
|
54 /** |
|
55 Creates the SMS account folder for GSM or CDMA. For CDMA mtm, |
|
56 it creates the respective utility class for creating the account |
|
57 @return TVerdict |
|
58 */ |
|
59 TVerdict CTestMessCreateSmsAccount::doTestStepL() |
|
60 { |
|
61 // Printing to the console and log file |
|
62 INFO_PRINTF1(_L("Create SMS account")); |
|
63 |
|
64 TPtrC ptrSCName; |
|
65 TBool returnValue =GetStringFromConfig(ConfigSection(), KSCName, ptrSCName); |
|
66 INFO_PRINTF2(_L("SC Name = %S"), &ptrSCName); |
|
67 |
|
68 TPtrC ptrSCNumber; |
|
69 returnValue =GetStringFromConfig(ConfigSection(), KSCNumber, ptrSCNumber); |
|
70 INFO_PRINTF2(_L("SC Number = %S"), &ptrSCNumber); |
|
71 |
|
72 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
73 CMsvScheduleSettings* scheduleSetting = CMsvScheduleSettings::NewLC(); |
|
74 CMsvOffPeakTimes* offPeakTimes=new (ELeave) CMsvOffPeakTimes(); |
|
75 CleanupStack::PushL(offPeakTimes); |
|
76 CMsvSendErrorActions* errorActions=CMsvSendErrorActions::NewLC(); |
|
77 CMsvSysAgentActions* sysAgentActions=new (ELeave) CMsvSysAgentActions(); |
|
78 CleanupStack::PushL(sysAgentActions); |
|
79 CSmsSettings* smsSettings = CSmsSettings::NewL(); |
|
80 CleanupStack::PushL(smsSettings); |
|
81 SetEntryL(KMsvRootIndexEntryId); |
|
82 |
|
83 EntryL().SetSortTypeL(SelectionOrdering()); |
|
84 CMsvEntrySelection* selection=EntryL().ChildrenWithTypeL(KUidMsvServiceEntry); |
|
85 CleanupStack::PushL(selection); |
|
86 TInt count=selection->Count(); |
|
87 TBool found=EFalse; |
|
88 for (TInt i=count; i>0 && !found; ) |
|
89 { |
|
90 SetEntryL(selection->At(--i)); |
|
91 |
|
92 // Only one Sms Service allowed |
|
93 if ( EntryL().Entry().iMtm == KUidMsgTypeSMS && |
|
94 EntryL().Entry().iType == KUidMsvServiceEntry |
|
95 ) |
|
96 { |
|
97 found=ETrue; |
|
98 } |
|
99 } |
|
100 |
|
101 if ( !found ) |
|
102 { |
|
103 smsAccount->InitialiseDefaultSettingsL(*smsSettings); |
|
104 smsAccount->InitialiseDefaultSettingsL(*scheduleSetting, *offPeakTimes, *errorActions, *sysAgentActions); |
|
105 |
|
106 TPtrC messageBearerType; |
|
107 messageBearerType.Set(KPtGSM); |
|
108 #if (defined CDMA_API_ENABLED) |
|
109 GetStringFromConfig(ConfigSection(), KPtMessageBearerType, messageBearerType); |
|
110 INFO_PRINTF2(_L("The message bearer type is : %S"), &messageBearerType); |
|
111 #endif |
|
112 |
|
113 CTestMessCreateSmsUtilBase* createSmsUtil = NULL; |
|
114 //Creates the util class for GSM or CDMA |
|
115 if ( messageBearerType.Compare(KPtGSM)==0 ) |
|
116 { |
|
117 createSmsUtil = new (ELeave) CTestMessCreateGsmSmsUtil(*this); |
|
118 } |
|
119 #if (defined CDMA_API_ENABLED) |
|
120 else if( messageBearerType.Compare(KPtCDMA)==0 ) |
|
121 { |
|
122 createSmsUtil = new (ELeave) CTestMessCreateCdmaSmsUtil(*this); |
|
123 } |
|
124 #endif |
|
125 else |
|
126 { |
|
127 WARN_PRINTF1(_L("Unknown bearer type using Gsm")); |
|
128 createSmsUtil= new (ELeave) CTestMessCreateGsmSmsUtil(*this); |
|
129 } |
|
130 CleanupStack::PushL(createSmsUtil); |
|
131 |
|
132 //Changes the new account settings |
|
133 createSmsUtil->SetSmsAccountSettings(*smsSettings); |
|
134 CleanupStack::PopAndDestroy(createSmsUtil); |
|
135 |
|
136 smsAccount->SaveSettingsL(*smsSettings); |
|
137 smsAccount->SaveSettingsL(*scheduleSetting, *offPeakTimes, *errorActions, *sysAgentActions); |
|
138 } |
|
139 |
|
140 if ( TestStepResult()==EPass ) |
|
141 { |
|
142 smsAccount->LoadSettingsL(*smsSettings); |
|
143 smsSettings->AddServiceCenterL(ptrSCName, ptrSCNumber); |
|
144 smsAccount->SaveSettingsL(*smsSettings); |
|
145 } |
|
146 |
|
147 CleanupStack::PopAndDestroy(2, smsSettings); |
|
148 CleanupStack::PopAndDestroy(5, smsAccount); |
|
149 |
|
150 return TestStepResult(); |
|
151 } |