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

📄 sysinfo60view3.cpp

📁 基于SYMBIAN OS 的Moblile硬件管理器. 支持series 70平台
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CSYSINFO60View3 from SYSINFO60View3.h
*  Part of  : SYSINFO60
*  Created  : 09.09.2003 by Petri-Veikko Alaj鋜vi OH1GIU
*  Implementation notes:
*     Initial content was generated by Series 60 AppWizard.
*  Version  :
*  Copyright: (c) 2003, Petri-Veikko Alaj鋜vi OH1GIU
* ============================================================================
*/

// INCLUDE FILES
#include <aknviewappui.h>
#include <eikmenup.h>
#include <avkon.hrh>
#include <SYSINFO60.rsg>
#include "SYSINFO60.hrh"
#include "SYSINFO60View3.h"
#include "SYSINFO60Container3.h"

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

// ---------------------------------------------------------
// CSYSINFO60View3::ConstructL(const TRect& aRect)
// EPOC two-phased constructor
// ---------------------------------------------------------
//
void CSYSINFO60View3::ConstructL()
    {
	iSockOK = 0;
    BaseConstructL( R_SYSINFO60_VIEW3 );
	iInfoBuf = HBufC::NewL(KInfoBufSize);
#ifndef __WINS__
	TInt err;
	err = iSocketServer.Connect();
	if (err == KErrNone)
	{
		TProtocolDesc protocolInfo;
		err = iSocketServer.FindProtocol(_L("BTLinkManager"), protocolInfo);
		if (err == KErrNone)
		{
			err = iSocket.Open(iSocketServer, KBTAddrFamily, KSockSeqPacket, KL2CAP);
			if (err == KErrNone)
				iSockOK = 1;
			else
				iSocketServer.Close();
		}
		else
			iSocketServer.Close();
	}
#endif
    }

// ---------------------------------------------------------
// CSYSINFO60View3::~CSYSINFO60View3()
// ?implementation_description
// ---------------------------------------------------------
//
CSYSINFO60View3::~CSYSINFO60View3()
    {
	delete iInfoBuf;
	iInfoBuf = NULL;

#ifndef __WINS__
	if (iSockOK)
	{
		iSocket.Close();
		iSocketServer.Close();
	}
#endif
    
	if ( iContainer )
        {
        AppUi()->RemoveFromViewStack( *this, iContainer );
        }
    delete iContainer;
    }

// ---------------------------------------------------------
// TUid CSYSINFO60View3::Id()
// ?implementation_description
// ---------------------------------------------------------
//
TUid CSYSINFO60View3::Id() const
    {
    return KView3Id;
    }

// ---------------------------------------------------------
// CSYSINFO60View3::HandleCommandL(TInt aCommand)
// ?implementation_description
// ---------------------------------------------------------
//
void CSYSINFO60View3::HandleCommandL(TInt aCommand)
    {   
    switch ( aCommand )
        {
        /*case EAknSoftkeyOk:
            {
            iEikonEnv->InfoMsg( _L("view2 ok") );
            break;
            }*/
		case ESYSINFO60CmdV3LocalVersion:
            {
			GetHCILocalVersion();
			break;
			}
		case ESYSINFO60CmdV3LocalFeatures:
            {
			GetHCILocalFeatures();
			break;
			}
		case ESYSINFO60CmdV3LocalAddress:
            {
			GetHCILocalAddress();
			break;
			}
		case ESYSINFO60CmdV3DeviceClass:
            {
			GetHCIDeviceClass();
			break;
			}
		case ESYSINFO60CmdV3CountryCode:
            {
			GetHCICountryCode();
			break;
			}
		case ESYSINFO60CmdV3VoiceSetting:
            {
			GetHCIVoiceSetting();
			break;
			}
		case ESYSINFO60CmdV3PageTimeout:
            {
			GetHCIPageTimeout();
			break;
			}
		case ESYSINFO60CmdV3ScanEnable:
            {
			GetHCIScanEnable();
			break;
			}
        case EAknSoftkeyBack:
            {
            AppUi()->HandleCommandL(EEikCmdExit);
            break;
            }
        default:
            {
            AppUi()->HandleCommandL(aCommand);
            break;
            }
        }
    }

// ---------------------------------------------------------
// CSYSINFO60View3::HandleClientRectChange()
// ---------------------------------------------------------
//
void CSYSINFO60View3::HandleClientRectChange()
    {
    if ( iContainer )
        {
        iContainer->SetRect( ClientRect() );
        }
    }

// ---------------------------------------------------------
// CSYSINFO60View3::DoActivateL(...)
// ?implementation_description
// ---------------------------------------------------------
//
void CSYSINFO60View3::DoActivateL(
   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
   const TDesC8& /*aCustomMessage*/)
    {
    if (!iContainer)
        {
        iContainer = new (ELeave) CSYSINFO60Container3;
        iContainer->SetMopParent(this);
        iContainer->ConstructL( ClientRect() );
        AppUi()->AddToStackL( *this, iContainer );
        }
   }

// ---------------------------------------------------------
// CSYSINFO60View3::HandleCommandL(TInt aCommand)
// ?implementation_description
// ---------------------------------------------------------
//
void CSYSINFO60View3::DoDeactivate()
    {
    if ( iContainer )
        {
        AppUi()->RemoveFromViewStack( *this, iContainer );
        }
    
    delete iContainer;
    iContainer = NULL;
    }

void CSYSINFO60View3::GetHCILocalVersion()
{
	iContainer->ClearL();
	iSocket.Ioctl(KHCILocalVersionIoctl, iStatus, &iLocalVersionBuf, KSolBtHCI);
	User::WaitForRequest(iStatus);
	if (iStatus.Int() == KErrNone)
	{
		TPtr buf = iInfoBuf->Des();
		iContainer->PrintLine(_L("Local version"));
		buf.Format(_L("HCI Version: %u"), iLocalVersionBuf().iHCIVersion);
		iContainer->PrintLine(buf);
		buf.Format(_L("HCI Revision: %u"), iLocalVersionBuf().iHCIRevision);
		iContainer->PrintLine(buf);
		buf.Format(_L("LMP Version: %u"), iLocalVersionBuf().iLMPVersion);
		iContainer->PrintLine(buf);
		buf.Format(_L("LMP Subversion: %u"), iLocalVersionBuf().iLMPSubversion);
		iContainer->PrintLine(buf);
		buf.Format(_L("Manufacturer: %u"), iLocalVersionBuf().iManufacturerName);
		iContainer->PrintLine(buf);
	}
	else
		iContainer->PrintLine(_L("ERROR"));
}

void CSYSINFO60View3::GetHCILocalFeatures()
{
	iContainer->ClearL();
	iSocket.Ioctl(KHCILocalFeaturesIoctl, iStatus, &iLocalFeaturesBuf, KSolBtHCI);
	User::WaitForRequest(iStatus);
	if (iStatus.Int() == KErrNone)
	{
		TPtr buf = iInfoBuf->Des();
		iContainer->PrintLine(_L("Local features"));
		buf.Format(_L("%x"), iLocalFeaturesBuf());
		iContainer->PrintLine(buf);
	}
	else
		iContainer->PrintLine(_L("ERROR"));
}

void CSYSINFO60View3::GetHCILocalAddress()
{
	iContainer->ClearL();
	iSocket.Ioctl(KHCILocalAddressIoctl, iStatus, &iDevAddrPckg, KSolBtHCI);
	User::WaitForRequest(iStatus);
	if (iStatus.Int() == KErrNone)
	{
		TPtr buf = iInfoBuf->Des();
		iContainer->PrintLine(_L("Local address"));
		iDevAddrPckg().GetReadable(buf);
		iContainer->PrintLine(buf);
		if (buf.Length() == 12)
		{
			iContainer->PrintLine(_L("Manufacturer"));
			iContainer->PrintLine(buf.Left(6));
			iContainer->PrintLine(_L("BT_DEV_ADDR"));
			iContainer->PrintLine(buf.Right(6));
		}
	}
	else
		iContainer->PrintLine(_L("ERROR"));
}

void CSYSINFO60View3::GetHCIDeviceClass()
{
	iContainer->ClearL();
	iSocket.Ioctl(KHCIReadDeviceClassIoctl, iStatus, &iCodbuf, KSolBtHCI);
	User::WaitForRequest(iStatus);
	if (iStatus.Int() == KErrNone)
	{
		TPtr buf = iInfoBuf->Des();
		iContainer->PrintLine(_L("Device class"));
		buf.Format(_L("Major class: %u"), iCodbuf().iMajorDeviceClass);
		iContainer->PrintLine(buf);
		buf.Format(_L("Minor class: %u"), iCodbuf().iMinorDeviceClass);
		iContainer->PrintLine(buf);
		buf.Format(_L("Service class: %u"), iCodbuf().iMajorServiceClass);
		iContainer->PrintLine(buf);
	}
	else
		iContainer->PrintLine(_L("ERROR"));
}

void CSYSINFO60View3::GetHCICountryCode()
{
	iContainer->ClearL();
	iSocket.Ioctl(KHCICountryCodeIoctl, iStatus, &iCountryCodeBuf, KSolBtHCI);
	User::WaitForRequest(iStatus);
	if (iStatus.Int() == KErrNone)
	{
		TPtr buf = iInfoBuf->Des();
		buf.Format(_L("Country code: %u"), iCountryCodeBuf());
		iContainer->PrintLine(buf);
	}
	else
		iContainer->PrintLine(_L("ERROR"));
}

