0
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <avkon.hrh>
|
|
20 |
#include <eikmenup.h>
|
|
21 |
#include <stringloader.h>
|
|
22 |
#include "EcmtGuiDocument.h"
|
|
23 |
#include "EcmtGui.pan"
|
|
24 |
#include "EcmtGuiAppUi.h"
|
|
25 |
#include "EcmtGuiLogView.h"
|
|
26 |
#include "EcmtWlanOddSettingView.h"
|
|
27 |
|
|
28 |
|
|
29 |
#if !defined(__WINS__) || defined(_ENABLE_SETINGS_ON_WINS_)
|
|
30 |
#include "EcmtGuiSettingsView.h"
|
|
31 |
#endif
|
|
32 |
|
|
33 |
#include "EcmtGuiUid.h"
|
|
34 |
#include "EcmtGui.hrh"
|
|
35 |
#include <EcmtGui.rsg>
|
|
36 |
// ===========================================================================
|
|
37 |
void CEcmtGuiAppUi::ConstructL()
|
|
38 |
{
|
|
39 |
BaseConstructL(EAknEnableSkin);
|
|
40 |
|
|
41 |
iLogView = CEcmtGuiLogView::NewL();
|
|
42 |
AddViewL(iLogView);
|
|
43 |
|
|
44 |
iWlanOdd =CWlanOddSettingView::NewL();
|
|
45 |
AddViewL(iWlanOdd);
|
|
46 |
#if !defined(__WINS__) || defined(_ENABLE_SETINGS_ON_WINS_)
|
|
47 |
iSettingsView = CEcmtGuiSettingsView::NewL();
|
|
48 |
AddViewL(iSettingsView);
|
|
49 |
#endif
|
|
50 |
|
|
51 |
SetDefaultViewL(*iLogView);
|
|
52 |
}
|
|
53 |
|
|
54 |
// ===========================================================================
|
|
55 |
CEcmtGuiAppUi::CEcmtGuiAppUi()
|
|
56 |
// ===========================================================================
|
|
57 |
{
|
|
58 |
}
|
|
59 |
|
|
60 |
// ===========================================================================
|
|
61 |
CEcmtGuiAppUi::~CEcmtGuiAppUi()
|
|
62 |
{
|
|
63 |
if (iLogView)
|
|
64 |
iLogView = NULL;
|
|
65 |
if (iWlanOdd)
|
|
66 |
iWlanOdd = NULL;
|
|
67 |
#if !defined(__WINS__) || defined(_ENABLE_SETINGS_ON_WINS_)
|
|
68 |
if ( iSettingsView )
|
|
69 |
iSettingsView = NULL;
|
|
70 |
#endif
|
|
71 |
}
|
|
72 |
|
|
73 |
// ===========================================================================
|
|
74 |
void CEcmtGuiAppUi::HandleResourceChangeL(TInt aType)
|
|
75 |
// ===========================================================================
|
|
76 |
{
|
|
77 |
CAknAppUi::HandleResourceChangeL(aType);
|
|
78 |
if (aType == KEikDynamicLayoutVariantSwitch)
|
|
79 |
{
|
|
80 |
iLogView->HandleSizeChange( aType );
|
|
81 |
#if !defined(__WINS__) || defined(_ENABLE_SETINGS_ON_WINS_)
|
|
82 |
iSettingsView->HandleSizeChange( aType );
|
|
83 |
#endif
|
|
84 |
}
|
|
85 |
}
|
|
86 |
|
|
87 |
// ===========================================================================
|
|
88 |
void CEcmtGuiAppUi::ConnectEcmtL()
|
|
89 |
// ===========================================================================
|
|
90 |
{
|
|
91 |
TInt retval = iEcmt.Connect();
|
|
92 |
if ( retval == KErrNone )
|
|
93 |
{
|
|
94 |
iLogView->SetConnected( ETrue );
|
|
95 |
iLogView->LogMessageL( R_SERVER_RUNNING );
|
|
96 |
iEcmt.SetServerObserverL( KUidEcmtGuiApp, this );
|
|
97 |
|
|
98 |
}
|
|
99 |
else
|
|
100 |
{
|
|
101 |
TBuf<KMaxLogMsgLen> status;
|
|
102 |
StringLoader::Load( status, R_SERVER_START_ERROR );
|
|
103 |
status.AppendNum( retval );
|
|
104 |
iLogView->LogMessageL( status );
|
|
105 |
}
|
|
106 |
}
|
|
107 |
|
|
108 |
// ===========================================================================
|
|
109 |
void CEcmtGuiAppUi::DisconnectEcmt()
|
|
110 |
// ===========================================================================
|
|
111 |
{
|
|
112 |
iEcmt.Close();
|
|
113 |
iLogView->SetConnected( EFalse );
|
|
114 |
iLogView->LogMessageL( R_SERVER_STOPPED );
|
|
115 |
}
|
|
116 |
|
|
117 |
// ===========================================================================
|
|
118 |
void CEcmtGuiAppUi::HandleCommandL(TInt aCommand)
|
|
119 |
// ===========================================================================
|
|
120 |
{
|
|
121 |
switch(aCommand)
|
|
122 |
{
|
|
123 |
case EEikCmdExit:
|
|
124 |
case EAknSoftkeyExit:
|
|
125 |
if ( iLogView->IsConnected() )
|
|
126 |
{
|
|
127 |
iEcmt.Close();
|
|
128 |
}
|
|
129 |
Exit();
|
|
130 |
break;
|
|
131 |
|
|
132 |
case EEcmtGuiCmdStart:
|
|
133 |
case EEcmtGuiCmdStop:
|
|
134 |
if ( !iLogView->IsConnected() )
|
|
135 |
{
|
|
136 |
ConnectEcmtL();
|
|
137 |
}
|
|
138 |
else
|
|
139 |
{
|
|
140 |
DisconnectEcmt();
|
|
141 |
}
|
|
142 |
break;
|
|
143 |
|
|
144 |
case EEcmtGuiCmdWlanOdd:
|
|
145 |
{
|
|
146 |
TVwsViewId aViewID = iWlanOdd->ViewId();
|
|
147 |
ActivateViewL(aViewID);
|
|
148 |
}
|
|
149 |
break;
|
|
150 |
|
|
151 |
case EEcmtGuiCmdClearLog:
|
|
152 |
iLogView->ClearLogL();
|
|
153 |
break;
|
|
154 |
|
|
155 |
default:
|
|
156 |
Panic(EEcmtGuiUi);
|
|
157 |
break;
|
|
158 |
}
|
|
159 |
}
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
// ===========================================================================
|
|
164 |
void CEcmtGuiAppUi::HandleEcmtServerNotification(const TDesC& aMsg,TInt aError)
|
|
165 |
{
|
|
166 |
// Turn on the lights when something happens
|
|
167 |
User::ResetInactivityTime();
|
|
168 |
|
|
169 |
// Message logging to screen should never leave unless we're totally out
|
|
170 |
// of memory, and in that case any attempt to show error notes will fail
|
|
171 |
// too so might as well trap and ignore the leave.
|
|
172 |
|
|
173 |
if (aError != KErrNone)
|
|
174 |
{
|
|
175 |
TBuf<KMaxLogMsgLen> status;
|
|
176 |
StringLoader::Load(status, R_ERROR_GETTING_NOTIFICATION);
|
|
177 |
status.AppendNum(aError);
|
|
178 |
TRAP_IGNORE( iLogView->LogMessageL(status) );
|
|
179 |
}
|
|
180 |
else
|
|
181 |
{
|
|
182 |
TRAP_IGNORE( iLogView->LogMessageL( aMsg ) );
|
|
183 |
}
|
|
184 |
}
|
|
185 |
|
|
186 |
|
|
187 |
|