⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iapconnectconninfoview.cpp

📁 symbian中如何取得内部联网方式
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CIAPConnectConnInfoView from IAPConnectConnInfoView.cpp
*  Part of  : Internet Access Points Example v2.0
*  Created  : 01.09.2006 by Forum Nokia
*  Version  : 2.0
*  Copyright: Forum Nokia
* ============================================================================
*/

// INCLUDE FILES
#include <iapconnect.rsg>
#include  <aknviewappui.h>
#include  <avkon.hrh>
#include  <AknDialog.h> 
#include <aknnotewrappers.h>  // CAknInformationNote
#include <txtetext.h> // CEditableText::ELineBreak
#include <eikmenup.h>
#include "IAPConnectConnInfoView.h"
#include "IAPConnectConnInfoContainer.h"
#include "IAPConnect.hrh"

// CONSTANTS
_LIT(KDemoServerName, "forum.nokia.com");
_LIT(KConnIndexNotFound, "Unable to get connection index");
_LIT(KNoConnection, "No connection");
const TInt KTempBufferLength = 10;
const TInt KDefaultTransferLimit = 1024;

// ================= MEMBER FUNCTIONS =======================

// Constructor
CIAPConnectConnInfoView::CIAPConnectConnInfoView(CIAPConnectAppUi& anAppUi):
iAppUi(anAppUi), iDemoStarted(EFalse)
	{
	}

// Destructor
CIAPConnectConnInfoView::~CIAPConnectConnInfoView()
    {
    if ( iContainer )
        {
        AppUi()->RemoveFromViewStack( *this, iContainer );
	    delete iContainer;
        iContainer = NULL;
        }
    if (iMonitor)
    	{
   		delete iMonitor;
        iMonitor = NULL;
    	}
    if (iDemoSettings)
        {
        delete iDemoSettings;
        iDemoSettings = NULL;
        }
    }

// ---------------------------------------------------------
// CIAPConnectConnInfoView::ConstructL()
// Symbian two-phased constructor
// ---------------------------------------------------------
//
void CIAPConnectConnInfoView::ConstructL( )
    {
    BaseConstructL( R_IAPCONNECT_CONNINFO_VIEW );
    }


// ---------------------------------------------------------
// TUid CIAPConnectConnInfoView::Id()
// Returns the id of the view.
// ---------------------------------------------------------
//
TUid CIAPConnectConnInfoView::Id() const
    {
    return KViewConnInfoId;
    }

// ---------------------------------------------------------
// CIAPConnectConnInfoView::HandleCommandL()
// takes care of view command handling
// ---------------------------------------------------------
//
void CIAPConnectConnInfoView::HandleCommandL(TInt aCommand)
    {   
    switch ( aCommand )
        {
        case EAknSoftkeyBack:
            {
            //Back to event log view
            AppUi() -> HandleCommandL(EIAPConnectCmdAppMainMenu);
            break;
            }
        case EIAPConnectCmdStartDemo:
	    	{
            // Get a pointer to the demo engine via the actual engine class
            CIAPConnectDemoEngine* demoEngine = iAppUi.Model()->DemoEngine();
            iContainer->ClearInfoL();
            iDemoStarted = ETrue;
            demoEngine->StartDemoL(iDemoSettings);
			break;	        	
			}
        case EIAPConnectCmdDemoSettings:
            {
            CIAPConnectDemoSettingsDialog* settingsDialog = 
                new (ELeave) CIAPConnectDemoSettingsDialog;
            
            //Give a pointer to the settings class.
            settingsDialog -> SetSettings( iDemoSettings );
             
            //Show dialog, attention: there is no need to separately delete 
            //settingsDialog
            settingsDialog -> ExecuteLD (R_IAPCONNECT_DEMO_SETTINGS_DIALOG);
            break;
            }
		case EIAPConnectCmdUplinkData:
			{
            GetMonitorInfoL(EUplinkData);
			break;
			}
		case EIAPConnectCmdDownlinkData:
			{
            GetMonitorInfoL(EDownlinkData);
			break;
			}
		case EIAPConnectCmdConnectionTime:
			{
            GetMonitorInfoL(EConnectionTime);
			break;
			}
        default:
            {
            AppUi()->HandleCommandL( aCommand );
            break;
            }
        }
    }

/*
-----------------------------------------------------------------------------

    void CIAPConnectConnInfoView::HandleStatusPaneSizeChange()

    Description: Called by framework when resource is changed.
    Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CIAPConnectConnInfoView::HandleStatusPaneSizeChange()
    {
    CAknView::HandleStatusPaneSizeChange(); //call to upper class
    if (iContainer)
        iContainer->SetRect(ClientRect());
    }


// ---------------------------------------------------------
// CIAPConnectConnInfoView::DoActivateL()
// ---------------------------------------------------------
//
void CIAPConnectConnInfoView::DoActivateL(
   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
   const TDesC8& /*aCustomMessage*/)
    {
    // Get the client rect via CAknAppUi instead of CAknView
    // (a workaround for a bug where CAknView::ClientRect() returns
    // a TRect that is too small)
    TRect rect = iAppUi.ClientRect();
        
    iDemoStarted = EFalse;
    if (!iContainer)
        {
        iContainer = new (ELeave) CIAPConnectConnInfoContainer;
        iContainer->SetMopParent(this);
        iContainer->ConstructL( rect );
        AppUi()->AddToStackL( *this, iContainer );
        }
    if (!iMonitor)
    	{
    	iMonitor = CIAPConnectDemoConnectionMonitor::NewL(*this);
		// Must be called before any other method on the monitor is called
    	iMonitor->GetActiveConnections();
    	}
    if (!iDemoSettings)
        {                       
        iDemoSettings = new (ELeave) CIAPConnectDemoSettings;
           
        // Predefined default settings
        iDemoSettings -> 
            AddSettingL( EIAPConnectDemoServerName, KDemoServerName );
        iDemoSettings -> 
            AddSettingL( EIAPConnectDemoSentData, KDefaultTransferLimit );
        iDemoSettings -> 
            AddSettingL( EIAPConnectDemoReceivedData, KDefaultTransferLimit );
        }
        
    HBufC* info = iAppUi.Model()->GetConnectionInfoL();
    iContainer->ShowInfoL(*info);
	iContainer->DrawNow();
    delete info;
	}

