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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use crate::common::*;
use crate::AppKit::*;
use crate::Foundation::*;
use crate::GameKit::*;

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "GameKit_GKLocalPlayer")]
    pub struct GKLocalPlayer;

    #[cfg(feature = "GameKit_GKLocalPlayer")]
    unsafe impl ClassType for GKLocalPlayer {
        #[inherits(GKBasePlayer, NSObject)]
        type Super = GKPlayer;
    }
);

#[cfg(feature = "GameKit_GKLocalPlayer")]
unsafe impl NSObjectProtocol for GKLocalPlayer {}

extern_methods!(
    #[cfg(feature = "GameKit_GKLocalPlayer")]
    unsafe impl GKLocalPlayer {
        #[method_id(@__retain_semantics Other local)]
        pub unsafe fn local() -> Id<GKLocalPlayer, Shared>;

        #[method_id(@__retain_semantics Other localPlayer)]
        pub unsafe fn localPlayer() -> Id<GKLocalPlayer, Shared>;

        #[method(isAuthenticated)]
        pub unsafe fn isAuthenticated(&self) -> bool;

        #[method(isUnderage)]
        pub unsafe fn isUnderage(&self) -> bool;

        #[method(isMultiplayerGamingRestricted)]
        pub unsafe fn isMultiplayerGamingRestricted(&self) -> bool;

        #[method(isPersonalizedCommunicationRestricted)]
        pub unsafe fn isPersonalizedCommunicationRestricted(&self) -> bool;

        #[cfg(all(feature = "Foundation_NSArray", feature = "Foundation_NSError"))]
        #[method(loadRecentPlayersWithCompletionHandler:)]
        pub unsafe fn loadRecentPlayersWithCompletionHandler(
            &self,
            completion_handler: Option<&Block<(*mut NSArray<GKPlayer>, *mut NSError), ()>>,
        );

        #[cfg(all(feature = "Foundation_NSArray", feature = "Foundation_NSError"))]
        #[method(loadChallengableFriendsWithCompletionHandler:)]
        pub unsafe fn loadChallengableFriendsWithCompletionHandler(
            &self,
            completion_handler: Option<&Block<(*mut NSArray<GKPlayer>, *mut NSError), ()>>,
        );

        #[cfg(all(feature = "Foundation_NSError", feature = "Foundation_NSString"))]
        #[method(setDefaultLeaderboardIdentifier:completionHandler:)]
        pub unsafe fn setDefaultLeaderboardIdentifier_completionHandler(
            &self,
            leaderboard_identifier: &NSString,
            completion_handler: Option<&Block<(*mut NSError,), ()>>,
        );

        #[cfg(all(feature = "Foundation_NSError", feature = "Foundation_NSString"))]
        #[method(loadDefaultLeaderboardIdentifierWithCompletionHandler:)]
        pub unsafe fn loadDefaultLeaderboardIdentifierWithCompletionHandler(
            &self,
            completion_handler: Option<&Block<(*mut NSString, *mut NSError), ()>>,
        );

        #[cfg(all(
            feature = "Foundation_NSData",
            feature = "Foundation_NSError",
            feature = "Foundation_NSURL"
        ))]
        #[method(fetchItemsForIdentityVerificationSignature:)]
        pub unsafe fn fetchItemsForIdentityVerificationSignature(
            &self,
            completion_handler: Option<
                &Block<(*mut NSURL, *mut NSData, *mut NSData, u64, *mut NSError), ()>,
            >,
        );
    }
);

extern_protocol!(
    pub unsafe trait GKLocalPlayerListener:
        GKChallengeListener + GKInviteEventListener + GKSavedGameListener + GKTurnBasedEventListener
    {
    }

    unsafe impl ProtocolType for dyn GKLocalPlayerListener {}
);

extern_methods!(
    /// GKLocalPlayerEvents
    #[cfg(feature = "GameKit_GKLocalPlayer")]
    unsafe impl GKLocalPlayer {
        #[method(registerListener:)]
        pub unsafe fn registerListener(&self, listener: &ProtocolObject<dyn GKLocalPlayerListener>);

        #[method(unregisterListener:)]
        pub unsafe fn unregisterListener(
            &self,
            listener: &ProtocolObject<dyn GKLocalPlayerListener>,
        );

        #[method(unregisterAllListeners)]
        pub unsafe fn unregisterAllListeners(&self);
    }
);

extern_static!(GKPlayerAuthenticationDidChangeNotificationName: &'static NSNotificationName);

extern_methods!(
    /// Deprecated
    #[cfg(feature = "GameKit_GKLocalPlayer")]
    unsafe impl GKLocalPlayer {
        #[cfg(all(feature = "Foundation_NSError", feature = "Foundation_NSString"))]
        #[deprecated = "Use setDefaultLeaderboardIdentifier:completionHandler: instead"]
        #[method(setDefaultLeaderboardCategoryID:completionHandler:)]
        pub unsafe fn setDefaultLeaderboardCategoryID_completionHandler(
            &self,
            category_id: Option<&NSString>,
            completion_handler: Option<&Block<(*mut NSError,), ()>>,
        );

        #[cfg(all(feature = "Foundation_NSError", feature = "Foundation_NSString"))]
        #[deprecated = "Use loadDefaultLeaderboardIdentifierWithCompletionHandler: instead"]
        #[method(loadDefaultLeaderboardCategoryIDWithCompletionHandler:)]
        pub unsafe fn loadDefaultLeaderboardCategoryIDWithCompletionHandler(
            &self,
            completion_handler: Option<&Block<(*mut NSString, *mut NSError), ()>>,
        );

        #[cfg(feature = "Foundation_NSError")]
        #[deprecated = "Set the authenticateHandler instead"]
        #[method(authenticateWithCompletionHandler:)]
        pub unsafe fn authenticateWithCompletionHandler(
            &self,
            completion_handler: Option<&Block<(*mut NSError,), ()>>,
        );

        #[cfg(all(
            feature = "Foundation_NSArray",
            feature = "Foundation_NSError",
            feature = "GameKit_GKPlayer"
        ))]
        #[deprecated]
        #[method(loadFriendPlayersWithCompletionHandler:)]
        pub unsafe fn loadFriendPlayersWithCompletionHandler(
            &self,
            completion_handler: Option<&Block<(*mut NSArray<GKPlayer>, *mut NSError), ()>>,
        );

        #[cfg(all(
            feature = "Foundation_NSData",
            feature = "Foundation_NSError",
            feature = "Foundation_NSURL"
        ))]
        #[deprecated = "API deprecated. Use fetchItemsForIdentityVerificationSignature: and the teamPlayerID value to verify a user identity."]
        #[method(generateIdentityVerificationSignatureWithCompletionHandler:)]
        pub unsafe fn generateIdentityVerificationSignatureWithCompletionHandler(
            &self,
            completion_handler: Option<
                &Block<(*mut NSURL, *mut NSData, *mut NSData, u64, *mut NSError), ()>,
            >,
        );
    }
);

extern_methods!(
    /// Obsoleted
    #[cfg(feature = "GameKit_GKLocalPlayer")]
    unsafe impl GKLocalPlayer {
        #[cfg(all(
            feature = "Foundation_NSArray",
            feature = "Foundation_NSError",
            feature = "Foundation_NSString"
        ))]
        #[deprecated = "This is never invoked and its implementation does nothing, use loadRecentPlayersWithCompletionHandler: instead"]
        #[method(loadFriendsWithCompletionHandler:)]
        pub unsafe fn loadFriendsWithCompletionHandler(
            &self,
            completion_handler: Option<&Block<(*mut NSArray<NSString>, *mut NSError), ()>>,
        );

        #[cfg(all(feature = "Foundation_NSArray", feature = "Foundation_NSString"))]
        #[deprecated = " This property is obsolete, Use loadFriendPlayersWithCompletionHandler: instead"]
        #[method_id(@__retain_semantics Other friends)]
        pub unsafe fn friends(&self) -> Option<Id<NSArray<NSString>, Shared>>;
    }
);

