From e5efc0a09a047a604fcd6b63347f8053a63606e9 Mon Sep 17 00:00:00 2001 From: hai007 Date: Wed, 8 Mar 2023 15:06:30 -0800 Subject: [PATCH] Add all options to `GNCAdvertisingOptions`, `GNCDiscoveryOptions`, and `GNCConnectionOptions`. PiperOrigin-RevId: 515153199 --- connections/swift/NearbyCoreAdapter/BUILD | 1 + .../GNCAdvertisingOptions+CppConversions.mm | 18 ++++++-- .../Sources/GNCAdvertisingOptions.mm | 5 ++- .../GNCConnectionOptions+CppConversions.h | 2 - .../GNCConnectionOptions+CppConversions.mm | 28 ++++++++++--- .../Sources/GNCConnectionOptions.mm | 11 ++++- .../GNCDiscoveryOptions+CppConversions.mm | 12 ++++-- .../Sources/GNCDiscoveryOptions.mm | 4 +- .../GNCSupportedMediums+CppConversions.h | 38 +++++++++++++++++ .../GNCSupportedMediums+CppConversions.mm | 38 +++++++++++++++++ .../Sources/GNCSupportedMediums.mm | 41 ++++++++++++++++++ .../NearbyCoreAdapter/GNCAdvertisingOptions.h | 34 ++++++++++----- .../NearbyCoreAdapter/GNCConnectionOptions.h | 37 +++++++++++++++- .../NearbyCoreAdapter/GNCDiscoveryOptions.h | 31 +++++++++----- .../NearbyCoreAdapter/GNCSupportedMediums.h | 42 +++++++++++++++++++ .../NearbyCoreAdapter/NearbyCoreAdapter.h | 1 + 16 files changed, 301 insertions(+), 42 deletions(-) create mode 100644 connections/swift/NearbyCoreAdapter/Sources/GNCSupportedMediums+CppConversions.h create mode 100644 connections/swift/NearbyCoreAdapter/Sources/GNCSupportedMediums+CppConversions.mm create mode 100644 connections/swift/NearbyCoreAdapter/Sources/GNCSupportedMediums.mm create mode 100644 connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCSupportedMediums.h diff --git a/connections/swift/NearbyCoreAdapter/BUILD b/connections/swift/NearbyCoreAdapter/BUILD index 573de2a3..212c6fd0 100644 --- a/connections/swift/NearbyCoreAdapter/BUILD +++ b/connections/swift/NearbyCoreAdapter/BUILD @@ -36,6 +36,7 @@ objc_library( "//internal/platform/implementation/apple", # buildcleaner: keep "//third_party/apple_frameworks:Foundation", "//third_party/apple_frameworks:ObjectiveC", + "//third_party/objective_c/google_toolbox_for_mac:GTM_Logger", ], ) diff --git a/connections/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions+CppConversions.mm b/connections/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions+CppConversions.mm index 46369376..3644bf72 100644 --- a/connections/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions+CppConversions.mm +++ b/connections/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions+CppConversions.mm @@ -12,14 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#import "connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCAdvertisingOptions.h" - -#import +#import "connections/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions+CppConversions.h" #include "connections/advertising_options.h" -#import "connections/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions+CppConversions.h" #import "connections/swift/NearbyCoreAdapter/Sources/GNCStrategy+Internal.h" +#import "connections/swift/NearbyCoreAdapter/Sources/GNCSupportedMediums+CppConversions.h" +#import "GoogleToolboxForMac/GTMLogger.h" using ::nearby::connections::AdvertisingOptions; using ::nearby::connections::CppStrategyFromGNCStrategy; @@ -28,7 +27,18 @@ using ::nearby::connections::CppStrategyFromGNCStrategy; - (AdvertisingOptions)toCpp { AdvertisingOptions advertising_options; + advertising_options.strategy = CppStrategyFromGNCStrategy(self.strategy); + advertising_options.allowed = [self.mediums toCpp]; + + advertising_options.auto_upgrade_bandwidth = self.autoUpgradeBandwidth; + advertising_options.low_power = self.lowPower; + advertising_options.enforce_topology_constraints = self.enforceTopologyConstraints; + if (self.enforceTopologyConstraints) { + GTMLoggerError(@"WARNING: Creating ConnectionOptions with enforceTopologyConstraints = true. " + "Make sure you know what you're doing!"); + } + return advertising_options; } diff --git a/connections/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions.mm b/connections/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions.mm index c44a5090..1bd9e06e 100644 --- a/connections/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions.mm +++ b/connections/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions.mm @@ -14,8 +14,7 @@ #import "connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCAdvertisingOptions.h" -#import - +#import "connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCSupportedMediums.h" #import "connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCStrategy.h" @implementation GNCAdvertisingOptions @@ -24,6 +23,8 @@ self = [super init]; if (self) { _strategy = strategy; + _autoUpgradeBandwidth = YES; + _mediums = [[GNCSupportedMediums alloc] initWithAllMediumsEnabled]; } return self; } diff --git a/connections/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.h b/connections/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.h index fe6dc3f8..7f2fcb0c 100644 --- a/connections/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.h +++ b/connections/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.h @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#import - #import "connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCConnectionOptions.h" #ifdef __cplusplus diff --git a/connections/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.mm b/connections/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.mm index 27dde784..36d36300 100644 --- a/connections/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.mm +++ b/connections/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.mm @@ -12,20 +12,38 @@ // See the License for the specific language governing permissions and // limitations under the License. -#import "connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCConnectionOptions.h" - -#import +#import "connections/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.h" #include "connections/connection_options.h" +#include "internal/platform/byte_array.h" -#import "connections/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.h" +#import "connections/swift/NearbyCoreAdapter/Sources/GNCSupportedMediums+CppConversions.h" +#import "GoogleToolboxForMac/GTMLogger.h" using ::nearby::connections::ConnectionOptions; @implementation GNCConnectionOptions (CppConversions) - (ConnectionOptions)toCpp { - return ConnectionOptions{}; + ConnectionOptions connection_options; + + connection_options.allowed = [self.mediums toCpp]; + + connection_options.auto_upgrade_bandwidth = self.autoUpgradeBandwidth; + connection_options.low_power = self.lowPower; + connection_options.enforce_topology_constraints = self.enforceTopologyConstraints; + if (self.enforceTopologyConstraints) { + GTMLoggerError(@"WARNING: Creating ConnectionOptions with enforceTopologyConstraints = true. " + "Make sure you know what you're doing!"); + } + + connection_options.keep_alive_interval_millis = self.keepAliveIntervalInSeconds * 1000; + connection_options.keep_alive_timeout_millis = self.keepAliveTimeoutInSeconds * 1000; + + connection_options.remote_bluetooth_mac_address = nearby::ByteArray( + (char *)[self.remoteBluetoothMACAddress bytes], [self.remoteBluetoothMACAddress length]); + + return connection_options; } @end diff --git a/connections/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions.mm b/connections/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions.mm index d90f81af..35587a19 100644 --- a/connections/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions.mm +++ b/connections/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions.mm @@ -14,8 +14,17 @@ #import "connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCConnectionOptions.h" -#import +#import "connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCSupportedMediums.h" @implementation GNCConnectionOptions +- (instancetype)init { + self = [super init]; + if (self) { + _autoUpgradeBandwidth = YES; + _mediums = [[GNCSupportedMediums alloc] initWithAllMediumsEnabled]; + } + return self; +} + @end diff --git a/connections/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions+CppConversions.mm b/connections/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions+CppConversions.mm index 2b2cc124..44939771 100644 --- a/connections/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions+CppConversions.mm +++ b/connections/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions+CppConversions.mm @@ -12,14 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#import "connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCDiscoveryOptions.h" - -#import +#import "connections/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions+CppConversions.h" #include "connections/discovery_options.h" -#import "connections/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions+CppConversions.h" #import "connections/swift/NearbyCoreAdapter/Sources/GNCStrategy+Internal.h" +#import "connections/swift/NearbyCoreAdapter/Sources/GNCSupportedMediums+CppConversions.h" using ::nearby::connections::CppStrategyFromGNCStrategy; using ::nearby::connections::DiscoveryOptions; @@ -28,7 +26,13 @@ using ::nearby::connections::DiscoveryOptions; - (DiscoveryOptions)toCpp { DiscoveryOptions discovery_options; + discovery_options.strategy = CppStrategyFromGNCStrategy(self.strategy); + discovery_options.allowed = [self.mediums toCpp]; + + discovery_options.enforce_topology_constraints = self.enforceTopologyConstraints; + discovery_options.low_power = self.lowPower; + return discovery_options; } diff --git a/connections/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions.mm b/connections/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions.mm index 48354035..4a0245ec 100644 --- a/connections/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions.mm +++ b/connections/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions.mm @@ -14,8 +14,7 @@ #import "connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCDiscoveryOptions.h" -#import - +#import "connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCSupportedMediums.h" #import "connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCStrategy.h" @implementation GNCDiscoveryOptions @@ -24,6 +23,7 @@ self = [super init]; if (self) { _strategy = strategy; + _mediums = [[GNCSupportedMediums alloc] initWithAllMediumsEnabled]; } return self; } diff --git a/connections/swift/NearbyCoreAdapter/Sources/GNCSupportedMediums+CppConversions.h b/connections/swift/NearbyCoreAdapter/Sources/GNCSupportedMediums+CppConversions.h new file mode 100644 index 00000000..f8b5777f --- /dev/null +++ b/connections/swift/NearbyCoreAdapter/Sources/GNCSupportedMediums+CppConversions.h @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import "connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCSupportedMediums.h" + +#ifdef __cplusplus + +namespace nearby { +namespace connections { + +template +class MediumSelector; + +using BooleanMediumSelector = MediumSelector; + +} // namespace connections +} // namespace nearby + +#endif + +@interface GNCSupportedMediums (CppConversions) + +#ifdef __cplusplus +- (nearby::connections::BooleanMediumSelector)toCpp; +#endif + +@end diff --git a/connections/swift/NearbyCoreAdapter/Sources/GNCSupportedMediums+CppConversions.mm b/connections/swift/NearbyCoreAdapter/Sources/GNCSupportedMediums+CppConversions.mm new file mode 100644 index 00000000..1fb2f84b --- /dev/null +++ b/connections/swift/NearbyCoreAdapter/Sources/GNCSupportedMediums+CppConversions.mm @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import "connections/swift/NearbyCoreAdapter/Sources/GNCSupportedMediums+CppConversions.h" + +#include "connections/medium_selector.h" + +#import "connections/swift/NearbyCoreAdapter/Sources/GNCStrategy+Internal.h" + +using ::nearby::connections::BooleanMediumSelector; + +@implementation GNCSupportedMediums (CppConversions) + +- (BooleanMediumSelector)toCpp { + BooleanMediumSelector selector; + + selector.ble = self.ble; + selector.bluetooth = self.bluetooth; + selector.web_rtc = self.webRTC; + selector.wifi_lan = self.wifiLAN; + selector.wifi_hotspot = self.wifiHotspot; + selector.wifi_direct = self.wifiDirect; + + return selector; +} + +@end diff --git a/connections/swift/NearbyCoreAdapter/Sources/GNCSupportedMediums.mm b/connections/swift/NearbyCoreAdapter/Sources/GNCSupportedMediums.mm new file mode 100644 index 00000000..f3a4ed53 --- /dev/null +++ b/connections/swift/NearbyCoreAdapter/Sources/GNCSupportedMediums.mm @@ -0,0 +1,41 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import "connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCSupportedMediums.h" + +@implementation GNCSupportedMediums + +- (instancetype)initWithAllMediumsEnabled { + return [self initWithBluetooth:YES ble:YES webRTC:YES wifiLAN:YES wifiHotspot:YES wifiDirect:YES]; +} + +- (instancetype)initWithBluetooth:(BOOL)bluetooth + ble:(BOOL)ble + webRTC:(BOOL)webRTC + wifiLAN:(BOOL)wifiLAN + wifiHotspot:(BOOL)wifiHotspot + wifiDirect:(BOOL)wifiDirect { + self = [super init]; + if (self) { + _bluetooth = bluetooth; + _ble = ble; + _webRTC = webRTC; + _wifiLAN = wifiLAN; + _wifiHotspot = wifiHotspot; + _wifiDirect = wifiDirect; + } + return self; +} + +@end diff --git a/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCAdvertisingOptions.h b/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCAdvertisingOptions.h index 01414da0..0899aa63 100644 --- a/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCAdvertisingOptions.h +++ b/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCAdvertisingOptions.h @@ -14,23 +14,35 @@ #import +@class GNCSupportedMediums; + typedef NS_CLOSED_ENUM(NSInteger, GNCStrategy); -// TODO(b/239609583): Current sdk only exposes `strategy`, but we should add full support. +NS_ASSUME_NONNULL_BEGIN + /** - * A @c GNCAdvertisingOptions object represents the configuration for local endpoint advertisement. + * A @c GNCAdvertisingOptions object represents the configuration for local + * endpoint advertisement. */ @interface GNCAdvertisingOptions : NSObject -/** - * The connection strategy. - */ +/** The @c GNCStrategy advertising strategy. */ @property(nonatomic, readonly) GNCStrategy strategy; -/** - * @remark init is not an available initializer. - */ -- (nonnull instancetype)init NS_UNAVAILABLE; +/** Defines which mediums are supported for advertising. */ +@property(nonatomic) GNCSupportedMediums* mediums; + +/** Whether bandwidth should automatically upgrade. */ +@property(nonatomic) BOOL autoUpgradeBandwidth; + +/** Whether topology constraints should be enforced. */ +@property(nonatomic) BOOL enforceTopologyConstraints; + +/** Whether low power should be used. */ +@property(nonatomic) BOOL lowPower; + +/** @remark init is not an available initializer. */ +- (instancetype)init NS_UNAVAILABLE; /** * Creates an advertising options object. @@ -39,6 +51,8 @@ typedef NS_CLOSED_ENUM(NSInteger, GNCStrategy); * * @return The initialized options object, or nil if an error occurs. */ -- (nonnull instancetype)initWithStrategy:(GNCStrategy)strategy NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithStrategy:(GNCStrategy)strategy NS_DESIGNATED_INITIALIZER; @end + +NS_ASSUME_NONNULL_END diff --git a/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCConnectionOptions.h b/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCConnectionOptions.h index 565178c1..d8565483 100644 --- a/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCConnectionOptions.h +++ b/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCConnectionOptions.h @@ -14,10 +14,43 @@ #import -// TODO(b/239610255): Current sdk doesn't expose anything, but we should add full support. +@class GNCSupportedMediums; + +NS_ASSUME_NONNULL_BEGIN + /** - * A @c GNCConnectionOptions object represents the configuration for connecting to remote endpoints. + * A @c GNCConnectionOptions object represents the configuration for connecting + * to remote endpoints. */ @interface GNCConnectionOptions : NSObject +/** The @c GNCStrategy advertising strategy. */ +@property(nonatomic) GNCSupportedMediums* mediums; + +/** Whether bandwidth should automatically upgrade. */ +@property(nonatomic) BOOL autoUpgradeBandwidth; + +/** Whether topology constraints should be enforced. */ +@property(nonatomic) BOOL enforceTopologyConstraints; + +/** Whether low power should be used. */ +@property(nonatomic) BOOL lowPower; + +/** The remote bluetooth MAC address for this connection. */ +@property(nonatomic, nullable) NSData* remoteBluetoothMACAddress; + +/** How often to send a keep alive message, in seconds. */ +@property(nonatomic) NSTimeInterval keepAliveIntervalInSeconds; + +/** + * How long to wait without receiving a keep alive message before timing out, + * in seconds. + */ +@property(nonatomic) NSTimeInterval keepAliveTimeoutInSeconds; + +/** @remark create a connection options class. */ +- (instancetype)init NS_DESIGNATED_INITIALIZER; + @end + +NS_ASSUME_NONNULL_END diff --git a/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCDiscoveryOptions.h b/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCDiscoveryOptions.h index c467d61a..5316d6da 100644 --- a/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCDiscoveryOptions.h +++ b/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCDiscoveryOptions.h @@ -14,23 +14,32 @@ #import +@class GNCSupportedMediums; + typedef NS_CLOSED_ENUM(NSInteger, GNCStrategy); -// TODO(b/239610253): Current sdk only exposes `strategy`, but we should add full support. +NS_ASSUME_NONNULL_BEGIN + /** - * A @c GNCDiscoveryOptions object represents the configuration for remote endpoint discovery. + * A @c GNCDiscoveryOptions object represents the configuration for remote + * endpoint discovery. */ @interface GNCDiscoveryOptions : NSObject -/** - * The connection strategy. - */ +/** The @c GNCStrategy advertising strategy. */ @property(nonatomic, readonly) GNCStrategy strategy; -/** - * @remark init is not an available initializer. - */ -- (nonnull instancetype)init NS_UNAVAILABLE; +/** Defines which mediums are supported for advertising.*/ +@property(nonatomic) GNCSupportedMediums* mediums; + +/** Whether topology constraints should be enforced. */ +@property(nonatomic) BOOL enforceTopologyConstraints; + +/** Whether low power should be used. */ +@property(nonatomic) BOOL lowPower; + +/** @remark init is not an available initializer. */ +- (instancetype)init NS_UNAVAILABLE; /** * Creates a discovery options object. @@ -39,6 +48,8 @@ typedef NS_CLOSED_ENUM(NSInteger, GNCStrategy); * * @return The initialized options object, or nil if an error occurs. */ -- (nonnull instancetype)initWithStrategy:(GNCStrategy)strategy NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithStrategy:(GNCStrategy)strategy NS_DESIGNATED_INITIALIZER; @end + +NS_ASSUME_NONNULL_END diff --git a/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCSupportedMediums.h b/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCSupportedMediums.h new file mode 100644 index 00000000..ddb43f5a --- /dev/null +++ b/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCSupportedMediums.h @@ -0,0 +1,42 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface GNCSupportedMediums : NSObject +- (instancetype)init NS_UNAVAILABLE; + +/** Initializes with all mediums being supported. */ +- (instancetype)initWithAllMediumsEnabled; + +/** Initializes, setting properties to the provided values. */ +- (instancetype)initWithBluetooth:(BOOL)bluetooth + ble:(BOOL)ble + webRTC:(BOOL)webRTC + wifiLAN:(BOOL)wifiLAN + wifiHotspot:(BOOL)wifiHotspot + wifiDirect:(BOOL)wifiDirect NS_DESIGNATED_INITIALIZER; + +@property(nonatomic) BOOL bluetooth; +@property(nonatomic) BOOL ble; +@property(nonatomic) BOOL webRTC; +@property(nonatomic) BOOL wifiLAN; +@property(nonatomic) BOOL wifiHotspot; +@property(nonatomic) BOOL wifiDirect; + +@end + +NS_ASSUME_NONNULL_END diff --git a/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/NearbyCoreAdapter.h b/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/NearbyCoreAdapter.h index 37ee0331..26d37bbc 100644 --- a/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/NearbyCoreAdapter.h +++ b/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/NearbyCoreAdapter.h @@ -22,3 +22,4 @@ #import "GNCPayload.h" #import "GNCPayloadDelegate.h" #import "GNCStrategy.h" +#import "GNCSupportedMediums.h"