wlanutilities/wlanqtutilities/tsrc/stubs/stub_wlanmgmtclient.cpp
changeset 56 de27cc8389dd
parent 46 2fbd1d709fe7
child 58 301aeb18ae47
equal deleted inserted replaced
50:d4198dcb9983 56:de27cc8389dd
    18 #include <e32std.h>
    18 #include <e32std.h>
    19 #include <e32base.h>
    19 #include <e32base.h>
    20 #include "wlanmgmtclient.h"
    20 #include "wlanmgmtclient.h"
    21 
    21 
    22 #include "wlanqtutilstestcontext.h"
    22 #include "wlanqtutilstestcontext.h"
       
    23 #include "wlanqtutilsiap.h"
    23 
    24 
    24 extern WlanQtUtilsTestContext testContext;
    25 extern WlanQtUtilsTestContext testContext;
    25 
    26 
    26 // Request status for canceling stubbed async request
    27 // Request status for canceling stubbed GetScanResults async request
    27 static TRequestStatus* iStubRequestStatus = 0;
    28 static TRequestStatus* iGetScanResultsStatus = 0;
       
    29 
       
    30 // Request status for canceling stubbed GetAvailableIaps async request
       
    31 static TRequestStatus* iGetAvailableIapsStatus = 0;
    28 
    32 
    29 // ---------------------------------------------------------
    33 // ---------------------------------------------------------
    30 // CWlanScanRequest::NewL
    34 // CWlanMgmtClient::NewL
    31 // ---------------------------------------------------------
    35 // ---------------------------------------------------------
    32 //
    36 //
    33 CWlanMgmtClient* CWlanMgmtClient::NewL()
    37 CWlanMgmtClient* CWlanMgmtClient::NewL()
    34     {
    38     {
    35     CWlanMgmtClient* self = new CWlanMgmtClient;
    39     CWlanMgmtClient* self = new CWlanMgmtClient;
    36     return self;
    40     return self;
    37     }
    41     }
    38     
    42     
    39 // ---------------------------------------------------------
    43 // ---------------------------------------------------------
    40 // CWlanScanRequest::~CWlanMgmtClient
    44 // CWlanMgmtClient::~CWlanMgmtClient
    41 // ---------------------------------------------------------
    45 // ---------------------------------------------------------
    42 //
    46 //
    43 CWlanMgmtClient::~CWlanMgmtClient()
    47 CWlanMgmtClient::~CWlanMgmtClient()
    44     {
    48     {
    45     }
    49     }
    46 
    50 
    47 // ---------------------------------------------------------
    51 // ---------------------------------------------------------
    48 // CWlanScanRequest::CWlanMgmtClient
    52 // CWlanMgmtClient::CWlanMgmtClient
    49 // ---------------------------------------------------------
    53 // ---------------------------------------------------------
    50 //
    54 //
    51 CWlanMgmtClient::CWlanMgmtClient()
    55 CWlanMgmtClient::CWlanMgmtClient()
    52     {
    56     {
    53     }
    57     }
    54 
    58 
    55 // ---------------------------------------------------------
    59 // ---------------------------------------------------------
    56 // CWlanScanRequest::GetScanResults
    60 // CWlanMgmtClient::GetScanResults
    57 // ---------------------------------------------------------
    61 // ---------------------------------------------------------
    58 //
    62 //
    59 void CWlanMgmtClient::GetScanResults(
    63 void CWlanMgmtClient::GetScanResults(
    60     TRequestStatus& aStatus,
    64     TRequestStatus& aStatus,
    61     CWlanScanInfo& aResults )
    65     CWlanScanInfo& aResults )
    62     {
    66     {
    63     if (testContext.mScan.mCompleteWlanScan) {
    67     (void)aResults;
       
    68     
       
    69     if (testContext.mScan.mCompleteWlanApScan) {
    64         // Complete the request immediately
    70         // Complete the request immediately
    65         TRequestStatus *status = &aStatus;
    71         TRequestStatus *status = &aStatus;
    66         User::RequestComplete(
    72         User::RequestComplete(
    67             status,
    73             status,
    68             testContext.mScan.mScanRetValue);
    74             testContext.mScan.mApScanRetValue);
    69     } else {
    75     } else {
    70         iStubRequestStatus = &aStatus;
    76         iGetScanResultsStatus = &aStatus;
    71     }
    77     }
    72     
    78     
    73     // Results are returned when asked per AP
    79     // Results are returned when asked per AP
    74     (void)aResults;
       
    75     }
    80     }
    76 
    81 
    77 // ---------------------------------------------------------
    82 // ---------------------------------------------------------
    78 // CWlanScanRequest::GetScanResults
    83 // CWlanMgmtClient::GetScanResults
    79 // ---------------------------------------------------------
    84 // ---------------------------------------------------------
    80 //
    85 //
    81 void CWlanMgmtClient::GetScanResults(
    86 void CWlanMgmtClient::GetScanResults(
    82     TWlanSsid& aSsid,
    87     TWlanSsid& aSsid,
    83     TRequestStatus& aStatus,
    88     TRequestStatus& aStatus,
    84     CWlanScanInfo& aResults )
    89     CWlanScanInfo& aResults )
    85     {
    90     {
    86     if (testContext.mScan.mCompleteWlanScan) {
    91     (void)aSsid;
       
    92     (void)aResults;
       
    93 
       
    94     if (testContext.mScan.mCompleteWlanApScan) {
    87         // Complete the request immediately
    95         // Complete the request immediately
    88         TRequestStatus *status = &aStatus;
    96         TRequestStatus *status = &aStatus;
    89         User::RequestComplete(
    97         User::RequestComplete(
    90             status,
    98             status,
    91             testContext.mScan.mScanRetValue);
    99             testContext.mScan.mApScanRetValue);
    92     } else {
   100     } else {
    93         iStubRequestStatus = &aStatus;
   101         iGetScanResultsStatus = &aStatus;
    94     }
   102     }
    95     
   103     
    96     // Results are returned when asked per AP
   104     // Results are returned when asked per AP
    97     (void)aSsid;
       
    98     (void)aResults;
       
    99     }
   105     }
   100 
   106 
   101 // ---------------------------------------------------------
   107 // ---------------------------------------------------------
   102 // CWlanScanRequest::CancelGetScanResults
   108 // CWlanMgmtClient::CancelGetScanResults
   103 // ---------------------------------------------------------
   109 // ---------------------------------------------------------
   104 //
   110 //
   105 void CWlanMgmtClient::CancelGetScanResults()
   111 void CWlanMgmtClient::CancelGetScanResults()
   106     {
   112     {
   107     User::RequestComplete(iStubRequestStatus, KErrCancel);
   113     if (iGetScanResultsStatus) {
   108     iStubRequestStatus = 0;
   114         User::RequestComplete(iGetScanResultsStatus, KErrCancel);
       
   115         iGetScanResultsStatus = NULL;
   109     }
   116     }
       
   117     }
       
   118 
       
   119 // ---------------------------------------------------------
       
   120 // CWlanMgmtClient::GetAvailableIaps
       
   121 // ---------------------------------------------------------
       
   122 //
       
   123 void CWlanMgmtClient::GetAvailableIaps(
       
   124     TInt& aCacheLifetime,
       
   125     TUint& aMaxDelay,
       
   126     TBool aFilteredResults,
       
   127     TRequestStatus& aStatus,
       
   128     RArray<TWlanIapAvailabilityData>& aAvailableIaps )
       
   129     {
       
   130     (void)aCacheLifetime;
       
   131     (void)aMaxDelay;
       
   132     (void)aFilteredResults;
       
   133     (void)aAvailableIaps;
       
   134 
       
   135     if (testContext.mScan.mCompleteWlanIapScan) {
       
   136         // Form results as defined in context
       
   137         aAvailableIaps.Reset();
       
   138         for (int i=0; i < testContext.mScan.mWlanScanIapResultList.count(); i++) {
       
   139             QSharedPointer<WlanQtUtilsIap> iap(testContext.mScan.mWlanScanIapResultList[i]);
       
   140             TWlanIapAvailabilityData data;
       
   141             data.iIapId = (TUint)iap->value(WlanQtUtilsIap::ConfIdIapId).toInt();
       
   142             data.iRssi = (TUint)iap->value(WlanQtUtilsAp::ConfIdSignalStrength).toInt();
       
   143             aAvailableIaps.AppendL(data);
       
   144         }
       
   145         
       
   146         // Complete the request immediately
       
   147         TRequestStatus *status = &aStatus;
       
   148         User::RequestComplete(
       
   149             status,
       
   150             testContext.mScan.mIapScanRetValue);
       
   151     } else {
       
   152         iGetAvailableIapsStatus = &aStatus;
       
   153     }
       
   154     }
       
   155 
       
   156 // ---------------------------------------------------------
       
   157 // CWlanMgmtClient::CancelGetAvailableIaps
       
   158 // ---------------------------------------------------------
       
   159 //
       
   160 void CWlanMgmtClient::CancelGetAvailableIaps()
       
   161     {
       
   162     if (iGetAvailableIapsStatus) {
       
   163         User::RequestComplete(iGetAvailableIapsStatus, KErrCancel);
       
   164         iGetAvailableIapsStatus = 0;
       
   165     }
       
   166     }