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: Configuration representation classes for Graphics Out of Memory Monitor
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <e32hashtab.h>
|
|
20 |
|
|
21 |
#include "goomconfig.h"
|
|
22 |
#include "goomconstants.hrh"
|
|
23 |
#include "goomapplicationconfig.h"
|
|
24 |
#include "goomrunpluginconfig.h"
|
|
25 |
#include "goomcloseappconfig.h"
|
|
26 |
#include "goomtraces.h"
|
|
27 |
|
|
28 |
CGOomConfig* CGOomConfig::NewL()
|
|
29 |
{
|
|
30 |
FUNC_LOG;
|
|
31 |
|
|
32 |
CGOomConfig* self = new (ELeave) CGOomConfig;
|
|
33 |
CleanupStack::PushL(self);
|
|
34 |
self->ConstructL();
|
|
35 |
CleanupStack::Pop(self);
|
|
36 |
return self;
|
|
37 |
}
|
|
38 |
|
|
39 |
|
|
40 |
// Add the configuration for an application closure.
|
|
41 |
// This class takes ownership of this action.
|
|
42 |
void CGOomConfig::SetAppCloseConfigL(CGOomCloseAppConfig* aActionConfig)
|
|
43 |
{
|
|
44 |
FUNC_LOG;
|
|
45 |
|
|
46 |
// Find the right application config (if there is one) for the app
|
|
47 |
// The map actually contains pointers for values, so we get pointers to pointers here...
|
|
48 |
CGOomApplicationConfig** applicationConfigPointer = iApplicationToConfigMapping.Find(aActionConfig->iId);
|
|
49 |
|
|
50 |
// Used to de-reference the pointer-to-pointer, hopefully making the code more readable
|
|
51 |
CGOomApplicationConfig* applicationConfig = NULL;
|
|
52 |
|
|
53 |
// Create a new CGOomApplicationConfig if there isn't one for this app
|
|
54 |
if (!applicationConfigPointer)
|
|
55 |
{
|
|
56 |
applicationConfig = CGOomApplicationConfig::NewL(aActionConfig->iId);
|
|
57 |
iApplicationToConfigMapping.InsertL(aActionConfig->iId, applicationConfig);
|
|
58 |
}
|
|
59 |
else
|
|
60 |
{
|
|
61 |
applicationConfig = *applicationConfigPointer;
|
|
62 |
}
|
|
63 |
|
|
64 |
// Append the action config to the appropriate list (the list for the relevant application)
|
|
65 |
applicationConfig->SetAppCloseConfig(aActionConfig);
|
|
66 |
}
|
|
67 |
|
|
68 |
// Add the configuration for a plugin action.
|
|
69 |
// This class takes ownership of the configuration object.
|
|
70 |
void CGOomConfig::AddPluginConfigL(CGOomRunPluginConfig* aPluginConfig)
|
|
71 |
{
|
|
72 |
FUNC_LOG;
|
|
73 |
|
|
74 |
// Check if the plugin has already been added, if so then this is an error in configuration (something is trying to add the same plugin twice)
|
|
75 |
CGOomRunPluginConfig** runPluginConfig = iPluginToConfigMapping.Find(aPluginConfig->Id());
|
|
76 |
if (runPluginConfig)
|
|
77 |
{
|
|
78 |
GOomMonitorPanic(KPluginConfigAddedTwice);
|
|
79 |
}
|
|
80 |
|
|
81 |
iPluginToConfigMapping.InsertL(aPluginConfig->Id(), aPluginConfig);
|
|
82 |
|
|
83 |
}
|
|
84 |
|
|
85 |
// Add a rule
|
|
86 |
// This class takes ownership of the given rule
|
|
87 |
// This rule applies to the specified application (and not a plugin associated with this application)
|
|
88 |
// The rule would usually apply to an "application close" event
|
|
89 |
void CGOomConfig::AddApplicationRuleL(TUint aTargetAppId, MGOomRuleConfig* aRule)
|
|
90 |
{
|
|
91 |
FUNC_LOG;
|
|
92 |
|
|
93 |
CGOomApplicationConfig** applicationConfig = iApplicationToConfigMapping.Find(aTargetAppId);
|
|
94 |
|
|
95 |
if (applicationConfig)
|
|
96 |
{
|
|
97 |
(*applicationConfig)->AddRuleL(aRule);
|
|
98 |
}
|
|
99 |
else
|
|
100 |
{
|
|
101 |
GOomMonitorPanic(KRuleConfiguredBeforeApplication);
|
|
102 |
}
|
|
103 |
}
|
|
104 |
|
|
105 |
// Add a rule for a plugin
|
|
106 |
// This class takes ownership of the given rule
|
|
107 |
// This rule is applied to the plugin with the specified ID
|
|
108 |
void CGOomConfig::AddPluginRuleL(TUint aPluginId, MGOomRuleConfig* aRule)
|
|
109 |
{
|
|
110 |
FUNC_LOG;
|
|
111 |
|
|
112 |
CGOomRunPluginConfig** runPluginConfig = iPluginToConfigMapping.Find(aPluginId);
|
|
113 |
|
|
114 |
if (runPluginConfig)
|
|
115 |
{
|
|
116 |
(*runPluginConfig)->AddRuleL(aRule);
|
|
117 |
}
|
|
118 |
else
|
|
119 |
{
|
|
120 |
GOomMonitorPanic(KRuleConfiguredBeforePlugin);
|
|
121 |
}
|
|
122 |
}
|
|
123 |
|
|
124 |
// Add this application config - this class takes ownership of it
|
|
125 |
// Application config includes settings for a particular application, e.g. whether or not it can be closed
|
|
126 |
void CGOomConfig::AddApplicationConfigL(CGOomApplicationConfig* aApplicationConfig)
|
|
127 |
{
|
|
128 |
FUNC_LOG;
|
|
129 |
|
|
130 |
// Check if the application has already been added, if so then this is an error in configuration (something is trying to add the same app twice)
|
|
131 |
CGOomApplicationConfig** applicationConfig = iApplicationToConfigMapping.Find(aApplicationConfig->Id());
|
|
132 |
if (applicationConfig)
|
|
133 |
{
|
|
134 |
GOomMonitorPanic(KAppConfigAddedTwice);
|
|
135 |
}
|
|
136 |
|
|
137 |
iApplicationToConfigMapping.InsertL(aApplicationConfig->Id(), aApplicationConfig);
|
|
138 |
}
|
|
139 |
|
|
140 |
// Get the list of configured actions for the given app id
|
|
141 |
// If no specific actions have been configured for this application then the default action is returned
|
|
142 |
CGOomApplicationConfig& CGOomConfig::GetApplicationConfig(TInt32 aAppId)
|
|
143 |
{
|
|
144 |
FUNC_LOG;
|
|
145 |
|
|
146 |
CGOomApplicationConfig** applicationConfig = iApplicationToConfigMapping.Find(aAppId);
|
|
147 |
|
|
148 |
if (!applicationConfig)
|
|
149 |
applicationConfig = iApplicationToConfigMapping.Find(KGOomDefaultAppId);
|
|
150 |
|
|
151 |
// The default app configuration should always exist
|
|
152 |
__ASSERT_ALWAYS(applicationConfig, GOomMonitorPanic(KGOomDefaultAppNotConfigured));
|
|
153 |
|
|
154 |
return *(*applicationConfig);
|
|
155 |
}
|
|
156 |
|
|
157 |
// Get the plugin configuration for the given plugin id
|
|
158 |
// If no specific actions have been configured for this plugin then the default plugin configuration is returned
|
|
159 |
CGOomRunPluginConfig& CGOomConfig::GetPluginConfig(TInt32 aPluginId)
|
|
160 |
{
|
|
161 |
FUNC_LOG;
|
|
162 |
|
|
163 |
CGOomRunPluginConfig** runPluginConfig = iPluginToConfigMapping.Find(aPluginId);
|
|
164 |
|
|
165 |
if (!runPluginConfig)
|
|
166 |
runPluginConfig = iPluginToConfigMapping.Find(KGOomDefaultPluginId);
|
|
167 |
|
|
168 |
// The default app configuration should always exist
|
|
169 |
__ASSERT_ALWAYS(runPluginConfig, GOomMonitorPanic(KGOomDefaultPluginNotConfigured));
|
|
170 |
|
|
171 |
return *(*runPluginConfig);
|
|
172 |
}
|
|
173 |
|
|
174 |
CGOomConfig::~CGOomConfig()
|
|
175 |
{
|
|
176 |
FUNC_LOG;
|
|
177 |
|
|
178 |
// Iterate through the hash map deleting all of the items
|
|
179 |
RHashMap<TInt32, CGOomApplicationConfig*>::TIter iterator(iApplicationToConfigMapping);
|
|
180 |
while (iterator.NextValue())
|
|
181 |
delete iterator.CurrentValue();
|
|
182 |
|
|
183 |
// Iterate through the plugiun hash map deleting all of the items
|
|
184 |
RHashMap<TInt32, CGOomRunPluginConfig*>::TIter pluginIterator(iPluginToConfigMapping);
|
|
185 |
while (pluginIterator.NextValue())
|
|
186 |
delete pluginIterator.CurrentValue();
|
|
187 |
|
|
188 |
iApplicationToConfigMapping.Close();
|
|
189 |
}
|
|
190 |
|
|
191 |
void CGOomConfig::ConstructL()
|
|
192 |
{
|
|
193 |
FUNC_LOG;
|
|
194 |
}
|