51
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 |
#include <memspy/engine/memspyenginehelperram.h>
|
|
19 |
|
|
20 |
// System includes
|
|
21 |
#include <hal.h>
|
|
22 |
#include <e32debug.h>
|
|
23 |
|
|
24 |
// User includes
|
|
25 |
#include <memspy/engine/memspyengine.h>
|
|
26 |
#include <memspy/engine/memspyengineutils.h>
|
|
27 |
#include <memspy/engine/memspyengineoutputlist.h>
|
|
28 |
#include "MemSpyEngineOutputListItem.h"
|
|
29 |
#include <memspy/engine/memspyengineoutputsink.h>
|
|
30 |
|
|
31 |
// Type defs
|
|
32 |
typedef TInt(*TAknIconCacheConfigFunction)(TBool);
|
|
33 |
|
|
34 |
// Constants
|
|
35 |
const TInt KAknIconCacheConfigOrdinal = 44;
|
|
36 |
|
|
37 |
// Literal constants
|
|
38 |
_LIT( KMemSpyAknIconDllName, "AKNICON.DLL" );
|
|
39 |
|
|
40 |
|
|
41 |
CMemSpyEngineHelperRAM::CMemSpyEngineHelperRAM( CMemSpyEngine& aEngine )
|
|
42 |
: iEngine( aEngine )
|
|
43 |
{
|
|
44 |
}
|
|
45 |
|
|
46 |
|
|
47 |
CMemSpyEngineHelperRAM::~CMemSpyEngineHelperRAM()
|
|
48 |
{
|
|
49 |
}
|
|
50 |
|
|
51 |
|
|
52 |
void CMemSpyEngineHelperRAM::ConstructL()
|
|
53 |
{
|
|
54 |
CheckIfAknIconCacheCanBeConfiguredL();
|
|
55 |
}
|
|
56 |
|
|
57 |
|
|
58 |
CMemSpyEngineHelperRAM* CMemSpyEngineHelperRAM::NewL( CMemSpyEngine& aEngine )
|
|
59 |
{
|
|
60 |
CMemSpyEngineHelperRAM* self = new(ELeave) CMemSpyEngineHelperRAM( aEngine );
|
|
61 |
CleanupStack::PushL( self );
|
|
62 |
self->ConstructL();
|
|
63 |
CleanupStack::Pop( self );
|
|
64 |
return self;
|
|
65 |
}
|
|
66 |
|
|
67 |
|
|
68 |
EXPORT_C TBool CMemSpyEngineHelperRAM::IsAknIconCacheConfigurable() const
|
|
69 |
{
|
|
70 |
return iIsAknIconCacheConfigurable;
|
|
71 |
}
|
|
72 |
|
|
73 |
|
|
74 |
EXPORT_C TInt64 CMemSpyEngineHelperRAM::SetAknIconCacheStatusL( TBool aEnabled )
|
|
75 |
{
|
|
76 |
TInt64 ret( 0 );
|
|
77 |
//
|
|
78 |
if ( iIsAknIconCacheConfigurable )
|
|
79 |
{
|
|
80 |
TInt freeRamBeforeOp = KErrNotFound;
|
|
81 |
User::LeaveIfError( HAL::Get( HALData::EMemoryRAMFree, freeRamBeforeOp ) );
|
|
82 |
//
|
|
83 |
const TInt error = SetAknIconStatus( aEnabled );
|
|
84 |
User::LeaveIfError( error );
|
|
85 |
//
|
|
86 |
if ( aEnabled == EFalse )
|
|
87 |
{
|
|
88 |
// Turning cache off, check how much ram we saved...
|
|
89 |
TInt freeRamAfterOp = KErrNotFound;
|
|
90 |
User::LeaveIfError( HAL::Get( HALData::EMemoryRAMFree, freeRamAfterOp ) );
|
|
91 |
|
|
92 |
// Work out how much ram was saved...
|
|
93 |
ret = ( freeRamAfterOp - freeRamBeforeOp );
|
|
94 |
}
|
|
95 |
}
|
|
96 |
//
|
|
97 |
return ret;
|
|
98 |
}
|
|
99 |
|
|
100 |
|
|
101 |
void CMemSpyEngineHelperRAM::CheckIfAknIconCacheCanBeConfiguredL()
|
|
102 |
{
|
|
103 |
#ifndef __WINS__
|
|
104 |
RLibrary lib;
|
|
105 |
const TInt loadErr = lib.Load( KMemSpyAknIconDllName );
|
|
106 |
#ifdef _DEBUG
|
|
107 |
RDebug::Printf( "CMemSpyEngineHelperRAM::SetAknIconStatus() - dll load: %d", loadErr );
|
|
108 |
#endif
|
|
109 |
if ( loadErr == KErrNone )
|
|
110 |
{
|
|
111 |
TLibraryFunction ordinal = lib.Lookup( KAknIconCacheConfigOrdinal );
|
|
112 |
#ifdef _DEBUG
|
|
113 |
RDebug::Printf( "CMemSpyEngineHelperRAM::SetAknIconStatus() - ordinal: 0x%08x", ordinal );
|
|
114 |
#endif
|
|
115 |
//
|
|
116 |
iIsAknIconCacheConfigurable = ( ordinal != NULL );
|
|
117 |
lib.Close();
|
|
118 |
}
|
|
119 |
#endif
|
|
120 |
}
|
|
121 |
|
|
122 |
|
|
123 |
TInt CMemSpyEngineHelperRAM::SetAknIconStatus( TBool aEnabled )
|
|
124 |
{
|
|
125 |
TInt ret = KErrNotSupported;
|
|
126 |
//
|
|
127 |
#ifndef __WINS__
|
|
128 |
RLibrary lib;
|
|
129 |
const TInt loadErr = lib.Load( KMemSpyAknIconDllName );
|
|
130 |
#ifdef _DEBUG
|
|
131 |
RDebug::Printf( "CMemSpyEngineHelperRAM::SetAknIconStatus() - dll load: %d", loadErr );
|
|
132 |
#endif
|
|
133 |
if ( loadErr == KErrNone )
|
|
134 |
{
|
|
135 |
TLibraryFunction ordinal = lib.Lookup( KAknIconCacheConfigOrdinal );
|
|
136 |
#ifdef _DEBUG
|
|
137 |
RDebug::Printf( "CMemSpyEngineHelperRAM::SetAknIconStatus() - ordinal: 0x%08x", ordinal );
|
|
138 |
#endif
|
|
139 |
//
|
|
140 |
if ( ordinal )
|
|
141 |
{
|
|
142 |
TAknIconCacheConfigFunction func = (TAknIconCacheConfigFunction) ordinal;
|
|
143 |
ret = (*func)( aEnabled );
|
|
144 |
#ifdef _DEBUG
|
|
145 |
RDebug::Printf( "CMemSpyEngineHelperRAM::SetAknIconStatus() - ret: %d", ret );
|
|
146 |
#endif
|
|
147 |
}
|
|
148 |
//
|
|
149 |
lib.Close();
|
|
150 |
}
|
|
151 |
#else
|
|
152 |
aEnabled = EFalse;
|
|
153 |
#endif
|
|
154 |
//
|
|
155 |
return ret;
|
|
156 |
}
|