Skip to content
1 change: 1 addition & 0 deletions Headers/Foundation/Foundation.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
#import <Foundation/NSLock.h>
#import <Foundation/NSLocale.h>
#import <Foundation/NSMapTable.h>
#import <Foundation/NSMassFormatter.h>
#import <Foundation/NSMeasurement.h>
#import <Foundation/NSMeasurementFormatter.h>
#import <Foundation/NSMetadata.h>
Expand Down
63 changes: 40 additions & 23 deletions Headers/Foundation/NSProgress.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,31 @@ DEFINE_BLOCK_TYPE_NO_ARGS(GSProgressPendingUnitCountBlock, void);
DEFINE_BLOCK_TYPE_NO_ARGS(GSProgressResumingHandler, void);

/**
* A progress object tracks an amount of work that is yet to be completed. Work
* is tracked in units. A progress is finished when the completed number of unit
* work is equal to the total number of unit work.
* A progress object tracks an amount of work that is yet to be completed.
* Work is tracked in units. A progress is finished when the completed
* number of unit work is equal to the total number of unit work.
*
* Progress objects can be arranged in a tree formation. Children of a parent progress
* continuosly report their progress and update the parents fractionCompleted property.
* Progress objects can be arranged in a tree formation. Children of a parent
* progress continuosly report their progress and update the parents
* fractionCompleted property.
* When a child is added to a parent progress, a pending unit count is
* specified. This count is added to the parent after completion of the child.
*
* There are two mechanisms to add a progress as a child to another progress object:
* One can explicitly add a child with -addChild:withPendingUnitCount:. There is also
* a way to implicitly add newly instantiated progress object as a child to an existing progress.
* There are two mechanisms to add a progress as a child to another progress
* object:
* One can explicitly add a child with -addChild:withPendingUnitCount:.
* There is also a way to implicitly add newly instantiated progress object
* as a child to an existing progress.
*
* For this, we first need to define how the "currentProgress" API works:
* Every thread has a thread-specific current progress stack. The top-most
* element on this stack can be accessed by +currentProgress class method. By
* sending -becomeCurrentWithPendingUnitCount: to a progress, the progress
* element on this stack can be accessed by +currentProgress class method.
* By sending -becomeCurrentWithPendingUnitCount: to a progress, the progress
* object is pushed onto the stack and becomes the new current progress.
*
* The next progress object instantiated (excluding creation with
* discreteProgressWithTotalUnitCount:) becomes a child of this current progress.
* discreteProgressWithTotalUnitCount:) becomes a child of this current
* progress.
* This is the second mechanism to implicitly add a child to a progress object.
*/

Expand Down Expand Up @@ -132,8 +136,8 @@ GS_NSProgress_IVARS;
pendingUnitCount: (int64_t)portionOfParentTotalUnitCount;

/**
* Retrieve the first progress object that is on the thread-local current progress
* stack.
* Retrieve the first progress object that is on the thread-local current
* progress stack.
*/
+ (NSProgress *) currentProgress;

Expand All @@ -147,15 +151,16 @@ GS_NSProgress_IVARS;
* created. If the child progress completes, the pending unit count is added to
* the receiver.
*
* The pending unit count represents the portion of work to perform in relation to
* the total number of units of work, which is the value of the receivers
* totalUnitCount property. The pending units of work should be less than or equal
* to the total units of work of the receiver. Ensure that the total number is not
* exceeded.
* The pending unit count represents the portion of work to perform in
* relation to the total number of units of work, which is the value of
* the receivers totalUnitCount property. The pending units of work should
* be less than or equal to the total units of work of the receiver.
* Ensure that the total number is not exceeded.
*
* Calls to this method must be matched by -[NSProgress resignCurrent].
*/
- (void) becomeCurrentWithPendingUnitCount: (int64_t)unitCount;

/**
* Receiver resigns the role of the current progress. The receiver is popped
* from the thread-local current progress stack.
Expand All @@ -178,6 +183,7 @@ GS_NSProgress_IVARS;
* Returns the total number of unit work to be tracked by the receiver.
*/
- (int64_t) totalUnitCount;

/**
* Sets the total nubmer of unit work to be tracked by the receiver.
*/
Expand All @@ -187,6 +193,7 @@ GS_NSProgress_IVARS;
* Returns the number of unit work already completed.
*/
- (int64_t) completedUnitCount;

/**
* Updates the number of unit work already completed. Monotonicity of this
* count is not enforced.
Expand Down Expand Up @@ -221,21 +228,27 @@ GS_NSProgress_IVARS;
- (double) fractionCompleted;

/**
* Indicates whether the progress is cancellable. By default, a progress is
* cancellable but not pausable.
* Indicates whether the underlying work whose progress is being tracked
* can be cancelled. This has no effect on whether the receiver can be
* cancelled. By default, a progress instance assumes that the
* work is cancellable but not pausable.
*/
- (BOOL) isCancellable;
- (void) setCancellable: (BOOL) cancellable;

