wlanutilities/wlanqtutilities/base/inc/wlanqtutils_p.h
changeset 19 10810c91db26
child 31 e8f4211554fb
equal deleted inserted replaced
3:ff3b37722600 19:10810c91db26
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 */
       
    16 
       
    17 #ifndef WLANQTUTILS_P_H
       
    18 #define WLANQTUTILS_P_H
       
    19 
       
    20 #include <QObject>
       
    21 #include <QMap>
       
    22 
       
    23 #include "wlanqtutilscommon.h"
       
    24 
       
    25 class WlanQtUtils;
       
    26 class WlanQtUtilsIap;
       
    27 class WlanQtUtilsWlanIap;
       
    28 class WlanQtUtilsWlanAp;
       
    29 class WlanQtUtilsActiveConn;
       
    30 class ConMonWrapper;
       
    31 class CmmWrapper;
       
    32 class EsockWrapper;
       
    33 class ConnTestWrapper;
       
    34 
       
    35 /**
       
    36  * Private implementation of Wlan Qt Utilities.
       
    37  */
       
    38 class WlanQtUtilsPrivate : public QObject
       
    39 {
       
    40     Q_OBJECT
       
    41 
       
    42 public:
       
    43     
       
    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();
       
   127     
       
   128 private slots:
       
   129 
       
   130     /**
       
   131      * Slot for handling WLAN scan result event from wrapper. Results are stored in member variable
       
   132      * (possible duplicates are removed).
       
   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);
       
   144 
       
   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);
       
   152     
       
   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);
       
   159     
       
   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);
       
   166     
       
   167     /**
       
   168      * Slot for updating active connection status from wrapper.
       
   169      * 
       
   170      * @param[in] connectionId ID of the updated connection.
       
   171      * @param[in] connectionStatus New status of the connection.
       
   172      */
       
   173     void updateActiveConnection(uint connectionId, WlanQtUtilsConnectionStatus connectionStatus);
       
   174     
       
   175 private: 
       
   176 
       
   177     int fetchIaps();
       
   178     
       
   179     /**
       
   180      * This function searches for a WLAN IAP with the given WLAN parameters.
       
   181      *  
       
   182      * @param[in] ssid SSID to search for.
       
   183      * @param[in] secMode Security mode to search for.
       
   184      * @return True, if suitable WLAN IAP found, false otherwise.
       
   185      */
       
   186     bool wlanIapExists(QString ssid, WlanQtUtilsWlanSecMode secMode);
       
   187 
       
   188     /**
       
   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     
       
   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
       
   233     // call event handlers of wrappers from test code.
       
   234     friend class TestWlanQtUtils;
       
   235 };
       
   236 
       
   237 #endif /* WLANQTUTILS_P_H */
       
   238 
       
   239 // End of File