cpsecplugins/devicelockplugin/src/cpdevicelockpluginview.cpp
branchRCL_3
changeset 22 03674e5abf46
parent 21 09b1ac925e3f
child 23 94da73d93b58
equal deleted inserted replaced
21:09b1ac925e3f 22:03674e5abf46
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0""
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:  
       
    15  *
       
    16  */
       
    17 
       
    18 #include "cpdevicelockpluginview.h"
       
    19 #include <QStringList>
       
    20 #include <hblineedit.h>
       
    21 #include <hbdataform.h>
       
    22 #include <hbdataformmodel.h>
       
    23 #include <hbdataformmodelitem.h>
       
    24 #include "cpremotelockdataformviewitem.h"
       
    25 #include <hblabel.h>
       
    26 #include <hbpushbutton.h>
       
    27 #include <HbMessageBox>
       
    28 #include <hbdataform.h>
       
    29 #include <QGraphicsLinearLayout>
       
    30 #include <secuisecuritysettings.h>
       
    31 #include <secuisecurityhandler.h>
       
    32 #include <etelmm.h>
       
    33 #include <rmmcustomapi.h>
       
    34 #include <hbinputdialog.h>
       
    35 #include <secui.h>
       
    36 #include <RemoteLockSettings.h>
       
    37 #include <e32cmn.h>
       
    38 #include <centralrepository.h>
       
    39 #include <settingsinternalcrkeys.h>
       
    40 #include <hbcombobox.h>
       
    41 #include<hbaction.h>
       
    42 #include <RemoteLockSettings.h>
       
    43 #include "debug.h"
       
    44 #include <qapplication.h>
       
    45 #include <qtranslator.h>
       
    46 #include <../../inc/cpsecplugins.h>
       
    47 
       
    48    
       
    49         
       
    50 /*
       
    51  *****************************************************************
       
    52  * Name        : CpDeviceLockPluginView()
       
    53  * Parameters  : QGraphicsItem*
       
    54  * Return value: None
       
    55  * Description : constructor
       
    56  *****************************************************************
       
    57  */
       
    58 CpDeviceLockPluginView::CpDeviceLockPluginView(QGraphicsItem *parent /*= 0*/)
       
    59 : CpBaseSettingView(0,parent)
       
    60     {
       
    61     QTranslator *translator = new QTranslator();
       
    62     QString lang = QLocale::system().name();
       
    63     QString path = "Z:/resource/qt/translations/";
       
    64     bool fine = translator->load("devicelocking_en.qm", path);
       
    65     if (fine)
       
    66         qApp->installTranslator(translator);
       
    67 
       
    68     QTranslator *commontranslator = new QTranslator();
       
    69 
       
    70     fine = commontranslator->load("common_" + lang, path);
       
    71     if (fine)
       
    72         qApp->installTranslator(commontranslator);
       
    73 
       
    74     TSecUi::InitializeLibL();
       
    75     mUiSecuSettings = CSecuritySettings::NewL();
       
    76     mRemoteLockSettings = CRemoteLockSettings::NewL();
       
    77     iALPeriodRep = CRepository::NewL(KCRUidSecuritySettings);
       
    78 
       
    79     mRemoteLockSettingClicked = false;
       
    80     mHack = 0;
       
    81     HbDataForm *form = qobject_cast<HbDataForm*> (widget());
       
    82     if (form)
       
    83         {
       
    84         QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(
       
    85                 Qt::Vertical);
       
    86         QList<HbAbstractViewItem *> protoTypeList = form->itemPrototypes();
       
    87         protoTypeList.append(new CpRemoteLockDataFormViewItem());
       
    88         form->setItemPrototypes(protoTypeList);
       
    89         form->setHeading(hbTrId("txt_cp_dblist_device_lock"));
       
    90 
       
    91         //DataFormModel
       
    92         formModel = new HbDataFormModel();
       
    93 
       
    94         //lockcode
       
    95         HbDataFormModelItem
       
    96                 *lockCodeItem =
       
    97                         new HbDataFormModelItem(
       
    98                                 static_cast<HbDataFormModelItem::DataItemType> (CpRemoteLockDataFormViewItem::CpCodeEditItem),
       
    99                                 hbTrId("txt_devicelocking_dialog_lock_code"));
       
   100         lockCodeItem->setContentWidgetData("echomode", HbLineEdit::Password);
       
   101         lockCodeItem->setContentWidgetData("text", "1234");
       
   102         lockCodeItem->setContentWidgetData("readonly", true);
       
   103         form->addConnection(lockCodeItem, SIGNAL(clicked()), this,
       
   104                 SLOT(onLockCodeClicked()));
       
   105         formModel->appendDataFormItem(lockCodeItem);
       
   106 
       
   107         //Autolock period
       
   108         mAutolockPeriodItem = new HbDataFormModelItem(
       
   109                 HbDataFormModelItem::ComboBoxItem, hbTrId(
       
   110                         "txt_devicelocking_formlabel_automatic_locking"));
       
   111         TInt autoLockVal;
       
   112         TInt err = iALPeriodRep->Get(KSettingsAutoLockTime, autoLockVal);
       
   113         TInt index = GetAutoLockIndex(autoLockVal);
       
   114         Dprint((_L("Current AL period value %d"),autoLockVal));
       
   115         RDEBUG("err", err);
       
   116         RDEBUG("index", index);
       
   117         RDEBUG("autoLockVal", autoLockVal);
       
   118         //TODO: need to set autoLockVal in editor
       
   119         QStringList autolockPeriodList;
       
   120         autolockPeriodList << hbTrId("txt_devicelocking_button_off")
       
   121                 << hbTrId("txt_devicelocking_setlabel_val_when_keys_screen")
       
   122                 << hbTrId("txt_devicelocking_setlabel_val_5_minutes")
       
   123                 << hbTrId("txt_devicelocking_setlabel_val_30_minutes")
       
   124                 << hbTrId("txt_devicelocking_setlabel_val_60_minutes");
       
   125         mAutolockPeriodItem->setContentWidgetData(QString("items"),
       
   126                 autolockPeriodList);
       
   127         mAutolockPeriodItem->setContentWidgetData(QString("currentIndex"),
       
   128                 index);
       
   129         mAutolockPeriodItem->setContentWidgetData(QString("editable"), true);
       
   130         QVariant themeComboData = mAutolockPeriodItem->contentWidgetData(
       
   131                 QString("currentIndex"));
       
   132         mThemeComboPrevIndex = themeComboData.toInt();
       
   133 
       
   134         form->addConnection(mAutolockPeriodItem,
       
   135                 SIGNAL(currentIndexChanged(int)), this,
       
   136                 SLOT(onAutoLockChanged(int)));
       
   137         //form->addConnection(mAutolockPeriodItem,SIGNAL(editTextChanged(const QString&)), this, SLOT(onAutoTextChanged(const QString&)));
       
   138         formModel->appendDataFormItem(mAutolockPeriodItem);
       
   139 
       
   140         //LockWhenSimChange
       
   141         mLockWhenSimChangeItem = new HbDataFormModelItem(
       
   142                 HbDataFormModelItem::ToggleValueItem, hbTrId(
       
   143                         "txt_devicelocking_formlabel_lock_when_sim_changed"));
       
   144         TBool lockVal = mUiSecuSettings->IsLockEnabledL(
       
   145                 RMobilePhone::ELockPhoneToICC);
       
   146         Dprint((_L("LockWhenSimChange enabled %d"),lockVal));
       
   147         RDEBUG("lockVal", lockVal);
       
   148         if (lockVal)
       
   149             {
       
   150             mLockWhenSimChangeItem->setContentWidgetData("text", hbTrId(
       
   151                     "txt_remotelocking_button_sim_changed_on"));
       
   152             mLockWhenSimChangeItem->setContentWidgetData("additionalText",
       
   153                     hbTrId("txt_devicelocking_button_sim_changed_off"));
       
   154             }
       
   155         else
       
   156             {
       
   157             mLockWhenSimChangeItem->setContentWidgetData("text", hbTrId(
       
   158                     "txt_devicelocking_button_sim_changed_off"));
       
   159             mLockWhenSimChangeItem->setContentWidgetData("additionalText",
       
   160                     hbTrId("txt_remotelocking_button_sim_changed_on"));
       
   161             }
       
   162         mLockWhenSimChangeItem->setContentWidgetData("readonly", true);
       
   163         mPrevSIMLockData = mLockWhenSimChangeItem->contentWidgetData(QString(
       
   164                 "text"));
       
   165 
       
   166         connect(formModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
       
   167                 this, SLOT(onSIMLockDataChanged(QModelIndex,QModelIndex)));
       
   168         formModel->appendDataFormItem(mLockWhenSimChangeItem);
       
   169 
       
   170         //Remote Lock Setting
       
   171         TBool enabled = true;
       
   172         TBool val = mRemoteLockSettings->GetEnabled(enabled);
       
   173         Dprint((_L("Remote Lock Setting enabled %d"),val));
       
   174         RDEBUG("val", val);
       
   175         mDeviceRemoteLockItem = new HbDataFormModelItem(
       
   176                 HbDataFormModelItem::ToggleValueItem, hbTrId(
       
   177                         "txt_devicelocking_subhead_remote_locking"));
       
   178 
       
   179         if (val && enabled)
       
   180             {
       
   181             mDeviceRemoteLockItem->setContentWidgetData("text", hbTrId(
       
   182                     "txt_devicelocking_button_remote_on"));
       
   183             mDeviceRemoteLockItem->setContentWidgetData("additionalText",
       
   184                     hbTrId("txt_devicelocking_button_remote_off"));
       
   185             }
       
   186         else
       
   187             {
       
   188             mDeviceRemoteLockItem->setContentWidgetData("text", hbTrId(
       
   189                     "txt_devicelocking_button_remote_off"));
       
   190             mDeviceRemoteLockItem->setContentWidgetData("additionalText",
       
   191                     hbTrId("txt_devicelocking_button_remote_on"));
       
   192             }
       
   193 
       
   194         mPrevRemLockData = mDeviceRemoteLockItem->contentWidgetData(QString(
       
   195                 "text"));
       
   196         QString s = mPrevRemLockData.toString();
       
   197         connect(formModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
       
   198                 this, SLOT(onRemoteLockDataChanged(QModelIndex,QModelIndex)));
       
   199         formModel->appendDataFormItem(mDeviceRemoteLockItem);
       
   200 
       
   201         //Remote lock message
       
   202         mRemoteLockMessageItem
       
   203                 = new HbDataFormModelItem(
       
   204                         static_cast<HbDataFormModelItem::DataItemType> (CpRemoteLockDataFormViewItem::CpCodeEditItem),
       
   205                         hbTrId("txt_devicelocking_formlabel_locking_message"));
       
   206         mRemoteLockMessageItem->setContentWidgetData("echoMode",
       
   207                 HbLineEdit::Password);
       
   208         mRemoteLockMessageItem->setContentWidgetData("text", "1111");
       
   209         mRemoteLockMessageItem->setContentWidgetData("readOnly", true);
       
   210 
       
   211         if (mPrevRemLockData.toString() == hbTrId(
       
   212                 "txt_devicelocking_button_remote_on"))
       
   213             mRemoteLockMessageItem->setEnabled(true);
       
   214         else
       
   215             mRemoteLockMessageItem->setEnabled(false);
       
   216 
       
   217         form->addConnection(mRemoteLockMessageItem, SIGNAL(clicked()), this,
       
   218                 SLOT(onLockMessageClicked()));
       
   219         formModel->appendDataFormItem(mRemoteLockMessageItem);
       
   220 
       
   221         form->setModel(formModel);
       
   222         layout->addItem(form);
       
   223         setLayout(layout);
       
   224         }
       
   225     }
       
   226 
       
   227 
       
   228 /*
       
   229  *****************************************************************
       
   230  * Name        : ~CpDeviceLockPluginView()
       
   231  * Parameters  : None
       
   232  * Return value: None
       
   233  * Description : destructor
       
   234  *****************************************************************
       
   235  */
       
   236 CpDeviceLockPluginView::~CpDeviceLockPluginView()
       
   237     {
       
   238     TSecUi::UnInitializeLib();
       
   239 }
       
   240 
       
   241 
       
   242 /*
       
   243  *****************************************************************
       
   244  * Name        : onLockCodeClicked()
       
   245  * Parameters  : None
       
   246  * Return value: None
       
   247  * Description : Enables user to change the lock code
       
   248  *****************************************************************
       
   249  */
       
   250 void CpDeviceLockPluginView::onLockCodeClicked()
       
   251     {
       
   252     Dprint(_L("CpDeviceLockPluginView::onLockCodeClicked()..Enter"));
       
   253     RDEBUG("0", 0);
       
   254     mUiSecuSettings->ChangeSecCodeL();
       
   255     Dprint(_L("CpDeviceLockPluginView::onLockCodeClicked()..Exit"));
       
   256 }
       
   257 
       
   258 
       
   259 /*
       
   260  ************************************************************************
       
   261  * Name        : onAutoLockChanged()
       
   262  * Parameters  : int
       
   263  * Return value: None
       
   264  * Description : handles the data when automatic lock timings are changed
       
   265  ************************************************************************
       
   266  */
       
   267 void CpDeviceLockPluginView::onAutoLockChanged(int index)
       
   268     {
       
   269     Dprint(_L("CpDeviceLockPluginView::onAutoLockChanged()..Enter"));
       
   270     RDEBUG("index", index);
       
   271     if (index != mThemeComboPrevIndex)
       
   272         {
       
   273         //TODO: need to set user entered/selected value
       
   274         TInt lockValue = GetValueAtIndex(index);
       
   275         TInt newAutoLockVal = mUiSecuSettings->ChangeAutoLockPeriodL(
       
   276                 lockValue);
       
   277         RDEBUG("newAutoLockVal", newAutoLockVal);
       
   278         RDEBUG("lockValue", lockValue);
       
   279         if (newAutoLockVal == lockValue)
       
   280             {
       
   281             Dprint(_L("onAutoLockChanged().AL setting success !!"));
       
   282             RDEBUG("success", 1);
       
   283             TInt err = iALPeriodRep->Set(KSettingsAutoLockTime, lockValue);
       
   284             RDEBUG("err", err);
       
   285             mThemeComboPrevIndex = index;
       
   286             }
       
   287         else
       
   288             {
       
   289             Dprint(_L("onAutoLockChanged()..Setting to previous value"));
       
   290             RDEBUG("previous", 0);
       
   291             QVariant data(mThemeComboPrevIndex);
       
   292             mAutolockPeriodItem->setContentWidgetData(
       
   293                     QString("currentIndex"), data);
       
   294             }
       
   295 
       
   296         }
       
   297     Dprint(_L("CpDeviceLockPluginView::onAutoLockChanged()..Exit"));
       
   298     RDEBUG("0", 0);
       
   299 }
       
   300 
       
   301 
       
   302 /*
       
   303  *************************************************************************
       
   304  * Name        : onLockMessageClicked()
       
   305  * Parameters  : None
       
   306  * Return value: None
       
   307  * Description : verifies security code and enables user to change the lock 
       
   308  *               message
       
   309  **************************************************************************
       
   310  */
       
   311 void CpDeviceLockPluginView::onLockMessageClicked()
       
   312     {
       
   313     Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..Exit"));
       
   314     RDEBUG("0", 0);
       
   315     TBuf<KRLockMaxLockCodeLength> remoteLockCode;
       
   316     TBool remoteLockStatus(EFalse);
       
   317     TInt retVal = KErrNone;
       
   318     TInt autoLockVal = -1;
       
   319     retVal = mUiSecuSettings->ChangeRemoteLockStatusL(remoteLockStatus,
       
   320             remoteLockCode, autoLockVal);
       
   321     RDEBUG("retVal", retVal);
       
   322     RDEBUG("autoLockVal", autoLockVal);
       
   323     RDEBUG("remoteLockStatus", remoteLockStatus);
       
   324     if (retVal)
       
   325         {
       
   326         Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..ChangeRemoteLockStatusL sucess"));
       
   327         RDEBUG("sucess", 1);
       
   328         }
       
   329     else
       
   330         {
       
   331         Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..ChangeRemoteLockStatusL failed"));
       
   332         RDEBUG("failed", 0);
       
   333         }
       
   334     Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..Exit"));
       
   335     RDEBUG("0", 0);
       
   336 }
       
   337 
       
   338 
       
   339 /*
       
   340  *************************************************************************
       
   341  * Name        : onAutoTextChanged()
       
   342  * Parameters  : QString&
       
   343  * Return value: None
       
   344  * Description :  
       
   345   **************************************************************************
       
   346  */
       
   347 /*
       
   348  *This slot can be enabled once fix from obit team for this siganl is available 
       
   349  */
       
   350 
       
   351 #if 0
       
   352 void CpDeviceLockPluginView::onAutoTextChanged(const QString& aText)
       
   353     {
       
   354     Dprint(_L("CpDeviceLockPluginView::onAutoTextChanged()..Enter"));
       
   355     RDEBUG("0", 0);
       
   356     //TBool ret = DisplaySecurityDialog(); 
       
   357     Dprint(_L("CpDeviceLockPluginView::onAutoTextChanged()..Exit"));
       
   358     RDEBUG("0", 0);
       
   359     }
       
   360 #endif
       
   361 
       
   362 /*
       
   363  *************************************************************************
       
   364  * Name        : onRemoteLockDataChanged()
       
   365  * Parameters  : QModelIndex
       
   366  * Return value: None
       
   367  * Description : handles the data when remote lock settings is changed
       
   368  **************************************************************************
       
   369  */
       
   370 void CpDeviceLockPluginView::onRemoteLockDataChanged(QModelIndex aStartIn,QModelIndex aEndIn)
       
   371     {
       
   372     Q_UNUSED(aEndIn);
       
   373     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..Enter"));
       
   374     RDEBUG("0", 0);
       
   375     HbDataFormModelItem *item = formModel->itemFromIndex(aStartIn);
       
   376 
       
   377     if ((item->type() == HbDataFormModelItem::ToggleValueItem)
       
   378             && (item->data(HbDataFormModelItem::LabelRole).toString()
       
   379                     == hbTrId("txt_devicelocking_subhead_remote_locking")))
       
   380         {
       
   381 				RDEBUG("mHack", mHack);
       
   382         //The following If-Else condition should be removed once orbit team fix the issue with datachanged() signal
       
   383         /****************************************************************************************************************
       
   384         if ((mHack % 2) == 0) //need to capture second datachanged() signal , not first one.
       
   385             {
       
   386             mHack++;
       
   387             return;
       
   388             }
       
   389         else
       
   390             {
       
   391             mHack++;
       
   392             }
       
   393         /****************************************************************************************************************/
       
   394         TInt autoLockVal;
       
   395         TInt retVal = KErrNone;
       
   396         TBuf<KRLockMaxLockCodeLength> remoteLockCode;
       
   397         TBool remoteLockStatus(EFalse);
       
   398         CRemoteLockSettings *remoteLockSetting = CRemoteLockSettings::NewL();
       
   399         TInt err = iALPeriodRep->Get(KSettingsAutoLockTime, autoLockVal);
       
   400         RDEBUG("err", err);
       
   401         RDEBUG("autoLockVal", autoLockVal);
       
   402         RDEBUG("retVal", retVal);
       
   403         QVariant remLockData = mDeviceRemoteLockItem->contentWidgetData(
       
   404                 QString("text"));
       
   405         if (remLockData.toString() == hbTrId(
       
   406                 "txt_devicelocking_button_remote_on"))
       
   407             {
       
   408             remoteLockStatus = ETrue;
       
   409             retVal = mUiSecuSettings->ChangeRemoteLockStatusL(
       
   410                     remoteLockStatus, remoteLockCode, autoLockVal);
       
   411             }
       
   412         else
       
   413             {
       
   414             remoteLockStatus = EFalse;
       
   415             retVal = mUiSecuSettings->ChangeRemoteLockStatusL(
       
   416                     remoteLockStatus, remoteLockCode, autoLockVal);
       
   417             }
       
   418         RDEBUG("retVal", retVal);
       
   419         if (retVal == KErrNone)
       
   420             {
       
   421             RDEBUG("remoteLockStatus", remoteLockStatus);
       
   422             if (remoteLockStatus)
       
   423                 {
       
   424                 if (remoteLockSetting->SetEnabledL(remoteLockCode))
       
   425                     {
       
   426                     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..remoteLockSetting->SetEnabledL success"));
       
   427                     RDEBUG("success", 1);
       
   428                     mPrevRemLockData
       
   429                             = mDeviceRemoteLockItem->contentWidgetData(
       
   430                                     QString("text"));
       
   431                     }
       
   432                 else
       
   433                     {
       
   434                     RollbackRemoteLockSettingState();
       
   435                     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..remoteLockSetting->SetEnabledL failed"));
       
   436                     RDEBUG("failed", 0);
       
   437                     }
       
   438                 }
       
   439             else
       
   440                 {
       
   441                 if (mRemoteLockSettings->SetDisabled())
       
   442                     {
       
   443                     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..remoteLockSetting->SetDisabled success"));
       
   444                     RDEBUG("success", 1);
       
   445                     mPrevRemLockData
       
   446                             = mDeviceRemoteLockItem->contentWidgetData(
       
   447                                     QString("text"));
       
   448                     }
       
   449                 else
       
   450                     {
       
   451                     RollbackRemoteLockSettingState();
       
   452                     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..remoteLockSetting->SetDisabled failed"));
       
   453                     RDEBUG("failed", 0);
       
   454                     }
       
   455                 }
       
   456             }
       
   457         else
       
   458             {
       
   459             Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..RollbackRemoteLockSettingState"));
       
   460             RDEBUG("Rollback", 0);
       
   461             RollbackRemoteLockSettingState();
       
   462             }
       
   463         delete remoteLockSetting;
       
   464         }
       
   465     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..Exit"));
       
   466     RDEBUG("0", 0);
       
   467 }
       
   468 
       
   469 
       
   470 /*
       
   471  *************************************************************************
       
   472  * Name        : onSIMLockDataChanged()
       
   473  * Parameters  : QModelIndex
       
   474  * Return value: None
       
   475  * Description : handles the data afer Lock when SIM changed settings is 
       
   476  *               changed
       
   477  **************************************************************************
       
   478  */
       
   479 void CpDeviceLockPluginView::onSIMLockDataChanged(QModelIndex aStartIn, QModelIndex aEndIn)
       
   480     {
       
   481     Q_UNUSED(aEndIn);
       
   482     HbDataFormModelItem *item = formModel->itemFromIndex(aStartIn);
       
   483 
       
   484     if ((item->type() == HbDataFormModelItem::ToggleValueItem)
       
   485             && (item->data(HbDataFormModelItem::LabelRole).toString()
       
   486                     == hbTrId(
       
   487                             "txt_devicelocking_formlabel_lock_when_sim_changed")))
       
   488         {
       
   489         RDEBUG("mHack", mHack);
       
   490         //The following If-Else condition should be removed once orbit team fix the issue with datachanged() signal
       
   491         /****************************************************************************************************************/
       
   492         if ((mHack % 2) == 0) //need to capture second datachanged() signal , not first one.
       
   493             {
       
   494             mHack++;
       
   495             return;
       
   496             }
       
   497         else
       
   498             {
       
   499             mHack++;
       
   500             }
       
   501         /****************************************************************************************************************/
       
   502 
       
   503         TBool ret = mUiSecuSettings->ChangeSimSecurityL();
       
   504         RDEBUG("ret", ret);
       
   505         if (!ret)
       
   506             {
       
   507             /* 
       
   508              * disconnect to datachanged() signal as we are not interested in this signal
       
   509              * generated as a part of setContentWidgetData() API call below
       
   510              */
       
   511             disconnect(formModel,
       
   512                     SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
       
   513                     SLOT(onSIMLockDataChanged(QModelIndex,QModelIndex)));
       
   514             QVariant txt = mLockWhenSimChangeItem->contentWidgetData(QString(
       
   515                     "text"));
       
   516             QVariant additionalText =
       
   517                     mLockWhenSimChangeItem->contentWidgetData(QString(
       
   518                             "additionalText"));
       
   519 
       
   520             mLockWhenSimChangeItem->setContentWidgetData(QString("text"),
       
   521                     additionalText);
       
   522             mLockWhenSimChangeItem->setContentWidgetData(QString(
       
   523                     "additionalText"), txt);
       
   524             /*
       
   525              * Now connect back to datachanged() signal .
       
   526              */
       
   527             connect(formModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
       
   528                     this, SLOT(onSIMLockDataChanged(QModelIndex,QModelIndex)));
       
   529             }
       
   530         }
       
   531 }
       
   532 
       
   533 
       
   534 /*
       
   535  *************************************************************************
       
   536  * Name        : GetAutoLockIndex()
       
   537  * Parameters  : TInt
       
   538  * Return value: TInt
       
   539  * Description : returns corresponding index for the given autolock value
       
   540  **************************************************************************
       
   541  */
       
   542 TInt CpDeviceLockPluginView::GetAutoLockIndex(TInt aValue)
       
   543     {
       
   544     TInt index = 0;
       
   545     RDEBUG("ret", aValue);
       
   546     switch (aValue)
       
   547         {
       
   548         case 0:
       
   549             index = 0;
       
   550             break;
       
   551         case 65535:
       
   552             index = 1;
       
   553             break;
       
   554         case 5:
       
   555             index = 2;
       
   556             break;
       
   557         case 30:
       
   558             index = 3;
       
   559             break;
       
   560         case 60:
       
   561             index = 4;
       
   562             break;
       
   563         default:
       
   564             break;
       
   565         }
       
   566 		RDEBUG("index", index);
       
   567     return index;
       
   568     }
       
   569 
       
   570 
       
   571 /*
       
   572  *************************************************************************
       
   573  * Name        : GetValueAtIndex()
       
   574  * Parameters  : TInt
       
   575  * Return value: TInt
       
   576  * Description : returns the corresponding autolock value for the given 
       
   577  *               index.
       
   578  **************************************************************************
       
   579  */
       
   580 TInt CpDeviceLockPluginView::GetValueAtIndex(TInt aIndex)
       
   581     {
       
   582     TInt value = 0;
       
   583 		RDEBUG("aIndex", aIndex);
       
   584     switch (aIndex)
       
   585         {
       
   586         case 0:
       
   587             value = 0;
       
   588             break;
       
   589         case 1:
       
   590             value = 65535;
       
   591             break;
       
   592         case 2:
       
   593             value = 5;
       
   594             break;
       
   595         case 3:
       
   596             value = 30;
       
   597             break;
       
   598         case 4:
       
   599             value = 60;
       
   600             break;
       
   601         default:
       
   602             break;
       
   603         }
       
   604 		RDEBUG("value", value);
       
   605     return value;
       
   606 }
       
   607 
       
   608 
       
   609 /*
       
   610  *************************************************************************
       
   611  * Name        : RollbackRemoteLockSettingState()
       
   612  * Parameters  : None
       
   613  * Return value: None
       
   614  * Description : If Remote Lock Settings fails or user cancels the settings
       
   615  *               then this function resets to previous value.
       
   616  **************************************************************************
       
   617  */
       
   618 void CpDeviceLockPluginView::RollbackRemoteLockSettingState()
       
   619     {
       
   620     RDEBUG("0", 0);
       
   621     /* 
       
   622      * disconnect to datachanged() signal as we are not interested in this signal
       
   623      * generated as a part of setContentWidgetData() API call below
       
   624      */
       
   625     disconnect(formModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
       
   626             this, SLOT(onRemoteLockDataChanged(QModelIndex,QModelIndex)));
       
   627 
       
   628     QVariant txt = mDeviceRemoteLockItem->contentWidgetData(QString("text"));
       
   629     QVariant additionaltxt = mDeviceRemoteLockItem->contentWidgetData(
       
   630             QString("additionalText"));
       
   631     mDeviceRemoteLockItem->setContentWidgetData(QString("text"),
       
   632             additionaltxt);
       
   633     mDeviceRemoteLockItem->setContentWidgetData(QString("additionalText"),
       
   634             txt);
       
   635     /*
       
   636      * Now connect back to datachanged() signal .
       
   637      */
       
   638     connect(formModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
       
   639             SLOT(onRemoteLockDataChanged(QModelIndex,QModelIndex)));
       
   640 
       
   641     if (mPrevRemLockData.toString() == hbTrId(
       
   642             "txt_devicelocking_button_remote_on"))
       
   643         mRemoteLockMessageItem->setEnabled(true);
       
   644     else
       
   645         mRemoteLockMessageItem->setEnabled(false);
       
   646 		RDEBUG("0", 0);
       
   647     }