diff -r a5deb6b96675 -r 63cf70d3ecd8 mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsusbnotifier.cpp --- a/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsusbnotifier.cpp Thu Sep 02 21:21:26 2010 +0300 +++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsusbnotifier.cpp Fri Sep 17 08:34:51 2010 +0300 @@ -18,19 +18,18 @@ */ -#include #include #include #include "dpsusbnotifier.h" #include "dpsconst.h" #include "dpsptpnotifier.h" #include "dpsconnectnotifier.h" +#include "mtpdebug.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "dpsusbnotifierTraces.h" +#endif -#ifdef _DEBUG -# define IF_DEBUG(t) {RDebug::t;} -#else -# define IF_DEBUG(t) -#endif const TInt KUnknownPersonality = 0; @@ -40,7 +39,6 @@ // CDpsUsbNotifier* CDpsUsbNotifier::NewL(CDpsEngine* aEngine) { - IF_DEBUG(Print(_L("CDpsUsbNotifier::NewL"))); CDpsUsbNotifier* self = new(ELeave) CDpsUsbNotifier(aEngine); CleanupStack::PushL(self); self->ConstructL(); @@ -58,9 +56,9 @@ iConnectState(EUsbDeviceStateUndefined), iConfigured(EFalse), iConnection(CDpsEngine::ENotConnected), iRollback(EFalse) { - IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::Ctor"))); + OstTraceFunctionEntry0( CDPSUSBNOTIFIER_CDPSUSBNOTIFIER_CONS_ENTRY ); CActiveScheduler::Add(this); - IF_DEBUG(Print(_L("<<>>~CDpsUsbNotifier"))); + OstTraceFunctionEntry0( CDPSUSBNOTIFIER_CDPSUSBNOTIFIER_DES_ENTRY ); Cancel(); Rollback(); delete iPtpP; iPtpP = NULL; delete iConnectP; iConnectP = NULL; iUsbM.Close(); iUsbW.Close(); - IF_DEBUG(Print(_L("<<<~CDpsUsbNotifier"))); + OstTraceFunctionExit0( CDPSUSBNOTIFIER_CDPSUSBNOTIFIER_DES_EXIT ); } // --------------------------------------------------------------------------- @@ -85,12 +83,16 @@ // void CDpsUsbNotifier::ConstructL() { - IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::ConstructL"))); - User::LeaveIfError(iUsbM.Connect()); - User::LeaveIfError(iUsbW.Connect()); + OstTraceFunctionEntry0( CDPSUSBNOTIFIER_CONSTRUCTL_ENTRY ); + LEAVEIFERROR(iUsbM.Connect(), + OstTrace1( TRACE_ERROR, CDPSUSBNOTIFIER_CONSTRUCTL, + "Connect to iUsbM failed! error code %d", munged_err)); + LEAVEIFERROR(iUsbW.Connect(), + OstTrace1( TRACE_ERROR, DUP1_CDPSUSBNOTIFIER_CONSTRUCTL, + "Connect to iUsbM failed! error code %d", munged_err)); iPtpP = CDpsPtpNotifier::NewL(this); iConnectP = CDpsConnectNotifier::NewL(this); - IF_DEBUG(Print(_L("<<ChangePtpPersonality(); + OstTraceFunctionExit0( CDPSUSBNOTIFIER_WAITFORPRINTERNOTIFY_EXIT ); } // --------------------------------------------------------------------------- @@ -109,7 +112,7 @@ // void CDpsUsbNotifier::CancelPrinterNotify() { - IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::CancelPrinterNotify"))); + OstTraceFunctionEntry0( CDPSUSBNOTIFIER_CANCELPRINTERNOTIFY_ENTRY ); if (CDpsEngine::ENotConnected == iConnection) { iPtpP->Cancel(); @@ -125,7 +128,7 @@ { User::RequestComplete(iEngine->PrinterConnectRequest(), KErrCancel); } - IF_DEBUG(Print(_L("<<>>CDpsUsbNotifier::ConnectNotify"))); + OstTraceFunctionEntry0( CDPSUSBNOTIFIER_CONNECTNOTIFY_ENTRY ); iConnectP->ConnectNotify(); - IF_DEBUG(Print(_L("<<>>CDpsUsbNotifier::Rollback"))); + OstTraceFunctionEntry0( CDPSUSBNOTIFIER_ROLLBACK_ENTRY ); // only when the personality has changed, we switch back to the previous // personality if (iPersonality) { TInt personalityId = KUsbPersonalityIdMTP; iUsbM.GetCurrentPersonalityId(personalityId); - IF_DEBUG(Print(_L("CDpsUsbNotifier::Rollback, current personality= %d"), personalityId)); + OstTrace1( TRACE_NORMAL, CDPSUSBNOTIFIER_ROLLBACK, "current personality= %d", personalityId ); if(KUsbPersonalityIdPCSuiteMTP != personalityId) { if (!iConfigured || iRollback) @@ -165,7 +168,7 @@ } } } - IF_DEBUG(Print(_L("<<>>CDpsUsbNotifier::PtpNotify %x %d"), - iConnectState, aErr)); + OstTraceFunctionEntry0( CDPSUSBNOTIFIER_PTPNOTIFY_ENTRY ); + OstTraceExt2( TRACE_NORMAL, CDPSUSBNOTIFIER_PTPNOTIFY, "connect status %x, error no %d", iConnectState, aErr ); + if (aErr == KErrNone) { // personality changed to MTP, but cable is not connected @@ -198,8 +202,8 @@ iConnection = CDpsEngine::EWrongPrintModeConnected; User::RequestComplete(iEngine->PrinterConnectRequest(), iConnection); } - - IF_DEBUG(Print(_L("<<>>CDpsUsbNotifier::PersonalityChanged %x"), - iPersonality)); + OstTraceFunctionEntry0( CDPSUSBNOTIFIER_PERSONALITYCHANGED_ENTRY ); + OstTrace1( TRACE_NORMAL, CDPSUSBNOTIFIER_PERSONALITYCHANGED, "iPersonality %x", iPersonality ); + if (iPersonality != KUsbPersonalityIdMTP) { iConnection = CDpsEngine::EWrongPrintModeConnected; @@ -222,8 +227,8 @@ } // when UI gets this notification, it must quit. As the result, the dps // engine will be deleted so we do not need to care the further change. - - IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::PersonalityChanged "))); + + OstTraceFunctionExit0( CDPSUSBNOTIFIER_PERSONALITYCHANGED_EXIT ); } // --------------------------------------------------------------------------- @@ -232,7 +237,7 @@ // void CDpsUsbNotifier::RunL() { - IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::RunL"))); + OstTraceFunctionEntry0( CDPSUSBNOTIFIER_RUNL_ENTRY ); if (EPrinterAvailable == iStatus.Int()) { @@ -245,8 +250,8 @@ iConnection = CDpsEngine::EOtherConnected; } User::RequestComplete(iEngine->PrinterConnectRequest(), iConnection); - - IF_DEBUG(Print(_L("<<>>CDpsUsbNotifier::DoCancel"))); + OstTraceFunctionEntry0( CDPSUSBNOTIFIER_DOCANCEL_ENTRY ); iEngine->Ptp().CancelIsDpsPrinter(); - IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::DoCancel"))); + OstTraceFunctionExit0( CDPSUSBNOTIFIER_DOCANCEL_EXIT ); } // --------------------------------------------------------------------------- @@ -266,7 +271,8 @@ // TInt CDpsUsbNotifier::RunError(TInt aErr) { - IF_DEBUG(Print(_L("CDpsUsbNotifier::RunError is %d"), aErr)); + OstTraceDef1( OST_TRACE_CATEGORY_PRODUCTION, TRACE_IMPORTANT, CDPSUSBNOTIFIER_RUNERROR, + "error code %d", aErr); return aErr; } @@ -276,7 +282,9 @@ // void CDpsUsbNotifier::DisconnectNotify(TUsbDeviceState aState) { - IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::DisconnectNotify %d"), aState)); + OstTraceFunctionEntry0( CDPSUSBNOTIFIER_DISCONNECTNOTIFY_ENTRY ); + OstTrace1( TRACE_NORMAL, CDPSUSBNOTIFIER_DISCONNECTNOTIFY, "status %d", aState ); + if (iConfigured) { iConnection = CDpsEngine::EPrinterDisconnected; @@ -294,8 +302,8 @@ { User::RequestComplete(iEngine->PrinterConnectRequest(), iConnection); } - - IF_DEBUG(Print(_L("<<>>CDpsUsbNotifier::ConnectState"))); - TInt ret = iUsbM.GetDeviceState(iConnectState); - IF_DEBUG(Print(_L("<<