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 |
#include "uloggerclient.h"
|
sl@0
|
17 |
#include "uloggershared.h"
|
sl@0
|
18 |
#include "uloggertools.h"
|
sl@0
|
19 |
#include "uloggercommands.h"
|
sl@0
|
20 |
#include <e32math.h>
|
sl@0
|
21 |
#include <e32base.h>
|
sl@0
|
22 |
#include <badesca.h>
|
sl@0
|
23 |
|
sl@0
|
24 |
|
sl@0
|
25 |
namespace Ulogger
|
sl@0
|
26 |
{
|
sl@0
|
27 |
//declarations
|
sl@0
|
28 |
|
sl@0
|
29 |
static const TUint KMessageSlots = 32;
|
sl@0
|
30 |
|
sl@0
|
31 |
///////////////////////////////////////////////////////////////////
|
sl@0
|
32 |
//
|
sl@0
|
33 |
// Definition of RULogger methods...
|
sl@0
|
34 |
//
|
sl@0
|
35 |
///////////////////////////////////////////////////////////////////
|
sl@0
|
36 |
|
sl@0
|
37 |
//constructor
|
sl@0
|
38 |
EXPORT_C RULogger::RULogger()
|
sl@0
|
39 |
{
|
sl@0
|
40 |
|
sl@0
|
41 |
}//</constructor>
|
sl@0
|
42 |
|
sl@0
|
43 |
//destructor
|
sl@0
|
44 |
EXPORT_C RULogger::~RULogger()
|
sl@0
|
45 |
{
|
sl@0
|
46 |
Close();
|
sl@0
|
47 |
}//</destructor>
|
sl@0
|
48 |
|
sl@0
|
49 |
EXPORT_C TInt RULogger::Connect()
|
sl@0
|
50 |
{
|
sl@0
|
51 |
TInt retVal = StartServer();
|
sl@0
|
52 |
|
sl@0
|
53 |
if((KErrNone == retVal) || (KErrAlreadyExists == retVal))
|
sl@0
|
54 |
{
|
sl@0
|
55 |
retVal = CreateSession(KServerName, this->Version(), KMessageSlots);
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
return retVal;
|
sl@0
|
59 |
}
|
sl@0
|
60 |
|
sl@0
|
61 |
EXPORT_C TInt RULogger::RunAsService(TBool /*aRunAsService*/)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
TInt retVal;
|
sl@0
|
64 |
|
sl@0
|
65 |
retVal = KErrNotSupported; // Replace with SendReceive call once functionality implemented in server
|
sl@0
|
66 |
//
|
sl@0
|
67 |
// // Replace above with following, once functionality implemented in server:
|
sl@0
|
68 |
//
|
sl@0
|
69 |
// if (aRunAsService)
|
sl@0
|
70 |
// retVal = SendReceive(ERunAsService);
|
sl@0
|
71 |
// else
|
sl@0
|
72 |
// retVal = SendReceive(EDontRunAsService);
|
sl@0
|
73 |
//
|
sl@0
|
74 |
|
sl@0
|
75 |
return retVal;
|
sl@0
|
76 |
}
|
sl@0
|
77 |
|
sl@0
|
78 |
EXPORT_C TInt RULogger::Start()
|
sl@0
|
79 |
{
|
sl@0
|
80 |
return SendReceive(EStart);
|
sl@0
|
81 |
}
|
sl@0
|
82 |
|
sl@0
|
83 |
EXPORT_C TInt RULogger::Stop()
|
sl@0
|
84 |
{
|
sl@0
|
85 |
return SendReceive(EStop);
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
EXPORT_C TInt RULogger::Restart()
|
sl@0
|
89 |
{
|
sl@0
|
90 |
return SendReceive(ERestart);
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
EXPORT_C TInt RULogger::SetPrimaryFiltersEnabled(const CArrayFixFlat<TUint8>& aFilters, TBool aEnabled)
|
sl@0
|
94 |
{
|
sl@0
|
95 |
TInt retVal = KErrNone;
|
sl@0
|
96 |
|
sl@0
|
97 |
//externalize filters array to string to send it in either a
|
sl@0
|
98 |
//ESetPrimaryFilter or ERemovePrimaryFilter message, but only if at least
|
sl@0
|
99 |
//one filter was actually specified in the filters array
|
sl@0
|
100 |
if(aFilters.Count())
|
sl@0
|
101 |
{
|
sl@0
|
102 |
//prepare data to send
|
sl@0
|
103 |
HBufC8 *des = NULL;
|
sl@0
|
104 |
TRAP(retVal, des = ExternalizeToBufL((const CArrayFix<TUint8>&) aFilters, sizeof(TUint8)));
|
sl@0
|
105 |
if(KErrNone == retVal)
|
sl@0
|
106 |
{
|
sl@0
|
107 |
//send data
|
sl@0
|
108 |
TPtr8 dataPtr(des->Des());
|
sl@0
|
109 |
TIpcArgs args(&dataPtr, aFilters.Count());
|
sl@0
|
110 |
if (aEnabled)
|
sl@0
|
111 |
retVal = SendReceive(ESetPrimaryFilter, args);
|
sl@0
|
112 |
else
|
sl@0
|
113 |
retVal = SendReceive(ERemovePrimaryFilter, args);
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
delete des;
|
sl@0
|
117 |
}
|
sl@0
|
118 |
else
|
sl@0
|
119 |
retVal = KErrArgument;
|
sl@0
|
120 |
|
sl@0
|
121 |
/**r
|
sl@0
|
122 |
if(retVal == KErrAlreadyExists)
|
sl@0
|
123 |
retVal = KErrNone;
|
sl@0
|
124 |
*/
|
sl@0
|
125 |
return retVal;
|
sl@0
|
126 |
}
|
sl@0
|
127 |
|
sl@0
|
128 |
EXPORT_C TInt RULogger::GetPrimaryFiltersEnabled(CArrayFixFlat<TUint8>& aFilters)
|
sl@0
|
129 |
{
|
sl@0
|
130 |
TInt retVal = KErrNone;
|
sl@0
|
131 |
|
sl@0
|
132 |
HBufC8 *buf = HBufC8::New(256);
|
sl@0
|
133 |
if(buf)
|
sl@0
|
134 |
{
|
sl@0
|
135 |
TPtr8 ptr(buf->Des());
|
sl@0
|
136 |
TIpcArgs args(&ptr);
|
sl@0
|
137 |
retVal = SendReceive(EGetPrimaryFilters, args);
|
sl@0
|
138 |
if (KErrNone == retVal)
|
sl@0
|
139 |
{
|
sl@0
|
140 |
TUint8 tmp = 1;
|
sl@0
|
141 |
TRAP(retVal, InternalizeFromBufL(*buf, aFilters, tmp));
|
sl@0
|
142 |
}
|
sl@0
|
143 |
|
sl@0
|
144 |
delete buf;
|
sl@0
|
145 |
buf = NULL;
|
sl@0
|
146 |
}
|
sl@0
|
147 |
else
|
sl@0
|
148 |
{
|
sl@0
|
149 |
return KErrNoMemory;
|
sl@0
|
150 |
}
|
sl@0
|
151 |
|
sl@0
|
152 |
return retVal;
|
sl@0
|
153 |
}
|
sl@0
|
154 |
|
sl@0
|
155 |
EXPORT_C TInt RULogger::SetSecondaryFiltersEnabled(const RArray<TUint32>& aFilters, TBool aEnabled)
|
sl@0
|
156 |
{
|
sl@0
|
157 |
TInt retVal = KErrNone;
|
sl@0
|
158 |
|
sl@0
|
159 |
//ensure max secondary filters limit isn't exceeded, otherwise return error
|
sl@0
|
160 |
if (aFilters.Count() > KMaxSecondaryFiltersLimit)
|
sl@0
|
161 |
{
|
sl@0
|
162 |
retVal = KErrArgument;
|
sl@0
|
163 |
}
|
sl@0
|
164 |
else
|
sl@0
|
165 |
{
|
sl@0
|
166 |
//externalize filters array to string to send it in either a
|
sl@0
|
167 |
//ESetSecondaryFilter or ERemoveSecondaryFilter message, but only if at least
|
sl@0
|
168 |
//one filter was actually specified in the filters array
|
sl@0
|
169 |
if(aFilters.Count())
|
sl@0
|
170 |
{
|
sl@0
|
171 |
//prepare data to send
|
sl@0
|
172 |
HBufC8 *des = NULL;
|
sl@0
|
173 |
|
sl@0
|
174 |
TRAP(retVal, des = ExternalizeToBufL(aFilters, sizeof(TUint32)));
|
sl@0
|
175 |
if(KErrNone == retVal)
|
sl@0
|
176 |
{
|
sl@0
|
177 |
//send data
|
sl@0
|
178 |
TPtr8 dataPtr(des->Des());
|
sl@0
|
179 |
TIpcArgs args(&dataPtr, aFilters.Count());
|
sl@0
|
180 |
if (aEnabled)
|
sl@0
|
181 |
retVal = SendReceive(ESetSecondaryFilter, args);
|
sl@0
|
182 |
else
|
sl@0
|
183 |
retVal = SendReceive(ERemoveSecondaryFilter, args);
|
sl@0
|
184 |
}
|
sl@0
|
185 |
|
sl@0
|
186 |
//clean up string if necessary
|
sl@0
|
187 |
delete des;
|
sl@0
|
188 |
}
|
sl@0
|
189 |
else
|
sl@0
|
190 |
retVal = KErrArgument;
|
sl@0
|
191 |
}
|
sl@0
|
192 |
|
sl@0
|
193 |
return retVal;
|
sl@0
|
194 |
}
|
sl@0
|
195 |
|
sl@0
|
196 |
EXPORT_C TInt RULogger::GetSecondaryFiltersEnabled(RArray<TUint32>& aFilters)
|
sl@0
|
197 |
{
|
sl@0
|
198 |
TInt retVal = KErrNone;
|
sl@0
|
199 |
|
sl@0
|
200 |
HBufC8 *buf = HBufC8::New(KMaxSecondaryFiltersLimit*sizeof(TUint32));
|
sl@0
|
201 |
if(buf)
|
sl@0
|
202 |
{
|
sl@0
|
203 |
TPtr8 ptr(buf->Des());
|
sl@0
|
204 |
TIpcArgs args(&ptr);
|
sl@0
|
205 |
retVal = SendReceive(EGetSecondaryFilters, args);
|
sl@0
|
206 |
if(KErrNone == retVal)
|
sl@0
|
207 |
{
|
sl@0
|
208 |
TUint32 tmp=1;
|
sl@0
|
209 |
TRAP(retVal, InternalizeFromBufL(*buf, aFilters, tmp));
|
sl@0
|
210 |
}
|
sl@0
|
211 |
|
sl@0
|
212 |
delete buf;
|
sl@0
|
213 |
buf = NULL;
|
sl@0
|
214 |
}
|
sl@0
|
215 |
else
|
sl@0
|
216 |
{
|
sl@0
|
217 |
retVal = KErrNoMemory;
|
sl@0
|
218 |
}
|
sl@0
|
219 |
|
sl@0
|
220 |
return retVal;
|
sl@0
|
221 |
}
|
sl@0
|
222 |
|
sl@0
|
223 |
EXPORT_C TInt RULogger::SetSecondaryFilteringEnabled(TBool aEnabled)
|
sl@0
|
224 |
{
|
sl@0
|
225 |
TInt retVal;
|
sl@0
|
226 |
|
sl@0
|
227 |
if (aEnabled)
|
sl@0
|
228 |
retVal = SendReceive(EEnableSecondaryFiltering);
|
sl@0
|
229 |
else
|
sl@0
|
230 |
retVal = SendReceive(EDisableSecondaryFiltering);
|
sl@0
|
231 |
|
sl@0
|
232 |
return retVal;
|
sl@0
|
233 |
}
|
sl@0
|
234 |
|
sl@0
|
235 |
EXPORT_C TInt RULogger::GetSecondaryFilteringEnabled(TBool& aEnabled)
|
sl@0
|
236 |
{
|
sl@0
|
237 |
//this code is a copy of GetModuleUidFiltering && GetBuffer && Notification etc etc....
|
sl@0
|
238 |
//should put all of it in a separate method...
|
sl@0
|
239 |
TInt retVal = KErrNone;
|
sl@0
|
240 |
|
sl@0
|
241 |
HBufC8 *buf = HBufC8::New(200);
|
sl@0
|
242 |
if(buf)
|
sl@0
|
243 |
{
|
sl@0
|
244 |
//send request to server
|
sl@0
|
245 |
TPtr8 ptr(buf->Des());
|
sl@0
|
246 |
TIpcArgs args(&ptr);
|
sl@0
|
247 |
retVal = SendReceive(EGetSecondaryFiltering, args);
|
sl@0
|
248 |
|
sl@0
|
249 |
if(!retVal)
|
sl@0
|
250 |
{
|
sl@0
|
251 |
TLex8 val(ptr);
|
sl@0
|
252 |
retVal = val.Val(aEnabled);
|
sl@0
|
253 |
}
|
sl@0
|
254 |
delete buf;
|
sl@0
|
255 |
buf = NULL;
|
sl@0
|
256 |
}
|
sl@0
|
257 |
else
|
sl@0
|
258 |
{
|
sl@0
|
259 |
retVal = KErrNoMemory;
|
sl@0
|
260 |
}
|
sl@0
|
261 |
|
sl@0
|
262 |
return retVal;
|
sl@0
|
263 |
}
|
sl@0
|
264 |
|
sl@0
|
265 |
EXPORT_C TInt RULogger::ActivateOutputPlugin(const TDesC8& aPluginName)
|
sl@0
|
266 |
{
|
sl@0
|
267 |
TIpcArgs iArgs; //Ipc arguments
|
sl@0
|
268 |
iArgs.Set(0, &aPluginName);
|
sl@0
|
269 |
return SendReceive(ESetActivePlugin, iArgs);
|
sl@0
|
270 |
}
|
sl@0
|
271 |
|
sl@0
|
272 |
EXPORT_C TInt RULogger::GetActiveOutputPlugin(TDes8& aPluginName)
|
sl@0
|
273 |
{
|
sl@0
|
274 |
TInt retVal = KErrNone;
|
sl@0
|
275 |
|
sl@0
|
276 |
HBufC8 *buf = HBufC8::New(2048); // Need to push on stack in that case
|
sl@0
|
277 |
// does it matter if its 8 or 16 buf?
|
sl@0
|
278 |
if(buf)
|
sl@0
|
279 |
{
|
sl@0
|
280 |
//send get active output plug-in message
|
sl@0
|
281 |
TPtr8 ptr(buf->Des());
|
sl@0
|
282 |
TIpcArgs args;
|
sl@0
|
283 |
args.Set(0, &ptr);
|
sl@0
|
284 |
retVal = SendReceive(EGetActivePlugin, args);
|
sl@0
|
285 |
|
sl@0
|
286 |
//parse response buffer
|
sl@0
|
287 |
TInt pos = 0;
|
sl@0
|
288 |
if(pos != KErrNotFound)
|
sl@0
|
289 |
{
|
sl@0
|
290 |
pos = buf->Des().Find(KSeparator); // Find separator
|
sl@0
|
291 |
//just don't send the separator?
|
sl@0
|
292 |
if(pos >= 0)
|
sl@0
|
293 |
{
|
sl@0
|
294 |
TPtrC8 ptrVal(buf->Des().Left(pos));
|
sl@0
|
295 |
if (aPluginName.MaxLength() < pos)
|
sl@0
|
296 |
retVal = KErrOverflow;
|
sl@0
|
297 |
else
|
sl@0
|
298 |
aPluginName.Copy(ptrVal);
|
sl@0
|
299 |
}
|
sl@0
|
300 |
}
|
sl@0
|
301 |
|
sl@0
|
302 |
delete buf;
|
sl@0
|
303 |
buf = NULL;
|
sl@0
|
304 |
}
|
sl@0
|
305 |
else
|
sl@0
|
306 |
{
|
sl@0
|
307 |
retVal = KErrNoMemory;
|
sl@0
|
308 |
}
|
sl@0
|
309 |
|
sl@0
|
310 |
return retVal;
|
sl@0
|
311 |
}
|
sl@0
|
312 |
|
sl@0
|
313 |
EXPORT_C TInt RULogger::GetInstalledOutputPlugins(CArrayPtrFlat<HBufC8>& aPluginNames)
|
sl@0
|
314 |
{
|
sl@0
|
315 |
TInt retVal = KErrNone;
|
sl@0
|
316 |
|
sl@0
|
317 |
HBufC8 *buf = HBufC8::New(2048);
|
sl@0
|
318 |
if(buf)
|
sl@0
|
319 |
{
|
sl@0
|
320 |
TPtr8 ptr(buf->Des());
|
sl@0
|
321 |
TIpcArgs args;
|
sl@0
|
322 |
args.Set(0, &ptr);
|
sl@0
|
323 |
retVal = SendReceive(EGetInstalledPlugins, args);
|
sl@0
|
324 |
|
sl@0
|
325 |
//parse buffer
|
sl@0
|
326 |
TInt pos = KErrNone;
|
sl@0
|
327 |
TInt err = KErrNone;
|
sl@0
|
328 |
while(pos != KErrNotFound)
|
sl@0
|
329 |
{
|
sl@0
|
330 |
pos = buf->Des().Find(KSeparator);
|
sl@0
|
331 |
if(pos > 0)
|
sl@0
|
332 |
{
|
sl@0
|
333 |
TPtrC8 ptrVal(buf->Des().Left(pos));
|
sl@0
|
334 |
HBufC8 *bufDes = HBufC8::New(ptrVal.Length()+8);
|
sl@0
|
335 |
if(bufDes)
|
sl@0
|
336 |
{
|
sl@0
|
337 |
bufDes->Des().Copy(ptrVal);
|
sl@0
|
338 |
TRAP(err, aPluginNames.AppendL(bufDes));
|
sl@0
|
339 |
}
|
sl@0
|
340 |
buf->Des().Delete(0,pos+1);
|
sl@0
|
341 |
}
|
sl@0
|
342 |
}
|
sl@0
|
343 |
|
sl@0
|
344 |
delete buf;
|
sl@0
|
345 |
buf = NULL;
|
sl@0
|
346 |
}
|
sl@0
|
347 |
|
sl@0
|
348 |
return retVal;
|
sl@0
|
349 |
}
|
sl@0
|
350 |
|
sl@0
|
351 |
EXPORT_C TInt RULogger::ActivateInputPlugin(const TDesC8& aPluginName)
|
sl@0
|
352 |
{
|
sl@0
|
353 |
TIpcArgs iArgs;
|
sl@0
|
354 |
iArgs.Set(0, &aPluginName);
|
sl@0
|
355 |
return SendReceive(ESetActiveInputPlugin, iArgs);
|
sl@0
|
356 |
}
|
sl@0
|
357 |
|
sl@0
|
358 |
EXPORT_C TInt RULogger::GetActiveInputPlugin(TDes8& aPluginName)
|
sl@0
|
359 |
{
|
sl@0
|
360 |
TInt retVal = KErrNone;
|
sl@0
|
361 |
|
sl@0
|
362 |
HBufC8 *buf = HBufC8::New(1024);// Push on stack in that case
|
sl@0
|
363 |
if(buf)
|
sl@0
|
364 |
{
|
sl@0
|
365 |
//send get active input plug-in message
|
sl@0
|
366 |
TPtr8 ptr(buf->Des());
|
sl@0
|
367 |
TIpcArgs args;
|
sl@0
|
368 |
args.Set(0, &ptr);
|
sl@0
|
369 |
retVal = SendReceive(EGetActiveInputPlugin, args);
|
sl@0
|
370 |
|
sl@0
|
371 |
//parse response buffer
|
sl@0
|
372 |
TInt pos = KErrNone;
|
sl@0
|
373 |
if(pos != KErrNotFound)
|
sl@0
|
374 |
{
|
sl@0
|
375 |
pos = buf->Des().Find(KSeparator);
|
sl@0
|
376 |
if(pos >= 0)
|
sl@0
|
377 |
{
|
sl@0
|
378 |
buf->Des().Delete(0, pos+1); // Get rid of media number + separator
|
sl@0
|
379 |
pos = buf->Des().Find(KSeparator); // Find separator after plug-in name
|
sl@0
|
380 |
|
sl@0
|
381 |
if(pos >= 0)
|
sl@0
|
382 |
{
|
sl@0
|
383 |
TPtrC8 ptrVal(buf->Des().Left(pos));
|
sl@0
|
384 |
if (aPluginName.MaxLength() < pos)
|
sl@0
|
385 |
retVal = KErrOverflow;
|
sl@0
|
386 |
else
|
sl@0
|
387 |
aPluginName.Copy(ptrVal);
|
sl@0
|
388 |
}
|
sl@0
|
389 |
}
|
sl@0
|
390 |
}
|
sl@0
|
391 |
|
sl@0
|
392 |
delete buf;
|
sl@0
|
393 |
buf = NULL;
|
sl@0
|
394 |
}
|
sl@0
|
395 |
else
|
sl@0
|
396 |
{
|
sl@0
|
397 |
retVal = KErrNoMemory;
|
sl@0
|
398 |
}
|
sl@0
|
399 |
|
sl@0
|
400 |
return retVal;
|
sl@0
|
401 |
}
|
sl@0
|
402 |
|
sl@0
|
403 |
EXPORT_C TInt RULogger::DeActivateInputPlugin()
|
sl@0
|
404 |
{
|
sl@0
|
405 |
TInt retVal = KErrNone;
|
sl@0
|
406 |
|
sl@0
|
407 |
//get currently active input plug-in name
|
sl@0
|
408 |
TBuf8<KMaxPath> activePluginName;
|
sl@0
|
409 |
retVal = GetActiveInputPlugin(activePluginName);
|
sl@0
|
410 |
|
sl@0
|
411 |
//deactivate currently active input plug-in
|
sl@0
|
412 |
if (KErrNone == retVal)
|
sl@0
|
413 |
{
|
sl@0
|
414 |
TIpcArgs iArgs;
|
sl@0
|
415 |
iArgs.Set(0, &activePluginName);
|
sl@0
|
416 |
retVal = SendReceive(EDeactivateInputPlugin, iArgs);
|
sl@0
|
417 |
}
|
sl@0
|
418 |
|
sl@0
|
419 |
return retVal;
|
sl@0
|
420 |
}
|
sl@0
|
421 |
|
sl@0
|
422 |
EXPORT_C TInt RULogger::GetInstalledInputPlugins(CArrayPtrFlat<HBufC8>& aPluginNames)
|
sl@0
|
423 |
{
|
sl@0
|
424 |
TInt retVal = KErrNone;
|
sl@0
|
425 |
|
sl@0
|
426 |
HBufC8 *buf = HBufC8::New(2048);//Push on stack in that case
|
sl@0
|
427 |
if(buf)
|
sl@0
|
428 |
{
|
sl@0
|
429 |
TPtr8 ptr(buf->Des());
|
sl@0
|
430 |
TIpcArgs args;
|
sl@0
|
431 |
args.Set(0, &ptr);
|
sl@0
|
432 |
retVal = SendReceive(EGetInputPlugins, args);
|
sl@0
|
433 |
|
sl@0
|
434 |
//parse buffer
|
sl@0
|
435 |
TInt pos = KErrNone;
|
sl@0
|
436 |
TInt err = KErrNone;
|
sl@0
|
437 |
while(pos != KErrNotFound)
|
sl@0
|
438 |
{
|
sl@0
|
439 |
pos = buf->Des().Find(KSeparator);
|
sl@0
|
440 |
if(pos > 0)
|
sl@0
|
441 |
{
|
sl@0
|
442 |
TPtrC8 ptrVal(buf->Des().Left(pos));
|
sl@0
|
443 |
HBufC8 *bufDes = HBufC8::New(ptrVal.Length()+8);//push on stack
|
sl@0
|
444 |
if(bufDes)
|
sl@0
|
445 |
{
|
sl@0
|
446 |
bufDes->Des().Copy(ptrVal);
|
sl@0
|
447 |
TRAP(err, aPluginNames.AppendL(bufDes));
|
sl@0
|
448 |
}
|
sl@0
|
449 |
buf->Des().Delete(0,pos+1);
|
sl@0
|
450 |
}
|
sl@0
|
451 |
}
|
sl@0
|
452 |
|
sl@0
|
453 |
delete buf;
|
sl@0
|
454 |
buf = NULL;
|
sl@0
|
455 |
}
|
sl@0
|
456 |
|
sl@0
|
457 |
return retVal;
|
sl@0
|
458 |
}
|
sl@0
|
459 |
|
sl@0
|
460 |
EXPORT_C TInt RULogger::SetPluginConfigurations(const TDesC8& aPluginName, const TPluginConfiguration& aConfiguration)
|
sl@0
|
461 |
{
|
sl@0
|
462 |
TInt retVal = KErrNone;
|
sl@0
|
463 |
|
sl@0
|
464 |
if(aConfiguration.Key().Length()==0||aConfiguration.Value().Length()==0)
|
sl@0
|
465 |
return KErrArgument;
|
sl@0
|
466 |
|
sl@0
|
467 |
//count total_length + separators
|
sl@0
|
468 |
TInt length = 1;
|
sl@0
|
469 |
length+=aConfiguration.Key().Length()+aConfiguration.Value().Length()+2;
|
sl@0
|
470 |
|
sl@0
|
471 |
HBufC *configs = HBufC::New(length);// Push on stack in that case
|
sl@0
|
472 |
if(configs)
|
sl@0
|
473 |
{
|
sl@0
|
474 |
TPtr formatConfigs(configs->Des());
|
sl@0
|
475 |
formatConfigs.AppendFormat(KConfigFormat, &(aConfiguration.Key()), &(aConfiguration.Value()));
|
sl@0
|
476 |
HBufC8 *settings= HBufC8::NewLC(configs->Length());//Push on stack in that case
|
sl@0
|
477 |
if(settings)
|
sl@0
|
478 |
{
|
sl@0
|
479 |
settings->Des().Copy(configs->Des());
|
sl@0
|
480 |
TPtr8 arg2(settings->Des());
|
sl@0
|
481 |
|
sl@0
|
482 |
TIpcArgs args; //Ipc arguments
|
sl@0
|
483 |
args.Set(0, &aPluginName);
|
sl@0
|
484 |
args.Set(1, &arg2);
|
sl@0
|
485 |
retVal = SendReceive(ESetPluginSettings,args);
|
sl@0
|
486 |
CleanupStack::PopAndDestroy(settings);
|
sl@0
|
487 |
}
|
sl@0
|
488 |
else
|
sl@0
|
489 |
return KErrNoMemory;
|
sl@0
|
490 |
|
sl@0
|
491 |
delete configs;
|
sl@0
|
492 |
}
|
sl@0
|
493 |
else
|
sl@0
|
494 |
return KErrNoMemory;
|
sl@0
|
495 |
|
sl@0
|
496 |
return retVal;
|
sl@0
|
497 |
}
|
sl@0
|
498 |
|
sl@0
|
499 |
EXPORT_C TInt RULogger::GetPluginConfigurations(const TDesC8& aPluginName, RPointerArray<TPluginConfiguration>& aConfigurations)
|
sl@0
|
500 |
{
|
sl@0
|
501 |
TInt retVal = KErrNone;
|
sl@0
|
502 |
|
sl@0
|
503 |
HBufC8 *buf = HBufC8::New(2048);//Push on stack in that case
|
sl@0
|
504 |
if(buf)
|
sl@0
|
505 |
{
|
sl@0
|
506 |
TPtr8 ptr(buf->Des());
|
sl@0
|
507 |
HBufC8 *mediaBuf = HBufC8::New(1+aPluginName.Length());// push on stack if we need to alloc this. Don't hardcode!!
|
sl@0
|
508 |
if(mediaBuf)
|
sl@0
|
509 |
{
|
sl@0
|
510 |
mediaBuf->Des().Copy(aPluginName);
|
sl@0
|
511 |
TPtr8 mediaPtr(mediaBuf->Des());
|
sl@0
|
512 |
|
sl@0
|
513 |
//send data
|
sl@0
|
514 |
TIpcArgs args;
|
sl@0
|
515 |
args.Set(0, &mediaPtr);
|
sl@0
|
516 |
args.Set(1, &ptr);
|
sl@0
|
517 |
retVal = SendReceive(EGetPluginSettings, args);
|
sl@0
|
518 |
|
sl@0
|
519 |
//parse received buffer
|
sl@0
|
520 |
TInt pos = buf->Des().Find(KSeparator);
|
sl@0
|
521 |
while((pos != KErrNotFound) && (retVal == KErrNone))
|
sl@0
|
522 |
{
|
sl@0
|
523 |
TPluginConfiguration* pluginConfig = new TPluginConfiguration();// Push on stack in that case
|
sl@0
|
524 |
//memory leak? not always deleted?
|
sl@0
|
525 |
if (pluginConfig)
|
sl@0
|
526 |
{
|
sl@0
|
527 |
TPtrC8 ptrKey(buf->Des().Left(pos));
|
sl@0
|
528 |
pluginConfig->SetKey(ptrKey);
|
sl@0
|
529 |
buf->Des().Delete(0, pos+1);
|
sl@0
|
530 |
pos = buf->Des().Find(KSeparator);
|
sl@0
|
531 |
if (pos != KErrNotFound)
|
sl@0
|
532 |
{
|
sl@0
|
533 |
TPtrC8 ptrVal(buf->Des().Left(pos));
|
sl@0
|
534 |
pluginConfig->SetValue(ptrVal);
|
sl@0
|
535 |
buf->Des().Delete(0, pos+1);
|
sl@0
|
536 |
retVal = aConfigurations.Append(pluginConfig);
|
sl@0
|
537 |
}
|
sl@0
|
538 |
else
|
sl@0
|
539 |
{
|
sl@0
|
540 |
delete pluginConfig; // Ignore trailing key
|
sl@0
|
541 |
}
|
sl@0
|
542 |
}
|
sl@0
|
543 |
else
|
sl@0
|
544 |
{
|
sl@0
|
545 |
retVal = KErrNoMemory;
|
sl@0
|
546 |
}
|
sl@0
|
547 |
pos = buf->Des().Find(KSeparator);
|
sl@0
|
548 |
}
|
sl@0
|
549 |
|
sl@0
|
550 |
delete mediaBuf;
|
sl@0
|
551 |
mediaBuf = NULL;
|
sl@0
|
552 |
}
|
sl@0
|
553 |
else
|
sl@0
|
554 |
{
|
sl@0
|
555 |
retVal = KErrNoMemory;
|
sl@0
|
556 |
}
|
sl@0
|
557 |
|
sl@0
|
558 |
delete buf;
|
sl@0
|
559 |
buf = NULL;
|
sl@0
|
560 |
}
|
sl@0
|
561 |
else
|
sl@0
|
562 |
{
|
sl@0
|
563 |
retVal = KErrNoMemory;
|
sl@0
|
564 |
}
|
sl@0
|
565 |
|
sl@0
|
566 |
return retVal;
|
sl@0
|
567 |
}
|
sl@0
|
568 |
|
sl@0
|
569 |
EXPORT_C TInt RULogger::RemovePluginConfigurations(const TDesC8& aPluginName)
|
sl@0
|
570 |
{
|
sl@0
|
571 |
TInt retVal = KErrNone;
|
sl@0
|
572 |
HBufC8 *mediaBuf = HBufC8::New(1+aPluginName.Length());// Push on stack at least
|
sl@0
|
573 |
if(mediaBuf)
|
sl@0
|
574 |
{
|
sl@0
|
575 |
mediaBuf->Des().Copy(aPluginName);
|
sl@0
|
576 |
TPtr8 mediaPtr(mediaBuf->Des());
|
sl@0
|
577 |
|
sl@0
|
578 |
//send data
|
sl@0
|
579 |
TIpcArgs args;
|
sl@0
|
580 |
args.Set(0, &mediaPtr);
|
sl@0
|
581 |
retVal = SendReceive(ERemovePluginSettings, args);
|
sl@0
|
582 |
delete mediaBuf;
|
sl@0
|
583 |
mediaBuf = NULL;
|
sl@0
|
584 |
}
|
sl@0
|
585 |
else
|
sl@0
|
586 |
{
|
sl@0
|
587 |
retVal = KErrNoMemory;
|
sl@0
|
588 |
}
|
sl@0
|
589 |
|
sl@0
|
590 |
return retVal;
|
sl@0
|
591 |
}
|
sl@0
|
592 |
|
sl@0
|
593 |
EXPORT_C TInt RULogger::SetBufferSize(TInt aSize)
|
sl@0
|
594 |
{
|
sl@0
|
595 |
TInt retVal;
|
sl@0
|
596 |
|
sl@0
|
597 |
if( (aSize > KMaxBufferSize) || (aSize < 1) )
|
sl@0
|
598 |
{
|
sl@0
|
599 |
retVal = KErrArgument;
|
sl@0
|
600 |
}
|
sl@0
|
601 |
else
|
sl@0
|
602 |
{
|
sl@0
|
603 |
retVal = SendReceive(EResizeTraceBuffer, TIpcArgs(aSize));
|
sl@0
|
604 |
}
|
sl@0
|
605 |
|
sl@0
|
606 |
return retVal;
|
sl@0
|
607 |
}
|
sl@0
|
608 |
|
sl@0
|
609 |
EXPORT_C TInt RULogger::GetBufferSize(TInt& aSize)
|
sl@0
|
610 |
{
|
sl@0
|
611 |
TInt retVal = KErrNone;
|
sl@0
|
612 |
|
sl@0
|
613 |
HBufC8 *buf = HBufC8::New(32);// push on stack if we need to alloc this. Don't hardcode!!
|
sl@0
|
614 |
if(buf)
|
sl@0
|
615 |
{
|
sl@0
|
616 |
TPtr8 ptr(buf->Des());
|
sl@0
|
617 |
TIpcArgs args(&ptr);
|
sl@0
|
618 |
retVal = SendReceive(EGetTraceBufferSize,args);
|
sl@0
|
619 |
if(retVal == KErrNone )
|
sl@0
|
620 |
{
|
sl@0
|
621 |
TLex8 val(ptr);
|
sl@0
|
622 |
retVal = val.Val(aSize);
|
sl@0
|
623 |
}
|
sl@0
|
624 |
delete buf;
|
sl@0
|
625 |
buf = NULL;
|
sl@0
|
626 |
}
|
sl@0
|
627 |
else
|
sl@0
|
628 |
return KErrNoMemory;
|
sl@0
|
629 |
|
sl@0
|
630 |
return retVal;
|
sl@0
|
631 |
}
|
sl@0
|
632 |
|
sl@0
|
633 |
EXPORT_C TInt RULogger::SetNotificationSize(TInt aSize)
|
sl@0
|
634 |
{
|
sl@0
|
635 |
TInt retVal;
|
sl@0
|
636 |
|
sl@0
|
637 |
if( (aSize > KMaxBufferSize) || (aSize < 0) )
|
sl@0
|
638 |
{
|
sl@0
|
639 |
retVal = KErrArgument;
|
sl@0
|
640 |
}
|
sl@0
|
641 |
else
|
sl@0
|
642 |
{
|
sl@0
|
643 |
retVal = SendReceive(ESetDataNotificationSize, TIpcArgs(aSize));
|
sl@0
|
644 |
}
|
sl@0
|
645 |
|
sl@0
|
646 |
return retVal;
|
sl@0
|
647 |
}
|
sl@0
|
648 |
|
sl@0
|
649 |
EXPORT_C TInt RULogger::GetNotificationSize(TInt& aSize)
|
sl@0
|
650 |
{
|
sl@0
|
651 |
TInt retVal = KErrNone;
|
sl@0
|
652 |
|
sl@0
|
653 |
HBufC8 *buf = HBufC8::New(32);// push on stack if we need to alloc this. Don't hardcode!!
|
sl@0
|
654 |
if(buf)
|
sl@0
|
655 |
{
|
sl@0
|
656 |
TPtr8 ptr(buf->Des());
|
sl@0
|
657 |
TIpcArgs args(&ptr);
|
sl@0
|
658 |
retVal = SendReceive(EGetDataNotificationSize,args);
|
sl@0
|
659 |
if(retVal == KErrNone )
|
sl@0
|
660 |
{
|
sl@0
|
661 |
TLex8 val(ptr);
|
sl@0
|
662 |
retVal = val.Val(aSize);
|
sl@0
|
663 |
}
|
sl@0
|
664 |
delete buf;
|
sl@0
|
665 |
buf = NULL;
|
sl@0
|
666 |
}
|
sl@0
|
667 |
else
|
sl@0
|
668 |
{
|
sl@0
|
669 |
retVal = KErrNoMemory;
|
sl@0
|
670 |
}
|
sl@0
|
671 |
|
sl@0
|
672 |
return retVal;
|
sl@0
|
673 |
}
|
sl@0
|
674 |
|
sl@0
|
675 |
EXPORT_C TInt RULogger::SetBufferMode(TInt aMode)
|
sl@0
|
676 |
{
|
sl@0
|
677 |
TInt retVal;
|
sl@0
|
678 |
|
sl@0
|
679 |
if( (aMode == EStraightBuffer) || (aMode==ECircularBuffer) )
|
sl@0
|
680 |
{
|
sl@0
|
681 |
retVal = SendReceive(ESetBufferMode, TIpcArgs(aMode));
|
sl@0
|
682 |
}
|
sl@0
|
683 |
else
|
sl@0
|
684 |
{
|
sl@0
|
685 |
retVal = KErrArgument;
|
sl@0
|
686 |
}
|
sl@0
|
687 |
|
sl@0
|
688 |
return retVal;
|
sl@0
|
689 |
}
|
sl@0
|
690 |
|
sl@0
|
691 |
EXPORT_C TInt RULogger::GetBufferMode(TInt& aMode)
|
sl@0
|
692 |
{
|
sl@0
|
693 |
TInt retVal = KErrNone;
|
sl@0
|
694 |
|
sl@0
|
695 |
HBufC8 *buf = HBufC8::New(32);// push on stack if we need to alloc this. Don't hardcode!!
|
sl@0
|
696 |
if(buf)
|
sl@0
|
697 |
{
|
sl@0
|
698 |
TPtr8 ptr(buf->Des());
|
sl@0
|
699 |
TIpcArgs args(&ptr);
|
sl@0
|
700 |
retVal = SendReceive(EGetBufferMode,args);
|
sl@0
|
701 |
if(retVal == KErrNone)
|
sl@0
|
702 |
{
|
sl@0
|
703 |
TLex8 val(ptr);
|
sl@0
|
704 |
retVal = val.Val(aMode);
|
sl@0
|
705 |
}
|
sl@0
|
706 |
delete buf;
|
sl@0
|
707 |
buf = NULL;
|
sl@0
|
708 |
}
|
sl@0
|
709 |
else
|
sl@0
|
710 |
{
|
sl@0
|
711 |
retVal = KErrNoMemory;
|
sl@0
|
712 |
}
|
sl@0
|
713 |
|
sl@0
|
714 |
return retVal;
|
sl@0
|
715 |
}
|
sl@0
|
716 |
|
sl@0
|
717 |
EXPORT_C TVersion RULogger::Version()
|
sl@0
|
718 |
{
|
sl@0
|
719 |
return TVersion(KULoggerSrvMajorVersionNumber,KULoggerSrvMinorVersionNumber,KULoggerSrvBuildVersionNumber);
|
sl@0
|
720 |
}
|
sl@0
|
721 |
|
sl@0
|
722 |
/**
|
sl@0
|
723 |
Internal Function - Starts the server
|
sl@0
|
724 |
*/
|
sl@0
|
725 |
TInt RULogger::StartServer()
|
sl@0
|
726 |
{
|
sl@0
|
727 |
TInt retVal = KErrNone;
|
sl@0
|
728 |
|
sl@0
|
729 |
TFullName serverName;
|
sl@0
|
730 |
TFindServer serverFinder(KServerName);
|
sl@0
|
731 |
retVal = serverFinder.Next(serverName);
|
sl@0
|
732 |
if(KErrNone == retVal)
|
sl@0
|
733 |
{
|
sl@0
|
734 |
retVal = KErrAlreadyExists;
|
sl@0
|
735 |
}
|
sl@0
|
736 |
else
|
sl@0
|
737 |
{
|
sl@0
|
738 |
//RProcess
|
sl@0
|
739 |
RProcess server;
|
sl@0
|
740 |
retVal = server.Create(KServerName, _L(""), EOwnerProcess);
|
sl@0
|
741 |
if(KErrNone == retVal)
|
sl@0
|
742 |
{
|
sl@0
|
743 |
// Synchronise with the server
|
sl@0
|
744 |
TRequestStatus reqStatus;
|
sl@0
|
745 |
server.Rendezvous(reqStatus);
|
sl@0
|
746 |
|
sl@0
|
747 |
// Start the test harness
|
sl@0
|
748 |
server.Resume();
|
sl@0
|
749 |
// Server will call the reciprocal static synchronise call
|
sl@0
|
750 |
User::WaitForRequest(reqStatus);
|
sl@0
|
751 |
server.Close();
|
sl@0
|
752 |
retVal = reqStatus.Int();
|
sl@0
|
753 |
}
|
sl@0
|
754 |
}
|
sl@0
|
755 |
|
sl@0
|
756 |
return retVal;
|
sl@0
|
757 |
}//</StartServer>
|
sl@0
|
758 |
|
sl@0
|
759 |
} // namespace
|