|
1 /* |
|
2 * Copyright (c) 2004 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: Active object based global note container. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <E32std.h> |
|
21 |
|
22 #include <avkon.rsg> |
|
23 #include <Avkon.hrh> |
|
24 #include <aknglobalnote.h> |
|
25 #include <impsconnectionuing.rsg> |
|
26 |
|
27 #include "CCnUiGlobalNoteContainer.h" |
|
28 #include "IMPSCommonUiDebugPrint.h" |
|
29 #include "impscommonuibuilddefinitions.h" |
|
30 |
|
31 |
|
32 // CONSTANTS |
|
33 /** |
|
34 * Global note framework seems to handle too |
|
35 * long prompt texts with leaving. This might be |
|
36 * a fatal problem for AA plug-ins |
|
37 * ==> clip the text length to maximum allowed by S60. |
|
38 */ |
|
39 const TInt KGlobalNoteMaxTextLength = 256; |
|
40 |
|
41 |
|
42 // ================= LOCAL FUNCTIONS ======================= |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // AllocMaxGlobalTextL() |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 HBufC* AllocMaxGlobalTextL( const TDesC& aPromptText ) |
|
49 { |
|
50 return aPromptText.Left( KGlobalNoteMaxTextLength ).AllocL(); |
|
51 } |
|
52 |
|
53 |
|
54 |
|
55 // ================= MEMBER FUNCTIONS ======================= |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CCnUiGlobalNoteContainer::NewLC |
|
59 // Two-phased constructor. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CCnUiGlobalNoteContainer* CCnUiGlobalNoteContainer::NewLC() |
|
63 { |
|
64 CCnUiGlobalNoteContainer* self = new ( ELeave ) CCnUiGlobalNoteContainer(); |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 return self; |
|
68 } |
|
69 |
|
70 |
|
71 // Destructor |
|
72 CCnUiGlobalNoteContainer::~CCnUiGlobalNoteContainer() |
|
73 { |
|
74 Cancel(); |
|
75 delete iGlobalNote; |
|
76 |
|
77 delete iPromptText; |
|
78 delete iDetailedPromptText; |
|
79 } |
|
80 |
|
81 |
|
82 // C++ default constructor can NOT contain any code, that |
|
83 // might leave. |
|
84 // |
|
85 CCnUiGlobalNoteContainer::CCnUiGlobalNoteContainer() |
|
86 : CActive( CActive::EPriorityStandard ), |
|
87 iState( ECnUiGNCIdle ) |
|
88 { |
|
89 CActiveScheduler::Add( this ); |
|
90 } |
|
91 |
|
92 |
|
93 // EPOC default constructor can leave. |
|
94 void CCnUiGlobalNoteContainer::ConstructL() |
|
95 { |
|
96 iGlobalNote = CAknGlobalNote::NewL(); |
|
97 } |
|
98 |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CCnUiGlobalNoteContainer::ShowWaitigDetailedNoteL() |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void CCnUiGlobalNoteContainer::ShowWaitigDetailedNoteL( const TDesC& aPromptText, |
|
105 const TDesC& aDetailedPromptText ) |
|
106 { |
|
107 Cancel(); |
|
108 ResetState(); |
|
109 iPromptText = AllocMaxGlobalTextL( aPromptText ); |
|
110 iDetailedPromptText = AllocMaxGlobalTextL( aDetailedPromptText ); |
|
111 |
|
112 IssueDetailedMainNoteL(); |
|
113 WaitCompletion(); |
|
114 } |
|
115 |
|
116 |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CCnUiGlobalNoteContainer::ShowWaitingNoteL() |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void CCnUiGlobalNoteContainer::ShowWaitingNoteL( const TDesC& aPromptText ) |
|
123 { |
|
124 Cancel(); |
|
125 ResetState(); |
|
126 iPromptText = AllocMaxGlobalTextL( aPromptText ); |
|
127 |
|
128 IssueWaitingNoteL(); |
|
129 WaitCompletion(); |
|
130 } |
|
131 |
|
132 |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CCnUiGlobalNoteContainer::RunL |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 void CCnUiGlobalNoteContainer::RunL() |
|
139 { |
|
140 IMPSCUI_DP( D_IMPSCUI_LIT( "CCnUiGlobalNoteContainer::RunL() state=%d, status=%d" ), iState, iStatus ); |
|
141 switch ( iState ) |
|
142 { |
|
143 case ECnUiGNCShowingDetailedNoteMain: |
|
144 { |
|
145 //Main note completed |
|
146 if ( iStatus == EAknSoftkeyDetails ) |
|
147 { |
|
148 //user selected details ==> show second detailed note |
|
149 IssueDetailedSecondNoteL(); |
|
150 } |
|
151 break; |
|
152 } |
|
153 |
|
154 //Flow trough... |
|
155 case ECnUiGNCShowingDetailedNoteSecond: |
|
156 case ECnUiGNCShowingWaitingNote: |
|
157 case ECnUiGNCIdle: |
|
158 default: |
|
159 { |
|
160 break; |
|
161 } |
|
162 } |
|
163 |
|
164 |
|
165 if ( !IsActive() ) |
|
166 { |
|
167 //if no subsequent processing steps started, |
|
168 //break away from scheduler loop... |
|
169 Completed(); |
|
170 ResetState(); |
|
171 } |
|
172 } |
|
173 |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CCnUiGlobalNoteContainer::DoCancel |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 void CCnUiGlobalNoteContainer::DoCancel() |
|
180 { |
|
181 //Note container needs to be dismissed |
|
182 //If note cancellation fails, there isn't anything to do |
|
183 //since this container is executed on AA plug-in or similar side and |
|
184 //actual note is in holded Series60 UI framework... |
|
185 TInt ignore; |
|
186 TRAP( ignore, iGlobalNote->CancelNoteL( iNoteId ) ); |
|
187 Completed(); |
|
188 ResetState(); |
|
189 } |
|
190 |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CCnUiGlobalNoteContainer::RunError |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 TInt CCnUiGlobalNoteContainer::RunError( TInt /*aError */ ) |
|
197 { |
|
198 Completed(); |
|
199 ResetState(); |
|
200 return KErrNone; |
|
201 } |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CCnUiGlobalNoteContainer::WaitCompletion() |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 void CCnUiGlobalNoteContainer::WaitCompletion() |
|
208 { |
|
209 //wait with the scheduler loop |
|
210 IMPSCUI_DP_TXT( "CCnUiGlobalNoteContainer::WaitCompletion() - starting wait" ); |
|
211 if ( !iWait.IsStarted() ) |
|
212 { |
|
213 // Code scanner warning "active object called without checking |
|
214 // whether it is active or cancelling it first" ignored because |
|
215 // CActiveSchedulerWait is not an active object |
|
216 iWait.Start(); // CSI: 10 # See above |
|
217 } |
|
218 IMPSCUI_DP_TXT( "CCnUiGlobalNoteContainer::WaitCompletion() - wait done" ); |
|
219 } |
|
220 |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CCnUiGlobalNoteContainer::Completed() |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 void CCnUiGlobalNoteContainer::Completed() |
|
227 { |
|
228 //break away from the waiting scheduler loop |
|
229 iWait.AsyncStop(); |
|
230 } |
|
231 |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CCnUiGlobalNoteContainer::ResetState() |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 void CCnUiGlobalNoteContainer::ResetState() |
|
238 { |
|
239 delete iPromptText; |
|
240 delete iDetailedPromptText; |
|
241 iPromptText = NULL; |
|
242 iDetailedPromptText = NULL; |
|
243 |
|
244 iState = ECnUiGNCIdle; |
|
245 iStatus = KErrNotFound; |
|
246 iNoteId = KErrNotFound; |
|
247 } |
|
248 |
|
249 |
|
250 // ----------------------------------------------------------------------------- |
|
251 // CCnUiGlobalNoteContainer::IssueDetailedMainNoteL() |
|
252 // ----------------------------------------------------------------------------- |
|
253 // |
|
254 void CCnUiGlobalNoteContainer::IssueDetailedMainNoteL() |
|
255 { |
|
256 __ASSERT_ALWAYS( iPromptText, User::Leave( KErrArgument ) ); |
|
257 |
|
258 iGlobalNote->SetSoftkeys( R_CNUI_SOFTKEYS_OK_DETAILS__OK ); |
|
259 iNoteId = iGlobalNote->ShowNoteL( iStatus, |
|
260 EAknGlobalInformationNote, |
|
261 *iPromptText ); |
|
262 SetActive(); |
|
263 iState = ECnUiGNCShowingDetailedNoteMain; |
|
264 } |
|
265 |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CCnUiGlobalNoteContainer::IssueDetailedSecondNoteL() |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 void CCnUiGlobalNoteContainer::IssueDetailedSecondNoteL() |
|
272 { |
|
273 __ASSERT_ALWAYS( iDetailedPromptText, User::Leave( KErrArgument ) ); |
|
274 |
|
275 iGlobalNote->SetSoftkeys( R_AVKON_SOFTKEYS_OK_EMPTY__OK ); |
|
276 iNoteId = iGlobalNote->ShowNoteL( iStatus, |
|
277 EAknGlobalInformationNote, |
|
278 *iDetailedPromptText ); |
|
279 SetActive(); |
|
280 iState = ECnUiGNCShowingDetailedNoteSecond; |
|
281 } |
|
282 |
|
283 |
|
284 // ----------------------------------------------------------------------------- |
|
285 // CCnUiGlobalNoteContainer::IssueWaitingNoteL() |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 void CCnUiGlobalNoteContainer::IssueWaitingNoteL() |
|
289 { |
|
290 __ASSERT_ALWAYS( iPromptText, User::Leave( KErrArgument ) ); |
|
291 |
|
292 |
|
293 iGlobalNote->SetSoftkeys( R_AVKON_SOFTKEYS_OK_EMPTY__OK ); |
|
294 iNoteId = iGlobalNote->ShowNoteL( iStatus, |
|
295 EAknGlobalInformationNote, |
|
296 *iPromptText ); |
|
297 SetActive(); |
|
298 iState = ECnUiGNCShowingWaitingNote; |
|
299 } |
|
300 |
|
301 |
|
302 // end of file |
|
303 |