wlanutilities/wlanqtutilities/base/inc/wlanqtutils.h
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 * WLAN Qt Utilities interface.
    15 */
    16 */
    16 
    17 
    17 #ifndef WLANQTUTILS_H
    18 #ifndef WLANQTUTILS_H
    18 #define WLANQTUTILS_H
    19 #define WLANQTUTILS_H
    19 
    20 
       
    21 // System includes
       
    22 
    20 #include <QObject>
    23 #include <QObject>
       
    24 #include <QScopedPointer>
       
    25 #include <QSharedPointer>
    21 
    26 
    22 #include "wlanqtutilscommon.h"
    27 // User includes
       
    28 
       
    29 // Forward declarations
    23 
    30 
    24 class WlanQtUtilsIap;
    31 class WlanQtUtilsIap;
    25 class WlanQtUtilsWlanIap;
    32 class WlanQtUtilsAp;
    26 class WlanQtUtilsWlanAp;
       
    27 class WlanQtUtilsPrivate;
    33 class WlanQtUtilsPrivate;
    28 
    34 
    29 const int WlanQtUtilsInvalidIapId = -1;
    35 // External data types
    30 
    36 
    31 /**
    37 // Constants
    32  * Wlan Qt Utilities.
    38 
    33  * 
    39 //! Library interface export macro
    34  * This class provides a Qt API to UI components for retrieving different kind of information
    40 #ifdef BUILD_WLANQTUTILITIES_DLL
    35  * related to WLAN functionality.
    41 #define WLANQTUTILS_EXPORT Q_DECL_EXPORT
    36  */
    42 #else
    37 class WLANQTUTILITIESDLL_EXPORT WlanQtUtils : public QObject
    43 #define WLANQTUTILS_EXPORT Q_DECL_IMPORT
       
    44 #endif
       
    45 
       
    46 // Class declaration
       
    47 
       
    48 class WLANQTUTILS_EXPORT WlanQtUtils : public QObject
    38 {
    49 {
    39     Q_OBJECT
    50     Q_OBJECT
    40 
    51 
    41 public:
    52 public:
       
    53 
       
    54     // Data types
       
    55 
       
    56     //! "None" IAP ID value (e.g. for "not found" cases)
       
    57     static const int IapIdNone = -1;
       
    58 
       
    59     /*!
       
    60         WLAN connection status.
       
    61         Remember to update traces/trace.properties when modifying this enum.
       
    62     */        
       
    63     enum ConnStatus {
       
    64         ConnStatusNone = 0,         //!< Reserved.
       
    65         ConnStatusConnecting,       //!< Connecting.
       
    66         ConnStatusConnected,        //!< Connected.
       
    67         ConnStatusDisconnected      //!< Disconnected.
       
    68     };
    42     
    69     
    43     /**
       
    44      * Constructor.
       
    45      */
       
    46     WlanQtUtils();
    70     WlanQtUtils();
    47     
    71     
    48     /**
       
    49      * Destructor.
       
    50      */
       
    51     ~WlanQtUtils();
    72     ~WlanQtUtils();
    52 
    73 
    53     /**
    74     void scanWlans();
    54      * Function to request details of available WLAN networks. Can be called at any time, calling right
    75     
    55      * after wlanScanReady() signal ensures you get the most recent results.
    76     void scanWlanAps();
    56      *
    77    
    57      * @param[out] wlanIapList List of available WLAN IAPs.
    78     void scanWlanDirect(const QString &ssid);
    58      * @param[out] wlanApList List of unknown WLAN APs.
    79 
    59      */
    80     void stopWlanScan();
       
    81 
       
    82     void availableWlans(
       
    83         QList< QSharedPointer<WlanQtUtilsIap> > &wlanIapList,
       
    84         QList< QSharedPointer<WlanQtUtilsAp> > &wlanApList) const;
       
    85     
    60     void availableWlanAps(
    86     void availableWlanAps(
    61         QList<WlanQtUtilsWlanIap *> &wlanIapList,
    87         QList< QSharedPointer<WlanQtUtilsAp> > &wlanApList) const;
    62         QList<WlanQtUtilsWlanAp *> &wlanApList);
       
    63     
    88     
    64     /**
    89     int createIap(const WlanQtUtilsAp *wlanAp);
    65      * Function to create an IAP from the given WLAN access point.
       
    66      *
       
    67      * @param[in] wlanAp Access point containing parameters to include in the new IAP.
       
    68      * @return ID of the newly created IAP.
       
    69      */
       
    70     int createWlanIap(const WlanQtUtilsWlanAp *wlanAp);
       
    71 
    90 
    72     /**
    91     bool updateIap(int iapId, const WlanQtUtilsAp *wlanAp);
    73      * Function to start connection creation for the given IAP. connectionStatus() signal will be emitted
       
    74      * when connection creation succeeds or fails.
       
    75      *
       
    76      * @param[in] iapId ID of the IAP to be connected.
       
    77      */
       
    78     void connectIap(int iapId);
       
    79 
    92 
    80     /**
    93     void deleteIap(int iapId);
    81      * Function to disconnect the given IAP.
    94 
    82      * 
    95     void connectIap(int iapId, bool runIct = false);
    83      * @param[in] iapId ID of the IAP to be disconnected.
    96 
    84      */
       
    85     void disconnectIap(int iapId);
    97     void disconnectIap(int iapId);
    86 
    98 
    87     /**
    99     ConnStatus connectionStatus() const;
    88      * Function to retrieve a pointer to the IAP with the given ID.
       
    89      * 
       
    90      * @param[in] iapId ID of the requested IAP.
       
    91      * @return Pointer to the found IAP, NULL if not found.
       
    92      */
       
    93     WlanQtUtilsIap *iap(int iapId) const;
       
    94     
   100     
    95     /**
   101     int activeIap() const;
    96      * Function for getting the master WLAN status.
       
    97      * 
       
    98      * @return Master WLAN status: true if enabled, otherwise false.
       
    99      */
       
   100     bool masterWlan() const;
       
   101     
   102     
   102     /**
   103     QString iapName(int iapId) const;
   103      * Function for switching the master WLAN status ON or OFF.
   104 
   104      * 
   105 signals:
   105      * @param[in] enabled If set to true, WLAN is switched ON, and vice versa.
   106 
   106      */
   107     /*!
   107     void setMasterWlan(bool enabled);
   108         Signal indicating that WLAN scan results are available. 
       
   109     */
       
   110     void wlanScanReady();
   108     
   111     
   109     /**
   112     /*!
   110      * Function for getting the ID of the (possibly) connected WLAN IAP.
   113         Signal indicating that WLAN scan results are available when scanning
   111      * 
   114         is requested with scanWlanAps() method.
   112      * @return ID of the connected IAP, WlanQtUtilsInvalidIapId if not valid.
   115     */
   113      */
   116     void wlanScanApReady();
   114     int connectedWlanId() const;
   117     
       
   118     /*!
       
   119         Signal indicating that WLAN scan results are available when scanning
       
   120         is requested with scanWlanDirect() method.
       
   121     */
       
   122     void wlanScanDirectReady();
       
   123     
       
   124     /*!
       
   125         Signal indicating that new WLAN network has been opened. 
   115 
   126 
   116     /**
   127         @param [in] iapId ID of the opened IAP.
   117      * Function for requesting a WLAN scan to be triggered. Currently triggers
   128     */
   118      * only a single scan, but can be extended to perform also periodic scans,
   129     void wlanNetworkOpened(int iapId);
   119      * if needed in the future.
       
   120      * 
       
   121      * Signal wlanScanReady() is emitted when new scan results are available.
       
   122      */
       
   123     void scanWlans();
       
   124     
   130     
   125 signals:
   131     /*!
       
   132         Signal indicating that a WLAN network has been closed.
       
   133 
       
   134         @param [in] iapId ID of the closed IAP.
       
   135         @param [in] reason RConnection::Start() error code.
       
   136                            This is the reason of the closure if user requested
       
   137                            connection creation and it failed.
       
   138                            Otherwise KErrNone.
       
   139     */
       
   140     void wlanNetworkClosed(int iapId, int reason);
       
   141 
       
   142     /*!
       
   143         Signal indicating result of finished ICT run.
       
   144 
       
   145         @param [in] iapId ID of IAP ICT was run for.
       
   146         @param [in] result True: ICT passed, False: ICT failed.
       
   147     */
       
   148     void ictResult(int iapId, bool result);
   126     
   149     
   127     /**
   150 public slots:
   128      * Signal indicating that WLAN scan results are available. 
       
   129      */
       
   130     void wlanScanReady();
       
   131 
   151 
   132     /**
   152 protected:
   133      * Signal indicating that new WLAN network has been opened. 
       
   134      * 
       
   135      * @param[in] iapId ID of the opened IAP.
       
   136      */
       
   137     void wlanNetworkOpened(int iapId);
       
   138 
   153 
   139     /**
   154 protected slots:
   140      * Signal indicating that a WLAN network has been closed. 
       
   141      * 
       
   142      * @param[in] iapId ID of the closed IAP.
       
   143      */
       
   144     void wlanNetworkClosed(int iapId);
       
   145 
   155 
   146     /**
   156 private:
   147      * Signal indicating that the WLAN master status has changed.
   157 
   148      */
   158     Q_DISABLE_COPY(WlanQtUtils)
   149     void masterWlanStatus(bool enabled);
   159 
       
   160 private slots:
       
   161 
       
   162 private: // data
       
   163 
       
   164     //! Pointer to private implementation
       
   165     QScopedPointer<WlanQtUtilsPrivate> d_ptr;
       
   166 
       
   167     // Friend classes
   150     
   168     
   151 private: // Data
   169     // This is defined as a friend class in order to be able to emit public 
   152 
   170     // signals directly from private implementation code.
   153     /** Pointer to private implementation */
       
   154     WlanQtUtilsPrivate *d_ptr;
       
   155 
       
   156 private: // Friend classes
       
   157 
       
   158     // This is defined as a friend class in order to be able to emit public signals
       
   159     // directly from private implementation code.
       
   160     friend class WlanQtUtilsPrivate;
   171     friend class WlanQtUtilsPrivate;
   161 
   172 
   162     // This is defined as a friend class in order to be able to
   173     // This is defined as a friend class in order to be able to
   163     // call event handlers of wrappers from test code.
   174     // call event handlers of wrappers from test code.
   164     friend class TestWlanQtUtils;
   175     friend class TestWlanQtUtils;
   165 };
   176 };
   166 
   177 
   167 #endif /* WLANQTUTILS_H */
   178 #endif // WLANQTUTILS_H
   168 
       
   169 // End of File