FepSetupContainer.cpp
资源名称:Symbian.zip [点击查看]
上传用户:tjsjht
上传日期:2021-01-13
资源大小:25k
文件大小:7k
源码类别:
输入法编程
开发平台:
Visual C++
- /*
- * ============================================================================
- * 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 tonInstall or UninstallnFepExample") );
- 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