|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef VCXTESTMESSAGEWAIT_H_ |
|
20 #define VCXTESTMESSAGEWAIT_H_ |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include "MIptvTestTimerObserver.h" |
|
25 |
|
26 // CONSTANTS |
|
27 |
|
28 // MACROS |
|
29 |
|
30 // DATA TYPES |
|
31 |
|
32 // FUNCTION PROTOTYPES |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 |
|
36 // CLASS DECLARATION |
|
37 class CIptvTestActiveWait; |
|
38 class CIptvTestTimer; |
|
39 |
|
40 /** |
|
41 * MVCXTestMessageWaitObserver |
|
42 */ |
|
43 class MVCXTestMessageWaitObserver |
|
44 { |
|
45 public: |
|
46 |
|
47 /** |
|
48 * Called when message queue empties or there's timeout. |
|
49 */ |
|
50 virtual void MessageWaitComplete( TInt aError ) = 0; |
|
51 |
|
52 }; |
|
53 |
|
54 /** |
|
55 * CVCXTestMessageWait |
|
56 */ |
|
57 class CVCXTestMessageWait : public CBase, public MIptvTestTimerObserver |
|
58 { |
|
59 public: // Constructors and destructor |
|
60 /** |
|
61 * Two-phased constructor. |
|
62 */ |
|
63 IMPORT_C static CVCXTestMessageWait * NewL( MVCXTestMessageWaitObserver* aObserver ); |
|
64 |
|
65 /** |
|
66 * Destructor. |
|
67 */ |
|
68 IMPORT_C virtual ~CVCXTestMessageWait (); |
|
69 |
|
70 |
|
71 public: // New functions |
|
72 |
|
73 /** |
|
74 * Resets already received messages, wait queue and cancels previous receiving. |
|
75 */ |
|
76 IMPORT_C void Reset(); |
|
77 |
|
78 /** |
|
79 * Resets only already received messages. |
|
80 */ |
|
81 IMPORT_C void ResetReceivedMessages(); |
|
82 |
|
83 /** |
|
84 * Adds message to the wait queue. |
|
85 */ |
|
86 IMPORT_C void AddMessage( TInt32 aMsg ); |
|
87 |
|
88 /** |
|
89 * Waits for a message. Calls observer callback when message is received. This will reset |
|
90 * previously added messages. |
|
91 */ |
|
92 IMPORT_C void WaitForMessageL( TInt32 aMsg, TInt aTimeoutSeconds, TBool aDoBlock ); |
|
93 |
|
94 /** |
|
95 * Waits for the added messages. Calls observer callback when messages have been received. |
|
96 */ |
|
97 IMPORT_C void WaitForAllL( TInt aTimeoutSeconds, TBool aDoBlock ); |
|
98 |
|
99 /** |
|
100 * Waits until messages have not been received for the specified seconds. |
|
101 */ |
|
102 IMPORT_C void CoolDownL( TInt aSeconds ); |
|
103 |
|
104 /** |
|
105 * Checks wait queue for the message. |
|
106 */ |
|
107 IMPORT_C void ReceiveMessage( TInt32 aMsg, TInt aError ); |
|
108 |
|
109 public: // From base classes. |
|
110 |
|
111 void TimerComplete( TInt aTimerId, TInt aError ); |
|
112 |
|
113 private: |
|
114 |
|
115 /** |
|
116 * C++ default constructor. |
|
117 */ |
|
118 CVCXTestMessageWait( MVCXTestMessageWaitObserver* aObserver ); |
|
119 |
|
120 /** |
|
121 * By default Symbian 2nd phase constructor is private. |
|
122 */ |
|
123 IMPORT_C void ConstructL(); |
|
124 |
|
125 private: // Data |
|
126 |
|
127 MVCXTestMessageWaitObserver* iObserver; |
|
128 |
|
129 CIptvTestActiveWait* iActiveWaitBlocking; |
|
130 |
|
131 CIptvTestTimer* iTimeoutTimer; |
|
132 |
|
133 // Messages which are received while waited messages array is empty. |
|
134 RArray<TInt32> iReceivedMessages; |
|
135 |
|
136 RArray<TInt32> iWaitedMessages; |
|
137 |
|
138 TInt iTimeoutSeconds; |
|
139 |
|
140 TBool iWaitStarted; |
|
141 |
|
142 TBool iCoolingDown; |
|
143 |
|
144 TInt iError; |
|
145 }; |
|
146 |
|
147 #endif // VCXTESTMESSAGEWAIT_H_ |
|
148 |
|
149 // End of File |