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

📄 bluetoothpmpexampleappui.cpp

📁 symbian系统下
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CBluetoothPMPExampleAppUi from BluetoothPMPExampleAppUi.cpp
*  Part of  : BluetoothPMPExample
*  Created  : 06.06.2006 by Forum Nokia
*  Implementation notes:
*     Initial content was generated by Series 60 AppWizard.
*  Version  :
*  Copyright: Nokia Corporation
* ============================================================================
*/


// INCLUDE FILES
#include <avkon.hrh>
#include <eikmenup.h>
#include <AknGlobalNote.h>  //avkon.lib, aknnotify.lib
#include <BtPmpEx.rsg>

#include "BluetoothPMPExampleAppUi.h"
#include "bluetoothpmpexample.hrh"

#include "BluetoothPMPExampleEngine.h"
#include "BluetoothPMPExampleRTEContainer.h"

//from porting guide:
#ifndef KEnableSkinFlag
    #define KEnableSkinFlag 0x1000
#endif
#ifndef KLayoutAwareFlag
#define KLayoutAwareFlag 0x08
#endif

// ----------------------------------------------------------------------------
// CBluetoothExampleAppUi::ConstructL()
//
// standard EPOC 2nd phase constructor
// ----------------------------------------------------------------------------
void CBluetoothPMPExampleAppUi::ConstructL()
    {
    #ifdef __SERIES60_3X__
        BaseConstructL(EAknEnableSkin);
    #else
        BaseConstructL(KEnableSkinFlag | KLayoutAwareFlag);
    #endif

    #ifdef __WINS__
        //in emulator do nothing
        _LIT(KEmulatorWarning,"This application should be tested on device");
        CAknGlobalNote* note = CAknGlobalNote::NewLC();
        note->ShowNoteL(EAknGlobalConfirmationNote,  KEmulatorWarning);
        CleanupStack::PopAndDestroy(note);
    #endif

    //Create container first so engine can display messages right away
    iContainer = CBluetoothPMPExampleRTEContainer::NewL(ClientRect());
    iContainer->SetMopParent( this );

    iEngine = CBluetoothPMPExampleEngine::NewL( *this );
    iEngine->TurnBtOnL();

    TBuf<KMaxTimeFormatSpec+KMaxTimeFormatSpec> time;
    TTime now;
    now.HomeTime(); // Current time
    now.FormatL(time,TTimeFormatSpec());

    _LIT(KInfo, "Bluetooth PMP example\n");
    iContainer->DrawTextL(KInfo);
    iContainer->DrawTextL(time);

    // add view to control stack
    AddToStackL( iContainer );


    }

// ----------------------------------------------------------------------------
// CBluetoothPMPExampleAppUi::~CBluetoothPMPExampleAppUi()
//
// destructor
// ----------------------------------------------------------------------------
CBluetoothPMPExampleAppUi::~CBluetoothPMPExampleAppUi()
    {
    RemoveFromStack( iContainer );

    delete iContainer;
    iContainer = NULL;

    delete iEngine;
    iEngine=NULL;
    }