ns_enum!(
    #[underlying(NSInteger)]
    pub enum GKFriendsAuthorizationStatus {
        GKFriendsAuthorizationStatusNotDetermined = 0,
        GKFriendsAuthorizationStatusRestricted = 1,
        GKFriendsAuthorizationStatusDenied = 2,
        GKFriendsAuthorizationStatusAuthorized = 3,
    }
);

extern_methods!(
    /// FriendsList
    #[cfg(feature = "GameKit_GKLocalPlayer")]
    unsafe impl GKLocalPlayer {
        #[cfg(feature = "Foundation_NSError")]
        #[method(loadFriendsAuthorizationStatus:)]
        pub unsafe fn loadFriendsAuthorizationStatus(
            &self,
            completion_handler: &Block<(GKFriendsAuthorizationStatus, *mut NSError), ()>,
        );

        #[cfg(all(
            feature = "Foundation_NSArray",
            feature = "Foundation_NSError",
            feature = "GameKit_GKPlayer"
        ))]
        #[method(loadFriends:)]
        pub unsafe fn loadFriends(
            &self,
            completion_handler: &Block<(*mut NSArray<GKPlayer>, *mut NSError), ()>,
        );

        #[cfg(all(
            feature = "Foundation_NSArray",
            feature = "Foundation_NSError",
            feature = "Foundation_NSString",
            feature = "GameKit_GKPlayer"
        ))]
        #[method(loadFriendsWithIdentifiers:completionHandler:)]
        pub unsafe fn loadFriendsWithIdentifiers_completionHandler(
            &self,
            identifiers: &NSArray<NSString>,
            completion_handler: &Block<(*mut NSArray<GKPlayer>, *mut NSError), ()>,
        );
    }
);

extern_methods!(
    /// UI
    #[cfg(feature = "GameKit_GKLocalPlayer")]
    unsafe impl GKLocalPlayer {
        #[cfg(all(feature = "AppKit_NSViewController", feature = "Foundation_NSError"))]
        #[method(authenticateHandler)]
        pub unsafe fn authenticateHandler(
            &self,
        ) -> *mut Block<(*mut NSViewController, *mut NSError), ()>;

        #[cfg(all(feature = "AppKit_NSViewController", feature = "Foundation_NSError"))]
        #[method(setAuthenticateHandler:)]
        pub unsafe fn setAuthenticateHandler(
            &self,
            authenticate_handler: Option<&Block<(*mut NSViewController, *mut NSError), ()>>,
        );

        #[method(isPresentingFriendRequestViewController)]
        pub unsafe fn isPresentingFriendRequestViewController(&self) -> bool;

        #[cfg(all(feature = "AppKit_NSWindow", feature = "Foundation_NSError"))]
        #[method(presentFriendRequestCreatorFromWindow:error:_)]
        pub unsafe fn presentFriendRequestCreatorFromWindow_error(
            &self,
            window: Option<&NSWindow>,
        ) -> Result<(), Id<NSError, Shared>>;
    }
);

extern_methods!(
    /// Methods declared on superclass `GKPlayer`
    #[cfg(feature = "GameKit_GKLocalPlayer")]
    unsafe impl GKLocalPlayer {
        #[cfg(feature = "Foundation_NSString")]
        #[method_id(@__retain_semantics Other anonymousGuestPlayerWithIdentifier:)]
        pub unsafe fn anonymousGuestPlayerWithIdentifier(
            guest_identifier: &NSString,
        ) -> Id<Self, Shared>;
    }
);