summaryrefslogtreecommitdiffstats
path: root/qt-ui/btdeviceselectiondialog.cpp
diff options
context:
space:
mode:
authorGravatar Claudiu Olteanu <olteanu.claudiu@ymail.com>2015-08-18 22:12:58 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-20 22:45:37 -0700
commit74187657e5e1fb10dcc81c03f68b8e9d22d1ea70 (patch)
tree064f58cbc8230df5a4123749be6e78438764e31a /qt-ui/btdeviceselectiondialog.cpp
parent2af14ba44588db5b7bfef39edd3a1f922d1474cf (diff)
downloadsubsurface-74187657e5e1fb10dcc81c03f68b8e9d22d1ea70.tar.gz
Initialize WinSock and hide the information about the local device
On Windows we cannot select a device or show information about the local device. Therefore we disable the UI section related to local device details. Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/btdeviceselectiondialog.cpp')
-rw-r--r--qt-ui/btdeviceselectiondialog.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/qt-ui/btdeviceselectiondialog.cpp b/qt-ui/btdeviceselectiondialog.cpp
index 813b07f88..a5657c1b4 100644
--- a/qt-ui/btdeviceselectiondialog.cpp
+++ b/qt-ui/btdeviceselectiondialog.cpp
@@ -25,7 +25,23 @@ BtDeviceSelectionDialog::BtDeviceSelectionDialog(QWidget *parent) :
this, SLOT(itemClicked(QListWidgetItem*)));
#if defined(Q_OS_WIN)
- // TODO do the initialization
+ ULONG ulRetCode = SUCCESS;
+ WSADATA WSAData = { 0 };
+
+ // Initialize WinSock and ask for version 2.2.
+ ulRetCode = WSAStartup(MAKEWORD(2, 2), &WSAData);
+ if (ulRetCode != SUCCESS) {
+ QMessageBox::StandardButton warningBox;
+ warningBox = QMessageBox::critical(this, "Bluetooth",
+ "Could not initialize the Winsock version 2.2", QMessageBox::Ok);
+ return;
+ }
+
+ // Initialize the device discovery agent
+ initializeDeviceDiscoveryAgent();
+
+ // On Windows we cannot select a device or show information about the local device
+ ui->localDeviceDetails->hide();
#else
// Initialize the local Bluetooth device
localDevice = new QBluetoothLocalDevice();
@@ -71,6 +87,7 @@ BtDeviceSelectionDialog::~BtDeviceSelectionDialog()
#if defined(Q_OS_WIN)
// Terminate the use of Winsock 2 DLL
+ WSACleanup();
#else
// Clean the local device
delete localDevice;