|
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: Helper class for wait notes |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "vimpstutilswaitnote.h" |
|
22 |
|
23 #include <vimpstuires.rsg> |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CVIMPSTUtilsWaitNote::CVIMPSTUtilsWaitNote |
|
29 // C++ default constructor can NOT contain any code, that |
|
30 // might leave. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CVIMPSTUtilsWaitNote::CVIMPSTUtilsWaitNote() |
|
34 { |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CVIMPSTUtilsWaitNote::ConstructL |
|
39 // Symbian 2nd phase constructor can leave. |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 EXPORT_C void CVIMPSTUtilsWaitNote::ConstructL( const TDesC& aText, |
|
43 TBool aShowImmediately, |
|
44 TBool aCanBeCanceledByUser, |
|
45 MVIMPSTUtilsWaitNoteObserver* aObserver ) |
|
46 { |
|
47 // don't give dialog pointer as a parameter because |
|
48 // it gets invalid after deletion of this instance |
|
49 iWaitDialog = new( ELeave )CAknWaitDialog( NULL, aShowImmediately ); |
|
50 if( aCanBeCanceledByUser ) |
|
51 { |
|
52 iWaitDialog->PrepareLC( R_IM_WAIT_NOTE_TEMPLATE_WITH_CANCEL ); |
|
53 } |
|
54 else |
|
55 { |
|
56 iWaitDialog->PrepareLC( R_IM_WAIT_NOTE_TEMPLATE ); |
|
57 } |
|
58 iWaitDialog->SetTone( CAknNoteDialog::ENoTone ); |
|
59 iWaitDialog->SetTextL( aText ); |
|
60 iWaitDialog->SetCallback( this ); |
|
61 |
|
62 SetObserver( aObserver ); |
|
63 iWaitDialog->RunLD(); // CSI: 50 # iWaitDialog is not owned by us |
|
64 } |
|
65 |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CVIMPSTUtilsWaitNote::ShowWaitNoteL |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 EXPORT_C CVIMPSTUtilsWaitNote* CVIMPSTUtilsWaitNote::ShowWaitNoteL( const TDesC& aText, |
|
72 TBool aShowImmediately /*= EFalse*/, |
|
73 TBool aCanBeCanceledByUser /*= EFalse*/, |
|
74 MVIMPSTUtilsWaitNoteObserver* aObserver /*= NULL*/ ) |
|
75 { |
|
76 CVIMPSTUtilsWaitNote* self = ShowWaitNoteLC(aText,aShowImmediately,aCanBeCanceledByUser,aObserver); |
|
77 CleanupStack::Pop( self ); |
|
78 return self; |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CVIMPSTUtilsWaitNote::ShowWaitNoteLC |
|
83 // Two-phased constructor. |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 EXPORT_C CVIMPSTUtilsWaitNote* CVIMPSTUtilsWaitNote::ShowWaitNoteLC( const TDesC& aText, |
|
87 TBool aShowImmediately /*= EFalse*/, |
|
88 TBool aCanBeCanceledByUser /*= EFalse*/, |
|
89 MVIMPSTUtilsWaitNoteObserver* aObserver /*= NULL*/ ) |
|
90 { |
|
91 CVIMPSTUtilsWaitNote* self = new( ELeave ) CVIMPSTUtilsWaitNote(); |
|
92 CleanupStack::PushL( self ); |
|
93 self->ConstructL( aText, aShowImmediately, aCanBeCanceledByUser, aObserver ); |
|
94 return self; |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CVIMPSTUtilsWaitNote::ShowWaitNoteLC |
|
99 // Two-phased constructor. |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C CVIMPSTUtilsWaitNote* CVIMPSTUtilsWaitNote::ShowWaitNoteLC( TInt aTextResource, |
|
103 TBool aShowImmediately /*= EFalse*/, |
|
104 TBool aCanBeCanceledByUser /*= EFalse*/, |
|
105 MVIMPSTUtilsWaitNoteObserver* aObserver /*= NULL*/ ) |
|
106 { |
|
107 CVIMPSTUtilsWaitNote* self = new( ELeave ) CVIMPSTUtilsWaitNote(); |
|
108 CleanupStack::PushL( self ); |
|
109 |
|
110 HBufC* text = CCoeEnv::Static()->AllocReadResourceLC( aTextResource ); |
|
111 self->ConstructL( *text, aShowImmediately, aCanBeCanceledByUser, aObserver ); |
|
112 CleanupStack::PopAndDestroy( text ); |
|
113 |
|
114 return self; |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CVIMPSTUtilsWaitNote::ShowWaitNoteL |
|
119 // Two-phased constructor. |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 EXPORT_C CVIMPSTUtilsWaitNote* CVIMPSTUtilsWaitNote::ShowWaitNoteL( TInt aTextResource, |
|
123 TBool aShowImmediately /*= EFalse*/, |
|
124 TBool aCanBeCanceledByUser /*= EFalse*/, |
|
125 MVIMPSTUtilsWaitNoteObserver* aObserver /*= NULL*/ ) |
|
126 { |
|
127 CVIMPSTUtilsWaitNote* self = ShowWaitNoteLC( aTextResource, |
|
128 aShowImmediately, |
|
129 aCanBeCanceledByUser, |
|
130 aObserver ); |
|
131 |
|
132 CleanupStack::Pop( self ); |
|
133 return self; |
|
134 } |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 // Destructor |
|
140 CVIMPSTUtilsWaitNote::~CVIMPSTUtilsWaitNote() |
|
141 { |
|
142 DismissDialog(); |
|
143 } |
|
144 |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CVIMPSTUtilsWaitNote::DialogDismissedL |
|
148 // Called when dialog is dismissed |
|
149 // (other items were commented in a header). |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 EXPORT_C void CVIMPSTUtilsWaitNote::DialogDismissedL( TInt aButtonId ) |
|
153 { |
|
154 iWaitDialog = NULL; |
|
155 if( iObserver ) |
|
156 { |
|
157 iObserver->NoteCanceled( aButtonId ); |
|
158 } |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CVIMPSTUtilsWaitNote::DismissDialog |
|
163 // Dismisses the dialog |
|
164 // (other items were commented in a header). |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 EXPORT_C void CVIMPSTUtilsWaitNote::DismissDialog() |
|
168 { |
|
169 if( iWaitDialog ) |
|
170 { |
|
171 iWaitDialog->SetCallback( NULL ); |
|
172 TRAPD( err, iWaitDialog->ProcessFinishedL() ); |
|
173 |
|
174 if( err != KErrNone ) |
|
175 { |
|
176 // don't know for sure that ProcessFinishedL deletes the dialog |
|
177 // in all cases, so let's delete it |
|
178 delete iWaitDialog; |
|
179 iWaitDialog = NULL; |
|
180 CActiveScheduler::Current()->Error( err ); |
|
181 } |
|
182 |
|
183 TRAP_IGNORE( DialogDismissedL( 0 ) ); |
|
184 } |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CVIMPSTUtilsWaitNote::SetObserver |
|
189 // (other items were commented in a header). |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 EXPORT_C void CVIMPSTUtilsWaitNote::SetObserver( MVIMPSTUtilsWaitNoteObserver* aObserver ) |
|
193 { |
|
194 iObserver = aObserver; |
|
195 } |
|
196 |
|
197 // End of File |