Revision: 201003 default
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 02 Feb 2010 00:52:37 +0200
changeset 4 7e15987c4500
parent 3 47c263f7e521
child 5 7068aba64af5
Revision: 201003 Kit: 201005
usbclasses/group/bld.inf
usbengines/usbwatcher/group/usbwatcherserver.mmp
usbengines/usbwatcher/inc/cusbwatcher.h
usbengines/usbwatcher/inc/tusbindicatorhandler.h
usbengines/usbwatcher/src/cusbactivestate.cpp
usbengines/usbwatcher/src/cusbwatcher.cpp
usbengines/usbwatcher/src/tusbindicatorhandler.cpp
usbuis/usbuinotif/group/usbuinotif.mmp
usbuis/usbuinotif/inc/usbuincableconnectednotifier.h
usbuis/usbuinotif/inc/usbuinotifdialerwatcher.h
usbuis/usbuinotif/inc/usbuinotifmsmmerror.h
usbuis/usbuinotif/inc/usbuinotifotgerror.h
usbuis/usbuinotif/src/usbuincableconnectednotifier.cpp
usbuis/usbuinotif/src/usbuinotifdialerwatcher.cpp
usbuis/usbuinotif/src/usbuinotifmsmmerror.cpp
usbuis/usbuinotif/src/usbuinotifotgerror.cpp
--- a/usbclasses/group/bld.inf	Tue Jan 26 12:55:41 2010 +0200
+++ b/usbclasses/group/bld.inf	Tue Feb 02 00:52:37 2010 +0200
@@ -23,9 +23,4 @@
 //#include "../sicdusbplugin/group/bld.inf"
 //#include "../ptpserver/group/bld.inf"
 #include "../pictbridgeengine/group/bld.inf"
-//Wusan@20091210: DEF143281: sf build break because of 
-//  msmmplugin & usbhidclassdriver do not contribute to.
-//PS, this comment and the below 2 line will be deleted after review!
-//#include "../msmmplugin/group/bld.inf"
-//#include "../usbhidclassdriver/group/bld.inf"
 #include "../usbphoneasmodem/group/bld.inf"
--- a/usbengines/usbwatcher/group/usbwatcherserver.mmp	Tue Jan 26 12:55:41 2010 +0200
+++ b/usbengines/usbwatcher/group/usbwatcherserver.mmp	Tue Feb 02 00:52:37 2010 +0200
@@ -37,6 +37,8 @@
 SOURCE      cusbdevicelock.cpp
 SOURCE      cusbdevconstarter.cpp
 SOURCE      cusbglobalsystemstateobserver.cpp
+SOURCE      tusbindicatorhandler.cpp
+
 
 USERINCLUDE   ../inc
 
--- a/usbengines/usbwatcher/inc/cusbwatcher.h	Tue Jan 26 12:55:41 2010 +0200
+++ b/usbengines/usbwatcher/inc/cusbwatcher.h	Tue Feb 02 00:52:37 2010 +0200
@@ -30,7 +30,7 @@
 #include "debug.h"
 #include "musbwatchernotify.h"
 #include "cusbwatchersession.h"
-
+#include "tusbindicatorhandler.h"
 
 
 class CUsbActiveState;
@@ -438,7 +438,16 @@
      * OTG Watcher
      */
     CUsbOtgWatcher* iOtgWatcher; //OTG
-     
+    
+    /*
+     * USB indicator handler to handle device side indicator
+     */
+    TUsbIndicatorHandler iUsbIndicatorHandler;
+    
+    /*
+     * Starting mode is normal?
+     */
+    TBool iNormalStart;
     };
     
 #include "cusbwatcher.inl"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/inc/tusbindicatorhandler.h	Tue Feb 02 00:52:37 2010 +0200
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Header file for class TUsbIndicatorHandler
+*
+*/
+
+
+#ifndef TUSBINDICATORHANDLER_H
+#define TUSBINDICATORHANDLER_H
+
+#include <bldvariant.hrh>
+#include <usbstates.h>
+
+
+/**
+*  USB indicator handler class for device side.
+*
+*  This class shows USB indicator when device state changes to Configured, 
+*  and hides USB indicator when device leaves Configured state. Suspended 
+ * state does not change the indicator.
+*
+*  @since TB9.2
+*/
+NONSHARABLE_CLASS( TUsbIndicatorHandler )
+    {
+
+public:
+    /**
+     * Constructor
+     */
+    TUsbIndicatorHandler();
+    
+	/**
+     * Set USB indicator (On/Off, maybe more in future) according to 
+     * the change of USB device state
+     *
+     * @param aStateOld previous USB device state
+     * @param aStateNew current USB device state
+     */
+    void HandleDeviceStateChange( TUsbDeviceState aStateOld, 
+            TUsbDeviceState aStateNew );
+            
+private:
+	/**
+     * Show USB indicator (On/Off, maybe more in future)
+     *
+     * @since TB9.2
+     * @param aUsbIndicatorState the state of the indicator, 0: OFF, 1: ON
+     */
+    void ShowUsbIndicator( TInt aUsbIndicatorState );
+	
+private:
+    /**
+     * The device state before suspend.
+     * Used to filter out suspend from others;
+     */
+    TUsbDeviceState iDevStateB4Suspend;
+    
+    /////////////////////////////////////////////////////////////////////////
+    // Test code
+    friend class CtTUsbIndicatorHandler;
+    TBool iUsbIndicator; 
+    // 
+    /////////////////////////////////////////////////////////////////////////
+     
+    };
+    
+
+#endif   // TUSBINDICATORHANDLER_H
+
+// End of File
--- a/usbengines/usbwatcher/src/cusbactivestate.cpp	Tue Jan 26 12:55:41 2010 +0200
+++ b/usbengines/usbwatcher/src/cusbactivestate.cpp	Tue Feb 02 00:52:37 2010 +0200
@@ -95,13 +95,25 @@
     LOG_FUNC
 
     LEAVEIFERROR( iStatus.Int() ); // Close process if error happens here
