From b284979b151e35475816926b144a2ad6b9b875e0 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Tue, 23 May 2023 19:54:45 -0400 Subject: [PATCH 1/4] Add method declarations to NSUserActivity --- Headers/Foundation/NSUserActivity.h | 134 ++++++++++++++++++++++++++-- 1 file changed, 128 insertions(+), 6 deletions(-) diff --git a/Headers/Foundation/NSUserActivity.h b/Headers/Foundation/NSUserActivity.h index a567a7a57f..5299314695 100644 --- a/Headers/Foundation/NSUserActivity.h +++ b/Headers/Foundation/NSUserActivity.h @@ -1,21 +1,21 @@ /* Definition of class NSUserActivity Copyright (C) 2019 Free Software Foundation, Inc. - + By: heron Date: Fri Nov 1 00:25:47 EDT 2019 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 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, @@ -25,7 +25,8 @@ #ifndef _NSUserActivity_h_GNUSTEP_BASE_INCLUDE #define _NSUserActivity_h_GNUSTEP_BASE_INCLUDE -#include +#import +#import #if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST) @@ -33,8 +34,130 @@ extern "C" { #endif +GS_EXPORT NSString* const NSUserActivityBrowsingWeb; + +@class NSString, NSInputStream, NSOutputStream, NSError, NSDictionary, NSSet, NSURL, NSDate; + +typedef NSString* NSUserActivityPersistentIdentifier; + +@protocol NSUserActivityDelegate; + +DEFINE_BLOCK_TYPE(GSContinuationStreamsCompletionHandler, void, NSInputStream*, NSOutputStream*, NSError*); + +DEFINE_BLOCK_TYPE_NO_ARGS(GSDeleteSavedCompletionHandler, void); + GS_EXPORT_CLASS @interface NSUserActivity : NSObject +{ + NSString *_activityType; + NSString *_title; + NSDictionary *_userInfo; + NSSet *_requiredUserInfoKeys; + NSURL *_webpageURL; + NSURL *_referrerURL; + NSDate *_expirationDate; + NSSet *_keywords; + id _delegate; + NSString *_targetContentIndentifier; + + BOOL _supportsContinuationStreams; + BOOL _needsSave; + BOOL _valid; +} + +- (instancetype) initWithActivityType: (NSString *)activityType; + +- (instancetype) init; + +- (void) becomeCurrent; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST) +- (void) resignCurrent; +#endif + +- (void) invalidate; + +- (void) getContinuationStreamsWithCompletionHandler: (GSContinuationStreamsCompletionHandler)handler; + ++ (void) deleteSavedUserActivitiesWithPersistentIdentifiers: (NSArray *)persistentIdentifies completionHandler: (GSDeleteSavedCompletionHandler)handler; + ++ (void) deleteAllSavedUserActivitiesWithCompletionHandler: (GSDeleteSavedCompletionHandler)handler; + +// properties... +- (NSString *) activityType; + +- (NSString *) title; + +- (void) setTitle: (NSString *)title; + +- (NSDictionary *) userInfo; + +- (void) setUserInfo: (NSDictionary *)userInfo; + +- (BOOL) needsSave; + +- (void) setNeedsSave: (BOOL)needsSave; + +- (NSURL *) webpageURL; + +- (void) setWebpageURL: (NSURL *)url; + +- (NSURL *) referrerURL; + +- (void) setReferrerURL: (NSURL *)url; + +- (NSDate *) expirationDate; + +- (void) setExpirationDate: (NSDate *)date; + +- (NSArray *) keywords; + +- (void) setKeywords: (NSArray *)keywords; + +- (BOOL) supportsContinuationStreams; + +- (void) setSupportsContinuationStreams: (BOOL)flag; + +- (id) delegate; + +- (void) setDelegate: (id)delegate; + +- (NSString *) targetContentIdentifier; + +- (void) setTargetContentIdentifier: (NSString *)targetContentIdentifier; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST) +- (BOOL) isEligibleForHandoff; + +- (void) setEligibleForHandoff: (BOOL)f; + +- (BOOL) isEligibleForSearch; + +- (void) setEligibleForSearch: (BOOL)f; + +- (BOOL) isEligibleForPublicIndexing; + +- (void) setEligibleForPublicIndexing: (BOOL)f; + +- (BOOL) isEligibleForPrediction; + +- (void) setEligibleForPrediction: (BOOL)f; +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_15, GS_API_LATEST) +- (NSUserActivityPersistentIdentifier) persistentIdentifier; + +- (void) setPersistentIdentifier: (NSUserActivityPersistentIdentifier)persistentIdentifier; +#endif +@end + +@protocol NSUserActivityDelegate + +- (void) userActivityWillSave: (NSUserActivity *)activity; + +- (void) userActivityWasContinued: (NSUserActivity *)activity; + +- (void) userActivity: (NSUserActivity *)activity didRecieveInputStream: (NSInputStream *)inputStream outputStream: (NSOutputStream *)outputStream; @end @@ -45,4 +168,3 @@ GS_EXPORT_CLASS #endif /* GS_API_MACOSX */ #endif /* _NSUserActivity_h_GNUSTEP_BASE_INCLUDE */ - From 041ed7b9e4c9b298432439ee2cf03442840e8a7d Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Tue, 23 May 2023 20:29:29 -0400 Subject: [PATCH 2/4] Add skeletal implementations of methods --- Headers/Foundation/NSUserActivity.h | 9 +- Source/NSUserActivity.m | 202 +++++++++++++++++++++++++++- 2 files changed, 208 insertions(+), 3 deletions(-) diff --git a/Headers/Foundation/NSUserActivity.h b/Headers/Foundation/NSUserActivity.h index 5299314695..7b55f71b77 100644 --- a/Headers/Foundation/NSUserActivity.h +++ b/Headers/Foundation/NSUserActivity.h @@ -58,11 +58,16 @@ GS_EXPORT_CLASS NSDate *_expirationDate; NSSet *_keywords; id _delegate; - NSString *_targetContentIndentifier; - + NSString *_targetContentIdentifier; + NSString *_persistentIdentifier; + BOOL _supportsContinuationStreams; BOOL _needsSave; BOOL _valid; + BOOL _eligibleForPrediction; + BOOL _eligibleForPublicIndexing; + BOOL _eligibleForSearch; + BOOL _eligibleForHandoff; } - (instancetype) initWithActivityType: (NSString *)activityType; diff --git a/Source/NSUserActivity.m b/Source/NSUserActivity.m index 7fc7a94576..ad1f716fb1 100644 --- a/Source/NSUserActivity.m +++ b/Source/NSUserActivity.m @@ -26,5 +26,205 @@ @implementation NSUserActivity -@end +- (instancetype) initWithActivityType: (NSString *)activityType +{ + self = [super init]; + if (self != nil) + { + } + + return self; +} + +- (instancetype) init +{ + self = [super init]; + if (self != nil) + { + } + + return self; +} + +- (void) becomeCurrent +{ +} + +- (void) resignCurrent +{ +} + +- (void) invalidate +{ + _valid = NO; +} + +- (void) getContinuationStreamsWithCompletionHandler: (GSContinuationStreamsCompletionHandler)handler +{ +} + ++ (void) deleteSavedUserActivitiesWithPersistentIdentifiers: (NSArray *)persistentIdentifies completionHandler: (GSDeleteSavedCompletionHandler)handler +{ +} + ++ (void) deleteAllSavedUserActivitiesWithCompletionHandler: (GSDeleteSavedCompletionHandler)handler +{ +} + +// properties... +- (NSString *) activityType +{ + return _activityType; +} + +- (NSString *) title +{ + return _title; +} + +- (void) setTitle: (NSString *)title +{ + ASSIGNCOPY(_title, title); +} + +- (NSDictionary *) userInfo +{ + return _userInfo; +} + +- (void) setUserInfo: (NSDictionary *)userInfo +{ + ASSIGNCOPY(_userInfo, userInfo); +} + +- (BOOL) needsSave +{ + return _needsSave; +} + +- (void) setNeedsSave: (BOOL)needsSave +{ + _needsSave = needsSave; +} + +- (NSURL *) webpageURL +{ + return _webpageURL; +} + +- (void) setWebpageURL: (NSURL *)url +{ + ASSIGNCOPY(_webpageURL, url); +} + +- (NSURL *) referrerURL +{ + return _referrerURL; +} + +- (void) setReferrerURL: (NSURL *)url +{ + ASSIGNCOPY(_referrerURL, url); +} +- (NSDate *) expirationDate +{ + return _expirationDate; +} + +- (void) setExpirationDate: (NSDate *)date +{ + ASSIGNCOPY(_expirationDate, date); +} + +- (NSSet *) keywords +{ + return _keywords; +} + +- (void) setKeywords: (NSArray *)keywords +{ + ASSIGNCOPY(_keywords, keywords); +} + +- (BOOL) supportsContinuationStreams +{ + return _supportsContinuationStreams; +} + +- (void) setSupportsContinuationStreams: (BOOL)flag +{ + _supportsContinuationStreams = flag; +} + +- (id) delegate +{ + return _delegate; +} + +- (void) setDelegate: (id)delegate +{ + _delegate = delegate; +} + +- (NSString *) targetContentIdentifier +{ + return _targetContentIdentifier; +} + +- (void) setTargetContentIdentifier: (NSString *)targetContentIdentifier +{ + ASSIGNCOPY(_targetContentIdentifier, targetContentIdentifier); +} + +- (BOOL) isEligibleForHandoff +{ + return _eligibleForHandoff; +} + +- (void) setEligibleForHandoff: (BOOL)f +{ + _eligibleForHandoff = f; +} + +- (BOOL) isEligibleForSearch +{ + return _eligibleForSearch; +} + +- (void) setEligibleForSearch: (BOOL)f +{ + _eligibleForSearch = f; +} + +- (BOOL) isEligibleForPublicIndexing +{ + return _eligibleForPublicIndexing; +} + +- (void) setEligibleForPublicIndexing: (BOOL)f +{ + _eligibleForPublicIndexing = f; +} + +- (BOOL) isEligibleForPrediction +{ + return _eligibleForPrediction; +} + +- (void) setEligibleForPrediction: (BOOL)f +{ + _eligibleForPrediction = f; +} + +- (NSUserActivityPersistentIdentifier) persistentIdentifier +{ + return _persistentIdentifier; +} + +- (void) setPersistentIdentifier: (NSUserActivityPersistentIdentifier)persistentIdentifier +{ + ASSIGNCOPY(_persistentIdentifier, persistentIdentifier); +} + +@end From 018e19e9e35d3f2a46f79fd7ac602d2f88c62ac7 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Sat, 27 May 2023 12:18:31 -0400 Subject: [PATCH 3/4] Add initialization, static __currentUserActivity --- Source/NSUserActivity.m | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/Source/NSUserActivity.m b/Source/NSUserActivity.m index ad1f716fb1..7baebc420b 100644 --- a/Source/NSUserActivity.m +++ b/Source/NSUserActivity.m @@ -22,15 +22,27 @@ Boston, MA 02110 USA. */ -#include +#import "Foundation/NSDate.h" +#import "Foundation/NSDictionary.h" +#import "Foundation/NSString.h" +#import "Foundation/NSSet.h" +#import "Foundation/NSURL.h" +#import "Foundation/NSUserActivity.h" + +static NSUserActivity *__currentUserActivity = nil; @implementation NSUserActivity - (instancetype) initWithActivityType: (NSString *)activityType { self = [super init]; + if (self != nil) { + ASSIGNCOPY(_activityType, activityType); + _userInfo = [[NSMutableDictionary alloc] init]; + _requiredUserInfoKeys = [[NSMutableSet alloc] initWithCapacity: 10]; + _keywords = [[NSMutableSet alloc] init]; } return self; @@ -39,19 +51,42 @@ - (instancetype) initWithActivityType: (NSString *)activityType - (instancetype) init { self = [super init]; + if (self != nil) { + _activityType = nil; } return self; -} +} + +- (void) dealloc +{ + __currentUserActivity = nil; + _delegate = nil; + + RELEASE(_activityType); + RELEASE(_title); + RELEASE(_userInfo); + RELEASE(_requiredUserInfoKeys); + RELEASE(_webpageURL); + RELEASE(_referrerURL); + RELEASE(_expirationDate); + RELEASE(_keywords); + RELEASE(_targetContentIdentifier); + RELEASE(_persistentIdentifier); + + [super dealloc]; +} - (void) becomeCurrent { + __currentUserActivity = self; } - (void) resignCurrent { + __currentUserActivity = nil; } - (void) invalidate From 2ea339eef882dae34d72aae3a4d97d0549ae15f9 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Sun, 28 May 2023 22:02:44 -0400 Subject: [PATCH 4/4] Updated imports for NSUbiquitousKeyValueStore updates to NSUserActivity --- Source/NSUbiquitousKeyValueStore.m | 16 ++++++++-------- Source/NSUserActivity.m | 8 +------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Source/NSUbiquitousKeyValueStore.m b/Source/NSUbiquitousKeyValueStore.m index 6b2c5c1174..d6cee06bef 100644 --- a/Source/NSUbiquitousKeyValueStore.m +++ b/Source/NSUbiquitousKeyValueStore.m @@ -20,21 +20,21 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110 USA. - */ + #import "common.h" #import "Foundation/NSAutoreleasePool.h" #import "Foundation/NSCoder.h" #import "Foundation/NSEnumerator.h" #import "Foundation/NSException.h" #import "Foundation/NSKeyedArchiver.h" -#import -#import -#import -#import -#import -#import -#import +#import "Foundation/NSUbiquitousKeyValueStore.h" +#import "Foundation/NSArray.h" +#import "Foundation/NSDictionary.h" +#import "Foundation/NSData.h" +#import "Foundation/NSString.h" +#import "Foundation/NSValue.h" +#import "Foundation/NSUserDefaults.h" static NSUbiquitousKeyValueStore *_sharedUbiquitousKeyValueStore = nil; diff --git a/Source/NSUserActivity.m b/Source/NSUserActivity.m index 7baebc420b..62c2052e28 100644 --- a/Source/NSUserActivity.m +++ b/Source/NSUserActivity.m @@ -50,13 +50,7 @@ - (instancetype) initWithActivityType: (NSString *)activityType - (instancetype) init { - self = [super init]; - - if (self != nil) - { - _activityType = nil; - } - + self = [self initWithActivityType: nil]; return self; }