[PC-BSD Commits] r15057 - pcbsd/current/src-qt4/pc-bluetoothmanager
svn at pcbsd.org
svn at pcbsd.org
Tue Jan 24 19:45:07 PST 2012
Author: kenmoore
Date: 2012-01-25 03:45:07 +0000 (Wed, 25 Jan 2012)
New Revision: 15057
Modified:
pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.cpp
pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.h
pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.ui
Log:
Add system name display and hcsecd.conf entry add/remove/read functionality to the bluetooth GUI
Modified: pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.cpp 2012-01-25 03:35:36 UTC (rev 15056)
+++ pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.cpp 2012-01-25 03:45:07 UTC (rev 15057)
@@ -10,6 +10,8 @@
* Old Device Tab: pushConfigureOld pushRemoveOld listOldDevice oldDeviceInfo
*/
+QStringList oldSaveBdaddrList, oldSaveKeyList, oldSavePinList, oldSaveNameList, newSaveBdaddrList;
+
btmaingui::btmaingui(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::btmaingui)
@@ -27,10 +29,16 @@
//Setup Signals/Slots
connect(ui->pushScanNew,SIGNAL(clicked()),this,SLOT(scanForDevices()));
connect(ui->tabWidget,SIGNAL(currentChanged(int)),this,SLOT(tabChanged(int)));
+ connect(ui->pushRemoveOld,SIGNAL(clicked()),this,SLOT(removeOldDevice()));
+ connect(ui->listOldDevice,SIGNAL(currentRowChanged(int)),this,SLOT(updateOldDeviceInfo(int)));
+ connect(ui->pushAddDevice,SIGNAL(clicked()),this,SLOT(addNewDevice()));
//Setup GUI enables/disables
//Start on the system settings tab
ui->tabWidget->setCurrentIndex(0);
+ //Load the information for each Tab as needed
+ updateCompInfo(); //Load info for computer settings tab
+ refreshOldDeviceList(); //Load info for the saved devices tab (fill needed arrays)
}
void btmaingui::tabChanged(int newTab){
@@ -39,7 +47,7 @@
}else if(newTab==1){ //New Device Tab
scanForDevices();
}else if(newTab==2){ //Old Device Tab
-
+ refreshOldDeviceList();
}else{
qDebug() << "BlueToothManager: TabChanged Error: Tab #"<< newTab << " does not exist";
}
@@ -50,40 +58,127 @@
ui->newDeviceInfo->clear();
ui->newDeviceInfo->append(tr("Searching for discoverable Bluetooth devices"));
ui->listNewDevice->clear();
+ newSaveBdaddrList.clear();
//Start scanning and put the results in the listbox
QStringList bdaddrList = Hardware::findBTdevices();
QStringList connectionList = Utils::runShellCommand("hccontrol read_connection_list");
for(int i=0; i<bdaddrList.length(); i++){
- if( !connectionList.contains(bdaddrList[i]) ){ //Check if it is a new device (not connected)
+ if( !connectionList.contains(bdaddrList[i]) && !oldSaveBdaddrList.contains(bdaddrList[i]) ){ //Check if it is a new device (not connected or saved)
QString name = Hardware::getBTRemoteName(bdaddrList[i]);
+ if( name.isEmpty() ){name = Hardware::getBTRemoteName(bdaddrList[i]);} //try one more time - have noticed occasional inconsistancy
+ newSaveBdaddrList << bdaddrList[i];
ui->listNewDevice->addItem(name+" ("+bdaddrList[i]+")"); //Add it to the new device list
}
}
- //Clear the
+ //Clear the info box
ui->newDeviceInfo->clear();
- if(ui->listNewDevice->count()==0){
- //No Devices found
+ if(ui->listNewDevice->count()==0){ //No Devices found
ui->newDeviceInfo->append(tr("No Bluetooth devices discovered! Please put your device into \"discovery\" mode and rescan."));
}
}
void btmaingui::refreshOldDeviceList(){
+ //Clear the list for updating
+ ui->listOldDevice->clear();
+ ui->listOldDevice->setCurrentRow(-1);
+ ui->oldDeviceInfo->clear();
+ ui->oldDeviceInfo->append(tr("Reading saved Bluetooth devices. Please wait."));
+ //Get all the Old Devices saved in hcsecd.conf and load them into memory
+ QStringList oldBdaddrList = Hardware::readAllSavedBTDevices();
+ oldSaveKeyList.clear(); oldSavePinList.clear(); oldSaveNameList.clear(); oldSaveBdaddrList.clear(); //reset the saved variables
+ if(oldBdaddrList.isEmpty()){
+ ui->oldDeviceInfo->clear();
+ QString userID = Utils::runShellCommand("id -u").join("");
+ if( userID.toInt() == 0){
+ ui->oldDeviceInfo->append(tr("No saved configurations found"));
+ }else{
+ ui->oldDeviceInfo->append(tr("This program must be run as root to view/edit saved configurations"));
+ }
+ return;
+ }
+ for(int i=0; i<oldBdaddrList.length(); i++){
+ QStringList temp = Hardware::readSavedBTDevice(oldBdaddrList[i]);
+ oldSaveBdaddrList << oldBdaddrList[i];
+ oldSaveNameList << temp[1];
+ oldSaveKeyList << temp[2];
+ oldSavePinList << temp[3];
+ }
+ //Display the name/bdaddr of all the saved devices
+ for(int i=0; i<oldSaveBdaddrList.length();i++){
+ ui->listOldDevice->addItem(oldSaveNameList[i]+" ("+oldSaveBdaddrList[i]+")");
+ }
+ ui->oldDeviceInfo->clear();
}
+void btmaingui::removeOldDevice(){
+ //Get the BDADDR of the selected device
+ int row = ui->listOldDevice->currentRow();
+ if(row == -1){
+ //No device selected
+ //----------put warning box here ------------
+ return;
+ }
+ QString bdaddr = oldSaveBdaddrList[row];
+ //Remove the Device from hcsecs.conf
+ Hardware::rmBTdevice(bdaddr,TRUE); //restart the network after removing the device
+ //Refresh the Device List
+ refreshOldDeviceList();
+}
+
void btmaingui::addNewDevice(){
+ //Get the BDADDR of the selected device
+ int row = ui->listNewDevice->currentRow();
+ if(row == -1){
+ //No device selected
+ //----------put warning box here ------------
+ return;
+ }
+ QString bdaddr = newSaveBdaddrList[row];
+ //Ask for PIN and KEY for configuration
+ //----Add configuration GUI here----
+ QString pin = "";
+ QString key = "";
+ //Add the entry to hcsecd.conf
+ Hardware::addBTdevice(bdaddr,"",key,pin);
+ //Move to the Saved devices tab
+ ui->tabWidget->setCurrentIndex(2);
+ refreshOldDeviceList();
+
}
void btmaingui::updateCompInfo(){
-
+ //Clear the display for action
+ ui->settingsInfo->clear();
+ //Get computer host/device names and display it
+ QStringList compName = Hardware::getBTdevNames(); //compName[0]=host name; compName[1]=device name
+ ui->settingsInfo->append(tr("Computer/Device ID: ")+compName[0]+" ("+compName[1]+")");
+ //List all active connections (if any)
+ QStringList connectionList = Utils::runShellCommand("hccontrol read_connection_list");
+ if(connectionList.length() > 1){
+ ui->settingsInfo->append("\n"+tr("Active Bluetooth Connections:"));
+ for(int i=1; i<connectionList.length(); i++){ //skip the first line (labels)
+ QString bdaddr = connectionList[i].section(" ",0,0,QString::SectionSkipEmpty).simplified();
+ QString name = Hardware::getBTRemoteName(bdaddr);
+ ui->settingsInfo->append(" "+name+" ("+bdaddr+")");
+ }
+ }
}
void btmaingui::updateNewDeviceInfo(){
}
-void btmaingui::updateOldDeviceInfo(){
-
+void btmaingui::updateOldDeviceInfo(int row){
+ //qDebug() << row << oldBdaddrList << oldNameList << oldKeyList << oldPinList;
+ //Display the hcsecd configuration for the selected device
+ ui->oldDeviceInfo->clear();
+ if(row != -1){
+ ui->oldDeviceInfo->append("BD_ADDR: "+oldSaveBdaddrList[row]);
+ ui->oldDeviceInfo->append("Name: "+oldSaveNameList[row]);
+ ui->oldDeviceInfo->append("Key: "+oldSaveKeyList[row]);
+ ui->oldDeviceInfo->append("PIN: "+oldSavePinList[row]);
+ }
}
Modified: pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.h
===================================================================
--- pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.h 2012-01-25 03:35:36 UTC (rev 15056)
+++ pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.h 2012-01-25 03:45:07 UTC (rev 15057)
@@ -25,10 +25,11 @@
void scanForDevices();
void tabChanged(int);
void refreshOldDeviceList();
+ void removeOldDevice();
void addNewDevice();
void updateCompInfo();
void updateNewDeviceInfo();
- void updateOldDeviceInfo();
+ void updateOldDeviceInfo(int);
};
Modified: pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.ui
===================================================================
(Binary files differ)
More information about the Commits
mailing list