?? iapconnectremoveiapview.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
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -