[PC-BSD Commits] r15129 - pcbsd/current/src-qt4/pc-bluetoothmanager
svn at pcbsd.org
svn at pcbsd.org
Wed Feb 1 16:54:36 PST 2012
Author: kenmoore
Date: 2012-02-02 00:54:36 +0000 (Thu, 02 Feb 2012)
New Revision: 15129
Modified:
pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.cpp
pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.h
Log:
New update to the bluetooth GUI, now supports connect/disconnect of devices and changing device configurations properly
Modified: pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.cpp 2012-02-01 21:26:30 UTC (rev 15128)
+++ pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.cpp 2012-02-02 00:54:36 UTC (rev 15129)
@@ -11,7 +11,7 @@
* Old Device Tab: pushConfigureOld pushRemoveOld listOldDevice oldDeviceInfo
*/
-QStringList oldSaveBdaddrList, oldSaveKeyList, oldSavePinList, oldSaveNameList, newSaveBdaddrList;
+QStringList oldSaveBdaddrList, oldSaveKeyList, oldSavePinList, oldSaveNameList, newSaveBdaddrList, currentSaveDeviceList;
btmaingui::btmaingui(QWidget *parent) :
QMainWindow(parent),
@@ -34,12 +34,14 @@
connect(ui->listOldDevice,SIGNAL(currentRowChanged(int)),this,SLOT(updateOldDeviceInfo(int)));
connect(ui->pushAddDevice,SIGNAL(clicked()),this,SLOT(addNewDevice()));
connect(ui->pushConfigureOld,SIGNAL(clicked()),this,SLOT(configureOldDevice()));
+ connect(ui->pushDisconnectDevice,SIGNAL(clicked()),this,SLOT(disconnectDevice()));
//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
+ scanForDevices(); //Do an initial Scan for available devices
refreshOldDeviceList(); //Load info for the saved devices tab (fill needed arrays)
}
@@ -47,7 +49,7 @@
if(newTab==0){ //Computer Settings
updateCompInfo();
}else if(newTab==1){ //New Device Tab
- scanForDevices();
+ //Do nothing
}else if(newTab==2){ //Old Device Tab
refreshOldDeviceList();
}else{
@@ -75,7 +77,7 @@
//Clear the info box
ui->newDeviceInfo->clear();
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."));
+ ui->newDeviceInfo->append(tr("No new Bluetooth devices discovered! Please put your device into \"discovery\" mode and rescan."));
}
}
@@ -173,6 +175,12 @@
ui->tabWidget->setCurrentIndex(2);
refreshOldDeviceList();
+ //Initiate pairing of device
+ QString result = Hardware::pairBTDevice(bdaddr);
+
+ //Rescan for devices in the background
+ scanForDevices();
+
}
void btmaingui::updateCompInfo(){
@@ -182,10 +190,12 @@
QStringList compName = Hardware::getBTdevNames(); //compName[0]=host name; compName[1]=device name
ui->lineCompName->setText(compName[0]+" ("+compName[1]+")");
//List all active connections (if any)
+ currentSaveDeviceList.clear();
QStringList connectionList = Utils::runShellCommand("hccontrol read_connection_list");
if(connectionList.length() > 1){
for(int i=1; i<connectionList.length(); i++){ //skip the first line (labels)
QString bdaddr = connectionList[i].section(" ",0,0,QString::SectionSkipEmpty).simplified();
+ currentSaveDeviceList << bdaddr;
QString name = Hardware::getBTRemoteName(bdaddr);
ui->listConnectedDevices->addItem(name+" ("+bdaddr+")");
}
@@ -228,7 +238,7 @@
QStringList requests;
requests << tr("PIN Code (Examples: 0000, 1234, or none)") << tr("Link Key (Leave blank for automatic)");
QStringList outputs = Utils::quickUserInputBox(tr("Device Configuration"),requests);
- if( outputs.length() != requests.length() ){ //rememberempty strings are valid
+ if( outputs.length() != requests.length() ){ //remember empty strings are valid
//Error/cancelled operation - do nothing
qDebug() << "Configure old device: Cancelled";
return;
@@ -236,9 +246,28 @@
QString pin = outputs[0];
QString key = outputs[1];
//Quick Check for pin validity
- if( pin.length()!=4 && !pin.isEmpty() ){
- QMessageBox::warning(this,tr("Warning"),tr("Invalid Pin length: Defaulting to none"));
- pin = "";
- }
if(pin == "none"){ pin=""; }
+
+ //Add the entry to hcsecd.conf
+ Hardware::addBTdevice(bdaddr,"",key,pin);
+
+ //Refresh the Tab
+ refreshOldDeviceList();
}
+
+void btmaingui::disconnectDevice(){
+ //Get the bdaddr of the selected device
+ int row = ui->listConnectedDevices->currentRow();
+ if(row == -1){
+ //No device selected
+ QMessageBox::warning(this,tr("Warning"),tr("No device has been selected. Please choose a device first."));
+ return;
+ }
+ QString bdaddr = currentSaveDeviceList[row];
+
+ //Call the disconnect routine
+ Hardware::disconnectBTDevice(bdaddr);
+
+ //Refresh the Box
+ updateCompInfo();
+}
Modified: pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.h
===================================================================
--- pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.h 2012-02-01 21:26:30 UTC (rev 15128)
+++ pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.h 2012-02-02 00:54:36 UTC (rev 15129)
@@ -32,6 +32,7 @@
void updateNewDeviceInfo();
void updateOldDeviceInfo(int);
void configureOldDevice();
+ void disconnectDevice();
};
#endif // BTMAINGUI_H
More information about the Commits
mailing list