wlanutilities/wlansniffer/wlansnifferapplication/src/wlansniffermainwindow.cpp
changeset 46 2fbd1d709fe7
parent 38 2dc6da6fb431
child 53 bdc64aa9b954
equal deleted inserted replaced
45:d9ec2b8c6bad 46:2fbd1d709fe7
    83  */
    83  */
    84 
    84 
    85 WlanSnifferMainWindow::~WlanSnifferMainWindow()
    85 WlanSnifferMainWindow::~WlanSnifferMainWindow()
    86 {
    86 {
    87     OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_WLANSNIFFERMAINWINDOWDESTR_ENTRY);
    87     OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_WLANSNIFFERMAINWINDOWDESTR_ENTRY);
    88     
       
    89     delete mWizard;
       
    90     
       
    91     OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_WLANSNIFFERMAINWINDOWDESTR_EXIT);
    88     OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_WLANSNIFFERMAINWINDOWDESTR_EXIT);
    92 }
    89 }
    93 
    90 
    94 /*!
    91 /*!
    95     Shows the WLAN Sniffer list view.
    92     Shows the WLAN Sniffer list view.
   130 }
   127 }
   131 
   128 
   132 /*!
   129 /*!
   133     Starts WLAN Wizard for new WLAN IAP creation.
   130     Starts WLAN Wizard for new WLAN IAP creation.
   134     
   131     
   135     @param [in] ap WLAN Access Point to create.
   132     @param [in] ap WLAN Access Point to create, or NULL for adding WLAN manually.
   136  */
   133  */
   137 
   134 
   138 void WlanSnifferMainWindow::startWlanWizard(const WlanQtUtilsAp *ap)
   135 void WlanSnifferMainWindow::startWlanWizard(const WlanQtUtilsAp *ap)
   139 {
   136 {
   140     OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_STARTWLANWIZARD_ENTRY);
   137     OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_STARTWLANWIZARD_ENTRY);
   142     Q_ASSERT(mWizard == NULL);
   139     Q_ASSERT(mWizard == NULL);
   143 
   140 
   144     // Stop WLAN scanning for the duration of WLAN Wizard
   141     // Stop WLAN scanning for the duration of WLAN Wizard
   145     mEngine->stopWlanScanning();
   142     mEngine->stopWlanScanning();
   146     
   143     
   147     mWizard = new WlanWizard(this);
   144     mWizard = QSharedPointer<WlanWizard>(new WlanWizard(this));
   148     bool connectStatus = connect(
   145     bool connectStatus = connect(
   149         mWizard,
   146         mWizard.data(),
   150         SIGNAL(finished(int,bool)),
   147         SIGNAL(finished(int,bool)),
   151         this,
   148         this,
   152         SLOT(handleWlanWizardComplete(int,bool)));
   149         SLOT(handleWlanWizardComplete(int,bool)),
       
   150         Qt::QueuedConnection);
   153     Q_ASSERT(connectStatus == true);
   151     Q_ASSERT(connectStatus == true);
   154     
   152     
   155     connectStatus = connect(
   153     connectStatus = connect(
   156         mWizard,
   154         mWizard.data(),
   157         SIGNAL(cancelled()),
   155         SIGNAL(cancelled()),
   158         this,
   156         this,
   159         SLOT(handleWlanWizardCancelled()));
   157         SLOT(handleWlanWizardCancelled()),
       
   158         Qt::QueuedConnection);
   160     Q_ASSERT(connectStatus == true);
   159     Q_ASSERT(connectStatus == true);
   161     
   160     
   162     mWizard->setParameters(
   161     // Create an IAP for a specific AP
   163         ap->value(WlanQtUtilsAp::ConfIdSsid).toString(),
   162     if (ap) {
   164         ap->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt(),
   163         mWizard->setParameters(
   165         ap->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(),
   164             ap->value(WlanQtUtilsAp::ConfIdSsid).toString(),
   166         ap->value(WlanQtUtilsAp::ConfIdWpaPskUse).toInt(),
   165             ap->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt(),
   167         ap->value(WlanQtUtilsAp::ConfIdHidden).toBool(),
   166             ap->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(),
   168         ap->value(WlanQtUtilsAp::ConfIdWpsSupported).toBool());
   167             ap->value(WlanQtUtilsAp::ConfIdWpaPskUse).toInt(),
       
   168             ap->value(WlanQtUtilsAp::ConfIdHidden).toBool(),
       
   169             ap->value(WlanQtUtilsAp::ConfIdWpsSupported).toBool());
       
   170     }
       
   171     // else: Add WLAN IAP manually
   169     
   172     
   170     mWizard->show();
   173     mWizard->show();
   171 
   174 
   172     OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_STARTWLANWIZARD_EXIT);
   175     OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_STARTWLANWIZARD_EXIT);
   173 }
   176 }
   183     int iapId,
   186     int iapId,
   184     bool connected)
   187     bool connected)
   185 {
   188 {
   186     OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCOMPLETE_ENTRY);
   189     OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCOMPLETE_ENTRY);
   187 
   190 
       
   191     // The wizard must exist
       
   192     Q_ASSERT(mWizard);
       
   193     
   188     // Enable scanning again
   194     // Enable scanning again
   189     mEngine->startWlanScanning();
   195     mEngine->startWlanScanning();
   190     
   196 
   191     // TODO: Will be needed in "Adding WLAN network manually" subfeature
   197     if (connected) {
   192     Q_UNUSED(connected);
   198         // The IAP ID must be valid
   193     
   199         Q_ASSERT(iapId != WlanQtUtils::IapIdNone);
   194     // The IAP ID must be valid
   200         
   195     Q_ASSERT(iapId != WlanQtUtils::IapIdNone);
   201         // Connect (share) the new IAP in order to keep the connection open when
   196     
   202         // deleting Wizard.
   197     // Connect (share) the new IAP in order to keep the connection open when
   203         mEngine->wlanQtUtils()->connectIap(iapId, false);
   198     // deleting Wizard.
   204     }
   199     // Todo: this needs some checking when "Adding WLAN IAP manually" subfeature
   205     // else: created IAP not connected at all, or already dropped
   200     // is implemented, because we don't want to connect the IAP, if Wizard didn't
   206     // (probably due to being out of coverage) so don't try to share it
   201     // connect it.
   207     
   202     mEngine->wlanQtUtils()->connectIap(iapId, false);
   208     // Delete the Wizard instance. This is OK since the connect is Qt::QueuedConnection.
   203     
   209     mWizard.clear();
       
   210     
       
   211     OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCOMPLETE_EXIT);
       
   212 }
       
   213 
       
   214 /*!
       
   215     WLAN Wizard cancellation handler.
       
   216  */
       
   217 
       
   218 void WlanSnifferMainWindow::handleWlanWizardCancelled()
       
   219 {
       
   220     OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCANCELLED_ENTRY);
       
   221 
   204     // The wizard must exist
   222     // The wizard must exist
   205     Q_ASSERT(mWizard);
   223     Q_ASSERT(mWizard);
   206     
   224     
   207     // Delete the Wizard instance, but only when returning to event loop, because
       
   208     // execution returns back to Wizard after this slot.
       
   209     mWizard->deleteLater();
       
   210     mWizard = NULL;
       
   211     
       
   212     OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCOMPLETE_EXIT);
       
   213 }
       
   214 
       
   215 /*!
       
   216     WLAN Wizard cancellation handler.
       
   217  */
       
   218 
       
   219 void WlanSnifferMainWindow::handleWlanWizardCancelled()
       
   220 {
       
   221     OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCANCELLED_ENTRY);
       
   222 
       
   223     // Enable scanning again
   225     // Enable scanning again
   224     mEngine->startWlanScanning();
   226     mEngine->startWlanScanning();
   225     
   227     
   226     // The wizard must exist
   228     // Delete the Wizard instance. This is OK since the connect is Qt::QueuedConnection.
   227     Q_ASSERT(mWizard);
   229     mWizard.clear();
   228     
       
   229     // Delete the Wizard instance, but only when returning to event loop, because
       
   230     // execution returns back to Wizard after this slot.
       
   231     mWizard->deleteLater();
       
   232     mWizard = NULL;
       
   233     
   230     
   234     OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCANCELLED_EXIT);
   231     OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCANCELLED_EXIT);
   235 }
   232 }