-    LOG2( "DeviceState change: %d ==> %d", iPreviousState, iCurrentState );
+
     TUsbDeviceState newState = iCurrentState;
     iUsbMan.DeviceStateNotification( KUsbAllStates, iCurrentState,
             iStatus );
     SetActive();
-    iOwner.StateChangeNotify( iPreviousState, newState );
-    iPreviousState = newState;
+    
+    // Notify only if there is a change
+    if ( newState != iPreviousState )
+        {
+        LOG2( "USB device state changed: %d ==> %d", iPreviousState,
+            newState );
+        iOwner.StateChangeNotify( iPreviousState, newState );
+        iPreviousState = newState;
+        }
+     else
+        {
+        LOG2("USB device change ignored: %d -> %d", iPreviousState,
+            newState ); 
+        }
     }
  
 // ----------------------------------------------------------------------------
--- a/usbengines/usbwatcher/src/cusbwatcher.cpp	Tue Jan 26 12:55:41 2010 +0200
+++ b/usbengines/usbwatcher/src/cusbwatcher.cpp	Tue Feb 02 00:52:37 2010 +0200
@@ -222,7 +222,14 @@
     {
     LOG_FUNC
 
-    if( IsDeviceA() ) // Will be handled by UsbOtgWatcher
+    // Handling USB indicator. This is valid for both A- and B-device cases.
+    // Not show USB indicator in charging mode
+    if ( iNormalStart ) 
+        {
+        iUsbIndicatorHandler.HandleDeviceStateChange( aStateOld, aStateNew );
+        }
+        
+    if ( IsDeviceA() ) // Will be handled by UsbOtgWatcher
         {
         LOG( "Device state change ignored by UsbWatcher in A-device state" );
         return;
@@ -533,13 +540,6 @@
 
     LOG2( "aPersonalityId=%d, aNonBlocking=%d", aPersonalityId, aNonBlocking );
 
-    if( IsDeviceA() ) 
-        {
-        LOG( "SetPersonality not allowed in A-device state" );
-        Notify( KErrAccessDenied );
-        return;
-        }
-    
     // Check if personality is exist
     TBool found = EFalse;
 
@@ -679,17 +679,21 @@
     {
     LOG_FUNC
 
-    if( IsDeviceA() ) 
-        {
-        LOG( "Not allowed in A-device state" );
-        Notify( KErrAccessDenied );
-        return;
-        }
 
     TUsbDeviceState state = iActiveState->CurrentState();
-    LOG1( "Device state : %d", state );
+    LOG2( "IsDeviceA: %d, Device state : %d", IsDeviceA(), state );
 
-    if( state != EUsbDeviceStateUndefined )
+    // As A-device, only cenrep will be updated for the reasons of
+    // - In A-host state, device state will be undefined 
+    // - In A-peripheral state, personality change can not happen otherwise 
+    // the connection will be lost
+    if ( IsDeviceA() || ( EUsbDeviceStateUndefined == state ) )
+        {
+        // if no connection -> just save the setting
+        LOG( "CUsbWatcher::SwitchPersonality: Notify" );
+        Notify( KErrNone );
+        }
+    else
         {
         switch ( iState )
             {
@@ -722,12 +726,6 @@
                 break;
             }
         }
-    else
-        {
-        // if no connection -> just save the setting
-        LOG( "CUsbWatcher::SwitchPersonality: Notify" );
-        Notify( KErrNone );
-        }
     }
 
 // ----------------------------------------------------------------------------
@@ -743,6 +741,7 @@
     if( iState == EUsbIdle )
         {
         iStarted = EFalse;
+        iNormalStart = EFalse;
         if( globalState == ESwStateCharging )
             {
             LOG( "Global state: charging" );
@@ -770,6 +769,7 @@
                    ( ESwStateNormalBTSap == globalState ) ))
             {
             LOG( "Global state: normal" );
+            iNormalStart = ETrue;
             if( ! iUsbDeviceLock->Locked() )
                 {
                 iGlobalStateObserver->Cancel();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbengines/usbwatcher/src/tusbindicatorhandler.cpp	Tue Feb 02 00:52:37 2010 +0200
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This implements TUsbIndicatorHandler class.
+*
+*/
+
+
+#include <e32std.h>
+#include <AknNotifySignature.h> // SAknNotifierPackage
+#include <avkon.hrh> //EAknIndicatorUSBConnection
+#include "tusbindicatorhandler.h"
+#include "debug.h"
+
+// ---------------------------------------------------------------------------
+// C++ Constructor 
+// ---------------------------------------------------------------------------
+//
+TUsbIndicatorHandler::TUsbIndicatorHandler() 
+    : iDevStateB4Suspend( EUsbDeviceStateUndefined )
+    , iUsbIndicator(EFalse)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Change USB Indicator 
+// ---------------------------------------------------------------------------
+//
+void TUsbIndicatorHandler::HandleDeviceStateChange( TUsbDeviceState aStateOld, 
+            TUsbDeviceState aStateNew )
+    {
+    LOG_FUNC
+
+    LOG2( "USB device state changed: %d ==> %d", aStateOld, aStateNew );
+    
+    if ( EUsbDeviceStateConfigured == aStateNew ) // Entering configed state 
+        {
+        // filter out case of configed -> suspended -> configed
+        if ( ( EUsbDeviceStateSuspended != aStateOld ) || 
+             ( EUsbDeviceStateConfigured != iDevStateB4Suspend) )
+            {
+            ShowUsbIndicator( ETrue );
+            }
+        }
+    else if ( EUsbDeviceStateSuspended == aStateNew )
+    // If current state is suspend, we do not change the indicator, but save
+    // the previous state
+        {
+        iDevStateB4Suspend = aStateOld;
+        }
+    else // New device state is not configured, nor suspended
+        {
+        // Hide USB indicator if previous state is either configured, or
+        // suspended AND state before is not configured
+        if( ( EUsbDeviceStateConfigured == aStateOld ) ||
+            ( ( EUsbDeviceStateSuspended == aStateOld ) &&
+              ( EUsbDeviceStateConfigured == iDevStateB4Suspend ) ) ) 
+            {
+            ShowUsbIndicator( EFalse );
+            }
+        } 
+    }
+    
+// ---------------------------------------------------------------------------
+// Show USB Indicator
+// ---------------------------------------------------------------------------
+//
+void TUsbIndicatorHandler::ShowUsbIndicator( TInt aUsbIndicatorState )
+    {
+    LOG_FUNC
+    
+    iUsbIndicator = aUsbIndicatorState;
+    LOG1( "USB indicator state %d", aUsbIndicatorState );
+    RNotifier notifier;
+    TInt err = notifier.Connect();
+    if ( KErrNone == err )
+        {
+        TPckgBuf< SAknNotifierPackage<SAknSmallIndicatorParams> > pckg;
+        pckg().iParamData.iSmallIndicatorUid =
+            TUid::Uid( EAknIndicatorUSBConnection );
+        pckg().iParamData.iValue = aUsbIndicatorState ? 
+            EAknIndicatorStateOn : EAknIndicatorStateOff ;
+        notifier.StartNotifier( KAknSmallIndicatorUid, pckg );
+        notifier.Close();
+        }
+    else
+        {
+        LOG1( "RNotifier::Connect error: %d", err );
+        }
+    }
+
+// End of file
--- a/usbuis/usbuinotif/group/usbuinotif.mmp	Tue Jan 26 12:55:41 2010 +0200
+++ b/usbuis/usbuinotif/group/usbuinotif.mmp	Tue Feb 02 00:52:37 2010 +0200
@@ -33,6 +33,10 @@
 SOURCE          usbuinotifotgwarning.cpp
 SOURCE          usbuinotifotgerror.cpp 
 SOURCE          usbuinotifmsmmerror.cpp
+SOURCE          usbuinotifdialerwatcher.cpp
+
+
+
 // ECom resource file
 START RESOURCE ../data/102068DC.rss
 TARGET  usbuinotif.rsc 
@@ -74,6 +78,8 @@
 LIBRARY aknnotifierwrapper.lib              // Avkon's notifier wrapper
 LIBRARY         apparc.lib 
 LIBRARY akncapserverclient.lib              // for suppressing the application key
+LIBRARY viewcli.lib 
+LIBRARY featmgr.lib
 
 DEBUGLIBRARY flogger.lib                    // File logging services
 
--- a/usbuis/usbuinotif/inc/usbuincableconnectednotifier.h	Tue Jan 26 12:55:41 2010 +0200
+++ b/usbuis/usbuinotif/inc/usbuincableconnectednotifier.h	Tue Feb 02 00:52:37 2010 +0200
@@ -120,6 +120,16 @@
      *  C++ default constructor.
      */
     CUSBUICableConnectedNotifier();
+    
+    /**
+     * Waiter for canceling notifier. Canceling is not posible when note is visible
+     */
+    CActiveSchedulerWait    iNoteWaiter;    
+    
+    /**
+    * Note visible
+    */
+    TBool   iNoteVisible;
 
     };
 #endif // USBUINCABLECONNECTEDNOTIFIER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/inc/usbuinotifdialerwatcher.h	Tue Feb 02 00:52:37 2010 +0200
@@ -0,0 +1,135 @@
+/*
+* Copyright (c) 2007, 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declares USB dialer activation watcher class
+ *
+*/
+
+#ifndef C_USBUINOTIFDIALERWATCHER_H
+#define C_USBUINOTIFDIALERWATCHER_H
+
+#include <e32base.h>
+#include <coecntrl.h> 
+#include <viewclipartner.h> 
+#include <viewcli.h> 
+
+
+/**
+ * Dialer activation callback
+ *
+ * This class specifies the functions when dialer is activated 
+ * or note can be reactivated 
+ * 
+ */
+class MDialerNotifier
+    {
+public:
+    /**     
+     * The function to be when Dialaer is activated
+     *          
+     */
+    virtual void DialerActivated() = 0;
+    
+    /**     
+     * The function to be when Dialaer is deactivated
+     * and note can be shown again
+     *          
+     */
+    virtual void ReActivateDialog() = 0;
+    };
+
+/** 
+ *
+ * This class will check if application key is pressed when error note is active. 
+ * When application key is pressed dialer view is activated and error notifier is 
+ * informed so it can dismis dialog. When dialer is deactivated error notifier is 
+ * notified that dialog can be again shown.
+ *
+ */
+NONSHARABLE_CLASS( CUsbuinotifDialerWatcher):  public CCoeControl,  
+                                               public MVwsSessionWrapperObserver  
+
+    {
+public:
+    /**
+     * Two-phased constructor.     
+     * @param aDialerKeyNotifier Callback interface for dialer activation/deactivation
+     * @return dialer watcher
+     */
+     
+    static CUsbuinotifDialerWatcher* NewL( MDialerNotifier* aDialerNotifier );
+
+    /**
+     * Two-phased constructor.
+     * @param aDialerKeyNotifier Callback interface for dialer activation/deactivation     
+     * @return dialer watcher 
+     */
+    static CUsbuinotifDialerWatcher* NewLC( MDialerNotifier* aDialerNotifier  );
+
+    /**
+     * Destructor
+     */
+    virtual ~CUsbuinotifDialerWatcher();
+    
+private:
+    
+    /**
+     * From CCoeControl
+     * @param aKeyEvent Key Event
+     * @param aType Type of event
+     */
+    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);    
+
+private:
+    
+    /**
+     * From MVwsSessionWrapperObserver
+     * @param aEvent View event
+     */
+    void HandleViewEventL(const TVwsViewEvent &aEvent);
+    
+
+private:
+
+    /**
+     * Constructor
+     * @param aDialerKeyNotifier Callback interface for dialer activation/deactivation     
+     */
+    CUsbuinotifDialerWatcher( MDialerNotifier* aDialerKeyNotifier  );
+    
+    /**
+     * Two-phased constructor.
+     */
+    void ConstructL();
+
+private:
+    // Member variables
+    
+    /**
+     *  The observer for this objects events
+     *  Not own. 
+     */
+    MDialerNotifier* iNotify;
+    
+    /**
+     *  The observer for this objects events
+     *  Own. 
+     */
+    CVwsSessionWrapper* iwsSession;
+    
+    /**
+     * Is notifier allready notified. 
+     */
+    TBool iNotified;
+    };
+#endif // C_USBUINOTIFDIALERWATCHER_H
--- a/usbuis/usbuinotif/inc/usbuinotifmsmmerror.h	Tue Jan 26 12:55:41 2010 +0200
+++ b/usbuis/usbuinotif/inc/usbuinotifmsmmerror.h	Tue Feb 02 00:52:37 2010 +0200
@@ -23,6 +23,8 @@
 
 #include "usbnotifier.h"      // Base class
 #include <AknQueryDialog.h>   // AVKON component
+#include "usbuinotifdialerwatcher.h"
+
 #define KUsbUiNotifOtgGeneralQueryGranularity 3
 // CLASS DECLARATION
 
@@ -32,7 +34,7 @@
  *
  *  @lib
  */
-NONSHARABLE_CLASS(CUsbUiNotifMSMMError) : public CUSBUINotifierBase
+NONSHARABLE_CLASS(CUsbUiNotifMSMMError) : public CUSBUINotifierBase, public MDialerNotifier
     {
 public:
 
@@ -95,6 +97,23 @@
      */
     void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot,
             const RMessagePtr2& aMessage);
+    
+private:
+    
+    /**
+     * From MDialerNotifier     
+     * The function to be when Dialaer is activated
+     *          
+     */
+    void DialerActivated();
+    
+    /**
+     * From MDialerNotifier     
+     * The function to be when Dialaer is deactivated
+     * and note can be shown again
+     *          
+     */
+    void ReActivateDialog();
 
 private:
 
@@ -121,5 +140,14 @@
     CAknQueryDialog* iQuery; 
     RArray<TInt> iStringIds;
     TInt iErrorId;
+    /**
+     * Dialer watcher 
+     * Own.
+     */
+    CUsbuinotifDialerWatcher* iDialerWatcher;
+    /**
+     * Dialog is dismissed. 
+     */
+    TBool iDismissed;
     };
 #endif // USBUINOTIFMSMMERROR_H
--- a/usbuis/usbuinotif/inc/usbuinotifotgerror.h	Tue Jan 26 12:55:41 2010 +0200
+++ b/usbuis/usbuinotif/inc/usbuinotifotgerror.h	Tue Feb 02 00:52:37 2010 +0200
@@ -23,6 +23,8 @@
 
 #include "usbnotifier.h"      // Base class
 #include <AknQueryDialog.h>   // AVKON component
+#include "usbuinotifdialerwatcher.h"
+
 #define KUsbUiNotifOtgGeneralQueryGranularity 3
 // CLASS DECLARATION
 
@@ -32,7 +34,7 @@
  *
  *  @lib
  */
-NONSHARABLE_CLASS(CUsbUiNotifOtgError) : public CUSBUINotifierBase
+NONSHARABLE_CLASS(CUsbUiNotifOtgError) : public CUSBUINotifierBase, public MDialerNotifier
     {
 public:
     // Constructors and destructor
@@ -85,6 +87,23 @@
      */
     void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot,
             const RMessagePtr2& aMessage);
+    
+private:
+    
+    /**
+     * From MDialerNotifier     
+     * The function to be when Dialaer is activated
+     *          
+     */
+    void DialerActivated();
+    
+    /**
+     * From MDialerNotifier     
+     * The function to be when Dialaer is deactivated
+     * and note can be shown again
+     *          
+     */
+    void ReActivateDialog();
 
 private:
 
@@ -111,5 +130,14 @@
     CAknQueryDialog* iQuery; 
     RArray<TInt> iStringIds;
     TInt iErrorId;
+    /**
+     * Dialer watcher 
+     * Own.
+     */
+    CUsbuinotifDialerWatcher* iDialerWatcher;
+    /**
+     * Dialog is dismissed. 
+     */
+    TBool iDismissed;
     };
 #endif // USBUINOTIFOTGERROR_H
