|
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 "MemSpyViewRAMInfo.h" |
|
19 |
|
20 // System includes |
|
21 #include <hal.h> |
|
22 #include <aknnotedialog.h> |
|
23 |
|
24 // Engine includes |
|
25 #include <memspy/engine/memspyengine.h> |
|
26 #include <memspy/engine/memspyengineobjectprocess.h> |
|
27 #include <memspy/engine/memspyengineobjectthread.h> |
|
28 #include <memspy/engine/memspyengineobjectcontainer.h> |
|
29 #include <memspy/engine/memspyengineobjectthreadinfoobjects.h> |
|
30 #include <memspy/engine/memspyengineobjectthreadinfocontainer.h> |
|
31 #include <memspy/engine/memspyenginehelperprocess.h> |
|
32 #include <memspy/engine/memspyenginehelperram.h> |
|
33 #include <memspy/engine/memspyengineutils.h> |
|
34 |
|
35 // User includes |
|
36 #include "MemSpyUiUtils.h" |
|
37 #include "MemSpyViewMainMenu.h" |
|
38 #include "MemSpyContainerObserver.h" |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 CMemSpyViewRAMInfo::CMemSpyViewRAMInfo( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver ) |
|
46 : CMemSpyViewBase( aEngine, aObserver ) |
|
47 { |
|
48 } |
|
49 |
|
50 |
|
51 void CMemSpyViewRAMInfo::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
|
52 { |
|
53 _LIT( KTitle, "RAM Info" ); |
|
54 SetTitleL( KTitle ); |
|
55 // |
|
56 CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune ); |
|
57 } |
|
58 |
|
59 |
|
60 void CMemSpyViewRAMInfo::RefreshL() |
|
61 { |
|
62 SetListBoxModelL(); |
|
63 CMemSpyViewBase::RefreshL(); |
|
64 } |
|
65 |
|
66 |
|
67 TMemSpyViewType CMemSpyViewRAMInfo::ViewType() const |
|
68 { |
|
69 return EMemSpyViewTypeRAMInfo; |
|
70 } |
|
71 |
|
72 |
|
73 CMemSpyViewBase* CMemSpyViewRAMInfo::PrepareParentViewL() |
|
74 { |
|
75 CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver ); |
|
76 CleanupStack::PushL( parent ); |
|
77 parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() ); |
|
78 CleanupStack::Pop( parent ); |
|
79 return parent; |
|
80 } |
|
81 |
|
82 |
|
83 CMemSpyViewBase* CMemSpyViewRAMInfo::PrepareChildViewL() |
|
84 { |
|
85 CMemSpyViewBase* child = NULL; |
|
86 return child; |
|
87 } |
|
88 |
|
89 |
|
90 void CMemSpyViewRAMInfo::SetListBoxModelL() |
|
91 { |
|
92 CDesCArrayFlat* model = new(ELeave) CDesCArrayFlat(5); |
|
93 CleanupStack::PushL( model ); |
|
94 |
|
95 TBuf<KMaxFullName + 1> item; |
|
96 |
|
97 TInt value; |
|
98 TMemSpySizeText size; |
|
99 TMemoryInfoV1Buf memInfoBuf; |
|
100 UserHal::MemoryInfo( memInfoBuf ); |
|
101 const TMemoryInfoV1 memInfo( memInfoBuf() ); |
|
102 |
|
103 // 1st item = Total RAM |
|
104 _LIT(KItem1Format, "\tTotal RAM\t\t%S"); |
|
105 size = MemSpyUiUtils::FormatSizeText( memInfo.iTotalRamInBytes ); |
|
106 item.Format( KItem1Format, &size ); |
|
107 model->AppendL( item ); |
|
108 |
|
109 // 2nd item = Max free RAM |
|
110 _LIT(KItem2Format, "\tMax Free RAM\t\t%S"); |
|
111 size = MemSpyUiUtils::FormatSizeText( memInfo.iMaxFreeRamInBytes ); |
|
112 item.Format( KItem2Format, &size ); |
|
113 model->AppendL( item ); |
|
114 |
|
115 // 3rd item = Free RAM |
|
116 _LIT(KItem3Format, "\tFree RAM\t\t%S (%S)"); |
|
117 const TMemSpyPercentText freeRamPercentage( MemSpyEngineUtils::FormatPercentage( TReal( memInfo.iTotalRamInBytes ), TReal( memInfo.iFreeRamInBytes ) ) ); |
|
118 size = MemSpyUiUtils::FormatSizeText( memInfo.iFreeRamInBytes ); |
|
119 item.Format( KItem3Format, &size, &freeRamPercentage ); |
|
120 model->AppendL( item ); |
|
121 |
|
122 // 4th item = RAM disk info |
|
123 _LIT(KItem4Format, "\tRAM Disk Size\t\t%S"); |
|
124 size = MemSpyUiUtils::FormatSizeText( memInfo.iInternalDiskRamInBytes ); |
|
125 item.Format( KItem4Format, &size ); |
|
126 model->AppendL( item ); |
|
127 |
|
128 // 5th item = Max RAM disk size |
|
129 _LIT(KItem5Format, "\tMax RAM Disk Size\t\t%S"); |
|
130 HAL::Get( HALData::EMaxRAMDriveSize, value ); |
|
131 size = MemSpyUiUtils::FormatSizeText( value ); |
|
132 item.Format( KItem5Format, &size ); |
|
133 model->AppendL( item ); |
|
134 |
|
135 // 6th item = RAM page size |
|
136 _LIT(KItem6Format, "\tMemory Page Size\t\t%S"); |
|
137 HAL::Get( HALData::EMemoryPageSize, value ); |
|
138 size = MemSpyUiUtils::FormatSizeText( value ); |
|
139 item.Format( KItem6Format, &size ); |
|
140 model->AppendL( item ); |
|
141 |
|
142 // Set up list box |
|
143 CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); |
|
144 listbox->Model()->SetItemTextArray( model ); |
|
145 listbox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
146 CleanupStack::Pop( model ); |
|
147 } |
|
148 |
|
149 |
|
150 TBool CMemSpyViewRAMInfo::HandleCommandL( TInt aCommand ) |
|
151 { |
|
152 TBool handled = ETrue; |
|
153 // |
|
154 if ( iEngine.HelperRAM().IsAknIconCacheConfigurable() ) |
|
155 { |
|
156 switch ( aCommand ) |
|
157 { |
|
158 case EMemSpyCmdRAMAvkonIconCacheDisabled: |
|
159 OnCmdSetIconCacheStatusL( EFalse ); |
|
160 break; |
|
161 case EMemSpyCmdRAMAvkonIconCacheEnabled: |
|
162 OnCmdSetIconCacheStatusL( ETrue ); |
|
163 break; |
|
164 |
|
165 default: |
|
166 handled = CMemSpyViewBase::HandleCommandL( aCommand ); |
|
167 break; |
|
168 } |
|
169 } |
|
170 else |
|
171 { |
|
172 handled = CMemSpyViewBase::HandleCommandL( aCommand ); |
|
173 } |
|
174 // |
|
175 return handled; |
|
176 } |
|
177 |
|
178 |
|
179 void CMemSpyViewRAMInfo::OnCmdSetIconCacheStatusL( TBool aEnabled ) |
|
180 { |
|
181 ASSERT( iEngine.HelperRAM().IsAknIconCacheConfigurable() ); |
|
182 // |
|
183 const TInt64 savedAmount = iEngine.HelperRAM().SetAknIconCacheStatusL( aEnabled ); |
|
184 if ( !aEnabled ) |
|
185 { |
|
186 TBuf<128> buf; |
|
187 // |
|
188 if ( savedAmount != 0 ) |
|
189 { |
|
190 _LIT(KSavedAmountFormatBuffer, "Saved %S of RAM"); |
|
191 const TMemSpySizeText savedAmountString( MemSpyEngineUtils::FormatSizeText( savedAmount, 0, EFalse ) ); |
|
192 buf.Format( KSavedAmountFormatBuffer, &savedAmountString ); |
|
193 } |
|
194 else |
|
195 { |
|
196 _LIT(KDidNotSaveAnyRAM, "Operation did not save any RAM"); |
|
197 buf.Copy( KDidNotSaveAnyRAM ); |
|
198 } |
|
199 |
|
200 // Show dialog |
|
201 CAknNoteDialog* note = new( ELeave ) CAknNoteDialog( CAknNoteDialog::ENoTone ); |
|
202 CleanupStack::PushL( note ); |
|
203 note->SetTextWrapping( ETrue ); |
|
204 note->PrepareLC( R_MEMSPY_RAM_MEMORY_DELTA_DIALOG ); |
|
205 note->SetTextL( buf ); |
|
206 CleanupStack::Pop( note ); |
|
207 note->RunLD(); |
|
208 } |
|
209 // |
|
210 RefreshL(); |
|
211 } |