|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "MCETestUI.hrh" |
|
20 #include "CMCETestUIStreamView.h" |
|
21 |
|
22 #include <e32def.h> |
|
23 #include <barsread.h> |
|
24 #include <AknNoteWrappers.h> |
|
25 #include <aknviewappui.h> |
|
26 #include <eikbtgpc.h> |
|
27 #include <akntitle.h> // for CAknTitlePane |
|
28 #include <aknnavi.h> // for CAknNavigationControlContainer |
|
29 #include <aknnavide.h> // for CAknNavigationDecorator |
|
30 #include "CMCETestUIAppUi.h" |
|
31 #include "CMCETestUiEngineAudioStream.h" |
|
32 #include "CMCETestUiEngineVideoStream.h" |
|
33 #include "CMCETestUiEngineOutSession.h" |
|
34 #include "CMCETestUiEngineInSession.h" |
|
35 #include <aknviewappui.h> |
|
36 |
|
37 // CONSTANTS |
|
38 |
|
39 |
|
40 CMCETestUIStreamView* CMCETestUIStreamView::NewL( CMCETestUIEngine& aEngine ) |
|
41 { |
|
42 CMCETestUIStreamView* self = new(ELeave) CMCETestUIStreamView( aEngine ); |
|
43 CleanupStack::PushL(self); |
|
44 self->ConstructL(); |
|
45 CleanupStack::Pop(self); |
|
46 return self; |
|
47 } |
|
48 |
|
49 CMCETestUIStreamView::CMCETestUIStreamView( CMCETestUIEngine& aEngine ) |
|
50 : iEngine( aEngine) |
|
51 { |
|
52 } |
|
53 |
|
54 // |
|
55 // Destructor for the view. |
|
56 // |
|
57 CMCETestUIStreamView::~CMCETestUIStreamView() |
|
58 { |
|
59 if (iContainer) |
|
60 { |
|
61 AppUi()->RemoveFromViewStack( *this, iContainer); |
|
62 delete iContainer; |
|
63 iContainer = NULL; |
|
64 } |
|
65 if (iVideoContainer) |
|
66 { |
|
67 AppUi()->RemoveFromViewStack( *this, iVideoContainer); |
|
68 delete iVideoContainer; |
|
69 iVideoContainer = NULL; |
|
70 } |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CMCETestUISessionView::EngineStateChangedL() |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CMCETestUIStreamView::EngineStateChangedL() |
|
78 { |
|
79 if ( iContainer ) |
|
80 { |
|
81 iContainer->ConstructModelL(); |
|
82 iContainer->DrawNow(); |
|
83 // ConstructStatusPaneL(); |
|
84 } |
|
85 if ( iVideoContainer ) |
|
86 { |
|
87 iVideoContainer->ConstructModelL(); |
|
88 iVideoContainer->DrawNow(); |
|
89 // ConstructStatusPaneL(); |
|
90 } |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CMCETestUISessionView::ChangeToMainViewL() |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CMCETestUIStreamView::ChangeToSessionViewL() |
|
98 { |
|
99 TUid viewId = TUid::Uid( EMCETestUISessionViewId ); |
|
100 TUid customMessageId = TUid::Uid( EMCETestUISessionViewId ); |
|
101 |
|
102 TBuf8<10> streamIndex; |
|
103 TInt aStreamIndex = 0; |
|
104 streamIndex.AppendNum( aStreamIndex ); |
|
105 |
|
106 TRAPD( err, AppUi()->ActivateLocalViewL( viewId,customMessageId,streamIndex ) ); |
|
107 if ( err != KErrNone ) |
|
108 { |
|
109 User::InfoPrint( _L("Error") ); |
|
110 } |
|
111 |
|
112 } |
|
113 |
|
114 /** |
|
115 * Called by the framework |
|
116 * @return The Uid for this view |
|
117 */ |
|
118 TUid CMCETestUIStreamView::Id() const |
|
119 { |
|
120 return TUid::Uid( EMCETestUIStreamViewId ); |
|
121 } |
|
122 |
|
123 |
|
124 /** |
|
125 * From CEikAppUi, takes care of command handling for this view. |
|
126 * |
|
127 * @param aCommand command to be handled |
|
128 */ |
|
129 void CMCETestUIStreamView::HandleCommandL( TInt aCommand ) |
|
130 { |
|
131 switch ( aCommand ) |
|
132 { |
|
133 case EAknSoftkeyBack: |
|
134 { |
|
135 ChangeToSessionViewL(); |
|
136 break; |
|
137 } |
|
138 case EAknSoftkeyOptions: |
|
139 { |
|
140 if ( iContainer ){ |
|
141 iContainer->DoShowMenuL(); |
|
142 } |
|
143 if ( iVideoContainer ){ |
|
144 iContainer->DoShowMenuL(); |
|
145 } |
|
146 break; |
|
147 } |
|
148 default: |
|
149 { |
|
150 } |
|
151 } |
|
152 } |
|
153 |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CMCETestUISessionView::DoActivateL |
|
157 // |
|
158 // Called by the framework when the view is activated. Constructs the |
|
159 // container if necessary, setting this view as its MOP parent, and |
|
160 // adding it to the control stack. |
|
161 // |
|
162 // ----------------------------------------------------------------------------- |
|
163 |
|
164 void CMCETestUIStreamView::DoActivateL( |
|
165 const TVwsViewId& /*aPrevViewId*/, |
|
166 TUid /*aCustomMessageId*/, |
|
167 const TDesC8& /*aCustomMessage */) |
|
168 { |
|
169 if (!iContainer) |
|
170 { |
|
171 |
|
172 // Solve session to be shown |
|
173 CEikonEnv* eikonEnv = CEikonEnv::Static(); |
|
174 CMCETestUIAppUi* tempUiPtr = (CMCETestUIAppUi*)eikonEnv->AppUi(); |
|
175 TInt sessionIndex = tempUiPtr->iCurrentSessionViewIndex ; |
|
176 const RPointerArray<CMCETestUIEngineOutSession>& outSessions = |
|
177 iEngine.OutSessions(); |
|
178 |
|
179 const RPointerArray<CMCETestUIEngineInSession>& inSessions = |
|
180 iEngine.InSessions(); |
|
181 |
|
182 if ( sessionIndex < outSessions.Count() ) |
|
183 { |
|
184 iSession = outSessions[sessionIndex]; |
|
185 } |
|
186 else |
|
187 { |
|
188 sessionIndex -= outSessions.Count(); |
|
189 if ( sessionIndex < inSessions.Count() ) |
|
190 { |
|
191 iSession = inSessions[sessionIndex]; |
|
192 } |
|
193 else |
|
194 { |
|
195 User::Leave( KErrArgument ); |
|
196 } |
|
197 } |
|
198 |
|
199 // Solve stream to be shown |
|
200 |
|
201 TInt streamIndex = tempUiPtr->iCurrentStreamViewIndex; |
|
202 |
|
203 |
|
204 const RPointerArray<CMCETestUIEngineAudioStream>& audioStreams = |
|
205 iSession->AudioStreamsL(); |
|
206 |
|
207 const RPointerArray<CMCETestUIEngineVideoStream>& videoStreams = |
|
208 iSession->VideoStreamsL(); |
|
209 |
|
210 if ( streamIndex < audioStreams.Count() ) |
|
211 { |
|
212 iStream = audioStreams[streamIndex]; |
|
213 iContainer = CMCETestUIStreamViewContainer::NewL( |
|
214 AppUi()->ClientRect(), *this, iEngine, *iStream ); |
|
215 iContainer->SetMopParent(this); |
|
216 //iContainer->ConstructL(AppUi()->ClientRect()); |
|
217 AppUi()->AddToViewStackL( *this, iContainer ); |
|
218 } |
|
219 else |
|
220 { |
|
221 streamIndex -= audioStreams.Count(); |
|
222 if ( streamIndex < videoStreams.Count() ) |
|
223 { |
|
224 iVideoStream = videoStreams[streamIndex]; |
|
225 iVideoContainer = CMCETestUIVideoStreamViewContainer::NewL( |
|
226 AppUi()->ClientRect(), *this, iEngine, *iVideoStream ); |
|
227 iVideoContainer->SetMopParent(this); |
|
228 //iContainer->ConstructL(AppUi()->ClientRect()); |
|
229 AppUi()->AddToViewStackL( *this, iVideoContainer ); |
|
230 } |
|
231 else |
|
232 { |
|
233 User::Leave( KErrArgument ); |
|
234 } |
|
235 } |
|
236 |
|
237 |
|
238 /* else |
|
239 { |
|
240 streamIndex -= audioStreams.Count(); |
|
241 iStream = audioStreams[streamIndex]; |
|
242 } |
|
243 */ |
|
244 /* iContainer = CMCETestUIStreamViewContainer::NewL( |
|
245 AppUi()->ClientRect(), *this, iEngine, *iStream ); |
|
246 iContainer->SetMopParent(this); |
|
247 //iContainer->ConstructL(AppUi()->ClientRect()); |
|
248 AppUi()->AddToViewStackL( *this, iContainer ); |
|
249 */ } |
|
250 |
|
251 |
|
252 Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); |
|
253 Cba()->DrawNow(); |
|
254 |
|
255 // ConstructStatusPaneL(); |
|
256 |
|
257 } |
|
258 |
|
259 |
|
260 // ----------------------------------------------------------------------------- |
|
261 // CMCETestUIStreamView::DoDeactivate |
|
262 // |
|
263 // Called by the framework when the view is deactivated. |
|
264 // Removes the container from the control stack and deletes it. |
|
265 // |
|
266 // ----------------------------------------------------------------------------- |
|
267 void CMCETestUIStreamView::DoDeactivate() |
|
268 { |
|
269 if (iContainer ) |
|
270 { |
|
271 // TODO: This should not leave |
|
272 CAknNavigationControlContainer* navi = |
|
273 static_cast<CAknNavigationControlContainer*> |
|
274 (StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) )); |
|
275 navi->Pop( iNaviLabel ); |
|
276 delete iNaviLabel; |
|
277 iNaviLabel = NULL; |
|
278 |
|
279 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
280 delete iContainer; |
|
281 iContainer = NULL; |
|
282 } |
|
283 if (iVideoContainer ) |
|
284 { |
|
285 // TODO: This should not leave |
|
286 CAknNavigationControlContainer* navi = |
|
287 static_cast<CAknNavigationControlContainer*> |
|
288 (StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) )); |
|
289 navi->Pop( iNaviLabel ); |
|
290 delete iNaviLabel; |
|
291 iNaviLabel = NULL; |
|
292 |
|
293 AppUi()->RemoveFromViewStack( *this, iVideoContainer ); |
|
294 delete iVideoContainer; |
|
295 iVideoContainer = NULL; |
|
296 } |
|
297 } |
|
298 |
|
299 // ----------------------------------------------------------------------------- |
|
300 // CMCETestUIStreamView::ConstructStatusPaneL |
|
301 // ----------------------------------------------------------------------------- |
|
302 // |
|
303 void CMCETestUIStreamView::ConstructStatusPaneL() |
|
304 { |
|
305 CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
|
306 (StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) )); |
|
307 titlePane->SetTextL( KStream ); |
|
308 |
|
309 CAknNavigationControlContainer* navi = |
|
310 static_cast<CAknNavigationControlContainer*> |
|
311 (StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) )); |
|
312 navi->Pop( iNaviLabel ); |
|
313 delete iNaviLabel; |
|
314 iNaviLabel = NULL; |
|
315 iNaviLabel = navi->CreateNavigationLabelL( iStream->State() ); |
|
316 navi->PushL( *iNaviLabel ); |
|
317 } |
|
318 |
|
319 // ----------------------------------------------------------------------------- |
|
320 // CMCETestUIStreamView::ConstructL |
|
321 // ----------------------------------------------------------------------------- |
|
322 // |
|
323 void CMCETestUIStreamView::ConstructL() |
|
324 { |
|
325 BaseConstructL(); |
|
326 } |