diff -r 630d2f34d719 -r 07a122eea281 telephonyutils/telephonywatchers/src/watcherbase.cpp --- a/telephonyutils/telephonywatchers/src/watcherbase.cpp Tue Aug 31 16:23:08 2010 +0300 +++ b/telephonyutils/telephonywatchers/src/watcherbase.cpp Wed Sep 01 12:40:21 2010 +0100 @@ -13,21 +13,8 @@ // Description: // - - -#include "OstTraceDefinitions.h" -#ifdef OST_TRACE_COMPILER_IN_USE -#include "watcherbaseTraces.h" -#endif - -#undef TCOM_ARG -#ifdef OST_TRACE_COMPILER_IN_USE -#define TCOM_ARG(x) x -#else -#define TCOM_ARG(x) -#endif - #include "watcherbase.h" +#include "watcherlog.h" // System includes #include @@ -66,7 +53,7 @@ TheSeed = now.Int64(); //-- define properties for test purposes - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_CTOR_1, "CTelWatcherBase : defining properties for testing"); + LOGCOMMON1("CTelWatcherBase : defining properties for testing"); //-- For debugging purposes only, used by TE_TelWatchers(Unit). @@ -96,7 +83,7 @@ EXPORT_C void CWatcherBase::ConstructL() { - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_CONSTRUCTL_1, "WatcherBase : Creating timer"); + LOGCOMMON1("WatcherBase : Creating timer"); User::LeaveIfError(iTimer.CreateLocal()); User::LeaveIfError(iPhonePowerProperty.Attach(KUidSystemCategory, KUidPhonePwr.iUid)); @@ -111,23 +98,30 @@ EXPORT_C void CWatcherBase::SuspendFor(TInt aTimeInSeconds) { - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_SUSPENDFOR_1, "WatcherBase : Pausing after error"); + LOGCOMMON1("WatcherBase : Pausing after error"); TTimeIntervalMicroSeconds32 timeToSuspendFor = aTimeInSeconds * KOneSecond; iTimer.After(iStatus, timeToSuspendFor); State() = EBaseStateSuspending; SetActive(); } -EXPORT_C void CWatcherBase::SetDisabled(const TDesC& TCOM_ARG(aLogEntry), TInt TCOM_ARG(aError)) +EXPORT_C void CWatcherBase::SetDisabled(const TDesC& aLogEntry, TInt aError) { - OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_SETDISABLED_1, "Log Entry \"%S\" error %d", aLogEntry, aError); - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_SETDISABLED_2, "WatcherBase : Watcher is now disabled"); +#ifdef _WATCHER_LOGGING_ENABLED + TBuf8<256> tmpBuf; + tmpBuf.Copy(aLogEntry); + LOGCOMMON3("Log Entry \"%S\" error %d", &tmpBuf, aError); +#else + (void) aLogEntry; + (void) aError; +#endif + LOGCOMMON1("WatcherBase : Watcher is now disabled"); State() = EBaseStateDisabled; } EXPORT_C void CWatcherBase::RequestNextState() { - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_REQUESTNEXTSTATE_1, "WatcherBase : Requesting State Change"); + LOGCOMMON1("WatcherBase : Requesting State Change"); if (State() != EBaseStateDisabled) { @@ -145,7 +139,7 @@ { TInt val; - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_WAITFORPHONETOPOWERUPL_1, "WatcherBase : Waiting for phone to be turned on"); + LOGCOMMON1("WatcherBase : Waiting for phone to be turned on"); __ASSERT_DEBUG(!IsActive(), WatcherBasePanic(EUnexpectedActiveState)); Cancel(); @@ -163,7 +157,7 @@ if (val != ESAPhoneOff) {//-- phone is already ON, complete request so that we go to RunL without waiting iPhonePowerProperty.Cancel(); - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_WAITFORPHONETOPOWERUPL_2, "CTelWatcherBase::WaitForPhoneToPowerUpL ??? phone is already turned ON"); + LOGCOMMON1("CTelWatcherBase::WaitForPhoneToPowerUpL ??? phone is already turned ON"); } } @@ -173,12 +167,12 @@ EXPORT_C void CWatcherBase::RunL() { - OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_RUNL_1, "WatcherBase : RunL(%d)", iStatus.Int()); + LOGCOMMON2("WatcherBase : RunL(%d)", iStatus.Int()); switch(State()) { case EBaseStateConnectingToPropertyNotifier: - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_RUNL_2, "WatcherBase : Attaching to Property"); + LOGCOMMON1("WatcherBase : Attaching to Property"); // Virtual function call back, for any subclasses that need to implement // any special stuff. @@ -192,7 +186,7 @@ case EBaseStateWaitingForPhoneToPowerUp: // We were waiting for the phone to become available again. We now must restart // this watcher from scratch. - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_RUNL_3, "WatcherBase : Phone available again. Restarting watcher framework"); + LOGCOMMON1("WatcherBase : Phone available again. Restarting watcher framework"); //-- phone power state has changed (it must be turned ON) //-- retrieve its state and check. @@ -202,19 +196,19 @@ if (val == ESAPhoneOn) { //-- everything OK, the phone has been turned ON, restart this watcher from scratch. - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_RUNL_4, "CTelWatcherBase : Phone has been turned ON. Restarting watcher framework"); + LOGCOMMON1("CTelWatcherBase : Phone has been turned ON. Restarting watcher framework"); State() = EBaseStateConnectingToPropertyNotifier; RequestNextState(); } else { //-- strange situation, we were waiting for phone On and it now Off, try to wait again - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_RUNL_5, "CTelWatcherBase : ??? Phone has been turned OFF. Continue waiting..."); + LOGCOMMON1("CTelWatcherBase : ??? Phone has been turned OFF. Continue waiting..."); WaitForPhoneToPowerUpL(); } break; case EBaseStateSuspending: - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_RUNL_6, "WatcherBase : Completed suspension. Resuming passive state"); + LOGCOMMON1("WatcherBase : Completed suspension. Resuming passive state"); State() = EBaseStatePassive; // Fall through @@ -224,7 +218,7 @@ default: case EBaseStateDisabled: - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_RUNL_7, "WatcherBase : RunL called in Disabled state. Ooops"); + LOGCOMMON1("WatcherBase : RunL called in Disabled state. Ooops"); __ASSERT_DEBUG(0, WatcherBasePanic(EUnexpectedState)); } } @@ -253,13 +247,17 @@ // Let other sub classes cancel their requests HandleCancel(); } - -EXPORT_C TInt CWatcherBase::RunError(TInt TCOM_ARG(aError)) + +EXPORT_C TInt CWatcherBase::RunError(TInt aError) // // Called when RunL (or a sub-function there-of) leaves. // { - OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_RUNERROR_1, "WatcherBase : RunError called with error of %d", aError); +#ifdef _WATCHER_LOGGING_ENABLED + LOGCOMMON2("WatcherBase : RunError called with error of %d", aError); +#else + (void) aError; +#endif // Should never be called from outside the framework __ASSERT_DEBUG(!IsActive(), WatcherBasePanic(EUnexpectedActiveState)); @@ -286,7 +284,7 @@ else { // Put us in the start up state again - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_RUNERROR_2, "WatcherBase : Phone available again. Restarting watcher framework"); + LOGCOMMON1("WatcherBase : Phone available again. Restarting watcher framework"); State() = EBaseStateConnectingToPropertyNotifier; RequestNextState(); } @@ -409,28 +407,32 @@ TInt CPhoneWatcher::RetrieveTSYName() { - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_RETRIEVETSYNAME_1, "PhoneWatcher : RetrieveTSYName()"); + LOGCOMMON1("PhoneWatcher : RetrieveTSYName()"); TRAPD(error, DoRetrieveTSYNameL()); return error; } TInt CPhoneWatcher::ConnectToETelServer() { - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOETELSERVER_1, "PhoneWatcher : ConnectToETelServer()"); + LOGCOMMON1("PhoneWatcher : ConnectToETelServer()"); return ETel().Connect(); } TInt CPhoneWatcher::LoadPhoneModule() { - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_LOADPHONEMODULE_1, "PhoneWatcher : LoadPhoneModule()"); - OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_LOADPHONEMODULE_2, "TSY Name to load is %S",iTSYName); +#ifdef _WATCHER_LOGGING_ENABLED + TBuf8<256> tmpBuf; + tmpBuf.Copy(iTSYName); + LOGCOMMON1("PhoneWatcher : LoadPhoneModule()"); + LOGCOMMON2("TSY Name to load is %S",&tmpBuf); +#endif return ETel().LoadPhoneModule(iTSYName); } TInt CPhoneWatcher::ConnectToPhone() { - OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOPHONE_1, "PhoneWatcher : ConnectToPhone()"); + LOGCOMMON1("PhoneWatcher : ConnectToPhone()"); TInt error; RTelServer::TPhoneInfo phoneInfo; @@ -440,11 +442,11 @@ error = ETel().EnumeratePhones(phoneCount); if (error < KErrNone) { - OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOPHONE_2, "PhoneWatcher : Failed to enumerate phones (%d)", error); + LOGCOMMON2("PhoneWatcher : Failed to enumerate phones (%d)", error); return error; } - OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOPHONE_3, "PhoneWatcher : Counted %d 'phones'", phoneCount); + LOGCOMMON2("PhoneWatcher : Counted %d 'phones'", phoneCount); // Iterate through all the phones for(TInt i=0; i tmpMatchTsyName; + tmpMatchTsyName.Copy(matchTsyName); + LOGCOMMON3("PhoneWatcher : TSY for phone %d is '%S'", i, &tmpMatchTsyName); +#endif // See if the phone belongs to the TSY if (matchTsyName.CompareF(iTSYName) == 0) { - OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOPHONE_6, "PhoneWatcher : %S is a match for CommDb TSY: %S", matchTsyName, iTSYName); +#ifdef _WATCHER_LOGGING_ENABLED + TBuf8<256> tsyNameBuf; + tsyNameBuf.Copy(iTSYName); + LOGCOMMON3("PhoneWatcher : %S is a match for CommDb TSY: %S", &tmpMatchTsyName, &tsyNameBuf); +#endif error = ETel().GetPhoneInfo(i, phoneInfo); if (error < KErrNone) { - OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOPHONE_7, "PhoneWatcher : Getting phone info failed (%d)", error); + LOGCOMMON2("PhoneWatcher : Getting phone info failed (%d)", error); return error; } break; @@ -481,11 +490,19 @@ error = Phone().Open(ETel(), phoneInfo.iName); if (error < KErrNone) { - OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOPHONE_8, "PhoneWatcher : Open phone %S failed (%d)", phoneInfo.iName, error); +#ifdef _WATCHER_LOGGING_ENABLED + TBuf8<256> tmpBuf; + tmpBuf.Copy(phoneInfo.iName); + LOGCOMMON3("PhoneWatcher : Open phone %S failed (%d)", &tmpBuf, error); +#endif return error; } - OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEWATCHER_CONNECTTOPHONE_9, "PhoneWatcher : Opened 'phone' %S", phoneInfo.iName); +#ifdef _WATCHER_LOGGING_ENABLED + TBuf8<256> tmpBuf; + tmpBuf.Copy(phoneInfo.iName); + LOGCOMMON2("PhoneWatcher : Opened 'phone' %S", &tmpBuf); +#endif // Indicate we're connected and to move to next state. return error;