--- a/usbuis/usbuinotif/src/usbuincableconnectednotifier.cpp	Tue Jan 26 12:55:41 2010 +0200
+++ b/usbuis/usbuinotif/src/usbuincableconnectednotifier.cpp	Tue Feb 02 00:52:37 2010 +0200
@@ -75,7 +75,8 @@
 // might leave.
 // ----------------------------------------------------------------------------
 //
-CUSBUICableConnectedNotifier::CUSBUICableConnectedNotifier()
+CUSBUICableConnectedNotifier::CUSBUICableConnectedNotifier(): 
+    iNoteVisible(EFalse)
     {
     FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::default constructor"));
     }
@@ -145,7 +146,7 @@
 void CUSBUICableConnectedNotifier::RunL()
     {
     FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::RunL"));
-
+    iNoteVisible = ETrue;
     DisableKeylock();
     SuppressAppSwitching(ETrue);
     RunQueryL();
@@ -163,7 +164,12 @@
 void CUSBUICableConnectedNotifier::Cancel()
     {
     FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::Cancel() "));
-
+    // Not allowed to cancel this one before note is closed.
+    if ( iNoteVisible )
+        {
+        iNoteWaiter.Start();    
+        }
+        
     CompleteMessage(KErrCancel);
     CUSBUINotifierBase::Cancel();
 
@@ -212,10 +218,10 @@
    TFileName usbUiIconFilename( KFileDrive );
    usbUiIconFilename += KDC_APP_BITMAP_DIR;
    usbUiIconFilename += KUSBUIconFileName;
+   iNoteVisible = ETrue;
    CAknDiscreetPopup::ShowGlobalPopupL(*header,*description,  KAknsIIDQgnPropUsb, AknIconUtils::AvkonIconFileName(),
-           EMbmAvkonQgn_prop_usb, EMbmAvkonQgn_prop_usb_mask,KAknDiscreetPopupDurationLong, EUSBUICmdDiscreetTapped,( MEikCommandObserver* ) this);
- 
-    CompleteMessage(KErrCancel);
+           EMbmAvkonQgn_prop_usb, EMbmAvkonQgn_prop_usb_mask,KAknDiscreetPopupDurationLong, EUSBUICmdDiscreetTapped,( MEikCommandObserver* ) this);    
+   
     CleanupStack::PopAndDestroy(description);
     CleanupStack::PopAndDestroy(header);
    
@@ -252,6 +258,13 @@
             TUidType uidtype(KExecutableImageUid, TUid::Uid(0x00),TUid::Uid(KUSBUIUid));
             CreateChosenViewL(KUSBExe(),uidtype);  
             }
