import c_borogove
public func setup(_ handler: @convention(c) @escaping (UnsafePointer<CChar>?)->Void) {
c_borogove.borogove_setup(handler)
}
public func stop(_ wait: Bool) {
c_borogove.borogove_stop(wait)
}
public protocol SDKObject {
var o: UnsafeMutableRawPointer {get}
}
internal func useString(_ mptr: UnsafePointer<CChar>?) -> String? {
if let ptr = mptr {
let r = String(cString: ptr)
c_borogove.borogove_release(ptr)
return r
} else {
return nil
}
}
internal func useString(_ mptr: UnsafeMutableRawPointer?) -> String? {
return useString(UnsafePointer(mptr?.assumingMemoryBound(to: CChar.self)))
}
// From https://github.com/swiftlang/swift/blob/dfc3933a05264c0c19f7cd43ea0dca351f53ed48/stdlib/private/SwiftPrivate/SwiftPrivate.swift
public func scan<
S : Sequence, U
>(_ seq: S, _ initial: U, _ combine: (U, S.Iterator.Element) -> U) -> [U] {
var result: [U] = []
result.reserveCapacity(seq.underestimatedCount)
var runningResult = initial
for element in seq {
runningResult = combine(runningResult, element)
result.append(runningResult)
}
return result
}
// From https://github.com/swiftlang/swift/blob/dfc3933a05264c0c19f7cd43ea0dca351f53ed48/stdlib/private/SwiftPrivate/SwiftPrivate.swift
internal func withArrayOfCStrings<R>(
_ args: [String], _ body: ([UnsafePointer<CChar>?]) -> R
) -> R {
let argsCounts = Array(args.map { $0.utf8.count + 1 })
let argsOffsets = [ 0 ] + scan(argsCounts, 0, +)
let argsBufferSize = argsOffsets.last!
var argsBuffer: [UInt8] = []
argsBuffer.reserveCapacity(argsBufferSize)
for arg in args {
argsBuffer.append(contentsOf: arg.utf8)
argsBuffer.append(0)
}
return argsBuffer.withUnsafeMutableBufferPointer {
(argsBuffer) in
let ptr = UnsafeRawPointer(argsBuffer.baseAddress!).bindMemory(
to: CChar.self, capacity: argsBuffer.count)
var cStrings: [UnsafePointer<CChar>?] = argsOffsets.dropLast().map { ptr + $0 }
return body(cStrings)
}
}
internal func withOptionalArrayOfCStrings<R>(
_ args: [String]?, _ body: ([UnsafePointer<CChar>?]?) -> R
) -> R {
if let args = args {
return withArrayOfCStrings(args, body)
} else {
return body(nil)
}
}
public protocol MediaStore: SDKObject {
}
public class AnyMediaStore: MediaStore {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
deinit {
c_borogove.borogove_release(o)
}
}
public class MediaStoreFS: SDKObject, MediaStore, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
Store media on the filesystem
@param path where on filesystem to store media
*/
public init(path: String) {
o = (c_borogove.borogove_persistence_media_store_fs_new(path))
}
/**
Get absolute path on filesystem to a particular piece of media
@param uri The URI to the media (ni:// or similar)
@returns Promise resolving to the path or null
*/
public func getMediaPath(uri: String) async -> String? {
return await withUnsafeContinuation { cont in
let __cont_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(cont as AnyObject).toOpaque())
return c_borogove.borogove_persistence_media_store_fs_get_media_path(
self.o,
uri,
{ (a, ctx) in
let cont = Unmanaged<AnyObject>.fromOpaque(ctx!).takeRetainedValue() as! UnsafeContinuation<String?, Never>
cont.resume(returning: useString(a))
},
__cont_ptr
)
}
}
deinit {
c_borogove.borogove_release(o)
}
}
public protocol KeyValueStore: SDKObject {
}
public class AnyKeyValueStore: KeyValueStore {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
deinit {
c_borogove.borogove_release(o)
}
}
public protocol Persistence: SDKObject {
}
public class AnyPersistence: Persistence {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
deinit {
c_borogove.borogove_release(o)
}
}
public class Hash: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
Create a new Hash from a hex string
@param algorithm name per https://xmpp.org/extensions/xep-0300.html
@param hash in hex format
@returns Hash or null on error
*/
public static func fromHex(algorithm: String, hash: String) -> Hash? {
(c_borogove.borogove_hash_from_hex(
algorithm,
hash
)).map({ Hash($0) })
}
/**
Create a new Hash from a ni:, cid: or similar URI
@param uri The URI
@returns Hash or null on error
*/
public static func fromUri(uri: String) -> Hash? {
(c_borogove.borogove_hash_from_uri(
uri
)).map({ Hash($0) })
}
/**
Hash algorithm name
*/
public var algorithm: String {
get {
useString(c_borogove.borogove_hash_algorithm(o))!
}
}
/**
Represent this Hash as a URI
@returns URI as a string
*/
public func toUri() -> String {
return useString(c_borogove.borogove_hash_to_uri(
self.o
))!
}
/**
Represent this Hash as a hex string
@returns hex string
*/
public func toHex() -> String {
return useString(c_borogove.borogove_hash_to_hex(
self.o
))!
}
/**
Represent this Hash as a Base64 string
@returns Base64-encoded string
*/
public func toBase64() -> String {
return useString(c_borogove.borogove_hash_to_base_64(
self.o
))!
}
/**
Represent this Hash as a Base64url string
@returns Base64url-encoded string
*/
public func toBase64Url() -> String {
return useString(c_borogove.borogove_hash_to_base_64_url(
self.o
))!
}
deinit {
c_borogove.borogove_release(o)
}
}
public class ChatAttachment: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
Create a new attachment for adding to a ChatMessage
@param name Optional filename
@param mime MIME type
@param size Size in bytes
@param uri URI to attachment
*/
public static func create(name: String?, mime: String, size: Int32, uri: String) -> ChatAttachment {
ChatAttachment(c_borogove.borogove_chat_attachment_create(
name,
mime,
size,
uri
)!)
}
/**
Filename
*/
public var name: String? {
get {
useString(c_borogove.borogove_chat_attachment_name(o))
}
}
/**
MIME Type
*/
public var mime: String {
get {
useString(c_borogove.borogove_chat_attachment_mime(o))!
}
}
/**
Size in bytes
*/
public var size: Int32? {
get {
c_borogove.borogove_chat_attachment_size(o)
}
}
/**
URIs to data
*/
public var uris: Array<String> {
get {
{var __ret: UnsafeMutablePointer<UnsafePointer<CChar>?>? = nil;let __ret_length = c_borogove.borogove_chat_attachment_uris(o, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafePointer<CChar>?>(start: __ret, count: __ret_length).map({useString($0)!});c_borogove.borogove_release(__ret);return __r;}();}()
}
}
/**
Hashes of data
*/
public var hashes: Array<Hash> {
get {
{var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_chat_attachment_hashes(o, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({Hash($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
}
deinit {
c_borogove.borogove_release(o)
}
}
public class Reaction: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
Create a new Unicode reaction to send
@param unicode emoji of the reaction
@returns Reaction
*/
public static func unicode(unicode: String) -> Reaction {
Reaction(c_borogove.borogove_reaction_unicode(
unicode
)!)
}
/**
ID of who sent this Reaction
*/
public var senderId: String {
get {
useString(c_borogove.borogove_reaction_sender_id(o))!
}
}
/**
Date and time when this Reaction was sent,
in format YYYY-MM-DDThh:mm:ss[.sss]+00:00
*/
public var timestamp: String {
get {
useString(c_borogove.borogove_reaction_timestamp(o))!
}
}
/**
Key for grouping reactions
*/
public var key: String {
get {
useString(c_borogove.borogove_reaction_key(o))!
}
}
deinit {
c_borogove.borogove_release(o)
}
}
public class EncryptionInfo: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
public var status: EncryptionStatus {
get {
c_borogove.borogove_encryption_info_status(o)
}
}
public var method: String {
get {
useString(c_borogove.borogove_encryption_info_method(o))!
}
}
public var methodName: String? {
get {
useString(c_borogove.borogove_encryption_info_method_name(o))
}
}
public var reason: String? {
get {
useString(c_borogove.borogove_encryption_info_reason(o))
}
}
public var reasonText: String? {
get {
useString(c_borogove.borogove_encryption_info_reason_text(o))
}
}
deinit {
c_borogove.borogove_release(o)
}
}
public class ChatMessage: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
The ID as set by the creator of this message
*/
public var localId: String? {
get {
useString(c_borogove.borogove_chat_message_local_id(o))
}
}
/**
The ID as set by the authoritative server
*/
public var serverId: String? {
get {
useString(c_borogove.borogove_chat_message_server_id(o))
}
}
/**
The ID of the server which set the serverId
*/
public var serverIdBy: String? {
get {
useString(c_borogove.borogove_chat_message_server_id_by(o))
}
}
/**
The type of this message (Chat, Call, etc)
*/
public var type: MessageType {
get {
c_borogove.borogove_chat_message_type(o)
}
}
/**
The timestamp of this message, in format YYYY-MM-DDThh:mm:ss[.sss]Z
*/
public var timestamp: String {
get {
useString(c_borogove.borogove_chat_message_timestamp(o))!
}
}
/**
The ID of the sender of this message
*/
public var senderId: String {
get {
useString(c_borogove.borogove_chat_message_sender_id(o))!
}
}
/**
Message this one is in reply to, or NULL
*/
public var replyToMessage: ChatMessage? {
get {
(c_borogove.borogove_chat_message_reply_to_message(o)).map({ ChatMessage($0) })
}
}
/**
ID of the thread this message is in, or NULL
*/
public var threadId: String? {
get {
useString(c_borogove.borogove_chat_message_thread_id(o))
}
}
/**
Array of attachments to this message
*/
public var attachments: Array<ChatAttachment> {
get {
{var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_chat_message_attachments(o, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({ChatAttachment($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
}
/**
List of reactions to this message
*/
public var reactionKeys: Array<String> {
get {
{var __ret: UnsafeMutablePointer<UnsafePointer<CChar>?>? = nil;let __ret_length = c_borogove.borogove_chat_message_reaction_keys(o, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafePointer<CChar>?>(start: __ret, count: __ret_length).map({useString($0)!});c_borogove.borogove_release(__ret);return __r;}();}()
}
}
/**
Details of a set of reaction to this message
*/
public func reactionDetails(reactionKey: String) -> Array<Reaction> {
return {var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_chat_message_reaction_details(
self.o,
reactionKey
, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({Reaction($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
/**
Body text of this message or NULL
*/
public var text: String? {
get {
useString(c_borogove.borogove_chat_message_text(o))
}
}
/**
Language code for the body text
*/
public var lang: String? {
get {
useString(c_borogove.borogove_chat_message_lang(o))
}
}
/**
Direction of this message
*/
public var direction: MessageDirection {
get {
c_borogove.borogove_chat_message_direction(o)
}
}
/**
Status of this message
*/
public var status: MessageStatus {
get {
c_borogove.borogove_chat_message_status(o)
}
}
/**
Message to go along with the message status
*/
public var statusText: String? {
get {
useString(c_borogove.borogove_chat_message_status_text(o))
}
}
/**
Array of past versions of this message, if it has been edited
*/
public var versions: Array<ChatMessage> {
get {
{var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_chat_message_versions(o, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({ChatMessage($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
}
/**
Information about the encryption used by the sender of
this message.
*/
public var encryption: EncryptionInfo? {
get {
(c_borogove.borogove_chat_message_encryption(o)).map({ EncryptionInfo($0) })
}
}
/**
Create a new ChatMessage in reply to this one
*/
public func reply() -> ChatMessageBuilder {
return ChatMessageBuilder(c_borogove.borogove_chat_message_reply(
self.o
)!)
}
/**
Get HTML version of the message body
WARNING: this is possibly untrusted HTML. You must parse or sanitize appropriately!
@param sender optionally specify the full details of the sender
*/
public func html(sender: Participant? = nil) -> String {
return useString(c_borogove.borogove_chat_message_html(
self.o,
sender?.o
))!
}
/**
The ID of the Chat this message is associated with
*/
public func chatId() -> String {
return useString(c_borogove.borogove_chat_message_chat_id(
self.o
))!
}
/**
The ID of the account associated with this message
*/
public func account() -> String {
return useString(c_borogove.borogove_chat_message_account(
self.o
))!
}
/**
Is this an incoming message?
*/
public func isIncoming() -> Bool {
return c_borogove.borogove_chat_message_is_incoming(
self.o
)
}
/**
The URI of an icon for the thread associated with this message, or NULL
*/
public func threadIcon() -> String?? {
return useString(c_borogove.borogove_chat_message_thread_icon(
self.o
))
}
/**
The last status of the call if this message is related to a call
*/
public func callStatus() -> String? {
return useString(c_borogove.borogove_chat_message_call_status(
self.o
))
}
/**
The session id of the call if this message is related to a call
*/
public func callSid() -> String? {
return useString(c_borogove.borogove_chat_message_call_sid(
self.o
))
}
/**
The duration of the call if this message is related to a call
*/
public func callDuration() -> String? {
return useString(c_borogove.borogove_chat_message_call_duration(
self.o
))
}
deinit {
c_borogove.borogove_release(o)
}
}
public class Sqlite: SDKObject, KeyValueStore, Persistence, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
Create a basic persistence layer based on sqlite
@param dbfile path to sqlite database
@params media a MediaStore to use for media
@returns new persistence layer
*/
public init(dbfile: String, media: MediaStore) {
o = (c_borogove.borogove_persistence_sqlite_new(dbfile, media.o))
}
/**
Get a single message
@param accountId the account the message was sent or received on
@param chatId the chat the message was sent or received on
@param serverId the serverId of the message (optional if localId is specified)
@param localId the localId of the message (optional if serverId is specified)
@returns Promise resolving to the message or null
*/
public func getMessage(accountId: String, chatId: String, serverId: String?, localId: String?) async -> ChatMessage? {
return await withUnsafeContinuation { cont in
let __cont_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(cont as AnyObject).toOpaque())
return c_borogove.borogove_persistence_sqlite_get_message(
self.o,
accountId,
chatId,
serverId,
localId,
{ (a, ctx) in
let cont = Unmanaged<AnyObject>.fromOpaque(ctx!).takeRetainedValue() as! UnsafeContinuation<ChatMessage?, Never>
cont.resume(returning: (a).map({ ChatMessage($0) }))
},
__cont_ptr
)
}
}
/**
Remove an account from storage
@param accountId the account to remove
@param completely if message history, etc should be removed also
*/
public func removeAccount(accountId: String, completely: Bool) -> Void {
return c_borogove.borogove_persistence_sqlite_remove_account(
self.o,
accountId,
completely
)
}
/**
List all known accounts
@returns Promise resolving to array of account IDs
*/
public func listAccounts() async -> Array<String> {
return await withUnsafeContinuation { cont in
let __cont_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(cont as AnyObject).toOpaque())
return c_borogove.borogove_persistence_sqlite_list_accounts(
self.o,
{ (a, a_length, ctx) in
let cont = Unmanaged<AnyObject>.fromOpaque(ctx!).takeRetainedValue() as! UnsafeContinuation<Array<String>, Never>
cont.resume(returning: {let __r = UnsafeMutableBufferPointer<UnsafePointer<CChar>?>(start: a, count: a_length).map({useString($0)!});c_borogove.borogove_release(a);return __r;}())
},
__cont_ptr
)
}
}
deinit {
c_borogove.borogove_release(o)
}
}
public class ChatMessageBuilder: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
@returns a new blank ChatMessageBuilder
*/
public init() {
o = (c_borogove.borogove_chat_message_builder_new())
}
/**
The ID as set by the creator of this message
*/
public var localId: String? {
get {
useString(c_borogove.borogove_chat_message_builder_local_id(o))
}
set {
c_borogove.borogove_chat_message_builder_set_local_id(o, newValue)
}
}
/**
The ID as set by the authoritative server
*/
public var serverId: String? {
get {
useString(c_borogove.borogove_chat_message_builder_server_id(o))
}
set {
c_borogove.borogove_chat_message_builder_set_server_id(o, newValue)
}
}
/**
The ID of the server which set the serverId
*/
public var serverIdBy: String? {
get {
useString(c_borogove.borogove_chat_message_builder_server_id_by(o))
}
set {
c_borogove.borogove_chat_message_builder_set_server_id_by(o, newValue)
}
}
/**
The type of this message (Chat, Call, etc)
*/
public var type: MessageType {
get {
c_borogove.borogove_chat_message_builder_type(o)
}
set {
c_borogove.borogove_chat_message_builder_set_type(o, newValue)
}
}
/**
The timestamp of this message, in format YYYY-MM-DDThh:mm:ss[.sss]+00:00
*/
public var timestamp: String? {
get {
useString(c_borogove.borogove_chat_message_builder_timestamp(o))
}
set {
c_borogove.borogove_chat_message_builder_set_timestamp(o, newValue)
}
}
/**
The ID of the message sender
*/
public var senderId: String? {
get {
useString(c_borogove.borogove_chat_message_builder_sender_id(o))
}
set {
c_borogove.borogove_chat_message_builder_set_sender_id(o, newValue)
}
}
/**
Message this one is in reply to, or NULL
*/
public var replyToMessage: ChatMessage? {
get {
(c_borogove.borogove_chat_message_builder_reply_to_message(o)).map({ ChatMessage($0) })
}
set {
c_borogove.borogove_chat_message_builder_set_reply_to_message(o, newValue?.o)
}
}
/**
ID of the thread this message is in, or NULL
*/
public var threadId: String? {
get {
useString(c_borogove.borogove_chat_message_builder_thread_id(o))
}
set {
c_borogove.borogove_chat_message_builder_set_thread_id(o, newValue)
}
}
/**
Array of attachments to this message
*/
public var attachments: Array<ChatAttachment> {
get {
{var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_chat_message_builder_attachments(o, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({ChatAttachment($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
}
/**
Body text of this message or NULL
*/
public var text: String? {
get {
useString(c_borogove.borogove_chat_message_builder_text(o))
}
set {
c_borogove.borogove_chat_message_builder_set_text(o, newValue)
}
}
/**
Language code for the body text
*/
public var lang: String? {
get {
useString(c_borogove.borogove_chat_message_builder_lang(o))
}
set {
c_borogove.borogove_chat_message_builder_set_lang(o, newValue)
}
}
/**
Direction of this message
*/
public var direction: MessageDirection {
get {
c_borogove.borogove_chat_message_builder_direction(o)
}
set {
c_borogove.borogove_chat_message_builder_set_direction(o, newValue)
}
}
/**
Status of this message
*/
public var status: MessageStatus {
get {
c_borogove.borogove_chat_message_builder_status(o)
}
set {
c_borogove.borogove_chat_message_builder_set_status(o, newValue)
}
}
/**
Human readable text to go with the status
*/
public var statusText: String? {
get {
useString(c_borogove.borogove_chat_message_builder_status_text(o))
}
set {
c_borogove.borogove_chat_message_builder_set_status_text(o, newValue)
}
}
/**
Array of past versions of this message, if it has been edited
*/
public var versions: Array<ChatMessage> {
get {
{var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_chat_message_builder_versions(o, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({ChatMessage($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
set {
c_borogove.borogove_chat_message_builder_set_versions(o, newValue.map { $0.o }, newValue.count)
}
}
/**
Information about the encryption used by the sender of
this message.
*/
public var encryption: EncryptionInfo? {
get {
(c_borogove.borogove_chat_message_builder_encryption(o)).map({ EncryptionInfo($0) })
}
set {
c_borogove.borogove_chat_message_builder_set_encryption(o, newValue?.o)
}
}
/**
Add an attachment to this message
@param attachment The ChatAttachment to add
*/
public func addAttachment(attachment: ChatAttachment) -> Void {
return c_borogove.borogove_chat_message_builder_add_attachment(
self.o,
attachment.o
)
}
/**
Set rich text using an HTML string
Also sets the plain text body appropriately
*/
public func setHtml(html: String) -> Void {
return c_borogove.borogove_chat_message_builder_set_html(
self.o,
html
)
}
/**
The ID of the Chat this message is associated with
*/
public func chatId() -> String {
return useString(c_borogove.borogove_chat_message_builder_chat_id(
self.o
))!
}
/**
The ID of the sender of this message
*/
public func get_senderId() -> String {
return useString(c_borogove.borogove_chat_message_builder_get_sender_id(
self.o
))!
}
/**
Build this builder into an immutable ChatMessage
@returns the ChatMessage
*/
public func build() -> ChatMessage {
return ChatMessage(c_borogove.borogove_chat_message_builder_build(
self.o
)!)
}
deinit {
c_borogove.borogove_release(o)
}
}
public class ProfileItem: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
public var id: String {
get {
useString(c_borogove.borogove_profile_item_id(o))!
}
}
public var key: String {
get {
useString(c_borogove.borogove_profile_item_key(o))!
}
}
public func parameters() -> Array<ProfileItem> {
return {var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_profile_item_parameters(
self.o
, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({ProfileItem($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
public func text() -> Array<String> {
return {var __ret: UnsafeMutablePointer<UnsafePointer<CChar>?>? = nil;let __ret_length = c_borogove.borogove_profile_item_text(
self.o
, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafePointer<CChar>?>(start: __ret, count: __ret_length).map({useString($0)!});c_borogove.borogove_release(__ret);return __r;}();}()
}
public func uri() -> Array<String> {
return {var __ret: UnsafeMutablePointer<UnsafePointer<CChar>?>? = nil;let __ret_length = c_borogove.borogove_profile_item_uri(
self.o
, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafePointer<CChar>?>(start: __ret, count: __ret_length).map({useString($0)!});c_borogove.borogove_release(__ret);return __r;}();}()
}
public func date() -> Array<String> {
return {var __ret: UnsafeMutablePointer<UnsafePointer<CChar>?>? = nil;let __ret_length = c_borogove.borogove_profile_item_date(
self.o
, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafePointer<CChar>?>(start: __ret, count: __ret_length).map({useString($0)!});c_borogove.borogove_release(__ret);return __r;}();}()
}
public func time() -> Array<String> {
return {var __ret: UnsafeMutablePointer<UnsafePointer<CChar>?>? = nil;let __ret_length = c_borogove.borogove_profile_item_time(
self.o
, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafePointer<CChar>?>(start: __ret, count: __ret_length).map({useString($0)!});c_borogove.borogove_release(__ret);return __r;}();}()
}
public func datetime() -> Array<String> {
return {var __ret: UnsafeMutablePointer<UnsafePointer<CChar>?>? = nil;let __ret_length = c_borogove.borogove_profile_item_datetime(
self.o
, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafePointer<CChar>?>(start: __ret, count: __ret_length).map({useString($0)!});c_borogove.borogove_release(__ret);return __r;}();}()
}
public func languageTag() -> Array<String> {
return {var __ret: UnsafeMutablePointer<UnsafePointer<CChar>?>? = nil;let __ret_length = c_borogove.borogove_profile_item_language_tag(
self.o
, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafePointer<CChar>?>(start: __ret, count: __ret_length).map({useString($0)!});c_borogove.borogove_release(__ret);return __r;}();}()
}
deinit {
c_borogove.borogove_release(o)
}
}
public class Profile: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
All items in the profile
*/
public var items: Array<ProfileItem> {
get {
{var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_profile_items(o, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({ProfileItem($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
}
deinit {
c_borogove.borogove_release(o)
}
}
public class Participant: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
public var displayName: String {
get {
useString(c_borogove.borogove_participant_display_name(o))!
}
}
public var photoUri: String? {
get {
useString(c_borogove.borogove_participant_photo_uri(o))
}
}
public var placeholderUri: String {
get {
useString(c_borogove.borogove_participant_placeholder_uri(o))!
}
}
public var isSelf: Bool {
get {
c_borogove.borogove_participant_is_self(o)
}
}
public func profile(client: Client) async -> Profile {
return await withUnsafeContinuation { cont in
let __cont_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(cont as AnyObject).toOpaque())
return c_borogove.borogove_participant_profile(
self.o,
client.o,
{ (a, ctx) in
let cont = Unmanaged<AnyObject>.fromOpaque(ctx!).takeRetainedValue() as! UnsafeContinuation<Profile, Never>
cont.resume(returning: Profile(a!))
},
__cont_ptr
)
}
}
deinit {
c_borogove.borogove_release(o)
}
}
public class Dummy: SDKObject, Persistence, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
Create a basic persistence layer that persists nothing
@returns new persistence layer
*/
public init() {
o = (c_borogove.borogove_persistence_dummy_new())
}
deinit {
c_borogove.borogove_release(o)
}
}
public class Push: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
Receive a new push notification from some external system
@param data the raw data from the push
@param persistence the persistence layer to write into
@returns a Notification representing the push data
*/
public static func receive(data: String, persistence: Persistence) -> Notification? {
(c_borogove.borogove_push_receive(
data,
persistence.o
)).map({ Notification($0) })
}
deinit {
c_borogove.borogove_release(o)
}
}
public class Notification: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
The title
*/
public var title: String {
get {
useString(c_borogove.borogove_notification_title(o))!
}
}
/**
The body text
*/
public var body: String {
get {
useString(c_borogove.borogove_notification_body(o))!
}
}
/**
The ID of the associated account
*/
public var accountId: String {
get {
useString(c_borogove.borogove_notification_account_id(o))!
}
}
/**
The ID of the associated chat
*/
public var chatId: String {
get {
useString(c_borogove.borogove_notification_chat_id(o))!
}
}
/**
The ID of the message sender
*/
public var senderId: String {
get {
useString(c_borogove.borogove_notification_sender_id(o))!
}
}
/**
The serverId of the message
*/
public var messageId: String {
get {
useString(c_borogove.borogove_notification_message_id(o))!
}
}
/**
The type of the message
*/
public var type: MessageType {
get {
c_borogove.borogove_notification_type(o)
}
}
/**
If this is a call notification, the call status
*/
public var callStatus: String? {
get {
useString(c_borogove.borogove_notification_call_status(o))
}
}
/**
If this is a call notification, the call session ID
*/
public var callSid: String? {
get {
useString(c_borogove.borogove_notification_call_sid(o))
}
}
/**
Optional image URI
*/
public var imageUri: String? {
get {
useString(c_borogove.borogove_notification_image_uri(o))
}
}
/**
Optional language code
*/
public var lang: String? {
get {
useString(c_borogove.borogove_notification_lang(o))
}
}
/**
Optional date and time of the event
*/
public var timestamp: String? {
get {
useString(c_borogove.borogove_notification_timestamp(o))
}
}
deinit {
c_borogove.borogove_release(o)
}
}
public class EventEmitter: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
Remove an event listener of any type, no matter how it was added
or what event it is for.
@param token the token that was returned when the listener was added
*/
public func removeEventListener(token: Int32) -> Void {
return c_borogove.borogove_event_emitter_remove_event_listener(
self.o,
token
)
}
deinit {
c_borogove.borogove_release(o)
}
}
public class AudioFormat: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
public init(format: String, payloadType: UInt8, clockRate: Int32, channels: Int32) {
o = (c_borogove.borogove_calls_audio_format_new(format, payloadType, clockRate, channels))
}
public var clockRate: Int32 {
get {
c_borogove.borogove_calls_audio_format_clock_rate(o)
}
}
public var channels: Int32 {
get {
c_borogove.borogove_calls_audio_format_channels(o)
}
}
deinit {
c_borogove.borogove_release(o)
}
}
public class MediaStreamTrack: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
public var id: String {
get {
useString(c_borogove.borogove_calls_media_stream_track_id(o))!
}
}
public var muted: Bool {
get {
c_borogove.borogove_calls_media_stream_track_muted(o)
}
}
public var kind: String {
get {
useString(c_borogove.borogove_calls_media_stream_track_kind(o))!
}
}
public var supportedAudioFormats: Array<AudioFormat> {
get {
{var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_calls_media_stream_track_supported_audio_formats(o, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({AudioFormat($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
}
/**
Event fired for new inbound audio frame
@param callback takes three arguments, the Signed 16-bit PCM data, the clock rate, and the number of channels
*/
public func addPCMListener(callback: @Sendable @escaping (Array<Int16>, Int32, Int32)->Void) -> Void {
let __callback_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(callback as AnyObject).toOpaque())
return c_borogove.borogove_calls_media_stream_track_add_pcm_listener(
self.o,
{ (a0, a0_length, a1, a2, ctx) in
let callback = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable (Array<Int16>, Int32, Int32)->Void
return callback({let __r = UnsafeMutableBufferPointer<Int16>(start: a0, count: a0_length).map({$0});c_borogove.borogove_release(a0);return __r;}(), a1, a2)
},
__callback_ptr
)
}
/**
Event fired when ready for next outbound audio frame
@param callback
*/
public func addReadyForPCMListener(callback: @Sendable @escaping ()->Void) -> Void {
let __callback_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(callback as AnyObject).toOpaque())
return c_borogove.borogove_calls_media_stream_track_add_ready_for_pcm_listener(
self.o,
{ (ctx) in
let callback = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable ()->Void
return callback()
},
__callback_ptr
)
}
/**
Send new audio to this track
@param pcm 16-bit signed linear PCM data (interleaved)
@param clockRate the sampling rate of the data
@param channels the number of audio channels
*/
public func writePCM(pcm: Array<Int16>, clockRate: Int32, channels: Int32) -> Void {
return c_borogove.borogove_calls_media_stream_track_write_pcm(
self.o,
pcm, pcm.count,
clockRate,
channels
)
}
public func stop() -> Void {
return c_borogove.borogove_calls_media_stream_track_stop(
self.o
)
}
deinit {
c_borogove.borogove_release(o)
}
}
public class FormOption: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
public var label: String {
get {
useString(c_borogove.borogove_form_option_label(o))!
}
}
public var value: String {
get {
useString(c_borogove.borogove_form_option_value(o))!
}
}
deinit {
c_borogove.borogove_release(o)
}
}
public protocol FormSection: SDKObject {
}
public class AnyFormSection: FormSection {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
deinit {
c_borogove.borogove_release(o)
}
}
public class FormField: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
public var name: String {
get {
useString(c_borogove.borogove_form_field_name(o))!
}
}
public var label: String? {
get {
useString(c_borogove.borogove_form_field_label(o))
}
}
public var desc: String? {
get {
useString(c_borogove.borogove_form_field_desc(o))
}
}
public var value: Array<String> {
get {
{var __ret: UnsafeMutablePointer<UnsafePointer<CChar>?>? = nil;let __ret_length = c_borogove.borogove_form_field_value(o, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafePointer<CChar>?>(start: __ret, count: __ret_length).map({useString($0)!});c_borogove.borogove_release(__ret);return __r;}();}()
}
}
public var required: Bool {
get {
c_borogove.borogove_form_field_required(o)
}
}
public var type: String {
get {
useString(c_borogove.borogove_form_field_type(o))!
}
}
public var datatype: String {
get {
useString(c_borogove.borogove_form_field_datatype(o))!
}
}
public var options: Array<FormOption> {
get {
{var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_form_field_options(o, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({FormOption($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
}
public var open: Bool {
get {
c_borogove.borogove_form_field_open(o)
}
}
public var rangeMin: String? {
get {
useString(c_borogove.borogove_form_field_range_min(o))
}
}
public var rangeMax: String? {
get {
useString(c_borogove.borogove_form_field_range_max(o))
}
}
public var regex: String? {
get {
useString(c_borogove.borogove_form_field_regex(o))
}
}
deinit {
c_borogove.borogove_release(o)
}
}
public class FormItem: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
public var text: String? {
get {
useString(c_borogove.borogove_form_item_text(o))
}
}
public var field: FormField? {
get {
(c_borogove.borogove_form_item_field(o)).map({ FormField($0) })
}
}
public var section: FormSection? {
get {
(c_borogove.borogove_form_item_section(o)).map({ AnyFormSection($0) })
}
}
public var status: String? {
get {
useString(c_borogove.borogove_form_item_status(o))
}
}
public var tableHeader: Array<FormField>? {
get {
{var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_form_item_table_header(o, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({FormField($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
}
deinit {
c_borogove.borogove_release(o)
}
}
public class Form: SDKObject, FormSection, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
Is this form entirely results / read-only?
*/
public func isResult() -> Bool {
return c_borogove.borogove_form_is_result(
self.o
)
}
/**
Title of this form
*/
public func title() -> String? {
return useString(c_borogove.borogove_form_title(
self.o
))
}
/**
URL to use instead of this form
*/
public func url() -> String? {
return useString(c_borogove.borogove_form_url(
self.o
))
}
/**
Items to render inside this form
*/
public func items() -> Array<FormItem> {
return {var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_form_items(
self.o
, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({FormItem($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
deinit {
c_borogove.borogove_release(o)
}
}
public class CommandSession: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
public var name: String {
get {
useString(c_borogove.borogove_command_session_name(o))!
}
}
public var status: String {
get {
useString(c_borogove.borogove_command_session_status(o))!
}
}
public var actions: Array<FormOption> {
get {
{var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_command_session_actions(o, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({FormOption($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
}
public var forms: Array<Form> {
get {
{var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_command_session_forms(o, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({Form($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
}
public func execute(action: String? = nil, data: FormSubmitBuilder? = nil, formIdx: Int32 = 0) async -> CommandSession {
return await withUnsafeContinuation { cont in
let __cont_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(cont as AnyObject).toOpaque())
return c_borogove.borogove_command_session_execute(
self.o,
action,
data?.o,
formIdx,
{ (a, ctx) in
let cont = Unmanaged<AnyObject>.fromOpaque(ctx!).takeRetainedValue() as! UnsafeContinuation<CommandSession, Never>
cont.resume(returning: CommandSession(a!))
},
__cont_ptr
)
}
}
deinit {
c_borogove.borogove_release(o)
}
}
public class Command: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
public var name: String {
get {
useString(c_borogove.borogove_command_name(o))!
}
}
/**
Start a new session for this command. May have side effects!
*/
public func execute() async -> CommandSession {
return await withUnsafeContinuation { cont in
let __cont_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(cont as AnyObject).toOpaque())
return c_borogove.borogove_command_execute(
self.o,
{ (a, ctx) in
let cont = Unmanaged<AnyObject>.fromOpaque(ctx!).takeRetainedValue() as! UnsafeContinuation<CommandSession, Never>
cont.resume(returning: CommandSession(a!))
},
__cont_ptr
)
}
}
deinit {
c_borogove.borogove_release(o)
}
}
public class Chat: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
ID of this Chat
*/
public var chatId: String {
get {
useString(c_borogove.borogove_chat_chat_id(o))!
}
}
/**
Current state of this chat
*/
public var uiState: UiState {
get {
c_borogove.borogove_chat_ui_state(o)
}
}
/**
Is this chat blocked?
*/
public var isBlocked: Bool {
get {
c_borogove.borogove_chat_is_blocked(o)
}
}
/**
The most recent message in this chat
*/
public var lastMessage: ChatMessage? {
get {
(c_borogove.borogove_chat_last_message(o)).map({ ChatMessage($0) })
}
}
/**
Has this chat ever been bookmarked?
*/
public var isBookmarked: Bool {
get {
c_borogove.borogove_chat_is_bookmarked(o)
}
}
/**
Fetch a page of messages before some point
@param beforeId id of the message to look before
@param beforeTime timestamp of the message to look before,
String in format YYYY-MM-DDThh:mm:ss[.sss]+00:00
@returns Promise resolving to an array of ChatMessage that are found
*/
public func getMessagesBefore(beforeId: String?, beforeTime: String?) async -> Array<ChatMessage> {
return await withUnsafeContinuation { cont in
let __cont_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(cont as AnyObject).toOpaque())
return c_borogove.borogove_chat_get_messages_before(
self.o,
beforeId,
beforeTime,
{ (a, a_length, ctx) in
let cont = Unmanaged<AnyObject>.fromOpaque(ctx!).takeRetainedValue() as! UnsafeContinuation<Array<ChatMessage>, Never>
cont.resume(returning: {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: a, count: a_length).map({ChatMessage($0!)});c_borogove.borogove_release(a);return __r;}())
},
__cont_ptr
)
}
}
/**
Fetch a page of messages after some point
@param afterId id of the message to look after
@param afterTime timestamp of the message to look after,
String in format YYYY-MM-DDThh:mm:ss[.sss]+00:00
@returns Promise resolving to an array of ChatMessage that are found
*/
public func getMessagesAfter(afterId: String?, afterTime: String?) async -> Array<ChatMessage> {
return await withUnsafeContinuation { cont in
let __cont_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(cont as AnyObject).toOpaque())
return c_borogove.borogove_chat_get_messages_after(
self.o,
afterId,
afterTime,
{ (a, a_length, ctx) in
let cont = Unmanaged<AnyObject>.fromOpaque(ctx!).takeRetainedValue() as! UnsafeContinuation<Array<ChatMessage>, Never>
cont.resume(returning: {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: a, count: a_length).map({ChatMessage($0!)});c_borogove.borogove_release(a);return __r;}())
},
__cont_ptr
)
}
}
/**
Fetch a page of messages around (before, including, and after) some point
@param aroundId id of the message to look around
@param aroundTime timestamp of the message to look around,
String in format YYYY-MM-DDThh:mm:ss[.sss]+00:00
@returns Promise resolving to an array of ChatMessage that are found
*/
public func getMessagesAround(aroundId: String?, aroundTime: String?) async -> Array<ChatMessage> {
return await withUnsafeContinuation { cont in
let __cont_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(cont as AnyObject).toOpaque())
return c_borogove.borogove_chat_get_messages_around(
self.o,
aroundId,
aroundTime,
{ (a, a_length, ctx) in
let cont = Unmanaged<AnyObject>.fromOpaque(ctx!).takeRetainedValue() as! UnsafeContinuation<Array<ChatMessage>, Never>
cont.resume(returning: {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: a, count: a_length).map({ChatMessage($0!)});c_borogove.borogove_release(a);return __r;}())
},
__cont_ptr
)
}
}
/**
Send a message to this Chat
@param message the ChatMessageBuilder to send
*/
public func sendMessage(message: ChatMessageBuilder) -> Void {
return c_borogove.borogove_chat_send_message(
self.o,
message.o
)
}
/**
Signals that all messages up to and including this one have probably
been displayed to the user
@param message the ChatMessage most recently displayed
*/
public func markReadUpTo(message: ChatMessage) -> Void {
return c_borogove.borogove_chat_mark_read_up_to(
self.o,
message.o
)
}
/**
Save this Chat on the server
*/
public func bookmark() -> Void {
return c_borogove.borogove_chat_bookmark(
self.o
)
}
/**
Get the list of IDs of participants in this Chat
@returns array of IDs
*/
public func getParticipants() -> Array<String> {
return {var __ret: UnsafeMutablePointer<UnsafePointer<CChar>?>? = nil;let __ret_length = c_borogove.borogove_chat_get_participants(
self.o
, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafePointer<CChar>?>(start: __ret, count: __ret_length).map({useString($0)!});c_borogove.borogove_release(__ret);return __r;}();}()
}
/**
Get the details for one participant in this Chat
@param participantId the ID of the participant to look up
*/
public func getParticipantDetails(participantId: String) -> Participant {
return Participant(c_borogove.borogove_chat_get_participant_details(
self.o,
participantId
)!)
}
/**
Correct an already-send message by replacing it with a new one
@param localId the localId of the message to correct
must be the localId of the first version ever sent, not a subsequent correction
@param message the new ChatMessage to replace it with
*/
public func correctMessage(localId: String, message: ChatMessageBuilder) -> Void {
return c_borogove.borogove_chat_correct_message(
self.o,
localId,
message.o
)
}
/**
Add new reaction to a message in this Chat
@param m ChatMessage to react to
@param reaction emoji of the reaction
*/
public func addReaction(m: ChatMessage, reaction: Reaction) -> Void {
return c_borogove.borogove_chat_add_reaction(
self.o,
m.o,
reaction.o
)
}
/**
Remove an already-sent reaction from a message
@param m ChatMessage to remove the reaction from
@param reaction the emoji to remove
*/
public func removeReaction(m: ChatMessage, reaction: Reaction) -> Void {
return c_borogove.borogove_chat_remove_reaction(
self.o,
m.o,
reaction.o
)
}
/**
Call this whenever the user is typing, can call on every keystroke
@param threadId optional, what thread the user has selected if any
@param content optional, what the user has typed so far
*/
public func typing(threadId: String?, content: String?) -> Void {
return c_borogove.borogove_chat_typing(
self.o,
threadId,
content
)
}
/**
Call this whenever the user makes a chat or thread "active" in your UX
If you call this with true you MUST later call it will false
@param active true if the chat is "active", false otherwise
@param threadId optional, what thread the user has selected if any
*/
public func setActive(active: Bool, threadId: String?) -> Void {
return c_borogove.borogove_chat_set_active(
self.o,
active,
threadId
)
}
/**
Archive this chat
*/
public func close() -> Void {
return c_borogove.borogove_chat_close(
self.o
)
}
/**
Pin or unpin this chat
*/
public func togglePinned() -> Void {
return c_borogove.borogove_chat_toggle_pinned(
self.o
)
}
/**
Block this chat so it will not re-open
*/
public func block(reportSpam: Bool = false, spamMessage: ChatMessage? = nil, onServer: Bool = true) -> Void {
return c_borogove.borogove_chat_block(
self.o,
reportSpam,
spamMessage?.o,
onServer
)
}
/**
Unblock this chat so it will open again
*/
public func unblock(onServer: Bool = true) -> Void {
return c_borogove.borogove_chat_unblock(
self.o,
onServer
)
}
/**
Update notification preferences
*/
public func setNotifications(filtered: Bool, mention: Bool, reply: Bool) -> Void {
return c_borogove.borogove_chat_set_notifications(
self.o,
filtered,
mention,
reply
)
}
/**
Should notifications be filtered?
*/
public func notificationsFiltered() -> Bool {
return c_borogove.borogove_chat_notifications_filtered(
self.o
)
}
/**
Should a mention produce a notification?
*/
public func notifyMention() -> Bool {
return c_borogove.borogove_chat_notify_mention(
self.o
)
}
/**
Should a reply produce a notification?
*/
public func notifyReply() -> Bool {
return c_borogove.borogove_chat_notify_reply(
self.o
)
}
/**
An ID of the most recent message in this chat
*/
public func lastMessageId() -> String? {
return useString(c_borogove.borogove_chat_last_message_id(
self.o
))
}
/**
Get the URI image to represent this Chat, or null
*/
public func getPhoto() -> String? {
return useString(c_borogove.borogove_chat_get_photo(
self.o
))
}
/**
Get the URI to a placeholder image to represent this Chat
*/
public func getPlaceholder() -> String {
return useString(c_borogove.borogove_chat_get_placeholder(
self.o
))!
}
/**
An ID of the last message displayed to the user
*/
public func readUpTo() -> String? {
return useString(c_borogove.borogove_chat_read_up_to(
self.o
))
}
/**
The number of message that have not yet been displayed to the user
*/
public func unreadCount() -> Int32 {
return c_borogove.borogove_chat_unread_count(
self.o
)
}
/**
A preview of the chat, such as the most recent message body
*/
public func preview() -> String {
return useString(c_borogove.borogove_chat_preview(
self.o
))!
}
/**
Set the display name to use for this chat
@param displayName String to use as display name
*/
public func setDisplayName(displayName: String) -> Void {
return c_borogove.borogove_chat_set_display_name(
self.o,
displayName
)
}
/**
The display name of this Chat
*/
public func getDisplayName() -> String {
return useString(c_borogove.borogove_chat_get_display_name(
self.o
))!
}
/**
Set if this chat is to be trusted with our presence, etc
@param trusted Bool if trusted or not
*/
public func setTrusted(trusted: Bool) -> Void {
return c_borogove.borogove_chat_set_trusted(
self.o,
trusted
)
}
/**
Is this a chat with an entity we trust to see our online status?
*/
public func isTrusted() -> Bool {
return c_borogove.borogove_chat_is_trusted(
self.o
)
}
/**
@returns if this chat is currently syncing with the server
*/
public func syncing() -> Bool {
return c_borogove.borogove_chat_syncing(
self.o
)
}
/**
Can audio calls be started in this Chat?
*/
public func canAudioCall() -> Bool {
return c_borogove.borogove_chat_can_audio_call(
self.o
)
}
/**
Can video calls be started in this Chat?
*/
public func canVideoCall() -> Bool {
return c_borogove.borogove_chat_can_video_call(
self.o
)
}
/**
Start a new call in this Chat
@param audio do we want audio in this call
@param video do we want video in this call
*/
public func startCall(audio: Bool, video: Bool) -> Session {
return AnySession(c_borogove.borogove_chat_start_call(
self.o,
audio,
video
)!)
}
/**
Accept any incoming calls in this Chat
*/
public func acceptCall() -> Void {
return c_borogove.borogove_chat_accept_call(
self.o
)
}
/**
Hangup or reject any calls in this chat
*/
public func hangup() -> Void {
return c_borogove.borogove_chat_hangup(
self.o
)
}
/**
The current status of a call in this chat
*/
public func callStatus() -> CallStatus {
return c_borogove.borogove_chat_call_status(
self.o
)
}
/**
A DTMFSender for a call in this chat, or NULL
*/
public func dtmf() -> DTMFSender? {
return (c_borogove.borogove_chat_dtmf(
self.o
)).map({ DTMFSender($0) })
}
/**
All video tracks in all active calls in this chat
*/
public func videoTracks() -> Array<MediaStreamTrack> {
return {var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_chat_video_tracks(
self.o
, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({MediaStreamTrack($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
/**
Get encryption mode for this chat
*/
public func encryptionMode() -> String {
return useString(c_borogove.borogove_chat_encryption_mode(
self.o
))!
}
/**
Can the user send messages to this chat?
*/
public func canSend() -> Bool {
return c_borogove.borogove_chat_can_send(
self.o
)
}
/**
Invite another chat's participants to participate in this one
*/
public func invite(other: Chat, threadId: String? = nil) -> Void {
return c_borogove.borogove_chat_invite(
self.o,
other.o,
threadId
)
}
/**
Can the user invite others to this chat?
*/
public func canInvite() -> Bool {
return c_borogove.borogove_chat_can_invite(
self.o
)
}
/**
This chat's primary mode of interaction is via commands
*/
public func isApp() -> Bool {
return c_borogove.borogove_chat_is_app(
self.o
)
}
/**
Does this chat provide a menu of commands?
*/
public func hasCommands() -> Bool {
return c_borogove.borogove_chat_has_commands(
self.o
)
}
public func commands() async -> Array<Command> {
return await withUnsafeContinuation { cont in
let __cont_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(cont as AnyObject).toOpaque())
return c_borogove.borogove_chat_commands(
self.o,
{ (a, a_length, ctx) in
let cont = Unmanaged<AnyObject>.fromOpaque(ctx!).takeRetainedValue() as! UnsafeContinuation<Array<Command>, Never>
cont.resume(returning: {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: a, count: a_length).map({Command($0!)});c_borogove.borogove_release(a);return __r;}())
},
__cont_ptr
)
}
}
/**
The Participant that originally invited us to this Chat, if we were invited
*/
public func invitedBy() -> Participant? {
return (c_borogove.borogove_chat_invited_by(
self.o
)).map({ Participant($0) })
}
deinit {
c_borogove.borogove_release(o)
}
}
public class AvailableChat: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
The ID of the Chat this search result represents
*/
public var chatId: String {
get {
useString(c_borogove.borogove_available_chat_chat_id(o))!
}
}
/**
The display name of this search result
*/
public var displayName: String? {
get {
useString(c_borogove.borogove_available_chat_display_name(o))
}
}
/**
A human-readable note associated with this search result
*/
public var note: String {
get {
useString(c_borogove.borogove_available_chat_note(o))!
}
}
/**
Is this search result a channel?
*/
public func isChannel() -> Bool {
return c_borogove.borogove_available_chat_is_channel(
self.o
)
}
deinit {
c_borogove.borogove_release(o)
}
}
public protocol Session: SDKObject {
}
public class AnySession: Session {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
deinit {
c_borogove.borogove_release(o)
}
}
public class MediaStream: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
public init() {
o = (c_borogove.borogove_calls_media_stream_new())
}
/**
Create default bidirectional audio track
*/
public static func makeAudio() -> MediaStream {
MediaStream(c_borogove.borogove_calls_media_stream_make_audio(
)!)
}
public func addTrack(track: MediaStreamTrack) -> Void {
return c_borogove.borogove_calls_media_stream_add_track(
self.o,
track.o
)
}
public func getTracks() -> Array<MediaStreamTrack> {
return {var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_calls_media_stream_get_tracks(
self.o
, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({MediaStreamTrack($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
deinit {
c_borogove.borogove_release(o)
}
}
public class InitiatedSession: SDKObject, Session, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
public var sid: String {
get {
useString(c_borogove.borogove_calls_initiated_session_sid(o))!
}
}
public var chatId: String {
get {
useString(c_borogove.borogove_calls_initiated_session_chat_id(o))!
}
}
public func accept() -> Void {
return c_borogove.borogove_calls_initiated_session_accept(
self.o
)
}
public func hangup() -> Void {
return c_borogove.borogove_calls_initiated_session_hangup(
self.o
)
}
public func addMedia(streams: Array<MediaStream>) -> Void {
return c_borogove.borogove_calls_initiated_session_add_media(
self.o,
streams.map { $0.o }, streams.count
)
}
public func callStatus() -> CallStatus {
return c_borogove.borogove_calls_initiated_session_call_status(
self.o
)
}
public func audioTracks() -> Array<MediaStreamTrack> {
return {var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_calls_initiated_session_audio_tracks(
self.o
, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({MediaStreamTrack($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
public func videoTracks() -> Array<MediaStreamTrack> {
return {var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_calls_initiated_session_video_tracks(
self.o
, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({MediaStreamTrack($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
public func dtmf() -> DTMFSender? {
return (c_borogove.borogove_calls_initiated_session_dtmf(
self.o
)).map({ DTMFSender($0) })
}
public func supplyMedia(streams: Array<MediaStream>) -> Void {
return c_borogove.borogove_calls_initiated_session_supply_media(
self.o,
streams.map { $0.o }, streams.count
)
}
deinit {
c_borogove.borogove_release(o)
}
}
public class Client: EventEmitter, @unchecked Sendable {
internal override init(_ ptr: UnsafeMutableRawPointer) {
super.init(ptr)
}
/**
Create a new Client to connect to a particular account
@param accountId the account to connect to
@param persistence the persistence layer to use for storage
*/
public init(accountId: String, persistence: Persistence) {
super.init(c_borogove.borogove_client_new(accountId, persistence.o))
}
/**
Start this client running and trying to connect to the server
*/
public func start() -> Void {
return c_borogove.borogove_client_start(
self.o
)
}
/**
Gets the client ready to use but does not connect to the server
@returns Promise resolving to true once the Client is ready
*/
public func startOffline() async -> Bool {
return await withUnsafeContinuation { cont in
let __cont_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(cont as AnyObject).toOpaque())
return c_borogove.borogove_client_start_offline(
self.o,
{ (a, ctx) in
let cont = Unmanaged<AnyObject>.fromOpaque(ctx!).takeRetainedValue() as! UnsafeContinuation<Bool, Never>
cont.resume(returning: a)
},
__cont_ptr
)
}
}
/**
Destroy local data for this account
@param completely if true chats, messages, etc will be deleted as well
*/
public func logout(completely: Bool) -> Void {
return c_borogove.borogove_client_logout(
self.o,
completely
)
}
/**
Sets the password to be used in response to the password needed event
@param password
*/
public func usePassword(password: String) -> Void {
return c_borogove.borogove_client_use_password(
self.o,
password
)
}
/**
Get the account ID for this Client
@returns account id
*/
public func accountId() -> String {
return useString(c_borogove.borogove_client_account_id(
self.o
))!
}
/**
Get the current display name for this account
@returns display name
*/
public func displayName() -> String {
return useString(c_borogove.borogove_client_display_name(
self.o
))!
}
/**
Set the current profile for this account on the server
@param profile to set
@param publicAccess set the access for the profile to public
*/
public func setProfile(profile: ProfileBuilder, publicAccess: Bool) -> Void {
return c_borogove.borogove_client_set_profile(
self.o,
profile.o,
publicAccess
)
}
/**
Turn a file into a ChatAttachment for attaching to a ChatMessage
@param source The AttachmentSource to use
@returns Promise resolving to a ChatAttachment or null
*/
public func prepareAttachment(source: AttachmentSource) async -> ChatAttachment? {
return await withUnsafeContinuation { cont in
let __cont_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(cont as AnyObject).toOpaque())
return c_borogove.borogove_client_prepare_attachment(
self.o,
source.o,
{ (a, ctx) in
let cont = Unmanaged<AnyObject>.fromOpaque(ctx!).takeRetainedValue() as! UnsafeContinuation<ChatAttachment?, Never>
cont.resume(returning: (a).map({ let x = ChatAttachment($0); print(x.name); return x }))
},
__cont_ptr
)
}
}
/**
@returns array of open chats, sorted by last activity
*/
public func getChats() -> Array<Chat> {
return {var __ret: UnsafeMutablePointer<UnsafeMutableRawPointer?>? = nil;let __ret_length = c_borogove.borogove_client_get_chats(
self.o
, &__ret);return {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: __ret, count: __ret_length).map({Chat($0!)});c_borogove.borogove_release(__ret);return __r;}();}()
}
/**
Search for chats the user can start or join
@param q the search query to use
@param callback takes two arguments, the query that was used and the array of results, and returns true if we should stop searching
*/
public func findAvailableChats(q: String, callback: @Sendable @escaping (String, Array<AvailableChat>)->Bool) -> Void {
let __callback_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(callback as AnyObject).toOpaque())
return c_borogove.borogove_client_find_available_chats(
self.o,
q,
{ (a0, a1, a1_length, ctx) in
let callback = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable (String, Array<AvailableChat>)->Bool
return callback(useString(a0)!, {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: a1, count: a1_length).map({AvailableChat($0!)});c_borogove.borogove_release(a1);return __r;}())
},
__callback_ptr
)
}
/**
Start or join a chat from the search results
@returns the chat that was started
*/
public func startChat(availableChat: AvailableChat) -> Chat {
return Chat(c_borogove.borogove_client_start_chat(
self.o,
availableChat.o
)!)
}
/**
Find a chat by id
@returns the chat if known, or NULL
*/
public func getChat(chatId: String) -> Chat? {
return (c_borogove.borogove_client_get_chat(
self.o,
chatId
)).map({ Chat($0) })
}
/**
Enable push notifications
@param push_service the address of a push proxy
@param vapid_private_pkcs8 the private key for signing JWT of the push service
@param endpoint the final target for the push proxy to forward to
@param p256dh A P-256 uncompressed point in ANSI X9.62 format
@param auth Random 16 octed value
@param grace Grace period during which not to generate push if another app is active for same account, in seconds (negative for none)
@param claims Optional additional JWT claims as key then value
*/
public func enablePush(push_service: String, endpoint: String, p256dh: Array<UInt8>, auth: Array<UInt8>, grace: Int32, vapid_private_pkcs8: Array<UInt8>? = nil, claims: Array<String>? = nil) -> Void {
withOptionalArrayOfCStrings(claims) { __claims in return c_borogove.borogove_client_enable_push(
self.o,
push_service,
endpoint,
p256dh, p256dh.count,
auth, auth.count,
grace,
vapid_private_pkcs8, vapid_private_pkcs8?.count ?? 0,
__claims, claims?.count ?? 0
)}
}
/**
Event fired when client needs a password for authentication
@param handler takes one argument, the Client that needs a password
@returns token for use with removeEventListener
*/
public func addPasswordNeededListener(handler: @Sendable @escaping (Client)->Void) -> Int32 {
let __handler_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(handler as AnyObject).toOpaque())
return c_borogove.borogove_client_add_password_needed_listener(
self.o,
{ (a0, ctx) in
let handler = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable (Client)->Void
return handler(Client(a0!))
},
__handler_ptr
)
}
/**
Event fired when client is connected and fully synchronized
@param handler takes no arguments
@returns token for use with removeEventListener
*/
public func addStatusOnlineListener(handler: @Sendable @escaping ()->Void) -> Int32 {
let __handler_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(handler as AnyObject).toOpaque())
return c_borogove.borogove_client_add_status_online_listener(
self.o,
{ (ctx) in
let handler = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable ()->Void
return handler()
},
__handler_ptr
)
}
/**
Event fired when client is disconnected
@param handler takes no arguments
@returns token for use with removeEventListener
*/
public func addStatusOfflineListener(handler: @Sendable @escaping ()->Void) -> Int32 {
let __handler_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(handler as AnyObject).toOpaque())
return c_borogove.borogove_client_add_status_offline_listener(
self.o,
{ (ctx) in
let handler = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable ()->Void
return handler()
},
__handler_ptr
)
}
/**
Event fired when connection fails with a fatal error and will not be retried
@param handler takes no arguments
@returns token for use with removeEventListener
*/
public func addConnectionFailedListener(handler: @Sendable @escaping ()->Void) -> Int32 {
let __handler_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(handler as AnyObject).toOpaque())
return c_borogove.borogove_client_add_connection_failed_listener(
self.o,
{ (ctx) in
let handler = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable ()->Void
return handler()
},
__handler_ptr
)
}
/**
Event fired when TLS checks fail, to give client the chance to override
@param handler takes two arguments, the PEM of the cert and an array of DNS names, and must return true to accept or false to reject
@returns token for use with removeEventListener
*/
public func addTlsCheckListener(handler: @Sendable @escaping (String, Array<String>)->Bool) -> Int32 {
let __handler_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(handler as AnyObject).toOpaque())
return c_borogove.borogove_client_add_tls_check_listener(
self.o,
{ (a0, a1, a1_length, ctx) in
let handler = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable (String, Array<String>)->Bool
return handler(useString(a0)!, {let __r = UnsafeMutableBufferPointer<UnsafePointer<CChar>?>(start: a1, count: a1_length).map({useString($0)!});c_borogove.borogove_release(a1);return __r;}())
},
__handler_ptr
)
}
/**
Event fired when a new ChatMessage comes in on any Chat
Also fires when status of a ChatMessage changes,
when a ChatMessage is edited, or when a reaction is added
@param handler takes two arguments, the ChatMessage and ChatMessageEvent enum describing what happened
@returns token for use with removeEventListener
*/
public func addChatMessageListener(handler: @Sendable @escaping (ChatMessage, Int32)->Void) -> Int32 {
let __handler_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(handler as AnyObject).toOpaque())
return c_borogove.borogove_client_add_chat_message_listener(
self.o,
{ (a0, a1, ctx) in
let handler = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable (ChatMessage, Int32)->Void
return handler(ChatMessage(a0!), a1)
},
__handler_ptr
)
}
/**
Event fired when syncing a new ChatMessage that was send when offline.
Normally you don't want this, but it may be useful if you want to notify on app start.
@param handler takes one argument, the ChatMessage
@returns token for use with removeEventListener
*/
public func addSyncMessageListener(handler: @Sendable @escaping (ChatMessage)->Void) -> Int32 {
let __handler_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(handler as AnyObject).toOpaque())
return c_borogove.borogove_client_add_sync_message_listener(
self.o,
{ (a0, ctx) in
let handler = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable (ChatMessage)->Void
return handler(ChatMessage(a0!))
},
__handler_ptr
)
}
/**
Event fired when a Chat's metadata is updated, or when a new Chat is added
@param handler takes one argument, an array of Chats that were updated
@returns token for use with removeEventListener
*/
public func addChatsUpdatedListener(handler: @Sendable @escaping (Array<Chat>)->Void) -> Int32 {
let __handler_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(handler as AnyObject).toOpaque())
return c_borogove.borogove_client_add_chats_updated_listener(
self.o,
{ (a0, a0_length, ctx) in
let handler = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable (Array<Chat>)->Void
return handler({let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: a0, count: a0_length).map({Chat($0!)});c_borogove.borogove_release(a0);return __r;}())
},
__handler_ptr
)
}
/**
Event fired when a new call comes in
@param handler takes one argument, the call Session
@returns token for use with removeEventListener
*/
public func addCallRingListener(handler: @Sendable @escaping (Session)->Void) -> Int32 {
let __handler_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(handler as AnyObject).toOpaque())
return c_borogove.borogove_client_add_call_ring_listener(
self.o,
{ (a0, ctx) in
let handler = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable (Session)->Void
return handler(AnySession(a0!))
},
__handler_ptr
)
}
/**
Event fired when a call is retracted or hung up
@param handler takes two arguments, the associated Chat ID and Session ID
@returns token for use with removeEventListener
*/
public func addCallRetractListener(handler: @Sendable @escaping (String, String)->Void) -> Int32 {
let __handler_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(handler as AnyObject).toOpaque())
return c_borogove.borogove_client_add_call_retract_listener(
self.o,
{ (a0, a1, ctx) in
let handler = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable (String, String)->Void
return handler(useString(a0)!, useString(a1)!)
},
__handler_ptr
)
}
/**
Event fired when an outgoing call starts ringing
@param handler takes one argument, the associated Session
@returns token for use with removeEventListener
*/
public func addCallRingingListener(handler: @Sendable @escaping (Session)->Void) -> Int32 {
let __handler_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(handler as AnyObject).toOpaque())
return c_borogove.borogove_client_add_call_ringing_listener(
self.o,
{ (a0, ctx) in
let handler = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable (Session)->Void
return handler(AnySession(a0!))
},
__handler_ptr
)
}
/**
Event fired when an existing call changes status (connecting, failed, etc)
@param handler takes one argument, the associated Session
@returns token for use with removeEventListener
*/
public func addCallUpdateStatusListener(handler: @Sendable @escaping (InitiatedSession)->Void) -> Int32 {
let __handler_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(handler as AnyObject).toOpaque())
return c_borogove.borogove_client_add_call_update_status_listener(
self.o,
{ (a0, ctx) in
let handler = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable (InitiatedSession)->Void
return handler(InitiatedSession(a0!))
},
__handler_ptr
)
}
/**
Event fired when a call is asking for media to send
@param handler takes three arguments, the call Session,
a boolean indicating if audio is desired,
and a boolean indicating if video is desired
@returns token for use with removeEventListener
*/
public func addCallMediaListener(handler: @Sendable @escaping (InitiatedSession, Bool, Bool)->Void) -> Int32 {
let __handler_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(handler as AnyObject).toOpaque())
return c_borogove.borogove_client_add_call_media_listener(
self.o,
{ (a0, a1, a2, ctx) in
let handler = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable (InitiatedSession, Bool, Bool)->Void
return handler(InitiatedSession(a0!), a1, a2)
},
__handler_ptr
)
}
/**
Event fired when call has a new MediaStreamTrack to play
@param handler takes three arguments, the associated Chat ID,
the new MediaStreamTrack, and an array of any associated MediaStreams
@returns token for use with removeEventListener
*/
public func addCallTrackListener(handler: @Sendable @escaping (InitiatedSession, MediaStreamTrack, Array<MediaStream>)->Void) -> Int32 {
let __handler_ptr = UnsafeMutableRawPointer(Unmanaged.passRetained(handler as AnyObject).toOpaque())
return c_borogove.borogove_client_add_call_track_listener(
self.o,
{ (a0, a1, a2, a2_length, ctx) in
let handler = Unmanaged<AnyObject>.fromOpaque(ctx!).takeUnretainedValue() as! @Sendable (InitiatedSession, MediaStreamTrack, Array<MediaStream>)->Void
return handler(InitiatedSession(a0!), MediaStreamTrack(a1!), {let __r = UnsafeMutableBufferPointer<UnsafeMutableRawPointer?>(start: a2, count: a2_length).map({MediaStream($0!)});c_borogove.borogove_release(a2);return __r;}())
},
__handler_ptr
)
}
/**
Let the SDK know the UI is in the foreground
*/
public func setInForeground() -> Void {
return c_borogove.borogove_client_set_in_foreground(
self.o
)
}
/**
Let the SDK know the UI is in the foreground
*/
public func setNotInForeground() -> Void {
return c_borogove.borogove_client_set_not_in_foreground(
self.o
)
}
}
public class FormSubmitBuilder: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
public init() {
o = (c_borogove.borogove_form_submit_builder_new())
}
public func add(k: String, v: String) -> Void {
return c_borogove.borogove_form_submit_builder_add(
self.o,
k,
v
)
}
deinit {
c_borogove.borogove_release(o)
}
}
public class AttachmentSource: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
public init(path: String, mime: String) {
o = (c_borogove.borogove_attachment_source_new(path, mime))
}
public var path: String {
get {
useString(c_borogove.borogove_attachment_source_path(o))!
}
}
public var type: String {
get {
useString(c_borogove.borogove_attachment_source_type(o))!
}
}
public var name: String {
get {
useString(c_borogove.borogove_attachment_source_name(o))!
}
}
public var size: Int32 {
get {
c_borogove.borogove_attachment_source_size(o)
}
}
deinit {
c_borogove.borogove_release(o)
}
}
public class ProfileBuilder: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
public init(profile: Profile) {
o = (c_borogove.borogove_profile_builder_new(profile.o))
}
/**
Add a new field to this profile
*/
public func add(k: String, v: String) -> Void {
return c_borogove.borogove_profile_builder_add(
self.o,
k,
v
)
}
/**
Set the value of an existing field on this profile
*/
public func set(id: String, v: String) -> Void {
return c_borogove.borogove_profile_builder_set(
self.o,
id,
v
)
}
/**
Move a profile item
@param id the item to move
@param moveTo the item currently in the position where it should move to
*/
public func move(id: String, moveTo: String) -> Void {
return c_borogove.borogove_profile_builder_move(
self.o,
id,
moveTo
)
}
/**
Remove a field from this profile
*/
public func remove(id: String) -> Void {
return c_borogove.borogove_profile_builder_remove(
self.o,
id
)
}
public func build() -> Profile {
return Profile(c_borogove.borogove_profile_builder_build(
self.o
)!)
}
deinit {
c_borogove.borogove_release(o)
}
}
public class Channel: Chat, @unchecked Sendable {
internal override init(_ ptr: UnsafeMutableRawPointer) {
super.init(ptr)
}
public func description() -> String {
return useString(c_borogove.borogove_channel_description(
self.o
))!
}
public func isPrivate() -> Bool {
return c_borogove.borogove_channel_is_private(
self.o
)
}
}
public class DirectChat: Chat, @unchecked Sendable {
internal override init(_ ptr: UnsafeMutableRawPointer) {
super.init(ptr)
}
}
public class DTMFSender: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
Schedule DTMF events to be sent
@param tones can be any number of 0123456789#*ABCD,
*/
public func insertDTMF(tones: String) -> Void {
return c_borogove.borogove_calls_dtmf_sender_insert_dtmf(
self.o,
tones
)
}
deinit {
c_borogove.borogove_release(o)
}
}
public class CustomEmojiReaction: Reaction, @unchecked Sendable {
internal override init(_ ptr: UnsafeMutableRawPointer) {
super.init(ptr)
}
/**
Create a new custom emoji reaction to send
@param text name of custom emoji
@param uri URI for media of custom emoji
@returns Reaction
*/
public static func custom(text: String, uri: String) -> CustomEmojiReaction {
CustomEmojiReaction(c_borogove.borogove_custom_emoji_reaction_custom(
text,
uri
)!)
}
public var uri: String {
get {
useString(c_borogove.borogove_custom_emoji_reaction_uri(o))!
}
}
}
public class Identicon: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
public static func svg(source: String) -> String {
useString(c_borogove.borogove_identicon_svg(
source
))!
}
deinit {
c_borogove.borogove_release(o)
}
}
public class Config: SDKObject, @unchecked Sendable {
public let o: UnsafeMutableRawPointer
internal init(_ ptr: UnsafeMutableRawPointer) {
o = ptr
}
/**
Produce /.well-known/ni/ paths instead of ni:/// URIs
for referencing media by hash.
This can be useful eg for intercepting with a Service Worker.
*/
public var relativeHashUri: Bool {
get {
c_borogove.borogove_config_relative_hash_uri()
}
set {
c_borogove.borogove_config_set_relative_hash_uri(newValue)
}
}
/**
Trades off some performance for lower / more consistent memory usage
*/
public static func enableConstrainedMemoryMode() -> Void {
c_borogove.borogove_config_enable_constrained_memory_mode(
)
}
deinit {
c_borogove.borogove_release(o)
}
}
public typealias UiState = borogove_ui_state
public typealias MessageType = borogove_message_type
public typealias MessageStatus = borogove_message_status
public typealias MessageDirection = borogove_message_direction
public typealias EncryptionStatus = borogove_encryption_status
public typealias CallStatus = borogove_calls_call_status