wlanutilities/wlanwizard/src/wlanwizardpagenetworkmode.cpp
changeset 43 72ebcbb64834
parent 39 7b3e49e4608a
child 53 bdc64aa9b954
equal deleted inserted replaced
39:7b3e49e4608a 43:72ebcbb64834
    47     mList(NULL),
    47     mList(NULL),
    48     mLabel(NULL),
    48     mLabel(NULL),
    49     mLoader(NULL),
    49     mLoader(NULL),
    50     mValid(false)
    50     mValid(false)
    51 {
    51 {
       
    52     OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_WLANWIZARDPAGENETWORKMODE_ENTRY );
       
    53     OstTraceFunctionExit0( WLANWIZARDPAGENETWORKMODE_WLANWIZARDPAGENETWORKMODE_EXIT );
    52 }
    54 }
    53 
    55 
    54 /*!
    56 /*!
    55  * Destructor. Loader widget is deleted.
    57  * Destructor. Loader widget is deleted.
    56  * All document widgets are deleted by wlanwizard_p destructor. 
    58  * All document widgets are deleted by wlanwizard_p destructor. 
    57  */
    59  */
    58 WlanWizardPageNetworkMode::~WlanWizardPageNetworkMode()
    60 WlanWizardPageNetworkMode::~WlanWizardPageNetworkMode()
    59 {
    61 {
       
    62     OstTraceFunctionEntry0( DUP1_WLANWIZARDPAGENETWORKMODE_WLANWIZARDPAGENETWORKMODE_ENTRY );
    60     delete mLoader;
    63     delete mLoader;
       
    64     OstTraceFunctionExit0( DUP1_WLANWIZARDPAGENETWORKMODE_WLANWIZARDPAGENETWORKMODE_EXIT );
    61 }
    65 }
    62 
    66 
    63 /*!
    67 /*!
    64  * Page initialization. If view is already loaded, does nothing.
    68  * Page initialization. If view is already loaded, does nothing.
    65  * Inherited from WlanWizardPage.
    69  * Inherited from WlanWizardPage.
    66  */
    70  */
    67 HbWidget* WlanWizardPageNetworkMode::initializePage()
    71 HbWidget* WlanWizardPageNetworkMode::initializePage()
    68 {
    72 {
       
    73     OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_INITIALIZEPAGE_ENTRY );
    69     OstTrace0( TRACE_NORMAL, WLANWIZARDPAGENETWORKMODE_INITIALIZEPAGE,
    74     OstTrace0( TRACE_NORMAL, WLANWIZARDPAGENETWORKMODE_INITIALIZEPAGE,
    70         "WlanWizardPageNetworkMode::initializePage" );
    75         "WlanWizardPageNetworkMode::initializePage" );
    71 
    76 
    72     if (mWidget == NULL) {
    77     if (mWidget == NULL) {
    73         mLoader = new HbDocumentLoader(mWizard->mainWindow());
    78         mLoader = new HbDocumentLoader(mWizard->mainWindow());
   108     
   113     
   109     populateRadioButtonList(items);
   114     populateRadioButtonList(items);
   110     
   115     
   111     mList->setItems(items);
   116     mList->setItems(items);
   112     
   117     
       
   118     OstTraceFunctionExit0( WLANWIZARDPAGENETWORKMODE_INITIALIZEPAGE_EXIT );
   113     return mWidget;
   119     return mWidget;
   114 }
   120 }
   115 
   121 
   116 /*!
   122 /*!
   117  * Evaluates the network mode selection and sets the configuration in
   123  * Evaluates the network mode selection and sets the configuration in
   119  * @param [out] removeFromStack always returns false.
   125  * @param [out] removeFromStack always returns false.
   120  * @return WlanWizardPageSecurityMode page id.
   126  * @return WlanWizardPageSecurityMode page id.
   121  */
   127  */
   122 int WlanWizardPageNetworkMode::nextId(bool &removeFromStack) const
   128 int WlanWizardPageNetworkMode::nextId(bool &removeFromStack) const
   123 {
   129 {
       
   130     OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_NEXTID_ENTRY );
   124     removeFromStack = false;
   131     removeFromStack = false;
   125     WlanNetworkSetting setting;
   132     WlanNetworkSetting setting;
   126     setting.mode = mNetworkModes.at(mList->selected());
   133     int index = mList->selected();
   127     setting.hidden = mIsHidden.at(mList->selected());
   134     int nextPage = WlanWizardPageInternal::PageNetworkSecurity;
   128     
   135     
   129     // TODO: Still no wps handling.
   136     if (mWpsSupported.at(index)) {
   130     setting.wpsSupported = false;
   137         nextPage = WlanWizardPageInternal::PageWpsStart;
   131     
   138     }
   132     mWizard->setConfiguration(WlanWizardPrivate::ConfNetworkMode,
   139     else {
   133         setting.mode);
   140         setting.mode = mNetworkModes.at(index);
   134     
   141         setting.hidden = mIsHidden.at(index);
   135     mWizard->setConfiguration(WlanWizardPrivate::ConfHiddenWlan,
   142         setting.wpsSupported = mWpsSupported.at(index);
   136         setting.hidden);
   143 
   137 
   144         mWizard->setConfiguration(WlanWizardPrivate::ConfNetworkMode,
   138     if (mWizard->configurationExists(WlanWizardPrivate::ConfAvailableNetworkOptions)) {
   145             setting.mode);
   139         return selectNextPage(setting);
   146 
   140     }
   147         mWizard->setConfiguration(WlanWizardPrivate::ConfHiddenWlan,
   141     
   148             setting.hidden);
   142     return WlanWizardPageInternal::PageNetworkSecurity;
   149         
       
   150         mWizard->setConfiguration(WlanWizardPrivate::ConfWpsSupported,
       
   151             setting.wpsSupported);
       
   152 
       
   153         if (mWizard->configurationExists(WlanWizardPrivate::ConfAvailableNetworkOptions)) {
       
   154             nextPage = selectNextPage(setting);
       
   155         }
       
   156     }
       
   157     OstTraceFunctionExit0( WLANWIZARDPAGENETWORKMODE_NEXTID_EXIT );
       
   158     return nextPage;
   143 }
   159 }
   144 
   160 
   145 /*!
   161 /*!
   146  * This method is overrides the default implementation from WlanWizardPage.
   162  * This method is overrides the default implementation from WlanWizardPage.
   147  * It indicates whether the Next-button should be enabled or not.
   163  * It indicates whether the Next-button should be enabled or not.
   148  * @return mValid, which is true if a radio button has been selected.
   164  * @return mValid, which is true if a radio button has been selected.
   149  */
   165  */
   150 bool WlanWizardPageNetworkMode::showPage()
   166 bool WlanWizardPageNetworkMode::showPage()
   151 {
   167 {
       
   168     OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_SHOWPAGE_ENTRY );
       
   169     OstTraceFunctionExit0( WLANWIZARDPAGENETWORKMODE_SHOWPAGE_EXIT );
   152     return mValid;
   170     return mValid;
   153 }
   171 }
   154 
   172 
   155 /*!
   173 /*!
   156  * This function is invoked when user selects a mode from the radio button list.
   174  * This function is invoked when user selects a mode from the radio button list.
   157  * (HbRadioButtonList's itemSelected-signal)
   175  * (HbRadioButtonList's itemSelected-signal)
   158  */
   176  */
   159 void WlanWizardPageNetworkMode::itemSelected()
   177 void WlanWizardPageNetworkMode::itemSelected()
   160 {
   178 {
       
   179     OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_ITEMSELECTED_ENTRY );
   161     OstTrace0( TRACE_BORDER, WLANWIZARDPAGENETWORKMODE_ITEMSELECTED,
   180     OstTrace0( TRACE_BORDER, WLANWIZARDPAGENETWORKMODE_ITEMSELECTED,
   162         "WlanWizardPageNetworkMode::itemSelected" );
   181         "WlanWizardPageNetworkMode::itemSelected" );
   163 
   182 
   164     mValid = true;
   183     mValid = true;
   165     mWizard->enableNextButton(mValid);
   184     mWizard->enableNextButton(mValid);
       
   185     OstTraceFunctionExit0( WLANWIZARDPAGENETWORKMODE_ITEMSELECTED_EXIT );
   166 }
   186 }
   167 
   187 
   168 /*!
   188 /*!
   169  * Loads the document orientation information from occ_add_wlan_02_03.docml.
   189  * Loads the document orientation information from occ_add_wlan_02_03.docml.
   170  * This is called each time phone orientation changes.
   190  * This is called each time phone orientation changes.
   171  * @param [in] orientation indicates whether the phone is in portrait or
   191  * @param [in] orientation indicates whether the phone is in portrait or
   172  * landscape mode.
   192  * landscape mode.
   173  */
   193  */
   174 void WlanWizardPageNetworkMode::loadDocmlSection(Qt::Orientation orientation)
   194 void WlanWizardPageNetworkMode::loadDocmlSection(Qt::Orientation orientation)
   175 {
   195 {
       
   196     OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_LOADDOCMLSECTION_ENTRY );
   176     OstTrace1( TRACE_NORMAL, WLANWIZARDPAGENETWORKMODE_LOADDOCML,
   197     OstTrace1( TRACE_NORMAL, WLANWIZARDPAGENETWORKMODE_LOADDOCML,
   177         "WlanWizardPageNetworkMode::loadDocml - Orientation;orientation=%x",
   198         "WlanWizardPageNetworkMode::loadDocml - Orientation;orientation=%x",
   178         ( TUint )( orientation ) );
   199         ( TUint )( orientation ) );
   179 
   200 
   180     WlanWizardPageInternal::loadDocmlSection(
   201     WlanWizardPageInternal::loadDocmlSection(
   181         mLoader,
   202         mLoader,
   182         orientation,
   203         orientation,
   183         ":/docml/occ_add_wlan_02_03.docml", 
   204         ":/docml/occ_add_wlan_02_03.docml", 
   184         "portrait_section",
   205         "portrait_section",
   185         "landscape_section");
   206         "landscape_section");
       
   207     OstTraceFunctionExit0( WLANWIZARDPAGENETWORKMODE_LOADDOCMLSECTION_EXIT );
   186 }
   208 }
   187 
   209 
   188 /*!
   210 /*!
   189  * A support function to map the radio button list to a generic network
   211  * A support function to map the radio button list to a generic network
   190  * mode list. This enables the changing of button order without it
   212  * mode list. This enables the changing of button order without it
   193  * available network mode options are shown in the radio button list.
   215  * available network mode options are shown in the radio button list.
   194  * @param [out] list is the list of captions used for the radio buttons.
   216  * @param [out] list is the list of captions used for the radio buttons.
   195  * @param [in] item is the caption to be added.
   217  * @param [in] item is the caption to be added.
   196  * @param [in] mode is the network mode to be added.
   218  * @param [in] mode is the network mode to be added.
   197  * @param [in] isHidden is the visibility status of the network.
   219  * @param [in] isHidden is the visibility status of the network.
   198  */
   220  * @param [in] wpsSupported is the possibility for wps support.
   199 void WlanWizardPageNetworkMode::addToList(QStringList &list,
   221  */
   200     const QString &item, int mode, bool isHidden)
   222 void WlanWizardPageNetworkMode::addToList(
   201 {
   223     QStringList &list,
       
   224     const QString &item,
       
   225     int mode,
       
   226     bool isHidden,
       
   227     bool wpsSupported)
       
   228 {
       
   229     OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_ADDTOLIST_ENTRY );
   202         
   230         
   203     if (mWizard->configurationExists(WlanWizardHelper::ConfAvailableNetworkOptions)) {
   231     if (mWizard->configurationExists(WlanWizardHelper::ConfAvailableNetworkOptions)) {
   204         WlanWizardScanList networkOptions = mWizard->configuration(
   232         WlanWizardScanList networkOptions = mWizard->configuration(
   205             WlanWizardHelper::ConfAvailableNetworkOptions).value<WlanWizardScanList> ();
   233             WlanWizardHelper::ConfAvailableNetworkOptions).value<WlanWizardScanList> ();
   206 
   234 
   207         QList<WlanNetworkSetting> modes = networkOptions.getNetModes();
   235         QList<WlanNetworkSetting> modes = networkOptions.getNetModes();
   208 
   236 
   209         for (int i = 0; i < modes.size(); i++) {
   237         for (int i = 0; i < modes.size(); i++) {
   210             if (modes[i].mode == mode && modes[i].hidden == isHidden) {
   238             if ( (modes[i].mode == mode 
       
   239                 && modes[i].hidden == isHidden
       
   240                 && modes[i].wpsSupported == wpsSupported)
       
   241                 || (modes[i].wpsSupported && wpsSupported) ) {
   211                 list << item;
   242                 list << item;
   212                 mNetworkModes.append(mode);
   243                 mNetworkModes.append(mode);
   213                 mIsHidden.append(isHidden);
   244                 mIsHidden.append(isHidden);
       
   245                 mWpsSupported.append(wpsSupported);
   214             }
   246             }
   215         }
   247         }
   216     }
   248     }
   217     else {  
   249     else { 
   218         list << item;
   250         list << item;
   219         mNetworkModes.append(mode);
   251         mNetworkModes.append(mode);
   220         mIsHidden.append(isHidden);
   252         mIsHidden.append(isHidden);
   221     }
   253         // If there are no known network options, WPS is not allowed to be
       
   254         // selected.
       
   255         mWpsSupported.append(false);
       
   256     }
       
   257     OstTraceFunctionExit0( WLANWIZARDPAGENETWORKMODE_ADDTOLIST_EXIT );
   222 }
   258 }
   223 
   259 
   224 /*!
   260 /*!
   225  * This function checks the sets up the radio button list for user input.
   261  * This function checks the sets up the radio button list for user input.
   226  * @param [out] list is the list of captions used for the radio buttons.
   262  * @param [out] list is the list of captions used for the radio buttons.
   227  */
   263  */
   228 void WlanWizardPageNetworkMode::populateRadioButtonList(QStringList &list)
   264 void WlanWizardPageNetworkMode::populateRadioButtonList(QStringList &list)
   229 {
   265 {
       
   266     OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_POPULATERADIOBUTTONLIST_ENTRY );
   230     list.clear();
   267     list.clear();
   231     mNetworkModes.clear();
   268     mNetworkModes.clear();
   232     mIsHidden.clear();
   269     mIsHidden.clear();
       
   270     mWpsSupported.clear();
   233 
   271 
   234     // A list is created. Since there is no practical way of knowing whether
   272     // A list is created. Since there is no practical way of knowing whether
   235     // the new contents are different from the previous contents (if there
   273     // the new contents are different from the previous contents (if there
   236     // even were any in the first place) the validity is always reset.
   274     // even were any in the first place) the validity is always reset.
   237     mValid = false;
   275     mValid = false;
   238         
   276         
   239     addToList(list, hbTrId("txt_occ_dblist_val_infrastructure_public"),
   277     addToList(list, hbTrId("txt_occ_dblist_val_infrastructure_public"),
   240         CMManagerShim::Infra, false);
   278         CMManagerShim::Infra, false, false);
   241 
   279 
   242     addToList(list, hbTrId("txt_occ_list_infrastructure_hidden"),
   280     addToList(list, hbTrId("txt_occ_list_infrastructure_hidden"),
   243         CMManagerShim::Infra, true);
   281         CMManagerShim::Infra, true, false);
   244 
   282 
   245     addToList(list, hbTrId("txt_occ_list_adhoc_1"), CMManagerShim::Adhoc,
   283     addToList(list, hbTrId("txt_occ_list_adhoc_1"), CMManagerShim::Adhoc,
   246         false);
   284         false, false);
       
   285     
       
   286     if (mWizard->configurationExists(WlanWizardHelper::ConfAvailableNetworkOptions)) {
       
   287         // addToList with wpsSupported=true is only called, when there are available
       
   288         // scan result options. If no network options exist, the user can not get to
       
   289         // wps wizard from this view. Also, mode and isHidden are "don't care".
       
   290         addToList(list, hbTrId("txt_occ_list_wifi_protected_setup"), NetworkModeNone, false, true);
       
   291     }
       
   292     OstTraceFunctionExit0( WLANWIZARDPAGENETWORKMODE_POPULATERADIOBUTTONLIST_EXIT );
   247 }
   293 }
   248 
   294 
   249 /*!
   295 /*!
   250  * This function selects the next page. Security mode may be skipped in case
   296  * This function selects the next page. Security mode may be skipped in case
   251  * scan results exist and only single option remains.
   297  * scan results exist and only single option remains.
   252  * @param [in] setting indicates the selected network mode.
   298  * @param [in] setting indicates the selected network mode.
   253  * @return Security mode query page identifier unless it can be skipped.
   299  * @return Security mode query page identifier unless it can be skipped.
   254  */
   300  */
   255 int WlanWizardPageNetworkMode::selectNextPage(const WlanNetworkSetting &setting) const
   301 int WlanWizardPageNetworkMode::selectNextPage(const WlanNetworkSetting &setting) const
   256 {
   302 {
       
   303     OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_SELECTNEXTPAGE_ENTRY );
       
   304     
       
   305     int nextPage = WlanWizardPageInternal::PageNetworkSecurity;
       
   306     
   257     WlanWizardScanList networkOptions = mWizard->configuration(
   307     WlanWizardScanList networkOptions = mWizard->configuration(
   258         WlanWizardHelper::ConfAvailableNetworkOptions).value<WlanWizardScanList>();
   308         WlanWizardHelper::ConfAvailableNetworkOptions).value<WlanWizardScanList>();
   259     
   309 
   260     if (networkOptions.secModes(setting) == SingleResult) {
   310     if (networkOptions.secModes(setting) == SingleResult) {
   261         WlanSecuritySetting secMode = networkOptions.getSecMode(setting);
   311         WlanSecuritySetting secMode = networkOptions.getSecMode(setting);
   262         
       
   263         mWizard->setConfiguration(WlanWizardHelper::ConfSecurityMode, secMode.mode);
   312         mWizard->setConfiguration(WlanWizardHelper::ConfSecurityMode, secMode.mode);
   264         mWizard->setConfiguration(WlanWizardHelper::ConfUsePsk, secMode.usePsk);
   313         mWizard->setConfiguration(WlanWizardHelper::ConfUsePsk, secMode.usePsk);
   265         return secMode.nextPageId;
   314         nextPage = secMode.nextPageId;
   266     }
   315     }
   267     
   316     
   268     return WlanWizardPageInternal::PageNetworkSecurity;
   317     OstTraceFunctionExit0( DUP1_WLANWIZARDPAGENETWORKMODE_SELECTNEXTPAGE_EXIT );
   269 }
   318     return nextPage;
   270 
   319 }
       
   320