+        case EAknDiscreetPopupCmdClose:                
+            if ( iNoteWaiter.IsStarted() )
+                {
+                iNoteWaiter.AsyncStop();
+                }
+            iNoteVisible = EFalse;    
+            CompleteMessage( KErrCancel );                    
             break;
         default:
                   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usbuis/usbuinotif/src/usbuinotifdialerwatcher.cpp	Tue Feb 02 00:52:37 2010 +0200
@@ -0,0 +1,128 @@
+/*
+* Copyright (c) 2007, 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  USB dialer activation watcher class
+ *
+*/
+
+
+#include <w32std.h>  
+#include <eikenv.h> 
+#include <coeaui.h> 
+#include <aiscutdefs.h>
+#include <vwsdef.H>
+
+
+#include "usbuinotifdialerwatcher.h"
+#include "debug.h"
+#include "usbuinotifdebug.h"
+
+// ======== MEMBER FUNCTIONS ========
+// ---------------------------------------------------------------------------
+// NewL
+// ---------------------------------------------------------------------------
+//
+CUsbuinotifDialerWatcher* CUsbuinotifDialerWatcher::NewL( MDialerNotifier* aDialerNotifier )
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbuinotifDialerWatcher::NewL"))
+    CUsbuinotifDialerWatcher* self = CUsbuinotifDialerWatcher::NewLC( aDialerNotifier);
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// NewLC
+// ---------------------------------------------------------------------------
+//    
+CUsbuinotifDialerWatcher* CUsbuinotifDialerWatcher::NewLC( MDialerNotifier* aDialerNotifier )
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbuinotifDialerWatcher::NewLC"))
+    CUsbuinotifDialerWatcher* self = new ( ELeave ) CUsbuinotifDialerWatcher( aDialerNotifier );
+    CleanupStack::PushL( self );
+    self->ConstructL(  );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CUsbuinotifDialerWatcher()
+// ---------------------------------------------------------------------------
+//
+CUsbuinotifDialerWatcher::CUsbuinotifDialerWatcher( MDialerNotifier* aDialerNotifier ) :
+    iNotify( aDialerNotifier )
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbuinotifDialerWatcher::CUsbuinotifDialerWatcher"))
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CUsbuinotifDialerWatcher::~CUsbuinotifDialerWatcher()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbuinotifDialerWatcher Destructor"))
+    CCoeAppUi* appui=CEikonEnv::Static()->AppUi();
+    appui->RemoveFromStack(this);
+    delete iwsSession;
+    }
+    
+// ---------------------------------------------------------------------------
+// ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CUsbuinotifDialerWatcher::ConstructL()
+    {    
+    FLOG(_L("[USBUINOTIF]\t CUsbuinotifDialerWatcher ConstructL"));    
+    CCoeAppUi* appui=CEikonEnv::Static()->AppUi();
+    appui->AddToStackL(this,ECoeStackPriorityCba);    
+    }
+
+// ---------------------------------------------------------------------------
+// HandleViewEventL()
+// ---------------------------------------------------------------------------
+//
+void CUsbuinotifDialerWatcher::HandleViewEventL(const TVwsViewEvent& /*aEvent*/)
+    {
+    FLOG((_L("[USBUINOTIF]\t HandleViewEventL ")));
+    
+    if ( !iNotified )
+        {
+        iNotify->ReActivateDialog();
+        iNotified=ETrue;        
+        }
+    FLOG(_L("[USBUINOTIF]\t HandleViewEventL Done"));
+    }
+
+// ---------------------------------------------------------------------------
+// OfferKeyEventL
+// ---------------------------------------------------------------------------
+//
+TKeyResponse CUsbuinotifDialerWatcher::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
+    {     
+    if (aKeyEvent.iScanCode == EStdKeyApplication0)
+        {    
+        if ( !iwsSession )
+            {
+            iwsSession = CVwsSessionWrapper::NewL(*this);
+            }
+        iNotified=EFalse;
+        const TVwsViewId viewId(KScutDiallerUid, KScutDiallerViewId );
+        TUid msgId = KScutDiallerViewCommand;            
+        iwsSession->CreateActivateViewEvent( viewId, msgId, KNullDesC8  );            
+        CCoeAppUi* appui=CEikonEnv::Static()->AppUi();                        
+        iNotify->DialerActivated();
+        iwsSession->NotifyNextDeactivation(viewId);  
+        }
+        
+    return EKeyWasNotConsumed;
+    }
+
--- a/usbuis/usbuinotif/src/usbuinotifmsmmerror.cpp	Tue Jan 26 12:55:41 2010 +0200
+++ b/usbuis/usbuinotif/src/usbuinotifmsmmerror.cpp	Tue Feb 02 00:52:37 2010 +0200
@@ -24,6 +24,7 @@
 #include <AknQueryDialog.h> 
 #include <aknnotewrappers.h>
 #include <usb/hostms/srverr.h> 