/**
* Returns YES if the reciever is cancelled.
* Returns YES if the reciever has been cancelled.
*/
- (BOOL) isCancelled;

/**
* Cancels a progress and its unfinished children. If a cancellation handler is
* set, it will be called before cancelling child progresses.
* Cancels tracking by the receiver (so subsequent calls to -isCancelled will
* return YES), and also cancels unfinished children.
* If a cancellation handler is set, it will be called before cancelling child
* progresses.
*/
- (void) cancel;

/**
* Sets a cancellation handler that is called when a progress gets cancelled.
*/
Expand All @@ -245,19 +258,23 @@ GS_NSProgress_IVARS;
* Pausation of a progress is not implemented. This method always returns 'NO'.
*/
- (BOOL) isPausable;

/**
* Pausation of a progress is not implemented. Therefore a progress is never
* paused and this method always returns 'NO'.
*/
- (BOOL) isPaused;

/**
* Pausation of a progress is not implemented. This method will throw an
* exception.
*/
- (void) pause;

- (void) setPausingHandler: (GSProgressPausingHandler) handler;

- (void) resume;

- (void) setResumingHandler: (GSProgressResumingHandler) handler;

- (BOOL) isIndeterminate;
Expand Down
12 changes: 9 additions & 3 deletions Headers/Foundation/NSUbiquitousKeyValueStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ GS_EXPORT_CLASS
* Getting the Shared Instance
*/
+ (NSUbiquitousKeyValueStore *) defaultStore;

// Getting Values

/**
* Returns the array associated with the specified key.
*/
- (NSArray *) arrayForKey: (NSString *)key;

/**
* Returns the Boolean value associated with the specified key.
*/
Expand All @@ -63,7 +63,7 @@ GS_EXPORT_CLASS
* Returns the data object associated with the specified key.
*/
- (NSData*) dataForKey: (NSString *)key;

/**
* Returns the dictionary object associated with the specified key.
*/
Expand Down Expand Up @@ -157,6 +157,12 @@ GS_EXPORT_CLASS
GS_EXPORT NSString* const NSUbiquitousKeyValueStoreDidChangeExternallyNotification;
GS_EXPORT NSString* const NSUbiquitousKeyValueStoreChangeReasonKey;

// Change reason values
GS_EXPORT NSString* const NSUbiquitousKeyValueStoreServerChange;
GS_EXPORT NSString* const NSUbiquitousKeyValueStoreInitialSyncChange;
GS_EXPORT NSString* const NSUbiquitousKeyValueStoreQuotaViolationChange;
GS_EXPORT NSString* const NSUbiquitousKeyValueStoreAccountChange;

#if defined(__cplusplus)
}
#endif
Expand Down
1 change: 1 addition & 0 deletions Headers/GNUstepBase/GSMime.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ GS_EXPORT_CLASS
*/
+ (NSData*) encodeBase64: (NSData*)source;
+ (NSString*) encodeBase64String: (NSString*)source;
+ (NSStringEncoding) encodingForXml: (id)xml;
+ (NSStringEncoding) encodingFromCharset: (NSString*)charset;

- (void) addContent: (id)newContent;
Expand Down
64 changes: 56 additions & 8 deletions Source/Additions/GSMime.m
Original file line number Diff line number Diff line change
Expand Up @@ -4777,20 +4777,25 @@ + (NSString*) charsetForXml: (id)xml
/*
* Determine encoding using byte-order-mark if present
*/
if ((ptr[0] == 0xFE && ptr[1] == 0xFF)
|| (ptr[0] == 0xFF && ptr[1] == 0xFE))
if (ptr[0] == 0xFE && ptr[1] == 0xFF)
{
return @"utf-16be";
}
if (ptr[0] == 0xFF && ptr[1] == 0xFE)
{
return @"utf-16";
return @"utf-16le";
}
if (ptr[0] == 0xEF && ptr[1] == 0xBB && ptr[2] == 0xBF)
{
return @"utf-8";
}
if ((ptr[0] == 0x00 && ptr[1] == 0x00)
&& ((ptr[2] == 0xFE && ptr[3] == 0xFF)
|| (ptr[2] == 0xFF && ptr[3] == 0xFE)))
if (ptr[0] == 0x00 && ptr[1] == 0x00 && ptr[2] == 0xFE && ptr[3] == 0xFF)
{
return @"utf-32be";
}
if (ptr[0] == 0xFF && ptr[1] == 0xFE && ptr[2] == 0x00 && ptr[3] == 0x00)
{
return @"ucs-4";
return @"utf-32le";
}

/*
Expand Down Expand Up @@ -4848,7 +4853,7 @@ + (NSString*) charsetForXml: (id)xml
}
else
{
return @"ucs-4";
return @"utf-32";
}
}
ptr += size * 5; // Step past '<?xml' prefix
Expand Down Expand Up @@ -5189,6 +5194,17 @@ + (NSString*) encodeBase64String: (NSString*)source
return r;
}

+ (NSStringEncoding) encodingForXml: (id)xml
{
NSString *charset = [self charsetFirXml: xml];

if (nil == charset)
{
return GSUndefinedEncoding;
}
return [self encodingFromCharset: charset];
}

/**
* Return the string encoding corresponding to the specified MIME
* characterset name.<br />
Expand Down Expand Up @@ -5383,14 +5399,34 @@ + (void) initialize

NSMapInsert(charsets, (void*)@"NSUTF16BigEndianStringEncoding",
(void*)NSUTF16BigEndianStringEncoding);
NSMapInsert(charsets, (void*)@"utf-16be",
(void*)NSUTF16BigEndianStringEncoding);
NSMapInsert(charsets, (void*)@"utf16be",
(void*)NSUTF16BigEndianStringEncoding);
NSMapInsert(charsets, (void*)@"NSUTF16LittleEndianStringEncoding",
(void*)NSUTF16LittleEndianStringEncoding);
NSMapInsert(charsets, (void*)@"utf-16le",
(void*)NSUTF16LittleEndianStringEncoding);
NSMapInsert(charsets, (void*)@"utf16le",
(void*)NSUTF16LittleEndianStringEncoding);
NSMapInsert(charsets, (void*)@"NSUTF32StringEncoding",
(void*)NSUTF32StringEncoding);
NSMapInsert(charsets, (void*)@"utf-32",
(void*)NSUTF32StringEncoding);
NSMapInsert(charsets, (void*)@"utf32",
(void*)NSUTF32StringEncoding);
NSMapInsert(charsets, (void*)@"NSUTF32BigEndianStringEncoding",
(void*)NSUTF32BigEndianStringEncoding);
NSMapInsert(charsets, (void*)@"utf-32be",
(void*)NSUTF32BigEndianStringEncoding);
NSMapInsert(charsets, (void*)@"utf32be",
(void*)NSUTF32BigEndianStringEncoding);
NSMapInsert(charsets, (void*)@"NSUTF32LittleEndianStringEncoding",
(void*)NSUTF32LittleEndianStringEncoding);
NSMapInsert(charsets, (void*)@"utf-32le",
(void*)NSUTF32LittleEndianStringEncoding);
NSMapInsert(charsets, (void*)@"utf32le",
(void*)NSUTF32LittleEndianStringEncoding);

#if !defined(NeXT_Foundation_LIBRARY)
NSMapInsert(charsets, (void*)@"gsm0338",
Expand Down Expand Up @@ -5691,6 +5727,18 @@ + (void) initialize
(void*)@"shift_JIS");
NSMapInsert(encodings, (void*)NSUTF8StringEncoding,
(void*)@"utf-8");
NSMapInsert(encodings, (void*)NSUnicodeStringEncoding,
(void*)@"utf-16");
NSMapInsert(encodings, (void*)NSUTF16BigEndianStringEncoding,
(void*)@"utf-16be");
NSMapInsert(encodings, (void*)NSUTF16LittleEndianStringEncoding,
(void*)@"utf-16le");
NSMapInsert(encodings, (void*)NSUTF32StringEncoding,
(void*)@"utf-32");
NSMapInsert(encodings, (void*)NSUTF32BigEndianStringEncoding,
(void*)@"utf-32be");
NSMapInsert(encodings, (void*)NSUTF32LittleEndianStringEncoding,
(void*)@"utf-32le");
NSMapInsert(encodings, (void*)NSMacOSRomanStringEncoding,
(void*)@"apple-roman");
#if !defined(NeXT_Foundation_LIBRARY)
Expand Down
13 changes: 13 additions & 0 deletions Source/NSProgress.m
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,13 @@ - (BOOL) isCancellable
return cancellable;
}

- (void) setCancellable: (BOOL) cancellable
{
GS_MUTEX_LOCK(internal->_lock);
internal->_cancellable = cancellable;
GS_MUTEX_UNLOCK(internal->_lock);
}

- (BOOL) isCancelled
{
BOOL cancelled;
Expand All @@ -604,6 +611,12 @@ - (BOOL) isCancelled

- (void) cancel
{
/*
* You are still able to cancel a progress despite it being marked as
* non-cancellable. We therefore do not exit early when cancellable is set to
* true. This was tested on macOS 26.0 (25A354).
*/

if (!internal->_cancelled)
{
GS_MUTEX_LOCK(internal->_lock);
Expand Down
Loading
Loading