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