|
1 /* |
|
2 * Copyright (c) 2010 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 <e32def.h> |
|
19 #include <e32cmn.h> |
|
20 |
|
21 #include "enginewrapper.h" |
|
22 |
|
23 |
|
24 // --------------------------------------------------------------------------- |
|
25 |
|
26 EngineWrapper::EngineWrapper() : mSettings(iSettings) |
|
27 { |
|
28 } |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 |
|
32 EngineWrapper::~EngineWrapper() |
|
33 { |
|
34 finalize(); |
|
35 } |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 |
|
39 bool EngineWrapper::initialize() |
|
40 { |
|
41 TInt err = KErrNone; |
|
42 |
|
43 TRAP(err, ConstructL()); |
|
44 if (err != KErrNone) |
|
45 return false; |
|
46 |
|
47 TRAP(err, ActivateEngineL()); |
|
48 if (err != KErrNone) |
|
49 return false; |
|
50 |
|
51 createSampleEntriesArray(); |
|
52 |
|
53 return true; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 |
|
58 int EngineWrapper::SampleEntryPosToSettingPos(int entryPos) const |
|
59 { |
|
60 int settingPos(0); // return position of aSampleEntryPos in settings |
|
61 |
|
62 if (entryPos >= iCPU0PositionInSamples && entryPos < iRAMPositionInSamples) |
|
63 { |
|
64 settingPos = ESourceCPU; |
|
65 } |
|
66 else if (entryPos == iRAMPositionInSamples) |
|
67 { |
|
68 settingPos = ESourceRAM; |
|
69 } |
|
70 else |
|
71 { |
|
72 settingPos = ESourceC + (entryPos - iCDrivePositionInSamples); |
|
73 } |
|
74 |
|
75 return settingPos; |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 |
|
80 void EngineWrapper::createSampleEntriesArray() |
|
81 { |
|
82 for (TInt i=0; i < iSampleEntryArray->Count(); i++) |
|
83 { |
|
84 mEntries.append(iSampleEntryArray->At(i)); |
|
85 } |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 |
|
90 void EngineWrapper::finalize() |
|
91 { |
|
92 TRAP_IGNORE(DeActivateEngineL()); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 |
|
97 bool EngineWrapper::updateSettings() |
|
98 { |
|
99 TInt err = KErrNone; |
|
100 |
|
101 TRAP(err, SaveSettingsL()); |
|
102 if (err != KErrNone) |
|
103 return false; |
|
104 |
|
105 TRAP(err, HandleSettingsChangeL()); |
|
106 if (err != KErrNone) |
|
107 return false; |
|
108 |
|
109 emit settingsUpdated(); |
|
110 return true; |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 |
|
115 void EngineWrapper::setLoggingEnabled(bool enabled) |
|
116 { |
|
117 EnableLogging(enabled); |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 |
|
122 void EngineWrapper::SendDrawEventToContainersL() |
|
123 { |
|
124 emit samplesUpdated(); |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |