|
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 "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: Info Note implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System Includes |
|
20 #include <eikenv.h> |
|
21 #include <e32std.h> |
|
22 #include <aknmessagequerydialog.h> |
|
23 #include <bautils.h> |
|
24 #include <StringLoader.h> |
|
25 #include <data_caging_path_literals.hrh> |
|
26 #include <AknNotiferAppServerApplication.h> |
|
27 #include <aknPopupHeadingPane.h> |
|
28 #include <evtinfonote.rsg> |
|
29 #include <s32mem.h> |
|
30 #include <eikbtgpc.h> |
|
31 #include <gulicon.h> |
|
32 #include <AknsUtils.h> |
|
33 #include <eikimage.h> |
|
34 |
|
35 #include <aknnotedialog.h> |
|
36 |
|
37 // User Includes |
|
38 #include "evtinfonoteparams.h" |
|
39 #include "evtinfonote.h" |
|
40 #include "evtinfonoteinterface.h" |
|
41 #include "evtinfonoteconsts.hrh" |
|
42 #include "evtinfonoteimpl.h" |
|
43 |
|
44 #include "evtdebug.h" |
|
45 |
|
46 // Constant Definitions |
|
47 _LIT(KResourceFileName, "evtinfonote.rsc"); |
|
48 static const TInt KLengthOfNum = 64; |
|
49 |
|
50 // |
|
51 // ------------------------- Member Function definition ---------------------- |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CEvtInfoNote::CEvtInfoNote() |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 CEvtInfoNote::CEvtInfoNote() |
|
58 : CActive( EPriorityStandard ) |
|
59 { |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CEvtInfoNote::~CEvtInfoNote() |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CEvtInfoNote::~CEvtInfoNote() |
|
67 { |
|
68 // If there is an existing message outstanding then |
|
69 // terminate the message |
|
70 CompleteMessage( KErrServerTerminated ); |
|
71 |
|
72 Cancel(); |
|
73 |
|
74 delete iInputBuffer; |
|
75 |
|
76 // Free the resources |
|
77 iEikEnv->DeleteResourceFile( iResourceFileFlag ); |
|
78 |
|
79 if ( iAppSwitchSupress && iAppUi ) |
|
80 { |
|
81 iAppUi->SuppressAppSwitching( EFalse ); |
|
82 iAppSwitchSupress = EFalse; |
|
83 } |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // void CEvtInfoNote::ConstructL() |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 void CEvtInfoNote::ConstructL() |
|
91 { |
|
92 EVTUIDEBUG( "+ CEvtInfoNote::ConstructL" ); |
|
93 |
|
94 // Store a Local pointer for Eikon Env |
|
95 iEikEnv = CEikonEnv::Static(); |
|
96 iAppUi = static_cast< CAknNotifierAppServerAppUi* >( iEikEnv->EikAppUi()); |
|
97 |
|
98 // Open the localized resource file |
|
99 TFileName dllDrive;; |
|
100 Dll::FileName( dllDrive ); |
|
101 |
|
102 // File name without the drive letter. |
|
103 TFileName filename; |
|
104 filename += KDC_RESOURCE_FILES_DIR; |
|
105 filename += KResourceFileName; |
|
106 |
|
107 // Append the drive letter to the file name. |
|
108 TParse parse; |
|
109 User::LeaveIfError( parse.Set( dllDrive, NULL, NULL ) ); |
|
110 User::LeaveIfError( parse.Set( parse.Drive(), &filename, NULL ) ); |
|
111 filename = parse.FullName(); |
|
112 |
|
113 BaflUtils::NearestLanguageFile(iEikEnv->FsSession(),filename); |
|
114 |
|
115 EVTUIDEBUG( "Before Resource File" ); |
|
116 |
|
117 iResourceFileFlag=iEikEnv->AddResourceFileL(filename); |
|
118 |
|
119 EVTUIDEBUG( "After Resource File" ); |
|
120 // Add the object to the Active scheduler |
|
121 CActiveScheduler::Add( this ); |
|
122 |
|
123 EVTUIDEBUG( "- CEvtInfoNote::ConstructL" ); |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CEvtInfoNote* CEvtInfoNote::NewL() |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 CEvtInfoNote* CEvtInfoNote::NewL() |
|
131 { |
|
132 CEvtInfoNote* self = new ( ELeave ) CEvtInfoNote; |
|
133 CleanupStack::PushL( self ); |
|
134 self->ConstructL(); |
|
135 CleanupStack::Pop( self ); |
|
136 return self; |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // void CEvtInfoNote::Release() |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CEvtInfoNote::Release() |
|
144 { |
|
145 EVTUIDEBUG( "+ CEvtInfoNote::Release" ); |
|
146 // This method is called to free all the resources |
|
147 // associated with the Notifier. Here it would mean deleting |
|
148 // the notifier handle |
|
149 delete this; |
|
150 EVTUIDEBUG( "- CEvtInfoNote::Release" ); |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // MEikSrvNotifierBase2::TNotifierInfo CEvtInfoNote::Info() const |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 MEikSrvNotifierBase2::TNotifierInfo CEvtInfoNote::Info() const |
|
158 { |
|
159 EVTUIDEBUG( "+ CEvtInfoNote::Info" ); |
|
160 // Return the notifier information |
|
161 return iInfo; |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------------------------- |
|
165 // TPtrC8 CEvtInfoNote::StartL |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 TPtrC8 CEvtInfoNote::StartL( const TDesC8& /* aBuffer */ ) |
|
169 { |
|
170 TPtrC8 ret( KNullDesC8 ); |
|
171 return ( ret ); |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // void CEvtInfoNote::StartL |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 void CEvtInfoNote::StartL( const TDesC8& aBuffer, |
|
179 TInt aReplySlot, |
|
180 const RMessagePtr2& aMessage ) |
|
181 { |
|
182 EVTUIDEBUG( "+ CEvtInfoNote::StartL" ); |
|
183 // The notifier will handle only one request at a time. |
|
184 if ( IsActive()) |
|
185 { |
|
186 User::Leave ( KErrInUse ); |
|
187 } |
|
188 |
|
189 iTriggerEvent = EDisplayNotifier; |
|
190 iMessage = aMessage; |
|
191 |
|
192 // Delete the old buffer and copy the contents of the argument into this |
|
193 // buffer |
|
194 // This buffer needs to be stored because, the user is going to handle |
|
195 // the request asynchrnously. |
|
196 delete iInputBuffer; |
|
197 iInputBuffer = NULL; |
|
198 iInputBuffer = aBuffer.AllocL(); |
|
199 |
|
200 // Copy the reply Slot |
|
201 iReplySlot = aReplySlot; |
|
202 |
|
203 TRequestStatus* status = &iStatus; |
|
204 SetActive(); |
|
205 User::RequestComplete( status, KErrNone ); |
|
206 EVTUIDEBUG( "- CEvtInfoNote::StartL" ); |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // void CEvtInfoNote::Cancel |
|
211 // --------------------------------------------------------------------------- |
|
212 // |
|
213 void CEvtInfoNote::Cancel() |
|
214 { |
|
215 EVTUIDEBUG( "+ CEvtInfoNote::Cancel" ); |
|
216 // Delete the running Information note |
|
217 delete iInfoNote; |
|
218 iInfoNote = NULL; |
|
219 |
|
220 CompleteMessage( KErrCancel ); |
|
221 |
|
222 delete iInputBuffer; |
|
223 iInputBuffer = NULL; |
|
224 |
|
225 iTriggerEvent = ENone; |
|
226 CActive::Cancel(); |
|
227 EVTUIDEBUG( "- CEvtInfoNote::Cancel" ); |
|
228 } |
|
229 |
|
230 // --------------------------------------------------------------------------- |
|
231 // TPtrC8 CEvtInfoNote::UpdateL |
|
232 // --------------------------------------------------------------------------- |
|
233 // |
|
234 TPtrC8 CEvtInfoNote::UpdateL( const TDesC8& /* aBuffer */ ) |
|
235 { |
|
236 TPtrC8 ret( KNullDesC8 ); |
|
237 return ( ret ); |
|
238 } |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // TPtrC8 CEvtInfoNote::UpdateL |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 void CEvtInfoNote::UpdateL( const TDesC8& /* aBuffer */, |
|
245 TInt /* aReplySlot */, |
|
246 const RMessagePtr2& aMessage) |
|
247 { |
|
248 aMessage.Complete( KErrNotSupported ); |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // CEvtInfoNote::TNotifierInfo CEvtInfoNote::RegisterL() |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 CEvtInfoNote::TNotifierInfo CEvtInfoNote::RegisterL() |
|
256 { |
|
257 iInfo.iUid = KEvtInfoNote; |
|
258 iInfo.iChannel = KEvtInfoNoteChannel; |
|
259 iInfo.iPriority = ENotifierPriorityHigh; |
|
260 return iInfo; |
|
261 } |
|
262 |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 // void CEvtInfoNote::CompleteMessage() |
|
266 // --------------------------------------------------------------------------- |
|
267 // |
|
268 void CEvtInfoNote::CompleteMessage( TInt aError, |
|
269 TInt aKeyPressEvent ) |
|
270 { |
|
271 EVTUIDEBUG( "+ CEvtInfoNote::CompleteMessage" ); |
|
272 // Check if the message is not NULL |
|
273 if ( !iMessage.IsNull() ) |
|
274 { |
|
275 |
|
276 // Obtain the Reply slot and communicate the response |
|
277 // to the user |
|
278 TInt desLength = iMessage.GetDesLength( iReplySlot ); |
|
279 if ( desLength >= KLengthOfNum ) |
|
280 { |
|
281 TBuf8< KLengthOfNum > returnBuf; |
|
282 returnBuf.AppendNum( aKeyPressEvent ); |
|
283 |
|
284 TInt length = returnBuf.Length(); |
|
285 length = length + 1; |
|
286 TInt error = iMessage.Write( iReplySlot, returnBuf ); |
|
287 if ( !error ) |
|
288 { |
|
289 EVTUIDEBUG1( "CEvtInfoNote::CompleteMessage - Write Error : %d", error ); |
|
290 } |
|
291 } |
|
292 |
|
293 iMessage.Complete( aError ); |
|
294 } |
|
295 |
|
296 if ( iAppSwitchSupress && iAppUi ) |
|
297 { |
|
298 iAppUi->SuppressAppSwitching( EFalse ); |
|
299 iAppSwitchSupress = EFalse; |
|
300 } |
|
301 |
|
302 iTriggerEvent = ENone; |
|
303 EVTUIDEBUG( "- CEvtInfoNote::CompleteMessage" ); |
|
304 } |
|
305 |
|
306 // --------------------------------------------------------------------------- |
|
307 // void CEvtInfoNote::RunL() |
|
308 // --------------------------------------------------------------------------- |
|
309 // |
|
310 void CEvtInfoNote::RunL() |
|
311 { |
|
312 EVTUIDEBUG( "+ CEvtInfoNote::RunL" ); |
|
313 // Do this only on KErrNone |
|
314 if ( !iStatus.Int()) |
|
315 { |
|
316 switch( iTriggerEvent ) |
|
317 { |
|
318 case EDisplayNotifier: |
|
319 { |
|
320 // Fetch the input parameters |
|
321 CEvtInfoNoteInputParam* param = GetInputParametersLC(); |
|
322 CleanupStack::Pop( param ); |
|
323 |
|
324 // Create a new dialog instance |
|
325 CEvtInfoNoteImpl* queryDialog = CEvtInfoNoteImpl::NewLC( param ); |
|
326 |
|
327 // Display the dialog in cover UI |
|
328 // queryDialog->PublishDialogL( SuplQueryId(), KCatUidSuplQuery ); |
|
329 |
|
330 // Store the value for the Query dialog. this would be useful |
|
331 // for cancelling it. |
|
332 iInfoNote = queryDialog; |
|
333 |
|
334 // Supress the App switching |
|
335 if ( !iAppSwitchSupress ) |
|
336 { |
|
337 iAppUi->SuppressAppSwitching( ETrue ); |
|
338 iAppSwitchSupress = ETrue; |
|
339 } |
|
340 TEvtInfoNoteCmds flag; |
|
341 TInt keypress = KErrNone; |
|
342 |
|
343 keypress = queryDialog->RunLD( &flag ); |
|
344 iInfoNote = NULL; |
|
345 |
|
346 EVTUIDEBUG1( "Key Press : %d", keypress ); |
|
347 EVTUIDEBUG1( "Return Code : %d", flag ); |
|
348 |
|
349 if ( keypress ) |
|
350 { |
|
351 switch( flag ) |
|
352 { |
|
353 case EEvtCmdOpenEvent: |
|
354 { |
|
355 CompleteMessage( KErrNone, EOpenTrigger ); |
|
356 break; |
|
357 } |
|
358 case EEvtCmdSnoozeEvent: |
|
359 { |
|
360 CompleteMessage( KErrNone, ESnoozeTrigger ); |
|
361 break; |
|
362 } |
|
363 case EEvtCmdShowDetails: |
|
364 { |
|
365 CompleteMessage( KErrNone, EShowDetails ); |
|
366 break; |
|
367 } |
|
368 case ECloseInfoNote: |
|
369 { |
|
370 CompleteMessage( KErrNone, ECloseInfoNote ); |
|
371 break; |
|
372 } |
|
373 default: |
|
374 { |
|
375 break; |
|
376 } |
|
377 } |
|
378 } |
|
379 else |
|
380 { |
|
381 CompleteMessage( KErrNone, ECloseInfoNote ); |
|
382 } |
|
383 |
|
384 // Reset the trigger Event |
|
385 iTriggerEvent = ENone; |
|
386 |
|
387 break; |
|
388 } |
|
389 default: |
|
390 { |
|
391 User::Leave( KErrNotSupported ); |
|
392 break; |
|
393 } |
|
394 } |
|
395 } |
|
396 else |
|
397 { |
|
398 EVTUIDEBUG1( "- CEvtInfoNote::Error %d ", iStatus.Int() ); |
|
399 // Error Handling for non-KErrNone status |
|
400 CompleteMessage( iStatus.Int()); |
|
401 } |
|
402 EVTUIDEBUG( "- CEvtInfoNote::RunL" ); |
|
403 } |
|
404 |
|
405 // --------------------------------------------------------------------------- |
|
406 // void CEvtInfoNote::DoCancel() |
|
407 // --------------------------------------------------------------------------- |
|
408 // |
|
409 void CEvtInfoNote::DoCancel() |
|
410 { |
|
411 // Reset the state machine |
|
412 iTriggerEvent = ENone; |
|
413 } |
|
414 |
|
415 // --------------------------------------------------------------------------- |
|
416 // TInt CEvtInfoNote::RunError() |
|
417 // --------------------------------------------------------------------------- |
|
418 // |
|
419 TInt CEvtInfoNote::RunError( TInt aError ) |
|
420 { |
|
421 EVTUIDEBUG( "+ CEvtInfoNote::RunError" ); |
|
422 // If the dialog value is set then the dialog must be |
|
423 // set to NULL because the dialog would have been destroyed |
|
424 // already since its present on the cleanup stack |
|
425 iInfoNote= NULL; |
|
426 |
|
427 // Complete the outstanding request with the error code |
|
428 CompleteMessage( aError ); |
|
429 |
|
430 // Reset the state machine. |
|
431 iTriggerEvent = ENone; |
|
432 |
|
433 EVTUIDEBUG( "- CEvtInfoNote::RunError" ); |
|
434 return CActive::RunError( aError ); |
|
435 } |
|
436 |
|
437 // --------------------------------------------------------------------------- |
|
438 // TInt CEvtInfoNoteInputParam::GetInputParametersLC() |
|
439 // --------------------------------------------------------------------------- |
|
440 // |
|
441 CEvtInfoNoteInputParam* CEvtInfoNote::GetInputParametersLC() |
|
442 { |
|
443 EVTUIDEBUG( "+ CEvtInfoNote::GetInputParametersLC" ); |
|
444 // Create a new input paramter object. The ownership of |
|
445 // this object will be transferred back to the calling |
|
446 // function. |
|
447 CEvtInfoNoteInputParam* input = CEvtInfoNoteInputParam::NewL(); |
|
448 CleanupStack::PushL( input ); |
|
449 |
|
450 // Obtain the parameters from the Input Buffer |
|
451 CBufFlat* inputParams = |
|
452 CBufFlat::NewL( iInputBuffer->Des().Length() ); |
|
453 CleanupStack::PushL( inputParams ); |
|
454 inputParams->ResizeL( iInputBuffer->Des().Length()); |
|
455 |
|
456 inputParams->Ptr( 0 ).Copy( *iInputBuffer ); |
|
457 |
|
458 // Set the Read buffer to read the values from input buffer |
|
459 RBufReadStream readStream( *inputParams, 0 ); |
|
460 CleanupClosePushL( readStream ); |
|
461 |
|
462 // Internalize the input buffer string to the current object. |
|
463 input->InternalizeL( readStream ); |
|
464 |
|
465 CleanupStack::PopAndDestroy( 2, inputParams ); |
|
466 |
|
467 EVTUIDEBUG( "- CEvtInfoNote::GetInputParametersLC" ); |
|
468 |
|
469 return input; |
|
470 } |