0
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 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 for LogContainer.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <EcmtGui.rsg>
|
|
20 |
|
|
21 |
#include "EcmtGuiLogView.h"
|
|
22 |
#include "EcmtGuiLogContainer.h"
|
|
23 |
#include "EcmtGui.hrh"
|
|
24 |
#include "EcmtGuiAppUi.h"
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
// ======== MEMBER FUNCTIONS ========
|
|
29 |
|
|
30 |
|
|
31 |
// ---------------------------------------------------------------------------
|
|
32 |
// Two-phased constructor.
|
|
33 |
// ---------------------------------------------------------------------------
|
|
34 |
//
|
|
35 |
CEcmtGuiLogView* CEcmtGuiLogView::NewL()
|
|
36 |
{
|
|
37 |
CEcmtGuiLogView* self = new (ELeave) CEcmtGuiLogView;
|
|
38 |
CleanupStack::PushL(self);
|
|
39 |
self->ConstructL();
|
|
40 |
CleanupStack::Pop(self);
|
|
41 |
return self;
|
|
42 |
}
|
|
43 |
|
|
44 |
// ---------------------------------------------------------------------------
|
|
45 |
// C++ default constructor
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
CEcmtGuiLogView::CEcmtGuiLogView()
|
|
49 |
{
|
|
50 |
}
|
|
51 |
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
// Destructor
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
CEcmtGuiLogView::~CEcmtGuiLogView()
|
|
57 |
{
|
|
58 |
if ( iContainer )
|
|
59 |
{
|
|
60 |
AppUi()->RemoveFromStack( iContainer );
|
|
61 |
delete iContainer;
|
|
62 |
}
|
|
63 |
if( iMessageList )
|
|
64 |
{
|
|
65 |
iMessageList->Reset();
|
|
66 |
delete iMessageList;
|
|
67 |
}
|
|
68 |
}
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
// From class CAknView.
|
|
71 |
// From CAknView.
|
|
72 |
// ---------------------------------------------------------------------------
|
|
73 |
//
|
|
74 |
TUid CEcmtGuiLogView::Id() const
|
|
75 |
{
|
|
76 |
return TUid::Uid(EEcmtLogViewId);
|
|
77 |
}
|
|
78 |
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
// From class CAknView.
|
|
81 |
// Handles commands.
|
|
82 |
// ---------------------------------------------------------------------------
|
|
83 |
//
|
|
84 |
void CEcmtGuiLogView::HandleCommandL( TInt aCommand )
|
|
85 |
{
|
|
86 |
switch( aCommand )
|
|
87 |
{
|
|
88 |
case EEcmtGuiCmdSettings:
|
|
89 |
AppUi()->ActivateLocalViewL( TUid::Uid( EEcmtSettingsViewId ) );
|
|
90 |
break;
|
|
91 |
|
|
92 |
default:
|
|
93 |
AppUi()->HandleCommandL( aCommand );
|
|
94 |
break;
|
|
95 |
}
|
|
96 |
}
|
|
97 |
|
|
98 |
// ---------------------------------------------------------------------------
|
|
99 |
// Symbian 2nd phase constructor can leave.
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
//
|
|
102 |
void CEcmtGuiLogView::ConstructL()
|
|
103 |
{
|
|
104 |
BaseConstructL(R_ECMTGUI_LOG_VIEW);
|
|
105 |
iMessageList = new (ELeave) CDesCArrayFlat(10);
|
|
106 |
}
|
|
107 |
|
|
108 |
// ---------------------------------------------------------------------------
|
|
109 |
// From class CAknView.
|
|
110 |
// Activates view.
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
//
|
|
113 |
void CEcmtGuiLogView::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
|
|
114 |
TUid /*aCustomMessageId*/,
|
|
115 |
const TDesC8& /*aCustomMessage*/ )
|
|
116 |
{
|
|
117 |
iContainer = new (ELeave) CEcmtGuiLogContainer( *iMessageList );
|
|
118 |
iContainer->SetMopParent( this );
|
|
119 |
|
|
120 |
iContainer->ConstructL(ClientRect());
|
|
121 |
|
|
122 |
AppUi()->AddToStackL( *this, iContainer );
|
|
123 |
iContainer->MakeVisible( ETrue );
|
|
124 |
//Start EcmtServer
|
|
125 |
if( !iConnected )
|
|
126 |
AppUi()->HandleCommandL( EEcmtGuiCmdStart );
|
|
127 |
}
|
|
128 |
|
|
129 |
// ---------------------------------------------------------------------------
|
|
130 |
// From class CAknView.
|
|
131 |
// Deactivates view
|
|
132 |
// ---------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
void CEcmtGuiLogView::DoDeactivate()
|
|
135 |
{
|
|
136 |
if ( iContainer )
|
|
137 |
{
|
|
138 |
AppUi()->RemoveFromViewStack( *this, iContainer );
|
|
139 |
delete iContainer;
|
|
140 |
iContainer = NULL;
|
|
141 |
}
|
|
142 |
}
|
|
143 |
|
|
144 |
// ---------------------------------------------------------------------------
|
|
145 |
// From class MEikAutoMenuObserver.
|
|
146 |
// Dynamically initialises a menu pane.
|
|
147 |
// ---------------------------------------------------------------------------
|
|
148 |
//
|
|
149 |
void CEcmtGuiLogView::DynInitMenuPaneL( TInt aResourceId,
|
|
150 |
CEikMenuPane *aMenuPane )
|
|
151 |
{
|
|
152 |
if ( aResourceId == R_ECMTGUI_LOG_MENU )
|
|
153 |
{
|
|
154 |
aMenuPane->SetItemDimmed( EEcmtGuiCmdStart, iConnected );
|
|
155 |
aMenuPane->SetItemDimmed( EEcmtGuiCmdStop, !iConnected );
|
|
156 |
aMenuPane->SetItemDimmed( EEcmtGuiCmdClearLog,
|
|
157 |
iMessageList->Count() < 2 );
|
|
158 |
|
|
159 |
#ifndef _ENABLE_SETINGS_ON_WINS_
|
|
160 |
#ifdef __WINS__
|
|
161 |
aMenuPane->SetItemDimmed( EEcmtGuiCmdSettings, ETrue );
|
|
162 |
#endif //__WINS__
|
|
163 |
#else //_ENABLE_SETINGS_ON_WINS_ is now defined
|
|
164 |
aMenuPane->SetItemDimmed( EEcmtGuiCmdSettings, EFalse );
|
|
165 |
#endif //_ENABLE_SETINGS_ON_WINS_
|
|
166 |
|
|
167 |
}
|
|
168 |
}
|
|
169 |
|
|
170 |
// ---------------------------------------------------------------------------
|
|
171 |
// Adds log message to the listbox.
|
|
172 |
// ---------------------------------------------------------------------------
|
|
173 |
//
|
|
174 |
void CEcmtGuiLogView::LogMessageL( TInt aMsgResId )
|
|
175 |
{
|
|
176 |
if( iContainer )
|
|
177 |
iContainer->LogMessageL( aMsgResId );
|
|
178 |
}
|
|
179 |
|
|
180 |
// ---------------------------------------------------------------------------
|
|
181 |
// Adds log message to the listbox.
|
|
182 |
// ---------------------------------------------------------------------------
|
|
183 |
//
|
|
184 |
void CEcmtGuiLogView::LogMessageL( const TDesC& aMsg )
|
|
185 |
{
|
|
186 |
if( iContainer )
|
|
187 |
iContainer->LogMessageL( aMsg );
|
|
188 |
}
|
|
189 |
|
|
190 |
// ---------------------------------------------------------------------------
|
|
191 |
// Clears the log.
|
|
192 |
// ---------------------------------------------------------------------------
|
|
193 |
//
|
|
194 |
void CEcmtGuiLogView::ClearLogL()
|
|
195 |
{
|
|
196 |
iMessageList->Reset();
|
|
197 |
//Update Listbox
|
|
198 |
if( iContainer )
|
|
199 |
iContainer->ClearMessageListL();
|
|
200 |
}
|
|
201 |
|
|
202 |
// ---------------------------------------------------------------------------
|
|
203 |
// Setter for iConnected.
|
|
204 |
// ---------------------------------------------------------------------------
|
|
205 |
//
|
|
206 |
void CEcmtGuiLogView::SetConnected( TBool aConnected )
|
|
207 |
{
|
|
208 |
iConnected = aConnected;
|
|
209 |
}
|
|
210 |
|
|
211 |
// ---------------------------------------------------------------------------
|
|
212 |
// Getter for Ecmt Server connectivity state.
|
|
213 |
// ---------------------------------------------------------------------------
|
|
214 |
//
|
|
215 |
TBool CEcmtGuiLogView::IsConnected()
|
|
216 |
{
|
|
217 |
return iConnected;
|
|
218 |
}
|
|
219 |
|
|
220 |
// ---------------------------------------------------------------------------
|
|
221 |
// Called by HandleResourceChangeL() from CEcmtGuiAppUi when layout
|
|
222 |
// is changed.
|
|
223 |
// ---------------------------------------------------------------------------
|
|
224 |
//
|
|
225 |
void CEcmtGuiLogView::HandleSizeChange( TInt aType )
|
|
226 |
{
|
|
227 |
if( iContainer )
|
|
228 |
{
|
|
229 |
iContainer->HandleResourceChange( aType );
|
|
230 |
|
|
231 |
if ( aType==KEikDynamicLayoutVariantSwitch )
|
|
232 |
{
|
|
233 |
TRect rect;
|
|
234 |
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
|
|
235 |
iContainer->SetRect(rect);
|
|
236 |
}
|
|
237 |
}
|
|
238 |
}
|
|
239 |
|