summaryrefslogtreecommitdiffstats
path: root/macosx/HBQueue.h
blob: 6a9f4e4cbdc9b00f3c14b07fb1d95c62d194631e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*  HBQueue.h $

 This file is part of the HandBrake source code.
 Homepage: <http://handbrake.fr/>.
 It may be used under the terms of the GNU General Public License. */

#import <Foundation/Foundation.h>

#import "HBDistributedArray.h"
#import "HBQueueItem.h"

NS_ASSUME_NONNULL_BEGIN

extern NSString * const HBQueueDidChangeStateNotification;

extern NSString * const HBQueueDidAddItemNotification;
extern NSString * const HBQueueDidRemoveItemNotification;
extern NSString * const HBQueueDidChangeItemNotification;
extern NSString * const HBQueueItemNotificationIndexesKey;           // NSIndexSet

extern NSString * const HBQueueDidMoveItemNotification;
extern NSString * const HBQueueItemNotificationSourceIndexesKey;     // NSArray<NSNumber *>
extern NSString * const HBQueueItemNotificationTargetIndexesKey;     // NSArray<NSNumber *>

extern NSString * const HBQueueReloadItemsNotification;

extern NSString * const HBQueueLowSpaceAlertNotification;

extern NSString * const HBQueueProgressNotification;
extern NSString * const HBQueueProgressNotificationPercentKey;       // NSNumber - double
extern NSString * const HBQueueProgressNotificationHoursKey;         // NSNumber - double
extern NSString * const HBQueueProgressNotificationMinutesKey;       // NSNumber - double
extern NSString * const HBQueueProgressNotificationSecondsKey;       // NSNumber - double
extern NSString * const HBQueueProgressNotificationInfoKey;          // NSString

extern NSString * const HBQueueDidStartNotification;
extern NSString * const HBQueueDidCompleteNotification;

extern NSString * const HBQueueDidStartItemNotification;
extern NSString * const HBQueueDidCompleteItemNotification;
extern NSString * const HBQueueItemNotificationItemKey;              // HBQueueItem

@interface HBQueue : NSObject

- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithURL:(NSURL *)queueURL;

@property (nonatomic, readonly) HBDistributedArray<HBQueueItem *> *items;

@property (nonatomic, nullable) HBQueueItem *currentItem;

@property (nonatomic) NSUInteger pendingItemsCount;
@property (nonatomic) NSUInteger failedItemsCount;
@property (nonatomic) NSUInteger completedItemsCount;

@property (nonatomic) NSUndoManager *undoManager;

- (void)addJob:(HBJob *)job;
- (void)addJobs:(NSArray<HBJob *> *)jobs;

- (void)addItems:(NSArray<HBQueueItem *> *)items atIndexes:(NSIndexSet *)indexes;
- (void)removeItemAtIndex:(NSUInteger)index;
- (void)removeItemsAtIndexes:(NSIndexSet *)indexes;
- (void)moveItems:(NSArray<HBQueueItem *> *)items toIndex:(NSUInteger)index;

- (BOOL)itemExistAtURL:(NSURL *)url;

- (void)removeAllItems;
- (void)removeCompletedAndCancelledItems;
- (void)removeNotWorkingItems;
- (void)removeCompletedItems;

- (void)resetItemsAtIndexes:(NSIndexSet *)indexes;
- (void)resetAllItems;
- (void)resetFailedItems;

- (void)setEncodingJobsAsPending;

@property (nonatomic, readonly) BOOL canEncode;
@property (nonatomic, readonly) BOOL isEncoding;

- (void)start;
- (void)cancelCurrentItemAndContinue;
- (void)finishCurrentAndStop;
- (void)cancelCurrentItemAndStop;

@property (nonatomic, readonly) BOOL canPause;
- (void)pause;

@property (nonatomic, readonly) BOOL canResume;
- (void)resume;

@end

NS_ASSUME_NONNULL_END