cmmanager/cppacketdataapplugin/src/cppacketdataapview.cpp
changeset 20 9c97ad6591ae
child 23 7ec726f93df1
equal deleted inserted replaced
18:fcbbe021d614 20:9c97ad6591ae
       
     1 /*
       
     2 * Copyright (c) 2010 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 * Control Panel packet data AP settings view header file.  
       
    16 *
       
    17 */
       
    18 
       
    19 // System includes
       
    20 #include <QString>
       
    21 #include <QStringList>
       
    22 #include <QVariant>
       
    23 #include <HbMainWindow>
       
    24 #include <HbMenu>
       
    25 #include <HbDataForm>
       
    26 #include <HbDataFormModel>
       
    27 #include <HbDataFormViewItem>
       
    28 #include <HbLineEdit>
       
    29 #include <HbEditorInterface>
       
    30 #include <HbUrlFilter>
       
    31 #include <HbPopup>
       
    32 #include <HbMessageBox>
       
    33 #include <HbAction>
       
    34 #include <cpsettingformitemdata.h>
       
    35 #include <cmconnectionmethod_shim.h>
       
    36 
       
    37 // User includes
       
    38 #include "cppacketdataapplugin.h"
       
    39 #include "cppacketdataapview.h"
       
    40 #include "cppacketdataapadvancedview.h"
       
    41 #include "OstTraceDefinitions.h"
       
    42 #ifdef OST_TRACE_COMPILER_IN_USE
       
    43 #include "cppacketdataapviewTraces.h"
       
    44 #endif
       
    45 
       
    46 /*!
       
    47     \class CpPacketDataApView
       
    48     \brief Implements the settings view for packet data bearer access points.
       
    49 */
       
    50 
       
    51 // External function prototypes
       
    52 
       
    53 // Local constants
       
    54 
       
    55 // ======== LOCAL FUNCTIONS ========
       
    56 
       
    57 // ======== MEMBER FUNCTIONS ========
       
    58 
       
    59 /*!
       
    60     Constructor.
       
    61 */
       
    62 CpPacketDataApView::CpPacketDataApView(
       
    63     CmConnectionMethodShim *cmConnectionMethod,
       
    64     QGraphicsItem *parent) :
       
    65         CpBaseSettingView(0, parent),
       
    66         mForm(0),
       
    67         mModel(0),
       
    68         mApSettingsGroupItem(0),
       
    69         mConnectionNameItem(0),
       
    70         mAccessPointNameItem(0),
       
    71         mUserNameItem(0),
       
    72         mPromptForAuthItem(0),
       
    73         mPasswordItem(0),
       
    74         mAuthenticationItem(0),
       
    75         mHomepageItem(0),
       
    76         mAdvancedSettingsAction(0),
       
    77         mCmConnectionMethod(cmConnectionMethod),
       
    78         mMessageBox(0)
       
    79 {
       
    80     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_CPPACKETDATAAPVIEW_ENTRY);
       
    81     
       
    82     HbMenu *menu = this->menu();
       
    83     mAdvancedSettingsAction = menu->addAction(
       
    84         hbTrId("txt_occ_opt_advanced_settings"));
       
    85     bool status = connect(
       
    86         menu,
       
    87         SIGNAL(triggered(HbAction*)),
       
    88         this,
       
    89         SLOT(menuActionTriggered(HbAction*)));
       
    90     Q_ASSERT(status);
       
    91 
       
    92     // Construct packet data AP settings UI
       
    93     mForm = settingForm();
       
    94     if (mForm) {
       
    95         mModel = new HbDataFormModel(mForm);
       
    96 
       
    97         // Add access point settings group
       
    98         createAccessPointSettingsGroup();
       
    99         
       
   100         mForm->setModel(mModel);
       
   101         
       
   102         status = connect(
       
   103             mForm,
       
   104             SIGNAL(itemShown(const QModelIndex)),
       
   105             this,
       
   106             SLOT(setEditorPreferences(const QModelIndex)));
       
   107         Q_ASSERT(status);
       
   108 
       
   109         // Expand Access point settings group
       
   110         mForm->setExpanded(mModel->indexFromItem(mApSettingsGroupItem), true);
       
   111     }
       
   112     
       
   113     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_CPPACKETDATAAPVIEW_EXIT);
       
   114 }
       
   115 
       
   116 /*!
       
   117     Destructor.
       
   118 */
       
   119 CpPacketDataApView::~CpPacketDataApView()
       
   120 {
       
   121     OstTraceFunctionEntry0(DUP1_CPPACKETDATAAPVIEW_CPPACKETDATAAPVIEW_ENTRY);
       
   122     
       
   123     OstTraceFunctionExit0(DUP1_CPPACKETDATAAPVIEW_CPPACKETDATAAPVIEW_EXIT);
       
   124 }
       
   125 
       
   126 /*!
       
   127     Adds settings group with all settings items to the model.
       
   128 */
       
   129 void CpPacketDataApView::createAccessPointSettingsGroup()
       
   130 {
       
   131     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_CREATEACCESSPOINTSETTINGSGROUP_ENTRY);
       
   132     
       
   133     // Access point settings group
       
   134     mApSettingsGroupItem = new HbDataFormModelItem(
       
   135         HbDataFormModelItem::GroupItem, 
       
   136         hbTrId("txt_occ_subhead_access_point_settings"));
       
   137     mModel->appendDataFormItem(mApSettingsGroupItem);
       
   138     
       
   139     // Connection name
       
   140     mConnectionNameItem = new CpSettingFormItemData(
       
   141         HbDataFormModelItem::TextItem,
       
   142         hbTrId("txt_occ_setlabel_connection_name"));
       
   143     // Connect signal and add item to group
       
   144     mForm->addConnection(
       
   145         mConnectionNameItem,
       
   146         SIGNAL(editingFinished()),
       
   147         this,
       
   148         SLOT(connectionNameChanged()));
       
   149     mApSettingsGroupItem->appendChild(mConnectionNameItem);
       
   150     
       
   151     // Access point name
       
   152     mAccessPointNameItem = new CpSettingFormItemData(
       
   153         HbDataFormModelItem::TextItem,
       
   154         hbTrId("txt_occ_setlabel_access_point_name"));
       
   155     // Connect signal and add item to group
       
   156     mForm->addConnection(
       
   157         mAccessPointNameItem,
       
   158         SIGNAL(editingFinished()),
       
   159         this,
       
   160         SLOT(accessPointNameChanged()));
       
   161     mApSettingsGroupItem->appendChild(mAccessPointNameItem);
       
   162     
       
   163     // User name
       
   164     mUserNameItem = new CpSettingFormItemData(
       
   165         HbDataFormModelItem::TextItem,
       
   166         hbTrId("txt_occ_setlabel_user_name"));
       
   167     // Connect signal and add item to group
       
   168     mForm->addConnection(
       
   169         mUserNameItem,
       
   170         SIGNAL(editingFinished()),
       
   171         this,
       
   172         SLOT(userNameChanged()));
       
   173     mApSettingsGroupItem->appendChild(mUserNameItem);
       
   174     
       
   175     // Prompt for password
       
   176     mPromptForAuthItem = new CpSettingFormItemData(
       
   177         HbDataFormModelItem::CheckBoxItem,
       
   178         hbTrId("txt_occ_setlabel_password"));
       
   179     mPromptForAuthItem->setContentWidgetData("text",
       
   180         hbTrId("txt_occ_setlabel_password_val_prompt"));
       
   181     // Construct map to link item values to setting values
       
   182     mPromptForAuthMap.insert(Qt::Unchecked, false); // Do not prompt
       
   183     mPromptForAuthMap.insert(Qt::Checked, true); // Prompt for password
       
   184     // Connect signal and add item to group
       
   185     mForm->addConnection(
       
   186         mPromptForAuthItem,
       
   187         SIGNAL(stateChanged(int)),
       
   188         this,
       
   189         SLOT(promptForAuthChanged(int)));
       
   190     mApSettingsGroupItem->appendChild(mPromptForAuthItem);
       
   191     
       
   192     // Password
       
   193     mPasswordItem = new CpSettingFormItemData(
       
   194         HbDataFormModelItem::TextItem,
       
   195         hbTrId("txt_occ_setlabel_password"));
       
   196     mPasswordItem->setContentWidgetData("echoMode", "Password");
       
   197     // Connect signal and add item to group
       
   198     mForm->addConnection(
       
   199         mPasswordItem,
       
   200         SIGNAL(editingFinished()),
       
   201         this,
       
   202         SLOT(passwordChanged()));
       
   203     mApSettingsGroupItem->appendChild(mPasswordItem);
       
   204     
       
   205     // Authentication
       
   206     mAuthenticationItem = new CpSettingFormItemData(
       
   207         HbDataFormModelItem::ComboBoxItem,
       
   208         hbTrId("txt_occ_setlabel_authentication"));
       
   209     // Add items to combobox
       
   210     QStringList authenticationItems;
       
   211     authenticationItems
       
   212         << hbTrId("txt_occ_setlabel_authentication_val_normal")
       
   213         << hbTrId("txt_occ_setlabel_authentication_val_secure");
       
   214     mAuthenticationItem->setContentWidgetData("items", authenticationItems);
       
   215     // Construct map to link item indexes to setting values
       
   216     mAuthenticationMap.insert(0, false); // normal (plaintext allowed)
       
   217     mAuthenticationMap.insert(1, true); // secure (plaintext disabled)
       
   218     // Connect signal and add item to group
       
   219     mForm->addConnection(
       
   220         mAuthenticationItem,
       
   221         SIGNAL(currentIndexChanged(int)),
       
   222         this,
       
   223         SLOT(authenticationChanged(int)));
       
   224     mApSettingsGroupItem->appendChild(mAuthenticationItem);
       
   225     
       
   226     // Homepage
       
   227     mHomepageItem = new CpSettingFormItemData(
       
   228         HbDataFormModelItem::TextItem,
       
   229         hbTrId("txt_occ_setlabel_homepage"));
       
   230     // Connect signal and add item to group
       
   231     mForm->addConnection(
       
   232         mHomepageItem,
       
   233         SIGNAL(editingFinished()),
       
   234         this,
       
   235         SLOT(homepageChanged()));
       
   236     mApSettingsGroupItem->appendChild(mHomepageItem);
       
   237     
       
   238     // Read settings from CommsDat and update widgets
       
   239     updateAccessPointSettingsGroup();
       
   240     
       
   241     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_CREATEACCESSPOINTSETTINGSGROUP_EXIT);
       
   242 }
       
   243 
       
   244 /*!
       
   245     Reads attribute values and updates "Access point settings" group settings.
       
   246 */
       
   247 void CpPacketDataApView::updateAccessPointSettingsGroup()
       
   248 {
       
   249     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_UPDATEACCESSPOINTSETTINGSGROUP_ENTRY);
       
   250 
       
   251     // Get attributes from CommsDat and set values to UI widgets
       
   252     
       
   253     // Connection name
       
   254     QString connectionName = mCmConnectionMethod->getStringAttribute(
       
   255         CMManagerShim::CmName);
       
   256     mConnectionNameItem->setContentWidgetData("text", connectionName);
       
   257     
       
   258     // Access point name
       
   259     QString accessPointName = mCmConnectionMethod->getStringAttribute(
       
   260         CMManagerShim::PacketDataAPName);
       
   261     mAccessPointNameItem->setContentWidgetData("text", accessPointName);
       
   262     
       
   263     // User name
       
   264     QString userName = mCmConnectionMethod->getStringAttribute(
       
   265         CMManagerShim::PacketDataIFAuthName);
       
   266     mUserNameItem->setContentWidgetData("text", userName);
       
   267     
       
   268     // Prompt for password
       
   269     bool promptForAuth = mCmConnectionMethod->getBoolAttribute(
       
   270         CMManagerShim::PacketDataIFPromptForAuth);
       
   271     mPromptForAuthItem->setContentWidgetData("checkState",
       
   272         mPromptForAuthMap.key(promptForAuth));
       
   273     if (promptForAuth) {
       
   274         mPasswordItem->setEnabled(false);
       
   275     } else {
       
   276         mPasswordItem->setEnabled(true);
       
   277     }
       
   278     
       
   279     // Password
       
   280     QString password = mCmConnectionMethod->getStringAttribute(
       
   281         CMManagerShim::PacketDataIFAuthPass);
       
   282     mPasswordItem->setContentWidgetData("text", password);
       
   283 
       
   284     // Authentication
       
   285     bool disablePlainText = mCmConnectionMethod->getBoolAttribute(
       
   286         CMManagerShim::PacketDataDisablePlainTextAuth);
       
   287     mAuthenticationItem->setContentWidgetData("currentIndex",
       
   288         mAuthenticationMap.key(disablePlainText));
       
   289     
       
   290     // Homepage
       
   291     QString homepage = mCmConnectionMethod->getStringAttribute(
       
   292         CMManagerShim::CmStartPage);
       
   293     mHomepageItem->setContentWidgetData("text", homepage);
       
   294     
       
   295     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_UPDATEACCESSPOINTSETTINGSGROUP_EXIT);
       
   296 }
       
   297 
       
   298 /*!
       
   299     Shows message box with "OK" button using given text.
       
   300 */
       
   301 void CpPacketDataApView::showMessageBox(
       
   302     HbMessageBox::MessageBoxType type,
       
   303     const QString &text)
       
   304 {
       
   305     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_SHOWMESSAGEBOX_ENTRY);
       
   306     
       
   307     // Create a message box
       
   308     mMessageBox = QSharedPointer<HbMessageBox>(new HbMessageBox(type));
       
   309     mMessageBox->setText(text);
       
   310     mMessageBox->setModal(true);
       
   311     mMessageBox->setTimeout(HbPopup::NoTimeout);
       
   312     mMessageBox->open();
       
   313     
       
   314     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_SHOWMESSAGEBOX_EXIT);
       
   315 }
       
   316 
       
   317 /*!
       
   318     Tries to update connection method changes to CommsDat.
       
   319     Returns "true" if success, "false" if some error happened. 
       
   320 */
       
   321 bool CpPacketDataApView::tryUpdate()
       
   322 {
       
   323     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_TRYUPDATE_ENTRY);
       
   324     
       
   325     // Try update
       
   326     try {
       
   327         mCmConnectionMethod->update();
       
   328     }
       
   329     catch (const std::exception&) {
       
   330         // Handle error
       
   331         handleUpdateError();
       
   332         
       
   333         OstTraceFunctionExit0(CPPACKETDATAAPVIEW_TRYUPDATE_EXIT);
       
   334         return false;
       
   335     }
       
   336 
       
   337     OstTraceFunctionExit0(DUP1_CPPACKETDATAAPVIEW_TRYUPDATE_EXIT);
       
   338     return true;
       
   339 }
       
   340 
       
   341 /*!
       
   342     Handles failed CommsDat update.
       
   343  */
       
   344 void CpPacketDataApView::handleUpdateError()
       
   345 {
       
   346     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_HANDLEUPDATEERROR_ENTRY);
       
   347     
       
   348     // Show error note to user
       
   349     showMessageBox(
       
   350         HbMessageBox::MessageTypeWarning,
       
   351         hbTrId("txt_occ_info_unable_to_save_setting"));
       
   352     // Reload settings from CommsDat and update UI
       
   353     try {
       
   354         mCmConnectionMethod->refresh();
       
   355     }
       
   356     catch (const std::exception&) {
       
   357         // Ignore error from refresh. Most likely this will not happen, but
       
   358         // if it does, there isn't very much we can do.
       
   359         OstTrace0(
       
   360             TRACE_ERROR,
       
   361             CPPACKETDATAAPVIEW_HANDLEUPDATEERROR,
       
   362             "Refresh failed");
       
   363     };
       
   364     updateAccessPointSettingsGroup();
       
   365     
       
   366     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_HANDLEUPDATEERROR_EXIT);
       
   367 }
       
   368 
       
   369 /*!
       
   370     Updates connection name to CommsDat.
       
   371 */
       
   372 void CpPacketDataApView::connectionNameChanged()
       
   373 {
       
   374     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_CONNECTIONNAMECHANGED_ENTRY);
       
   375     
       
   376     QString connectionName =
       
   377         mConnectionNameItem->contentWidgetData("text").toString();
       
   378     if (!connectionName.isEmpty()) {
       
   379         // Update to CommsDat
       
   380         mCmConnectionMethod->setStringAttribute(
       
   381             CMManagerShim::CmName,
       
   382             connectionName);
       
   383         if (tryUpdate()) {
       
   384             // Update successful
       
   385             // Read name because in case the name already exists it will
       
   386             // be made unique by CMManager
       
   387             connectionName = mCmConnectionMethod->getStringAttribute(
       
   388                 CMManagerShim::CmName);
       
   389             mConnectionNameItem->setContentWidgetData("text", connectionName);
       
   390         }
       
   391     } else {
       
   392         // Inform user of invalid name
       
   393         showMessageBox(
       
   394             HbMessageBox::MessageTypeInformation,
       
   395             hbTrId("txt_occ_info_invalid_name"));
       
   396 
       
   397         // Empty name not allowed, revert back to old value in CommsDat
       
   398         connectionName = mCmConnectionMethod->getStringAttribute(
       
   399             CMManagerShim::CmName);
       
   400         mConnectionNameItem->setContentWidgetData("text", connectionName);
       
   401      }
       
   402     
       
   403     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_CONNECTIONNAMECHANGED_EXIT);
       
   404 }
       
   405 
       
   406 /*!
       
   407     Updates access point name to CommsDat.
       
   408 */
       
   409 void CpPacketDataApView::accessPointNameChanged()
       
   410 {
       
   411     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_ACCESSPOINTNAMECHANGED_ENTRY);
       
   412     
       
   413     // Update to CommsDat
       
   414     QString accessPointName =
       
   415         mAccessPointNameItem->contentWidgetData("text").toString();
       
   416     if (!accessPointName.isEmpty()) {
       
   417         mCmConnectionMethod->setStringAttribute(
       
   418             CMManagerShim::PacketDataAPName,
       
   419             accessPointName);
       
   420         (void)tryUpdate();
       
   421     } else {
       
   422         // Inform user of invalid name
       
   423         showMessageBox(
       
   424             HbMessageBox::MessageTypeInformation,
       
   425             hbTrId("txt_occ_info_invalid_name"));
       
   426     
       
   427         // Empty name not allowed, revert back to old value in CommsDat
       
   428         accessPointName = mCmConnectionMethod->getStringAttribute(
       
   429             CMManagerShim::PacketDataAPName);
       
   430         mAccessPointNameItem->setContentWidgetData("text", accessPointName);
       
   431     }
       
   432     
       
   433     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_ACCESSPOINTNAMECHANGED_EXIT);
       
   434 }
       
   435 
       
   436 /*!
       
   437     Updates user name to CommsDat.
       
   438 */
       
   439 void CpPacketDataApView::userNameChanged()
       
   440 {
       
   441     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_USERNAMECHANGED_ENTRY);
       
   442     
       
   443     // Update to CommsDat
       
   444     QVariant userName = mUserNameItem->contentWidgetData("text");
       
   445     mCmConnectionMethod->setStringAttribute(
       
   446         CMManagerShim::PacketDataIFAuthName,
       
   447         userName.toString());
       
   448     (void)tryUpdate();
       
   449     
       
   450     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_USERNAMECHANGED_EXIT);
       
   451 }
       
   452 
       
   453 /*!
       
   454     Updates prompt for password setting to CommsDat.
       
   455 */
       
   456 void CpPacketDataApView::promptForAuthChanged(int state)
       
   457 {
       
   458     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_PROMPTFORAUTHCHANGED_ENTRY);
       
   459     
       
   460     // If prompt for auth is selected, password edit should be disabled.
       
   461     if (state == Qt::Checked) {
       
   462         mPasswordItem->setEnabled(false);
       
   463     } else {
       
   464         mPasswordItem->setEnabled(true);
       
   465     }
       
   466     // Update to CommsDat
       
   467     mCmConnectionMethod->setBoolAttribute(
       
   468         CMManagerShim::PacketDataIFPromptForAuth,
       
   469         mPromptForAuthMap.value(static_cast<Qt::CheckState>(state)));
       
   470     (void)tryUpdate();
       
   471     
       
   472     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_PROMPTFORAUTHCHANGED_EXIT);
       
   473 }
       
   474 
       
   475 /*!
       
   476     Updates password to CommsDat.
       
   477 */
       
   478 void CpPacketDataApView::passwordChanged()
       
   479 {
       
   480     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_PASSWORDCHANGED_ENTRY);
       
   481     
       
   482     // Update to CommsDat
       
   483     QVariant password = mPasswordItem->contentWidgetData("text");
       
   484     mCmConnectionMethod->setStringAttribute(
       
   485         CMManagerShim::PacketDataIFAuthPass,
       
   486         password.toString());
       
   487     (void)tryUpdate();
       
   488     
       
   489     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_PASSWORDCHANGED_EXIT);
       
   490 }
       
   491 
       
   492 /*!
       
   493     Updates authentication setting to CommsDat.
       
   494 */
       
   495 void CpPacketDataApView::authenticationChanged(int index)
       
   496 {
       
   497     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_AUTHENTICATIONCHANGED_ENTRY);
       
   498     
       
   499     // Update to CommsDat
       
   500     mCmConnectionMethod->setBoolAttribute(
       
   501         CMManagerShim::PacketDataDisablePlainTextAuth,
       
   502         mAuthenticationMap.value(index));
       
   503     (void)tryUpdate();
       
   504     
       
   505     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_AUTHENTICATIONCHANGED_EXIT);
       
   506 }
       
   507 
       
   508 /*!
       
   509     Updates homepage to CommsDat.
       
   510 */
       
   511 void CpPacketDataApView::homepageChanged()
       
   512 {
       
   513     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_HOMEPAGECHANGED_ENTRY);
       
   514     
       
   515     // Update to CommsDat
       
   516     QString homepage = mHomepageItem->contentWidgetData("text").toString();
       
   517     mCmConnectionMethod->setStringAttribute(
       
   518         CMManagerShim::CmStartPage, homepage);
       
   519     (void)tryUpdate();
       
   520     
       
   521     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_HOMEPAGECHANGED_EXIT);
       
   522 }
       
   523 
       
   524 /*!
       
   525     Handles menu actions.
       
   526 */
       
   527 void CpPacketDataApView::menuActionTriggered(HbAction *action)
       
   528 {
       
   529     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_MENUACTIONTRIGGERED_ENTRY);
       
   530     
       
   531     if (action == mAdvancedSettingsAction) {
       
   532         // "Advanced settings" selected
       
   533         HbMainWindow *mainWindow = this->mainWindow();
       
   534 
       
   535         // Create the advanced settings view
       
   536         HbView *newView = new CpPacketDataApAdvancedView(mCmConnectionMethod);
       
   537         // Connect signal to return back to the previous view
       
   538         bool status = QObject::connect(
       
   539             newView,
       
   540             SIGNAL(aboutToClose()),
       
   541             this,
       
   542             SLOT(restoreCurrentView()));
       
   543         Q_ASSERT(status);
       
   544 
       
   545         // Show the advanced settings view
       
   546         mainWindow->addView(newView);
       
   547         mainWindow->setCurrentView(newView);
       
   548     }
       
   549     
       
   550     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_MENUACTIONTRIGGERED_EXIT);
       
   551 }
       
   552 
       
   553 /*!
       
   554     Deletes the current view and sets this view as the current one.
       
   555 */
       
   556 void CpPacketDataApView::restoreCurrentView()
       
   557 {
       
   558     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_RESTORECURRENTVIEW_ENTRY);
       
   559     
       
   560     HbMainWindow *mainWindow = this->mainWindow();
       
   561     
       
   562     // Remove the previous view and delete it
       
   563     HbView *prevView = mainWindow->currentView();
       
   564     mainWindow->removeView(prevView);
       
   565     prevView->deleteLater();
       
   566     
       
   567     // Set this view on top
       
   568     mainWindow->setCurrentView(this);
       
   569     
       
   570     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_RESTORECURRENTVIEW_EXIT);
       
   571 }
       
   572 
       
   573 /*!
       
   574     Sets editor preferences for all HbLineEdit items.
       
   575 */
       
   576 void CpPacketDataApView::setEditorPreferences(const QModelIndex modelIndex)
       
   577 {
       
   578     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_SETEDITORPREFERENCES_ENTRY);
       
   579     
       
   580     HbDataFormViewItem *viewItem = mForm->dataFormViewItem(modelIndex);
       
   581     HbDataFormModelItem *modelItem = mModel->itemFromIndex(modelIndex);
       
   582     
       
   583     if (modelItem == mConnectionNameItem
       
   584         || modelItem == mAccessPointNameItem
       
   585         || modelItem == mUserNameItem
       
   586         || modelItem == mPasswordItem
       
   587         || modelItem == mHomepageItem ) {
       
   588         // HbLineEdit items, get editor and editor interface
       
   589         HbLineEdit *edit = qobject_cast<HbLineEdit *>
       
   590             (viewItem->dataItemContentWidget());
       
   591         HbEditorInterface editInterface(edit);
       
   592         
       
   593         if (modelItem == mConnectionNameItem) {
       
   594             // Setup editor for connection name
       
   595             editInterface.setConstraints(HbEditorConstraintLatinAlphabetOnly);
       
   596             edit->setInputMethodHints(Qt::ImhNoPredictiveText); 
       
   597             edit->setMaxLength(CMManagerShim::CmNameLength);
       
   598         } else if (modelItem == mAccessPointNameItem) {
       
   599             // Setup editor for packet data AP name
       
   600             editInterface.setInputMode(HbInputModeNone);
       
   601             editInterface.setConstraints(HbEditorConstraintLatinAlphabetOnly);
       
   602             editInterface.setLocalDigitType(HbDigitTypeNone);
       
   603             edit->setInputMethodHints(
       
   604                 Qt::ImhNoPredictiveText
       
   605                 | Qt::ImhPreferLowercase);
       
   606             edit->setMaxLength(CMManagerShim::PacketDataAPNameLength);
       
   607         } else if (modelItem == mUserNameItem) {
       
   608             // Setup editor for user name
       
   609             editInterface.setInputMode(HbInputModeNone);
       
   610             editInterface.setConstraints(HbEditorConstraintLatinAlphabetOnly);
       
   611             editInterface.setEditorClass(HbInputEditorClassUsername);
       
   612             editInterface.setLocalDigitType(HbDigitTypeNone);
       
   613             edit->setInputMethodHints(
       
   614                 Qt::ImhNoPredictiveText
       
   615                 | Qt::ImhPreferLowercase);
       
   616             edit->setMaxLength(CMManagerShim::PacketDataIFAuthNameLength);
       
   617         } else if (modelItem == mPasswordItem) {
       
   618             // Setup editor for password
       
   619             editInterface.setInputMode(HbInputModeNone);
       
   620             editInterface.setConstraints(HbEditorConstraintLatinAlphabetOnly);
       
   621             editInterface.setEditorClass(HbInputEditorClassPassword);
       
   622             editInterface.setLocalDigitType(HbDigitTypeNone);
       
   623             edit->setInputMethodHints(
       
   624                 Qt::ImhNoPredictiveText
       
   625                 | Qt::ImhPreferLowercase);
       
   626             edit->setMaxLength(CMManagerShim::PacketDataIFAuthPassLength);
       
   627         } else { /* mHomepageItem */
       
   628             // Setup editor for URL
       
   629             editInterface.setInputMode(HbInputModeNone);
       
   630             editInterface.setConstraints(HbEditorConstraintLatinAlphabetOnly);
       
   631             editInterface.setFilter(HbUrlFilter::instance());
       
   632             editInterface.setEditorClass(HbInputEditorClassUrl);
       
   633             editInterface.setLocalDigitType(HbDigitTypeNone);
       
   634             edit->setInputMethodHints(
       
   635                 Qt::ImhNoPredictiveText
       
   636                 | Qt::ImhPreferLowercase);
       
   637             edit->setMaxLength(CMManagerShim::CmStartPageLength);
       
   638         }
       
   639     }
       
   640     
       
   641     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_SETEDITORPREFERENCES_EXIT);
       
   642 }