-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FileProvider] Add Xcode 9 Beta 1, 2 & 3 Bindings (#2279)
* [FileProvider] Add Xcode 9 Beta 1 Bindings * Better naming * Feedback not related to BindAs * [FileProvider] Removes BindAs, add manual code for it and updated to Beta 3 * [FileProvider] Implement feedback
- Loading branch information
Showing
11 changed files
with
493 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/FileProvider/NSFileProviderItemIdentifierExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// NSFileProviderItemIdentifierExtensions.cs | ||
// | ||
// Authors: | ||
// Alex Soto <[email protected]> | ||
// | ||
// Copyright 2017 Xamarin Inc. All rights reserved. | ||
// | ||
|
||
#if XAMCORE_2_0 | ||
using System; | ||
using XamCore.Foundation; | ||
|
||
namespace XamCore.FileProvider { | ||
public partial class NSFileProviderItemIdentifierExtensions { | ||
|
||
public static NSString[] GetConstants (this NSFileProviderItemIdentifier[] self) | ||
{ | ||
if (self == null) | ||
throw new ArgumentNullException (nameof (self)); | ||
|
||
var array = new NSString [self.Length]; | ||
for (int n = 0; n < self.Length; n++) | ||
array [n] = self [n].GetConstant (); | ||
return array; | ||
} | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,307 @@ | ||
// | ||
// FileProvider C# bindings | ||
// | ||
// Authors: | ||
// Alex Soto <[email protected]> | ||
// | ||
// Copyright 2017 Xamarin Inc. All rights reserved. | ||
// | ||
|
||
#if XAMCORE_2_0 | ||
|
||
using System; | ||
using XamCore.ObjCRuntime; | ||
using XamCore.CoreGraphics; | ||
using XamCore.Foundation; | ||
|
||
namespace XamCore.FileProvider { | ||
|
||
[iOS (11,0)] | ||
[ErrorDomain ("NSFileProviderErrorDomain")] | ||
[Native] | ||
public enum NSFileProviderError : nint { | ||
NotAuthenticated = -1000, | ||
FilenameCollision = -1001, | ||
SyncAnchorExpired = -1002, | ||
PageExpired = SyncAnchorExpired, | ||
InsufficientQuota = -1003, | ||
ServerUnreachable = -1004, | ||
NoSuchItem = -1005, | ||
} | ||
|
||
[iOS (11,0)] | ||
enum NSFileProviderItemIdentifier { | ||
|
||
[Field ("NSFileProviderRootContainerItemIdentifier")] | ||
RootContainer, | ||
|
||
[Field ("NSFileProviderWorkingSetContainerItemIdentifier")] | ||
WorkingSetContainer, | ||
} | ||
|
||
[iOS (11,0)] | ||
[Native] | ||
[Flags] | ||
public enum NSFileProviderItemCapabilities : nuint { | ||
Reading = 1 << 0, | ||
Writing = 1 << 1, | ||
Reparenting = 1 << 2, | ||
Renaming = 1 << 3, | ||
Trashing = 1 << 4, | ||
Deleting = 1 << 5, | ||
AddingSubItems = Writing, | ||
ContentEnumerating = Reading, | ||
All = Reading | Writing | Reparenting | Renaming | Trashing | Deleting, | ||
} | ||
|
||
[iOS (11,0)] | ||
[DisableDefaultCtor] | ||
[BaseType (typeof (NSObject))] | ||
interface NSFileProviderDomain { | ||
|
||
[Export ("initWithIdentifier:displayName:pathRelativeToDocumentStorage:")] | ||
IntPtr Constructor (string identifier, string displayName, string pathRelativeToDocumentStorage); | ||
|
||
[Export ("identifier")] | ||
string Identifier { get; } | ||
|
||
[Export ("displayName")] | ||
string DisplayName { get; } | ||
|
||
[Export ("pathRelativeToDocumentStorage")] | ||
string PathRelativeToDocumentStorage { get; } | ||
} | ||
|
||
interface INSFileProviderEnumerationObserver { } | ||
|
||
[iOS (11,0)] | ||
[Protocol] | ||
interface NSFileProviderEnumerationObserver { | ||
|
||
[Abstract] | ||
[Export ("didEnumerateItems:")] | ||
void DidEnumerateItems (INSFileProviderItem [] updatedItems); | ||
|
||
[Abstract] | ||
[Export ("finishEnumeratingUpToPage:")] | ||
void FinishEnumerating ([NullAllowed] NSData upToPage); | ||
|
||
[Abstract] | ||
[Export ("finishEnumeratingWithError:")] | ||
void FinishEnumerating (NSError error); | ||
} | ||
|
||
interface INSFileProviderChangeObserver { } | ||
|
||
[iOS (11,0)] | ||
[Protocol] | ||
interface NSFileProviderChangeObserver { | ||
|
||
[Abstract] | ||
[Export ("didUpdateItems:")] | ||
void DidUpdateItems (INSFileProviderItem [] updatedItems); | ||
|
||
[Abstract] | ||
[Export ("didDeleteItemsWithIdentifiers:")] | ||
void DidDeleteItems (string [] deletedItemIdentifiers); | ||
|
||
[Abstract] | ||
[Export ("finishEnumeratingChangesUpToSyncAnchor:moreComing:")] | ||
void FinishEnumeratingChanges (NSData anchor, bool moreComing); | ||
|
||
[Abstract] | ||
[Export ("finishEnumeratingWithError:")] | ||
void FinishEnumerating (NSError error); | ||
} | ||
|
||
interface INSFileProviderEnumerator { } | ||
|
||
[iOS (11,0)] | ||
[Protocol] | ||
interface NSFileProviderEnumerator { | ||
|
||
[Abstract] | ||
[Export ("invalidate")] | ||
void Invalidate (); | ||
|
||
[Abstract] | ||
[Export ("enumerateItemsForObserver:startingAtPage:")] | ||
void EnumerateItems (INSFileProviderEnumerationObserver observer, NSData startPage); | ||
|
||
[Export ("enumerateChangesForObserver:fromSyncAnchor:")] | ||
void EnumerateChanges (INSFileProviderChangeObserver observer, NSData syncAnchor); | ||
|
||
[Export ("currentSyncAnchorWithCompletionHandler:")] | ||
void CurrentSyncAnchor (Action<NSData> completionHandler); | ||
} | ||
|
||
interface INSFileProviderItem { } | ||
|
||
[iOS (11,0)] | ||
[Protocol] | ||
interface NSFileProviderItem { | ||
|
||
[Advice ("Use 'NSFileProviderItemIdentifierExtensions.GetValue (ItemIdentifier)' to get a 'NSFileProviderItemIdentifier' enum.")] | ||
[Abstract] | ||
[Export ("itemIdentifier")] | ||
NSString Identifier { get; } | ||
|
||
[Advice ("Use 'NSFileProviderItemIdentifierExtensions.GetValue (ParentItemIdentifier)' to get a 'NSFileProviderItemIdentifier' enum.")] | ||
[Abstract] | ||
[Export ("parentItemIdentifier")] | ||
NSString ParentIdentifier { get; } | ||
|
||
[Abstract] | ||
[Export ("filename")] | ||
string Filename { get; } | ||
|
||
[Abstract] | ||
[Export ("typeIdentifier")] | ||
string TypeIdentifier { get; } | ||
|
||
[Export ("capabilities")] | ||
NSFileProviderItemCapabilities GetCapabilities (); | ||
|
||
[return: NullAllowed] | ||
[Export ("documentSize", ArgumentSemantic.Copy)] | ||
NSNumber GetDocumentSize (); | ||
|
||
[return: NullAllowed] | ||
[Export ("childItemCount", ArgumentSemantic.Copy)] | ||
NSNumber GetChildItemCount (); | ||
|
||
[return: NullAllowed] | ||
[Export ("creationDate", ArgumentSemantic.Copy)] | ||
NSDate GetCreationDate (); | ||
|
||
[return: NullAllowed] | ||
[Export ("contentModificationDate", ArgumentSemantic.Copy)] | ||
NSDate GetContentModificationDate (); | ||
|
||
[return: NullAllowed] | ||
[Export ("lastUsedDate", ArgumentSemantic.Copy)] | ||
NSDate GetLastUsedDate (); | ||
|
||
[return: NullAllowed] | ||
[Export ("tagData", ArgumentSemantic.Copy)] | ||
NSData GetTagData (); | ||
|
||
[return: NullAllowed] | ||
[Export ("favoriteRank", ArgumentSemantic.Copy)] | ||
NSNumber GetFavoriteRank (); | ||
|
||
[Export ("isTrashed")] | ||
bool IsTrashed (); | ||
|
||
[Export ("isUploaded")] | ||
bool IsUploaded (); | ||
|
||
[Export ("isUploading")] | ||
bool IsUploading (); | ||
|
||
[return: NullAllowed] | ||
[Export ("uploadingError", ArgumentSemantic.Copy)] | ||
NSError GetUploadingError (); | ||
|
||
[Export ("isDownloaded")] | ||
bool IsDownloaded (); | ||
|
||
[Export ("isDownloading")] | ||
bool IsDownloading (); | ||
|
||
[return: NullAllowed] | ||
[Export ("downloadingError", ArgumentSemantic.Copy)] | ||
NSError GetDownloadingError (); | ||
|
||
[Export ("isMostRecentVersionDownloaded")] | ||
bool IsMostRecentVersionDownloaded (); | ||
|
||
[Export ("isShared")] | ||
bool IsShared (); | ||
|
||
[Export ("isSharedByCurrentUser")] | ||
bool IsSharedByCurrentUser (); | ||
|
||
[return: NullAllowed] | ||
[Export ("ownerNameComponents")] | ||
NSPersonNameComponents GetOwnerNameComponents (); | ||
|
||
[return: NullAllowed] | ||
[Export ("mostRecentEditorNameComponents")] | ||
NSPersonNameComponents GetMostRecentEditorNameComponents (); | ||
|
||
[return: NullAllowed] | ||
[Export ("versionIdentifier")] | ||
NSData GetVersionIdentifier (); | ||
|
||
[return: NullAllowed] | ||
[Export ("userInfo")] | ||
NSDictionary GetUserInfo (); | ||
} | ||
|
||
[iOS (11,0)] | ||
[BaseType (typeof (NSObject))] | ||
[DisableDefaultCtor] | ||
interface NSFileProviderManager { | ||
|
||
[Static] | ||
[Export ("defaultManager", ArgumentSemantic.Strong)] | ||
NSFileProviderManager DefaultManager { get; } | ||
|
||
[Protected] | ||
[Export ("signalEnumeratorForContainerItemIdentifier:completionHandler:")] | ||
// Not Async'ified on purpose, because this can switch from app to extension. | ||
void SignalEnumerator (NSString containerItemIdentifier, Action<NSError> completion); | ||
|
||
[Wrap ("SignalEnumerator (containerItemIdentifier.GetConstant (), completion)")] | ||
void SignalEnumerator (NSFileProviderItemIdentifier containerItemIdentifier, Action<NSError> completion); | ||
|
||
// Not Async'ified on purpose, because the task must be accesed while the completion action is performing... | ||
[Protected] | ||
[Export ("registerURLSessionTask:forItemWithIdentifier:completionHandler:")] | ||
void Register (NSUrlSessionTask task, NSString identifier, Action<NSError> completion); | ||
|
||
[Wrap ("Register (task, identifier.GetConstant (), completion)")] | ||
void Register (NSUrlSessionTask task, NSFileProviderItemIdentifier identifier, Action<NSError> completion); | ||
|
||
[Export ("providerIdentifier")] | ||
string ProviderIdentifier { get; } | ||
|
||
[Export ("documentStorageURL")] | ||
NSUrl DocumentStorageUrl { get; } | ||
|
||
[Static] | ||
[Export ("writePlaceholderAtURL:withMetadata:error:")] | ||
bool WritePlaceholder (NSUrl placeholderUrl, INSFileProviderItem metadata, out NSError error); | ||
|
||
[Static] | ||
[Export ("placeholderURLForURL:")] | ||
NSUrl GetPlaceholderUrl (NSUrl url); | ||
|
||
[Static] | ||
[Async] | ||
[Export ("addDomain:completionHandler:")] | ||
void AddDomain (NSFileProviderDomain domain, Action<NSError> completionHandler); | ||
|
||
[Static] | ||
[Async] | ||
[Export ("removeDomain:completionHandler:")] | ||
void RemoveDomain (NSFileProviderDomain domain, Action<NSError> completionHandler); | ||
|
||
[Static] | ||
[Async] | ||
[Export ("getDomainsWithCompletionHandler:")] | ||
void GetDomains (Action<NSFileProviderDomain [], NSError> completionHandler); | ||
|
||
[Static] | ||
[Async] | ||
[Export ("removeAllDomainsWithCompletionHandler:")] | ||
void RemoveAllDomains (Action<NSError> completionHandler); | ||
|
||
[Static] | ||
[Export ("managerForDomain:")] | ||
[return: NullAllowed] | ||
NSFileProviderManager FromDomain (NSFileProviderDomain domain); | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.