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