wlanutilities/wlanwizard/src/wlanwizardpagesummary.cpp
branchRCL_3
changeset 24 63be7eb3fc78
equal deleted inserted replaced
23:b852595f5cbe 24:63be7eb3fc78
       
     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 * Wlan Wizard Page: Summary
       
    16 */
       
    17 
       
    18 // System includes
       
    19 
       
    20 #include <HbMainWindow>
       
    21 #include <HbDocumentLoader>
       
    22 #include <HbWidget>
       
    23 #include <HbListWidget>
       
    24 #include <HbListWidgetItem>
       
    25 #include <HbStyleLoader>
       
    26 
       
    27 // User includes
       
    28 
       
    29 #include "wlanqtutils.h"
       
    30 #include "wlanwizard_p.h"
       
    31 #include "wlanwizardplugin.h"
       
    32 #include "wlanwizardsummaryviewitem.h"
       
    33 #include "wlanwizardpagesummary.h"
       
    34 
       
    35 #include "OstTraceDefinitions.h"
       
    36 #ifdef OST_TRACE_COMPILER_IN_USE
       
    37 #include "wlanwizardpagesummaryTraces.h"
       
    38 #endif
       
    39 
       
    40 
       
    41 /*!
       
    42    \class WlanWizardPageSummary
       
    43    \brief Implements Wizard summary page.
       
    44  */
       
    45 
       
    46 // External function prototypes
       
    47 
       
    48 // Local constants
       
    49 
       
    50 //! Path for layout of custom list widget
       
    51 static const char WlanWizardPageSummaryLayout[] = ":/wizardsummarylayout/";
       
    52 
       
    53 // ======== LOCAL FUNCTIONS ========
       
    54 
       
    55 // ======== MEMBER FUNCTIONS ========
       
    56 
       
    57 /*!
       
    58    Constructor.
       
    59    
       
    60    @param [in] parent pointer to private implementation of wizard.
       
    61  */
       
    62 WlanWizardPageSummary::WlanWizardPageSummary(WlanWizardPrivate* parent) :
       
    63     WlanWizardPageInternal(parent), 
       
    64     mListWidget(NULL) 
       
    65 {
       
    66     OstTraceFunctionEntry0(WLANWIZARDPAGESUMMARY_WLANWIZARDPAGESUMMARY_ENTRY);
       
    67     OstTraceFunctionExit0(WLANWIZARDPAGESUMMARY_WLANWIZARDPAGESUMMARY_EXIT);
       
    68 }
       
    69 
       
    70 /*!
       
    71    Destructor.
       
    72  */
       
    73 WlanWizardPageSummary::~WlanWizardPageSummary()
       
    74 {
       
    75     OstTraceFunctionEntry0(DUP1_WLANWIZARDPAGESUMMARY_WLANWIZARDPAGESUMMARY_ENTRY);
       
    76     
       
    77     HbStyleLoader::unregisterFilePath(WlanWizardPageSummaryLayout);
       
    78     
       
    79     // Wizard framework deletes the visualization (owns mListWidget).
       
    80     
       
    81     OstTraceFunctionExit0(DUP1_WLANWIZARDPAGESUMMARY_WLANWIZARDPAGESUMMARY_EXIT);
       
    82 }
       
    83 
       
    84 /*!
       
    85    See WlanWizardPage::initializePage()
       
    86  */
       
    87 HbWidget* WlanWizardPageSummary::initializePage()
       
    88 {
       
    89     OstTraceFunctionEntry0(WLANWIZARDPAGESUMMARY_INITIALIZEPAGE_ENTRY);
       
    90     
       
    91     // Note that from summary page it is not possible to step back
       
    92     // this means that it is not possible that this method is called twice.
       
    93     Q_ASSERT(!mListWidget);
       
    94     
       
    95     loadDocml();
       
    96     int row = 0;
       
    97     
       
    98     appendToList(
       
    99         row, 
       
   100         hbTrId("txt_occ_dblist_network_name"),
       
   101         mWizard->configuration(WlanWizardPrivate::ConfSsid).toString());
       
   102 
       
   103     appendToList( 
       
   104         row, hbTrId("txt_occ_dblist_network_mode"), networkModeText());
       
   105 
       
   106     appendToList(
       
   107         row, hbTrId("txt_occ_dblist_security_mode"), securityModeText());    
       
   108 
       
   109     addDynamicItems(row);
       
   110         
       
   111     OstTraceFunctionExit0(WLANWIZARDPAGESUMMARY_INITIALIZEPAGE_EXIT);
       
   112     return qobject_cast<HbWidget*>(mListWidget);
       
   113 }
       
   114 
       
   115 /*!
       
   116    Loads docml.
       
   117  */
       
   118 void WlanWizardPageSummary::loadDocml()
       
   119 {
       
   120     OstTraceFunctionEntry0(WLANWIZARDPAGESUMMARY_LOADDOCML_ENTRY);
       
   121     
       
   122     bool ok;    
       
   123     HbDocumentLoader docLoader(mWizard->mainWindow());
       
   124     
       
   125     docLoader.load(":/docml/occ_add_wlan_05.docml", &ok);
       
   126     Q_ASSERT(ok);
       
   127     
       
   128     mListWidget = qobject_cast<HbListWidget *>(docLoader.findWidget("occ_add_wlan_05"));
       
   129     Q_ASSERT(mListWidget != NULL);
       
   130 
       
   131     // Set own list prototype handler to disable TAP gestures and selections
       
   132     mListWidget->setItemPrototype(
       
   133         new WlanWizardSummaryListViewItem(mListWidget));
       
   134     
       
   135     // set the layout name to match the layout name in hblistviewitem.css file
       
   136     mListWidget->setLayoutName("wlanwizardsummaryitem");
       
   137     
       
   138     // Register the location of hblistviewitem.css and hblistviewitem.widgetml  
       
   139     ok = HbStyleLoader::registerFilePath(WlanWizardPageSummaryLayout);
       
   140     Q_ASSERT(ok);
       
   141     
       
   142     OstTraceFunctionExit0(WLANWIZARDPAGESUMMARY_LOADDOCML_EXIT);
       
   143 }
       
   144 
       
   145 /*!
       
   146    Gets localized network mode from the WlanWizardPrivate::ConfNetworkMode
       
   147    configuration.
       
   148     
       
   149    @return localized network mode text.
       
   150  */
       
   151 QString WlanWizardPageSummary::networkModeText() const
       
   152 {
       
   153     OstTraceFunctionEntry0(WLANWIZARDPAGESUMMARY_NETWORKMODETEXT_ENTRY);
       
   154     
       
   155     QString ret;
       
   156     int mode = mWizard->configuration(
       
   157         WlanWizardPrivate::ConfNetworkMode).toInt();
       
   158         
       
   159     switch (mode) {
       
   160     case CMManagerShim::Adhoc:
       
   161         ret = hbTrId("txt_occ_dblist_network_mode_val_adhoc");
       
   162         break;
       
   163 
       
   164      default:
       
   165          Q_ASSERT(mode == CMManagerShim::Infra); 
       
   166          if (mWizard->configuration(WlanWizardPrivate::ConfWlanScanSSID).toBool()) {
       
   167              ret = hbTrId("txt_occ_dblist_network_mode_val_infrastructure_hi");
       
   168          } else {
       
   169              ret = hbTrId("txt_occ_dblist_network_mode_val_infrastructure_pu");
       
   170          }
       
   171          break;
       
   172     }
       
   173     
       
   174     OstTraceFunctionExit0(WLANWIZARDPAGESUMMARY_NETWORKMODETEXT_EXIT);
       
   175     return ret;
       
   176 }
       
   177 
       
   178 /*!
       
   179    Gets localized security mode from the WlanWizardPrivate::ConfSecurityMode
       
   180    configuration.
       
   181    
       
   182    @return localized security mode text.
       
   183  */
       
   184 QString WlanWizardPageSummary::securityModeText() const
       
   185 {
       
   186     OstTraceFunctionEntry0(WLANWIZARDPAGESUMMARY_SECURITYMODETEXT_ENTRY);
       
   187     
       
   188     QString ret;
       
   189     int mode = mWizard->configuration(WlanWizardPrivate::ConfSecurityMode).toInt();
       
   190     switch (mode) {
       
   191     case CMManagerShim::WlanSecMode802_1x:
       
   192         ret = hbTrId("txt_occ_dblist_security_mode_val_8021x");
       
   193         break;
       
   194         
       
   195     case CMManagerShim::WlanSecModeWep:
       
   196         ret = hbTrId("txt_occ_dblist_security_mode_val_wep");
       
   197         break;
       
   198         
       
   199     case CMManagerShim::WlanSecModeWpa:
       
   200         if (mWizard->configuration(WlanWizardPrivate::ConfUsePsk).toBool()) {
       
   201             ret = hbTrId("txt_occ_dblist_security_mode_val_wpawpa2psk");
       
   202         } else {
       
   203             ret = hbTrId("txt_occ_dblist_security_mode_val_wpawpa2_with_eap");
       
   204         }
       
   205         break;
       
   206         
       
   207     case CMManagerShim::WlanSecModeWpa2:
       
   208         if (mWizard->configuration(WlanWizardPrivate::ConfUsePsk).toBool()) {
       
   209             ret = hbTrId("txt_occ_dblist_security_mode_val_wpa2_with_passwor");
       
   210         } else {
       
   211             ret = hbTrId("txt_occ_dblist_security_mode_val_wpa2_with_eap");
       
   212         }
       
   213         break;
       
   214         
       
   215     default:
       
   216         Q_ASSERT(mode == CMManagerShim::WlanSecModeOpen);
       
   217         ret = hbTrId("txt_occ_dblist_security_mode_val_open");
       
   218         break;
       
   219     }
       
   220     
       
   221     OstTraceFunctionExit0(WLANWIZARDPAGESUMMARY_SECURITYMODETEXT_EXIT);
       
   222     return ret;
       
   223 }
       
   224 
       
   225 /*!
       
   226    Adds dynamic content to the view.
       
   227    
       
   228    @param [in,out] row row to where insert happens.
       
   229  */
       
   230 void WlanWizardPageSummary::addDynamicItems(int &row)
       
   231 {
       
   232     OstTraceFunctionEntry0(WLANWIZARDPAGESUMMARY_ADDDYNAMICITEMS_ENTRY);
       
   233     
       
   234     if (mWizard->isEapEnabled()) {
       
   235         appendToListPluginInfo(WlanWizardPlugin::SummaryEapOuterType, row);
       
   236         appendToListPluginInfo(WlanWizardPlugin::SummaryEapInnerType, row);
       
   237         appendToListPluginInfo(WlanWizardPlugin::SummaryEapFastProvisioningMode, row);
       
   238     }
       
   239 
       
   240     QString value;
       
   241 
       
   242     switch (mWizard->configuration(WlanWizardPrivate::ConfIctStatus).toInt()) {
       
   243     case WlanQtUtils::IctPassed:
       
   244         value = hbTrId("txt_occ_dblist_destination_val_internet");
       
   245         appendToList(row, hbTrId("txt_occ_dblist_destination"), value);
       
   246         break;
       
   247         
       
   248     case WlanQtUtils::IctFailed:
       
   249         value = hbTrId("txt_occ_dblist_destination_val_uncategorized");
       
   250         appendToList(row, hbTrId("txt_occ_dblist_destination"), value);
       
   251         break;
       
   252         
       
   253     default:
       
   254         Q_ASSERT(WlanQtUtils::IctHotspotPassed ==
       
   255             mWizard->configuration(WlanWizardPrivate::ConfIctStatus).toInt());
       
   256         // Add nothing to list.
       
   257         break;
       
   258     }
       
   259     
       
   260     OstTraceFunctionExit0(WLANWIZARDPAGESUMMARY_ADDDYNAMICITEMS_EXIT);
       
   261 }
       
   262 
       
   263 /*!
       
   264    Appends new item to the end of the summary list
       
   265    
       
   266    @param [in,out] row number to where the item is inserted
       
   267    @param [in] title title of the item
       
   268    @param [in] value value of the item
       
   269  */
       
   270 void WlanWizardPageSummary::appendToList(
       
   271     int &row, 
       
   272     const QString title, 
       
   273     const QString value)
       
   274 {
       
   275     OstTraceFunctionEntry0(WLANWIZARDPAGESUMMARY_APPENDTOLIST_ENTRY);
       
   276     
       
   277     HbListWidgetItem *item = new HbListWidgetItem();
       
   278     item->setText(title);
       
   279     item->setSecondaryText(value);
       
   280     mListWidget->insertItem(row++, item);
       
   281     
       
   282     OstTraceFunctionExit0(WLANWIZARDPAGESUMMARY_APPENDTOLIST_EXIT);
       
   283 }
       
   284 
       
   285 /*!
       
   286    Appends new item to the end of the summary list
       
   287    
       
   288    @param [in] id Plugin summary id
       
   289    @param [in,out] row number to where the item is inserted
       
   290  */
       
   291 void WlanWizardPageSummary::appendToListPluginInfo( 
       
   292     WlanWizardPlugin::Summary id,
       
   293     int &row)
       
   294 {
       
   295     OstTraceFunctionEntry0(WLANWIZARDPAGESUMMARY_APPENDTOLISTPLUGININFO_ENTRY);
       
   296     
       
   297     QString title;
       
   298     QString value;
       
   299     WlanWizardPlugin *plugin = mWizard->wlanWizardPlugin();
       
   300     Q_ASSERT(plugin);
       
   301     if (plugin->summary(id, title, value)) {
       
   302         appendToList(row, title, value );
       
   303     }
       
   304     
       
   305     OstTraceFunctionExit0(WLANWIZARDPAGESUMMARY_APPENDTOLISTPLUGININFO_EXIT);
       
   306 }