📄 btobjectexchangeappui.cpp
字号:
/* Copyright (c) 2004, Nokia. All rights reserved */
// INCLUDE FILES
#include <avkon.hrh>
#include <eikmenup.h>
#include <BTObjectExchange.rsg>
#include <aknnotewrappers.h>
#include <stringloader.h>
#include <bautils.h>
#include <documenthandler.h>
#include <caknfileselectiondialog.h>
#include <caknmemoryselectiondialog.h>
#include "BTObjectExchange.pan"
#include "BTObjectExchangeAppUi.h"
#include "BTObjectExchangeAppView.h"
#include "BTObjectExchange.hrh"
#include "ObjectExchangeClient.h"
#include "ObjectExchangeServer.h"
#include <apmstd.h>
#include <sendui.h>
#ifdef __SERIES60_3X__
#include <cmessagedata.h>
#endif
#define KEnableSkinFlag 0x1000
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CBTObjectExchangeAppUi::ConstructL()
// ConstructL is called by the application framework.
// -----------------------------------------------------------------------------
//
void CBTObjectExchangeAppUi::ConstructL()
{
#ifdef __SERIES60_3X__
BaseConstructL(EAknEnableSkin);
#else
BaseConstructL(KEnableSkinFlag);
#endif
iAppView = CBTObjectExchangeAppView::NewL( ClientRect() );
iAppView->SetMopParent( this ); // so view can update scroll bars
AddToStackL( iAppView );
iClient = CObjectExchangeClient::NewL( *iAppView );
iServer = CObjectExchangeServer::NewL( *iAppView );
// check whether BT is available or not
RSdp sdpSession;
if ( sdpSession.Connect() == KErrNone )
{
sdpSession.Close();
iBtAvailable = ETrue;
}
else
{
iBtAvailable = EFalse;
}
iAppView->LogL(KTitle);
//make sure that BT is on
if(iBtAvailable)
{
//Make sure BT is on
TurnBtOnL();
}
//Create the sendui object
#ifdef __SERIES60_3X__
iSendUi = CSendUi::NewL();
#else
iSendUi = CSendAppUi::NewL(ESendViaSendUi);
#endif
}
// -----------------------------------------------------------------------------
// CBTObjectExchangeAppUi::CBTObjectExchangeAppUi()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CBTObjectExchangeAppUi::CBTObjectExchangeAppUi()
{
// no implementation required
}
// -----------------------------------------------------------------------------
// CBTObjectExchangeAppUi::~CBTObjectExchangeAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CBTObjectExchangeAppUi::~CBTObjectExchangeAppUi()
{
if ( iAppView )
{
RemoveFromStack( iAppView );
delete iAppView;
iAppView = NULL;
}
delete iClient;
iClient = NULL;
delete iServer;
iServer = NULL;
delete iDocHandler;
iDocHandler = NULL;
delete iSendUi;
iSendUi = NULL;
}
// -----------------------------------------------------------------------------
// CBTObjectExchangeAppUi::HandleCommandL()
// Handle any menu commands.
// -----------------------------------------------------------------------------
//
void CBTObjectExchangeAppUi::HandleCommandL( TInt aCommand )
{
if ( !iBtAvailable && (
( aCommand == EBTObjectExchangeStartServer ) ||
( aCommand == EBTObjectExchangeConnect ) ) )
{
// Load a string from the resource file and display it
HBufC* textResource = StringLoader::LoadLC( R_BTOB_NO_BT );
CAknErrorNote* errorNote;
errorNote = new ( ELeave ) CAknErrorNote;
// Show the information Note with
// textResource loaded with StringLoader.
errorNote->ExecuteLD( *textResource);
// Pop HBuf from CleanUpStack and Destroy it.
CleanupStack::PopAndDestroy( textResource );
}
else
{
switch ( aCommand )
{
case EAknSoftkeyExit:
iClient->StopL();
iServer->DisconnectL();
Exit();
break;
case EBTObjectExchangeStartServer:
iServer->StartL();
break;
case EBTObjectExchangeStopServer:
iServer->DisconnectL();
break;
case EBTObjectExchangeConnect:
iClient->ConnectL();
break;
case EBTObjectExchangeSendMessage:
{
TFileName filename;
if( AskFileL(filename) )
iClient->SendObjectL(filename);
else
ShowMessageL( KCanceled );
}
break;
case EBTObjectExchangeDisconnect:
iClient->DisconnectL();
break;
case EBTObjectExchangeClearList:
iAppView->ClearMessageListL();
break;
case ESendViaSendUi:
//These are the commands from Send cascade menu
//(actually needed only in 1st and 2nd edition)
case ESendViaSendUi1: //FALLTHROUGH
case ESendViaSendUi2: //FALLTHROUGH
case ESendViaSendUi3: //FALLTHROUGH
case ESendViaSendUi4: //FALLTHROUGH
case ESendViaSendUi5: //FALLTHROUGH
case ESendViaSendUi6: //FALLTHROUGH
case ESendViaSendUi7: //FALLTHROUGH
case ESendViaSendUi8: //FALLTHROUGH
case ESendViaSendUi9:
{
//With all the commands we send a file.
//Pass the command to the function. It's required
//by CSendAppUi sending function
SendFileViaSendUiL(aCommand);
break;
}
default:
Panic( EBTObjectExchangeBasicUi );
break;
}
}
}
// -----------------------------------------------------------------------------
// CBTObjectExchangeAppUi::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 CBTObjectExchangeAppUi::DynInitMenuPaneL( TInt aResourceId,
CEikMenuPane* aMenuPane )
{
if ( aResourceId == R_BTOBJECTEXCHANGE_MENU )
{
if ( !iClient->IsConnected() && !iServer->IsConnected() )
{
aMenuPane->SetItemDimmed( EBTObjectExchangeStartServer, EFalse );
aMenuPane->SetItemDimmed( EBTObjectExchangeStopServer, ETrue );
aMenuPane->SetItemDimmed( EBTObjectExchangeConnect, EFalse );
aMenuPane->SetItemDimmed( EBTObjectExchangeSendMessage, ETrue );
aMenuPane->SetItemDimmed( EBTObjectExchangeDisconnect, ETrue );
}
else if ( iServer->IsConnected() )
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -