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