usbuis/usbuinotif/src/usbuinotifdialerwatcher.cpp
changeset 4 7e15987c4500
child 5 7068aba64af5
equal deleted inserted replaced
3:47c263f7e521 4:7e15987c4500
       
     1 /*
       
     2 * Copyright (c) 2007, 2009 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:  USB dialer activation watcher class
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include <w32std.h>  
       
    20 #include <eikenv.h> 
       
    21 #include <coeaui.h> 
       
    22 #include <aiscutdefs.h>
       
    23 #include <vwsdef.H>
       
    24 
       
    25 
       
    26 #include "usbuinotifdialerwatcher.h"
       
    27 #include "debug.h"
       
    28 #include "usbuinotifdebug.h"
       
    29 
       
    30 // ======== MEMBER FUNCTIONS ========
       
    31 // ---------------------------------------------------------------------------
       
    32 // NewL
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 CUsbuinotifDialerWatcher* CUsbuinotifDialerWatcher::NewL( MDialerNotifier* aDialerNotifier )
       
    36     {
       
    37     FLOG(_L("[USBUINOTIF]\t CUsbuinotifDialerWatcher::NewL"))
       
    38     CUsbuinotifDialerWatcher* self = CUsbuinotifDialerWatcher::NewLC( aDialerNotifier);
       
    39     CleanupStack::Pop( self );
       
    40     return self;
       
    41     }
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // NewLC
       
    45 // ---------------------------------------------------------------------------
       
    46 //    
       
    47 CUsbuinotifDialerWatcher* CUsbuinotifDialerWatcher::NewLC( MDialerNotifier* aDialerNotifier )
       
    48     {
       
    49     FLOG(_L("[USBUINOTIF]\t CUsbuinotifDialerWatcher::NewLC"))
       
    50     CUsbuinotifDialerWatcher* self = new ( ELeave ) CUsbuinotifDialerWatcher( aDialerNotifier );
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL(  );
       
    53     return self;
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // CUsbuinotifDialerWatcher()
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 CUsbuinotifDialerWatcher::CUsbuinotifDialerWatcher( MDialerNotifier* aDialerNotifier ) :
       
    61     iNotify( aDialerNotifier )
       
    62     {
       
    63     FLOG(_L("[USBUINOTIF]\t CUsbuinotifDialerWatcher::CUsbuinotifDialerWatcher"))
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // Destructor
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 CUsbuinotifDialerWatcher::~CUsbuinotifDialerWatcher()
       
    71     {
       
    72     FLOG(_L("[USBUINOTIF]\t CUsbuinotifDialerWatcher Destructor"))
       
    73     CCoeAppUi* appui=CEikonEnv::Static()->AppUi();
       
    74     appui->RemoveFromStack(this);
       
    75     delete iwsSession;
       
    76     }
       
    77     
       
    78 // ---------------------------------------------------------------------------
       
    79 // ConstructL()
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 void CUsbuinotifDialerWatcher::ConstructL()
       
    83     {    
       
    84     FLOG(_L("[USBUINOTIF]\t CUsbuinotifDialerWatcher ConstructL"));    
       
    85     CCoeAppUi* appui=CEikonEnv::Static()->AppUi();
       
    86     appui->AddToStackL(this,ECoeStackPriorityCba);    
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // HandleViewEventL()
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 void CUsbuinotifDialerWatcher::HandleViewEventL(const TVwsViewEvent& /*aEvent*/)
       
    94     {
       
    95     FLOG((_L("[USBUINOTIF]\t HandleViewEventL ")));
       
    96     
       
    97     if ( !iNotified )
       
    98         {
       
    99         iNotify->ReActivateDialog();
       
   100         iNotified=ETrue;        
       
   101         }
       
   102     FLOG(_L("[USBUINOTIF]\t HandleViewEventL Done"));
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // OfferKeyEventL
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 TKeyResponse CUsbuinotifDialerWatcher::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
       
   110     {     
       
   111     if (aKeyEvent.iScanCode == EStdKeyApplication0)
       
   112         {    
       
   113         if ( !iwsSession )
       
   114             {
       
   115             iwsSession = CVwsSessionWrapper::NewL(*this);
       
   116             }
       
   117         iNotified=EFalse;
       
   118         const TVwsViewId viewId(KScutDiallerUid, KScutDiallerViewId );
       
   119         TUid msgId = KScutDiallerViewCommand;            
       
   120         iwsSession->CreateActivateViewEvent( viewId, msgId, KNullDesC8  );            
       
   121         CCoeAppUi* appui=CEikonEnv::Static()->AppUi();                        
       
   122         iNotify->DialerActivated();
       
   123         iwsSession->NotifyNextDeactivation(viewId);  
       
   124         }
       
   125         
       
   126     return EKeyWasNotConsumed;
       
   127     }
       
   128