|
1 /* |
|
2 * Copyright (c) 2005-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 the License "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: VoD information popup functionality implementation* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <AknInfoPopupNoteController.h> |
|
22 #include <aknview.h> |
|
23 #include <e32base.h> |
|
24 #include <eikmenup.h> |
|
25 #include <StringLoader.h> |
|
26 #include "vcxnsservice.h" |
|
27 #include "vcxnsserviceproviderif.h" |
|
28 #include "vcxnsuiengine.h" |
|
29 #include <vcxhgvodui.rsg> |
|
30 |
|
31 #include "vcxhgvodinformationpopup.h" |
|
32 |
|
33 // CONSTANTS |
|
34 const TInt KTimeForPopupInView = 60000; // 60 sec |
|
35 const TInt KVcxNsInformationPopupTimerMediumDelay = 100000; // 0,1 sec |
|
36 const TInt KVcxNsInformationPopupTimerShortDelay = 100; // 0,0001 sec |
|
37 const TInt KNoDelay = 10; // 0,00001 sec |
|
38 |
|
39 // ============================ MEMBER FUNCTIONS ============================= |
|
40 |
|
41 // --------------------------------------------------------- |
|
42 // CVcxHgVodInformationPopup::CVcxHgVodInformationPopup |
|
43 // --------------------------------------------------------- |
|
44 // |
|
45 CVcxHgVodInformationPopup::CVcxHgVodInformationPopup( |
|
46 CAknView& aParentView, |
|
47 CVcxNsUiEngine& aUiEngine ) |
|
48 : iParentView ( aParentView ), |
|
49 iUiEngine ( aUiEngine ) |
|
50 { |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------- |
|
54 // CVcxHgVodInformationPopup::ConstructL |
|
55 // --------------------------------------------------------- |
|
56 // |
|
57 void CVcxHgVodInformationPopup::ConstructL() |
|
58 { |
|
59 iTimer = CIptvTimer::NewL( CActive::EPriorityStandard, *this ); |
|
60 iPopupText = StringLoader::LoadL( R_VCXHG_VOD_UPDATING ); |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------- |
|
64 // CVcxHgVodInformationPopup::NewL |
|
65 // --------------------------------------------------------- |
|
66 // |
|
67 CVcxHgVodInformationPopup* CVcxHgVodInformationPopup::NewL( |
|
68 CAknView& aParentView, |
|
69 CVcxNsUiEngine& aUiEngine ) |
|
70 { |
|
71 CVcxHgVodInformationPopup* self = |
|
72 new( ELeave ) CVcxHgVodInformationPopup ( aParentView, aUiEngine ); |
|
73 CleanupStack::PushL( self ); |
|
74 self->ConstructL(); |
|
75 CleanupStack::Pop( self ); |
|
76 return self; |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------- |
|
80 // CVcxHgVodInformationPopup::~CVcxHgVodInformationPopup |
|
81 // --------------------------------------------------------- |
|
82 // |
|
83 CVcxHgVodInformationPopup::~CVcxHgVodInformationPopup() |
|
84 { |
|
85 DeleteControl(); |
|
86 |
|
87 delete iPopupText; |
|
88 |
|
89 if (iTimer->IsActive()) |
|
90 { |
|
91 iTimer->Cancel(); |
|
92 } |
|
93 delete iTimer; |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------- |
|
97 // CVcxHgVodInformationPopup::CreateControl |
|
98 // --------------------------------------------------------- |
|
99 // |
|
100 TBool CVcxHgVodInformationPopup::CreateControlL() |
|
101 { |
|
102 TBool controlCreated( EFalse ); |
|
103 |
|
104 if ( !iPopupController ) |
|
105 { |
|
106 iPopupController = CAknInfoPopupNoteController::NewL(); |
|
107 |
|
108 iPopupController->AddObserverL(*this); |
|
109 iPopupController->SetTimePopupInView( KTimeForPopupInView ); |
|
110 //Show immediately |
|
111 iPopupController->SetTimeDelayBeforeShow( KNoDelay ); |
|
112 |
|
113 if ( !iPopupText ) |
|
114 { |
|
115 iPopupText = StringLoader::LoadL( R_VCXHG_VOD_UPDATING ); |
|
116 } |
|
117 |
|
118 iPopupController->SetTextL( iPopupText->Des() ); |
|
119 |
|
120 TRect clientRect = iParentView.ClientRect(); |
|
121 TPoint topRight( clientRect.iBr.iX, clientRect.iTl.iY ); |
|
122 iTopRight = topRight; |
|
123 |
|
124 controlCreated = ETrue; |
|
125 } |
|
126 |
|
127 iPopupController->SetPositionAndAlignment( iTopRight, EHRightVCenter ); |
|
128 |
|
129 return controlCreated; |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------- |
|
133 // CVcxHgVodInformationPopup::DeleteControl |
|
134 // --------------------------------------------------------- |
|
135 // |
|
136 void CVcxHgVodInformationPopup::DeleteControl() |
|
137 { |
|
138 if ( iPopupController ) |
|
139 { |
|
140 iPopupController->RemoveObserver(*this); |
|
141 |
|
142 delete iPopupController; |
|
143 iPopupController = NULL; |
|
144 } |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------- |
|
148 // CVcxHgVodInformationPopup::SetTextL |
|
149 // --------------------------------------------------------- |
|
150 // |
|
151 void CVcxHgVodInformationPopup::SetTextL( const TDesC& aText ) |
|
152 { |
|
153 if ( iPopupText && iPopupController ) |
|
154 { |
|
155 delete iPopupText; |
|
156 iPopupText = NULL; |
|
157 iPopupText = HBufC16::NewL( aText.Length() ); |
|
158 *iPopupText = aText; |
|
159 iPopupController->SetTextL( iPopupText->Des() ); |
|
160 } |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------- |
|
164 // CVcxHgVodInformationPopup::Hide |
|
165 // --------------------------------------------------------- |
|
166 // |
|
167 void CVcxHgVodInformationPopup::Hide() |
|
168 { |
|
169 if ( iTimer->IsActive() ) |
|
170 { |
|
171 iTimer->Cancel(); |
|
172 } |
|
173 |
|
174 if ( iPopupController ) |
|
175 { |
|
176 iPopupController->HideInfoPopupNote(); |
|
177 } |
|
178 |
|
179 DeleteControl(); |
|
180 |
|
181 // Reset the text when hiding on purpose. |
|
182 delete iPopupText; |
|
183 iPopupText = NULL; |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------- |
|
187 // CVcxHgVodInformationPopup::ShowL |
|
188 // --------------------------------------------------------- |
|
189 // |
|
190 void CVcxHgVodInformationPopup::ShowL() |
|
191 { |
|
192 CreateControlL(); |
|
193 |
|
194 if ( iPopupController ) |
|
195 { |
|
196 iPopupController->ShowInfoPopupNote(); |
|
197 } |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------- |
|
201 // CVcxHgVodInformationPopup::HandleInfoPopupNoteEvent |
|
202 // --------------------------------------------------------- |
|
203 // |
|
204 void CVcxHgVodInformationPopup::HandleInfoPopupNoteEvent( |
|
205 CAknInfoPopupNoteController* aController, |
|
206 MAknInfoPopupNoteObserver::TAknInfoPopupNoteEvent aEvent ) |
|
207 { |
|
208 if ( aController ) |
|
209 { |
|
210 if ( aEvent == EInfoPopupNoteHidden ) |
|
211 { |
|
212 TVcxNsAppState state = iUiEngine.VcAppState(); |
|
213 |
|
214 if ( ( state == EStateContentView || state == EStateCategoryView ) |
|
215 && iParentView.IsForeground() ) |
|
216 { |
|
217 // Check if still updating --> if yes, show note again. |
|
218 // We do this because any key press closes the note. |
|
219 TRAP_IGNORE |
|
220 ( |
|
221 if ( iUiEngine.GetServiceProviderL()->GetActiveServiceData()-> |
|
222 GetUpdateStatus() == CVcxNsService::EUpdateOngoing ) |
|
223 { |
|
224 if ( iTimer->IsActive() ) |
|
225 { |
|
226 iTimer->Cancel(); |
|
227 } |
|
228 iTimer->After( KVcxNsInformationPopupTimerShortDelay ); |
|
229 } |
|
230 ) |
|
231 } |
|
232 } |
|
233 else |
|
234 { |
|
235 if ( iTimer->IsActive() ) |
|
236 { |
|
237 iTimer->Cancel(); |
|
238 } |
|
239 } |
|
240 } |
|
241 } |
|
242 |
|
243 // --------------------------------------------------------- |
|
244 // CVcxHgVodInformationPopup::TimerExpired() |
|
245 // --------------------------------------------------------- |
|
246 // |
|
247 void CVcxHgVodInformationPopup::TimerExpired( CIptvTimer* /*aTimer*/ ) |
|
248 { |
|
249 DeleteControl(); |
|
250 TVcxNsAppState state = iUiEngine.VcAppState(); |
|
251 |
|
252 if ( state == EStatePlayback || state == EStateNoState ) |
|
253 { |
|
254 if ( iTimer->IsActive() ) |
|
255 { |
|
256 iTimer->Cancel(); |
|
257 } |
|
258 return; |
|
259 } |
|
260 |
|
261 // When timer expires, check that view still exist (might have been closed) |
|
262 // and update is still ongoing (might have been finished). If both are true |
|
263 // the information pop-up needs to be shown still. |
|
264 |
|
265 if ( ( state == EStateContentView || state == EStateCategoryView ) |
|
266 && iParentView.IsForeground() ) |
|
267 { |
|
268 MVcxNsServiceProviderIf* serviceIf = NULL; |
|
269 TRAPD( leave, serviceIf = iUiEngine.GetServiceProviderL() ); |
|
270 if ( !leave && serviceIf && |
|
271 serviceIf->GetActiveServiceData()->GetUpdateStatus() == CVcxNsService::EUpdateOngoing ) |
|
272 { |
|
273 // If there's a menu, we need to delay note for a moment. Can't display with menu. |
|
274 if( iParentView.MenuBar() && iParentView.MenuBar()->IsDisplayed() ) |
|
275 { |
|
276 if ( iTimer->IsActive() ) |
|
277 { |
|
278 iTimer->Cancel(); |
|
279 } |
|
280 iTimer->After( KVcxNsInformationPopupTimerMediumDelay ); |
|
281 } |
|
282 else |
|
283 { |
|
284 TRAP_IGNORE( ShowL() ); |
|
285 } |
|
286 } |
|
287 } |
|
288 } |
|
289 |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 // ----------------------------------------------------------------------------- |
|
293 // |
|
294 void CVcxHgVodInformationPopup::HandleForegroundEventL( TBool aForeground ) |
|
295 { |
|
296 if ( aForeground ) |
|
297 { |
|
298 // Don't active timer after Hide() has been called (iPopupText is then NULL) |
|
299 if ( iPopupText ) |
|
300 { |
|
301 iTimer->Cancel(); |
|
302 iTimer->After( KVcxNsInformationPopupTimerShortDelay ); |
|
303 } |
|
304 } |
|
305 else |
|
306 { |
|
307 // Nothing to do |
|
308 } |
|
309 } |
|
310 |
|
311 // ----------------------------------------------------------------------------- |
|
312 // |
|
313 // ----------------------------------------------------------------------------- |
|
314 // |
|
315 void CVcxHgVodInformationPopup::HandleSizeChange() |
|
316 { |
|
317 // Must update popup position relative to client rect. |
|
318 // Don't active timer after Hide() has been called (iPopupText is then NULL) |
|
319 if ( iPopupController && iPopupText ) |
|
320 { |
|
321 iTimer->Cancel(); |
|
322 iTimer->After( KVcxNsInformationPopupTimerShortDelay ); |
|
323 } |
|
324 } |