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