examples/SFExamples/RecipeEx/src/MobilityView.cpp

00001 // Symbian Foundation Example Code
00002 // 
00003 // This software is in the public domain. No copyright is claimed, and you 
00004 // may use it for any purpose without license from the Symbian Foundation.
00005 // No warranty for any purpose is expressed or implied by the authors or
00006 // the Symbian Foundation. 
00007 
00008 
00009 // Includes
00010 #include <aknviewappui.h>
00011 #include <avkon.hrh>
00012 #include <RecipeEx_0xE8FAA390.rsg>
00013 #include <eikmenup.h>
00014 
00015 #include "MobilityView.h"
00016 #include "LogContainer.h"
00017 #include "LogContainer.h" 
00018 #include "RecipeEx.hrh"
00019 #include "MobilityEngine.h"
00020 #include "MainView.h" // KMainViewId
00021 
00022 
00023 // ================= MEMBER FUNCTIONS =======================
00024 
00026 CMobilityView* CMobilityView::NewL()
00027         {
00028         CMobilityView* self = CMobilityView::NewLC();
00029         CleanupStack::Pop( self );
00030         return self;
00031         }
00032 
00034 CMobilityView* CMobilityView::NewLC()
00035         {
00036         CMobilityView* self = new ( ELeave ) CMobilityView;
00037         CleanupStack::PushL( self );
00038         self->ConstructL();
00039         return self;
00040         }
00041 
00043 void CMobilityView::ConstructL()
00044     {
00045     BaseConstructL( R_MOBILITY_VIEW );
00046     }
00047 
00049 CMobilityView::~CMobilityView()
00050     {
00051     if (iLogContainer)
00052         {
00053         AppUi()->RemoveFromViewStack(*this, iLogContainer);
00054         }
00055 
00056     delete iLogContainer;
00057     }
00058 
00060 TUid CMobilityView::Id() const
00061     {
00062     return KMobilityViewId;
00063     }
00064 
00071 void CMobilityView::HandleCommandL(TInt aCommand)
00072     {   
00073     switch ( aCommand )
00074         {
00075         case EConnect:
00076                 {
00077                 iMobilityEngine->ConnectL();
00078                 break;
00079                 }
00080         case EDisconnect:
00081                 {
00082                 iMobilityEngine->Disconnect();
00083                 break;
00084                 }
00085         case EAknSoftkeyBack:
00086                 {
00087             AppUi()->ActivateLocalViewL(KMainViewId);
00088                 break;
00089                 }       
00090         default:
00091             {
00092             AppUi()->HandleCommandL( aCommand );
00093             break;
00094             }
00095         }
00096     }
00097 
00108 void CMobilityView::DoActivateL(
00109    const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
00110    const TDesC8& /*aCustomMessage*/)
00111         {
00112     if (!iLogContainer)
00113         {
00114         iLogContainer = CLogContainer::NewL(ClientRect());
00115         iLogContainer->SetMopParent(this);
00116         AppUi()->AddToStackL( *this, iLogContainer );
00117         } 
00118     if (!iMobilityEngine)
00119         {
00120         iMobilityEngine = CMobilityEngine::NewL(iLogContainer);
00121         }
00122         }
00123 
00129 void CMobilityView::DoDeactivate()
00130     {
00131     if ( iMobilityEngine )
00132         {
00133         delete iMobilityEngine; 
00134         iMobilityEngine = NULL;
00135         }
00136 
00137     if ( iLogContainer )
00138         {
00139         AppUi()->RemoveFromViewStack( *this, iLogContainer );
00140         }
00141     
00142     delete iLogContainer;
00143     iLogContainer = NULL;
00144     
00145     }
00146 
00150 void CMobilityView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
00151     {
00152     if (aResourceId == R_MOBILITY_VIEW_MENU)
00153         {
00154         // Toggle connection commands according to connection state
00155         TBool idle = iMobilityEngine->IsIdle();
00156         aMenuPane->SetItemDimmed(EConnect, !idle);
00157         aMenuPane->SetItemDimmed(EDisconnect, idle);    
00158         }
00159     }
00160 
00161 // End of File

Generated by  doxygen 1.6.2