|
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: XIMP Framework Test Code |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CGLOBALWAITINGNOTE_H |
|
19 #define CGLOBALWAITINGNOTE_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 #include <aknglobalprogressdialog.h> |
|
24 #include <avkon.rsg> |
|
25 |
|
26 |
|
27 |
|
28 /** |
|
29 * Global waiting message for XIMP Framework Eunit tests. |
|
30 */ |
|
31 class CGlobalWaitingNote : public CActive |
|
32 { |
|
33 public: |
|
34 |
|
35 /** |
|
36 * Shows the waiting message with progress bar. |
|
37 * |
|
38 * @param aMessage The message text to show. |
|
39 * @param aTotalShowTime The show time in milliseconds. |
|
40 * @param aProgressSteps How many progress steps the progress bar should have. |
|
41 */ |
|
42 inline static void ShowMsgL( const TDesC& aMessage, |
|
43 TInt aTotalShowTime, |
|
44 TInt aProgressSteps ); |
|
45 |
|
46 |
|
47 private: |
|
48 |
|
49 inline CGlobalWaitingNote(); |
|
50 inline ~CGlobalWaitingNote(); |
|
51 inline void ConstructL(); |
|
52 |
|
53 inline void DoShowMsgL( const TDesC& aMessage, |
|
54 TInt aTotalShowTime, |
|
55 TInt aProgressSteps ); |
|
56 |
|
57 inline static TInt ProgressTickCb( TAny* aSelf ); |
|
58 inline TInt HandleProgressTick(); |
|
59 |
|
60 inline void RunL(); |
|
61 inline TInt RunError( TInt aError ); |
|
62 inline void DoCancel(); |
|
63 |
|
64 |
|
65 |
|
66 private: //data |
|
67 |
|
68 //OWN: Active Scheduler wait |
|
69 CActiveSchedulerWait iWait; |
|
70 |
|
71 //OWN: Progress ticker |
|
72 CPeriodic* iProgressTicker; |
|
73 |
|
74 //OWN: The global note. |
|
75 CAknGlobalProgressDialog* iGlobalNote; |
|
76 |
|
77 //OWN: Total show time |
|
78 TInt iTotalShowTime; |
|
79 |
|
80 //OWN: Progress interval |
|
81 TInt iProgressInterval; |
|
82 |
|
83 //OWN: Current progress value |
|
84 TInt iCurrentProgress; |
|
85 }; |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CGlobalWaitingNote public functions |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 void CGlobalWaitingNote::ShowMsgL( const TDesC& aMessage, |
|
96 TInt aTotalShowTime, |
|
97 TInt aProgressSteps ) |
|
98 { |
|
99 CGlobalWaitingNote* self = new (ELeave) CGlobalWaitingNote; |
|
100 CleanupStack::PushL( self ); |
|
101 self->ConstructL(); |
|
102 self->DoShowMsgL( aMessage, |
|
103 aTotalShowTime, |
|
104 aProgressSteps ); |
|
105 |
|
106 CleanupStack::PopAndDestroy(); |
|
107 } |
|
108 |
|
109 |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CGlobalWaitingNote private functions |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 CGlobalWaitingNote::CGlobalWaitingNote() |
|
116 : CActive( CActive::EPriorityStandard ) |
|
117 { |
|
118 } |
|
119 |
|
120 |
|
121 CGlobalWaitingNote::~CGlobalWaitingNote() |
|
122 { |
|
123 delete iProgressTicker; |
|
124 delete iGlobalNote; |
|
125 } |
|
126 |
|
127 |
|
128 void CGlobalWaitingNote::ConstructL() |
|
129 { |
|
130 CActiveScheduler::Add( this ); |
|
131 iGlobalNote = CAknGlobalProgressDialog::NewL(); |
|
132 |
|
133 iProgressTicker = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
134 } |
|
135 |
|
136 |
|
137 |
|
138 void CGlobalWaitingNote::DoShowMsgL( const TDesC& aMessage, |
|
139 TInt aTotalShowTime, |
|
140 TInt aProgressSteps ) |
|
141 { |
|
142 iGlobalNote->ShowProgressDialogL( iStatus, |
|
143 aMessage, |
|
144 R_AVKON_SOFTKEYS_OK_EMPTY, |
|
145 aTotalShowTime ); |
|
146 SetActive(); |
|
147 |
|
148 iProgressInterval = aTotalShowTime / aProgressSteps; |
|
149 iTotalShowTime = aTotalShowTime; |
|
150 iCurrentProgress = 0; |
|
151 |
|
152 TCallBack progressCb( CGlobalWaitingNote::ProgressTickCb, this ); |
|
153 iProgressTicker->Start( iProgressInterval, iProgressInterval, progressCb ); |
|
154 |
|
155 iWait.Start(); |
|
156 } |
|
157 |
|
158 |
|
159 TInt CGlobalWaitingNote::ProgressTickCb( TAny* aSelf ) |
|
160 { |
|
161 return ( (CGlobalWaitingNote*) aSelf )->HandleProgressTick(); |
|
162 } |
|
163 |
|
164 |
|
165 TInt CGlobalWaitingNote::HandleProgressTick() |
|
166 { |
|
167 if( iCurrentProgress < iTotalShowTime ) |
|
168 { |
|
169 iCurrentProgress += iProgressInterval; |
|
170 iGlobalNote->UpdateProgressDialog( iCurrentProgress, iTotalShowTime ); |
|
171 } |
|
172 |
|
173 else |
|
174 { |
|
175 iGlobalNote->ProcessFinished(); |
|
176 } |
|
177 |
|
178 return KErrNone; |
|
179 } |
|
180 |
|
181 |
|
182 |
|
183 void CGlobalWaitingNote::RunL() |
|
184 { |
|
185 iWait.AsyncStop(); |
|
186 } |
|
187 |
|
188 |
|
189 TInt CGlobalWaitingNote::RunError( TInt /*aError*/ ) |
|
190 { |
|
191 return KErrNone; |
|
192 } |
|
193 |
|
194 |
|
195 void CGlobalWaitingNote::DoCancel() |
|
196 { |
|
197 iGlobalNote->ProcessFinished(); |
|
198 } |
|
199 |
|
200 #endif // CGLOBALWAITINGNOTE_H |
|
201 |
|
202 // end of file |
|
203 |
|
204 |
|
205 |