+#include <featmgr.h>
 
 #include <usbuinotif.h>                     // pck
 #include <usbuinotif.rsg>                   // Own resources
@@ -67,6 +68,8 @@
     //this virtual function call is to local CUsbUiNotifMSMMError::Cancel, 
     //not to any possibly derived class implementation. 
     Cancel();
+    delete iDialerWatcher;    
+    delete iQuery;    
     }
 
 void CUsbUiNotifMSMMError::ConstructL()
@@ -141,16 +144,28 @@
     {
     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::RunL"));
     TInt returnValue = KErrNone;
-
+    FeatureManager::InitializeLibL();
+    if ( FeatureManager::FeatureSupported( KFeatureIdFfKeypadNoSendKey ) )
+        { 
+        if (!iDialerWatcher)
+            {
+            iDialerWatcher = CUsbuinotifDialerWatcher::NewL(this);
+            }
+        }        
+    iDismissed=EFalse;
     DisableKeylock();
     SuppressAppSwitching( ETrue );
 
     //Excute dialog and check return value
     returnValue = QueryUserResponseL();
-
-    SuppressAppSwitching( EFalse );
-    RestoreKeylock();
-    CompleteMessage( returnValue );
+    if (!iDismissed)
+        {
+        SuppressAppSwitching( EFalse );
+        RestoreKeylock();
+        delete iDialerWatcher;
+        iDialerWatcher = NULL;
+        CompleteMessage( returnValue );
+        }
 
     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::RunL() completed"));
     }
