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