/** * 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 }
// --------------------------------------------------------------------------- // 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; }
// ----------------------------------------------------------------------------- // 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 ); }
/** * 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); }
// ------------------------------------------------------------------------------------- // 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; }
/** * 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); }
/** * 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); }
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); } }