|
1 /*------------------------------------------------------------------ |
|
2 - |
|
3 * Software Name : UserEmulator |
|
4 * Version : v4.2.1309 |
|
5 * |
|
6 * Copyright (c) 2009 France Telecom. All rights reserved. |
|
7 * This software is distributed under the License |
|
8 * "Eclipse Public License - v 1.0" the text of which is available |
|
9 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
10 * |
|
11 * Initial Contributors: |
|
12 * France Telecom |
|
13 * |
|
14 * Contributors: |
|
15 *------------------------------------------------------------------ |
|
16 - |
|
17 * File Name: ThreadNotifier.h |
|
18 * |
|
19 * Created: 13/08/2009 |
|
20 * Author(s): Marcell Kiss, Reshma Sandeep Das |
|
21 * |
|
22 * Description: |
|
23 * Active object implementation for capturing panics |
|
24 *------------------------------------------------------------------ |
|
25 - |
|
26 * |
|
27 */ |
|
28 |
|
29 #ifndef THREADNOTIFIER_H_ |
|
30 #define THREADNOTIFIER_H_ |
|
31 |
|
32 // System Includes |
|
33 #include <e32base.h> |
|
34 #include <ImageConversion.h> |
|
35 |
|
36 // User Includes |
|
37 #include "Logger.h" |
|
38 #include "Settings.h" |
|
39 #include "ImageCapture.h" |
|
40 #include "UserEmulatorScriptsView.h" |
|
41 #include "Constants.h" |
|
42 |
|
43 /** |
|
44 * Panic observer interface class |
|
45 */ |
|
46 class MPanicObserver |
|
47 { |
|
48 public: |
|
49 /** |
|
50 * Callback to notify AppUi (and eventually Random test) if a panic occured |
|
51 */ |
|
52 virtual void PanicOccured() = 0; |
|
53 virtual void RestartRandomTests() =0; |
|
54 }; |
|
55 /** |
|
56 * CThreadNotifier |
|
57 * Active object implementation for capturing panics |
|
58 */ |
|
59 class CThreadNotifier : public CActive, |
|
60 public MScreenshotObserver |
|
61 { |
|
62 public: |
|
63 /** |
|
64 * Static constructor. |
|
65 * @param aObserver Reference to panic observer |
|
66 * @param aLogger A reference to the CLogger class for logging panics. |
|
67 * @param aSettings A reference to the CSettings class |
|
68 * @param aEikonEnv A refernce to the CEikionEnv class |
|
69 * @return CThreadNotifier* A pointer to the newly alocated CThreadNotifier class. |
|
70 * NULL, if the class cannot be created |
|
71 */ |
|
72 static CThreadNotifier* NewL(MPanicObserver& aObserver, CLogger& aLogger, CSettings& aSettings,CEikonEnv* aEikonEnv); |
|
73 |
|
74 /** |
|
75 * Static constructor. On return the instance is left to the CleanupStack |
|
76 * @param aObserver Reference to panic observer |
|
77 * @param aLogger A reference to the CLogger class for logging panics. |
|
78 * @param aSettings A reference to the CSettings class |
|
79 * @param aEikonEnv A refernce to the CEikionEnv class |
|
80 * @return CThreadNotifier* A pointer to the newly alocated CThreadNotifier class. |
|
81 * NULL, if the class cannot be created |
|
82 */ |
|
83 static CThreadNotifier* NewLC(MPanicObserver& aObserver, CLogger& aLogger, CSettings& aSettings,CEikonEnv* aEikonEnv); |
|
84 |
|
85 /** |
|
86 * Destructor |
|
87 */ |
|
88 ~CThreadNotifier(); |
|
89 |
|
90 /** |
|
91 * Function to issues a request for notification of the death of a thread. |
|
92 */ |
|
93 void IssueRequest(); |
|
94 |
|
95 private: |
|
96 /** |
|
97 * Constructor |
|
98 * @param aObserver Reference to panic observer |
|
99 * @param aLogger A reference to the CLogger class for logging panics. |
|
100 * @param aSettings A reference to the CSettings class |
|
101 * @param aEikonEnv A refernce to the CEikionEnv class |
|
102 */ |
|
103 CThreadNotifier(MPanicObserver& aObserver, CLogger& aLogger, CSettings& aSettings, CEikonEnv* aEikonEnv); |
|
104 /** |
|
105 * ConstructL |
|
106 */ |
|
107 void ConstructL(); |
|
108 /** |
|
109 * Function that indicates the exit type of the thread |
|
110 * @param aExitType Exit type |
|
111 */ |
|
112 void ExitType(TInt aExitType); |
|
113 |
|
114 /** |
|
115 * Callback implementation from the Image Capturer |
|
116 * @param aInterval |
|
117 */ |
|
118 void PerformNextAction(TInt aInterval); |
|
119 |
|
120 private: //From CActive |
|
121 /** |
|
122 * Cancels any outstanding request. |
|
123 */ |
|
124 void DoCancel(); |
|
125 |
|
126 /** |
|
127 * Handles the completion of the active request. |
|
128 */ |
|
129 void RunL(); |
|
130 |
|
131 private: |
|
132 /** |
|
133 * Reference to the Logger class |
|
134 */ |
|
135 CLogger& iLogger; |
|
136 /** |
|
137 * Reference to the settings class |
|
138 */ |
|
139 CSettings& iSettings; |
|
140 /** |
|
141 * Exit type |
|
142 */ |
|
143 TBuf<KBuffer64> iExitType; |
|
144 /** |
|
145 * Exit type |
|
146 */ |
|
147 CEikonEnv* iEEnv; |
|
148 /** |
|
149 * Handle to thread death notifier |
|
150 */ |
|
151 RUndertaker iUndertaker; |
|
152 /** |
|
153 * Thread handle |
|
154 */ |
|
155 TInt iThreadHandle; |
|
156 /** |
|
157 * Handle to panic observer |
|
158 */ |
|
159 MPanicObserver& iObserver; |
|
160 }; |
|
161 |
|
162 #endif /*THREADNOTIFIER_H_*/ |