diff --git a/ChangeLog b/ChangeLog index b93166b0b8..ee618701d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-05-07 Gregory John Casamento + + * Headers/AppKit/AppKit.h: Add headers + * Headers/AppKit/NSFilePromiseProvider.h + * Headers/AppKit/NSFilePromiseReceiver.h: Declarations. + * Source/GNUmakefile: Add to build + * Source/NSFilePromiseProvider.m + * Source/NSFilePromiseReceiver.m: Implementation + 2024-03-18 Fred Kiefer * Source/NSTextView.m: Add support for NSFilenamenPboardType. diff --git a/Headers/AppKit/AppKit.h b/Headers/AppKit/AppKit.h index 8395122e1d..f3851ff287 100644 --- a/Headers/AppKit/AppKit.h +++ b/Headers/AppKit/AppKit.h @@ -169,6 +169,8 @@ #import #import #import +#import +#import #import #import #import diff --git a/Headers/AppKit/NSFilePromiseProvider.h b/Headers/AppKit/NSFilePromiseProvider.h new file mode 100644 index 0000000000..1ab08b5559 --- /dev/null +++ b/Headers/AppKit/NSFilePromiseProvider.h @@ -0,0 +1,83 @@ +/* Interface of class NSFilePromiseProvider + Copyright (C) 2024 Free Software Foundation, Inc. + + By: Gregory John Casamento + Date: 05-05-2024 + + This file is part of the GNUstep Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110 USA. +*/ + +#ifndef _NSFilePromiseProvider_h_GNUSTEP_GUI_INCLUDE +#define _NSFilePromiseProvider_h_GNUSTEP_GUI_INCLUDE + +#import +#import +#import + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST) + +#if defined(__cplusplus) +extern "C" { +#endif + +@class NSError; +@class NSFilePromiseProvider; +@class NSOperationQueue; +@class NSString; +@class NSURL; + +DEFINE_BLOCK_TYPE_NO_ARGS(GSFilePromiseProviderCompletionHandler, NSError*); + +@protocol NSFilePromiseProviderDelegate +- (NSString *) filePromiseProvider: (NSFilePromiseProvider *)filePromiseProvider filenameForType: (NSString *)fileType; + +- (void)filePromiseProvider: (NSFilePromiseProvider *)filePromiseProvider + writePromiseToURL: (NSURL *)url + completionHandler: (GSFilePromiseProviderCompletionHandler)completionHandler; + +- (NSOperationQueue *)operationQueueForFilePromiseProvider: (NSFilePromiseProvider *)filePromiseProvider; +@end + +APPKIT_EXPORT_CLASS +@interface NSFilePromiseProvider : NSObject +{ + NSString *_fileType; + id _delegate; + id _userInfo; +} + +- (instancetype) initWithFileType: (NSString *)fileType delegate: (id)delegate; + +- (id) delegate; +- (void) setDelegate: (id) delegate; + +- (NSString *) fileType; +- (void) setFileType: (NSString *)fileType; + +- (id) userInfo; +- (void) setUserInfo: (id)userInfo; + +@end + +#if defined(__cplusplus) +} +#endif + +#endif /* GS_API_MACOSX */ + +#endif /* _NSFilePromiseProvider_h_GNUSTEP_GUI_INCLUDE */ diff --git a/Headers/AppKit/NSFilePromiseReceiver.h b/Headers/AppKit/NSFilePromiseReceiver.h new file mode 100644 index 0000000000..338a0ce1ef --- /dev/null +++ b/Headers/AppKit/NSFilePromiseReceiver.h @@ -0,0 +1,75 @@ +/* Interface of class NSFilePromiseReceiver + Copyright (C) 2024 Free Software Foundation, Inc. + + By: Gregory John Casamento + Date: 05-05-2024 + + This file is part of the GNUstep Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110 USA. +*/ + +#ifndef _NSFilePromiseReceiver_h_GNUSTEP_GUI_INCLUDE +#define _NSFilePromiseReceiver_h_GNUSTEP_GUI_INCLUDE + +#import + +#import +#import + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST) + +#if defined(__cplusplus) +extern "C" { +#endif + +@class NSArray; +@class NSError; +@class NSOperationQueue; +@class NSURL; + +DEFINE_BLOCK_TYPE(GSFilePromiseReceiverReaderHandler, void, NSURL*, NSError*); + +APPKIT_EXPORT_CLASS +@interface NSFilePromiseReceiver : NSObject +{ + NSArray *_fileNames; + NSArray *_fileTypes; + NSArray *_readableDraggedTypes; +} + +- (NSArray *) fileNames; +- (void) setFileNames: (NSArray *)fileNames; + +- (NSArray *) fileTypes; +- (void) setFileTypes: (NSArray *)fileTypes; + +- (NSArray *) readableDraggedTypes; + +- (void) receivePromisedFilesAtDestination: (NSURL *)destinationDir + options: (NSDictionary *)options + operationQueue: (NSOperationQueue *)operationQueue + reader: (GSFilePromiseReceiverReaderHandler)reader; + +@end + +#if defined(__cplusplus) +} +#endif + +#endif /* GS_API_MACOSX */ + +#endif /* _NSFilePromiseReceiver_h_GNUSTEP_GUI_INCLUDE */ diff --git a/Source/GNUmakefile b/Source/GNUmakefile index 5e1409a101..29acbf93b6 100644 --- a/Source/GNUmakefile +++ b/Source/GNUmakefile @@ -110,6 +110,8 @@ NSDocumentController.m \ NSDrawer.m \ NSEPSImageRep.m \ NSEvent.m \ +NSFilePromiseProvider.m \ +NSFilePromiseReceiver.m \ NSFileWrapperExtensions.m \ NSFont.m \ NSFontAssetRequest.m \ @@ -457,6 +459,8 @@ NSDrawer.h \ NSEPSImageRep.h \ NSErrors.h \ NSEvent.h \ +NSFilePromiseProvider.h \ +NSFilePromiseReceiver.h \ NSFileWrapper.h \ NSFileWrapperExtensions.h \ NSFont.h \ diff --git a/Source/NSFilePromiseProvider.m b/Source/NSFilePromiseProvider.m new file mode 100644 index 0000000000..1e69f8af17 --- /dev/null +++ b/Source/NSFilePromiseProvider.m @@ -0,0 +1,91 @@ +/* Implementation of class NSFilePromiseProvider + Copyright (C) 2024 Free Software Foundation, Inc. + + By: Gregory John Casamento + Date: 05-05-2024 + + This file is part of the GNUstep Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110 USA. +*/ + +#import +#import + +#import "AppKit/NSFilePromiseProvider.h" + +@implementation NSFilePromiseProvider + +- (instancetype) initWithFileType: (NSString *)fileType delegate: (id)delegate +{ + self = [super init]; + + if (self != nil) + { + ASSIGN(_fileType, fileType); + _delegate = delegate; + } + + return self; +} + +- (void) dealloc +{ + RELEASE(_fileType); + [super dealloc]; +} + +- (id) delegate +{ + return _delegate; +} + +- (void) setDelegate: (id)delegate +{ + _delegate = delegate; // retained by caller... +} + +- (NSString *) fileType +{ + return _fileType; +} + +- (void) setFileType: (NSString *)fileType +{ + ASSIGN(_fileType, fileType); +} + +- (id) userInfo +{ + return _userInfo; +} + +- (void) setUserInfo: (id)userInfo +{ + ASSIGN(_userInfo, userInfo); +} + +- (NSArray *) writableTypesForPasteboard: (NSPasteboard *)pasteboard +{ + return nil; +} + +- (id) pasteboardPropertyListForType: (NSString *)type +{ + return nil; +} + +@end diff --git a/Source/NSFilePromiseReceiver.m b/Source/NSFilePromiseReceiver.m new file mode 100644 index 0000000000..300d0f05af --- /dev/null +++ b/Source/NSFilePromiseReceiver.m @@ -0,0 +1,95 @@ +/* Implementation of class NSFilePromiseReceiver + Copyright (C) 2024 Free Software Foundation, Inc. + + By: Gregory John Casamento + Date: 05-05-2024 + + This file is part of the GNUstep Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110 USA. +*/ + +#import "AppKit/NSFilePromiseReceiver.h" + +#import +#import +#import + +#import "GSFastEnumeration.h" + +@implementation NSFilePromiseReceiver + +// NSPasteboardReading protocol -- start + +- (id)initWithPasteboardPropertyList: (id)propertyList ofType: (NSString *)type +{ + self = [super init]; + + if (self != nil) + { + } + + return self; +} + ++ (NSArray *) readableTypesForPasteboard: (NSPasteboard *)pasteboard +{ + return nil; +} + +// NSPasteboardReading protocol -- end + +- (void) dealloc +{ + RELEASE(_fileNames); + RELEASE(_fileTypes); + RELEASE(_readableDraggedTypes); + [super dealloc]; +} + +- (NSArray *) fileNames +{ + return _fileNames; +} + +- (void) setFileNames: (NSArray *)fileNames +{ + ASSIGN(_fileNames, fileNames); +} + +- (NSArray *) fileTypes +{ + return _fileTypes; +} + +- (void) setFileTypes: (NSArray *)fileTypes +{ + ASSIGN(_fileTypes, fileTypes); +} + +- (NSArray *) readableDraggedTypes +{ + return _readableDraggedTypes; +} + +- (void) receivePromisedFilesAtDestination: (NSURL *)destinationDir + options: (NSDictionary *)options + operationQueue: (NSOperationQueue *)operationQueue + reader: (GSFilePromiseReceiverReaderHandler)reader +{ +} + +@end