1 /* |
|
2 * Copyright (c) 2005 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: Implementation of the query dialog with timeout timer. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "SyncMLTimedQueryDialog.h" |
|
22 #include "SyncMLNotifDebug.h" |
|
23 |
|
24 // CONSTANTS |
|
25 const TInt KSyncMLuSecsInSec = 1000000; // Microseconds in a second |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CSyncMLTimedMessageQuery::CSyncMLTimedMessageQuery |
|
31 // C++ default constructor can NOT contain any code, that |
|
32 // might leave. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CSyncMLTimedQueryDialog::CSyncMLTimedQueryDialog( TInt aTimeout ) |
|
36 : iTimeout( aTimeout ) |
|
37 { |
|
38 iTone = EConfirmationTone; |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CSyncMLTimedMessageQuery::NewL |
|
43 // Two-phased constructor. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CSyncMLTimedQueryDialog* CSyncMLTimedQueryDialog::NewL( const TDesC& aMessage, |
|
47 TInt aTimeout ) |
|
48 { |
|
49 CSyncMLTimedQueryDialog* self = |
|
50 new( ELeave ) CSyncMLTimedQueryDialog ( aTimeout ); |
|
51 |
|
52 CleanupStack::PushL( self ); |
|
53 self->SetPromptL( aMessage ); |
|
54 CleanupStack::Pop( self ); |
|
55 |
|
56 return self; |
|
57 } |
|
58 |
|
59 |
|
60 // Destructor |
|
61 CSyncMLTimedQueryDialog::~CSyncMLTimedQueryDialog() |
|
62 { |
|
63 if ( iTimer ) |
|
64 { |
|
65 iTimer->Cancel(); |
|
66 delete iTimer; |
|
67 iTimer = NULL; |
|
68 } |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CSyncMLTimedMessageQuery::OkToExitL |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 TBool CSyncMLTimedQueryDialog::OkToExitL( TInt aButtonId ) |
|
76 { |
|
77 if ( aButtonId == KErrTimedOut ) |
|
78 { |
|
79 return ETrue; |
|
80 } |
|
81 return CAknQueryDialog::OkToExitL( aButtonId ); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CSyncMLTimedMessageQuery::TimerExpired |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void CSyncMLTimedQueryDialog::TimerExpired() |
|
89 { |
|
90 if ( iTimer ) |
|
91 { |
|
92 iTimer->Cancel(); |
|
93 delete iTimer; |
|
94 iTimer = NULL; |
|
95 iTimeout = KSyncMLNNoTimeout; |
|
96 } |
|
97 TRAPD( err, TryExitL( KErrTimedOut ) ); |
|
98 |
|
99 if ( err != KErrNone ) |
|
100 { |
|
101 FTRACE( FPrint( |
|
102 _L("[SmlNotif]\t CSyncMLTimedQueryDialog::TimerExpired() \ |
|
103 TryExitL returned %d"), err ) ); |
|
104 } |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CSyncMLTimedMessageQuery::PostLayoutDynInitL |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CSyncMLTimedQueryDialog::PostLayoutDynInitL() |
|
112 { |
|
113 if ( iTimeout > KSyncMLNNoTimeout ) |
|
114 { |
|
115 iTimer = CSyncMLQueryTimer::NewL( this ); |
|
116 iTimer->After( iTimeout * KSyncMLuSecsInSec ); |
|
117 } |
|
118 CAknQueryDialog::PostLayoutDynInitL(); |
|
119 } |
|
120 |
|
121 |
|
122 // End of File |
|