wlanutilities/wlanqtutilities/base/src/wlanqtutils.cpp
changeset 31 e8f4211554fb
parent 19 10810c91db26
child 39 7b3e49e4608a
equal deleted inserted replaced
30:ab513c8439db 31:e8f4211554fb
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 */
    15 * WLAN Qt Utilities implementation.
    16 
    16 */
    17 #include "wlanqtutilswlanap.h"
    17 
    18 #include "wlanqtutilswlaniap.h"
    18 // System includes
    19 
    19 
       
    20 // User includes
       
    21 
       
    22 #include "wlanqtutilsap.h"
       
    23 #include "wlanqtutilsiap.h"
    20 #include "wlanqtutils_p.h"
    24 #include "wlanqtutils_p.h"
    21 #include "wlanqtutils.h"
    25 #include "wlanqtutils.h"
    22 
    26 
    23 WlanQtUtils::WlanQtUtils()
    27 /*!
    24 {
    28     \class WlanQtUtils
    25     d_ptr = new WlanQtUtilsPrivate(this);
    29     \brief Wlan Qt Utilities. This class provides a Qt API for UI components
    26 }
    30            for retrieving different kind of information related to WLAN
       
    31            functionality.
       
    32 */
       
    33 
       
    34 
       
    35 // External function prototypes
       
    36 
       
    37 // Local constants
       
    38 
       
    39 // ======== LOCAL FUNCTIONS ========
       
    40 
       
    41 // ======== MEMBER FUNCTIONS ========
       
    42 
       
    43 /*!
       
    44     Constructor.
       
    45 */
       
    46 
       
    47 WlanQtUtils::WlanQtUtils() :
       
    48     d_ptr(new WlanQtUtilsPrivate(this))
       
    49 {
       
    50 }
       
    51 
       
    52 /*!
       
    53     Destructor.
       
    54 */
    27 
    55 
    28 WlanQtUtils::~WlanQtUtils()
    56 WlanQtUtils::~WlanQtUtils()
    29 {
    57 {
    30     delete d_ptr;
    58 }
    31 }
    59 
       
    60 /*!
       
    61     Function for requesting a single WLAN scan to be triggered.
       
    62     Signal wlanScanReady() is emitted when new scan results are available.
       
    63 */
       
    64 
       
    65 void WlanQtUtils::scanWlans()
       
    66 {
       
    67     d_ptr->scanWlans();
       
    68 }
       
    69 
       
    70 /*!
       
    71     Function for requesting a WLAN AP scan to be triggered.
       
    72     Signal availableWlanAps() is emitted when new scan results are available.
       
    73 */
       
    74 
       
    75 void WlanQtUtils::scanWlanAps()
       
    76 {
       
    77     d_ptr->scanWlanAps();
       
    78 }
       
    79 
       
    80 /*!
       
    81     Function for requesting a direct WLAN scan with given SSID.
       
    82 
       
    83     Signal wlanScanDirectReady() is emitted when new scan results are
       
    84     available.
       
    85 
       
    86     @param [in] ssid Network name to be found
       
    87 */
       
    88 
       
    89 void WlanQtUtils::scanWlanDirect(const QString &ssid)
       
    90 {
       
    91     d_ptr->scanWlanDirect(ssid);
       
    92 }
       
    93 
       
    94 /*!
       
    95     Function for stopping a (possibly) ongoing WLAN scan. No scan result
       
    96     signal will be sent before a new scan request is made.
       
    97 */
       
    98 
       
    99 void WlanQtUtils::stopWlanScan()
       
   100 {
       
   101     d_ptr->stopWlanScan();
       
   102 }
       
   103 
       
   104 /*!
       
   105     Function to request details of available WLAN networks. Can be called 
       
   106     at any time. Calling right after wlanScanReady() signal ensures you get
       
   107     the most recent results.
       
   108 
       
   109     @param [out] wlanIapList List of available WLAN IAPs.
       
   110     @param [out] wlanApList List of unknown WLAN APs.
       
   111 */
       
   112 
       
   113 void WlanQtUtils::availableWlans(
       
   114     QList< QSharedPointer<WlanQtUtilsIap> > &wlanIapList,
       
   115     QList< QSharedPointer<WlanQtUtilsAp> > &wlanApList) const
       
   116 {
       
   117     d_ptr->availableWlans(wlanIapList, wlanApList);
       
   118 }
       
   119 
       
   120 /*!
       
   121     Function to request details of available WLAN networks. This function is
       
   122     used to get the results that are informed by following signals:
       
   123     -wlanScanApReady()
       
   124     -wlanScanDirectReady()
       
   125 
       
   126     @param [out] wlanApList List of unknown WLAN APs.
       
   127 */
    32 
   128 
    33 void WlanQtUtils::availableWlanAps(
   129 void WlanQtUtils::availableWlanAps(
    34     QList<WlanQtUtilsWlanIap *> &wlanIapList,
   130     QList< QSharedPointer<WlanQtUtilsAp> > &wlanApList) const
    35     QList<WlanQtUtilsWlanAp *> &wlanApList)
   131 {
    36 {
   132     d_ptr->availableWlanAps(wlanApList);
    37     d_ptr->availableWlanAps(wlanIapList, wlanApList);
   133 }
    38 }
   134 
    39 
   135 /*!
    40 int WlanQtUtils::createWlanIap(const WlanQtUtilsWlanAp *wlanAp)
   136     Function to create an IAP from the given WLAN access point.
    41 {
   137 
    42     return d_ptr->createWlanIap(wlanAp);
   138     @param [in] wlanAp Access point containing parameters to include in the new IAP.
    43 }
   139     
    44 
   140     @return IAP ID if creation succeeds, IapIdNone otherwise.
    45 void WlanQtUtils::connectIap(int iapId)
   141 */
    46 {
   142 
    47     d_ptr->connectIap(iapId);
   143 int WlanQtUtils::createIap(const WlanQtUtilsAp *wlanAp)
    48 }
   144 {
       
   145     return d_ptr->createIap(wlanAp);
       
   146 }
       
   147 
       
   148 /*!
       
   149     Function to update an IAP from the given WLAN access point.
       
   150 
       
   151     @param [in] iapId ID of the IAP to be updated.
       
   152     @param [in] wlanAp Access point containing parameters to update in the IAP.
       
   153     
       
   154     @return Was update successful?
       
   155 */
       
   156 
       
   157 bool WlanQtUtils::updateIap(int iapId, const WlanQtUtilsAp *wlanAp)
       
   158 {
       
   159     return d_ptr->updateIap(iapId, wlanAp);
       
   160 }
       
   161 
       
   162 /*!
       
   163     Function to delete an IAP.
       
   164 
       
   165     @param [in] iapId ID of the IAP to be deleted.
       
   166 */
       
   167 
       
   168 void WlanQtUtils::deleteIap(int iapId)
       
   169 {
       
   170     d_ptr->deleteIap(iapId);
       
   171 }
       
   172 
       
   173 /*!
       
   174     Function to start connection creation for the given IAP. Runs also
       
   175     Internet Connectivity Test (ICT), if requested with the optional
       
   176     parameter.
       
   177     
       
   178     Connecting while there is already a connection is also supported.
       
   179 
       
   180     wlanNetworkOpened() or wlanNetworkClosed() signal will be emitted
       
   181     when connection status changes.
       
   182     
       
   183     ictResult() signal will be emitted when (possible) ICT result is
       
   184     available.
       
   185 
       
   186     @param [in] iapId ID of the IAP to be connected.
       
   187     @param [in] runIct Should ICT be run or not?
       
   188 */
       
   189 
       
   190 void WlanQtUtils::connectIap(int iapId, bool runIct)
       
   191 {
       
   192     d_ptr->connectIap(iapId, runIct);
       
   193 }
       
   194 
       
   195 /*!
       
   196     Function to disconnect the given IAP.
       
   197     Disconnecting when there is no connection is also supported.
       
   198 
       
   199     @param [in] iapId ID of the IAP to be disconnected.
       
   200 */
    49 
   201 
    50 void WlanQtUtils::disconnectIap(int iapId)
   202 void WlanQtUtils::disconnectIap(int iapId)
    51 {
   203 {
    52     d_ptr->disconnectIap(iapId);
   204     d_ptr->disconnectIap(iapId);
    53 }
   205 }
    54 
   206 
    55 WlanQtUtilsIap *WlanQtUtils::iap(int iapId) const
   207 /*!
    56 {
   208     Function to retrieve the name of the IAP with the given ID.
    57     return d_ptr->iap(iapId);
   209 
    58 }
   210     @param [in] iapId ID of the requested IAP.
    59 
   211     
    60 bool WlanQtUtils::masterWlan() const
   212     @return Name of the IAP or empty QString if IAP is not found.
    61 {
   213 */
    62     return d_ptr->masterWlan();
   214 
    63 }
   215 QString WlanQtUtils::iapName(int iapId) const
    64 
   216 {
    65 void WlanQtUtils::setMasterWlan(bool enabled)
   217     return d_ptr->iapName(iapId);
    66 {
   218 }
    67     d_ptr->setMasterWlan(enabled);
   219 
    68 }
   220 /*!
    69 
   221     Connection status getter.
    70 int WlanQtUtils::connectedWlanId() const
   222     
    71 {
   223     @return Current WLAN connection status. 
    72     return d_ptr->connectedWlanId();
   224 */
    73 }
   225 
    74 
   226 WlanQtUtils::ConnStatus WlanQtUtils::connectionStatus() const
    75 void WlanQtUtils::scanWlans()
   227 {
    76 {
   228     return d_ptr->connectionStatus();
    77     d_ptr->scanWlans();
   229 }
    78 }
   230 
    79 
   231 /*!
    80 // End of File
   232     Function for getting the ID of the (possibly) active WLAN IAP.
       
   233     Active here means non-disconnected.
       
   234     Use connectionStatus() for retrieving the actual status.
       
   235 
       
   236     @return ID of the active IAP, IapIdNone if not valid.
       
   237 */
       
   238 
       
   239 int WlanQtUtils::activeIap() const
       
   240 {
       
   241     return d_ptr->activeIap();
       
   242 }