[Haiku-commits] r29366 - haiku/trunk/src/preferences/bluetooth

oruizdorantes at BerliOS oruizdorantes at mail.berlios.de
Sun Mar 1 15:48:12 CET 2009


Author: oruizdorantes
Date: 2009-03-01 15:48:11 +0100 (Sun, 01 Mar 2009)
New Revision: 29366
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=29366&view=rev

Modified:
   haiku/trunk/src/preferences/bluetooth/DeviceListItem.h
   haiku/trunk/src/preferences/bluetooth/InquiryPanel.cpp
   haiku/trunk/src/preferences/bluetooth/InquiryPanel.h
Log:
- Add the retrieval of remote names to the discovered devices



Modified: haiku/trunk/src/preferences/bluetooth/DeviceListItem.h
===================================================================
--- haiku/trunk/src/preferences/bluetooth/DeviceListItem.h	2009-03-01 14:44:56 UTC (rev 29365)
+++ haiku/trunk/src/preferences/bluetooth/DeviceListItem.h	2009-03-01 14:48:11 UTC (rev 29366)
@@ -27,10 +27,9 @@
 		void Update(BView *owner, const BFont *font);
 		
 		static int Compare(const void *firstArg, const void *secondArg);
-
-	private:
 		void SetDevice(BluetoothDevice* bDevice);
 
+	private:
 		BluetoothDevice*	fDevice;
 		bdaddr_t			fAddress;
 		DeviceClass			fClass;

Modified: haiku/trunk/src/preferences/bluetooth/InquiryPanel.cpp
===================================================================
--- haiku/trunk/src/preferences/bluetooth/InquiryPanel.cpp	2009-03-01 14:44:56 UTC (rev 29365)
+++ haiku/trunk/src/preferences/bluetooth/InquiryPanel.cpp	2009-03-01 14:48:11 UTC (rev 29366)
@@ -85,6 +85,7 @@
  :	BWindow(frame, "Bluetooth", B_FLOATING_WINDOW,
  		B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS,
  		B_ALL_WORKSPACES ), fScanning(false)
+ 						  , fRetrieving(false)
  						  , fLocalDevice(lDevice)
 {
 //	BRect iDontCare(0,0,0,0);
@@ -157,6 +158,7 @@
 {
 	static float timer = 0; // expected time of the inquiry process
 	static float scanningTime = 0;
+	static int32 retrievalIndex = 0;
 	
 	switch (message->what) {
 		case kMsgInquiry:
@@ -194,19 +196,19 @@
 
 		case kMsgStart:
 			fRemoteList->MakeEmpty();
-			fScanProgress->Reset();
+			fScanProgress->Reset();			
+			scanningTime = 0;			
+			fScanning = true;
 			
-			scanningTime = 0;			
-			fScanning = true;			
 			UpdateUIStatus();
-			
 		break;
 
 		case kMsgFinish:
-			
+			retrievalIndex = 0;
 			fScanning = false;
+			fRetrieving = true;
+
 			UpdateUIStatus();
-			
 		break;
 		
 		case kMsgSecond:
@@ -221,11 +223,28 @@
 
 				scanningTime = scanningTime + 1;
 			}
-			
-			if (fRemoteList->CurrentSelection() < 0 || fScanning)
-				fAddButton->SetEnabled(false);
-			else
-				fAddButton->SetEnabled(true);
+				
+			if (fRetrieving) {
+				
+				if (retrievalIndex < fDiscoveryAgent->RetrieveDevices(0).CountItems()) {
+					
+					((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;
 
@@ -244,12 +263,19 @@
 		fInquiryButton->SetEnabled(false);
 		fScanProgress->SetBarColor(activeColor);
 			
-	} else {
+	} else if (fRetrieving) {
 		fInquiryButton->SetEnabled(true);
-		fScanProgress->SetBarColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 		fScanProgress->SetTo(100);
-		fScanProgress->SetText("Scan completed");		
+		fScanProgress->SetTrailingText("Retrieving names ...");
+	} else {
+
 	}
+	
+	if (fRemoteList->CurrentSelection() < 0 || fScanning)
+		fAddButton->SetEnabled(false);
+	else
+		fAddButton->SetEnabled(true);
+
 }
 
 

Modified: haiku/trunk/src/preferences/bluetooth/InquiryPanel.h
===================================================================
--- haiku/trunk/src/preferences/bluetooth/InquiryPanel.h	2009-03-01 14:44:56 UTC (rev 29365)
+++ haiku/trunk/src/preferences/bluetooth/InquiryPanel.h	2009-03-01 14:48:11 UTC (rev 29366)
@@ -37,6 +37,7 @@
 	BMessageRunner*			fRunner;
 	
 	bool					fScanning;
+	bool					fRetrieving;
 	LocalDevice*			fLocalDevice;
 	DiscoveryAgent*			fDiscoveryAgent;
 	DiscoveryListener*		fDiscoveryListener;




More information about the Haiku-commits mailing list