|
1 /* |
|
2 * Copyright (c) 2009 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 "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 |
|
20 #include <e32svr.h> |
|
21 #include <StifParser.h> |
|
22 #include <StifLogger.h> |
|
23 #include <StifTestInterface.h> |
|
24 |
|
25 |
|
26 /* This class is used to notify the observer |
|
27 * about the timeout |
|
28 */ |
|
29 class MTimeoutObserver |
|
30 { |
|
31 public: // New functions |
|
32 |
|
33 /** |
|
34 * Timeout |
|
35 */ |
|
36 virtual void HandleTimeout(TInt error) = 0; |
|
37 }; |
|
38 |
|
39 |
|
40 _LIT(KFormatTimeStamp, "%:0%J%:1%T%:2%S%.%*C4%:3%+B"); |
|
41 |
|
42 |
|
43 /* This class is used for extra time controlling |
|
44 * The STIF timeout isn't enough |
|
45 */ |
|
46 class CSimpleTimeout : public CActive |
|
47 { |
|
48 public: // Enumerations |
|
49 // None |
|
50 |
|
51 private: // Enumerations |
|
52 // None |
|
53 |
|
54 public: // Constructors and destructor |
|
55 |
|
56 /** |
|
57 * Two-phased constructor. |
|
58 */ |
|
59 static CSimpleTimeout* NewL( MTimeoutObserver* aObserver, CStifLogger* aLogger); |
|
60 |
|
61 /** |
|
62 * Destructor. |
|
63 */ |
|
64 ~CSimpleTimeout(); |
|
65 |
|
66 public: // New functions |
|
67 |
|
68 /** |
|
69 * Starts timeout counting |
|
70 */ |
|
71 void Start(TTimeIntervalMicroSeconds aTimeout); |
|
72 |
|
73 /** |
|
74 * Cancel timeout counting |
|
75 */ |
|
76 void Stop(); |
|
77 |
|
78 |
|
79 public: // Functions from base classes |
|
80 |
|
81 /** |
|
82 * RunL derived from CActive handles the completed requests. |
|
83 */ |
|
84 void RunL(); |
|
85 |
|
86 /** |
|
87 * DoCancel derived from CActive handles the cancel |
|
88 */ |
|
89 void DoCancel(); |
|
90 |
|
91 /** |
|
92 * RunError derived from CActive handles errors from active handler. |
|
93 */ |
|
94 TInt RunError( TInt aError ); |
|
95 |
|
96 protected: // New functions |
|
97 // None |
|
98 |
|
99 protected: // Functions from base classes |
|
100 // None |
|
101 |
|
102 private: |
|
103 |
|
104 /** |
|
105 * By default Symbian OS constructor is private. |
|
106 */ |
|
107 void ConstructL(MTimeoutObserver* aObserver, CStifLogger* aLogger); |
|
108 |
|
109 /** |
|
110 * C++ constructor. |
|
111 */ |
|
112 CSimpleTimeout(); |
|
113 |
|
114 public: // Data |
|
115 // None |
|
116 |
|
117 protected: // Data |
|
118 // None |
|
119 |
|
120 private: // Data |
|
121 MTimeoutObserver* iObserver; |
|
122 RTimer iTimer; |
|
123 |
|
124 // Storage for testcase timeout. |
|
125 TTime iTestCaseTimeout; |
|
126 CStifLogger* iLog; |
|
127 |
|
128 public: // Friend classes |
|
129 // None |
|
130 |
|
131 protected: // Friend classes |
|
132 // None |
|
133 |
|
134 private: // Friend classes |
|
135 // None |
|
136 |
|
137 }; |