Cog/Playlist/PlaylistController.h
Christopher Snowhill c23bece62c Reintroducing App Sandbox, and more
- Implemented App Sandboxing in a more friendly manner.
- All sandboxed paths will need to be set in Preferences. Set as loose
  a path as you want. The shortest path will be preferred.
- Removed Last.fm client support, as it was non-functional by now,
  unfortunately. Maybe something better can come in the future.
- Added support for insecure SSL to the HTTP/S reader, in case anyone
  needs streams which are "protected" by self-signed or expired
  certificates, without having to futz around by adding certificates to
  the system settings, especially for expired certificates that can't
  otherwise be dodged this way.

If you want to import your old playlists to the new version, copy the
contents of `~/Library/Application Support/Cog` to the alternate sandbox
path: `~/Library/Containers/org.cogx.cog/Data/Library/Application `...
...continued...`Support/Cog`. The preferences file will migrate to the
new version automatically.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-20 03:35:29 -07:00

153 lines
4.2 KiB
Objective-C

//
// PlaylistController.h
// Cog
//
// Created by Vincent Spader on 3/18/05.
// Copyright 2005 Vincent Spader All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <CoreData/CoreData.h>
#import <Foundation/NSUndoManager.h>
#import "DNDArrayController.h"
@class AlbumArtwork;
@class PlaylistLoader;
@class PlaylistEntry;
@class SpotlightWindowController;
@class PlaybackController;
@interface NSApplication (CoreDataStorageExtension)
- (NSPersistentContainer *_Nonnull)sharedPersistentContainer;
@end
typedef NS_ENUM(NSInteger, RepeatMode) {
RepeatModeNoRepeat = 0,
RepeatModeRepeatOne,
RepeatModeRepeatAlbum,
RepeatModeRepeatAll
};
static inline BOOL IsRepeatOneSet() {
return [[NSUserDefaults standardUserDefaults] integerForKey:@"repeat"] == RepeatModeRepeatOne;
}
typedef enum { ShuffleOff = 0,
ShuffleAlbums,
ShuffleAll } ShuffleMode;
typedef NS_ENUM(NSInteger, URLOrigin) {
URLOriginInternal = 0,
URLOriginExternal
};
@interface PlaylistController : DNDArrayController <NSTableViewDelegate> {
IBOutlet PlaylistLoader *playlistLoader;
IBOutlet SpotlightWindowController *spotlightWindowController;
IBOutlet PlaybackController *playbackController;
NSValueTransformer *statusImageTransformer;
NSMutableArray *shuffleList;
NSMutableArray *queueList;
NSString *totalTime;
NSString *currentStatus;
PlaylistEntry *currentEntry;
PlaylistEntry *nextEntryAfterDeleted;
NSUndoManager *undoManager;
BOOL observersRegistered;
}
@property(nonatomic, retain) PlaylistEntry *_Nullable currentEntry;
@property(retain) NSString *_Nullable totalTime;
@property(retain) NSString *_Nullable currentStatus;
@property(strong, nonatomic, readonly) NSOperationQueue *_Nonnull persistentContainerQueue;
@property(strong, nonatomic, readonly) NSPersistentContainer *_Nonnull persistentContainer;
@property(strong, nonatomic, readonly) NSMutableDictionary<NSString *, AlbumArtwork *> *_Nonnull persistentArtStorage;
// Private Methods
- (void)commitPersistentStore;
- (void)updateTotalTime;
- (void)updatePlaylistIndexes;
- (IBAction)stopAfterCurrent:(id _Nullable)sender;
// PUBLIC METHODS
- (void)setShuffle:(ShuffleMode)s;
- (ShuffleMode)shuffle;
- (void)setRepeat:(RepeatMode)r;
- (RepeatMode)repeat;
- (NSArray *_Nullable)filterPlaylistOnAlbum:(NSString *_Nullable)album;
- (PlaylistEntry *_Nullable)getNextEntry:(PlaylistEntry *_Nullable)pe;
- (PlaylistEntry *_Nullable)getPrevEntry:(PlaylistEntry *_Nullable)pe;
/* Methods for undoing various actions */
- (NSUndoManager *_Nullable)undoManager;
- (IBAction)toggleShuffle:(id _Nullable)sender;
- (IBAction)toggleRepeat:(id _Nullable)sender;
- (IBAction)randomizeList:(id _Nullable)sender;
- (IBAction)removeDuplicates:(id _Nullable)sender;
- (IBAction)removeDeadItems:(id _Nullable)sender;
- (IBAction)remove:(id _Nullable)sender;
- (IBAction)trash:(id _Nullable)sender;
- (IBAction)showEntryInFinder:(id _Nullable)sender;
- (IBAction)clearFilterPredicate:(id _Nullable)sender;
- (IBAction)clear:(id _Nullable)sender;
//- (IBAction)showTagEditor:(id)sender;
// Spotlight
- (IBAction)searchByArtist:(id _Nullable)sender;
- (IBAction)searchByAlbum:(id _Nullable)sender;
// FUN PLAYLIST MANAGEMENT STUFF!
- (BOOL)next;
- (BOOL)prev;
- (void)addShuffledListToBack;
- (void)addShuffledListToFront;
- (void)resetShuffleList;
- (PlaylistEntry *_Nullable)shuffledEntryAtIndex:(NSInteger)i;
- (PlaylistEntry *_Nullable)entryAtIndex:(NSInteger)i;
// Event inlets:
- (void)willInsertURLs:(NSArray *_Nullable)urls origin:(URLOrigin)origin;
- (void)didInsertURLs:(NSArray *_Nullable)urls origin:(URLOrigin)origin;
// queue methods
- (IBAction)toggleQueued:(id _Nullable)sender;
- (IBAction)emptyQueueList:(id _Nullable)sender;
- (void)emptyQueueListUnsynced;
- (NSMutableArray *_Nullable)queueList;
// internal methods for data store init
- (void)readQueueFromDataStore;
- (void)readShuffleListFromDataStore;
// reload metadata of selection
- (IBAction)reloadTags:(id _Nullable)sender;
// Play statistics
- (void)updatePlayCountForTrack:(PlaylistEntry *_Nonnull)pe;
- (void)moveObjectsInArrangedObjectsFromIndexes:(NSIndexSet *_Nullable)indexSet
toIndex:(NSUInteger)insertIndex;
- (void)insertObjectsUnsynced:(NSArray *_Nullable)objects atArrangedObjectIndexes:(NSIndexSet *_Nullable)indexes;
@end