void CSYSINFO60View3::GetHCIVoiceSetting()
{
	iContainer->ClearL();
	iSocket.Ioctl(KHCIReadVoiceSettingIoctl, iStatus, &iVoiceSetBuf, KSolBtHCI);
	User::WaitForRequest(iStatus);
	if (iStatus.Int() == KErrNone)
	{
		TPtr buf = iInfoBuf->Des();
		buf.Format(_L("Voice setting: %u"), iVoiceSetBuf());
		iContainer->PrintLine(buf);
	}
	else
		iContainer->PrintLine(_L("ERROR"));
}

void CSYSINFO60View3::GetHCIPageTimeout()
{
	iContainer->ClearL();
	iSocket.Ioctl(KHCIReadPageTimeoutIoctl, iStatus, &iVoiceSetBuf, KSolBtHCI);
	User::WaitForRequest(iStatus);
	if (iStatus.Int() == KErrNone)
	{
		TPtr buf = iInfoBuf->Des();
		buf.Format(_L("Page timeout: %u"), iVoiceSetBuf());
		iContainer->PrintLine(buf);
	}
	else
		iContainer->PrintLine(_L("ERROR"));
}

void CSYSINFO60View3::GetHCIScanEnable()
{
	iContainer->ClearL();
	iSocket.Ioctl(KHCIReadScanEnableIoctl, iStatus, &iVoiceSetBuf, KSolBtHCI);
	User::WaitForRequest(iStatus);
	if (iStatus.Int() == KErrNone)
	{
		TPtr buf(iInfoBuf->Des());
		buf.Format(_L("Scan enable: %u"), iVoiceSetBuf());
		iContainer->PrintLine(buf);
		switch (iVoiceSetBuf())
		{
		case EHCINoScansEnabled:
			iContainer->PrintLine(_L("No scans enabled"));
			break;
		case EHCIInquiryScanOnly:
			iContainer->PrintLine(_L("Inquiry scan enabled"));
			iContainer->PrintLine(_L("Page scan disabled"));
			break;
		case EHCIPageScanOnly:
			iContainer->PrintLine(_L("Inquiry scan disabled"));
			iContainer->PrintLine(_L("Page scan enabled"));
			break;
		case EHCIInquiryAndPageScan:
			iContainer->PrintLine(_L("Inquiry scan enabled"));
			iContainer->PrintLine(_L("Page scan enabled"));
			break;
		default:
			break;
		}
	}
	else
		iContainer->PrintLine(_L("ERROR"));
}

void CSYSINFO60View3::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
{
	if (aResourceId == R_SYSINFO60_VIEW3_MENU)
	{
		UpdateMenuL(aMenuPane);
	}
}

void CSYSINFO60View3::UpdateMenuL(CEikMenuPane* aMenuPane)
{
	if (iSockOK)
	{
		aMenuPane->SetItemDimmed(ESYSINFO60CmdV3LocalVersion, EFalse);
		aMenuPane->SetItemDimmed(ESYSINFO60CmdV3LocalFeatures, EFalse);
		aMenuPane->SetItemDimmed(ESYSINFO60CmdV3LocalAddress, EFalse);
		aMenuPane->SetItemDimmed(ESYSINFO60CmdV3DeviceClass, EFalse);
		aMenuPane->SetItemDimmed(ESYSINFO60CmdV3CountryCode, EFalse);
		aMenuPane->SetItemDimmed(ESYSINFO60CmdV3VoiceSetting, EFalse);
		aMenuPane->SetItemDimmed(ESYSINFO60CmdV3PageTimeout, EFalse);
		aMenuPane->SetItemDimmed(ESYSINFO60CmdV3ScanEnable, EFalse);
	}
	else
	{
		aMenuPane->SetItemDimmed(ESYSINFO60CmdV3LocalVersion, ETrue);
		aMenuPane->SetItemDimmed(ESYSINFO60CmdV3LocalFeatures, ETrue);
		aMenuPane->SetItemDimmed(ESYSINFO60CmdV3LocalAddress, ETrue);
		aMenuPane->SetItemDimmed(ESYSINFO60CmdV3DeviceClass, ETrue);
		aMenuPane->SetItemDimmed(ESYSINFO60CmdV3CountryCode, ETrue);
		aMenuPane->SetItemDimmed(ESYSINFO60CmdV3VoiceSetting, ETrue);
		aMenuPane->SetItemDimmed(ESYSINFO60CmdV3PageTimeout, ETrue);
		aMenuPane->SetItemDimmed(ESYSINFO60CmdV3ScanEnable, ETrue);
	}
}

// End of File

⌨️ 快捷键说明

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