14 * Description: Declares USB UI notifiers base class. |
14 * Description: Declares USB UI notifiers base class. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 // INCLUDE FILES |
18 // INCLUDE FILES |
19 |
19 #include <eikenv.h> // Eikon environment |
20 #include <bautils.h> // BAFL utils (for language file) |
20 #include <bautils.h> // BAFL utils (for language file) |
|
21 #include <StringLoader.h> // Localisation stringloader |
|
22 #include <centralrepository.h> |
|
23 #include <coreapplicationuisdomainpskeys.h> |
21 #include <data_caging_path_literals.hrh> |
24 #include <data_caging_path_literals.hrh> |
22 #include <hb/hbcore/hbtextresolversymbian.h> |
25 #include <featmgr.h> |
|
26 #include <AknNotiferAppServerApplication.h> |
23 |
27 |
24 #include "usbnotifier.h" // Own class |
28 #include "usbnotifier.h" // Own class |
25 #include "usbuinotifdebug.h" |
29 #include "usbuinotifdebug.h" |
26 |
30 #include "aknkeylock.h" //RAknKeyLock |
27 // CONSTANTS |
31 // CONSTANTS |
28 |
32 |
29 // ================= MEMBER FUNCTIONS ========================================= |
33 // ================= MEMBER FUNCTIONS ========================================= |
30 |
34 |
31 // ---------------------------------------------------------------------------- |
35 // ---------------------------------------------------------------------------- |
33 // C++ default constructor can NOT contain any code, that |
37 // C++ default constructor can NOT contain any code, that |
34 // might leave. Sets the AOs priority and puts |
38 // might leave. Sets the AOs priority and puts |
35 // itself to the active scheduler stack. |
39 // itself to the active scheduler stack. |
36 // ---------------------------------------------------------------------------- |
40 // ---------------------------------------------------------------------------- |
37 // |
41 // |
38 CUSBUINotifierBase::CUSBUINotifierBase() |
42 CUSBUINotifierBase::CUSBUINotifierBase() : |
|
43 CActive( EPriorityStandard ) |
39 { |
44 { |
40 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Default constructor()")); |
45 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Default constructor()")); |
|
46 CActiveScheduler::Add( this ); |
41 } |
47 } |
42 |
48 |
43 // ---------------------------------------------------------------------------- |
49 // ---------------------------------------------------------------------------- |
44 // CUSBUINotifierBase::ConstructL |
50 // CUSBUINotifierBase::ConstructL |
45 // Symbian 2nd phase constructor can leave. |
51 // Symbian 2nd phase constructor can leave. |
47 // ---------------------------------------------------------------------------- |
53 // ---------------------------------------------------------------------------- |
48 // |
54 // |
49 void CUSBUINotifierBase::ConstructL() |
55 void CUSBUINotifierBase::ConstructL() |
50 { |
56 { |
51 iEikEnv = CEikonEnv::Static(); |
57 iEikEnv = CEikonEnv::Static(); |
52 |
58 iAppsKeyBlocked = EFalse; |
|
59 iKeylockChanged = EFalse; |
|
60 |
53 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::ConstructL()")); |
61 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::ConstructL()")); |
54 |
62 TFileName filename; |
55 // use TLS as a boolean, set to EFalse |
63 |
56 TBool initialized = EFalse; |
64 const TDriveNumber KStoreDrive = EDriveZ; |
57 TInt error; |
65 TDriveUnit driveUnit( KStoreDrive ); |
58 error = Dll::SetTls((TAny* )initialized); |
66 TDriveName drive = driveUnit.Name(); |
59 error = error; // to suppress a compiler warning |
67 filename.Insert( 0, drive ); |
60 FTRACE(FPrint(_L("[USBUINOTIF]\t Dll:SetTls returned %d"), error )); |
68 |
61 |
69 filename += KDC_RESOURCE_FILES_DIR; // From data_caging_path_literals.hrh |
|
70 filename += KResourceFileName; |
|
71 BaflUtils::NearestLanguageFile( iEikEnv->FsSession(), filename ); |
|
72 iResourceFileFlag = iEikEnv->AddResourceFileL( filename ); |
|
73 |
|
74 FeatureManager::InitializeLibL(); |
|
75 iCoverDisplaySupported = FeatureManager::FeatureSupported( |
|
76 KFeatureIdCoverDisplay ); |
|
77 FeatureManager::UnInitializeLib(); |
|
78 |
62 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::ConstructL() completed")); |
79 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::ConstructL() completed")); |
63 } |
80 } |
64 |
81 |
65 // ---------------------------------------------------------------------------- |
82 // ---------------------------------------------------------------------------- |
66 // Destructor. |
83 // Destructor. |
71 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Destructor")); |
88 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Destructor")); |
72 //Make sure that the request is completed. Note that inside the destructor, |
89 //Make sure that the request is completed. Note that inside the destructor, |
73 //this virtual function call is to the local CUSBUINotifierBase::Cancel, |
90 //this virtual function call is to the local CUSBUINotifierBase::Cancel, |
74 //not to any possibly derived class implementation. |
91 //not to any possibly derived class implementation. |
75 Cancel(); |
92 Cancel(); |
76 |
93 iEikEnv->DeleteResourceFile( iResourceFileFlag ); |
|
94 |
77 // Complete the RMessage2 if needed |
95 // Complete the RMessage2 if needed |
78 // |
96 // |
79 CompleteMessage( KErrDied ); |
97 CompleteMessage( KErrDied ); |
80 |
98 |
|
99 // Activate apps -key again (if not previously activated yet) |
|
100 SuppressAppSwitching( EFalse ); |
|
101 |
|
102 //Don't call RestoreKeylock here. It's up to specific note notfier logic. |
|
103 //If failed to RestoreKeylock there, it doesn't matter to leave keylock open. |
|
104 |
81 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Destructor completed")); |
105 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Destructor completed")); |
82 } |
106 } |
83 |
107 |
84 // ---------------------------------------------------------------------------- |
108 // ---------------------------------------------------------------------------- |
85 // CUSBUINotifierBase::Release |
109 // CUSBUINotifierBase::Release |
123 // |
147 // |
124 void CUSBUINotifierBase::StartL(const TDesC8& aBuffer, TInt aReplySlot, |
148 void CUSBUINotifierBase::StartL(const TDesC8& aBuffer, TInt aReplySlot, |
125 const RMessagePtr2& aMessage) |
149 const RMessagePtr2& aMessage) |
126 { |
150 { |
127 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::StartL()")); |
151 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::StartL()")); |
128 TRAPD( err, StartDialogL( aBuffer, aReplySlot, aMessage )); |
152 TRAPD( err, GetParamsL( aBuffer, aReplySlot, aMessage )); |
129 if (err) |
153 if (err) |
130 { |
154 { |
131 aMessage.Complete( err ); |
155 aMessage.Complete( err ); |
132 iNeedToCompleteMessage = EFalse; |
156 iNeedToCompleteMessage = EFalse; |
133 User::Leave( err ); |
157 User::Leave( err ); |
141 // ---------------------------------------------------------------------------- |
165 // ---------------------------------------------------------------------------- |
142 // |
166 // |
143 void CUSBUINotifierBase::Cancel() |
167 void CUSBUINotifierBase::Cancel() |
144 { |
168 { |
145 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Cancel()")); |
169 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Cancel()")); |
146 //The message box closed callback gets not run in subclass cancel calls. |
170 CActive::Cancel(); |
147 CompleteMessage(KErrCancel); |
171 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Cancel completed()")); |
148 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Cancel completed")); |
|
149 } |
172 } |
150 |
173 |
151 // ---------------------------------------------------------------------------- |
174 // ---------------------------------------------------------------------------- |
152 // CUSBUINotifierBase::UpdateL |
175 // CUSBUINotifierBase::UpdateL |
153 // Notifier update. Not supported. |
176 // Notifier update. Not supported. |
158 TPtrC8 ret( KNullDesC8 ); |
181 TPtrC8 ret( KNullDesC8 ); |
159 return (ret); |
182 return (ret); |
160 } |
183 } |
161 |
184 |
162 // ---------------------------------------------------------------------------- |
185 // ---------------------------------------------------------------------------- |
|
186 // CUSBUINotifierBase::DoCancel |
|
187 // This method will be called by framework (CActive) |
|
188 // if active object is still active. |
|
189 // Does nothing here. |
|
190 // ---------------------------------------------------------------------------- |
|
191 // |
|
192 void CUSBUINotifierBase::DoCancel() |
|
193 { |
|
194 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::DoCancel()")); |
|
195 } |
|
196 |
|
197 // ---------------------------------------------------------------------------- |
|
198 // CUSBUINotifierBase::RunError |
|
199 // This method is called if any leaving has been occured |
|
200 // during RunL. Optional method for CActive derived objects. |
|
201 // ---------------------------------------------------------------------------- |
|
202 // |
|
203 TInt CUSBUINotifierBase::RunError(TInt aError) |
|
204 { |
|
205 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RunError()")); |
|
206 |
|
207 // Activate apps -key again (if not previously activated yet) |
|
208 // |
|
209 SuppressAppSwitching( EFalse ); |
|
210 |
|
211 // Write error message to caller |
|
212 // |
|
213 CompleteMessage( aError ); |
|
214 |
|
215 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RunError() completed")); |
|
216 |
|
217 return aError; |
|
218 } |
|
219 |
|
220 // ---------------------------------------------------------------------------- |
|
221 // CUSBUINotifierBase::SuppressAppSwitching |
|
222 // |
|
223 // ---------------------------------------------------------------------------- |
|
224 // |
|
225 void CUSBUINotifierBase::SuppressAppSwitching(TBool aEnable) |
|
226 { |
|
227 FTRACE(FPrint(_L("[USBUINOTIF]\t CUSBUINotifierBase::SuppressAppSwitching() %d"), aEnable)); |
|
228 |
|
229 if (iAppsKeyBlocked != aEnable) |
|
230 { |
|
231 TInt err = iAknServer.ConnectAndSendAppsKeySuppress( aEnable ); // error is stored only for logging purposes |
|
232 iAppsKeyBlocked = aEnable; |
|
233 FTRACE(FPrint(_L("[USBUINOTIF]\t CUSBUINotifierBase::SuppressAppSwitching() ConnectAndSendAppsKeySuppress returned %d"), err )); |
|
234 } |
|
235 |
|
236 if (!iAppsKeyBlocked) |
|
237 { |
|
238 iAknServer.Close(); // close the connection once we have re-enabled swithcing |
|
239 } |
|
240 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::SuppressAppSwitching() completed")); |
|
241 } |
|
242 |
|
243 // ---------------------------------------------------------------------------- |
163 // CUSBUINotifierBase::CompleteMessage |
244 // CUSBUINotifierBase::CompleteMessage |
164 // Check if message needs to be completed and complete it. |
245 // Check if message needs to be completed and complete it. |
165 // ---------------------------------------------------------------------------- |
246 // ---------------------------------------------------------------------------- |
166 // |
247 // |
167 void CUSBUINotifierBase::CompleteMessage(TInt aReason) |
248 void CUSBUINotifierBase::CompleteMessage(TInt aReason) |
174 } |
255 } |
175 iReplySlot = 0; |
256 iReplySlot = 0; |
176 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::CompleteMessage() completed")); |
257 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::CompleteMessage() completed")); |
177 } |
258 } |
178 |
259 |
179 void CUSBUINotifierBase::InitializeTextResolver() |
260 // ---------------------------------------------------------------------------- |
180 { |
261 // CUSBUINotifierBase::DisableKeylock |
181 _LIT(KFileName, "usbdialogs_"); |
262 // ---------------------------------------------------------------------------- |
182 _LIT(KPath, "z:/resource/qt/translations/"); |
263 // Turn off the keyguard if it was on. |
183 TInt error = KErrNone; |
264 // |
184 |
265 void CUSBUINotifierBase::DisableKeylock() |
185 iTranslator = (TBool )Dll::Tls(); |
266 { |
186 |
267 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::DisableKeylock()")); |
187 FTRACE(FPrint(_L("[USBUINOTIF]\t Dll:Tls returned %d"), iTranslator )); |
268 RAknKeylock2 keylock; |
188 |
269 iKeylockChanged = EFalse; |
189 if (!iTranslator) |
270 if (KErrNone == keylock.Connect()) |
190 { |
271 { |
191 iTranslator = HbTextResolverSymbian::Init(KFileName, KPath); |
272 if (keylock.IsKeyLockEnabled()) //Check and save the keylock status |
192 FTRACE(FPrint(_L("[USBUINOTIF]\t HbTextResolverSymbian::Init returned %d"), iTranslator )); |
|
193 if (iTranslator) |
|
194 { |
273 { |
195 error = Dll::SetTls((TAny* )iTranslator); |
274 keylock.DisableWithoutNote();// Unlock |
|
275 iKeylockChanged = ETrue; |
196 } |
276 } |
197 FTRACE(FPrint(_L("[USBUINOTIF]\t Dll:SetTls returned %d"), error )); |
277 keylock.Close(); |
198 } |
278 } |
199 |
279 else |
200 error = error; // to suppress a compiler warning |
280 { |
201 FTRACE( FPrint( |
281 FLOG( _L( "[USBUINOTIF]\t CUSBUINotifierBase::DisableKeylock() fail caused by RAknKeylock2::Connect()") ); |
202 _L( "[USBUINOTIF]\t CUSBUINotifierBase::InitializeTextResolver result = %d" ), |
282 } |
203 iTranslator ) ); |
283 |
204 |
284 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::DisableKeylock() completed")); |
205 } |
285 } |
206 |
286 |
|
287 // ---------------------------------------------------------------------------- |
|
288 // CUSBUINotifierBase::RestoreKeylock |
|
289 // ---------------------------------------------------------------------------- |
|
290 // Restore the keyguard on. |
|
291 // |
|
292 void CUSBUINotifierBase::RestoreKeylock() |
|
293 { |
|
294 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock()")); |
|
295 if (iKeylockChanged) |
|
296 { |
|
297 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock(): iKeylockChanged true")); |
|
298 RAknKeylock2 keylock; |
|
299 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock(): RAknKeyLock2 initialized")); |
|
300 if (KErrNone == keylock.Connect()) |
|
301 { |
|
302 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock(): RAknKeyLock2::Connect() complete")); |
|
303 keylock.EnableWithoutNote();// Lock back |
|
304 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock(): RAknKeyLock2::EnableWithoutNote() complete")); |
|
305 keylock.Close(); |
|
306 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock(): RAknKeyLock2::Close() complete")); |
|
307 iKeylockChanged = EFalse; |
|
308 } |
|
309 else |
|
310 { |
|
311 FLOG( _L( "[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock() fail caused by RAknKeylock2::Connect()") ); |
|
312 } |
|
313 } |
|
314 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock() completed")); |
|
315 } |
207 |
316 |
208 // End of File |
317 // End of File |