|
1 /* |
|
2 * Copyright (c) 2002 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: view class |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <eikmenup.h> |
|
22 #include <akntitle.h> //for CAknTitlePane |
|
23 #include <ConnectionMonitorUi.rsg> |
|
24 #include <StringLoader.h> |
|
25 |
|
26 #include <hlplch.h> |
|
27 #include <csxhelp/cmon.hlp.hrh> |
|
28 |
|
29 |
|
30 #include "ConnectionMonitorUiDetailsView.h" |
|
31 #include "ConnectionMonitorUi.hrh" |
|
32 #include "ConnectionMonitorUiAppUi.h" |
|
33 #include "ConnectionMonitorUiView.h" |
|
34 #include "ConnectionMonitorUiContainer.h" |
|
35 #include "ConnectionArray.h" |
|
36 #include "FeatureManagerWrapper.h" |
|
37 |
|
38 |
|
39 // CONSTANTS |
|
40 |
|
41 // ================= MEMBER FUNCTIONS ======================= |
|
42 // --------------------------------------------------------- |
|
43 // CConnectionMonitorUiView::CConnectionMonitorUiView |
|
44 // --------------------------------------------------------- |
|
45 // |
|
46 #ifdef RD_CONTROL_PANEL |
|
47 CConnectionMonitorUiView::CConnectionMonitorUiView( |
|
48 CConnectionArray* const aConnectionArray, |
|
49 RConnectionMonitor* aMonitor, |
|
50 TBool aIsEmbedded, |
|
51 CActiveWrapper* aActiveWrapper ) |
|
52 : CAknView(), |
|
53 iConnectionArray( aConnectionArray ), |
|
54 iMonitor( aMonitor ), |
|
55 isHelpSupported( EFalse ), |
|
56 iIsEmbedded( EFalse ), |
|
57 iActiveWrapper( aActiveWrapper ) |
|
58 { |
|
59 iIsEmbedded = aIsEmbedded; |
|
60 } |
|
61 #else |
|
62 CConnectionMonitorUiView::CConnectionMonitorUiView( |
|
63 CConnectionArray* const aConnectionArray, |
|
64 RConnectionMonitor* aMonitor, |
|
65 CActiveWrapper* aActiveWrapper ) |
|
66 : CAknView(), |
|
67 iConnectionArray( aConnectionArray ), |
|
68 iMonitor( aMonitor ), |
|
69 isHelpSupported( EFalse ), |
|
70 iActiveWrapper( aActiveWrapper ) |
|
71 { |
|
72 } |
|
73 #endif // RD_CONTROL_PANEL |
|
74 |
|
75 // --------------------------------------------------------- |
|
76 // CConnectionMonitorUiView::ConstructL |
|
77 // --------------------------------------------------------- |
|
78 // |
|
79 void CConnectionMonitorUiView::ConstructL() |
|
80 { |
|
81 isHelpSupported = FeatureManager::FeatureSupported( KFeatureIdHelp ); |
|
82 |
|
83 TInt actView( NULL ); |
|
84 |
|
85 #ifdef RD_CONTROL_PANEL |
|
86 if ( iIsEmbedded ) |
|
87 { |
|
88 actView = R_CP_CONNECTIONMONITORUI_VIEW; |
|
89 } |
|
90 else |
|
91 { |
|
92 actView = R_CONNECTIONMONITORUI_VIEW; |
|
93 } |
|
94 #else |
|
95 actView = R_CONNECTIONMONITORUI_VIEW; |
|
96 #endif // RD_CONTROL_PANEL |
|
97 |
|
98 BaseConstructL( actView ); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------- |
|
102 // CConnectionMonitorUiView::~CConnectionMonitorUiView() |
|
103 // --------------------------------------------------------- |
|
104 // |
|
105 CConnectionMonitorUiView::~CConnectionMonitorUiView() |
|
106 { |
|
107 delete iContainer; |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------- |
|
111 // TUid CConnectionMonitorUiView::Id() |
|
112 // --------------------------------------------------------- |
|
113 // |
|
114 TUid CConnectionMonitorUiView::Id() const |
|
115 { |
|
116 return KConnectionsViewId; |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------- |
|
120 // CConnectionMonitorUiView::HandleCommandL( TInt aCommand ) |
|
121 // --------------------------------------------------------- |
|
122 // |
|
123 void CConnectionMonitorUiView::HandleCommandL( TInt aCommand ) |
|
124 { |
|
125 switch ( aCommand ) |
|
126 { |
|
127 case EAknSoftkeyDetails: |
|
128 { |
|
129 if ( IsSelectedConnectionAlive() ) |
|
130 { |
|
131 BringupDetailsViewL(); |
|
132 } |
|
133 break; |
|
134 } |
|
135 case EConnectionMonitorUiCmdAppDetails: |
|
136 { |
|
137 BringupDetailsViewL(); |
|
138 break; |
|
139 } |
|
140 case EConnectionMonitorUiCmdAppEndConn: |
|
141 { |
|
142 iContainer->EndConnectionL(); |
|
143 break; |
|
144 } |
|
145 case EConnectionMonitorUiCmdAppEndAll: |
|
146 { |
|
147 iContainer->EndAllConnectionL(); |
|
148 break; |
|
149 } |
|
150 case EAknCmdHelp: |
|
151 { |
|
152 if ( isHelpSupported ) |
|
153 { |
|
154 HlpLauncher::LaunchHelpApplicationL( |
|
155 CEikonEnv::Static()->WsSession(), |
|
156 CEikonEnv::Static()->EikAppUi()->AppHelpContextL() ); |
|
157 } |
|
158 break; |
|
159 } |
|
160 default: |
|
161 { |
|
162 AppUi()->HandleCommandL( aCommand ); |
|
163 break; |
|
164 } |
|
165 } |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------- |
|
169 // CConnectionMonitorUiView::DynInitMenuPaneL() |
|
170 // --------------------------------------------------------- |
|
171 // |
|
172 void CConnectionMonitorUiView::DynInitMenuPaneL( TInt aResourceId, |
|
173 CEikMenuPane* aMenuPane ) |
|
174 { |
|
175 MEikMenuObserver::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
176 switch ( aResourceId ) |
|
177 { |
|
178 case R_CONNECTIONMONITORUI_VIEW_MENU: |
|
179 { |
|
180 if ( !iConnectionArray->MdcaCount() ) |
|
181 { |
|
182 aMenuPane->DeleteMenuItem( |
|
183 EConnectionMonitorUiCmdAppDetails ); |
|
184 aMenuPane->DeleteMenuItem( |
|
185 EConnectionMonitorUiCmdAppEndConn ); |
|
186 aMenuPane->DeleteMenuItem( |
|
187 EConnectionMonitorUiCmdAppEndAll ); |
|
188 } |
|
189 else if ( iConnectionArray->MdcaCount() == 1 ) |
|
190 { |
|
191 aMenuPane->DeleteMenuItem( |
|
192 EConnectionMonitorUiCmdAppEndAll ); |
|
193 if ( !IsSelectedConnectionAlive() ) |
|
194 { |
|
195 aMenuPane->DeleteMenuItem( |
|
196 EConnectionMonitorUiCmdAppDetails ); |
|
197 } |
|
198 else if ( IsSelectedConnectionSuspended() ) |
|
199 { |
|
200 aMenuPane->DeleteMenuItem( |
|
201 EConnectionMonitorUiCmdAppEndConn ); |
|
202 } |
|
203 } |
|
204 else if ( iConnectionArray->NumberOfSuspendedConnections() >= 1 ) |
|
205 { |
|
206 aMenuPane->DeleteMenuItem( |
|
207 EConnectionMonitorUiCmdAppEndAll ); |
|
208 if ( IsSelectedConnectionSuspended() ) |
|
209 { |
|
210 aMenuPane->DeleteMenuItem( |
|
211 EConnectionMonitorUiCmdAppEndConn ); |
|
212 } |
|
213 } |
|
214 else |
|
215 { |
|
216 if ( !IsSelectedConnectionAlive() ) |
|
217 { |
|
218 aMenuPane->DeleteMenuItem( |
|
219 EConnectionMonitorUiCmdAppDetails ); |
|
220 aMenuPane->DeleteMenuItem( |
|
221 EConnectionMonitorUiCmdAppEndConn ); |
|
222 } |
|
223 } |
|
224 break; |
|
225 } |
|
226 case R_CONNECTIONMONITORUI_APP_MENU: |
|
227 { |
|
228 if ( !isHelpSupported ) |
|
229 { |
|
230 aMenuPane->DeleteMenuItem( EAknCmdHelp ); |
|
231 } |
|
232 break; |
|
233 } |
|
234 default: |
|
235 { |
|
236 break; |
|
237 } |
|
238 } |
|
239 } |
|
240 |
|
241 // --------------------------------------------------------- |
|
242 // CConnectionMonitorUiView::HandleListBoxEventL |
|
243 // --------------------------------------------------------- |
|
244 // |
|
245 void CConnectionMonitorUiView::HandleListBoxEventL( CEikListBox* /*aListBox*/, |
|
246 TListBoxEvent aEventType ) |
|
247 { |
|
248 switch ( aEventType ) |
|
249 { |
|
250 case EEventEnterKeyPressed: |
|
251 //case EEventItemDoubleClicked: |
|
252 case EEventItemSingleClicked: |
|
253 { |
|
254 if ( IsSelectedConnectionAlive() ) |
|
255 { |
|
256 BringupDetailsViewL(); |
|
257 } |
|
258 } |
|
259 break; |
|
260 default: |
|
261 break; |
|
262 } |
|
263 } |
|
264 |
|
265 // --------------------------------------------------------- |
|
266 // CConnectionMonitorUiView::DoActivateL |
|
267 // --------------------------------------------------------- |
|
268 // |
|
269 void CConnectionMonitorUiView::DoActivateL( |
|
270 const TVwsViewId& /*aPrevViewId*/, |
|
271 TUid /*aCustomMessageId*/, |
|
272 const TDesC8& /*aCustomMessage*/ ) |
|
273 { |
|
274 CMUILOGGER_ENTERFN( "CConnectionMonitorUiView::DoActivateL" ); |
|
275 |
|
276 if ( !iContainer ) |
|
277 { |
|
278 iContainer = new( ELeave ) CConnectionMonitorUiContainer( |
|
279 iConnectionArray, |
|
280 iMonitor, |
|
281 iActiveWrapper ); |
|
282 iContainer->SetMopParent( this ); |
|
283 |
|
284 |
|
285 CConnectionMonitorUiDetailsView* view = |
|
286 STATIC_CAST( CConnectionMonitorUiDetailsView*, |
|
287 AppUi()->View( TUid::Uid( EConnectionMonitorUiDetailsViewTab ) ) ); |
|
288 |
|
289 TInt index = view->GetSelectedConnection(); |
|
290 CMUILOGGER_WRITE_F( "index: %d", index ); |
|
291 |
|
292 iContainer->ConstructL( index, ClientRect() ); |
|
293 iContainer->ListBox()->SetListBoxObserver( this ); |
|
294 |
|
295 CConnectionMonitorUiAppUi::Static()->StartConnEventNotification( |
|
296 iContainer ); |
|
297 iContainer->PushAndRefreshNaviPaneL(); |
|
298 AppUi()->AddToViewStackL( *this, iContainer ); |
|
299 ConnectionKeyObserver(); |
|
300 } |
|
301 CMUILOGGER_LEAVEFN( "CConnectionMonitorUiView::DoActivateL" ); |
|
302 |
|
303 } |
|
304 |
|
305 // --------------------------------------------------------- |
|
306 // CConnectionMonitorUiView::DoDeactivate |
|
307 // --------------------------------------------------------- |
|
308 // |
|
309 void CConnectionMonitorUiView::DoDeactivate() |
|
310 { |
|
311 CMUILOGGER_ENTERFN( "CConnectionMonitorUiView::DoDeactivate" ); |
|
312 |
|
313 if ( iContainer ) |
|
314 { |
|
315 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
316 CConnectionMonitorUiAppUi::Static()->StopConnEventNotification( |
|
317 iContainer ); |
|
318 iContainer->PopNaviPane(); |
|
319 delete iContainer; |
|
320 iContainer = NULL; |
|
321 } |
|
322 CMUILOGGER_LEAVEFN( "CConnectionMonitorUiView::DoDeactivate" ); |
|
323 } |
|
324 |
|
325 // --------------------------------------------------------- |
|
326 // CConnectionMonitorUiView::SetTitlePaneTextL |
|
327 // --------------------------------------------------------- |
|
328 // |
|
329 void CConnectionMonitorUiView::SetTitlePaneTextL( TInt aResourceId ) |
|
330 { |
|
331 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
332 CAknTitlePane* titlePane = |
|
333 ( CAknTitlePane* )statusPane->ControlL( |
|
334 TUid::Uid( EEikStatusPaneUidTitle ) ); |
|
335 HBufC* text = iEikonEnv->AllocReadResourceLC( aResourceId ); |
|
336 titlePane->SetTextL( text->Des() ); |
|
337 CleanupStack::PopAndDestroy( text ); |
|
338 } |
|
339 |
|
340 // --------------------------------------------------------- |
|
341 // CConnectionMonitorUiView::BringupDetailsViewL |
|
342 // --------------------------------------------------------- |
|
343 // |
|
344 void CConnectionMonitorUiView::BringupDetailsViewL() |
|
345 { |
|
346 CConnectionMonitorUiDetailsView* view = |
|
347 STATIC_CAST( CConnectionMonitorUiDetailsView*, |
|
348 AppUi()->View( TUid::Uid( |
|
349 EConnectionMonitorUiDetailsViewTab ) ) ); |
|
350 |
|
351 TInt selIndex = iContainer->SelectedConnection(); |
|
352 view->SetSelectedConnection( selIndex ); |
|
353 AppUi()->ActivateLocalViewL( |
|
354 TUid::Uid( EConnectionMonitorUiDetailsViewTab ) ); |
|
355 } |
|
356 |
|
357 // --------------------------------------------------------- |
|
358 // CConnectionMonitorUiView::IsSelectedConnectionAlive |
|
359 // --------------------------------------------------------- |
|
360 // |
|
361 TBool CConnectionMonitorUiView::IsSelectedConnectionAlive() const |
|
362 { |
|
363 TInt selIndex = iContainer->SelectedConnection(); |
|
364 TBool result( EFalse ); |
|
365 if ( selIndex > -1 ) |
|
366 { |
|
367 result = ( *iConnectionArray )[selIndex]->IsAlive(); |
|
368 } |
|
369 |
|
370 return result; |
|
371 } |
|
372 |
|
373 // --------------------------------------------------------- |
|
374 // CConnectionMonitorUiView::IsSelectedConnectionSuspended |
|
375 // --------------------------------------------------------- |
|
376 // |
|
377 TBool CConnectionMonitorUiView::IsSelectedConnectionSuspended() const |
|
378 { |
|
379 TInt selIndex = iContainer->SelectedConnection(); |
|
380 TBool result( EFalse ); |
|
381 if ( selIndex > -1 ) |
|
382 { |
|
383 result = ( *iConnectionArray )[selIndex]->IsSuspended(); |
|
384 } |
|
385 |
|
386 return result; |
|
387 } |
|
388 |
|
389 // --------------------------------------------------------- |
|
390 // CConnectionMonitorUiView::ConnectionKeyObserver |
|
391 // --------------------------------------------------------- |
|
392 // |
|
393 void CConnectionMonitorUiView::ConnectionKeyObserver() const |
|
394 { |
|
395 if ( !( iConnectionArray->MdcaCount() ) ) |
|
396 { |
|
397 Cba()->MakeCommandVisible( EAknSoftkeyDetails,EFalse ); |
|
398 } |
|
399 else |
|
400 { |
|
401 if ( iConnectionArray->NumberOfActiveConnections() ) |
|
402 { |
|
403 Cba()->MakeCommandVisible( EAknSoftkeyDetails,ETrue ); |
|
404 } |
|
405 else |
|
406 { |
|
407 Cba()->MakeCommandVisible( EAknSoftkeyDetails,EFalse ); |
|
408 } |
|
409 } |
|
410 } |
|
411 |
|
412 |
|
413 |
|
414 // End of File |