diff -r 5b2a402e96ac -r 25fce757be94 usbuis/usbuinotif/src/usbnotifier.cpp --- a/usbuis/usbuinotif/src/usbnotifier.cpp Thu Aug 19 10:54:11 2010 +0300 +++ b/usbuis/usbuinotif/src/usbnotifier.cpp Tue Aug 31 16:13:57 2010 +0300 @@ -16,18 +16,14 @@ */ // INCLUDE FILES -#include // Eikon environment + #include // BAFL utils (for language file) -#include // Localisation stringloader -#include -#include #include -#include -#include +#include #include "usbnotifier.h" // Own class #include "usbuinotifdebug.h" -#include "aknkeylock.h" //RAknKeyLock + // CONSTANTS // ================= MEMBER FUNCTIONS ========================================= @@ -39,11 +35,9 @@ // itself to the active scheduler stack. // ---------------------------------------------------------------------------- // -CUSBUINotifierBase::CUSBUINotifierBase() : - CActive( EPriorityStandard ) +CUSBUINotifierBase::CUSBUINotifierBase() { FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Default constructor()")); - CActiveScheduler::Add( this ); } // ---------------------------------------------------------------------------- @@ -55,27 +49,16 @@ void CUSBUINotifierBase::ConstructL() { iEikEnv = CEikonEnv::Static(); - iAppsKeyBlocked = EFalse; - iKeylockChanged = EFalse; - + FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::ConstructL()")); - TFileName filename; - - const TDriveNumber KStoreDrive = EDriveZ; - TDriveUnit driveUnit( KStoreDrive ); - TDriveName drive = driveUnit.Name(); - filename.Insert( 0, drive ); - - filename += KDC_RESOURCE_FILES_DIR; // From data_caging_path_literals.hrh - filename += KResourceFileName; - BaflUtils::NearestLanguageFile( iEikEnv->FsSession(), filename ); - iResourceFileFlag = iEikEnv->AddResourceFileL( filename ); - - FeatureManager::InitializeLibL(); - iCoverDisplaySupported = FeatureManager::FeatureSupported( - KFeatureIdCoverDisplay ); - FeatureManager::UnInitializeLib(); - + + // use TLS as a boolean, set to EFalse + TBool initialized = EFalse; + TInt error; + error = Dll::SetTls((TAny* )initialized); + error = error; // to suppress a compiler warning + FTRACE(FPrint(_L("[USBUINOTIF]\t Dll:SetTls returned %d"), error )); + FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::ConstructL() completed")); } @@ -90,18 +73,11 @@ //this virtual function call is to the local CUSBUINotifierBase::Cancel, //not to any possibly derived class implementation. Cancel(); - iEikEnv->DeleteResourceFile( iResourceFileFlag ); - + // Complete the RMessage2 if needed // CompleteMessage( KErrDied ); - // Activate apps -key again (if not previously activated yet) - SuppressAppSwitching( EFalse ); - - //Don't call RestoreKeylock here. It's up to specific note notfier logic. - //If failed to RestoreKeylock there, it doesn't matter to leave keylock open. - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Destructor completed")); } @@ -149,7 +125,7 @@ const RMessagePtr2& aMessage) { FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::StartL()")); - TRAPD( err, GetParamsL( aBuffer, aReplySlot, aMessage )); + TRAPD( err, StartDialogL( aBuffer, aReplySlot, aMessage )); if (err) { aMessage.Complete( err ); @@ -167,8 +143,9 @@ void CUSBUINotifierBase::Cancel() { FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Cancel()")); - CActive::Cancel(); - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Cancel completed()")); + //The message box closed callback gets not run in subclass cancel calls. + CompleteMessage(KErrCancel); + FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::Cancel completed")); } // ---------------------------------------------------------------------------- @@ -183,64 +160,6 @@ } // ---------------------------------------------------------------------------- -// CUSBUINotifierBase::DoCancel -// This method will be called by framework (CActive) -// if active object is still active. -// Does nothing here. -// ---------------------------------------------------------------------------- -// -void CUSBUINotifierBase::DoCancel() - { - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::DoCancel()")); - } - -// ---------------------------------------------------------------------------- -// CUSBUINotifierBase::RunError -// This method is called if any leaving has been occured -// during RunL. Optional method for CActive derived objects. -// ---------------------------------------------------------------------------- -// -TInt CUSBUINotifierBase::RunError(TInt aError) - { - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RunError()")); - - // Activate apps -key again (if not previously activated yet) - // - SuppressAppSwitching( EFalse ); - - // Write error message to caller - // - CompleteMessage( aError ); - - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RunError() completed")); - - return aError; - } - -// ---------------------------------------------------------------------------- -// CUSBUINotifierBase::SuppressAppSwitching -// -// ---------------------------------------------------------------------------- -// -void CUSBUINotifierBase::SuppressAppSwitching(TBool aEnable) - { - FTRACE(FPrint(_L("[USBUINOTIF]\t CUSBUINotifierBase::SuppressAppSwitching() %d"), aEnable)); - - if (iAppsKeyBlocked != aEnable) - { - TInt err = iAknServer.ConnectAndSendAppsKeySuppress( aEnable ); // error is stored only for logging purposes - iAppsKeyBlocked = aEnable; - FTRACE(FPrint(_L("[USBUINOTIF]\t CUSBUINotifierBase::SuppressAppSwitching() ConnectAndSendAppsKeySuppress returned %d"), err )); - } - - if (!iAppsKeyBlocked) - { - iAknServer.Close(); // close the connection once we have re-enabled swithcing - } - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::SuppressAppSwitching() completed")); - } - -// ---------------------------------------------------------------------------- // CUSBUINotifierBase::CompleteMessage // Check if message needs to be completed and complete it. // ---------------------------------------------------------------------------- @@ -257,61 +176,33 @@ FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::CompleteMessage() completed")); } -// ---------------------------------------------------------------------------- -// CUSBUINotifierBase::DisableKeylock -// ---------------------------------------------------------------------------- -// Turn off the keyguard if it was on. -// -void CUSBUINotifierBase::DisableKeylock() +void CUSBUINotifierBase::InitializeTextResolver() { - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::DisableKeylock()")); - RAknKeylock2 keylock; - iKeylockChanged = EFalse; - if (KErrNone == keylock.Connect()) + _LIT(KFileName, "usbdialogs_"); + _LIT(KPath, "z:/resource/qt/translations/"); + TInt error = KErrNone; + + iTranslator = (TBool )Dll::Tls(); + + FTRACE(FPrint(_L("[USBUINOTIF]\t Dll:Tls returned %d"), iTranslator )); + + if (!iTranslator) { - if (keylock.IsKeyLockEnabled()) //Check and save the keylock status + iTranslator = HbTextResolverSymbian::Init(KFileName, KPath); + FTRACE(FPrint(_L("[USBUINOTIF]\t HbTextResolverSymbian::Init returned %d"), iTranslator )); + if (iTranslator) { - keylock.DisableWithoutNote();// Unlock - iKeylockChanged = ETrue; + error = Dll::SetTls((TAny* )iTranslator); } - keylock.Close(); - } - else - { - FLOG( _L( "[USBUINOTIF]\t CUSBUINotifierBase::DisableKeylock() fail caused by RAknKeylock2::Connect()") ); - } - - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::DisableKeylock() completed")); + FTRACE(FPrint(_L("[USBUINOTIF]\t Dll:SetTls returned %d"), error )); + } + + error = error; // to suppress a compiler warning + FTRACE( FPrint( + _L( "[USBUINOTIF]\t CUSBUINotifierBase::InitializeTextResolver result = %d" ), + iTranslator ) ); + } -// ---------------------------------------------------------------------------- -// CUSBUINotifierBase::RestoreKeylock -// ---------------------------------------------------------------------------- -// Restore the keyguard on. -// -void CUSBUINotifierBase::RestoreKeylock() - { - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock()")); - if (iKeylockChanged) - { - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock(): iKeylockChanged true")); - RAknKeylock2 keylock; - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock(): RAknKeyLock2 initialized")); - if (KErrNone == keylock.Connect()) - { - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock(): RAknKeyLock2::Connect() complete")); - keylock.EnableWithoutNote();// Lock back - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock(): RAknKeyLock2::EnableWithoutNote() complete")); - keylock.Close(); - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock(): RAknKeyLock2::Close() complete")); - iKeylockChanged = EFalse; - } - else - { - FLOG( _L( "[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock() fail caused by RAknKeylock2::Connect()") ); - } - } - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::RestoreKeylock() completed")); - } // End of File