htiui/HtiServicePlugins/HtiSysInfoServicePlugin/src/HtiSysInfoServicePlugin.cpp
branchRCL_3
changeset 42 d40e813b23c0
parent 22 822c625f7adc
equal deleted inserted replaced
33:65b472535a0d 42:d40e813b23c0
    29 #endif
    29 #endif
    30 
    30 
    31 #include <AknSkinsInternalCRKeys.h>
    31 #include <AknSkinsInternalCRKeys.h>
    32 #include <AknsSkinUID.h>
    32 #include <AknsSkinUID.h>
    33 #include <AknsSrvClient.h>
    33 #include <AknsSrvClient.h>
       
    34 #include <AknFepInternalCRKeys.h>
       
    35 #include <AknFepGlobalEnums.h> //For chinese input modes
       
    36 #include <CommonEngineDomainCRKeys.h>
       
    37 #include <featmgr.h>
    34 #include <bautils.h>
    38 #include <bautils.h>
    35 #include <btengsettings.h>
    39 #include <btengsettings.h>
    36 #include <btengdomaincrkeys.h>
    40 #include <btengdomaincrkeys.h>
    37 #include <bt_subscribe.h>
    41 #include <bt_subscribe.h>
    38 #include <btmanclient.h>
    42 #include <btmanclient.h>
    59 
    63 
    60 const TInt KTimeDataLength = 7;
    64 const TInt KTimeDataLength = 7;
    61 const TInt KMaxBtNameLength = 30;
    65 const TInt KMaxBtNameLength = 30;
    62 const TInt KDateTimeFormatCmdLength = 6;
    66 const TInt KDateTimeFormatCmdLength = 6;
    63 
    67 
       
    68 const TInt KFepChineseInputModeLength = 10;
       
    69 
    64 _LIT( KTempFilePath, "\\" );
    70 _LIT( KTempFilePath, "\\" );
    65 _LIT( KTempFileName, "HtiTempFile.tmp" );
    71 _LIT( KTempFileName, "HtiTempFile.tmp" );
    66 _LIT( KMatchFileName, "HtiTempFile.tmp*" );
    72 _LIT( KMatchFileName, "HtiTempFile.tmp*" );
    67 _LIT( KDateSeparatorChars, ".:/-" );
    73 _LIT( KDateSeparatorChars, ".:/-" );
    68 _LIT( KTimeSeparatorChars, ".:" );
    74 _LIT( KTimeSeparatorChars, ".:" );
    81 _LIT8( KErrDescrSetSizeTempFile, "Error allocating size for temp file" );
    87 _LIT8( KErrDescrSetSizeTempFile, "Error allocating size for temp file" );
    82 _LIT8( KErrDescrDeleteTempFile, "Error deleting temp file" );
    88 _LIT8( KErrDescrDeleteTempFile, "Error deleting temp file" );
    83 _LIT8( KErrDescrSysUtil, "SysUtil failed" );
    89 _LIT8( KErrDescrSysUtil, "SysUtil failed" );
    84 _LIT8( KErrDescrSetTime, "Setting time failed" );
    90 _LIT8( KErrDescrSetTime, "Setting time failed" );
    85 _LIT8( KErrDescrDateTimeFormat, "Setting date and time formats failed" );
    91 _LIT8( KErrDescrDateTimeFormat, "Setting date and time formats failed" );
       
    92 _LIT8( KErrDescrSetLanguage, "Setting language failed");
    86 _LIT8( KErrDescrGetNetworkModes, "Getting network modes failed" );
    93 _LIT8( KErrDescrGetNetworkModes, "Getting network modes failed" );
    87 _LIT8( KErrDescrSetNetworkMode, "Setting network mode failed" );
    94 _LIT8( KErrDescrSetNetworkMode, "Setting network mode failed" );
    88 _LIT8( KErrDescrIrActivation, "IR activation failed" );
    95 _LIT8( KErrDescrIrActivation, "IR activation failed" );
    89 _LIT8( KErrDescrGetBtPower, "Getting BT power state failed" );
    96 _LIT8( KErrDescrGetBtPower, "Getting BT power state failed" );
    90 _LIT8( KErrDescrSetBtPower, "Setting BT power state failed" );
    97 _LIT8( KErrDescrSetBtPower, "Setting BT power state failed" );
   128     EReleaseDiskSpace =       0x10,
   135     EReleaseDiskSpace =       0x10,
   129 
   136 
   130     ESysInfoSetHomeTime =     0x20,
   137     ESysInfoSetHomeTime =     0x20,
   131     ESysInfoGetHomeTime =     0x21,
   138     ESysInfoGetHomeTime =     0x21,
   132     ESetDateTimeFormat =      0x22,
   139     ESetDateTimeFormat =      0x22,
       
   140     
       
   141     ESetLanguage =            0x25,
   133 
   142 
   134     ELightStatus =            0x30,
   143     ELightStatus =            0x30,
   135     ELightOn =                0x31,
   144     ELightOn =                0x31,
   136     ELightOff =               0x32,
   145     ELightOff =               0x32,
   137     ELightBlink =             0x33,
   146     ELightBlink =             0x33,
   162     EUpdateMediaGallery =     0x7A,
   171     EUpdateMediaGallery =     0x7A,
   163 
   172 
   164     EActivateSkin =           0x80
   173     EActivateSkin =           0x80
   165     };
   174     };
   166 
   175 
       
   176 enum TGSNumberModes
       
   177     {
       
   178     EGSNbrModeLatin, EGSNbrModeArabic = 1, EGSNbrModeIndic = 1
       
   179     };
       
   180 
       
   181 // Number mode type
       
   182 enum TGSNumberModeType
       
   183     {
       
   184     EGSNbrModeTypeArabic, EGSNbrModeTypeIndic, EGSNbrModeTypeEasternArabic
       
   185     // for Urdu & Farsi languages
       
   186     };
   167 
   187 
   168 //------------------------------------------------------------------------------
   188 //------------------------------------------------------------------------------
   169 // Create instance of concrete ECOM interface implementation
   189 // Create instance of concrete ECOM interface implementation
   170 //------------------------------------------------------------------------------
   190 //------------------------------------------------------------------------------
   171 CHtiSysInfoServicePlugin* CHtiSysInfoServicePlugin::NewL()
   191 CHtiSysInfoServicePlugin* CHtiSysInfoServicePlugin::NewL()
   209         }
   229         }
   210 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
   230 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
   211     iAllowSSProperty.Close();
   231     iAllowSSProperty.Close();
   212 #endif 
   232 #endif 
   213     delete iAllowSSSubscriber;
   233     delete iAllowSSSubscriber;
       
   234     
       
   235     FeatureManager::UnInitializeLib();
   214     }
   236     }
   215 
   237 
   216 //------------------------------------------------------------------------------
   238 //------------------------------------------------------------------------------
   217 // Second phase construction
   239 // Second phase construction
   218 //------------------------------------------------------------------------------
   240 //------------------------------------------------------------------------------
   219 void CHtiSysInfoServicePlugin::ConstructL()
   241 void CHtiSysInfoServicePlugin::ConstructL()
   220     {
   242     {
   221     HTI_LOG_TEXT( "CHtiSysInfoServicePlugin::ConstructL" );
   243     HTI_LOG_TEXT( "CHtiSysInfoServicePlugin::ConstructL" );
   222     User::LeaveIfError( iFs.Connect() );
   244     User::LeaveIfError( iFs.Connect() );
   223     iFileMan = CFileMan::NewL( iFs );
   245     iFileMan = CFileMan::NewL( iFs );
       
   246     
       
   247     FeatureManager::InitializeLibL();
   224     }
   248     }
   225 
   249 
   226 //------------------------------------------------------------------------------
   250 //------------------------------------------------------------------------------
   227 // CHtiSysInfoServicePlugin::ProcessMessageL
   251 // CHtiSysInfoServicePlugin::ProcessMessageL
   228 //------------------------------------------------------------------------------
   252 //------------------------------------------------------------------------------
   348                 break;
   372                 break;
   349             case ESetDateTimeFormat:
   373             case ESetDateTimeFormat:
   350                 {
   374                 {
   351                 HTI_LOG_TEXT( "ESetDateTimeFormat" );
   375                 HTI_LOG_TEXT( "ESetDateTimeFormat" );
   352                 HandleSetDateTimeFormatL( aMessage );
   376                 HandleSetDateTimeFormatL( aMessage );
       
   377                 }
       
   378                 break;
       
   379             case ESetLanguage:
       
   380                 {
       
   381                 HTI_LOG_TEXT("ESetLanguage");
       
   382                 HandleSetLanguageL( aMessage);
   353                 }
   383                 }
   354                 break;
   384                 break;
   355             case ELightStatus:
   385             case ELightStatus:
   356             case ELightOn:
   386             case ELightOn:
   357             case ELightOff:
   387             case ELightOff:
  2849 
  2879 
  2850     HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleActivateSkinL" );
  2880     HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleActivateSkinL" );
  2851     }
  2881     }
  2852 
  2882 
  2853 //------------------------------------------------------------------------------
  2883 //------------------------------------------------------------------------------
       
  2884 // CHtiSysInfoServicePlugin::HandleSetLanguageL
       
  2885 //------------------------------------------------------------------------------
       
  2886 void CHtiSysInfoServicePlugin::HandleSetLanguageL( const TDesC8& aMessage )
       
  2887     {
       
  2888     HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleSetLanguageL" );
       
  2889     if ( aMessage.Length() != 3 )
       
  2890         {
       
  2891         iDispatcher->DispatchOutgoingErrorMessage( KErrArgument,
       
  2892                 KErrDescrArgument, KSysInfoServiceUid );
       
  2893         return;
       
  2894         }
       
  2895     
       
  2896     TInt language = aMessage[1] + ( aMessage[2] << 8 );
       
  2897     if(language < 0)
       
  2898         {
       
  2899         iDispatcher->DispatchOutgoingErrorMessage( KErrArgument,
       
  2900                 KErrDescrSetLanguage, KSysInfoServiceUid );
       
  2901         return;
       
  2902         }
       
  2903     HTI_LOG_FORMAT( "Set language to %d", language );
       
  2904     
       
  2905     // Never set Language code 0 to HAL
       
  2906     if (language != 0)
       
  2907         {
       
  2908         User::LeaveIfError(HAL::Set(HAL::ELanguageIndex, language));
       
  2909         }
       
  2910     
       
  2911     CRepository* commonEngineRepository = CRepository::NewL(
       
  2912             KCRUidCommonEngineKeys);
       
  2913     CleanupStack::PushL(commonEngineRepository);
       
  2914     
       
  2915     User::LeaveIfError(commonEngineRepository->Set(KGSDisplayTxtLang, language));
       
  2916 
       
  2917     CleanupStack::PopAndDestroy();
       
  2918 
       
  2919     TBool nbrModeSaved = EFalse;
       
  2920     if (language == ELangArabic || User::Language() == ELangArabic)
       
  2921         {
       
  2922         //numberMode = EGSNumberModeArabicIndic;
       
  2923         SetDefaultNumberModeL(EGSNbrModeArabic, EGSNbrModeTypeArabic);
       
  2924         nbrModeSaved = ETrue;
       
  2925         }
       
  2926     else if ((language == ELangUrdu || User::Language() == ELangUrdu)
       
  2927             || (language == ELangFarsi || User::Language() == ELangFarsi))
       
  2928         {
       
  2929         //numberMode = EGSNumberModeEasternArabicIndic;
       
  2930         SetDefaultNumberModeL(EGSNbrModeLatin, EGSNbrModeTypeEasternArabic);
       
  2931         nbrModeSaved = ETrue;
       
  2932         }
       
  2933     else if (language == ELangHindi || User::Language() == ELangHindi
       
  2934             || language == ELangMarathi || User::Language() == ELangMarathi)
       
  2935         {
       
  2936         //numberMode = EGSNumberModeIndic;
       
  2937         SetDefaultNumberModeL(EGSNbrModeLatin, EGSNbrModeTypeIndic);
       
  2938         nbrModeSaved = ETrue;
       
  2939         }
       
  2940 
       
  2941     //if number mode is not set above, then set it to Latin with respective
       
  2942     //number mode types. This part might be executed when Automatic is
       
  2943     //selected and the SIM card does not support the language.
       
  2944     if (!nbrModeSaved)
       
  2945         {
       
  2946         TInt nbrModeType = EGSNbrModeTypeIndic;
       
  2947         if (language == ELangArabic || User::Language() == ELangArabic)
       
  2948             {
       
  2949             nbrModeType = EGSNbrModeTypeArabic;
       
  2950             }
       
  2951         else if ((language == ELangUrdu || User::Language() == ELangUrdu)
       
  2952                 || (language == ELangFarsi || User::Language() == ELangFarsi))
       
  2953             {
       
  2954             nbrModeType = EGSNbrModeTypeEasternArabic;
       
  2955             }
       
  2956 
       
  2957         //EGSNumberModeLatin is true in both cases;
       
  2958         SetDefaultNumberModeL(EGSNbrModeLatin, nbrModeType);
       
  2959         }
       
  2960     
       
  2961     // Change input language
       
  2962     CRepository* aknFepRepository = CRepository::NewL( KCRUidAknFep );
       
  2963     CleanupStack::PushL(aknFepRepository);
       
  2964     User::LeaveIfError(  aknFepRepository->Set( KAknFepInputTxtLang,
       
  2965                                                 language ));
       
  2966     // Change input method for Chinese variants
       
  2967     if( FeatureManager::FeatureSupported( KFeatureIdChinese ) )
       
  2968         {
       
  2969         TBuf<KFepChineseInputModeLength> conversion;
       
  2970         if( language == ELangPrcChinese )
       
  2971             {
       
  2972             conversion.Num( EPinyin, EHex );
       
  2973             User::LeaveIfError( aknFepRepository->Set( KAknFepChineseInputMode, conversion ) );
       
  2974             }
       
  2975         else if( language == ELangHongKongChinese )
       
  2976             {
       
  2977             conversion.Num( EStroke, EHex );
       
  2978             User::LeaveIfError( aknFepRepository->Set( KAknFepChineseInputMode, conversion ) );
       
  2979             }
       
  2980         else if( language == ELangTaiwanChinese )
       
  2981             {
       
  2982             conversion.Num( EZhuyin, EHex );
       
  2983             User::LeaveIfError( aknFepRepository->Set( KAknFepChineseInputMode, conversion ) );
       
  2984             }
       
  2985         }
       
  2986     CleanupStack::PopAndDestroy();
       
  2987     
       
  2988     iReply = HBufC8::NewL( 1 );
       
  2989     iReply->Des().Append( 0 );
       
  2990     HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleSetLanguageL" );
       
  2991     }
       
  2992 
       
  2993 void CHtiSysInfoServicePlugin::SetDefaultNumberModeL(TInt aMode, TInt aNbrModeType)
       
  2994     {
       
  2995 
       
  2996     CRepository* localeRepository = CRepository::NewL(KCRUidLocaleSettings);
       
  2997     CleanupStack::PushL(localeRepository);
       
  2998     if (aNbrModeType == EGSNbrModeTypeArabic || aNbrModeType
       
  2999             == EGSNbrModeTypeEasternArabic)
       
  3000         {
       
  3001         localeRepository->Set(KSettingsDefaultNumberMode, aMode);
       
  3002         }
       
  3003     else
       
  3004         {
       
  3005         localeRepository->Set(KSettingsIndicDefaultNumberMode, aMode);
       
  3006         }
       
  3007     CleanupStack::PopAndDestroy();
       
  3008 
       
  3009     TLocale locale;
       
  3010     if (aMode == EGSNbrModeLatin)
       
  3011         {
       
  3012         locale.SetDigitType(EDigitTypeWestern);
       
  3013         }
       
  3014     else
       
  3015         {
       
  3016         //if aMode <> EGSNbrModeLatin, then it should be either latin or arabic. However
       
  3017         //as EGSNbrModeArabic and EGsNbrModeIndic both have a value = 1, we can't use
       
  3018         //that constant for below comparison. Hence, need to depend on the 2nd param.
       
  3019         switch (aNbrModeType)
       
  3020             {
       
  3021             case EGSNbrModeTypeArabic:
       
  3022                 locale.SetDigitType(EDigitTypeArabicIndic);
       
  3023                 break;
       
  3024             case EGSNbrModeTypeIndic:
       
  3025                 locale.SetDigitType(EDigitTypeDevanagari);
       
  3026                 break;
       
  3027             case EGSNbrModeTypeEasternArabic:
       
  3028                 locale.SetDigitType(EDigitTypeEasternArabicIndic);
       
  3029                 break;
       
  3030             default:
       
  3031                 break;
       
  3032             }
       
  3033         }
       
  3034 
       
  3035     locale.Set();
       
  3036     }
       
  3037 //------------------------------------------------------------------------------
  2854 // CHtiSysInfoServicePlugin::ParseTimeDataL
  3038 // CHtiSysInfoServicePlugin::ParseTimeDataL
  2855 //------------------------------------------------------------------------------
  3039 //------------------------------------------------------------------------------
  2856 void CHtiSysInfoServicePlugin::ParseTimeDataL( const TDesC8& aTimeData,
  3040 void CHtiSysInfoServicePlugin::ParseTimeDataL( const TDesC8& aTimeData,
  2857                                                TTime& aResult )
  3041                                                TTime& aResult )
  2858     {
  3042     {