wlanutilities/wlanwizard/src/wlanwizard_p.cpp
changeset 46 2fbd1d709fe7
parent 38 2dc6da6fb431
child 43 72ebcbb64834
equal deleted inserted replaced
45:d9ec2b8c6bad 46:2fbd1d709fe7
    29 #include <HbLabel>
    29 #include <HbLabel>
    30 #include <HbAction>
    30 #include <HbAction>
    31 #include <HbStyleLoader>
    31 #include <HbStyleLoader>
    32 
    32 
    33 // User includes
    33 // User includes
    34 #ifdef WLAN_WIZARD_RND_EAP
       
    35 #include "eapwizard.h"
    34 #include "eapwizard.h"
    36 #endif
       
    37 
       
    38 #ifdef WLAN_WIZARD_RND_WPS
       
    39 #include "wpswizard.h"
    35 #include "wpswizard.h"
    40 #endif
       
    41 #include "wlanqtutils.h"
    36 #include "wlanqtutils.h"
    42 #include "wlanqtutilsap.h"
    37 #include "wlanqtutilsap.h"
    43 #include "wlanwizardplugin.h"
    38 #include "wlanwizardplugin.h"
    44 #include "wlanwizard.h"
    39 #include "wlanwizard.h"
    45 #include "wlanwizard_p.h"
    40 #include "wlanwizard_p.h"
    46 #include "wlanwizardutils.h"
    41 #include "wlanwizardutils.h"
    47 #include "wlanwizardpagekeyquery.h"
    42 #include "wlanwizardpagekeyquery.h"
    48 #include "wlanwizardpagesummary.h"
    43 #include "wlanwizardpagesummary.h"
    49 #include "wlanwizardpageprocessingsettings.h"
    44 #include "wlanwizardpageprocessingsettings.h"
    50 #include "wlanwizardpagegenericerror.h"
    45 #include "wlanwizardpagegenericerror.h"
    51 
       
    52 #ifdef WLAN_WIZARD_RND
       
    53 #include "wlanwizardpagessid.h"
    46 #include "wlanwizardpagessid.h"
    54 #include "wlanwizardpagenetworkmode.h"
    47 #include "wlanwizardpagenetworkmode.h"
    55 #include "wlanwizardpagescanning.h"
    48 #include "wlanwizardpagescanning.h"
    56 #include "wlanwizardpagesecuritymode.h"
    49 #include "wlanwizardpagesecuritymode.h"
    57 #endif
       
    58 
    50 
    59 #include "OstTraceDefinitions.h"
    51 #include "OstTraceDefinitions.h"
    60 #ifdef OST_TRACE_COMPILER_IN_USE
    52 #ifdef OST_TRACE_COMPILER_IN_USE
    61 #include "wlanwizard_pTraces.h"
    53 #include "wlanwizard_pTraces.h"
    62 #endif
    54 #endif
   126     loadDocml();
   118     loadDocml();
   127 
   119 
   128     // Creates the control object of the wlan wizard pages. 
   120     // Creates the control object of the wlan wizard pages. 
   129     createPages();
   121     createPages();
   130 
   122 
       
   123     // EAP Wizard will add wizard pages at construction phase using
       
   124     // WlanWizardHelper::addPage()
       
   125     mEapWizard.reset(new EapWizard(this) );
       
   126 
       
   127     // WPS Wizard will add wizard pages at construction phase using
       
   128     // WlanWizardHelper::addPage()
       
   129     mWpsWizard.reset(new WpsWizard(this));
       
   130 
   131     // First page is SSID query, unless client sets configurations via
   131     // First page is SSID query, unless client sets configurations via
   132     // setParameters(), which decides the first page..
   132     // setParameters(), which decides the first page..
   133     mFirstPageId = WlanWizardPageInternal::PageSsid;
   133     mFirstPageId = WlanWizardPageInternal::PageSsid;
   134 
   134 
   135     OstTraceExt2( TRACE_BORDER, WLANWIZARDPRIVATE_WLANWIZARDPRIVATE_DONE,
   135     OstTraceExt2( TRACE_BORDER, WLANWIZARDPRIVATE_WLANWIZARDPRIVATE_DONE,
   163 
   163 
   164     // WlanWizardPage objects are automatically deleted since this is the
   164     // WlanWizardPage objects are automatically deleted since this is the
   165     // parent of the objects.
   165     // parent of the objects.
   166     mPages.clear();
   166     mPages.clear();
   167     
   167     
   168 #ifdef WLAN_WIZARD_RND_EAP
       
   169     delete mEapWizard;
       
   170 #endif
       
   171 #ifdef WLAN_WIZARD_RND_WPS
       
   172     delete mWpsWizard;
       
   173 #endif
       
   174     // timer is cancelled/deleted automatically when the parent (this) is deleted 
   168     // timer is cancelled/deleted automatically when the parent (this) is deleted 
   175     
   169     
   176     // TODO: See TSW Error: MTAA-854DK8 and loadDocml()
   170     // TODO: See TSW Error: MTAA-854DK8 and loadDocml()
   177     HbStyleLoader::unregisterFilePath(":/css/custom.css");
   171     HbStyleLoader::unregisterFilePath(":/css/custom.css");
       
   172     
       
   173     mDialog->setAttribute( Qt::WA_DeleteOnClose, true );
       
   174     mDialog->close();
       
   175     // Remove the pointer from QScopedPointer to prevent double deallocation
       
   176     mDialog.take();
   178     
   177     
   179     OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_DWLANWIZARDPRIVATE_DONE,
   178     OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_DWLANWIZARDPRIVATE_DONE,
   180         "WlanWizardPrivate::~WlanWizardPrivate-Done;this=%x",
   179         "WlanWizardPrivate::~WlanWizardPrivate-Done;this=%x",
   181         this );
   180         this );
   182 }
   181 }
   270 WlanWizardPlugin* WlanWizardPrivate::wlanWizardPlugin() const
   269 WlanWizardPlugin* WlanWizardPrivate::wlanWizardPlugin() const
   271 {
   270 {
   272     WlanWizardPlugin* plugin = NULL;
   271     WlanWizardPlugin* plugin = NULL;
   273 
   272 
   274     if (isEapEnabled()) {
   273     if (isEapEnabled()) {
   275 #ifdef WLAN_WIZARD_RND_EAP
   274         plugin = mEapWizard.data();
   276         plugin = mEapWizard;
       
   277         Q_ASSERT(plugin);
   275         Q_ASSERT(plugin);
   278 #endif
       
   279     }
   276     }
   280     
   277     
   281     OstTrace1( TRACE_NORMAL, WLANWIZARDPRIVATE_WLANWIZARDPLUGIN, 
   278     OstTrace1( TRACE_NORMAL, WLANWIZARDPRIVATE_WLANWIZARDPLUGIN, 
   282         "WlanWizardPrivate::wlanWizardPlugin;plugin=%x", 
   279         "WlanWizardPrivate::wlanWizardPlugin;plugin=%x", 
   283         plugin );
   280         plugin );
   323     bool ret = true;
   320     bool ret = true;
   324     bool usePsk = true;
   321     bool usePsk = true;
   325     int securityMode = configuration(ConfSecurityMode).toInt();
   322     int securityMode = configuration(ConfSecurityMode).toInt();
   326     WlanQtUtilsAp wlanAp;
   323     WlanQtUtilsAp wlanAp;
   327    
   324    
       
   325     // Set default values
       
   326     wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPsk, QString());
       
   327     wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true );
       
   328     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex1 );
       
   329     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey1, QString());
       
   330     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey2, QString());
       
   331     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey3, QString());
       
   332     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey4, QString());
       
   333     
   328     // Set configuration
   334     // Set configuration
   329     wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, configuration(ConfSsid));
   335     wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, configuration(ConfSsid));
   330     wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, 
   336     wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, 
   331         configuration(ConfNetworkMode));
   337         configuration(ConfNetworkMode));
   332     wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, securityMode );
   338     wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, securityMode );
   438 
   444 
   439     mConfigurations[confId] = value;
   445     mConfigurations[confId] = value;
   440 }
   446 }
   441 
   447 
   442 /*!
   448 /*!
       
   449  * See WlanWizardHelper::clearConfiguration().
       
   450  */
       
   451 void WlanWizardPrivate::clearConfiguration(ConfigurationId confId)
       
   452 {
       
   453     OstTrace1( TRACE_FLOW, WLANWIZARDPRIVATE_CLEARCONFIGURATION,
       
   454         "WlanWizardPrivate::clearConfiguration;confId=%{ConfigurationId}",
       
   455         (uint)confId );
       
   456     
       
   457     mConfigurations.remove(confId);
       
   458 }
       
   459 
       
   460 /*!
       
   461  * See WlanWizardHelper::configurationExists().
       
   462  */
       
   463 bool WlanWizardPrivate::configurationExists(ConfigurationId confId)
       
   464 {
       
   465     OstTrace1( TRACE_DUMP, WLANWIZARDPRIVATE_CONFIGURATIONEXISTS,
       
   466         "WlanWizardPrivate::configurationExists;confId=%{ConfigurationId}",
       
   467         (uint)confId );
       
   468     
       
   469     return mConfigurations[confId].isValid();
       
   470 }
       
   471     
       
   472 /*!
   443    See WlanWizardHelper::enableNextButton().
   473    See WlanWizardHelper::enableNextButton().
   444  */
   474  */
   445 void WlanWizardPrivate::enableNextButton(bool enable)
   475 void WlanWizardPrivate::enableNextButton(bool enable)
   446 {
   476 {
   447     OstTraceExt2( TRACE_FLOW, WLANWIZARDPRIVATE_ENABLENEXTBUTTON,
   477     OstTraceExt2( TRACE_FLOW, WLANWIZARDPRIVATE_ENABLENEXTBUTTON,
   449         (unsigned)this, (uint)enable );
   479         (unsigned)this, (uint)enable );
   450     mActionNext->setEnabled(enable);
   480     mActionNext->setEnabled(enable);
   451 }
   481 }
   452 
   482 
   453 /*!
   483 /*!
   454    See WlanWizardHelper::enablePrevButton().
       
   455  */
       
   456 void WlanWizardPrivate::enablePrevButton(bool enable)
       
   457 {
       
   458     OstTraceExt2( TRACE_FLOW, WLANWIZARDPRIVATE_ENABLEPREVBUTTON,
       
   459         "WlanWizardPrivate::enablePrevButton;this=%x;enable=%x", 
       
   460         (unsigned)this, (uint)(enable) );
       
   461     
       
   462     mActionPrevious->setEnabled(enable);
       
   463 }
       
   464 
       
   465 /*!
       
   466    See WlanWizardHelper::addPage().
   484    See WlanWizardHelper::addPage().
   467  */
   485  */
   468 void WlanWizardPrivate::addPage(int pageId, WlanWizardPage *page)
   486 void WlanWizardPrivate::addPage(int pageId, WlanWizardPage *page)
   469 {
   487 {
   470     OstTraceExt3( TRACE_FLOW, WLANWIZARDPRIVATE_ADDPAGE, 
   488     OstTraceExt3( TRACE_FLOW, WLANWIZARDPRIVATE_ADDPAGE, 
   517    See WlanWizardHelper::nextPageId()
   535    See WlanWizardHelper::nextPageId()
   518  */
   536  */
   519 int WlanWizardPrivate::nextPageId(bool useWps)
   537 int WlanWizardPrivate::nextPageId(bool useWps)
   520 {
   538 {
   521     int ret;
   539     int ret;
   522     int secMode = configuration(WlanWizardHelper::ConfSecurityMode).toInt();
       
   523     switch (secMode) {
       
   524     case CMManagerShim::WlanSecModeWep:
       
   525         ret = WlanWizardPageInternal::PageKeyQuery;
       
   526         break;
       
   527         
       
   528     case CMManagerShim::WlanSecModeWpa:
       
   529     case CMManagerShim::WlanSecModeWpa2:
       
   530         if (configuration(WlanWizardHelper::ConfUsePsk).toBool()) {
       
   531             ret = WlanWizardPageInternal::PageKeyQuery;
       
   532         } else {
       
   533 #ifdef WLAN_WIZARD_RND_EAP
       
   534             ret = WlanWizardPage::PageEapStart;
       
   535 #else
       
   536             ret = WlanWizardPageInternal::PageProcessSettings;
       
   537             setConfiguration(ConfSecurityMode, CMManagerShim::WlanSecModeOpen);
       
   538 #endif
       
   539 
       
   540         }
       
   541         break;
       
   542         
       
   543     case CMManagerShim::WlanSecMode802_1x:
       
   544 #ifdef WLAN_WIZARD_RND_EAP
       
   545         ret = WlanWizardPage::PageEapStart;
       
   546 #else
       
   547         ret = WlanWizardPageInternal::PageProcessSettings;
       
   548         setConfiguration(ConfSecurityMode, CMManagerShim::WlanSecModeOpen);
       
   549 #endif
       
   550         break;
       
   551         
       
   552     case CMManagerShim::WlanSecModeWapi:
       
   553     case CMManagerShim::WlanSecModeOpen:
       
   554     default:
       
   555         Q_ASSERT(
       
   556             secMode == CMManagerShim::WlanSecModeOpen || 
       
   557             secMode == CMManagerShim::WlanSecModeWapi);
       
   558         
       
   559         setConfiguration(ConfSecurityMode, CMManagerShim::WlanSecModeOpen);
       
   560         ret = WlanWizardPageInternal::PageProcessSettings;
       
   561         break;
       
   562     }
       
   563 
       
   564     Q_UNUSED(useWps);
       
   565 #ifdef WLAN_WIZARD_RND_WPS
       
   566     // TODO: WPS: and switch case above to else branch
       
   567     if (useWps) {
   540     if (useWps) {
   568         ret = WlanWizardPage::PageWpsStart;
   541         ret = WlanWizardPage::PageWpsStart;
   569     }
   542     } else {
   570 #endif
   543         int secMode = configuration(WlanWizardHelper::ConfSecurityMode).toInt();
       
   544         switch (secMode) {
       
   545         case CMManagerShim::WlanSecModeWep:
       
   546             ret = WlanWizardPageInternal::PageKeyQuery;
       
   547             break;
       
   548             
       
   549         case CMManagerShim::WlanSecModeWpa:
       
   550         case CMManagerShim::WlanSecModeWpa2:
       
   551             if (configuration(WlanWizardHelper::ConfUsePsk).toBool()) {
       
   552                 ret = WlanWizardPageInternal::PageKeyQuery;
       
   553             } else {
       
   554                 ret = WlanWizardPage::PageEapStart;
       
   555             }
       
   556             break;
       
   557             
       
   558         case CMManagerShim::WlanSecMode802_1x:
       
   559             ret = WlanWizardPage::PageEapStart;
       
   560             break;
       
   561             
       
   562         default:
       
   563             Q_ASSERT(
       
   564                 secMode == CMManagerShim::WlanSecModeOpen || 
       
   565                 secMode == CMManagerShim::WlanSecModeWapi);
       
   566             
       
   567             setConfiguration(ConfSecurityMode, CMManagerShim::WlanSecModeOpen);
       
   568             ret = WlanWizardPageInternal::PageProcessSettings;
       
   569             break;
       
   570         }
       
   571     }
   571 
   572 
   572     OstTraceExt3( TRACE_NORMAL, WLANWIZARDPRIVATE_NEXTPAGEID,
   573     OstTraceExt3( TRACE_NORMAL, WLANWIZARDPRIVATE_NEXTPAGEID,
   573         "WlanWizardPrivate::nextPageId;this=%x;useWps=%x;ret=%{PageIds}",
   574         "WlanWizardPrivate::nextPageId;this=%x;useWps=%x;ret=%{PageIds}",
   574         ( unsigned )this, ( TUint )( useWps ), ret );
   575         ( unsigned )this, ( TUint )( useWps ), ret );
   575 
   576 
   605         // - connection establishment is ongoing
   606         // - connection establishment is ongoing
   606         mWlanQtUtils->disconnectIap(referenceId);
   607         mWlanQtUtils->disconnectIap(referenceId);
   607         
   608         
   608         // if IAP deletion fails, there is nothing we can do with it
   609         // if IAP deletion fails, there is nothing we can do with it
   609         mWlanQtUtils->deleteIap(referenceId);
   610         mWlanQtUtils->deleteIap(referenceId);
   610         WlanWizardPlugin* plugin = wlanWizardPlugin();
       
   611         if (plugin) {
       
   612             // if deletion of plugin specific configuration fails we are not
       
   613             // able to do anything
       
   614             plugin->deleteSettings();
       
   615         }
       
   616         setConfiguration(ConfIapId, WlanQtUtils::IapIdNone);
   611         setConfiguration(ConfIapId, WlanQtUtils::IapIdNone);
   617     }
   612     }
   618     closeViews();
   613     closeViews();
   619     Q_ASSERT(q_ptr);
   614     Q_ASSERT(q_ptr);
   620 
   615 
   810             } else {
   805             } else {
   811                 pageId = WlanWizardPage::PageGenericError;
   806                 pageId = WlanWizardPage::PageGenericError;
   812                 setConfiguration(
   807                 setConfiguration(
   813                     ConfGenericErrorString, 
   808                     ConfGenericErrorString, 
   814                     hbTrId("txt_occ_dialog_unable_to_save_settings_please_ret"));
   809                     hbTrId("txt_occ_dialog_unable_to_save_settings_please_ret"));
       
   810                 
       
   811                 setConfiguration(
       
   812                     ConfGenericErrorPageStepsBackwards, 
       
   813                     WlanWizardPage::OneStepBackwards);
   815             }
   814             }
   816             OstTraceExt2( TRACE_FLOW, WLANWIZARDPRIVATE_SHOWPAGE_UPDATE,
   815             OstTraceExt2( TRACE_FLOW, WLANWIZARDPRIVATE_SHOWPAGE_UPDATE,
   817                 "WlanWizardPrivate::showPage - change page;this=%x;"
   816                 "WlanWizardPrivate::showPage - change page;this=%x;"
   818                 "pageId=%{PageIds}",
   817                 "pageId=%{PageIds}",
   819                 ( unsigned )this, pageId);
   818                 ( unsigned )this, pageId);
   820         }
   819         }
   821     }
   820     }
   822     
       
   823 #ifdef WLAN_WIZARD_RND_EAP
       
   824     if (pageId == WlanWizardPage::PageEapStart) {
       
   825         if (!mEapWizard) {
       
   826             // EAP Wizard will add wizard pages at construction phase using
       
   827             // WlanWizardHelper::addPage()
       
   828             mEapWizard = new EapWizard(this);
       
   829         }
       
   830     }
       
   831 #endif
       
   832 #ifdef WLAN_WIZARD_RND_WPS
       
   833     if (pageId == WlanWizardPage::PageWpsStart) {
       
   834         if (!mWpsWizard) {
       
   835             // WPS Wizard will add wizard pages at construction phase using
       
   836             // WlanWizardHelper::addPage()
       
   837             mWpsWizard = new WpsWizard(this);
       
   838         }
       
   839     }
       
   840 #endif
       
   841 
   821 
   842     // Create visualization of next page and store it to mappers
   822     // Create visualization of next page and store it to mappers
   843     WlanWizardPage* page = mPages[pageId];
   823     WlanWizardPage* page = mPages[pageId];
   844     Q_ASSERT(page);
   824     Q_ASSERT(page);
   845     HbWidget* widget = page->initializePage();
   825     HbWidget* widget = page->initializePage();
   880    Creates all control objects of WLAN wizard pages which are inherited from
   860    Creates all control objects of WLAN wizard pages which are inherited from
   881    WlanWizardPage and adds those into a internal database. 
   861    WlanWizardPage and adds those into a internal database. 
   882  */
   862  */
   883 void WlanWizardPrivate::createPages()
   863 void WlanWizardPrivate::createPages()
   884 {
   864 {
   885     OstTrace0( TRACE_NORMAL, WLANWIZARDPRIVATE_CREATEPAGES,
   865     OstTrace0(
   886         "WlanWizardPrivate::createPages" );
   866         TRACE_NORMAL,
   887     
   867         WLANWIZARDPRIVATE_CREATEPAGES,
   888     addPage(WlanWizardPageInternal::PageKeyQuery, 
   868         "WlanWizardPrivate::createPages");
       
   869     
       
   870     addPage(
       
   871         WlanWizardPageInternal::PageKeyQuery, 
   889         new WlanWizardPageKeyQuery(this));
   872         new WlanWizardPageKeyQuery(this));
   890     
   873     
   891     addPage(WlanWizardPageInternal::PageProcessSettings, 
   874     addPage(
       
   875         WlanWizardPageInternal::PageProcessSettings, 
   892         new WlanWizardPageProcessingSettings(this));
   876         new WlanWizardPageProcessingSettings(this));
   893     
   877     
   894     addPage(WlanWizardPageInternal::PageSummary, 
   878     addPage(
       
   879         WlanWizardPageInternal::PageSummary, 
   895         new WlanWizardPageSummary(this));
   880         new WlanWizardPageSummary(this));
   896 
   881 
   897     addPage(WlanWizardPageInternal::PageGenericError, 
   882     addPage(
       
   883         WlanWizardPageInternal::PageGenericError, 
   898         new WlanWizardPageGenericError(this));
   884         new WlanWizardPageGenericError(this));
   899     
   885     
   900 #ifdef WLAN_WIZARD_RND
   886     addPage(
   901     addPage(WlanWizardPageInternal::PageSsid, new WlanWizardPageSsid(this));
   887         WlanWizardPageInternal::PageSsid,
   902     
   888         new WlanWizardPageSsid(this));
   903     addPage(WlanWizardPageInternal::PageScanning, 
   889     
       
   890     addPage(
       
   891         WlanWizardPageInternal::PageScanning, 
   904         new WlanWizardPageScanning(this));
   892         new WlanWizardPageScanning(this));
   905     
   893     
   906     addPage(WlanWizardPageInternal::PageNetworkMode, 
   894     addPage(
       
   895         WlanWizardPageInternal::PageNetworkMode, 
   907         new WlanWizardPageNetworkMode(this));
   896         new WlanWizardPageNetworkMode(this));
   908     
   897     
   909     addPage(WlanWizardPageInternal::PageNetworkSecurity, 
   898     addPage(
       
   899         WlanWizardPageInternal::PageNetworkSecurity, 
   910         new WlanWizardPageSecurityMode(this));
   900         new WlanWizardPageSecurityMode(this));
   911 #endif
       
   912 }
   901 }
   913 
   902 
   914 /*!
   903 /*!
   915    Called when wizard is closed 
   904    Called when wizard is closed 
   916    - cancelled by the user
   905    - cancelled by the user
   917    - finished by the user
   906    - finished by the user
   918  */
   907  */
   919 void WlanWizardPrivate::closeViews()
   908 void WlanWizardPrivate::closeViews()
   920 {
   909 {
       
   910     mDialog->hide();
   921     mClosed = true;
   911     mClosed = true;
   922     mDialog->close();
       
   923 }
   912 }
   924 
   913 
   925 /*!
   914 /*!
   926    This method takes care of the title of wizard and toolbutton. Correct items
   915    This method takes care of the title of wizard and toolbutton. Correct items
   927    are selected based on the \a pageId and the amount of objects in the stacked
   916    are selected based on the \a pageId and the amount of objects in the stacked