📄 blueshareappui.cpp
字号:
/*
============================================================================
Name : BlueShareAppUi.cpp
Author :
Copyright : Your copyright notice
Description : CBlueShareAppUi implementation
============================================================================
*/
// INCLUDE FILES
#include <avkon.hrh>
#include <aknnotewrappers.h>
#include <stringloader.h>
#include <btnotifierapi.h>
#include <btsdp.h>
#include <BlueShare_0xE0005B8E.rsg>
#include "BlueShare.hrh"
#include "BlueShare.pan"
#include "BlueShareApplication.h"
#include "BlueShareAppUi.h"
#include "BlueShareAppView.h"
#include "ObjectExchangeClient.h"
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CBlueShareAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CBlueShareAppUi::ConstructL()
{
// Initialise app UI with standard value.
BaseConstructL(CAknAppUi::EAknEnableSkin);
// Create view object
iAppView = CBlueShareAppView::NewL(ClientRect() );
iAppView->SetMopParent(this); //so view can update scroll bars
AddToStackL(iAppView);
iClient = CObjectExchangeClient::NewL();
// Check whether BT is available or not
RSdp sdpSession;
if (sdpSession.Connect() == KErrNone)
{
sdpSession.Close();
iBtAvailable = ETrue;
}
else
{
iBtAvailable = EFalse;
}
// Make sure that BT is on
if (iBtAvailable)
{
TurnBtOnL();
}
}
// -----------------------------------------------------------------------------
// CBlueShareAppUi::CBlueShareAppUi()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CBlueShareAppUi::CBlueShareAppUi()
{
// No implementation required
}
// -----------------------------------------------------------------------------
// CBlueShareAppUi::~CBlueShareAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CBlueShareAppUi::~CBlueShareAppUi()
{
if (iAppView)
{
RemoveFromStack(iAppView);
delete iAppView;
iAppView = NULL;
}
delete iClient;
iClient = NULL;
}
// -----------------------------------------------------------------------------
// CBlueShareAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CBlueShareAppUi::HandleCommandL(TInt aCommand)
{
if (!iBtAvailable && (aCommand == EBlueShareSendSis))
{
HBufC* textResource = StringLoader::LoadL(R_BTOB_NO_BT);
CAknErrorNote* errorNote = new (ELeave) CAknErrorNote;
errorNote->ExecuteLD(*textResource);
CleanupStack::PopAndDestroy(textResource);
}
else
{
switch (aCommand)
{
case EEikCmdExit:
case EAknSoftkeyExit:
{
iClient->StopL();
Exit();
break;
}
case EBlueShareSendSis:
{
iClient->ConnectL();
break;
}
default:
Panic(EBlueShareUi);
break;
}
}
}
// -----------------------------------------------------------------------------
// Called by the framework when the application status pane
// size is changed. Passes the new client rectangle to the
// AppView
// -----------------------------------------------------------------------------
void CBlueShareAppUi::HandleResourceChangeL(TInt aType)
{
CAknAppUi::HandleResourceChangeL(aType);
/**
* Added for scalable UI
*/
if (aType == KEikDynamicLayoutVariantSwitch)
{
iAppView->SetRect(ClientRect());
}
iAppView->HandleResourceChange(aType);
}
// -----------------------------------------------------------------------------
// Use bluetooth power mode notifier to check, if it is off, a dialog will bring
// up to prompt to switch on the bluetooth
// -----------------------------------------------------------------------------
//
void CBlueShareAppUi::TurnBtOnL()
{
RNotifier notifier;
User::LeaveIfError(notifier.Connect());
TPckgBuf<TBool> dummy(ETrue);
TPckgBuf<TBool> reply(EFalse);
TRequestStatus stat;
notifier.StartNotifierAndGetResponse(stat, KPowerModeSettingNotifierUid, dummy, reply);
User::WaitForRequest(stat);
notifier.CancelNotifier(KPowerModeSettingNotifierUid);
notifier.Close();
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -