コード例 #1
0
TInt CCommDbTest036_03::executeStepL()
	{
	CCommsDbTemplateRecord* templateRecord = CCommsDbTemplateRecord::NewL(iTheDb, TPtrC(MODEM_BEARER));
	CleanupStack::PushL(templateRecord);
	
	User::LeaveIfError(templateRecord->Modify());

	TBufC<KCommsDbSvrMaxFieldLength> inputString = _L("string");
	templateRecord->WriteTextL(TPtrC(COMMDB_NAME), _L("DummyName"));
	templateRecord->WriteTextL(TPtrC(MODEM_PORT_NAME), inputString);
	User::LeaveIfError(templateRecord->StoreModifications());

	CleanupStack::PopAndDestroy(templateRecord);

	//Create a view on the modem table, make a new record and check the value is the one set for the template

	CCommsDbTableView* tableView = iTheDb->OpenTableLC(TPtrC(MODEM_BEARER));
	TUint32 dummyId;
	//Create a new record, so we can be sure it is the same as the templated one
	User::LeaveIfError(tableView->InsertRecord(dummyId));
	tableView->WriteTextL(TPtrC(COMMDB_NAME), _L("NewModem"));
	User::LeaveIfError(tableView->PutRecordChanges());

	//Retrieve the string we set for the template
	TBuf<KCommsDbSvrMaxFieldLength> retrievedString;
	tableView->ReadTextL(TPtrC(MODEM_PORT_NAME), retrievedString);
	CleanupStack::PopAndDestroy(tableView);

	if(retrievedString!=inputString)
		return KErrGeneral;

	return KErrNone;
	}
コード例 #2
0
// ---------------------------------------------------------
// RHssInterface::CheckBackgroundScanL
// ---------------------------------------------------------
//
EXPORT_C TUint32 RHssInterface::CheckBackgroundScanL()
	{
	DEBUG( "RHssInterface::CheckBackgroundScanL()" );
    CCommsDatabase*    commDB = NULL;
    CCommsDbTableView* table  = NULL;

    // Open commDB
    commDB = CCommsDatabase::NewL();
    CleanupStack::PushL( commDB );

    table = commDB->OpenViewMatchingUintLC( KHssWlanDeviceSettings,
	                                        KHssWlanDeviceSettingsType,
	                                        KHssWlanUserSettings );

    TInt err = table->GotoFirstRecord();

    if ( err )
        {
        User::Leave( err );  
        }
	
	TUint32 scanInterval;
    table->ReadUintL( KHssBgScanInterval, scanInterval ); 

    // cleanup
    CleanupStack::PopAndDestroy( table );
    CleanupStack::PopAndDestroy( commDB );
    
    return (scanInterval);
	
	}
コード例 #3
0
TBool CDefaultRecordAccess::OpenRecordL(CCommsDatabase* aDb, TUint32 aId)
/**
Close the view if there is one already open. If this has been overriden then use
the original ID given to us, if not, then use the new one. Open the view on the
table and position to the correct record.
@return if the record ID has changed, to notify client.
*/
{
    __ASSERT_DEBUG(iName.Length() > 0, AgentPanic(Agent::EUnknownTableName));

    CloseTable();

    TBool ret=ETrue;
    if (iId==aId || iOverridden)	// if the ID's happen to be the same or the record is already overridden
        ret=EFalse;

    if (!iOverridden)
        iId=aId;

    if (iId == 0)
        User::Leave(KErrNetConDatabaseDefaultUndefined);

    CCommsDbTableView* table = aDb->OpenViewMatchingUintLC(iName,TPtrC(COMMDB_ID),iId);

    User::LeaveIfError(table->GotoFirstRecord());

    CleanupStack::Pop(); // table
    iTable = table;

    return ret;
}
コード例 #4
0
// --------------------------------------------------------------------------
// UPnPAppSettingItemHomeIAP::CheckAPSecurity
// Checks if selected access point is unsecured and shows warning note
// --------------------------------------------------------------------------
//
TInt UPnPAppSettingItemHomeIAP::CheckAPSecurityL(TInt aAccessPoint)
    {
    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
    TUint32 serviceId = 0;
    TUint32 securityMode = 0;

    CCommsDatabase* db = CCommsDatabase::NewL( EDatabaseTypeIAP );
    CleanupStack::PushL( db );

    CCommsDbTableView* view = db->OpenViewMatchingUintLC(TPtrC(IAP),
                              TPtrC(COMMDB_ID), aAccessPoint);

    TInt error = view->GotoFirstRecord();

    if( error == KErrNone )
        {
        view->ReadUintL(TPtrC(IAP_SERVICE), serviceId);
        }

    CCommsDbTableView* wLanServiceTable = NULL;

    TRAPD(err,
    {// this leaves if the table is empty....
    wLanServiceTable = db->OpenViewMatchingUintLC(
        TPtrC( WLAN_SERVICE ),
        TPtrC( WLAN_SERVICE_ID ),
        serviceId );
    CleanupStack::Pop( wLanServiceTable );
    });
コード例 #5
0
//=====================================================
//		CNSmlProfileContentHandler::AccessPointIdL()
//		
//		
//=====================================================	
TInt CNSmlProfileContentHandler::AccessPointIdL(TDesC& aBuf)
{

	const TInt defConn = -2;
	if (aBuf == _L("-1"))
		{
			return defConn; // return default connection always
		}
		
	CCommsDatabase *database = CCommsDatabase::NewL();
    TUint32 aId ;
    TInt retVal;
    CleanupStack::PushL(database);
    CCommsDbTableView*  checkView;
    checkView = database->OpenViewMatchingTextLC(TPtrC(IAP),TPtrC(COMMDB_NAME), aBuf);
    TInt error = checkView->GotoFirstRecord();
    if (error == KErrNone)
        {
         //Get the IAP ID 
         checkView->ReadUintL(TPtrC(COMMDB_ID), aId);
         retVal = aId;
        }
    else
    	{
        	retVal = defConn;
	   	}	  
       	
    CleanupStack::PopAndDestroy(2);    
    return retVal;          
	
	
}
コード例 #6
0
ファイル: iap.cpp プロジェクト: kuailexs/symbiandump-mw1
// ---------------------------------------------------------------------------
// TIap::ResolveIapL
// ---------------------------------------------------------------------------
//  
TInt TIap::ResolveIapL( RArray<TIap>& aIapArray )
    {
    RDebug::Print( _L("TEST PRINT: CTestAppConsole::ResolveIapL -start\n") );
    
    TBuf<40> name;
    TUint32 iapid;

    CCommsDatabase* db = CCommsDatabase::NewL( EDatabaseTypeIAP );
    CleanupStack::PushL( db );
    CCommsDbTableView* view = db->OpenTableLC( TPtrC( IAP ) );

    TInt res = view->GotoFirstRecord();
    
    if ( res != KErrNone )
        {
        CleanupStack::PopAndDestroy( 2 ); // db, view
        RDebug::Print( _L("TEST PRINT: CTestAppConsole::ResolveIapL -end err: %d\n"), res );
        return res;
        }
    while ( res == KErrNone )  
        {
        view->ReadTextL( TPtrC( COMMDB_NAME ), name );
        view->ReadUintL( TPtrC( COMMDB_ID ), iapid );
        aIapArray.AppendL( TIap( iapid, name ) );
        res = view->GotoNextRecord();
        }
    CleanupStack::PopAndDestroy( 2 ); // db, view

    RDebug::Print( _L("TEST PRINT: CTestAppConsole::ResolveIapL -end" ) );
    return KErrNone;
    }
コード例 #7
0
TInt CCommDbTest036_10::executeStepL()
	{
	CCommsDbTemplateRecord* templateRecord = CCommsDbTemplateRecord::NewL(iTheDb, TPtrC(DIAL_IN_ISP));
	CleanupStack::PushL(templateRecord);
	
	User::LeaveIfError(templateRecord->Modify());

	TUint32 inputInt = RMobileCall::KCapsSpeed32000;
	templateRecord->WriteTextL(TPtrC(COMMDB_NAME), _L("Name"));
	templateRecord->WriteTextL(TPtrC(ISP_IP_NAME_SERVER1),_L("MyDnsServer"));
	templateRecord->WriteBoolL(TPtrC(ISP_IP_ADDR_FROM_SERVER), ETrue);
	templateRecord->WriteBoolL(TPtrC(ISP_IP_DNS_ADDR_FROM_SERVER), ETrue);
	templateRecord->WriteBoolL(TPtrC(ISP_IP6_DNS_ADDR_FROM_SERVER), ETrue);
	templateRecord->WriteUintL(TPtrC(ISP_BEARER_SPEED), inputInt);
	User::LeaveIfError(templateRecord->StoreModifications());

	CleanupStack::PopAndDestroy(templateRecord);

	//Create a view on the DialInISP table, make a new record and change the value we set in the template
	CCommsDbTableView* tableView = iTheDb->OpenTableLC(TPtrC(DIAL_IN_ISP));
	TUint32 dummyId;
	//Create a new record, so we can be sure it is the same as the templated one
	User::LeaveIfError(tableView->InsertRecord(dummyId));
	tableView->WriteTextL(TPtrC(COMMDB_NAME), _L("Test ISP"));
	tableView->WriteBoolL(TPtrC(ISP_IP_ADDR_FROM_SERVER), EFalse);
	tableView->WriteBoolL(TPtrC(ISP_IP_DNS_ADDR_FROM_SERVER), EFalse);
	tableView->WriteBoolL(TPtrC(ISP_IP6_DNS_ADDR_FROM_SERVER), EFalse);
	//Overwrite value we set in the template
	TUint32 overwriteInt = RMobileCall::KCapsSpeed64000;
	tableView->WriteUintL(TPtrC(ISP_BEARER_SPEED), overwriteInt);
	User::LeaveIfError(tableView->PutRecordChanges());

	//Retrieve the TUint32 we just set
	TUint32 retrievedInt;
	tableView->ReadUintL(TPtrC(ISP_BEARER_SPEED), retrievedInt);

	TBuf16<KCommsDbSvrMaxFieldLength> ifAuthName(_L16("Invalid"));
	tableView->ReadTextL(TPtrC(ISP_IP_NAME_SERVER1), ifAuthName);
	if(ifAuthName.Compare(_L16("MyDnsServer")))
		{
		User::Leave(KErrGeneral);
		}

	CleanupStack::PopAndDestroy(tableView);

	if(retrievedInt!=overwriteInt)
		return KErrGeneral;

	return KErrNone;
	}
コード例 #8
0
void CPodcastModel::GetProxyInformationForConnectionL(TBool& aIsUsed, HBufC*& aProxyServerName, TUint32& aPort)
	{
	TInt iapId = GetIapId();
	CCommsDbTableView* table = iCommDB->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(COMMDB_ID), iapId);
	
	TUint32 iapService;
	HBufC* iapServiceType;
	table->ReadUintL(TPtrC(IAP_SERVICE), iapService);
	iapServiceType = table->ReadLongTextLC(TPtrC(IAP_SERVICE_TYPE));
	
	CCommsDbTableView* proxyTableView = iCommDB->OpenViewOnProxyRecordLC(iapService, *iapServiceType);
	TInt err = proxyTableView->GotoFirstRecord();
	if( err != KErrNone)
		{
		User::Leave(KErrNotFound);	
		}

	proxyTableView->ReadBoolL(TPtrC(PROXY_USE_PROXY_SERVER), aIsUsed);
	if(aIsUsed)
		{
		HBufC* serverName = proxyTableView->ReadLongTextLC(TPtrC(PROXY_SERVER_NAME));
		proxyTableView->ReadUintL(TPtrC(PROXY_PORT_NUMBER), aPort);
		aProxyServerName = serverName->AllocL();
		CleanupStack::PopAndDestroy(serverName);
		}
		
	CleanupStack::PopAndDestroy(proxyTableView);
	CleanupStack::PopAndDestroy(iapServiceType);
	CleanupStack::PopAndDestroy(table);
	}
コード例 #9
0
// -----------------------------------------------------------------------------
// CCommsDatEnforcement::LockWLANAccessPointsL()
// -----------------------------------------------------------------------------
//
void CCommsDatEnforcement::LockWLANAccessPointsL( TBool aLockValue )
	{
	RDEBUG_2("CCommsDatEnforcement::LockAccessPoint( %d )", aLockValue );
	
	//Get WLAN service table and get ServiceID--> which is nothing but IAP ID and lock that record

	//TBool ret = EFalse;
	TUint32 apIAPID = 0;
		
    CCommsDbTableView*  checkView;
	CCommsDatabase* commsDataBase = CCommsDatabase::NewL();
	CleanupStack::PushL( commsDataBase );
    checkView = commsDataBase->OpenTableLC(TPtrC(IAP));
   	RDEBUG("		-> After opening IAP table ");
   	TBuf<KCommsDbSvrMaxFieldLength> serviceType;
    TInt error = checkView->GotoFirstRecord();
    RDEBUG("		-> After going to first record ");
    while (error == KErrNone)
        {
        RDEBUG("		-> KERRNONE ");
       		// Get the ID and check for service type
       	checkView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
        if(serviceType == TPtrC(LAN_SERVICE))
            {
               	checkView->ReadUintL(TPtrC(COMMDB_ID), apIAPID);
               		RDEBUG_2("	->found %d WLAN AP. being protected or unprotected", apIAPID );
               	if(aLockValue)
               	{
               	((CCommsDbProtectTableView*)checkView)->ProtectRecord();
               	RDEBUG("		-> WLAN AP protected successfully!");	
               	}
               	else
               	{
               		((CCommsDbProtectTableView*)checkView)->UnprotectRecord();
               		RDEBUG("		-> WLAN AP UN protected successfully!");
               	}
               	
            }
            error = checkView->GotoNextRecord();
            
        }
    CleanupStack::PopAndDestroy(); // checkView

    CleanupStack::PopAndDestroy( commsDataBase );	


	}	
コード例 #10
0
/**
 * Function that accesses the PAN Service Table in the CommsDb and configures
 * the IAP to the required settings.
 */		
void CPanConnections::ConfigureIAPL(TBool aIsListening, TBTDevAddr* aDevAddr, TBool aUsePANNotifier)
	{
	// Open CommDb and get a view of the PAN service extentions table.
	CCommsDatabase* db = CCommsDatabase::NewL();
	CleanupStack::PushL(db);
	CCommsDbTableView* tableView = db->OpenTableLC(TPtrC(PAN_SERVICE_EXTENSIONS));

	TBuf<KMaxBufferSize> tableName;
	TInt err = tableView->GotoFirstRecord();
	if(err == KErrNone)
		{
		tableView->ReadTextL(TPtrC(COMMDB_NAME), tableName);
		if(tableName == TPtrC(_S("PANServiceExtensionsTable1")))
			{
			
			User::LeaveIfError(tableView->UpdateRecord());// Start update
			//enable listening mode	
			tableView->WriteBoolL(TPtrC(PAN_ALLOW_INCOMING),aIsListening);
			tableView->WriteBoolL(TPtrC(PAN_DISABLE_SDP_QUERY), 0);

			tableView->WriteBoolL(TPtrC(PAN_PROMPT_FOR_REMOTE_DEVICES), aUsePANNotifier);

			if(aDevAddr)
				{
				TBuf<KMaxBufferSize> buf;
				aDevAddr->GetReadable(buf);

				tableView->WriteTextL(TPtrC(PAN_PEER_MAC_ADDRESSES), buf);
				}
			else
				{
				tableView->WriteTextL(TPtrC(PAN_PEER_MAC_ADDRESSES), _L(""));
				}
			// Finalise changes made.
			User::LeaveIfError(tableView->PutRecordChanges());// Finish update
			User::LeaveIfError(db->CommitTransaction());

			CleanupStack::PopAndDestroy(2); // db & tableView
			return;
			}
		}
	User::Leave(KErrNotFound);
	}
コード例 #11
0
TInt CCommDbTest036_06::executeStepL()
	{
	CCommsDbTemplateRecord* templateRecord = CCommsDbTemplateRecord::NewL(iTheDb, TPtrC(DIAL_IN_ISP));
	CleanupStack::PushL(templateRecord);
	
	User::LeaveIfError(templateRecord->Modify());

	TBufC<KCommsDbSvrMaxFieldLength> inputString = _L("test string");
	templateRecord->WriteTextL(TPtrC(COMMDB_NAME), _L("Name"));
//	templateRecord->WriteTextL(TPtrC(ISP_IF_NAME), _L("SLIP"));
	templateRecord->WriteBoolL(TPtrC(ISP_IP_ADDR_FROM_SERVER), ETrue);
	templateRecord->WriteBoolL(TPtrC(ISP_IP_DNS_ADDR_FROM_SERVER), ETrue);
	templateRecord->WriteBoolL(TPtrC(ISP_IP6_DNS_ADDR_FROM_SERVER), ETrue);
	templateRecord->WriteLongTextL(TPtrC(ISP_LOGIN_SCRIPT), inputString);
	User::LeaveIfError(templateRecord->StoreModifications());

	CleanupStack::PopAndDestroy(templateRecord);

	//Create a view on the DialInISP table, make a new record and change the value we set int he template

	CCommsDbTableView* tableView = iTheDb->OpenTableLC(TPtrC(DIAL_IN_ISP));
	TUint32 dummyId;
	//Create a new record, so we can be sure it is the same as the templated one
	User::LeaveIfError(tableView->InsertRecord(dummyId));
	tableView->WriteTextL(TPtrC(COMMDB_NAME), _L("Test ISP"));
//	tableView->WriteTextL(TPtrC(ISP_IF_NAME), _L("Test If"));
	tableView->WriteBoolL(TPtrC(ISP_IP_ADDR_FROM_SERVER), EFalse);
	tableView->WriteBoolL(TPtrC(ISP_IP_DNS_ADDR_FROM_SERVER), EFalse);
	tableView->WriteBoolL(TPtrC(ISP_IP6_DNS_ADDR_FROM_SERVER), EFalse);
	//Overwrite value set above in template
	TBufC<KCommsDbSvrMaxFieldLength> overwriteString = _L("new string");
	tableView->WriteLongTextL(TPtrC(ISP_LOGIN_SCRIPT), overwriteString);
	User::LeaveIfError(tableView->PutRecordChanges());

	//Retrieve the string we just set
	HBufC* retrievedString = tableView->ReadLongTextLC(TPtrC(ISP_LOGIN_SCRIPT));

	TInt ret(KErrNone);
	if(*retrievedString!=overwriteString)
		ret= KErrGeneral;

	CleanupStack::PopAndDestroy();	//retrievedString
	CleanupStack::PopAndDestroy(tableView);

	return ret;
	}
コード例 #12
0
/**
 * Function that takes an IP address from user input, accesses the
 * Bluetooth PAN Profile table in the CommDb and updates the IpAddr
 * field with the supplied address.
 */		
void CPanConnections::SetLocalIpAddrL(TUint32 addr)
	{
	iLocalIpAddr = addr;
	iSrcAddr.SetAddress(iLocalIpAddr);
	CCommsDatabase* db = CCommsDatabase::NewL();
	CleanupStack::PushL(db);
	// Get the LAN service table
	CCommsDbTableView* tableView = db->OpenTableLC(TPtrC(LAN_SERVICE));

	TBuf<KMaxBufferSize> tableName;
	TInt err = tableView->GotoFirstRecord();
	if(err == KErrNone)
		{
		// Get the name of the table
		tableView->ReadTextL(TPtrC(COMMDB_NAME), tableName);
		if(tableName == TPtrC(_S("BluetoothPANProfile")))
			{
			TInetAddr tempAddr;
			TBuf<KMaxBufferSize> dispBuf;
			tempAddr.SetAddress(iLocalIpAddr);
			tempAddr.Output(dispBuf);
			
			User::LeaveIfError(tableView->UpdateRecord());	
			tableView->WriteTextL(_L("IpAddr"), dispBuf);
		
			User::LeaveIfError(tableView->PutRecordChanges());
			User::LeaveIfError(db->CommitTransaction());	
			}
		}
	else
		{
		User::Leave(KErrNotFound);
		}
	CleanupStack::PopAndDestroy(2);//db & tableView 
	}
コード例 #13
0
TInt CCommDbTest036_08::executeStepL()
	{
	CCommsDbTemplateRecord* templateRecord = CCommsDbTemplateRecord::NewL(iTheDb, TPtrC(DIAL_IN_ISP));
	CleanupStack::PushL(templateRecord);
	
	User::LeaveIfError(templateRecord->Modify());

	TBool inputBool = ETrue;
	templateRecord->WriteTextL(TPtrC(COMMDB_NAME), _L("Name"));
//	templateRecord->WriteTextL(TPtrC(ISP_IF_NAME), _L("SLIP"));
	templateRecord->WriteBoolL(TPtrC(ISP_IP_ADDR_FROM_SERVER), ETrue);
	templateRecord->WriteBoolL(TPtrC(ISP_IP_DNS_ADDR_FROM_SERVER), ETrue);
	templateRecord->WriteBoolL(TPtrC(ISP_IP6_DNS_ADDR_FROM_SERVER), ETrue);
	templateRecord->WriteBoolL(TPtrC(ISP_USE_LOGIN_SCRIPT), inputBool);	//Set to ETrue, since EFalse is default
	User::LeaveIfError(templateRecord->StoreModifications());

	CleanupStack::PopAndDestroy(templateRecord);

	//Create a view on the DialInISP table, make a new record and change the value we set in the template

	CCommsDbTableView* tableView = iTheDb->OpenTableLC(TPtrC(DIAL_IN_ISP));
	TUint32 dummyId;
	//Create a new record, so we can be sure it is the same as the templated one
	User::LeaveIfError(tableView->InsertRecord(dummyId));
	tableView->WriteTextL(TPtrC(COMMDB_NAME), _L("Test ISP"));
//	tableView->WriteTextL(TPtrC(ISP_IF_NAME), _L("Test If"));
	tableView->WriteBoolL(TPtrC(ISP_IP_ADDR_FROM_SERVER), EFalse);
	tableView->WriteBoolL(TPtrC(ISP_IP_DNS_ADDR_FROM_SERVER), EFalse);
	tableView->WriteBoolL(TPtrC(ISP_IP6_DNS_ADDR_FROM_SERVER), EFalse);
	//Overwrite the value set in the template
	TBool overwriteBool = EFalse;
	tableView->WriteBoolL(TPtrC(ISP_USE_LOGIN_SCRIPT), overwriteBool);
	User::LeaveIfError(tableView->PutRecordChanges());

	//Retrieve the bool we just set for the record
	TBool retrievedBool;
	tableView->ReadBoolL(TPtrC(ISP_USE_LOGIN_SCRIPT), retrievedBool);

	CleanupStack::PopAndDestroy(tableView);

	if(retrievedBool!=overwriteBool)
		return KErrGeneral;

	return KErrNone;
	}
コード例 #14
0
TInt CCommDbTest036_02::executeStepL()
	{
	CCommsDbTemplateRecord* templateRecord = CCommsDbTemplateRecord::NewL(iTheDb, TPtrC(MODEM_BEARER));
	CleanupStack::PushL(templateRecord);
	
	User::LeaveIfError(templateRecord->Modify());

	TBufC8<KCommsDbSvrMaxFieldLength> firstInputString = _L8("string");
	templateRecord->WriteTextL(TPtrC(COMMDB_NAME), _L("DummyName"));
	templateRecord->WriteTextL(TPtrC(MODEM_FAX_INIT_STRING), firstInputString);
	User::LeaveIfError(templateRecord->StoreModifications());

	CleanupStack::PopAndDestroy(templateRecord);

	//Create a view on the modem table, over write the template value previosly set and check it sticks

	CCommsDbTableView* tableView = iTheDb->OpenTableLC(TPtrC(MODEM_BEARER));
	TUint32 dummyId;
	//Create a new record, so we can be sure it is the same as the templated one
	User::LeaveIfError(tableView->InsertRecord(dummyId));
	tableView->WriteTextL(TPtrC(COMMDB_NAME), _L("NewModem"));
	//Do overwrite of setting
	TBufC8<KCommsDbSvrMaxFieldLength> overwriteString = _L8("different string");
	tableView->WriteTextL(TPtrC(MODEM_FAX_INIT_STRING), overwriteString);
	User::LeaveIfError(tableView->PutRecordChanges());

	TBuf8<KCommsDbSvrMaxFieldLength> retrievedString;
	tableView->ReadTextL(TPtrC(MODEM_FAX_INIT_STRING), retrievedString);
	CleanupStack::PopAndDestroy(tableView);

	if(retrievedString!=overwriteString)
		return KErrGeneral;

	return KErrNone;
	}
コード例 #15
0
// -------------------------------------------------------------------------------------
// CNSmlDsProvisioningAdapter::GetDefaultIAPL()
// Gets the default NAPId 
// -------------------------------------------------------------------------------------
TInt CNSmlDsProvisioningAdapter::GetDefaultIAPL()
	{
	TInt iapId = KErrNotFound;

	CCommsDatabase* database = CCommsDatabase::NewL();
	CleanupStack::PushL( database );

	CCommsDbTableView* tableView = database->OpenTableLC( TPtrC( IAP ) );

	TInt errorCode = tableView->GotoFirstRecord();
		
	if ( errorCode == KErrNone ) 
		{
		TUint32	value;
		tableView->ReadUintL( TPtrC( COMMDB_ID ), value );
		iapId = value;
		}

	CleanupStack::PopAndDestroy( 2 ); // database, tableView

	return iapId;
	}
QList<XQAccessPoint> XQAccessPointManagerPrivate::accessPointsL() const
{
    QList<XQAccessPoint> aps;
    XQAccessPoint ap;

    //open internet accesspoint table
    CCommsDbTableView* pDbTView = ipCommsDB->OpenTableLC(TPtrC(IAP));

    // Loop through all IAPs
    TUint32 apId = 0;
    TInt retVal = pDbTView->GotoFirstRecord();
    while (retVal == KErrNone) {
        pDbTView->ReadUintL(TPtrC(COMMDB_ID), apId);
        ap = accessPointById(apId);
        if (!ap.isNull()) {
            aps << ap;
        }
        retVal = pDbTView->GotoNextRecord();
    }

    CleanupStack::PopAndDestroy(pDbTView);
    
    return aps;
}
コード例 #17
0
// -----------------------------------------------------------------------------
// COMASuplSettings::ConvertIAPNameToIdL
// 
// -----------------------------------------------------------------------------
TBool COMASuplSettings::ConvertIAPNameToIdL(const TDesC& aIAPName, TUint32& aIAPId)
	{
		TBool result = EFalse;
	
		CCommsDatabase* commDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
		CleanupStack::PushL(commDb);
		CCommsDbTableView* tableView = commDb->OpenIAPTableViewMatchingBearerSetLC(ECommDbBearerCSD|ECommDbBearerGPRS,
											ECommDbConnectionDirectionOutgoing);
	   	TInt retval = tableView->GotoFirstRecord();
	   	while ((retval == KErrNone) && (!result))
	   	{
	      HBufC * iap_name = tableView->ReadLongTextLC( TPtrC( COMMDB_NAME) );

	      if (iap_name && (iap_name->Compare(aIAPName) == 0))
	        {
	           	tableView->ReadUintL(TPtrC(COMMDB_ID), aIAPId);
	            result = ETrue;
	       	}
	       CleanupStack::PopAndDestroy(); // iap_name
	       retval = tableView->GotoNextRecord();
	   	}
		CleanupStack::PopAndDestroy(2);//delete tableView and commDb
		return result;
	}
コード例 #18
0
/**
 * Function that will access the PAN service table in the CommDb
 * and use the values contained to printout the current state.
 */		
void CPanConnections::PrintIAPL()
	{
	CCommsDatabase* db = CCommsDatabase::NewL();
	CleanupStack::PushL(db);
	CCommsDbTableView* tableView = db->OpenTableLC(TPtrC(PAN_SERVICE_EXTENSIONS));

	TInt err = tableView->GotoFirstRecord();
	
	if(err == KErrNone)
		{
		// Print the IAP
		TUint32 uVal;
		TBool bVal;
		TBuf<KMaxBufferSize> sVal;
	

		iConsole.Printf(_L("------------------- CURRENT IAP ------------------\n"));
		
		tableView->ReadUintL(TPtrC(PAN_LOCAL_ROLE), uVal);
		iConsole.Printf(_L("Local Role: %d, "), uVal);			
		tableView->ReadUintL(TPtrC(PAN_PEER_ROLE), uVal);
		iConsole.Printf(_L("Peer Role: %d\n"), uVal);
		tableView->ReadBoolL(TPtrC(PAN_PROMPT_FOR_REMOTE_DEVICES), bVal);
		iConsole.Printf(_L("Peer Prompt: %d, "), bVal);			
		tableView->ReadBoolL(TPtrC(PAN_DISABLE_SDP_QUERY), bVal);
		iConsole.Printf(_L("Disable SDP: %d, "), bVal);			
		tableView->ReadBoolL(TPtrC(PAN_ALLOW_INCOMING), bVal);
		iConsole.Printf(_L("Listening: %d\n"), bVal);			
		tableView->ReadTextL(TPtrC(PAN_PEER_MAC_ADDRESSES), sVal);
		iConsole.Printf(_L("Peer MAC Addr: %S\n"), &sVal);

		iConsole.Printf(_L("--------------------------------------------------\n"));
		CleanupStack::PopAndDestroy(2);
		return;
		}
	User::Leave(KErrNotFound);
	}
コード例 #19
0
void CSymTorrentIAPSelectView::GetGPRSIAPsFromIAPTableL()
{ 
	TBuf<52> iapfromtable;
	TBuf<53> listItem;
	TInt err = KErrNone;
	
	CCommsDatabase* commsDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
	CleanupStack::PushL(commsDB);

	// Open IAP table using the GPRS as the bearer.
	CCommsDbTableView* gprsTable = commsDB->OpenIAPTableViewMatchingBearerSetLC(ECommDbBearerGPRS,
		ECommDbConnectionDirectionOutgoing);
	// Point to the first entry
	User::LeaveIfError(gprsTable->GotoFirstRecord());
	gprsTable->ReadTextL(TPtrC(COMMDB_NAME), iapfromtable);
	listItem.SetLength(0);
	listItem.Append(_L("\t"));
	listItem.Append(iapfromtable);
	iContainer->AppendItemL(listItem);	
	
	TUint32 id;
	gprsTable->ReadUintL(TPtrC(COMMDB_ID), id);
	User::LeaveIfError(iIAPIDs.Append(id));

	while (err = gprsTable->GotoNextRecord(), err == KErrNone)
	{
		gprsTable->ReadTextL(TPtrC(COMMDB_NAME), iapfromtable);
		listItem.SetLength(0);
		listItem.Append(_L("\t"));
		listItem.Append(iapfromtable);
		iContainer->AppendItemL(listItem);
			
		TUint32 id;
		gprsTable->ReadUintL(TPtrC(COMMDB_ID), id);
		User::LeaveIfError(iIAPIDs.Append(id));
	}

	CleanupStack::PopAndDestroy(); // gprsTable
	CleanupStack::PopAndDestroy(); // commsDB
}
コード例 #20
0
EXPORT_C void CPodcastModel::UpdateIAPListL()
	{
	iIapNameArray->Reset();
	iIapIdArray.Reset();	   

	CCommsDbTableView* table = iCommDB->OpenTableLC (TPtrC (IAP)); 
	TInt ret = table->GotoFirstRecord ();
	TPodcastIAPItem IAPItem;
	TBuf <KCommsDbSvrMaxFieldLength> bufName;
	while (ret == KErrNone) // There was a first record
		{
		table->ReadUintL(TPtrC(COMMDB_ID), IAPItem.iIapId);
		table->ReadTextL (TPtrC(COMMDB_NAME), bufName);
		table->ReadTextL (TPtrC(IAP_BEARER_TYPE), IAPItem.iBearerType);
		table->ReadTextL (TPtrC(IAP_SERVICE_TYPE), IAPItem.iServiceType);

		iIapIdArray.Append(IAPItem);
		iIapNameArray->AppendL(bufName); 		 
		ret = table->GotoNextRecord();
		}
	CleanupStack::PopAndDestroy(); // Close table
	}
コード例 #21
0
/**
 * Function that accesses the PAN Service table in the CommDb 
 * and applies the appropriate role, this function will be used for
 * local or peer as well as the PAN role (U or Gn).
 */	
void CPanConnections::SetFixedRoleL(TSide aSide, TUint aRole)
	{
	if (aSide == ELocalRole)
		iLocalRole = aRole;
	else
		iPeerRole = aRole;
	
	CCommsDatabase* db = CCommsDatabase::NewL();
	CleanupStack::PushL(db);
	CCommsDbTableView* tableView = db->OpenTableLC(TPtrC(PAN_SERVICE_EXTENSIONS));

	TBuf<KMaxBufferSize> tableName;
	TInt err = tableView->GotoFirstRecord();
	if(err == KErrNone)
		{
		tableView->ReadTextL(TPtrC(COMMDB_NAME), tableName);
		if(tableName == TPtrC(_S("PANServiceExtensionsTable1")))
			{
			User::LeaveIfError(tableView->UpdateRecord());	
			if(aSide == ELocalRole)
				{
				tableView->WriteBoolL(TPtrC(PAN_LOCAL_ROLE), aRole);
				}
			else 
				{
				tableView->WriteBoolL(TPtrC(PAN_PEER_ROLE), aRole);
				}
			User::LeaveIfError(tableView->PutRecordChanges());
			User::LeaveIfError(db->CommitTransaction());

			CleanupStack::PopAndDestroy(2);
			return;
			}
		}
	User::Leave(KErrNotFound);
	}
コード例 #22
0
/**
 *	Check the current retrieved Contact Point, contained in
 *	iContactPoint, to check that the connection details are
 *	valid for a connection-oriented Push session. If the
 *	iContactPoint passes the tests iConnPoint is set and 
 *	this value will be used for opening a connection.
 *	@return TBool
 *		Returns True if ContactPoint is valid
 *		retruns False if invalid contact point
 *	@leave CCommsDatabase::OpenViewMatchingTextLC
 *		CommDb methods can Leave - so just propogate
 *		as can't verfiy address and security.
 *	@leave CCommsDbTableView::ReadBoolL
 */
TBool CSIAContentHandler::ValidContactPointL()
	{
	__LOG_PTR_DEBUG("CSIAContentHandler:: ValidContactPointL Called");

	TBool valid = ETrue;
	TUint index = 0;

	// check first bit of first byte to see if bearer Type present 
	TUint8 byte = iContactPoint[index];
	index++;
	// will be zero if flag not set - non-zero overwise
	TUint8 bearerFlagPresent = STATIC_CAST(TUint8, byte & KBearerFlagBitMask);
	TUint8 portFlagPresent = STATIC_CAST(TUint8, byte & KPortFlagBitMask);
	// mask off 1st two bits to get the 6 bits representing address length
	TUint8 addressLength = STATIC_CAST(TUint8, byte & KAddressLengthBitMask);

	//check bearer type
	if (bearerFlagPresent)
		{
		byte = iContactPoint[index];
		index++;
		if ((byte != KCSDBearer) && (byte != KGPRSBearer))
			{
			// unsupported bearer
			__LOG_PTR_DEBUG("CSIAContentHandler: unsupported Bearer Type");
			valid = EFalse;
			return valid;
			}
		}

	//set postion of the first byte of the port
	TUint portStartByte = index; 
	
	// get address
	if (portFlagPresent)
		index += 2;
	TPtrC8 address;
	address.Set(iContactPoint.Mid(index, addressLength));

	//Look up supplied address in commsdb. Leave possible from here on in... 
	TPtrC KTableName(WAP_IP_BEARER);
	TPtrC KColumnName(WAP_GATEWAY_ADDRESS);
	TPtrC KSecurityCol(WAP_SECURITY);
	CCommsDbTableView* table = iCommDb->OpenViewMatchingTextLC(KTableName, KColumnName, address); 
	
	TInt ret = table->GotoFirstRecord();
	if (ret == KErrNone)	//address found
		{
		__LOG_PTR_DEBUG("CSIAContentHandler:: Commdb lookup");

		// set port number, using the following logic:
		// 1. if port number supplied, use it with an unsecure security setting
		// 2. if no port supplied, use the default port for the security setting 
		//    returned by the commsdb address lookup
		TUint16 port;
		if (portFlagPresent)
			{
			TUint8 portNumHighByte = iContactPoint[portStartByte];
			TUint8 portNumlowByte = iContactPoint[portStartByte + 1];
			port = STATIC_CAST(TUint16, ((portNumHighByte<<8)|portNumlowByte));
			}
		else
			{
			TBool secure;
			table->ReadBoolL(KSecurityCol, secure);
			 if (secure)
				port = KPushPortSecure;
			 else
				port = KPushPortUnsecure;
			}

		//set connection point
		iConnPoint.iHost = address;
		iConnPoint.iPort = port;
		}
	else	//address lookup failed
		{
		valid = EFalse;
		__LOG_PTR_DEBUG("CSIAContentHandler:: Commdb lookup failed");
		}
	CleanupStack::PopAndDestroy(); // table

	// will only return true if not SMS and address in CommDB
	return valid;
	}
コード例 #23
0
   bool GetProxy( char*& aHost, uint32& aPort, const int32 aIAP )
   { 
# ifdef NAV2_CLIENT_SERIES60_V2
      CCommsDatabase * comdb = CCommsDatabase::NewL();
# else
      CCommsDatabase * comdb = CCommsDatabase::NewL( EDatabaseTypeUnspecified );
# endif
      CleanupStack::PushL( comdb );
   
      // First get the IAP
      CCommsDbTableView* iaptable = comdb->OpenViewMatchingUintLC( TPtrC( IAP ), 
                                                                TPtrC( COMMDB_ID ), aIAP );
      TInt iapres = iaptable->GotoFirstRecord();
      bool found = false;
      if ( iapres == KErrNone ) {
         HBufC* iap_name = iaptable->ReadLongTextLC( TPtrC( COMMDB_NAME) );
         uint32 iap_service = 0;
         iaptable->ReadUintL( TPtrC( IAP_SERVICE ), iap_service );
            
         // The current IAP exists!
         HBufC* iap_type = iaptable->ReadLongTextLC( TPtrC( IAP_SERVICE_TYPE ) );
      
         // Find Proxy for ISP (and same service type)
         CCommsDbTableView* proxytable = comdb->OpenViewMatchingUintLC( TPtrC( PROXIES ), 
                                                                     TPtrC( PROXY_ISP ), iap_service );
         TInt dretval= proxytable->GotoFirstRecord();
         while ( dretval == KErrNone && !found ) {
            // Check if matching proxy service type
            HBufC* proxy_service_type = proxytable->ReadLongTextLC( TPtrC( PROXY_SERVICE_TYPE ) );
            if ( proxy_service_type != NULL &&
               proxy_service_type->CompareC( *iap_type ) == 0 ) 
            {
               // Match!
               // PROXY_USE_PROXY_SERVER 
               TBool proxy_use_proxy_server = 0;
               proxytable->ReadBoolL( TPtrC( PROXY_USE_PROXY_SERVER ), proxy_use_proxy_server );
# ifdef NAV2_CLIENT_SERIES60_V2
               if ( proxy_use_proxy_server ) {
# endif
               // PROXY_SERVER_NAME - Name of the proxy server
               HBufC* proxy_server_name = proxytable->ReadLongTextLC( 
               TPtrC( PROXY_SERVER_NAME ) );
               if ( proxy_server_name ) {
                  found = true;
                  // Convert to something we can use.
                  aHost = WFTextUtil::TDesCToUtf8L( proxy_server_name->Des() );
                  proxytable->ReadUintL( TPtrC( PROXY_PORT_NUMBER ), aPort );
               
                  // Sanity on port
                  if ( aPort == 9201 ) {
                     // We don't talk wap
                     // XXX: Or no proxy at all?
                     aPort = 8080;
                  } else if ( aPort == 0 ) {
                     // Not valid => no proxy
                     found = false;
                     delete [] aHost;
                     aHost = NULL;
                  }
               } // End if have proxy_server_name
                     
               CleanupStack::PopAndDestroy( proxy_server_name );
# ifdef NAV2_CLIENT_SERIES60_V2
               } // End if proxy_use_proxy_server is true
# endif
            } // End if service type matches
            CleanupStack::PopAndDestroy( proxy_service_type );
            dretval = proxytable->GotoNextRecord(); // next proxy
         } // End while all proxies

         // XXX: Perhaps "IAP_SERVICE_TYPE" table -> [GPRS|ISP]_IP_GATEWAY 
         // especially in s60v1
         CleanupStack::PopAndDestroy( proxytable );
         CleanupStack::PopAndDestroy( iap_type );
         CleanupStack::PopAndDestroy( iap_name );
      } // End if the current IAP is found
      
      CleanupStack::PopAndDestroy( iaptable );
      CleanupStack::PopAndDestroy( comdb );
     
      return found;   
   }
コード例 #24
0
ファイル: ConnectionManager.cpp プロジェクト: addame/rhodes
TInt CConnectionManager::SelectIAP()
{
	CArrayFixFlat<TIapData>* iEApList=new (ELeave) CArrayFixFlat<TIapData>(2) ;
	TInt stack=0;
	// Make listitems. and PUSH it
	CAknSinglePopupMenuStyleListBox* list = new(ELeave) CAknSinglePopupMenuStyleListBox;
	CleanupStack::PushL(list);
	stack++; 
 
	// Create popup list and PUSH it.
	CAknPopupList* popupList = CAknPopupList::NewL(list,
		R_AVKON_SOFTKEYS_OK_CANCEL, AknPopupLayouts::EMenuWindow);
	CleanupStack::PushL(popupList);stack++; 
 
	CDesCArrayFlat* items = new (ELeave) CDesCArrayFlat(5);
	CleanupStack::PushL(items);stack++; 
	// initialize listbox.
	list->ConstructL(popupList, CEikListBox::ELeftDownInViewRect);
	list->CreateScrollBarFrameL(ETrue);
	list->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,
		CEikScrollBarFrame::EAuto);
 
 
	TBuf<52> iapfromtable;
	TInt err = KErrNone;
 
	CCommsDatabase* iCommsDB=CCommsDatabase::NewL(EDatabaseTypeIAP);
	CleanupStack::PushL(iCommsDB);stack++; 
#ifdef __SERIES60_3X__
	CCommsDbTableView* gprsTable = iCommsDB->OpenIAPTableViewMatchingBearerSetLC(
			iBearerFilter == EApBearerTypeWLAN 
				? ECommDbBearerWLAN 
				: ECommDbBearerGPRS|ECommDbBearerWLAN|ECommDbBearerVirtual,
		ECommDbConnectionDirectionOutgoing); 
#else
	CCommsDbTableView* gprsTable = iCommsDB->OpenIAPTableViewMatchingBearerSetLC(
		ECommDbBearerGPRS|ECommDbBearerVirtual,
		ECommDbConnectionDirectionOutgoing); 
#endif
	User::LeaveIfError(gprsTable->GotoFirstRecord());
	TInt i=0;
	TUint32 id;
	TIapData eap;	
 
	TInt cur =0; //current value
	do
	{
		gprsTable->ReadTextL(TPtrC(COMMDB_NAME), iapfromtable);
		gprsTable->ReadUintL(TPtrC(COMMDB_ID), id);
		items->AppendL(iapfromtable);
		eap.iIap = id;
		eap.iName.Copy(iapfromtable);
		iEApList->AppendL(eap);
 
		err = gprsTable->GotoNextRecord();
		i++;
	}
	while (err == KErrNone);
	CleanupStack::PopAndDestroy(2); stack--; 
 
	// Set listitems.
	CTextListBoxModel* model = list->Model();
	model->SetItemTextArray(items);
	model->SetOwnershipType(ELbmOwnsItemArray);
	CleanupStack::Pop();    
 
	popupList->SetTitleL(_L("Access Point"));
	list->SetListBoxObserver(popupList);
	TInt popupOk = popupList->ExecuteLD();
	CleanupStack::Pop();    
	TInt iap=0;
	if (popupOk)
	{	
		TInt index = list->CurrentItemIndex();
		iap=(*iEApList)[index].iIap;
 
	}
	CleanupStack::PopAndDestroy();  
	iEApList->Reset();
	delete iEApList;
	return iap;
}
コード例 #25
0
void CIAPSettingItem::CompleteConstructionL()
{
   _LIT(KmRouter, "mroute");

   CArrayPtr<CAknEnumeratedText> * iaps = new(ELeave) CArrayPtrSeg<CAknEnumeratedText>(10);
   CleanupStack::PushL(iaps);
   CArrayPtr<HBufC> * poppedUp = new(ELeave) CArrayPtrSeg<HBufC>(10);
   CleanupStack::PushL(poppedUp);

   CAknEnumeratedTextPopupSettingItem::CompleteConstructionL();

   // The selection of IAP that indicates "always ask"
   HBufC * buf;
   buf = CEikonEnv::Static()->AllocReadResourceL( R_SETTINGS_IAP_ALWAYS_ASK );
   iaps->AppendL(new(ELeave) CAknEnumeratedText(-1, buf ));
   // The selection of IAP that indicates "system default is only shown in
   // development mode, not in release mode.
   if ( ! iRelease ) {
      buf = CEikonEnv::Static()->AllocReadResourceL( R_SETTINGS_IAP_SYSTEM_DEFAULT );
      iaps->AppendL(new(ELeave) CAknEnumeratedText(-2, buf ));
   }


#ifdef NAV2_CLIENT_SERIES60_V2
   CCommsDatabase * comdb = CCommsDatabase::NewL();
#else
   CCommsDatabase * comdb = CCommsDatabase::NewL(EDatabaseTypeUnspecified);
#endif
   CleanupStack::PushL(comdb);
   CCommsDbTableView * iaptable = comdb->OpenTableLC( TPtrC( IAP ) );

   TInt retval;
   retval = iaptable->GotoFirstRecord();

   // display all IAPs except mrouter
   while (retval == KErrNone) {
      HBufC * iap_name = iaptable->ReadLongTextLC( TPtrC( COMMDB_NAME) );
      if ( KErrNotFound == iap_name->FindF(KmRouter) ) {
         TUint32 iap_id;
         iaptable->ReadUintL( TPtrC( COMMDB_ID), iap_id );
         iaps->AppendL(new(ELeave) CAknEnumeratedText(iap_id, iap_name ));
      }
      CleanupStack::Pop(iap_name);   // FIXME - Is this right? Does AppendL take over ownership of the iap name?
      retval = iaptable->GotoNextRecord();
   }

   CleanupStack::PopAndDestroy(iaptable);
   CleanupStack::PopAndDestroy(comdb);

   SetEnumeratedTextArrays(iaps, poppedUp);
   CleanupStack::Pop(poppedUp);
   CleanupStack::Pop(iaps);

   // Does the (old) specified iap still exist? Default to 
   // "always ask" otherwise.
   if (IndexFromValue(ExternalValue()) < 0) {
      SetInternalValue(-1);
      SetExternalValue(-1);
   }


}
void XQAccessPointManagerPrivate::storeWPADataL(const TInt aIapId, const TDesC& aPresharedKey, const XQWLAN& aWlan)
{
    CCommsDbTableView* wLanServiceTable;
    
    CApUtils* apUtils = CApUtils::NewLC(*ipCommsDB);
    TUint32 iapId = apUtils->IapIdFromWapIdL(aIapId);
    CleanupStack::PopAndDestroy(apUtils);

    TUint32 serviceId;

    CCommsDbTableView* iapTable = ipCommsDB->OpenViewMatchingUintLC(TPtrC(IAP),
                                                                    TPtrC(COMMDB_ID),
                                                                    iapId);
    User::LeaveIfError(iapTable->GotoFirstRecord());
    iapTable->ReadUintL(TPtrC(IAP_SERVICE), serviceId);
    CleanupStack::PopAndDestroy( iapTable );

    wLanServiceTable = ipCommsDB->OpenViewMatchingUintLC(TPtrC(XQ_WLAN_SERVICE),
                                                         TPtrC(XQ_WLAN_SERVICE_ID),
                                                         serviceId );
    TInt errorCode = wLanServiceTable->GotoFirstRecord();
    if (errorCode == KErrNone) {
        User::LeaveIfError(wLanServiceTable->UpdateRecord());
    } else {
        TUint32 dummyUid(0);
        User::LeaveIfError(wLanServiceTable->InsertRecord(dummyUid));
        wLanServiceTable->WriteUintL(TPtrC(XQ_WLAN_SERVICE_ID), aIapId);
    }
    CleanupCancelPushL(*wLanServiceTable);

    TBool usesPsk(aWlan.usesPreSharedKey());
    // Save WPA Mode
    wLanServiceTable->WriteUintL(TPtrC(XQ_WLAN_ENABLE_WPA_PSK), usesPsk); 
    
    // Save security mode
    wLanServiceTable->WriteUintL(TPtrC(XQ_WLAN_SECURITY_MODE),
                                 fromQtSecurityModeToS60SecurityMode(aWlan.securityMode())); 

    // Save PreShared Key
    TBuf8<KWpaKeyMaxLength> keyWPA;
    
    //convert to 8 bit
    keyWPA.Copy(aPresharedKey);
    wLanServiceTable->WriteTextL(TPtrC(XQ_WLAN_WPA_PRE_SHARED_KEY),keyWPA);

    // Check and save PreShared Key Length
    TInt len(keyWPA.Length());
        
    wLanServiceTable->WriteUintL(TPtrC(XQ_WLAN_WPA_KEY_LENGTH),len);

    User::LeaveIfError(wLanServiceTable->PutRecordChanges());

    CleanupStack::Pop(wLanServiceTable); // table rollback...
    CleanupStack::PopAndDestroy(wLanServiceTable);
}
void XQAccessPointManagerPrivate::storeWEPDataL(const TInt aIapId, const TDesC& aPresharedKey)
{
    CCommsDbTableView* wLanServiceTable;

    CApUtils* apUtils = CApUtils::NewLC(*ipCommsDB);
    TUint32 iapId = apUtils->IapIdFromWapIdL(aIapId);
    CleanupStack::PopAndDestroy(apUtils);

    TUint32 serviceId;

    CCommsDbTableView* iapTable = ipCommsDB->OpenViewMatchingUintLC(TPtrC(IAP),
                                                                    TPtrC(COMMDB_ID),
                                                                    iapId);
                            
    User::LeaveIfError(iapTable->GotoFirstRecord());
    iapTable->ReadUintL(TPtrC(IAP_SERVICE), serviceId);
    CleanupStack::PopAndDestroy(iapTable);

    wLanServiceTable = ipCommsDB->OpenViewMatchingUintLC(TPtrC(XQ_WLAN_SERVICE),
                                                         TPtrC(XQ_WLAN_SERVICE_ID),
                                                         serviceId);
    TInt errorCode = wLanServiceTable->GotoFirstRecord();
    if (errorCode == KErrNone) {
        User::LeaveIfError(wLanServiceTable->UpdateRecord());
    }
    else {
        TUint32 dummyUid = 0;
        User::LeaveIfError(wLanServiceTable->InsertRecord(dummyUid));
        wLanServiceTable->WriteUintL(TPtrC(XQ_WLAN_SERVICE_ID), aIapId);
    }
    
    CleanupCancelPushL(*wLanServiceTable);

    // Save index of key in use
    TUint32 keyInUse(KFirstWepKey);
    wLanServiceTable->WriteUintL(TPtrC(XQ_WLAN_WEP_INDEX), keyInUse);

    // Save authentication mode
    TUint32 auth(0); // set to open... 
    if (isS60VersionGreaterThan3_1()) {  
        //TODO: wLanServiceTable->WriteUintL(TPtrC(NU_WLAN_AUTHENTICATION_MODE), auth);
    } else {
        wLanServiceTable->WriteUintL(TPtrC(XQ_WLAN_AUTHENTICATION_MODE), auth);
    }
    // not we need to convert the key.... to 8bit and to hex... and again detect the required bits..
    TBuf8<KMaxWepKeyLen> key;
    
    //convert to 8 bit
    key.Copy(aPresharedKey);

    TBool useHex(EFalse);
    TWepKeyLength keyLength;
    TBool validKey = validWepKeyLength(aPresharedKey, useHex, keyLength);
    
    if (!useHex) {
        // Must be converted to hexa and stored as a hexa
        // Ascii key is half the length of Hex
        HBufC8* buf8Conv = HBufC8::NewLC(key.Length() * 2);
        asciiToHex(key, buf8Conv);
        
        if (isS60VersionGreaterThan3_1()) {  
            wLanServiceTable->WriteTextL(TPtrC(XQ_WLAN_HEX_WEP_KEY1), buf8Conv->Des());
        } else {
            wLanServiceTable->WriteTextL(TPtrC(XQ_WLAN_WEP_KEY1), buf8Conv->Des());
        }
        CleanupStack::PopAndDestroy(buf8Conv);
    } else if (isHex(aPresharedKey)) {
        //already in hexa format
        if (isS60VersionGreaterThan3_1()) {  
            wLanServiceTable->WriteTextL(TPtrC(XQ_WLAN_HEX_WEP_KEY1), key);
        } else {
            wLanServiceTable->WriteTextL(TPtrC(XQ_WLAN_WEP_KEY1), key);
        }
    }
  
    wLanServiceTable->WriteUintL(TPtrC(XQ_WLAN_WEP_KEY1_FORMAT), useHex);
  
    key.Zero();
    // write default values to the rest of the columns
    if (isS60VersionGreaterThan3_1()) {  
        wLanServiceTable->WriteTextL(TPtrC(XQ_WLAN_HEX_WEP_KEY2), 
                                     key);
    } else { 
        wLanServiceTable->WriteTextL(TPtrC(XQ_WLAN_WEP_KEY2), 
                                     key );
    }
    // Save third WEP key
    if (isS60VersionGreaterThan3_1()) {  
        wLanServiceTable->WriteTextL(TPtrC(XQ_WLAN_HEX_WEP_KEY3), 
                                     key);
    } else { 
        wLanServiceTable->WriteTextL(TPtrC(XQ_WLAN_WEP_KEY3), 
                                     key);
    }
    // Save fourth WEP key
    if (isS60VersionGreaterThan3_1()) {  
        //TODO: wLanServiceTable->WriteTextL(TPtrC(NU_WLAN_WEP_KEY4), 
        //                             key);
    } else {
        wLanServiceTable->WriteTextL(TPtrC(XQ_WLAN_WEP_KEY4), 
                                     key);
    }
    wLanServiceTable->WriteUintL(TPtrC(XQ_WLAN_WEP_KEY2_FORMAT), 
                                 (TUint32&)useHex);

    wLanServiceTable->WriteUintL(TPtrC(XQ_WLAN_WEP_KEY3_FORMAT), 
                                 (TUint32&)useHex);

    wLanServiceTable->WriteUintL(TPtrC(XQ_WLAN_WEP_KEY4_FORMAT), 
                                 (TUint32&)useHex);
 
    wLanServiceTable->PutRecordChanges();

    CleanupStack::Pop(wLanServiceTable); // table rollback...
    CleanupStack::PopAndDestroy(wLanServiceTable);
}