|
1 /* |
|
2 * Copyright (c) 2005,2006 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: Mediator logging services implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifdef _DEBUG |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <barsread.h> |
|
24 #include <barsc.h> |
|
25 #include <f32file.h> |
|
26 #include <flogger.h> |
|
27 #include <MediatorDebug.rsg> |
|
28 #include "MediatorServerObjectHandler.h" |
|
29 #include "MediatorServer.h" |
|
30 #include "MediatorDebug.h" |
|
31 #include "MediatorServerCommandHandler.h" |
|
32 #include "MediatorServerPluginHandler.h" |
|
33 #include "MediatorServerSession.h" |
|
34 |
|
35 // CONSTANTS |
|
36 _LIT( KMediatorDbgResPath, "z:\\resource\\MediatorDebug.rsc"); |
|
37 _LIT(KMediatorLogFolder, "mediator"); // this will go under c:\logs |
|
38 _LIT(KMediatorLogFolderFullPath, "c:\\logs\\mediator\\"); |
|
39 _LIT(KMediatorErrorFile, "error.txt"); |
|
40 _LIT(KMediatorPrintTag, "[Mediator] "); |
|
41 |
|
42 RMediatorDebug* RMediatorDebug::iInstance = NULL; |
|
43 |
|
44 |
|
45 // ============================ MEMBER FUNCTIONS =============================== |
|
46 // ----------------------------------------------------------------------------- |
|
47 // RMediatorDebug::RMediatorDebug |
|
48 // |
|
49 // (other items were commented in a header). |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 RMediatorDebug::RMediatorDebug() |
|
53 { |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // RMediatorDebug::ConstructL |
|
58 // |
|
59 // (other items were commented in a header). |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 void RMediatorDebug::ConstructL(CMediatorServer* aMediator) |
|
63 { |
|
64 __ASSERT_ALWAYS(aMediator, User::Panic(_L("Invalid mediator"), KErrNotFound)); |
|
65 |
|
66 iMediator = aMediator; |
|
67 |
|
68 // read settings from resource files |
|
69 RResourceFile resourceFile; |
|
70 RFs fsSession; |
|
71 |
|
72 User::LeaveIfError(fsSession.Connect()); |
|
73 CleanupClosePushL(fsSession); |
|
74 |
|
75 TFileName resourceFileName (KMediatorDbgResPath); |
|
76 resourceFile.OpenL(fsSession, resourceFileName); |
|
77 |
|
78 CleanupClosePushL(resourceFile); |
|
79 |
|
80 // Read the first resource |
|
81 HBufC8* res = resourceFile.AllocReadLC(DEBUG_CONF); |
|
82 TResourceReader theReader; |
|
83 theReader.SetBuffer(res); |
|
84 |
|
85 |
|
86 iDomainOptions = static_cast<EDebugLogMode>(theReader.ReadUint8()); |
|
87 |
|
88 |
|
89 TInt domainCount = theReader.ReadUint16(); |
|
90 |
|
91 // read domain UIDs |
|
92 TUid uid; |
|
93 |
|
94 for (TInt i = 0; i < domainCount; i++) |
|
95 { |
|
96 uid.iUid = theReader.ReadUint32(); |
|
97 iDomains.AppendL(uid); |
|
98 } |
|
99 |
|
100 |
|
101 iCategoryOptions = static_cast<EDebugLogMode>(theReader.ReadUint8()); |
|
102 |
|
103 TInt categoryCount = theReader.ReadUint16(); |
|
104 |
|
105 // read category UIDs |
|
106 for (TInt i = 0; i < categoryCount; i++) |
|
107 { |
|
108 uid.iUid = theReader.ReadUint32(); |
|
109 iDomains.AppendL(uid); |
|
110 } |
|
111 |
|
112 // read the generic options |
|
113 iOptions = theReader.ReadUint8(); |
|
114 |
|
115 // read output file |
|
116 TPtrC outFile = theReader.ReadTPtrC(); |
|
117 |
|
118 // if output file is specified, then file logging must also be done |
|
119 if (outFile.Length() != 0) |
|
120 { |
|
121 // create directory if it does not exist |
|
122 TInt err = fsSession.MkDir( KMediatorLogFolderFullPath ); |
|
123 |
|
124 if ( err != KErrNone && err != KErrAlreadyExists ) |
|
125 { |
|
126 User::Leave( err ); |
|
127 } |
|
128 |
|
129 // open and configure log |
|
130 User::LeaveIfError( iFileLogger.Connect() ); |
|
131 |
|
132 iFileLogger.CreateLog( KMediatorLogFolder, outFile, EFileLoggingModeAppend ); |
|
133 |
|
134 iFileLogger.SetDateAndTime( EFalse, ETrue ); |
|
135 } |
|
136 |
|
137 // Make print buffer ready. During normal operation tag is inserted in PrintL. |
|
138 iBuf.Append( KMediatorPrintTag ); |
|
139 |
|
140 CleanupStack::PopAndDestroy( res ); |
|
141 CleanupStack::PopAndDestroy( &resourceFile ); |
|
142 CleanupStack::PopAndDestroy( &fsSession ); |
|
143 |
|
144 PrintConfigurationL(); |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // RMediatorDebug::NewL |
|
149 // |
|
150 // (other items were commented in a header). |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 RMediatorDebug* RMediatorDebug::NewL(CMediatorServer* aMediator) |
|
154 { |
|
155 RMediatorDebug* self = new( ELeave ) RMediatorDebug; |
|
156 |
|
157 CleanupStack::PushL( self ); |
|
158 self->ConstructL(aMediator); |
|
159 CleanupStack::Pop( self ); |
|
160 |
|
161 return self; |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // RMediatorDebug::~RMediatorDebug |
|
166 // |
|
167 // (other items were commented in a header). |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 RMediatorDebug::~RMediatorDebug() |
|
171 { |
|
172 iDomains.Close(); |
|
173 iCategories.Close(); |
|
174 iFileLogger.CloseLog(); |
|
175 iFileLogger.Close(); |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // RMediatorDebug::ShouldPrintLogL |
|
180 // |
|
181 // (other items were commented in a header). |
|
182 // ----------------------------------------------------------------------------- |
|
183 // |
|
184 TBool RMediatorDebug::ShouldPrintLogL(const RMessage2& aMessage, CMediatorServerSession& aSession) |
|
185 { |
|
186 if (!(KLogEvents & iOptions) && aMessage.Function() == ERaiseEvent) |
|
187 { |
|
188 return EFalse; |
|
189 } |
|
190 |
|
191 if (!(KLogCommands & iOptions) && |
|
192 (aMessage.Function() == EIssueCommand || aMessage.Function() == EIssueResponse || aMessage.Function() == ECancelCommand)) |
|
193 { |
|
194 return EFalse; |
|
195 } |
|
196 |
|
197 TBool hasDomain = HasDomain( aMessage ); |
|
198 |
|
199 // check whether this domain should be logged |
|
200 if ( hasDomain && (iDomainOptions != ELogAll) ) |
|
201 { |
|
202 TMediatorCategory categ = aSession.ReadCategoryL(aMessage, 0); |
|
203 |
|
204 TInt idx = iDomains.Find(categ.iDomain); |
|
205 |
|
206 if ((idx == KErrNotFound && iDomainOptions == ELogInclusive) |
|
207 || (idx != KErrNotFound && iDomainOptions == ELogExclusive)) |
|
208 { |
|
209 return EFalse; |
|
210 } |
|
211 } |
|
212 else if ( !hasDomain && ( iDomainOptions == ELogInclusive ) ) |
|
213 { |
|
214 // If inclusive logging is specified, drop also domainless operations |
|
215 return EFalse; |
|
216 } |
|
217 |
|
218 TBool hasCategory = HasCategory( aMessage ); |
|
219 |
|
220 // check whether this category should be logged |
|
221 if ( hasCategory && (iCategoryOptions != ELogAll) ) |
|
222 { |
|
223 TMediatorCategory categ = aSession.ReadCategoryL(aMessage, 0); |
|
224 |
|
225 TInt idx = iCategories.Find(categ.iCategory); |
|
226 |
|
227 if ((idx == KErrNotFound && iCategoryOptions == ELogInclusive) |
|
228 || (idx != KErrNotFound && iCategoryOptions == ELogExclusive)) |
|
229 { |
|
230 return EFalse; |
|
231 } |
|
232 } |
|
233 else if ( !hasCategory && (iCategoryOptions == ELogInclusive) ) |
|
234 { |
|
235 // If inclusive logging is specified, drop also category-less operations |
|
236 return EFalse; |
|
237 } |
|
238 |
|
239 // all filters passed - log this |
|
240 return ETrue; |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // RMediatorDebug::OperationString |
|
245 // |
|
246 // (other items were commented in a header). |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 TPtrC RMediatorDebug::OperationString(TInt aOperation) |
|
250 { |
|
251 if (aOperation == ERegisterEventList) return TPtrC(_L("ERegisterEventList")); |
|
252 if (aOperation == ERegisterCommandList) return TPtrC(_L("ERegisterCommandList")); |
|
253 if (aOperation == EUnregisterEventList) return TPtrC(_L("EUnregisterEventList")); |
|
254 if (aOperation == EUnregisterCommandList) return TPtrC(_L("EUnregisterCommandList")); |
|
255 if (aOperation == ERaiseEvent) return TPtrC(_L("ERaiseEvent")); |
|
256 if (aOperation == ESubscribeEventList) return TPtrC(_L("ESubscribeEventList")); |
|
257 if (aOperation == EUnsubscribeEventList) return TPtrC(_L("EUnsubscribeEventList")); |
|
258 if (aOperation == EIssueCommand) return TPtrC(_L("EIssueCommand")); |
|
259 if (aOperation == ECancelCommand) return TPtrC(_L("ECancelCommand")); |
|
260 if (aOperation == EIssueResponse) return TPtrC(_L("EIssueResponse")); |
|
261 if (aOperation == EWaitForEvent) return TPtrC(_L("EWaitForEvent")); |
|
262 if (aOperation == EWaitForCommand) return TPtrC(_L("EWaitForCommand")); |
|
263 if (aOperation == EWaitForCommandResponse) return TPtrC(_L("EWaitForCommandResponse")); |
|
264 if (aOperation == EWaitForNotifications) return TPtrC(_L("EWaitForNotifications")); |
|
265 if (aOperation == ECancelNotifications) return TPtrC(_L("ECancelNotifications")); |
|
266 if (aOperation == EGetDomains) return TPtrC(_L("EGetDomains")); |
|
267 if (aOperation == EGetCategories) return TPtrC(_L("EGetCategories")); |
|
268 if (aOperation == EGetEvents) return TPtrC(_L("EGetEvents")); |
|
269 if (aOperation == EGetCommands) return TPtrC(_L("EGetCommands")); |
|
270 if (aOperation == EFetchParameterData) return TPtrC(_L("EFetchParameterData")); |
|
271 if (aOperation == ECancelAll) return TPtrC(_L("ECancelAll")); |
|
272 if (aOperation == EFetchNotificationEventList) return TPtrC(_L("EFetchNotificationEventList")); |
|
273 if (aOperation == EFetchNotificationCommandList) return TPtrC(_L("EFetchNotificationCommandList")); |
|
274 |
|
275 return TPtrC(_L("Unknown operation")); |
|
276 |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // RMediatorDebug::ErrorString |
|
281 // |
|
282 // (other items were commented in a header). |
|
283 // ----------------------------------------------------------------------------- |
|
284 // |
|
285 TPtrC RMediatorDebug::ErrorString(TInt aError) |
|
286 { |
|
287 // Mediator errors |
|
288 if (aError == KErrMediatorDomainNotFound) return TPtrC(_L("KErrMediatorDomainNotFound")); |
|
289 if (aError == KErrMediatorCategoryNotFound) return TPtrC(_L("KErrMediatorCategoryNotFound")); |
|
290 if (aError == KErrMediatorCommandNotFound) return TPtrC(_L("KErrMediatorCommandNotFound")); |
|
291 if (aError == KErrMediatorEventNotFound) return TPtrC(_L("KErrMediatorEventNotFound")); |
|
292 if (aError == KErrMediatorCommandAlreadyExists) return TPtrC(_L("KErrMediatorCommandAlreadyExists")); |
|
293 if (aError == KErrMediatorEventAlreadyExists) return TPtrC(_L("KErrMediatorEventAlreadyExists")); |
|
294 if (aError == KErrMediatorAlreadySubscribed) return TPtrC(_L("KErrMediatorAlreadySubscribed")); |
|
295 if (aError == KErrMediatorNoSubscription) return TPtrC(_L("KErrMediatorNoSubscription")); |
|
296 if (aError == KErrMediatorSecureIdMismatch) return TPtrC(_L("KErrMediatorSecureIdMismatch")); |
|
297 if (aError == KErrMediatorVersionMismatch) return TPtrC(_L("KErrMediatorVersionMismatch")); |
|
298 if (aError == KErrMediatorTimeout) return TPtrC(_L("KErrMediatorTimeout")); |
|
299 if (aError == KErrMediatorCommandRemoved) return TPtrC(_L("KErrMediatorCommandRemoved")); |
|
300 |
|
301 // Symbian standard errors |
|
302 if (aError == KErrNone) return TPtrC(_L("KErrNone")); |
|
303 if (aError == KErrNotFound) return TPtrC(_L("KErrNotFound")); |
|
304 if (aError == KErrGeneral) return TPtrC(_L("KErrGeneral")); |
|
305 if (aError == KErrCancel) return TPtrC(_L("KErrCancel")); |
|
306 if (aError == KErrNoMemory) return TPtrC(_L("KErrNoMemory")); |
|
307 if (aError == KErrNotSupported) return TPtrC(_L("KErrNotSupported")); |
|
308 if (aError == KErrArgument) return TPtrC(_L("KErrArgument")); |
|
309 if (aError == KErrTotalLossOfPrecision) return TPtrC(_L("KErrTotalLossOfPrecision")); |
|
310 if (aError == KErrBadHandle) return TPtrC(_L("KErrBadHandle")); |
|
311 if (aError == KErrOverflow) return TPtrC(_L("KErrOverflow")); |
|
312 if (aError == KErrUnderflow) return TPtrC(_L("KErrUnderflow")); |
|
313 if (aError == KErrAlreadyExists) return TPtrC(_L("KErrAlreadyExists")); |
|
314 if (aError == KErrPathNotFound) return TPtrC(_L("KErrPathNotFound")); |
|
315 if (aError == KErrDied) return TPtrC(_L("KErrDied")); |
|
316 if (aError == KErrInUse) return TPtrC(_L("KErrInUse")); |
|
317 if (aError == KErrServerTerminated) return TPtrC(_L("KErrServerTerminated")); |
|
318 if (aError == KErrServerBusy) return TPtrC(_L("KErrServerBusy")); |
|
319 if (aError == KErrCompletion) return TPtrC(_L("KErrCompletion")); |
|
320 if (aError == KErrNotReady) return TPtrC(_L("KErrNotReady")); |
|
321 if (aError == KErrUnknown) return TPtrC(_L("KErrMediatorDomainNotFound")); |
|
322 if (aError == KErrCorrupt) return TPtrC(_L("KErrCorrupt")); |
|
323 if (aError == KErrAccessDenied) return TPtrC(_L("KErrAccessDenied")); |
|
324 if (aError == KErrLocked) return TPtrC(_L("KErrLocked")); |
|
325 if (aError == KErrWrite) return TPtrC(_L("KErrWrite")); |
|
326 if (aError == KErrDisMounted) return TPtrC(_L("KErrMediatorDomainNotFound")); |
|
327 if (aError == KErrEof) return TPtrC(_L("KErrEof")); |
|
328 if (aError == KErrDiskFull) return TPtrC(_L("KErrDiskFull")); |
|
329 if (aError == KErrBadDriver) return TPtrC(_L("KErrBadDriver")); |
|
330 if (aError == KErrBadName) return TPtrC(_L("KErrBadName")); |
|
331 if (aError == KErrCommsLineFail) return TPtrC(_L("KErrCommsLineFail")); |
|
332 if (aError == KErrCommsFrame) return TPtrC(_L("KErrCommsFrame")); |
|
333 if (aError == KErrCommsOverrun) return TPtrC(_L("KErrCommsOverrun")); |
|
334 if (aError == KErrCommsParity) return TPtrC(_L("KErrCommsParity")); |
|
335 if (aError == KErrTimedOut) return TPtrC(_L("KErrTimedOut")); |
|
336 if (aError == KErrCouldNotConnect) return TPtrC(_L("KErrCouldNotConnect")); |
|
337 if (aError == KErrCouldNotDisconnect) return TPtrC(_L("KErrCouldNotDisconnect")); |
|
338 if (aError == KErrDisconnected) return TPtrC(_L("KErrDisconnected")); |
|
339 if (aError == KErrBadLibraryEntryPoint) return TPtrC(_L("KErrBadLibraryEntryPoint")); |
|
340 if (aError == KErrBadDescriptor) return TPtrC(_L("KErrBadDescr")); |
|
341 if (aError == KErrAbort) return TPtrC(_L("KErrAbort")); |
|
342 if (aError == KErrTooBig) return TPtrC(_L("KErrTooBig")); |
|
343 if (aError == KErrDivideByZero) return TPtrC(_L("KErrDivideByZero")); |
|
344 if (aError == KErrBadPower) return TPtrC(_L("KErrBadPower")); |
|
345 if (aError == KErrDirFull) return TPtrC(_L("KErrDirFull")); |
|
346 if (aError == KErrHardwareNotAvailable) return TPtrC(_L("KErrHardwareNotAvailable")); |
|
347 if (aError == KErrSessionClosed) return TPtrC(_L("KErrSessionClosed")); |
|
348 if (aError == KErrPermissionDenied) return TPtrC(_L("KErrPermissionDenied")); |
|
349 if (aError == KErrExtensionNotSupported) return TPtrC(_L("KErrExtensionNotSupported")); |
|
350 if (aError == KErrCommsBreak) return TPtrC(_L("KErrCommsBreak")); |
|
351 |
|
352 return TPtrC(_L("Unknown error")); |
|
353 } |
|
354 |
|
355 // ----------------------------------------------------------------------------- |
|
356 // RMediatorDebug::CapabilityString |
|
357 // |
|
358 // (other items were commented in a header). |
|
359 // ----------------------------------------------------------------------------- |
|
360 // |
|
361 TPtrC RMediatorDebug::CapabilityString( TCapability aCapability ) |
|
362 { |
|
363 |
|
364 if ( aCapability == ECapabilityTCB ) return TPtrC( _L("TCB") ); |
|
365 if ( aCapability == ECapabilityCommDD ) return TPtrC( _L("CDD") ); |
|
366 if ( aCapability == ECapabilityPowerMgmt ) return TPtrC( _L("PM") ); |
|
367 if ( aCapability == ECapabilityMultimediaDD ) return TPtrC( _L("MDD") ); |
|
368 if ( aCapability == ECapabilityReadDeviceData ) return TPtrC( _L("RDD") ); |
|
369 if ( aCapability == ECapabilityWriteDeviceData ) return TPtrC( _L("WDD") ); |
|
370 if ( aCapability == ECapabilityDRM ) return TPtrC( _L("DRM") ); |
|
371 if ( aCapability == ECapabilityTrustedUI ) return TPtrC( _L("TUI") ); |
|
372 if ( aCapability == ECapabilityProtServ ) return TPtrC( _L("PS") ); |
|
373 if ( aCapability == ECapabilityDiskAdmin ) return TPtrC( _L("DA") ); |
|
374 if ( aCapability == ECapabilityNetworkControl ) return TPtrC( _L("NC") ); |
|
375 if ( aCapability == ECapabilityAllFiles ) return TPtrC( _L("AF") ); |
|
376 if ( aCapability == ECapabilitySwEvent ) return TPtrC( _L("SE") ); |
|
377 if ( aCapability == ECapabilityNetworkServices ) return TPtrC( _L("NS") ); |
|
378 if ( aCapability == ECapabilityLocalServices ) return TPtrC( _L("LS") ); |
|
379 if ( aCapability == ECapabilityReadUserData ) return TPtrC( _L("RUD") ); |
|
380 if ( aCapability == ECapabilityWriteUserData ) return TPtrC( _L("WUD") ); |
|
381 if ( aCapability == ECapabilityLocation ) return TPtrC( _L("Loc") ); |
|
382 if ( aCapability == ECapabilitySurroundingsDD ) return TPtrC( _L("SDD") ); |
|
383 if ( aCapability == ECapabilityUserEnvironment ) return TPtrC( _L("UE") ); |
|
384 |
|
385 return TPtrC( _L("Unknown") ); // new capabilities declared in system |
|
386 } |
|
387 |
|
388 // ----------------------------------------------------------------------------- |
|
389 // RMediatorDebug::HasDomain |
|
390 // |
|
391 // (other items were commented in a header). |
|
392 // ----------------------------------------------------------------------------- |
|
393 // |
|
394 TBool RMediatorDebug::HasDomain(const RMessage2& aMessage) |
|
395 { |
|
396 switch (aMessage.Function()) |
|
397 { |
|
398 case ERegisterEventList: |
|
399 case ERegisterCommandList: |
|
400 case EUnregisterEventList: |
|
401 case EUnregisterCommandList: |
|
402 case ERaiseEvent: |
|
403 case ESubscribeEventList: |
|
404 case EUnsubscribeEventList: |
|
405 case EIssueCommand: |
|
406 case ECancelCommand: |
|
407 case EIssueResponse: |
|
408 case EGetEvents: |
|
409 case EGetCommands: |
|
410 case EGetCategories: |
|
411 return ETrue; |
|
412 |
|
413 default: |
|
414 case EWaitForEvent: |
|
415 case EWaitForCommand: |
|
416 case EWaitForCommandResponse: |
|
417 case EWaitForNotifications: |
|
418 case ECancelNotifications: |
|
419 case EGetDomains: |
|
420 case ECancelAll: |
|
421 case EFetchParameterData: |
|
422 case EFetchNotificationEventList: |
|
423 case EFetchNotificationCommandList: |
|
424 return EFalse; |
|
425 } |
|
426 } |
|
427 |
|
428 // ----------------------------------------------------------------------------- |
|
429 // RMediatorDebug::HasCategory |
|
430 // |
|
431 // (other items were commented in a header). |
|
432 // ----------------------------------------------------------------------------- |
|
433 // |
|
434 TBool RMediatorDebug::HasCategory(const RMessage2& aMessage) |
|
435 { |
|
436 switch (aMessage.Function()) |
|
437 { |
|
438 case ERegisterEventList: |
|
439 case ERegisterCommandList: |
|
440 case EUnregisterEventList: |
|
441 case EUnregisterCommandList: |
|
442 case ERaiseEvent: |
|
443 case ESubscribeEventList: |
|
444 case EUnsubscribeEventList: |
|
445 case EIssueCommand: |
|
446 case ECancelCommand: |
|
447 case EIssueResponse: |
|
448 case EGetEvents: |
|
449 case EGetCommands: |
|
450 return ETrue; |
|
451 |
|
452 default: |
|
453 case EGetCategories: |
|
454 case EWaitForEvent: |
|
455 case EWaitForCommand: |
|
456 case EWaitForCommandResponse: |
|
457 case EWaitForNotifications: |
|
458 case ECancelNotifications: |
|
459 case EGetDomains: |
|
460 case ECancelAll: |
|
461 case EFetchParameterData: |
|
462 case EFetchNotificationEventList: |
|
463 case EFetchNotificationCommandList: |
|
464 return EFalse; |
|
465 } |
|
466 } |
|
467 |
|
468 // ----------------------------------------------------------------------------- |
|
469 // RMediatorDebug::PrintOperationL |
|
470 // |
|
471 // (other items were commented in a header). |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 void RMediatorDebug::PrintOperationL(const RMessage2& aMessage, CMediatorServerSession& aSession) |
|
475 { |
|
476 |
|
477 if (!iInstance->ShouldPrintLogL(aMessage, aSession)) |
|
478 { |
|
479 return; |
|
480 } |
|
481 |
|
482 TPtrC opString = OperationString( aMessage.Function() ); |
|
483 iBuf.AppendFormat( _L("%S"), &iOf, &opString ); |
|
484 |
|
485 iBuf.AppendFormat(_L(" issued by 0x%08X(SID)"), &iOf, (TUint32)aMessage.SecureId()); |
|
486 |
|
487 if (HasDomain(aMessage)) |
|
488 { |
|
489 TMediatorCategory categ = aSession.ReadCategoryL(aMessage, 0); |
|
490 iBuf.AppendFormat(_L(" D:0x%08X"), &iOf, categ.iDomain); |
|
491 |
|
492 if (HasCategory(aMessage)) |
|
493 { |
|
494 iBuf.AppendFormat(_L(" C:0x%08X"), &iOf, categ.iCategory); |
|
495 } |
|
496 } |
|
497 |
|
498 PrintL(); |
|
499 } |
|
500 |
|
501 // ----------------------------------------------------------------------------- |
|
502 // RMediatorDebug::PrintPluginL |
|
503 // |
|
504 // (other items were commented in a header). |
|
505 // ----------------------------------------------------------------------------- |
|
506 // |
|
507 void RMediatorDebug::PrintPluginL(const CImplementationInformation* aImpl) |
|
508 { |
|
509 TPtrC implName( aImpl->DisplayName() ); |
|
510 |
|
511 iBuf.AppendFormat( _L("Loading plugin %S, UID=0x%08X"), &iOf, |
|
512 &implName, |
|
513 aImpl->ImplementationUid() ); |
|
514 |
|
515 PrintL(); |
|
516 } |
|
517 |
|
518 // ----------------------------------------------------------------------------- |
|
519 // RMediatorDebug::AppendCapabilitiesL |
|
520 // |
|
521 // (other items were commented in a header). |
|
522 // ----------------------------------------------------------------------------- |
|
523 // |
|
524 void RMediatorDebug::AppendCapabilitiesL( const TCapabilitySet& aCaps ) |
|
525 { |
|
526 TBool capsFound = EFalse; |
|
527 |
|
528 for ( TInt i = 0; i < ECapability_Limit; i++ ) |
|
529 { |
|
530 if ( aCaps.HasCapability( static_cast<TCapability>( i ) ) ) |
|
531 { |
|
532 TPtrC capName( CapabilityString( static_cast<TCapability>( i ) ) ); |
|
533 |
|
534 iBuf.AppendFormat( _L(" %S"), &iOf, &capName ); |
|
535 |
|
536 capsFound = ETrue; |
|
537 |
|
538 } |
|
539 } |
|
540 |
|
541 if ( !capsFound ) // no capabilities specified |
|
542 { |
|
543 _LIT( KTextNone, "None"); |
|
544 TPtrC textNone(KTextNone); |
|
545 iBuf.AppendFormat( _L("%S"), &iOf, &textNone ); |
|
546 } |
|
547 |
|
548 } |
|
549 |
|
550 // ----------------------------------------------------------------------------- |
|
551 // RMediatorDebug::PrintEventL |
|
552 // |
|
553 // (other items were commented in a header). |
|
554 // ----------------------------------------------------------------------------- |
|
555 // |
|
556 void RMediatorDebug::PrintEventL(const RMessage2& aMessage, CMediatorServerSession& aSession, const TEvent& aEvent, TInt aEventNmbr) |
|
557 { |
|
558 if (!iInstance->ShouldPrintLogL(aMessage, aSession)) |
|
559 { |
|
560 return; |
|
561 } |
|
562 |
|
563 iBuf.AppendFormat(_L("\tEVENT%03d ID:%d VER:%d.%d.%d CAPS:"), &iOf, aEventNmbr, aEvent.iEventId, |
|
564 aEvent.iVersion.iMajor, aEvent.iVersion.iMinor, aEvent.iVersion.iBuild); |
|
565 |
|
566 |
|
567 AppendCapabilitiesL( aEvent.iCaps ); |
|
568 |
|
569 PrintL(); |
|
570 |
|
571 } |
|
572 |
|
573 // ----------------------------------------------------------------------------- |
|
574 // RMediatorDebug::PrintEventListL |
|
575 // |
|
576 // (other items were commented in a header). |
|
577 // ----------------------------------------------------------------------------- |
|
578 // |
|
579 void RMediatorDebug::PrintEventListL(const RMessage2& aMessage, CMediatorServerSession& aSession, const REventList& aList) |
|
580 { |
|
581 if (!iInstance->ShouldPrintLogL(aMessage, aSession)) |
|
582 { |
|
583 return; |
|
584 } |
|
585 |
|
586 for( TInt i = 0; i < aList.Count(); i++) |
|
587 { |
|
588 PrintEventL(aMessage, aSession, aList[i], i); |
|
589 } |
|
590 } |
|
591 |
|
592 // ----------------------------------------------------------------------------- |
|
593 // RMediatorDebug::PrintCommandL |
|
594 // |
|
595 // (other items were commented in a header). |
|
596 // ----------------------------------------------------------------------------- |
|
597 // |
|
598 void RMediatorDebug::PrintCommandL(const RMessage2& aMessage, CMediatorServerSession& aSession, const TCommand& aCmd, TInt aCmdNmbr) |
|
599 { |
|
600 if (!iInstance->ShouldPrintLogL(aMessage, aSession)) |
|
601 { |
|
602 return; |
|
603 } |
|
604 |
|
605 iBuf.AppendFormat(_L("\tCMD%03d ID:%d VER:%d.%d.%d TOUT:%d CAPS:"), &iOf, aCmdNmbr, aCmd.iCommandId, |
|
606 aCmd.iVersion.iMajor, aCmd.iVersion.iMinor, aCmd.iVersion.iBuild, aCmd.iTimeout); |
|
607 |
|
608 AppendCapabilitiesL( aCmd.iCaps ); |
|
609 |
|
610 PrintL(); |
|
611 } |
|
612 |
|
613 // ----------------------------------------------------------------------------- |
|
614 // RMediatorDebug::PrintCommandListL |
|
615 // |
|
616 // (other items were commented in a header). |
|
617 // ----------------------------------------------------------------------------- |
|
618 // |
|
619 void RMediatorDebug::PrintCommandListL(const RMessage2& aMessage, CMediatorServerSession& aSession, const RCommandList& aList) |
|
620 { |
|
621 if (!iInstance->ShouldPrintLogL(aMessage, aSession)) |
|
622 { |
|
623 return; |
|
624 } |
|
625 |
|
626 |
|
627 for( TInt i = 0; i < aList.Count(); i++) |
|
628 { |
|
629 PrintCommandL(aMessage, aSession, aList[i], i); |
|
630 } |
|
631 } |
|
632 |
|
633 // ----------------------------------------------------------------------------- |
|
634 // RMediatorDebug::PrintCategoryListL |
|
635 // |
|
636 // (other items were commented in a header). |
|
637 // ----------------------------------------------------------------------------- |
|
638 // |
|
639 void RMediatorDebug::PrintCategoryListL(const RMessage2& aMessage, CMediatorServerSession& aSession, const RCategoryList& aList) |
|
640 { |
|
641 if (!iInstance->ShouldPrintLogL(aMessage, aSession)) |
|
642 { |
|
643 return; |
|
644 } |
|
645 |
|
646 _LIT(KDomain, " 0x%08X"); |
|
647 |
|
648 // if domain is specified with this request, then it is submitted for querying categories |
|
649 if (HasDomain(aMessage)) |
|
650 { |
|
651 iBuf.AppendFormat(_L("Categories(count=%d):"), &iOf, aList.Count()); |
|
652 } |
|
653 else |
|
654 { |
|
655 iBuf.AppendFormat(_L("Domains(count=%d):"), &iOf, aList.Count()); |
|
656 } |
|
657 |
|
658 for (TInt i = 0; i < aList.Count(); i++) |
|
659 { |
|
660 iBuf.AppendFormat(KDomain, &iOf, aList[i].iUid); |
|
661 } |
|
662 |
|
663 PrintL(); |
|
664 } |
|
665 |
|
666 // ----------------------------------------------------------------------------- |
|
667 // RMediatorDebug::PrintRawL |
|
668 // |
|
669 // (other items were commented in a header). |
|
670 // ----------------------------------------------------------------------------- |
|
671 // |
|
672 void RMediatorDebug::PrintRawL(const RMessage2& aMessage, CMediatorServerSession& aSession, const TDesC8& aData) |
|
673 { |
|
674 if (!iInstance->ShouldPrintLogL(aMessage, aSession)) |
|
675 { |
|
676 return; |
|
677 } |
|
678 |
|
679 // printing parameters may be flagged out |
|
680 if ((iOptions & KLogParameterData)) |
|
681 { |
|
682 const TInt KRowLen = 32; |
|
683 |
|
684 _LIT(KFormatData, " %02X"); |
|
685 _LIT(KFormatLine, "\tPARAM%03d :" ); |
|
686 TInt dataLen = aData.Length(); |
|
687 const TUint8* data = aData.Ptr(); |
|
688 |
|
689 // print parameter data as an hexdump, 32 bytes each row |
|
690 // PARAM000: 00 AA BB CC DD EE ... |
|
691 while (dataLen > 0) |
|
692 { |
|
693 iBuf.AppendFormat(KFormatLine, &iOf, ((data-aData.Ptr())/KRowLen)); |
|
694 |
|
695 for (TInt i = 0; i < KRowLen; i++) |
|
696 { |
|
697 |
|
698 if (--dataLen < 0) |
|
699 { |
|
700 break; |
|
701 } |
|
702 |
|
703 iBuf.AppendFormat(KFormatData, &iOf, *data++); |
|
704 |
|
705 } |
|
706 |
|
707 PrintL(); |
|
708 } |
|
709 } |
|
710 } |
|
711 |
|
712 // ----------------------------------------------------------------------------- |
|
713 // RMediatorDebug::PrintErrorL |
|
714 // |
|
715 // (other items were commented in a header). |
|
716 // ----------------------------------------------------------------------------- |
|
717 // |
|
718 void RMediatorDebug::PrintErrorL(const RMessage2& aMessage, TInt aError) |
|
719 { |
|
720 TPtrC opString = OperationString( aMessage.Function() ); |
|
721 TPtrC errString = ErrorString( aError ); |
|
722 |
|
723 iBuf.AppendFormat( _L("Server responded to operation %S with error %S (%d)"), &iOf, |
|
724 &opString, |
|
725 &errString, |
|
726 aError ); |
|
727 |
|
728 PrintL(); |
|
729 } |
|
730 |
|
731 // ----------------------------------------------------------------------------- |
|
732 // RMediatorDebug::PrintServerStatusL |
|
733 // |
|
734 // (other items were commented in a header). |
|
735 // ----------------------------------------------------------------------------- |
|
736 // |
|
737 void RMediatorDebug::PrintServerStatusL() |
|
738 { |
|
739 |
|
740 if (!(iOptions & KLogStatus)) |
|
741 { |
|
742 return; |
|
743 } |
|
744 |
|
745 RThread thread; |
|
746 TInt allocSize = 0; |
|
747 User::Heap().AllocSize( allocSize ); |
|
748 |
|
749 iBuf.Append( _L("-- MEDIATOR STATUS START --") ); |
|
750 PrintL(); |
|
751 |
|
752 iBuf.AppendFormat(_L("\t\tMemory allocated:%d"), &iOf, allocSize); |
|
753 PrintL(); |
|
754 |
|
755 iBuf.AppendFormat(_L("\t\tPlugins loaded: %d"), &iOf, iMediator->PluginHandler().PluginCount()); |
|
756 PrintL(); |
|
757 |
|
758 TInt categCount; |
|
759 TInt domainCount; |
|
760 TInt observerCount; |
|
761 TInt eventCount; |
|
762 TInt commandCount; |
|
763 |
|
764 iMediator->ObjectHandler().GetStatistics(domainCount, categCount, eventCount, commandCount, observerCount); |
|
765 |
|
766 iBuf.AppendFormat(_L("\t\tDomains: %d\tCategories: %d\tObservers: %d"), &iOf, domainCount, categCount, observerCount); |
|
767 PrintL(); |
|
768 |
|
769 iBuf.AppendFormat(_L("\t\tEvents: %d"), &iOf, eventCount); |
|
770 PrintL(); |
|
771 |
|
772 iBuf.AppendFormat(_L("\t\tCommands: %d"), &iOf, commandCount); |
|
773 PrintL(); |
|
774 |
|
775 TPtrC statusEnd( _L("-- MEDIATOR STATUS END --") ); |
|
776 iBuf.AppendFormat(_L("\t\tPending commands: %d"), &iOf, |
|
777 iMediator->CommandHandler().CommandPendingCount() ); |
|
778 PrintL(); |
|
779 |
|
780 |
|
781 iBuf.Append( _L("-- MEDIATOR STATUS END --") ); |
|
782 PrintL(); |
|
783 } |
|
784 |
|
785 // ----------------------------------------------------------------------------- |
|
786 // RMediatorDebug::PrintStartupConfigurationL |
|
787 // |
|
788 // (other items were commented in a header). |
|
789 // ----------------------------------------------------------------------------- |
|
790 // |
|
791 void RMediatorDebug::PrintConfigurationL() |
|
792 { |
|
793 |
|
794 iBuf.Append( _L("Server side logging service initialized.") ); |
|
795 PrintL(); |
|
796 |
|
797 iBuf.Append( _L("Logging filters status (set in MediatorDebug.rss):") ); |
|
798 PrintL(); |
|
799 |
|
800 TPtrC filterOff( _L( "Off" ) ); |
|
801 TPtrC filterOn( _L( "On" ) ); |
|
802 TPtrC modeInclusive( _L( "Inclusive" ) ); |
|
803 TPtrC modeExclusive( _L( "Exclusive") ); |
|
804 TPtrC modeNotFiltered( _L("Not applied") ); |
|
805 TDesC* currMode; |
|
806 |
|
807 switch ( iDomainOptions ) |
|
808 { |
|
809 default: |
|
810 case ELogAll: |
|
811 currMode = &modeNotFiltered; |
|
812 break; |
|
813 |
|
814 case ELogInclusive: |
|
815 currMode = &modeInclusive; |
|
816 break; |
|
817 |
|
818 case ELogExclusive: |
|
819 currMode = &modeExclusive; |
|
820 break; |
|
821 } |
|
822 |
|
823 iBuf.AppendFormat( _L("\tDomain filtering: %S"), &iOf, currMode ); |
|
824 PrintL(); |
|
825 |
|
826 switch ( iCategoryOptions ) |
|
827 { |
|
828 default: |
|
829 case ELogAll: |
|
830 currMode = &modeNotFiltered; |
|
831 break; |
|
832 |
|
833 case ELogInclusive: |
|
834 currMode = &modeInclusive; |
|
835 break; |
|
836 |
|
837 case ELogExclusive: |
|
838 currMode = &modeExclusive; |
|
839 break; |
|
840 } |
|
841 |
|
842 iBuf.AppendFormat( _L("\tCategory filtering: %S"), &iOf, currMode ); |
|
843 PrintL(); |
|
844 |
|
845 currMode = ( iOptions & KLogEvents ) ? &filterOn : &filterOff; |
|
846 iBuf.AppendFormat( _L("\tEvent logging: %S") , &iOf, currMode); |
|
847 PrintL(); |
|
848 |
|
849 currMode = ( iOptions & KLogCommands ) ? &filterOn : &filterOff; |
|
850 iBuf.AppendFormat( _L("\tCommand logging: %S") , &iOf, currMode); |
|
851 PrintL(); |
|
852 |
|
853 currMode = ( iOptions & KLogStatus ) ? &filterOn : &filterOff; |
|
854 iBuf.AppendFormat( _L("\tStatus report: %S") , &iOf, currMode); |
|
855 PrintL(); |
|
856 |
|
857 currMode = ( iOptions & KLogParameterData ) ? &filterOn : &filterOff; |
|
858 iBuf.AppendFormat( _L("\tParameter data logging: %S") , &iOf, currMode); |
|
859 PrintL(); |
|
860 |
|
861 iBuf.Append( _L("In order to enable function tracing define flag _DEBUG_MEDIATOR in debug.h") ); |
|
862 PrintL(); |
|
863 } |
|
864 |
|
865 // ----------------------------------------------------------------------------- |
|
866 // RMediatorDebug::PrintL |
|
867 // |
|
868 // (other items were commented in a header). |
|
869 // ----------------------------------------------------------------------------- |
|
870 // |
|
871 void RMediatorDebug::PrintL() |
|
872 { |
|
873 // check that zero termination can be done |
|
874 if (iBuf.Length() >= iBuf.MaxLength()) |
|
875 { |
|
876 User::Leave(KErrOverflow); |
|
877 } |
|
878 |
|
879 iBuf.ZeroTerminate(); |
|
880 |
|
881 Print(iBuf); |
|
882 |
|
883 iBuf.Zero(); // so that next caller can append text to this buffer |
|
884 iBuf.Append( KMediatorPrintTag ); // ready for next print |
|
885 } |
|
886 |
|
887 // ----------------------------------------------------------------------------- |
|
888 // RMediatorDebug::Print |
|
889 // |
|
890 // (other items were commented in a header). |
|
891 // ----------------------------------------------------------------------------- |
|
892 // |
|
893 void RMediatorDebug::Print(const TDesC& aText) |
|
894 { |
|
895 // print this text to com port and/or to a file |
|
896 iFileLogger.Write( aText ); // safe to call even if session is not opened |
|
897 |
|
898 RDebug::Print( aText ); |
|
899 } |
|
900 |
|
901 // ----------------------------------------------------------------------------- |
|
902 // RMediatorDebug::HandleInternalError |
|
903 // |
|
904 // (other items were commented in a header). |
|
905 // ----------------------------------------------------------------------------- |
|
906 // |
|
907 void RMediatorDebug::HandleInternalError(TInt aError) |
|
908 { |
|
909 if (aError != KErrNone) |
|
910 { |
|
911 const TInt KMsgLen = 100; |
|
912 TBuf<KMsgLen> errMsg; |
|
913 errMsg.Format(_L("Log writing failed with error %d"), aError); |
|
914 errMsg.ZeroTerminate(); |
|
915 Print(errMsg); |
|
916 } |
|
917 } |
|
918 |
|
919 // ----------------------------------------------------------------------------- |
|
920 // RMediatorDebug::HandleInitError |
|
921 // |
|
922 // (other items were commented in a header). |
|
923 // ----------------------------------------------------------------------------- |
|
924 // |
|
925 void RMediatorDebug::HandleInitError( TInt aError ) |
|
926 { |
|
927 const TInt KMsgLen = 100; |
|
928 TBuf<KMsgLen> errorMsg; |
|
929 errorMsg.AppendFormat(_L("[Mediator] RMediatorDebug::Initialize failed with code %d. Debug services not available."), aError ); |
|
930 errorMsg.ZeroTerminate(); |
|
931 RDebug::Print(errorMsg); |
|
932 RFileLogger::WriteFormat(KMediatorLogFolder, KMediatorErrorFile, EFileLoggingModeAppend, errorMsg); |
|
933 } |
|
934 #endif // _DEBUG |
|
935 |
|
936 // End of File |