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

📄 testeapiappui.cpp.svn-base

📁 qaSDQDaca<FCSASDAVCASC SDVFDSVDF
💻 SVN-BASE
字号:
/*
============================================================================
 Name		: TesteAPIAppUi.cpp
 Author	  : Tiago Sousa
 Copyright   : 
 Description : CTesteAPIAppUi implementation
============================================================================
*/

// INCLUDE FILES
#include <avkon.hrh>
#include <aknmessagequerydialog.h>
#include <aknnotewrappers.h>
#include <stringloader.h>
#include <f32file.h>
#include <s32file.h>
#include <hlplch.h>

#include <TesteAPI_0xEA13183C.rsg>

#include "TesteAPI_0xEA13183C.hlp.hrh"
#include "TesteAPI.hrh"
#include "TesteAPI.pan"
#include "TesteAPIApplication.h"
#include "TesteAPIAppUi.h"
#include "TesteAPIAppView.h"

_LIT( KFileName, "C:\\private\\EA13183C\\TesteAPI.txt" );
_LIT( KText, "BlueTooth!");

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


// -----------------------------------------------------------------------------
// CTesteAPIAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CTesteAPIAppUi::ConstructL()
	{
	// Initialise app UI with standard value.
	BaseConstructL(CAknAppUi::EAknEnableSkin);

	// Create view object
	iAppView = CTesteAPIAppView::NewL( ClientRect() );

	// Create a file to write the text to
	RFs fsSession;
	User::LeaveIfError(fsSession.Connect());
	CleanupClosePushL( fsSession );

	TInt err = fsSession.MkDirAll(KFileName);
	if ( (KErrNone != err) && (KErrAlreadyExists != err) )
		{
		CleanupStack::PopAndDestroy(1); //  fsSession
		return;
		}
	
	RFile file;
	err = file.Replace(fsSession, KFileName, EFileWrite );
	CleanupClosePushL( file );
	if ( KErrNone != err )
		{
		CleanupStack::PopAndDestroy(2); // file, fsSession
		return;
		}
	
	RFileWriteStream outputFileStream( file );
	CleanupClosePushL( outputFileStream );
	outputFileStream << KText;

	CleanupStack::PopAndDestroy(3); // outputFileStream, file, fsSession

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

// -----------------------------------------------------------------------------
// CTesteAPIAppUi::~CTesteAPIAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CTesteAPIAppUi::~CTesteAPIAppUi()
	{
	if ( iAppView )
		{
		delete iAppView;
		iAppView = NULL;
		}
	}

// -----------------------------------------------------------------------------
// CTesteAPIAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CTesteAPIAppUi::HandleCommandL( TInt aCommand )
	{
	switch( aCommand )
			{
			case EEikCmdExit:
			case EAknSoftkeyExit:
				iAppView->DisconnectAsServer(); // Stops advertising when the application is closed
				Exit();
				break;

			case ECommand1:
				{
				iAppView->BTConnectServer();
				
				CAknInformationNote* note = new (ELeave) CAknInformationNote;
				note->ExecuteLD(_L("Server"));
				}
				break;
			case ECommand2:
				{
				iAppView->BTConnectClient();
				
				CAknInformationNote* note = new (ELeave) CAknInformationNote;
				note->ExecuteLD(_L("Client"));
				}
				break;
			case ECommand3:
				{
				iAppView->DisconnectAsServer();
				}
				break;
			case ECommand4:
				{
				iAppView->DisconnectAsClient();
				}
				break;
			case ESymbian:
				{
				iAppView->BTSendMsg("Symbian OS");
				
				CAknInformationNote* note = new (ELeave) CAknInformationNote;
				note->ExecuteLD(_L("Sent"));
				}
				break;
			case EEmbedded1:
				{
				iAppView->BTSendMsg("Embedded Academy");
				
				CAknInformationNote* note = new (ELeave) CAknInformationNote;
				note->ExecuteLD(_L("Sent"));
				}
				break;
			case EUFCG:
				{
				iAppView->BTSendMsg("UFCG");
				
				CAknInformationNote* note = new (ELeave) CAknInformationNote;
				note->ExecuteLD(_L("Sent"));
				}
				break;
			case EHelp:
				{
				
				CArrayFix<TCoeHelpContext>* buf = CCoeAppUi::AppHelpContextL();
				HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), buf);
				}
				break;
			case EAbout:
				{
				
				CAknMessageQueryDialog* dlg = new (ELeave)CAknMessageQueryDialog(); 
				dlg->PrepareLC(R_ABOUT_QUERY_DIALOG);
				HBufC* title = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TITLE);
				dlg->QueryHeading()->SetTextL(*title);
				CleanupStack::PopAndDestroy(); //title
				HBufC* msg = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TEXT);
				dlg->SetMessageTextL(*msg);
				CleanupStack::PopAndDestroy(); //msg
				dlg->RunLD(); 
				}
				break;
			default:
//				Panic( EAPIbluetoothUi );
				break;
			}
	}
// -----------------------------------------------------------------------------
//  Called by the framework when the application status pane
//  size is changed.  Passes the new client rectangle to the
//  AppView
// -----------------------------------------------------------------------------
//
void CTesteAPIAppUi::HandleStatusPaneSizeChange()
	{
	iAppView->SetRect( ClientRect() );
	} 

CArrayFix<TCoeHelpContext>* CTesteAPIAppUi::HelpContextL() const
	{
	#warning "Please see comment about help and UID3..."
	// Note: help will not work if the application uid3 is not in the
	// protected range.  The default uid3 range for projects created
	// from this template (0xE0000000 - 0xEFFFFFFF) are not in the protected range so they
	// can be self signed and installed on the device during testing.
	// Once you get your official uid3 from Symbian Ltd. and find/replace
	// all occurrences of uid3 in your project, the context help will
	// work.
	CArrayFixFlat<TCoeHelpContext>* array = new(ELeave)CArrayFixFlat<TCoeHelpContext>(1);
	CleanupStack::PushL(array);
	array->AppendL(TCoeHelpContext(KUidTesteAPIApp, KGeneral_Information));
	CleanupStack::Pop(array);
	return array;
	}

// End of File

⌨️ 快捷键说明

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