Remove dedicated implementation of GetAddress and GetName in server side.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28784 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -9,8 +9,6 @@
|
||||
// LocalDevice
|
||||
#define BT_MSG_COUNT_LOCAL_DEVICES 'btCd'
|
||||
#define BT_MSG_ACQUIRE_LOCAL_DEVICE 'btAd'
|
||||
#define BT_MSG_GET_FRIENDLY_NAME 'btFn'
|
||||
#define BT_MSG_GET_ADDRESS 'btGa'
|
||||
#define BT_MSG_HANDLE_SIMPLE_REQUEST 'btsR'
|
||||
#define BT_MSG_ADD_DEVICE 'btDD'
|
||||
|
||||
|
||||
@@ -119,16 +119,14 @@ void BluetoothServer::MessageReceived(BMessage *message)
|
||||
message->FindString("name", &str);
|
||||
BPath path(str.String());
|
||||
|
||||
(Output::Instance()->Post( str.String(), BLACKBOARD_GENERAL));
|
||||
(Output::Instance()->Post(" requested LocalDevice\n", BLACKBOARD_GENERAL));
|
||||
(Output::Instance()->Postf(BLACKBOARD_GENERAL, "Requested LocalDevice %s\n", str.String()));
|
||||
|
||||
LocalDeviceImpl* ldi = LocalDeviceImpl::CreateTransportAccessor(&path);
|
||||
|
||||
if (ldi->GetID() >= 0) {
|
||||
fLocalDevicesList.AddItem(ldi);
|
||||
Output::Instance()->AddTab("Local Device", BLACKBOARD_LD(ldi->GetID()));
|
||||
(Output::Instance()->Post( str.String(), BLACKBOARD_LD(ldi->GetID())));
|
||||
(Output::Instance()->Post(" LocalDevice added\n", BLACKBOARD_LD(ldi->GetID())));
|
||||
(Output::Instance()->Postf(BLACKBOARD_LD(ldi->GetID()), "LocalDevice %s id=%x added\n", str.String(), ldi->GetID()));
|
||||
|
||||
|
||||
} else {
|
||||
@@ -149,14 +147,6 @@ void BluetoothServer::MessageReceived(BMessage *message)
|
||||
status = HandleAcquireLocalDevice(message, &reply);
|
||||
break;
|
||||
|
||||
case BT_MSG_GET_FRIENDLY_NAME:
|
||||
status = HandleGetFriendlyName(message, &reply);
|
||||
break;
|
||||
|
||||
case BT_MSG_GET_ADDRESS:
|
||||
status = HandleGetAddress(message, &reply);
|
||||
break;
|
||||
|
||||
case BT_MSG_HANDLE_SIMPLE_REQUEST:
|
||||
status = HandleSimpleRequest(message, &reply);
|
||||
break;
|
||||
@@ -271,9 +261,10 @@ BluetoothServer::HandleAcquireLocalDevice(BMessage* message, BMessage* reply)
|
||||
|
||||
bdaddr_t local;
|
||||
ldi = fLocalDevicesList.ItemAt(index);
|
||||
if ((ldi->GetAddress(&local, message) == B_OK) && bacmp(&local, &bdaddr)) {
|
||||
break;
|
||||
}
|
||||
// TODO: Only if the property is available
|
||||
//if ((ldi->GetAddress(&local, message) == B_OK) && bacmp(&local, &bdaddr)) {
|
||||
// break;
|
||||
//}
|
||||
}
|
||||
|
||||
} else
|
||||
@@ -305,45 +296,6 @@ BluetoothServer::HandleAcquireLocalDevice(BMessage* message, BMessage* reply)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BluetoothServer::HandleGetFriendlyName(BMessage* message, BMessage* reply)
|
||||
{
|
||||
LocalDeviceImpl* ldi = LocateDelegateFromMessage(message);
|
||||
BString name;
|
||||
|
||||
if (ldi == NULL)
|
||||
return B_ERROR;
|
||||
|
||||
/* If the device was ocupied... Autlock?->LocalDeviceImpl will decide */
|
||||
if (ldi->GetFriendlyName(name, DetachCurrentMessage()) == B_OK) {
|
||||
|
||||
return reply->AddString("friendlyname", name);
|
||||
}
|
||||
|
||||
return B_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BluetoothServer::HandleGetAddress(BMessage* message, BMessage* reply)
|
||||
{
|
||||
LocalDeviceImpl* ldi = LocateDelegateFromMessage(message);
|
||||
bdaddr_t bdaddr;
|
||||
|
||||
if (ldi == NULL)
|
||||
return B_ERROR;
|
||||
|
||||
/* If the device was ocupied... Autlock?->LocalDeviceImpl will decide */
|
||||
status_t status = ldi->GetAddress(&bdaddr, DetachCurrentMessage());
|
||||
if ( status == B_OK) {
|
||||
|
||||
return reply->AddData("bdaddr", B_ANY_TYPE, &bdaddr, sizeof(bdaddr_t));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BluetoothServer::HandleSimpleRequest(BMessage* message, BMessage* reply)
|
||||
{
|
||||
|
||||
@@ -619,72 +619,6 @@ LocalDeviceImpl::LinkKeyNotify(hci_ev_link_key_notify *event, BMessage* request,
|
||||
#endif
|
||||
|
||||
|
||||
status_t
|
||||
LocalDeviceImpl::GetAddress(bdaddr_t* bdaddr, BMessage* request)
|
||||
{
|
||||
ssize_t ssize;
|
||||
|
||||
if (fProperties->FindData("bdaddr", B_ANY_TYPE, 0, (const void **)bdaddr, &ssize) == B_OK) {
|
||||
|
||||
|
||||
/* We have this info, returning back */
|
||||
return B_OK;
|
||||
|
||||
} else {
|
||||
size_t size;
|
||||
|
||||
void* command = buildReadBdAddr(&size);
|
||||
|
||||
/* Adding a wanted event in the queue */
|
||||
request->AddInt16("eventExpected", HCI_EVENT_CMD_COMPLETE);
|
||||
request->AddInt16("opcodeExpected", PACK_OPCODE(OGF_INFORMATIONAL_PARAM, OCF_READ_BD_ADDR));
|
||||
|
||||
AddWantedEvent(request);
|
||||
request->PrintToStream();
|
||||
|
||||
if (((HCITransportAccessor*)fHCIDelegate)->IssueCommand(command, size) == B_ERROR)
|
||||
(Output::Instance()->Post("Command issue error\n", BLACKBOARD_EVENTS));
|
||||
|
||||
(Output::Instance()->Post("Command issued for GetAddress\n", BLACKBOARD_EVENTS));
|
||||
return B_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
LocalDeviceImpl::GetFriendlyName(BString str, BMessage* request)
|
||||
{
|
||||
|
||||
if (fProperties->FindString("friendlyname", &str) == B_OK) {
|
||||
|
||||
(Output::Instance()->Post("Friendly name already present in server\n", BLACKBOARD_EVENTS));
|
||||
/* We have this info, returning back */
|
||||
return B_OK;
|
||||
|
||||
} else {
|
||||
size_t size;
|
||||
|
||||
void* command = buildReadLocalName(&size);
|
||||
|
||||
/* Adding a wanted event in the queue */
|
||||
request->AddInt16("eventExpected", HCI_EVENT_CMD_COMPLETE);
|
||||
request->AddInt16("opcodeExpected", PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_READ_LOCAL_NAME));
|
||||
|
||||
AddWantedEvent(request);
|
||||
request->PrintToStream();
|
||||
|
||||
if (((HCITransportAccessor*)fHCIDelegate)->IssueCommand(command, size) == B_ERROR)
|
||||
(Output::Instance()->Post("Command issue error\n", BLACKBOARD_EVENTS));
|
||||
|
||||
(Output::Instance()->Post("Command issued for GetFriendlyname\n", BLACKBOARD_EVENTS));
|
||||
|
||||
return B_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
LocalDeviceImpl::ProcessSimpleRequest(BMessage* request)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user