mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 811569 - Patch 4: Remove asynchronous function GetProperty , r=echou
This commit is contained in:
parent
86d8eef233
commit
9ae2cfbdcb
@ -314,8 +314,9 @@ BluetoothService::Cleanup()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothService::RegisterBluetoothSignalHandler(const nsAString& aNodeName,
|
||||
BluetoothSignalObserver* aHandler)
|
||||
BluetoothService::RegisterBluetoothSignalHandler(
|
||||
const nsAString& aNodeName,
|
||||
BluetoothSignalObserver* aHandler)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aHandler);
|
||||
@ -331,8 +332,9 @@ BluetoothService::RegisterBluetoothSignalHandler(const nsAString& aNodeName,
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothService::UnregisterBluetoothSignalHandler(const nsAString& aNodeName,
|
||||
BluetoothSignalObserver* aHandler)
|
||||
BluetoothService::UnregisterBluetoothSignalHandler(
|
||||
const nsAString& aNodeName,
|
||||
BluetoothSignalObserver* aHandler)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aHandler);
|
||||
|
@ -166,20 +166,6 @@ public:
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
* Fetches the propertes for the specified object
|
||||
*
|
||||
* @param aType Type of the object (see BluetoothObjectType in BluetoothCommon.h)
|
||||
* @param aPath Path of the object
|
||||
* @param aRunnable Runnable to return to after receiving callback
|
||||
*
|
||||
* @return NS_OK on function run, NS_ERROR_FAILURE otherwise
|
||||
*/
|
||||
virtual nsresult
|
||||
GetProperties(BluetoothObjectType aType,
|
||||
const nsAString& aPath,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
* Fetches the propertes for the specified device
|
||||
*
|
||||
* @param aSignal BluetoothSignal to be distrubuted after retrieving device properties
|
||||
@ -312,9 +298,6 @@ public:
|
||||
protected:
|
||||
BluetoothService()
|
||||
: mEnabled(false)
|
||||
#ifdef DEBUG
|
||||
, mLastRequestedEnable(false)
|
||||
#endif
|
||||
{
|
||||
mBluetoothSignalObserverTable.Init();
|
||||
}
|
||||
@ -403,10 +386,6 @@ protected:
|
||||
BluetoothManagerList mLiveManagers;
|
||||
|
||||
bool mEnabled;
|
||||
|
||||
#ifdef DEBUG
|
||||
bool mLastRequestedEnable;
|
||||
#endif
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
@ -189,8 +189,6 @@ BluetoothParent::RecvPBluetoothRequestConstructor(
|
||||
return actor->DoRequest(aRequest.get_DefaultAdapterPathRequest());
|
||||
case Request::TSetPropertyRequest:
|
||||
return actor->DoRequest(aRequest.get_SetPropertyRequest());
|
||||
case Request::TGetPropertyRequest:
|
||||
return actor->DoRequest(aRequest.get_GetPropertyRequest());
|
||||
case Request::TStartDiscoveryRequest:
|
||||
return actor->DoRequest(aRequest.get_StartDiscoveryRequest());
|
||||
case Request::TStopDiscoveryRequest:
|
||||
@ -318,20 +316,6 @@ BluetoothRequestParent::DoRequest(const SetPropertyRequest& aRequest)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothRequestParent::DoRequest(const GetPropertyRequest& aRequest)
|
||||
{
|
||||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TGetPropertyRequest);
|
||||
|
||||
nsresult rv =
|
||||
mService->GetProperties(aRequest.type(), aRequest.path(),
|
||||
mReplyRunnable.get());
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothRequestParent::DoRequest(const StartDiscoveryRequest& aRequest)
|
||||
{
|
||||
|
@ -140,15 +140,6 @@ BluetoothServiceChildProcess::StartDiscoveryInternal(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::GetProperties(BluetoothObjectType aType,
|
||||
const nsAString& aPath,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, GetPropertyRequest(aType, nsString(aPath)));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::SetProperty(BluetoothObjectType aType,
|
||||
const nsAString& aPath,
|
||||
|
@ -59,11 +59,6 @@ public:
|
||||
StartDiscoveryInternal(const nsAString& aAdapterPath,
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
GetProperties(BluetoothObjectType aType,
|
||||
const nsAString& aPath,
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
SetProperty(BluetoothObjectType aType,
|
||||
const nsAString& aPath,
|
||||
|
@ -309,10 +309,7 @@ public:
|
||||
|
||||
// Get device properties and then send to BluetoothAdapter
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
if (!bs) {
|
||||
NS_WARNING("BluetoothService not available!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
|
||||
|
||||
// Due to the fact that we need to queue the dbus call to the command thread
|
||||
// inside the bluetoothservice, we have to route the call down to the main
|
||||
@ -365,6 +362,8 @@ static void
|
||||
UnpackIntMessage(DBusMessage* aMsg, DBusError* aErr,
|
||||
BluetoothValue& aValue, nsAString& aErrorStr)
|
||||
{
|
||||
MOZ_ASSERT(aMsg);
|
||||
|
||||
DBusError err;
|
||||
dbus_error_init(&err);
|
||||
if (!IsDBusMessageError(aMsg, aErr, aErrorStr)) {
|
||||
@ -496,7 +495,7 @@ AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data)
|
||||
errorStr.AssignLiteral("Invalid arguments for RequestConfirmation() method");
|
||||
} else {
|
||||
parameters.AppendElement(BluetoothNamedValue(
|
||||
NS_LITERAL_STRING("address"),
|
||||
NS_LITERAL_STRING("path"),
|
||||
NS_ConvertUTF8toUTF16(objectPath)));
|
||||
parameters.AppendElement(BluetoothNamedValue(
|
||||
NS_LITERAL_STRING("passkey"),
|
||||
@ -528,7 +527,7 @@ AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data)
|
||||
errorStr.AssignLiteral("Invalid arguments for RequestPinCode() method");
|
||||
} else {
|
||||
parameters.AppendElement(BluetoothNamedValue(
|
||||
NS_LITERAL_STRING("address"),
|
||||
NS_LITERAL_STRING("path"),
|
||||
NS_ConvertUTF8toUTF16(objectPath)));
|
||||
|
||||
KeepDBusPairingMessage(GetAddressFromObjectPath(
|
||||
@ -556,7 +555,7 @@ AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data)
|
||||
errorStr.AssignLiteral("Invalid arguments for RequestPasskey() method");
|
||||
} else {
|
||||
parameters.AppendElement(BluetoothNamedValue(
|
||||
NS_LITERAL_STRING("address"),
|
||||
NS_LITERAL_STRING("path"),
|
||||
NS_ConvertUTF8toUTF16(objectPath)));
|
||||
|
||||
KeepDBusPairingMessage(GetAddressFromObjectPath(
|
||||
@ -1779,68 +1778,54 @@ public:
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
}
|
||||
|
||||
~BluetoothDevicePropertiesRunnable()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
nsString devicePath;
|
||||
BluetoothValue v = mSignal.value();
|
||||
if (v.type() == BluetoothValue::TArrayOfBluetoothNamedValue &&
|
||||
v.get_ArrayOfBluetoothNamedValue().Length() ) {
|
||||
const InfallibleTArray<BluetoothNamedValue>& arr = v.get_ArrayOfBluetoothNamedValue();
|
||||
NS_ASSERTION(arr[0].value().type() == BluetoothValue::TnsString, "failed to get_nsString");
|
||||
devicePath = arr[0].value().get_nsString();
|
||||
}
|
||||
else if (v.type() == BluetoothValue::TnsString) {
|
||||
devicePath = v.get_nsString();
|
||||
}
|
||||
else {
|
||||
if (v.type() != BluetoothValue::TArrayOfBluetoothNamedValue ||
|
||||
v.get_ArrayOfBluetoothNamedValue().Length() == 0) {
|
||||
NS_WARNING("Invalid value type for GetDeviceProperties() method");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
const InfallibleTArray<BluetoothNamedValue>& arr =
|
||||
v.get_ArrayOfBluetoothNamedValue();
|
||||
NS_ASSERTION(arr[0].name().EqualsLiteral("path"), "failed to get object path");
|
||||
NS_ASSERTION(arr[0].value().type() == BluetoothValue::TnsString,
|
||||
"failed to get_nsString");
|
||||
devicePath = arr[0].value().get_nsString();
|
||||
|
||||
BluetoothValue prop;
|
||||
if (!GetPropertiesInternal(devicePath, DBUS_DEVICE_IFACE, prop)) {
|
||||
NS_WARNING("Getting properties failed!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
InfallibleTArray<BluetoothNamedValue> properties(prop.get_ArrayOfBluetoothNamedValue());
|
||||
if (v.type() == BluetoothValue::TArrayOfBluetoothNamedValue) {
|
||||
// Return original dbus message parameters and also device name
|
||||
// for agent events "RequestConfirmation", "RequestPinCode", and "RequestPasskey"
|
||||
InfallibleTArray<BluetoothNamedValue> parameters(v.get_ArrayOfBluetoothNamedValue());
|
||||
InfallibleTArray<BluetoothNamedValue>& properties =
|
||||
prop.get_ArrayOfBluetoothNamedValue();
|
||||
|
||||
// For consistency, append path
|
||||
nsString path = parameters[0].value();
|
||||
BluetoothNamedValue pathprop;
|
||||
pathprop.name().AssignLiteral("Path");
|
||||
pathprop.value() = path;
|
||||
parameters.AppendElement(pathprop);
|
||||
// Return original dbus message parameters and also device name
|
||||
// for agent events "RequestConfirmation", "RequestPinCode", and "RequestPasskey"
|
||||
InfallibleTArray<BluetoothNamedValue>& parameters =
|
||||
v.get_ArrayOfBluetoothNamedValue();
|
||||
|
||||
// Replace object path with device address
|
||||
nsString address = GetAddressFromObjectPath(path);
|
||||
parameters[0].value() = address;
|
||||
// Replace object path with device address
|
||||
nsString address = GetAddressFromObjectPath(devicePath);
|
||||
parameters[0].name().AssignLiteral("address");
|
||||
parameters[0].value() = address;
|
||||
|
||||
uint8_t i;
|
||||
for (i = 0; i < properties.Length(); i++) {
|
||||
// Append device name
|
||||
if (properties[i].name().EqualsLiteral("Name")) {
|
||||
properties[i].name().AssignLiteral("name");
|
||||
parameters.AppendElement(properties[i]);
|
||||
mSignal.value() = parameters;
|
||||
break;
|
||||
}
|
||||
uint8_t i;
|
||||
for (i = 0; i < properties.Length(); i++) {
|
||||
// Append device name
|
||||
if (properties[i].name().EqualsLiteral("Name")) {
|
||||
properties[i].name().AssignLiteral("name");
|
||||
parameters.AppendElement(properties[i]);
|
||||
mSignal.value() = parameters;
|
||||
break;
|
||||
}
|
||||
NS_ASSERTION(i != properties.Length(), "failed to get device name");
|
||||
} else {
|
||||
// Return all device properties for event "DeviceCreated", including device path
|
||||
properties.AppendElement(BluetoothNamedValue(NS_LITERAL_STRING("Path"), mSignal.value()));
|
||||
mSignal.value() = properties;
|
||||
}
|
||||
NS_ASSERTION(i != properties.Length(), "failed to get device name");
|
||||
|
||||
nsRefPtr<DistributeBluetoothSignalTask> t =
|
||||
new DistributeBluetoothSignalTask(mSignal);
|
||||
@ -1921,36 +1906,6 @@ private:
|
||||
nsTArray<nsString> mDeviceAddresses;
|
||||
};
|
||||
|
||||
nsresult
|
||||
BluetoothDBusService::GetProperties(BluetoothObjectType aType,
|
||||
const nsAString& aPath,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Must be called from main thread!");
|
||||
|
||||
MOZ_ASSERT(aType < ArrayLength(sBluetoothDBusIfaces));
|
||||
MOZ_ASSERT(aType < ArrayLength(sBluetoothDBusPropCallbacks));
|
||||
|
||||
const char* interface = sBluetoothDBusIfaces[aType];
|
||||
DBusCallback callback = sBluetoothDBusPropCallbacks[aType];
|
||||
|
||||
nsRefPtr<BluetoothReplyRunnable> runnable = aRunnable;
|
||||
|
||||
if (!dbus_func_args_async(mConnection,
|
||||
1000,
|
||||
callback,
|
||||
(void*)aRunnable,
|
||||
NS_ConvertUTF16toUTF8(aPath).get(),
|
||||
interface,
|
||||
"GetProperties",
|
||||
DBUS_TYPE_INVALID)) {
|
||||
NS_WARNING("Could not start async function!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
runnable.forget();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothDBusService::GetDevicePropertiesInternal(const BluetoothSignal& aSignal)
|
||||
{
|
||||
|
@ -41,11 +41,6 @@ public:
|
||||
virtual nsresult StopDiscoveryInternal(const nsAString& aAdapterPath,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual nsresult
|
||||
GetProperties(BluetoothObjectType aType,
|
||||
const nsAString& aPath,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual nsresult
|
||||
GetDevicePropertiesInternal(const BluetoothSignal& aSignal);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user