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

📄 fepsetupcontainer.cpp

📁 运行EXE实例的一个实例
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CFepSetupContainer from FepSetupContainer.h
*  Part of  : FepSetup
*  Created  : 02/23/2003 by Forum Nokia
*  Implementation notes:
*     Initial content was generated by Series 60 AppWizard.
*  Version  :
*  Copyright: 
* ============================================================================
*/

// INCLUDE FILES
#include "FepSetupContainer.h"

#include <eiklabel.h>			// for example label control
#include <f32file.h> // for TParseBase
#include <avkon.hrh>
#include <fepsetup.rsg>
#include "fepsetup.hrh"
#include <AknListQueryDialog.h> // for query dialog
#include <aknnotewrappers.h>

_LIT(KT9FepName, "T9FEP.FEP");

_LIT(KFepInstalled, "%S Installed!");
_LIT(KFepUninstalled, "%S Uninstalled!");
_LIT(KFepAlreadyInstalled, "%S Already Installed!");

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

// ---------------------------------------------------------
// CFepSetupContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CFepSetupContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

    iLabel = new (ELeave) CEikLabel;
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL( _L("Select Options to\nInstall or Uninstall\nFepExample") );

	iFepSetting = CFepGenericGlobalSettings::NewL(*iEikonEnv, 
					TFepOnOrOffKeyData(EKeyEnter, EModifierFunc|EModifierShift, EModifierFunc),
					TFepOnOrOffKeyData(EKeyEnter, EModifierFunc|EModifierShift, EModifierShift), 
					EFalse);
	iFileNamesOfAvailableFeps = iEikonEnv->FileNamesOfAvailableFepsL();

	// Get the number of all Feps available in the system
	const TInt numberOfAvailableFeps = iFileNamesOfAvailableFeps->MdcaCount(); 
	
	// Get the name, including the path, of all the Feps in the system
	iNamesOfAvailableFeps = new(ELeave) CDesCArrayFlat(numberOfAvailableFeps+1);
	for(TInt i=0; i<numberOfAvailableFeps; i++)
		{
		// Get name of fep excluding path
		iNamesOfAvailableFeps->AppendL(TParsePtrC(iFileNamesOfAvailableFeps->MdcaPoint(i)).Name());  
		}

    SetRect(aRect);
    ActivateL();
    }

// Destructor
CFepSetupContainer::~CFepSetupContainer()
    {
    delete iLabel;
	delete iFepSetting;
	delete iFileNamesOfAvailableFeps;
	delete iNamesOfAvailableFeps;

    }

// ---------------------------------------------------------
// CFepSetupContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CFepSetupContainer::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    iLabel->SetExtent( TPoint(30,50), iLabel->MinimumSize() );
    }

// ---------------------------------------------------------
// CFepSetupContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CFepSetupContainer::CountComponentControls() const
    {
    return 1; // return nbr of controls inside this container
    }

// ---------------------------------------------------------
// CFepSetupContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CFepSetupContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
        {
        case 0:
            return iLabel;
        default:
            return NULL;
        }
    }

// ---------------------------------------------------------
// CFepSetupContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CFepSetupContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    // TODO: Add your drawing code here
    // example code...
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushColor(KRgbGray);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.DrawRect(aRect);
    }

// ---------------------------------------------------------
// CFepSetupContainer::HandleControlEventL(
//     CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CFepSetupContainer::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
    // TODO: Add your control event handler code here
    }

void CFepSetupContainer::InstallFepL()
	{
	TBuf<256> formatingBuf;

    TInt index(0);
    CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog(&index);
    dlg->PrepareLC(R_FEPSETUP_LIST_QUERY);
    dlg->SetItemTextArray(iNamesOfAvailableFeps);
    dlg->SetOwnershipType(ELbmDoesNotOwnItemArray);

    // Execute the dialog
	TInt answer = dlg->RunLD();

    if (answer == EAknSoftkeyOk)
		{
		iEikonEnv->InfoMsg(TParsePtrC(iFileNamesOfAvailableFeps->MdcaPoint(index)).Name());

		// The code below is to check whether the selected Fep is already installed.
		TPtrC nameOfFepToInstallPtr(TParsePtrC(iFileNamesOfAvailableFeps->MdcaPoint(index)).Name()); // file name parsing
			
		HBufC* nameOfInstalledFep = iCoeEnv->NameOfInstalledFepL();
		CleanupStack::PushL(nameOfInstalledFep);
		TPtrC fepFileNamePtr(TParsePtrC(nameOfInstalledFep->Des()).Name()); // file name parsing

		if( nameOfFepToInstallPtr.Compare(fepFileNamePtr) == 0) // Already installed?
			{
			formatingBuf.Format(KFepAlreadyInstalled, &nameOfFepToInstallPtr);
			CAknConfirmationNote* confirmationDialog = new(ELeave)CAknConfirmationNote();
			confirmationDialog->ExecuteLD(formatingBuf);
			}
		else
			{
			// Loads the specified FEP DLL into all running applications. 
			// The current loaded FEP, if any, will be unloaded.
			iCoeEnv->InstallFepL( iFileNamesOfAvailableFeps->MdcaPoint(index));	  // _L("Z:\\SYSTEM\\FEP\\T9FEP.FEP")

			formatingBuf.Format(KFepInstalled, &nameOfFepToInstallPtr);
			CAknConfirmationNote* confirmationDialog = new(ELeave)CAknConfirmationNote();
			confirmationDialog->ExecuteLD(formatingBuf);
			}

		CleanupStack::PopAndDestroy(); // nameOfInstalledFep;
		}
	else
		{
		iEikonEnv->InfoMsg(_L("No Fep Selected"));			
		}
	}

void CFepSetupContainer::UnInstallFepL()
	{
	TBuf<256> formatingBuf;

	HBufC* nameOfInstalledFep = iCoeEnv->NameOfInstalledFepL();
	CleanupStack::PushL(nameOfInstalledFep);
	TPtrC fepFileNamePtr(TParsePtrC(nameOfInstalledFep->Des()).Name()); // file name parsing

	iCoeEnv->InstallFepL(KT9FepName); // Install the default T9 Fep

	formatingBuf.Format(KFepUninstalled, &fepFileNamePtr);
	CAknConfirmationNote* dialog = new(ELeave)CAknConfirmationNote();
	dialog->ExecuteLD(formatingBuf);

	CleanupStack::PopAndDestroy(); // nameOfInstalledFep;
	}

// End of File  

⌨️ 快捷键说明

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