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
// This file has been automatically generated by `objc2`'s `header-translator`.
// DO NOT EDIT

#![allow(unused_imports)]
#![allow(deprecated)]
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
#![allow(missing_docs)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::type_complexity)]
#![allow(clippy::upper_case_acronyms)]
#![allow(clippy::identity_op)]
#![allow(clippy::missing_safety_doc)]

#[link(name = "FinderSync", kind = "framework")]
extern "C" {}

use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-app-kit")]
use objc2_app_kit::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct FIFinderSyncController;

    unsafe impl ClassType for FIFinderSyncController {
        #[inherits(NSObject)]
        type Super = NSExtensionContext;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSObjectProtocol for FIFinderSyncController {}

extern_methods!(
    unsafe impl FIFinderSyncController {
        #[method_id(@__retain_semantics Other defaultController)]
        pub unsafe fn defaultController() -> Retained<Self>;

        #[method_id(@__retain_semantics Other directoryURLs)]
        pub unsafe fn directoryURLs(&self) -> Retained<NSSet<NSURL>>;

        #[method(setDirectoryURLs:)]
        pub unsafe fn setDirectoryURLs(&self, directory_ur_ls: Option<&NSSet<NSURL>>);

        #[cfg(feature = "objc2-app-kit")]
        #[method(setBadgeImage:label:forBadgeIdentifier:)]
        pub unsafe fn setBadgeImage_label_forBadgeIdentifier(
            &self,
            image: &NSImage,
            label: Option<&NSString>,
            badge_id: &NSString,
        );

        #[method(setBadgeIdentifier:forURL:)]
        pub unsafe fn setBadgeIdentifier_forURL(&self, badge_id: &NSString, url: &NSURL);

        #[method_id(@__retain_semantics Other targetedURL)]
        pub unsafe fn targetedURL(&self) -> Option<Retained<NSURL>>;

        #[method_id(@__retain_semantics Other selectedItemURLs)]
        pub unsafe fn selectedItemURLs(&self) -> Option<Retained<NSArray<NSURL>>>;

        #[method_id(@__retain_semantics Other lastUsedDateForItemWithURL:)]
        pub unsafe fn lastUsedDateForItemWithURL(
            &self,
            item_url: &NSURL,
        ) -> Option<Retained<NSDate>>;

        #[cfg(feature = "block2")]
        #[method(setLastUsedDate:forItemWithURL:completion:)]
        pub unsafe fn setLastUsedDate_forItemWithURL_completion(
            &self,
            last_used_date: &NSDate,
            item_url: &NSURL,
            completion: &block2::Block<dyn Fn(NonNull<NSError>)>,
        );

        #[method_id(@__retain_semantics Other tagDataForItemWithURL:)]
        pub unsafe fn tagDataForItemWithURL(&self, item_url: &NSURL) -> Option<Retained<NSData>>;

        #[cfg(feature = "block2")]
        #[method(setTagData:forItemWithURL:completion:)]
        pub unsafe fn setTagData_forItemWithURL_completion(
            &self,
            tag_data: Option<&NSData>,
            item_url: &NSURL,
            completion: &block2::Block<dyn Fn(NonNull<NSError>)>,
        );

        #[method(isExtensionEnabled)]
        pub unsafe fn isExtensionEnabled() -> bool;

        #[method(showExtensionManagementInterface)]
        pub unsafe fn showExtensionManagementInterface();
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl FIFinderSyncController {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct FIMenuKind(pub NSUInteger);
impl FIMenuKind {
    #[doc(alias = "FIMenuKindContextualMenuForItems")]
    pub const ContextualMenuForItems: Self = Self(0);
    #[doc(alias = "FIMenuKindContextualMenuForContainer")]
    pub const ContextualMenuForContainer: Self = Self(1);
    #[doc(alias = "FIMenuKindContextualMenuForSidebar")]
    pub const ContextualMenuForSidebar: Self = Self(2);
    #[doc(alias = "FIMenuKindToolbarItemMenu")]
    pub const ToolbarItemMenu: Self = Self(3);
}

unsafe impl Encode for FIMenuKind {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for FIMenuKind {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_protocol!(
    pub unsafe trait FIFinderSyncProtocol {
        #[cfg(feature = "objc2-app-kit")]
        #[optional]
        #[method_id(@__retain_semantics Other menuForMenuKind:)]
        unsafe fn menuForMenuKind(
            &self,
            menu: FIMenuKind,
            mtm: MainThreadMarker,
        ) -> Option<Retained<NSMenu>>;

        #[optional]
        #[method(beginObservingDirectoryAtURL:)]
        unsafe fn beginObservingDirectoryAtURL(&self, url: &NSURL);

        #[optional]
        #[method(endObservingDirectoryAtURL:)]
        unsafe fn endObservingDirectoryAtURL(&self, url: &NSURL);

        #[optional]
        #[method(requestBadgeIdentifierForURL:)]
        unsafe fn requestBadgeIdentifierForURL(&self, url: &NSURL);

        #[optional]
        #[method_id(@__retain_semantics Other toolbarItemName)]
        unsafe fn toolbarItemName(&self) -> Retained<NSString>;

        #[cfg(feature = "objc2-app-kit")]
        #[optional]
        #[method_id(@__retain_semantics Other toolbarItemImage)]
        unsafe fn toolbarItemImage(&self) -> Retained<NSImage>;

        #[optional]
        #[method_id(@__retain_semantics Other toolbarItemToolTip)]
        unsafe fn toolbarItemToolTip(&self) -> Retained<NSString>;

        #[optional]
        #[method_id(@__retain_semantics Other supportedServiceNamesForItemWithURL:)]
        unsafe fn supportedServiceNamesForItemWithURL(
            &self,
            item_url: &NSURL,
        ) -> Retained<NSArray<NSFileProviderServiceName>>;

        #[optional]
        #[method_id(@__retain_semantics Other makeListenerEndpointForServiceName:itemURL:andReturnError:_)]
        unsafe fn makeListenerEndpointForServiceName_itemURL_andReturnError(
            &self,
            service_name: &NSFileProviderServiceName,
            item_url: &NSURL,
        ) -> Result<Retained<NSXPCListenerEndpoint>, Retained<NSError>>;

        #[cfg(feature = "block2")]
        #[optional]
        #[method(valuesForAttributes:forItemWithURL:completion:)]
        unsafe fn valuesForAttributes_forItemWithURL_completion(
            &self,
            attributes: &NSArray<NSURLResourceKey>,
            item_url: &NSURL,
            completion: &block2::Block<
                dyn Fn(NonNull<NSDictionary<NSURLResourceKey, AnyObject>>, *mut NSError),
            >,
        );
    }

    unsafe impl ProtocolType for dyn FIFinderSyncProtocol {
        const NAME: &'static str = "FIFinderSync";
    }
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct FIFinderSync;

    unsafe impl ClassType for FIFinderSync {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl FIFinderSyncProtocol for FIFinderSync {}

unsafe impl NSExtensionRequestHandling for FIFinderSync {}

unsafe impl NSObjectProtocol for FIFinderSync {}

extern_methods!(
    unsafe impl FIFinderSync {}
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl FIFinderSync {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);