objc2_event_kit/generated/
EKAlarm.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// The EKAlarm class provides an interface for accessing and manipulating calendar event alarms.
12    ///
13    /// The EKAlarm class represents alarms on an event. An alarm can be relative (e.g. 15 mins before)
14    /// or absolute (specific time).
15    ///
16    /// See also [Apple's documentation](https://developer.apple.com/documentation/eventkit/ekalarm?language=objc)
17    #[unsafe(super(EKObject, NSObject))]
18    #[derive(Debug, PartialEq, Eq, Hash)]
19    #[cfg(feature = "EKObject")]
20    pub struct EKAlarm;
21);
22
23#[cfg(feature = "EKObject")]
24extern_conformance!(
25    unsafe impl NSCopying for EKAlarm {}
26);
27
28#[cfg(feature = "EKObject")]
29unsafe impl CopyingHelper for EKAlarm {
30    type Result = Self;
31}
32
33#[cfg(feature = "EKObject")]
34extern_conformance!(
35    unsafe impl NSObjectProtocol for EKAlarm {}
36);
37
38#[cfg(feature = "EKObject")]
39impl EKAlarm {
40    extern_methods!(
41        /// Creates a new autoreleased alarm with an absolute trigger time.
42        ///
43        /// Parameter `date`: The date the alarm should fire.
44        #[unsafe(method(alarmWithAbsoluteDate:))]
45        #[unsafe(method_family = none)]
46        pub unsafe fn alarmWithAbsoluteDate(date: &NSDate) -> Retained<EKAlarm>;
47
48        /// Creates a new autoreleased alarm with a relative trigger time.
49        ///
50        /// Creates a new autoreleased alarm with a relative trigger time. This offset
51        /// is added to the start date of the event.
52        ///
53        ///
54        /// Parameter `offset`: The offset from the event start that the alarm should fire.
55        #[unsafe(method(alarmWithRelativeOffset:))]
56        #[unsafe(method_family = none)]
57        pub unsafe fn alarmWithRelativeOffset(offset: NSTimeInterval) -> Retained<EKAlarm>;
58
59        /// Specifies a relative offset from an event start date to fire an alarm.
60        ///
61        /// Set this property to an appropriate negative value to establish an alarm trigger
62        /// relative to the start date/time of an event. Setting this clears any existing
63        /// date trigger.
64        #[unsafe(method(relativeOffset))]
65        #[unsafe(method_family = none)]
66        pub unsafe fn relativeOffset(&self) -> NSTimeInterval;
67
68        /// Setter for [`relativeOffset`][Self::relativeOffset].
69        #[unsafe(method(setRelativeOffset:))]
70        #[unsafe(method_family = none)]
71        pub unsafe fn setRelativeOffset(&self, relative_offset: NSTimeInterval);
72
73        /// Represents an alarm that fires at a specific date.
74        ///
75        /// Set this property to a date to establish an absolute alarm trigger. Setting this
76        /// clears any relative interval trigger.
77        #[unsafe(method(absoluteDate))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn absoluteDate(&self) -> Option<Retained<NSDate>>;
80
81        /// Setter for [`absoluteDate`][Self::absoluteDate].
82        #[unsafe(method(setAbsoluteDate:))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn setAbsoluteDate(&self, absolute_date: Option<&NSDate>);
85
86        #[cfg(feature = "EKStructuredLocation")]
87        /// Allows you to set a structured location (a location with a potential geo-coordinate)
88        /// on an alarm. This is used in conjunction with proximity to do geofence-based
89        /// triggering of reminders.
90        #[unsafe(method(structuredLocation))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn structuredLocation(&self) -> Option<Retained<EKStructuredLocation>>;
93
94        #[cfg(feature = "EKStructuredLocation")]
95        /// Setter for [`structuredLocation`][Self::structuredLocation].
96        #[unsafe(method(setStructuredLocation:))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn setStructuredLocation(
99            &self,
100            structured_location: Option<&EKStructuredLocation>,
101        );
102
103        #[cfg(feature = "EKTypes")]
104        /// Defines whether this alarm triggers via entering/exiting a geofence as defined by
105        /// structuredLocation.
106        #[unsafe(method(proximity))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn proximity(&self) -> EKAlarmProximity;
109
110        #[cfg(feature = "EKTypes")]
111        /// Setter for [`proximity`][Self::proximity].
112        #[unsafe(method(setProximity:))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn setProximity(&self, proximity: EKAlarmProximity);
115
116        #[cfg(feature = "EKTypes")]
117        /// The type of alarm, based on the action taken when triggering the alarm.
118        ///
119        /// This field is read-only; to change the type of alarm, set emailAddress for EKAlarmTypeEmail,
120        /// soundName for EKAlarmTypeAudio or url for EKAlarmTypeProcedure.
121        /// Setting all of those to nil will change it to EKAlarmTypeDisplay.
122        #[unsafe(method(type))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn r#type(&self) -> EKAlarmType;
125
126        /// An email address that is the recipient of an email alarm, which is an alarm that triggers an email message.
127        ///
128        /// When you set the emailAddress property, the action property is set to EKAlarmTypeEmail,
129        /// and the soundName and url properties are set to nil.
130        #[unsafe(method(emailAddress))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn emailAddress(&self) -> Option<Retained<NSString>>;
133
134        /// Setter for [`emailAddress`][Self::emailAddress].
135        #[unsafe(method(setEmailAddress:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn setEmailAddress(&self, email_address: Option<&NSString>);
138
139        /// The name of the sound to play when the alarm triggers.
140        ///
141        /// The value of this property is the name of a system sound that can be used with
142        /// the soundNamed: class method to create an NSSound object. When you set the soundName property,
143        /// the action property is set to EKAlarmTypeAudio, and the emailAddress and url properties are set to nil.
144        #[unsafe(method(soundName))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn soundName(&self) -> Option<Retained<NSString>>;
147
148        /// Setter for [`soundName`][Self::soundName].
149        #[unsafe(method(setSoundName:))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn setSoundName(&self, sound_name: Option<&NSString>);
152
153        /// The URL to open when the alarm triggers.
154        ///
155        /// When you set the url property, the action property is set to EKAlarmTypeProcedure,
156        /// and the emailAddress and soundName properties are set to nil.
157        /// Note: Starting with OS X 10.9, it is not possible to create new procedure alarms or view URLs for existing procedure alarms.
158        /// Trying to save or modify a procedure alarm will result in a save error.
159        /// Editing other aspects of events or reminders that have existing procedure alarms is allowed as long as the alarm isn't modified.
160        #[deprecated]
161        #[unsafe(method(url))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn url(&self) -> Option<Retained<NSURL>>;
164
165        /// Setter for [`url`][Self::url].
166        #[deprecated]
167        #[unsafe(method(setUrl:))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn setUrl(&self, url: Option<&NSURL>);
170    );
171}
172
173/// Methods declared on superclass `NSObject`.
174#[cfg(feature = "EKObject")]
175impl EKAlarm {
176    extern_methods!(
177        #[unsafe(method(init))]
178        #[unsafe(method_family = init)]
179        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
180
181        #[unsafe(method(new))]
182        #[unsafe(method_family = new)]
183        pub unsafe fn new() -> Retained<Self>;
184    );
185}