@@ -163,17 +178,56 @@
 void CUsbUiNotifMSMMError::Cancel()
     {
     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel"));
+    // If dialog is not dismissed this is normal cancel and if query
+    // doesn't exsist notifier is canceled during dismission
+    if (!iDismissed || !iQuery )
+        {        
+        delete iDialerWatcher;
+        iDialerWatcher = NULL;
+        CompleteMessage( KErrCancel );
+        }        
     if (iQuery)
         {
         delete iQuery;
         iQuery = NULL;
         }
-    CompleteMessage( KErrCancel );
+
 
     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel() completed"));
     }
 
 // ----------------------------------------------------------------------------
+// CUsbUiNotifOtgError::DialerActivated
+// Release all own resources (member variables)
+// ----------------------------------------------------------------------------
+//
+void CUsbUiNotifMSMMError::DialerActivated()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::AppKeyPressed()"));
+    if ( iQuery )
+        {
+        iDismissed=ETrue;    
+        Cancel();
+        }    
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgError::ReActivateDialog
+// Release all own resources (member variables)
+// ----------------------------------------------------------------------------
+//	
+void CUsbUiNotifMSMMError::ReActivateDialog()
+    {    
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::ReActivateDialog()"));
+    if ( !IsActive())
+        {
+        SetActive();
+        iStatus = KRequestPending;
+        TRequestStatus* stat = &iStatus;
+        User::RequestComplete( stat, KErrNone );
+        }
+    }	
+// ----------------------------------------------------------------------------
 // CUsbUiNotifMSMMError::QueryUserResponseL
 // Show query dialog. 
 // ----------------------------------------------------------------------------
@@ -183,9 +237,17 @@
     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::QueryUserResponseL"));
     TInt returnValue = KErrNone;
     TInt resourceId = R_USB_QUERY_OTG_ERROR;
-
-    iQuery = CAknQueryDialog::NewL( CAknQueryDialog::EErrorTone );
-
+    if (iDismissed)
+        {
+        iQuery = CAknQueryDialog::NewL();
+        }
+    else
+        {
+        iQuery = CAknQueryDialog::NewL( CAknQueryDialog::EErrorTone );
+        }
+    
+    
+    iDismissed=EFalse;
     if (iCoverDisplaySupported)
         {
         iQuery->PublishDialogL( iErrorId, KUsbUiNotifMsmmError );
--- a/usbuis/usbuinotif/src/usbuinotifotgerror.cpp	Tue Jan 26 12:55:41 2010 +0200
+++ b/usbuis/usbuinotif/src/usbuinotifotgerror.cpp	Tue Feb 02 00:52:37 2010 +0200
@@ -23,6 +23,7 @@
 #include <StringLoader.h>    // Localisation stringloader
 #include <AknQueryDialog.h> 
 #include <aknnotewrappers.h>
+#include <featmgr.h>
 
 #include <usbuinotif.h>                     // pck
 #include <usbuinotif.rsg>                   // Own resources
@@ -66,6 +67,8 @@
     //this virtual function call is to local CUsbUiNotifOtgError::Cancel, 
     //not to any possibly derived class implementation. 
     Cancel();
+    delete iDialerWatcher;    
+    delete iQuery;    
     }
 
 void CUsbUiNotifOtgError::ConstructL()
