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

📄 btpointtopointappui.cpp

📁 Symbian下的p2p工程
💻 CPP
字号:
/* Copyright (c) 2004, Nokia. All rights reserved */


// INCLUDE FILES
#include <avkon.hrh>
#include <eikmenup.h>
#include <BtPointToPoint.rsg>

#include "BTPointToPoint.pan"
#include "BTPointToPointAppUi.h"
#include "BTPointToPointAppView.h"
#include "BTPointToPoint.hrh"
#include "MessageServer.h"
#include "MessageClient.h"

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

// ----------------------------------------------------------------------------
// CBTPointToPointAppUi::ConstructL() 
// ConstructL is called by the application framework.
// ----------------------------------------------------------------------------
//
void CBTPointToPointAppUi::ConstructL()
    {
    BaseConstructL();

    iAppView = CBTPointToPointAppView::NewL( ClientRect() );    

    iAppView->SetMopParent( this );   //  so view can update scroll bars

    AddToStackL( iAppView );

    iServer = CMessageServer::NewL( *iAppView );
    iClient = CMessageClient::NewL( *iAppView );
    }

// ----------------------------------------------------------------------------
// CBTPointToPointAppUi::CBTPointToPointAppUi() 
// C++ default constructor can NOT contain any code, that might leave.
// ----------------------------------------------------------------------------
//
CBTPointToPointAppUi::CBTPointToPointAppUi()                              
    {
    // no implementation required
    }

// ----------------------------------------------------------------------------
// CBTPointToPointAppUi::~CBTPointToPointAppUi() 
// Destructor.
// ----------------------------------------------------------------------------
//
CBTPointToPointAppUi::~CBTPointToPointAppUi()
    {
    delete iServer;
    iServer = NULL;

    delete iClient;
    iClient = NULL;

    if ( iAppView )
        {
        RemoveFromStack( iAppView );

        delete iAppView;
        iAppView = NULL;
        }
    }

// ----------------------------------------------------------------------------
// CBTPointToPointAppUi::DynInitMenuPaneL() 
// This function is called by the EIKON framework just before it displays
// a menu pane. Its default implementation is empty, and by overriding it,
// the application can set the state of menu items dynamically according
// to the state of application data.
// ----------------------------------------------------------------------------
//
void CBTPointToPointAppUi::DynInitMenuPaneL( TInt aResourceId,
                                             CEikMenuPane* aMenuPane )
    {
    if ( aResourceId == R_BTPOINTTOPOINT_MENU )
        {
        if ( iClient->IsConnected() )
            {
            aMenuPane->SetItemDimmed( EBTPointToPointStartReceiver, ETrue );
            aMenuPane->SetItemDimmed( EBTPointToPointStopReceiver, ETrue );
            aMenuPane->SetItemDimmed( EBTPointToPointConnect, ETrue );
            aMenuPane->SetItemDimmed( EBTPointToPointDisconnect, EFalse );
            aMenuPane->SetItemDimmed( EBTPointToPointSendMessage,
                                    ( !iClient->IsReadyToSendMessage() ) );
            }
        else if ( iClient->IsConnecting() )
            {
            aMenuPane->SetItemDimmed( EBTPointToPointStartReceiver, ETrue );
            aMenuPane->SetItemDimmed( EBTPointToPointStopReceiver, ETrue );
            aMenuPane->SetItemDimmed( EBTPointToPointConnect, ETrue );
            aMenuPane->SetItemDimmed( EBTPointToPointDisconnect, ETrue );
            aMenuPane->SetItemDimmed( EBTPointToPointSendMessage, ETrue );
            }
        else if ( iClient->IsSendingMessage() )
            {
            aMenuPane->SetItemDimmed( EBTPointToPointStartReceiver, ETrue );
            aMenuPane->SetItemDimmed( EBTPointToPointStopReceiver, ETrue );
            aMenuPane->SetItemDimmed( EBTPointToPointConnect, ETrue );
            aMenuPane->SetItemDimmed( EBTPointToPointDisconnect, EFalse );
            aMenuPane->SetItemDimmed( EBTPointToPointSendMessage, ETrue );
            }
        else if ( iServer->IsConnected() )
            {
            aMenuPane->SetItemDimmed( EBTPointToPointStartReceiver, ETrue );
            aMenuPane->SetItemDimmed( EBTPointToPointStopReceiver, EFalse );
            aMenuPane->SetItemDimmed( EBTPointToPointConnect, ETrue );
            aMenuPane->SetItemDimmed( EBTPointToPointDisconnect, ETrue );
            aMenuPane->SetItemDimmed( EBTPointToPointSendMessage, ETrue );
            }
        else // both the server and the client are not connected
            {
            aMenuPane->SetItemDimmed( EBTPointToPointStartReceiver, EFalse );
            aMenuPane->SetItemDimmed( EBTPointToPointStopReceiver, ETrue );
            aMenuPane->SetItemDimmed( EBTPointToPointConnect, EFalse );
            aMenuPane->SetItemDimmed( EBTPointToPointDisconnect, ETrue );
            aMenuPane->SetItemDimmed( EBTPointToPointSendMessage, ETrue );
            }
        aMenuPane->SetItemDimmed( EBTPointToPointClearList, 
                                 !iAppView->ContainsEntries() );
        }
    }

// ----------------------------------------------------------------------------
// CBTObjectExchangeAppUi::HandleCommandL()
// Handle any menu commands.
// ----------------------------------------------------------------------------
//
void CBTPointToPointAppUi::HandleCommandL( TInt aCommand )
    {
    switch ( aCommand )
        {
        case EEikCmdExit:
        case EAknSoftkeyExit:
            Exit();
            break;

        case EBTPointToPointStartReceiver:
            iServer->StartL();
            break;

        case EBTPointToPointStopReceiver:
            iServer->StopL();
            break;

        case EBTPointToPointConnect:
            iClient->ConnectL();
            break;

        case EBTPointToPointDisconnect:
            iClient->DisconnectL();
            break;

        case EBTPointToPointSendMessage:
            iClient->SendMessageL();
            break;

        case EBTPointToPointClearList:
            iAppView->ClearMessageListL();
            break;

        default:
            Panic( EBTPointToPointBasicUi );
            break;
        }
    }

// End of File

⌨️ 快捷键说明

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