wlanutilities/wlanqtutilities/base/inc/wlanqtutils_p.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 private implementation interface.
    15 */
    16 */
    16 
    17 
    17 #ifndef WLANQTUTILS_P_H
    18 #ifndef WLANQTUTILS_P_H
    18 #define WLANQTUTILS_P_H
    19 #define WLANQTUTILS_P_H
    19 
    20 
       
    21 // System includes
       
    22 
    20 #include <QObject>
    23 #include <QObject>
    21 #include <QMap>
    24 #include <QSharedPointer>
       
    25 #include <QList>
    22 
    26 
    23 #include "wlanqtutilscommon.h"
    27 // User includes
       
    28 
       
    29 #include "wlanqtutils.h"
       
    30 
       
    31 // Forward declarations
    24 
    32 
    25 class WlanQtUtils;
    33 class WlanQtUtils;
    26 class WlanQtUtilsIap;
    34 class WlanQtUtilsIap;
    27 class WlanQtUtilsWlanIap;
    35 class WlanQtUtilsAp;
    28 class WlanQtUtilsWlanAp;
    36 class WlanQtUtilsConnection;
    29 class WlanQtUtilsActiveConn;
    37 class WlanQtUtilsIapSettings;
    30 class ConMonWrapper;
    38 class WlanQtUtilsConMonWrapper;
    31 class CmmWrapper;
    39 class WlanQtUtilsEsockWrapper;
    32 class EsockWrapper;
       
    33 class ConnTestWrapper;
    40 class ConnTestWrapper;
    34 
    41 
    35 /**
    42 // External data types
    36  * Private implementation of Wlan Qt Utilities.
    43 
    37  */
    44 // Constants
       
    45 
       
    46 // Class declaration
       
    47 
    38 class WlanQtUtilsPrivate : public QObject
    48 class WlanQtUtilsPrivate : public QObject
    39 {
    49 {
    40     Q_OBJECT
    50     Q_OBJECT
    41 
    51 
    42 public:
    52 public:
       
    53 
       
    54     // Data types
       
    55 
       
    56     explicit WlanQtUtilsPrivate(WlanQtUtils *q_ptr);
       
    57 
       
    58     virtual ~WlanQtUtilsPrivate();
    43     
    59     
    44     /**
       
    45      * Constructor.
       
    46      */
       
    47     WlanQtUtilsPrivate(WlanQtUtils *publicPtr);
       
    48     
       
    49     /**
       
    50      * Destructor.
       
    51      */
       
    52     ~WlanQtUtilsPrivate();
       
    53 
       
    54     // Functions duplicating WlanQtUtils public interface
       
    55     
       
    56     /**
       
    57      * Function to request details of available WLAN networks. Can be called at any time, calling right
       
    58      * after wlanScanReady() signal ensures you get the most recent results.
       
    59      *
       
    60      * @param[out] wlanIapList List of available WLAN IAPs.
       
    61      * @param[out] wlanApList List of unknown WLAN APs.
       
    62      */
       
    63     void availableWlanAps(
       
    64         QList<WlanQtUtilsWlanIap *> &wlanIapList,
       
    65         QList<WlanQtUtilsWlanAp *> &wlanApList);
       
    66 
       
    67     /**
       
    68      * Function to create an IAP from the given WLAN access point.
       
    69      *
       
    70      * @param[in] wlanAp Access point containing parameters to include in the new IAP.
       
    71      * @return ID of the newly created IAP.
       
    72      */
       
    73     int createWlanIap(const WlanQtUtilsWlanAp *wlanAp);
       
    74 
       
    75     /**
       
    76      * Function to start connection creation for the given IAP. connectionStatus() signal will be emitted
       
    77      * when connection creation succeeds or fails.
       
    78      *
       
    79      * @param[in] iapId ID of the IAP to be connected.
       
    80      */
       
    81     void connectIap(int iapId);
       
    82     
       
    83     /**
       
    84      * Function to disconnect the given IAP.
       
    85      * 
       
    86      * @param[in] iapId ID of the IAP to be disconnected.
       
    87      */
       
    88     void disconnectIap(int iapId);
       
    89     
       
    90     /**
       
    91      * Function to retrieve a pointer to the IAP with the given ID.
       
    92      * 
       
    93      * @param[in] iapId ID of the requested IAP.
       
    94      * @return Pointer to the found IAP, NULL if not found.
       
    95      */
       
    96     WlanQtUtilsIap *iap(int iapId) const;
       
    97 
       
    98     /**
       
    99      * Function for getting the master WLAN status.
       
   100      * 
       
   101      * @return Master WLAN status: true if enabled, otherwise false.
       
   102      */
       
   103     bool masterWlan() const;
       
   104     
       
   105     /**
       
   106      * Function for switching the master WLAN status ON or OFF.
       
   107      * 
       
   108      * @param[in] enabled If set to true, WLAN is switched ON, and vice versa.
       
   109      */
       
   110     void setMasterWlan(bool enabled);
       
   111 
       
   112     /**
       
   113      * Function for getting the ID of the (possibly) connected WLAN IAP.
       
   114      * 
       
   115      * @return ID of the connected IAP, WlanQtUtilsInvalidIapId if not valid.
       
   116      */
       
   117     int connectedWlanId() const;
       
   118     
       
   119     /**
       
   120      * Function for requesting a WLAN scan to be triggered. Currently triggers
       
   121      * only a single scan, but can be extended to perform also periodic scans,
       
   122      * if needed in the future.
       
   123      * 
       
   124      * Signal wlanScanReady() is emitted when new scan results are available.
       
   125      */
       
   126     void scanWlans();
    60     void scanWlans();
   127     
    61     
       
    62     void scanWlanAps();
       
    63     
       
    64     void scanWlanDirect(const QString &ssid);
       
    65 
       
    66     void stopWlanScan();
       
    67 
       
    68     void availableWlans(
       
    69         QList< QSharedPointer<WlanQtUtilsIap> > &wlanIapList,
       
    70         QList< QSharedPointer<WlanQtUtilsAp> > &wlanApList) const;
       
    71 
       
    72     void availableWlanAps(
       
    73         QList< QSharedPointer<WlanQtUtilsAp> > &wlanApList) const;  
       
    74 
       
    75     int createIap(const WlanQtUtilsAp *wlanAp);
       
    76 
       
    77     bool updateIap(int iapId, const WlanQtUtilsAp *wlanAp);
       
    78 
       
    79     void deleteIap(int iapId);
       
    80 
       
    81     void connectIap(int iapId, bool runIct);
       
    82 
       
    83     void disconnectIap(int iapId);
       
    84 
       
    85     WlanQtUtils::ConnStatus connectionStatus() const;
       
    86 
       
    87     int activeIap() const;
       
    88 
       
    89     QString iapName(int iapId) const;
       
    90 
       
    91 signals:
       
    92 
       
    93 public slots:
       
    94 
       
    95 protected:
       
    96 
       
    97 protected slots:
       
    98 
       
    99 private:
       
   100 
       
   101     Q_DISABLE_COPY(WlanQtUtilsPrivate)
       
   102 
       
   103     bool wlanIapExists(
       
   104         const QList< QSharedPointer<WlanQtUtilsIap> > list,
       
   105         const WlanQtUtilsAp *ap) const;
       
   106     
       
   107     void traceIapsAndAps(
       
   108         const QList< QSharedPointer<WlanQtUtilsIap> > &iaps,
       
   109         const QList< QSharedPointer<WlanQtUtilsAp> > &aps) const;
       
   110 
   128 private slots:
   111 private slots:
   129 
   112 
   130     /**
   113     void updateAvailableWlanAps(
   131      * Slot for handling WLAN scan result event from wrapper. Results are stored in member variable
   114         QList< QSharedPointer<WlanQtUtilsAp> > &availableWlans);
   132      * (possible duplicates are removed).
   115     
   133      * 
       
   134      * @param[in] availableWlans WLAN networks found in scan.
       
   135      */
       
   136     void updateAvailableWlanAps(QList<WlanQtUtilsWlanAp *> &availableWlans);
       
   137 
       
   138     /**
       
   139      * Slot for handling connection setup status event from wrapper.
       
   140      * 
       
   141      * @param[in] isOpened Was connection setup successful?
       
   142      */
       
   143     void updateConnectionStatus(bool isOpened);
   116     void updateConnectionStatus(bool isOpened);
   144 
   117     
   145     /**
       
   146      * Slot for handling connectivity test result event from wrapper. Tested IAP is stored to
       
   147      * Internet SNAP, if test was successful.
       
   148      * 
       
   149      * @param[in] result Was the test successful?
       
   150      */
       
   151     void updateConnectivityTestResult(bool result);
   118     void updateConnectivityTestResult(bool result);
   152     
   119     
   153     /**
       
   154      * Slot for updating active connection status from wrapper.
       
   155      * 
       
   156      * @param[in] connectionId ID of the new connection.
       
   157      */
       
   158     void addActiveConnection(uint connectionId);
   120     void addActiveConnection(uint connectionId);
   159     
   121     
   160     /**
       
   161      * Slot for updating active connection status from wrapper.
       
   162      * 
       
   163      * @param[in] connectionId ID of the deleted connection.
       
   164      */
       
   165     void removeActiveConnection(uint connectionId);
   122     void removeActiveConnection(uint connectionId);
   166     
   123     
   167     /**
   124     void updateActiveConnection(
   168      * Slot for updating active connection status from wrapper.
   125         uint connectionId,
   169      * 
   126         WlanQtUtils::ConnStatus connectionStatus);
   170      * @param[in] connectionId ID of the updated connection.
   127 
   171      * @param[in] connectionStatus New status of the connection.
   128 private: // data
   172      */
   129 
   173     void updateActiveConnection(uint connectionId, WlanQtUtilsConnectionStatus connectionStatus);
   130     // Not owned data
       
   131 
       
   132     //! Pointer to public implementation.
       
   133     WlanQtUtils *q_ptr;
       
   134 
       
   135     // Owned data
       
   136 
       
   137     //! Iap settings handler.
       
   138     WlanQtUtilsIapSettings *mSettings;
   174     
   139     
   175 private: 
   140     //! Wrapper object for Connection Monitor and other parts of connmon library.
       
   141     WlanQtUtilsConMonWrapper *mConMonWrapper;
       
   142     
       
   143     //! Wrapper object for esock library.
       
   144     WlanQtUtilsEsockWrapper *mEsockWrapper;
   176 
   145 
   177     int fetchIaps();
   146     //! Wrapper object for Internet Connectivity Test library.
       
   147     ConnTestWrapper *mConnTestWrapper;
       
   148 
       
   149     //! List of available WLAN APs according to the latest scan.
       
   150     QList< QSharedPointer<WlanQtUtilsAp> > mWlanScanList;
       
   151 
       
   152     //! ID of IAP requiring ICT running, IapIdNone if not valid.
       
   153     int mToBeTestedIapId;
   178     
   154     
   179     /**
   155     //! ID of IAP being connected by us (requested by UI), IapIdNone if not valid.
   180      * This function searches for a WLAN IAP with the given WLAN parameters.
   156     int mConnectingIapId;
   181      *  
   157     
   182      * @param[in] ssid SSID to search for.
   158     //! Information of possible active connection.
   183      * @param[in] secMode Security mode to search for.
   159     QSharedPointer<WlanQtUtilsConnection> mConnection;
   184      * @return True, if suitable WLAN IAP found, false otherwise.
       
   185      */
       
   186     bool wlanIapExists(QString ssid, WlanQtUtilsWlanSecMode secMode);
       
   187 
   160 
   188     /**
   161     // Friend classes
   189      * This function updates the connection status of:
       
   190      * - IAP with the given ID
       
   191      * - all other IAPs, which represent the same network (SSID & security mode match)
       
   192      *  
       
   193      * @param[in] iapId ID of the IAP whose status is to be updated.
       
   194      * @param[in] status Updated connection status.
       
   195      */
       
   196     void updateIapConnectionStatuses(int iapId, WlanQtUtilsConnectionStatus status);
       
   197 
       
   198 private: // Data
       
   199     
   162     
   200     /** Pointer to public implementation */
       
   201     WlanQtUtils *q_ptr;
       
   202     
       
   203     /** Wrapper object for Connection Method Manager. */
       
   204     CmmWrapper *cmmWrapper_;
       
   205     
       
   206     /** Wrapper object for Connection Monitor and other parts of connmon library. */
       
   207     ConMonWrapper *conMonWrapper_;
       
   208     
       
   209     /** Wrapper object for esock library. */
       
   210     EsockWrapper *esockWrapper_;
       
   211 
       
   212     /** Wrapper object for Internet Connectivity Test library. */
       
   213     ConnTestWrapper *connTestWrapper_;
       
   214 
       
   215     /** List of available WLAN APs according to the latest scan. */
       
   216     QList<WlanQtUtilsWlanAp *> wlanScanList_;
       
   217     
       
   218     /** List of WLAN IAPs configured to the device. */
       
   219     QMap<int, WlanQtUtilsWlanIap *> wlanIapList_;
       
   220     
       
   221     /** ID of IAP requiring ICT running, -1 if not valid. */
       
   222     int toBeTestedIapId_;
       
   223     
       
   224     /** ID of IAP being connected by us (requested by UI), -1 if not valid. */
       
   225     int connectingIapId_;
       
   226     
       
   227     /** Information of possible active connection. */
       
   228     WlanQtUtilsActiveConn *activeConnection_;
       
   229     
       
   230 private: // Friend classes
       
   231 
       
   232     // This is defined as a friend class in order to be able to
   163     // This is defined as a friend class in order to be able to
   233     // call event handlers of wrappers from test code.
   164     // call event handlers of wrappers from test code.
   234     friend class TestWlanQtUtils;
   165     friend class TestWlanQtUtils;
   235 };
   166 };
   236 
   167 
   237 #endif /* WLANQTUTILS_P_H */
   168 #endif // WLANQTUTILS_P_H
   238 
       
   239 // End of File