cpsecplugins/devicelockplugin/src/cpdevicelockpluginview.cpp
changeset 37 7bad16cccaca
parent 26 aad866c37519
child 48 6ed68423b759
equal deleted inserted replaced
26:aad866c37519 37:7bad16cccaca
    41 #include<hbaction.h>
    41 #include<hbaction.h>
    42 #include <RemoteLockSettings.h>
    42 #include <RemoteLockSettings.h>
    43 #include "debug.h"
    43 #include "debug.h"
    44 #include <qapplication.h>
    44 #include <qapplication.h>
    45 #include <qtranslator.h>
    45 #include <qtranslator.h>
    46 
    46 #include <../../inc/cpsecplugins.h>
    47 
    47 
    48    
    48    
    49         
    49         
    50 /*
    50 /*
    51  *****************************************************************
    51  *****************************************************************
   110                         "txt_devicelocking_formlabel_automatic_locking"));
   110                         "txt_devicelocking_formlabel_automatic_locking"));
   111         TInt autoLockVal;
   111         TInt autoLockVal;
   112         TInt err = iALPeriodRep->Get(KSettingsAutoLockTime, autoLockVal);
   112         TInt err = iALPeriodRep->Get(KSettingsAutoLockTime, autoLockVal);
   113         TInt index = GetAutoLockIndex(autoLockVal);
   113         TInt index = GetAutoLockIndex(autoLockVal);
   114         Dprint((_L("Current AL period value %d"),autoLockVal));
   114         Dprint((_L("Current AL period value %d"),autoLockVal));
       
   115         RDEBUG("err", err);
       
   116         RDEBUG("index", index);
       
   117         RDEBUG("autoLockVal", autoLockVal);
   115         //TODO: need to set autoLockVal in editor
   118         //TODO: need to set autoLockVal in editor
   116         QStringList autolockPeriodList;
   119         QStringList autolockPeriodList;
   117         autolockPeriodList << hbTrId("txt_devicelocking_button_off")
   120         autolockPeriodList << hbTrId("txt_devicelocking_button_off")
   118                 << hbTrId("txt_devicelocking_setlabel_val_when_keys_screen")
   121                 << hbTrId("txt_devicelocking_setlabel_val_when_keys_screen")
   119                 << hbTrId("txt_devicelocking_setlabel_val_5_minutes")
   122                 << hbTrId("txt_devicelocking_setlabel_val_5_minutes")
   139                 HbDataFormModelItem::ToggleValueItem, hbTrId(
   142                 HbDataFormModelItem::ToggleValueItem, hbTrId(
   140                         "txt_devicelocking_formlabel_lock_when_sim_changed"));
   143                         "txt_devicelocking_formlabel_lock_when_sim_changed"));
   141         TBool lockVal = mUiSecuSettings->IsLockEnabledL(
   144         TBool lockVal = mUiSecuSettings->IsLockEnabledL(
   142                 RMobilePhone::ELockPhoneToICC);
   145                 RMobilePhone::ELockPhoneToICC);
   143         Dprint((_L("LockWhenSimChange enabled %d"),lockVal));
   146         Dprint((_L("LockWhenSimChange enabled %d"),lockVal));
       
   147         RDEBUG("lockVal", lockVal);
   144         if (lockVal)
   148         if (lockVal)
   145             {
   149             {
   146             mLockWhenSimChangeItem->setContentWidgetData("text", hbTrId(
   150             mLockWhenSimChangeItem->setContentWidgetData("text", hbTrId(
   147                     "txt_remotelocking_button_sim_changed_on"));
   151                     "txt_remotelocking_button_sim_changed_on"));
   148             mLockWhenSimChangeItem->setContentWidgetData("additionalText",
   152             mLockWhenSimChangeItem->setContentWidgetData("additionalText",
   165 
   169 
   166         //Remote Lock Setting
   170         //Remote Lock Setting
   167         TBool enabled = true;
   171         TBool enabled = true;
   168         TBool val = mRemoteLockSettings->GetEnabled(enabled);
   172         TBool val = mRemoteLockSettings->GetEnabled(enabled);
   169         Dprint((_L("Remote Lock Setting enabled %d"),val));
   173         Dprint((_L("Remote Lock Setting enabled %d"),val));
       
   174         RDEBUG("val", val);
   170         mDeviceRemoteLockItem = new HbDataFormModelItem(
   175         mDeviceRemoteLockItem = new HbDataFormModelItem(
   171                 HbDataFormModelItem::ToggleValueItem, hbTrId(
   176                 HbDataFormModelItem::ToggleValueItem, hbTrId(
   172                         "txt_devicelocking_subhead_remote_locking"));
   177                         "txt_devicelocking_subhead_remote_locking"));
   173 
   178 
   174         if (val && enabled)
   179         if (val && enabled)
   243  *****************************************************************
   248  *****************************************************************
   244  */
   249  */
   245 void CpDeviceLockPluginView::onLockCodeClicked()
   250 void CpDeviceLockPluginView::onLockCodeClicked()
   246     {
   251     {
   247     Dprint(_L("CpDeviceLockPluginView::onLockCodeClicked()..Enter"));
   252     Dprint(_L("CpDeviceLockPluginView::onLockCodeClicked()..Enter"));
       
   253     RDEBUG("0", 0);
   248     mUiSecuSettings->ChangeSecCodeL();
   254     mUiSecuSettings->ChangeSecCodeL();
   249     Dprint(_L("CpDeviceLockPluginView::onLockCodeClicked()..Exit"));
   255     Dprint(_L("CpDeviceLockPluginView::onLockCodeClicked()..Exit"));
   250 }
   256 }
   251 
   257 
   252 
   258 
   259  ************************************************************************
   265  ************************************************************************
   260  */
   266  */
   261 void CpDeviceLockPluginView::onAutoLockChanged(int index)
   267 void CpDeviceLockPluginView::onAutoLockChanged(int index)
   262     {
   268     {
   263     Dprint(_L("CpDeviceLockPluginView::onAutoLockChanged()..Enter"));
   269     Dprint(_L("CpDeviceLockPluginView::onAutoLockChanged()..Enter"));
       
   270     RDEBUG("index", index);
   264     if (index != mThemeComboPrevIndex)
   271     if (index != mThemeComboPrevIndex)
   265         {
   272         {
   266         //TODO: need to set user entered/selected value
   273         //TODO: need to set user entered/selected value
   267         TInt lockValue = GetValueAtIndex(index);
   274         TInt lockValue = GetValueAtIndex(index);
   268         TInt newAutoLockVal = mUiSecuSettings->ChangeAutoLockPeriodL(
   275         TInt newAutoLockVal = mUiSecuSettings->ChangeAutoLockPeriodL(
   269                 lockValue);
   276                 lockValue);
       
   277         RDEBUG("newAutoLockVal", newAutoLockVal);
       
   278         RDEBUG("lockValue", lockValue);
   270         if (newAutoLockVal == lockValue)
   279         if (newAutoLockVal == lockValue)
   271             {
   280             {
   272             Dprint(_L("onAutoLockChanged().AL setting success !!"));
   281             Dprint(_L("onAutoLockChanged().AL setting success !!"));
       
   282             RDEBUG("success", 1);
   273             TInt err = iALPeriodRep->Set(KSettingsAutoLockTime, lockValue);
   283             TInt err = iALPeriodRep->Set(KSettingsAutoLockTime, lockValue);
       
   284             RDEBUG("err", err);
   274             mThemeComboPrevIndex = index;
   285             mThemeComboPrevIndex = index;
   275             }
   286             }
   276         else
   287         else
   277             {
   288             {
   278             Dprint(_L("onAutoLockChanged()..Setting to previous value"));
   289             Dprint(_L("onAutoLockChanged()..Setting to previous value"));
       
   290             RDEBUG("previous", 0);
   279             QVariant data(mThemeComboPrevIndex);
   291             QVariant data(mThemeComboPrevIndex);
   280             mAutolockPeriodItem->setContentWidgetData(
   292             mAutolockPeriodItem->setContentWidgetData(
   281                     QString("currentIndex"), data);
   293                     QString("currentIndex"), data);
   282             }
   294             }
   283 
   295 
   284         }
   296         }
   285     Dprint(_L("CpDeviceLockPluginView::onAutoLockChanged()..Exit"));
   297     Dprint(_L("CpDeviceLockPluginView::onAutoLockChanged()..Exit"));
       
   298     RDEBUG("0", 0);
   286 }
   299 }
   287 
   300 
   288 
   301 
   289 /*
   302 /*
   290  *************************************************************************
   303  *************************************************************************
   296  **************************************************************************
   309  **************************************************************************
   297  */
   310  */
   298 void CpDeviceLockPluginView::onLockMessageClicked()
   311 void CpDeviceLockPluginView::onLockMessageClicked()
   299     {
   312     {
   300     Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..Exit"));
   313     Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..Exit"));
       
   314     RDEBUG("0", 0);
   301     TBuf<KRLockMaxLockCodeLength> remoteLockCode;
   315     TBuf<KRLockMaxLockCodeLength> remoteLockCode;
   302     TBool remoteLockStatus(EFalse);
   316     TBool remoteLockStatus(EFalse);
   303     TInt retVal = KErrNone;
   317     TInt retVal = KErrNone;
   304     TInt autoLockVal = -1;
   318     TInt autoLockVal = -1;
   305     retVal = mUiSecuSettings->ChangeRemoteLockStatusL(remoteLockStatus,
   319     retVal = mUiSecuSettings->ChangeRemoteLockStatusL(remoteLockStatus,
   306             remoteLockCode, autoLockVal);
   320             remoteLockCode, autoLockVal);
       
   321     RDEBUG("retVal", retVal);
       
   322     RDEBUG("autoLockVal", autoLockVal);
       
   323     RDEBUG("remoteLockStatus", remoteLockStatus);
   307     if (retVal)
   324     if (retVal)
   308         {
   325         {
   309         Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..ChangeRemoteLockStatusL sucess"));
   326         Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..ChangeRemoteLockStatusL sucess"));
       
   327         RDEBUG("sucess", 1);
   310         }
   328         }
   311     else
   329     else
   312         {
   330         {
   313         Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..ChangeRemoteLockStatusL failed"));
   331         Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..ChangeRemoteLockStatusL failed"));
       
   332         RDEBUG("failed", 0);
   314         }
   333         }
   315     Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..Exit"));
   334     Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..Exit"));
       
   335     RDEBUG("0", 0);
   316 }
   336 }
   317 
   337 
   318 
   338 
   319 /*
   339 /*
   320  *************************************************************************
   340  *************************************************************************
   330 
   350 
   331 #if 0
   351 #if 0
   332 void CpDeviceLockPluginView::onAutoTextChanged(const QString& aText)
   352 void CpDeviceLockPluginView::onAutoTextChanged(const QString& aText)
   333     {
   353     {
   334     Dprint(_L("CpDeviceLockPluginView::onAutoTextChanged()..Enter"));
   354     Dprint(_L("CpDeviceLockPluginView::onAutoTextChanged()..Enter"));
       
   355     RDEBUG("0", 0);
   335     //TBool ret = DisplaySecurityDialog(); 
   356     //TBool ret = DisplaySecurityDialog(); 
   336     Dprint(_L("CpDeviceLockPluginView::onAutoTextChanged()..Exit"));
   357     Dprint(_L("CpDeviceLockPluginView::onAutoTextChanged()..Exit"));
   337     
   358     RDEBUG("0", 0);
   338     }
   359     }
   339 #endif
   360 #endif
   340 
   361 
   341 /*
   362 /*
   342  *************************************************************************
   363  *************************************************************************
   348  */
   369  */
   349 void CpDeviceLockPluginView::onRemoteLockDataChanged(QModelIndex aStartIn,QModelIndex aEndIn)
   370 void CpDeviceLockPluginView::onRemoteLockDataChanged(QModelIndex aStartIn,QModelIndex aEndIn)
   350     {
   371     {
   351     Q_UNUSED(aEndIn);
   372     Q_UNUSED(aEndIn);
   352     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..Enter"));
   373     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..Enter"));
       
   374     RDEBUG("0", 0);
   353     HbDataFormModelItem *item = formModel->itemFromIndex(aStartIn);
   375     HbDataFormModelItem *item = formModel->itemFromIndex(aStartIn);
   354 
   376 
   355     if ((item->type() == HbDataFormModelItem::ToggleValueItem)
   377     if ((item->type() == HbDataFormModelItem::ToggleValueItem)
   356             && (item->data(HbDataFormModelItem::LabelRole).toString()
   378             && (item->data(HbDataFormModelItem::LabelRole).toString()
   357                     == hbTrId("txt_devicelocking_subhead_remote_locking")))
   379                     == hbTrId("txt_devicelocking_subhead_remote_locking")))
   358         {
   380         {
   359 
   381 				RDEBUG("mHack", mHack);
   360         //The following If-Else condition should be removed once orbit team fix the issue with datachanged() signal
   382         //The following If-Else condition should be removed once orbit team fix the issue with datachanged() signal
   361         /****************************************************************************************************************/
   383         /****************************************************************************************************************/
   362         if ((mHack % 2) == 0) //need to capture second datachanged() signal , not first one.
   384         if ((mHack % 2) == 0) //need to capture second datachanged() signal , not first one.
   363             {
   385             {
   364             mHack++;
   386             mHack++;
   373         TInt retVal = KErrNone;
   395         TInt retVal = KErrNone;
   374         TBuf<KRLockMaxLockCodeLength> remoteLockCode;
   396         TBuf<KRLockMaxLockCodeLength> remoteLockCode;
   375         TBool remoteLockStatus(EFalse);
   397         TBool remoteLockStatus(EFalse);
   376         CRemoteLockSettings *remoteLockSetting = CRemoteLockSettings::NewL();
   398         CRemoteLockSettings *remoteLockSetting = CRemoteLockSettings::NewL();
   377         TInt err = iALPeriodRep->Get(KSettingsAutoLockTime, autoLockVal);
   399         TInt err = iALPeriodRep->Get(KSettingsAutoLockTime, autoLockVal);
       
   400         RDEBUG("err", err);
       
   401         RDEBUG("autoLockVal", autoLockVal);
       
   402         RDEBUG("retVal", retVal);
   378         QVariant remLockData = mDeviceRemoteLockItem->contentWidgetData(
   403         QVariant remLockData = mDeviceRemoteLockItem->contentWidgetData(
   379                 QString("text"));
   404                 QString("text"));
   380         if (remLockData.toString() == hbTrId(
   405         if (remLockData.toString() == hbTrId(
   381                 "txt_devicelocking_button_remote_on"))
   406                 "txt_devicelocking_button_remote_on"))
   382             {
   407             {
   388             {
   413             {
   389             remoteLockStatus = EFalse;
   414             remoteLockStatus = EFalse;
   390             retVal = mUiSecuSettings->ChangeRemoteLockStatusL(
   415             retVal = mUiSecuSettings->ChangeRemoteLockStatusL(
   391                     remoteLockStatus, remoteLockCode, autoLockVal);
   416                     remoteLockStatus, remoteLockCode, autoLockVal);
   392             }
   417             }
       
   418         RDEBUG("retVal", retVal);
   393         if (retVal == KErrNone)
   419         if (retVal == KErrNone)
   394             {
   420             {
       
   421             RDEBUG("remoteLockStatus", remoteLockStatus);
   395             if (remoteLockStatus)
   422             if (remoteLockStatus)
   396                 {
   423                 {
   397                 if (remoteLockSetting->SetEnabledL(remoteLockCode))
   424                 if (remoteLockSetting->SetEnabledL(remoteLockCode))
   398                     {
   425                     {
   399                     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..remoteLockSetting->SetEnabledL success"));
   426                     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..remoteLockSetting->SetEnabledL success"));
       
   427                     RDEBUG("success", 1);
   400                     mPrevRemLockData
   428                     mPrevRemLockData
   401                             = mDeviceRemoteLockItem->contentWidgetData(
   429                             = mDeviceRemoteLockItem->contentWidgetData(
   402                                     QString("text"));
   430                                     QString("text"));
   403                     }
   431                     }
   404                 else
   432                 else
   405                     {
   433                     {
   406                     RollbackRemoteLockSettingState();
   434                     RollbackRemoteLockSettingState();
   407                     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..remoteLockSetting->SetEnabledL failed"));
   435                     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..remoteLockSetting->SetEnabledL failed"));
       
   436                     RDEBUG("failed", 0);
   408                     }
   437                     }
   409                 }
   438                 }
   410             else
   439             else
   411                 {
   440                 {
   412                 if (mRemoteLockSettings->SetDisabled())
   441                 if (mRemoteLockSettings->SetDisabled())
   413                     {
   442                     {
   414                     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..remoteLockSetting->SetDisabled success"));
   443                     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..remoteLockSetting->SetDisabled success"));
       
   444                     RDEBUG("success", 1);
   415                     mPrevRemLockData
   445                     mPrevRemLockData
   416                             = mDeviceRemoteLockItem->contentWidgetData(
   446                             = mDeviceRemoteLockItem->contentWidgetData(
   417                                     QString("text"));
   447                                     QString("text"));
   418                     }
   448                     }
   419                 else
   449                 else
   420                     {
   450                     {
   421                     RollbackRemoteLockSettingState();
   451                     RollbackRemoteLockSettingState();
   422                     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..remoteLockSetting->SetDisabled failed"));
   452                     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..remoteLockSetting->SetDisabled failed"));
       
   453                     RDEBUG("failed", 0);
   423                     }
   454                     }
   424                 }
   455                 }
   425             }
   456             }
   426         else
   457         else
   427             {
   458             {
   428             Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..RollbackRemoteLockSettingState"));
   459             Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..RollbackRemoteLockSettingState"));
       
   460             RDEBUG("Rollback", 0);
   429             RollbackRemoteLockSettingState();
   461             RollbackRemoteLockSettingState();
   430             }
   462             }
   431         delete remoteLockSetting;
   463         delete remoteLockSetting;
   432         }
   464         }
   433     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..Exit"));
   465     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..Exit"));
       
   466     RDEBUG("0", 0);
   434 }
   467 }
   435 
   468 
   436 
   469 
   437 /*
   470 /*
   438  *************************************************************************
   471  *************************************************************************
   451     if ((item->type() == HbDataFormModelItem::ToggleValueItem)
   484     if ((item->type() == HbDataFormModelItem::ToggleValueItem)
   452             && (item->data(HbDataFormModelItem::LabelRole).toString()
   485             && (item->data(HbDataFormModelItem::LabelRole).toString()
   453                     == hbTrId(
   486                     == hbTrId(
   454                             "txt_devicelocking_formlabel_lock_when_sim_changed")))
   487                             "txt_devicelocking_formlabel_lock_when_sim_changed")))
   455         {
   488         {
       
   489         RDEBUG("mHack", mHack);
   456         //The following If-Else condition should be removed once orbit team fix the issue with datachanged() signal
   490         //The following If-Else condition should be removed once orbit team fix the issue with datachanged() signal
   457         /****************************************************************************************************************/
   491         /****************************************************************************************************************/
   458         if ((mHack % 2) == 0) //need to capture second datachanged() signal , not first one.
   492         if ((mHack % 2) == 0) //need to capture second datachanged() signal , not first one.
   459             {
   493             {
   460             mHack++;
   494             mHack++;
   465             mHack++;
   499             mHack++;
   466             }
   500             }
   467         /****************************************************************************************************************/
   501         /****************************************************************************************************************/
   468 
   502 
   469         TBool ret = mUiSecuSettings->ChangeSimSecurityL();
   503         TBool ret = mUiSecuSettings->ChangeSimSecurityL();
       
   504         RDEBUG("ret", ret);
   470         if (!ret)
   505         if (!ret)
   471             {
   506             {
   472             /* 
   507             /* 
   473              * disconnect to datachanged() signal as we are not interested in this signal
   508              * disconnect to datachanged() signal as we are not interested in this signal
   474              * generated as a part of setContentWidgetData() API call below
   509              * generated as a part of setContentWidgetData() API call below
   505  **************************************************************************
   540  **************************************************************************
   506  */
   541  */
   507 TInt CpDeviceLockPluginView::GetAutoLockIndex(TInt aValue)
   542 TInt CpDeviceLockPluginView::GetAutoLockIndex(TInt aValue)
   508     {
   543     {
   509     TInt index = 0;
   544     TInt index = 0;
       
   545     RDEBUG("ret", aValue);
   510     switch (aValue)
   546     switch (aValue)
   511         {
   547         {
   512         case 0:
   548         case 0:
   513             index = 0;
   549             index = 0;
   514             break;
   550             break;
   525             index = 4;
   561             index = 4;
   526             break;
   562             break;
   527         default:
   563         default:
   528             break;
   564             break;
   529         }
   565         }
   530 
   566 		RDEBUG("index", index);
   531     return index;
   567     return index;
   532     }
   568     }
   533 
   569 
   534 
   570 
   535 /*
   571 /*
   542  **************************************************************************
   578  **************************************************************************
   543  */
   579  */
   544 TInt CpDeviceLockPluginView::GetValueAtIndex(TInt aIndex)
   580 TInt CpDeviceLockPluginView::GetValueAtIndex(TInt aIndex)
   545     {
   581     {
   546     TInt value = 0;
   582     TInt value = 0;
   547 
   583 		RDEBUG("aIndex", aIndex);
   548     switch (aIndex)
   584     switch (aIndex)
   549         {
   585         {
   550         case 0:
   586         case 0:
   551             value = 0;
   587             value = 0;
   552             break;
   588             break;
   563             value = 60;
   599             value = 60;
   564             break;
   600             break;
   565         default:
   601         default:
   566             break;
   602             break;
   567         }
   603         }
   568 
   604 		RDEBUG("value", value);
   569     return value;
   605     return value;
   570 }
   606 }
   571 
   607 
   572 
   608 
   573 /*
   609 /*
   579  *               then this function resets to previous value.
   615  *               then this function resets to previous value.
   580  **************************************************************************
   616  **************************************************************************
   581  */
   617  */
   582 void CpDeviceLockPluginView::RollbackRemoteLockSettingState()
   618 void CpDeviceLockPluginView::RollbackRemoteLockSettingState()
   583     {
   619     {
       
   620     RDEBUG("0", 0);
   584     /* 
   621     /* 
   585      * disconnect to datachanged() signal as we are not interested in this signal
   622      * disconnect to datachanged() signal as we are not interested in this signal
   586      * generated as a part of setContentWidgetData() API call below
   623      * generated as a part of setContentWidgetData() API call below
   587      */
   624      */
   588     disconnect(formModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
   625     disconnect(formModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
   604     if (mPrevRemLockData.toString() == hbTrId(
   641     if (mPrevRemLockData.toString() == hbTrId(
   605             "txt_devicelocking_button_remote_on"))
   642             "txt_devicelocking_button_remote_on"))
   606         mRemoteLockMessageItem->setEnabled(true);
   643         mRemoteLockMessageItem->setEnabled(true);
   607     else
   644     else
   608         mRemoteLockMessageItem->setEnabled(false);
   645         mRemoteLockMessageItem->setEnabled(false);
   609 
   646 		RDEBUG("0", 0);
   610     }
   647     }