// ----------------------------------------------------------------------------
// CBluetoothPMPExampleAppUi::DynInitMenuPaneL(TInt aResourceId,
//     CEikMenuPane* aMenuPane)
//
// 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 CBluetoothPMPExampleAppUi::DynInitMenuPaneL(TInt aResourceId,
                                                 CEikMenuPane* aMenuPane)
    {
    if (aResourceId == R_BLUETOOTHPMPEXAMPLE_MENU)
        {
        if (iEngine->iIsSlave)
            {
            // slave mode
            aMenuPane->SetItemDimmed(EBTCmdDiscoverDevices, ETrue);
            aMenuPane->SetItemDimmed(EBTCmdDiscoverServices, ETrue);
            aMenuPane->SetItemDimmed(EBTCmdConnectDevices, ETrue);
            aMenuPane->SetItemDimmed(EBTCmdShowConnectedDevices, ETrue);
            aMenuPane->SetItemDimmed(EBTCmdStartSlave, ETrue);
            if ( iEngine->iListener->IsConnected() )
                {
                aMenuPane->SetItemDimmed(EBTCmdSendMessage, EFalse);
                }
            else
                {
                aMenuPane->SetItemDimmed(EBTCmdSendMessage, ETrue);
                }
            }
        else
            {
            // master mode
            aMenuPane->SetItemDimmed(EBTCmdDiscoverDevices, EFalse);
            aMenuPane->SetItemDimmed(EBTCmdDiscoverServices, EFalse);
            aMenuPane->SetItemDimmed(EBTCmdConnectDevices, EFalse);
            aMenuPane->SetItemDimmed(EBTCmdShowConnectedDevices, EFalse);
            if ( iEngine->iDeviceDiscoverer->HasDevices() )
                {
                // we have found devices, show discover services item
                aMenuPane->SetItemDimmed(EBTCmdDiscoverServices, EFalse);
                // disable slave option, entered master mode
                aMenuPane->SetItemDimmed(EBTCmdStartSlave, ETrue);
                }
            else
                {
                // disconnected
                aMenuPane->SetItemDimmed(EBTCmdDiscoverServices, ETrue);
                }

            if ( iEngine->iServiceDiscoverer->HasServices() )
                {
                // we have found services, show connect item
                aMenuPane->SetItemDimmed(EBTCmdConnectDevices, EFalse);
                }
            else
                {
                // no services
                aMenuPane->SetItemDimmed(EBTCmdConnectDevices, ETrue);
                }

            if ( iEngine->HasConnections() )
                {
                // we are connected, show send message item
                aMenuPane->SetItemDimmed(EBTCmdSendMessage, EFalse);
                aMenuPane->SetItemDimmed(EBTCmdShowConnectedDevices, EFalse);
                }
            else
                {
                // disconnected
                aMenuPane->SetItemDimmed(EBTCmdSendMessage, ETrue);
                aMenuPane->SetItemDimmed(EBTCmdShowConnectedDevices, ETrue);
                }
            }
        }
    }



// ----------------------------------------------------------------------------
// CBluetoothPMPExampleAppUi::HandleKeyEventL(
//     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
//
// takes care of key event handling
// ----------------------------------------------------------------------------
TKeyResponse CBluetoothPMPExampleAppUi::HandleKeyEventL(
    const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
    {
    return EKeyWasNotConsumed;
    }


// ----------------------------------------------------------------------------
// CBluetoothPMPExampleAppUi::HandleCommandL(TInt aCommand)
//
// takes care of command handling
// ----------------------------------------------------------------------------
void CBluetoothPMPExampleAppUi::HandleCommandL(TInt aCommand)
    {
    switch ( aCommand )
        {
        case EAknSoftkeyBack:
        case EEikCmdExit:
            {
            Exit();
            break;
            }
        case EBTCmdStartSlave:
            {
            if ( !iEngine->iIsSlave )
                iEngine->StartSlaveL();
            break;
            }
        case EBTCmdDiscoverDevices:
            {
            if ( !iEngine->iIsSlave )
                iEngine->DiscoverDevicesL();
            break;
            }
        case EBTCmdDiscoverServices:
            {
            if ( !iEngine->iIsSlave )
                iEngine->DiscoverServicesL();
            break;
            }
        case EBTCmdConnectDevices:
            {
            if ( !iEngine->iIsSlave )
                iEngine->ConnectDevicesL();
            break;
            }
        case EBTCmdShowConnectedDevices:
            {
            if ( !iEngine->iIsSlave )
                iEngine->ShowConnectedDevicesL();
            break;
            }
        case EBTCmdSendMessage:
            {
            TRAPD(err,iEngine->SendMessageL() );
            if( err )
                iContainer->ShowMessageL( KMsgSendFailed );
            break;
            }
        case EBtCmdClearScreen:
            {
            iContainer->ClearScreenL();
            }

        default:
            break;
        }
    }

void CBluetoothPMPExampleAppUi::HandleResourceChangeL(TInt aType)
    {
    CAknAppUi::HandleResourceChangeL(aType); //call to upper class

    // ADDED FOR SCALABLE UI SUPPORT
    // *****************************
    //if ( aType == KEikDynamicLayoutVariantSwitch )
    //hard coded constant so it can be compiled with first edition
    if ( aType == 0x101F8121 )
        {
        iContainer->SetRect( ClientRect() );
        }
    }


CBluetoothPMPExampleRTEContainer& CBluetoothPMPExampleAppUi::Container()
    {
    return *iContainer;
    }

// End of File

⌨️ 快捷键说明

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