From 6a2c251d454f6960d0ade3ba201802b4af4cb433 Mon Sep 17 00:00:00 2001 From: Eitot Date: Wed, 10 May 2023 22:21:38 +0200 Subject: [PATCH 1/5] Convert global variables into constants --- Vienna/Sources/Database/Field.m | 14 +-- Vienna/Sources/Download window/DownloadItem.m | 4 +- Vienna/Sources/Fetching/OpenReader.m | 4 +- Vienna/Sources/Models/Article.h | 42 ++++--- Vienna/Sources/Models/Article.m | 36 +++--- Vienna/Sources/Shared/Constants.h | 118 +++++++++--------- Vienna/Sources/Shared/Constants.m | 116 ++++++++--------- 7 files changed, 169 insertions(+), 165 deletions(-) diff --git a/Vienna/Sources/Database/Field.m b/Vienna/Sources/Database/Field.m index 072d582b3e..cac2b44bf2 100644 --- a/Vienna/Sources/Database/Field.m +++ b/Vienna/Sources/Database/Field.m @@ -20,13 +20,13 @@ #import "Field.h" -static NSString *const VNACodingKeyDisplayName = @"displayName"; -static NSString *const VNACodingKeyName = @"name"; -static NSString *const VNACodingKeySQLField = @"sqlField"; -static NSString *const VNACodingKeyTag = @"tag"; -static NSString *const VNACodingKeyType = @"type"; -static NSString *const VNACodingKeyVisible = @"visible"; -static NSString *const VNACodingKeyWidth = @"width"; +static NSString * const VNACodingKeyDisplayName = @"displayName"; +static NSString * const VNACodingKeyName = @"name"; +static NSString * const VNACodingKeySQLField = @"sqlField"; +static NSString * const VNACodingKeyTag = @"tag"; +static NSString * const VNACodingKeyType = @"type"; +static NSString * const VNACodingKeyVisible = @"visible"; +static NSString * const VNACodingKeyWidth = @"width"; @implementation Field diff --git a/Vienna/Sources/Download window/DownloadItem.m b/Vienna/Sources/Download window/DownloadItem.m index 95d55a2893..a291c1e9a4 100644 --- a/Vienna/Sources/Download window/DownloadItem.m +++ b/Vienna/Sources/Download window/DownloadItem.m @@ -22,8 +22,8 @@ @import UniformTypeIdentifiers; -static NSString *const VNACodingKeyFilename = @"filename"; -static NSString *const VNACodingKeySize = @"size"; +static NSString * const VNACodingKeyFilename = @"filename"; +static NSString * const VNACodingKeySize = @"size"; @interface DownloadItem () diff --git a/Vienna/Sources/Fetching/OpenReader.m b/Vienna/Sources/Fetching/OpenReader.m index 59d4e9f9d3..4a134f820b 100644 --- a/Vienna/Sources/Fetching/OpenReader.m +++ b/Vienna/Sources/Fetching/OpenReader.m @@ -42,8 +42,8 @@ #import "ActivityItem.h" #import "Article.h" -static NSString *LoginBaseURL = @"%@://%@/accounts/ClientLogin?accountType=GOOGLE&service=reader"; -static NSString *ClientName = @"ViennaRSS"; +static NSString * const LoginBaseURL = @"%@://%@/accounts/ClientLogin?accountType=GOOGLE&service=reader"; +static NSString * const ClientName = @"ViennaRSS"; static NSString *latestAlertDescription = @""; // host specific variables diff --git a/Vienna/Sources/Models/Article.h b/Vienna/Sources/Models/Article.h index d65370f7de..a9ac205b9f 100644 --- a/Vienna/Sources/Models/Article.h +++ b/Vienna/Sources/Models/Article.h @@ -21,27 +21,31 @@ @import Foundation; -extern NSString * _Nonnull MA_Field_GUID; -extern NSString * _Nullable MA_Field_Subject; -extern NSString * _Nullable MA_Field_Author; -extern NSString * _Nullable MA_Field_Link; -extern NSString * _Nullable MA_Field_Date; -extern NSString * _Nullable MA_Field_Read; -extern NSString * _Nullable MA_Field_Flagged; -extern NSString * _Nullable MA_Field_Comments; -extern NSString * _Nullable MA_Field_Deleted; -extern NSString * _Nullable MA_Field_Text; -extern NSString * _Nullable MA_Field_Folder; -extern NSString * _Nullable MA_Field_Parent; -extern NSString * _Nullable MA_Field_Headlines; -extern NSString * _Nullable MA_Field_Summary; -extern NSString * _Nullable MA_Field_CreatedDate; -extern NSString * _Nullable MA_Field_Enclosure; -extern NSString * _Nullable MA_Field_EnclosureDownloaded; -extern NSString * _Nullable MA_Field_HasEnclosure; - @class Folder; +NS_ASSUME_NONNULL_BEGIN + +extern NSString * const MA_Field_GUID; +extern NSString * const MA_Field_Subject; +extern NSString * const MA_Field_Author; +extern NSString * const MA_Field_Link; +extern NSString * const MA_Field_Date; +extern NSString * const MA_Field_Read; +extern NSString * const MA_Field_Flagged; +extern NSString * const MA_Field_Comments; +extern NSString * const MA_Field_Deleted; +extern NSString * const MA_Field_Text; +extern NSString * const MA_Field_Folder; +extern NSString * const MA_Field_Parent; +extern NSString * const MA_Field_Headlines; +extern NSString * const MA_Field_Summary; +extern NSString * const MA_Field_CreatedDate; +extern NSString * const MA_Field_Enclosure; +extern NSString * const MA_Field_EnclosureDownloaded; +extern NSString * const MA_Field_HasEnclosure; + +NS_ASSUME_NONNULL_END + // Article field IDs typedef NS_ENUM(NSInteger, ArticleFieldID) { ArticleFieldIDGUID = 400, diff --git a/Vienna/Sources/Models/Article.m b/Vienna/Sources/Models/Article.m index f748afa6cc..6e3110ca7e 100644 --- a/Vienna/Sources/Models/Article.m +++ b/Vienna/Sources/Models/Article.m @@ -27,24 +27,24 @@ #import "Folder.h" // The names here are internal field names, not for localisation. -NSString * MA_Field_GUID = @"GUID"; -NSString * MA_Field_Subject = @"Subject"; -NSString * MA_Field_Author = @"Author"; -NSString * MA_Field_Link = @"Link"; -NSString * MA_Field_Date = @"Date"; -NSString * MA_Field_Comments = @"Comments"; -NSString * MA_Field_Read = @"Read"; -NSString * MA_Field_Flagged = @"Flagged"; -NSString * MA_Field_Deleted = @"Deleted"; -NSString * MA_Field_Text = @"Text"; -NSString * MA_Field_Folder = @"Folder"; -NSString * MA_Field_Parent = @"Parent"; -NSString * MA_Field_Headlines = @"Headlines"; -NSString * MA_Field_Summary = @"Summary"; -NSString * MA_Field_CreatedDate = @"CreatedDate"; -NSString * MA_Field_Enclosure = @"Enclosure"; -NSString * MA_Field_EnclosureDownloaded = @"EnclosureDownloaded"; -NSString * MA_Field_HasEnclosure = @"HasEnclosure"; +NSString * const MA_Field_GUID = @"GUID"; +NSString * const MA_Field_Subject = @"Subject"; +NSString * const MA_Field_Author = @"Author"; +NSString * const MA_Field_Link = @"Link"; +NSString * const MA_Field_Date = @"Date"; +NSString * const MA_Field_Comments = @"Comments"; +NSString * const MA_Field_Read = @"Read"; +NSString * const MA_Field_Flagged = @"Flagged"; +NSString * const MA_Field_Deleted = @"Deleted"; +NSString * const MA_Field_Text = @"Text"; +NSString * const MA_Field_Folder = @"Folder"; +NSString * const MA_Field_Parent = @"Parent"; +NSString * const MA_Field_Headlines = @"Headlines"; +NSString * const MA_Field_Summary = @"Summary"; +NSString * const MA_Field_CreatedDate = @"CreatedDate"; +NSString * const MA_Field_Enclosure = @"Enclosure"; +NSString * const MA_Field_EnclosureDownloaded = @"EnclosureDownloaded"; +NSString * const MA_Field_HasEnclosure = @"HasEnclosure"; @implementation Article diff --git a/Vienna/Sources/Shared/Constants.h b/Vienna/Sources/Shared/Constants.h index 7e15b675c8..eb34ac1b28 100644 --- a/Vienna/Sources/Shared/Constants.h +++ b/Vienna/Sources/Shared/Constants.h @@ -20,72 +20,72 @@ @import Cocoa; -extern NSString * MA_DefaultUserAgentString; -extern NSString * MA_BrowserUserAgentString; +extern NSString * const MA_DefaultUserAgentString; +extern NSString * const MA_BrowserUserAgentString; -extern NSString *const MAPref_ArticleListFont; -extern NSString * MAPref_AutoSortFoldersTree; -extern NSString * MAPref_CheckForUpdatedArticles; -extern NSString * MAPref_ShowUnreadArticlesInBold; -extern NSString * MAPref_CachedFolderID; -extern NSString * MAPref_DefaultDatabase; -extern NSString *const MAPref_DownloadsFolderBookmark; -extern NSString * MAPref_SortColumn; -extern NSString * MAPref_CheckFrequency; -extern NSString * MAPref_ArticleListColumns; -extern NSString * MAPref_CheckForNewArticlesOnStartup; -extern NSString * MAPref_ActiveStyleName; -extern NSString * MAPref_ActiveTextSizeMultiplier; -extern NSString * MAPref_FolderStates; -extern NSString * MAPref_BacktrackQueueSize; -extern NSString * MAPref_MarkReadInterval; -extern NSString * MAPref_OpenLinksInVienna; -extern NSString * MAPref_OpenLinksInBackground; -extern NSString * MAPref_MinimumFontSize; -extern NSString * MAPref_UseMinimumFontSize; -extern NSString * MAPref_AutoExpireDuration; -extern NSString *const MAPref_DownloadItemList; -extern NSString * MAPref_ShowFolderImages; -extern NSString * MAPref_UseJavaScript; -extern NSString * MAPref_CachedArticleGUID; -extern NSString *const MAPref_ArticleListSortOrders; -extern NSString * MAPref_FilterMode; -extern NSString * MAPref_LastRefreshDate; -extern NSString * MAPref_TabList; -extern NSString * MAPref_TabTitleDictionary; -extern NSString * MAPref_Layout; -extern NSString * MAPref_NewArticlesNotification; -extern NSString * MAPref_EmptyTrashNotification; -extern NSString * MAPref_ShowAppInStatusBar; -extern NSString * MAPref_ShowStatusBar; -extern NSString * MAPref_ShowFilterBar; -extern NSString * MAPref_LastViennaVersionRun; -extern NSString * MAPref_HighestViennaVersionRun; -extern NSString * MAPref_ShouldSaveFeedSource; -extern NSString * MAPref_ShouldSaveFeedSourceBackup; -extern NSString * MAPref_SearchMethod; -extern NSString * MAPref_SyncGoogleReader; -extern NSString * MAPref_GoogleNewSubscription; -extern NSString * MAPref_ConcurrentDownloads; -extern NSString * MAPref_SyncServer; -extern NSString * MAPref_SyncScheme; -extern NSString * MAPref_SyncingUser; -extern NSString * MAPref_SyncingAppId; -extern NSString * MAPref_SyncingAppKey; -extern NSString * MAPref_AlwaysAcceptBetas; -extern NSString * MAPref_UserAgentName; -extern NSString *const MAPref_UseRelativeDates; +extern NSString * const MAPref_ArticleListFont; +extern NSString * const MAPref_AutoSortFoldersTree; +extern NSString * const MAPref_CheckForUpdatedArticles; +extern NSString * const MAPref_ShowUnreadArticlesInBold; +extern NSString * const MAPref_CachedFolderID; +extern NSString * const MAPref_DefaultDatabase; +extern NSString * const MAPref_DownloadsFolderBookmark; +extern NSString * const MAPref_SortColumn; +extern NSString * const MAPref_CheckFrequency; +extern NSString * const MAPref_ArticleListColumns; +extern NSString * const MAPref_CheckForNewArticlesOnStartup; +extern NSString * const MAPref_ActiveStyleName; +extern NSString * const MAPref_ActiveTextSizeMultiplier; +extern NSString * const MAPref_FolderStates; +extern NSString * const MAPref_BacktrackQueueSize; +extern NSString * const MAPref_MarkReadInterval; +extern NSString * const MAPref_OpenLinksInVienna; +extern NSString * const MAPref_OpenLinksInBackground; +extern NSString * const MAPref_MinimumFontSize; +extern NSString * const MAPref_UseMinimumFontSize; +extern NSString * const MAPref_AutoExpireDuration; +extern NSString * const MAPref_DownloadItemList; +extern NSString * const MAPref_ShowFolderImages; +extern NSString * const MAPref_UseJavaScript; +extern NSString * const MAPref_CachedArticleGUID; +extern NSString * const MAPref_ArticleListSortOrders; +extern NSString * const MAPref_FilterMode; +extern NSString * const MAPref_LastRefreshDate; +extern NSString * const MAPref_TabList; +extern NSString * const MAPref_TabTitleDictionary; +extern NSString * const MAPref_Layout; +extern NSString * const MAPref_NewArticlesNotification; +extern NSString * const MAPref_EmptyTrashNotification; +extern NSString * const MAPref_ShowAppInStatusBar; +extern NSString * const MAPref_ShowStatusBar; +extern NSString * const MAPref_ShowFilterBar; +extern NSString * const MAPref_LastViennaVersionRun; +extern NSString * const MAPref_HighestViennaVersionRun; +extern NSString * const MAPref_ShouldSaveFeedSource; +extern NSString * const MAPref_ShouldSaveFeedSourceBackup; +extern NSString * const MAPref_SearchMethod; +extern NSString * const MAPref_SyncGoogleReader; +extern NSString * const MAPref_GoogleNewSubscription; +extern NSString * const MAPref_ConcurrentDownloads; +extern NSString * const MAPref_SyncServer; +extern NSString * const MAPref_SyncScheme; +extern NSString * const MAPref_SyncingUser; +extern NSString * const MAPref_SyncingAppId; +extern NSString * const MAPref_SyncingAppKey; +extern NSString * const MAPref_AlwaysAcceptBetas; +extern NSString * const MAPref_UserAgentName; +extern NSString * const MAPref_UseRelativeDates; extern NSString * const MAPref_ShowDetailsOnFeedCredentialsDialog; extern NSString * const MAPref_ShowEnclosureBar; extern NSString * const MAPref_FeedListSizeMode; extern NSString * const MAPref_ShowFeedsWithUnreadItemsInBold; // Deprecated defaults keys -extern NSString *const MAPref_Deprecated_ArticleListFont; -extern NSString *const MAPref_Deprecated_ArticleListSortOrders; -extern NSString *const MAPref_Deprecated_DownloadItemList; -extern NSString *const MAPref_Deprecated_FolderFont; -extern NSString *const MAPref_Deprecated_FolderListFont; +extern NSString * const MAPref_Deprecated_ArticleListFont; +extern NSString * const MAPref_Deprecated_ArticleListSortOrders; +extern NSString * const MAPref_Deprecated_DownloadItemList; +extern NSString * const MAPref_Deprecated_FolderFont; +extern NSString * const MAPref_Deprecated_FolderListFont; extern NSInteger const MA_Default_BackTrackQueueSize; extern NSInteger const MA_Default_RefreshThreads; diff --git a/Vienna/Sources/Shared/Constants.m b/Vienna/Sources/Shared/Constants.m index 7ca3a00bd6..5f16e55417 100644 --- a/Vienna/Sources/Shared/Constants.m +++ b/Vienna/Sources/Shared/Constants.m @@ -20,67 +20,67 @@ #import "Constants.h" -NSString * MA_DefaultUserAgentString = @"%@/%@ (Macintosh; Intel macOS %@)"; -NSString * MA_BrowserUserAgentString = @"(Macintosh; Intel Mac OS X %@) AppleWebKit/%@ (KHTML, like Gecko) Version/%@ Safari/604.1.38 %@/%@"; +NSString * const MA_DefaultUserAgentString = @"%@/%@ (Macintosh; Intel macOS %@)"; +NSString * const MA_BrowserUserAgentString = @"(Macintosh; Intel Mac OS X %@) AppleWebKit/%@ (KHTML, like Gecko) Version/%@ Safari/604.1.38 %@/%@"; -NSString *const MAPref_ArticleListFont = @"ArticleListFont"; -NSString * MAPref_AutoSortFoldersTree = @"AutomaticallySortFoldersTree"; -NSString * MAPref_CheckForUpdatedArticles = @"CheckForUpdatedArticles"; -NSString * MAPref_ShowUnreadArticlesInBold = @"ShowUnreadArticlesInBold"; -NSString * MAPref_CachedFolderID = @"CachedFolderID"; -NSString * MAPref_DefaultDatabase = @"DefaultDatabase"; -NSString *const MAPref_DownloadsFolderBookmark = @"DownloadsFolderBookmark"; -NSString * MAPref_SortColumn = @"SortColumn"; -NSString * MAPref_CheckFrequency = @"CheckFrequencyInSeconds"; -NSString * MAPref_ArticleListColumns = @"MessageColumns"; -NSString * MAPref_CheckForNewArticlesOnStartup = @"CheckForNewMessagesOnStartup"; -NSString * MAPref_ActiveStyleName = @"ActiveStyle"; -NSString * MAPref_ActiveTextSizeMultiplier = @"TextSizeMultiplier"; -NSString * MAPref_FolderStates = @"FolderStates"; -NSString * MAPref_BacktrackQueueSize = @"BacktrackQueueSize"; -NSString * MAPref_MarkReadInterval = @"MarkReadInterval"; -NSString * MAPref_OpenLinksInVienna = @"OpenLinksInVienna"; -NSString * MAPref_OpenLinksInBackground = @"OpenLinksInBackground"; -NSString * MAPref_MinimumFontSize = @"MinimumFontSize"; -NSString * MAPref_UseMinimumFontSize = @"UseMinimumFontSize"; -NSString * MAPref_AutoExpireDuration = @"AutoExpireFrequency"; -NSString *const MAPref_DownloadItemList = @"DownloadItemsList"; -NSString * MAPref_ShowFolderImages = @"ShowFolderImages"; -NSString * MAPref_UseJavaScript = @"UseJavaScript"; -NSString * MAPref_CachedArticleGUID = @"CachedArticleGUID"; -NSString *const MAPref_ArticleListSortOrders = @"ArticleListSortOrders"; -NSString * MAPref_FilterMode = @"FilterMode"; -NSString * MAPref_LastRefreshDate = @"LastRefreshDate"; -NSString * MAPref_TabList = @"TabList"; -NSString * MAPref_TabTitleDictionary = @"TabTitleDict"; -NSString * MAPref_Layout = @"Layout"; -NSString * MAPref_NewArticlesNotification = @"NewArticlesNotification"; -NSString * MAPref_EmptyTrashNotification = @"EmptyTrashNotification"; -NSString * MAPref_ShowAppInStatusBar = @"ShowAppInStatusBar"; -NSString * MAPref_ShowStatusBar = @"ShowStatusBar"; -NSString * MAPref_ShowFilterBar = @"ShowFilterBar"; -NSString * MAPref_LastViennaVersionRun = @"LastViennaVersionRun"; -NSString * MAPref_HighestViennaVersionRun = @"HighestViennaVersionRun"; -NSString * MAPref_ShouldSaveFeedSource = @"ShouldSaveFeedSource"; -NSString * MAPref_ShouldSaveFeedSourceBackup = @"ShouldSaveFeedSourceBackup"; -NSString * MAPref_SearchMethod = @"SearchMethod"; -NSString * MAPref_SyncGoogleReader = @"SyncGoogleReader"; -NSString * MAPref_GoogleNewSubscription = @"GoogleNewSubscription"; -NSString * MAPref_ConcurrentDownloads = @"ConcurrentDownloads"; -NSString * MAPref_SyncServer = @"SyncServer"; -NSString * MAPref_SyncScheme = @"SyncScheme"; -NSString * MAPref_SyncingUser = @"SyncingUser"; -NSString * MAPref_SyncingAppId = @"SyncingAppId"; -NSString * MAPref_SyncingAppKey = @"SyncingAppKey"; -NSString * MAPref_AlwaysAcceptBetas = @"AlwayAcceptBetas"; -NSString * MAPref_UserAgentName = @"UserAgentName"; +NSString * const MAPref_ArticleListFont = @"ArticleListFont"; +NSString * const MAPref_AutoSortFoldersTree = @"AutomaticallySortFoldersTree"; +NSString * const MAPref_CheckForUpdatedArticles = @"CheckForUpdatedArticles"; +NSString * const MAPref_ShowUnreadArticlesInBold = @"ShowUnreadArticlesInBold"; +NSString * const MAPref_CachedFolderID = @"CachedFolderID"; +NSString * const MAPref_DefaultDatabase = @"DefaultDatabase"; +NSString * const MAPref_DownloadsFolderBookmark = @"DownloadsFolderBookmark"; +NSString * const MAPref_SortColumn = @"SortColumn"; +NSString * const MAPref_CheckFrequency = @"CheckFrequencyInSeconds"; +NSString * const MAPref_ArticleListColumns = @"MessageColumns"; +NSString * const MAPref_CheckForNewArticlesOnStartup = @"CheckForNewMessagesOnStartup"; +NSString * const MAPref_ActiveStyleName = @"ActiveStyle"; +NSString * const MAPref_ActiveTextSizeMultiplier = @"TextSizeMultiplier"; +NSString * const MAPref_FolderStates = @"FolderStates"; +NSString * const MAPref_BacktrackQueueSize = @"BacktrackQueueSize"; +NSString * const MAPref_MarkReadInterval = @"MarkReadInterval"; +NSString * const MAPref_OpenLinksInVienna = @"OpenLinksInVienna"; +NSString * const MAPref_OpenLinksInBackground = @"OpenLinksInBackground"; +NSString * const MAPref_MinimumFontSize = @"MinimumFontSize"; +NSString * const MAPref_UseMinimumFontSize = @"UseMinimumFontSize"; +NSString * const MAPref_AutoExpireDuration = @"AutoExpireFrequency"; +NSString * const MAPref_DownloadItemList = @"DownloadItemsList"; +NSString * const MAPref_ShowFolderImages = @"ShowFolderImages"; +NSString * const MAPref_UseJavaScript = @"UseJavaScript"; +NSString * const MAPref_CachedArticleGUID = @"CachedArticleGUID"; +NSString * const MAPref_ArticleListSortOrders = @"ArticleListSortOrders"; +NSString * const MAPref_FilterMode = @"FilterMode"; +NSString * const MAPref_LastRefreshDate = @"LastRefreshDate"; +NSString * const MAPref_TabList = @"TabList"; +NSString * const MAPref_TabTitleDictionary = @"TabTitleDict"; +NSString * const MAPref_Layout = @"Layout"; +NSString * const MAPref_NewArticlesNotification = @"NewArticlesNotification"; +NSString * const MAPref_EmptyTrashNotification = @"EmptyTrashNotification"; +NSString * const MAPref_ShowAppInStatusBar = @"ShowAppInStatusBar"; +NSString * const MAPref_ShowStatusBar = @"ShowStatusBar"; +NSString * const MAPref_ShowFilterBar = @"ShowFilterBar"; +NSString * const MAPref_LastViennaVersionRun = @"LastViennaVersionRun"; +NSString * const MAPref_HighestViennaVersionRun = @"HighestViennaVersionRun"; +NSString * const MAPref_ShouldSaveFeedSource = @"ShouldSaveFeedSource"; +NSString * const MAPref_ShouldSaveFeedSourceBackup = @"ShouldSaveFeedSourceBackup"; +NSString * const MAPref_SearchMethod = @"SearchMethod"; +NSString * const MAPref_SyncGoogleReader = @"SyncGoogleReader"; +NSString * const MAPref_GoogleNewSubscription = @"GoogleNewSubscription"; +NSString * const MAPref_ConcurrentDownloads = @"ConcurrentDownloads"; +NSString * const MAPref_SyncServer = @"SyncServer"; +NSString * const MAPref_SyncScheme = @"SyncScheme"; +NSString * const MAPref_SyncingUser = @"SyncingUser"; +NSString * const MAPref_SyncingAppId = @"SyncingAppId"; +NSString * const MAPref_SyncingAppKey = @"SyncingAppKey"; +NSString * const MAPref_AlwaysAcceptBetas = @"AlwayAcceptBetas"; +NSString * const MAPref_UserAgentName = @"UserAgentName"; // Deprecated defaults keys -NSString *const MAPref_Deprecated_ArticleListFont = @"MessageListFont"; -NSString *const MAPref_Deprecated_ArticleListSortOrders = @"ArticleSortDescriptors"; -NSString *const MAPref_Deprecated_DownloadItemList = @"DownloadsList"; -NSString *const MAPref_Deprecated_FolderFont = @"FolderFont"; -NSString *const MAPref_Deprecated_FolderListFont = @"FolderListFont"; +NSString * const MAPref_Deprecated_ArticleListFont = @"MessageListFont"; +NSString * const MAPref_Deprecated_ArticleListSortOrders = @"ArticleSortDescriptors"; +NSString * const MAPref_Deprecated_DownloadItemList = @"DownloadsList"; +NSString * const MAPref_Deprecated_FolderFont = @"FolderFont"; +NSString * const MAPref_Deprecated_FolderListFont = @"FolderListFont"; NSInteger const MA_Default_BackTrackQueueSize = 20; NSInteger const MA_Default_RefreshThreads = 20; From aa001012999de5e8978325c360e0797f2115ea9e Mon Sep 17 00:00:00 2001 From: Eitot Date: Wed, 10 May 2023 23:14:43 +0200 Subject: [PATCH 2/5] Convert deprecated NSUserDefaults keys to local constants --- .../Sources/Preferences window/Preferences.m | 37 +++++++++++-------- Vienna/Sources/Shared/Constants.h | 7 ---- Vienna/Sources/Shared/Constants.m | 7 ---- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/Vienna/Sources/Preferences window/Preferences.m b/Vienna/Sources/Preferences window/Preferences.m index 5714ca3bf4..f5161a4308 100644 --- a/Vienna/Sources/Preferences window/Preferences.m +++ b/Vienna/Sources/Preferences window/Preferences.m @@ -240,8 +240,15 @@ -(NSDictionary *)allocFactoryDefaults - (void)migrateEncodedPreferences { - if ([userPrefs objectForKey:MAPref_Deprecated_ArticleListSortOrders]) { - NSData *archive = [self objectForKey:MAPref_Deprecated_ArticleListSortOrders]; + // Deprecated defaults keys. These were used in older versions of Vienna. + NSString * const articleSortDescriptorsKey = @"ArticleSortDescriptors"; + NSString * const downloadsListKey = @"DownloadsList"; + NSString * const messageListFontKey = @"MessageListFont"; + NSString * const folderFontKey = @"FolderFont"; + NSString * const folderListFontKey = @"FolderListFont"; + + if ([userPrefs objectForKey:articleSortDescriptorsKey]) { + NSData *archive = [self objectForKey:articleSortDescriptorsKey]; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" NSMutableArray *sortDescriptors = [[NSUnarchiver unarchiveObjectWithData:archive] mutableCopy]; @@ -260,12 +267,12 @@ - (void)migrateEncodedPreferences NSData *keyedArchive = [NSKeyedArchiver vna_archivedDataWithRootObject:[sortDescriptors copy] requiringSecureCoding:YES]; [self setObject:keyedArchive forKey:MAPref_ArticleListSortOrders]; - [userPrefs removeObjectForKey:MAPref_Deprecated_ArticleListSortOrders]; + [userPrefs removeObjectForKey:articleSortDescriptorsKey]; } - if ([userPrefs objectForKey:MAPref_Deprecated_DownloadItemList]) { + if ([userPrefs objectForKey:downloadsListKey]) { // Download items were stored as an array of non-keyed archives. - NSArray *array = [self objectForKey:MAPref_Deprecated_DownloadItemList]; + NSArray *array = [self objectForKey:downloadsListKey]; NSMutableArray *downloadItems = [NSMutableArray array]; for (NSData *archive in array) { @@ -284,11 +291,11 @@ - (void)migrateEncodedPreferences NSData *keyedArchive = [NSKeyedArchiver vna_archivedDataWithRootObject:downloadItems requiringSecureCoding:YES]; [self setObject:keyedArchive forKey:MAPref_DownloadItemList]; - [userPrefs removeObjectForKey:MAPref_Deprecated_DownloadItemList]; + [userPrefs removeObjectForKey:downloadsListKey]; } - if ([userPrefs objectForKey:MAPref_Deprecated_ArticleListFont]) { - NSData *archive = [self objectForKey:MAPref_Deprecated_ArticleListFont]; + if ([userPrefs objectForKey:messageListFontKey]) { + NSData *archive = [self objectForKey:messageListFontKey]; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" NSFont *font = [NSUnarchiver unarchiveObjectWithData:archive]; @@ -296,11 +303,11 @@ - (void)migrateEncodedPreferences NSData *keyedArchive = [NSKeyedArchiver vna_archivedDataWithRootObject:font requiringSecureCoding:YES]; [self setObject:keyedArchive forKey:MAPref_ArticleListFont]; - [userPrefs removeObjectForKey:MAPref_Deprecated_ArticleListFont]; + [userPrefs removeObjectForKey:messageListFontKey]; } - if ([userPrefs objectForKey:MAPref_Deprecated_FolderFont]) { - NSData *archive = [self objectForKey:MAPref_Deprecated_FolderFont]; + if ([userPrefs objectForKey:folderFontKey]) { + NSData *archive = [self objectForKey:folderFontKey]; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" NSFont *font = [NSUnarchiver unarchiveObjectWithData:archive]; @@ -309,11 +316,11 @@ - (void)migrateEncodedPreferences [userPrefs setInteger:VNAFeedListSizeModeTiny forKey:MAPref_FeedListSizeMode]; } - [userPrefs removeObjectForKey:MAPref_Deprecated_FolderFont]; + [userPrefs removeObjectForKey:folderFontKey]; } - if ([userPrefs objectForKey:MAPref_Deprecated_FolderListFont]) { - NSData *archive = [self objectForKey:MAPref_Deprecated_FolderListFont]; + if ([userPrefs objectForKey:folderListFontKey]) { + NSData *archive = [self objectForKey:folderListFontKey]; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" NSFont *font = [NSKeyedUnarchiver vna_unarchivedObjectOfClass:[NSFont class] @@ -323,7 +330,7 @@ - (void)migrateEncodedPreferences [userPrefs setInteger:VNAFeedListSizeModeTiny forKey:MAPref_FeedListSizeMode]; } - [userPrefs removeObjectForKey:MAPref_Deprecated_FolderListFont]; + [userPrefs removeObjectForKey:folderListFontKey]; } } diff --git a/Vienna/Sources/Shared/Constants.h b/Vienna/Sources/Shared/Constants.h index eb34ac1b28..8185ff054c 100644 --- a/Vienna/Sources/Shared/Constants.h +++ b/Vienna/Sources/Shared/Constants.h @@ -80,13 +80,6 @@ extern NSString * const MAPref_ShowEnclosureBar; extern NSString * const MAPref_FeedListSizeMode; extern NSString * const MAPref_ShowFeedsWithUnreadItemsInBold; -// Deprecated defaults keys -extern NSString * const MAPref_Deprecated_ArticleListFont; -extern NSString * const MAPref_Deprecated_ArticleListSortOrders; -extern NSString * const MAPref_Deprecated_DownloadItemList; -extern NSString * const MAPref_Deprecated_FolderFont; -extern NSString * const MAPref_Deprecated_FolderListFont; - extern NSInteger const MA_Default_BackTrackQueueSize; extern NSInteger const MA_Default_RefreshThreads; extern float const MA_Default_Read_Interval; diff --git a/Vienna/Sources/Shared/Constants.m b/Vienna/Sources/Shared/Constants.m index 5f16e55417..d61668a39c 100644 --- a/Vienna/Sources/Shared/Constants.m +++ b/Vienna/Sources/Shared/Constants.m @@ -75,13 +75,6 @@ NSString * const MAPref_AlwaysAcceptBetas = @"AlwayAcceptBetas"; NSString * const MAPref_UserAgentName = @"UserAgentName"; -// Deprecated defaults keys -NSString * const MAPref_Deprecated_ArticleListFont = @"MessageListFont"; -NSString * const MAPref_Deprecated_ArticleListSortOrders = @"ArticleSortDescriptors"; -NSString * const MAPref_Deprecated_DownloadItemList = @"DownloadsList"; -NSString * const MAPref_Deprecated_FolderFont = @"FolderFont"; -NSString * const MAPref_Deprecated_FolderListFont = @"FolderListFont"; - NSInteger const MA_Default_BackTrackQueueSize = 20; NSInteger const MA_Default_RefreshThreads = 20; NSInteger const MA_Default_MinimumFontSize = 9; From 1d8812f6c69170a4ffb9c3a0a121d7729ef52318 Mon Sep 17 00:00:00 2001 From: Eitot Date: Fri, 12 May 2023 20:11:59 +0200 Subject: [PATCH 3/5] Convert notification name strings into NSNotificationName constants --- Vienna/Sources/Alerts/FeedCredentials.m | 4 +- Vienna/Sources/Application/AppController.m | 26 ++++---- Vienna/Sources/Database/Database.m | 20 +++--- .../Sources/Download window/DownloadManager.m | 4 +- .../Sources/Download window/DownloadWindow.m | 3 +- Vienna/Sources/Fetching/OpenReader.m | 25 ++++---- Vienna/Sources/Fetching/RefreshManager.m | 20 +++--- .../Sources/Info panel/InfoPanelController.m | 3 +- Vienna/Sources/Info panel/InfoPanelManager.m | 7 ++- Vienna/Sources/Main window/ArticleCellView.m | 3 +- .../Sources/Main window/ArticleController.m | 20 +++--- .../Main window/ArticleConverter.swift | 2 +- Vienna/Sources/Main window/ArticleListView.m | 10 +-- Vienna/Sources/Main window/EnclosureView.m | 3 +- Vienna/Sources/Main window/FoldersTree.m | 20 +++--- .../TabbedBrowserViewController.swift | 4 +- .../Sources/Main window/UnifiedDisplayView.m | 4 +- .../Main window/WebKitArticleTab.swift | 4 +- .../AppearancePreferencesViewController.m | 8 ++- .../GeneralPreferencesViewController.m | 4 +- .../Sources/Preferences window/Preferences.h | 4 -- .../Sources/Preferences window/Preferences.m | 61 +++++++++---------- .../SyncingPreferencesViewController.m | 6 +- .../UpdatePreferencesViewController.m | 2 +- Vienna/Sources/Shared/Constants.h | 37 +++++++++++ Vienna/Sources/Shared/Constants.m | 37 +++++++++++ Vienna/Sources/Vienna-Bridging-Header.h | 1 + 27 files changed, 209 insertions(+), 133 deletions(-) diff --git a/Vienna/Sources/Alerts/FeedCredentials.m b/Vienna/Sources/Alerts/FeedCredentials.m index 11d4af7b3c..1686736344 100644 --- a/Vienna/Sources/Alerts/FeedCredentials.m +++ b/Vienna/Sources/Alerts/FeedCredentials.m @@ -136,7 +136,7 @@ - (IBAction)updateCredentials:(id)sender [self.credentialsWindow.sheetParent endSheet:self.credentialsWindow]; [self.credentialsWindow orderOut:self]; - [NSNotificationCenter.defaultCenter postNotificationName:@"MA_Notify_GotAuthenticationForFolder" + [NSNotificationCenter.defaultCenter postNotificationName:MA_Notify_GotAuthenticationForFolder object:self.folder]; } @@ -145,7 +145,7 @@ - (IBAction)cancel:(id)sender [self.credentialsWindow.sheetParent endSheet:self.credentialsWindow]; [self.credentialsWindow orderOut:self]; - [NSNotificationCenter.defaultCenter postNotificationName:@"MA_Notify_CancelAuthenticationForFolder" + [NSNotificationCenter.defaultCenter postNotificationName:MA_Notify_CancelAuthenticationForFolder object:self.folder]; } diff --git a/Vienna/Sources/Application/AppController.m b/Vienna/Sources/Application/AppController.m index cc9303de0d..7f2ce0d132 100644 --- a/Vienna/Sources/Application/AppController.m +++ b/Vienna/Sources/Application/AppController.m @@ -261,20 +261,20 @@ -(void)applicationDidFinishLaunching:(NSNotification *)aNot // Register a bunch of notifications NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self selector:@selector(handleFolderSelection:) name:@"MA_Notify_FolderSelectionChange" object:nil]; - [nc addObserver:self selector:@selector(handleCheckFrequencyChange:) name:@"MA_Notify_CheckFrequencyChange" object:nil]; - [nc addObserver:self selector:@selector(handleEditFolder:) name:@"MA_Notify_EditFolder" object:nil]; - [nc addObserver:self selector:@selector(handleRefreshStatusChange:) name:@"MA_Notify_RefreshStatus" object:nil]; - [nc addObserver:self selector:@selector(handleTabChange:) name:@"MA_Notify_TabChanged" object:nil]; - [nc addObserver:self selector:@selector(handleTabCountChange:) name:@"MA_Notify_TabCountChanged" object:nil]; - [nc addObserver:self selector:@selector(handleFolderNameChange:) name:@"MA_Notify_FolderNameChanged" object:nil]; + [nc addObserver:self selector:@selector(handleFolderSelection:) name:MA_Notify_FolderSelectionChange object:nil]; + [nc addObserver:self selector:@selector(handleCheckFrequencyChange:) name:MA_Notify_CheckFrequencyChange object:nil]; + [nc addObserver:self selector:@selector(handleEditFolder:) name:MA_Notify_EditFolder object:nil]; + [nc addObserver:self selector:@selector(handleRefreshStatusChange:) name:MA_Notify_RefreshStatus object:nil]; + [nc addObserver:self selector:@selector(handleTabChange:) name:MA_Notify_TabChanged object:nil]; + [nc addObserver:self selector:@selector(handleTabCountChange:) name:MA_Notify_TabCountChanged object:nil]; + [nc addObserver:self selector:@selector(handleFolderNameChange:) name:MA_Notify_FolderNameChanged object:nil]; [nc addObserver:self selector:@selector(handleDidBecomeKeyWindow:) name:NSWindowDidBecomeKeyNotification object:nil]; - [nc addObserver:self selector:@selector(handleReloadPreferences:) name:@"MA_Notify_PreferenceChange" object:nil]; - [nc addObserver:self selector:@selector(handleShowAppInStatusBar:) name:@"MA_Notify_ShowAppInStatusBarChanged" object:nil]; - [nc addObserver:self selector:@selector(handleShowFilterBar:) name:@"MA_Notify_FilterBarChanged" object:nil]; - [nc addObserver:self selector:@selector(handleUpdateUnreadCount:) name:@"MA_Notify_FoldersUpdated" object:nil]; + [nc addObserver:self selector:@selector(handleReloadPreferences:) name:MA_Notify_PreferenceChange object:nil]; + [nc addObserver:self selector:@selector(handleShowAppInStatusBar:) name:MA_Notify_ShowAppInStatusBarChanged object:nil]; + [nc addObserver:self selector:@selector(handleShowFilterBar:) name:MA_Notify_FilterBarChanged object:nil]; + [nc addObserver:self selector:@selector(handleUpdateUnreadCount:) name:MA_Notify_FoldersUpdated object:nil]; //Open Reader Notifications - [nc addObserver:self selector:@selector(handleGoogleAuthFailed:) name:@"MA_Notify_GoogleAuthFailed" object:nil]; + [nc addObserver:self selector:@selector(handleGoogleAuthFailed:) name:MA_Notify_GoogleAuthFailed object:nil]; // Initialize the database if ((db = [Database sharedManager]) == nil) { @@ -2539,7 +2539,7 @@ -(IBAction)setLoadFullHTMLFlag:(BOOL)loadFullHTMLPages [folder clearFlag:VNAFolderFlagLoadFullHTML]; [[Database sharedManager] clearFlag:VNAFolderFlagLoadFullHTML forFolder:folderID]; } - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_LoadFullHTMLChange" object:@(folderID)]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_LoadFullHTMLChange object:@(folderID)]; } } diff --git a/Vienna/Sources/Database/Database.m b/Vienna/Sources/Database/Database.m index fffe5a438f..6425b7f0bc 100644 --- a/Vienna/Sources/Database/Database.m +++ b/Vienna/Sources/Database/Database.m @@ -552,7 +552,7 @@ -(void)clearFlag:(NSUInteger)flag forFolder:(NSInteger)folderId FMDatabaseQueue *queue = self.databaseQueue; [queue inDatabase:^(FMDatabase *db) { [db executeUpdate:@"UPDATE folders SET flags=? WHERE folder_id=?", @(folder.flags), @(folderId)]; - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FoldersUpdated" object:@(folderId)]; + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FoldersUpdated object:@(folderId)]; }]; } } @@ -577,7 +577,7 @@ -(void)setFlag:(NSUInteger)flag forFolder:(NSInteger)folderId FMDatabaseQueue *queue = self.databaseQueue; [queue inDatabase:^(FMDatabase *db) { [db executeUpdate:@"UPDATE folders SET flags=? WHERE folder_id=?", @(folder.flags), @(folderId)]; - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FoldersUpdated" object:@(folderId)]; + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FoldersUpdated object:@(folderId)]; }]; } } @@ -659,7 +659,7 @@ -(BOOL)setFeedURL:(NSString *)feed_url forFolder:(NSInteger)folderId FMDatabaseQueue *queue = self.databaseQueue; [queue inDatabase:^(FMDatabase *db) { [db executeUpdate:@"UPDATE rss_folders SET feed_url=? WHERE folder_id=?", feed_url, @(folderId)]; - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FoldersUpdated" object:@(folderId)]; + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FoldersUpdated object:@(folderId)]; }]; } return YES; @@ -866,7 +866,7 @@ -(NSInteger)addFolder:(NSInteger)parentId afterChild:(NSInteger)predId folderNam } // Send a notification when new folders are added - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FolderAdded" object:folder]; + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FolderAdded object:folder]; } return newItemId; } @@ -1100,7 +1100,7 @@ -(BOOL)setName:(NSString *)newName forFolder:(NSInteger)folderId // Send a notification that the folder has changed. It is the responsibility of the // notifiee that they work out that the name is the part that has changed. - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FolderNameChanged" object:@(folderId)]; + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FolderNameChanged object:@(folderId)]; return YES; } @@ -1142,7 +1142,7 @@ -(BOOL)setDescription:(NSString *)newDescription forFolder:(NSInteger)folderId // Send a notification that the folder has changed. It is the responsibility of the // notifiee that they work out that the description is the part that has changed. - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FolderDescriptionChanged" + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FolderDescriptionChanged object:@(folderId)]; return YES; } @@ -1187,7 +1187,7 @@ -(BOOL)setHomePage:(NSString *)homePageURL forFolder:(NSInteger)folderId // Send a notification that the folder has changed. It is the responsibility of the // notifiee that they work out that the link is the part that has changed. - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FolderHomePageChanged" + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FolderHomePageChanged object:@(folderId)]; return YES; } @@ -1690,7 +1690,7 @@ -(void)purgeDeletedArticles for (Folder * folder in [self.foldersDict objectEnumerator]) [folder clearCache]; - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FoldersUpdated" object:@(self.trashFolderId)]; + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FoldersUpdated object:@(self.trashFolderId)]; } } @@ -1802,7 +1802,7 @@ -(void)updateSearchFolder:(NSInteger)folderId withFolder:(NSString *)folderName self.smartfoldersDict[@(folderId)] = criteriaTree; NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; - [nc vna_postNotificationOnMainThreadWithName:@"MA_Notify_ArticleListContentChange" + [nc vna_postNotificationOnMainThreadWithName:MA_Notify_ArticleListContentChange object:@(folderId)]; } @@ -2355,7 +2355,7 @@ -(void)setFolderUnreadCount:(Folder *)folder adjustment:(NSUInteger)adjustment FMDatabaseQueue *queue = self.databaseQueue; [queue inDatabase:^(FMDatabase *db) { [db executeUpdate:@"UPDATE folders SET unread_count=? WHERE folder_id=?", @(newCount), @(folder.itemId)]; - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FoldersUpdated" object:@(folder.itemId)]; + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FoldersUpdated object:@(folder.itemId)]; }]; // Update childUnreadCount for parents. diff --git a/Vienna/Sources/Download window/DownloadManager.m b/Vienna/Sources/Download window/DownloadManager.m index f47dd76b50..9020cc608a 100644 --- a/Vienna/Sources/Download window/DownloadManager.m +++ b/Vienna/Sources/Download window/DownloadManager.m @@ -250,7 +250,7 @@ + (BOOL)isFileDownloaded:(NSString *)filename { // Send a notification that the specified download item has changed. - (void)notifyDownloadItemChange:(DownloadItem *)item { NSNotificationCenter *nc = NSNotificationCenter.defaultCenter; - [nc postNotificationName:@"MA_Notify_DownloadsListChange" object:item]; + [nc postNotificationName:MA_Notify_DownloadsListChange object:item]; } // Delivers a user notification for the given download item. @@ -274,7 +274,7 @@ - (void)deliverNotificationForDownloadItem:(DownloadItem *)item { notification.userInfo = @{UserNotificationContextKey: UserNotificationContextFileDownloadCompleted, UserNotificationFilePathKey: fileName}; - [NSNotificationCenter.defaultCenter postNotificationName:@"MA_Notify_DownloadCompleted" object:fileName]; + [NSNotificationCenter.defaultCenter postNotificationName:MA_Notify_DownloadCompleted object:fileName]; } else if (item.state == DownloadStateFailed) { notification.title = NSLocalizedString(@"Download failed", @"Notification title"); notification.informativeText = [NSString stringWithFormat:NSLocalizedString(@"File %@ failed to download", @"Notification body"), fileName]; diff --git a/Vienna/Sources/Download window/DownloadWindow.m b/Vienna/Sources/Download window/DownloadWindow.m index f92ab6e95d..04ae26d7f2 100644 --- a/Vienna/Sources/Download window/DownloadWindow.m +++ b/Vienna/Sources/Download window/DownloadWindow.m @@ -21,6 +21,7 @@ #import "DownloadWindow.h" #import "AppController+Notifications.h" +#import "Constants.h" #import "DownloadItem.h" #import "DownloadManager.h" #import "HelperFunctions.h" @@ -53,7 +54,7 @@ -(void)windowDidLoad // Register to get notified when the download manager's list changes NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self selector:@selector(handleDownloadsChange:) name:@"MA_Notify_DownloadsListChange" object:nil]; + [nc addObserver:self selector:@selector(handleDownloadsChange:) name:MA_Notify_DownloadsListChange object:nil]; // Set the cell for each row ImageAndTextCell * imageAndTextCell; diff --git a/Vienna/Sources/Fetching/OpenReader.m b/Vienna/Sources/Fetching/OpenReader.m index 4a134f820b..6cc39dcdc2 100644 --- a/Vienna/Sources/Fetching/OpenReader.m +++ b/Vienna/Sources/Fetching/OpenReader.m @@ -31,6 +31,7 @@ @import os.log; +#import "Constants.h" #import "URLRequestExtensions.h" #import "Folder.h" #import "Database.h" @@ -192,13 +193,13 @@ -(void)addClientTokenToRequest:(NSMutableURLRequest *)clientRequest if (error) { NSString * alertDescription = error.localizedDescription; if (![alertDescription isEqualToString:latestAlertDescription]) { - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_GoogleAuthFailed" object:alertDescription]; + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_GoogleAuthFailed object:alertDescription]; latestAlertDescription = alertDescription; } } else if (((NSHTTPURLResponse *)response).statusCode != 200) { NSString * alertDescription = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; if (![alertDescription isEqualToString:latestAlertDescription]) { - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_GoogleAuthFailed" object:alertDescription]; + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_GoogleAuthFailed object:alertDescription]; latestAlertDescription = alertDescription; } } else { // statusCode 200 @@ -503,7 +504,7 @@ -(void)feedRequestFailed:(NSMutableURLRequest *)request response:(NSURLResponse [refreshedFolder clearNonPersistedFlag:VNAFolderFlagUpdating]; [refreshedFolder setNonPersistedFlag:VNAFolderFlagError]; [refreshedFolder clearNonPersistedFlag:VNAFolderFlagSyncedOK]; // get ready for next request - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FoldersUpdated" + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FoldersUpdated object:@(refreshedFolder.itemId)]; } @@ -682,7 +683,7 @@ -(void)feedRequestDone:(NSMutableURLRequest *)request response:(NSURLResponse *) [refreshedFolder setNonPersistedFlag:VNAFolderFlagError]; [refreshedFolder clearNonPersistedFlag:VNAFolderFlagSyncedOK]; } - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FoldersUpdated" + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FoldersUpdated object:@(refreshedFolder.itemId)]; }); //block for dispatch_async } // feedRequestDone @@ -729,7 +730,7 @@ -(void)readRequestDone:(NSMutableURLRequest *)request response:(NSURLResponse *) }); [refreshedFolder clearNonPersistedFlag:VNAFolderFlagUpdating]; [refreshedFolder setNonPersistedFlag:VNAFolderFlagError]; - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FoldersUpdated" object:@( + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FoldersUpdated object:@( refreshedFolder.itemId)]; return; } // try/catch @@ -748,7 +749,7 @@ -(void)readRequestDone:(NSMutableURLRequest *)request response:(NSURLResponse *) [refreshedFolder clearNonPersistedFlag:VNAFolderFlagUpdating]; [refreshedFolder setNonPersistedFlag:VNAFolderFlagError]; } - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FoldersUpdated" + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FoldersUpdated object:@(refreshedFolder.itemId)]; }); //block for dispatch_async } // readRequestDone @@ -780,7 +781,7 @@ -(void)starredRequestDone:(NSMutableURLRequest *)request response:(NSURLResponse [guidArray addObject:guid]; [[refreshedFolder articleFromGuid:guid] markFlagged:YES]; } - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_ArticleListContentChange" object:@( + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_ArticleListContentChange object:@( refreshedFolder.itemId)]; [[Database sharedManager] markStarredArticlesFromFolder:refreshedFolder guidArray:guidArray]; @@ -803,7 +804,7 @@ -(void)starredRequestDone:(NSMutableURLRequest *)request response:(NSURLResponse [refreshedFolder clearNonPersistedFlag:VNAFolderFlagUpdating]; [refreshedFolder setNonPersistedFlag:VNAFolderFlagError]; } - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FoldersUpdated" + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FoldersUpdated object:@(refreshedFolder.itemId)]; }); //block for dispatch_async } // starredRequestDone @@ -932,7 +933,7 @@ -(void)subscriptionsRequestDone:(NSMutableURLRequest *)request response:(NSURLRe neededParentId = VNAFolderTypeRoot; } if (localFolder.parentId != neededParentId) { - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_OpenReaderFolderChange" + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_OpenReaderFolderChange object:@[ [NSNumber numberWithInteger:nativeId], [NSNumber numberWithInteger:neededParentId], [NSNumber numberWithInteger:0]]]; @@ -1132,8 +1133,8 @@ -(void)markReadDone:(NSMutableURLRequest *)request response:(NSURLResponse *)res [[Database sharedManager] markArticleRead:article.folderId guid:article.guid isRead:readFlag]; [article markRead:readFlag]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - [nc vna_postNotificationOnMainThreadWithName:@"MA_Notify_FoldersUpdated" object:@(article.folderId)]; - [nc vna_postNotificationOnMainThreadWithName:@"MA_Notify_ArticleListStateChange" object:@(article.folderId)]; + [nc vna_postNotificationOnMainThreadWithName:MA_Notify_FoldersUpdated object:@(article.folderId)]; + [nc vna_postNotificationOnMainThreadWithName:MA_Notify_ArticleListStateChange object:@(article.folderId)]; } } @@ -1174,7 +1175,7 @@ -(void)markAllReadDone:(NSMutableURLRequest *)request response:(NSURLResponse *) Folder *folder = ((NSDictionary *)[request vna_userInfo])[@"folder"]; [[Database sharedManager] markFolderRead:folder.itemId]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - [nc vna_postNotificationOnMainThreadWithName:@"MA_Notify_ArticleListStateChange" object:@(folder.itemId)]; + [nc vna_postNotificationOnMainThreadWithName:MA_Notify_ArticleListStateChange object:@(folder.itemId)]; } } diff --git a/Vienna/Sources/Fetching/RefreshManager.m b/Vienna/Sources/Fetching/RefreshManager.m index 99a93f8fea..2b57561587 100644 --- a/Vienna/Sources/Fetching/RefreshManager.m +++ b/Vienna/Sources/Fetching/RefreshManager.m @@ -104,11 +104,11 @@ -(instancetype)init _urlSession = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:[NSOperationQueue mainQueue]]; NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self selector:@selector(handleGotAuthenticationForFolder:) name:@"MA_Notify_GotAuthenticationForFolder" object:nil]; - [nc addObserver:self selector:@selector(handleCancelAuthenticationForFolder:) name:@"MA_Notify_CancelAuthenticationForFolder" + [nc addObserver:self selector:@selector(handleGotAuthenticationForFolder:) name:MA_Notify_GotAuthenticationForFolder object:nil]; + [nc addObserver:self selector:@selector(handleCancelAuthenticationForFolder:) name:MA_Notify_CancelAuthenticationForFolder object:nil]; [nc addObserver:self selector:@selector(handleWillDeleteFolder:) name:VNADatabaseWillDeleteFolderNotification object:nil]; - [nc addObserver:self selector:@selector(handleChangeConcurrentDownloads:) name:@"MA_Notify_CowncurrentDownloadsChange" object:nil]; + [nc addObserver:self selector:@selector(handleChangeConcurrentDownloads:) name:MA_Notify_CowncurrentDownloadsChange object:nil]; // be notified on system wake up after sleep [[NSWorkspace sharedWorkspace].notificationCenter addObserver:self selector:@selector(handleDidWake:) name:@"NSWorkspaceDidWakeNotification" object:nil]; @@ -363,7 +363,7 @@ -(void)setFolderErrorFlag:(Folder *)folder flag:(BOOL)theFlag } else { [folder clearNonPersistedFlag:VNAFolderFlagError]; } - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FoldersUpdated" object:@(folder.itemId)]; + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FoldersUpdated object:@(folder.itemId)]; } /* setFolderUpdatingFlag @@ -377,7 +377,7 @@ -(void)setFolderUpdatingFlag:(Folder *)folder flag:(BOOL)theFlag } else { [folder clearNonPersistedFlag:VNAFolderFlagUpdating]; } - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FoldersUpdated" object:@(folder.itemId)]; + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FoldersUpdated object:@(folder.itemId)]; } /* pumpFolderIconRefresh @@ -417,7 +417,7 @@ -(void)pumpFolderIconRefresh:(Folder *)folder folder.image = iconImage; // Broadcast a notification since the folder image has now changed - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_FoldersUpdated" + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_FoldersUpdated object:@(folder.itemId)]; // Log additional details about this. @@ -536,7 +536,7 @@ -(void)refreshFeed:(Folder *)folder fromURL:(NSURL *)url withLog:(ActivityItem * hasStarted = YES; countOfNewArticles = 0; [[OpenReader sharedManager] resetCountOfNewArticles]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_RefreshStatus" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_RefreshStatus object:nil]; } } // refreshFeed @@ -902,7 +902,7 @@ -(void)finalizeFolderRefresh:(NSDictionary *)parameters dispatch_async(dispatch_get_main_queue(), ^{ connectorItem.status = logText; }); - [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:@"MA_Notify_ArticleListContentChange" object:@(folder. + [[NSNotificationCenter defaultCenter] vna_postNotificationOnMainThreadWithName:MA_Notify_ArticleListContentChange object:@(folder. itemId)]; } @@ -1207,8 +1207,8 @@ -(void)finishConnectionQueue { if (hasStarted && networkQueue.operationCount == 0) { NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - [nc postNotificationName:@"MA_Notify_RefreshStatus" object:nil]; - [nc postNotificationName:@"MA_Notify_ArticleListContentChange" object:nil]; + [nc postNotificationName:MA_Notify_RefreshStatus object:nil]; + [nc postNotificationName:MA_Notify_ArticleListContentChange object:nil]; statusMessageDuringRefresh = NSLocalizedString(@"Refresh completed", nil); hasStarted = NO; os_log_info(VNA_LOG, "Finished refreshing"); diff --git a/Vienna/Sources/Info panel/InfoPanelController.m b/Vienna/Sources/Info panel/InfoPanelController.m index f6a5f497c6..8559ba4055 100644 --- a/Vienna/Sources/Info panel/InfoPanelController.m +++ b/Vienna/Sources/Info panel/InfoPanelController.m @@ -20,6 +20,7 @@ #import "InfoPanelController.h" +#import "Constants.h" #import "Database.h" #import "DateFormatterExtension.h" #import "Folder.h" @@ -155,7 +156,7 @@ -(IBAction)loadFullHTMLChanged:(id)sender } else { [[Database sharedManager] clearFlag:VNAFolderFlagLoadFullHTML forFolder:self.infoFolderId]; } - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_LoadFullHTMLChange" + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_LoadFullHTMLChange object:@(self.infoFolderId)]; } diff --git a/Vienna/Sources/Info panel/InfoPanelManager.m b/Vienna/Sources/Info panel/InfoPanelManager.m index 4f94defee1..000b6e0a95 100644 --- a/Vienna/Sources/Info panel/InfoPanelManager.m +++ b/Vienna/Sources/Info panel/InfoPanelManager.m @@ -21,6 +21,7 @@ #import "InfoPanelManager.h" #import "AppController.h" +#import "Constants.h" #import "Database.h" #import "InfoPanelController.h" @@ -59,9 +60,9 @@ -(instancetype)init NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; [nc addObserver:self selector:@selector(handleFolderDeleted:) name:VNADatabaseDidDeleteFolderNotification object:nil]; - [nc addObserver:self selector:@selector(handleFolderChange:) name:@"MA_Notify_FolderNameChanged" object:nil]; - [nc addObserver:self selector:@selector(handleFolderChange:) name:@"MA_Notify_FoldersUpdated" object:nil]; - [nc addObserver:self selector:@selector(handleFolderChange:) name:@"MA_Notify_LoadFullHTMLChange" object:nil]; + [nc addObserver:self selector:@selector(handleFolderChange:) name:MA_Notify_FolderNameChanged object:nil]; + [nc addObserver:self selector:@selector(handleFolderChange:) name:MA_Notify_FoldersUpdated object:nil]; + [nc addObserver:self selector:@selector(handleFolderChange:) name:MA_Notify_LoadFullHTMLChange object:nil]; } return self; } diff --git a/Vienna/Sources/Main window/ArticleCellView.m b/Vienna/Sources/Main window/ArticleCellView.m index 54009967fa..db2a5fc0ee 100644 --- a/Vienna/Sources/Main window/ArticleCellView.m +++ b/Vienna/Sources/Main window/ArticleCellView.m @@ -9,6 +9,7 @@ #import "AppController.h" #import "ArticleController.h" +#import "Constants.h" #import "Preferences.h" #import "Vienna-Swift.h" @@ -184,7 +185,7 @@ - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigat //set the new frame to the webview webView.frame = newWebViewRect; self.fittingHeight = fittingHeight; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_CellResize" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_CellResize object:self]; WebKitArticleView *articleView = (WebKitArticleView *)(self.articleView); [articleView deleteHtmlFile]; }]; diff --git a/Vienna/Sources/Main window/ArticleController.m b/Vienna/Sources/Main window/ArticleController.m index 7aef2804d7..9d4482411e 100644 --- a/Vienna/Sources/Main window/ArticleController.m +++ b/Vienna/Sources/Main window/ArticleController.m @@ -126,8 +126,8 @@ -(instancetype)init // Register for notifications NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self selector:@selector(handleArticleListContentChange:) name:@"MA_Notify_ArticleListContentChange" object:nil]; - [nc addObserver:self selector:@selector(handleArticleListStateChange:) name:@"MA_Notify_ArticleListStateChange" object:nil]; + [nc addObserver:self selector:@selector(handleArticleListContentChange:) name:MA_Notify_ArticleListContentChange object:nil]; + [nc addObserver:self selector:@selector(handleArticleListStateChange:) name:MA_Notify_ArticleListStateChange object:nil]; [NSUserDefaults.standardUserDefaults addObserver:self forKeyPath:MAPref_FilterMode @@ -168,7 +168,7 @@ -(void)setLayout:(NSInteger)newLayout [self selectFolderAndArticle:currentFolderId guid:currentSelectedArticle.guid]; [self ensureSelectedArticle]; } - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_ArticleViewChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_ArticleViewChange object:nil]; } /* currentFolderId @@ -495,7 +495,7 @@ -(void)reloadArrayOfArticles [[Preferences standardPreferences] boolForKey:MAPref_CheckForUpdatedArticles] && currentArticle.revised && !currentArticle.read) { - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_ArticleViewChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_ArticleViewChange object:nil]; } } // reloadArrayOfArticles @@ -795,7 +795,7 @@ -(void)innerMarkReadByArray:(NSArray *)articleArray readFlag:(BOOL)readFlag [[Database sharedManager] markArticleRead:folderId guid:theArticle.guid isRead:readFlag]; [theArticle markRead:readFlag]; if (folderId != lastFolderId && lastFolderId != -1) { - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_FoldersUpdated" + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_FoldersUpdated object:@(lastFolderId)]; } lastFolderId = folderId; @@ -803,7 +803,7 @@ -(void)innerMarkReadByArray:(NSArray *)articleArray readFlag:(BOOL)readFlag } } if (lastFolderId != -1) { - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_FoldersUpdated" + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_FoldersUpdated object:@(lastFolderId)]; } } @@ -827,14 +827,14 @@ -(void)innerMarkReadByRefsArray:(NSArray *)articleArray readFlag:(BOOL)readFlag } else { [db markArticleRead:folderId guid:articleRef.guid isRead:readFlag]; if (folderId != lastFolderId && lastFolderId != -1) { - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_FoldersUpdated" + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_FoldersUpdated object:@(lastFolderId)]; } lastFolderId = folderId; } } if (lastFolderId != -1) { - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_FoldersUpdated" + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_FoldersUpdated object:@(lastFolderId)]; } } @@ -936,7 +936,7 @@ -(void)markAllReadByReferencesArray:(NSArray *)refArray readFlag:(BOOL)readFlag } else { [dbManager markArticleRead:folderId guid:theGuid isRead:readFlag]; if (folderId != lastFolderId && lastFolderId != -1) { - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_FoldersUpdated" + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_FoldersUpdated object:@(lastFolderId)]; } lastFolderId = folderId; @@ -948,7 +948,7 @@ -(void)markAllReadByReferencesArray:(NSArray *)refArray readFlag:(BOOL)readFlag } if (lastFolderId != -1) { - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_FoldersUpdated" + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_FoldersUpdated object:@(lastFolderId)]; } if (lastFolderId != -1 && [dbManager folderFromID:currentFolderId].type != VNAFolderTypeRSS diff --git a/Vienna/Sources/Main window/ArticleConverter.swift b/Vienna/Sources/Main window/ArticleConverter.swift index dae2984f29..91b135577a 100644 --- a/Vienna/Sources/Main window/ArticleConverter.swift +++ b/Vienna/Sources/Main window/ArticleConverter.swift @@ -25,7 +25,7 @@ extension ArticleConverter { func setup() { // Update the article content style when the active display style has // changed. - NotificationCenter.default.addObserver(self, selector: #selector(self.initForCurrentStyle), name: NSNotification.Name("MA_Notify_StyleChange"), object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(self.initForCurrentStyle), name: .styleChanged, object: nil) self.initForCurrentStyle() } diff --git a/Vienna/Sources/Main window/ArticleListView.m b/Vienna/Sources/Main window/ArticleListView.m index 3559255726..4f26383483 100644 --- a/Vienna/Sources/Main window/ArticleListView.m +++ b/Vienna/Sources/Main window/ArticleListView.m @@ -98,11 +98,11 @@ -(void)awakeFromNib { // Register for notification NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self selector:@selector(handleArticleListFontChange:) name:@"MA_Notify_ArticleListFontChange" object:nil]; - [nc addObserver:self selector:@selector(handleReadingPaneChange:) name:@"MA_Notify_ReadingPaneChange" object:nil]; - [nc addObserver:self selector:@selector(handleLoadFullHTMLChange:) name:@"MA_Notify_LoadFullHTMLChange" object:nil]; - [nc addObserver:self selector:@selector(handleRefreshArticle:) name:@"MA_Notify_ArticleViewChange" object:nil]; - [nc addObserver:self selector:@selector(handleArticleViewEnded:) name:@"MA_Notify_ArticleViewEnded" object:nil]; + [nc addObserver:self selector:@selector(handleArticleListFontChange:) name:MA_Notify_ArticleListFontChange object:nil]; + [nc addObserver:self selector:@selector(handleReadingPaneChange:) name:MA_Notify_ReadingPaneChange object:nil]; + [nc addObserver:self selector:@selector(handleLoadFullHTMLChange:) name:MA_Notify_LoadFullHTMLChange object:nil]; + [nc addObserver:self selector:@selector(handleRefreshArticle:) name:MA_Notify_ArticleViewChange object:nil]; + [nc addObserver:self selector:@selector(handleArticleViewEnded:) name:MA_Notify_ArticleViewEnded object:nil]; [self initialiseArticleView]; } diff --git a/Vienna/Sources/Main window/EnclosureView.m b/Vienna/Sources/Main window/EnclosureView.m index 30e526e5f6..ffc9c6f04a 100644 --- a/Vienna/Sources/Main window/EnclosureView.m +++ b/Vienna/Sources/Main window/EnclosureView.m @@ -22,6 +22,7 @@ @import UniformTypeIdentifiers; +#import "Constants.h" #import "DownloadManager.h" #import "DSClickableURLTextField.h" #import "NSWorkspace+OpenWithMenu.h" @@ -45,7 +46,7 @@ -(instancetype)initWithFrame:(NSRect)frameRect // Register to be notified when a download completes. NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self selector:@selector(handleDownloadCompleted:) name:@"MA_Notify_DownloadCompleted" object:nil]; + [nc addObserver:self selector:@selector(handleDownloadCompleted:) name:MA_Notify_DownloadCompleted object:nil]; } return self; } diff --git a/Vienna/Sources/Main window/FoldersTree.m b/Vienna/Sources/Main window/FoldersTree.m index b63e2c861b..d1da3e6a1a 100644 --- a/Vienna/Sources/Main window/FoldersTree.m +++ b/Vienna/Sources/Main window/FoldersTree.m @@ -111,13 +111,13 @@ -(void)initialiseFoldersTree // Register for notifications NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self selector:@selector(handleFolderUpdate:) name:@"MA_Notify_FoldersUpdated" object:nil]; - [nc addObserver:self selector:@selector(handleFolderNameChange:) name:@"MA_Notify_FolderNameChanged" object:nil]; - [nc addObserver:self selector:@selector(handleFolderAdded:) name:@"MA_Notify_FolderAdded" object:nil]; + [nc addObserver:self selector:@selector(handleFolderUpdate:) name:MA_Notify_FoldersUpdated object:nil]; + [nc addObserver:self selector:@selector(handleFolderNameChange:) name:MA_Notify_FolderNameChanged object:nil]; + [nc addObserver:self selector:@selector(handleFolderAdded:) name:MA_Notify_FolderAdded object:nil]; [nc addObserver:self selector:@selector(handleFolderDeleted:) name:VNADatabaseDidDeleteFolderNotification object:nil]; - [nc addObserver:self selector:@selector(handleShowFolderImagesChange:) name:@"MA_Notify_ShowFolderImages" object:nil]; - [nc addObserver:self selector:@selector(handleAutoSortFoldersTreeChange:) name:@"MA_Notify_AutoSortFoldersTreeChange" object:nil]; - [nc addObserver:self selector:@selector(handleOpenReaderFolderChange:) name:@"MA_Notify_OpenReaderFolderChange" object:nil]; + [nc addObserver:self selector:@selector(handleShowFolderImagesChange:) name:MA_Notify_ShowFolderImages object:nil]; + [nc addObserver:self selector:@selector(handleAutoSortFoldersTreeChange:) name:MA_Notify_AutoSortFoldersTreeChange object:nil]; + [nc addObserver:self selector:@selector(handleOpenReaderFolderChange:) name:MA_Notify_OpenReaderFolderChange object:nil]; [userDefaults addObserver:self forKeyPath:MAPref_FeedListSizeMode @@ -397,7 +397,7 @@ -(BOOL)selectFolder:(NSInteger)folderId [self.outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:(NSUInteger)rowIndex] byExtendingSelection:NO]; [self.outlineView scrollRowToVisible:rowIndex]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_FolderSelectionChange" object:node]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_FolderSelectionChange object:node]; self.blockSelectionHandler = NO; return YES; } @@ -641,7 +641,7 @@ -(void)handleDoubleClick:(id)sender [APPCONTROLLER openURLFromString:urlString inPreferredBrowser:YES]; } } else if (node.folder.type == VNAFolderTypeSmart) { - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_EditFolder" object:node]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_EditFolder object:node]; } } @@ -678,7 +678,7 @@ -(void)handleFolderDeleted:(NSNotification *)nc if (currentFolderId == folderId) { self.blockSelectionHandler = YES; [self selectFolder:nextNode.nodeId]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_FolderSelectionChange" object:nextNode]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_FolderSelectionChange object:nextNode]; self.blockSelectionHandler = NO; } } @@ -1477,7 +1477,7 @@ -(void)outlineViewSelectionDidChange:(NSNotification *)notification { if (!self.blockSelectionHandler) { TreeNode * node = [self.outlineView itemAtRow:self.outlineView.selectedRow]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_FolderSelectionChange" object:node]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_FolderSelectionChange object:node]; } } diff --git a/Vienna/Sources/Main window/TabbedBrowserViewController.swift b/Vienna/Sources/Main window/TabbedBrowserViewController.swift index 6b5acb37ba..016a88e7f8 100644 --- a/Vienna/Sources/Main window/TabbedBrowserViewController.swift +++ b/Vienna/Sources/Main window/TabbedBrowserViewController.swift @@ -308,11 +308,11 @@ extension TabbedBrowserViewController: MMTabBarViewDelegate { } func tabView(_ tabView: NSTabView, didSelect tabViewItem: NSTabViewItem?) { - NotificationCenter.default.post(name: NSNotification.Name(rawValue: "MA_Notify_TabChanged"), object: tabViewItem?.view) + NotificationCenter.default.post(name: .tabChanged, object: tabViewItem?.view) } func tabViewDidChangeNumberOfTabViewItems(_ tabView: NSTabView) { - NotificationCenter.default.post(name: NSNotification.Name(rawValue: "MA_Notify_TabCountChanged"), object: tabView) + NotificationCenter.default.post(name: .tabCountChanged, object: tabView) } } diff --git a/Vienna/Sources/Main window/UnifiedDisplayView.m b/Vienna/Sources/Main window/UnifiedDisplayView.m index 3c711e3676..c61fae3329 100644 --- a/Vienna/Sources/Main window/UnifiedDisplayView.m +++ b/Vienna/Sources/Main window/UnifiedDisplayView.m @@ -80,8 +80,8 @@ -(void)awakeFromNib { // Register for notification NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self selector:@selector(handleReadingPaneChange:) name:@"MA_Notify_ReadingPaneChange" object:nil]; - [nc addObserver:self selector:@selector(handleCellDidResize:) name:@"MA_Notify_CellResize" object:nil]; + [nc addObserver:self selector:@selector(handleReadingPaneChange:) name:MA_Notify_ReadingPaneChange object:nil]; + [nc addObserver:self selector:@selector(handleCellDidResize:) name:MA_Notify_CellResize object:nil]; [self initTableView]; } diff --git a/Vienna/Sources/Main window/WebKitArticleTab.swift b/Vienna/Sources/Main window/WebKitArticleTab.swift index 60113a8c84..0638e02882 100644 --- a/Vienna/Sources/Main window/WebKitArticleTab.swift +++ b/Vienna/Sources/Main window/WebKitArticleTab.swift @@ -116,11 +116,11 @@ class WebKitArticleTab: BrowserTab, ArticleContentView { override func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { super.webView(webView, didFinish: navigation) - NotificationCenter.default.post(name: NSNotification.Name(rawValue: "MA_Notify_ArticleViewEnded"), object: self) + NotificationCenter.default.post(name: .articleViewEnded, object: self) } override func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) { super.webView(webView, didFailProvisionalNavigation: navigation, withError: error) - NotificationCenter.default.post(name: NSNotification.Name(rawValue: "MA_Notify_ArticleViewEnded"), object: self) + NotificationCenter.default.post(name: .articleViewEnded, object: self) } } diff --git a/Vienna/Sources/Preferences window/AppearancePreferencesViewController.m b/Vienna/Sources/Preferences window/AppearancePreferencesViewController.m index 5eb357df0c..ad05fe2d07 100644 --- a/Vienna/Sources/Preferences window/AppearancePreferencesViewController.m +++ b/Vienna/Sources/Preferences window/AppearancePreferencesViewController.m @@ -19,6 +19,8 @@ // #import "AppearancePreferencesViewController.h" + +#import "Constants.h" #import "Preferences.h" // List of minimum font sizes. I picked the ones that matched the same option in @@ -37,9 +39,9 @@ @implementation AppearancePreferencesViewController - (void)viewDidLoad { NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self selector:@selector(handleReloadPreferences:) name:@"MA_Notify_ArticleListFontChange" object:nil]; - [nc addObserver:self selector:@selector(handleReloadPreferences:) name:kMA_Notify_MinimumFontSizeChange object:nil]; - [nc addObserver:self selector:@selector(handleReloadPreferences:) name:@"MA_Notify_PreferenceChange" object:nil]; + [nc addObserver:self selector:@selector(handleReloadPreferences:) name:MA_Notify_ArticleListFontChange object:nil]; + [nc addObserver:self selector:@selector(handleReloadPreferences:) name:MA_Notify_MinimumFontSizeChange object:nil]; + [nc addObserver:self selector:@selector(handleReloadPreferences:) name:MA_Notify_PreferenceChange object:nil]; } - (void)viewWillAppear { diff --git a/Vienna/Sources/Preferences window/GeneralPreferencesViewController.m b/Vienna/Sources/Preferences window/GeneralPreferencesViewController.m index 92228f592e..839d0f428e 100644 --- a/Vienna/Sources/Preferences window/GeneralPreferencesViewController.m +++ b/Vienna/Sources/Preferences window/GeneralPreferencesViewController.m @@ -45,8 +45,8 @@ @implementation GeneralPreferencesViewController - (void)viewDidLoad { NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self selector:@selector(handleReloadPreferences:) name:@"MA_Notify_CheckFrequencyChange" object:nil]; - [nc addObserver:self selector:@selector(handleReloadPreferences:) name:@"MA_Notify_PreferenceChange" object:nil]; + [nc addObserver:self selector:@selector(handleReloadPreferences:) name:MA_Notify_CheckFrequencyChange object:nil]; + [nc addObserver:self selector:@selector(handleReloadPreferences:) name:MA_Notify_PreferenceChange object:nil]; appToPathMap = [[NSMutableDictionary alloc] init]; } diff --git a/Vienna/Sources/Preferences window/Preferences.h b/Vienna/Sources/Preferences window/Preferences.h index 90e4d775b9..950d0fb674 100644 --- a/Vienna/Sources/Preferences window/Preferences.h +++ b/Vienna/Sources/Preferences window/Preferences.h @@ -62,10 +62,6 @@ NS_ASSUME_NONNULL_BEGIN NSString * syncingUser; } -// String constants for NSNotificationCenter -extern NSString * const kMA_Notify_MinimumFontSizeChange; -extern NSString * const kMA_Notify_UseJavaScriptChange; - @property (class, readonly, nonatomic) Preferences *standardPreferences; // Accessor functions diff --git a/Vienna/Sources/Preferences window/Preferences.m b/Vienna/Sources/Preferences window/Preferences.m index f5161a4308..b5f401a819 100644 --- a/Vienna/Sources/Preferences window/Preferences.m +++ b/Vienna/Sources/Preferences window/Preferences.m @@ -41,11 +41,6 @@ static NSString * const MA_Database_Name = @"messages.db"; static NSString * const MA_FeedSourcesFolder_Name = @"Sources"; -// NSNotificationCenter string constants -NSString * const kMA_Notify_MinimumFontSizeChange = @"MA_Notify_MinimumFontSizeChange"; -NSString * const kMA_Notify_UseJavaScriptChange = @"MA_Notify_UseJavaScriptChange"; - - // The default preferences object. static Preferences * _standardPreferences = nil; @@ -469,7 +464,7 @@ -(void)setUseJavaScript:(BOOL)flag if (useJavaScript != flag) { useJavaScript = flag; [self setBool:flag forKey:MAPref_UseJavaScript]; - [[NSNotificationCenter defaultCenter] postNotificationName:kMA_Notify_UseJavaScriptChange + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_UseJavaScriptChange object:nil]; } } @@ -482,7 +477,7 @@ -(void)setConcurrentDownloads:(NSUInteger)downloads { if (downloads != concurrentDownloads) { concurrentDownloads = downloads; [self setInteger:downloads forKey:MAPref_ConcurrentDownloads]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_CowncurrentDownloadsChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_CowncurrentDownloadsChange object:nil]; } } @@ -504,7 +499,7 @@ -(void)setMinimumFontSize:(NSInteger)newSize if (newSize != minimumFontSize) { minimumFontSize = newSize; [self setInteger:minimumFontSize forKey:MAPref_MinimumFontSize]; - [[NSNotificationCenter defaultCenter] postNotificationName:kMA_Notify_MinimumFontSizeChange + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_MinimumFontSizeChange object:nil]; } } @@ -517,7 +512,7 @@ -(void)setEnableMinimumFontSize:(BOOL)flag if (enableMinimumFontSize != flag) { enableMinimumFontSize = flag; [self setBool:flag forKey:MAPref_UseMinimumFontSize]; - [[NSNotificationCenter defaultCenter] postNotificationName:kMA_Notify_MinimumFontSizeChange + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_MinimumFontSizeChange object:nil]; } } @@ -538,7 +533,7 @@ -(void)setShowFolderImages:(BOOL)flag if (showFolderImages != flag) { showFolderImages = flag; [self setBool:flag forKey:MAPref_ShowFolderImages]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_ShowFolderImages" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_ShowFolderImages object:nil]; } } @@ -580,7 +575,7 @@ -(void)setLayout:(NSInteger)newLayout if (layout != newLayout) { layout = newLayout; [self setInteger:newLayout forKey:MAPref_Layout]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_ReadingPaneChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_ReadingPaneChange object:nil]; } } @@ -621,7 +616,7 @@ -(void)setRefreshFrequency:(NSInteger)newFrequency if (refreshFrequency != newFrequency) { refreshFrequency = newFrequency; [self setInteger:newFrequency forKey:MAPref_CheckFrequency]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_CheckFrequencyChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_CheckFrequencyChange object:nil]; } } @@ -641,7 +636,7 @@ -(void)setRefreshOnStartup:(BOOL)flag if (flag != refreshOnStartup) { refreshOnStartup = flag; [self setBool:flag forKey:MAPref_CheckForNewArticlesOnStartup]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_PreferenceChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_PreferenceChange object:nil]; } } @@ -661,7 +656,7 @@ -(void)setAlwaysAcceptBetas:(BOOL)flag if (flag != alwaysAcceptBetas) { alwaysAcceptBetas = flag; [self setBool:flag forKey:MAPref_AlwaysAcceptBetas]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_PreferenceChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_PreferenceChange object:nil]; } } @@ -683,7 +678,7 @@ -(void)setMarkReadInterval:(float)newInterval if (newInterval != markReadInterval) { markReadInterval = newInterval; [self setObject:@((float)newInterval) forKey:MAPref_MarkReadInterval]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_PreferenceChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_PreferenceChange object:nil]; } } @@ -724,7 +719,7 @@ -(void)setOpenLinksInVienna:(BOOL)flag if (openLinksInVienna != flag) { openLinksInVienna = flag; [self setBool:flag forKey:MAPref_OpenLinksInVienna]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_PreferenceChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_PreferenceChange object:nil]; } } @@ -745,7 +740,7 @@ -(void)setOpenLinksInBackground:(BOOL)flag if (openLinksInBackground != flag) { openLinksInBackground = flag; [self setBool:flag forKey:MAPref_OpenLinksInBackground]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_PreferenceChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_PreferenceChange object:nil]; } } @@ -766,7 +761,7 @@ -(void)setMarkUpdatedAsNew:(BOOL)flag if (markUpdatedAsNew != flag) { markUpdatedAsNew = flag; [self setBool:flag forKey:MAPref_CheckForUpdatedArticles]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_PreferenceChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_PreferenceChange object:nil]; } } @@ -795,7 +790,7 @@ -(void)setDisplayStyle:(NSString *)newStyleName withNotification:(BOOL)flag displayStyle = newStyleName; [self setString:displayStyle forKey:MAPref_ActiveStyleName]; if (flag) { - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_StyleChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_StyleChange object:nil]; } } } @@ -816,7 +811,7 @@ -(void)setTextSizeMultiplier:(CGFloat)newValue if (newValue != textSizeMultiplier) { textSizeMultiplier = newValue; [self setObject:@(newValue) forKey:MAPref_ActiveTextSizeMultiplier]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_StyleChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_StyleChange object:nil]; } } @@ -845,7 +840,7 @@ -(void)setArticleListFont:(NSString *)newFontName NSData *archive = [NSKeyedArchiver vna_archivedDataWithRootObject:articleFont requiringSecureCoding:YES]; [self setObject:archive forKey:MAPref_ArticleListFont]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_ArticleListFontChange" object:articleFont]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_ArticleListFontChange object:articleFont]; } /* setArticleListFontSize @@ -857,7 +852,7 @@ -(void)setArticleListFontSize:(NSInteger)newFontSize NSData *archive = [NSKeyedArchiver vna_archivedDataWithRootObject:articleFont requiringSecureCoding:YES]; [self setObject:archive forKey:MAPref_ArticleListFont]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_ArticleListFontChange" object:articleFont]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_ArticleListFontChange object:articleFont]; } /* articleSortDescriptors @@ -890,7 +885,7 @@ -(void)setArticleSortDescriptors:(NSArray *)newSortDescriptors NSData *archive = [NSKeyedArchiver vna_archivedDataWithRootObject:articleSortDescriptors requiringSecureCoding:YES]; [self setObject:archive forKey:MAPref_ArticleListSortOrders]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_PreferenceChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_PreferenceChange object:nil]; } } @@ -910,7 +905,7 @@ -(void)setFoldersTreeSortMethod:(NSInteger)newMethod if (foldersTreeSortMethod != newMethod) { foldersTreeSortMethod = newMethod; [self setInteger:newMethod forKey:MAPref_AutoSortFoldersTree]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_AutoSortFoldersTreeChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_AutoSortFoldersTreeChange object:nil]; } } @@ -930,7 +925,7 @@ -(void)setNewArticlesNotification:(NSInteger)newMethod if (newMethod != newArticlesNotification) { newArticlesNotification = newMethod; [self setInteger:newArticlesNotification forKey:MAPref_NewArticlesNotification]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_PreferenceChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_PreferenceChange object:nil]; } } @@ -950,7 +945,7 @@ -(void)setShowAppInStatusBar:(BOOL)show if (showAppInStatusBar != show) { showAppInStatusBar = show; [self setBool:showAppInStatusBar forKey:MAPref_ShowAppInStatusBar]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_ShowAppInStatusBarChanged" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_ShowAppInStatusBarChanged object:nil]; } } @@ -989,7 +984,7 @@ -(void)setShowFilterBar:(BOOL)show if (showFilterBar != show) { showFilterBar = show; [self setBool:showFilterBar forKey:MAPref_ShowFilterBar]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_FilterBarChanged" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_FilterBarChanged object:nil]; } } @@ -1020,7 +1015,7 @@ -(void)setShouldSaveFeedSource:(BOOL)shouldSave [self createFeedSourcesFolderIfNecessary]; } [self setBool:shouldSaveFeedSource forKey:MAPref_ShouldSaveFeedSource]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_PreferenceChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_PreferenceChange object:nil]; } } @@ -1051,7 +1046,7 @@ -(void)setSyncGoogleReader:(BOOL)flag if (syncGoogleReader != flag) { syncGoogleReader = flag; [self setBool:syncGoogleReader forKey:MAPref_SyncGoogleReader]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_SyncGoogleReaderChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_SyncGoogleReaderChange object:nil]; } } @@ -1068,7 +1063,7 @@ -(void)setPrefersGoogleNewSubscription:(BOOL)flag if (prefersGoogleNewSubscription != flag) { prefersGoogleNewSubscription = flag; [self setBool:prefersGoogleNewSubscription forKey:MAPref_GoogleNewSubscription]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_GoogleReaderNewSubscriptionChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_GoogleReaderNewSubscriptionChange object:nil]; } } @@ -1085,7 +1080,7 @@ -(void)setSyncServer:(NSString *)newServer if (![syncServer isEqualToString:newServer]) { syncServer = [newServer copy]; [self setString:syncServer forKey:MAPref_SyncServer]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_SyncGoogleReaderChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_SyncGoogleReaderChange object:nil]; } } @@ -1102,7 +1097,7 @@ -(void)setSyncScheme:(NSString *)newScheme if (![syncScheme isEqualToString:newScheme]) { syncScheme = [newScheme copy]; [self setString:syncScheme forKey:MAPref_SyncScheme]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_SyncGoogleReaderChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_SyncGoogleReaderChange object:nil]; } } @@ -1119,7 +1114,7 @@ -(void)setSyncingUser:(NSString *)newUser if (![syncingUser isEqualToString:newUser]) { syncingUser = [newUser copy]; [self setString:syncingUser forKey:MAPref_SyncingUser]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"MA_Notify_SyncGoogleReaderChange" object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_SyncGoogleReaderChange object:nil]; } } diff --git a/Vienna/Sources/Preferences window/SyncingPreferencesViewController.m b/Vienna/Sources/Preferences window/SyncingPreferencesViewController.m index f99a705c13..d662061c79 100644 --- a/Vienna/Sources/Preferences window/SyncingPreferencesViewController.m +++ b/Vienna/Sources/Preferences window/SyncingPreferencesViewController.m @@ -18,11 +18,13 @@ // limitations under the License. // +#import "SyncingPreferencesViewController.h" + +#import "Constants.h" #import "OpenReader.h" #import "Keychain.h" #import "Preferences.h" #import "StringExtensions.h" -#import "SyncingPreferencesViewController.h" @interface SyncingPreferencesViewController () @@ -41,7 +43,7 @@ @implementation SyncingPreferencesViewController - (void)viewWillAppear { // Set up to be notified NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self selector:@selector(handleGoogleAuthFailed:) name:@"MA_Notify_GoogleAuthFailed" object:nil]; + [nc addObserver:self selector:@selector(handleGoogleAuthFailed:) name:MA_Notify_GoogleAuthFailed object:nil]; [nc addObserver:self selector:@selector(handleServerTextDidChange:) name:NSControlTextDidChangeNotification object:openReaderHost]; [nc addObserver:self selector:@selector(handleUserTextDidChange:) name:NSControlTextDidChangeNotification object:username]; [nc addObserver:self selector:@selector(handlePasswordTextDidChange:) name:NSControlTextDidChangeNotification object:password]; diff --git a/Vienna/Sources/Preferences window/UpdatePreferencesViewController.m b/Vienna/Sources/Preferences window/UpdatePreferencesViewController.m index 2b40dc0568..e3d48af442 100644 --- a/Vienna/Sources/Preferences window/UpdatePreferencesViewController.m +++ b/Vienna/Sources/Preferences window/UpdatePreferencesViewController.m @@ -32,7 +32,7 @@ @implementation UpdatePreferencesViewController - (void)viewDidLoad { NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self selector:@selector(handleReloadPreferences:) name:@"MA_Notify_PreferenceChange" object:nil]; + [nc addObserver:self selector:@selector(handleReloadPreferences:) name:MA_Notify_PreferenceChange object:nil]; } - (void)viewWillAppear { diff --git a/Vienna/Sources/Shared/Constants.h b/Vienna/Sources/Shared/Constants.h index 8185ff054c..119172dff7 100644 --- a/Vienna/Sources/Shared/Constants.h +++ b/Vienna/Sources/Shared/Constants.h @@ -23,6 +23,43 @@ extern NSString * const MA_DefaultUserAgentString; extern NSString * const MA_BrowserUserAgentString; +extern NSNotificationName const MA_Notify_ArticleListContentChange; +extern NSNotificationName const MA_Notify_ArticleListFontChange; +extern NSNotificationName const MA_Notify_ArticleListStateChange; +extern NSNotificationName const MA_Notify_ArticleViewChange; +extern NSNotificationName const MA_Notify_ArticleViewEnded NS_SWIFT_NAME(articleViewEnded); +extern NSNotificationName const MA_Notify_AutoSortFoldersTreeChange; +extern NSNotificationName const MA_Notify_CancelAuthenticationForFolder; +extern NSNotificationName const MA_Notify_CellResize; +extern NSNotificationName const MA_Notify_CheckFrequencyChange; +extern NSNotificationName const MA_Notify_CowncurrentDownloadsChange; +extern NSNotificationName const MA_Notify_DownloadCompleted; +extern NSNotificationName const MA_Notify_DownloadsListChange; +extern NSNotificationName const MA_Notify_EditFolder; +extern NSNotificationName const MA_Notify_FilterBarChanged; +extern NSNotificationName const MA_Notify_FolderAdded; +extern NSNotificationName const MA_Notify_FolderDescriptionChanged; // Unused +extern NSNotificationName const MA_Notify_FolderHomePageChanged; // Unused +extern NSNotificationName const MA_Notify_FolderNameChanged; +extern NSNotificationName const MA_Notify_FolderSelectionChange; +extern NSNotificationName const MA_Notify_FoldersUpdated; +extern NSNotificationName const MA_Notify_GoogleAuthFailed; +extern NSNotificationName const MA_Notify_GoogleReaderNewSubscriptionChange; // Unused +extern NSNotificationName const MA_Notify_GotAuthenticationForFolder; +extern NSNotificationName const MA_Notify_LoadFullHTMLChange; +extern NSNotificationName const MA_Notify_MinimumFontSizeChange; +extern NSNotificationName const MA_Notify_OpenReaderFolderChange; +extern NSNotificationName const MA_Notify_PreferenceChange; +extern NSNotificationName const MA_Notify_ReadingPaneChange; +extern NSNotificationName const MA_Notify_RefreshStatus; +extern NSNotificationName const MA_Notify_ShowAppInStatusBarChanged; +extern NSNotificationName const MA_Notify_ShowFolderImages; +extern NSNotificationName const MA_Notify_StyleChange NS_SWIFT_NAME(styleChanged); +extern NSNotificationName const MA_Notify_SyncGoogleReaderChange; // Unused +extern NSNotificationName const MA_Notify_TabChanged NS_SWIFT_NAME(tabChanged); +extern NSNotificationName const MA_Notify_TabCountChanged NS_SWIFT_NAME(tabCountChanged); +extern NSNotificationName const MA_Notify_UseJavaScriptChange; // Unused + extern NSString * const MAPref_ArticleListFont; extern NSString * const MAPref_AutoSortFoldersTree; extern NSString * const MAPref_CheckForUpdatedArticles; diff --git a/Vienna/Sources/Shared/Constants.m b/Vienna/Sources/Shared/Constants.m index d61668a39c..307b68c315 100644 --- a/Vienna/Sources/Shared/Constants.m +++ b/Vienna/Sources/Shared/Constants.m @@ -23,6 +23,43 @@ NSString * const MA_DefaultUserAgentString = @"%@/%@ (Macintosh; Intel macOS %@)"; NSString * const MA_BrowserUserAgentString = @"(Macintosh; Intel Mac OS X %@) AppleWebKit/%@ (KHTML, like Gecko) Version/%@ Safari/604.1.38 %@/%@"; +NSNotificationName const MA_Notify_ArticleListContentChange = @"MA_Notify_ArticleListContentChange"; +NSNotificationName const MA_Notify_ArticleListFontChange = @"MA_Notify_ArticleListFontChange"; +NSNotificationName const MA_Notify_ArticleListStateChange = @"MA_Notify_ArticleListStateChange"; +NSNotificationName const MA_Notify_ArticleViewChange = @"MA_Notify_ArticleViewChange"; +NSNotificationName const MA_Notify_ArticleViewEnded = @"MA_Notify_ArticleViewEnded"; +NSNotificationName const MA_Notify_AutoSortFoldersTreeChange = @"MA_Notify_AutoSortFoldersTreeChange"; +NSNotificationName const MA_Notify_CancelAuthenticationForFolder = @"MA_Notify_CancelAuthenticationForFolder"; +NSNotificationName const MA_Notify_CellResize = @"MA_Notify_CellResize"; +NSNotificationName const MA_Notify_CheckFrequencyChange = @"MA_Notify_CheckFrequencyChange"; +NSNotificationName const MA_Notify_CowncurrentDownloadsChange = @"MA_Notify_CowncurrentDownloadsChange"; +NSNotificationName const MA_Notify_DownloadCompleted = @"MA_Notify_DownloadCompleted"; +NSNotificationName const MA_Notify_DownloadsListChange = @"MA_Notify_DownloadsListChange"; +NSNotificationName const MA_Notify_EditFolder = @"MA_Notify_EditFolder"; +NSNotificationName const MA_Notify_FilterBarChanged = @"MA_Notify_FilterBarChanged"; +NSNotificationName const MA_Notify_FolderAdded = @"MA_Notify_FolderAdded"; +NSNotificationName const MA_Notify_FolderDescriptionChanged = @"MA_Notify_FolderDescriptionChanged"; +NSNotificationName const MA_Notify_FolderHomePageChanged = @"MA_Notify_FolderHomePageChanged"; +NSNotificationName const MA_Notify_FolderNameChanged = @"MA_Notify_FolderNameChanged"; +NSNotificationName const MA_Notify_FolderSelectionChange = @"MA_Notify_FolderSelectionChange"; +NSNotificationName const MA_Notify_FoldersUpdated = @"MA_Notify_FoldersUpdated"; +NSNotificationName const MA_Notify_GoogleAuthFailed = @"MA_Notify_GoogleAuthFailed"; +NSNotificationName const MA_Notify_GoogleReaderNewSubscriptionChange = @"MA_Notify_GoogleReaderNewSubscriptionChange"; +NSNotificationName const MA_Notify_GotAuthenticationForFolder = @"MA_Notify_GotAuthenticationForFolder"; +NSNotificationName const MA_Notify_LoadFullHTMLChange = @"MA_Notify_LoadFullHTMLChange"; +NSNotificationName const MA_Notify_MinimumFontSizeChange = @"MA_Notify_MinimumFontSizeChange"; +NSNotificationName const MA_Notify_OpenReaderFolderChange = @"MA_Notify_OpenReaderFolderChange"; +NSNotificationName const MA_Notify_PreferenceChange = @"MA_Notify_PreferenceChange"; +NSNotificationName const MA_Notify_ReadingPaneChange = @"MA_Notify_ReadingPaneChange"; +NSNotificationName const MA_Notify_RefreshStatus = @"MA_Notify_RefreshStatus"; +NSNotificationName const MA_Notify_ShowAppInStatusBarChanged = @"MA_Notify_ShowAppInStatusBarChanged"; +NSNotificationName const MA_Notify_ShowFolderImages = @"MA_Notify_ShowFolderImages"; +NSNotificationName const MA_Notify_StyleChange = @"MA_Notify_StyleChange"; +NSNotificationName const MA_Notify_SyncGoogleReaderChange = @"MA_Notify_SyncGoogleReaderChange"; +NSNotificationName const MA_Notify_TabChanged = @"MA_Notify_TabChanged"; +NSNotificationName const MA_Notify_TabCountChanged = @"MA_Notify_TabCountChanged"; +NSNotificationName const MA_Notify_UseJavaScriptChange = @"MA_Notify_UseJavaScriptChange"; + NSString * const MAPref_ArticleListFont = @"ArticleListFont"; NSString * const MAPref_AutoSortFoldersTree = @"AutomaticallySortFoldersTree"; NSString * const MAPref_CheckForUpdatedArticles = @"CheckForUpdatedArticles"; diff --git a/Vienna/Sources/Vienna-Bridging-Header.h b/Vienna/Sources/Vienna-Bridging-Header.h index 88a90ac5f3..9bf7f44066 100644 --- a/Vienna/Sources/Vienna-Bridging-Header.h +++ b/Vienna/Sources/Vienna-Bridging-Header.h @@ -3,6 +3,7 @@ #import "ArticleConverter.h" #import "ArticleListView.h" #import "ArticleViewDelegate.h" +#import "Constants.h" #import "DisclosureView.h" #import "Feed.h" #import "FeedItem.h" From 228a2d83a753759e3ac53784730dfb0164fa9759 Mon Sep 17 00:00:00 2001 From: Eitot Date: Sat, 13 May 2023 09:41:04 +0200 Subject: [PATCH 4/5] Remove unused constants --- Vienna/Sources/Shared/Constants.h | 3 --- Vienna/Sources/Shared/Constants.m | 3 --- 2 files changed, 6 deletions(-) diff --git a/Vienna/Sources/Shared/Constants.h b/Vienna/Sources/Shared/Constants.h index 119172dff7..143e740ca5 100644 --- a/Vienna/Sources/Shared/Constants.h +++ b/Vienna/Sources/Shared/Constants.h @@ -118,13 +118,10 @@ extern NSString * const MAPref_FeedListSizeMode; extern NSString * const MAPref_ShowFeedsWithUnreadItemsInBold; extern NSInteger const MA_Default_BackTrackQueueSize; -extern NSInteger const MA_Default_RefreshThreads; extern float const MA_Default_Read_Interval; extern NSInteger const MA_Default_MinimumFontSize; extern NSInteger const MA_Default_AutoExpireDuration; extern NSInteger const MA_Default_Check_Frequency; -extern CGFloat const MA_Default_Main_Window_Min_Width; -extern CGFloat const MA_Default_Main_Window_Min_Height; extern NSInteger const MA_Default_ConcurrentDownloads; extern NSPasteboardType const VNAPasteboardTypeRSSItem; diff --git a/Vienna/Sources/Shared/Constants.m b/Vienna/Sources/Shared/Constants.m index 307b68c315..2de36c948e 100644 --- a/Vienna/Sources/Shared/Constants.m +++ b/Vienna/Sources/Shared/Constants.m @@ -113,13 +113,10 @@ NSString * const MAPref_UserAgentName = @"UserAgentName"; NSInteger const MA_Default_BackTrackQueueSize = 20; -NSInteger const MA_Default_RefreshThreads = 20; NSInteger const MA_Default_MinimumFontSize = 9; float const MA_Default_Read_Interval = 0.5; NSInteger const MA_Default_AutoExpireDuration = 0; NSInteger const MA_Default_Check_Frequency = 10800; -CGFloat const MA_Default_Main_Window_Min_Width = 700.0; -CGFloat const MA_Default_Main_Window_Min_Height = 350.0; NSInteger const MA_Default_ConcurrentDownloads = 10; // Constants for External Weblog Editor Interface according to http://ranchero.com/netnewswire/developers/externalinterface.php From 788da5348bf3577ad3bcac2754319a57ea08b763 Mon Sep 17 00:00:00 2001 From: Eitot Date: Thu, 18 May 2023 13:09:37 +0200 Subject: [PATCH 5/5] Fix typo in NSNotificationName constant --- Vienna/Sources/Fetching/RefreshManager.m | 2 +- Vienna/Sources/Preferences window/Preferences.m | 2 +- Vienna/Sources/Shared/Constants.h | 2 +- Vienna/Sources/Shared/Constants.m | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Vienna/Sources/Fetching/RefreshManager.m b/Vienna/Sources/Fetching/RefreshManager.m index 2b57561587..9011980173 100644 --- a/Vienna/Sources/Fetching/RefreshManager.m +++ b/Vienna/Sources/Fetching/RefreshManager.m @@ -108,7 +108,7 @@ -(instancetype)init [nc addObserver:self selector:@selector(handleCancelAuthenticationForFolder:) name:MA_Notify_CancelAuthenticationForFolder object:nil]; [nc addObserver:self selector:@selector(handleWillDeleteFolder:) name:VNADatabaseWillDeleteFolderNotification object:nil]; - [nc addObserver:self selector:@selector(handleChangeConcurrentDownloads:) name:MA_Notify_CowncurrentDownloadsChange object:nil]; + [nc addObserver:self selector:@selector(handleChangeConcurrentDownloads:) name:MA_Notify_ConcurrentDownloadsChange object:nil]; // be notified on system wake up after sleep [[NSWorkspace sharedWorkspace].notificationCenter addObserver:self selector:@selector(handleDidWake:) name:@"NSWorkspaceDidWakeNotification" object:nil]; diff --git a/Vienna/Sources/Preferences window/Preferences.m b/Vienna/Sources/Preferences window/Preferences.m index b5f401a819..66a9193918 100644 --- a/Vienna/Sources/Preferences window/Preferences.m +++ b/Vienna/Sources/Preferences window/Preferences.m @@ -477,7 +477,7 @@ -(void)setConcurrentDownloads:(NSUInteger)downloads { if (downloads != concurrentDownloads) { concurrentDownloads = downloads; [self setInteger:downloads forKey:MAPref_ConcurrentDownloads]; - [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_CowncurrentDownloadsChange object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MA_Notify_ConcurrentDownloadsChange object:nil]; } } diff --git a/Vienna/Sources/Shared/Constants.h b/Vienna/Sources/Shared/Constants.h index 143e740ca5..2c4dc21066 100644 --- a/Vienna/Sources/Shared/Constants.h +++ b/Vienna/Sources/Shared/Constants.h @@ -32,7 +32,7 @@ extern NSNotificationName const MA_Notify_AutoSortFoldersTreeChange; extern NSNotificationName const MA_Notify_CancelAuthenticationForFolder; extern NSNotificationName const MA_Notify_CellResize; extern NSNotificationName const MA_Notify_CheckFrequencyChange; -extern NSNotificationName const MA_Notify_CowncurrentDownloadsChange; +extern NSNotificationName const MA_Notify_ConcurrentDownloadsChange; extern NSNotificationName const MA_Notify_DownloadCompleted; extern NSNotificationName const MA_Notify_DownloadsListChange; extern NSNotificationName const MA_Notify_EditFolder; diff --git a/Vienna/Sources/Shared/Constants.m b/Vienna/Sources/Shared/Constants.m index 2de36c948e..483bcbb11b 100644 --- a/Vienna/Sources/Shared/Constants.m +++ b/Vienna/Sources/Shared/Constants.m @@ -32,7 +32,7 @@ NSNotificationName const MA_Notify_CancelAuthenticationForFolder = @"MA_Notify_CancelAuthenticationForFolder"; NSNotificationName const MA_Notify_CellResize = @"MA_Notify_CellResize"; NSNotificationName const MA_Notify_CheckFrequencyChange = @"MA_Notify_CheckFrequencyChange"; -NSNotificationName const MA_Notify_CowncurrentDownloadsChange = @"MA_Notify_CowncurrentDownloadsChange"; +NSNotificationName const MA_Notify_ConcurrentDownloadsChange = @"MA_Notify_ConcurrentDownloadsChange"; NSNotificationName const MA_Notify_DownloadCompleted = @"MA_Notify_DownloadCompleted"; NSNotificationName const MA_Notify_DownloadsListChange = @"MA_Notify_DownloadsListChange"; NSNotificationName const MA_Notify_EditFolder = @"MA_Notify_EditFolder";