// ---------------------------------------------------------
// CIAPConnectConnInfoView::DoDeactivate()
// ---------------------------------------------------------
//
void CIAPConnectConnInfoView::DoDeactivate()
    {
    if (iDemoStarted && iAppUi.Model())
        {
        CIAPConnectDemoEngine* demoEngine = iAppUi.Model()->DemoEngine();
        // There's nothing we can do if the stop fails...
        TRAPD(err, demoEngine->StopDemoL());
        iDemoStarted = EFalse;
        }
    if ( iContainer )
        {
        AppUi()->RemoveFromViewStack( *this, iContainer );
		delete iContainer;
		iContainer = NULL;
        }
	if (iMonitor)
		{
		delete iMonitor;
		iMonitor = NULL;
		}  
    if (iDemoSettings)
        {
        delete iDemoSettings;
        iDemoSettings = NULL;
        }              
    }
	
// ---------------------------------------------------------
// CIAPConnectConnInfoView::ShowInfoL(const TDesC& aText)
// ---------------------------------------------------------
//
void CIAPConnectConnInfoView::ShowInfoL( const TDesC& aText )
	{
    CAknInformationNote* note = new (ELeave) CAknInformationNote();
    note -> ExecuteLD( aText );	
	}

// ---------------------------------------------------------
// void CIAPConnectConnInfoView::ErrorL(const TDesC& aErrMsg, 
//    const TInt& aErrCode)
//
// From MIAPConnectDemoEngineObserver
// ---------------------------------------------------------
//
void CIAPConnectConnInfoView::ErrorL(const TDesC& aErrMsg, 
    const TInt& aErrCode)
    {
    if (iContainer)
        {
        iContainer->AppendInfoL(aErrMsg);
        TBuf<KTempBufferLength> temp;
        temp.Append(CEditableText::ELineBreak);
        temp.AppendNum(aErrCode);
        temp.Append(CEditableText::ELineBreak);
        iContainer->AppendInfoL(temp);
        iContainer->DrawNow();
        }
    }

// ---------------------------------------------------------
// void CIAPConnectConnInfoView::SetStatusL( 
//    const TDesC& aStatusMsg )
//
// From MIAPConnectDemoEngineObserver
// ---------------------------------------------------------
//
void CIAPConnectConnInfoView::SetStatusL( 
    const TDesC& aStatusMsg )
    {
    if (iContainer)
        {
        iContainer->AppendInfoL(aStatusMsg);
        TBuf<KTempBufferLength> temp;
        temp.Append(CEditableText::ELineBreak);
        iContainer->AppendInfoL(temp);
        iContainer->DrawNow();
        }
    }

// ---------------------------------------------------------------------------
// void CIAPConnectConnInfoView::DynInitMenuPaneL(TInt aResourceId, 
//                                        CEikMenuPane* aMenuPane)
//
// Called by the framework when the menu is displayed
// ---------------------------------------------------------------------------
//
void CIAPConnectConnInfoView::DynInitMenuPaneL(TInt aResourceId, 
                                            CEikMenuPane* aMenuPane)
    {
    if (aResourceId == R_IAPCONNECT_CONNINFO_VIEW_MENU)
        {
        if (iDemoStarted)
            {
            // Hide the menu command for starting the demo...
            aMenuPane->SetItemDimmed(EIAPConnectCmdDemoMenu, ETrue);     
            // ...and show the commands for getting connection paramaters
            aMenuPane->SetItemDimmed(EIAPConnectCmdUplinkData, EFalse);                
            aMenuPane->SetItemDimmed(EIAPConnectCmdDownlinkData, EFalse);                
            aMenuPane->SetItemDimmed(EIAPConnectCmdConnectionTime, EFalse);
            }
         else
            {
            // Show the menu command for starting the demo...                
            aMenuPane->SetItemDimmed(EIAPConnectCmdDemoMenu, EFalse);                            
            // ...and hide the commands for getting connection paramaters
            aMenuPane->SetItemDimmed(EIAPConnectCmdUplinkData, ETrue);                
            aMenuPane->SetItemDimmed(EIAPConnectCmdDownlinkData, ETrue);                
            aMenuPane->SetItemDimmed(EIAPConnectCmdConnectionTime, ETrue);
            }
        }
    }
    

// ---------------------------------------------------------------------------
// void CIAPConnectConnInfoView::GetMonitorInfoL(const TMonitorState& aType)
//
// Get the requested type of info (uplink data, downlink data etc.) 
// from the connection monitor
// ---------------------------------------------------------------------------
//
void CIAPConnectConnInfoView::GetMonitorInfoL(const TMonitorState& aType)
    {
    TUint index;
    if (iAppUi.Model()->GetConnectionIndex(index) == KErrNone)
        {
        if (!iMonitor->GetInfo(index, aType))
            {
            ShowInfoL(KNoConnection);
            }
        }
    else
        {
        ShowInfoL(KConnIndexNotFound);
        }
     }
    
// End of File

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -