|
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 // __ACTION_INFO_BEGIN__ |
|
15 // [Action Name] |
|
16 // ReceiveSmsMessages2 |
|
17 // [Action Parameters] |
|
18 // CMsvSession Session <input>: Reference to the session. |
|
19 // TInt Counter <input>: Value of expected number of messages |
|
20 // [Action Description] |
|
21 // Receives a specified number of sms messages. It waits for a new |
|
22 // message to appear in the inbox and decrements a count. It completes |
|
23 // once the required number of messages has been received. |
|
24 // [APIs Used] |
|
25 // CMsvEntry::SetEntryL |
|
26 // CMsvEntry::AddObserverL |
|
27 // __ACTION_INFO_END__ |
|
28 // |
|
29 // |
|
30 |
|
31 /** |
|
32 @file |
|
33 */ |
|
34 |
|
35 |
|
36 #include <smut.h> |
|
37 #include <msvapi.h> |
|
38 |
|
39 #include "CMtfTestActionReceiveSmsMessages2.h" |
|
40 #include "CMtfTestCase.h" |
|
41 #include "CMtfTestActionParameters.h" |
|
42 |
|
43 CMtfTestAction* CMtfTestActionReceiveSmsMessages2::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
44 { |
|
45 CMtfTestActionReceiveSmsMessages2* self = new (ELeave) CMtfTestActionReceiveSmsMessages2(aTestCase); |
|
46 CleanupStack::PushL(self); |
|
47 self->ConstructL(aActionParameters); |
|
48 CleanupStack::Pop(); |
|
49 return self; |
|
50 } |
|
51 |
|
52 CMtfTestActionReceiveSmsMessages2::CMtfTestActionReceiveSmsMessages2(CMtfTestCase& aTestCase) |
|
53 : CMtfTestAction(aTestCase) |
|
54 { |
|
55 } |
|
56 |
|
57 CMtfTestActionReceiveSmsMessages2::~CMtfTestActionReceiveSmsMessages2() |
|
58 { |
|
59 } |
|
60 |
|
61 |
|
62 void CMtfTestActionReceiveSmsMessages2::StopReceiveSmsMessages2() |
|
63 { |
|
64 //Cancel(); |
|
65 iMsventry->RemoveObserver(*this); |
|
66 delete iMsventry; |
|
67 } |
|
68 |
|
69 |
|
70 void CMtfTestActionReceiveSmsMessages2::ExecuteActionL() |
|
71 { |
|
72 TestCase().Logger().Write(_L("CMtfTestActionReceiveSmsMessages2::ExecuteActionL IN")); |
|
73 |
|
74 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
75 iNumberOfMessages = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(1)); |
|
76 iMsventry = CMsvEntry::NewL(*paramSession,KMsvGlobalInBoxIndexEntryId,TMsvSelectionOrdering()); |
|
77 iMsventry->AddObserverL(*this); |
|
78 iStatus = KRequestPending; |
|
79 |
|
80 //StoreParameterL<CMtfTestAction>(TestCase(), (*this), ActionParameters().Parameter(2)); |
|
81 |
|
82 CActiveScheduler::Add(this); |
|
83 SetActive(); |
|
84 |
|
85 TestCase().Logger().Write(_L("CMtfTestActionReceiveSmsMessages2::ExecuteActionL OUT")); |
|
86 } |
|
87 |
|
88 void CMtfTestActionReceiveSmsMessages2::DoCancel() |
|
89 { |
|
90 TRequestStatus *status=&iStatus; |
|
91 User::RequestComplete(status,KErrCancel); |
|
92 } |
|
93 |
|
94 void CMtfTestActionReceiveSmsMessages2::RunL() |
|
95 { |
|
96 TestCase().ActionCompletedL(*this); |
|
97 } |
|
98 |
|
99 void CMtfTestActionReceiveSmsMessages2::HandleEntryEventL(TMsvEntryEvent aEvent, TAny* aArg1, TAny* /* aArg2*/, TAny* /*aArg3*/) |
|
100 /** |
|
101 * Called by CMsvEntry when a messaging event has occurred. It is used here to find out if any new messages have been created. |
|
102 */ |
|
103 { |
|
104 TestCase().Logger().Write(_L("CMtfTestActionReceiveSmsMessages2::HandleEntryEventL IN")); |
|
105 |
|
106 CMsvEntrySelection* entries = NULL; |
|
107 switch (aEvent) |
|
108 { |
|
109 case EMsvNewChildren: |
|
110 if(aArg1 == NULL) |
|
111 { |
|
112 User::Leave(KErrGeneral); |
|
113 } |
|
114 else{ |
|
115 entries = static_cast<CMsvEntrySelection*>(aArg1); |
|
116 } |
|
117 break; |
|
118 |
|
119 default: |
|
120 User::Leave(KErrGeneral); |
|
121 } |
|
122 |
|
123 TestCase().Logger().WriteFormat(_L("CMtfTestActionReceiveSmsMessages2::HandleEntryEventL entries %d") , entries->Count()); |
|
124 |
|
125 iNumberOfMessages-=entries->Count(); |
|
126 |
|
127 TestCase().Logger().WriteFormat(_L("CMtfTestActionReceiveSmsMessages2::HandleEntryEventL entries remaining %d") , iNumberOfMessages); |
|
128 |
|
129 if(iNumberOfMessages>0) |
|
130 { |
|
131 return; |
|
132 } |
|
133 else if(iNumberOfMessages == 0) |
|
134 { |
|
135 TRequestStatus *status=&iStatus; |
|
136 StopReceiveSmsMessages2(); |
|
137 User::RequestComplete(status,KErrNone); |
|
138 } |
|
139 else if(iNumberOfMessages<0) |
|
140 { |
|
141 User::Leave(KErrGeneral); |
|
142 } |
|
143 } |
|
144 |
|
145 |
|
146 |