58
|
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 |
// This is a security measure to prevent menu pane updates when
|
|
177 |
// the main view is not active. This should not happen but
|
|
178 |
// just to be safe it is checked.
|
|
179 |
if ( !iContainer )
|
|
180 |
{
|
|
181 |
return;
|
|
182 |
}
|
|
183 |
switch ( aResourceId )
|
|
184 |
{
|
|
185 |
case R_CONNECTIONMONITORUI_VIEW_MENU:
|
|
186 |
{
|
|
187 |
if ( !iConnectionArray->MdcaCount() )
|
|
188 |
{
|
|
189 |
aMenuPane->DeleteMenuItem(
|
|
190 |
EConnectionMonitorUiCmdAppDetails );
|
|
191 |
aMenuPane->DeleteMenuItem(
|
|
192 |
EConnectionMonitorUiCmdAppEndConn );
|
|
193 |
aMenuPane->DeleteMenuItem(
|
|
194 |
EConnectionMonitorUiCmdAppEndAll );
|
|
195 |
}
|
|
196 |
else if ( iConnectionArray->MdcaCount() == 1 )
|
|
197 |
{
|
|
198 |
aMenuPane->DeleteMenuItem(
|
|
199 |
EConnectionMonitorUiCmdAppEndAll );
|
|
200 |
if ( !IsSelectedConnectionAlive() )
|
|
201 |
{
|
|
202 |
aMenuPane->DeleteMenuItem(
|
|
203 |
EConnectionMonitorUiCmdAppDetails );
|
|
204 |
}
|
|
205 |
else if ( IsSelectedConnectionSuspended() )
|
|
206 |
{
|
|
207 |
aMenuPane->DeleteMenuItem(
|
|
208 |
EConnectionMonitorUiCmdAppEndConn );
|
|
209 |
}
|
|
210 |
}
|
|
211 |
else if ( iConnectionArray->NumberOfSuspendedConnections() >= 1 )
|
|
212 |
{
|
|
213 |
aMenuPane->DeleteMenuItem(
|
|
214 |
EConnectionMonitorUiCmdAppEndAll );
|
|
215 |
if ( IsSelectedConnectionSuspended() )
|
|
216 |
{
|
|
217 |
aMenuPane->DeleteMenuItem(
|
|
218 |
EConnectionMonitorUiCmdAppEndConn );
|
|
219 |
}
|
|
220 |
}
|
|
221 |
else
|
|
222 |
{
|
|
223 |
if ( !IsSelectedConnectionAlive() )
|
|
224 |
{
|
|
225 |
aMenuPane->DeleteMenuItem(
|
|
226 |
EConnectionMonitorUiCmdAppDetails );
|
|
227 |
aMenuPane->DeleteMenuItem(
|
|
228 |
EConnectionMonitorUiCmdAppEndConn );
|
|
229 |
}
|
|
230 |
}
|
|
231 |
break;
|
|
232 |
}
|
|
233 |
case R_CONNECTIONMONITORUI_APP_MENU:
|
|
234 |
{
|
|
235 |
if ( !isHelpSupported )
|
|
236 |
{
|
|
237 |
aMenuPane->DeleteMenuItem( EAknCmdHelp );
|
|
238 |
}
|
|
239 |
break;
|
|
240 |
}
|
|
241 |
default:
|
|
242 |
{
|
|
243 |
break;
|
|
244 |
}
|
|
245 |
}
|
|
246 |
}
|
|
247 |
|
|
248 |
// ---------------------------------------------------------
|
|
249 |
// CConnectionMonitorUiView::HandleListBoxEventL
|
|
250 |
// ---------------------------------------------------------
|
|
251 |
//
|
|
252 |
void CConnectionMonitorUiView::HandleListBoxEventL( CEikListBox* /*aListBox*/,
|
|
253 |
TListBoxEvent aEventType )
|
|
254 |
{
|
|
255 |
switch ( aEventType )
|
|
256 |
{
|
|
257 |
case EEventEnterKeyPressed:
|
|
258 |
//case EEventItemDoubleClicked:
|
|
259 |
case EEventItemSingleClicked:
|
|
260 |
{
|
|
261 |
if ( IsSelectedConnectionAlive() )
|
|
262 |
{
|
|
263 |
BringupDetailsViewL();
|
|
264 |
}
|
|
265 |
}
|
|
266 |
break;
|
|
267 |
default:
|
|
268 |
break;
|
|
269 |
}
|
|
270 |
}
|
|
271 |
|
|
272 |
// ---------------------------------------------------------
|
|
273 |
// CConnectionMonitorUiView::DoActivateL
|
|
274 |
// ---------------------------------------------------------
|
|
275 |
//
|
|
276 |
void CConnectionMonitorUiView::DoActivateL(
|
|
277 |
const TVwsViewId& /*aPrevViewId*/,
|
|
278 |
TUid /*aCustomMessageId*/,
|
|
279 |
const TDesC8& /*aCustomMessage*/ )
|
|
280 |
{
|
|
281 |
CMUILOGGER_ENTERFN( "CConnectionMonitorUiView::DoActivateL" );
|
|
282 |
|
|
283 |
if ( !iContainer )
|
|
284 |
{
|
|
285 |
iContainer = new( ELeave ) CConnectionMonitorUiContainer(
|
|
286 |
iConnectionArray,
|
|
287 |
iMonitor,
|
|
288 |
iActiveWrapper );
|
|
289 |
iContainer->SetMopParent( this );
|
|
290 |
|
|
291 |
|
|
292 |
CConnectionMonitorUiDetailsView* view =
|
|
293 |
STATIC_CAST( CConnectionMonitorUiDetailsView*,
|
|
294 |
AppUi()->View( TUid::Uid( EConnectionMonitorUiDetailsViewTab ) ) );
|
|
295 |
|
|
296 |
TInt index = view->GetSelectedConnection();
|
|
297 |
CMUILOGGER_WRITE_F( "index: %d", index );
|
|
298 |
|
|
299 |
iContainer->ConstructL( index, ClientRect() );
|
|
300 |
iContainer->ListBox()->SetListBoxObserver( this );
|
|
301 |
|
|
302 |
CConnectionMonitorUiAppUi::Static()->StartConnEventNotification(
|
|
303 |
iContainer );
|
|
304 |
iContainer->PushAndRefreshNaviPaneL();
|
|
305 |
AppUi()->AddToViewStackL( *this, iContainer );
|
|
306 |
ConnectionKeyObserver();
|
|
307 |
}
|
|
308 |
CMUILOGGER_LEAVEFN( "CConnectionMonitorUiView::DoActivateL" );
|
|
309 |
|
|
310 |
}
|
|
311 |
|
|
312 |
// ---------------------------------------------------------
|
|
313 |
// CConnectionMonitorUiView::DoDeactivate
|
|
314 |
// ---------------------------------------------------------
|
|
315 |
//
|
|
316 |
void CConnectionMonitorUiView::DoDeactivate()
|
|
317 |
{
|
|
318 |
CMUILOGGER_ENTERFN( "CConnectionMonitorUiView::DoDeactivate" );
|
|
319 |
|
|
320 |
if ( iContainer )
|
|
321 |
{
|
|
322 |
AppUi()->RemoveFromViewStack( *this, iContainer );
|
|
323 |
CConnectionMonitorUiAppUi::Static()->StopConnEventNotification(
|
|
324 |
iContainer );
|
|
325 |
iContainer->PopNaviPane();
|
|
326 |
delete iContainer;
|
|
327 |
iContainer = NULL;
|
|
328 |
}
|
|
329 |
CMUILOGGER_LEAVEFN( "CConnectionMonitorUiView::DoDeactivate" );
|
|
330 |
}
|
|
331 |
|
|
332 |
// ---------------------------------------------------------
|
|
333 |
// CConnectionMonitorUiView::SetTitlePaneTextL
|
|
334 |
// ---------------------------------------------------------
|
|
335 |
//
|
|
336 |
void CConnectionMonitorUiView::SetTitlePaneTextL( TInt aResourceId )
|
|
337 |
{
|
|
338 |
CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
|
|
339 |
CAknTitlePane* titlePane =
|
|
340 |
( CAknTitlePane* )statusPane->ControlL(
|
|
341 |
TUid::Uid( EEikStatusPaneUidTitle ) );
|
|
342 |
HBufC* text = iEikonEnv->AllocReadResourceLC( aResourceId );
|
|
343 |
titlePane->SetTextL( text->Des() );
|
|
344 |
CleanupStack::PopAndDestroy( text );
|
|
345 |
}
|
|
346 |
|
|
347 |
// ---------------------------------------------------------
|
|
348 |
// CConnectionMonitorUiView::BringupDetailsViewL
|
|
349 |
// ---------------------------------------------------------
|
|
350 |
//
|
|
351 |
void CConnectionMonitorUiView::BringupDetailsViewL()
|
|
352 |
{
|
|
353 |
CConnectionMonitorUiDetailsView* view =
|
|
354 |
STATIC_CAST( CConnectionMonitorUiDetailsView*,
|
|
355 |
AppUi()->View( TUid::Uid(
|
|
356 |
EConnectionMonitorUiDetailsViewTab ) ) );
|
|
357 |
|
|
358 |
TInt selIndex = iContainer->SelectedConnection();
|
|
359 |
view->SetSelectedConnection( selIndex );
|
|
360 |
AppUi()->ActivateLocalViewL(
|
|
361 |
TUid::Uid( EConnectionMonitorUiDetailsViewTab ) );
|
|
362 |
}
|
|
363 |
|
|
364 |
// ---------------------------------------------------------
|
|
365 |
// CConnectionMonitorUiView::IsSelectedConnectionAlive
|
|
366 |
// ---------------------------------------------------------
|
|
367 |
//
|
|
368 |
TBool CConnectionMonitorUiView::IsSelectedConnectionAlive() const
|
|
369 |
{
|
|
370 |
TInt selIndex = iContainer->SelectedConnection();
|
|
371 |
TBool result( EFalse );
|
|
372 |
if ( selIndex > -1 )
|
|
373 |
{
|
|
374 |
result = ( *iConnectionArray )[selIndex]->IsAlive();
|
|
375 |
}
|
|
376 |
|
|
377 |
return result;
|
|
378 |
}
|
|
379 |
|
|
380 |
// ---------------------------------------------------------
|
|
381 |
// CConnectionMonitorUiView::IsSelectedConnectionSuspended
|
|
382 |
// ---------------------------------------------------------
|
|
383 |
//
|
|
384 |
TBool CConnectionMonitorUiView::IsSelectedConnectionSuspended() const
|
|
385 |
{
|
|
386 |
TInt selIndex = iContainer->SelectedConnection();
|
|
387 |
TBool result( EFalse );
|
|
388 |
if ( selIndex > -1 )
|
|
389 |
{
|
|
390 |
result = ( *iConnectionArray )[selIndex]->IsSuspended();
|
|
391 |
}
|
|
392 |
|
|
393 |
return result;
|
|
394 |
}
|
|
395 |
|
|
396 |
// ---------------------------------------------------------
|
|
397 |
// CConnectionMonitorUiView::ConnectionKeyObserver
|
|
398 |
// ---------------------------------------------------------
|
|
399 |
//
|
|
400 |
void CConnectionMonitorUiView::ConnectionKeyObserver() const
|
|
401 |
{
|
|
402 |
if ( !( iConnectionArray->MdcaCount() ) )
|
|
403 |
{
|
|
404 |
Cba()->MakeCommandVisible( EAknSoftkeyDetails,EFalse );
|
|
405 |
}
|
|
406 |
else
|
|
407 |
{
|
|
408 |
if ( iConnectionArray->NumberOfActiveConnections() )
|
|
409 |
{
|
|
410 |
Cba()->MakeCommandVisible( EAknSoftkeyDetails,ETrue );
|
|
411 |
}
|
|
412 |
else
|
|
413 |
{
|
|
414 |
Cba()->MakeCommandVisible( EAknSoftkeyDetails,EFalse );
|
|
415 |
}
|
|
416 |
}
|
|
417 |
}
|
|
418 |
|
|
419 |
|
|
420 |
|
|
421 |
|
|
422 |
// End of File
|