Resolve allocation of multiple Messengers,(Mika Lindqvist)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26449 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes
2008-07-16 19:04:53 +00:00
parent fe5d1557e4
commit 870ae24a6d
2 changed files with 30 additions and 23 deletions
+7 -6
View File
@@ -55,14 +55,15 @@ class DiscoveryAgent {
*/ */
private: private:
DiscoveryAgent(LocalDevice* ld); DiscoveryAgent(LocalDevice* ld);
void SetLocalDeviceOwner(LocalDevice* ld); ~DiscoveryAgent();
void SetLocalDeviceOwner(LocalDevice* ld);
DiscoveryListener* fLastUsedListener; DiscoveryListener* fLastUsedListener;
LocalDevice* fLocalDevice; LocalDevice* fLocalDevice;
BMessenger* fMessenger;
friend class LocalDevice;
friend class LocalDevice;
}; };
} }
+15 -9
View File
@@ -43,10 +43,9 @@ DiscoveryAgent::StartInquiry(int accessCode, DiscoveryListener* listener)
status_t status_t
DiscoveryAgent::StartInquiry(uint32 accessCode, DiscoveryListener* listener, bigtime_t secs) DiscoveryAgent::StartInquiry(uint32 accessCode, DiscoveryListener* listener, bigtime_t secs)
{ {
BMessenger* btsm = NULL;
size_t size; size_t size;
if ((btsm = _RetrieveBluetoothMessenger()) == NULL) if (fMessenger == NULL)
return B_ERROR; return B_ERROR;
if (secs < 1 || secs > 61 ) if (secs < 1 || secs > 61 )
@@ -81,7 +80,7 @@ DiscoveryAgent::StartInquiry(uint32 accessCode, DiscoveryListener* listener, big
request.AddInt16("eventExpected", HCI_EVENT_INQUIRY_COMPLETE); request.AddInt16("eventExpected", HCI_EVENT_INQUIRY_COMPLETE);
if (btsm->SendMessage(&request, listener) == B_OK) if (fMessenger->SendMessage(&request, listener) == B_OK)
{ {
return B_OK; return B_OK;
} }
@@ -94,10 +93,9 @@ DiscoveryAgent::StartInquiry(uint32 accessCode, DiscoveryListener* listener, big
status_t status_t
DiscoveryAgent::CancelInquiry(DiscoveryListener* listener) DiscoveryAgent::CancelInquiry(DiscoveryListener* listener)
{ {
BMessenger* btsm = NULL; //TODO: this should be a member field
size_t size; size_t size;
if ((btsm = _RetrieveBluetoothMessenger()) == NULL) if (fMessenger == NULL)
return B_ERROR; return B_ERROR;
void* cancelInquiryCommand = NULL; void* cancelInquiryCommand = NULL;
@@ -114,10 +112,10 @@ DiscoveryAgent::CancelInquiry(DiscoveryListener* listener)
request.AddInt16("eventExpected", HCI_EVENT_CMD_STATUS); request.AddInt16("eventExpected", HCI_EVENT_CMD_STATUS);
request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_LINK_CONTROL, OCF_INQUIRY_CANCEL)); request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_LINK_CONTROL, OCF_INQUIRY_CANCEL));
if (btsm->SendMessage(&request, &reply) == B_OK) { if (fMessenger->SendMessage(&request, &reply) == B_OK) {
if (reply.FindInt8("status", &bt_status ) == B_OK ) { if (reply.FindInt8("status", &bt_status ) == B_OK ) {
return bt_status; return bt_status;
} }
} }
return B_ERROR; return B_ERROR;
@@ -131,7 +129,15 @@ DiscoveryAgent::SetLocalDeviceOwner(LocalDevice* ld)
DiscoveryAgent::DiscoveryAgent(LocalDevice* ld) DiscoveryAgent::DiscoveryAgent(LocalDevice* ld)
{ {
fLocalDevice = ld; fLocalDevice = ld;
fMessenger = _RetrieveBluetoothMessenger();
}
DiscoveryAgent::~DiscoveryAgent()
{
if (fMessenger)
delete fMessenger;
} }