FepSetupContainer.cpp
上传用户:tjsjht
上传日期:2021-01-13
资源大小:25k
文件大小:7k
源码类别:

输入法编程

开发平台:

Visual C++

  1. /*
  2. * ============================================================================
  3. *  Name     : CFepSetupContainer from FepSetupContainer.h
  4. *  Part of  : FepSetup
  5. *  Created  : 02/23/2003 by Forum Nokia
  6. *  Implementation notes:
  7. *     Initial content was generated by Series 60 AppWizard.
  8. *  Version  :
  9. *  Copyright: 
  10. * ============================================================================
  11. */
  12. // INCLUDE FILES
  13. #include "FepSetupContainer.h"
  14. #include <eiklabel.h> // for example label control
  15. #include <f32file.h> // for TParseBase
  16. #include <avkon.hrh>
  17. #include <fepsetup.rsg>
  18. #include "fepsetup.hrh"
  19. #include <AknListQueryDialog.h> // for query dialog
  20. #include <aknnotewrappers.h>
  21. _LIT(KT9FepName, "T9FEP.FEP");
  22. _LIT(KFepInstalled, "%S Installed!");
  23. _LIT(KFepUninstalled, "%S Uninstalled!");
  24. _LIT(KFepAlreadyInstalled, "%S Already Installed!");
  25. // ================= MEMBER FUNCTIONS =======================
  26. // ---------------------------------------------------------
  27. // CFepSetupContainer::ConstructL(const TRect& aRect)
  28. // EPOC two phased constructor
  29. // ---------------------------------------------------------
  30. //
  31. void CFepSetupContainer::ConstructL(const TRect& aRect)
  32.     {
  33.     CreateWindowL();
  34.     iLabel = new (ELeave) CEikLabel;
  35.     iLabel->SetContainerWindowL( *this );
  36.     iLabel->SetTextL( _L("Select Options tonInstall or UninstallnFepExample") );
  37. iFepSetting = CFepGenericGlobalSettings::NewL(*iEikonEnv, 
  38. TFepOnOrOffKeyData(EKeyEnter, EModifierFunc|EModifierShift, EModifierFunc),
  39. TFepOnOrOffKeyData(EKeyEnter, EModifierFunc|EModifierShift, EModifierShift), 
  40. EFalse);
  41. iFileNamesOfAvailableFeps = iEikonEnv->FileNamesOfAvailableFepsL();
  42. // Get the number of all Feps available in the system
  43. const TInt numberOfAvailableFeps = iFileNamesOfAvailableFeps->MdcaCount(); 
  44. // Get the name, including the path, of all the Feps in the system
  45. iNamesOfAvailableFeps = new(ELeave) CDesCArrayFlat(numberOfAvailableFeps+1);
  46. for(TInt i=0; i<numberOfAvailableFeps; i++)
  47. {
  48. // Get name of fep excluding path
  49. iNamesOfAvailableFeps->AppendL(TParsePtrC(iFileNamesOfAvailableFeps->MdcaPoint(i)).Name());  
  50. }
  51.     SetRect(aRect);
  52.     ActivateL();
  53.     }
  54. // Destructor
  55. CFepSetupContainer::~CFepSetupContainer()
  56.     {
  57.     delete iLabel;
  58. delete iFepSetting;
  59. delete iFileNamesOfAvailableFeps;
  60. delete iNamesOfAvailableFeps;
  61.     }
  62. // ---------------------------------------------------------
  63. // CFepSetupContainer::SizeChanged()
  64. // Called by framework when the view size is changed
  65. // ---------------------------------------------------------
  66. //
  67. void CFepSetupContainer::SizeChanged()
  68.     {
  69.     // TODO: Add here control resize code etc.
  70.     iLabel->SetExtent( TPoint(30,50), iLabel->MinimumSize() );
  71.     }
  72. // ---------------------------------------------------------
  73. // CFepSetupContainer::CountComponentControls() const
  74. // ---------------------------------------------------------
  75. //
  76. TInt CFepSetupContainer::CountComponentControls() const
  77.     {
  78.     return 1; // return nbr of controls inside this container
  79.     }
  80. // ---------------------------------------------------------
  81. // CFepSetupContainer::ComponentControl(TInt aIndex) const
  82. // ---------------------------------------------------------
  83. //
  84. CCoeControl* CFepSetupContainer::ComponentControl(TInt aIndex) const
  85.     {
  86.     switch ( aIndex )
  87.         {
  88.         case 0:
  89.             return iLabel;
  90.         default:
  91.             return NULL;
  92.         }
  93.     }
  94. // ---------------------------------------------------------
  95. // CFepSetupContainer::Draw(const TRect& aRect) const
  96. // ---------------------------------------------------------
  97. //
  98. void CFepSetupContainer::Draw(const TRect& aRect) const
  99.     {
  100.     CWindowGc& gc = SystemGc();
  101.     // TODO: Add your drawing code here
  102.     // example code...
  103.     gc.SetPenStyle(CGraphicsContext::ENullPen);
  104.     gc.SetBrushColor(KRgbGray);
  105.     gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
  106.     gc.DrawRect(aRect);
  107.     }
  108. // ---------------------------------------------------------
  109. // CFepSetupContainer::HandleControlEventL(
  110. //     CCoeControl* aControl,TCoeEvent aEventType)
  111. // ---------------------------------------------------------
  112. //
  113. void CFepSetupContainer::HandleControlEventL(
  114.     CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
  115.     {
  116.     // TODO: Add your control event handler code here
  117.     }
  118. void CFepSetupContainer::InstallFepL()
  119. {
  120. TBuf<256> formatingBuf;
  121.     TInt index(0);
  122.     CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog(&index);
  123.     dlg->PrepareLC(R_FEPSETUP_LIST_QUERY);
  124.     dlg->SetItemTextArray(iNamesOfAvailableFeps);
  125.     dlg->SetOwnershipType(ELbmDoesNotOwnItemArray);
  126.     // Execute the dialog
  127. TInt answer = dlg->RunLD();
  128.     if (answer == EAknSoftkeyOk)
  129. {
  130. iEikonEnv->InfoMsg(TParsePtrC(iFileNamesOfAvailableFeps->MdcaPoint(index)).Name());
  131. // The code below is to check whether the selected Fep is already installed.
  132. TPtrC nameOfFepToInstallPtr(TParsePtrC(iFileNamesOfAvailableFeps->MdcaPoint(index)).Name()); // file name parsing
  133. HBufC* nameOfInstalledFep = iCoeEnv->NameOfInstalledFepL();
  134. CleanupStack::PushL(nameOfInstalledFep);
  135. TPtrC fepFileNamePtr(TParsePtrC(nameOfInstalledFep->Des()).Name()); // file name parsing
  136. if( nameOfFepToInstallPtr.Compare(fepFileNamePtr) == 0) // Already installed?
  137. {
  138. formatingBuf.Format(KFepAlreadyInstalled, &nameOfFepToInstallPtr);
  139. CAknConfirmationNote* confirmationDialog = new(ELeave)CAknConfirmationNote();
  140. confirmationDialog->ExecuteLD(formatingBuf);
  141. }
  142. else
  143. {
  144. // Loads the specified FEP DLL into all running applications. 
  145. // The current loaded FEP, if any, will be unloaded.
  146. iCoeEnv->InstallFepL( iFileNamesOfAvailableFeps->MdcaPoint(index));   // _L("Z:\SYSTEM\FEP\T9FEP.FEP")
  147. formatingBuf.Format(KFepInstalled, &nameOfFepToInstallPtr);
  148. CAknConfirmationNote* confirmationDialog = new(ELeave)CAknConfirmationNote();
  149. confirmationDialog->ExecuteLD(formatingBuf);
  150. }
  151. CleanupStack::PopAndDestroy(); // nameOfInstalledFep;
  152. }
  153. else
  154. {
  155. iEikonEnv->InfoMsg(_L("No Fep Selected"));
  156. }
  157. }
  158. void CFepSetupContainer::UnInstallFepL()
  159. {
  160. TBuf<256> formatingBuf;
  161. HBufC* nameOfInstalledFep = iCoeEnv->NameOfInstalledFepL();
  162. CleanupStack::PushL(nameOfInstalledFep);
  163. TPtrC fepFileNamePtr(TParsePtrC(nameOfInstalledFep->Des()).Name()); // file name parsing
  164. iCoeEnv->InstallFepL(KT9FepName); // Install the default T9 Fep
  165. formatingBuf.Format(KFepUninstalled, &fepFileNamePtr);
  166. CAknConfirmationNote* dialog = new(ELeave)CAknConfirmationNote();
  167. dialog->ExecuteLD(formatingBuf);
  168. CleanupStack::PopAndDestroy(); // nameOfInstalledFep;
  169. }
  170. // End of File