Skip to content

Commit

Permalink
Blacklisted items are removed when calling getServices/Characteristic…
Browse files Browse the repository at this point in the history
…s/Descriptors.
  • Loading branch information
fokinv authored and zakorgy committed Nov 4, 2016
1 parent dd733f6 commit d30bcbd
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 15 deletions.
7 changes: 6 additions & 1 deletion components/bluetooth/lib.rs
Expand Up @@ -19,6 +19,7 @@ use bluetooth_traits::{BluetoothCharacteristicMsg, BluetoothCharacteristicsMsg};
use bluetooth_traits::{BluetoothDescriptorMsg, BluetoothDescriptorsMsg};
use bluetooth_traits::{BluetoothDeviceMsg, BluetoothError, BluetoothMethodMsg};
use bluetooth_traits::{BluetoothResult, BluetoothServiceMsg, BluetoothServicesMsg};
use bluetooth_traits::blacklist::{uuid_is_blacklisted, Blacklist};
use bluetooth_traits::scanfilter::{BluetoothScanfilter, BluetoothScanfilterSequence, RequestDeviceoptions};
use device::bluetooth::{BluetoothAdapter, BluetoothDevice, BluetoothGATTCharacteristic};
use device::bluetooth::{BluetoothGATTDescriptor, BluetoothGATTService};
Expand Down Expand Up @@ -681,7 +682,8 @@ impl BluetoothManager {
}
}
}
services_vec.retain(|s| self.allowed_services
services_vec.retain(|s| !uuid_is_blacklisted(&s.uuid, Blacklist::All) &&
self.allowed_services
.get(&device_id)
.map_or(false, |uuids| uuids.contains(&s.uuid)));
if services_vec.is_empty() {
Expand Down Expand Up @@ -758,6 +760,7 @@ impl BluetoothManager {
if let Some(uuid) = uuid {
services_vec.retain(|ref s| s.uuid == uuid);
}
services_vec.retain(|s| !uuid_is_blacklisted(&s.uuid, Blacklist::All));
if services_vec.is_empty() {
return drop(sender.send(Err(BluetoothError::NotFound)));
}
Expand Down Expand Up @@ -834,6 +837,7 @@ impl BluetoothManager {
});
}
}
characteristics_vec.retain(|c| !uuid_is_blacklisted(&c.uuid, Blacklist::All));
if characteristics_vec.is_empty() {
return drop(sender.send(Err(BluetoothError::NotFound)));
}
Expand Down Expand Up @@ -888,6 +892,7 @@ impl BluetoothManager {
});
}
}
descriptors_vec.retain(|d| !uuid_is_blacklisted(&d.uuid, Blacklist::All));
if descriptors_vec.is_empty() {
return drop(sender.send(Err(BluetoothError::NotFound)));
}
Expand Down
2 changes: 2 additions & 0 deletions components/bluetooth_traits/Cargo.toml
Expand Up @@ -11,5 +11,7 @@ path = "lib.rs"

[dependencies]
ipc-channel = "0.5"
regex = "0.1.43"
serde = "0.8"
serde_derive = "0.8"
util = {path = "../util"}
File renamed without changes.
3 changes: 3 additions & 0 deletions components/bluetooth_traits/lib.rs
Expand Up @@ -5,9 +5,12 @@
#![feature(proc_macro)]

extern crate ipc_channel;
extern crate regex;
#[macro_use]
extern crate serde_derive;
extern crate util;

pub mod blacklist;
pub mod scanfilter;

use ipc_channel::ipc::IpcSender;
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/bluetooth.rs
Expand Up @@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
use bluetooth_traits::{BluetoothError, BluetoothMethodMsg};
use bluetooth_traits::blacklist::{Blacklist, uuid_is_blacklisted};
use bluetooth_traits::scanfilter::{BluetoothScanfilter, BluetoothScanfilterSequence};
use bluetooth_traits::scanfilter::{RequestDeviceoptions, ServiceUUIDSequence};
use core::clone::Clone;
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/bluetoothremotegattcharacteristic.rs
Expand Up @@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
use bluetooth_traits::BluetoothMethodMsg;
use bluetooth_traits::blacklist::{Blacklist, uuid_is_blacklisted};
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::
BluetoothCharacteristicPropertiesMethods;
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/bluetoothremotegattdescriptor.rs
Expand Up @@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
use bluetooth_traits::BluetoothMethodMsg;
use bluetooth_traits::blacklist::{Blacklist, uuid_is_blacklisted};
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/bluetoothremotegattserver.rs
Expand Up @@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
use bluetooth_traits::BluetoothMethodMsg;
use bluetooth_traits::blacklist::{Blacklist, uuid_is_blacklisted};
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/bluetoothremotegattservice.rs
Expand Up @@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
use bluetooth_traits::BluetoothMethodMsg;
use bluetooth_traits::blacklist::{Blacklist, uuid_is_blacklisted};
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding;
Expand Down
1 change: 0 additions & 1 deletion components/script/lib.rs
Expand Up @@ -96,7 +96,6 @@ extern crate webrender_traits;
extern crate websocket;
extern crate xml5ever;

pub mod bluetooth_blacklist;
mod body;
pub mod clipboard_provider;
mod devtools;
Expand Down
2 changes: 2 additions & 0 deletions components/servo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions ports/cef/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

0 comments on commit d30bcbd

Please sign in to comment.