diff options
author | Joe George <joe@zeroc.com> | 2019-03-12 15:14:09 -0400 |
---|---|---|
committer | Joe George <joe@zeroc.com> | 2019-03-12 15:14:09 -0400 |
commit | 626656749bb88979ee545a0fc32e933b3ec2f4af (patch) | |
tree | 8ec2520b36a61b095e20e698211abbc56c7bb554 /swift/src | |
parent | Fix for twoway operations (diff) | |
download | ice-626656749bb88979ee545a0fc32e933b3ec2f4af.tar.bz2 ice-626656749bb88979ee545a0fc32e933b3ec2f4af.tar.xz ice-626656749bb88979ee545a0fc32e933b3ec2f4af.zip |
Add iAP ConnectionInfo and EndpointInfo
Diffstat (limited to 'swift/src')
-rw-r--r-- | swift/src/Ice/ConnectionInfoFactory.swift | 28 | ||||
-rw-r--r-- | swift/src/Ice/EndpointI.swift | 22 | ||||
-rw-r--r-- | swift/src/Ice/EndpointInfoFactory.swift | 30 | ||||
-rw-r--r-- | swift/src/IceObjc/Connection.mm | 19 | ||||
-rw-r--r-- | swift/src/IceObjc/Endpoint.mm | 17 | ||||
-rw-r--r-- | swift/src/IceObjc/IceObjcConfig.h | 4 | ||||
-rw-r--r-- | swift/src/IceObjc/IceObjcConnection.h | 16 | ||||
-rw-r--r-- | swift/src/IceObjc/IceObjcEndpoint.h | 14 |
8 files changed, 139 insertions, 11 deletions
diff --git a/swift/src/Ice/ConnectionInfoFactory.swift b/swift/src/Ice/ConnectionInfoFactory.swift index fec177c024f..d8af48eaa7d 100644 --- a/swift/src/Ice/ConnectionInfoFactory.swift +++ b/swift/src/Ice/ConnectionInfoFactory.swift @@ -99,9 +99,33 @@ class ConnectionInfoFactory: ICEConnectionInfoFactory { verified: verified) } + #if os(iOS) || os(watchOS) || os(tvOS) + + static func createIAPConnectionInfo(_ underlying: Any, + incoming: Bool, + adapterName: String, + connectionId: String, + name: String, + manufacturer: String, + modelNumber: String, + firmwareRevision: String, + hardwareRevision: String, + protocol: String) -> Any { + return IAPConnectionInfo(underlying: getUnderlying(underlying), + incoming: incoming, + adapterName: adapterName, + connectionId: connectionId, + name: name, + manufacturer: manufacturer, + modelNumber: modelNumber, + firmwareRevision: firmwareRevision, + hardwareRevision: hardwareRevision, + _protocol: `protocol`) + } + + #endif + static func getUnderlying(_ info: Any) -> ConnectionInfo? { return info as? ConnectionInfo } } - -// TODO: add iAP diff --git a/swift/src/Ice/EndpointI.swift b/swift/src/Ice/EndpointI.swift index b29464c5819..6592d2c1d89 100644 --- a/swift/src/Ice/EndpointI.swift +++ b/swift/src/Ice/EndpointI.swift @@ -125,3 +125,25 @@ class OpaqueEndpointInfoI: EndpointInfoI, OpaqueEndpointInfo { // IceSSL // class SSLEndpointInfoI: EndpointInfoI, SSLEndpointInfo {} + +#if os(iOS) + +// +// IceIAP (iOS only) +// +class IAPEndpointInfoI: EndpointInfoI, IAPEndpointInfo { + var manufacturer: String + var modelNumber: String + var name: String + var _protocol: String + + public init(handle: ICEEndpointInfo, underlying: EndpointInfo?, timeout: Int32, compress: Bool, manufacturer: String, modelNumber: String, name: String, protocol: String) { + self.manufacturer = manufacturer + self.modelNumber = modelNumber + self.name = name + self._protocol = `protocol` + super.init(handle: handle, underlying: underlying, timeout: timeout, compress: compress) + } +} + +#endif diff --git a/swift/src/Ice/EndpointInfoFactory.swift b/swift/src/Ice/EndpointInfoFactory.swift index 511ef7bde0f..ec14462330d 100644 --- a/swift/src/Ice/EndpointInfoFactory.swift +++ b/swift/src/Ice/EndpointInfoFactory.swift @@ -86,7 +86,6 @@ class EndpointInfoFactory: ICEEndpointInfoFactory { timeout: timeout, compress: compress, rawEncoding: EncodingVersion(major: encodingMajor, minor: encodingMajor), - // swiftlint:disable force_cast rawBytes: rawBytes as! [UInt8]) } @@ -100,16 +99,29 @@ class EndpointInfoFactory: ICEEndpointInfoFactory { compress: compress) } -// static func createIAPEndpointInfo(_: ICEEndpointInfo, -// underlying _: Any, -// timeout _: Int32, -// compress _: Bool) -> Any { -// return IAPEndpoin -// } + #if os(iOS) || os(watchOS) || os(tvOS) + + static func createIAPEndpointInfo(_ handle: ICEEndpointInfo, + underlying: Any, + timeout: Int32, + compress: Bool, + manufacturer: String, + modelNumber: String, + name: String, + protocol: String) -> Any { + return IAPEndpointInfoI(handle: handle, + underlying: getUnderlying(underlying), + timeout: timeout, + compress: compress, + manufacturer: manufacturer, + modelNumber: modelNumber, + name: name, + protocol: `protocol`) + } + + #endif static func getUnderlying(_ info: Any) -> EndpointInfo? { return info as? EndpointInfo } } - -// TODO: add iAP on iOS diff --git a/swift/src/IceObjc/Connection.mm b/swift/src/IceObjc/Connection.mm index 7900bae0b08..43ac90d352b 100644 --- a/swift/src/IceObjc/Connection.mm +++ b/swift/src/IceObjc/Connection.mm @@ -319,6 +319,25 @@ verified:sslInfo->verified]; } +#if TARGET_OS_IPHONE + + auto iapInfo = std::dynamic_pointer_cast<IceIAP::ConnectionInfo>(infoPtr); + if(iapInfo) + { + return [factory createIAPConnectionInfo:underlying + incoming:iapInfo->incoming + adapterName:toNSString(iapInfo->adapterName) + connectionId:toNSString(iapInfo->connectionId) + name:toNSString(iapInfo->name) + manufacturer:toNSString(iapInfo->manufacturer) + modelNumber:toNSString(iapInfo->modelNumber) + firmwareRevision:toNSString(iapInfo->firmwareRevision) + hardwareRevision:toNSString(iapInfo->hardwareRevision) + protocol:toNSString(iapInfo->protocol)]; + } + +#endif + return [NSNull null]; } @end diff --git a/swift/src/IceObjc/Endpoint.mm b/swift/src/IceObjc/Endpoint.mm index e9ab867a812..77e372f3a05 100644 --- a/swift/src/IceObjc/Endpoint.mm +++ b/swift/src/IceObjc/Endpoint.mm @@ -151,6 +151,23 @@ compress:infoPtr->compress]; } +#if TARGET_OS_IPHONE + + auto iapInfo = std::dynamic_pointer_cast<IceIAP::EndpointInfo>(infoPtr); + if(iapInfo) + { + return [factory createIAPEndpointInfo:handle + underlying:underlying + timeout:iapInfo->timeout + compress:iapInfo->compress + manufacturer:toNSString(iapInfo->manufacturer) + modelNumber:toNSString(iapInfo->modelNumber) + name:toNSString(iapInfo->name) + protocol:toNSString(iapInfo->protocol)]; + } + +#endif + return [NSNull null]; } @end diff --git a/swift/src/IceObjc/IceObjcConfig.h b/swift/src/IceObjc/IceObjcConfig.h index 6421a352b8b..98957a7d42e 100644 --- a/swift/src/IceObjc/IceObjcConfig.h +++ b/swift/src/IceObjc/IceObjcConfig.h @@ -16,6 +16,10 @@ #include <Ice/Ice.h> #include <IceSSL/IceSSL.h> +#if TARGET_OS_IPHONE +# include <IceIAP/IceIAP.h> +#endif + #endif # define ICE_SWIFT_UNAVAILABLE(msg) __attribute__((unavailable(msg))) diff --git a/swift/src/IceObjc/IceObjcConnection.h b/swift/src/IceObjc/IceObjcConnection.h index d4dff35cef4..575853403e5 100644 --- a/swift/src/IceObjc/IceObjcConnection.h +++ b/swift/src/IceObjc/IceObjcConnection.h @@ -83,6 +83,22 @@ NS_ASSUME_NONNULL_BEGIN cipher:(NSString*)cipher certs:(NSArray<NSString*>*)certs verified:(BOOL)verified; + +#if TARGET_OS_IPHONE + ++(id) createIAPConnectionInfo:(id)underlying + incoming:(BOOL)incoming + adapterName:(NSString*)adapterName + connectionId:(NSString*)connectionId + name:(NSString*)name + manufacturer:(NSString*)manufacturer + modelNumber:(NSString*)modelNumber + firmwareRevision:(NSString*)firmwareRevision + hardwareRevision:(NSString*)hardwareRevision + protocol:(NSString*)protocol; + +#endif + @end #ifdef __cplusplus diff --git a/swift/src/IceObjc/IceObjcEndpoint.h b/swift/src/IceObjc/IceObjcEndpoint.h index 52f2995e74a..031d8e81155 100644 --- a/swift/src/IceObjc/IceObjcEndpoint.h +++ b/swift/src/IceObjc/IceObjcEndpoint.h @@ -67,6 +67,20 @@ NS_ASSUME_NONNULL_BEGIN underlying:(id)underlying timeout:(int32_t)timeout compress:(BOOL)compress; + +#if TARGET_OS_IPHONE + ++(id) createIAPEndpointInfo:(ICEEndpointInfo*)handle + underlying:(id)underlying + timeout:(int32_t)timeout + compress:(BOOL)compress + manufacturer:(NSString*)manufacturer + modelNumber:(NSString*)modelNumber + name:(NSString*)name + protocol:(NSString*)protocol; + +#endif + @end #ifdef __cplusplus |