📄 ftpexampleappui.cpp
字号:
/*
* ============================================================================
* Name : CFtpExampleAppUi from FtpExampleAppUi.cpp
* Part of : FtpExample
* Created : 03/11/2005 by Forum Nokia
* Version : 1.0
* Copyright: Nokia Corporation
* ============================================================================
*/
// INCLUDE FILES
#include <avkon.hrh>
#include <avkon.rsg>
#include <eikbtgpc.h> //CEikButtonGroupContainer
#include <eikmenup.h> //CEikMenuPane
#include <FtpExample.rsg>
#include "FtpExampleAppUi.h"
#include "FtpExampleContainer.h"
#include "FtpExampleEngine.h"
// CONSTANTS
_LIT(KConnect, "Connect");
_LIT(KDisconnect, "Disconnect");
// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CFtpExampleAppUi::ConstructL()
//
// ----------------------------------------------------------
//
void CFtpExampleAppUi::ConstructL()
{
BaseConstructL(EAknEnableSkin);
iContainer = CFtpExampleContainer::NewL(ClientRect(), *this);
iContainer->SetMopParent(this);
AddToStackL(iContainer);
iEngine = CFtpExampleEngine::NewL(iContainer);
TFileName fullPath = Application()->AppFullName();
TParsePtr path(fullPath);
RFs fs = iCoeEnv->FsSession();
// Set default path to program path. Files will be downloaded here.
User::LeaveIfError(fs.SetDefaultPath(path.DriveAndPath()));
}
// ----------------------------------------------------
// CFtpExampleAppUi::~CFtpExampleAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CFtpExampleAppUi::~CFtpExampleAppUi()
{
if (iContainer)
{
RemoveFromStack(iContainer);
delete iContainer;
}
delete iEngine;
}
// ------------------------------------------------------------------------------
// CFtpExampleAppUi::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 CFtpExampleAppUi::DynInitMenuPaneL(
TInt aResourceId,CEikMenuPane* aMenuPane)
{
if (aResourceId == R_FTPEXAMPLE_MENU)
{
if (iContainer->Connected())
{
aMenuPane->SetItemDimmed(EFtpExampleCommands, EFalse);
aMenuPane->SetItemTextL(EFtpExampleCmdConnect, KDisconnect);
}
else
{
aMenuPane->SetItemDimmed(EFtpExampleCommands, ETrue);
aMenuPane->SetItemTextL(EFtpExampleCmdConnect, KConnect);
}
}
}
// ----------------------------------------------------
// CFtpExampleAppUi::HandleKeyEventL()
// takes care of key event handling
// ----------------------------------------------------
//
TKeyResponse CFtpExampleAppUi::HandleKeyEventL(
const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
{
return EKeyWasNotConsumed;
}
// ----------------------------------------------------
// CFtpExampleAppUi::HandleCommandL()
// takes care of command handling
// ----------------------------------------------------
//
void CFtpExampleAppUi::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EAknSoftkeyExit:
case EEikCmdExit:
{
Exit();
break;
}
case EFtpExampleCmdConnect:
{
iContainer->ConnectL();
break;
}
case EAknSoftkeyCancel:
{
iEngine->Cancel();
break;
}
case EFtpExampleCmdPwd:
{
iContainer->PwdL();
break;
}
case EFtpExampleCmdDir:
{
iContainer->DirL();
break;
}
case EFtpExampleCmdCd:
{
iContainer->CdL();
break;
}
case EFtpExampleCmdMkdir:
{
iContainer->MkdirL();
break;
}
case EFtpExampleCmdRmdir:
{
iContainer->RmdirL();
break;
}
case EFtpExampleCmdGetBinary:
{
iContainer->GetL(ETrue);
break;
}
case EFtpExampleCmdGetAscii:
{
iContainer->GetL(EFalse);
break;
}
case EFtpExampleCmdPutBinary:
{
iContainer->PutL(ETrue);
break;
}
case EFtpExampleCmdPutAscii:
{
iContainer->PutL(EFalse);
break;
}
case EFtpExampleCmdRename:
{
iContainer->RenameL();
break;
}
case EFtpExampleCmdDelete:
{
iContainer->DeleteL();
break;
}
default:
break;
}
}
// ----------------------------------------------------
// CFtpExampleAppUi::Model()
// Return a reference to the FTP engine.
// ----------------------------------------------------
//
CFtpExampleEngine& CFtpExampleAppUi::Model()
{
return *iEngine;
}
// ----------------------------------------------------
// CFtpExampleAppUi::CommandExecutingL()
// While an FTP command is executing, show only a
// Cancel softkey to user. When FTP command is not
// executing, show Options and Exit.
// ----------------------------------------------------
//
void CFtpExampleAppUi::CommandExecutingL(const TBool& aExecuting)
{
if (aExecuting)
{
Cba()->SetCommandSetL(R_AVKON_SOFTKEYS_CANCEL);
}
else
{
Cba()->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_EXIT);
}
Cba()->DrawNow();
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -