diff --git a/Frameworks/Bindings.txt b/Frameworks/Bindings.txt index 702c949d1dd03ac8030c0ef9c5a36af0c325f134..83a8da383de3a57509257d2b3b05af2c65d64fe1 100644 --- a/Frameworks/Bindings.txt +++ b/Frameworks/Bindings.txt @@ -1,4 +1,4 @@ -https://git.xx.network/elixxir/client/-/commit/9a44f79889f967704d60a43f1c24a945028afb06 +https://git.xx.network/elixxir/client/-/commit/57b7e3b88e740c36935ab2da04d94fd5a6a85262 go version go1.17.13 darwin/arm64 Xcode 13.4.1 Build version 13F100 gomobile bind target: ios,iossimulator,macos diff --git a/Frameworks/Bindings.xcframework/Info.plist b/Frameworks/Bindings.xcframework/Info.plist index 3d81013ba0ba606da4b42b6f3119f688c6d9b97d..43fe32dad94767ae305b61db56f5604f8612617e 100644 --- a/Frameworks/Bindings.xcframework/Info.plist +++ b/Frameworks/Bindings.xcframework/Info.plist @@ -6,7 +6,7 @@ <array> <dict> <key>LibraryIdentifier</key> - <string>ios-arm64_x86_64-simulator</string> + <string>macos-arm64_x86_64</string> <key>LibraryPath</key> <string>Bindings.framework</string> <key>SupportedArchitectures</key> @@ -15,13 +15,11 @@ <string>x86_64</string> </array> <key>SupportedPlatform</key> - <string>ios</string> - <key>SupportedPlatformVariant</key> - <string>simulator</string> + <string>macos</string> </dict> <dict> <key>LibraryIdentifier</key> - <string>macos-arm64_x86_64</string> + <string>ios-arm64_x86_64-simulator</string> <key>LibraryPath</key> <string>Bindings.framework</string> <key>SupportedArchitectures</key> @@ -30,7 +28,9 @@ <string>x86_64</string> </array> <key>SupportedPlatform</key> - <string>macos</string> + <string>ios</string> + <key>SupportedPlatformVariant</key> + <string>simulator</string> </dict> <dict> <key>LibraryIdentifier</key> diff --git a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Bindings b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Bindings index 0ce0097a9af5e6db2577a9264a6ca65277b87a5f..381c2ba28c87178ac5f80950ba6439f8b4bfa8f1 100644 Binary files a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Bindings and b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Bindings differ diff --git a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Headers/Bindings.objc.h b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Headers/Bindings.objc.h index 40a89ee2ee4afde62d99dcdcac9ef77d09c7c663..313101ebfb224eb77a7b3e3b99459fab55b79c3c 100644 --- a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Headers/Bindings.objc.h +++ b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Headers/Bindings.objc.h @@ -33,6 +33,7 @@ @class BindingsGroupSendReport; @class BindingsMessage; @class BindingsNodeRegistrationReport; +@class BindingsNotificationReport; @class BindingsProgress; @class BindingsReceivedFile; @class BindingsReceptionIdentity; @@ -78,6 +79,8 @@ @class BindingsSingleUseResponse; @protocol BindingsStopper; @class BindingsStopper; +@protocol BindingsTrackServicesCallback; +@class BindingsTrackServicesCallback; @protocol BindingsUdLookupCallback; @class BindingsUdLookupCallback; @protocol BindingsUdNetworkStatus; @@ -196,6 +199,10 @@ Parameters: - (void)stop; @end +@protocol BindingsTrackServicesCallback <NSObject> +- (void)callback:(NSData* _Nullable)marshalData err:(NSError* _Nullable)err; +@end + @protocol BindingsUdLookupCallback <NSObject> - (void)callback:(NSData* _Nullable)contactBytes err:(NSError* _Nullable)err; @end @@ -552,6 +559,17 @@ If the network follower is running and this fails, the Cmix object will most likely be in an unrecoverable state and need to be trashed. */ - (BOOL)stopNetworkFollower:(NSError* _Nullable* _Nullable)error; +/** + * TrackServices will return via a callback the list of services the +backend keeps track of, which is formally referred to as a +[message.ServiceList]. This may be passed into other bindings call which +may need context on the available services for this client. + +Parameters: + - cb - A TrackServicesCallback, which will be passed the marshalled + message.ServiceList. + */ +- (void)trackServices:(id<BindingsTrackServicesCallback> _Nullable)cb; /** * WaitForNetwork will block until either the network is healthy or the passed timeout is reached. It will return true if the network is healthy. @@ -1406,6 +1424,57 @@ Cmix.GetNodeRegistrationStatus returns JSON marshalled. @property (nonatomic) long numberOfNodes; @end +/** + * NotificationReport is the bindings' representation for notifications for +this user. + +Example NotificationReport JSON: + +{ + "ForMe": true, + "Type": "e2e", + "Source": "dGVzdGVyMTIzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +} + +Given the Type, the Source value will have specific contextual meanings. +Below is a table that will define the contextual meaning of the Source field +given all possible Type fields. + + TYPE | SOURCE | DESCRIPTION + ________________________________________________________________________________________ + "default" | recipient user ID | A message with no association. + "request" | sender user ID | A channel request has been received, from Source. + "reset" | sender user ID | A channel reset has been received. + "confirm" | sender user ID | A channel request has been accepted. + "silent" | sender user ID | A message where the user should not be notified. + "e2e" | sender user ID | A reception of an E2E message. + "group" | group ID | A reception of a group chat message. + "endFT" | sender user ID | The last message sent confirming end of file transfer. + "groupRQ" | sender user ID | A request from Source to join a group chat. + todo iterate over this docstring, ensure descriptions/sources are + still accurate (they are from the old implementation + */ +@interface BindingsNotificationReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * ForMe determines whether this value is for the user. If it is +false, this report may be ignored. + */ +@property (nonatomic) BOOL forMe; +/** + * Type is the type of notification. The list can be seen + */ +@property (nonatomic) NSString* _Nonnull type; +/** + * Source is the source of the notification. + */ +@property (nonatomic) NSData* _Nullable source; +@end + /** * Progress is a public struct that represents the progress of an in-progress file transfer. @@ -1810,6 +1879,25 @@ Returns: */ FOUNDATION_EXPORT NSData* _Nullable BindingsGetIDFromContact(NSData* _Nullable marshaledContact, NSError* _Nullable* _Nullable error); +/** + * GetNotificationsReport parses the received notification data to determine which +notifications are for this user. // This returns the JSON-marshalled +NotificationReports. + +Parameters: + - e2eID - e2e object ID in the tracker + - notificationCSV - the notification data received from the + notifications' server. + - marshalledServices - the JSON-marshalled list of services the backend + keeps track of. Refer to Cmix.TrackServices for information about this. + +Returns: + - []byte - A JSON marshalled NotificationReports. Some NotificationReport's + within in this structure may have their NotificationReport.ForMe + set to false. These may be ignored. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetNotificationsReport(long e2eId, NSString* _Nullable notificationCSV, NSData* _Nullable marshalledServices, NSError* _Nullable* _Nullable error); + /** * GetPubkeyFromContact returns the DH public key in the [contact.Contact] object. @@ -2283,6 +2371,8 @@ FOUNDATION_EXPORT BOOL BindingsUpdateCommonErrors(NSString* _Nullable jsonFile, @class BindingsStopper; +@class BindingsTrackServicesCallback; + @class BindingsUdLookupCallback; @class BindingsUdNetworkStatus; @@ -2564,6 +2654,45 @@ registered listener. - (void)stop; @end +/** + * TrackServicesCallback is the callback for Cmix.TrackServices. +This will pass to the user a JSON-marshalled list of backend services. +If there was an error retrieving or marshalling the service list, +there is an error for the second parameter which will be non-null. + +Example JSON: + +[ + { + "Id": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "Services": [ + { + "Identifier": null, + "Tag": "test", + "Metadata": null + } + ] + }, + { + "Id": "AAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "Services": [ + { + "Identifier": null, + "Tag": "test", + "Metadata": null + } + ] + }, +] + */ +@interface BindingsTrackServicesCallback : NSObject <goSeqRefInterface, BindingsTrackServicesCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)marshalData err:(NSError* _Nullable)err; +@end + /** * UdLookupCallback contains the callback called by LookupUD that returns the contact that matches the passed in ID. diff --git a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Bindings b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Bindings index c302dc6cf19adf806e3a638565957629c1798bba..1005ae67edb1b57deb38ed23b9639767d796f5ab 100644 Binary files a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Bindings and b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Bindings differ diff --git a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Headers/Bindings.objc.h b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Headers/Bindings.objc.h index 40a89ee2ee4afde62d99dcdcac9ef77d09c7c663..313101ebfb224eb77a7b3e3b99459fab55b79c3c 100644 --- a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Headers/Bindings.objc.h +++ b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Headers/Bindings.objc.h @@ -33,6 +33,7 @@ @class BindingsGroupSendReport; @class BindingsMessage; @class BindingsNodeRegistrationReport; +@class BindingsNotificationReport; @class BindingsProgress; @class BindingsReceivedFile; @class BindingsReceptionIdentity; @@ -78,6 +79,8 @@ @class BindingsSingleUseResponse; @protocol BindingsStopper; @class BindingsStopper; +@protocol BindingsTrackServicesCallback; +@class BindingsTrackServicesCallback; @protocol BindingsUdLookupCallback; @class BindingsUdLookupCallback; @protocol BindingsUdNetworkStatus; @@ -196,6 +199,10 @@ Parameters: - (void)stop; @end +@protocol BindingsTrackServicesCallback <NSObject> +- (void)callback:(NSData* _Nullable)marshalData err:(NSError* _Nullable)err; +@end + @protocol BindingsUdLookupCallback <NSObject> - (void)callback:(NSData* _Nullable)contactBytes err:(NSError* _Nullable)err; @end @@ -552,6 +559,17 @@ If the network follower is running and this fails, the Cmix object will most likely be in an unrecoverable state and need to be trashed. */ - (BOOL)stopNetworkFollower:(NSError* _Nullable* _Nullable)error; +/** + * TrackServices will return via a callback the list of services the +backend keeps track of, which is formally referred to as a +[message.ServiceList]. This may be passed into other bindings call which +may need context on the available services for this client. + +Parameters: + - cb - A TrackServicesCallback, which will be passed the marshalled + message.ServiceList. + */ +- (void)trackServices:(id<BindingsTrackServicesCallback> _Nullable)cb; /** * WaitForNetwork will block until either the network is healthy or the passed timeout is reached. It will return true if the network is healthy. @@ -1406,6 +1424,57 @@ Cmix.GetNodeRegistrationStatus returns JSON marshalled. @property (nonatomic) long numberOfNodes; @end +/** + * NotificationReport is the bindings' representation for notifications for +this user. + +Example NotificationReport JSON: + +{ + "ForMe": true, + "Type": "e2e", + "Source": "dGVzdGVyMTIzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +} + +Given the Type, the Source value will have specific contextual meanings. +Below is a table that will define the contextual meaning of the Source field +given all possible Type fields. + + TYPE | SOURCE | DESCRIPTION + ________________________________________________________________________________________ + "default" | recipient user ID | A message with no association. + "request" | sender user ID | A channel request has been received, from Source. + "reset" | sender user ID | A channel reset has been received. + "confirm" | sender user ID | A channel request has been accepted. + "silent" | sender user ID | A message where the user should not be notified. + "e2e" | sender user ID | A reception of an E2E message. + "group" | group ID | A reception of a group chat message. + "endFT" | sender user ID | The last message sent confirming end of file transfer. + "groupRQ" | sender user ID | A request from Source to join a group chat. + todo iterate over this docstring, ensure descriptions/sources are + still accurate (they are from the old implementation + */ +@interface BindingsNotificationReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * ForMe determines whether this value is for the user. If it is +false, this report may be ignored. + */ +@property (nonatomic) BOOL forMe; +/** + * Type is the type of notification. The list can be seen + */ +@property (nonatomic) NSString* _Nonnull type; +/** + * Source is the source of the notification. + */ +@property (nonatomic) NSData* _Nullable source; +@end + /** * Progress is a public struct that represents the progress of an in-progress file transfer. @@ -1810,6 +1879,25 @@ Returns: */ FOUNDATION_EXPORT NSData* _Nullable BindingsGetIDFromContact(NSData* _Nullable marshaledContact, NSError* _Nullable* _Nullable error); +/** + * GetNotificationsReport parses the received notification data to determine which +notifications are for this user. // This returns the JSON-marshalled +NotificationReports. + +Parameters: + - e2eID - e2e object ID in the tracker + - notificationCSV - the notification data received from the + notifications' server. + - marshalledServices - the JSON-marshalled list of services the backend + keeps track of. Refer to Cmix.TrackServices for information about this. + +Returns: + - []byte - A JSON marshalled NotificationReports. Some NotificationReport's + within in this structure may have their NotificationReport.ForMe + set to false. These may be ignored. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetNotificationsReport(long e2eId, NSString* _Nullable notificationCSV, NSData* _Nullable marshalledServices, NSError* _Nullable* _Nullable error); + /** * GetPubkeyFromContact returns the DH public key in the [contact.Contact] object. @@ -2283,6 +2371,8 @@ FOUNDATION_EXPORT BOOL BindingsUpdateCommonErrors(NSString* _Nullable jsonFile, @class BindingsStopper; +@class BindingsTrackServicesCallback; + @class BindingsUdLookupCallback; @class BindingsUdNetworkStatus; @@ -2564,6 +2654,45 @@ registered listener. - (void)stop; @end +/** + * TrackServicesCallback is the callback for Cmix.TrackServices. +This will pass to the user a JSON-marshalled list of backend services. +If there was an error retrieving or marshalling the service list, +there is an error for the second parameter which will be non-null. + +Example JSON: + +[ + { + "Id": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "Services": [ + { + "Identifier": null, + "Tag": "test", + "Metadata": null + } + ] + }, + { + "Id": "AAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "Services": [ + { + "Identifier": null, + "Tag": "test", + "Metadata": null + } + ] + }, +] + */ +@interface BindingsTrackServicesCallback : NSObject <goSeqRefInterface, BindingsTrackServicesCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)marshalData err:(NSError* _Nullable)err; +@end + /** * UdLookupCallback contains the callback called by LookupUD that returns the contact that matches the passed in ID. diff --git a/Frameworks/Bindings.xcframework/macos-arm64_x86_64/Bindings.framework/Versions/A/Bindings b/Frameworks/Bindings.xcframework/macos-arm64_x86_64/Bindings.framework/Versions/A/Bindings index ad4d0f109edc52b1309a375c2bfea9a9b61764ec..2b925090d31ec9d29ff598919efa963e385b8603 100644 Binary files a/Frameworks/Bindings.xcframework/macos-arm64_x86_64/Bindings.framework/Versions/A/Bindings and b/Frameworks/Bindings.xcframework/macos-arm64_x86_64/Bindings.framework/Versions/A/Bindings differ diff --git a/Frameworks/Bindings.xcframework/macos-arm64_x86_64/Bindings.framework/Versions/A/Headers/Bindings.objc.h b/Frameworks/Bindings.xcframework/macos-arm64_x86_64/Bindings.framework/Versions/A/Headers/Bindings.objc.h index 40a89ee2ee4afde62d99dcdcac9ef77d09c7c663..313101ebfb224eb77a7b3e3b99459fab55b79c3c 100644 --- a/Frameworks/Bindings.xcframework/macos-arm64_x86_64/Bindings.framework/Versions/A/Headers/Bindings.objc.h +++ b/Frameworks/Bindings.xcframework/macos-arm64_x86_64/Bindings.framework/Versions/A/Headers/Bindings.objc.h @@ -33,6 +33,7 @@ @class BindingsGroupSendReport; @class BindingsMessage; @class BindingsNodeRegistrationReport; +@class BindingsNotificationReport; @class BindingsProgress; @class BindingsReceivedFile; @class BindingsReceptionIdentity; @@ -78,6 +79,8 @@ @class BindingsSingleUseResponse; @protocol BindingsStopper; @class BindingsStopper; +@protocol BindingsTrackServicesCallback; +@class BindingsTrackServicesCallback; @protocol BindingsUdLookupCallback; @class BindingsUdLookupCallback; @protocol BindingsUdNetworkStatus; @@ -196,6 +199,10 @@ Parameters: - (void)stop; @end +@protocol BindingsTrackServicesCallback <NSObject> +- (void)callback:(NSData* _Nullable)marshalData err:(NSError* _Nullable)err; +@end + @protocol BindingsUdLookupCallback <NSObject> - (void)callback:(NSData* _Nullable)contactBytes err:(NSError* _Nullable)err; @end @@ -552,6 +559,17 @@ If the network follower is running and this fails, the Cmix object will most likely be in an unrecoverable state and need to be trashed. */ - (BOOL)stopNetworkFollower:(NSError* _Nullable* _Nullable)error; +/** + * TrackServices will return via a callback the list of services the +backend keeps track of, which is formally referred to as a +[message.ServiceList]. This may be passed into other bindings call which +may need context on the available services for this client. + +Parameters: + - cb - A TrackServicesCallback, which will be passed the marshalled + message.ServiceList. + */ +- (void)trackServices:(id<BindingsTrackServicesCallback> _Nullable)cb; /** * WaitForNetwork will block until either the network is healthy or the passed timeout is reached. It will return true if the network is healthy. @@ -1406,6 +1424,57 @@ Cmix.GetNodeRegistrationStatus returns JSON marshalled. @property (nonatomic) long numberOfNodes; @end +/** + * NotificationReport is the bindings' representation for notifications for +this user. + +Example NotificationReport JSON: + +{ + "ForMe": true, + "Type": "e2e", + "Source": "dGVzdGVyMTIzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +} + +Given the Type, the Source value will have specific contextual meanings. +Below is a table that will define the contextual meaning of the Source field +given all possible Type fields. + + TYPE | SOURCE | DESCRIPTION + ________________________________________________________________________________________ + "default" | recipient user ID | A message with no association. + "request" | sender user ID | A channel request has been received, from Source. + "reset" | sender user ID | A channel reset has been received. + "confirm" | sender user ID | A channel request has been accepted. + "silent" | sender user ID | A message where the user should not be notified. + "e2e" | sender user ID | A reception of an E2E message. + "group" | group ID | A reception of a group chat message. + "endFT" | sender user ID | The last message sent confirming end of file transfer. + "groupRQ" | sender user ID | A request from Source to join a group chat. + todo iterate over this docstring, ensure descriptions/sources are + still accurate (they are from the old implementation + */ +@interface BindingsNotificationReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * ForMe determines whether this value is for the user. If it is +false, this report may be ignored. + */ +@property (nonatomic) BOOL forMe; +/** + * Type is the type of notification. The list can be seen + */ +@property (nonatomic) NSString* _Nonnull type; +/** + * Source is the source of the notification. + */ +@property (nonatomic) NSData* _Nullable source; +@end + /** * Progress is a public struct that represents the progress of an in-progress file transfer. @@ -1810,6 +1879,25 @@ Returns: */ FOUNDATION_EXPORT NSData* _Nullable BindingsGetIDFromContact(NSData* _Nullable marshaledContact, NSError* _Nullable* _Nullable error); +/** + * GetNotificationsReport parses the received notification data to determine which +notifications are for this user. // This returns the JSON-marshalled +NotificationReports. + +Parameters: + - e2eID - e2e object ID in the tracker + - notificationCSV - the notification data received from the + notifications' server. + - marshalledServices - the JSON-marshalled list of services the backend + keeps track of. Refer to Cmix.TrackServices for information about this. + +Returns: + - []byte - A JSON marshalled NotificationReports. Some NotificationReport's + within in this structure may have their NotificationReport.ForMe + set to false. These may be ignored. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetNotificationsReport(long e2eId, NSString* _Nullable notificationCSV, NSData* _Nullable marshalledServices, NSError* _Nullable* _Nullable error); + /** * GetPubkeyFromContact returns the DH public key in the [contact.Contact] object. @@ -2283,6 +2371,8 @@ FOUNDATION_EXPORT BOOL BindingsUpdateCommonErrors(NSString* _Nullable jsonFile, @class BindingsStopper; +@class BindingsTrackServicesCallback; + @class BindingsUdLookupCallback; @class BindingsUdNetworkStatus; @@ -2564,6 +2654,45 @@ registered listener. - (void)stop; @end +/** + * TrackServicesCallback is the callback for Cmix.TrackServices. +This will pass to the user a JSON-marshalled list of backend services. +If there was an error retrieving or marshalling the service list, +there is an error for the second parameter which will be non-null. + +Example JSON: + +[ + { + "Id": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "Services": [ + { + "Identifier": null, + "Tag": "test", + "Metadata": null + } + ] + }, + { + "Id": "AAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "Services": [ + { + "Identifier": null, + "Tag": "test", + "Metadata": null + } + ] + }, +] + */ +@interface BindingsTrackServicesCallback : NSObject <goSeqRefInterface, BindingsTrackServicesCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)marshalData err:(NSError* _Nullable)err; +@end + /** * UdLookupCallback contains the callback called by LookupUD that returns the contact that matches the passed in ID. diff --git a/Sources/XXClient/CMix/Functors/CMixTrackServices.swift b/Sources/XXClient/CMix/Functors/CMixTrackServices.swift new file mode 100644 index 0000000000000000000000000000000000000000..3f653cb715f7464e6c275ea35c48550d0333634e --- /dev/null +++ b/Sources/XXClient/CMix/Functors/CMixTrackServices.swift @@ -0,0 +1,26 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CMixTrackServices { + public var run: (TrackServicesCallback) -> Void + + public func callAsFunction( + callback: TrackServicesCallback + ) -> Void { + run(callback) + } +} + +extension CMixTrackServices { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixTrackServices { + CMixTrackServices { callback in + bindingsCMix.trackServices(callback.makeBindingsHealthCallback()) + } + } +} + +extension CMixTrackServices { + public static let unimplemented = CMixTrackServices( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/XXClient/Callbacks/TrackServicesCallback.swift b/Sources/XXClient/Callbacks/TrackServicesCallback.swift new file mode 100644 index 0000000000000000000000000000000000000000..df3043bb2a90252e85dc8181fcd3e7f5d6c6265a --- /dev/null +++ b/Sources/XXClient/Callbacks/TrackServicesCallback.swift @@ -0,0 +1,42 @@ +import Bindings +import XCTestDynamicOverlay + +public struct TrackServicesCallback { + public init(handle: @escaping (Result<Data, Error>) -> Void) { + self.handle = handle + } + + public var handle: (Result<Data, Error>) -> Void +} + +extension TrackServicesCallback { + public static let unimplemented = HealthCallback( + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension TrackServicesCallback { + func makeBindingsHealthCallback() -> BindingsTrackServicesCallbackProtocol { + class CallbackObject: NSObject, BindingsTrackServicesCallbackProtocol { + init(_ callback: TrackServicesCallback) { + self.callback = callback + } + + let callback: TrackServicesCallback + + func callback(_ marshalData: Data?, err: Error?) { + if let err = err { + callback.handle(.failure(err)) + return + } + if let marshalData = marshalData { + callback.handle(.success(marshalData)) + return + } + fatalError("BindingsTrackServicesCallback received nil marshalData and err") + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/XXClient/Functors/GetNotificationsReport.swift b/Sources/XXClient/Functors/GetNotificationsReport.swift new file mode 100644 index 0000000000000000000000000000000000000000..0b5d31f8d5ffb7fc0f9f4cd67d6c2b6a0ec11aa1 --- /dev/null +++ b/Sources/XXClient/Functors/GetNotificationsReport.swift @@ -0,0 +1,41 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GetNotificationsReport { + public var run: (Int, String, Data) throws -> NotificationReport + + public func callAsFunction( + e2eId: Int, + notificationCSV: String, + marshaledServices: Data + ) throws -> NotificationReport { + try run(e2eId, notificationCSV, marshaledServices) + } +} + +extension GetNotificationsReport { + public static func live() -> GetNotificationsReport { + GetNotificationsReport { e2eId, notificationCSV, marshaledServices in + var error: NSError? + let result = BindingsGetNotificationsReport( + e2eId, + notificationCSV, + marshaledServices, + &error + ) + if let error = error { + throw error + } + guard let result = result else { + fatalError("BindingsGetNotificationsReport returned nil without providing error") + } + return try NotificationReport.decode(result) + } + } +} + +extension GetNotificationsReport { + public static let unimplemented = GetNotificationsReport( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/XXClient/Models/NotificationReport.swift b/Sources/XXClient/Models/NotificationReport.swift new file mode 100644 index 0000000000000000000000000000000000000000..31c106a34f5a083478522acf542d8b608544a333 --- /dev/null +++ b/Sources/XXClient/Models/NotificationReport.swift @@ -0,0 +1,47 @@ +import Foundation + +public struct NotificationReport: Equatable { + public enum ReportType: String, Equatable { + case `default` + case request + case reset + case confirm + case silent + case e2e + case group + case endFT + case groupRQ + } + + public init( + forMe: Bool, + type: NotificationReport.ReportType, + source: Data + ) { + self.forMe = forMe + self.type = type + self.source = source + } + + public var forMe: Bool + public var type: ReportType + public var source: Data +} + +extension NotificationReport.ReportType: Codable {} + +extension NotificationReport: Codable { + enum CodingKeys: String, CodingKey { + case forMe = "ForMe" + case type = "Type" + case source = "Source" + } + + public static func decode(_ data: Data) throws -> Self { + try JSONDecoder().decode(Self.self, from: data) + } + + public func encode() throws -> Data { + try JSONEncoder().encode(self) + } +} diff --git a/Tests/XXClientTests/Models/NotificationReportTests.swift b/Tests/XXClientTests/Models/NotificationReportTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..9e99d82544e5631c26142d4a43b5a64ba96342bc --- /dev/null +++ b/Tests/XXClientTests/Models/NotificationReportTests.swift @@ -0,0 +1,31 @@ +import CustomDump +import XCTest +@testable import XXClient + +final class NotificationReportTests: XCTestCase { + func testCoding() throws { + let forMe = true + let type = NotificationReport.ReportType.default + let sourceB64 = "dGVzdGVyMTIzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + let jsonString = """ + { + "ForMe": true, + "Type": "\(type.rawValue)", + "Source": "\(sourceB64)" + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try NotificationReport.decode(jsonData) + + XCTAssertNoDifference(model, NotificationReport( + forMe: forMe, + type: type, + source: Data(base64Encoded: sourceB64)! + )) + + let encodedModel = try model.encode() + let decodedModel = try NotificationReport.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +}