- Add the retrieval of remote names to the discovered devices
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29366 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -27,10 +27,9 @@ class DeviceListItem : public BListItem
|
|||||||
void Update(BView *owner, const BFont *font);
|
void Update(BView *owner, const BFont *font);
|
||||||
|
|
||||||
static int Compare(const void *firstArg, const void *secondArg);
|
static int Compare(const void *firstArg, const void *secondArg);
|
||||||
|
|
||||||
private:
|
|
||||||
void SetDevice(BluetoothDevice* bDevice);
|
void SetDevice(BluetoothDevice* bDevice);
|
||||||
|
|
||||||
|
private:
|
||||||
BluetoothDevice* fDevice;
|
BluetoothDevice* fDevice;
|
||||||
bdaddr_t fAddress;
|
bdaddr_t fAddress;
|
||||||
DeviceClass fClass;
|
DeviceClass fClass;
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice)
|
|||||||
: BWindow(frame, "Bluetooth", B_FLOATING_WINDOW,
|
: BWindow(frame, "Bluetooth", B_FLOATING_WINDOW,
|
||||||
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS,
|
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS,
|
||||||
B_ALL_WORKSPACES ), fScanning(false)
|
B_ALL_WORKSPACES ), fScanning(false)
|
||||||
|
, fRetrieving(false)
|
||||||
, fLocalDevice(lDevice)
|
, fLocalDevice(lDevice)
|
||||||
{
|
{
|
||||||
// BRect iDontCare(0,0,0,0);
|
// BRect iDontCare(0,0,0,0);
|
||||||
@@ -157,6 +158,7 @@ InquiryPanel::MessageReceived(BMessage *message)
|
|||||||
{
|
{
|
||||||
static float timer = 0; // expected time of the inquiry process
|
static float timer = 0; // expected time of the inquiry process
|
||||||
static float scanningTime = 0;
|
static float scanningTime = 0;
|
||||||
|
static int32 retrievalIndex = 0;
|
||||||
|
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case kMsgInquiry:
|
case kMsgInquiry:
|
||||||
@@ -194,19 +196,19 @@ InquiryPanel::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
case kMsgStart:
|
case kMsgStart:
|
||||||
fRemoteList->MakeEmpty();
|
fRemoteList->MakeEmpty();
|
||||||
fScanProgress->Reset();
|
fScanProgress->Reset();
|
||||||
|
|
||||||
scanningTime = 0;
|
scanningTime = 0;
|
||||||
fScanning = true;
|
fScanning = true;
|
||||||
UpdateUIStatus();
|
|
||||||
|
|
||||||
|
UpdateUIStatus();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kMsgFinish:
|
case kMsgFinish:
|
||||||
|
retrievalIndex = 0;
|
||||||
fScanning = false;
|
fScanning = false;
|
||||||
|
fRetrieving = true;
|
||||||
|
|
||||||
UpdateUIStatus();
|
UpdateUIStatus();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kMsgSecond:
|
case kMsgSecond:
|
||||||
@@ -221,11 +223,28 @@ InquiryPanel::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
scanningTime = scanningTime + 1;
|
scanningTime = scanningTime + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fRemoteList->CurrentSelection() < 0 || fScanning)
|
if (fRetrieving) {
|
||||||
fAddButton->SetEnabled(false);
|
|
||||||
else
|
if (retrievalIndex < fDiscoveryAgent->RetrieveDevices(0).CountItems()) {
|
||||||
fAddButton->SetEnabled(true);
|
|
||||||
|
((DeviceListItem*)fRemoteList->ItemAt(retrievalIndex))->
|
||||||
|
SetDevice((BluetoothDevice*)fDiscoveryAgent->RetrieveDevices(0).ItemAt(retrievalIndex));
|
||||||
|
|
||||||
|
fRemoteList->Invalidate();
|
||||||
|
retrievalIndex++;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
fRetrieving = false;
|
||||||
|
retrievalIndex = 0;
|
||||||
|
|
||||||
|
fScanProgress->SetBarColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
fScanProgress->SetTrailingText("Scanning completed ...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateUIStatus();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -244,12 +263,19 @@ InquiryPanel::UpdateUIStatus(void)
|
|||||||
fInquiryButton->SetEnabled(false);
|
fInquiryButton->SetEnabled(false);
|
||||||
fScanProgress->SetBarColor(activeColor);
|
fScanProgress->SetBarColor(activeColor);
|
||||||
|
|
||||||
} else {
|
} else if (fRetrieving) {
|
||||||
fInquiryButton->SetEnabled(true);
|
fInquiryButton->SetEnabled(true);
|
||||||
fScanProgress->SetBarColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
fScanProgress->SetTo(100);
|
fScanProgress->SetTo(100);
|
||||||
fScanProgress->SetText("Scan completed");
|
fScanProgress->SetTrailingText("Retrieving names ...");
|
||||||
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fRemoteList->CurrentSelection() < 0 || fScanning)
|
||||||
|
fAddButton->SetEnabled(false);
|
||||||
|
else
|
||||||
|
fAddButton->SetEnabled(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ private:
|
|||||||
BMessageRunner* fRunner;
|
BMessageRunner* fRunner;
|
||||||
|
|
||||||
bool fScanning;
|
bool fScanning;
|
||||||
|
bool fRetrieving;
|
||||||
LocalDevice* fLocalDevice;
|
LocalDevice* fLocalDevice;
|
||||||
DiscoveryAgent* fDiscoveryAgent;
|
DiscoveryAgent* fDiscoveryAgent;
|
||||||
DiscoveryListener* fDiscoveryListener;
|
DiscoveryListener* fDiscoveryListener;
|
||||||
|
|||||||
Reference in New Issue
Block a user