@@ -133,16 +136,29 @@
     {
     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::RunL"));
     TInt returnValue = KErrNone;
-
+    FeatureManager::InitializeLibL();
+    if ( FeatureManager::FeatureSupported( KFeatureIdFfKeypadNoSendKey ) )
+        {    
+        if (!iDialerWatcher)
+            {
+            iDialerWatcher = CUsbuinotifDialerWatcher::NewL(this);
+            }
+        }        
+    FeatureManager::UnInitializeLib(); 
+    iDismissed=EFalse;
     DisableKeylock();
     SuppressAppSwitching( ETrue );
 
     //Excute dialog and check return value
     returnValue = QueryUserResponseL();
-
-    SuppressAppSwitching( EFalse );
-    RestoreKeylock();
-    CompleteMessage( returnValue );
+    if (!iDismissed)
+        {
+        SuppressAppSwitching( EFalse );
+        RestoreKeylock();
+        delete iDialerWatcher;
+        iDialerWatcher = NULL;
+        CompleteMessage( returnValue );
+        }
 
     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::RunL() completed"));
     }
@@ -154,15 +170,54 @@
 //
 void CUsbUiNotifOtgError::Cancel()
     {
-    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel"));
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel"));    
+    
+    // If dialog is not dismissed this is normal cancel and if query
+    // doesn't exsist notifier is canceled during dismission
+    if (!iDismissed || !iQuery )
+        {        
+        delete iDialerWatcher;
+        iDialerWatcher = NULL;
+        CompleteMessage( KErrCancel );
+        }        
     if (iQuery)
         {
         delete iQuery;
         iQuery = NULL;
         }
-    CompleteMessage( KErrCancel );
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel() completed"));
+    }
 
-    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel() completed"));
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgError::DialerActivated
+// Release all own resources (member variables)
+// ----------------------------------------------------------------------------
+//
+void CUsbUiNotifOtgError::DialerActivated()
+    {
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::AppKeyPressed()"));
+    if ( iQuery )
+        {
+        iDismissed=ETrue;    
+        Cancel();
+        }    
+    }
+
+// ----------------------------------------------------------------------------
+// CUsbUiNotifOtgError::ReActivateDialog
+// Release all own resources (member variables)
+// ----------------------------------------------------------------------------
+//   
+void CUsbUiNotifOtgError::ReActivateDialog()
+    {    
+    FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::ReActivateDialog()"));
+    if ( !IsActive())
+        {
+        SetActive();
+        iStatus = KRequestPending;
+        TRequestStatus* stat = &iStatus;
+        User::RequestComplete( stat, KErrNone );
+        }
     }
 
 // ----------------------------------------------------------------------------
@@ -175,9 +230,17 @@
     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::QueryUserResponseL"));
     TInt returnValue = KErrNone;
     TInt resourceId = R_USB_QUERY_OTG_ERROR;
-
-    iQuery = CAknQueryDialog::NewL( CAknQueryDialog::EErrorTone );
-
+    if (iDismissed)
+        {
+        iQuery = CAknQueryDialog::NewL();
+        }
+    else
+        {
+        iQuery = CAknQueryDialog::NewL( CAknQueryDialog::EErrorTone );
+        }
+    
+    
+    iDismissed=EFalse;
     if (iCoverDisplaySupported)
         {
         iQuery->PublishDialogL( iErrorId, KUsbUiNotifOtgError );