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

📄 iapconnectremoveiapview.cpp

📁 这是一个手机编程s60 基于c++的关于手机连接internet的数据库协议
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CIAPConnectRemoveIapView from IAPConnectRemoveIapView.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  "IAPConnectRemoveIapView.h"
#include  "IAPConnectRemoveIapContainer.h" 
#include  "IAPConnect.hrh"
#include  <aknviewappui.h>
#include  <avkon.hrh>
#include  <aknnotewrappers.h> //infonote
#include  <commdb.h> 
#include  <AknDialog.h> 

// CONSTANTS
_LIT(KRemoveError, "Error while removing IAP");
_LIT(KIapRemoved, "IAP removed");

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

// Constructor
CIAPConnectRemoveIapView::CIAPConnectRemoveIapView(
    CIAPConnectAppUi& anAppUi) : iAppUi(anAppUi)
    {
    }

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

// ---------------------------------------------------------
// CIAPConnectRemoveIapView::ConstructL()
// Symbian two-phased constructor
// ---------------------------------------------------------
//
void CIAPConnectRemoveIapView::ConstructL( )
    {
    BaseConstructL( R_IAPCONNECT_REMOVEIAP_VIEW );
    }


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

// ---------------------------------------------------------
// CIAPConnectRemoveIapView::HandleCommandL()
// takes care of view command handling
// ---------------------------------------------------------
//
void CIAPConnectRemoveIapView::HandleCommandL(TInt aCommand)
    {   
    switch ( aCommand )
        {
        case EAknSoftkeyBack:
            {
            AppUi() -> HandleCommandL(EIAPConnectCmdAppMainMenu);
            break;
            }
        case EIAPConnectCmdRemoveIAP:
	        {
			TRAPD(error, RemoveIapL());
			if ( error == KErrNone )
				{
				iContainer -> GetIapListL();		        	
                CAknWarningNote* note = new (ELeave) CAknWarningNote();
                note -> ExecuteLD(KIapRemoved);
				}
			else
				{
				CAknWarningNote* note = new (ELeave) CAknWarningNote();
				note -> ExecuteLD(KRemoveError);
				}
			break;
	        }
        default:
            {
            AppUi()->HandleCommandL( aCommand );
            break;
            }
        }
    }

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

// ---------------------------------------------------------
// CIAPConnectRemoveIapView::DoActivateL()
// ---------------------------------------------------------
//
void CIAPConnectRemoveIapView::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();
    if (!iContainer)
        {
        iContainer = new (ELeave) CIAPConnectRemoveIapContainer;
        iContainer->SetMopParent(this);
        iContainer->ConstructL( rect );
        AppUi()->AddToStackL( *this, iContainer );
        }
   }

// ---------------------------------------------------------
// CIAPConnectRemoveIapView::DoDeactivate()
// ---------------------------------------------------------
//
void CIAPConnectRemoveIapView::DoDeactivate()
    {
    if ( iContainer )
        {
        AppUi()->RemoveFromViewStack( *this, iContainer );
        }
    
    delete iContainer;
    iContainer = NULL;
    }


// ---------------------------------------------------------
// CIAPConnectRemoveIapView::RemoveIapL()
// Remove selected IAP from database
// ---------------------------------------------------------
// 
void CIAPConnectRemoveIapView::RemoveIapL()
	{

	TUint32 selectedIapId = iContainer -> GetSelectedIapId();
	
	// open commdb
	CCommsDatabase* commDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
	CleanupStack::PushL(commDb);
	
	// open IAP table
	CCommsDbTableView* commView = 
        commDb->OpenIAPTableViewMatchingBearerSetLC(ECommDbBearerGPRS,
            ECommDbConnectionDirectionOutgoing);

	TUint32 iapId = 0;

	TInt returnValue = 0;
	
	returnValue = commView -> GotoFirstRecord();

	TInt deleteValue = 0;

	while( returnValue == KErrNone)
		{
    	commView->ReadUintL(TPtrC(COMMDB_ID), iapId);			
		if(iapId == selectedIapId)
			{
			deleteValue = commView -> DeleteRecord();
			if( deleteValue != KErrNone)
				{
				User::Leave(deleteValue);		
				}
			break;
			}
		returnValue = commView -> GotoNextRecord();
		}
	
	CleanupStack::PopAndDestroy(commView);
	CleanupStack::PopAndDestroy(commDb);
	}

// End of File

⌨️ 快捷键说明

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