wlanutilities/wlanqtutilities/tsrc/stubs/wlanqtutilsconnmonstub.cpp
changeset 46 2fbd1d709fe7
parent 45 d9ec2b8c6bad
child 47 b3d8f88532b7
child 50 d4198dcb9983
equal deleted inserted replaced
45:d9ec2b8c6bad 46:2fbd1d709fe7
     1 /*
       
     2 * Copyright (c) 2009-2010 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 * This is a source file for connmon library stub functions
       
    16 */
       
    17 
       
    18 #include <QString>
       
    19 #include <QObject>
       
    20 #include <QVariant>
       
    21 #include <rconnmon.h>
       
    22 #include <nifvar.h>
       
    23 #include <cmmanager_shim.h>
       
    24 
       
    25 #include "wlanqtutilsap.h"
       
    26 
       
    27 #ifdef __WINS__
       
    28 
       
    29 // TODO: This function is copied from ConnMonWLANNetworksArrayPckg_v2.cpp because this
       
    30 // function, although being in rconnmon.h, is not in the interface because IMPORT_C/EXPORT_C
       
    31 // declarations are not used for this particular constructor. The only change that was made to 
       
    32 // this version was to remove traces and some empty lines. This function is needed when
       
    33 // creating output in RConnectionMonitor::GetPckgAttribute() for WLAN scan results.
       
    34 // This is needed for both UT and emulator compilation.
       
    35 CConnMonWlanNetworksPtrArrayPckg::CConnMonWlanNetworksPtrArrayPckg(
       
    36     const RPointerArray<CConnMonWlanNetwork>& aRef,
       
    37     TUint aBufLen )
       
    38     {
       
    39     RPointerArray<HBufC> items;
       
    40     TUint len( 0 );
       
    41 
       
    42     for ( TUint i( 0 ); i < aRef.Count(); ++i )
       
    43         {
       
    44         const HBufC* item( aRef[i]->ToBuf() );
       
    45         if ( item )
       
    46             {
       
    47             // Is there room in buffer
       
    48             TUint countFields( 3 ); // aRef.Count(); items->Count(); item->Length()
       
    49             if ( (countFields + len + item->Length()) > aBufLen )
       
    50                 {
       
    51                 delete item;
       
    52                 item = NULL;
       
    53                 break;
       
    54                 }
       
    55             items.Append( item );
       
    56             ++( len += item->Length() ); // ++ is for item's size
       
    57             }
       
    58         else
       
    59             {
       
    60             ; // There was a trace.
       
    61             }
       
    62         }
       
    63     // Check that given buflen (aBufLen) is not smaller than one
       
    64     // item (TConnMonWLANNetwork) + aRef count + items count
       
    65     // + item length
       
    66     if ( items.Count() == 0 && aRef.Count() > 0 )
       
    67         {
       
    68         aBufLen = 2; // aRef.Count(), items.Count()
       
    69         }
       
    70 
       
    71     iBuf = HBufC::New( aBufLen ); // Set size exactly to a buffer length
       
    72     if ( !iBuf )
       
    73         {
       
    74         items.ResetAndDestroy();
       
    75         items.Close();
       
    76         return;
       
    77         }
       
    78     iBuf->Des().Append( aRef.Count() ); // Total amount of data
       
    79     iBuf->Des().Append( items.Count() );  // Amount of transferring data
       
    80     for ( TUint i(0); i<items.Count(); ++i )
       
    81         {
       
    82         iBuf->Des().Append( items[i]->Length() );
       
    83         iBuf->Des().Append( *items[i] );
       
    84         }
       
    85     items.ResetAndDestroy();
       
    86     items.Close();
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CConnMonEventBase::CConnMonEventBase
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 CConnMonEventBase::CConnMonEventBase( const TInt aEventType, const TUint aConnectionId )
       
    94     {
       
    95     iEventType = aEventType;
       
    96     iConnectionId = aConnectionId;
       
    97     }
       
    98 
       
    99 // Destructor
       
   100 CConnMonEventBase::~CConnMonEventBase()
       
   101     {
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // CConnMonEventBase::EventType
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 TInt CConnMonEventBase::EventType() const
       
   109     {
       
   110     return iEventType;
       
   111     }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CConnMonConnectionStatusChange::CConnMonConnectionStatusChange
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 CConnMonConnectionStatusChange::CConnMonConnectionStatusChange(
       
   118     const TUint aConnectionId,
       
   119     const TUint aSubConnectionId,
       
   120     const TInt aConnectionStatus ) :
       
   121     CConnMonEventBase(EConnMonConnectionStatusChange, aConnectionId)
       
   122     {
       
   123     iSubConnectionId = aSubConnectionId;
       
   124     iConnectionStatus = aConnectionStatus;
       
   125     }
       
   126 
       
   127 // Destructor
       
   128 CConnMonConnectionStatusChange::~CConnMonConnectionStatusChange()
       
   129     {
       
   130     }
       
   131 
       
   132 #ifdef WLANQTUTILS_T_WLANQTUTILS_UT_FLAG
       
   133 
       
   134 // ----------------------------------------------
       
   135 // Stub functions for connmon library, used in UT
       
   136 // ----------------------------------------------
       
   137 
       
   138 #include "wlanqtutilstestcontext.h"
       
   139 
       
   140 extern WlanQtUtilsTestContext testContext;
       
   141 
       
   142 // Request status for canceling stubbed async request
       
   143 TRequestStatus* iStubRequestStatus = 0;
       
   144 
       
   145 EXPORT_C void RConnectionMonitor::CancelAsyncRequest(
       
   146     TInt aReqToCancel)
       
   147 {
       
   148     (void)aReqToCancel;
       
   149     User::RequestComplete(iStubRequestStatus, KErrCancel);
       
   150     iStubRequestStatus = 0;
       
   151 }
       
   152 
       
   153 EXPORT_C void RConnectionMonitor::GetConnectionCount(
       
   154     TUint& aConnectionCount,
       
   155     TRequestStatus& aStatus)
       
   156 {
       
   157     aConnectionCount = testContext.connMon_.activeConnections_.activeConnList_.count();
       
   158     User::RequestComplete(&aStatus, KErrNone);
       
   159 }
       
   160 
       
   161 EXPORT_C TInt RConnectionMonitor::GetConnectionInfo(
       
   162         const TUint aIndex,
       
   163         TUint& aConnectionId,
       
   164         TUint& aSubConnectionCount ) const
       
   165 {
       
   166     aConnectionId = testContext.connMon_.activeConnections_.activeConnList_[aIndex - 1]->connectionId();
       
   167     aSubConnectionCount = 0;
       
   168     return KErrNone; // TODO: put return value into context.
       
   169 }
       
   170 
       
   171 EXPORT_C void RConnectionMonitor::GetIntAttribute(
       
   172         const TUint aConnectionId,
       
   173         const TUint /* aSubConnectionId */,
       
   174         const TUint aAttribute,
       
   175         TInt& aValue,
       
   176         TRequestStatus& aStatus )
       
   177 {
       
   178     WlanQtUtilsCtxActiveConn *activeConn = testContext.connMon_.activeConnections_.findActiveConn(aConnectionId);
       
   179     if (aAttribute == KBearer) {
       
   180         aValue = activeConn->connMonBearerType_;
       
   181     } else if (aAttribute == KConnectionStatus) {
       
   182         aValue = activeConn->connMonConnectionStatus_;
       
   183     } else {
       
   184         Q_ASSERT(false);
       
   185     }
       
   186     User::RequestComplete(&aStatus, KErrNone); // TODO: Take return value from the context.
       
   187 }
       
   188 
       
   189 EXPORT_C void RConnectionMonitor::GetUintAttribute(
       
   190         const TUint aConnectionId,
       
   191         const TUint /* aSubConnectionId */,
       
   192         const TUint aAttribute,
       
   193         TUint& aValue,
       
   194         TRequestStatus& aStatus )
       
   195 {
       
   196     WlanQtUtilsCtxActiveConn *activeConn = testContext.connMon_.activeConnections_.findActiveConn(aConnectionId);
       
   197     if (aAttribute == KIAPId) {
       
   198         aValue = activeConn->iapId();
       
   199     } else {
       
   200         Q_ASSERT(false);
       
   201     }
       
   202 
       
   203     User::RequestComplete(&aStatus, KErrNone); // TODO: Take return value from the context.
       
   204 }
       
   205 
       
   206 EXPORT_C void RConnectionMonitor::GetPckgAttribute(
       
   207     const TUint aConnectionId,
       
   208     const TUint aSubConnectionId,
       
   209     const TUint aAttribute,
       
   210     TDes8& aValue,
       
   211     TRequestStatus& aStatus ) const
       
   212 {
       
   213     // This is copy-paste from real implementation and we'll use that for other requests.
       
   214     TIpcArgs args(aConnectionId, aSubConnectionId, aAttribute, &aValue);
       
   215     SendReceive(EReqGetPckgAttribute, args, aStatus);
       
   216 }
       
   217 
       
   218 // ---------------------------------------------------------
       
   219 // connUtils2ConnMonSecModeMap()
       
   220 // Local function to map WlanQtUtilsWlanSecMode into Connection
       
   221 // monitor's security mode. Currently for UT use only.
       
   222 // ---------------------------------------------------------
       
   223 //
       
   224 static TUint connUtils2ConnMonSecModeMap(int connUtilsWlanSecMode, bool pskUse)
       
   225 {
       
   226     TUint ret;
       
   227     switch (connUtilsWlanSecMode) {
       
   228     case CMManagerShim::WlanSecModeWep:
       
   229         ret = EConnMonSecurityV2WepOpen;
       
   230         break;
       
   231     case CMManagerShim::WlanSecMode802_1x:
       
   232         ret = EConnMonSecurityV2802d1x;        
       
   233         break;
       
   234     case CMManagerShim::WlanSecModeWpa:
       
   235         if (pskUse) {
       
   236             ret = EConnMonSecurityV2WpaPsk;
       
   237         } else {
       
   238             ret = EConnMonSecurityV2Wpa;            
       
   239         }
       
   240         break;
       
   241     case CMManagerShim::WlanSecModeWpa2:
       
   242         if (pskUse) {
       
   243             ret = EConnMonSecurityV2Wpa2Psk;
       
   244         } else {
       
   245             ret = EConnMonSecurityV2Wpa2;            
       
   246         }
       
   247         break;
       
   248     case CMManagerShim::WlanSecModeWapi:
       
   249         if (pskUse) {
       
   250             ret = EConnMonSecurityV2WapiPsk;
       
   251         } else {
       
   252             ret = EConnMonSecurityV2Wapi;            
       
   253         }
       
   254         break;
       
   255     default:
       
   256         ret = EConnMonSecurityV2Open;
       
   257         break;
       
   258     }
       
   259     return ret;
       
   260 }
       
   261 
       
   262 
       
   263 // ---------------------------------------------------------
       
   264 // connUtils2ConnMonConModeMap()
       
   265 // ---------------------------------------------------------
       
   266 //
       
   267 static TUint connUtils2ConnMonConModeMap(int connUtilsWlanConMode)
       
   268 {
       
   269     TUint ret;
       
   270     switch (connUtilsWlanConMode) {
       
   271     case CMManagerShim::Adhoc:
       
   272         ret = EConnMonAdHoc;
       
   273         break;
       
   274     case CMManagerShim::Infra:
       
   275         ret = EConnMonInfraStructure;        
       
   276         break;
       
   277     }
       
   278     return ret;
       
   279 }
       
   280 
       
   281 
       
   282 EXPORT_C void RConnectionMonitor::GetPckgAttribute(
       
   283     const TUint /* aConnectionId */,
       
   284     const TUint /* aSubConnectionId */,
       
   285     const TUint /* aAttribute */,
       
   286     TDes16& aValue,
       
   287     TRequestStatus& aStatus ) const
       
   288     {
       
   289     // TODO: verify input parameters, i.e., first three params...
       
   290     
       
   291     RConnMonWlanNetworksPtrArray wlanPtrArray;
       
   292     RBuf vendorData;
       
   293 
       
   294     for (int i = 0; i < testContext.connMon_.wlanScanResult_.wlanScanResultList_.count(); i++) {
       
   295         WlanQtUtilsAp* ap = testContext.connMon_.wlanScanResult_.wlanScanResultList_[i];
       
   296         TBufC<CConnMonWlanNetwork::KMaxNameLength> name(ap->value(WlanQtUtilsAp::ConfIdSsid).toString().utf16());
       
   297 
       
   298         TBufC<CConnMonWlanNetwork::KWlanBssId> bssid16(QString("addMAC").utf16());
       
   299         TBuf8<CConnMonWlanNetwork::KWlanBssId> bssid;
       
   300         bssid.Copy(bssid16);
       
   301         
       
   302         CConnMonWlanNetwork* wlanAp = CConnMonWlanNetwork::NewL(
       
   303             name,
       
   304             connUtils2ConnMonConModeMap(ap->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt()),
       
   305             ap->value(WlanQtUtilsAp::ConfIdSignalStrength).toInt(),
       
   306             0, // old security mode not used anymore
       
   307             connUtils2ConnMonSecModeMap(
       
   308                 ap->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(),
       
   309                 ap->value(WlanQtUtilsAp::ConfIdWpaPskUse).toBool()),
       
   310             0,
       
   311             bssid,
       
   312             vendorData );
       
   313         wlanPtrArray.Append(wlanAp);
       
   314     }
       
   315 
       
   316     CConnMonWlanNetworksPtrArrayPckg wlanBuf(wlanPtrArray, 2560);
       
   317     aValue.Copy(wlanBuf.Buf()->Des());
       
   318 
       
   319     if (testContext.connMon_.wlanScanResult_.completeWlanScan_) {
       
   320         User::RequestComplete(&aStatus, testContext.connMon_.wlanScanResult_.scanRetValue_);
       
   321     } else {
       
   322         iStubRequestStatus = &aStatus;
       
   323     }
       
   324     }
       
   325 
       
   326 #else // WLANQTUTILS_T_WLANQTUTILS_UT_FLAG
       
   327 
       
   328 // ----------------------------------------------------
       
   329 // Stub functions for connmon library, used in emulator
       
   330 // ----------------------------------------------------
       
   331 
       
   332 #if 0
       
   333 // In emulator, there are always two active connections.
       
   334 // The following functions return different properties of these active connection
       
   335 // so that it's easy to test in emulator.
       
   336 
       
   337 EXPORT_C void RConnectionMonitor::GetConnectionCount(
       
   338     TUint& aConnectionCount,
       
   339     TRequestStatus& aStatus)
       
   340 {
       
   341     aConnectionCount = 2;
       
   342     User::RequestComplete(&aStatus, KErrNone);
       
   343 }
       
   344 
       
   345 EXPORT_C TInt RConnectionMonitor::GetConnectionInfo(
       
   346         const TUint aIndex,
       
   347         TUint& aConnectionId,
       
   348         TUint& aSubConnectionCount ) const
       
   349 {
       
   350     if (aIndex == 1) {
       
   351         aConnectionId = 10;
       
   352     } else if (aIndex == 2) {
       
   353         aConnectionId = 20;
       
   354     } else {
       
   355         Q_ASSERT(false);
       
   356     }
       
   357 
       
   358     aSubConnectionCount = 0;
       
   359     return KErrNone;
       
   360 }
       
   361 
       
   362 EXPORT_C void RConnectionMonitor::GetIntAttribute(
       
   363         const TUint aConnectionId,
       
   364         const TUint /* aSubConnectionId */,
       
   365         const TUint aAttribute,
       
   366         TInt& aValue,
       
   367         TRequestStatus& aStatus )
       
   368 {
       
   369     if (aAttribute == KBearer) {
       
   370         if (aConnectionId == 10) {
       
   371             aValue = EBearerGPRS;
       
   372         } else if (aConnectionId == 20) {
       
   373             aValue = EBearerWLAN;
       
   374         } else {
       
   375             Q_ASSERT(false);
       
   376         }
       
   377     } else if (aAttribute == KConnectionStatus) {
       
   378         if (aConnectionId == 10) {
       
   379             aValue = KConnectionOpen;
       
   380         } else if (aConnectionId == 20) {
       
   381             aValue = KStartingConnection;
       
   382         } else {
       
   383             Q_ASSERT(false);
       
   384         }
       
   385     } else if (aAttribute == KSignalStrength) {
       
   386         if (aConnectionId == 10) {
       
   387             Q_ASSERT(false);
       
   388         } else if (aConnectionId == 20) {
       
   389             aValue = 78;
       
   390         } else {
       
   391             Q_ASSERT(false);
       
   392         }
       
   393     } else if (aAttribute == KNetworkMode) {
       
   394         if (aConnectionId == 10) {
       
   395             Q_ASSERT(false);
       
   396         } else if (aConnectionId == 20) {
       
   397             aValue = EConnMonInfraStructure;
       
   398         } else {
       
   399             Q_ASSERT(false);
       
   400         }
       
   401     } else if (aAttribute == KSecurityMode) {
       
   402         if (aConnectionId == 10) {
       
   403             Q_ASSERT(false);
       
   404         } else if (aConnectionId == 20) {
       
   405             aValue = EConnMonSecurityWpaPsk;
       
   406         } else {
       
   407             Q_ASSERT(false);
       
   408         }
       
   409     } else {
       
   410         Q_ASSERT(false);
       
   411     }
       
   412     User::RequestComplete(&aStatus, KErrNone);
       
   413 }
       
   414 
       
   415 EXPORT_C void RConnectionMonitor::GetUintAttribute(
       
   416         const TUint aConnectionId,
       
   417         const TUint /* aSubConnectionId */,
       
   418         const TUint aAttribute,
       
   419         TUint& aValue,
       
   420         TRequestStatus& aStatus )
       
   421 {
       
   422     if (aAttribute == KIAPId) {
       
   423         if (aConnectionId == 10) {
       
   424             aValue = 1;
       
   425         } else if (aConnectionId == 20) {
       
   426             aValue = 10;
       
   427         } else {
       
   428             Q_ASSERT(false);
       
   429         }
       
   430     } else if (aAttribute == KDownlinkData) {
       
   431         if (aConnectionId == 10) {
       
   432             aValue = 123;
       
   433         } else if (aConnectionId == 20) {
       
   434             aValue = 12345;
       
   435         } else {
       
   436             Q_ASSERT(false);
       
   437         }
       
   438     } else if (aAttribute == KUplinkData) {
       
   439         if (aConnectionId == 10) {
       
   440             aValue = 987654321;
       
   441         } else if (aConnectionId == 20) {
       
   442             aValue = 1234567890;
       
   443         } else {
       
   444             Q_ASSERT(false);
       
   445         }
       
   446     } else if (aAttribute == KTransmitPower) {
       
   447         if (aConnectionId == 10) {
       
   448             Q_ASSERT(false);
       
   449         } else if (aConnectionId == 20) {
       
   450             aValue = 50;
       
   451         } else {
       
   452             Q_ASSERT(false);
       
   453         }
       
   454     } else {
       
   455         Q_ASSERT(false);
       
   456     }
       
   457 
       
   458     User::RequestComplete(&aStatus, KErrNone);
       
   459 }
       
   460 
       
   461 EXPORT_C void RConnectionMonitor::GetBoolAttribute(
       
   462         const TUint aConnectionId,
       
   463         const TUint /* aSubConnectionId */,
       
   464         const TUint aAttribute,
       
   465         TBool& aValue,
       
   466         TRequestStatus& aStatus )
       
   467 {
       
   468     if (aAttribute == KConnectionActive) {
       
   469         if (aConnectionId == 10) {
       
   470             aValue = EFalse;
       
   471         } else if (aConnectionId == 20) {
       
   472             aValue = ETrue;
       
   473         } else {
       
   474             Q_ASSERT(false);
       
   475         }
       
   476     } else {
       
   477         Q_ASSERT(false);
       
   478     }
       
   479 
       
   480     User::RequestComplete(&aStatus, KErrNone);
       
   481 }
       
   482 
       
   483 EXPORT_C void RConnectionMonitor::GetStringAttribute(
       
   484     const TUint aConnectionId,
       
   485     const TUint /* aSubConnectionId */,
       
   486     const TUint aAttribute,
       
   487     TDes& aValue,
       
   488     TRequestStatus& aStatus ) const
       
   489 {
       
   490     if (aAttribute == KIAPName) {
       
   491         if (aConnectionId == 10) {
       
   492             _LIT(iapNameLit, "PACKET DATA 1");
       
   493             TBufC<KConnMonMaxStringAttributeLength> iapName(iapNameLit);
       
   494             aValue = iapName.Des();
       
   495         } else if (aConnectionId == 20) {
       
   496             _LIT(iapNameLit, "WLAN IAP 3");
       
   497             TBufC<KConnMonMaxStringAttributeLength> iapName(iapNameLit);
       
   498             aValue = iapName.Des();
       
   499         } else {
       
   500             Q_ASSERT(false);
       
   501         }
       
   502     } else if (aAttribute == KNetworkName) {
       
   503         if (aConnectionId == 10) {
       
   504             Q_ASSERT(false);
       
   505         } else if (aConnectionId == 20) {
       
   506             _LIT(ssidLit, "WLAN SSID 3");
       
   507             TBufC<KConnMonMaxStringAttributeLength> ssid(ssidLit);
       
   508             aValue = ssid.Des();
       
   509         } else {
       
   510             Q_ASSERT(false);
       
   511         }
       
   512     } else if (aAttribute == KAccessPointName) {
       
   513         if (aConnectionId == 10) {
       
   514             _LIT(iapNameLit, "PACKET DATA 1");
       
   515             TBufC<KConnMonMaxStringAttributeLength> iapName(iapNameLit);
       
   516             aValue = iapName.Des();
       
   517         } else if (aConnectionId == 20) {
       
   518             Q_ASSERT(false);
       
   519         } else {
       
   520             Q_ASSERT(false);
       
   521         }
       
   522     } else {
       
   523         Q_ASSERT(false);
       
   524     }
       
   525 
       
   526     User::RequestComplete(&aStatus, KErrNone);
       
   527 }
       
   528 
       
   529 EXPORT_C void RConnectionMonitor::GetPckgAttribute(
       
   530     const TUint aConnectionId,
       
   531     const TUint aSubConnectionId,
       
   532     const TUint aAttribute,
       
   533     TDes8& aValue,
       
   534     TRequestStatus& aStatus ) const
       
   535 {
       
   536     if (aAttribute == KStartTime) {
       
   537         if (aConnectionId == 10) {
       
   538             TDateTime dateTime(2009, EMarch, 31-1, 15, 15, 15, 0);
       
   539             TTime time(dateTime);
       
   540             TConnMonTimeBuf timePckg(time);
       
   541             aValue.Copy(timePckg);
       
   542         } else if (aConnectionId == 20) {
       
   543             TTime time;
       
   544             time.UniversalTime();
       
   545             TConnMonTimeBuf timePckg(time);
       
   546             aValue.Copy(timePckg);
       
   547         } else {
       
   548             Q_ASSERT(false);
       
   549         }
       
   550         User::RequestComplete(&aStatus, KErrNone);
       
   551     } else if (aAttribute == KClientInfo) {
       
   552         TConnMonClientEnum applications;
       
   553         if (aConnectionId == 10) {
       
   554             applications.iCount = 1;
       
   555             applications.iUid[0].iUid = 0x10008D39; // Web
       
   556             applications.iUid[1].iUid = 0;
       
   557             applications.iUid[2].iUid = 0;
       
   558             applications.iUid[3].iUid = 0;
       
   559             applications.iUid[4].iUid = 0;
       
   560             applications.iUid[5].iUid = 0;
       
   561             applications.iUid[6].iUid = 0;
       
   562             applications.iUid[7].iUid = 0;
       
   563             applications.iUid[8].iUid = 0;
       
   564             applications.iUid[9].iUid = 0;
       
   565         } else if (aConnectionId == 20) {
       
   566             applications.iCount = 7;
       
   567             applications.iUid[0].iUid = 0x101fd9c5; // KBannedServerUID
       
   568             applications.iUid[1].iUid = 0x1020728E; // KFeedsServerUid
       
   569             applications.iUid[2].iUid = 0x10008D60; // KDownloadMgrServerUid
       
   570             applications.iUid[3].iUid = 0x1000484b; // KMessagingServerUid
       
   571             applications.iUid[4].iUid = 0x102033E6; // KJavaVMUid
       
   572             applications.iUid[5].iUid = 0x102073CA; // KSUPLServerUid
       
   573             applications.iUid[6].iUid = 0x200212F3; // Connect Screen
       
   574             applications.iUid[7].iUid = 0;
       
   575             applications.iUid[8].iUid = 0;
       
   576             applications.iUid[9].iUid = 0;
       
   577         } else {
       
   578             Q_ASSERT(false);
       
   579         }
       
   580         TPckgBuf< TConnMonClientEnum > applicationsPckg( applications );
       
   581         aValue.Copy(applicationsPckg);
       
   582         User::RequestComplete(&aStatus, KErrNone);
       
   583     } else {
       
   584         // This is copy-paste from real implementation and we'll use that for other requests.
       
   585         TIpcArgs args( aConnectionId, aSubConnectionId, aAttribute, &aValue );
       
   586         SendReceive( EReqGetPckgAttribute, args, aStatus );
       
   587     }
       
   588 }
       
   589 #endif
       
   590 
       
   591 // This function returns WLAN scan results.
       
   592 // Six results in every second scan and the others have two.
       
   593 EXPORT_C void RConnectionMonitor::GetPckgAttribute(
       
   594     const TUint /* aConnectionId */,
       
   595     const TUint /* aSubConnectionId */,
       
   596     const TUint aAttribute,
       
   597     TDes16& aValue,
       
   598     TRequestStatus& aStatus ) const {
       
   599 
       
   600     if (aAttribute == KWlanNetworks) {
       
   601         RConnMonWlanNetworksPtrArray wlanPtrArray;
       
   602         RBuf vendorData;
       
   603     
       
   604         TBufC<CConnMonWlanNetwork::KWlanBssId> bssid16(QString("addMAC").utf16());
       
   605         TBuf8<CConnMonWlanNetwork::KWlanBssId> bssid;
       
   606         bssid.Copy(bssid16);
       
   607     
       
   608         static bool refresh = true;
       
   609     
       
   610         _LIT(wlanAp1Name, "Test AP 1");
       
   611         TBufC<CConnMonWlanNetwork::KMaxNameLength> name1(wlanAp1Name);
       
   612         CConnMonWlanNetwork* wlanAp1 = CConnMonWlanNetwork::NewL(
       
   613             name1,
       
   614             EConnMonInfraStructure,
       
   615             20,
       
   616             EConnMonSecurityOpen,
       
   617             EConnMonSecurityV2Open,
       
   618             0,
       
   619             bssid,
       
   620             vendorData );
       
   621         wlanPtrArray.Append(wlanAp1);
       
   622     
       
   623         _LIT(wlanAp2Name, "Test AP 2");
       
   624         TBufC<CConnMonWlanNetwork::KMaxNameLength> name2(wlanAp2Name);
       
   625         CConnMonWlanNetwork* wlanAp2 = CConnMonWlanNetwork::NewL(
       
   626             name2,
       
   627             EConnMonAdHoc,
       
   628             (refresh == true) ? 20 : 90, // signal strength variates between refreshes
       
   629             EConnMonSecurityOpen,
       
   630             EConnMonSecurityV2Open,
       
   631             0,
       
   632             bssid,
       
   633             vendorData );
       
   634         wlanPtrArray.Append(wlanAp2);
       
   635     
       
   636         if (refresh) {
       
   637             _LIT(wlanAp3Name, "Test AP 3");
       
   638             TBufC<CConnMonWlanNetwork::KMaxNameLength> name3(wlanAp3Name);
       
   639             CConnMonWlanNetwork* wlanAp3 = CConnMonWlanNetwork::NewL(
       
   640                 name3,
       
   641                 EConnMonInfraStructure,
       
   642                 20,
       
   643                 EConnMonSecurityWep,
       
   644                 EConnMonSecurityV2WepOpen,
       
   645                 0,
       
   646                 bssid,
       
   647                 vendorData );
       
   648             wlanPtrArray.Append(wlanAp3);
       
   649     
       
   650             _LIT(wlanAp4Name, "Test AP 4");
       
   651             TBufC<CConnMonWlanNetwork::KMaxNameLength> name4(wlanAp4Name);
       
   652             CConnMonWlanNetwork* wlanAp4 = CConnMonWlanNetwork::NewL(
       
   653                 name4,
       
   654                 EConnMonInfraStructure,
       
   655                 20,
       
   656                 EConnMonSecurityOpen,
       
   657                 EConnMonSecurityV2Open,
       
   658                 0,
       
   659                 bssid,
       
   660                 vendorData );
       
   661             wlanPtrArray.Append(wlanAp4);
       
   662     
       
   663             _LIT(wlanAp5Name, "Test AP 5");
       
   664             TBufC<CConnMonWlanNetwork::KMaxNameLength> name5(wlanAp5Name);
       
   665             CConnMonWlanNetwork* wlanAp5 = CConnMonWlanNetwork::NewL(
       
   666                 name5,
       
   667                 EConnMonInfraStructure,
       
   668                 20,
       
   669                 EConnMonSecurityWpa,
       
   670                 EConnMonSecurityV2Wpa,
       
   671                 0,
       
   672                 bssid,
       
   673                 vendorData );
       
   674             wlanPtrArray.Append(wlanAp5);
       
   675     
       
   676             _LIT(wlanAp6Name, "Test AP 6");
       
   677             TBufC<CConnMonWlanNetwork::KMaxNameLength> name6(wlanAp6Name);
       
   678             CConnMonWlanNetwork* wlanAp6 = CConnMonWlanNetwork::NewL(
       
   679                 name6,
       
   680                 EConnMonInfraStructure,
       
   681                 20,
       
   682                 EConnMonSecurityWpaPsk,
       
   683                 EConnMonSecurityV2WpaPsk,
       
   684                 0,
       
   685                 bssid,
       
   686                 vendorData );
       
   687             wlanPtrArray.Append(wlanAp6);
       
   688     
       
   689             refresh = false;
       
   690         } else {
       
   691             refresh = true;
       
   692         }
       
   693     
       
   694         CConnMonWlanNetworksPtrArrayPckg wlanBuf(wlanPtrArray, 2560); // TODO: buffer size to more dynamic or use constant
       
   695         aValue.Copy(wlanBuf.Buf()->Des());
       
   696     } else {
       
   697         Q_ASSERT(false);
       
   698     }
       
   699     
       
   700     User::RequestComplete(&aStatus, KErrNone);
       
   701 }
       
   702 
       
   703 #endif // WLANQTUTILS_T_WLANQTUTILS_UT_FLAG
       
   704 #endif // __WINS__