sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
|
sl@0
|
17 |
#include "uloggersysconfig.h"
|
sl@0
|
18 |
#include "sysconfigimpl.h"
|
sl@0
|
19 |
#include "uloggershared.h"
|
sl@0
|
20 |
#include <e32base.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
|
sl@0
|
23 |
namespace Ulogger
|
sl@0
|
24 |
{
|
sl@0
|
25 |
|
sl@0
|
26 |
/** Creates a sysconfig settings iterator object
|
sl@0
|
27 |
@return a pointer to the created object
|
sl@0
|
28 |
@leave KErrNoMemory if not enough memory available
|
sl@0
|
29 |
*/
|
sl@0
|
30 |
EXPORT_C CConfigSettingsIter* CConfigSettingsIter::NewL()
|
sl@0
|
31 |
{
|
sl@0
|
32 |
CConfigSettingsIter* self=new (ELeave)CConfigSettingsIter();
|
sl@0
|
33 |
CleanupStack::PushL(self);
|
sl@0
|
34 |
self->iImpl=CConfigSettingsImpl::NewL();
|
sl@0
|
35 |
CleanupStack::Pop();
|
sl@0
|
36 |
return self;
|
sl@0
|
37 |
}
|
sl@0
|
38 |
|
sl@0
|
39 |
/**
|
sl@0
|
40 |
A function to loop through the settings in the system config
|
sl@0
|
41 |
and return the setting and its value through the passed in pointer
|
sl@0
|
42 |
@param aSetting a pointer to the buffered setting name
|
sl@0
|
43 |
@param aSettingValue a pointer to the buffered setting value
|
sl@0
|
44 |
@return ETrue if there are more setting
|
sl@0
|
45 |
EFalse if the iterator is at end of settings
|
sl@0
|
46 |
Other system wide errors
|
sl@0
|
47 |
@post the iterator now points to the next setting
|
sl@0
|
48 |
*/
|
sl@0
|
49 |
EXPORT_C TBool CConfigSettingsIter::Next(TPtrC8& aSetting,TPtrC8& aSettingValue)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
return iImpl->Next(aSetting,aSettingValue);
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
/**
|
sl@0
|
55 |
Reset the iterator to point to the first setting
|
sl@0
|
56 |
@post the iterator now points to the first setting
|
sl@0
|
57 |
*/
|
sl@0
|
58 |
EXPORT_C void CConfigSettingsIter::Reset()
|
sl@0
|
59 |
{
|
sl@0
|
60 |
iImpl->Reset();
|
sl@0
|
61 |
}
|
sl@0
|
62 |
|
sl@0
|
63 |
/**
|
sl@0
|
64 |
Public Destructor
|
sl@0
|
65 |
*/
|
sl@0
|
66 |
EXPORT_C CConfigSettingsIter::~CConfigSettingsIter()
|
sl@0
|
67 |
{
|
sl@0
|
68 |
delete iImpl;
|
sl@0
|
69 |
}
|
sl@0
|
70 |
|
sl@0
|
71 |
CConfigSettingsIter::CConfigSettingsIter(){}
|
sl@0
|
72 |
|
sl@0
|
73 |
////////////////////////////////////////////////////////////////////////////
|
sl@0
|
74 |
|
sl@0
|
75 |
/**
|
sl@0
|
76 |
Create a pointer to a CConfig object initialised with the current
|
sl@0
|
77 |
configuration settings for the system wide framework.
|
sl@0
|
78 |
|
sl@0
|
79 |
Therefore it allocates and manages memory to store these settings.
|
sl@0
|
80 |
If the client has a requirement to use a private heap then a reference to it
|
sl@0
|
81 |
must be supplied should the notification funtionality be required
|
sl@0
|
82 |
as this will result in the settings being reloaded and hence memory
|
sl@0
|
83 |
will need to be reallocated.
|
sl@0
|
84 |
Clients with this requirement will need to ensure heaps are switch to ensure
|
sl@0
|
85 |
the CConfig object is itself allocated on the correct heap.
|
sl@0
|
86 |
|
sl@0
|
87 |
@param aHeap a pointer to a private heap location
|
sl@0
|
88 |
@param aFilename name of the configuration file with full path
|
sl@0
|
89 |
@return a pointer to the new CConfig object
|
sl@0
|
90 |
*/
|
sl@0
|
91 |
EXPORT_C CConfig* CConfig::NewL(RHeap* aHeap,TFileName& aFilename)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
CConfig* self= new(ELeave) CConfig();
|
sl@0
|
94 |
CleanupStack::PushL(self);
|
sl@0
|
95 |
self->iImpl=CConfigImpl::NewL(aHeap,aFilename);
|
sl@0
|
96 |
CleanupStack::Pop();
|
sl@0
|
97 |
return self;
|
sl@0
|
98 |
}
|
sl@0
|
99 |
|
sl@0
|
100 |
/**
|
sl@0
|
101 |
Create a pointer to a CConfig object initialised with the current
|
sl@0
|
102 |
configuration settings for the system wide framework. Places object
|
sl@0
|
103 |
on the Cleanup stack.
|
sl@0
|
104 |
|
sl@0
|
105 |
Therefore it allocates and manages memory to store these settings.
|
sl@0
|
106 |
If the client has a requirement to use a private heap then a reference to it
|
sl@0
|
107 |
must be supplied should the notification funtionality be required
|
sl@0
|
108 |
as this will result in the settings being reloaded and hence memory
|
sl@0
|
109 |
will need to be reallocated.
|
sl@0
|
110 |
Clients with this requirement will need to ensure heaps are switch to ensure
|
sl@0
|
111 |
the CConfig object is itself allocated on the correct heap.
|
sl@0
|
112 |
|
sl@0
|
113 |
@param aHeap a pointer to a private heap location
|
sl@0
|
114 |
@param aFilename name of the configuration file with full path
|
sl@0
|
115 |
@return a pointer to the new CConfig object
|
sl@0
|
116 |
*/
|
sl@0
|
117 |
EXPORT_C CConfig* CConfig::NewLC(RHeap* aHeap,TFileName& aFilename)
|
sl@0
|
118 |
{
|
sl@0
|
119 |
CConfig* self=CConfig::NewL(aHeap,aFilename);
|
sl@0
|
120 |
CleanupStack::PushL(self);
|
sl@0
|
121 |
return self;
|
sl@0
|
122 |
}
|
sl@0
|
123 |
|
sl@0
|
124 |
|
sl@0
|
125 |
/**
|
sl@0
|
126 |
Create and initialize a setting iterator to the list of output
|
sl@0
|
127 |
channels
|
sl@0
|
128 |
@param aIter reference to the setting iterator object
|
sl@0
|
129 |
@return KErrNone if no error
|
sl@0
|
130 |
Other system wide errors
|
sl@0
|
131 |
*/
|
sl@0
|
132 |
EXPORT_C TInt CConfig::GetOutputPlugins(CConfigSettingsIter& aIter)
|
sl@0
|
133 |
{
|
sl@0
|
134 |
return iImpl->GetSection(KActiveSection,aIter);
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
|
sl@0
|
138 |
EXPORT_C TInt CConfig::GetActivePlugins(CConfigSettingsIter& aIter)
|
sl@0
|
139 |
{
|
sl@0
|
140 |
return iImpl->GetSection(KActiveControlSection,aIter);
|
sl@0
|
141 |
}
|
sl@0
|
142 |
|
sl@0
|
143 |
|
sl@0
|
144 |
/**
|
sl@0
|
145 |
Create and initialize a setting iterator to the list filters
|
sl@0
|
146 |
@param aIter reference to the setting iterator object
|
sl@0
|
147 |
@return KErrNone if no error
|
sl@0
|
148 |
Other system wide errors
|
sl@0
|
149 |
*/
|
sl@0
|
150 |
EXPORT_C TInt CConfig::GetActiveFilters(CConfigSettingsIter& aIter,TInt aFilter)
|
sl@0
|
151 |
{
|
sl@0
|
152 |
if(aFilter == 1)
|
sl@0
|
153 |
return iImpl->GetSection(KPrimaryFilterSection,aIter);
|
sl@0
|
154 |
else if(aFilter == 2)
|
sl@0
|
155 |
return iImpl->GetSection(KSecondaryFilterSection,aIter);
|
sl@0
|
156 |
else
|
sl@0
|
157 |
return KErrNone;
|
sl@0
|
158 |
}
|
sl@0
|
159 |
|
sl@0
|
160 |
EXPORT_C TInt CConfig::GetSectionValues(const TDesC8& aSectionName,CConfigSettingsIter& aIter)
|
sl@0
|
161 |
{
|
sl@0
|
162 |
return iImpl->GetSection(aSectionName,aIter);
|
sl@0
|
163 |
}
|
sl@0
|
164 |
|
sl@0
|
165 |
|
sl@0
|
166 |
/**
|
sl@0
|
167 |
Removes output channel setting section from the configuration file
|
sl@0
|
168 |
@param aOutputChanId the plugin name which has to be removed
|
sl@0
|
169 |
@return KErrNone if no error,
|
sl@0
|
170 |
KErrNotFound if output channel setting section does not exist
|
sl@0
|
171 |
Other System wide errors
|
sl@0
|
172 |
*/
|
sl@0
|
173 |
EXPORT_C TInt CConfig::RemovePluginSettings(const TDesC8& aChanId)
|
sl@0
|
174 |
{
|
sl@0
|
175 |
//
|
sl@0
|
176 |
// NEW CODE:
|
sl@0
|
177 |
//
|
sl@0
|
178 |
|
sl@0
|
179 |
CConfigSettingsIter* iter = CConfigSettingsIter::NewL();
|
sl@0
|
180 |
CleanupStack::PushL(iter);
|
sl@0
|
181 |
|
sl@0
|
182 |
TInt ret = iImpl->GetSection(aChanId, *iter);
|
sl@0
|
183 |
|
sl@0
|
184 |
if (KErrNone == ret)
|
sl@0
|
185 |
{
|
sl@0
|
186 |
TPtrC8 key;
|
sl@0
|
187 |
TPtrC8 dummy;
|
sl@0
|
188 |
|
sl@0
|
189 |
//remove all keys from section aChanId
|
sl@0
|
190 |
while(iter->Next(key, dummy))
|
sl@0
|
191 |
{
|
sl@0
|
192 |
iImpl->RemoveKey(aChanId, key);
|
sl@0
|
193 |
iter->Reset(); // otherwise we'd be skipping every 2nd element!
|
sl@0
|
194 |
}
|
sl@0
|
195 |
|
sl@0
|
196 |
//remove section
|
sl@0
|
197 |
iImpl->RemoveSection(aChanId);
|
sl@0
|
198 |
//finally write into ini file
|
sl@0
|
199 |
ret = iImpl->PersistIniFile();
|
sl@0
|
200 |
}
|
sl@0
|
201 |
|
sl@0
|
202 |
CleanupStack::PopAndDestroy(iter);
|
sl@0
|
203 |
|
sl@0
|
204 |
return ret;
|
sl@0
|
205 |
}
|
sl@0
|
206 |
|
sl@0
|
207 |
/**
|
sl@0
|
208 |
Set a particular channel id settings, create one if settings does not exist yet
|
sl@0
|
209 |
@param aOutputChanId the channel id
|
sl@0
|
210 |
@param aSetting the channel setting to modify or add
|
sl@0
|
211 |
@param aValue the value to assign to this setting
|
sl@0
|
212 |
@return KErrNone if no error,
|
sl@0
|
213 |
KErrNotFound if no matching output id
|
sl@0
|
214 |
Other System wide errors
|
sl@0
|
215 |
*/
|
sl@0
|
216 |
EXPORT_C TInt CConfig::SetPluginSetting(const TDesC8& aChanId,const TDesC8& aSetting,const TDesC8& aValue)
|
sl@0
|
217 |
{
|
sl@0
|
218 |
TInt ret = iImpl->SetKeyValue(aChanId,aSetting,aValue);
|
sl@0
|
219 |
|
sl@0
|
220 |
if (KErrNone == ret)
|
sl@0
|
221 |
{
|
sl@0
|
222 |
//finally write into ini file
|
sl@0
|
223 |
ret = iImpl->PersistIniFile();
|
sl@0
|
224 |
}
|
sl@0
|
225 |
|
sl@0
|
226 |
return ret;
|
sl@0
|
227 |
}
|
sl@0
|
228 |
|
sl@0
|
229 |
/**
|
sl@0
|
230 |
Register Active Plugin
|
sl@0
|
231 |
An internal active name that maps to this plugin is generated internally
|
sl@0
|
232 |
@param aPluginName the plugin to be added to the system.
|
sl@0
|
233 |
@param aMediaName pointer to the internal media name
|
sl@0
|
234 |
@return KErrNone if no error
|
sl@0
|
235 |
KErrAlreadyExists if the plugin name already exists
|
sl@0
|
236 |
Other system wide errors
|
sl@0
|
237 |
*/
|
sl@0
|
238 |
EXPORT_C TInt CConfig::SetActiveOutputPlugin(const TDesC8& aMediaName)
|
sl@0
|
239 |
{
|
sl@0
|
240 |
//first check whether plugin already registered
|
sl@0
|
241 |
TPtrC8 key;
|
sl@0
|
242 |
TPtrC8 val;
|
sl@0
|
243 |
TPtrC8 aMedia;
|
sl@0
|
244 |
|
sl@0
|
245 |
TInt keyCount=0;
|
sl@0
|
246 |
TInt ret=iImpl->CheckValueExist(KActiveSection,aMediaName,keyCount);
|
sl@0
|
247 |
if(ret == KErrAlreadyExists)
|
sl@0
|
248 |
return ret;
|
sl@0
|
249 |
if ((ret==KErrNone && keyCount))
|
sl@0
|
250 |
{
|
sl@0
|
251 |
CConfigSettingsIter* iter = CConfigSettingsIter::NewL();
|
sl@0
|
252 |
CleanupStack::PushL(iter);
|
sl@0
|
253 |
GetOutputPlugins(*iter);
|
sl@0
|
254 |
while(iter->Next(val,key))
|
sl@0
|
255 |
{
|
sl@0
|
256 |
ret=iImpl->RemoveKey(KActiveSection,val);
|
sl@0
|
257 |
}
|
sl@0
|
258 |
CleanupStack::PopAndDestroy();
|
sl@0
|
259 |
}
|
sl@0
|
260 |
|
sl@0
|
261 |
//get the internally generated name
|
sl@0
|
262 |
TBuf8<15> internalName;
|
sl@0
|
263 |
ret=iImpl->GenerateInternalKey(KActiveSection,internalName);
|
sl@0
|
264 |
if (ret!=KErrNone)
|
sl@0
|
265 |
return ret;
|
sl@0
|
266 |
|
sl@0
|
267 |
ret=iImpl->SetKeyValue(KActiveSection,internalName,aMediaName);
|
sl@0
|
268 |
if (ret!=KErrNone)
|
sl@0
|
269 |
return ret;
|
sl@0
|
270 |
|
sl@0
|
271 |
ret= iImpl->GetPointerToKeyName(KActiveSection,internalName,aMedia);
|
sl@0
|
272 |
if (ret!=KErrNone)
|
sl@0
|
273 |
return ret;
|
sl@0
|
274 |
|
sl@0
|
275 |
//finally write into ini file
|
sl@0
|
276 |
return iImpl->PersistIniFile();
|
sl@0
|
277 |
}
|
sl@0
|
278 |
|
sl@0
|
279 |
|
sl@0
|
280 |
EXPORT_C TInt CConfig::SetActiveInputPlugin(const TDesC8& aMediaName)
|
sl@0
|
281 |
{
|
sl@0
|
282 |
//first check whether plugin already registered
|
sl@0
|
283 |
TPtrC8 key;
|
sl@0
|
284 |
TPtrC8 val;
|
sl@0
|
285 |
TPtrC8 aMedia;
|
sl@0
|
286 |
|
sl@0
|
287 |
TInt keyCount=0;
|
sl@0
|
288 |
TInt ret=iImpl->CheckValueExist(KActiveControlSection,aMediaName,keyCount);
|
sl@0
|
289 |
if(ret == KErrAlreadyExists)
|
sl@0
|
290 |
return ret;
|
sl@0
|
291 |
if ((ret==KErrNone && keyCount))
|
sl@0
|
292 |
{
|
sl@0
|
293 |
CConfigSettingsIter* iter = CConfigSettingsIter::NewL();
|
sl@0
|
294 |
CleanupStack::PushL(iter);
|
sl@0
|
295 |
GetActivePlugins(*iter);
|
sl@0
|
296 |
while(iter->Next(val,key))
|
sl@0
|
297 |
{
|
sl@0
|
298 |
ret=iImpl->RemoveKey(KActiveControlSection,val);
|
sl@0
|
299 |
}
|
sl@0
|
300 |
CleanupStack::PopAndDestroy();
|
sl@0
|
301 |
}
|
sl@0
|
302 |
|
sl@0
|
303 |
//get the internally generated name
|
sl@0
|
304 |
TBuf8<15> internalName;
|
sl@0
|
305 |
ret=iImpl->GenerateInternalKey(KActiveControlSection,internalName);
|
sl@0
|
306 |
if (ret!=KErrNone)
|
sl@0
|
307 |
return ret;
|
sl@0
|
308 |
|
sl@0
|
309 |
ret=iImpl->SetKeyValue(KActiveControlSection,internalName,aMediaName);
|
sl@0
|
310 |
if (ret!=KErrNone)
|
sl@0
|
311 |
return ret;
|
sl@0
|
312 |
|
sl@0
|
313 |
ret= iImpl->GetPointerToKeyName(KActiveControlSection,internalName,aMedia);
|
sl@0
|
314 |
if (ret!=KErrNone)
|
sl@0
|
315 |
return ret;
|
sl@0
|
316 |
|
sl@0
|
317 |
//finally write into ini file
|
sl@0
|
318 |
return iImpl->PersistIniFile();
|
sl@0
|
319 |
}
|
sl@0
|
320 |
|
sl@0
|
321 |
|
sl@0
|
322 |
EXPORT_C TInt CConfig::DeActivateOutputPlugin(const TDesC8& aMediaName)
|
sl@0
|
323 |
{
|
sl@0
|
324 |
TPtrC8 key;
|
sl@0
|
325 |
TPtrC8 val;
|
sl@0
|
326 |
TPtrC8 aMedia;
|
sl@0
|
327 |
|
sl@0
|
328 |
TInt keyCount=0;
|
sl@0
|
329 |
TInt ret=iImpl->CheckValueExist(KActiveSection,aMediaName,keyCount);
|
sl@0
|
330 |
if(ret==KErrNone)
|
sl@0
|
331 |
return KErrNotFound;
|
sl@0
|
332 |
else if (ret==KErrAlreadyExists)
|
sl@0
|
333 |
{
|
sl@0
|
334 |
CConfigSettingsIter* iter = CConfigSettingsIter::NewL();
|
sl@0
|
335 |
CleanupStack::PushL(iter);
|
sl@0
|
336 |
User::LeaveIfError(GetOutputPlugins(*iter));
|
sl@0
|
337 |
while(iter->Next(val,key))
|
sl@0
|
338 |
{
|
sl@0
|
339 |
ret=iImpl->RemoveKey(KActiveSection,val);
|
sl@0
|
340 |
}
|
sl@0
|
341 |
CleanupStack::PopAndDestroy();
|
sl@0
|
342 |
}
|
sl@0
|
343 |
if(ret!=KErrNone)
|
sl@0
|
344 |
return ret;
|
sl@0
|
345 |
return iImpl->PersistIniFile();
|
sl@0
|
346 |
}
|
sl@0
|
347 |
|
sl@0
|
348 |
|
sl@0
|
349 |
EXPORT_C TInt CConfig::DeActivateInputPlugin(const TDesC8& aMediaName)
|
sl@0
|
350 |
{
|
sl@0
|
351 |
TPtrC8 key;
|
sl@0
|
352 |
TPtrC8 val;
|
sl@0
|
353 |
TPtrC8 aMedia;
|
sl@0
|
354 |
|
sl@0
|
355 |
TInt keyCount=0;
|
sl@0
|
356 |
TInt ret=iImpl->CheckValueExist(KActiveControlSection,aMediaName,keyCount);
|
sl@0
|
357 |
if(ret==KErrNone)
|
sl@0
|
358 |
return KErrNotFound;
|
sl@0
|
359 |
else if (ret==KErrAlreadyExists)
|
sl@0
|
360 |
{
|
sl@0
|
361 |
CConfigSettingsIter* iter = CConfigSettingsIter::NewL();
|
sl@0
|
362 |
CleanupStack::PushL(iter);
|
sl@0
|
363 |
TInt a = GetActivePlugins(*iter);
|
sl@0
|
364 |
if(a != KErrNone)
|
sl@0
|
365 |
return a;
|
sl@0
|
366 |
while(iter->Next(val,key))
|
sl@0
|
367 |
{
|
sl@0
|
368 |
ret=iImpl->RemoveKey(KActiveControlSection,val);
|
sl@0
|
369 |
}
|
sl@0
|
370 |
CleanupStack::PopAndDestroy();
|
sl@0
|
371 |
}
|
sl@0
|
372 |
if(ret!=KErrNone)
|
sl@0
|
373 |
return ret;
|
sl@0
|
374 |
return iImpl->PersistIniFile();
|
sl@0
|
375 |
}
|
sl@0
|
376 |
|
sl@0
|
377 |
|
sl@0
|
378 |
EXPORT_C TInt CConfig::SetActiveFilter(const RArray<TUint32>& aFilter, const TDesC8 &aSectionName)
|
sl@0
|
379 |
{
|
sl@0
|
380 |
TInt error = KErrNone;
|
sl@0
|
381 |
|
sl@0
|
382 |
for(TInt i = 0; i < aFilter.Count(); i++)
|
sl@0
|
383 |
{
|
sl@0
|
384 |
//copy the filter as a string
|
sl@0
|
385 |
HBufC8* filter = HBufC8::NewLC(32);
|
sl@0
|
386 |
filter->Des().Num(aFilter[i]);
|
sl@0
|
387 |
TPtr8 filterPtr(filter->Des());
|
sl@0
|
388 |
TInt keycount = 0;
|
sl@0
|
389 |
//check if the section exists
|
sl@0
|
390 |
error = iImpl->CheckValueExist(aSectionName, filterPtr, keycount);
|
sl@0
|
391 |
if (!error)//either the section or the value didn't exist
|
sl@0
|
392 |
{
|
sl@0
|
393 |
TBuf8<15> internalName;
|
sl@0
|
394 |
error = iImpl->GenerateInternalKey(aSectionName, internalName);
|
sl@0
|
395 |
if(!error)
|
sl@0
|
396 |
error = iImpl->SetKeyValue(aSectionName,internalName,filterPtr);
|
sl@0
|
397 |
}
|
sl@0
|
398 |
if(error == KErrAlreadyExists) //ignore these
|
sl@0
|
399 |
error = KErrNone;
|
sl@0
|
400 |
CleanupStack::PopAndDestroy();//filter
|
sl@0
|
401 |
if(error)
|
sl@0
|
402 |
break;
|
sl@0
|
403 |
}
|
sl@0
|
404 |
//finally write into ini file
|
sl@0
|
405 |
iImpl->PersistIniFile();
|
sl@0
|
406 |
return error;
|
sl@0
|
407 |
}
|
sl@0
|
408 |
|
sl@0
|
409 |
EXPORT_C TInt CConfig:: SetTraceSettings(const TDesC8& aValue, const TDesC8& aSetting)
|
sl@0
|
410 |
{
|
sl@0
|
411 |
TPtrC8 aMedia;
|
sl@0
|
412 |
TPtrC8 value;
|
sl@0
|
413 |
//get the internally generated name
|
sl@0
|
414 |
|
sl@0
|
415 |
TInt ret;
|
sl@0
|
416 |
if(aSetting.Compare(KBuffer) == 0)
|
sl@0
|
417 |
{
|
sl@0
|
418 |
ret=iImpl->SetKeyValue(KTrace,KBuffer,aValue);
|
sl@0
|
419 |
if (ret!=KErrNone)
|
sl@0
|
420 |
return ret;
|
sl@0
|
421 |
|
sl@0
|
422 |
ret= iImpl->GetPointerToKeyName(KTrace,KBuffer,aMedia);
|
sl@0
|
423 |
if (ret!=KErrNone)
|
sl@0
|
424 |
return ret;
|
sl@0
|
425 |
}
|
sl@0
|
426 |
else if(aSetting.Compare(KSecondaryGlobalFilter) == 0)
|
sl@0
|
427 |
{
|
sl@0
|
428 |
iImpl->GetKeyValue(KTrace,KSecondaryGlobalFilter,value);
|
sl@0
|
429 |
if(value.Compare(aValue)==0)
|
sl@0
|
430 |
return KErrNone;
|
sl@0
|
431 |
else
|
sl@0
|
432 |
{
|
sl@0
|
433 |
ret=iImpl->SetKeyValue(KTrace,KSecondaryGlobalFilter,aValue);
|
sl@0
|
434 |
if (ret!=KErrNone)
|
sl@0
|
435 |
return ret;
|
sl@0
|
436 |
|
sl@0
|
437 |
ret= iImpl->GetPointerToKeyName(KTrace,KSecondaryGlobalFilter,aMedia);
|
sl@0
|
438 |
if (ret!=KErrNone)
|
sl@0
|
439 |
return ret;
|
sl@0
|
440 |
}
|
sl@0
|
441 |
}
|
sl@0
|
442 |
else if(aSetting.Compare(KDataNotification) == 0)
|
sl@0
|
443 |
{
|
sl@0
|
444 |
ret=iImpl->SetKeyValue(KTrace,KDataNotification,aValue);
|
sl@0
|
445 |
if (ret!=KErrNone)
|
sl@0
|
446 |
return ret;
|
sl@0
|
447 |
|
sl@0
|
448 |
ret= iImpl->GetPointerToKeyName(KTrace,KDataNotification,aMedia);
|
sl@0
|
449 |
if (ret!=KErrNone)
|
sl@0
|
450 |
return ret;
|
sl@0
|
451 |
}
|
sl@0
|
452 |
else if(aSetting.Compare(KBufferMode) == 0)
|
sl@0
|
453 |
{
|
sl@0
|
454 |
ret=iImpl->SetKeyValue(KTrace,KBufferMode,aValue);
|
sl@0
|
455 |
if (ret!=KErrNone)
|
sl@0
|
456 |
return ret;
|
sl@0
|
457 |
|
sl@0
|
458 |
ret= iImpl->GetPointerToKeyName(KTrace,KBufferMode,aMedia);
|
sl@0
|
459 |
if (ret!=KErrNone)
|
sl@0
|
460 |
return ret;
|
sl@0
|
461 |
}
|
sl@0
|
462 |
else
|
sl@0
|
463 |
return KErrNotFound;
|
sl@0
|
464 |
|
sl@0
|
465 |
|
sl@0
|
466 |
//finally write into ini file
|
sl@0
|
467 |
return iImpl->PersistIniFile();
|
sl@0
|
468 |
|
sl@0
|
469 |
}
|
sl@0
|
470 |
|
sl@0
|
471 |
|
sl@0
|
472 |
|
sl@0
|
473 |
EXPORT_C TInt CConfig:: GetTraceSettings(CConfigSettingsIter& aIter)
|
sl@0
|
474 |
{
|
sl@0
|
475 |
return iImpl->GetSection(KTrace,aIter);
|
sl@0
|
476 |
}
|
sl@0
|
477 |
|
sl@0
|
478 |
/**
|
sl@0
|
479 |
Remove a Filter based on its internal media name. It will fail if
|
sl@0
|
480 |
any of this media is still referenced by one of the output channel
|
sl@0
|
481 |
@param aMediaName the internal media name of the plugin to be removed
|
sl@0
|
482 |
@return KErrNone if no error
|
sl@0
|
483 |
KErrNotFound if no matching media name
|
sl@0
|
484 |
KErrAccessDenied if still referenced by one of the output channel
|
sl@0
|
485 |
*/
|
sl@0
|
486 |
|
sl@0
|
487 |
EXPORT_C TInt CConfig::RemoveActiveFilter(const RArray<TUint32>& aFilter, const TInt &aFilterValue)
|
sl@0
|
488 |
{
|
sl@0
|
489 |
TPtrC8 sectionName;
|
sl@0
|
490 |
TPtrC8 val;
|
sl@0
|
491 |
TPtrC8 key;
|
sl@0
|
492 |
TInt ret = KErrNotFound;
|
sl@0
|
493 |
|
sl@0
|
494 |
if(aFilterValue == 1)
|
sl@0
|
495 |
sectionName.Set(KPrimaryFilterSection());
|
sl@0
|
496 |
else if(aFilterValue == 2)
|
sl@0
|
497 |
sectionName.Set(KSecondaryFilterSection());
|
sl@0
|
498 |
|
sl@0
|
499 |
CConfigSettingsIter* iter = CConfigSettingsIter::NewL();
|
sl@0
|
500 |
CleanupStack::PushL(iter);
|
sl@0
|
501 |
GetActiveFilters(*iter, aFilterValue);
|
sl@0
|
502 |
|
sl@0
|
503 |
for(TInt i=0; i<aFilter.Count();i++)
|
sl@0
|
504 |
{
|
sl@0
|
505 |
//ret = iImpl->GetSection(aSectionName,iter);
|
sl@0
|
506 |
HBufC8* filter = HBufC8::NewLC(32);
|
sl@0
|
507 |
filter->Des().Num(aFilter[i]);
|
sl@0
|
508 |
TPtr8 ptr(filter->Des());
|
sl@0
|
509 |
CleanupStack::Pop(1);
|
sl@0
|
510 |
|
sl@0
|
511 |
while(iter->Next(val,key))
|
sl@0
|
512 |
{
|
sl@0
|
513 |
if (key.Compare(ptr)==0)
|
sl@0
|
514 |
{
|
sl@0
|
515 |
TInt tmpRet = iImpl->RemoveKey(sectionName,val);
|
sl@0
|
516 |
if(ret != KErrNone)
|
sl@0
|
517 |
ret = tmpRet;
|
sl@0
|
518 |
break;
|
sl@0
|
519 |
}
|
sl@0
|
520 |
}
|
sl@0
|
521 |
iter->Reset();
|
sl@0
|
522 |
|
sl@0
|
523 |
}
|
sl@0
|
524 |
CleanupStack::PopAndDestroy();
|
sl@0
|
525 |
//finally write into ini file
|
sl@0
|
526 |
iImpl->PersistIniFile();
|
sl@0
|
527 |
return ret;
|
sl@0
|
528 |
|
sl@0
|
529 |
}
|
sl@0
|
530 |
|
sl@0
|
531 |
/**
|
sl@0
|
532 |
Public Destructor
|
sl@0
|
533 |
*/
|
sl@0
|
534 |
EXPORT_C CConfig::~CConfig()
|
sl@0
|
535 |
{
|
sl@0
|
536 |
delete iImpl;
|
sl@0
|
537 |
}
|
sl@0
|
538 |
|
sl@0
|
539 |
//default constructor
|
sl@0
|
540 |
CConfig::CConfig(){}
|
sl@0
|
541 |
|
sl@0
|
542 |
}
|
sl@0
|
543 |
|