64
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: alfperfappdeamon implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <eikstart.h>
|
|
21 |
#include <apgwgnam.h>
|
|
22 |
#include "alfperfappdaemon.h"
|
|
23 |
|
|
24 |
#include "../../alfdebugextension/inc/alfdebug.h"
|
|
25 |
|
|
26 |
/**
|
|
27 |
* Reset inactity period in microseconds.
|
|
28 |
*/
|
|
29 |
const TInt KAlfPerfAppActivityPollPeriod = 2500000;
|
|
30 |
|
|
31 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
32 |
|
|
33 |
//
|
|
34 |
// Implementation of CAlfPerfAppDaemonApplication
|
|
35 |
//
|
|
36 |
|
|
37 |
CApaDocument* CAlfPerfAppDaemonApplication::CreateDocumentL()
|
|
38 |
{
|
|
39 |
return new (ELeave) CAlfPerfAppDaemonDocument( *this );
|
|
40 |
}
|
|
41 |
|
|
42 |
TUid CAlfPerfAppDaemonApplication::AppDllUid() const
|
|
43 |
{
|
|
44 |
return KAlfPerfAppDaemonUid;
|
|
45 |
}
|
|
46 |
|
|
47 |
void CAlfPerfAppDaemonApplication::NewAppServerL( CApaAppServer*& aAppServer )
|
|
48 |
{
|
|
49 |
aAppServer = NULL;
|
|
50 |
aAppServer = new (ELeave) CAlfPerfAppDaemonServer;
|
|
51 |
}
|
|
52 |
|
|
53 |
//
|
|
54 |
// Implementation of CAlfPerfAppDaemonDocument
|
|
55 |
//
|
|
56 |
|
|
57 |
CAlfPerfAppDaemonDocument::CAlfPerfAppDaemonDocument( CEikApplication& aApp )
|
|
58 |
: CAknDocument( aApp )
|
|
59 |
{
|
|
60 |
}
|
|
61 |
|
|
62 |
CEikAppUi* CAlfPerfAppDaemonDocument::CreateAppUiL()
|
|
63 |
{
|
|
64 |
return new (ELeave) CAlfPerfAppDaemonAppUi;
|
|
65 |
}
|
|
66 |
|
|
67 |
void CAlfPerfAppDaemonDocument::UpdateTaskNameL(CApaWindowGroupName* aWgName)
|
|
68 |
{
|
|
69 |
CAknDocument::UpdateTaskNameL( aWgName );
|
|
70 |
aWgName->SetHidden( ETrue );
|
|
71 |
}
|
|
72 |
|
|
73 |
//
|
|
74 |
// Implementation of CAlfPerfAppDaemonAppUi
|
|
75 |
//
|
|
76 |
|
|
77 |
CAlfPerfAppDaemonAppUi::CAlfPerfAppDaemonAppUi()
|
|
78 |
{
|
|
79 |
}
|
|
80 |
|
|
81 |
CAlfPerfAppDaemonAppUi::~CAlfPerfAppDaemonAppUi()
|
|
82 |
{
|
|
83 |
delete iDebug;
|
|
84 |
delete iFactory;
|
|
85 |
iLibrary.Close();
|
|
86 |
}
|
|
87 |
|
|
88 |
CAlfDebugExtension* CAlfPerfAppDaemonAppUi::Debug()
|
|
89 |
{
|
|
90 |
return iDebug;
|
|
91 |
}
|
|
92 |
|
|
93 |
void CAlfPerfAppDaemonAppUi::ConstructL()
|
|
94 |
{
|
|
95 |
CAknAppUi::BaseConstructL( EAknEnableSkin | EAknEnableMSK );
|
|
96 |
|
|
97 |
RWsSession& wsSession = iEikonEnv->WsSession();
|
|
98 |
wsSession.ComputeMode( RWsSession::EPriorityControlDisabled );
|
|
99 |
RProcess().SetPriority( EPriorityHigh );
|
|
100 |
iEikonEnv->SetSystem( ETrue );
|
|
101 |
|
|
102 |
if ( iLibrary.Load( KAlfDebugExtensionLibraryName ) == KErrNone )
|
|
103 |
{
|
|
104 |
TInt res = iLibrary.Lookup( KAlfDebugExtensionLibraryEntryOrdinal )();
|
|
105 |
iFactory = (CAlfDebugFactory*)res;
|
|
106 |
if ( iFactory )
|
|
107 |
{
|
|
108 |
iDebug = iFactory->CreateDebugExtensionL( NULL );
|
|
109 |
}
|
|
110 |
}
|
|
111 |
}
|
|
112 |
|
|
113 |
// -----------------------------------------------------------------------------
|
|
114 |
// Common commands are handled here.
|
|
115 |
// -----------------------------------------------------------------------------
|
|
116 |
//
|
|
117 |
void CAlfPerfAppDaemonAppUi::HandleCommandL( TInt aCommand )
|
|
118 |
{
|
|
119 |
switch ( aCommand )
|
|
120 |
{
|
|
121 |
case EEikCmdExit:
|
|
122 |
Exit();
|
|
123 |
break;
|
|
124 |
|
|
125 |
default:
|
|
126 |
break;
|
|
127 |
}
|
|
128 |
}
|
|
129 |
|
|
130 |
//
|
|
131 |
// Implementation of CAlfPerfAppDaemonServer
|
|
132 |
//
|
|
133 |
|
|
134 |
CAlfPerfAppDaemonServer::CAlfPerfAppDaemonServer()
|
|
135 |
{
|
|
136 |
}
|
|
137 |
|
|
138 |
CApaAppServiceBase* CAlfPerfAppDaemonServer::CreateServiceL( TUid aServiceType ) const
|
|
139 |
{
|
|
140 |
if ( aServiceType == KAlfPerfAppDaemonUid )
|
|
141 |
{
|
|
142 |
return new (ELeave) CAlfPerfAppDaemonService;
|
|
143 |
}
|
|
144 |
else
|
|
145 |
{
|
|
146 |
User::Leave( KErrNotSupported );
|
|
147 |
return NULL;
|
|
148 |
}
|
|
149 |
}
|
|
150 |
|
|
151 |
//
|
|
152 |
// Implementation of CAlfPerfAppDaemonService
|
|
153 |
//
|
|
154 |
|
|
155 |
CAlfPerfAppDaemonService::CAlfPerfAppDaemonService()
|
|
156 |
{
|
|
157 |
}
|
|
158 |
|
|
159 |
CAlfPerfAppDaemonService::~CAlfPerfAppDaemonService()
|
|
160 |
{
|
|
161 |
if ( iActivityPoll )
|
|
162 |
{
|
|
163 |
iActivityPoll->Cancel();
|
|
164 |
delete iActivityPoll;
|
|
165 |
}
|
|
166 |
}
|
|
167 |
|
|
168 |
void CAlfPerfAppDaemonService::ServiceL( const RMessage2& aMessage )
|
|
169 |
{
|
|
170 |
switch ( aMessage.Function() )
|
|
171 |
{
|
|
172 |
case EAlfPerfAppIpcGetMeasurements:
|
|
173 |
{
|
|
174 |
CAlfPerfAppDaemonAppUi* appui =
|
|
175 |
static_cast<CAlfPerfAppDaemonAppUi*>(
|
|
176 |
CEikonEnv::Static()->EikAppUi() );
|
|
177 |
CAlfDebugExtension* debug = appui->Debug();
|
|
178 |
if ( debug )
|
|
179 |
{
|
|
180 |
TAlfDebugServerMeasurements measurements;
|
|
181 |
TInt err = debug->GetMeasurements( measurements );
|
|
182 |
if ( err == KErrNone )
|
|
183 |
{
|
|
184 |
TPckgC<TAlfDebugServerMeasurements> pckg( measurements );
|
|
185 |
err = aMessage.Write( 0, pckg );
|
|
186 |
}
|
|
187 |
aMessage.Complete( err );
|
|
188 |
}
|
|
189 |
else
|
|
190 |
{
|
|
191 |
aMessage.Complete( KErrNotSupported );
|
|
192 |
}
|
|
193 |
}
|
|
194 |
break;
|
|
195 |
|
|
196 |
case EAlfPerfAppIpcEnableActivityPoll:
|
|
197 |
{
|
|
198 |
const TBool enable = ( aMessage.Int0() != 0 );
|
|
199 |
if ( enable )
|
|
200 |
{
|
|
201 |
User::ResetInactivityTime();
|
|
202 |
if ( !iActivityPoll )
|
|
203 |
{
|
|
204 |
iActivityPoll = CPeriodic::NewL( CActive::EPriorityHigh );
|
|
205 |
}
|
|
206 |
iActivityPoll->Cancel();
|
|
207 |
iActivityPoll->Start(
|
|
208 |
KAlfPerfAppActivityPollPeriod,
|
|
209 |
KAlfPerfAppActivityPollPeriod,
|
|
210 |
TCallBack( ActivityPollCallBack, this ) );
|
|
211 |
}
|
|
212 |
else
|
|
213 |
{
|
|
214 |
if ( iActivityPoll )
|
|
215 |
{
|
|
216 |
iActivityPoll->Cancel();
|
|
217 |
}
|
|
218 |
delete iActivityPoll;
|
|
219 |
iActivityPoll = NULL;
|
|
220 |
}
|
|
221 |
|
|
222 |
aMessage.Complete( KErrNone );
|
|
223 |
}
|
|
224 |
break;
|
|
225 |
|
|
226 |
default:
|
|
227 |
CAknAppServiceBase::ServiceL( aMessage );
|
|
228 |
break;
|
|
229 |
}
|
|
230 |
}
|
|
231 |
|
|
232 |
TInt CAlfPerfAppDaemonService::ActivityPollCallBack( TAny* /*aAny*/ )
|
|
233 |
{
|
|
234 |
User::ResetInactivityTime();
|
|
235 |
return KErrNone;
|
|
236 |
}
|
|
237 |
|
|
238 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
239 |
|
|
240 |
LOCAL_C CApaApplication* NewApplication()
|
|
241 |
{
|
|
242 |
return new CAlfPerfAppDaemonApplication;
|
|
243 |
}
|
|
244 |
|
|
245 |
GLDEF_C TInt E32Main()
|
|
246 |
{
|
|
247 |
return EikStart::RunApplication( NewApplication );
|
|
248 |
}
|
|
249 |
|