1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-ui-kit")]
use objc2_ui_kit::*;
use crate::*;
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/carplay/carplayerrordomain?language=objc)
pub static CarPlayErrorDomain: &'static NSString;
}
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpinterfacecontroller?language=objc)
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct CPInterfaceController;
);
extern_conformance!(
unsafe impl NSObjectProtocol for CPInterfaceController {}
);
impl CPInterfaceController {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
/// The delegate for this interface controller.
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub unsafe fn delegate(
&self,
) -> Option<Retained<ProtocolObject<dyn CPInterfaceControllerDelegate>>>;
/// Setter for [`delegate`][Self::delegate].
///
/// This is a [weak property][objc2::topics::weak_property].
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn CPInterfaceControllerDelegate>>,
);
/// Set the preferred interface style to UIUserInterfaceStyleDark for all templates. Set this value to YES prior to setting a root template
/// or pushing any templates for first appearance to have style UIUserInterfaceStyleDark. The default value is NO which will allow templates to change between light and dark styles.
#[unsafe(method(prefersDarkUserInterfaceStyle))]
#[unsafe(method_family = none)]
pub unsafe fn prefersDarkUserInterfaceStyle(&self) -> bool;
/// Setter for [`prefersDarkUserInterfaceStyle`][Self::prefersDarkUserInterfaceStyle].
#[unsafe(method(setPrefersDarkUserInterfaceStyle:))]
#[unsafe(method_family = none)]
pub unsafe fn setPrefersDarkUserInterfaceStyle(
&self,
prefers_dark_user_interface_style: bool,
);
#[cfg(all(feature = "CPTemplate", feature = "block2"))]
/// Set the root template. If no existing templates exist in the template navigation hierarchy, the animated flag will be ignored.
/// If there is an existing template navigation hierarchy, the existing stack will be replaced by the new root template.
///
/// The completion block will be called after the template has been presented. If the template was presented successfully,
/// the boolean parameter will be YES. Otherwise, the boolean parameter will be NO and an
/// `NSError`will be provided describing the failure.
///
///
/// Note: If the template presentation is not successful AND no completion block is specified, an exception will be thrown.
#[unsafe(method(setRootTemplate:animated:completion:))]
#[unsafe(method_family = none)]
pub unsafe fn setRootTemplate_animated_completion(
&self,
root_template: &CPTemplate,
animated: bool,
completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
);
#[cfg(all(feature = "CPTemplate", feature = "block2"))]
/// Push a new template onto the template navigation hierarchy, showing it immediately.
///
/// The completion block will be called after the template has been presented. If the template was presented successfully,
/// the boolean parameter will be YES. Otherwise, the boolean parameter will be NO and an
/// `NSError`will be provided describing the failure.
///
///
/// Note: If the template presentation is not successful AND no completion block is specified, an exception will be thrown.
#[unsafe(method(pushTemplate:animated:completion:))]
#[unsafe(method_family = none)]
pub unsafe fn pushTemplate_animated_completion(
&self,
template_to_push: &CPTemplate,
animated: bool,
completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
);
#[cfg(feature = "block2")]
/// Pop back a single level in the template navigation hierarchy.
/// The completion block will be called after the pop completes.
/// The success parameter in the completion block indicates if any template was popped.
#[unsafe(method(popTemplateAnimated:completion:))]
#[unsafe(method_family = none)]
pub unsafe fn popTemplateAnimated_completion(
&self,
animated: bool,
completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
);
#[cfg(feature = "block2")]
/// Pop back to the first template in the template navigation hierarchy.
/// The completion block will be called after the pop completes.
/// The success parameter in the completion block indicates if any templates were popped.
#[unsafe(method(popToRootTemplateAnimated:completion:))]
#[unsafe(method_family = none)]
pub unsafe fn popToRootTemplateAnimated_completion(
&self,
animated: bool,
completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
);
#[cfg(all(feature = "CPTemplate", feature = "block2"))]
/// Pop back to a specified template.
///
/// targetTemplate must exist in the current template navigation hierarchy.
///
/// The completion block will be called after the pop completes.
/// If the specified template does not exist in the template stack,
/// the completion block will be called with a success parameter of NO and a non-nil NSError.
#[unsafe(method(popToTemplate:animated:completion:))]
#[unsafe(method_family = none)]
pub unsafe fn popToTemplate_animated_completion(
&self,
target_template: &CPTemplate,
animated: bool,
completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
);
#[cfg(all(feature = "CPTemplate", feature = "block2"))]
/// Present a template modally over the navigation hierarchy. Only one template may be presented at a time.
///
///
/// Note: Supported template types:
/// `CPActionSheetTemplate,``CPAlertTemplate,``CPVoiceControlTemplate`The completion block will be called after the template has been presented. If the template was presented successfully,
/// the boolean parameter will be YES. Otherwise, the boolean parameter will be NO and an
/// `NSError`will be provided describing the failure.
///
///
/// Note: If the template presentation is not successful AND no completion block is specified, an exception will be thrown.
#[unsafe(method(presentTemplate:animated:completion:))]
#[unsafe(method_family = none)]
pub unsafe fn presentTemplate_animated_completion(
&self,
template_to_present: &CPTemplate,
animated: bool,
completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
);
#[cfg(feature = "block2")]
/// Dismiss the current modally-presented template, optionally animating the dismissal.
///
///
/// Note: If there is no current modally-presented template, this method will have no effect.
///
/// The completion block will be called after the template has been dismissed. If the template was dismissed successfully,
/// the boolean parameter will be YES. Otherwise, the boolean parameter will be NO and an
/// `NSError`will be provided describing the failure.
#[unsafe(method(dismissTemplateAnimated:completion:))]
#[unsafe(method_family = none)]
pub unsafe fn dismissTemplateAnimated_completion(
&self,
animated: bool,
completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
);
#[cfg(feature = "CPTemplate")]
/// The current modally-presented template.
///
///
/// Warning: Reading this property may synchronously perform an IPC call to retrieve the current presented template.
#[unsafe(method(presentedTemplate))]
#[unsafe(method_family = none)]
pub unsafe fn presentedTemplate(&self) -> Option<Retained<CPTemplate>>;
#[cfg(feature = "CPTemplate")]
/// Returns the root template.
#[unsafe(method(rootTemplate))]
#[unsafe(method_family = none)]
pub unsafe fn rootTemplate(&self) -> Retained<CPTemplate>;
#[cfg(feature = "CPTemplate")]
/// The top template in the navigation hierarchy.
///
///
/// Warning: Reading this property may synchronously perform an IPC call to retrieve the current top-most template.
#[unsafe(method(topTemplate))]
#[unsafe(method_family = none)]
pub unsafe fn topTemplate(&self) -> Option<Retained<CPTemplate>>;
#[cfg(feature = "CPTemplate")]
/// The current stack of templates in the navigation hierarchy.
///
///
/// Warning: Reading this property may synchronously perform an IPC call to retrieve the current stack of templates.
#[unsafe(method(templates))]
#[unsafe(method_family = none)]
pub unsafe fn templates(&self) -> Retained<NSArray<CPTemplate>>;
#[cfg(feature = "objc2-ui-kit")]
/// The trait collection for the car's primary screen.
///
/// Your app should use this trait collection when deriving metrics, like screen scale, for
/// your templates. For example, images you display in any template should be sized to a
/// display scale matching the scale of the
/// `carTraitCollection,`not the scale of the
/// iOS device's main screen.
#[unsafe(method(carTraitCollection))]
#[unsafe(method_family = none)]
pub unsafe fn carTraitCollection(&self) -> Retained<UITraitCollection>;
#[cfg(feature = "CPTemplate")]
/// Set the root template. If no existing templates exist in the template navigation hierarchy, the animated flag will be ignored.
/// If there is an existing template navigation hierarchy, the existing stack will be replaced by the new root template.
#[deprecated]
#[unsafe(method(setRootTemplate:animated:))]
#[unsafe(method_family = none)]
pub unsafe fn setRootTemplate_animated(&self, root_template: &CPTemplate, animated: bool);
#[cfg(feature = "CPTemplate")]
/// Push a new template onto the template navigation hierarchy, showing it immediately.
#[deprecated]
#[unsafe(method(pushTemplate:animated:))]
#[unsafe(method_family = none)]
pub unsafe fn pushTemplate_animated(&self, template_to_push: &CPTemplate, animated: bool);
/// Pop back a single level in the template navigation hierarchy.
#[deprecated]
#[unsafe(method(popTemplateAnimated:))]
#[unsafe(method_family = none)]
pub unsafe fn popTemplateAnimated(&self, animated: bool);
/// Pop back to the first template in the template navigation hierarchy.
#[deprecated]
#[unsafe(method(popToRootTemplateAnimated:))]
#[unsafe(method_family = none)]
pub unsafe fn popToRootTemplateAnimated(&self, animated: bool);
#[cfg(feature = "CPTemplate")]
/// Pop back to a specified template.
///
/// targetTemplate must exist in the current template navigation hierarchy.
#[deprecated]
#[unsafe(method(popToTemplate:animated:))]
#[unsafe(method_family = none)]
pub unsafe fn popToTemplate_animated(&self, target_template: &CPTemplate, animated: bool);
#[cfg(feature = "CPTemplate")]
/// Present a template modally over the navigation hierarchy. Only one template may be presented at a time.
///
///
/// Note: Supported template types:
/// `CPActionSheetTemplate,``CPAlertTemplate,``CPVoiceControlTemplate`
#[deprecated]
#[unsafe(method(presentTemplate:animated:))]
#[unsafe(method_family = none)]
pub unsafe fn presentTemplate_animated(
&self,
template_to_present: &CPTemplate,
animated: bool,
);
/// Dismiss the current modally-presented template, optionally animating the dismissal.
///
///
/// Note: If there is no current modally-presented template, this method will have no effect.
#[deprecated]
#[unsafe(method(dismissTemplateAnimated:))]
#[unsafe(method_family = none)]
pub unsafe fn dismissTemplateAnimated(&self, animated: bool);
);
}
extern_protocol!(
/// CPInterfaceControllerDelegate allows your app to observe template visibility lifecycles for
/// the templates presented by your app.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpinterfacecontrollerdelegate?language=objc)
pub unsafe trait CPInterfaceControllerDelegate:
NSObjectProtocol + MainThreadOnly
{
#[cfg(feature = "CPTemplate")]
#[optional]
#[unsafe(method(templateWillAppear:animated:))]
#[unsafe(method_family = none)]
unsafe fn templateWillAppear_animated(&self, a_template: &CPTemplate, animated: bool);
#[cfg(feature = "CPTemplate")]
#[optional]
#[unsafe(method(templateDidAppear:animated:))]
#[unsafe(method_family = none)]
unsafe fn templateDidAppear_animated(&self, a_template: &CPTemplate, animated: bool);
#[cfg(feature = "CPTemplate")]
#[optional]
#[unsafe(method(templateWillDisappear:animated:))]
#[unsafe(method_family = none)]
unsafe fn templateWillDisappear_animated(&self, a_template: &CPTemplate, animated: bool);
#[cfg(feature = "CPTemplate")]
#[optional]
#[unsafe(method(templateDidDisappear:animated:))]
#[unsafe(method_family = none)]
unsafe fn templateDidDisappear_animated(&self, a_template: &CPTemplate, animated: bool);
}
);
extern_protocol!(
/// A set of methods that are called by the
/// `UIApplication`singleton in response to CarPlay lifecycle events.
///
///
/// This must be implemented by the same object that serves as your application's delegate object.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpapplicationdelegate?language=objc)
#[cfg(feature = "objc2-ui-kit")]
#[deprecated]
pub unsafe trait CPApplicationDelegate: UIApplicationDelegate {
#[cfg(feature = "CPWindow")]
/// The CarPlay screen has connected and is ready to present content.
///
/// Your app should create its view controller and assign it to the
/// `rootViewController`property
/// of this window.
///
///
/// Note: It is the responsibility of the delegate to maintain a reference to the interface controller beyond the scope of this method.
#[deprecated]
#[unsafe(method(application:didConnectCarInterfaceController:toWindow:))]
#[unsafe(method_family = none)]
unsafe fn application_didConnectCarInterfaceController_toWindow(
&self,
application: &UIApplication,
interface_controller: &CPInterfaceController,
window: &CPWindow,
);
#[cfg(feature = "CPWindow")]
/// The CarPlay screen has disconnected.
#[deprecated]
#[unsafe(method(application:didDisconnectCarInterfaceController:fromWindow:))]
#[unsafe(method_family = none)]
unsafe fn application_didDisconnectCarInterfaceController_fromWindow(
&self,
application: &UIApplication,
interface_controller: &CPInterfaceController,
window: &CPWindow,
);
#[cfg(feature = "CPNavigationAlert")]
/// If your application posts a
/// `CPNavigationAlert`while backgrounded, a notification banner may be presented to the user.
/// If the user taps on that banner, your application will launch on the car screen and this method will be called
/// with the alert the user tapped.
#[deprecated]
#[optional]
#[unsafe(method(application:didSelectNavigationAlert:))]
#[unsafe(method_family = none)]
unsafe fn application_didSelectNavigationAlert(
&self,
application: &UIApplication,
navigation_alert: &CPNavigationAlert,
);
#[cfg(feature = "CPManeuver")]
/// If your application posts a
/// `CPManeuver`while backgrounded, a notification banner may be presented to the user.
/// If the user taps on that banner, your application will launch on the car screen and this method will be called
/// with the maneuver the user tapped.
#[deprecated]
#[optional]
#[unsafe(method(application:didSelectManeuver:))]
#[unsafe(method_family = none)]
unsafe fn application_didSelectManeuver(
&self,
application: &UIApplication,
maneuver: &CPManeuver,
);
}
);