objc2_call_kit/generated/
CXProvider.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "dispatch2")]
6use dispatch2::*;
7use objc2::__framework_prelude::*;
8#[cfg(feature = "objc2-avf-audio")]
9use objc2_avf_audio::*;
10use objc2_foundation::*;
11
12use crate::*;
13
14/// [Apple's documentation](https://developer.apple.com/documentation/callkit/cxcallendedreason?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct CXCallEndedReason(pub NSInteger);
19impl CXCallEndedReason {
20    #[doc(alias = "CXCallEndedReasonFailed")]
21    pub const Failed: Self = Self(1);
22    #[doc(alias = "CXCallEndedReasonRemoteEnded")]
23    pub const RemoteEnded: Self = Self(2);
24    #[doc(alias = "CXCallEndedReasonUnanswered")]
25    pub const Unanswered: Self = Self(3);
26    #[doc(alias = "CXCallEndedReasonAnsweredElsewhere")]
27    pub const AnsweredElsewhere: Self = Self(4);
28    #[doc(alias = "CXCallEndedReasonDeclinedElsewhere")]
29    pub const DeclinedElsewhere: Self = Self(5);
30}
31
32unsafe impl Encode for CXCallEndedReason {
33    const ENCODING: Encoding = NSInteger::ENCODING;
34}
35
36unsafe impl RefEncode for CXCallEndedReason {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40extern_protocol!(
41    /// [Apple's documentation](https://developer.apple.com/documentation/callkit/cxproviderdelegate?language=objc)
42    pub unsafe trait CXProviderDelegate: NSObjectProtocol {
43        /// Called when the provider has been reset. Delegates must respond to this callback by cleaning up all internal call state (disconnecting communication channels, releasing network resources, etc.). This callback can be treated as a request to end all calls without the need to respond to any actions
44        #[unsafe(method(providerDidReset:))]
45        #[unsafe(method_family = none)]
46        unsafe fn providerDidReset(&self, provider: &CXProvider);
47
48        /// Called when the provider has been fully created and is ready to send actions and receive updates
49        #[optional]
50        #[unsafe(method(providerDidBegin:))]
51        #[unsafe(method_family = none)]
52        unsafe fn providerDidBegin(&self, provider: &CXProvider);
53
54        #[cfg(feature = "CXTransaction")]
55        /// Called whenever a new transaction should be executed. Return whether or not the transaction was handled:
56        ///
57        /// - NO: the transaction was not handled indicating that the perform*CallAction methods should be called sequentially for each action in the transaction
58        /// - YES: the transaction was handled and the perform*CallAction methods should not be called sequentially
59        ///
60        /// If the method is not implemented, NO is assumed.
61        #[optional]
62        #[unsafe(method(provider:executeTransaction:))]
63        #[unsafe(method_family = none)]
64        unsafe fn provider_executeTransaction(
65            &self,
66            provider: &CXProvider,
67            transaction: &CXTransaction,
68        ) -> bool;
69
70        #[cfg(all(
71            feature = "CXAction",
72            feature = "CXCallAction",
73            feature = "CXStartCallAction"
74        ))]
75        #[optional]
76        #[unsafe(method(provider:performStartCallAction:))]
77        #[unsafe(method_family = none)]
78        unsafe fn provider_performStartCallAction(
79            &self,
80            provider: &CXProvider,
81            action: &CXStartCallAction,
82        );
83
84        #[cfg(all(
85            feature = "CXAction",
86            feature = "CXAnswerCallAction",
87            feature = "CXCallAction"
88        ))]
89        #[optional]
90        #[unsafe(method(provider:performAnswerCallAction:))]
91        #[unsafe(method_family = none)]
92        unsafe fn provider_performAnswerCallAction(
93            &self,
94            provider: &CXProvider,
95            action: &CXAnswerCallAction,
96        );
97
98        #[cfg(all(
99            feature = "CXAction",
100            feature = "CXCallAction",
101            feature = "CXEndCallAction"
102        ))]
103        #[optional]
104        #[unsafe(method(provider:performEndCallAction:))]
105        #[unsafe(method_family = none)]
106        unsafe fn provider_performEndCallAction(
107            &self,
108            provider: &CXProvider,
109            action: &CXEndCallAction,
110        );
111
112        #[cfg(all(
113            feature = "CXAction",
114            feature = "CXCallAction",
115            feature = "CXSetHeldCallAction"
116        ))]
117        #[optional]
118        #[unsafe(method(provider:performSetHeldCallAction:))]
119        #[unsafe(method_family = none)]
120        unsafe fn provider_performSetHeldCallAction(
121            &self,
122            provider: &CXProvider,
123            action: &CXSetHeldCallAction,
124        );
125
126        #[cfg(all(
127            feature = "CXAction",
128            feature = "CXCallAction",
129            feature = "CXSetMutedCallAction"
130        ))]
131        #[optional]
132        #[unsafe(method(provider:performSetMutedCallAction:))]
133        #[unsafe(method_family = none)]
134        unsafe fn provider_performSetMutedCallAction(
135            &self,
136            provider: &CXProvider,
137            action: &CXSetMutedCallAction,
138        );
139
140        #[cfg(all(
141            feature = "CXAction",
142            feature = "CXCallAction",
143            feature = "CXSetGroupCallAction"
144        ))]
145        #[optional]
146        #[unsafe(method(provider:performSetGroupCallAction:))]
147        #[unsafe(method_family = none)]
148        unsafe fn provider_performSetGroupCallAction(
149            &self,
150            provider: &CXProvider,
151            action: &CXSetGroupCallAction,
152        );
153
154        #[cfg(all(
155            feature = "CXAction",
156            feature = "CXCallAction",
157            feature = "CXPlayDTMFCallAction"
158        ))]
159        #[optional]
160        #[unsafe(method(provider:performPlayDTMFCallAction:))]
161        #[unsafe(method_family = none)]
162        unsafe fn provider_performPlayDTMFCallAction(
163            &self,
164            provider: &CXProvider,
165            action: &CXPlayDTMFCallAction,
166        );
167
168        #[cfg(feature = "CXAction")]
169        /// Called when an action was not performed in time and has been inherently failed. Depending on the action, this timeout may also force the call to end. An action that has already timed out should not be fulfilled or failed by the provider delegate
170        #[optional]
171        #[unsafe(method(provider:timedOutPerformingAction:))]
172        #[unsafe(method_family = none)]
173        unsafe fn provider_timedOutPerformingAction(
174            &self,
175            provider: &CXProvider,
176            action: &CXAction,
177        );
178
179        #[cfg(feature = "objc2-avf-audio")]
180        /// Called when the provider's audio session activation state changes.
181        #[optional]
182        #[unsafe(method(provider:didActivateAudioSession:))]
183        #[unsafe(method_family = none)]
184        unsafe fn provider_didActivateAudioSession(
185            &self,
186            provider: &CXProvider,
187            audio_session: &AVAudioSession,
188        );
189
190        #[cfg(feature = "objc2-avf-audio")]
191        #[optional]
192        #[unsafe(method(provider:didDeactivateAudioSession:))]
193        #[unsafe(method_family = none)]
194        unsafe fn provider_didDeactivateAudioSession(
195            &self,
196            provider: &CXProvider,
197            audio_session: &AVAudioSession,
198        );
199    }
200);
201
202extern_class!(
203    /// [Apple's documentation](https://developer.apple.com/documentation/callkit/cxprovider?language=objc)
204    #[unsafe(super(NSObject))]
205    #[derive(Debug, PartialEq, Eq, Hash)]
206    pub struct CXProvider;
207);
208
209extern_conformance!(
210    unsafe impl NSObjectProtocol for CXProvider {}
211);
212
213impl CXProvider {
214    extern_methods!(
215        #[cfg(feature = "CXProviderConfiguration")]
216        /// Initialize a new provider instance with the supplied configuration
217        #[unsafe(method(initWithConfiguration:))]
218        #[unsafe(method_family = init)]
219        pub unsafe fn initWithConfiguration(
220            this: Allocated<Self>,
221            configuration: &CXProviderConfiguration,
222        ) -> Retained<Self>;
223
224        #[unsafe(method(new))]
225        #[unsafe(method_family = new)]
226        pub unsafe fn new() -> Retained<Self>;
227
228        #[unsafe(method(init))]
229        #[unsafe(method_family = init)]
230        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
231
232        #[cfg(feature = "dispatch2")]
233        /// Set delegate and optional queue for delegate callbacks to be performed on.
234        /// A nil queue implies that delegate callbacks should happen on the main queue. The delegate is stored weakly
235        ///
236        /// # Safety
237        ///
238        /// `queue` possibly has additional threading requirements.
239        #[unsafe(method(setDelegate:queue:))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn setDelegate_queue(
242            &self,
243            delegate: Option<&ProtocolObject<dyn CXProviderDelegate>>,
244            queue: Option<&DispatchQueue>,
245        );
246
247        #[cfg(all(feature = "CXCallUpdate", feature = "block2"))]
248        /// Report a new incoming call to the system.
249        ///
250        /// If completion is invoked with a non-nil `error`, the incoming call has been disallowed by the system and will not be displayed, so the provider should not proceed with the call.
251        ///
252        /// Completion block will be called on delegate queue, if specified, otherwise on a private serial queue.
253        #[unsafe(method(reportNewIncomingCallWithUUID:update:completion:))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn reportNewIncomingCallWithUUID_update_completion(
256            &self,
257            uuid: &NSUUID,
258            update: &CXCallUpdate,
259            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
260        );
261
262        #[cfg(feature = "CXCallUpdate")]
263        /// Report an update to call information.
264        #[unsafe(method(reportCallWithUUID:updated:))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn reportCallWithUUID_updated(&self, uuid: &NSUUID, update: &CXCallUpdate);
267
268        /// Report that a call ended. A nil value for `dateEnded` results in the ended date being set to now.
269        #[unsafe(method(reportCallWithUUID:endedAtDate:reason:))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn reportCallWithUUID_endedAtDate_reason(
272            &self,
273            uuid: &NSUUID,
274            date_ended: Option<&NSDate>,
275            ended_reason: CXCallEndedReason,
276        );
277
278        /// Report that an outgoing call started connecting. A nil value for `dateStartedConnecting` results in the started connecting date being set to now.
279        #[unsafe(method(reportOutgoingCallWithUUID:startedConnectingAtDate:))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn reportOutgoingCallWithUUID_startedConnectingAtDate(
282            &self,
283            uuid: &NSUUID,
284            date_started_connecting: Option<&NSDate>,
285        );
286
287        /// Report that an outgoing call connected. A nil value for `dateConnected` results in the connected date being set to now.
288        #[unsafe(method(reportOutgoingCallWithUUID:connectedAtDate:))]
289        #[unsafe(method_family = none)]
290        pub unsafe fn reportOutgoingCallWithUUID_connectedAtDate(
291            &self,
292            uuid: &NSUUID,
293            date_connected: Option<&NSDate>,
294        );
295
296        #[cfg(feature = "block2")]
297        /// From within a Notification Service Extension, request the containing application be launched to handle an incoming VoIP call. The application's PKPushRegistryDelegate must handle the push upon launch.
298        ///
299        /// # Safety
300        ///
301        /// `dictionary_payload` generic should be of the correct type.
302        #[unsafe(method(reportNewIncomingVoIPPushPayload:completion:))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn reportNewIncomingVoIPPushPayload_completion(
305            dictionary_payload: &NSDictionary,
306            completion: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
307        );
308
309        #[cfg(feature = "CXProviderConfiguration")]
310        /// The receiver's current configuration.
311        #[unsafe(method(configuration))]
312        #[unsafe(method_family = none)]
313        pub unsafe fn configuration(&self) -> Retained<CXProviderConfiguration>;
314
315        #[cfg(feature = "CXProviderConfiguration")]
316        /// Setter for [`configuration`][Self::configuration].
317        ///
318        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
319        #[unsafe(method(setConfiguration:))]
320        #[unsafe(method_family = none)]
321        pub unsafe fn setConfiguration(&self, configuration: &CXProviderConfiguration);
322
323        /// Invalidate the receiver. All existing calls will be marked as ended in failure. The provider must be invalidated before it is deallocated.
324        #[unsafe(method(invalidate))]
325        #[unsafe(method_family = none)]
326        pub unsafe fn invalidate(&self);
327
328        #[cfg(feature = "CXTransaction")]
329        /// List of all transactions that are incomplete.
330        #[unsafe(method(pendingTransactions))]
331        #[unsafe(method_family = none)]
332        pub unsafe fn pendingTransactions(&self) -> Retained<NSArray<CXTransaction>>;
333
334        #[cfg(all(feature = "CXAction", feature = "CXCallAction"))]
335        /// Returns subset of call actions contained in any transaction in -pendingTransactions of the specified class and with the specified call UUID.
336        ///
337        /// # Safety
338        ///
339        /// `call_action_class` probably has further requirements.
340        #[unsafe(method(pendingCallActionsOfClass:withCallUUID:))]
341        #[unsafe(method_family = none)]
342        pub unsafe fn pendingCallActionsOfClass_withCallUUID(
343            &self,
344            call_action_class: &AnyClass,
345            call_uuid: &NSUUID,
346        ) -> Retained<NSArray<CXCallAction>>;
347    );
348}