diff --git a/FsprgEmbeddedStore/FsprgEmbeddedStore.h b/FsprgEmbeddedStore/FsprgEmbeddedStore.h index 900e197..143f80d 100644 --- a/FsprgEmbeddedStore/FsprgEmbeddedStore.h +++ b/FsprgEmbeddedStore/FsprgEmbeddedStore.h @@ -2,15 +2,21 @@ // FsprgEmbeddedStore.h // FsprgEmbeddedStore // -// Created by Lars Steiger on 2/28/10. -// Copyright 2010 FastSpring. All rights reserved. +// Created by Luc Vandal on 2016-07-19. +// Copyright © 2016 Edovia Inc. All rights reserved. // +#import + +//! Project version number for FsprgEmbeddedStore. +FOUNDATION_EXPORT double FsprgEmbeddedStoreVersionNumber; + +//! Project version string for FsprgEmbeddedStore. +FOUNDATION_EXPORT const unsigned char FsprgEmbeddedStoreVersionString[]; #import "FsprgEmbeddedStoreController.h" #import "FsprgEmbeddedStoreDelegate.h" #import "FsprgStoreParameters.h" - -// Model +// Mode" #import "FsprgOrder.h" #import "FsprgOrderItem.h" #import "FsprgFulfillment.h" diff --git a/FsprgEmbeddedStore/FsprgEmbeddedStoreController.h b/FsprgEmbeddedStore/FsprgEmbeddedStoreController.h index 983685b..03e0ec1 100755 --- a/FsprgEmbeddedStore/FsprgEmbeddedStoreController.h +++ b/FsprgEmbeddedStore/FsprgEmbeddedStoreController.h @@ -10,6 +10,8 @@ #import #import "FsprgEmbeddedStoreDelegate.h" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" /*! * Controller for FastSpring's embedded store. @@ -21,19 +23,17 @@ NSMutableDictionary *hostCertificates; } -- (WebView *)webView; +@property (NS_NONATOMIC_IOSONLY, strong) WebView *webView; /*! * Connects this controller to a web view. * @param aWebView Web view to connect. */ -- (void)setWebView:(WebView *)aWebView; -- (id )delegate; +@property (NS_NONATOMIC_IOSONLY, assign) id delegate; /*! * Sets a delegate to which it has a weak reference. * @param aDelegate Delegate to set. */ -- (void)setDelegate:(id )aDelegate; /*! * Loads the store using the given parameters. @@ -51,30 +51,32 @@ * Useful to trigger e.g. the hidden flag of a progress bar. * @result TRUE if loading a page. */ -- (BOOL)isLoading; +@property (NS_NONATOMIC_IOSONLY, getter=isLoading, readonly) BOOL loading; /*! * Useful to provide the value for a progress bar. * @result The loading progress in percent of a page (0 - 100) */ -- (double)estimatedLoadingProgress; +@property (NS_NONATOMIC_IOSONLY, readonly) double estimatedLoadingProgress; /** * Useful to show a secure icon. * @result TRUE if connection is secure (SSL) */ -- (BOOL)isSecure; +@property (NS_NONATOMIC_IOSONLY, getter=isSecure, readonly) BOOL secure; /** * * @result NSArray containing SecCertificateRef objects for the host of the main frame, if it was loaded via https. */ -- (NSArray *)securityCertificates; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *securityCertificates; /*! * Host that delivers the store (e.g. sites.fastspring.com). * @result nil until the store has been loaded. */ -- (NSString *)storeHost; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *storeHost; + +#pragma clang diagnostic pop @end diff --git a/FsprgEmbeddedStore/FsprgEmbeddedStoreController.m b/FsprgEmbeddedStore/FsprgEmbeddedStoreController.m index b2c40fe..9dd533b 100755 --- a/FsprgEmbeddedStore/FsprgEmbeddedStoreController.m +++ b/FsprgEmbeddedStore/FsprgEmbeddedStoreController.m @@ -5,13 +5,18 @@ // Created by Lars Steiger on 2/12/10. // Copyright 2010 FastSpring. All rights reserved. // +// Updated by Pascal Harris 10/10/2026. +// Updated to work with macOS 26 'Tahoe', removing +// deprecations and fixing (most) static analysis +// and compiler warnings. #import "FsprgEmbeddedStoreController.h" #import "FsprgOrderView.h" #import "FsprgOrderDocumentRepresentation.h" + // We don't retrieve SSL certificates below OSX 10.6 -#define RETRIEVE_SSL_CERTIFICATES defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 +//#define RETRIEVE_SSL_CERTIFICATES defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 @interface FsprgEmbeddedStoreController () @@ -21,15 +26,17 @@ - (void)setIsSecure:(BOOL)aFlag; - (void)setStoreHost:(NSString *)aHost; - (void)resizeContentDivE; - (void)webViewFrameChanged:(NSNotification *)aNotification; -- (NSMutableDictionary *)hostCertificates; -- (void)setHostCertificates:(NSMutableDictionary *)aHostCertificates; +@property (nonatomic, copy) NSMutableDictionary *hostCertificates; @end -#if defined(MAC_OS_X_VERSION_10_11) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_11 +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +//#if defined(MAC_OS_X_VERSION_10_11) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_11 @interface FsprgEmbeddedStoreController () @end -#endif +//#endif @implementation FsprgEmbeddedStoreController @@ -41,21 +48,21 @@ + (void)initialize forMIMEType:@"application/x-fsprgorder+xml"]; } -- (id) init +- (instancetype) init { self = [super init]; if (self != nil) { [self setWebView:nil]; [self setDelegate:nil]; [self setStoreHost:nil]; - [self setHostCertificates:[NSMutableDictionary dictionary]]; + self.hostCertificates = [NSMutableDictionary dictionary]; } return self; } - (WebView *)webView { - return [[webView retain] autorelease]; + return webView; } - (void)setWebView:(WebView *)aWebView @@ -68,15 +75,14 @@ - (void)setWebView:(WebView *)aWebView [webView setApplicationNameForUserAgent:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self]; - [webView release]; - webView = [aWebView retain]; + webView = aWebView; if (webView) { [webView setPostsFrameChangedNotifications:TRUE]; - [webView setFrameLoadDelegate:self]; - [webView setUIDelegate:self]; - [webView setResourceLoadDelegate:self]; - [webView setApplicationNameForUserAgent:@"FSEmbeddedStore/2.0"]; + webView.frameLoadDelegate = self; + webView.UIDelegate = self; + webView.resourceLoadDelegate = self; + webView.applicationNameForUserAgent = @"FSEmbeddedStore/2.0"; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(webViewFrameChanged:) name:NSViewFrameDidChangeNotification @@ -96,7 +102,7 @@ - (void)setWebView:(WebView *)aWebView - (id )delegate { if(delegate == nil) { - NSLog(@"No delegate has been assigned to FsprgEmbeddedStoreController!"); + // NSLog(@"No delegate has been assigned to FsprgEmbeddedStoreController!"); } return delegate; } @@ -115,15 +121,15 @@ - (void)loadWithParameters:(FsprgStoreParameters *)parameters return; } - NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:[urlRequest URL]]; - NSUInteger i, count = [cookies count]; + NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:urlRequest.URL]; + NSUInteger i, count = cookies.count; for (i = 0; i < count; i++) { - NSHTTPCookie *cookie = [cookies objectAtIndex:i]; + NSHTTPCookie *cookie = cookies[i]; [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie]; } [self setStoreHost:nil]; - [[webView mainFrame] loadRequest:urlRequest]; + [webView.mainFrame loadRequest:urlRequest]; } - (void)loadWithContentsOfFile:(NSString *)aPath @@ -132,15 +138,15 @@ - (void)loadWithContentsOfFile:(NSString *)aPath NSData *data = [NSData dataWithContentsOfFile:aPath]; if(data == nil) { - NSLog(@"File %@ not found.", aPath); + // NSLog(@"File %@ not found.", aPath); } else { - [[webView mainFrame] loadData:data MIMEType:@"application/x-fsprgorder+xml" textEncodingName:@"UTF-8" baseURL:nil]; + [webView.mainFrame loadData:data MIMEType:@"application/x-fsprgorder+xml" textEncodingName:@"UTF-8" baseURL:nil]; } } - (BOOL)isLoading { - return [self estimatedLoadingProgress] < 100; + return self.estimatedLoadingProgress < 100; } - (void)setIsLoading:(BOOL)aFlag { @@ -148,7 +154,7 @@ - (void)setIsLoading:(BOOL)aFlag } - (double)estimatedLoadingProgress { - return [webView estimatedProgress] * 100; + return webView.estimatedProgress * 100; } - (void)setEstimatedLoadingProgress:(double)aProgress { @@ -161,8 +167,8 @@ - (void)estimatedLoadingProgressChanged:(NSNotification *)aNotification } - (BOOL)isSecure { - WebDataSource *mainFrameDs = [[[self webView] mainFrame] dataSource]; - return [@"https" isEqualTo:[[[mainFrameDs request] URL] scheme]]; + WebDataSource *mainFrameDs = self.webView.mainFrame.dataSource; + return [@"https" isEqualTo:mainFrameDs.request.URL.scheme]; } - (void)setIsSecure:(BOOL)aFlag { @@ -171,54 +177,53 @@ - (void)setIsSecure:(BOOL)aFlag - (NSArray *)securityCertificates { - if ([self isSecure] == NO) { + if (self.secure == NO) { return nil; } - NSString *mainFrameURL = [[self webView] mainFrameURL]; - NSString *host = [[NSURL URLWithString:mainFrameURL] host]; - return [[self hostCertificates] objectForKey:host]; + NSString *mainFrameURL = self.webView.mainFrameURL; + NSString *host = [NSURL URLWithString:mainFrameURL].host; + return self.hostCertificates[host]; } - (NSString *)storeHost { - return [[storeHost retain] autorelease]; + return storeHost; } - (void)setStoreHost:(NSString *)aHost { if (storeHost != aHost) { - [storeHost release]; - storeHost = [aHost retain]; + storeHost = aHost; } } - (void)resizeContentDivE { - if ([[self delegate] respondsToSelector:@selector(shouldStoreControllerFixContentDivHeight:)]) { - if ([[self delegate] shouldStoreControllerFixContentDivHeight:self] == NO) { + if ([self.delegate respondsToSelector:@selector(shouldStoreControllerFixContentDivHeight:)]) { + if ([self.delegate shouldStoreControllerFixContentDivHeight:self] == NO) { return; } } - DOMElement *resizableContentE = [[[[self webView] mainFrame] DOMDocument] getElementById:@"FsprgResizableContent"]; + DOMElement *resizableContentE = [self.webView.mainFrame.DOMDocument getElementById:@"FsprgResizableContent"]; if(resizableContentE == nil) { return; } - CGFloat windowHeight = [[self webView] frame].size.height; - id result = [[[self webView] windowScriptObject] evaluateWebScript:@"document.getElementsByClassName('store-page-navigation')[0].clientHeight"]; + CGFloat windowHeight = self.webView.frame.size.height; + id result = [self.webView.windowScriptObject evaluateWebScript:@"document.getElementsByClassName('store-page-navigation')[0].clientHeight"]; if (result == [WebUndefined undefined]) { return; } - float pageNavigationHeight = [(NSString *)result floatValue]; + float pageNavigationHeight = ((NSString *)result).floatValue; - DOMCSSStyleDeclaration *cssStyle = [[self webView] computedStyleForElement:resizableContentE pseudoElement:nil]; - float paddingTop = [[[cssStyle paddingBottom] substringToIndex:[[cssStyle paddingTop] length]-2] floatValue]; - float paddingBottom = [[[cssStyle paddingBottom] substringToIndex:[[cssStyle paddingBottom] length]-2] floatValue]; + DOMCSSStyleDeclaration *cssStyle = [self.webView computedStyleForElement:resizableContentE pseudoElement:nil]; + float paddingTop = [[cssStyle paddingBottom] substringToIndex:[cssStyle paddingTop].length-2].floatValue; + float paddingBottom = [[cssStyle paddingBottom] substringToIndex:[cssStyle paddingBottom].length-2].floatValue; CGFloat newHeight = windowHeight - paddingTop - paddingBottom - pageNavigationHeight; - [[resizableContentE style] setHeight:[NSString stringWithFormat:@"%fpx", newHeight]]; + [resizableContentE.style setHeight:[NSString stringWithFormat:@"%fpx", newHeight]]; } - (void)webViewFrameChanged:(NSNotification *)aNotification @@ -228,13 +233,12 @@ - (void)webViewFrameChanged:(NSNotification *)aNotification - (NSMutableDictionary *)hostCertificates { - return [[hostCertificates retain] autorelease]; + return hostCertificates; } + - (void)setHostCertificates:(NSMutableDictionary *)anHostCertificates { if (hostCertificates != anHostCertificates) { - [anHostCertificates retain]; - [hostCertificates release]; hostCertificates = anHostCertificates; } } @@ -244,8 +248,8 @@ - (void)setHostCertificates:(NSMutableDictionary *)anHostCertificates - (void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame { - if ([[self delegate] respondsToSelector:@selector(webView:didStartProvisionalLoadForFrame:)]) { - [[self delegate] webView:sender didStartProvisionalLoadForFrame:frame]; + if ([self.delegate respondsToSelector:@selector(webView:didStartProvisionalLoadForFrame:)]) { + [self.delegate webView:sender didStartProvisionalLoadForFrame:frame]; } } @@ -255,45 +259,45 @@ - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame [self resizeContentDivE]; - NSURL *newURL = [[[frame dataSource] request] URL]; + NSURL *newURL = frame.dataSource.request.URL; NSString *newStoreHost; - if ([@"file" isEqualTo:[newURL scheme]]) { + if ([@"file" isEqualTo:newURL.scheme]) { newStoreHost = @"file"; } else { - newStoreHost = [newURL host]; + newStoreHost = newURL.host; } - if([self storeHost] == nil) { + if(self.storeHost == nil) { [self setStoreHost:newStoreHost]; - [[self delegate] didLoadStore:newURL]; + [self.delegate didLoadStore:newURL]; } else { FsprgPageType newPageType; - if([newStoreHost isEqualTo:[self storeHost]]) { + if([newStoreHost isEqualTo:self.storeHost]) { newPageType = FsprgPageFS; } else if([newStoreHost hasSuffix:@"paypal.com"]) { newPageType = FsprgPagePayPal; } else { newPageType = FsprgPageUnknown; } - [[self delegate] didLoadPage:newURL ofType:newPageType]; + [self.delegate didLoadPage:newURL ofType:newPageType]; } } - (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame { - [[self delegate] webView:sender didFailProvisionalLoadWithError:error forFrame:frame]; + [self.delegate webView:sender didFailProvisionalLoadWithError:error forFrame:frame]; } - (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame { - [[self delegate] webView:sender didFailLoadWithError:error forFrame:frame]; + [self.delegate webView:sender didFailLoadWithError:error forFrame:frame]; } #pragma mark - WebUIDelegate - (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame { - NSString *title = [sender mainFrameTitle]; + NSString *title = sender.mainFrameTitle; NSAlert *alertPanel = [[NSAlert alloc] init]; [alertPanel setMessageText:title]; [alertPanel setInformativeText:message]; @@ -302,6 +306,7 @@ - (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString * #else [alertPanel beginSheetModalForWindow:[sender window] completionHandler:nil]; #endif + [alertPanel release]; } - (NSUInteger)webView:(WebView *)sender dragDestinationActionMaskForDraggingInfo:(id )draggingInfo @@ -312,15 +317,15 @@ - (NSUInteger)webView:(WebView *)sender dragDestinationActionMaskForDraggingInfo - (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request { NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,0,0) - styleMask:(NSClosableWindowMask|NSResizableWindowMask) + styleMask:(NSWindowStyleMaskClosable|NSWindowStyleMaskResizable) backing:NSBackingStoreBuffered defer:NO]; - WebView *subWebView = [[[WebView alloc] initWithFrame:NSMakeRect(0,0,0,0)] autorelease]; + WebView *subWebView = [[WebView alloc] initWithFrame:NSMakeRect(0,0,0,0)]; [window setReleasedWhenClosed:TRUE]; [window setContentView:subWebView]; [window makeKeyAndOrderFront:sender]; - return subWebView; + return [subWebView autorelease]; } #pragma mark - WebResourceLoadDelegate @@ -333,7 +338,7 @@ - (BOOL)webView:(WebView *)sender resource:(id)identifier canAuthenticateAgainst - (void)webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource { - SecTrustRef trustRef = [[challenge protectionSpace] serverTrust]; + SecTrustRef trustRef = challenge.protectionSpace.serverTrust; SecTrustResultType resultType; SecTrustEvaluate(trustRef, &resultType); NSUInteger count = (NSUInteger)SecTrustGetCertificateCount(trustRef); @@ -342,13 +347,13 @@ - (void)webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticati CFIndex idx; for (idx = 0; idx < (CFIndex)count; idx++) { SecCertificateRef certificateRef = SecTrustGetCertificateAtIndex(trustRef, idx); - [certificates addObject:(id)certificateRef]; + [certificates addObject:(__bridge id)certificateRef]; } - NSString *host = [[challenge protectionSpace] host]; - [[self hostCertificates] setObject:certificates forKey:host]; + NSString *host = challenge.protectionSpace.host; + self.hostCertificates[host] = certificates; - [[challenge sender] useCredential:[NSURLCredential credentialForTrust:trustRef] forAuthenticationChallenge:challenge]; + [challenge.sender useCredential:[NSURLCredential credentialForTrust:trustRef] forAuthenticationChallenge:challenge]; } #endif @@ -359,8 +364,9 @@ - (void)dealloc [self setDelegate:nil]; [self setStoreHost:nil]; [self setHostCertificates:nil]; - - [super dealloc]; + [super dealloc]; //pgh } +#pragma clang diagnostic pop + @end diff --git a/FsprgEmbeddedStore/FsprgEmbeddedStoreDelegate.h b/FsprgEmbeddedStore/FsprgEmbeddedStoreDelegate.h index 9f0aa6a..02a9a0f 100755 --- a/FsprgEmbeddedStore/FsprgEmbeddedStoreDelegate.h +++ b/FsprgEmbeddedStore/FsprgEmbeddedStoreDelegate.h @@ -11,12 +11,15 @@ #import "FsprgStoreParameters.h" #import "FsprgOrder.h" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + /*! Type for didLoadPage:ofType: */ -typedef enum { +typedef NS_ENUM(unsigned int, FsprgPageType) { FsprgPageFS, FsprgPagePayPal, FsprgPageUnknown -} FsprgPageType; +}; @class FsprgEmbeddedStoreController; @@ -86,4 +89,6 @@ typedef enum { */ - (void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame; +#pragma clang diagnostic pop + @end diff --git a/FsprgEmbeddedStore/FsprgOrderDocumentRepresentation.h b/FsprgEmbeddedStore/FsprgOrderDocumentRepresentation.h index 2e90831..9af4d4f 100644 --- a/FsprgEmbeddedStore/FsprgOrderDocumentRepresentation.h +++ b/FsprgEmbeddedStore/FsprgOrderDocumentRepresentation.h @@ -10,6 +10,8 @@ #import #import "FsprgOrder.h" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" /*! * WebDocumentRepresentation that calls FsprgEmbeddedStoreDelegate on receiving the order. @@ -18,7 +20,8 @@ FsprgOrder *order; } -- (FsprgOrder *)order; -- (void)setOrder:(FsprgOrder *)anOrder; +@property (NS_NONATOMIC_IOSONLY, strong) FsprgOrder *order; + +#pragma clang diagnostic pop @end diff --git a/FsprgEmbeddedStore/FsprgOrderDocumentRepresentation.m b/FsprgEmbeddedStore/FsprgOrderDocumentRepresentation.m index f8e88ff..4bf3cc6 100644 --- a/FsprgEmbeddedStore/FsprgOrderDocumentRepresentation.m +++ b/FsprgEmbeddedStore/FsprgOrderDocumentRepresentation.m @@ -12,7 +12,7 @@ @implementation FsprgOrderDocumentRepresentation -- (id) init +- (instancetype) init { self = [super init]; if (self != nil) { @@ -23,14 +23,13 @@ - (id) init - (FsprgOrder *)order { - return [[order retain] autorelease]; + return order; } - (void)setOrder:(FsprgOrder *)anOrder { if (order != anOrder) { - [order release]; - order = [anOrder retain]; + order = anOrder; } } @@ -47,15 +46,18 @@ - (BOOL)canProvideDocumentSource return FALSE; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + - (void)setDataSource:(WebDataSource *)aDataSource { } - (void)receivedData:(NSData *)aData withDataSource:(WebDataSource *)aDataSource { - [self setOrder:[FsprgOrder orderFromData:aData]]; - FsprgEmbeddedStoreController *delegate = [[[aDataSource webFrame] webView] frameLoadDelegate]; - [[delegate delegate] didReceiveOrder:[self order]]; + self.order = [FsprgOrder orderFromData:aData]; + FsprgEmbeddedStoreController *delegate = aDataSource.webFrame.webView.frameLoadDelegate; + [delegate.delegate didReceiveOrder:self.order]; } - (void)receivedError:(NSError *)anError withDataSource:(WebDataSource *)aDataSource @@ -69,8 +71,9 @@ - (void)finishedLoadingWithDataSource:(WebDataSource *)aDataSource - (void)dealloc { [self setOrder:nil]; - - [super dealloc]; + [super dealloc]; //pgh fix } +#pragma clang diagnostic pop + @end diff --git a/FsprgEmbeddedStore/FsprgOrderView.h b/FsprgEmbeddedStore/FsprgOrderView.h index ff6b63b..e9af88b 100644 --- a/FsprgEmbeddedStore/FsprgOrderView.h +++ b/FsprgEmbeddedStore/FsprgOrderView.h @@ -9,6 +9,8 @@ #import #import +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" /*! * WebDocumentView implementation encapsulating the order @@ -19,9 +21,9 @@ BOOL needsLayout; } -- (WebDataSource *)dataSource; -- (void)setDataSource:(WebDataSource *)aDataSource; -- (BOOL)needsLayout; -- (void)setNeedsLayout:(BOOL)flag; +@property (NS_NONATOMIC_IOSONLY, assign) WebDataSource *dataSource; +@property (NS_NONATOMIC_IOSONLY) BOOL needsLayout; + +#pragma clang diagnostic pop @end diff --git a/FsprgEmbeddedStore/FsprgOrderView.m b/FsprgEmbeddedStore/FsprgOrderView.m index 53bda55..048104d 100644 --- a/FsprgEmbeddedStore/FsprgOrderView.m +++ b/FsprgEmbeddedStore/FsprgOrderView.m @@ -5,6 +5,10 @@ // Created by Lars Steiger on 2/18/10. // Copyright 2010 FastSpring. All rights reserved. // +// Updated by Pascal Harris 10/10/2026. +// Updated to work with macOS 26 'Tahoe', removing +// deprecations and fixing (most) static analysis +// and compiler warnings. #import "FsprgOrderView.h" #import "FsprgOrderDocumentRepresentation.h" @@ -13,34 +17,40 @@ @implementation FsprgOrderView -- (id)initWithFrame:(NSRect)frame +- (instancetype)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { [self setDataSource:nil]; [self setNeedsLayout:FALSE]; [self setAutoresizesSubviews:TRUE]; - [self setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + self.autoresizingMask = (NSViewWidthSizable | NSViewHeightSizable); } return self; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + - (WebDataSource *)dataSource { - return [[dataSource retain] autorelease]; + return dataSource; } + - (void)setDataSource:(WebDataSource *)aDataSource { if (dataSource != aDataSource) { - [dataSource release]; - dataSource = [aDataSource retain]; + dataSource = aDataSource; } } + - (void)dataSourceUpdated:(WebDataSource *)aDataSource { - [self setDataSource:aDataSource]; + self.dataSource = aDataSource; } +#pragma clang diagnostic pop + - (BOOL)needsLayout { return needsLayout; @@ -53,7 +63,7 @@ - (void)setNeedsLayout:(BOOL)flag - (void)drawRect:(NSRect)aRect { - if([self needsLayout]) { + if(self.needsLayout) { [self setNeedsLayout:FALSE]; [self layout]; } @@ -62,14 +72,14 @@ - (void)drawRect:(NSRect)aRect - (void)layout { - if([[self subviews] count] == 0) { - [self setFrame:[[self superview] frame]]; + if(self.subviews.count == 0) { + self.frame = self.superview.frame; - FsprgOrderDocumentRepresentation *representation = (FsprgOrderDocumentRepresentation *)[[self dataSource] representation]; - FsprgOrder *order = [representation order]; + FsprgOrderDocumentRepresentation *representation = (FsprgOrderDocumentRepresentation *)self.dataSource.representation; + FsprgOrder *order = representation.order; - FsprgEmbeddedStoreController *delegate = [[[[self dataSource] webFrame] webView] UIDelegate]; - NSView *newSubview = [[delegate delegate] viewWithFrame:[self frame] forOrder:order]; + FsprgEmbeddedStoreController *delegate = self.dataSource.webFrame.webView.UIDelegate; + NSView *newSubview = [delegate.delegate viewWithFrame:self.frame forOrder:order]; [self addSubview:newSubview]; } @@ -81,6 +91,7 @@ - (void)layout - (void)viewDidMoveToHostWindow { } + - (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow { } @@ -88,8 +99,8 @@ - (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow - (void)dealloc { [self setDataSource:nil]; - - [super dealloc]; + [super dealloc]; //pgh } @end + diff --git a/FsprgEmbeddedStore/FsprgStoreParameters.h b/FsprgEmbeddedStore/FsprgStoreParameters.h index a5f4184..e27661e 100755 --- a/FsprgEmbeddedStore/FsprgStoreParameters.h +++ b/FsprgEmbeddedStore/FsprgStoreParameters.h @@ -31,54 +31,46 @@ extern NSString * const kFsprgModeTest; + (FsprgStoreParameters *)parameters; + (FsprgStoreParameters *)parametersWithRaw:(NSMutableDictionary *)aRaw; -- (NSURLRequest *)toURLRequest; -- (NSURL *)toURL; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSURLRequest *toURLRequest; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSURL *toURL; -- (id)initWithRaw:(NSMutableDictionary *)aRaw; -- (NSMutableDictionary *)raw; -- (void)setRaw:(NSMutableDictionary *)aRaw; +- (instancetype)initWithRaw:(NSMutableDictionary *)aRaw NS_DESIGNATED_INITIALIZER; +@property (NS_NONATOMIC_IOSONLY, copy) NSMutableDictionary *raw; /*! * Pass a language code via the URL to bypass automatic language detection. * Example: de */ -- (NSString *)language; -- (void)setLanguage:(NSString *)aLanguage; +@property (NS_NONATOMIC_IOSONLY, copy) NSString *language; /*! * Use kFsprgOrderProcessDetail or kFsprgOrderProcessInstant. */ -- (NSString *)orderProcessType; -- (void)setOrderProcessType:(NSString *)anOrderProcessType; +@property (NS_NONATOMIC_IOSONLY, copy) NSString *orderProcessType; /*! * Store path name and product path name. * These are found in a full product URL such as sites.fastspring.com//product/ */ - (void)setStoreId:(NSString *)aStoreId withProductId:(NSString *)aProductId; -- (NSString *)storeId; -- (void)setStoreId:(NSString *)aStoreId; -- (NSString *)productId; -- (void)setProductId:(NSString *)aProductId; +@property (NS_NONATOMIC_IOSONLY, copy) NSString *storeId; +@property (NS_NONATOMIC_IOSONLY, copy) NSString *productId; /*! * Use kFsprgModeActive, kFsprgModeActiveTest or kFsprgModeTest. */ -- (NSString *)mode; -- (void)setMode:(NSString *)aMode; +@property (NS_NONATOMIC_IOSONLY, copy) NSString *mode; /*! * Used for "External Tracking". Go to "Link Sources" inside SpringBoard. * Example: november_sale_post */ -- (NSString *)campaign; -- (void)setCampaign:(NSString *)aCampaign; +@property (NS_NONATOMIC_IOSONLY, copy) NSString *campaign; /*! * Used for advanced and atypical store configuration options. */ -- (NSString *)option; -- (void)setOption:(NSString *)anOption; +@property (NS_NONATOMIC_IOSONLY, copy) NSString *option; /*! * Pass a custom referrer via the URL to override the automatically detected referring URL (HTTP_REFERER). @@ -86,23 +78,20 @@ extern NSString * const kFsprgModeTest; * passed in this parameter then no data will be stored from the HTTP_REFERER header. * Example: xyz123 */ -- (NSString *)referrer; -- (void)setReferrer:(NSString *)aReferrer; +@property (NS_NONATOMIC_IOSONLY, copy) NSString *referrer; /*! * Used for "External Tracking". Go to "Link Sources" inside SpringBoard. * Example: my_blog */ -- (NSString *)source; -- (void)setSource:(NSString *)aSource; +@property (NS_NONATOMIC_IOSONLY, copy) NSString *source; /*! * Pass a coupon code via the URL to automatically apply a coupon to the order so that the customer * does not need to enter it. A corresponding coupon code must be setup and associated with a promotion. * Example: DECSPECIAL987 */ -- (NSString *)coupon; -- (void)setCoupon:(NSString *)aCoupon; +@property (NS_NONATOMIC_IOSONLY, copy) NSString *coupon; /*! * This parameter has many uses within SpringBoard. A tag is a variable that can hold any positive integer value. @@ -111,19 +100,13 @@ extern NSString * const kFsprgModeTest; * * mytaga,mytagb,mytagc=2,anothertag=8 */ -- (NSString *)tags; -- (void)setTags:(NSString *)aTags; - -- (BOOL)hasContactDefaults; -- (NSString *)contactFname; -- (void)setContactFname:(NSString *)aContactFname; -- (NSString *)contactLname; -- (void)setContactLname:(NSString *)aContactLname; -- (NSString *)contactEmail; -- (void)setContactEmail:(NSString *)aContactEmail; -- (NSString *)contactCompany; -- (void)setContactCompany:(NSString *)aContactCompany; -- (NSString *)contactPhone; -- (void)setContactPhone:(NSString *)aContactPhone; +@property (NS_NONATOMIC_IOSONLY, copy) NSString *tags; + +@property (NS_NONATOMIC_IOSONLY, readonly) BOOL hasContactDefaults; +@property (NS_NONATOMIC_IOSONLY, copy) NSString *contactFname; +@property (NS_NONATOMIC_IOSONLY, copy) NSString *contactLname; +@property (NS_NONATOMIC_IOSONLY, copy) NSString *contactEmail; +@property (NS_NONATOMIC_IOSONLY, copy) NSString *contactCompany; +@property (NS_NONATOMIC_IOSONLY, copy) NSString *contactPhone; @end diff --git a/FsprgEmbeddedStore/FsprgStoreParameters.m b/FsprgEmbeddedStore/FsprgStoreParameters.m index caede0a..4811091 100755 --- a/FsprgEmbeddedStore/FsprgStoreParameters.m +++ b/FsprgEmbeddedStore/FsprgStoreParameters.m @@ -5,6 +5,10 @@ // Created by Lars Steiger on 2/19/10. // Copyright 2010 FastSpring. All rights reserved. // +// Updated by Pascal Harris 10/10/2026. +// Updated to work with macOS 26 'Tahoe', removing +// deprecations and fixing (most) static analysis +// and compiler warnings. #import "FsprgStoreParameters.h" @@ -39,7 +43,7 @@ @implementation FsprgStoreParameters + (void)initialize { - keyPathsForValuesAffecting = [[NSMutableDictionary dictionaryWithCapacity:1] retain]; + keyPathsForValuesAffecting = [NSMutableDictionary dictionaryWithCapacity:1]; NSSet *toURLSet = [NSSet setWithObjects:NSStringFromSelector(@selector(language)), NSStringFromSelector(@selector(orderProcessType)), @@ -57,7 +61,7 @@ + (void)initialize NSStringFromSelector(@selector(contactCompany)), NSStringFromSelector(@selector(contactPhone)), nil]; - [keyPathsForValuesAffecting setObject:toURLSet forKey:NSStringFromSelector(@selector(toURL))]; + keyPathsForValuesAffecting[NSStringFromSelector(@selector(toURL))] = toURLSet; } + (FsprgStoreParameters *)parameters @@ -81,31 +85,35 @@ + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key } } -- (id)initWithRaw:(NSMutableDictionary *)aRaw +- (instancetype)init +{ + return [self initWithRaw:[NSMutableDictionary dictionary]]; +} + +- (instancetype)initWithRaw:(NSMutableDictionary *)aRaw { self = [super init]; if (self != nil) { - [self setRaw:aRaw]; + self.raw = aRaw; } return self; } - (NSMutableDictionary *)raw { - return [[raw retain] autorelease]; + return raw; } - (void)setRaw:(NSMutableDictionary *)aRaw { if (raw != aRaw) { - [raw release]; - raw = [aRaw retain]; + raw = aRaw; } } - (NSURLRequest *)toURLRequest { - NSURL *toURL = [self toURL]; + NSURL *toURL = self.toURL; if (toURL) { return [NSMutableURLRequest requestWithURL:toURL]; } else { @@ -115,50 +123,50 @@ - (NSURLRequest *)toURLRequest - (NSURL *)toURL { - NSString *storeIdEncoded = [[self storeId] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + NSString *storeIdEncoded = [self.storeId stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet]; if(storeIdEncoded == nil) { storeIdEncoded = @""; } - NSString *productIdEncoded = [[self productId] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + NSString *productIdEncoded = [self.productId stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet]; if(productIdEncoded == nil) { productIdEncoded = @""; } NSString *urlAsStr; - if([kFsprgOrderProcessDetail isEqualTo:[self orderProcessType]]) { + if([kFsprgOrderProcessDetail isEqualTo:self.orderProcessType]) { NSString *protocol = @"http"; - if([self hasContactDefaults]) { + if(self.hasContactDefaults) { protocol = @"https"; } urlAsStr = [NSString stringWithFormat:@"%@://sites.fastspring.com/%@/product/%@", protocol, storeIdEncoded, productIdEncoded]; - } else if([kFsprgOrderProcessInstant isEqualTo:[self orderProcessType]]) { + } else if([kFsprgOrderProcessInstant isEqualTo:self.orderProcessType]) { urlAsStr = [NSString stringWithFormat:@"https://sites.fastspring.com/%@/instant/%@", storeIdEncoded, productIdEncoded]; - } else if ([kFsprgOrderProcessCheckout isEqualTo:[self orderProcessType]]) { + } else if ([kFsprgOrderProcessCheckout isEqualTo:self.orderProcessType]) { urlAsStr = [NSString stringWithFormat:@"https://sites.fastspring.com/%@/checkout/%@", storeIdEncoded, productIdEncoded]; } else { NSAssert1(FALSE, @"OrderProcessType '%@' unknown.", [self orderProcessType]); return nil; } - NSMutableArray *keys = [NSMutableArray arrayWithArray:[[self raw] allKeys]]; + NSMutableArray *keys = [NSMutableArray arrayWithArray:self.raw.allKeys]; [keys removeObject:kOrderProcessType]; [keys removeObject:kStoreId]; [keys removeObject:kProductId]; [keys sortUsingSelector:@selector(compare:)]; NSString *queryStr = @""; - NSUInteger i, count = [keys count]; + NSUInteger i, count = keys.count; for (i = 0; i < count; i++) { - NSString *key = [keys objectAtIndex:i]; - NSString *value = [[self raw] valueForKey:key]; + NSString *key = keys[i]; + NSString *value = [self.raw valueForKey:key]; if(value != nil) { queryStr = [queryStr stringByAppendingFormat:@"&%@=%@", key, - [value stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; + [value stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet]]; } } - if([queryStr length] > 0) { + if(queryStr.length > 0) { urlAsStr = [NSString stringWithFormat:@"%@?%@", urlAsStr, [queryStr substringFromIndex:1]]; } @@ -168,15 +176,15 @@ - (NSURL *)toURL - (void)setObject:(NSString *)anObject forKey:(NSString *)aKey { if(anObject == nil) { - [[self raw] removeObjectForKey:aKey]; + [self.raw removeObjectForKey:aKey]; } else { - [[self raw] setObject:anObject forKey:aKey]; + self.raw[aKey] = anObject; } } - (NSString *)language { - return [[self raw] objectForKey:kLanguage]; + return self.raw[kLanguage]; } - (void)setLanguage:(NSString *)aLanguage @@ -186,7 +194,7 @@ - (void)setLanguage:(NSString *)aLanguage - (NSString *)orderProcessType { - return [[self raw] objectForKey:kOrderProcessType]; + return self.raw[kOrderProcessType]; } - (void)setOrderProcessType:(NSString *)anOrderProcessType { @@ -195,13 +203,13 @@ - (void)setOrderProcessType:(NSString *)anOrderProcessType - (void)setStoreId:(NSString *)aStoreId withProductId:(NSString *)aProductId { - [self setStoreId:aStoreId]; - [self setProductId:aProductId]; + self.storeId = aStoreId; + self.productId = aProductId; } - (NSString *)storeId { - return [[self raw] objectForKey:kStoreId]; + return self.raw[kStoreId]; } - (void)setStoreId:(NSString *)aStoreId { @@ -210,7 +218,7 @@ - (void)setStoreId:(NSString *)aStoreId - (NSString *)productId { - return [[self raw] objectForKey:kProductId]; + return self.raw[kProductId]; } - (void)setProductId:(NSString *)aProductId { @@ -219,7 +227,7 @@ - (void)setProductId:(NSString *)aProductId - (NSString *)mode { - return [[self raw] objectForKey:kMode]; + return self.raw[kMode]; } - (void)setMode:(NSString *)aMode { @@ -228,7 +236,7 @@ - (void)setMode:(NSString *)aMode - (NSString *)campaign { - return [[self raw] objectForKey:kCampaign]; + return self.raw[kCampaign]; } - (void)setCampaign:(NSString *)aCampaign { @@ -237,7 +245,7 @@ - (void)setCampaign:(NSString *)aCampaign - (NSString *)option { - return [[self raw] objectForKey:kOption]; + return self.raw[kOption]; } - (void)setOption:(NSString *)anOption { @@ -246,7 +254,7 @@ - (void)setOption:(NSString *)anOption - (NSString *)referrer { - return [[self raw] objectForKey:kReferrer]; + return self.raw[kReferrer]; } - (void)setReferrer:(NSString *)aReferrer { @@ -255,7 +263,7 @@ - (void)setReferrer:(NSString *)aReferrer - (NSString *)source { - return [[self raw] objectForKey:kSource]; + return self.raw[kSource]; } - (void)setSource:(NSString *)aSource { @@ -264,7 +272,7 @@ - (void)setSource:(NSString *)aSource - (NSString *)coupon { - return [[self raw] objectForKey:kCoupon]; + return self.raw[kCoupon]; } - (void)setCoupon:(NSString *)aCoupon { @@ -273,7 +281,7 @@ - (void)setCoupon:(NSString *)aCoupon - (NSString *)tags { - return [[self raw] objectForKey:kTags]; + return self.raw[kTags]; } - (void)setTags:(NSString *)aTags { @@ -282,7 +290,7 @@ - (void)setTags:(NSString *)aTags - (BOOL)hasContactDefaults { - NSArray *allKeys = [[self raw] allKeys]; + NSArray *allKeys = self.raw.allKeys; return [allKeys containsObject:kContactFname] || [allKeys containsObject:kContactLname] || @@ -293,7 +301,7 @@ - (BOOL)hasContactDefaults - (NSString *)contactFname { - return [[self raw] objectForKey:kContactFname]; + return self.raw[kContactFname]; } - (void)setContactFname:(NSString *)aContactFname { @@ -302,7 +310,7 @@ - (void)setContactFname:(NSString *)aContactFname - (NSString *)contactLname { - return [[self raw] objectForKey:kContactLname]; + return self.raw[kContactLname]; } - (void)setContactLname:(NSString *)aContactLname { @@ -311,7 +319,7 @@ - (void)setContactLname:(NSString *)aContactLname - (NSString *)contactEmail { - return [[self raw] objectForKey:kContactEmail]; + return self.raw[kContactEmail]; } - (void)setContactEmail:(NSString *)aContactEmail { @@ -320,7 +328,7 @@ - (void)setContactEmail:(NSString *)aContactEmail - (NSString *)contactCompany { - return [[self raw] objectForKey:kContactCompany]; + return self.raw[kContactCompany]; } - (void)setContactCompany:(NSString *)aContactCompany { @@ -329,7 +337,7 @@ - (void)setContactCompany:(NSString *)aContactCompany - (NSString *)contactPhone { - return [[self raw] objectForKey:kContactPhone]; + return self.raw[kContactPhone]; } - (void)setContactPhone:(NSString *)aContactPhone { @@ -339,8 +347,7 @@ - (void)setContactPhone:(NSString *)aContactPhone - (void)dealloc { [self setRaw:nil]; - - [super dealloc]; + [super dealloc]; // pgh } @end diff --git a/FsprgEmbeddedStore/Model/FsprgFileDownload.h b/FsprgEmbeddedStore/Model/FsprgFileDownload.h index 793baac..c7241d0 100644 --- a/FsprgEmbeddedStore/Model/FsprgFileDownload.h +++ b/FsprgEmbeddedStore/Model/FsprgFileDownload.h @@ -19,10 +19,9 @@ + (FsprgFileDownload *)fileDownloadWithDictionary:(NSDictionary *)aDictionary; -- (FsprgFileDownload *)initWithDictionary:(NSDictionary *)aDictionary; -- (NSDictionary *)raw; -- (void)setRaw:(NSDictionary *)aDictionary; +- (instancetype)initWithDictionary:(NSDictionary *)aDictionary NS_DESIGNATED_INITIALIZER; +@property (NS_NONATOMIC_IOSONLY, copy) NSDictionary *raw; -- (NSURL *)fileURL; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSURL *fileURL; @end diff --git a/FsprgEmbeddedStore/Model/FsprgFileDownload.m b/FsprgEmbeddedStore/Model/FsprgFileDownload.m index f36825f..72228ae 100644 --- a/FsprgEmbeddedStore/Model/FsprgFileDownload.m +++ b/FsprgEmbeddedStore/Model/FsprgFileDownload.m @@ -5,6 +5,10 @@ // Created by Lars Steiger on 2/24/10. // Copyright 2010 FastSpring. All rights reserved. // +// Updated by Pascal Harris 10/10/2026. +// Updated to work with macOS 26 'Tahoe', removing +// deprecations and fixing (most) static analysis +// and compiler warnings. #import "FsprgFileDownload.h" @@ -16,29 +20,35 @@ + (FsprgFileDownload *)fileDownloadWithDictionary:(NSDictionary *)aDictionary return [[[FsprgFileDownload alloc] initWithDictionary:aDictionary] autorelease]; } -- (FsprgFileDownload *)initWithDictionary:(NSDictionary *)aDictionary +- (instancetype)init +{ + return [self initWithDictionary:@{}]; +} + +- (instancetype)initWithDictionary:(NSDictionary *)aDictionary { self = [super init]; if (self != nil) { - [self setRaw:aDictionary]; + self.raw = aDictionary; } return self; } + - (NSDictionary *)raw { - return [[raw retain] autorelease]; + return raw; } + - (void)setRaw:(NSDictionary *)aDictionary { if (raw != aDictionary) { - [raw release]; - raw = [aDictionary retain]; + raw = aDictionary; } } - (NSURL *)fileURL { - return [NSURL URLWithString:[[self raw] valueForKey:@"FileURL"]]; + return [NSURL URLWithString:[self.raw valueForKey:@"FileURL"]]; } + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key @@ -50,8 +60,7 @@ + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key - (void)dealloc { [self setRaw:nil]; - - [super dealloc]; + [super dealloc]; //pgh } @end diff --git a/FsprgEmbeddedStore/Model/FsprgFulfillment.h b/FsprgEmbeddedStore/Model/FsprgFulfillment.h index de932b2..0a89667 100644 --- a/FsprgEmbeddedStore/Model/FsprgFulfillment.h +++ b/FsprgEmbeddedStore/Model/FsprgFulfillment.h @@ -19,9 +19,8 @@ + (FsprgFulfillment *)fulfillmentWithDictionary:(NSDictionary *)aDictionary; -- (FsprgFulfillment *)initWithDictionary:(NSDictionary *)aDictionary; -- (NSDictionary *)raw; -- (void)setRaw:(NSDictionary *)aDictionary; +- (instancetype)initWithDictionary:(NSDictionary *)aDictionary NS_DESIGNATED_INITIALIZER; +@property (NS_NONATOMIC_IOSONLY, copy) NSDictionary *raw; /*! * @param aKey type of fulfillment (e.g. license, download) diff --git a/FsprgEmbeddedStore/Model/FsprgFulfillment.m b/FsprgEmbeddedStore/Model/FsprgFulfillment.m index 1745458..621e3a1 100644 --- a/FsprgEmbeddedStore/Model/FsprgFulfillment.m +++ b/FsprgEmbeddedStore/Model/FsprgFulfillment.m @@ -5,6 +5,10 @@ // Created by Lars Steiger on 2/24/10. // Copyright 2010 FastSpring. All rights reserved. // +// Updated by Pascal Harris 10/10/2026. +// Updated to work with macOS 26 'Tahoe', removing +// deprecations and fixing (most) static analysis +// and compiler warnings. #import "FsprgFulfillment.h" #import "FsprgLicense.h" @@ -18,30 +22,35 @@ + (FsprgFulfillment *)fulfillmentWithDictionary:(NSDictionary *)aDictionary return [[[FsprgFulfillment alloc] initWithDictionary:aDictionary] autorelease]; } -- (FsprgFulfillment *)initWithDictionary:(NSDictionary *)aDictionary +- (instancetype)init +{ + return [self initWithDictionary:@{}]; +} + +- (instancetype)initWithDictionary:(NSDictionary *)aDictionary { self = [super init]; if (self != nil) { - [self setRaw:aDictionary]; + self.raw = aDictionary; } return self; } + - (NSDictionary *)raw { - return [[raw retain] autorelease]; + return raw; } - (void)setRaw:(NSDictionary *)aDictionary { if (raw != aDictionary) { - [raw release]; - raw = [aDictionary retain]; + raw = aDictionary; } } - (id)valueForKey:(NSString *)aKey { - NSDictionary *anItem = [[self raw] valueForKey:aKey]; + NSDictionary *anItem = [self.raw valueForKey:aKey]; if([[anItem valueForKey:@"FulfillmentType"] isEqual:@"License"]) { return [FsprgLicense licenseWithDictionary:anItem]; @@ -62,8 +71,7 @@ + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key - (void)dealloc { [self setRaw:nil]; - - [super dealloc]; + [super dealloc]; //pgh } @end diff --git a/FsprgEmbeddedStore/Model/FsprgLicense.h b/FsprgEmbeddedStore/Model/FsprgLicense.h index 27a1e7d..ac83133 100644 --- a/FsprgEmbeddedStore/Model/FsprgLicense.h +++ b/FsprgEmbeddedStore/Model/FsprgLicense.h @@ -19,16 +19,15 @@ + (FsprgLicense *)licenseWithDictionary:(NSDictionary *)aDictionary; -- (FsprgLicense *)initWithDictionary:(NSDictionary *)aDictionary; -- (NSDictionary *)raw; -- (void)setRaw:(NSDictionary *)aDictionary; +- (instancetype)initWithDictionary:(NSDictionary *)aDictionary NS_DESIGNATED_INITIALIZER; +@property (NS_NONATOMIC_IOSONLY, copy) NSDictionary *raw; -- (NSString *)licenseName; -- (NSString *)licenseEmail; -- (NSString *)licenseCompany; -- (NSString *)firstLicenseCode; -- (NSArray *)licenseCodes; -- (NSDictionary *)licensePropertyList; -- (NSURL *)licenseURL; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *licenseName; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *licenseEmail; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *licenseCompany; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *firstLicenseCode; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *licenseCodes; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSDictionary *licensePropertyList; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSURL *licenseURL; @end diff --git a/FsprgEmbeddedStore/Model/FsprgLicense.m b/FsprgEmbeddedStore/Model/FsprgLicense.m index 0bd919c..d1bfbdd 100644 --- a/FsprgEmbeddedStore/Model/FsprgLicense.m +++ b/FsprgEmbeddedStore/Model/FsprgLicense.m @@ -5,6 +5,10 @@ // Created by Lars Steiger on 2/24/10. // Copyright 2010 FastSpring. All rights reserved. // +// Updated by Pascal Harris 10/10/2026. +// Updated to work with macOS 26 'Tahoe', removing +// deprecations and fixing (most) static analysis +// and compiler warnings. #import "FsprgLicense.h" @@ -16,60 +20,64 @@ + (FsprgLicense *)licenseWithDictionary:(NSDictionary *)aDictionary return [[[FsprgLicense alloc] initWithDictionary:aDictionary] autorelease]; } -- (FsprgLicense *)initWithDictionary:(NSDictionary *)aDictionary +- (instancetype)init +{ + return [self initWithDictionary:@{}]; +} + +- (instancetype)initWithDictionary:(NSDictionary *)aDictionary { self = [super init]; if (self != nil) { - [self setRaw:aDictionary]; + self.raw = aDictionary; } return self; } - (NSDictionary *)raw { - return [[raw retain] autorelease]; + return raw; } - (void)setRaw:(NSDictionary *)aDictionary { if (raw != aDictionary) { - [raw release]; - raw = [aDictionary retain]; + raw = aDictionary; } } - (NSString *)licenseName { - return [[self raw] valueForKey:@"LicenseName"]; + return [self.raw valueForKey:@"LicenseName"]; } - (NSString *)licenseEmail { - return [[self raw] valueForKey:@"LicenseEmail"]; + return [self.raw valueForKey:@"LicenseEmail"]; } - (NSString *)licenseCompany { - return [[self raw] valueForKey:@"LicenseCompany"]; + return [self.raw valueForKey:@"LicenseCompany"]; } - (NSString *)firstLicenseCode { - return [[self licenseCodes] objectAtIndex:0]; + return self.licenseCodes[0]; } - (NSArray *)licenseCodes { - return [[self raw] valueForKey:@"LicenseCodes"]; + return [self.raw valueForKey:@"LicenseCodes"]; } - (NSDictionary *)licensePropertyList { - return [[self raw] valueForKey:@"LicensePropertyList"]; + return [self.raw valueForKey:@"LicensePropertyList"]; } - (NSURL *)licenseURL { - return [NSURL URLWithString:[[self raw] valueForKey:@"LicenseURL"]]; + return [NSURL URLWithString:[self.raw valueForKey:@"LicenseURL"]]; } + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key @@ -81,8 +89,7 @@ + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key - (void)dealloc { [self setRaw:nil]; - - [super dealloc]; + [super dealloc]; //pgh } @end diff --git a/FsprgEmbeddedStore/Model/FsprgOrder.h b/FsprgEmbeddedStore/Model/FsprgOrder.h index 23f0ab5..64ddc76 100644 --- a/FsprgEmbeddedStore/Model/FsprgOrder.h +++ b/FsprgEmbeddedStore/Model/FsprgOrder.h @@ -20,26 +20,25 @@ + (FsprgOrder *)orderFromData:(NSData *)aData; -- (FsprgOrder *)initWithDictionary:(NSDictionary *)aDictionary; -- (NSDictionary *)raw; -- (void)setRaw:(NSDictionary *)aDictionary; - -- (BOOL)orderIsTest; -- (NSString *)orderReference; -- (NSString *)orderLanguage; -- (NSString *)orderCurrency; -- (NSNumber *)orderTotal; -- (NSNumber *)orderTotalUSD; -- (NSString *)customerFirstName; -- (NSString *)customerLastName; -- (NSString *)customerCompany; -- (NSString *)customerEmail; +- (instancetype)initWithDictionary:(NSDictionary *)aDictionary NS_DESIGNATED_INITIALIZER; +@property (NS_NONATOMIC_IOSONLY, copy) NSDictionary *raw; + +@property (NS_NONATOMIC_IOSONLY, readonly) BOOL orderIsTest; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *orderReference; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *orderLanguage; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *orderCurrency; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSNumber *orderTotal; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSNumber *orderTotalUSD; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *customerFirstName; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *customerLastName; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *customerCompany; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *customerEmail; /*! * Shortcut for [[self orderItems] objectAtIndex:0]. * @result First item. */ -- (FsprgOrderItem *)firstOrderItem; -- (NSArray *)orderItems; +@property (NS_NONATOMIC_IOSONLY, readonly, strong) FsprgOrderItem *firstOrderItem; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *orderItems; @end diff --git a/FsprgEmbeddedStore/Model/FsprgOrder.m b/FsprgEmbeddedStore/Model/FsprgOrder.m index 2164f8e..b3292c0 100644 --- a/FsprgEmbeddedStore/Model/FsprgOrder.m +++ b/FsprgEmbeddedStore/Model/FsprgOrder.m @@ -5,6 +5,10 @@ // Created by Lars Steiger on 2/12/10. // Copyright 2010 FastSpring. All rights reserved. // +// Updated by Pascal Harris 10/10/2026. +// Updated to work with macOS 26 'Tahoe', removing +// deprecations and fixing (most) static analysis +// and compiler warnings. #import "FsprgOrder.h" @@ -14,108 +18,105 @@ @implementation FsprgOrder + (FsprgOrder *)orderFromData:(NSData *)aData { NSPropertyListFormat *format = nil; - NSString *errorDesc = nil; - -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 - NSDictionary *aDict = [NSPropertyListSerialization propertyListFromData:aData - mutabilityOption:NSPropertyListImmutable - format:format - errorDescription:&errorDesc]; - -#else + NSDictionary *aDict = [NSPropertyListSerialization propertyListWithData:aData options:NSPropertyListImmutable format:format error:nil]; -#endif - - return [[[FsprgOrder alloc] initWithDictionary:aDict] autorelease]; + + return [[[FsprgOrder alloc] initWithDictionary:aDict] autorelease]; +} + +- (instancetype)init +{ + return [self initWithDictionary:@{}]; } -- (FsprgOrder *)initWithDictionary:(NSDictionary *)aDictionary +- (instancetype)initWithDictionary:(NSDictionary *)aDictionary { self = [super init]; if (self != nil) { - [self setRaw:aDictionary]; + self.raw = aDictionary; } return self; -} +} + - (NSDictionary *)raw { - return [[raw retain] autorelease]; + return raw; } + - (void)setRaw:(NSDictionary *)aDictionary { if (raw != aDictionary) { - [raw release]; - raw = [aDictionary retain]; + raw = aDictionary; } } - (BOOL)orderIsTest { - return [[[self raw] valueForKey:@"OrderIsTest"] boolValue]; + return [[self.raw valueForKey:@"OrderIsTest"] boolValue]; } - (NSString *)orderReference { - return [[self raw] valueForKey:@"OrderReference"]; + return [self.raw valueForKey:@"OrderReference"]; } - (NSString *)orderLanguage { - return [[self raw] valueForKey:@"OrderLanguage"]; + return [self.raw valueForKey:@"OrderLanguage"]; } - (NSString *)orderCurrency { - return [[self raw] valueForKey:@"OrderCurrency"]; + return [self.raw valueForKey:@"OrderCurrency"]; } - (NSNumber *)orderTotal { - return [[self raw] valueForKey:@"OrderTotal"]; + return [self.raw valueForKey:@"OrderTotal"]; } - (NSNumber *)orderTotalUSD { - return [[self raw] valueForKey:@"OrderTotalUSD"]; + return [self.raw valueForKey:@"OrderTotalUSD"]; } - (NSString *)customerFirstName { - return [[self raw] valueForKey:@"CustomerFirstName"]; + return [self.raw valueForKey:@"CustomerFirstName"]; } - (NSString *)customerLastName { - return [[self raw] valueForKey:@"CustomerLastName"]; + return [self.raw valueForKey:@"CustomerLastName"]; } - (NSString *)customerCompany { - return [[self raw] valueForKey:@"CustomerCompany"]; + return [self.raw valueForKey:@"CustomerCompany"]; } - (NSString *)customerEmail { - return [[self raw] valueForKey:@"CustomerEmail"]; + return [self.raw valueForKey:@"CustomerEmail"]; } - (FsprgOrderItem *)firstOrderItem { - NSArray *items = [[self raw] valueForKey:@"OrderItems"]; - return [FsprgOrderItem itemWithDictionary:[items objectAtIndex:0]]; + NSArray *items = [self.raw valueForKey:@"OrderItems"]; + return [FsprgOrderItem itemWithDictionary:items[0]]; } - (NSArray *)orderItems { - NSArray *items = [[self raw] valueForKey:@"OrderItems"]; - NSMutableArray *orderItems = [NSMutableArray arrayWithCapacity:[items count]]; + NSArray *items = [self.raw valueForKey:@"OrderItems"]; + NSMutableArray *orderItems = [NSMutableArray arrayWithCapacity:items.count]; - NSUInteger i, count = [items count]; + NSUInteger i, count = items.count; for (i = 0; i < count; i++) { - NSDictionary *anItem = [items objectAtIndex:i]; + NSDictionary *anItem = items[i]; [orderItems addObject:[FsprgOrderItem itemWithDictionary:anItem]]; } @@ -131,8 +132,7 @@ + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key - (void)dealloc { [self setRaw:nil]; - - [super dealloc]; + [super dealloc]; //pgh } @end diff --git a/FsprgEmbeddedStore/Model/FsprgOrderItem.h b/FsprgEmbeddedStore/Model/FsprgOrderItem.h index f71ee07..c7d5526 100644 --- a/FsprgEmbeddedStore/Model/FsprgOrderItem.h +++ b/FsprgEmbeddedStore/Model/FsprgOrderItem.h @@ -22,39 +22,38 @@ + (FsprgOrderItem *)itemWithDictionary:(NSDictionary *)aDictionary; -- (FsprgOrderItem *)initWithDictionary:(NSDictionary *)aDictionary; -- (NSDictionary *)raw; -- (void)setRaw:(NSDictionary *)aDictionary; +- (instancetype)initWithDictionary:(NSDictionary *)aDictionary NS_DESIGNATED_INITIALIZER; +@property (NS_NONATOMIC_IOSONLY, copy) NSDictionary *raw; -- (NSString *)productName; -- (NSString *)productDisplay; -- (NSNumber *)quantity; -- (NSNumber *)itemTotal; -- (NSNumber *)itemTotalUSD; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *productName; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *productDisplay; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSNumber *quantity; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSNumber *itemTotal; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSNumber *itemTotalUSD; /*! * This reference can be used to make calls to FastSpring's Subscription API. * See https://support.fastspring.com/entries/236487-api-subscriptions */ -- (NSString *)subscriptionReference; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *subscriptionReference; /*! * This URL can be presented to the customer to manage their subscription. */ -- (NSURL *)subscriptionCustomerURL; +@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSURL *subscriptionCustomerURL; -- (FsprgFulfillment *)fulfillment; +@property (NS_NONATOMIC_IOSONLY, readonly, strong) FsprgFulfillment *fulfillment; /*! * Shortcut for [[self fulfillment] valueForKey:@"license"]. * @result License information. */ -- (FsprgLicense *)license; +@property (NS_NONATOMIC_IOSONLY, readonly, strong) FsprgLicense *license; /*! * Shortcut for [[self fulfillment] valueForKey:@"download"]. * @result Download information. */ -- (FsprgFileDownload *)download; +@property (NS_NONATOMIC_IOSONLY, readonly, strong) FsprgFileDownload *download; @end diff --git a/FsprgEmbeddedStore/Model/FsprgOrderItem.m b/FsprgEmbeddedStore/Model/FsprgOrderItem.m index 9a13cf2..4aa2126 100644 --- a/FsprgEmbeddedStore/Model/FsprgOrderItem.m +++ b/FsprgEmbeddedStore/Model/FsprgOrderItem.m @@ -5,6 +5,10 @@ // Created by Lars Steiger on 2/24/10. // Copyright 2010 FastSpring. All rights reserved. // +// Updated by Pascal Harris 10/10/2026. +// Updated to work with macOS 26 'Tahoe', removing +// deprecations and fixing (most) static analysis +// and compiler warnings. #import "FsprgOrderItem.h" @@ -16,75 +20,80 @@ + (FsprgOrderItem *)itemWithDictionary:(NSDictionary *)aDictionary return [[[FsprgOrderItem alloc] initWithDictionary:aDictionary] autorelease]; } -- (FsprgOrderItem *)initWithDictionary:(NSDictionary *)aDictionary +- (instancetype)init +{ + return [self initWithDictionary:@{}]; +} + +- (instancetype)initWithDictionary:(NSDictionary *)aDictionary { self = [super init]; if (self != nil) { - [self setRaw:aDictionary]; + self.raw = aDictionary; } return self; } + - (NSDictionary *)raw { - return [[raw retain] autorelease]; + return raw; } - (void)setRaw:(NSDictionary *)aDictionary { if (raw != aDictionary) { - [raw release]; - raw = [aDictionary retain]; + raw = aDictionary; } } - (NSString *)productName { - return [[self raw] valueForKey:@"ProductName"]; + return [self.raw valueForKey:@"ProductName"]; } - (NSString *)productDisplay { - return [[self raw] valueForKey:@"ProductDisplay"]; + return [self.raw valueForKey:@"ProductDisplay"]; } - (NSNumber *)quantity { - return [[self raw] valueForKey:@"Quantity"]; + return [self.raw valueForKey:@"Quantity"]; } - (NSNumber *)itemTotal { - return [[self raw] valueForKey:@"ItemTotal"]; + return [self.raw valueForKey:@"ItemTotal"]; } - (NSNumber *)itemTotalUSD { - return [[self raw] valueForKey:@"ItemTotalUSD"]; + return [self.raw valueForKey:@"ItemTotalUSD"]; } - (NSString *)subscriptionReference { - return [[self raw] valueForKey:@"SubscriptionReference"]; + return [self.raw valueForKey:@"SubscriptionReference"]; } - (NSURL *)subscriptionCustomerURL { - return [NSURL URLWithString:[[self raw] valueForKey:@"SubscriptionCustomerURL"]]; + return [NSURL URLWithString:[self.raw valueForKey:@"SubscriptionCustomerURL"]]; } - (FsprgFulfillment *)fulfillment { - return [FsprgFulfillment fulfillmentWithDictionary:[[self raw] valueForKey:@"Fulfillment"]]; + return [FsprgFulfillment fulfillmentWithDictionary:[self.raw valueForKey:@"Fulfillment"]]; } - (FsprgLicense *)license { - return [[self fulfillment] valueForKey:@"license"]; + return [self.fulfillment valueForKey:@"license"]; } - (FsprgFileDownload *)download { - return [[self fulfillment] valueForKey:@"download"]; + return [self.fulfillment valueForKey:@"download"]; } + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key @@ -96,8 +105,7 @@ + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key - (void)dealloc { [self setRaw:nil]; - - [super dealloc]; + [super dealloc]; //pgh } @end diff --git a/README.mdown b/README.mdown index cd6b890..539bcf9 100644 --- a/README.mdown +++ b/README.mdown @@ -6,7 +6,7 @@ FastSpring's embedded store consists of a controller with some integration point To get an idea of how it works, the SDK provides two examples and a test application. All source code is released under the MIT license. It is open to contributions and its use is unrestricted. See RELEASE_NOTES.html for the latest changes. - +Updated to work with macOS 26, removing deprecations and fixing compiler warnings by Pascal Harris, # FsprgEmbeddedStore #