|
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 // __ACTION_INFO_BEGIN__ |
|
15 // [Action Name] |
|
16 // CreateEmailOverSmsMessage |
|
17 // [Action Parameters] |
|
18 // Session <input>: Reference to the session. |
|
19 // ParentId <input>: Value of the parent id. |
|
20 // ServiceId <input>: Value of the the service id. |
|
21 // (ConfigIndexHeader) <input>: Value of config index for SMS header settings. Default is 0. |
|
22 // MessageId <output>: Value of the created message id. |
|
23 // [Action Description] |
|
24 // Creates a message on the specified parent. |
|
25 // [APIs Used] |
|
26 // TMsvEntry::iMtm |
|
27 // TMsvEntry::iServiceId |
|
28 // TMsvEntry::iDate |
|
29 // TMsvEntry::Id |
|
30 // CMsvEntry::SetEntryL |
|
31 // CMsvEntry::CreateL |
|
32 // CSmsHeader::NewL |
|
33 // CSmsHeader::StoreL |
|
34 // __ACTION_INFO_END__ |
|
35 // |
|
36 // |
|
37 |
|
38 // |
|
39 #include "CMtfTestActionCreateEmailOverSmsMessage.h" |
|
40 #include "CMtfTestCase.h" |
|
41 #include "CMtfTestActionParameters.h" |
|
42 #include "CMtfTestActionUtilsConfigFileParser.h" |
|
43 #include <msvapi.h> |
|
44 #include <msvuids.h> |
|
45 #include <txtrich.h> |
|
46 #include <smuthdr.h> |
|
47 #include <csmsemailfields.h> |
|
48 |
|
49 |
|
50 _LIT(KSentToAddress, "SentToAddress"); |
|
51 _LIT(KBodyText, "BodyText"); |
|
52 |
|
53 CMtfTestAction* CMtfTestActionCreateEmailOverSmsMessage::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
54 { |
|
55 CMtfTestActionCreateEmailOverSmsMessage* self = new (ELeave) CMtfTestActionCreateEmailOverSmsMessage(aTestCase); |
|
56 CleanupStack::PushL(self); |
|
57 self->ConstructL(aActionParameters); |
|
58 CleanupStack::Pop(self); |
|
59 return self; |
|
60 } |
|
61 |
|
62 |
|
63 CMtfTestActionCreateEmailOverSmsMessage::CMtfTestActionCreateEmailOverSmsMessage(CMtfTestCase& aTestCase) |
|
64 : CMtfSynchronousTestAction(aTestCase) |
|
65 { |
|
66 } |
|
67 |
|
68 void CMtfTestActionCreateEmailOverSmsMessage::ExecuteActionL() |
|
69 { |
|
70 TestCase().Logger().Write(_L("CMtfTestActionCreateEmailOverSmsMessage::ExecuteActionL IN")); |
|
71 TInt paramCount = ActionParameters().Count(); |
|
72 if( paramCount != 5) |
|
73 { |
|
74 User::Leave(KErrArgument); |
|
75 } |
|
76 |
|
77 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
78 TMsvId paramParentId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); |
|
79 TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(2)); |
|
80 |
|
81 |
|
82 TMsvEntry indexEntry; |
|
83 indexEntry.iType = KUidMsvMessageEntry; |
|
84 indexEntry.iMtm = KUidMsgTypeSMS; |
|
85 indexEntry.iServiceId = paramServiceId; |
|
86 indexEntry.SetVisible(ETrue); |
|
87 indexEntry.iDate.HomeTime(); |
|
88 indexEntry.iSize=0; |
|
89 |
|
90 _LIT(KNullDesC, "" ); |
|
91 indexEntry.iDescription.Set(KNullDesC); |
|
92 indexEntry.iDetails.Set(KNullDesC); |
|
93 |
|
94 indexEntry.SetSendingState(KMsvSendStateWaiting); |
|
95 indexEntry.SetInPreparation(ETrue); |
|
96 |
|
97 CMsvEntry* entry = paramSession->GetEntryL(paramParentId); |
|
98 CleanupStack::PushL(entry); |
|
99 entry->CreateL(indexEntry); |
|
100 TMsvId paramMessageId = indexEntry.Id(); |
|
101 paramSession->CleanupEntryPushL(paramMessageId); |
|
102 entry->SetEntryL(paramMessageId); |
|
103 |
|
104 InitializeHeaderFromConfigL(&indexEntry , entry); |
|
105 |
|
106 paramSession->CleanupEntryPop(); |
|
107 CleanupStack::PopAndDestroy(entry); |
|
108 |
|
109 StoreParameterL<TMsvId>(TestCase(),paramMessageId,ActionParameters().Parameter(4)); |
|
110 |
|
111 TestCase().Logger().Write(_L("CMtfTestActionCreateEmailOverSmsMessage::ExecuteActionL OUT")); |
|
112 TestCase().ActionCompletedL(*this); |
|
113 } |
|
114 |
|
115 |
|
116 void CMtfTestActionCreateEmailOverSmsMessage::InitializeHeaderFromConfigL(TMsvEntry* indexEntry, CMsvEntry* aEntry) |
|
117 { |
|
118 TInt paramConfigIndexHeader = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(3),0); |
|
119 TPtrC smsMessageFileName = TestCase().GetConfigurationFileL(CMtfConfigurationType::EMtfSmsMessage,paramConfigIndexHeader); |
|
120 CMtfTestActionUtilsConfigFileParser* configParser = CMtfTestActionUtilsConfigFileParser::NewL(smsMessageFileName); |
|
121 CleanupStack::PushL(configParser); |
|
122 |
|
123 CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL(); |
|
124 CleanupStack::PushL(paraFormatLayer); |
|
125 |
|
126 CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(); |
|
127 CleanupStack::PushL(charFormatLayer); |
|
128 |
|
129 CRichText* richText = CRichText::NewL(paraFormatLayer,charFormatLayer); |
|
130 CleanupStack::PushL(richText); |
|
131 |
|
132 CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *richText); |
|
133 CleanupStack::PushL(header); |
|
134 |
|
135 |
|
136 |
|
137 CSmsEmailFields* emailFields = CSmsEmailFields::NewL(); |
|
138 CleanupStack::PushL(emailFields); |
|
139 |
|
140 _LIT( KEmailToAddress, "EmailToAddress" ); |
|
141 TPtrC emailToAddressText; |
|
142 if(configParser->GetFieldAsString(KEmailToAddress, emailToAddressText) != KErrNotFound) |
|
143 { |
|
144 indexEntry->iDetails.Set(emailToAddressText); |
|
145 emailFields->AddAddressL( emailToAddressText ); |
|
146 } |
|
147 |
|
148 |
|
149 _LIT( KSubject, "Subject" ); |
|
150 TPtrC subjectText; |
|
151 if(configParser->GetFieldAsString(KSubject, subjectText) != KErrNotFound) |
|
152 { |
|
153 indexEntry->iDescription.Set( subjectText ); |
|
154 emailFields->SetSubjectL( subjectText ); |
|
155 } |
|
156 |
|
157 |
|
158 header->SetEmailFieldsL(*emailFields); |
|
159 |
|
160 |
|
161 //header->SetServiceCenterAddressL(KServiceCentre); //????? |
|
162 //header->SetSmsSettingsL(ServiceSettings()); //????? |
|
163 |
|
164 |
|
165 CleanupStack::PopAndDestroy(emailFields); |
|
166 |
|
167 CMsvStore* store = aEntry->EditStoreL(); |
|
168 CleanupStack::PushL(store); |
|
169 |
|
170 TPtrC toAddress; |
|
171 if(configParser->GetFieldAsString(KSentToAddress,toAddress) != KErrNotFound) |
|
172 { |
|
173 CArrayPtrFlat<CSmsNumber>& recipientList = header->Recipients(); |
|
174 CSmsNumber* recipient = CSmsNumber::NewL(); |
|
175 CleanupStack::PushL(recipient); |
|
176 recipient->SetAddressL(toAddress); |
|
177 CleanupStack::Pop(recipient); |
|
178 recipientList.AppendL(recipient); |
|
179 } |
|
180 TestCase().Logger().WriteFormat(_L("CMtfTestActionCreateEmailOverSmsMessage:: recipient: %S"), &toAddress); |
|
181 |
|
182 TPtrC bodyText; |
|
183 if(configParser->GetFieldAsString(KBodyText, bodyText) != KErrNotFound) |
|
184 { |
|
185 richText->InsertL(0, bodyText); |
|
186 } |
|
187 |
|
188 |
|
189 TestCase().Logger().WriteFormat(_L("CMtfTestActionCreateEmailOverSmsMessage:: body text: %S"), &bodyText); |
|
190 |
|
191 header->StoreL(*store); |
|
192 store->StoreBodyTextL(*richText); |
|
193 store->CommitL(); |
|
194 |
|
195 indexEntry->SetInPreparation(EFalse); |
|
196 aEntry->ChangeL(*indexEntry); |
|
197 |
|
198 |
|
199 CleanupStack::PopAndDestroy(6, configParser); |
|
200 } |
|
201 |